Submit
Path:
~
/
home
/
bfxleof
/
www
/
wp-content
/
plugins
/
wordpress-seo
/
src
/
conditionals
/
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
admin
---
0755
third-party
---
0755
-20260707003426.DS_Store
10234 bytes
0644
.DS_Store
10234 bytes
0644
AjaxController.php
2162 bytes
0644
DownloadConfController.php
945 bytes
0644
Inverter.php
6818 bytes
0644
JsonSerializable.php
577 bytes
0644
LimitStream-20260705054834.php
4209 bytes
0644
LimitStream.php
4209 bytes
0644
README.md
2555 bytes
0644
admin-network-it_IT.l10n-20260707145328.php
42133 bytes
0644
admin-network-it_IT.l10n.php
42133 bytes
0644
article-modified-time-presenter.php
609 bytes
0644
baidu-presenter.php
659 bytes
0644
class-admin-utils.php
2147 bytes
0644
class-helpscout.php
6972 bytes
0644
class-metabox-formatter.php
12602 bytes
0644
class-option-tab.php
1784 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-taxonomy-columns.php
7324 bytes
0644
class-wpseo-replacement-variable.php
1375 bytes
0644
class-wpseo-statistics.php
1443 bytes
0644
class-yoast-notification.php
9611 bytes
0644
class-yoast-plugin-conflict-20260707001927.php
10390 bytes
0644
class-yoast-plugin-conflict.php
10390 bytes
0644
class.constants.php
150 bytes
0644
class.pack.database.php
30838 bytes
0644
class.password.php
6377 bytes
0644
controller.php
2441 bytes
0644
ctrl.package.php
17073 bytes
0644
dashboard-1650-rtl.css
1634 bytes
0644
deactivation.php
21118 bytes
0644
define.php
4567 bytes
0644
duplicator-20260705054832-20260707082944.php
1781 bytes
0644
duplicator-20260705054832.php
1781 bytes
0644
duplicator-en_US.mo
582 bytes
0644
duplicator.php
1781 bytes
0644
elFinderPlugin-20260706164159.php
3331 bytes
0644
elFinderPlugin.php
3331 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500-20260705194237.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class-20260623050500.php
48544 bytes
0644
elFinderVolumeLocalFileSystem.class.php
48544 bytes
0644
estimated-reading-time-20260703220613-20260704100556.php
1111 bytes
0644
estimated-reading-time-20260703220613.php
1111 bytes
0644
estimated-reading-time.php
1111 bytes
0644
exceptions-20260706233928.php
708 bytes
0644
exceptions.php
708 bytes
0644
flexible-widget.php
11167 bytes
0644
get-request-conditional-20260623010739.php
466 bytes
0644
image-helper.php
10231 bytes
0644
inc.validator.php
5401 bytes
0644
index.php
157663 bytes
0644
loco-20260703230809.xml
657 bytes
0644
loco.xml
657 bytes
0644
manager-20260705164022.php
14659 bytes
0644
manager.php
14659 bytes
0644
meta-fields-presenter.php
1600 bytes
0644
module.php
1297 bytes
0644
news-conditional.php
363 bytes
0644
no-conditionals-trait.php
381 bytes
0644
primary-category-conditional.php
1042 bytes
0644
quick-edit-handler-1650-20260707145523.js
1848 bytes
0644
quick-edit-handler-1650.js
1848 bytes
0644
root.php
1951 bytes
0644
semrush-client.php
7615 bytes
0644
setup.php
2699 bytes
0644
should-index-links-conditional.php
1036 bytes
0644
the-events-calendar-conditional.php
379 bytes
0644
uninstall.php
4401 bytes
0644
web-stories-conditional-20260623074811.php
440 bytes
0644
web-stories-conditional.php
440 bytes
0644
woocommerce-conditional-20260622103552.php
412 bytes
0644
wordpress-seo-es_ES.json
25583 bytes
0644
wordpress-seojs-ar-20260705060213.json
25925 bytes
0644
wordpress-seojs-ar.json
25925 bytes
0644
wordpress-seojs-bs_BA-20260704104040.json
13790 bytes
0644
wordpress-seojs-bs_BA.json
13790 bytes
0644
wordpress-seojs-es_CR.json
14212 bytes
0644
wordpress-seojs-es_ES.json
20568 bytes
0644
wordpress-seojs-it_IT.json
20244 bytes
0644
wordpress-seojs-ja-20260705034726.json
21424 bytes
0644
wordpress-seojs-ja.json
21424 bytes
0644
wordpress-seojs-uk-20260705021517.json
26506 bytes
0644
wordpress-seojs-uk.json
26506 bytes
0644
wp-seo-main.php
17504 bytes
0644
yoast-admin-and-dashboard-conditional.php
1433 bytes
0644
yoast-tools-page-conditional.php
522 bytes
0644
N4ST4R_ID | Naxtarrr