PluginProbe ʕ •ᴥ•ʔ
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 23.8
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v23.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 19.1 19.10 19.11 19.12 19.13 19.14 19.2 19.3 19.4 19.5 19.5.1 19.6 19.6.1 19.7 19.7.1 19.7.2 19.8 19.9 20.0 20.1 20.10 20.11 20.12 20.13 20.2 20.2.1 20.3 20.4 20.5 20.6 20.7 20.8 20.9 21.0 21.1 21.2 21.3 21.4 21.5 21.6 21.7 21.8 21.8.1 21.9 21.9.1 22.0 22.1 22.2 22.3 22.4 22.5 22.6 22.7 22.8 22.9 23.0 23.1 23.2 23.3 23.4 23.5 23.6 23.7 23.8 23.9 24.0 24.1 24.2 24.3 24.4 24.5 24.6 24.7 24.8 24.8.1 24.9 25.0 25.1 25.2 25.3 25.3.1 25.4 25.5 25.6 25.7 25.8 25.9 26.0 26.1 26.1.1 26.2 26.3 26.4 26.5 26.6 26.7 26.8 26.9 27.0 27.1 27.1.1 27.2 27.3 27.4
wordpress-seo / admin / class-wincher-dashboard-widget.php
wordpress-seo / admin Last commit date
ajax 2 years ago capabilities 2 years ago endpoints 2 years ago exceptions 7 years ago filters 2 years ago formatter 1 year ago google_search_console 2 years ago import 2 years ago listeners 8 years ago menu 1 year ago metabox 1 year ago notifiers 3 years ago pages 2 years ago roles 2 years ago services 5 years ago statistics 2 years ago taxonomy 1 year ago tracking 1 year ago views 1 year ago watchers 2 years ago admin-settings-changed-listener.php 2 years ago ajax.php 2 years ago class-admin-asset-analysis-worker-location.php 5 years ago class-admin-asset-dev-server-location.php 2 years ago class-admin-asset-location.php 8 years ago class-admin-asset-manager.php 1 year ago class-admin-asset-seo-location.php 4 years ago class-admin-editor-specific-replace-vars.php 2 years ago class-admin-gutenberg-compatibility-notification.php 2 years ago class-admin-help-panel.php 5 years ago class-admin-init.php 2 years ago class-admin-recommended-replace-vars.php 2 years ago class-admin-user-profile.php 1 year ago class-admin-utils.php 2 years ago class-admin.php 1 year ago class-asset.php 1 year ago class-bulk-description-editor-list-table.php 5 years ago class-bulk-editor-list-table.php 2 years ago class-bulk-title-editor-list-table.php 6 years ago class-collector.php 2 years ago class-config.php 1 year ago class-database-proxy.php 2 years ago class-export.php 2 years ago class-expose-shortlinks.php 2 years ago class-gutenberg-compatibility.php 1 year ago class-meta-columns.php 2 years ago class-my-yoast-proxy.php 2 years ago class-option-tab.php 4 years ago class-option-tabs-formatter.php 2 years ago class-option-tabs.php 2 years ago class-paper-presenter.php 5 years ago class-plugin-availability.php 1 year ago class-plugin-conflict.php 2 years ago class-premium-popup.php 2 years ago class-premium-upsell-admin-block.php 1 year ago class-primary-term-admin.php 2 years ago class-product-upsell-notice.php 2 years ago class-remote-request.php 2 years ago class-schema-person-upgrade-notification.php 2 years ago class-suggested-plugins.php 2 years ago class-wincher-dashboard-widget.php 2 years ago class-yoast-columns.php 2 years ago class-yoast-dashboard-widget.php 2 years ago class-yoast-form.php 1 year ago class-yoast-input-validation.php 1 year ago class-yoast-network-admin.php 2 years ago class-yoast-network-settings-api.php 4 years ago class-yoast-notification-center.php 1 year ago class-yoast-notification.php 1 year ago class-yoast-notifications.php 2 years ago class-yoast-plugin-conflict.php 2 years ago index.php 10 years ago interface-collection.php 7 years ago interface-installable.php 8 years ago
class-wincher-dashboard-widget.php
137 lines
1 <?php
2 /**
3 * WPSEO plugin file.
4 *
5 * @package WPSEO\Admin
6 */
7
8 /**
9 * Wincher dashboard widget.
10 */
11 class Wincher_Dashboard_Widget implements WPSEO_WordPress_Integration {
12
13 /**
14 * Holds an instance of the admin asset manager.
15 *
16 * @var WPSEO_Admin_Asset_Manager
17 */
18 protected $asset_manager;
19
20 /**
21 * Wincher_Dashboard_Widget constructor.
22 */
23 public function __construct() {
24 $this->asset_manager = new WPSEO_Admin_Asset_Manager();
25 }
26
27 /**
28 * Register WordPress hooks.
29 *
30 * @return void
31 */
32 public function register_hooks() {
33 add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_wincher_dashboard_assets' ] );
34 add_action( 'admin_init', [ $this, 'queue_wincher_dashboard_widget' ] );
35 }
36
37 /**
38 * Adds the Wincher dashboard widget if it should be shown.
39 *
40 * @return void
41 */
42 public function queue_wincher_dashboard_widget() {
43 if ( $this->show_widget() ) {
44 add_action( 'wp_dashboard_setup', [ $this, 'add_wincher_dashboard_widget' ] );
45 }
46 }
47
48 /**
49 * Adds the Wincher dashboard widget to WordPress.
50 *
51 * @return void
52 */
53 public function add_wincher_dashboard_widget() {
54 add_filter( 'postbox_classes_dashboard_wpseo-wincher-dashboard-overview', [ $this, 'wpseo_wincher_dashboard_overview_class' ] );
55 wp_add_dashboard_widget(
56 'wpseo-wincher-dashboard-overview',
57 /* translators: %1$s expands to Yoast SEO, %2$s to Wincher */
58 sprintf( __( '%1$s / %2$s: Top Keyphrases', 'wordpress-seo' ), 'Yoast SEO', 'Wincher' ),
59 [ $this, 'display_wincher_dashboard_widget' ]
60 );
61 }
62
63 /**
64 * Adds CSS classes to the dashboard widget.
65 *
66 * @param array $classes An array of postbox CSS classes.
67 *
68 * @return array
69 */
70 public function wpseo_wincher_dashboard_overview_class( $classes ) {
71 $classes[] = 'yoast wpseo-wincherdashboard-overview';
72 return $classes;
73 }
74
75 /**
76 * Displays the Wincher dashboard widget.
77 *
78 * @return void
79 */
80 public function display_wincher_dashboard_widget() {
81 echo '<div id="yoast-seo-wincher-dashboard-widget"></div>';
82 }
83
84 /**
85 * Enqueues assets for the dashboard if the current page is the dashboard.
86 *
87 * @return void
88 */
89 public function enqueue_wincher_dashboard_assets() {
90 if ( ! $this->is_dashboard_screen() ) {
91 return;
92 }
93
94 $this->asset_manager->localize_script( 'wincher-dashboard-widget', 'wpseoWincherDashboardWidgetL10n', $this->localize_wincher_dashboard_script() );
95 $this->asset_manager->enqueue_script( 'wincher-dashboard-widget' );
96 $this->asset_manager->enqueue_style( 'wp-dashboard' );
97 $this->asset_manager->enqueue_style( 'monorepo' );
98 }
99
100 /**
101 * Translates strings used in the Wincher dashboard widget.
102 *
103 * @return array The translated strings.
104 */
105 public function localize_wincher_dashboard_script() {
106
107 return [
108 'wincher_is_logged_in' => YoastSEO()->helpers->wincher->login_status(),
109 'wincher_website_id' => WPSEO_Options::get( 'wincher_website_id', '' ),
110 ];
111 }
112
113 /**
114 * Checks if the current screen is the dashboard screen.
115 *
116 * @return bool Whether or not this is the dashboard screen.
117 */
118 private function is_dashboard_screen() {
119 $current_screen = get_current_screen();
120
121 return ( $current_screen instanceof WP_Screen && $current_screen->id === 'dashboard' );
122 }
123
124 /**
125 * Returns true when the Wincher dashboard widget should be shown.
126 *
127 * @return bool
128 */
129 private function show_widget() {
130 $analysis_seo = new WPSEO_Metabox_Analysis_SEO();
131 $user_can_edit = $analysis_seo->is_enabled() && current_user_can( 'edit_posts' );
132 $is_wincher_active = YoastSEO()->helpers->wincher->is_active();
133
134 return $user_can_edit && $is_wincher_active;
135 }
136 }
137