Make WordPress Core

Ticket #40513: 40513.3.diff

File 40513.3.diff, 6.5 KB (added by spacedmonkey, 7 years ago)
  • src/wp-admin/includes/class-wp-ms-sites-list-table.php

     
    330330                </strong>
    331331                <?php
    332332                if ( 'list' !== $mode ) {
    333                         switch_to_blog( $blog['blog_id'] );
     333                        switch_to_blog( get_site( $blog['blog_id'] ) );
    334334                        echo '<p>';
    335335                        printf(
    336336                                /* translators: 1: site name, 2: site tagline. */
  • src/wp-admin/includes/ms.php

     
    231231
    232232        if ( ! empty( $blogs ) ) {
    233233                foreach ( $blogs as $blog ) {
    234                         switch_to_blog( $blog->userblog_id );
     234                        switch_to_blog( get_site( $blog ) );
    235235                        remove_user_from_blog( $id, $blog->userblog_id );
    236236
    237237                        $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) );
  • src/wp-admin/network/site-themes.php

     
    6969$is_main_site = is_main_site( $id );
    7070
    7171if ( $action ) {
    72         switch_to_blog( $id );
     72        switch_to_blog( $details );
    7373        $allowed_themes = get_option( 'allowedthemes' );
    7474
    7575        switch ( $action ) {
  • src/wp-admin/network/site-users.php

     
    6161
    6262$is_main_site = is_main_site( $id );
    6363
    64 switch_to_blog( $id );
     64switch_to_blog( $details );
    6565
    6666$action = $wp_list_table->current_action();
    6767
  • src/wp-includes/admin-bar.php

     
    508508        ) );
    509509
    510510        foreach ( (array) $wp_admin_bar->user->blogs as $blog ) {
    511                 switch_to_blog( $blog->userblog_id );
     511                switch_to_blog( get_site( $blog ) );
    512512
    513513                $blavatar = '<div class="blavatar"></div>';
    514514
  • src/wp-includes/class-wp-site.php

     
    334334
    335335                if ( false === $details ) {
    336336
    337                         switch_to_blog( $this->blog_id );
     337                        switch_to_blog( $this );
    338338                        // Create a raw copy of the object for backwards compatibility with the filter below.
    339339                        $details = new stdClass();
    340340                        foreach ( get_object_vars( $this ) as $key => $value ) {
  • src/wp-includes/class-wp-xmlrpc-server.php

     
    632632                                continue;
    633633
    634634                        $blog_id = $blog->userblog_id;
    635 
    636                         switch_to_blog( $blog_id );
     635                        $site = get_site( $blog );
     636                        switch_to_blog( $site );
    637637
    638638                        $is_admin = current_user_can( 'manage_options' );
    639639                        $is_primary = ( (int) $blog_id === $primary_blog_id );
  • src/wp-includes/ms-blogs.php

     
    229229                return $details;
    230230        }
    231231
    232         switch_to_blog( $blog_id );
     232        switch_to_blog( $details );
    233233        $details->blogname   = get_option( 'blogname' );
    234234        $details->siteurl    = get_option( 'siteurl' );
    235235        $details->post_count = get_option( 'post_count' );
     
    788788 * @global string          $table_prefix
    789789 * @global WP_Object_Cache $wp_object_cache
    790790 *
    791  * @param int  $new_blog   The id of the blog you want to switch to. Default: current blog
     791 * @param WP_Site|int  $new_blog   The id of the blog you want to switch to. Default: current blog
    792792 * @param bool $deprecated Deprecated argument
    793793 * @return true Always returns True.
    794794 */
     
    796796        global $wpdb, $wp_roles;
    797797
    798798        $blog_id = get_current_blog_id();
     799        $site_object = false;
    799800        if ( empty( $new_blog ) ) {
    800801                $new_blog = $blog_id;
     802        } else if ( $new_blog instanceof WP_Site ) {
     803                $site_object = $new_blog;
     804                $new_blog = $site_object->blog_id;
    801805        }
    802806
    803807        $GLOBALS['_wp_switched_stack'][] = $blog_id;
     
    815819                 *
    816820                 * @param int $new_blog New blog ID.
    817821                 * @param int $new_blog Blog ID.
     822                 * @param WP_Site $site_object Optional Site object.
    818823                 */
    819                 do_action( 'switch_blog', $new_blog, $new_blog );
     824                do_action( 'switch_blog', $new_blog, $new_blog, $site_object );
    820825                $GLOBALS['switched'] = true;
    821826                return true;
    822827        }
     
    855860        }
    856861
    857862        /** This filter is documented in wp-includes/ms-blogs.php */
    858         do_action( 'switch_blog', $new_blog, $prev_blog_id );
     863        do_action( 'switch_blog', $new_blog, $prev_blog_id, $site_object );
    859864        $GLOBALS['switched'] = true;
    860865
    861866        return true;
     
    877882 * @return bool True on success, false if we're already on the current blog
    878883 */
    879884function restore_current_blog() {
    880         global $wpdb, $wp_roles;
     885        global $wpdb, $wp_roles, $current_blog;
    881886
    882887        if ( empty( $GLOBALS['_wp_switched_stack'] ) ) {
    883888                return false;
     
    888893
    889894        if ( $blog_id == $blog ) {
    890895                /** This filter is documented in wp-includes/ms-blogs.php */
    891                 do_action( 'switch_blog', $blog, $blog );
     896                do_action( 'switch_blog', $blog, $blog, $current_blog );
    892897                // If we still have items in the switched stack, consider ourselves still 'switched'
    893898                $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
    894899                return true;
     
    929934        }
    930935
    931936        /** This filter is documented in wp-includes/ms-blogs.php */
    932         do_action( 'switch_blog', $blog, $prev_blog_id );
     937        do_action( 'switch_blog', $blog, $prev_blog_id, $current_blog );
    933938
    934939        // If we still have items in the switched stack, consider ourselves still 'switched'
    935940        $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
  • src/wp-includes/ms-functions.php

     
    11701170        if ( ! $blog_id = insert_blog($domain, $path, $site_id) )
    11711171                return new WP_Error('insert_blog', __('Could not create site.'));
    11721172
    1173         switch_to_blog($blog_id);
     1173        switch_to_blog( get_site( $blog_id ) );
    11741174        install_blog($blog_id, $title);
    11751175        wp_install_defaults($user_id);
    11761176