Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
afragen committed Jun 27, 2023
2 parents 69b9491 + 67aab95 commit 3895a09
Show file tree
Hide file tree
Showing 34 changed files with 489 additions and 315 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/wp-phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
php-version: ${{ matrix.php-versions }}
coverage: none
extensions: mysql, mysqli
tools: composer, wp-cli, phpunit-polyfills, phpunit
tools: composer, wp-cli, phpunit-polyfills:1.0
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#### [unreleased]

#### 12.2.3 / 2023-06-27
* composer update
* get `gu_disable_cron` hook result once per repository
* ensure git class is instantiated when checking `waiting_for_background_update()`
* add check for `$response->error` to `API::validate_response()`
* update `freemius/wordpress-sdk` to 2.5.10

#### 12.2.2 /2023-05-22
* add back Network only activate for multisite, may cause issue where post-license activation Freemius doesn't re-direct to network admin
* update anonymous functions as static functions for better performance
Expand Down
30 changes: 15 additions & 15 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.2
* Version: 12.2.3
* Author: Andy Fragen
* License: MIT
* Domain Path: /languages
Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Donate link: https://thefragens.com/git-updater-donate
Tags: plugin, theme, language pack, updater
Requires at least: 5.2
Requires PHP: 7.2
Tested up to: 6.2
Tested up to: 6.3
Stable tag: master
License: MIT

Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/API/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ protected function exit_no_update( $response, $branch = false ) {
* @return bool true if invalid
*/
protected function validate_response( $response ) {
return empty( $response ) || isset( $response->message ) || is_wp_error( $response );
return empty( $response ) || isset( $response->message ) || isset( $response->error ) || is_wp_error( $response );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/GU_Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/**
* Class GU_Upgrade
*/
class GU_Upgrade {
final class GU_Upgrade {
use GU_Trait;

/**
Expand Down
9 changes: 3 additions & 6 deletions src/Git_Updater/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,10 @@ public function get_remote_plugin_meta() {
*/
$config = apply_filters( 'gu_config_pre_process', $this->config );

foreach ( (array) $config as $plugin ) {
$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );
$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );

foreach ( (array) $config as $plugin ) {
if ( ! $this->waiting_for_background_update( $plugin ) || static::is_wp_cli() || $disable_wp_cron ) {
$this->base->get_remote_repo_meta( $plugin );
} else {
Expand All @@ -300,9 +300,6 @@ public function get_remote_plugin_meta() {

$schedule_event = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ? is_main_site() : true;

$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );

if ( $schedule_event && ! empty( $plugins ) ) {
if ( ! $disable_wp_cron && ! $this->is_cron_event_scheduled( 'gu_get_remote_plugin' ) ) {
wp_schedule_single_event( time(), 'gu_get_remote_plugin', [ $plugins ] );
Expand Down
2 changes: 1 addition & 1 deletion src/Git_Updater/Shim.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ function wp_opcache_invalidate_directory( $dir ) {
__( '%s expects a non-empty string.' ),
'<code>wp_opcache_invalidate_directory()</code>'
);
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_trigger_error, WordPress.Security.EscapeOutput.OutputNotEscaped
trigger_error( $error_message );
}
return;
Expand Down
9 changes: 3 additions & 6 deletions src/Git_Updater/Theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ public function get_remote_theme_meta() {
*/
$config = apply_filters( 'gu_config_pre_process', $this->config );

foreach ( (array) $config as $theme ) {
$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );
$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );

foreach ( (array) $config as $theme ) {
if ( ! $this->waiting_for_background_update( $theme ) || static::is_wp_cli() || $disable_wp_cron
) {
$this->base->get_remote_repo_meta( $theme );
Expand All @@ -266,9 +266,6 @@ public function get_remote_theme_meta() {

$schedule_event = defined( 'DISABLE_WP_CRON' ) && DISABLE_WP_CRON ? is_main_site() : true;

$disable_wp_cron = (bool) apply_filters( 'gu_disable_wpcron', false );
$disable_wp_cron = $disable_wp_cron ?: (bool) apply_filters_deprecated( 'github_updater_disable_wpcron', [ false ], '10.0.0', 'gu_disable_wpcron' );

if ( $schedule_event && ! empty( $themes ) ) {
if ( ! $disable_wp_cron && ! $this->is_cron_event_scheduled( 'gu_get_remote_theme' ) ) {
wp_schedule_single_event( time(), 'gu_get_remote_theme', [ $themes ] );
Expand Down
7 changes: 7 additions & 0 deletions src/Git_Updater/Traits/GU_Trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,13 @@ function ( $e ) {
protected function waiting_for_background_update( $repo = null ) {
$caches = [];
if ( null !== $repo ) {

// Getting class instance also runs API::settings_hook().
if ( isset( $repo->git ) ) {
$git_class = 'Fragen\\Git_Updater\\API\\' . $this->base::$git_servers[ $repo->git ] . '_API';
Singleton::get_instance( $git_class, $this );
}

$cache = isset( $repo->slug ) ? $this->get_repo_cache( $repo->slug ) : null;

// Probably not managed by Git Updater if $cache is empty.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,11 @@ protected function parse_section( $lines ) {
protected function parse_markdown( $text ) {
static $markdown = null;

// Return early if the Markdown processor isn't available.
if ( ! class_exists( '\WordPressdotorg\Plugin_Directory\Markdown' ) ) {
return $text;
}

if ( is_null( $markdown ) ) {
$markdown = new Markdown();
}
Expand Down
2 changes: 1 addition & 1 deletion vendor/afragen/wp-dismiss-notice/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "afragen/wp-dismiss-notice",
"description": "Library for time dismissible WordPress admin notices.",
"version": "0.3.4",
"version": "0.3.7",
"type": "library",
"license": "MIT",
"authors": [
Expand Down
28 changes: 14 additions & 14 deletions vendor/afragen/wp-dismiss-notice/wp-dismiss-notice.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public static function load_script() {
return;
}

$js_url = plugins_url( 'js/dismiss-notice.js', __FILE__, 'wp-dismiss-notice' );
$version = json_decode( file_get_contents( __DIR__ . '/composer.json' ) )->version;

/**
* Filter composer.json vendor directory.
* Some people don't use the standard vendor directory.
Expand All @@ -36,26 +39,23 @@ public static function load_script() {
*/
$vendor_dir = apply_filters( 'dismiss_notice_vendor_dir', '/vendor' );
$composer_js_path = untrailingslashit( $vendor_dir ) . '/afragen/wp-dismiss-notice/js/dismiss-notice.js';
$plugin_js_url = plugins_url( 'js/dismiss-notice.js', __FILE__, 'wp-dismiss-notice' );

// Test to get correct URL for JS.
$response = get_transient( 'wp-dismiss-notice_jsurl' );
if ( ! $response || is_object( $response ) ) {
$response = wp_remote_head( $plugin_js_url );
$response = is_wp_error( $response ) ? 0 : wp_remote_retrieve_response_code( $response );
if ( is_int( $response ) ) {
set_transient( 'wp-dismiss-notice_jsurl', $response, WEEK_IN_SECONDS );
}

$theme_js_url = get_theme_file_uri( $composer_js_path );
$theme_js_file = parse_url( $theme_js_url, PHP_URL_PATH );

if ( file_exists( ABSPATH . $theme_js_file ) ) {
$js_url = $theme_js_url;
}

if ( '/vendor' !== $vendor_dir ) {
$js_url = home_url( $composer_js_path );
}
$js_url = ( 200 === (int) $response )
? $plugin_js_url
: get_stylesheet_directory_uri() . $composer_js_path;

wp_enqueue_script(
'dismissible-notices',
$js_url,
[ 'jquery', 'common' ],
false,
$version,
true
);

Expand Down
Loading

0 comments on commit 3895a09

Please sign in to comment.