[wp-trac] [WordPress Trac] #36717: Allow to access network and site properties using the current naming conventions

WordPress Trac noreply at wordpress.org
Fri Apr 29 08:07:59 UTC 2016


#36717: Allow to access network and site properties using the current naming
conventions
--------------------------------+-----------------------------
 Reporter:  flixos90            |      Owner:
     Type:  enhancement         |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Networks and Sites  |    Version:  4.5
 Severity:  normal              |   Keywords:
  Focuses:  multisite           |
--------------------------------+-----------------------------
 In multisite we have the issue that we used to call a site a blog and a
 network a site. Therefore the `WP_Site` and `WP_Network` classes use weird
 naming conventions for their properties. It has to be like that for
 backwards compatibility, but since the classes itself now use the new
 conventions, it can be extremely confusing to interact with them
 (`$site->site_id` will give me the network ID for example).

 That's why I'm proposing to add magic getters to both these classes,
 allowing to access these properties in the following way:

 * in both classes, `id` simply refers to the objects ID (so in `WP_Site`
 it will be the site ID, and in `WP_Network` it will be the network ID)
 * to get the network ID of a site, we can use `$site->network_id`
 * to get the main site ID of a network, we can use `$network->site_id`

 While this doesn't provide a functional benefit, it would make interacting
 with these classes a lot more logical. And it's also backwards compatible
 since we're only adding these new properties virtually.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/36717>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list