| @@ -10,8 +10,15 @@ | ||
| 10 | 10 | */ |
| 11 | 11 | class WPSEO_Tracking_Plugin_Data implements WPSEO_Collection { |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | + * Plugins with auto updating enabled. | |
| 15 | + * | |
| 16 | + * @var array | |
| 17 | + */ | |
| 18 | + private $auto_update_plugin_list; | |
| 19 | + | |
| 20 | + /** | |
| 14 | 21 | * Returns the collection data. |
| 15 | 22 | * |
| 16 | 23 | * @return array The collection data. |
| 17 | 24 | */ |
| @@ -30,11 +37,12 @@ | ||
| 30 | 37 | |
| 31 | 38 | if ( ! function_exists( 'get_plugin_data' ) ) { |
| 32 | 39 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 33 | 40 | } |
| 41 | + $plugins = wp_get_active_and_valid_plugins(); | |
| 34 | 42 | |
| 35 | - $plugins = wp_get_active_and_valid_plugins(); | |
| 36 | 43 | $plugins = array_map( 'get_plugin_data', $plugins ); |
| 44 | + $this->set_auto_update_plugin_list(); | |
| 37 | 45 | $plugins = array_map( [ $this, 'format_plugin' ], $plugins ); |
| 38 | 46 | |
| 39 | 47 | $plugin_data = []; |
| 40 | 48 | foreach ( $plugins as $plugin ) { |
| @@ -45,8 +53,27 @@ | ||
| 45 | 53 | return $plugin_data; |
| 46 | 54 | } |
| 47 | 55 | |
| 48 | 56 | /** |
| 57 | + * Sets all auto updating plugin data so it can be used in the tracking list. | |
| 58 | + * | |
| 59 | + * @return void | |
| 60 | + */ | |
| 61 | + public function set_auto_update_plugin_list() { | |
| 62 | + | |
| 63 | + $auto_update_plugins = []; | |
| 64 | + $auto_update_plugin_files = get_option( 'auto_update_plugins' ); | |
| 65 | + if ( $auto_update_plugin_files ) { | |
| 66 | + foreach ( $auto_update_plugin_files as $auto_update_plugin ) { | |
| 67 | + $data = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $auto_update_plugin ); | |
| 68 | + $auto_update_plugins[ $data['Name'] ] = $data; | |
| 69 | + } | |
| 70 | + } | |
| 71 | + | |
| 72 | + $this->auto_update_plugin_list = $auto_update_plugins; | |
| 73 | + } | |
| 74 | + | |
| 75 | + /** | |
| 49 | 76 | * Formats the plugin array. |
| 50 | 77 | * |
| 51 | 78 | * @param array $plugin The plugin details. |
| 52 | 79 | * |
| @@ -52,10 +79,12 @@ | ||
| 52 | 79 | * |
| 53 | 80 | * @return array The formatted array. |
| 54 | 81 | */ |
| 55 | 82 | protected function format_plugin( array $plugin ) { |
| 83 | + | |
| 56 | 84 | return [ |
| 57 | - 'name' => $plugin['Name'], | |
| 58 | - 'version' => $plugin['Version'], | |
| 85 | + 'name' => $plugin['Name'], | |
| 86 | + 'version' => $plugin['Version'], | |
| 87 | + 'auto_updating' => array_key_exists( $plugin['Name'], $this->auto_update_plugin_list ), | |
| 59 | 88 | ]; |
| 60 | 89 | } |
| 61 | 90 | } |