wc_rest_should_load_namespace хук-фильтрWC 9.4

Filters whether a namespace should be loaded.

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

add_filter( 'wc_rest_should_load_namespace', 'wp_kama_wc_rest_should_load_namespace_filter', 10, 4 );

/**
 * Function for `wc_rest_should_load_namespace` filter-hook.
 * 
 * @param bool   $should_load      True if the namespace should be loaded, false otherwise.
 * @param string $ns               The namespace to check.
 * @param string $rest_route       The REST route being checked.
 * @param array  $known_namespaces Known namespaces that we know are safe to not load if the request is not for them.
 *
 * @return bool
 */
function wp_kama_wc_rest_should_load_namespace_filter( $should_load, $ns, $rest_route, $known_namespaces ){

	// filter...
	return $should_load;
}
$should_load(true|false)
True if the namespace should be loaded, false otherwise.
$ns(строка)
The namespace to check.
$rest_route(строка)
The REST route being checked.
$known_namespaces(массив)
Known namespaces that we know are safe to not load if the request is not for them.

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

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

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

wc_rest_should_load_namespace()
wc_rest_should_load_namespace
woocommerce/includes/wc-rest-functions.php 435
return apply_filters( 'wc_rest_should_load_namespace', str_starts_with( $rest_route, $ns ), $ns, $rest_route, $known_namespaces );

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

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