← All changes
|
src/integrations/admin/indexing-notification-integration.php
+13
-42
18.2
→
trunk
View file →
| @@ -28,46 +28,11 @@ | ||
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * The notification ID. |
| 31 | 31 | */ |
| 32 | - const NOTIFICATION_ID = 'wpseo-reindex'; | |
| 32 | + public const NOTIFICATION_ID = 'wpseo-reindex'; | |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * Represents the reason that the indexing process failed and should be tried again. | |
| 36 | - * | |
| 37 | - * @deprecated 15.3 | |
| 38 | - */ | |
| 39 | - const REASON_INDEXING_FAILED = Indexing_Reasons::REASON_INDEXING_FAILED; | |
| 40 | - | |
| 41 | - /** | |
| 42 | - * Represents the reason that the permalink settings are changed. | |
| 43 | - * | |
| 44 | - * @deprecated 15.3 | |
| 45 | - */ | |
| 46 | - const REASON_PERMALINK_SETTINGS = Indexing_Reasons::REASON_PERMALINK_SETTINGS; | |
| 47 | - | |
| 48 | - /** | |
| 49 | - * Represents the reason that the category base is changed. | |
| 50 | - * | |
| 51 | - * @deprecated 15.3 | |
| 52 | - */ | |
| 53 | - const REASON_CATEGORY_BASE_PREFIX = Indexing_Reasons::REASON_CATEGORY_BASE_PREFIX; | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * Represents the reason that the tag base is changed. | |
| 57 | - * | |
| 58 | - * @deprecated 15.3 | |
| 59 | - */ | |
| 60 | - const REASON_TAG_BASE_PREFIX = Indexing_Reasons::REASON_TAG_BASE_PREFIX; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * Represents the reason that the home url option is changed. | |
| 64 | - * | |
| 65 | - * @deprecated 15.3 | |
| 66 | - */ | |
| 67 | - const REASON_HOME_URL_OPTION = Indexing_Reasons::REASON_HOME_URL_OPTION; | |
| 68 | - | |
| 69 | - /** | |
| 70 | 35 | * The Yoast notification center. |
| 71 | 36 | * |
| 72 | 37 | * @var Yoast_Notification_Center |
| 73 | 38 | */ |
| @@ -188,15 +153,16 @@ | ||
| 188 | 153 | |
| 189 | 154 | /** |
| 190 | 155 | * Checks whether the notification should be shown and adds |
| 191 | 156 | * it to the notification center if this is the case. |
| 157 | + * | |
| 158 | + * @return void | |
| 192 | 159 | */ |
| 193 | 160 | public function maybe_create_notification() { |
| 194 | - if ( ! $this->should_show_notification() ) { | |
| 195 | - return; | |
| 196 | - } | |
| 197 | - | |
| 198 | - if ( ! $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ) ) { | |
| 161 | + if ( | |
| 162 | + ! $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ) | |
| 163 | + && $this->should_show_notification() | |
| 164 | + ) { | |
| 199 | 165 | $notification = $this->notification(); |
| 200 | 166 | $this->notification_helper->restore_notification( $notification ); |
| 201 | 167 | $this->notification_center->add_notification( $notification ); |
| 202 | 168 | } |
| @@ -204,8 +170,10 @@ | ||
| 204 | 170 | |
| 205 | 171 | /** |
| 206 | 172 | * Checks whether the notification should not be shown anymore and removes |
| 207 | 173 | * it from the notification center if this is the case. |
| 174 | + * | |
| 175 | + * @return void | |
| 208 | 176 | */ |
| 209 | 177 | public function maybe_cleanup_notification() { |
| 210 | 178 | $notification = $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ); |
| 211 | 179 | |
| @@ -233,8 +201,11 @@ | ||
| 233 | 201 | if ( $this->indexing_helper->get_started() > 0 ) { |
| 234 | 202 | return false; |
| 235 | 203 | } |
| 236 | 204 | |
| 205 | + // We're about to perform expensive queries, let's inform. | |
| 206 | + \add_filter( 'wpseo_unindexed_count_queries_ran', '__return_true' ); | |
| 207 | + | |
| 237 | 208 | // Never show a notification when nothing should be indexed. |
| 238 | 209 | return $this->indexing_helper->get_limited_filtered_unindexed_count( 1 ) > 0; |
| 239 | 210 | } |
| 240 | 211 | |
| @@ -254,9 +225,9 @@ | ||
| 254 | 225 | 'type' => Yoast_Notification::WARNING, |
| 255 | 226 | 'id' => self::NOTIFICATION_ID, |
| 256 | 227 | 'capabilities' => 'wpseo_manage_options', |
| 257 | 228 | 'priority' => 0.8, |
| 258 | - ] | |
| 229 | + ], | |
| 259 | 230 | ); |
| 260 | 231 | } |
| 261 | 232 | |
| 262 | 233 | /** |