Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_get_main_site_id

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

Line Code
220            * Filters the main site ID.
221            *
222            * Returning a positive integer will effectively short-circuit the function.
223            *
224            * @since 4.9.0
225            *
226            * @param int|null   $main_site_id If a positive integer is returned, it is interpreted as the main site ID.
227            * @param WP_Network $network      The network object for which the main site was detected.
228            */
229           $main_site_id = (int) apply_filters( 'pre_get_main_site_id', null, $this );
230           if ( 0 < $main_site_id ) {
231                return $main_site_id;
232           }
233
234           if ( 0 < (int) $this->blog_id ) {
235                return (int) $this->blog_id;
236           }
237
238           if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && DOMAIN_CURRENT_SITE === $this->domain && PATH_CURRENT_SITE === $this->path )