Multisite: Introduce `get_network()`.
Given a network ID or network object, `get_network()` retrieves network data in the same vein as `get_site()` or `get_post()`. This will allow for clean retrieval of networks from a primed cache when `WP_Network_Query` is implemented. Props flixos90. See #32504. Built from https://develop.svn.wordpress.org/trunk@37893 git-svn-id: http://core.svn.wordpress.org/trunk@37834 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5bf4b20d31
commit
5d478fbe5e
|
@ -1071,6 +1071,49 @@ function get_last_updated( $deprecated = '', $start = 0, $quantity = 40 ) {
|
|||
return $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' AND last_updated != '0000-00-00 00:00:00' ORDER BY last_updated DESC limit %d, %d", $wpdb->siteid, $start, $quantity ) , ARRAY_A );
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves network data given a network ID or network object.
|
||||
*
|
||||
* Network data will be cached and returned after being passed through a filter.
|
||||
* If the provided network is empty, the current network global will be used.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @global WP_Network $current_site
|
||||
*
|
||||
* @param WP_Network|int|null $network Network to retrieve.
|
||||
* @return WP_Network|null The network object or null if not found.
|
||||
*/
|
||||
function get_network( &$network = null ) {
|
||||
global $current_site;
|
||||
if ( empty( $network ) && isset( $current_site ) ) {
|
||||
$network = $current_site;
|
||||
}
|
||||
|
||||
if ( $network instanceof WP_Network ) {
|
||||
$_network = $network;
|
||||
} elseif ( is_object( $network ) ) {
|
||||
$_network = new WP_Network( $network );
|
||||
} else {
|
||||
$_network = WP_Network::get_instance( $network );
|
||||
}
|
||||
|
||||
if ( ! $_network ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires after a network is retrieved.
|
||||
*
|
||||
* @since 4.6.0
|
||||
*
|
||||
* @param WP_Network $_network Network data.
|
||||
*/
|
||||
$_network = apply_filters( 'get_network', $_network );
|
||||
|
||||
return $_network;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for updating the blog date when a post is published or an already published post is changed.
|
||||
*
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.6-alpha-37892';
|
||||
$wp_version = '4.6-alpha-37893';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue