pre_get_main_site_id
Filter HookDescription
Filters the main site ID. Returning a positive integer will effectively short-circuit the function.Hook Information
File Location |
wp-includes/class-wp-network.php
View on GitHub
|
Hook Type | Filter |
Line Number | 230 |
Hook Parameters
Type | Name | Description |
---|---|---|
int|null
|
$main_site_id
|
If a positive integer is returned, it is interpreted as the main site ID. |
WP_Network
|
$network
|
The network object for which the main site was detected. |
Usage Examples
Basic Usage
<?php
// Hook into pre_get_main_site_id
add_filter('pre_get_main_site_id', 'my_custom_filter', 10, 2);
function my_custom_filter($main_site_id, $network) {
// Your custom filtering logic here
return $main_site_id;
}
Source Code Context
wp-includes/class-wp-network.php:230
- How this hook is used in WordPress core
<?php
225 * @since 4.9.0
226 *
227 * @param int|null $main_site_id If a positive integer is returned, it is interpreted as the main site ID.
228 * @param WP_Network $network The network object for which the main site was detected.
229 */
230 $main_site_id = (int) apply_filters( 'pre_get_main_site_id', null, $this );
231
232 if ( 0 < $main_site_id ) {
233 return $main_site_id;
234 }
235
PHP Documentation
<?php
/**
* Filters the main site ID.
*
* Returning a positive integer will effectively short-circuit the function.
*
* @since 4.9.0
*
* @param int|null $main_site_id If a positive integer is returned, it is interpreted as the main site ID.
* @param WP_Network $network The network object for which the main site was detected.
*/
Quick Info
- Hook Type: Filter
- Parameters: 2
- File: wp-includes/class-wp-network.php
Related Hooks
Related hooks will be displayed here in future updates.