| Server IP : 103.82.32.14 / Your IP : 216.73.217.121 Web Server : Apache/2.2.32 (Unix) mod_ssl/2.2.32 OpenSSL/1.0.1e-fips mod_fcgid/2.3.9 System : Linux cloud.lonmanhoabinh.com 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : lonmakmf ( 524) PHP Version : 5.6.30 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : OFF Directory : /home/lonmakmf/public_html/wp-content/plugins/wordpress-seo/admin/ |
Upload File : |
<?php
/**
* @package WPSEO\Admin
* @since 1.5.3
*/
/**
* Implements individual notification.
*/
class Yoast_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.
*
* @var array
*/
private $options;
/**
* Contains default values for the optional arguments
*
* @var array
*/
private $defaults = array(
'type' => 'updated',
'id' => '',
'nonce' => null,
'data_json' => array(),
);
/**
* Notification class constructor.
*
* @param string $message Message string.
* @param array $options Set of options.
*/
public function __construct( $message, $options = array() ) {
$this->options = wp_parse_args( $options, $this->defaults );
$this->message = $message;
}
/**
* Retrieve notification ID string.
*
* @return string
*/
public function get_id() {
return $this->options['id'];
}
/**
* Return the object properties as an array
*
* @return array
*/
public function to_array() {
return array(
'message' => $this->message,
'options' => $this->options,
);
}
/**
* Adds string (view) behaviour to the Notification
*
* @return string
*/
public function __toString() {
return '<div class="yoast-notice notice is-dismissible ' . esc_attr( $this->options['type'] ) . '" id="' . esc_attr( $this->options['id'] ) . '"' . $this->parse_data_attributes() . '>' . wpautop( $this->message ) . '</div>' . PHP_EOL;
}
/**
* Parsing the data attributes
*
* @return string
*/
private function parse_data_attributes() {
return $this->parse_nonce_attribute() . '' . $this->parse_data_json_attribute();
}
/**
* Returns a data attribute containing the nonce if present
*
* @return string
*/
private function parse_nonce_attribute() {
return ( ! empty( $this->options['nonce'] ) ? ' data-nonce="' . $this->options['nonce'] . '"' : '' );
}
/**
* Make it possible to pass some JSON data
*
* @return string
*/
private function parse_data_json_attribute() {
if ( empty( $this->options['data_json'] ) ) {
return '';
}
return " data-json='" . WPSEO_Utils::json_encode( $this->options['data_json'] ) . "'";
}
}