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

WordPress Trac noreply at wordpress.org
Sun Sep 17 18:17:42 UTC 2017


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

Comment (by spacedmonkey):

 Looking at [changeset:"41380"] there are a number of issues / things I
 would change.

 - In is_main_site do not use `get_main_site_id`. It you have built a
 `WP_Network` and set $current_site this will be ignored and logic run
 again. Return to `int) get_network($network_id)->site_id; `
 - Change docs / variable name for `is_main_site` and `get_main_site_id`.
 `$network_id` is not valid docs, as it allows, int, WP_Network, object and
 null to be passed.
 - Where possible we should as the object to `get_main_site_id`. Example
 `$current_site->blog_id = get_main_site_id( $current_site->id ); ` can be
 changed to `$current_site->blog_id = get_main_site_id( $current_site ); `.
 This saves needlessly generating new a WP_Network object.
 - Change `pre_get_main_site_id` to pass network object as second param.

 cc @flixos90

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


More information about the wp-trac mailing list