PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 18.1
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v18.1
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
wordpress-seo / admin / tracking / class-tracking-plugin-data.php

class-tracking-plugin-data.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI 18.1, at admin/tracking/class-tracking-plugin-data.php

62 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin\Tracking
6 */
7
8 /**
9 * Represents the plugin data.
10 */
11 class WPSEO_Tracking_Plugin_Data implements WPSEO_Collection {
12
13 /**
14 * Returns the collection data.
15 *
16 * @return array The collection data.
17 */
18 public function get() {
19 return [
20 'plugins' => $this->get_plugin_data(),
21 ];
22 }
23
24 /**
25 * Returns all plugins.
26 *
27 * @return array The formatted plugins.
28 */
29 protected function get_plugin_data() {
30
31 if ( ! function_exists( 'get_plugin_data' ) ) {
32 require_once ABSPATH . 'wp-admin/includes/plugin.php';
33 }
34
35 $plugins = wp_get_active_and_valid_plugins();
36 $plugins = array_map( 'get_plugin_data', $plugins );
37 $plugins = array_map( [ $this, 'format_plugin' ], $plugins );
38
39 $plugin_data = [];
40 foreach ( $plugins as $plugin ) {
41 $plugin_key = sanitize_title( $plugin['name'] );
42 $plugin_data[ $plugin_key ] = $plugin;
43 }
44
45 return $plugin_data;
46 }
47
48 /**
49 * Formats the plugin array.
50 *
51 * @param array $plugin The plugin details.
52 *
53 * @return array The formatted array.
54 */
55 protected function format_plugin( array $plugin ) {
56 return [
57 'name' => $plugin['Name'],
58 'version' => $plugin['Version'],
59 ];
60 }
61 }
62