PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
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 / class-schema-person-upgrade-notification.php

class-schema-person-upgrade-notification.php in Yoast SEO – Advanced SEO with real-time guidance and built-in AI trunk, at admin/class-schema-person-upgrade-notification.php

84 lines 2.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
6 */
7
8 /**
9 * Notifies the user to update the Search Appearance settings when the site is set to represent a Person,
10 * but no person (name) has been chosen.
11 */
12 class WPSEO_Schema_Person_Upgrade_Notification implements WPSEO_WordPress_Integration {
13
14 /**
15 * Registers all hooks to WordPress
16 *
17 * @return void
18 */
19 public function register_hooks() {
20 add_action( 'admin_init', [ $this, 'handle_notification' ] );
21 }
22
23 /**
24 * Handles if the notification should be added or removed.
25 *
26 * @return void
27 */
28 public function handle_notification() {
29 $company_or_person_user_id = WPSEO_Options::get( 'company_or_person_user_id', false );
30 if ( WPSEO_Options::get( 'company_or_person' ) === 'person' && empty( $company_or_person_user_id ) ) {
31 $this->add_notification();
32 return;
33 }
34
35 $this->remove_notification();
36 }
37
38 /**
39 * Adds a notification to the notification center.
40 *
41 * @return void
42 */
43 protected function add_notification() {
44 $notification_center = Yoast_Notification_Center::get();
45 $notification_center->add_notification( $this->get_notification() );
46 }
47
48 /**
49 * Removes a notification to the notification center.
50 *
51 * @return void
52 */
53 protected function remove_notification() {
54 $notification_center = Yoast_Notification_Center::get();
55 $notification_center->remove_notification( $this->get_notification() );
56 }
57
58 /**
59 * Gets the notification object.
60 *
61 * @return Yoast_Notification
62 */
63 protected function get_notification() {
64 $message = sprintf(
65 /* translators: %1$s is a link start tag to the Search Appearance settings, %2$s is the link closing tag. */
66 __( 'You have previously set your site to represent a person. We’ve improved our functionality around Schema and the Knowledge Graph, so you should go in and %1$scomplete those settings%2$s.', 'wordpress-seo' ),
67 '<a href="' . esc_url( admin_url( 'admin.php?page=wpseo_page_settings#/site-representation' ) ) . '">',
68 '</a>',
69 );
70
71 $notification = new Yoast_Notification(
72 $message,
73 [
74 'type' => Yoast_Notification::WARNING,
75 'id' => 'wpseo-schema-person-upgrade',
76 'capabilities' => 'wpseo_manage_options',
77 'priority' => 0.8,
78 ],
79 );
80
81 return $notification;
82 }
83 }
84