[wp-trac] [WordPress Trac] #30294: Introduce get_primary_network_id() function

WordPress Trac noreply at wordpress.org
Wed Nov 12 04:11:24 UTC 2014


#30294: Introduce get_primary_network_id() function
--------------------------------+-----------------------------
 Reporter:  johnjamesjacoby     |       Owner:  jeremyfelt
     Type:  enhancement         |      Status:  assigned
 Priority:  normal              |   Milestone:  Future Release
Component:  Networks and Sites  |     Version:  3.7
 Severity:  normal              |  Resolution:
 Keywords:                      |     Focuses:  multisite
--------------------------------+-----------------------------
Changes (by jeremyfelt):

 * type:  defect (bug) => enhancement
 * milestone:  Awaiting Review => Future Release


Comment:

 I think this will make sense at some point. I don't think there's anything
 stopping us from doing it earlier than later. Now?

 My only use case so far has only really been for a shaky
 `switch_to_network()` system. I've spent some time thinking of how else it
 could be used or when it would be likely for a primary network to ever
 change. It would be interesting to hear some other possible use cases. I
 guess sunsetting an entire network and firing up a new one could be
 interesting.

 I do like that having a function available may start to avoid any overuse
 of the `PRIMARY_NETWORK_ID` constant.

 One spot in the patch is a bit confusing. A different results is possible
 in `is_main_network()` and `get_primary_network_id()` because of this
 check in the prior:

 {{{
 if ( 1 === $current_network_id ) {
         return ( $network_id === $current_network_id );
 }
 }}}

 I think moving that check to `get_primary_network_id()` would make sense.

 > Also worth adding a function to get the data for the primary network to
 avoid two queries (i.e. get primary network ID, then get network data for
 that ID). We have this in the multinetwork plugin; pretty easy to do.

 Worth another ticket, though I'd be a little worried at introducing this
 too early before we really shook out `wp_get_network`(s) and what that
 looks like long term.

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


More information about the wp-trac mailing list