Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
admin
/
File Content:
class-yoast-notification.php
<?php /** * WPSEO plugin file. * * @package WPSEO\Admin\Notifications * @since 1.5.3 */ /** * Implements individual notification. */ class Yoast_Notification { /** * Type of capability check. * * @var string */ const MATCH_ALL = 'all'; /** * Type of capability check. * * @var string */ const MATCH_ANY = 'any'; /** * Notification type. * * @var string */ const ERROR = 'error'; /** * Notification type. * * @var string */ const WARNING = 'warning'; /** * Notification type. * * @var string */ const UPDATED = 'updated'; /** * Options of this Notification. * * Contains optional arguments: * * - type: The notification type, i.e. 'updated' or 'error' * - id: The ID of the notification * - nonce: Security nonce to use in case of dismissible notice. * - priority: From 0 to 1, determines the order of Notifications. * - dismissal_key: Option name to save dismissal information in, ID will be used if not supplied. * - capabilities: Capabilities that a user must have for this Notification to show. * - capability_check: How to check capability pass: all or any. * - wpseo_page_only: Only display on wpseo page or on every page. * * @var array */ private $options = []; /** * Contains default values for the optional arguments. * * @var array */ private $defaults = [ 'type' => self::UPDATED, 'id' => '', 'user' => null, 'nonce' => null, 'priority' => 0.5, 'data_json' => [], 'dismissal_key' => null, 'capabilities' => [], 'capability_check' => self::MATCH_ALL, 'yoast_branding' => false, ]; /** * The message for the notification. * * @var string */ private $message; /** * Notification class constructor. * * @param string $message Message string. * @param array $options Set of options. */ public function __construct( $message, $options = [] ) { $this->message = $message; $this->options = $this->normalize_options( $options ); } /** * Retrieve notification ID string. * * @return string */ public function get_id() { return $this->options['id']; } /** * Retrieve the user to show the notification for. * * @return WP_User The user to show this notification for. */ public function get_user() { return $this->options['user']; } /** * Retrieve the is of the user to show the notification for. * * Returns the id of the current user if not user has been sent. * * @return int The user id */ public function get_user_id() { if ( $this->get_user() !== null ) { return $this->get_user()->ID; } return get_current_user_id(); } /** * Retrieve nonce identifier. * * @return string|null Nonce for this Notification. */ public function get_nonce() { if ( $this->options['id'] && empty( $this->options['nonce'] ) ) { $this->options['nonce'] = wp_create_nonce( $this->options['id'] ); } return $this->options['nonce']; } /** * Make sure the nonce is up to date. */ public function refresh_nonce() { if ( $this->options['id'] ) { $this->options['nonce'] = wp_create_nonce( $this->options['id'] ); } } /** * Get the type of the notification. * * @return string */ public function get_type() { return $this->options['type']; } /** * Priority of the notification. * * Relative to the type. * * @return float Returns the priority between 0 and 1. */ public function get_priority() { return $this->options['priority']; } /** * Get the User Meta key to check for dismissal of notification. * * @return string User Meta Option key that registers dismissal. */ public function get_dismissal_key() { if ( empty( $this->options['dismissal_key'] ) ) { return $this->options['id']; } return $this->options['dismissal_key']; } /** * Is this Notification persistent. * * @return bool True if persistent, False if fire and forget. */ public function is_persistent() { $id = $this->get_id(); return ! empty( $id ); } /** * Check if the notification is relevant for the current user. * * @return bool True if a user needs to see this notification, false if not. */ public function display_for_current_user() { // If the notification is for the current page only, always show. if ( ! $this->is_persistent() ) { return true; } // If the current user doesn't match capabilities. return $this->match_capabilities(); } /** * Does the current user match required capabilities. * * @return bool */ public function match_capabilities() { // Super Admin can do anything. if ( is_multisite() && is_super_admin( $this->options['user']->ID ) ) { return true; } /** * Filter capabilities that enable the displaying of this notification. * * @param array $capabilities The capabilities that must be present for this notification. * @param Yoast_Notification $notification The notification object. * * @return array Array of capabilities or empty for no restrictions. * * @since 3.2 */ $capabilities = apply_filters( 'wpseo_notification_capabilities', $this->options['capabilities'], $this ); // Should be an array. if ( ! is_array( $capabilities ) ) { $capabilities = (array) $capabilities; } /** * Filter capability check to enable all or any capabilities. * * @param string $capability_check The type of check that will be used to determine if an capability is present. * @param Yoast_Notification $notification The notification object. * * @return string self::MATCH_ALL or self::MATCH_ANY. * * @since 3.2 */ $capability_check = apply_filters( 'wpseo_notification_capability_check', $this->options['capability_check'], $this ); if ( ! in_array( $capability_check, [ self::MATCH_ALL, self::MATCH_ANY ], true ) ) { $capability_check = self::MATCH_ALL; } if ( ! empty( $capabilities ) ) { $has_capabilities = array_filter( $capabilities, [ $this, 'has_capability' ] ); switch ( $capability_check ) { case self::MATCH_ALL: return $has_capabilities === $capabilities; case self::MATCH_ANY: return ! empty( $has_capabilities ); } } return true; } /** * Array filter function to find matched capabilities. * * @param string $capability Capability to test. * * @return bool */ private function has_capability( $capability ) { $user = $this->options['user']; return $user->has_cap( $capability ); } /** * Return the object properties as an array. * * @return array */ public function to_array() { return [ 'message' => $this->message, 'options' => $this->options, ]; } /** * Adds string (view) behaviour to the notification. * * @return string */ public function __toString() { return $this->render(); } /** * Renders the notification as a string. * * @return string The rendered notification. */ public function render() { $attributes = []; // Default notification classes. $classes = [ 'yoast-notification', ]; // Maintain WordPress visualisation of notifications when they are not persistent. if ( ! $this->is_persistent() ) { $classes[] = 'notice'; $classes[] = $this->get_type(); } if ( ! empty( $classes ) ) { $attributes['class'] = implode( ' ', $classes ); } // Combined attribute key and value into a string. array_walk( $attributes, [ $this, 'parse_attributes' ] ); $message = null; if ( $this->options['yoast_branding'] ) { $message = $this->wrap_yoast_seo_icon( $this->message ); } if ( $message === null ) { $message = wpautop( $this->message ); } // Build the output DIV. return '<div ' . implode( ' ', $attributes ) . '>' . $message . '</div>' . PHP_EOL; } /** * Wraps the message with a Yoast SEO icon. * * @param string $message The message to wrap. * * @return string The wrapped message. */ private function wrap_yoast_seo_icon( $message ) { $out = sprintf( '<img src="%1$s" height="%2$d" width="%3$d" class="yoast-seo-icon" />', esc_url( plugin_dir_url( WPSEO_FILE ) . 'packages/js/images/Yoast_SEO_Icon.svg' ), 60, 60 ); $out .= '<div class="yoast-seo-icon-wrap">'; $out .= $message; $out .= '</div>'; return $out; } /** * Get the JSON if provided. * * @return false|string */ public function get_json() { if ( empty( $this->options['data_json'] ) ) { return ''; } return WPSEO_Utils::format_json_encode( $this->options['data_json'] ); } /** * Make sure we only have values that we can work with. * * @param array $options Options to normalize. * * @return array */ private function normalize_options( $options ) { $options = wp_parse_args( $options, $this->defaults ); // Should not exceed 0 or 1. $options['priority'] = min( 1, max( 0, $options['priority'] ) ); // Set default capabilities when not supplied. if ( empty( $options['capabilities'] ) || $options['capabilities'] === [] ) { $options['capabilities'] = [ 'wpseo_manage_options' ]; } // Set to the current user if not supplied. if ( $options['user'] === null ) { $options['user'] = wp_get_current_user(); } return $options; } /** * Format HTML element attributes. * * @param string $value Attribute value. * @param string $key Attribute name. */ private function parse_attributes( &$value, $key ) { $value = sprintf( '%s="%s"', sanitize_key( $key ), esc_attr( $value ) ); } }
Edit
Rename
Chmod
Delete
FILE
FOLDER
Name
Size
Permission
Action
ajax
---
0755
capabilities
---
0755
config-ui
---
0755
endpoints
---
0755
exceptions
---
0755
filters
---
0755
formatter
---
0755
google_search_console
---
0755
import
---
0755
listeners
---
0755
menu
---
0755
metabox
---
0755
notifiers
---
0755
pages
---
0755
roles
---
0755
ryte
---
0755
services
---
0755
statistics
---
0755
taxonomy
---
0755
tracking
---
0755
views
---
0755
watchers
---
0755
.DS_Store
10234 bytes
0644
20200616130143_ReplacePermalinkHashIndex-20260705090100.php
2293 bytes
0644
20200616130143_ReplacePermalinkHashIndex.php
2293 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController-20260706051531.php
945 bytes
0644
DownloadConfController.php
945 bytes
0644
JsonSerializable-20260705095652.php
577 bytes
0644
JsonSerializable-20260705181353.php
577 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream.php
4209 bytes
0644
MessageInterface.php
6950 bytes
0644
README.md
2555 bytes
0644
admin-network-it_IT.l10n.php
42133 bytes
0644
admin-settings-changed-listener.php
2403 bytes
0644
ajax.php
9095 bytes
0644
base-20260707183508.php
2793 bytes
0644
base.php
2793 bytes
0644
bing-presenter.php
638 bytes
0644
class-abstract-capability-manager.php
2265 bytes
0644
class-abstract-plugin-importer.php
8466 bytes
0644
class-admin-asset-analysis-worker-location.php
1849 bytes
0644
class-admin-asset-location.php
488 bytes
0644
class-admin-asset-manager-20260623075208.php
17386 bytes
0644
class-admin-asset-manager.php
17386 bytes
0644
class-admin-asset-seo-location.php
2147 bytes
0644
class-admin-asset-yoast-components-l10n.php
1679 bytes
0644
class-admin-media-purge-notification.php
3300 bytes
0644
class-admin-menu-20260623023741.php
4046 bytes
0644
class-admin-utils-20260622095013.php
2147 bytes
0644
class-admin-utils.php
2147 bytes
0644
class-asset.php
4016 bytes
0644
class-bulk-description-editor-list-table.php
2100 bytes
0644
class-bulk-editor-list-table.php
28411 bytes
0644
class-bulk-title-editor-list-table.php
2286 bytes
0644
class-collector.php
984 bytes
0644
class-config-20260622104031.php
5976 bytes
0644
class-endpoint.php
471 bytes
0644
class-expose-shortlinks-20260622052420.php
4996 bytes
0644
class-expose-shortlinks.php
4996 bytes
0644
class-gutenberg-compatibility-20260622104351.php
2510 bytes
0644
class-helpscout-20260623075312.php
6972 bytes
0644
class-helpscout.php
6972 bytes
0644
class-import-detector.php
728 bytes
0644
class-meta-columns.php
22386 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-metabox-null-tab-20260705060522.php
425 bytes
0644
class-metabox-null-tab.php
425 bytes
0644
class-my-yoast-proxy.php
5373 bytes
0644
class-option-tab-20260622044109.php
1784 bytes
0644
class-option-tabs-formatter-20260622034247.php
2321 bytes
0644
class-option-tabs-formatter.php
2321 bytes
0644
class-option-tabs.php
2097 bytes
0644
class-paper-presenter.php
3600 bytes
0644
class-plugin-availability-20260622071513.php
8440 bytes
0644
class-plugin-availability.php
8440 bytes
0644
class-plugin-conflict-20260622015355.php
8640 bytes
0644
class-premium-popup.php
2833 bytes
0644
class-premium-upsell-admin-block.php
3631 bytes
0644
class-product-upsell-notice.php
5216 bytes
0644
class-schema-person-upgrade-notification.php
2133 bytes
0644
class-sitemaps-admin-20260703023908.php
3665 bytes
0644
class-sitemaps-admin-20260705122758.php
3665 bytes
0644
class-sitemaps-admin.php
3665 bytes
0644
class-tracking-server-data.php
1989 bytes
0644
class-tracking-settings-data-20260623041512.php
5203 bytes
0644
class-tracking-settings-data.php
5203 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-columns.php
3281 bytes
0644
class-yoast-dashboard-widget.php
4033 bytes
0644
class-yoast-form-20260622052325.php
31520 bytes
0644
class-yoast-form.php
31520 bytes
0644
class-yoast-notification-20260622071615.php
9611 bytes
0644
class-yoast-notification-center.php
23601 bytes
0644
class-yoast-notification.php
9611 bytes
0644
class-yoast-notifications.php
8784 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
class.archive.config.php
1364 bytes
0644
class.pack.database.php
30838 bytes
0644
ctrl.package.php
17073 bytes
0644
dashboard-1650-rtl.css
1634 bytes
0644
define.php
4567 bytes
0644
description-presenter-20260623011438.php
1026 bytes
0644
duplicator-20260623154449.php
1781 bytes
0644
duplicator-en_US.mo
582 bytes
0644
duplicator-main-20260623011502.php
26907 bytes
0644
duplicator.php
1781 bytes
0644
elFinderPlugin-20260705182242.php
3331 bytes
0644
elFinderPlugin.php
3331 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260705194237.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260706065003.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.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
image-helper.php
10231 bytes
0644
image-presenter.php
2093 bytes
0644
inc.data.php
5121 bytes
0644
inc.validator-20260705162141.php
5401 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
157663 bytes
0644
interface-sitemap-cache-data.php
1208 bytes
0644
loco-20260705162115-20260707054756.php
5626 bytes
0644
loco-20260705162115.php
5626 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-20260706041630-20260707074326.php
1297 bytes
0644
module-20260706041630.php
1297 bytes
0644
module.php
1297 bytes
0644
partial-notifications-errors-20260623074505.php
1139 bytes
0644
partial-notifications-errors.php
1139 bytes
0644
quick-edit-handler-1650-20260707001148.js
1848 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
recovery.php
1146 bytes
0644
request-methods-header.php
1127 bytes
0644
root.php
1951 bytes
0644
setup.php
2699 bytes
0644
social.php
725 bytes
0644
uninstall.php
4401 bytes
0644
wordpress-seo-es_ES.json
25583 bytes
0644
wordpress-seojs-ar-20260705091659.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-ja.json
21424 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
wp-seo-main.php
17504 bytes
0644
N4ST4R_ID | Naxtarrr