plugin = $plugin; // Handle admin notices. add_action( 'wp_ajax_AjaxDismissNotice', array( $this, 'ajax_dismiss_notice' ) ); } /** * Dismiss an admin notice through ajax. * * @internal */ public function ajax_dismiss_notice() { if ( ! Settings_Helper::current_user_can( 'view' ) ) { die( 'Access Denied.' ); } // Filter $_POST array for security. $post_array = filter_input_array( INPUT_POST ); if ( ! isset( $post_array['notice'] ) ) { die( 'Notice name expected as "notice" parameter.' ); } $this->dismiss_notice( $post_array['notice'] ); } /** * Method: Check if notice is dismissed. * * @param string $name — Name of notice. * @return boolean — Whether notice got dismissed or not. */ public function is_notice_dismissed( $name ) { $user_id = get_current_user_id(); $meta_key = 'wsal-notice-' . $name; self::$allowed_notice_names[] = $name; return get_user_meta( $user_id, $meta_key, true ); } /** * Method: Dismiss notice. * * @param string $name — Name of notice to dismiss. */ public function dismiss_notice( $name ) { $user_id = get_current_user_id(); $meta_key = 'wsal-notice-' . $name; $old_value = get_user_meta( $user_id, $meta_key, true ); if ( in_array( $name, self::$allowed_notice_names ) || false === $old_value || empty( $old_value ) ) { // phpcs:ignore update_user_meta( $user_id, $meta_key, '1' ); } } /** * Method: Register notice. * * @param string $name — Makes this notice available. */ public function register_notice( $name ) { self::$allowed_notice_names[] = $name; } /** * Method: Return page name (for menu etc). * * @return string */ abstract public function get_name(); /** * Method: Return page title. * * @return string */ abstract public function get_title(); /** * Method: Page icon name. * * @return string */ abstract public function get_icon(); /** * Method: Menu weight, the higher this is, the lower it goes. * * @return int */ abstract public function get_weight(); /** * Renders and outputs the view directly. */ abstract public function render(); /** * Renders the view icon (this has been deprecated in newer WP versions). */ public function render_icon() { ?>