wp_speculation_rules_href_exclude_paths filter-hookWP 6.8.0

Filters the paths for which speculative loading should be disabled.

All paths should start in a forward slash, relative to the root document. The * can be used as a wildcard. If the WordPress site is in a subdirectory, the exclude paths will automatically be prefixed as necessary.

Note that WordPress always excludes certain path patterns such as /wp-login.php and /wp-admin/*, and those cannot be modified using the filter.

Usage

add_filter( 'wp_speculation_rules_href_exclude_paths', 'wp_kama_speculation_rules_href_exclude_paths_filter', 10, 2 );

/**
 * Function for `wp_speculation_rules_href_exclude_paths` filter-hook.
 * 
 * @param string[] $href_exclude_paths Additional path patterns to disable speculative loading for.
 * @param string   $mode               Mode used to apply speculative loading. Either 'prefetch' or 'prerender'.
 *
 * @return string[]
 */
function wp_kama_speculation_rules_href_exclude_paths_filter( $href_exclude_paths, $mode ){

	// filter...
	return $href_exclude_paths;
}
$href_exclude_paths(string[])
Additional path patterns to disable speculative loading for.
$mode(string)
Mode used to apply speculative loading. Either 'prefetch' or 'prerender'.

Changelog

Since 6.8.0 Introduced.

Where the hook is called

wp_get_speculation_rules()
wp_speculation_rules_href_exclude_paths
wp-includes/speculative-loading.php 154
$href_exclude_paths = (array) apply_filters( 'wp_speculation_rules_href_exclude_paths', array(), $mode );

Where the hook is used in WordPress

Usage not found.