Edit File by line
/home/barbar84/www/wp-inclu...
File: ms-network.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Network API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Multisite
[5] Fix | Delete
* @since 5.1.0
[6] Fix | Delete
*/
[7] Fix | Delete
[8] Fix | Delete
/**
[9] Fix | Delete
* Retrieves network data given a network ID or network object.
[10] Fix | Delete
*
[11] Fix | Delete
* Network data will be cached and returned after being passed through a filter.
[12] Fix | Delete
* If the provided network is empty, the current network global will be used.
[13] Fix | Delete
*
[14] Fix | Delete
* @since 4.6.0
[15] Fix | Delete
*
[16] Fix | Delete
* @global WP_Network $current_site
[17] Fix | Delete
*
[18] Fix | Delete
* @param WP_Network|int|null $network Optional. Network to retrieve. Default is the current network.
[19] Fix | Delete
* @return WP_Network|null The network object or null if not found.
[20] Fix | Delete
*/
[21] Fix | Delete
function get_network( $network = null ) {
[22] Fix | Delete
global $current_site;
[23] Fix | Delete
if ( empty( $network ) && isset( $current_site ) ) {
[24] Fix | Delete
$network = $current_site;
[25] Fix | Delete
}
[26] Fix | Delete
[27] Fix | Delete
if ( $network instanceof WP_Network ) {
[28] Fix | Delete
$_network = $network;
[29] Fix | Delete
} elseif ( is_object( $network ) ) {
[30] Fix | Delete
$_network = new WP_Network( $network );
[31] Fix | Delete
} else {
[32] Fix | Delete
$_network = WP_Network::get_instance( $network );
[33] Fix | Delete
}
[34] Fix | Delete
[35] Fix | Delete
if ( ! $_network ) {
[36] Fix | Delete
return null;
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
/**
[40] Fix | Delete
* Fires after a network is retrieved.
[41] Fix | Delete
*
[42] Fix | Delete
* @since 4.6.0
[43] Fix | Delete
*
[44] Fix | Delete
* @param WP_Network $_network Network data.
[45] Fix | Delete
*/
[46] Fix | Delete
$_network = apply_filters( 'get_network', $_network );
[47] Fix | Delete
[48] Fix | Delete
return $_network;
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
/**
[52] Fix | Delete
* Retrieves a list of networks.
[53] Fix | Delete
*
[54] Fix | Delete
* @since 4.6.0
[55] Fix | Delete
*
[56] Fix | Delete
* @param string|array $args Optional. Array or string of arguments. See WP_Network_Query::parse_query()
[57] Fix | Delete
* for information on accepted arguments. Default empty array.
[58] Fix | Delete
* @return array|int List of WP_Network objects, a list of network IDs when 'fields' is set to 'ids',
[59] Fix | Delete
* or the number of networks when 'count' is passed as a query var.
[60] Fix | Delete
*/
[61] Fix | Delete
function get_networks( $args = array() ) {
[62] Fix | Delete
$query = new WP_Network_Query();
[63] Fix | Delete
[64] Fix | Delete
return $query->query( $args );
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Removes a network from the object cache.
[69] Fix | Delete
*
[70] Fix | Delete
* @since 4.6.0
[71] Fix | Delete
*
[72] Fix | Delete
* @global bool $_wp_suspend_cache_invalidation
[73] Fix | Delete
*
[74] Fix | Delete
* @param int|array $ids Network ID or an array of network IDs to remove from cache.
[75] Fix | Delete
*/
[76] Fix | Delete
function clean_network_cache( $ids ) {
[77] Fix | Delete
global $_wp_suspend_cache_invalidation;
[78] Fix | Delete
[79] Fix | Delete
if ( ! empty( $_wp_suspend_cache_invalidation ) ) {
[80] Fix | Delete
return;
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
foreach ( (array) $ids as $id ) {
[84] Fix | Delete
wp_cache_delete( $id, 'networks' );
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Fires immediately after a network has been removed from the object cache.
[88] Fix | Delete
*
[89] Fix | Delete
* @since 4.6.0
[90] Fix | Delete
*
[91] Fix | Delete
* @param int $id Network ID.
[92] Fix | Delete
*/
[93] Fix | Delete
do_action( 'clean_network_cache', $id );
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
wp_cache_set( 'last_changed', microtime(), 'networks' );
[97] Fix | Delete
}
[98] Fix | Delete
[99] Fix | Delete
/**
[100] Fix | Delete
* Updates the network cache of given networks.
[101] Fix | Delete
*
[102] Fix | Delete
* Will add the networks in $networks to the cache. If network ID already exists
[103] Fix | Delete
* in the network cache then it will not be updated. The network is added to the
[104] Fix | Delete
* cache using the network group with the key using the ID of the networks.
[105] Fix | Delete
*
[106] Fix | Delete
* @since 4.6.0
[107] Fix | Delete
*
[108] Fix | Delete
* @param array $networks Array of network row objects.
[109] Fix | Delete
*/
[110] Fix | Delete
function update_network_cache( $networks ) {
[111] Fix | Delete
foreach ( (array) $networks as $network ) {
[112] Fix | Delete
wp_cache_add( $network->id, $network, 'networks' );
[113] Fix | Delete
}
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
/**
[117] Fix | Delete
* Adds any networks from the given IDs to the cache that do not already exist in cache.
[118] Fix | Delete
*
[119] Fix | Delete
* @since 4.6.0
[120] Fix | Delete
* @access private
[121] Fix | Delete
*
[122] Fix | Delete
* @see update_network_cache()
[123] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[124] Fix | Delete
*
[125] Fix | Delete
* @param array $network_ids Array of network IDs.
[126] Fix | Delete
*/
[127] Fix | Delete
function _prime_network_caches( $network_ids ) {
[128] Fix | Delete
global $wpdb;
[129] Fix | Delete
[130] Fix | Delete
$non_cached_ids = _get_non_cached_ids( $network_ids, 'networks' );
[131] Fix | Delete
if ( ! empty( $non_cached_ids ) ) {
[132] Fix | Delete
$fresh_networks = $wpdb->get_results( sprintf( "SELECT $wpdb->site.* FROM $wpdb->site WHERE id IN (%s)", implode( ',', array_map( 'intval', $non_cached_ids ) ) ) ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
[133] Fix | Delete
[134] Fix | Delete
update_network_cache( $fresh_networks );
[135] Fix | Delete
}
[136] Fix | Delete
}
[137] Fix | Delete
[138] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function