Docs: Correct usage of the dynamic auto_update_{$type} filter.

This ensures that the canonical name of the filter is used in Site Health debug data, as well as on plugin and theme screens, so the developer reference site remains correct.

Props johnbillion.
Fixes #50868.

git-svn-id: https://develop.svn.wordpress.org/trunk@48750 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-08-07 16:12:11 +00:00
parent 54cba57fa6
commit 8c11d506e1
5 changed files with 31 additions and 15 deletions

View File

@ -179,7 +179,12 @@ class WP_Automatic_Updater {
* Filters whether to automatically update core, a plugin, a theme, or a language. * Filters whether to automatically update core, a plugin, a theme, or a language.
* *
* The dynamic portion of the hook name, `$type`, refers to the type of update * The dynamic portion of the hook name, `$type`, refers to the type of update
* being checked. Can be 'core', 'theme', 'plugin', or 'translation'. * being checked. Potential hook names include:
*
* - `auto_update_core`
* - `auto_update_plugin`
* - `auto_update_theme`
* - `auto_update_translation`
* *
* Generally speaking, plugins, themes, and major core versions are not updated * Generally speaking, plugins, themes, and major core versions are not updated
* by default, while translations and minor and development versions for core * by default, while translations and minor and development versions for core

View File

@ -971,8 +971,9 @@ class WP_Debug_Data {
$item = array_merge( $item, array_intersect_key( $plugin, $item ) ); $item = array_merge( $item, array_intersect_key( $plugin, $item ) );
} }
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'plugin';
$auto_update_forced = apply_filters( 'auto_update_plugin', null, (object) $item ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) { if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced; $enabled = $auto_update_forced;
@ -1114,8 +1115,9 @@ class WP_Debug_Data {
); );
} }
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'theme';
$auto_update_forced = apply_filters( 'auto_update_theme', null, (object) $item ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) { if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced; $enabled = $auto_update_forced;
@ -1201,8 +1203,9 @@ class WP_Debug_Data {
); );
} }
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'theme';
$auto_update_forced = apply_filters( 'auto_update_theme', null, (object) $item ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) { if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced; $enabled = $auto_update_forced;
@ -1290,8 +1293,9 @@ class WP_Debug_Data {
); );
} }
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'theme';
$auto_update_forced = apply_filters( 'auto_update_theme', null, (object) $item ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, (object) $item );
if ( ! is_null( $auto_update_forced ) ) { if ( ! is_null( $auto_update_forced ) ) {
$enabled = $auto_update_forced; $enabled = $auto_update_forced;

View File

@ -231,8 +231,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
); );
$filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) ); $filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $plugin_data, $filter_payload ) );
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'plugin';
$auto_update_forced = apply_filters( 'auto_update_plugin', null, $filter_payload ); /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$auto_update_forced = apply_filters( "auto_update_{$type}", null, $filter_payload );
if ( ! is_null( $auto_update_forced ) ) { if ( ! is_null( $auto_update_forced ) ) {
$plugin_data['auto-update-forced'] = $auto_update_forced; $plugin_data['auto-update-forced'] = $auto_update_forced;
} }

View File

@ -2372,10 +2372,14 @@ class WP_Site_Health {
'requires_php' => '5.6.20', 'requires_php' => '5.6.20',
); );
$type = 'plugin';
/** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */ /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$test_plugins_enabled = apply_filters( 'auto_update_plugin', true, $mock_plugin ); $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 */ /** This filter is documented in wp-admin/includes/class-wp-automatic-updater.php */
$test_themes_enabled = apply_filters( 'auto_update_theme', true, $mock_theme ); $test_themes_enabled = apply_filters( "auto_update_{$type}", true, $mock_theme );
$ui_enabled_for_plugins = wp_is_auto_update_enabled_for_type( 'plugin' ); $ui_enabled_for_plugins = wp_is_auto_update_enabled_for_type( 'plugin' );
$ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' ); $ui_enabled_for_themes = wp_is_auto_update_enabled_for_type( 'theme' );
$plugin_filter_present = has_filter( 'auto_update_plugin' ); $plugin_filter_present = has_filter( 'auto_update_plugin' );

View File

@ -716,8 +716,9 @@ function wp_prepare_themes_for_js( $themes = null ) {
); );
} }
/** This action is documented in wp-admin/includes/class-wp-automatic-updater.php */ $type = 'theme';
$auto_update_forced = apply_filters( 'auto_update_theme', null, $auto_update_filter_payload ); /** 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 );
$prepared_themes[ $slug ] = array( $prepared_themes[ $slug ] = array(
'id' => $slug, 'id' => $slug,