Skip to content

Commit 0ada9ea

Browse files
committed
Merge branch 'develop'
2 parents 3895a09 + 33e8988 commit 0ada9ea

22 files changed

+107
-94
lines changed

CHANGES.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
#### [unreleased]
22

3+
#### 12.3.0 / 2023-08-10
4+
* update Bitbucket Add-on message for consistency
5+
* ensure `Shim` available during `register_activation_hook()`
6+
* add conditional to `get_remote_api_branches()` to ensure `$response` is not a scalar
7+
* use null coalescing operator
8+
* update for PHP 8.2
9+
310
#### 12.2.3 / 2023-06-27
411
* composer update
512
* get `gu_disable_cron` hook result once per repository

composer.lock

+10-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

git-updater.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Plugin Name: Git Updater
1313
* Plugin URI: https://git-updater.com
1414
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
15-
* Version: 12.2.3
15+
* Version: 12.3.0
1616
* Author: Andy Fragen
1717
* License: MIT
1818
* Domain Path: /languages

languages/git-updater.pot

+15-15
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
# This file is distributed under the MIT.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: Git Updater 12.2.0\n"
5+
"Project-Id-Version: Git Updater 12.3.0\n"
66
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/git-updater\n"
77
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
88
"Language-Team: LANGUAGE <[email protected]>\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=UTF-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
12-
"POT-Creation-Date: 2023-04-19T18:44:46+00:00\n"
12+
"POT-Creation-Date: 2023-08-11T00:39:53+00:00\n"
1313
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14-
"X-Generator: WP-CLI 2.7.1\n"
14+
"X-Generator: WP-CLI 2.8.1\n"
1515
"X-Domain: git-updater\n"
1616

1717
#. Plugin Name of the plugin
@@ -49,7 +49,7 @@ msgid "Git Updater - Bitbucket"
4949
msgstr ""
5050

5151
#: src/Git_Updater/Add_Ons.php:75
52-
msgid "Add Bitbucket and Bitbucket Server repositories to the Git Updater plugin."
52+
msgid "Add Bitbucket and Bitbucket Server hosted repositories to the Git Updater plugin."
5353
msgstr ""
5454

5555
#: src/Git_Updater/Add_Ons.php:86
@@ -240,42 +240,42 @@ msgid "Installed Plugins and Themes"
240240
msgstr ""
241241

242242
#. translators: %s: theme name
243-
#: src/Git_Updater/Theme.php:389
244-
#: src/Git_Updater/Theme.php:515
243+
#: src/Git_Updater/Theme.php:384
244+
#: src/Git_Updater/Theme.php:510
245245
msgid "There is a new version of %s available."
246246
msgstr ""
247247

248248
#. translators: %s: theme version
249-
#: src/Git_Updater/Theme.php:401
249+
#: src/Git_Updater/Theme.php:396
250250
msgid "View version %s details."
251251
msgstr ""
252252

253-
#: src/Git_Updater/Theme.php:405
253+
#: src/Git_Updater/Theme.php:400
254254
msgid "Automatic update is unavailable for this theme."
255255
msgstr ""
256256

257257
#. translators: 1: version number, 2: closing anchor tag, 3: update URL
258-
#: src/Git_Updater/Theme.php:410
259-
#: src/Git_Updater/Theme.php:526
258+
#: src/Git_Updater/Theme.php:405
259+
#: src/Git_Updater/Theme.php:521
260260
msgid "View version %1$s details%2$s or %3$supdate now%2$s."
261261
msgstr ""
262262

263263
#. translators: %s: theme name
264-
#: src/Git_Updater/Theme.php:415
265-
#: src/Git_Updater/Theme.php:531
264+
#: src/Git_Updater/Theme.php:410
265+
#: src/Git_Updater/Theme.php:526
266266
msgid "Update %s now"
267267
msgstr ""
268268

269269
#. translators: 1: version number, 2: closing anchor tag, 3: update URL
270-
#: src/Git_Updater/Theme.php:538
270+
#: src/Git_Updater/Theme.php:533
271271
msgid "View version %1$s details%2$s."
272272
msgstr ""
273273

274274
#. translators: %s: opening/closing paragraph and italic tags
275-
#: src/Git_Updater/Theme.php:544
275+
#: src/Git_Updater/Theme.php:539
276276
msgid "%1$sAutomatic update is unavailable for this theme.%2$s"
277277
msgstr ""
278278

279-
#: src/Git_Updater/Traits/GU_Trait.php:666
279+
#: src/Git_Updater/Traits/GU_Trait.php:673
280280
msgid "There may be a problem with WP-Cron. A Git Updater WP-Cron event is overdue."
281281
msgstr ""

src/Git_Updater/API/API.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -217,13 +217,13 @@ public function api( $url ) {
217217
$this->set_repo_cache( 'error_cache', $response, md5( $url ), "+{$timeout} minutes" );
218218
}
219219

220-
static::$error_code[ $this->type->slug ] = isset( static::$error_code[ $this->type->slug ] ) ? static::$error_code[ $this->type->slug ] : [];
220+
static::$error_code[ $this->type->slug ] = static::$error_code[ $this->type->slug ] ?? [];
221221
static::$error_code[ $this->type->slug ] = array_merge(
222222
static::$error_code[ $this->type->slug ],
223223
[
224224
'repo' => $this->type->slug,
225225
'code' => $code,
226-
'name' => isset( $this->type->name ) ? $this->type->name : $this->type->slug,
226+
'name' => $this->type->name ?? $this->type->slug,
227227
'git' => $this->type->git,
228228
]
229229
);
@@ -295,7 +295,7 @@ public function get_api_url( $endpoint, $download_link = false ) {
295295
'owner' => $this->type->owner,
296296
'repo' => $this->type->slug,
297297
'branch' => empty( $this->type->branch ) ? $this->type->primary_branch : $this->type->branch,
298-
'gist_id' => isset( $this->type->gist_id ) ? $this->type->gist_id : null,
298+
'gist_id' => $this->type->gist_id ?? null,
299299
];
300300

301301
foreach ( $segments as $segment => $value ) {
@@ -339,7 +339,7 @@ public function get_api_url( $endpoint, $download_link = false ) {
339339
* @return bool|int|mixed|string|\WP_Error
340340
*/
341341
protected function get_dot_org_data() {
342-
$response = isset( $this->response['dot_org'] ) ? $this->response['dot_org'] : false;
342+
$response = $this->response['dot_org'] ?? false;
343343

344344
if ( ! $response ) {
345345
$url = "https://api.wordpress.org/{$this->type->type}s/info/1.2/";
@@ -545,11 +545,11 @@ public function set_readme_info( $readme ) {
545545
$readme['tested'] = implode( '.', $tested_arr );
546546
}
547547

548-
$this->type->tested = isset( $readme['tested'] ) ? $readme['tested'] : '';
549-
$this->type->requires = isset( $readme['requires'] ) ? $readme['requires'] : '';
550-
$this->type->requires_php = isset( $readme['requires_php'] ) ? $readme['requires_php'] : '';
551-
$this->type->donate_link = isset( $readme['donate_link'] ) ? $readme['donate_link'] : '';
552-
$this->type->contributors = isset( $readme['contributors'] ) ? $readme['contributors'] : [];
548+
$this->type->tested = $readme['tested'] ?? '';
549+
$this->type->requires = $readme['requires'] ?? '';
550+
$this->type->requires_php = $readme['requires_php'] ?? '';
551+
$this->type->donate_link = $readme['donate_link'] ?? '';
552+
$this->type->contributors = $readme['contributors'] ?? [];
553553
if ( empty( $readme['upgrade_notice'] ) ) {
554554
unset( $readme['upgrade_notice'] );
555555
} else {
@@ -583,7 +583,7 @@ protected function get_release_asset_redirect( $asset, $aws = false ) {
583583
unset( $this->response['release_asset_redirect'] );
584584
}
585585

586-
$response = isset( $this->response['release_asset_redirect'] ) ? $this->response['release_asset_redirect'] : false;
586+
$response = $this->response['release_asset_redirect'] ?? false;
587587

588588
// phpcs:disable WordPress.Security.NonceVerification.Recommended
589589
if ( isset( $_REQUEST['key'] ) ) {

src/Git_Updater/API/GitHub_API.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public static function ratelimit_reset( $response, $repo ) {
205205
$reset = (int) $data['x-ratelimit-reset'];
206206
//phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
207207
$wait = date( 'i', $reset - time() );
208-
static::$error_code[ $repo ] = isset( static::$error_code[ $repo ] ) ? static::$error_code[ $repo ] : [];
208+
static::$error_code[ $repo ] = static::$error_code[ $repo ] ?? [];
209209
static::$error_code[ $repo ] = array_merge( static::$error_code[ $repo ], [ 'wait' => $wait ] );
210210

211211
return $wait;
@@ -464,7 +464,7 @@ public function github_access_token() {
464464
*/
465465
public function remote_install( $headers, $install ) {
466466
$github_com = true;
467-
$options['github_access_token'] = isset( static::$options['github_access_token'] ) ? static::$options['github_access_token'] : null;
467+
$options['github_access_token'] = static::$options['github_access_token'] ?? null;
468468

469469
if ( 'github.com' === $headers['host'] || empty( $headers['host'] ) ) {
470470
$base = 'https://api.github.com';

src/Git_Updater/Add_Ons.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function load_addon_config() {
7272
[
7373
'name' => __( 'Git Updater - Bitbucket', 'git-updater' ),
7474
'author' => __( 'Andy Fragen' ),
75-
'description' => __( 'Add Bitbucket and Bitbucket Server repositories to the Git Updater plugin.', 'git-updater' ),
75+
'description' => __( 'Add Bitbucket and Bitbucket Server hosted repositories to the Git Updater plugin.', 'git-updater' ),
7676
'host' => 'github',
7777
'slug' => 'git-updater-bitbucket/git-updater-bitbucket.php',
7878
'uri' => 'afragen/git-updater-bitbucket',

src/Git_Updater/Additions/Settings.php

+3-5
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,7 @@ public function save_settings( $post_data ) {
8585
if ( isset( $post_data['option_page'] ) &&
8686
'git_updater_additions' === $post_data['option_page']
8787
) {
88-
$new_options = isset( $post_data['git_updater_additions'] )
89-
? $post_data['git_updater_additions']
90-
: [];
88+
$new_options = $post_data['git_updater_additions'] ?? [];
9189

9290
$new_options = $this->sanitize( $new_options );
9391

@@ -285,7 +283,7 @@ public function print_section_additions() {
285283
* @return void
286284
*/
287285
public function callback_field( $args ) {
288-
$placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : null;
286+
$placeholder = $args['placeholder'] ?? null;
289287
?>
290288
<label for="<?php echo esc_attr( $args['id'] ); ?>">
291289
<input type="text" style="width:50%;" id="<?php esc_attr( $args['id'] ); ?>" name="git_updater_additions[<?php echo esc_attr( $args['setting'] ); ?>]" value="" placeholder="<?php echo esc_attr( $placeholder ); ?>">
@@ -332,7 +330,7 @@ public function callback_dropdown( $args ) {
332330
* @param array $args Callback args.
333331
*/
334332
public function callback_checkbox( $args ) {
335-
$checked = isset( self::$options_additions[ $args['id'] ] ) ? self::$options_additions[ $args['id'] ] : null;
333+
$checked = self::$options_additions[ $args['id'] ] ?? null;
336334
?>
337335
<label for="<?php echo esc_attr( $args['id'] ); ?>">
338336
<input type="checkbox" id="<?php echo esc_attr( $args['id'] ); ?>" name="git_updater_additions[<?php echo esc_attr( $args['setting'] ); ?>]" value="1" <?php checked( 1, intval( $checked ), true ); ?> <?php disabled( '-1', $checked, true ); ?> >

src/Git_Updater/Base.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,6 @@ public function get_git_icon( $file, $add_padding ) {
707707
}
708708
}
709709

710-
return isset( $icon ) ? $icon : null;
710+
return $icon ?? null;
711711
}
712712
}

src/Git_Updater/Bootstrap.php

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public function rename_on_activation() {
181181
}
182182

183183
if ( $slug && 'git-updater/git-updater.php' !== $slug ) {
184+
require_once __DIR__ . '/Shim.php';
184185
$result = move_dir( $plugin_dir . dirname( $slug ), $plugin_dir . 'git-updater', true );
185186
if ( \is_wp_error( $result ) ) {
186187
return $result;

src/Git_Updater/Branch.php

+10-7
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class Branch {
5454
*/
5555
protected $cache;
5656

57+
/**
58+
* Holds data to be stored.
59+
*
60+
* @var string[]
61+
*/
62+
protected $response;
63+
5764
/**
5865
* Constructor.
5966
*/
@@ -161,7 +168,7 @@ public function set_branch_on_switch( $repo ) {
161168
$tag_array = isset( $this->cache['tags'] ) && is_array( $this->cache['tags'] );
162169
$in_tag_array = $tag_array && in_array( $rollback, $this->cache['tags'], true );
163170
if ( $in_tag_array ) {
164-
$current_branch = isset( $this->cache[ $repo ]['PrimaryBranch'] ) ? $this->cache[ $repo ]['PrimaryBranch'] : 'master';
171+
$current_branch = $this->cache[ $repo ]['PrimaryBranch'] ?? 'master';
165172
}
166173

167174
if ( ! $in_tag_array && isset( $_GET['action'], $this->cache['branches'] )
@@ -221,9 +228,7 @@ public function plugin_branch_switcher( $plugin_file, $plugin_data ) {
221228

222229
if ( ! empty( $plugin ) ) {
223230
$id = $plugin['slug'] . '-id';
224-
$branches = isset( $config[ $plugin['slug'] ]->branches )
225-
? $config[ $plugin['slug'] ]->branches
226-
: null;
231+
$branches = $config[ $plugin['slug'] ]->branches ?? null;
227232
} else {
228233
return false;
229234
}
@@ -270,9 +275,7 @@ public function multisite_branch_switcher( $theme_key, $theme ) {
270275

271276
$enclosure = $this->base->update_row_enclosure( $theme_key, 'theme', true );
272277
$id = $theme_key . '-id';
273-
$branches = isset( $config[ $theme_key ]->branches )
274-
? $config[ $theme_key ]->branches
275-
: null;
278+
$branches = $config[ $theme_key ]->branches ?? null;
276279
$nonced_update_url = wp_nonce_url(
277280
$this->base->get_update_url( 'theme', 'upgrade-theme', $theme_key ),
278281
'upgrade-theme_' . $theme_key

src/Git_Updater/Install.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ private function set_install_post_data( $config ) {
240240
? rtrim( $headers['host'], '.com' )
241241
: rtrim( $headers['host'], '.org' );
242242

243-
$api = isset( $config['git'] ) ? $config['git'] : $api;
243+
$api = $config['git'] ?? $api;
244244

245245
$_POST['git_updater_repo'] = $config['uri'];
246246
$_POST['git_updater_branch'] = $config['branch'];

src/Git_Updater/Plugin.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,7 @@ function ( $key ) use ( $plugin ) {
172172
unset( self::$options[ $current_branch ] );
173173
update_site_option( 'git_updater', self::$options );
174174
}
175-
$branch = isset( self::$options[ $current_branch ] )
176-
? self::$options[ $current_branch ]
177-
: $header['primary_branch'];
175+
$branch = self::$options[ $current_branch ] ?? $header['primary_branch'];
178176

179177
$git_plugin['type'] = 'plugin';
180178
$git_plugin['git'] = $repo_parts['git_server'];

src/Git_Updater/REST/Rest_Update.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ public function process_request( $request = null ) {
262262
$tag = $branch;
263263
$remote_branch = $branch;
264264
}
265-
$remote_branch = isset( $remote_branch ) ? $remote_branch : $tag;
265+
$remote_branch = $remote_branch ?? $tag;
266266
$current_branch = $override ? $remote_branch : $current_branch;
267267
if ( $remote_branch !== $current_branch && ! $override ) {
268268
throw new \UnexpectedValueException( 'Webhook tag and current branch are not matching. Consider using `override` query arg.' );
@@ -365,11 +365,11 @@ private function get_local_branch( $plugin, $theme ) {
365365
$repo = false;
366366
if ( $plugin ) {
367367
$repos = Singleton::get_instance( 'Fragen\Git_Updater\Plugin', $this )->get_plugin_configs();
368-
$repo = isset( $repos[ $plugin ] ) ? $repos[ $plugin ] : false;
368+
$repo = $repos[ $plugin ] ?? false;
369369
}
370370
if ( $theme ) {
371371
$repos = Singleton::get_instance( 'Fragen\Git_Updater\Theme', $this )->get_theme_configs();
372-
$repo = isset( $repos[ $theme ] ) ? $repos[ $theme ] : false;
372+
$repo = $repos[ $theme ] ?? false;
373373
}
374374
$current_branch = $repo ?
375375
( new Branch() )->get_current_branch( $repo ) :
@@ -387,7 +387,7 @@ private function get_local_branch( $plugin, $theme ) {
387387
*/
388388
private function get_primary_branch( $slug ) {
389389
$cache = $this->get_repo_cache( $slug );
390-
$primary_branch = isset( $cache[ $slug ]['PrimaryBranch'] ) ? $cache[ $slug ]['PrimaryBranch'] : 'master';
390+
$primary_branch = $cache[ $slug ]['PrimaryBranch'] ?? 'master';
391391

392392
return $primary_branch;
393393
}

0 commit comments

Comments
 (0)