Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
src
/
integrations
/
watchers
/
File Content:
auto-update-watcher.php
<?php namespace Yoast\WP\SEO\Integrations\Watchers; use Yoast\WP\SEO\Conditionals\No_Conditionals; use Yoast\WP\SEO\Helpers\Notification_Helper; use Yoast\WP\SEO\Integrations\Integration_Interface; use Yoast\WP\SEO\Presenters\Admin\Auto_Update_Notification_Presenter; use Yoast_Notification; use Yoast_Notification_Center; /** * Shows a notification for users who have WordPress auto updates enabled but not Yoast SEO auto updates. */ class Auto_Update_Watcher implements Integration_Interface { use No_Conditionals; /** * The notification ID. */ const NOTIFICATION_ID = 'wpseo-auto-update'; /** * The Yoast notification center. * * @var Yoast_Notification_Center */ protected $notification_center; /** * The notification helper. * * @var Notification_Helper */ protected $notification_helper; /** * Auto_Update constructor. * * @param Yoast_Notification_Center $notification_center The notification center. * @param Notification_Helper $notification_helper The notification helper. */ public function __construct( Yoast_Notification_Center $notification_center, Notification_Helper $notification_helper ) { $this->notification_center = $notification_center; $this->notification_helper = $notification_helper; } /** * Initializes the integration. * * On admin_init, it is checked whether the notification to auto-update Yoast SEO needs to be shown or removed. * This is also done when major WP core updates are being enabled or disabled, * and when automatic updates for Yoast SEO are being enabled or disabled. * * @return void */ public function register_hooks() { \add_action( 'admin_init', [ $this, 'auto_update_notification_not_if_dismissed' ] ); \add_action( 'update_site_option_auto_update_core_major', [ $this, 'auto_update_notification_even_if_dismissed' ] ); \add_action( 'update_site_option_auto_update_plugins', [ $this, 'auto_update_notification_not_if_dismissed' ] ); } /** * Handles the Yoast SEO auto-update notification when the user toggles the auto-update setting for WordPress Core. * * If it should be shown, this will be done even if the notification has been dismissed in the past. * * @return void */ public function auto_update_notification_even_if_dismissed() { if ( ! $this->should_show_notification() ) { $this->save_dismissal_status(); $this->maybe_remove_notification(); return; } $this->maybe_create_notification(); } /** * Handles the Yoast SEO auto-update notification on all admin pages, * as well as when the user toggles the Yoast SEO auto-update setting. * * If it should be shown, this will only be done if the notification has not been dismissed in the past. * * @return void */ public function auto_update_notification_not_if_dismissed() { if ( ! $this->should_show_notification() ) { $this->save_dismissal_status(); $this->maybe_remove_notification(); return; } $this->maybe_create_notification_if_not_dismissed(); } /** * Checks whether the Yoast SEO auto-update notification should be shown. * * @return bool Whether the notification should be shown. */ protected function should_show_notification() { $core_updates_enabled = \get_site_option( 'auto_update_core_major' ) === 'enabled'; $yoast_updates_enabled = $this->yoast_auto_updates_enabled(); return $core_updates_enabled && ! $yoast_updates_enabled; } /** * Saves the dismissal status of the notification in an option in wp_usermeta, if the notification gets dismissed. * * @return void */ protected function save_dismissal_status() { // This option exists if the notification has been dismissed at some point. $notification_dismissed = \get_user_option( 'wp_' . self::NOTIFICATION_ID ); // We wish to have its value in a different option, so we can still access it even when the notification gets removed. if ( $notification_dismissed && ! \get_user_option( 'wp_' . self::NOTIFICATION_ID . '_dismissed' ) ) { \update_user_option( \get_current_user_id(), self::NOTIFICATION_ID . '_dismissed', true ); } } /** * Removes the notification from the notification center, if it exists. * * @return void */ protected function maybe_remove_notification() { $this->notification_center->remove_notification_by_id( self::NOTIFICATION_ID ); } /** * Creates the notification if it doesn't exist already. * * @return void */ protected function maybe_create_notification() { if ( ! $this->notification_center->get_notification_by_id( self::NOTIFICATION_ID ) ) { $notification = $this->notification(); $this->notification_helper->restore_notification( $notification ); $this->notification_center->add_notification( $notification ); } } /** * Creates the notification when Yoast SEO auto-updates are enabled, if it hasn't been dismissed in the past. * * @return void */ protected function maybe_create_notification_if_not_dismissed() { $notification_dismissed = \get_user_option( 'wp_' . self::NOTIFICATION_ID . '_dismissed' ) === '1'; $yoast_updates_enabled = $this->yoast_auto_updates_enabled(); if ( $notification_dismissed && ! $yoast_updates_enabled ) { return; } $this->maybe_create_notification(); } /** * Checks whether auto-updates are enabled for Yoast SEO. * * @return bool True if they are enabled, false if not. */ protected function yoast_auto_updates_enabled() { $plugins_to_auto_update = \get_site_option( 'auto_update_plugins' ); // If no plugins are set to be automatically updated, it means that Yoast SEO isn't either. if ( ! $plugins_to_auto_update ) { return false; } // Check if the Yoast SEO plugin file is in the array of plugins for which auto-updates are enabled. return \in_array( 'wordpress-seo/wp-seo.php', $plugins_to_auto_update, true ); } /** * Returns an instance of the notification. * * @return Yoast_Notification The notification to show. */ protected function notification() { $presenter = new Auto_Update_Notification_Presenter(); return new Yoast_Notification( $presenter->present(), [ 'type' => Yoast_Notification::WARNING, 'id' => self::NOTIFICATION_ID, 'capabilities' => 'wpseo_manage_options', 'priority' => 0.8, ] ); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
.DS_Store
10234 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
auto-update-watcher.php
6315 bytes
0644
base.php
2793 bytes
0644
class-admin-utils-20260622095013.php
2147 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-option-tabs-formatter.php
2321 bytes
0644
class-sitemaps-admin-20260703023908.php
3665 bytes
0644
class-sitemaps-admin.php
3665 bytes
0644
class-wpseo-replacement-variable.php
1375 bytes
0644
class-wpseo-statistics-20260703220502.php
1443 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
controller.php
2441 bytes
0644
define.php
4567 bytes
0644
description-presenter-20260623011438.php
1026 bytes
0644
duplicator-en_US.mo
582 bytes
0644
duplicator.php
1781 bytes
0644
elFinderPlugin.php
3331 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
estimated-reading-time.php
1111 bytes
0644
exceptions.php
708 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
15 bytes
0644
indexable-ancestor-watcher.php
8187 bytes
0644
indexable-author-watcher.php
2130 bytes
0644
indexable-category-permalink-watcher.php
1663 bytes
0644
indexable-date-archive-watcher.php
2568 bytes
0644
indexable-home-page-watcher.php
3110 bytes
0644
indexable-homeurl-watcher.php
2824 bytes
0644
indexable-post-meta-watcher.php
2914 bytes
0644
indexable-post-type-archive-watcher.php
3512 bytes
0644
indexable-post-watcher.php
8497 bytes
0644
indexable-static-home-page-watcher.php
2190 bytes
0644
indexable-system-page-watcher.php
2686 bytes
0644
indexable-term-watcher.php
3194 bytes
0644
interface-wpseo-wordpress-integration.php
348 bytes
0644
loco.php
5626 bytes
0644
loco.xml
657 bytes
0644
manager.php
14659 bytes
0644
module.php
1297 bytes
0644
option-titles-watcher.php
3196 bytes
0644
option-wpseo-watcher.php
1291 bytes
0644
primary-category-quick-edit-watcher.php
5806 bytes
0644
primary-term-watcher.php
4006 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
uninstall.php
4401 bytes
0644
wordpress-seo-es_ES.json
25583 bytes
0644
wordpress-seojs-ar-20260704200849.json
25925 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wordpress-seojs-es_ES.json
20568 bytes
0644
wordpress-seojs-gl_ES.json
20143 bytes
0644
wordpress-seojs-ja.json
21424 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
N4ST4R_ID | Naxtarrr