Make WordPress Core

Ticket #36717: 36717.3.diff

File 36717.3.diff, 4.4 KB (added by jeremyfelt, 9 years ago)
  • src/wp-includes/class-wp-network.php

     
    1717 * ability to interact with any network of sites is required.
    1818 *
    1919 * @since 4.4.0
     20 *
     21 * @property string $site_id
    2022 */
    2123class WP_Network {
    2224
     
    5860         * A numeric string, for compatibility reasons.
    5961         *
    6062         * @since 4.4.0
    61          * @access public
     63         * @access private
    6264         * @var string
    6365         */
    64         public $blog_id = 0;
     66        private $blog_id = 0;
    6567
    6668        /**
    6769         * Domain used to set cookies for this network.
     
    138140        }
    139141
    140142        /**
     143         * Getter.
     144         *
     145         * Allows current multisite naming conventions when getting properties.
     146         *
     147         * @since 4.6.0
     148         * @access public
     149         *
     150         * @param string $key Property to get.
     151         * @return mixed Value of the property. Null if not available.
     152         */
     153        public function __get( $key ) {
     154                switch ( $key ) {
     155                        case 'blog_id':
     156                        case 'site_id':
     157                                return $this->blog_id;
     158                }
     159
     160                return null;
     161        }
     162
     163        /**
     164         * Isset-er.
     165         *
     166         * Allows current multisite naming conventions when checking for properties.
     167         *
     168         * @since 4.6.0
     169         * @access public
     170         *
     171         * @param string $key Property to check if set.
     172         * @return bool Whether the property is set.
     173         */
     174        public function __isset( $key ) {
     175                switch( $key ) {
     176                        case 'blog_id':
     177                        case 'site_id':
     178                                return true;
     179                }
     180
     181                return false;
     182        }
     183
     184        /**
     185         * Setter.
     186         *
     187         * Allows current multisite naming conventions while setting properties.
     188         *
     189         * @since 4.6.0
     190         * @access public
     191         *
     192         * @param string $key   Property to set.
     193         * @param mixed  $value Value to assign to the property.
     194         */
     195        public function __set( $key, $value ) {
     196                switch( $key ) {
     197                        case 'blog_id':
     198                        case 'site_id':
     199                                $this->blog_id = $value;
     200                                break;
     201                        default:
     202                                $this->$key = $value;
     203                }
     204        }
     205
     206        /**
    141207         * Set the site name assigned to the network if one has not been populated.
    142208         *
    143209         * @since 4.4.0
  • src/wp-includes/class-wp-site.php

     
    1414 * setup the current site.
    1515 *
    1616 * @since 4.5.0
     17 *
     18 * @property string $id
     19 * @property string $network_id
    1720 */
    1821final class WP_Site {
    1922
     
    2326         * A numeric string, for compatibility reasons.
    2427         *
    2528         * @since 4.5.0
    26          * @access public
     29         * @access private
    2730         * @var string
    2831         */
    29         public $blog_id;
     32        private $blog_id;
    3033
    3134        /**
    3235         * Domain of the site.
     
    5558         * A numeric string, for compatibility reasons.
    5659         *
    5760         * @since 4.5.0
    58          * @access public
     61         * @access private
    5962         * @var string
    6063         */
    61         public $site_id = '0';
     64        private $site_id = '0';
    6265
    6366        /**
    6467         * The date on which the site was created or registered.
     
    210213        public function to_array() {
    211214                return get_object_vars( $this );
    212215        }
     216
     217        /**
     218         * Getter.
     219         *
     220         * Allows current multisite naming conventions when getting properties.
     221         *
     222         * @since 4.6.0
     223         * @access public
     224         *
     225         * @param string $key Property to get.
     226         * @return mixed Value of the property. Null if not available.
     227         */
     228        public function __get( $key ) {
     229                switch ( $key ) {
     230                        case 'id':
     231                        case 'blog_id':
     232                                return $this->blog_id;
     233                        case 'site_id':
     234                        case 'network_id':
     235                                return $this->site_id;
     236                }
     237
     238                return null;
     239        }
     240
     241        /**
     242         * Isset-er.
     243         *
     244         * Allows current multisite naming conventions when checking for properties.
     245         *
     246         * @since 4.6.0
     247         * @access public
     248         *
     249         * @param string $key Property to check if set.
     250         * @return bool Whether the property is set.
     251         */
     252        public function __isset( $key ) {
     253                switch ( $key ) {
     254                        case 'id':
     255                        case 'blog_id':
     256                        case 'site_id':
     257                        case 'network_id':
     258                                return true;
     259                }
     260
     261                return false;
     262        }
     263
     264        /**
     265         * Setter.
     266         *
     267         * Allows current multisite naming conventions while setting properties.
     268         *
     269         * @since 4.6.0
     270         * @access public
     271         *
     272         * @param string $key   Property to set.
     273         * @param mixed  $value Value to assign to the property.
     274         */
     275        public function __set( $key, $value ) {
     276                switch( $key ) {
     277                        case 'id':
     278                        case 'blog_id':
     279                                $this->blog_id = $value;
     280                                break;
     281                        case 'site_id':
     282                        case 'network_id':
     283                                $this->site_id = $value;
     284                                break;
     285                        default:
     286                                $this->$key = $value;
     287                }
     288        }
    213289}