notice_name = $notice_name; $this->notice_type = $notice_type; add_action( 'wp_ajax_wpseo_dismiss_' . $notice_name, [ $this, 'dismiss_notice' ] ); } /** * Handles the dismiss notice request. */ public function dismiss_notice() { check_ajax_referer( 'wpseo-dismiss-' . $this->notice_name ); $this->save_dismissed(); wp_die( 'true' ); } /** * Storing the dismissed value in the database. The target location is based on the set notification type. */ private function save_dismissed() { if ( $this->notice_type === self::FOR_SITE ) { update_option( 'wpseo_dismiss_' . $this->notice_name, 1 ); return; } if ( $this->notice_type === self::FOR_NETWORK ) { update_site_option( 'wpseo_dismiss_' . $this->notice_name, 1 ); return; } update_user_meta( get_current_user_id(), 'wpseo_dismiss_' . $this->notice_name, 1 ); } }