From c4587d9b1ee1a8d153d250a8bb436db3d0329a87 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 30 Dec 2018 09:37:42 -0800 Subject: [PATCH 01/18] remove `tmp-readme.txt` after parsing Fixes https://github.com/afragen/github-updater/issues/754 --- CHANGES.md | 1 + src/GitHub_Updater/Readme_Parser.php | 2 ++ 2 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 7712dfe01..f5ac3ae75 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,5 @@ #### [unreleased] +* remove `tmp-readme.txt` after parsing, fixes [#754](https://github.com/afragen/github-updater/issues/754) #### 8.6.0 / 2018-12-28 🎂 * add action hook `github_updater_post_rest_process_request` for @Raruto diff --git a/src/GitHub_Updater/Readme_Parser.php b/src/GitHub_Updater/Readme_Parser.php index f6c2bf7d9..802fabef5 100644 --- a/src/GitHub_Updater/Readme_Parser.php +++ b/src/GitHub_Updater/Readme_Parser.php @@ -73,6 +73,8 @@ public function parse_data() { $data = $this->faq_as_h4( $data ); $data = $this->changelog_as_h4( $data ); + @unlink( WP_CONTENT_DIR . '/tmp-readme.txt' ); + return $data; } From 236ec86bcbe70fba20dc876f4b2cb434c9b6b35e Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 30 Dec 2018 09:38:09 -0800 Subject: [PATCH 02/18] simplify docblocks --- src/GitHub_Updater/Traits/API_Common.php | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/GitHub_Updater/Traits/API_Common.php b/src/GitHub_Updater/Traits/API_Common.php index 27ff27cef..ec9bffee0 100644 --- a/src/GitHub_Updater/Traits/API_Common.php +++ b/src/GitHub_Updater/Traits/API_Common.php @@ -172,9 +172,7 @@ public function get_remote_api_tag( $git, $request ) { public function get_remote_api_changes( $git, $changes, $request ) { $response = isset( $this->response['changes'] ) ? $this->response['changes'] : false; - /* - * Set response from local file if no update available. - */ + // Set $response from local file if no update available. if ( ! $response && ! $this->can_update_repo( $this->type ) ) { $response = $this->get_local_info( $this->type, $changes ); } @@ -220,9 +218,7 @@ public function get_remote_api_readme( $git, $request ) { $response = isset( $this->response['readme'] ) ? $this->response['readme'] : false; - /* - * Set $response from local file if no update available. - */ + // Set $response from local file if no update available. if ( ! $response && ! $this->can_update_repo( $this->type ) ) { $response = $this->get_local_info( $this->type, 'readme.txt' ); } From bba13f9c23c5e30517c14c3b0322f6d1927d7933 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 30 Dec 2018 09:43:16 -0800 Subject: [PATCH 03/18] directly call `wp_cron()` after refresh cache Maybe fixes https://github.com/afragen/github-updater/issues/753 --- CHANGES.md | 1 + github-updater.php | 2 +- src/GitHub_Updater/Traits/GHU_Trait.php | 19 +------------------ 3 files changed, 3 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f5ac3ae75..f36b3391b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ #### [unreleased] * remove `tmp-readme.txt` after parsing, fixes [#754](https://github.com/afragen/github-updater/issues/754) +* directly call `wp_cron()` after refreshing cache #### 8.6.0 / 2018-12-28 🎂 * add action hook `github_updater_post_rest_process_request` for @Raruto diff --git a/github-updater.php b/github-updater.php index e1b74a6d6..6bd7e54c7 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0 + * Version: 8.6.0.1 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/GitHub_Updater/Traits/GHU_Trait.php b/src/GitHub_Updater/Traits/GHU_Trait.php index 97ef9af4b..77ffaf215 100644 --- a/src/GitHub_Updater/Traits/GHU_Trait.php +++ b/src/GitHub_Updater/Traits/GHU_Trait.php @@ -183,28 +183,11 @@ public function delete_all_cached_data() { $wpdb->query( $wpdb->prepare( $delete_string, [ '%ghu-%' ] ) ); - $this->force_run_cron_job(); + wp_cron(); return true; } - /** - * Force wp-cron.php to run. - */ - public function force_run_cron_job() { - $doing_wp_cron = sprintf( '%.22F', microtime( true ) ); - $cron_request = [ - 'url' => site_url( 'wp-cron.php?doing_wp_cron=' . $doing_wp_cron ), - 'args' => [ - 'timeout' => 0.01, - 'blocking' => false, - 'sslverify' => apply_filters( 'https_local_ssl_verify', true ), - ], - ]; - - wp_remote_post( $cron_request['url'], $cron_request['args'] ); - } - /** * Is this a private repo with a token/checked or needing token/checked? * Test for whether remote_version is set ( default = 0.0.0 ) or From 220dce6a743666e68b1b61959371bd2009b925e6 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sun, 30 Dec 2018 17:50:58 -0800 Subject: [PATCH 04/18] playing with travis more play more play more play find path path path path path path cleanup final cleanup spacing test nightly --- .travis.yml | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d7ba9de7a..6debcbe6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,26 +12,40 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 env: - WP_VERSION=latest WP_MULTISITE=0 - WP_VERSION=latest WP_MULTISITE=1 + - WP_VERSION=nightly + +cache: + apt: true + directories: + - node_modules + - vendor + - $HOME/.composer/cache + +matrix: + fast_finish: true + allow_failures: + - php 7.3 before_script: - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION - - export PATH="$HOME/.config/composer/vendor:$PATH" - - phpunit --version + - export PATH="$HOME/.composer/vendor/bin:$PATH" - | if [[ ${TRAVIS_PHP_VERSION:0:2} == "7." ]]; then composer global require "phpunit/phpunit:^6" elif [[ ${TRAVIS_PHP_VERSION:0:3} != "5.2" ]]; then composer global require "phpunit/phpunit:^4" fi - - $HOME/.config/composer/vendor/phpunit/phpunit/phpunit --version + - $HOME/.composer/vendor/bin/phpunit --version + - phpunit --version script: -- phpenv config-rm xdebug.ini -- $HOME/.config/composer/vendor/phpunit/phpunit/phpunit +- phpenv config-rm xdebug.ini || echo "xdebug.ini does not exist" +- phpunit before_deploy: - git archive -o /tmp/github-updater-${TRAVIS_TAG}.zip --prefix=github-updater/ ${TRAVIS_COMMIT} From c6fa30ea02cfcef2f7e909699c45736851d13121 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Tue, 1 Jan 2019 10:34:17 -0800 Subject: [PATCH 05/18] use 'WordPress' not 'WordPress-Core' for linting --- src/GitHub_Updater/API.php | 3 ++- .../API/Bitbucket_Server_API.php | 18 +++++++++--------- src/GitHub_Updater/Traits/API_Common.php | 6 +++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/GitHub_Updater/API.php b/src/GitHub_Updater/API.php index 7a4987d5d..88abaad37 100644 --- a/src/GitHub_Updater/API.php +++ b/src/GitHub_Updater/API.php @@ -807,7 +807,7 @@ protected function get_release_asset_redirect( $asset, $aws = false ) { * * @since 6.1.0 * - * @param array $args + * @param array $args * @param string $url * * @return mixed $args @@ -820,6 +820,7 @@ public function set_aws_release_asset_header( $args, $url = '' ) { /** * Set AWS redirect URL from action hook. + * * @uses `requests-requests.before_redirect` Action hook. * * @param string $location diff --git a/src/GitHub_Updater/API/Bitbucket_Server_API.php b/src/GitHub_Updater/API/Bitbucket_Server_API.php index 1fd8797cc..91f2ce4d4 100644 --- a/src/GitHub_Updater/API/Bitbucket_Server_API.php +++ b/src/GitHub_Updater/API/Bitbucket_Server_API.php @@ -246,18 +246,18 @@ public function add_endpoints( $git, $endpoint ) { * @return bool|array false upon failure || return wp_safe_remote_get() response array **/ private function bbserver_fetch_raw_file( $file ) { - //$file = urlencode( $file ); - //$download_url = '/1.0/projects/:owner/repos/:repo/browse/' . $file; - //$download_url = $this->add_endpoints( $this, $download_url ); - //$download_url = $this->get_api_url( $download_url ); + // $file = urlencode( $file ); + // $download_url = '/1.0/projects/:owner/repos/:repo/browse/' . $file; + // $download_url = $this->add_endpoints( $this, $download_url ); + // $download_url = $this->get_api_url( $download_url ); // - //$response = wp_safe_remote_get( $download_url ); + // $response = wp_safe_remote_get( $download_url ); // - //if ( is_wp_error( $response ) ) { - // return false; - //} + // if ( is_wp_error( $response ) ) { + // return false; + // } // - //return wp_remote_retrieve_body( $response ); + // return wp_remote_retrieve_body( $response ); } /** diff --git a/src/GitHub_Updater/Traits/API_Common.php b/src/GitHub_Updater/Traits/API_Common.php index ec9bffee0..7a9db9f20 100644 --- a/src/GitHub_Updater/Traits/API_Common.php +++ b/src/GitHub_Updater/Traits/API_Common.php @@ -28,7 +28,7 @@ trait API_Common { * Decode API responses that are base64 encoded. * * @param string $git (github|bitbucket|gitlab|gitea) - * @param mixed $response API response. + * @param mixed $response API response. * @return mixed $response */ private function decode_response( $git, $response ) { @@ -46,7 +46,7 @@ private function decode_response( $git, $response ) { * Parse API response that returns as stdClass. * * @param string $git (github|bitbucket|gitlab|gitea) - * @param mixed $response API response. + * @param mixed $response API response. * @return mixed $response */ private function parse_response( $git, $response ) { @@ -64,7 +64,7 @@ private function parse_response( $git, $response ) { * * @param string $git (github|bitbucket|gitlab|gitea) * @param string $request Query to API->api(). - * @param mixed $response API response. + * @param mixed $response API response. * @return string $response Release asset download link. */ private function parse_release_asset( $git, $request, $response ) { From 6ca592609fecc59b203d5aa1ccee9c2a6ad59bf3 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Tue, 1 Jan 2019 12:38:56 -0800 Subject: [PATCH 06/18] more linter updates --- mu/ghu-loader.php | 5 ++--- src/GitHub_Updater/API.php | 4 ++-- src/GitHub_Updater/API/Bitbucket_Server_API.php | 2 +- src/GitHub_Updater/API/GitLab_API.php | 4 ++-- src/GitHub_Updater/API/Language_Pack_API.php | 2 +- src/GitHub_Updater/Base.php | 6 +++--- src/GitHub_Updater/Init.php | 5 ++++- src/GitHub_Updater/Install.php | 6 +++--- src/GitHub_Updater/Language_Pack.php | 2 +- src/GitHub_Updater/Remote_Management.php | 2 +- src/GitHub_Updater/Rest_Update.php | 4 ++++ src/GitHub_Updater/Settings.php | 6 +++--- src/GitHub_Updater/Traits/GHU_Trait.php | 2 +- src/GitHub_Updater/WP_CLI/CLI_Common.php | 3 +++ src/GitHub_Updater/WP_CLI/CLI_Integration.php | 8 ++++---- 15 files changed, 35 insertions(+), 26 deletions(-) diff --git a/mu/ghu-loader.php b/mu/ghu-loader.php index 4dbf15dc8..547d5fd47 100644 --- a/mu/ghu-loader.php +++ b/mu/ghu-loader.php @@ -35,8 +35,7 @@ /** * Deactivate if plugin in loaded not as mu-plugin. * - * @param $plugin - * @param $network_wide + * @param string $plugin Plugin slug. */ function ghu_deactivate( $plugin, $network_wide ) { $ghu_plugin_file = 'github-updater/github-updater.php'; @@ -48,7 +47,7 @@ function ghu_deactivate( $plugin, $network_wide ) { /** * Label as mu-plugin in plugin view. * - * @param $actions + * @param array $actions Link actions. * * @return array */ diff --git a/src/GitHub_Updater/API.php b/src/GitHub_Updater/API.php index 88abaad37..3cdd9ecf1 100644 --- a/src/GitHub_Updater/API.php +++ b/src/GitHub_Updater/API.php @@ -490,8 +490,8 @@ protected function get_dot_org_data() { $url = "https://api.wordpress.org/{$this->type->type}s/info/1.1/"; $url = add_query_arg( [ - 'action' => "{$this->type->type}_information", - urlencode( 'request[slug]' ) => $this->type->slug, + 'action' => "{$this->type->type}_information", + rawurlencode( 'request[slug]' ) => $this->type->slug, ], $url ); diff --git a/src/GitHub_Updater/API/Bitbucket_Server_API.php b/src/GitHub_Updater/API/Bitbucket_Server_API.php index 91f2ce4d4..4b9cce767 100644 --- a/src/GitHub_Updater/API/Bitbucket_Server_API.php +++ b/src/GitHub_Updater/API/Bitbucket_Server_API.php @@ -246,7 +246,7 @@ public function add_endpoints( $git, $endpoint ) { * @return bool|array false upon failure || return wp_safe_remote_get() response array **/ private function bbserver_fetch_raw_file( $file ) { - // $file = urlencode( $file ); + // $file = rawurlencode( $file ); // $download_url = '/1.0/projects/:owner/repos/:repo/browse/' . $file; // $download_url = $this->add_endpoints( $this, $download_url ); // $download_url = $this->get_api_url( $download_url ); diff --git a/src/GitHub_Updater/API/GitLab_API.php b/src/GitHub_Updater/API/GitLab_API.php index d5a0aaba8..023c2cde7 100644 --- a/src/GitHub_Updater/API/GitLab_API.php +++ b/src/GitHub_Updater/API/GitLab_API.php @@ -269,7 +269,7 @@ public function get_gitlab_id() { if ( ! $response ) { self::$method = 'projects'; $id = implode( '/', [ $this->type->owner, $this->type->slug ] ); - $id = urlencode( $id ); + $id = rawurlencode( $id ); $response = $this->api( '/projects/' . $id ); if ( $this->validate_response( $response ) ) { @@ -571,7 +571,7 @@ public function remote_install( $headers, $install ) { $gitlab_com = false; } - $id = urlencode( $install['github_updater_repo'] ); + $id = rawurlencode( $install['github_updater_repo'] ); $install['download_link'] = "{$base}/api/v4/projects/{$id}/repository/archive.zip"; $install['download_link'] = add_query_arg( 'sha', $install['github_updater_branch'], $install['download_link'] ); diff --git a/src/GitHub_Updater/API/Language_Pack_API.php b/src/GitHub_Updater/API/Language_Pack_API.php index 95fc5fd2b..ce301ab0b 100644 --- a/src/GitHub_Updater/API/Language_Pack_API.php +++ b/src/GitHub_Updater/API/Language_Pack_API.php @@ -85,7 +85,7 @@ private function get_language_pack_json( $git, $headers, $response ) { $response = $this->api( '/2.0/repositories/' . $headers['owner'] . '/' . $headers['repo'] . '/src/master/language-pack.json' ); break; case 'gitlab': - $id = urlencode( $headers['owner'] . '/' . $headers['repo'] ); + $id = rawurlencode( $headers['owner'] . '/' . $headers['repo'] ); $response = $this->api( '/projects/' . $id . '/repository/files/language-pack.json' ); $response = isset( $response->content ) ? json_decode( base64_decode( $response->content ) ) diff --git a/src/GitHub_Updater/Base.php b/src/GitHub_Updater/Base.php index cfbffeeed..29adc7f73 100644 --- a/src/GitHub_Updater/Base.php +++ b/src/GitHub_Updater/Base.php @@ -906,7 +906,7 @@ protected function make_branch_switch_row( $data ) { printf( '
  • %s
  • ', $data['nonced_update_url'], - '&rollback=' . urlencode( $branch ), + '&rollback=' . rawurlencode( $branch ), esc_attr( $branch ) ); } @@ -922,7 +922,7 @@ protected function make_branch_switch_row( $data ) { printf( '
  • %s
  • ', $data['nonced_update_url'], - '&rollback=' . urlencode( $tag ), + '&rollback=' . rawurlencode( $tag ), esc_attr( $tag ) ); } @@ -948,7 +948,7 @@ protected function get_update_url( $type, $action, $repo_name ) { add_query_arg( [ 'action' => $action, - $type => urlencode( $repo_name ), + $type => rawurlencode( $repo_name ), ], self_admin_url( 'update.php' ) ) diff --git a/src/GitHub_Updater/Init.php b/src/GitHub_Updater/Init.php index faf0f8907..4dcc3098a 100644 --- a/src/GitHub_Updater/Init.php +++ b/src/GitHub_Updater/Init.php @@ -20,6 +20,9 @@ die; } +/** + * Class Init + */ class Init extends Base { use GHU_Trait, Basic_Auth_Loader; @@ -50,7 +53,7 @@ public function rename_on_activation() { $slug = isset( $_GET['plugin'] ) ? $_GET['plugin'] : false; $exploded = explode( '-', dirname( $slug ) ); - if ( in_array( 'develop', $exploded ) ) { + if ( in_array( 'develop', $exploded, true ) ) { $options = $this->get_class_vars( 'Base', 'options' ); update_site_option( 'github_updater', array_merge( $options, [ 'current_branch_github-updater' => 'develop' ] ) ); } diff --git a/src/GitHub_Updater/Install.php b/src/GitHub_Updater/Install.php index bff43564e..4346a80b5 100644 --- a/src/GitHub_Updater/Install.php +++ b/src/GitHub_Updater/Install.php @@ -531,8 +531,8 @@ public function install_theme_complete_actions( $install_actions, $api, $theme_i $activate_link = add_query_arg( [ 'action' => 'activate', - // 'template' => urlencode( $template ), - 'stylesheet' => urlencode( $stylesheet ), + // 'template' => rawurlencode( $template ), + 'stylesheet' => rawurlencode( $stylesheet ), ], admin_url( 'themes.php' ) ); @@ -544,7 +544,7 @@ public function install_theme_complete_actions( $install_actions, $api, $theme_i $network_activate_link = add_query_arg( [ 'action' => 'enable', - 'theme' => urlencode( $stylesheet ), + 'theme' => rawurlencode( $stylesheet ), ], network_admin_url( 'themes.php' ) ); diff --git a/src/GitHub_Updater/Language_Pack.php b/src/GitHub_Updater/Language_Pack.php index 8b3666ffd..2556b97a9 100644 --- a/src/GitHub_Updater/Language_Pack.php +++ b/src/GitHub_Updater/Language_Pack.php @@ -74,7 +74,7 @@ public function run() { /** * Add language translations to update_plugins or update_themes transients. * - * @param $transient + * @param mixed $transient pre_set_site_transient. * * @return mixed */ diff --git a/src/GitHub_Updater/Remote_Management.php b/src/GitHub_Updater/Remote_Management.php index 74eef0027..48458b8a8 100644 --- a/src/GitHub_Updater/Remote_Management.php +++ b/src/GitHub_Updater/Remote_Management.php @@ -66,7 +66,7 @@ private function load_options() { */ public function ensure_api_key_is_set() { if ( ! self::$api_key ) { - update_site_option( 'github_updater_api_key', md5( uniqid( mt_rand(), true ) ) ); + update_site_option( 'github_updater_api_key', md5( uniqid( wp_rand(), true ) ) ); } } diff --git a/src/GitHub_Updater/Rest_Update.php b/src/GitHub_Updater/Rest_Update.php index 57c90b71b..e724d0714 100644 --- a/src/GitHub_Updater/Rest_Update.php +++ b/src/GitHub_Updater/Rest_Update.php @@ -53,6 +53,7 @@ public function __construct() { * @param string $tag * * @throws \Exception + * @throws \UnexpectedValueException */ public function update_plugin( $plugin_slug, $tag = 'master' ) { $plugin = null; @@ -111,6 +112,7 @@ function ( $current ) use ( $plugin, $update ) { * @param string $tag * * @throws \Exception + * @throws \UnexpectedValueException */ public function update_theme( $theme_slug, $tag = 'master' ) { $theme = null; @@ -170,6 +172,8 @@ public function get_messages() { * If the request came through a webhook, and if the branch in the * webhook matches the branch specified by the url, use the latest * update available as specified in the webhook payload. + * + * @throws \UnexpectedValueException */ public function process_request() { $start = microtime( true ); diff --git a/src/GitHub_Updater/Settings.php b/src/GitHub_Updater/Settings.php index 52504491f..07a1266bf 100644 --- a/src/GitHub_Updater/Settings.php +++ b/src/GitHub_Updater/Settings.php @@ -551,12 +551,12 @@ private function display_dot_org_overrides() { echo '

    ' . esc_html__( 'The following plugins or themes might exist on wp.org, but any updates will be downloaded from their respective git repositories.', 'github-updater' ) . '

    '; foreach ( $plugins as $plugin ) { - if ( in_array( $plugin->file, $overrides ) ) { + if ( in_array( $plugin->file, $overrides, true ) ) { echo '

    ' . $dashicon_plugin . $plugin->name . '

    '; } } foreach ( $themes as $theme ) { - if ( in_array( $theme->slug, $overrides ) ) { + if ( in_array( $theme->slug, $overrides, true ) ) { echo '

    ' . $dashicon_theme . $theme->name . '

    '; } } @@ -684,7 +684,7 @@ protected function redirect_on_save() { ], $redirect_url ); - wp_redirect( $location ); + wp_safe_redirect( $location ); exit; } } diff --git a/src/GitHub_Updater/Traits/GHU_Trait.php b/src/GitHub_Updater/Traits/GHU_Trait.php index 77ffaf215..ddb5cba97 100644 --- a/src/GitHub_Updater/Traits/GHU_Trait.php +++ b/src/GitHub_Updater/Traits/GHU_Trait.php @@ -59,7 +59,7 @@ public function load_options() { */ public function is_current_page( array $pages ) { global $pagenow; - return in_array( $pagenow, $pages ); + return in_array( $pagenow, $pages, true ); } /** diff --git a/src/GitHub_Updater/WP_CLI/CLI_Common.php b/src/GitHub_Updater/WP_CLI/CLI_Common.php index c2e758906..a29e4b044 100644 --- a/src/GitHub_Updater/WP_CLI/CLI_Common.php +++ b/src/GitHub_Updater/WP_CLI/CLI_Common.php @@ -10,6 +10,9 @@ namespace Fragen\GitHub_Updater\WP_CLI; +/** + * Class CLI_Common + */ class CLI_Common { /** * Delete all `ghu-` prefixed data from options table. diff --git a/src/GitHub_Updater/WP_CLI/CLI_Integration.php b/src/GitHub_Updater/WP_CLI/CLI_Integration.php index 7cbb87fb6..915fe3c16 100644 --- a/src/GitHub_Updater/WP_CLI/CLI_Integration.php +++ b/src/GitHub_Updater/WP_CLI/CLI_Integration.php @@ -205,8 +205,8 @@ public function install_theme( $args, $assoc_args ) { /** * Process WP-CLI config data. * - * @param string $uri - * @param array $assoc_args + * @param string $uri URI to process. + * @param array $assoc_args Args to process. * * @return array $cli_config */ @@ -243,8 +243,8 @@ private function process_args( $uri, $assoc_args ) { /** * Process branch setting for WP-CLI. * - * @param array $cli_config - * @param string $slug + * @param array $cli_config Config args. + * @param string $slug Repository slug. */ private function process_branch( $cli_config, $slug ) { $branch_data['github_updater_branch'] = $cli_config['branch']; From 88875f1df3ddf9f435540610121d4efee2ecd5f5 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Tue, 1 Jan 2019 12:39:13 -0800 Subject: [PATCH 07/18] update mu loader --- mu/ghu-loader.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mu/ghu-loader.php b/mu/ghu-loader.php index 547d5fd47..3d163d1aa 100644 --- a/mu/ghu-loader.php +++ b/mu/ghu-loader.php @@ -12,9 +12,9 @@ * Plugin Name: GitHub Updater MU loader * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to load GitHub Updater as a must-use plugin. Disables normal plugin activation and deletion. - * Version: 1.5.2 + * Version: 1.5.3 * Author: Andy Fragen - * License: GNU General Public License v2 + * License: GPL-2.0+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html * GitHub Plugin URI: https://github.com/afragen/github-updater/tree/develop/mu */ @@ -27,7 +27,7 @@ /* * Load normal plugin. */ -if ( ! class_exists( 'Fragen\\GitHub_Updater\\Init' ) ) { +if ( ! class_exists( 'Fragen\\GitHub_Updater\\Bootstrap' ) ) { $ghu_plugin_file = 'github-updater/github-updater.php'; require trailingslashit( WP_PLUGIN_DIR ) . $ghu_plugin_file; } @@ -37,7 +37,7 @@ * * @param string $plugin Plugin slug. */ -function ghu_deactivate( $plugin, $network_wide ) { +function ghu_deactivate( $plugin ) { $ghu_plugin_file = 'github-updater/github-updater.php'; if ( $ghu_plugin_file === $plugin ) { deactivate_plugins( $ghu_plugin_file ); @@ -68,7 +68,7 @@ function ghu_mu_plugin_active( $actions ) { /* * Deactivate normal plugin as it's loaded as mu-plugin. */ -add_action( 'activated_plugin', 'ghu_deactivate', 10, 2 ); +add_action( 'activated_plugin', 'ghu_deactivate', 10, 1 ); /* * Remove links and checkbox from Plugins page so user can't delete main plugin. From 2be944a0512ae8c044e9a33029e066d4664ae190 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Wed, 2 Jan 2019 10:55:17 -0800 Subject: [PATCH 08/18] create/update POT with `composer update` --- composer.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/composer.json b/composer.json index f2d01ff18..dbe1d9a08 100644 --- a/composer.json +++ b/composer.json @@ -39,5 +39,10 @@ "psr-4": { "Fragen\\GitHub_Updater\\": "src/GitHub_Updater/" } + }, + "scripts": { + "post-update-cmd": [ + "wp i18n make-pot . languages/github-updater.pot" + ] } } From 5a91a0cd907996e6c576663bc9639c1e175d8717 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Thu, 3 Jan 2019 11:16:23 -0800 Subject: [PATCH 09/18] update docblocks --- src/GitHub_Updater/API.php | 23 ++++++++--------- src/GitHub_Updater/API/API_Interface.php | 6 ++--- src/GitHub_Updater/API/Bitbucket_API.php | 4 +-- .../API/Bitbucket_Server_API.php | 4 +-- src/GitHub_Updater/API/GitHub_API.php | 14 +++++------ src/GitHub_Updater/API/GitLab_API.php | 4 +-- src/GitHub_Updater/API/Gitea_API.php | 12 ++++----- src/GitHub_Updater/API/Zipfile_API.php | 6 ++--- src/GitHub_Updater/Base.php | 25 +++++++++---------- src/GitHub_Updater/Branch.php | 2 +- src/GitHub_Updater/Install.php | 12 ++++----- src/GitHub_Updater/Messages.php | 2 +- src/GitHub_Updater/Plugin.php | 16 ++++++------ src/GitHub_Updater/Remote_Management.php | 14 +++++------ src/GitHub_Updater/Rest_Update.php | 15 +++++------ src/GitHub_Updater/Rest_Upgrader_Skin.php | 18 ++++++++++--- src/GitHub_Updater/Settings.php | 8 +++--- src/GitHub_Updater/Theme.php | 24 ++++++++---------- src/GitHub_Updater/Traits/GHU_Trait.php | 2 +- 19 files changed, 107 insertions(+), 104 deletions(-) diff --git a/src/GitHub_Updater/API.php b/src/GitHub_Updater/API.php index 3cdd9ecf1..24cfaf0a9 100644 --- a/src/GitHub_Updater/API.php +++ b/src/GitHub_Updater/API.php @@ -50,7 +50,7 @@ class API { /** * Holds extra headers. * - * @var + * @var array $extra_headers */ protected static $extra_headers; @@ -149,9 +149,8 @@ function ( $auth_required ) use ( $git ) { /** * Add data to the setting_field in Settings. * - * @param array $fields - * @param array $repo - * @param string $type + * @param array $fields + * @param array $repo * * @return array */ @@ -217,8 +216,8 @@ function ( $type ) use ( $git ) { /** * Take remote file contents as string and parse headers. * - * @param $contents - * @param $type + * @param string $contents + * @param string $type plugin|theme. * * @return array */ @@ -576,8 +575,8 @@ protected function add_access_token_endpoint( $git, $endpoint ) { /** * Test to exit early if no update available, saves API calls. * - * @param $response array|bool - * @param $branch bool + * @param array|bool $response + * @param bool $branch * * @return bool */ @@ -656,8 +655,8 @@ protected function sort_tags( $parsed_tags ) { /** * Get local file info if no update available. Save API calls. * - * @param $repo - * @param $file + * @param \stdClass $repo Repo data. + * @param string $file * * @return null|string */ @@ -680,7 +679,7 @@ protected function get_local_info( $repo, $file ) { /** * Set repo object file info. * - * @param $response + * @param array $response Repo data. */ protected function set_file_info( $response ) { $this->type->transient = $response; @@ -706,7 +705,7 @@ protected function add_meta_repo_object() { * Create some sort of rating from 0 to 100 for use in star ratings. * I'm really just making this up, more based upon popularity. * - * @param $repo_meta + * @param array $repo_meta * * @return integer */ diff --git a/src/GitHub_Updater/API/API_Interface.php b/src/GitHub_Updater/API/API_Interface.php index 99055f50d..e991eb7b9 100644 --- a/src/GitHub_Updater/API/API_Interface.php +++ b/src/GitHub_Updater/API/API_Interface.php @@ -154,15 +154,15 @@ public function add_settings( $auth_required); /** * Add remote install settings fields. * - * @param $type + * @param string $type plugin|theme. */ public function add_install_settings_fields( $type); /** * Add remote install feature, create endpoint. * - * @param $headers - * @param $install + * @param array $headers + * @param array $install * * @return mixed $install */ diff --git a/src/GitHub_Updater/API/Bitbucket_API.php b/src/GitHub_Updater/API/Bitbucket_API.php index 31e5bb5a0..9bd2f6755 100644 --- a/src/GitHub_Updater/API/Bitbucket_API.php +++ b/src/GitHub_Updater/API/Bitbucket_API.php @@ -287,8 +287,8 @@ public function parse_changelog_response( $response ) { /** * Parse tags and create download links. * - * @param $response - * @param $repo_type + * @param \stdClass|array $response Response from API call. + * @param string $repo_type * * @return array */ diff --git a/src/GitHub_Updater/API/Bitbucket_Server_API.php b/src/GitHub_Updater/API/Bitbucket_Server_API.php index 4b9cce767..2802ab09e 100644 --- a/src/GitHub_Updater/API/Bitbucket_Server_API.php +++ b/src/GitHub_Updater/API/Bitbucket_Server_API.php @@ -317,7 +317,7 @@ function ( $e ) use ( &$arr ) { * * @param string $response Response from API call. * - * @return array $arr Array of changes in base64. + * @return void */ public function parse_changelog_response( $response ) { } @@ -327,7 +327,7 @@ public function parse_changelog_response( $response ) { * * @param string|\stdClass $response * - * @return \stdClass $response + * @return void */ protected function parse_readme_response( $response ) { } diff --git a/src/GitHub_Updater/API/GitHub_API.php b/src/GitHub_Updater/API/GitHub_API.php index 96e67c78f..7271e5fa4 100644 --- a/src/GitHub_Updater/API/GitHub_API.php +++ b/src/GitHub_Updater/API/GitHub_API.php @@ -202,8 +202,8 @@ public function add_endpoints( $git, $endpoint ) { /** * Calculate and store time until rate limit reset. * - * @param $response - * @param $repo + * @param array $response HTTP headers. + * @param string $repo Repo name. */ public static function ratelimit_reset( $response, $repo ) { if ( isset( $response['headers']['x-ratelimit-reset'] ) ) { @@ -299,8 +299,8 @@ function ( $e ) use ( &$arr ) { /** * Parse tags and create download links. * - * @param $response - * @param $repo_type + * @param \stdClass|array $response Response from API call. + * @param array $repo_type * * @return array */ @@ -413,7 +413,7 @@ public function print_section_github_access_token() { /** * Add remote install settings fields. * - * @param $type + * @param string $type plugin|theme. */ public function add_install_settings_fields( $type ) { add_settings_field( @@ -455,8 +455,8 @@ public function github_access_token() { /** * Add remote install feature, create endpoint. * - * @param $headers - * @param $install + * @param array $headers + * @param array $install * * @return mixed */ diff --git a/src/GitHub_Updater/API/GitLab_API.php b/src/GitHub_Updater/API/GitLab_API.php index 023c2cde7..bc917ce42 100644 --- a/src/GitHub_Updater/API/GitLab_API.php +++ b/src/GitHub_Updater/API/GitLab_API.php @@ -370,8 +370,8 @@ function ( $e ) use ( &$arr ) { /** * Parse tags and create download links. * - * @param $response - * @param $repo_type + * @param \stdClass|array $response Response from API call. + * @param array $repo_type * * @return array */ diff --git a/src/GitHub_Updater/API/Gitea_API.php b/src/GitHub_Updater/API/Gitea_API.php index 43d914729..d9ab8a0d8 100644 --- a/src/GitHub_Updater/API/Gitea_API.php +++ b/src/GitHub_Updater/API/Gitea_API.php @@ -100,7 +100,7 @@ public function get_remote_tag() { * * @param string $changes Changelog filename. * - * @return bool + * @return mixed */ public function get_remote_changes( $changes ) { return $this->get_remote_api_changes( 'gitea', $changes, "/repos/:owner/:repo/raw/:branch/{$changes}" ); @@ -109,7 +109,7 @@ public function get_remote_changes( $changes ) { /** * Read and parse remote readme.txt. * - * @return bool + * @return mixed */ public function get_remote_readme() { return $this->get_remote_api_readme( 'gitea', '/repos/:owner/:repo/raw/:branch/readme.txt' ); @@ -118,7 +118,7 @@ public function get_remote_readme() { /** * Read the repository meta from API. * - * @return bool + * @return mixed */ public function get_repo_meta() { return $this->get_remote_api_repo_meta( 'gitea', '/repos/:owner/:repo' ); @@ -127,7 +127,7 @@ public function get_repo_meta() { /** * Create array of branches and download links as array. * - * @return bool + * @return mixed */ public function get_remote_branches() { return $this->get_remote_api_branches( 'gitea', '/repos/:owner/:repo/branches' ); @@ -269,8 +269,8 @@ public function parse_changelog_response( $response ) { /** * Parse tags and create download links. * - * @param $response - * @param $repo_type + * @param \stdClass|array $response Response from API call. + * @param array $repo_type * * @return array */ diff --git a/src/GitHub_Updater/API/Zipfile_API.php b/src/GitHub_Updater/API/Zipfile_API.php index 5314d891f..67b34f353 100644 --- a/src/GitHub_Updater/API/Zipfile_API.php +++ b/src/GitHub_Updater/API/Zipfile_API.php @@ -29,7 +29,7 @@ class Zipfile_API { /** * Add remote install settings fields. * - * @param $type + * @param string $type plugin|theme. */ public function add_install_settings_fields( $type ) { add_settings_field( @@ -59,8 +59,8 @@ public function zipfile_slug() { /** * Add remote install feature, create endpoint. * - * @param $headers - * @param $install + * @param array $headers + * @param array $install * * @return mixed $install */ diff --git a/src/GitHub_Updater/Base.php b/src/GitHub_Updater/Base.php index 29adc7f73..17a969db0 100644 --- a/src/GitHub_Updater/Base.php +++ b/src/GitHub_Updater/Base.php @@ -121,7 +121,6 @@ protected function set_installed_apis() { if ( file_exists( __DIR__ . '/API/Zipfile_API.php' ) ) { self::$installed_apis['zipfile_api'] = true; self::$git_servers['zipfile'] = 'Zipfile'; - } else { self::$installed_apis['zipfile_api'] = false; } @@ -244,7 +243,7 @@ public function set_options_filter() { /** * Add extra headers to get_plugins() or wp_get_themes(). * - * @param $extra_headers + * @param array $extra_headers * * @return array */ @@ -291,7 +290,7 @@ public function run_cron_batch( array $batches ) { * Get remote repo meta data for plugins or themes. * Calls remote APIs for data. * - * @param $repo + * @param \stdClass $repo * * @return bool */ @@ -337,7 +336,7 @@ public function get_remote_repo_meta( $repo ) { /** * Set default values for plugin/theme. * - * @param $type + * @param string $type */ protected function set_defaults( $type ) { if ( ! isset( self::$options['branch_switch'] ) ) { @@ -404,7 +403,7 @@ protected function get_changelog_filename( $repo ) { /** * Remove hooks after use. * - * @param object $repo_api + * @param \stdClass $repo_api */ public function remove_hooks( $repo_api ) { remove_filter( 'extra_theme_headers', [ $this, 'add_headers' ] ); @@ -440,8 +439,8 @@ public function is_duplicate_wp_cron_event( $event ) { /** * Check to see if wp-cron event is overdue by 24 hours and report error message. * - * @param $cron - * @param $timestamp + * @param array $cron + * @param int $timestamp */ public function is_cron_overdue( $cron, $timestamp ) { $overdue = ( ( time() - $timestamp ) / HOUR_IN_SECONDS ) > 24; @@ -688,7 +687,7 @@ protected function set_rollback_transient( $type, $repo, $set_transient = false * * @param string $download_link Download URL. * @param /stdClass $repo - * @param string $this->tag Branch or tag for rollback. + * @param string $this->tag Branch or tag for rollback. */ $download_link = apply_filters( 'github_updater_set_rollback_package', $download_link, $repo, $this->tag ); @@ -802,8 +801,8 @@ function ( $e ) { /** * Create repo parts. * - * @param $repo - * @param $type + * @param string $repo + * @param string $type plugin|theme. * * @return mixed */ @@ -840,9 +839,9 @@ protected function get_repo_parts( $repo, $type ) { /** * Return correct update row opening and closing tags for Shiny Updates. * - * @param $repo_name - * @param $type - * @param bool $branch_switcher + * @param string $repo_name + * @param string $type plugin|theme. + * @param bool $branch_switcher * * @return array */ diff --git a/src/GitHub_Updater/Branch.php b/src/GitHub_Updater/Branch.php index cef4e75c3..ba737e27e 100644 --- a/src/GitHub_Updater/Branch.php +++ b/src/GitHub_Updater/Branch.php @@ -58,7 +58,7 @@ public function __construct( $cache = null ) { * * @access public * - * @param $repo + * @param \stdClass $repo * * @return mixed */ diff --git a/src/GitHub_Updater/Install.php b/src/GitHub_Updater/Install.php index 4346a80b5..49d33149a 100644 --- a/src/GitHub_Updater/Install.php +++ b/src/GitHub_Updater/Install.php @@ -501,9 +501,9 @@ public function install_api() { /** * Remove activation links after plugin installation as no method to get $plugin_file. * - * @param $install_actions - * @param $api - * @param $plugin_file + * @param array $install_actions + * @param mixed $api + * @param string $plugin_file * * @return mixed */ @@ -516,9 +516,9 @@ public function install_plugin_complete_actions( $install_actions, $api, $plugin /** * Fix activation links after theme installation, no method to get proper theme name. * - * @param $install_actions - * @param $api - * @param $theme_info + * @param array $install_actions + * @param mixed $api + * @param mixed $theme_info * * @return mixed */ diff --git a/src/GitHub_Updater/Messages.php b/src/GitHub_Updater/Messages.php index 2ed8aa61b..cb5a66f60 100644 --- a/src/GitHub_Updater/Messages.php +++ b/src/GitHub_Updater/Messages.php @@ -35,7 +35,7 @@ class Messages { /** * Display message when API returns other than 200 or 404. * - * @param string + * @param string $type * * @return bool */ diff --git a/src/GitHub_Updater/Plugin.php b/src/GitHub_Updater/Plugin.php index ea92ab062..c9e0e1280 100644 --- a/src/GitHub_Updater/Plugin.php +++ b/src/GitHub_Updater/Plugin.php @@ -235,8 +235,8 @@ public function load_pre_filters() { /** * Add branch switch row to plugins page. * - * @param $plugin_file - * @param $plugin_data + * @param string $plugin_file + * @param \stdClass $plugin_data * * @return bool */ @@ -285,8 +285,8 @@ public function plugin_branch_switcher( $plugin_file, $plugin_data ) { /** * Add 'View details' link to plugins page. * - * @param $links - * @param $file + * @param array $links + * @param string $file * * @return array $links */ @@ -334,9 +334,9 @@ public function plugin_row_meta( $links, $file ) { /** * Put changelog in plugins_api, return WP.org data as appropriate * - * @param $false - * @param $action - * @param $response + * @param bool $false + * @param string $action + * @param \stdClass $response * * @return mixed */ @@ -385,7 +385,7 @@ public function plugins_api( $false, $action, $response ) { /** * Hook into pre_set_site_transient_update_plugins to update from GitHub. * - * @param $transient + * @param \stdClass $transient * * @return mixed */ diff --git a/src/GitHub_Updater/Remote_Management.php b/src/GitHub_Updater/Remote_Management.php index 48458b8a8..d4c855adf 100644 --- a/src/GitHub_Updater/Remote_Management.php +++ b/src/GitHub_Updater/Remote_Management.php @@ -21,14 +21,14 @@ class Remote_Management { /** * Holds the values for remote management settings. * - * @var mixed + * @var array $option_remote */ public static $options_remote; /** * Supported remote management services. * - * @var array + * @var array $remote_management */ public static $remote_management = [ 'ithemes_sync' => 'iThemes Sync', @@ -40,7 +40,7 @@ class Remote_Management { /** * Holds the value for the Remote Management API key. * - * @var + * @var string $api_key */ private static $api_key; @@ -110,7 +110,7 @@ public function extra_admin_pages( $admin_pages ) { * @uses 'github_updater_update_settings' action hook * @uses 'github_updater_save_redirect' filter hook * - * @param $post_data + * @param array $post_data $_POST data. */ public function save_settings( $post_data ) { if ( isset( $post_data['option_page'] ) && @@ -157,8 +157,8 @@ function ( $tab, $action ) { * * @uses 'github_updater_add_admin_page' action hook * - * @param $tab - * @param $action + * @param string $tab Tab name. + * @param string $action Form action. */ public function add_admin_page( $tab, $action ) { if ( 'github_updater_remote_management' === $tab ) { @@ -241,7 +241,7 @@ public function print_section_remote_management() { * Get the settings option array and print one of its values. * For remote management settings. * - * @param $args + * @param array $args Checkbox args. * * @return bool|void */ diff --git a/src/GitHub_Updater/Rest_Update.php b/src/GitHub_Updater/Rest_Update.php index e724d0714..4575c302d 100644 --- a/src/GitHub_Updater/Rest_Update.php +++ b/src/GitHub_Updater/Rest_Update.php @@ -2,8 +2,7 @@ /** * GitHub Updater * - * @author Andy Fragen - * @author Mikael Lindqvist + * @author Andy Fragen, Mikael Lindqvist * @license GPL-2.0+ * @link https://github.com/afragen/github-updater * @package github-updater @@ -33,7 +32,7 @@ class Rest_Update extends Base { /** * Holds REST Upgrader Skin. * - * @var \Fragen\GitHub_Updater\Rest_Upgrader_Skin + * @var Rest_Upgrader_Skin $upgrader_skin */ protected $upgrader_skin; @@ -52,8 +51,7 @@ public function __construct() { * @param string $plugin_slug * @param string $tag * - * @throws \Exception - * @throws \UnexpectedValueException + * @throws \UnexpectedValueException Plugin not found or not updatable. */ public function update_plugin( $plugin_slug, $tag = 'master' ) { $plugin = null; @@ -111,8 +109,7 @@ function ( $current ) use ( $plugin, $update ) { * @param string $theme_slug * @param string $tag * - * @throws \Exception - * @throws \UnexpectedValueException + * @throws \UnexpectedValueException Theme not found or not updatable. */ public function update_theme( $theme_slug, $tag = 'master' ) { $theme = null; @@ -173,7 +170,7 @@ public function get_messages() { * webhook matches the branch specified by the url, use the latest * update available as specified in the webhook payload. * - * @throws \UnexpectedValueException + * @throws \UnexpectedValueException Under multiple bad or missing params. */ public function process_request() { $start = microtime( true ); @@ -303,7 +300,7 @@ private function log_exit( $response, $code ) { * @since 8.6.0 * * @param array $response - * @param int $code HTTP response. + * @param int $code HTTP response. */ do_action( 'github_updater_post_rest_process_request', $response, $code ); diff --git a/src/GitHub_Updater/Rest_Upgrader_Skin.php b/src/GitHub_Updater/Rest_Upgrader_Skin.php index 6d6e7fd96..681e9772b 100644 --- a/src/GitHub_Updater/Rest_Upgrader_Skin.php +++ b/src/GitHub_Updater/Rest_Upgrader_Skin.php @@ -2,8 +2,7 @@ /** * GitHub Updater * - * @author Andy Fragen - * @author Mikael Lindqvist + * @author Andy Fragen, Mikael Lindqvist * @license GPL-2.0+ * @link https://github.com/afragen/github-updater * @package github-updater @@ -27,7 +26,18 @@ * processing, rather than printing them out. */ class Rest_Upgrader_Skin extends \WP_Upgrader_Skin { + /** + * Holds messages. + * + * @var array $messages + */ public $messages = []; + + /** + * Boolean if errors are present. + * + * @var bool $error + */ public $error; /** @@ -60,7 +70,7 @@ public function feedback( $string ) { /** * Set the error flag to true, then let the base class handle the rest. * - * @param $errors + * @param mixed $errors */ public function error( $errors ) { $this->error = true; @@ -70,7 +80,7 @@ public function error( $errors ) { /** * Do nothing. * - * @param $type + * @param mixed $type */ protected function decrement_update_count( $type ) { } diff --git a/src/GitHub_Updater/Settings.php b/src/GitHub_Updater/Settings.php index 07a1266bf..31124064b 100644 --- a/src/GitHub_Updater/Settings.php +++ b/src/GitHub_Updater/Settings.php @@ -488,7 +488,7 @@ function ( $e ) use ( &$ghu_unset_keys, $ghu_tokens, &$reset_keys ) { /** * Check to see if it's an enterprise or private repo and set variables. * - * @param $token + * @param \stdClass $token Repo data. */ private function set_auth_required( $token ) { // Set booleans for Enterprise repos. @@ -567,7 +567,7 @@ private function display_dot_org_overrides() { /** * Get the settings option array and print one of its values. * - * @param $args + * @param array $args */ public function token_callback_text( $args ) { $name = isset( static::$options[ $args['id'] ] ) ? esc_attr( static::$options[ $args['id'] ] ) : ''; @@ -582,7 +582,7 @@ public function token_callback_text( $args ) { /** * Get the settings option array and print one of its values. * - * @param $args + * @param array $args */ public function token_callback_checkbox( $args ) { $checked = isset( static::$options[ $args['id'] ] ) ? static::$options[ $args['id'] ] : null; @@ -710,7 +710,7 @@ private function refresh_transients() { * * @link http://codex.wordpress.org/Plugin_API/Filter_Reference/plugin_action_links_(plugin_file_name) * - * @param $links + * @param array $links * * @return array */ diff --git a/src/GitHub_Updater/Theme.php b/src/GitHub_Updater/Theme.php index 1864da36c..95832e5f3 100644 --- a/src/GitHub_Updater/Theme.php +++ b/src/GitHub_Updater/Theme.php @@ -236,9 +236,9 @@ public function load_pre_filters() { /** * Put changelog in themes_api, return WP.org data as appropriate. * - * @param $false - * @param $action - * @param $response + * @param bool $false + * @param string $action + * @param \stdClass $response * * @return mixed */ @@ -282,8 +282,8 @@ public function themes_api( $false, $action, $response ) { * Add custom theme update row, from /wp-admin/includes/update.php * Display update details or rollback links for multisite installation. * - * @param $theme_key - * @param $theme + * @param string $theme_key + * @param array $theme * * @author Seth Carstens */ @@ -321,9 +321,7 @@ public function wp_theme_update_row( $theme_key, $theme ) { ); $enclosure = $this->update_row_enclosure( $theme_key, 'theme' ); - /* - * Update transient if necessary. - */ + // Update transient if necessary. if ( empty( $current->response ) && empty( $current->up_to_date ) ) { $this->pre_set_site_transient_update_themes( $current ); } @@ -374,8 +372,8 @@ public function wp_theme_update_row( $theme_key, $theme ) { /** * Create branch switcher row for multisite installation. * - * @param $theme_key - * @param $theme + * @param string $theme_key + * @param array $theme * * @return bool */ @@ -420,8 +418,8 @@ public function multisite_branch_switcher( $theme_key, $theme ) { * * @author @grappler * - * @param $theme_key - * @param $theme + * @param string $theme_key + * @param array $theme */ public function remove_after_theme_row( $theme_key, $theme ) { $themes = $this->get_theme_configs(); @@ -465,7 +463,7 @@ public function remove_after_theme_row( $theme_key, $theme ) { * * @author Seth Carstens * - * @param $prepared_themes + * @param array $prepared_themes * * @return mixed */ diff --git a/src/GitHub_Updater/Traits/GHU_Trait.php b/src/GitHub_Updater/Traits/GHU_Trait.php index ddb5cba97..022f922a3 100644 --- a/src/GitHub_Updater/Traits/GHU_Trait.php +++ b/src/GitHub_Updater/Traits/GHU_Trait.php @@ -149,7 +149,7 @@ public function get_error_codes() { /** * Function to check if plugin or theme object is able to be updated. * - * @param $type + * @param \stdClass $type * * @return bool */ From f76d117c83ae89b25a1894f49338e026243122db Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Thu, 3 Jan 2019 14:43:42 -0800 Subject: [PATCH 10/18] bring plugin run out of class file add namespace linting --- github-updater.php | 8 ++++---- src/GitHub_Updater/Bootstrap.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/github-updater.php b/github-updater.php index 6bd7e54c7..4773f6c7c 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0.1 + * Version: 8.6.0.2 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -25,6 +25,8 @@ * Requires PHP: 5.6 */ +namespace Fragen\GitHub_Updater; + /* * Exit if called directly. * PHP version check and exit. @@ -46,8 +48,6 @@ return false; } -define( 'GITHUB_UPDATER_FILE', __FILE__ ); -define( 'GITHUB_UPDATER_DIR', __DIR__ ); - // Setup plugin loading. require_once __DIR__ . '/src/GitHub_Updater/Bootstrap.php'; +( new Bootstrap() )->run( __FILE__, __DIR__ ); diff --git a/src/GitHub_Updater/Bootstrap.php b/src/GitHub_Updater/Bootstrap.php index 36803d233..c06dc1e02 100644 --- a/src/GitHub_Updater/Bootstrap.php +++ b/src/GitHub_Updater/Bootstrap.php @@ -17,8 +17,6 @@ die; } -( new Bootstrap() )->run( GITHUB_UPDATER_FILE, GITHUB_UPDATER_DIR ); - /** * Class Bootstrap */ @@ -39,6 +37,8 @@ function() { } ); + define( 'GITHUB_UPDATER_DIR', $dir ); + // Load Autoloader. require_once $dir . '/vendor/autoload.php'; From c7c2c1d8b8f36f4a73b3f0bb37d137e3e3ffbb5d Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 4 Jan 2019 08:59:13 -0800 Subject: [PATCH 11/18] move parameter pass to class constructor --- github-updater.php | 2 +- src/GitHub_Updater/Bootstrap.php | 34 ++++++++++++++++++++++++++------ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/github-updater.php b/github-updater.php index 4773f6c7c..770e5918d 100644 --- a/github-updater.php +++ b/github-updater.php @@ -50,4 +50,4 @@ // Setup plugin loading. require_once __DIR__ . '/src/GitHub_Updater/Bootstrap.php'; -( new Bootstrap() )->run( __FILE__, __DIR__ ); +( new Bootstrap( __FILE__ ) )->run(); diff --git a/src/GitHub_Updater/Bootstrap.php b/src/GitHub_Updater/Bootstrap.php index c06dc1e02..34fd0458a 100644 --- a/src/GitHub_Updater/Bootstrap.php +++ b/src/GitHub_Updater/Bootstrap.php @@ -21,15 +21,37 @@ * Class Bootstrap */ class Bootstrap { + /** + * Holds main plugin file. + * + * @var $file + */ + protected $file; + + /** + * Holds main plugin directory. + * + * @var $dir + */ + protected $dir; + + /** + * Constructor. + * + * @param string $file Main plugin file. + * @return void + */ + public function __construct( $file ) { + $this->file = $file; + $this->dir = dirname( $file ); + } /** * Run the bootstrap. * - * @param string $file Path to main plugin file. - * @param string $dir Path to main plugin directory. * @return void */ - public function run( $file, $dir ) { + public function run() { add_action( 'init', function() { @@ -37,12 +59,12 @@ function() { } ); - define( 'GITHUB_UPDATER_DIR', $dir ); + define( 'GITHUB_UPDATER_DIR', $this->dir ); // Load Autoloader. - require_once $dir . '/vendor/autoload.php'; + require_once $this->dir . '/vendor/autoload.php'; - register_activation_hook( $file, array( new Init(), 'rename_on_activation' ) ); + register_activation_hook( $this->file, array( new Init(), 'rename_on_activation' ) ); ( new Init() )->run(); /** From f6e2d4b49bd24356cf4ac0c8e85f9504ecc50ec0 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 4 Jan 2019 08:59:21 -0800 Subject: [PATCH 12/18] changes, bump --- CHANGES.md | 1 + github-updater.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index f36b3391b..9ad97ba5f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ #### [unreleased] * remove `tmp-readme.txt` after parsing, fixes [#754](https://github.com/afragen/github-updater/issues/754) * directly call `wp_cron()` after refreshing cache +* update POT via `composer.json` and wp-cli #### 8.6.0 / 2018-12-28 🎂 * add action hook `github_updater_post_rest_process_request` for @Raruto diff --git a/github-updater.php b/github-updater.php index 770e5918d..59dc38a50 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0.2 + * Version: 8.6.0.3 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html From a7dff3bd81354389fb01e9eab262df772e526544 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sat, 5 Jan 2019 08:30:24 -0800 Subject: [PATCH 13/18] add wiki link to text Fixes https://github.com/afragen/github-updater/issues/755 --- src/GitHub_Updater/Remote_Management.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/GitHub_Updater/Remote_Management.php b/src/GitHub_Updater/Remote_Management.php index d4c855adf..5d6de95d3 100644 --- a/src/GitHub_Updater/Remote_Management.php +++ b/src/GitHub_Updater/Remote_Management.php @@ -228,7 +228,15 @@ public function print_section_remote_management() { ); ?>

    - + wiki for complete list of attributes. RESTful endpoints begin at:', 'github-updater' ) + ), + 'https://github.com/afragen/github-updater/wiki/Remote-Management---RESTful-Endpoints' + ); + ?>

    From ba81e8483d14d0b2593036b0c2434a19873ab83d Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sat, 5 Jan 2019 12:06:13 -0800 Subject: [PATCH 14/18] move get_file_headers() to GHU_Trait --- src/GitHub_Updater/API.php | 73 ----------------------- src/GitHub_Updater/Traits/GHU_Trait.php | 77 +++++++++++++++++++++++++ 2 files changed, 77 insertions(+), 73 deletions(-) diff --git a/src/GitHub_Updater/API.php b/src/GitHub_Updater/API.php index 24cfaf0a9..4a6902f80 100644 --- a/src/GitHub_Updater/API.php +++ b/src/GitHub_Updater/API.php @@ -213,79 +213,6 @@ function ( $type ) use ( $git ) { ); } - /** - * Take remote file contents as string and parse headers. - * - * @param string $contents - * @param string $type plugin|theme. - * - * @return array - */ - public function get_file_headers( $contents, $type ) { - $all_headers = []; - $default_plugin_headers = [ - 'Name' => 'Plugin Name', - 'PluginURI' => 'Plugin URI', - 'Version' => 'Version', - 'Description' => 'Description', - 'Author' => 'Author', - 'AuthorURI' => 'Author URI', - 'TextDomain' => 'Text Domain', - 'DomainPath' => 'Domain Path', - 'Network' => 'Network', - ]; - - $default_theme_headers = [ - 'Name' => 'Theme Name', - 'ThemeURI' => 'Theme URI', - 'Description' => 'Description', - 'Author' => 'Author', - 'AuthorURI' => 'Author URI', - 'Version' => 'Version', - 'Template' => 'Template', - 'Status' => 'Status', - 'Tags' => 'Tags', - 'TextDomain' => 'Text Domain', - 'DomainPath' => 'Domain Path', - ]; - - if ( 'plugin' === $type ) { - $all_headers = $default_plugin_headers; - } - if ( 'theme' === $type ) { - $all_headers = $default_theme_headers; - } - - /* - * Make sure we catch CR-only line endings. - */ - $file_data = str_replace( "\r", "\n", $contents ); - - /* - * Merge extra headers and default headers. - */ - $all_headers = array_merge( self::$extra_headers, $all_headers ); - $all_headers = array_unique( $all_headers ); - - foreach ( $all_headers as $field => $regex ) { - if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { - $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); - } else { - $all_headers[ $field ] = ''; - } - } - - // Reduce array to only headers with data. - $all_headers = array_filter( - $all_headers, - function ( $e ) { - return ! empty( $e ); - } - ); - - return $all_headers; - } - /** * Call the API and return a json decoded body. * Create error messages. diff --git a/src/GitHub_Updater/Traits/GHU_Trait.php b/src/GitHub_Updater/Traits/GHU_Trait.php index 022f922a3..0d38daf2a 100644 --- a/src/GitHub_Updater/Traits/GHU_Trait.php +++ b/src/GitHub_Updater/Traits/GHU_Trait.php @@ -319,4 +319,81 @@ protected function parse_header_uri( $repo_header ) { return $header; } + + /** + * Take remote file contents as string or array and parse and reduce headers. + * + * @param string|array $contents File contents or array of file headers. + * @param string $type plugin|theme. + * + * @return array $all_headers Reduced array of all headers. + */ + public function get_file_headers( $contents, $type ) { + $all_headers = []; + $default_plugin_headers = [ + 'Name' => 'Plugin Name', + 'PluginURI' => 'Plugin URI', + 'Version' => 'Version', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + 'Network' => 'Network', + ]; + + $default_theme_headers = [ + 'Name' => 'Theme Name', + 'ThemeURI' => 'Theme URI', + 'Description' => 'Description', + 'Author' => 'Author', + 'AuthorURI' => 'Author URI', + 'Version' => 'Version', + 'Template' => 'Template', + 'Status' => 'Status', + 'Tags' => 'Tags', + 'TextDomain' => 'Text Domain', + 'DomainPath' => 'Domain Path', + ]; + + if ( 'plugin' === $type ) { + $all_headers = $default_plugin_headers; + } + if ( 'theme' === $type ) { + $all_headers = $default_theme_headers; + } + + /* + * Merge extra headers and default headers. + */ + $all_headers = array_merge( self::$extra_headers, $all_headers ); + $all_headers = array_unique( $all_headers ); + + /* + * Make sure we catch CR-only line endings. + */ + if ( is_string( $contents ) ) { + $file_data = str_replace( "\r", "\n", $contents ); + + foreach ( $all_headers as $field => $regex ) { + if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { + $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); + } else { + $all_headers[ $field ] = ''; + } + } + } + + $all_headers = is_array( $contents ) ? $contents : $all_headers; + + // Reduce array to only headers with data. + $all_headers = array_filter( + $all_headers, + function ( $e ) { + return ! empty( $e ); + } + ); + + return $all_headers; + } } From fd68361489e21f9e6361e985dfe51ee1a74e1f7a Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sat, 5 Jan 2019 12:06:54 -0800 Subject: [PATCH 15/18] unnecessary test, it's picked up in the test below --- src/GitHub_Updater/Plugin.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/GitHub_Updater/Plugin.php b/src/GitHub_Updater/Plugin.php index c9e0e1280..dbf8072b0 100644 --- a/src/GitHub_Updater/Plugin.php +++ b/src/GitHub_Updater/Plugin.php @@ -95,10 +95,6 @@ protected function get_plugin_meta() { foreach ( (array) static::$extra_headers as $value ) { $header = null; - if ( in_array( $value, [ 'Requires PHP', 'Requires WP', 'Languages' ], true ) ) { - continue; - } - if ( empty( $headers[ $value ] ) || false === stripos( $value, 'Plugin' ) ) { continue; } From 6daa2ea999e82abd27774cd067937e8441339a25 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Sat, 5 Jan 2019 13:01:09 -0800 Subject: [PATCH 16/18] remove spaces from keys --- CHANGES.md | 2 ++ github-updater.php | 2 +- src/GitHub_Updater/Base.php | 30 +++++++++++++++--------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9ad97ba5f..c5cb6c6b6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,8 @@ * remove `tmp-readme.txt` after parsing, fixes [#754](https://github.com/afragen/github-updater/issues/754) * directly call `wp_cron()` after refreshing cache * update POT via `composer.json` and wp-cli +* moved `get_file_headers()` to `trait GHU_Trait` +* cleanup extra header key/value pairs #### 8.6.0 / 2018-12-28 🎂 * add action hook `github_updater_post_rest_process_request` for @Raruto diff --git a/github-updater.php b/github-updater.php index 59dc38a50..57dda4eda 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0.3 + * Version: 8.6.0.4 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/GitHub_Updater/Base.php b/src/GitHub_Updater/Base.php index 17a969db0..283fc4212 100644 --- a/src/GitHub_Updater/Base.php +++ b/src/GitHub_Updater/Base.php @@ -60,8 +60,8 @@ class Base { * @var array */ protected static $extra_repo_headers = [ - 'languages' => 'Languages', - 'ci_job' => 'CI Job', + 'Languages' => 'Languages', + 'CIJob' => 'CI Job', ]; /** @@ -249,22 +249,22 @@ public function set_options_filter() { */ public function add_headers( $extra_headers ) { $ghu_extra_headers = [ - 'Requires WP' => 'Requires WP', - 'Requires PHP' => 'Requires PHP', - 'Release Asset' => 'Release Asset', + 'RequiresWP' => 'Requires WP', + 'RequiresPHP' => 'Requires PHP', + 'ReleaseAsset' => 'Release Asset', ]; $uri_types = [ - 'plugin' => ' Plugin URI', - 'theme' => ' Theme URI', + 'PluginURI' => ' Plugin URI', + 'ThemeURI' => ' Theme URI', ]; foreach ( self::$git_servers as $server ) { - foreach ( $uri_types as $uri_type ) { - $ghu_extra_headers[ $server . $uri_type ] = $server . $uri_type; + foreach ( $uri_types as $uri_key => $uri_value ) { + $ghu_extra_headers[ $server . $uri_key ] = $server . $uri_value; } - foreach ( self::$extra_repo_headers as $header ) { - $ghu_extra_headers[ $server . ' ' . $header ] = $server . ' ' . $header; + foreach ( self::$extra_repo_headers as $header_key => $header_value ) { + $ghu_extra_headers[ $server . $header_key ] = $server . ' ' . $header_value; } } @@ -370,7 +370,7 @@ protected function set_defaults( $type ) { $this->$type->watchers = 0; $this->$type->forks = 0; $this->$type->open_issues = 0; - $this->$type->requires = null; + $this->$type->requires = false; $this->$type->requires_php = false; } @@ -1008,16 +1008,16 @@ protected function parse_extra_headers( $header, $headers, $header_parts, $repo_ ! empty( $headers[ $repo_parts[ $part ] ] ) ) { switch ( $part ) { - case 'languages': + case 'Languages': $header['languages'] = $headers[ $repo_parts[ $part ] ]; break; - case 'ci_job': + case 'CIJob': $header['ci_job'] = $headers[ $repo_parts[ $part ] ]; break; } } } - $header['release_asset'] = ! $header['release_asset'] ? 'true' === $headers['Release Asset'] : $header['release_asset']; + $header['release_asset'] = ! $header['release_asset'] && isset( $headers['Release Asset'] ) ? 'true' === $headers['Release Asset'] : $header['release_asset']; return $header; } From e6c94159f1aa2a2714d329f0d5e98ae2fdc74c78 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 11 Jan 2019 09:17:50 -0800 Subject: [PATCH 17/18] add endpoints to Bitbucket to retrieve more items per page and sort Fixes https://github.com/afragen/github-updater/issues/752 Fixes https://github.com/afragen/github-updater/pull/756 --- CHANGES.md | 1 + github-updater.php | 2 +- src/GitHub_Updater/API.php | 1 + src/GitHub_Updater/API/Bitbucket_API.php | 27 +++++++++++++++++++++++- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index c5cb6c6b6..d7cbe587e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ * update POT via `composer.json` and wp-cli * moved `get_file_headers()` to `trait GHU_Trait` * cleanup extra header key/value pairs +* add endpoint to Bitbucket to get more than default number of tags, branches, or release assets. Fixes [#752](https://github.com/afragen/github-updater/issues/752) thanks @idpaterson #### 8.6.0 / 2018-12-28 🎂 * add action hook `github_updater_post_rest_process_request` for @Raruto diff --git a/github-updater.php b/github-updater.php index 57dda4eda..470ebcafd 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0.4 + * Version: 8.6.0.5 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/src/GitHub_Updater/API.php b/src/GitHub_Updater/API.php index 4a6902f80..61a8dd6a8 100644 --- a/src/GitHub_Updater/API.php +++ b/src/GitHub_Updater/API.php @@ -385,6 +385,7 @@ protected function get_api_url( $endpoint, $download_link = false ) { if ( $download_link && 'release_asset' === self::$method ) { $type['base_download'] = $type['base_uri']; } + $endpoint = $repo_api->add_endpoints( $this, $endpoint ); break; case 'gitea': if ( $download_link ) { diff --git a/src/GitHub_Updater/API/Bitbucket_API.php b/src/GitHub_Updater/API/Bitbucket_API.php index 9bd2f6755..42fee2e27 100644 --- a/src/GitHub_Updater/API/Bitbucket_API.php +++ b/src/GitHub_Updater/API/Bitbucket_API.php @@ -211,7 +211,7 @@ public function construct_download_link( $branch_switch = false ) { } /** - * Added due to interface contract, not used for Bitbucket. + * Create Bitbucket API endpoints. * * @param Bitbucket_API|API $git * @param string $endpoint @@ -219,6 +219,31 @@ public function construct_download_link( $branch_switch = false ) { * @return string|void $endpoint */ public function add_endpoints( $git, $endpoint ) { + switch ( $git::$method ) { + case 'file': + case 'readme': + case 'meta': + case 'changes': + case 'translation': + break; + case 'tags': + case 'branches': + case 'release_asset': + $endpoint = add_query_arg( + [ + 'pagelen' => '100', + 'sort' => '-name', + ], + $endpoint + ); + break; + default: + break; + } + + $endpoint = $this->add_access_token_endpoint( $git, $endpoint ); + + return $endpoint; } /** From c4bc4497ac7381001f56d78b4c51da1cfaa07647 Mon Sep 17 00:00:00 2001 From: Andy Fragen Date: Fri, 11 Jan 2019 09:54:05 -0800 Subject: [PATCH 18/18] release --- CHANGES.md | 2 + README.md | 2 +- composer.lock | 20 ++--- github-updater.php | 2 +- languages/github-updater.pot | 79 ++++++++++--------- readme.txt | 2 +- vendor/afragen/singleton/composer.json | 2 +- .../composer.json | 2 +- vendor/composer/installed.json | 20 ++--- 9 files changed, 67 insertions(+), 64 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index d7cbe587e..c3a36cf7b 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,4 +1,6 @@ #### [unreleased] + +#### 8.6.1 / 2019-01-11 * remove `tmp-readme.txt` after parsing, fixes [#754](https://github.com/afragen/github-updater/issues/754) * directly call `wp_cron()` after refreshing cache * update POT via `composer.json` and wp-cli diff --git a/README.md b/README.md index ad9a7f791..b8ee69677 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ * Tags: plugin, theme, update, updater, github, bitbucket, gitlab, remote install * Requires at least: 4.6 * Requires PHP: 5.6 -* Tested up to: 5.0 +* Tested up to: 5.1 * Stable tag: [master](https://github.com/afragen/github-updater/releases/latest) * Donate link: * License: GPLv2 or later diff --git a/composer.lock b/composer.lock index 741ed31fa..a087ee80d 100644 --- a/composer.lock +++ b/composer.lock @@ -12,16 +12,16 @@ "source": { "type": "git", "url": "https://github.com/afragen/singleton.git", - "reference": "e2baf7c8d070d7a575cd430561ae945463146b5e" + "reference": "75bce9e88abaefdbbf4d12bc02f71079e465326d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/afragen/singleton/zipball/e2baf7c8d070d7a575cd430561ae945463146b5e", - "reference": "e2baf7c8d070d7a575cd430561ae945463146b5e", + "url": "https://api.github.com/repos/afragen/singleton/zipball/75bce9e88abaefdbbf4d12bc02f71079e465326d", + "reference": "75bce9e88abaefdbbf4d12bc02f71079e465326d", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=5.4" }, "type": "library", "autoload": { @@ -46,7 +46,7 @@ "singleton", "wordpress" ], - "time": "2018-11-25T06:11:53+00:00" + "time": "2019-01-05T16:19:38+00:00" }, { "name": "afragen/wordpress-plugin-readme-parser", @@ -54,17 +54,17 @@ "source": { "type": "git", "url": "https://github.com/afragen/wordpress-plugin-readme-parser.git", - "reference": "4de9307c6e56d6d578f012f82f8de84851096422" + "reference": "df96450ef96aafee3db3c86c67cf7f3119519a07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/afragen/wordpress-plugin-readme-parser/zipball/4de9307c6e56d6d578f012f82f8de84851096422", - "reference": "4de9307c6e56d6d578f012f82f8de84851096422", + "url": "https://api.github.com/repos/afragen/wordpress-plugin-readme-parser/zipball/df96450ef96aafee3db3c86c67cf7f3119519a07", + "reference": "df96450ef96aafee3db3c86c67cf7f3119519a07", "shasum": "" }, "require": { "erusev/parsedown": "^1.7", - "php": ">=5.6" + "php": ">=5.4" }, "type": "library", "autoload": { @@ -88,7 +88,7 @@ "readme", "wordpress" ], - "time": "2018-11-25T20:45:52+00:00" + "time": "2019-01-05T16:19:09+00:00" }, { "name": "collizo4sky/persist-admin-notices-dismissal", diff --git a/github-updater.php b/github-updater.php index 470ebcafd..087b8acfe 100644 --- a/github-updater.php +++ b/github-updater.php @@ -12,7 +12,7 @@ * Plugin Name: GitHub Updater * Plugin URI: https://github.com/afragen/github-updater * Description: A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs. It also allows for remote installation of plugins or themes into WordPress. - * Version: 8.6.0.5 + * Version: 8.6.1 * Author: Andy Fragen * License: GNU General Public License v2 * License URI: http://www.gnu.org/licenses/gpl-2.0.html diff --git a/languages/github-updater.pot b/languages/github-updater.pot index 3b875fd78..b993175e1 100644 --- a/languages/github-updater.pot +++ b/languages/github-updater.pot @@ -1,15 +1,15 @@ -# Copyright (C) 2018 Andy Fragen +# Copyright (C) 2019 Andy Fragen # This file is distributed under the same license as the GitHub Updater plugin. msgid "" msgstr "" -"Project-Id-Version: GitHub Updater 8.6.0\n" +"Project-Id-Version: GitHub Updater 8.6.1\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/github-updater\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2018-12-27T23:59:31+00:00\n" +"POT-Creation-Date: 2019-01-11T17:52:58+00:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.1.0\n" "X-Domain: github-updater\n" @@ -33,12 +33,12 @@ msgstr "" msgid "Andy Fragen" msgstr "" -#: mu/ghu-loader.php:66 +#: mu/ghu-loader.php:65 msgid "Activated as mu-plugin" msgstr "" #. translators: 1: minimum PHP version required, 2: Upgrade PHP URL -#: github-updater.php:40 +#: github-updater.php:42 msgid "GitHub Updater cannot run on PHP versions older than %1$s. Learn about upgrading your PHP." msgstr "" @@ -157,65 +157,65 @@ msgstr "" msgid "Installed Plugins and Themes" msgstr "" -#: src/GitHub_Updater/Plugin.php:326 +#: src/GitHub_Updater/Plugin.php:322 msgid "View details" msgstr "" #. translators: %s: theme name -#: src/GitHub_Updater/Theme.php:337 -#: src/GitHub_Updater/Theme.php:533 +#: src/GitHub_Updater/Theme.php:335 +#: src/GitHub_Updater/Theme.php:531 msgid "There is a new version of %s available." msgstr "" #. translators: %s: theme version -#: src/GitHub_Updater/Theme.php:349 +#: src/GitHub_Updater/Theme.php:347 msgid "View version %s details." msgstr "" -#: src/GitHub_Updater/Theme.php:353 +#: src/GitHub_Updater/Theme.php:351 msgid "Automatic update is unavailable for this theme." msgstr "" #. translators: 1: version number, 2: closing anchor tag, 3: update URL -#: src/GitHub_Updater/Theme.php:358 -#: src/GitHub_Updater/Theme.php:543 +#: src/GitHub_Updater/Theme.php:356 +#: src/GitHub_Updater/Theme.php:541 msgid "View version %1$s details%2$s or %3$supdate now%2$s." msgstr "" #. translators: %s: theme name -#: src/GitHub_Updater/Theme.php:363 -#: src/GitHub_Updater/Theme.php:548 +#: src/GitHub_Updater/Theme.php:361 +#: src/GitHub_Updater/Theme.php:546 msgid "Update %s now" msgstr "" #. translators: 1: branch name, 2: jQuery dropdown, 3: closing tag -#: src/GitHub_Updater/Theme.php:585 -#: src/GitHub_Updater/Base.php:896 +#: src/GitHub_Updater/Theme.php:583 +#: src/GitHub_Updater/Base.php:895 msgid "Current branch is `%1$s`, try %2$sanother version%3$s" msgstr "" -#: src/GitHub_Updater/Theme.php:593 +#: src/GitHub_Updater/Theme.php:591 msgid "Choose a Version" msgstr "" -#: src/GitHub_Updater/Theme.php:611 -#: src/GitHub_Updater/Base.php:931 +#: src/GitHub_Updater/Theme.php:609 +#: src/GitHub_Updater/Base.php:930 msgid "No previous tags to rollback to." msgstr "" -#: src/GitHub_Updater/Theme.php:615 +#: src/GitHub_Updater/Theme.php:613 msgid "Install" msgstr "" -#: src/GitHub_Updater/Base.php:449 +#: src/GitHub_Updater/Base.php:448 msgid "There may be a problem with WP-Cron. A GitHub Updater WP-Cron event is overdue." msgstr "" -#: src/GitHub_Updater/Base.php:907 +#: src/GitHub_Updater/Base.php:906 msgid "Switch to branch " msgstr "" -#: src/GitHub_Updater/Base.php:923 +#: src/GitHub_Updater/Base.php:922 msgid "Switch to release " msgstr "" @@ -228,57 +228,58 @@ msgstr "" msgid "Reset RESTful key" msgstr "" -#: src/GitHub_Updater/Remote_Management.php:231 -msgid "Please refer to README for complete list of attributes. RESTful endpoints begin at:" +#. translators: %s: Link to wiki +#: src/GitHub_Updater/Remote_Management.php:235 +msgid "Please refer to the wiki for complete list of attributes. RESTful endpoints begin at:" msgstr "" -#: src/GitHub_Updater/Remote_Management.php:235 +#: src/GitHub_Updater/Remote_Management.php:243 msgid "Use of Remote Management services may result increase some page load speeds only for `admin` level users in the dashboard." msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:326 +#: src/GitHub_Updater/API/Bitbucket_API.php:351 msgid "Bitbucket Private Settings" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:333 -#: src/GitHub_Updater/API/Bitbucket_API.php:421 +#: src/GitHub_Updater/API/Bitbucket_API.php:358 +#: src/GitHub_Updater/API/Bitbucket_API.php:446 msgid "Bitbucket Username" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:342 -#: src/GitHub_Updater/API/Bitbucket_API.php:429 +#: src/GitHub_Updater/API/Bitbucket_API.php:367 +#: src/GitHub_Updater/API/Bitbucket_API.php:454 msgid "Bitbucket Password" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:358 +#: src/GitHub_Updater/API/Bitbucket_API.php:383 msgid "Bitbucket Private Repositories" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:388 +#: src/GitHub_Updater/API/Bitbucket_API.php:413 msgid "Bitbucket" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:397 +#: src/GitHub_Updater/API/Bitbucket_API.php:422 msgid "Check box if private repository. Leave unchecked for public repositories." msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:404 +#: src/GitHub_Updater/API/Bitbucket_API.php:429 msgid "Enter your personal Bitbucket username and password." msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:438 +#: src/GitHub_Updater/API/Bitbucket_API.php:463 msgid "Private Bitbucket Repository" msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:454 +#: src/GitHub_Updater/API/Bitbucket_API.php:479 msgid "Check for private Bitbucket repositories." msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:469 +#: src/GitHub_Updater/API/Bitbucket_API.php:494 msgid "Enter Bitbucket username." msgstr "" -#: src/GitHub_Updater/API/Bitbucket_API.php:484 +#: src/GitHub_Updater/API/Bitbucket_API.php:509 msgid "Enter Bitbucket password." msgstr "" diff --git a/readme.txt b/readme.txt index 955d3b676..33494f549 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://thefragens.com/github-updater-donate Tags: plugin, theme, language pack, updater, remote install Requires at least: 4.6 Requires PHP: 5.6 -Tested up to: 5.0 +Tested up to: 5.1 Stable tag: master License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/vendor/afragen/singleton/composer.json b/vendor/afragen/singleton/composer.json index a0627572e..c86f04e7f 100644 --- a/vendor/afragen/singleton/composer.json +++ b/vendor/afragen/singleton/composer.json @@ -23,7 +23,7 @@ ], "prefer-stable": true, "require": { - "php": ">=5.6" + "php": ">=5.4" }, "autoload": { "classmap": [ diff --git a/vendor/afragen/wordpress-plugin-readme-parser/composer.json b/vendor/afragen/wordpress-plugin-readme-parser/composer.json index 92c056607..fef027810 100644 --- a/vendor/afragen/wordpress-plugin-readme-parser/composer.json +++ b/vendor/afragen/wordpress-plugin-readme-parser/composer.json @@ -22,7 +22,7 @@ ], "prefer-stable": true, "require": { - "php": ">=5.6", + "php": ">=5.4", "erusev/parsedown": "^1.7" }, "autoload": { diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 1463da7a5..bac21c48a 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -6,18 +6,18 @@ "source": { "type": "git", "url": "https://github.com/afragen/singleton.git", - "reference": "e2baf7c8d070d7a575cd430561ae945463146b5e" + "reference": "75bce9e88abaefdbbf4d12bc02f71079e465326d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/afragen/singleton/zipball/e2baf7c8d070d7a575cd430561ae945463146b5e", - "reference": "e2baf7c8d070d7a575cd430561ae945463146b5e", + "url": "https://api.github.com/repos/afragen/singleton/zipball/75bce9e88abaefdbbf4d12bc02f71079e465326d", + "reference": "75bce9e88abaefdbbf4d12bc02f71079e465326d", "shasum": "" }, "require": { - "php": ">=5.6" + "php": ">=5.4" }, - "time": "2018-11-25T06:11:53+00:00", + "time": "2019-01-05T16:19:38+00:00", "type": "library", "installation-source": "dist", "autoload": { @@ -50,19 +50,19 @@ "source": { "type": "git", "url": "https://github.com/afragen/wordpress-plugin-readme-parser.git", - "reference": "4de9307c6e56d6d578f012f82f8de84851096422" + "reference": "df96450ef96aafee3db3c86c67cf7f3119519a07" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/afragen/wordpress-plugin-readme-parser/zipball/4de9307c6e56d6d578f012f82f8de84851096422", - "reference": "4de9307c6e56d6d578f012f82f8de84851096422", + "url": "https://api.github.com/repos/afragen/wordpress-plugin-readme-parser/zipball/df96450ef96aafee3db3c86c67cf7f3119519a07", + "reference": "df96450ef96aafee3db3c86c67cf7f3119519a07", "shasum": "" }, "require": { "erusev/parsedown": "^1.7", - "php": ">=5.6" + "php": ">=5.4" }, - "time": "2018-11-25T20:45:52+00:00", + "time": "2019-01-05T16:19:09+00:00", "type": "library", "installation-source": "dist", "autoload": {