X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/03f2fa83c13c1b532284205fa7efcab9b8b2c41f..607b7e02d77e7326161e8ec15639052d2040f745:/wp-includes/class-wp-network.php diff --git a/wp-includes/class-wp-network.php b/wp-includes/class-wp-network.php index 0ccafafd..5ab29c2c 100644 --- a/wp-includes/class-wp-network.php +++ b/wp-includes/class-wp-network.php @@ -17,6 +17,9 @@ * ability to interact with any network of sites is required. * * @since 4.4.0 + * + * @property int $id + * @property int $site_id */ class WP_Network { @@ -24,10 +27,13 @@ class WP_Network { * Network ID. * * @since 4.4.0 - * @access public + * @since 4.6.0 Converted from public to private to explicitly enable more intuitive + * access via magic methods. As part of the access change, the type was + * also changed from `string` to `int`. + * @access private * @var int */ - public $id; + private $id; /** * Domain of the network. @@ -53,18 +59,20 @@ class WP_Network { * Named "blog" vs. "site" for legacy reasons. A main site is mapped to * the network when the network is created. * + * A numeric string, for compatibility reasons. + * * @since 4.4.0 - * @access public - * @var int + * @access private + * @var string */ - public $blog_id = 0; + private $blog_id = '0'; /** * Domain used to set cookies for this network. * * @since 4.4.0 * @access public - * @var int + * @var string */ public $cookie_domain = ''; @@ -133,6 +141,77 @@ class WP_Network { $this->_set_cookie_domain(); } + /** + * Getter. + * + * Allows current multisite naming conventions when getting properties. + * + * @since 4.6.0 + * @access public + * + * @param string $key Property to get. + * @return mixed Value of the property. Null if not available. + */ + public function __get( $key ) { + switch ( $key ) { + case 'id'; + return (int) $this->id; + case 'blog_id': + return $this->blog_id; + case 'site_id': + return (int) $this->blog_id; + } + + return null; + } + + /** + * Isset-er. + * + * Allows current multisite naming conventions when checking for properties. + * + * @since 4.6.0 + * @access public + * + * @param string $key Property to check if set. + * @return bool Whether the property is set. + */ + public function __isset( $key ) { + switch ( $key ) { + case 'id': + case 'blog_id': + case 'site_id': + return true; + } + + return false; + } + + /** + * Setter. + * + * Allows current multisite naming conventions while setting properties. + * + * @since 4.6.0 + * @access public + * + * @param string $key Property to set. + * @param mixed $value Value to assign to the property. + */ + public function __set( $key, $value ) { + switch ( $key ) { + case 'id': + $this->id = (int) $value; + break; + case 'blog_id': + case 'site_id': + $this->blog_id = (string) $value; + break; + default: + $this->$key = $value; + } + } + /** * Set the site name assigned to the network if one has not been populated. * @@ -226,7 +305,7 @@ class WP_Network { $path_segments = array_filter( explode( '/', trim( $path, '/' ) ) ); /** - * Filter the number of path segments to consider when searching for a site. + * Filters the number of path segments to consider when searching for a site. * * @since 3.9.0 *