[wp-trac] [WordPress Trac] #33900: introduce get_current_network_id helper function

WordPress Trac noreply at wordpress.org
Mon Jun 6 20:39:12 UTC 2016


#33900: introduce get_current_network_id helper function
--------------------------------+------------------------
 Reporter:  spacedmonkey        |       Owner:  flixos90
     Type:  enhancement         |      Status:  assigned
 Priority:  normal              |   Milestone:  4.6
Component:  Networks and Sites  |     Version:  4.4
 Severity:  normal              |  Resolution:
 Keywords:  has-patch           |     Focuses:  multisite
--------------------------------+------------------------

Comment (by flixos90):

 [attachment:33900.3.patch] is an updated patch with the following changes:

 * return `1` if no multisite
 * use `get_main_network_id()` if `$current_site` is not a `WP_Network`
 instance
 * add a similar instance check in `get_main_network_id()` (otherwise this
 change would have no point and could cause an error)
 * make sure to return an integer (the `id` property of `WP_Network` is a
 string)

 I wonder whether the instance check is really necessary (edge-case). We
 can probably do it since it shouldn't cause issues, but we don't do a
 check like this in other areas of Core (see the change in
 `get_main_network_id()` in this patch for example). I wonder whether this
 is worth changing in this function - I'm not opposed to it, it's just
 different from how we handle `$current_site` in the rest of Core (always
 assume it's a `WP_Network`).

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


More information about the wp-trac mailing list