WordPress.org

Make WordPress Core

Ticket #40513: 40513.diff

File 40513.diff, 2.2 KB (added by spacedmonkey, 2 years ago)
  • src/wp-includes/ms-blogs.php

     
    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;
     
    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, false );
    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, false );
    933938
    934939        // If we still have items in the switched stack, consider ourselves still 'switched'
    935940        $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );