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
221            * Filters the main site ID.
222            *
223            * Returning a positive integer will effectively short-circuit the function.
224            *
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           if ( 0 < $main_site_id ) {
232                return $main_site_id;
233           }
234
235           if ( 0 < (int) $this->blog_id ) {
236                return (int) $this->blog_id;
237           }
238
239           if ( ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) && DOMAIN_CURRENT_SITE === $this->domain && PATH_CURRENT_SITE === $this->path )