Upgrade/Install: Introduce a wrapper for the auto_update_{$type} filter checks.

This allows for cleaner checks whether auto-updates are forced for a plugin or theme.

Follow-up to [48750].

Props rebasaurus, garrett-eclipse, SergeyBiryukov.
Fixes #50875.

git-svn-id: https://develop.svn.wordpress.org/trunk@49241 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-10-20 17:37:16 +00:00
parent 310d8eb83d
commit 6b5b87db58
6 changed files with 27 additions and 29 deletions

View File

@@ -977,9 +977,7 @@ class WP_Debug_Data {
$item = array_merge( $item, array_intersect_key( $plugin, $item ) );
}
$type = 'plugin';
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
$auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced;
@@ -1121,9 +1119,7 @@ class WP_Debug_Data {
);
}
$type = 'theme';
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced;
@@ -1209,9 +1205,7 @@ class WP_Debug_Data {
);
}
$type = 'theme';
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced;
@@ -1299,9 +1293,7 @@ class WP_Debug_Data {
);
}
$type = 'theme';
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced;
@@ -1327,7 +1319,7 @@ class WP_Debug_Data {
$auto_updates_string = apply_filters( 'theme_auto_update_debug_string', $auto_updates_string, $theme, $enabled );
$theme_version_string .= ' | ' . $auto_updates_string;
$theme_version_string_debug .= ',' . $auto_updates_string;
$theme_version_string_debug .= ', ' . $auto_updates_string;
}
$info['wp-themes-inactive']['fields'][ sanitize_text_field( $theme->name ) ] = array(