rest_pre_update_setting хук-фильтрWP 4.7.0

Filters whether to preempt a setting value update via the REST API.

Allows hijacking the setting update logic and overriding the built-in behavior by returning true.

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

add_filter( 'rest_pre_update_setting', 'wp_kama_rest_pre_update_setting_filter', 10, 4 );

/**
 * Function for `rest_pre_update_setting` filter-hook.
 * 
 * @param bool   $result Whether to override the default behavior for updating the value of a setting.
 * @param string $name   Setting name (as shown in REST API responses).
 * @param mixed  $value  Updated setting value.
 * @param array  $args   Arguments passed to register_setting() for this setting.
 *
 * @return bool
 */
function wp_kama_rest_pre_update_setting_filter( $result, $name, $value, $args ){

	// filter...
	return $result;
}
$result(true|false)
Whether to override the default behavior for updating the value of a setting.
$name(строка)
Setting name (as shown in REST API responses).
$value(разное)
Updated setting value.
$args(массив)
Arguments passed to register_setting() for this setting.

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

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

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

WP_REST_Settings_Controller::update_item()
rest_pre_update_setting
wp-includes/rest-api/endpoints/class-wp-rest-settings-controller.php 170
$updated = apply_filters( 'rest_pre_update_setting', false, $name, $request[ $name ], $args );

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

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