woocommerce_save_settings_(current_tab) │ хук-фильтр │ WC 3.3.0

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.

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

add_filter( 'woocommerce_save_settings_(current_tab)', 'wp_kama_woocommerce_save_settings_current_tab_filter' );

/**
 * Function for `woocommerce_save_settings_(current_tab)` filter-hook.
 * 
 * @param bool $save Whether to save.
 *
 * @return bool
 */
function wp_kama_woocommerce_save_settings_current_tab_filter( $save ){
	// filter...
	return $save;
}
$save(true|false)
Whether to save.
По умолчанию: true when the settings form was submitted

Список изменений

С версии 3.3.0 Введена.

Где вызывается хук

WC_Admin_Menus::save_settings()
woocommerce_save_settings_(current_tab)
woocommerce/includes/admin/class-wc-admin-menus.php 212
&& 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.

Где используется хук в WooCommerce

woocommerce/includes/admin/class-wc-admin-api-keys.php 22
add_filter( 'woocommerce_save_settings_advanced_keys', array( $this, 'allow_save_settings' ) );
woocommerce/includes/admin/class-wc-admin-webhooks.php 22
add_filter( 'woocommerce_save_settings_advanced_webhooks', array( $this, 'allow_save_settings' ) );