Make WordPress Core


Ignore:
Timestamp:
09/27/2017 09:43:59 PM (7 years ago)
Author:
flixos90
Message:

Multisite: Improve initializing available roles when switch sites.

Switching the available roles and the current user's capabilities no longer happens in switch_to_blog() and restore_current_blog(), instead it has been moved to a new function wp_switch_roles_and_user() which is hooked into the site switching process. This allows to improve performance by temporarily unhooking the function when roles and capabilities do not need to be switched.

This change ensures that switching available roles now works closer to switching user capabilities, particularly the changes in [41624]. A new WP_Roles::for_site( $site_id ) method has been introduced, and the WP_Roles::_init() method has been deprecated. It is furthermore possible to retrieve the site ID for which the available roles are currently initialized through a new WP_Roles::get_site_id().

Props johnjamesjacoby, flixos90.
Fixes #38645.

File:
1 edited

Legend:

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

    r40596 r41625  
    3232add_action( 'network_user_new_created_user',   'wp_send_new_user_notifications' );
    3333add_filter( 'sanitize_user', 'strtolower' );
     34
     35// Roles
     36add_action( 'switch_blog', 'wp_switch_roles_and_user', 1, 2 );
    3437
    3538// Blogs
Note: See TracChangeset for help on using the changeset viewer.