Filter hook 'wp_speculation_rules_href_exclude_paths'

in WP Core File wp-includes/speculative-loading.php at line 154

View Source

wp_speculation_rules_href_exclude_paths

Filter Hook
Description
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.

Hook Information

File Location wp-includes/speculative-loading.php View on GitHub
Hook Type Filter
Line Number 154

Hook Parameters

Type Name Description
string[] $href_exclude_paths Additional path patterns to disable speculative loading for.
string $mode Mode used to apply speculative loading. Either 'prefetch' or 'prerender'.

Usage Examples

Basic Usage
<?php
// Hook into wp_speculation_rules_href_exclude_paths
add_filter('wp_speculation_rules_href_exclude_paths', 'my_custom_filter', 10, 2);

function my_custom_filter($href_exclude_paths, $mode) {
    // Your custom filtering logic here
    return $href_exclude_paths;
}

Source Code Context

wp-includes/speculative-loading.php:154 - How this hook is used in WordPress core
<?php
 149  	 * @since 6.8.0
 150  	 *
 151  	 * @param string[] $href_exclude_paths Additional path patterns to disable speculative loading for.
 152  	 * @param string   $mode               Mode used to apply speculative loading. Either 'prefetch' or 'prerender'.
 153  	 */
 154  	$href_exclude_paths = (array) apply_filters( 'wp_speculation_rules_href_exclude_paths', array(), $mode );
 155  
 156  	// Ensure that:
 157  	// 1. There are no duplicates.
 158  	// 2. The base paths cannot be removed.
 159  	// 3. The array has sequential keys (i.e. array_is_list()).

PHP Documentation

<?php
/**
	 * 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.
	 *
	 * @since 6.8.0
	 *
	 * @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'.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/speculative-loading.php
Related Hooks

Related hooks will be displayed here in future updates.