芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/optimyar/wp-content/plugins/elementskit-lite/libs/notice/notice.php
script_version; } /** * get_script_location * * @return string */ public function get_script_location() { return __FILE__; } // config /** * Configures all setter variables * * @param string $prefix * @return void */ public function config( $text_domain = '', $unique_id = '' ) { $this->text_domain = $text_domain; $this->unique_id = $unique_id; $this->notice_id = $text_domain . '-' . $unique_id; $this->dismissible = false; // false, user, global $this->expired_time = 1; $this->html = ''; $this->title = ''; $this->message = ''; $this->class = ''; $this->gutter = true; $this->logo = ''; $this->logo_style = ''; $this->size = array(); $this->button = array( 'default_class' => 'button', 'class' => 'button-secondary ', // button-primary button-secondary button-small button-large button-link 'text' => 'Button', 'url' => '#', 'icon' => '', ); $this->buttons = array(); return $this; } // setters begin /** * Adds classes to the container * * @param string $classname * @return void */ public function set_class( $classname = '' ) { $this->class .= $classname; return $this; } public function set_type( $type = '' ) { $this->class .= ' notice-' . $type; return $this; } public function set_style_css( $style_css = '' ) { $this->style_css = $style_css; return $this; } public function set_button( $button = array() ) { $button = array_merge( $this->button, $button ); $this->buttons[] = $button; return $this; } public function set_id( $id ) { $this->notice_id = $id; return $this; } public function set_admin_only( $admin_only ) { $this->$admin_only = $admin_only; return $this; } public function set_title( $title = '' ) { $this->title .= $title; return $this; } public function set_message( $message = '' ) { $this->message .= $message; return $this; } public function set_gutter( $gutter = true ) { $this->gutter .= $gutter; $this->class .= ( $gutter === true ? '' : ' no-gutter' ); return $this; } public function set_logo( $logo = '', $logo_style = '' ) { $this->logo = $logo; $this->logo_style = $logo_style; return $this; } public function set_html( $html = '' ) { $this->html .= $html; return $this; } // setters ends // group getter public function get_data() { return array( 'message' => $this->message, 'title' => $this->title, 'buttons' => $this->buttons, 'class' => $this->class, 'html' => $this->html, ); } public function call() { // check if current user is admin if ( ! current_user_can( 'manage_options' ) ) { return false; } add_action( 'admin_notices', array( $this, 'get_notice' ) ); } public function get_notice() { // dismissible conditions if ( 'user' === $this->dismissible ) { $expired = get_user_meta( get_current_user_id(), $this->notice_id, true ); } elseif ( 'global' === $this->dismissible ) { $expired = get_transient( $this->notice_id ); } else { $expired = ''; } global $oxaim_lib_notice_list; if ( ! isset( $oxaim_lib_notice_list[ $this->notice_id ] ) ) { $oxaim_lib_notice_list[ $this->notice_id ] = __FILE__; // is transient expired? if ( false === $expired || empty( $expired ) ) { $this->generate_html(); } } } public function set_dismiss( $scope = 'global', $time = ( 3600 * 24 * 7 ) ) { $this->dismissible = $scope; $this->expired_time = $time; return $this; } public function generate_html() { ?>
logo ) ) : ?>
html ) ) : ?> title ) ? '' : sprintf( '
%s
', esc_html($this->title) ) ); ?>
message, $this->get_kses_array() ); ?>
buttons ) ) : ?>
buttons as $button ) : ?>
html, $this->get_kses_array() ); ?>
dismissible ) : ?>
x
jQuery(document).ready(function ($) { $( '.wpmet-notice.is-dismissible' ).on( 'click', '.notice-dismiss', function() { _this = $( this ).parents('.wpmet-notice').eq(0); var notice_id = _this.attr( 'id' ) || ''; var expired_time = _this.attr( 'expired_time' ) || ''; var dismissible = _this.attr( 'dismissible' ) || ''; var x = $( this ).attr('class'); // console.log({ // _this, x, notice_id, expired_time, dismissible // }); // return; _this.hide(); $.ajax({ url: ajaxurl, type: 'POST', data: { action : 'wpmet-notices', notice_id : notice_id, dismissible : dismissible, expired_time : expired_time, nonce : '" . esc_js( wp_create_nonce( 'wpmet-notices' ) ) . "' }, }); }); }); "; } private static $instance; /** * Method: instance -> Return Notice module class instance * * @param string|null $text_domain * @param string|null $unique_id * @return mixed */ public static function instance( $text_domain = null, $unique_id = null ) { if ( $text_domain == null ) { return false; } self::$instance = new self(); return self::$instance->config( $text_domain, ( is_null( $unique_id ) ? uniqid() : $unique_id ) ); } public function get_kses_array(){ return array( 'a' => array( 'class' => array(), 'href' => array(), 'rel' => array(), 'title' => array(), 'target' => array(), 'style' => array(), ), 'b' => array( 'class' => array(), 'style' => array(), ), 'div' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'strong' => array( 'class' => array(), 'style' => array(), ), 'h1' => array( 'class' => array(), 'style' => array(), ), 'h2' => array( 'class' => array(), 'style' => array(), ), 'h3' => array( 'class' => array(), 'style' => array(), ), 'h4' => array( 'class' => array(), 'style' => array(), ), 'i' => array( 'class' => array(), 'style' => array(), ), 'img' => array( 'alt' => array(), 'class' => array(), 'height' => array(), 'src' => array(), 'width' => array(), 'style' => array(), 'title' => array(), 'srcset' => array(), 'loading' => array(), 'sizes' => array(), ), 'figure' => array( 'class' => array(), 'style' => array(), ), 'li' => array( 'class' => array(), 'style' => array(), ), 'ol' => array( 'class' => array(), 'style' => array(), ), 'p' => array( 'class' => array(), 'style' => array(), ), 'span' => array( 'class' => array(), 'title' => array(), 'style' => array(), ), 'iframe' => array( 'width' => array(), 'height' => array(), 'scrolling' => array(), 'frameborder' => array(), 'allow' => array(), 'src' => array(), 'class' => array(), 'style' => array(), ), 'strike' => array(), 'br' => array(), 'table' => array(), 'ul' => array( 'class' => array(), 'style' => array(), ), 'svg' => array( 'class' => true, 'aria-hidden' => true, 'aria-labelledby' => true, 'role' => true, 'xmlns' => true, 'width' => true, 'height' => true, 'viewbox' => true, // <= Must be lower case! 'preserveaspectratio' => true, ) ); } } endif;