WC_Admin_Menus::save_settings │ public │ WC 1.0

Handle saving of settings.

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

Возвращает

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

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

$WC_Admin_Menus = new WC_Admin_Menus();
$WC_Admin_Menus->save_settings();

Код WC_Admin_Menus::save_settings() WC 11.2.2

public function save_settings() {
	global $current_tab, $current_section;

	// We should only save on the settings page.
	if ( ! is_wc_admin_settings_page() ) {
		return;
	}

	// Include settings pages.
	WC_Admin_Settings::get_settings_pages();

	// Get current tab/section.
	$current_tab     = empty( $_GET['tab'] ) ? 'general' : sanitize_title( wp_unslash( $_GET['tab'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only selector; settings mutations verify capability and nonce.
	$current_section = empty( $_REQUEST['section'] ) ? '' : sanitize_title( wp_unslash( $_REQUEST['section'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Read-only selector; settings mutations verify capability and nonce.

	// Save settings if data has been posted.
	/**
	 * Filters whether the posted data for a settings section should be saved.
	 *
	 * The dynamic portions of the hook name, `$current_tab` and `$current_section`, are the
	 * sanitized `tab` and `section` request values of the settings screen being viewed.
	 *
	 * @since 3.3.0
	 * @param bool $save Whether to save. Defaults to true when the settings form was submitted.
	 */
	if ( '' !== $current_section && apply_filters( "woocommerce_save_settings_{$current_tab}_{$current_section}", ! empty( $_POST['save'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Presence check only; WC_Admin_Settings::save() verifies the manage_woocommerce capability and the woocommerce-settings nonce before anything is written.
		WC_Admin_Settings::save();
	} elseif (
		'' === $current_section
		/**
		 * Filters whether the posted data for a settings tab should be saved.
		 *
		 * The dynamic portion of the hook name, `$current_tab`, is the sanitized `tab` request
		 * value of the settings screen being viewed. This variant fires only when no section is
		 * selected.
		 *
		 * @since 3.3.0
		 * @param bool $save Whether to save. Defaults to true when the settings form was submitted.
		 */
		&& apply_filters( "woocommerce_save_settings_{$current_tab}", ! empty( $_POST['save'] ) ) // phpcs:ignore WordPress.Security.NonceVerification.Missing -- Presence check only; WC_Admin_Settings::save() verifies the manage_woocommerce capability and the woocommerce-settings nonce before anything is written.
	) {
		WC_Admin_Settings::save();
	}
}