WP_Site::__isset() WordPress Method

The WP_Site::__isset() method allows you to check whether a given site property exists. You can use this method to check if a given site property exists before attempting to access it. This can be useful for making sure that a site property exists before trying to use it.

WP_Site::__isset( string $key ) #

Isset-er.


Description

Allows current multisite naming conventions when checking for properties. Checks for extended site properties.


Top ↑

Parameters

$key

(string)(Required)Property to check if set.


Top ↑

Return

(bool) Whether the property is set.


Top ↑

Source

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

	public function __isset( $key ) {
		switch ( $key ) {
			case 'id':
			case 'network_id':
				return true;
			case 'blogname':
			case 'siteurl':
			case 'post_count':
			case 'home':
				if ( ! did_action( 'ms_loaded' ) ) {
					return false;
				}
				return true;
			default: // Custom properties added by 'site_details' filter.
				if ( ! did_action( 'ms_loaded' ) ) {
					return false;
				}

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

		return false;
	}


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.