[wp-trac] [WordPress Trac] #29684: Add get_main_site_id() function

WordPress Trac noreply at wordpress.org
Wed Aug 30 21:53:05 UTC 2017


#29684: Add get_main_site_id() function
-------------------------------------------------+-------------------------
 Reporter:  rmccue                               |       Owner:  jeremyfelt
     Type:  enhancement                          |      Status:  reviewing
 Priority:  normal                               |   Milestone:  4.9
Component:  Networks and Sites                   |     Version:  3.9
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests ms-roadmap  |     Focuses:  multisite
-------------------------------------------------+-------------------------

Comment (by spacedmonkey):

 [https://core.trac.wordpress.org/attachment/ticket/29684/29684.13.diff
 29684.13.diff]

 Small change, changed back last line of `is_main_site` to the following.

 {{{#!php
 return (int) $site_id === (int) get_network( $network_id )->site_id;
 }}}

 Because there is a magic getting in WP_Network, calling site_id will call
 `get_main_site_id`. The reason you want to make sure the magic getter run,
 is that it only runs once. This stops the logic running multiple times.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/29684#comment:30>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list