diff --git a/wp-admin/includes/class-wp-debug-data.php b/wp-admin/includes/class-wp-debug-data.php index 7e21785cce..0419aa4cdf 100644 --- a/wp-admin/includes/class-wp-debug-data.php +++ b/wp-admin/includes/class-wp-debug-data.php @@ -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( diff --git a/wp-admin/includes/class-wp-ms-themes-list-table.php b/wp-admin/includes/class-wp-ms-themes-list-table.php index 113fad5c43..b3df81c008 100644 --- a/wp-admin/includes/class-wp-ms-themes-list-table.php +++ b/wp-admin/includes/class-wp-ms-themes-list-table.php @@ -181,9 +181,7 @@ class WP_MS_Themes_List_Table extends WP_List_Table { $filter_payload = array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); - $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) $filter_payload ); + $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $filter_payload ); if ( ! is_null( $auto_update_forced ) ) { $theme->auto_update_forced = $auto_update_forced; diff --git a/wp-admin/includes/class-wp-plugins-list-table.php b/wp-admin/includes/class-wp-plugins-list-table.php index 4c7c653d2d..5a1f682455 100644 --- a/wp-admin/includes/class-wp-plugins-list-table.php +++ b/wp-admin/includes/class-wp-plugins-list-table.php @@ -229,11 +229,10 @@ class WP_Plugins_List_Table extends WP_List_Table { 'requires_php' => '', 'compatibility' => new stdClass(), ); + $filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) ); - $type = 'plugin'; - /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $auto_update_forced = apply_filters( "auto_update_{$type}", null, $filter_payload ); + $auto_update_forced = wp_is_auto_update_forced_for_item( 'plugin', null, $filter_payload ); if ( ! is_null( $auto_update_forced ) ) { $plugin_data['auto-update-forced'] = $auto_update_forced; diff --git a/wp-admin/includes/class-wp-site-health.php b/wp-admin/includes/class-wp-site-health.php index 67c6272b6b..e036113837 100644 --- a/wp-admin/includes/class-wp-site-health.php +++ b/wp-admin/includes/class-wp-site-health.php @@ -2398,13 +2398,8 @@ class WP_Site_Health { 'requires_php' => '5.6.20', ); - $type = 'plugin'; - /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $test_plugins_enabled = apply_filters( "auto_update_{$type}", true, $mock_plugin ); - - $type = 'theme'; - /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $test_themes_enabled = apply_filters( "auto_update_{$type}", true, $mock_theme ); + $test_plugins_enabled = wp_is_auto_update_forced_for_item( 'plugin', true, $mock_plugin ); + $test_themes_enabled = wp_is_auto_update_forced_for_item( 'theme', true, $mock_theme ); $ui_enabled_for_plugins = wp_is_auto_update_enabled_for_type( 'plugin' ); $ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' ); diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php index 84b13c58f7..e83653bc17 100644 --- a/wp-admin/includes/theme.php +++ b/wp-admin/includes/theme.php @@ -716,9 +716,7 @@ function wp_prepare_themes_for_js( $themes = null ) { ); } - $type = 'theme'; - /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ - $auto_update_forced = apply_filters( "auto_update_{$type}", null, $auto_update_filter_payload ); + $auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $auto_update_filter_payload ); $prepared_themes[ $slug ] = array( 'id' => $slug, diff --git a/wp-admin/includes/update.php b/wp-admin/includes/update.php index 8bc61fd0b3..14a0e70fe0 100644 --- a/wp-admin/includes/update.php +++ b/wp-admin/includes/update.php @@ -1045,6 +1045,22 @@ function wp_is_auto_update_enabled_for_type( $type ) { return false; } +/** + * Checks whether auto-updates are forced for an item. + * + * @since 5.6.0 + * + * @param string $type The type of update being checked: 'theme' or 'plugin'. + * @param bool|null $update Whether to update. The value of null is internally used + * to detect whether nothing has hooked into this filter. + * @param object $item The update offer. + * @return bool True if auto-updates are forced for `$item`, false otherwise. + */ +function wp_is_auto_update_forced_for_item( $type, $update, $item ) { + /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ + return apply_filters( "auto_update_{$type}", $update, $item ); +} + /** * Determines the appropriate auto-update message to be displayed. * diff --git a/wp-includes/version.php b/wp-includes/version.php index e6961e9fc2..7c99ac9168 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49240'; +$wp_version = '5.6-alpha-49241'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.