addon-update-watcher.php
3 months ago
auto-update-watcher.php
2 years ago
indexable-ancestor-watcher.php
3 months ago
indexable-attachment-watcher.php
1 year ago
indexable-author-archive-watcher.php
3 months ago
indexable-author-watcher.php
1 year ago
indexable-category-permalink-watcher.php
2 years ago
indexable-date-archive-watcher.php
2 years ago
indexable-home-page-watcher.php
1 year ago
indexable-homeurl-watcher.php
5 years ago
indexable-permalink-watcher.php
2 years ago
indexable-post-meta-watcher.php
2 years ago
indexable-post-type-archive-watcher.php
1 year ago
indexable-post-type-change-watcher.php
1 year ago
indexable-post-watcher.php
3 months ago
indexable-static-home-page-watcher.php
2 years ago
indexable-system-page-watcher.php
2 years ago
indexable-taxonomy-change-watcher.php
1 year ago
indexable-term-watcher.php
1 year ago
option-titles-watcher.php
3 months ago
option-wpseo-watcher.php
1 year ago
primary-category-quick-edit-watcher.php
2 years ago
primary-term-watcher.php
1 year ago
search-engines-discouraged-watcher.php
3 months ago
woocommerce-beta-editor-watcher.php
3 months ago
auto-update-watcher.php
59 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Yoast\WP\SEO\Integrations\Watchers; |
| 4 | |
| 5 | use Yoast\WP\SEO\Conditionals\No_Conditionals; |
| 6 | use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 7 | use Yoast_Notification_Center; |
| 8 | |
| 9 | /** |
| 10 | * Shows a notification for users who have WordPress auto updates enabled but not Yoast SEO auto updates. |
| 11 | */ |
| 12 | class Auto_Update_Watcher implements Integration_Interface { |
| 13 | |
| 14 | use No_Conditionals; |
| 15 | |
| 16 | /** |
| 17 | * The notification ID. |
| 18 | */ |
| 19 | public const NOTIFICATION_ID = 'wpseo-auto-update'; |
| 20 | |
| 21 | /** |
| 22 | * The Yoast notification center. |
| 23 | * |
| 24 | * @var Yoast_Notification_Center |
| 25 | */ |
| 26 | protected $notification_center; |
| 27 | |
| 28 | /** |
| 29 | * Auto_Update constructor. |
| 30 | * |
| 31 | * @param Yoast_Notification_Center $notification_center The notification center. |
| 32 | */ |
| 33 | public function __construct( Yoast_Notification_Center $notification_center ) { |
| 34 | $this->notification_center = $notification_center; |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * Initializes the integration. |
| 39 | * |
| 40 | * On admin_init, it is checked whether the notification to auto-update Yoast SEO needs to be shown or removed. |
| 41 | * This is also done when major WP core updates are being enabled or disabled, |
| 42 | * and when automatic updates for Yoast SEO are being enabled or disabled. |
| 43 | * |
| 44 | * @return void |
| 45 | */ |
| 46 | public function register_hooks() { |
| 47 | \add_action( 'admin_init', [ $this, 'remove_notification' ] ); |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Removes the notification from the notification center, if it exists. |
| 52 | * |
| 53 | * @return void |
| 54 | */ |
| 55 | public function remove_notification() { |
| 56 | $this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID ); |
| 57 | } |
| 58 | } |
| 59 |