[wp-trac] [WordPress Trac] #29684: Add get_main_site_id() function
WordPress Trac
noreply at wordpress.org
Thu Aug 31 08:44:22 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 flixos90):
@jeremyfelt
> I have a feeling that `get_site()` will work (by providing the site's
network ID) and that there's an unrelated issue in another test that's
causing cross-pollution.
Ah right, I missed this. Let's add these two tests back in, and in
`get_main_site_id()` call `get_network( get_site()->network_id )`. A bit
strange, but that should make it work.
> 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.
I think I prefer to call regular functions from other functions instead of
relying on object properties. Furthermore this will only have benefits if
`$network_id` is null, because otherwise the network returned is a new
object and it must call `get_main_site_id()` regardless. I'm not heavily
opposed, but I lean towards keeping `get_main_site_id()` in there.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/29684#comment:31>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list