WordPress.org

Make WordPress Core

Changeset 47105


Ignore:
Timestamp:
01/22/2020 08:51:26 PM (23 months ago)
Author:
iandunn
Message:

Multisite: Add $context parameter to switch_blog action.

The action is fired by both switch_to_blog() and restore_current_blog(), and previously it was difficult for callback functions to determine which function had fired it.

Props SergeyBiryukov, johnbillion, jeremyfelt.
Fixes #49265.

File:
1 edited

Legend:

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

    r46823 r47105  
    509509         *
    510510         * @since MU (3.0.0)
     511         * @since 5.4.0 The `$context` parameter was added.
    511512         *
    512          * @param int $new_blog_id  New blog ID.
    513          * @param int $prev_blog_id Previous blog ID.
     513         * @param int    $new_blog_id  New blog ID.
     514         * @param int    $prev_blog_id Previous blog ID.
     515         * @param string $context      Additional context. Accepts 'switch' when called from switch_to_blog()
     516         *                             or 'restore' when called from restore_current_blog().
    514517         */
    515         do_action( 'switch_blog', $new_blog_id, $prev_blog_id );
     518        do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' );
    516519        $GLOBALS['switched'] = true;
    517520        return true;
     
    545548
    546549    /** This filter is documented in wp-includes/ms-blogs.php */
    547     do_action( 'switch_blog', $new_blog_id, $prev_blog_id );
     550    do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'switch' );
    548551    $GLOBALS['switched'] = true;
    549552
     
    578581    if ( $new_blog_id == $prev_blog_id ) {
    579582        /** This filter is documented in wp-includes/ms-blogs.php */
    580         do_action( 'switch_blog', $new_blog_id, $prev_blog_id );
     583        do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );
    581584        // If we still have items in the switched stack, consider ourselves still 'switched'
    582585        $GLOBALS['switched'] = ! empty( $GLOBALS['_wp_switched_stack'] );
     
    612615
    613616    /** This filter is documented in wp-includes/ms-blogs.php */
    614     do_action( 'switch_blog', $new_blog_id, $prev_blog_id );
     617    do_action( 'switch_blog', $new_blog_id, $prev_blog_id, 'restore' );
    615618
    616619    // If we still have items in the switched stack, consider ourselves still 'switched'
Note: See TracChangeset for help on using the changeset viewer.