WPSEO_Admin_Settings_Changed_Listener::intercept_save_update_notification()publicYoast 1.0

Checks and overwrites the wp_settings_errors global to determine whether the Yoast SEO settings have been saved.

Метод класса: WPSEO_Admin_Settings_Changed_Listener{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WPSEO_Admin_Settings_Changed_Listener = new WPSEO_Admin_Settings_Changed_Listener();
$WPSEO_Admin_Settings_Changed_Listener->intercept_save_update_notification();

Код WPSEO_Admin_Settings_Changed_Listener::intercept_save_update_notification() Yoast 23.6

public function intercept_save_update_notification() {
	global $pagenow;

	if ( $pagenow !== 'admin.php' || ! YoastSEO()->helpers->current_page->is_yoast_seo_page() ) {
		return;
	}

	// Variable name is the same as the global that is set by get_settings_errors.
	$wp_settings_errors = get_settings_errors();

	foreach ( $wp_settings_errors as $key => $wp_settings_error ) {
		if ( ! $this->is_settings_updated_notification( $wp_settings_error ) ) {
			continue;
		}

		self::$settings_saved = true;
		unset( $wp_settings_errors[ $key ] );
		// phpcs:ignore WordPress.WP.GlobalVariablesOverride -- Overwrite the global with the list excluding the Changed saved message.
		$GLOBALS['wp_settings_errors'] = $wp_settings_errors;
		break;
	}
}