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
← All changes | admin/class-product-upsell-notice.php +34 -10 18.9 → trunk View file →
@@ -16,9 +16,9 @@
16 16 * The value of this database field holds whether the user has dismissed this notice or not.
17 17 *
18 18 * @var string
19 19 */
20 - const USER_META_DISMISSED = 'wpseo-remove-upsell-notice';
20 + public const USER_META_DISMISSED = 'wpseo-remove-upsell-notice';
21 21
22 22 /**
23 23 * Holds the option name.
24 24 *
@@ -23,9 +23,9 @@
23 23 * Holds the option name.
24 24 *
25 25 * @var string
26 26 */
27 - const OPTION_NAME = 'wpseo';
27 + public const OPTION_NAME = 'wpseo';
28 28
29 29 /**
30 30 * Holds the options.
31 31 *
@@ -41,8 +41,10 @@
41 41 }
42 42
43 43 /**
44 44 * Checks if the notice should be added or removed.
45 + *
46 + * @return void
45 47 */
46 48 public function initialize() {
47 49 $this->remove_notification();
48 50 }
@@ -48,8 +50,10 @@
48 50 }
49 51
50 52 /**
51 53 * Sets the upgrade notice.
54 + *
55 + * @return void
52 56 */
53 57 public function set_upgrade_notice() {
54 58
55 59 if ( $this->has_first_activated_on() ) {
@@ -61,18 +65,28 @@
61 65 }
62 66
63 67 /**
64 68 * Listener for the upsell notice.
69 + *
70 + * @return void
65 71 */
66 72 public function dismiss_notice_listener() {
67 - if ( filter_input( INPUT_GET, 'yoast_dismiss' ) !== 'upsell' ) {
73 + // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.MissingUnslash,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized -- Reason: We are validating a nonce here.
74 + if ( ! isset( $_GET['_wpnonce'] ) || ! wp_verify_nonce( $_GET['_wpnonce'], 'dismiss-5star-upsell' ) ) {
68 75 return;
69 76 }
70 77
78 + $dismiss_upsell = isset( $_GET['yoast_dismiss'] ) && is_string( $_GET['yoast_dismiss'] ) ? sanitize_text_field( wp_unslash( $_GET['yoast_dismiss'] ) ) : '';
79 +
80 + if ( $dismiss_upsell !== 'upsell' ) {
81 + return;
82 + }
83 +
71 84 $this->dismiss_notice();
72 85
73 - wp_safe_redirect( admin_url( 'admin.php?page=wpseo_dashboard' ) );
74 - exit;
86 + if ( wp_safe_redirect( admin_url( 'admin.php?page=wpseo_dashboard' ) ) ) {
87 + exit();
88 + }
75 89 }
76 90
77 91 /**
78 92 * When the notice should be shown.
@@ -93,8 +107,10 @@
93 107 }
94 108
95 109 /**
96 110 * Sets the first activated on.
111 + *
112 + * @return void
97 113 */
98 114 protected function set_first_activated_on() {
99 115 $this->options['first_activated_on'] = strtotime( '-2weeks' );
100 116
@@ -102,8 +118,10 @@
102 118 }
103 119
104 120 /**
105 121 * Adds a notification to the notification center.
122 + *
123 + * @return void
106 124 */
107 125 protected function add_notification() {
108 126 $notification_center = Yoast_Notification_Center::get();
109 127 $notification_center->add_notification( $this->get_notification() );
@@ -110,8 +128,10 @@
110 128 }
111 129
112 130 /**
113 131 * Removes a notification to the notification center.
132 + *
133 + * @return void
114 134 */
115 135 protected function remove_notification() {
116 136 $notification_center = Yoast_Notification_Center::get();
117 137 $notification_center->remove_notification( $this->get_notification() );
@@ -127,9 +147,9 @@
127 147 return sprintf(
128 148 /* translators: %1$s expands anchor to premium plugin page, %2$s expands to </a> */
129 149 __( 'By the way, did you know we also have a %1$sPremium plugin%2$s? It offers advanced features, like a redirect manager and support for multiple keyphrases. It also comes with 24/7 personal support.', 'wordpress-seo' ),
130 150 "<a href='" . WPSEO_Shortlinker::get( 'https://yoa.st/premium-notification' ) . "'>",
131 - '</a>'
151 + '</a>',
132 152 );
133 153 }
134 154
135 155 return '';
@@ -145,9 +165,9 @@
145 165 /* translators: %1$s expands to Yoast SEO, %2$s is a link start tag to the plugin page on WordPress.org, %3$s is the link closing tag. */
146 166 __( 'We\'ve noticed you\'ve been using %1$s for some time now; we hope you love it! We\'d be thrilled if you could %2$sgive us a 5 stars rating on WordPress.org%3$s!', 'wordpress-seo' ),
147 167 'Yoast SEO',
148 168 '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/rate-yoast-seo' ) . '">',
149 - '</a>'
169 + '</a>',
150 170 ) . "\n\n";
151 171
152 172 $message .= sprintf(
153 173 /* translators: %1$s is a link start tag to the bugreport guidelines on the Yoast help center, %2$s is the link closing tag. */
@@ -152,14 +172,14 @@
152 172 $message .= sprintf(
153 173 /* translators: %1$s is a link start tag to the bugreport guidelines on the Yoast help center, %2$s is the link closing tag. */
154 174 __( 'If you are experiencing issues, %1$splease file a bug report%2$s and we\'ll do our best to help you out.', 'wordpress-seo' ),
155 175 '<a href="' . WPSEO_Shortlinker::get( 'https://yoa.st/bugreport' ) . '">',
156 - '</a>'
176 + '</a>',
157 177 ) . "\n\n";
158 178
159 179 $message .= $this->get_premium_upsell_section() . "\n\n";
160 180
161 - $message .= '<a class="button" href="' . admin_url( '?page=' . WPSEO_Admin::PAGE_IDENTIFIER . '&yoast_dismiss=upsell' ) . '">' . __( 'Please don\'t show me this notification anymore', 'wordpress-seo' ) . '</a>';
181 + $message .= '<a class="button" href="' . wp_nonce_url( admin_url( '?page=' . WPSEO_Admin::PAGE_IDENTIFIER . '&yoast_dismiss=upsell' ), 'dismiss-5star-upsell' ) . '">' . __( 'Please don\'t show me this notification anymore', 'wordpress-seo' ) . '</a>';
162 182
163 183 $notification = new Yoast_Notification(
164 184 $message,
165 185 [
@@ -166,9 +186,9 @@
166 186 'type' => Yoast_Notification::WARNING,
167 187 'id' => 'wpseo-upsell-notice',
168 188 'capabilities' => 'wpseo_manage_options',
169 189 'priority' => 0.8,
170 - ]
190 + ],
171 191 );
172 192
173 193 return $notification;
174 194 }
@@ -183,8 +203,10 @@
183 203 }
184 204
185 205 /**
186 206 * Dismisses the notice.
207 + *
208 + * @return void
187 209 */
188 210 protected function dismiss_notice() {
189 211 update_user_meta( get_current_user_id(), self::USER_META_DISMISSED, true );
190 212 }
@@ -199,8 +221,10 @@
199 221 }
200 222
201 223 /**
202 224 * Saves the options to the database.
225 + *
226 + * @return void
203 227 */
204 228 protected function save_options() {
205 229 update_option( self::OPTION_NAME, $this->options );
206 230 }