[wp-trac] [WordPress Trac] #31985: WP_Network class

WordPress Trac noreply at wordpress.org
Wed Oct 14 18:08:44 UTC 2015


#31985: WP_Network class
--------------------------------+-------------------------
 Reporter:  johnjamesjacoby     |       Owner:  jeremyfelt
     Type:  task (blessed)      |      Status:  closed
 Priority:  normal              |   Milestone:  4.4
Component:  Networks and Sites  |     Version:  3.0
 Severity:  normal              |  Resolution:  fixed
 Keywords:  has-patch           |     Focuses:  multisite
--------------------------------+-------------------------

Comment (by jeremyfelt):

 Replying to [comment:51 toscho]:
 > > * We're introducing this as the way to populate `$current_site`, which
 has assumed properties that have been stomped on for years. We risk
 breakage if we make those properties private all of a sudden.
 >
 > Then just use `__get( $name )`. That solves the problem without direct
 write access. Just make sure that a property is always the same, no matter
 when I'm calling it.

 Some type of write access is needed to support existing uses of the
 `$current_site` global. We could add `__set()`, but it doesn't seem
 necessary until we have a property that needs validation.

 {{{
 // Custom via sunrise.php
 $current_site = new stdClass();
 $current_site->site_id = 1;
 $current_site->domain = 'mydomain.com';
 $current_site->path = '/';
 $current_site->site_name = 'My Network';

 // WP trunk, ms-settings.php
 $current_site = new WP_Network( $current_site );

 // Custom network switching via plugin
 $current_site->site_id = 2;
 $current_site->blog_id = 5;
 $current_site->site_name = 'My other network';
 // etc...
 }}}

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


More information about the wp-trac mailing list