Multisite: Introduce get_site()
Given a site ID or site object, `get_site()` retrieves site data in the same vein as `get_post()` or `get_comment()`. This will allow for clean retrieval of sites from a primed cache when `WP_Site_Query` is implemented. Adds a `WP_Site::to_array()` method to support multiple return types within `get_site()`. Props spacedmonkey. See #35791. Built from https://develop.svn.wordpress.org/trunk@37468 git-svn-id: http://core.svn.wordpress.org/trunk@37436 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -198,4 +198,16 @@ final class WP_Site {
|
||||
$this->$key = $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an object to array.
|
||||
*
|
||||
* @since 4.6.0
|
||||
* @access public
|
||||
*
|
||||
* @return array Object as array.
|
||||
*/
|
||||
public function to_array() {
|
||||
return get_object_vars( $this );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user