← All changes
|
src/integrations/watchers/addon-update-watcher.php
+14
-6
18.4.1
→
trunk
View file →
| @@ -16,9 +16,9 @@ | ||
| 16 | 16 | * ID string used by WordPress to identify the free plugin. |
| 17 | 17 | * |
| 18 | 18 | * @var string |
| 19 | 19 | */ |
| 20 | - const WPSEO_FREE_PLUGIN_ID = 'wordpress-seo/wp-seo.php'; | |
| 20 | + public const WPSEO_FREE_PLUGIN_ID = 'wordpress-seo/wp-seo.php'; | |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * A list of Yoast add-on identifiers. |
| 24 | 24 | * |
| @@ -23,9 +23,9 @@ | ||
| 23 | 23 | * A list of Yoast add-on identifiers. |
| 24 | 24 | * |
| 25 | 25 | * @var string[] |
| 26 | 26 | */ |
| 27 | - const ADD_ON_PLUGIN_FILES = [ | |
| 27 | + public const ADD_ON_PLUGIN_FILES = [ | |
| 28 | 28 | 'wordpress-seo-premium/wp-seo-premium.php', |
| 29 | 29 | 'wpseo-video/video-seo.php', |
| 30 | 30 | 'wpseo-local/local-seo.php', // When installing Local through a released zip, the path is different from the path on a dev environment. |
| 31 | 31 | 'wpseo-woocommerce/wpseo-woocommerce.php', |
| @@ -34,8 +34,10 @@ | ||
| 34 | 34 | ]; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * Registers the hooks. |
| 38 | + * | |
| 39 | + * @return void | |
| 38 | 40 | */ |
| 39 | 41 | public function register_hooks() { |
| 40 | 42 | \add_action( 'add_site_option_auto_update_plugins', [ $this, 'call_toggle_auto_updates_with_empty_array' ], 10, 2 ); |
| 41 | 43 | \add_action( 'update_site_option_auto_update_plugins', [ $this, 'toggle_auto_updates_for_add_ons' ], 10, 3 ); |
| @@ -80,10 +82,10 @@ | ||
| 80 | 82 | '<em>%s</em>', |
| 81 | 83 | \sprintf( |
| 82 | 84 | /* Translators: %1$s resolves to Yoast SEO. */ |
| 83 | 85 | \esc_html__( 'Auto-updates are enabled based on this setting for %1$s.', 'wordpress-seo' ), |
| 84 | - 'Yoast SEO' | |
| 85 | - ) | |
| 86 | + 'Yoast SEO', | |
| 87 | + ), | |
| 86 | 88 | ); |
| 87 | 89 | } |
| 88 | 90 | |
| 89 | 91 | return \sprintf( |
| @@ -90,10 +92,10 @@ | ||
| 90 | 92 | '<em>%s</em>', |
| 91 | 93 | \sprintf( |
| 92 | 94 | /* Translators: %1$s resolves to Yoast SEO. */ |
| 93 | 95 | \esc_html__( 'Auto-updates are disabled based on this setting for %1$s.', 'wordpress-seo' ), |
| 94 | - 'Yoast SEO' | |
| 95 | - ) | |
| 96 | + 'Yoast SEO', | |
| 97 | + ), | |
| 96 | 98 | ); |
| 97 | 99 | } |
| 98 | 100 | |
| 99 | 101 | /** |
| @@ -100,8 +102,10 @@ | ||
| 100 | 102 | * Handles the situation where the auto_update_plugins option did not previously exist. |
| 101 | 103 | * |
| 102 | 104 | * @param string $option The name of the option that is being created. |
| 103 | 105 | * @param array|mixed $value The new (and first) value of the option that is being created. |
| 106 | + * | |
| 107 | + * @return void | |
| 104 | 108 | */ |
| 105 | 109 | public function call_toggle_auto_updates_with_empty_array( $option, $value ) { |
| 106 | 110 | if ( $option !== 'auto_update_plugins' ) { |
| 107 | 111 | return; |
| @@ -186,8 +190,10 @@ | ||
| 186 | 190 | /** |
| 187 | 191 | * Enables auto-updates for all addons. |
| 188 | 192 | * |
| 189 | 193 | * @param string[] $auto_updated_plugins The current list of auto-updated plugins. |
| 194 | + * | |
| 195 | + * @return void | |
| 190 | 196 | */ |
| 191 | 197 | protected function enable_auto_updates_for_addons( $auto_updated_plugins ) { |
| 192 | 198 | $plugins = \array_unique( \array_merge( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) ); |
| 193 | 199 | \update_site_option( 'auto_update_plugins', $plugins ); |
| @@ -196,8 +202,10 @@ | ||
| 196 | 202 | /** |
| 197 | 203 | * Disables auto-updates for all addons. |
| 198 | 204 | * |
| 199 | 205 | * @param string[] $auto_updated_plugins The current list of auto-updated plugins. |
| 206 | + * | |
| 207 | + * @return void | |
| 200 | 208 | */ |
| 201 | 209 | protected function disable_auto_updates_for_addons( $auto_updated_plugins ) { |
| 202 | 210 | $plugins = \array_values( \array_diff( $auto_updated_plugins, self::ADD_ON_PLUGIN_FILES ) ); |
| 203 | 211 | \update_site_option( 'auto_update_plugins', $plugins ); |