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

WordPress Trac noreply at wordpress.org
Mon Jun 26 09:23:07 UTC 2017

#29684: Add get_main_site() function
 Reporter:  rmccue                      |       Owner:  jeremyfelt
     Type:  enhancement                 |      Status:  reviewing
 Priority:  normal                      |   Milestone:  Future Release
Component:  Networks and Sites          |     Version:  3.9
 Severity:  normal                      |  Resolution:
 Keywords:  has-patch needs-unit-tests  |     Focuses:  multisite

Comment (by flixos90):

 I'd like to revive discussion around this.

 I think since we have `get_main_network_id()`, we should also introduce
 `get_main_site_id()` (referring to @jeremyfelt's above proposal of only
 returning the site's ID instead of entire object). This function could as
 well be added to the `functions.php` file and return 1 if not a multisite.

 Once the function exists, we can use it in
 `ms_load_current_site_and_network()` for populating the `$blog_id`
 property of the current network. We should then also use the function in
 the `is_main_site()` function and could then easily add support for a
 network ID parameter there, i.e. `is_main_site( $site_id = null,
 $network_id = null )`.

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

More information about the wp-trac mailing list