WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/19/2017 11:59:16 PM (3 years ago)
Author:
flixos90
Message:

Multisite: Add $network_id parameter to wp_update_network_site_counts().

Using the new parameter, it is now possible to update the site counts on a network different from the current network.

Props PieWP, johnjamesjacoby.
Fixes #37528. See #38699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r40391 r40484  
    23302330 *
    23312331 * @since 3.7.0
    2332  *
    2333  * @global wpdb $wpdb WordPress database abstraction object.
    2334  */
    2335 function wp_update_network_site_counts() {
    2336     global $wpdb;
     2332 * @since 4.8.0 The $network_id parameter has been added.
     2333 *
     2334 * @param int|null $network_id ID of the network. Default is the current network.
     2335 */
     2336function wp_update_network_site_counts( $network_id = null ) {
     2337    $network_id = (int) $network_id;
     2338    if ( ! $network_id ) {
     2339        $network_id = get_current_network_id();
     2340    }
    23372341
    23382342    $count = get_sites( array(
    2339         'network_id' => $wpdb->siteid,
     2343        'network_id' => $network_id,
    23402344        'spam'       => 0,
    23412345        'deleted'    => 0,
     
    23442348    ) );
    23452349
    2346     update_site_option( 'blog_count', $count );
     2350    update_network_option( $network_id, 'blog_count', $count );
    23472351}
    23482352
Note: See TracChangeset for help on using the changeset viewer.