pre_get_network_by_path
Determine a network by its domain and path.
Description
This allows one to short-circuit the default logic, perhaps by replacing it with a routine that is more optimal for your setup.
Return null to avoid the short-circuit. Return false if no network can be found at the requested domain and path. Otherwise, return an object from wp_get_network(…)
.
Parameters (5)
- 0. $null (null) =>
null
- Network value to return by path.
- 1. $domain (string)
- The requested domain.
- 2. $path (string)
- The requested path, in full.
- 3. $segments (int|null)
- The suggested number of paths to consult. Default null, meaning the entire path was to be consulted.
- 4. $paths (array)
- The paths to search for, based on
$path
and$segments
.
Usage
- To run the hook, copy the example below.
- $null = apply_filters( 'pre_get_network_by_path', $null, $domain, $path, $segments, $paths );
- if ( !empty( $null ) ) {
- // everything has led up to this point...
- }
- The following example is for adding a hook callback.
- // define the pre_get_network_by_path callback
- function filter_pre_get_network_by_path( $null, $domain, $path, $segments, $paths ) {
- // make filter magic happen here...
- return $null;
- };
- // add the filter
- add_filter( 'pre_get_network_by_path', 'filter_pre_get_network_by_path', 10, 5 );
- To remove a hook callback, use the example below.
- // remove the filter
- remove_filter( 'pre_get_network_by_path', 'filter_pre_get_network_by_path', 10, 5 );
Defined (1)
The filter is defined in the following location(s).
- /wp-includes/class-wp-network.php
- $pre = apply_filters( 'pre_get_network_by_path', null, $domain, $path, $segments, $paths );