PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
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
← All changes | admin/class-yoast-dashboard-widget.php +13 -12 18.428.5 View file →
@@ -14,9 +14,9 @@
14 14 * Holds the cache transient key.
15 15 *
16 16 * @var string
17 17 */
18 - const CACHE_TRANSIENT_KEY = 'wpseo-dashboard-totals';
18 + public const CACHE_TRANSIENT_KEY = 'wpseo-dashboard-totals';
19 19
20 20 /**
21 21 * Holds an instance of the admin asset manager.
22 22 *
@@ -35,12 +35,10 @@
35 35 * Yoast_Dashboard_Widget constructor.
36 36 *
37 37 * @param WPSEO_Statistics|null $statistics WPSEO_Statistics instance.
38 38 */
39 - public function __construct( WPSEO_Statistics $statistics = null ) {
40 - if ( $statistics === null ) {
41 - $statistics = new WPSEO_Statistics();
42 - }
39 + public function __construct( ?WPSEO_Statistics $statistics = null ) {
40 + $statistics ??= new WPSEO_Statistics();
43 41
44 42 $this->statistics = $statistics;
45 43 $this->asset_manager = new WPSEO_Admin_Asset_Manager();
46 44 }
@@ -46,8 +44,10 @@
46 44 }
47 45
48 46 /**
49 47 * Register WordPress hooks.
48 + *
49 + * @return void
50 50 */
51 51 public function register_hooks() {
52 52 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_dashboard_assets' ] );
53 53 add_action( 'admin_init', [ $this, 'queue_dashboard_widget' ] );
@@ -65,8 +65,10 @@
65 65 }
66 66
67 67 /**
68 68 * Adds dashboard widget to WordPress.
69 + *
70 + * @return void
69 71 */
70 72 public function add_dashboard_widget() {
71 73 add_filter( 'postbox_classes_dashboard_wpseo-dashboard-overview', [ $this, 'wpseo_dashboard_overview_class' ] );
72 74 wp_add_dashboard_widget(
@@ -72,9 +74,9 @@
72 74 wp_add_dashboard_widget(
73 75 'wpseo-dashboard-overview',
74 76 /* translators: %s is the plugin name */
75 77 sprintf( __( '%s Posts Overview', 'wordpress-seo' ), 'Yoast SEO' ),
76 - [ $this, 'display_dashboard_widget' ]
78 + [ $this, 'display_dashboard_widget' ],
77 79 );
78 80 }
79 81
80 82 /**
@@ -90,8 +92,10 @@
90 92 }
91 93
92 94 /**
93 95 * Displays the dashboard widget.
96 + *
97 + * @return void
94 98 */
95 99 public function display_dashboard_widget() {
96 100 echo '<div id="yoast-seo-dashboard-widget"></div>';
97 101 }
@@ -97,8 +101,10 @@
97 101 }
98 102
99 103 /**
100 104 * Enqueues assets for the dashboard if the current page is the dashboard.
105 + *
106 + * @return void
101 107 */
102 108 public function enqueue_dashboard_assets() {
103 109 if ( ! $this->is_dashboard_screen() ) {
104 110 return;
@@ -115,22 +121,17 @@
115 121 *
116 122 * @return array The translated strings.
117 123 */
118 124 public function localize_dashboard_script() {
119 - $is_wincher_active = YoastSEO()->helpers->wincher->is_active();
120 -
121 125 return [
122 126 'feed_header' => sprintf(
123 127 /* translators: %1$s resolves to Yoast.com */
124 128 __( 'Latest blog posts on %1$s', 'wordpress-seo' ),
125 - 'Yoast.com'
129 + 'Yoast.com',
126 130 ),
127 131 'feed_footer' => __( 'Read more like this on our SEO blog', 'wordpress-seo' ),
128 132 'wp_version' => substr( $GLOBALS['wp_version'], 0, 3 ) . '-' . ( is_plugin_active( 'classic-editor/classic-editor.php' ) ? '1' : '0' ),
129 133 'php_version' => PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION,
130 - 'is_wincher_active' => ( $is_wincher_active ) ? 1 : 0,
131 - 'wincher_is_logged_in' => ( $is_wincher_active ) ? YoastSEO()->helpers->wincher->login_status() : false,
132 - 'wincher_website_id' => WPSEO_Options::get( 'wincher_website_id', '' ),
133 134 ];
134 135 }
135 136
136 137 /**