mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-07-01 07:40:07 +00:00
Multisite: Introduce the WP_Network class.
A `WP_Network` object initially matches a row from `wp_site` and is populated with additional properties used by WordPress core. The first iteration is used to retrieve an existing network based on data passed to the class. * A network can be retrieved by its ID through `WP_Network::get_instance()`, following in the steps of `WP_Post` and `WP_Comment`. * A network object can be created or completed by passing initial properties in as a standard object to `new WP_Network()`. Using these methods, we are now able to populate the global `$current_site` during load via this class. Props johnjamesjacoby, jeremyfelt, drewapicture, wonderboymusic. See #31985. git-svn-id: https://develop.svn.wordpress.org/trunk@34097 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -258,20 +258,16 @@ function get_network_by_path( $domain, $path, $segments = null ) {
|
||||
* Retrieve an object containing information about the requested network.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @global wpdb $wpdb
|
||||
* @since 4.4.0 Converted to leverage WP_Network
|
||||
*
|
||||
* @param object|int $network The network's database row or ID.
|
||||
* @return object|false Object containing network information if found, false if not.
|
||||
* @return WP_Network|false Object containing network information if found, false if not.
|
||||
*/
|
||||
function wp_get_network( $network ) {
|
||||
global $wpdb;
|
||||
|
||||
if ( ! is_object( $network ) ) {
|
||||
$network = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->site WHERE id = %d", $network ) );
|
||||
if ( ! $network ) {
|
||||
return false;
|
||||
}
|
||||
$network = WP_Network::get_instance( $network );
|
||||
} else {
|
||||
$network = new WP_Network( $network );
|
||||
}
|
||||
|
||||
return $network;
|
||||
|
||||
Reference in New Issue
Block a user