Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
src
/
actions
/
File Content:
alert-dismissal-action.php
<?php namespace Yoast\WP\SEO\Actions; use Yoast\WP\SEO\Helpers\User_Helper; /** * Class Alert_Dismissal_Action. */ class Alert_Dismissal_Action { const USER_META_KEY = '_yoast_alerts_dismissed'; /** * Holds the user helper instance. * * @var User_Helper */ protected $user; /** * Constructs Alert_Dismissal_Action. * * @param User_Helper $user User helper. */ public function __construct( User_Helper $user ) { $this->user = $user; } /** * Dismisses an alert. * * @param string $alert_identifier Alert identifier. * * @return bool Whether the dismiss was successful or not. */ public function dismiss( $alert_identifier ) { $user_id = $this->user->get_current_user_id(); if ( $user_id === 0 ) { return false; } if ( $this->is_allowed( $alert_identifier ) === false ) { return false; } $dismissed_alerts = $this->get_dismissed_alerts( $user_id ); if ( $dismissed_alerts === false ) { return false; } if ( \array_key_exists( $alert_identifier, $dismissed_alerts ) === true ) { // The alert is already dismissed. return true; } // Add this alert to the dismissed alerts. $dismissed_alerts[ $alert_identifier ] = true; // Save. return $this->user->update_meta( $user_id, static::USER_META_KEY, $dismissed_alerts ) !== false; } /** * Resets an alert. * * @param string $alert_identifier Alert identifier. * * @return bool Whether the reset was successful or not. */ public function reset( $alert_identifier ) { $user_id = $this->user->get_current_user_id(); if ( $user_id === 0 ) { return false; } if ( $this->is_allowed( $alert_identifier ) === false ) { return false; } $dismissed_alerts = $this->get_dismissed_alerts( $user_id ); if ( $dismissed_alerts === false ) { return false; } $amount_of_dismissed_alerts = \count( $dismissed_alerts ); if ( $amount_of_dismissed_alerts === 0 ) { // No alerts: nothing to reset. return true; } if ( \array_key_exists( $alert_identifier, $dismissed_alerts ) === false ) { // Alert not found: nothing to reset. return true; } if ( $amount_of_dismissed_alerts === 1 ) { // The 1 remaining dismissed alert is the alert to reset: delete the alerts user meta row. return $this->user->delete_meta( $user_id, static::USER_META_KEY, $dismissed_alerts ); } // Remove this alert from the dismissed alerts. unset( $dismissed_alerts[ $alert_identifier ] ); // Save. return $this->user->update_meta( $user_id, static::USER_META_KEY, $dismissed_alerts ) !== false; } /** * Returns if an alert is dismissed or not. * * @param string $alert_identifier Alert identifier. * * @return bool Whether the alert has been dismissed. */ public function is_dismissed( $alert_identifier ) { $user_id = $this->user->get_current_user_id(); if ( $user_id === 0 ) { return false; } if ( $this->is_allowed( $alert_identifier ) === false ) { return false; } $dismissed_alerts = $this->get_dismissed_alerts( $user_id ); if ( $dismissed_alerts === false ) { return false; } return \array_key_exists( $alert_identifier, $dismissed_alerts ); } /** * Returns an object with all alerts dismissed by current user. * * @return array|false An array with the keys of all Alerts that have been dismissed * by the current user or `false`. */ public function all_dismissed() { $user_id = $this->user->get_current_user_id(); if ( $user_id === 0 ) { return false; } $dismissed_alerts = $this->get_dismissed_alerts( $user_id ); if ( $dismissed_alerts === false ) { return false; } return $dismissed_alerts; } /** * Returns if an alert is allowed or not. * * @param string $alert_identifier Alert identifier. * * @return bool Whether the alert is allowed. */ public function is_allowed( $alert_identifier ) { return \in_array( $alert_identifier, $this->get_allowed_dismissable_alerts(), true ); } /** * Retrieves the dismissed alerts. * * @param int $user_id User ID. * * @return string[]|false The dismissed alerts. False for an invalid $user_id. */ protected function get_dismissed_alerts( $user_id ) { $dismissed_alerts = $this->user->get_meta( $user_id, static::USER_META_KEY, true ); if ( $dismissed_alerts === false ) { // Invalid user ID. return false; } if ( $dismissed_alerts === '' ) { /* * When no database row exists yet, an empty string is returned because of the `single` parameter. * We do want a single result returned, but the default should be an empty array instead. */ return []; } return $dismissed_alerts; } /** * Retrieves the allowed dismissable alerts. * * @return string[] The allowed dismissable alerts. */ protected function get_allowed_dismissable_alerts() { /** * Filter: 'wpseo_allowed_dismissable_alerts' - List of allowed dismissable alerts. * * @api string[] $allowed_dismissable_alerts Allowed dismissable alerts list. */ $allowed_dismissable_alerts = \apply_filters( 'wpseo_allowed_dismissable_alerts', [] ); if ( \is_array( $allowed_dismissable_alerts ) === false ) { return []; } // Only allow strings. $allowed_dismissable_alerts = \array_filter( $allowed_dismissable_alerts, 'is_string' ); // Filter unique and reorder indices. $allowed_dismissable_alerts = \array_values( \array_unique( $allowed_dismissable_alerts ) ); return $allowed_dismissable_alerts; } }
Submit
FILE
FOLDER
Name
Size
Permission
Action
addon-installation
---
0755
indexables
---
0755
indexing
---
0755
semrush
---
0755
.DS_Store
10234 bytes
0644
20200616130143_ReplacePermalinkHashIndex.php
2293 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController-20260707160810.php
945 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable-20260705095652.php
577 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
README.md
2555 bytes
0644
alert-dismissal-action.php
5493 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
class-admin-user-profile.php
2740 bytes
0644
class-admin-utils-20260622095013.php
2147 bytes
0644
class-admin-utils-20260623093658.php
2147 bytes
0644
class-admin-utils.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-tracking-server-data.php
1989 bytes
0644
class-upgrade-history.php
2939 bytes
0644
class-wpseo-replacement-variable.php
1375 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
class.pack.database.php
30838 bytes
0644
class.password.php
6377 bytes
0644
deactivation.php
21118 bytes
0644
define.php
4567 bytes
0644
description-presenter-20260623011438.php
1026 bytes
0644
duplicator-en_US-20260704105605.mo
582 bytes
0644
duplicator-en_US.mo
582 bytes
0644
duplicator.php
1781 bytes
0644
elFinderPlugin.php
3331 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260705194237.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260706203857.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260624161850.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
environment-helper.php
596 bytes
0644
exceptions.php
708 bytes
0644
flexible-widget.php
11167 bytes
0644
get-request-conditional-20260623154335.php
466 bytes
0644
get-request-conditional.php
466 bytes
0644
image-helper.php
10231 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
157663 bytes
0644
interface-sitemap-cache-data.php
1208 bytes
0644
interface-wpseo-wordpress-integration-20260623184809.php
348 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
meta-fields-presenter.php
1600 bytes
0644
module.php
1297 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
recovery.php
1146 bytes
0644
root.php
1951 bytes
0644
uninstall-20260623130947.php
4401 bytes
0644
uninstall.php
4401 bytes
0644
wordpress-seo-es_ES.json
25583 bytes
0644
wordpress-seojs-ar-20260707044348.json
25925 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wordpress-seojs-gl_ES.json
20143 bytes
0644
wordpress-seojs-it_IT.json
20244 bytes
0644
wordpress-seojs-ja.json
21424 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
wp-query-wrapper.php
834 bytes
0644
N4ST4R_ID | Naxtarrr