wc_rest_should_load_namespace filter-hookWC 9.4

Filters whether a namespace should be loaded.

Usage

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(string)
The namespace to check.
$rest_route(string)
The REST route being checked.
$known_namespaces(array)
Known namespaces that we know are safe to not load if the request is not for them.

Changelog

Since 9.4 Introduced.

Where the hook is called

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 );

Where the hook is used in WooCommerce

Usage not found.