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

@@ -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;