WP_Site::__get() WordPress Method

The WP_Site::__get() method is used to get a value from a WordPress site object. The method takes two parameters: the name of the value to get, and an optional default value to return if the value does not exist.

WP_Site::__get( string $key ) #

Getter.


Description

Allows current multisite naming conventions when getting properties. Allows access to extended site properties.


Top ↑

Parameters

$key

(string)(Required)Property to get.


Top ↑

Return

(mixed) Value of the property. Null if not available.


Top ↑

Source

File: wp-includes/class-wp-site.php

	public function __get( $key ) {
		switch ( $key ) {
			case 'id':
				return (int) $this->blog_id;
			case 'network_id':
				return (int) $this->site_id;
			case 'blogname':
			case 'siteurl':
			case 'post_count':
			case 'home':
			default: // Custom properties added by 'site_details' filter.
				if ( ! did_action( 'ms_loaded' ) ) {
					return null;
				}

				$details = $this->get_details();
				if ( isset( $details->$key ) ) {
					return $details->$key;
				}
		}

		return null;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.6.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.