X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/4feeb71a9d812a9ae371c28a3d8b442a4394ded7..607b7e02d77e7326161e8ec15639052d2040f745:/wp-includes/class-wp-network.php diff --git a/wp-includes/class-wp-network.php b/wp-includes/class-wp-network.php index 529c73f3..5ab29c2c 100644 --- a/wp-includes/class-wp-network.php +++ b/wp-includes/class-wp-network.php @@ -17,19 +17,23 @@ * ability to interact with any network of sites is required. * * @since 4.4.0 + * + * @property int $id + * @property int $site_id */ class WP_Network { /** * Network ID. * - * A numeric string, for compatibility reasons. - * * @since 4.4.0 - * @access public - * @var string + * @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. @@ -58,10 +62,10 @@ class WP_Network { * A numeric string, for compatibility reasons. * * @since 4.4.0 - * @access public + * @access private * @var string */ - public $blog_id = 0; + private $blog_id = '0'; /** * Domain used to set cookies for this network. @@ -137,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. * @@ -230,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 *