Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Aug 11, 2023
2 parents 3895a09 + 33e8988 commit 0ada9ea
Show file tree
Hide file tree
Showing 22 changed files with 107 additions and 94 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#### [unreleased]

#### 12.3.0 / 2023-08-10
* update Bitbucket Add-on message for consistency
* ensure `Shim` available during `register_activation_hook()`
* add conditional to `get_remote_api_branches()` to ensure `$response` is not a scalar
* use null coalescing operator
* update for PHP 8.2

#### 12.2.3 / 2023-06-27
* composer update
* get `gu_disable_cron` hook result once per repository
Expand Down
16 changes: 10 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion git-updater.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Plugin Name: Git Updater
* Plugin URI: https://git-updater.com
* Description: A plugin to automatically update GitHub hosted plugins, themes, and language packs. Additional API plugins available for Bitbucket, GitLab, Gitea, and Gist.
* Version: 12.2.3
* Version: 12.3.0
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down
30 changes: 15 additions & 15 deletions languages/git-updater.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
# This file is distributed under the MIT.
msgid ""
msgstr ""
"Project-Id-Version: Git Updater 12.2.0\n"
"Project-Id-Version: Git Updater 12.3.0\n"
"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/git-updater\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2023-04-19T18:44:46+00:00\n"
"POT-Creation-Date: 2023-08-11T00:39:53+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Generator: WP-CLI 2.8.1\n"
"X-Domain: git-updater\n"

#. Plugin Name of the plugin
Expand Down Expand Up @@ -49,7 +49,7 @@ msgid "Git Updater - Bitbucket"
msgstr ""

#: src/Git_Updater/Add_Ons.php:75
msgid "Add Bitbucket and Bitbucket Server repositories to the Git Updater plugin."
msgid "Add Bitbucket and Bitbucket Server hosted repositories to the Git Updater plugin."
msgstr ""

#: src/Git_Updater/Add_Ons.php:86
Expand Down Expand Up @@ -240,42 +240,42 @@ msgid "Installed Plugins and Themes"
msgstr ""

#. translators: %s: theme name
#: src/Git_Updater/Theme.php:389
#: src/Git_Updater/Theme.php:515
#: src/Git_Updater/Theme.php:384
#: src/Git_Updater/Theme.php:510
msgid "There is a new version of %s available."
msgstr ""

#. translators: %s: theme version
#: src/Git_Updater/Theme.php:401
#: src/Git_Updater/Theme.php:396
msgid "View version %s details."
msgstr ""

#: src/Git_Updater/Theme.php:405
#: src/Git_Updater/Theme.php:400
msgid "Automatic update is unavailable for this theme."
msgstr ""

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

#. translators: %s: theme name
#: src/Git_Updater/Theme.php:415
#: src/Git_Updater/Theme.php:531
#: src/Git_Updater/Theme.php:410
#: src/Git_Updater/Theme.php:526
msgid "Update %s now"
msgstr ""

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

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

#: src/Git_Updater/Traits/GU_Trait.php:666
#: src/Git_Updater/Traits/GU_Trait.php:673
msgid "There may be a problem with WP-Cron. A Git Updater WP-Cron event is overdue."
msgstr ""
20 changes: 10 additions & 10 deletions src/Git_Updater/API/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ public function api( $url ) {
$this->set_repo_cache( 'error_cache', $response, md5( $url ), "+{$timeout} minutes" );
}

static::$error_code[ $this->type->slug ] = isset( static::$error_code[ $this->type->slug ] ) ? static::$error_code[ $this->type->slug ] : [];
static::$error_code[ $this->type->slug ] = static::$error_code[ $this->type->slug ] ?? [];
static::$error_code[ $this->type->slug ] = array_merge(
static::$error_code[ $this->type->slug ],
[
'repo' => $this->type->slug,
'code' => $code,
'name' => isset( $this->type->name ) ? $this->type->name : $this->type->slug,
'name' => $this->type->name ?? $this->type->slug,
'git' => $this->type->git,
]
);
Expand Down Expand Up @@ -295,7 +295,7 @@ public function get_api_url( $endpoint, $download_link = false ) {
'owner' => $this->type->owner,
'repo' => $this->type->slug,
'branch' => empty( $this->type->branch ) ? $this->type->primary_branch : $this->type->branch,
'gist_id' => isset( $this->type->gist_id ) ? $this->type->gist_id : null,
'gist_id' => $this->type->gist_id ?? null,
];

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

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

$this->type->tested = isset( $readme['tested'] ) ? $readme['tested'] : '';
$this->type->requires = isset( $readme['requires'] ) ? $readme['requires'] : '';
$this->type->requires_php = isset( $readme['requires_php'] ) ? $readme['requires_php'] : '';
$this->type->donate_link = isset( $readme['donate_link'] ) ? $readme['donate_link'] : '';
$this->type->contributors = isset( $readme['contributors'] ) ? $readme['contributors'] : [];
$this->type->tested = $readme['tested'] ?? '';
$this->type->requires = $readme['requires'] ?? '';
$this->type->requires_php = $readme['requires_php'] ?? '';
$this->type->donate_link = $readme['donate_link'] ?? '';
$this->type->contributors = $readme['contributors'] ?? [];
if ( empty( $readme['upgrade_notice'] ) ) {
unset( $readme['upgrade_notice'] );
} else {
Expand Down Expand Up @@ -583,7 +583,7 @@ protected function get_release_asset_redirect( $asset, $aws = false ) {
unset( $this->response['release_asset_redirect'] );
}

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

// phpcs:disable WordPress.Security.NonceVerification.Recommended
if ( isset( $_REQUEST['key'] ) ) {
Expand Down
4 changes: 2 additions & 2 deletions src/Git_Updater/API/GitHub_API.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public static function ratelimit_reset( $response, $repo ) {
$reset = (int) $data['x-ratelimit-reset'];
//phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date
$wait = date( 'i', $reset - time() );
static::$error_code[ $repo ] = isset( static::$error_code[ $repo ] ) ? static::$error_code[ $repo ] : [];
static::$error_code[ $repo ] = static::$error_code[ $repo ] ?? [];
static::$error_code[ $repo ] = array_merge( static::$error_code[ $repo ], [ 'wait' => $wait ] );

return $wait;
Expand Down Expand Up @@ -464,7 +464,7 @@ public function github_access_token() {
*/
public function remote_install( $headers, $install ) {
$github_com = true;
$options['github_access_token'] = isset( static::$options['github_access_token'] ) ? static::$options['github_access_token'] : null;
$options['github_access_token'] = static::$options['github_access_token'] ?? null;

if ( 'github.com' === $headers['host'] || empty( $headers['host'] ) ) {
$base = 'https://api.github.com';
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Add_Ons.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected function load_addon_config() {
[
'name' => __( 'Git Updater - Bitbucket', 'git-updater' ),
'author' => __( 'Andy Fragen' ),
'description' => __( 'Add Bitbucket and Bitbucket Server repositories to the Git Updater plugin.', 'git-updater' ),
'description' => __( 'Add Bitbucket and Bitbucket Server hosted repositories to the Git Updater plugin.', 'git-updater' ),
'host' => 'github',
'slug' => 'git-updater-bitbucket/git-updater-bitbucket.php',
'uri' => 'afragen/git-updater-bitbucket',
Expand Down
8 changes: 3 additions & 5 deletions src/Git_Updater/Additions/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ public function save_settings( $post_data ) {
if ( isset( $post_data['option_page'] ) &&
'git_updater_additions' === $post_data['option_page']
) {
$new_options = isset( $post_data['git_updater_additions'] )
? $post_data['git_updater_additions']
: [];
$new_options = $post_data['git_updater_additions'] ?? [];

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

Expand Down Expand Up @@ -285,7 +283,7 @@ public function print_section_additions() {
* @return void
*/
public function callback_field( $args ) {
$placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : null;
$placeholder = $args['placeholder'] ?? null;
?>
<label for="<?php echo esc_attr( $args['id'] ); ?>">
<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 ); ?>">
Expand Down Expand Up @@ -332,7 +330,7 @@ public function callback_dropdown( $args ) {
* @param array $args Callback args.
*/
public function callback_checkbox( $args ) {
$checked = isset( self::$options_additions[ $args['id'] ] ) ? self::$options_additions[ $args['id'] ] : null;
$checked = self::$options_additions[ $args['id'] ] ?? null;
?>
<label for="<?php echo esc_attr( $args['id'] ); ?>">
<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 ); ?> >
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,6 @@ public function get_git_icon( $file, $add_padding ) {
}
}

return isset( $icon ) ? $icon : null;
return $icon ?? null;
}
}
1 change: 1 addition & 0 deletions src/Git_Updater/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ public function rename_on_activation() {
}

if ( $slug && 'git-updater/git-updater.php' !== $slug ) {
require_once __DIR__ . '/Shim.php';
$result = move_dir( $plugin_dir . dirname( $slug ), $plugin_dir . 'git-updater', true );
if ( \is_wp_error( $result ) ) {
return $result;
Expand Down
17 changes: 10 additions & 7 deletions src/Git_Updater/Branch.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ class Branch {
*/
protected $cache;

/**
* Holds data to be stored.
*
* @var string[]
*/
protected $response;

/**
* Constructor.
*/
Expand Down Expand Up @@ -161,7 +168,7 @@ public function set_branch_on_switch( $repo ) {
$tag_array = isset( $this->cache['tags'] ) && is_array( $this->cache['tags'] );
$in_tag_array = $tag_array && in_array( $rollback, $this->cache['tags'], true );
if ( $in_tag_array ) {
$current_branch = isset( $this->cache[ $repo ]['PrimaryBranch'] ) ? $this->cache[ $repo ]['PrimaryBranch'] : 'master';
$current_branch = $this->cache[ $repo ]['PrimaryBranch'] ?? 'master';
}

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

if ( ! empty( $plugin ) ) {
$id = $plugin['slug'] . '-id';
$branches = isset( $config[ $plugin['slug'] ]->branches )
? $config[ $plugin['slug'] ]->branches
: null;
$branches = $config[ $plugin['slug'] ]->branches ?? null;
} else {
return false;
}
Expand Down Expand Up @@ -270,9 +275,7 @@ public function multisite_branch_switcher( $theme_key, $theme ) {

$enclosure = $this->base->update_row_enclosure( $theme_key, 'theme', true );
$id = $theme_key . '-id';
$branches = isset( $config[ $theme_key ]->branches )
? $config[ $theme_key ]->branches
: null;
$branches = $config[ $theme_key ]->branches ?? null;
$nonced_update_url = wp_nonce_url(
$this->base->get_update_url( 'theme', 'upgrade-theme', $theme_key ),
'upgrade-theme_' . $theme_key
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Install.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ private function set_install_post_data( $config ) {
? rtrim( $headers['host'], '.com' )
: rtrim( $headers['host'], '.org' );

$api = isset( $config['git'] ) ? $config['git'] : $api;
$api = $config['git'] ?? $api;

$_POST['git_updater_repo'] = $config['uri'];
$_POST['git_updater_branch'] = $config['branch'];
Expand Down
4 changes: 1 addition & 3 deletions src/Git_Updater/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,7 @@ function ( $key ) use ( $plugin ) {
unset( self::$options[ $current_branch ] );
update_site_option( 'git_updater', self::$options );
}
$branch = isset( self::$options[ $current_branch ] )
? self::$options[ $current_branch ]
: $header['primary_branch'];
$branch = self::$options[ $current_branch ] ?? $header['primary_branch'];

$git_plugin['type'] = 'plugin';
$git_plugin['git'] = $repo_parts['git_server'];
Expand Down
8 changes: 4 additions & 4 deletions src/Git_Updater/REST/Rest_Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public function process_request( $request = null ) {
$tag = $branch;
$remote_branch = $branch;
}
$remote_branch = isset( $remote_branch ) ? $remote_branch : $tag;
$remote_branch = $remote_branch ?? $tag;
$current_branch = $override ? $remote_branch : $current_branch;
if ( $remote_branch !== $current_branch && ! $override ) {
throw new \UnexpectedValueException( 'Webhook tag and current branch are not matching. Consider using `override` query arg.' );
Expand Down Expand Up @@ -365,11 +365,11 @@ private function get_local_branch( $plugin, $theme ) {
$repo = false;
if ( $plugin ) {
$repos = Singleton::get_instance( 'Fragen\Git_Updater\Plugin', $this )->get_plugin_configs();
$repo = isset( $repos[ $plugin ] ) ? $repos[ $plugin ] : false;
$repo = $repos[ $plugin ] ?? false;
}
if ( $theme ) {
$repos = Singleton::get_instance( 'Fragen\Git_Updater\Theme', $this )->get_theme_configs();
$repo = isset( $repos[ $theme ] ) ? $repos[ $theme ] : false;
$repo = $repos[ $theme ] ?? false;
}
$current_branch = $repo ?
( new Branch() )->get_current_branch( $repo ) :
Expand All @@ -387,7 +387,7 @@ private function get_local_branch( $plugin, $theme ) {
*/
private function get_primary_branch( $slug ) {
$cache = $this->get_repo_cache( $slug );
$primary_branch = isset( $cache[ $slug ]['PrimaryBranch'] ) ? $cache[ $slug ]['PrimaryBranch'] : 'master';
$primary_branch = $cache[ $slug ]['PrimaryBranch'] ?? 'master';

return $primary_branch;
}
Expand Down
Loading

0 comments on commit 0ada9ea

Please sign in to comment.