icon_url = isset($args['icon_url']) ? $args['icon_url'] : ''; $this->title = isset($args['title']) ? $args['title'] : ''; $this->content = isset($args['content']) ? $args['content'] : ''; $this->button_text = isset($args['button_text']) ? $args['button_text'] : ''; $this->button_url = isset($args['button_url']) ? $args['button_url'] : ''; $this->dismissed_transient_key = 'aiautotool_notice_dismissed'; // Gọi hàm để hiển thị thông báo tùy chỉnh $dismissed = get_transient($this->dismissed_transient_key); // Add action only if the notice is not dismissed if (!$dismissed) { // add_action('admin_notices', array($this, 'create_custom_notice')); } add_action('wp_ajax_dismiss_aiautotool_notice', array($this, 'aiautotool_dismiss_notice_callback')); } public function add_notice($message, $class = '', $show_on = null, $persist = false, $id = '') { $notice = [ 'message' => $message, 'class' => $class . ' is-dismissible', 'show_on' => $show_on, ]; if (!$id) { $id = md5(serialize($notice)); } if ($persist) { $notices = get_option('aiautotool_notices', []); $notices[$id] = $notice; update_option('aiautotool_notices', $notices, null, 'no'); return; } $this->notices[$id] = $notice; } public function display_notices() { $screen = get_current_screen(); $stored = get_option( 'aiautotool_notices', [] ); $this->notices = array_merge( $stored, $this->notices ); delete_option( 'aiautotool_notices' ); foreach ( $this->notices as $notice ) { if ( ! empty( $notice['show_on'] ) && is_array( $notice['show_on'] ) && ! in_array( $screen->id, $notice['show_on'], true ) ) { return; } $class = 'notice instant-indexing-notice ' . $notice['class']; printf( '
%2$s