Skip to:
Content

BuddyPress.org

Changeset 11223


Ignore:
Timestamp:
11/03/2016 08:47:31 AM (3 years ago)
Author:
djpaul
Message:

Core: remove wp->init() PHP notice from bp_setup_current_user() due to load order changes in WordPress 4.7.

In WordPress 4.7, the get_user_locale() function will always invoke the current user object before the init hook has fired.
This should cause no other regression for BuddyPress as we don't use primitive roles yet.

Fixes #7305 for the 2.7 branch, props johnjamesjacoby

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/src/bp-core/bp-core-dependency.php

    r10899 r11223  
    208208 * Set up the currently logged-in user.
    209209 *
    210  * We white-list the WordPress Customizer which purposely loads the user early.
    211  * If the current user is being setup before the "init" action has fired,
    212  * strange (and difficult to debug) role/capability issues will occur.
    213  *
    214210 * @since 1.7.0
    215211 *
     
    218214 */
    219215function bp_setup_current_user() {
    220     $skip_warning = (
    221         ( isset( $_REQUEST['wp_customize'] ) && 'on' === $_REQUEST['wp_customize'] ) ||
    222         ( is_admin() && 'customize.php' === basename( $_SERVER['PHP_SELF'] ) )
    223     );
    224 
    225     if ( ! $skip_warning && ! did_action( 'after_setup_theme' ) ) {
    226         $e = new Exception;
    227         $trace = $e->getTraceAsString();
    228 
    229         _doing_it_wrong( __FUNCTION__, __( 'The current user is being initialized without using $wp->init().', 'buddypress' ) . "\n===\nTrace:\n" . substr( $trace, strpos( $trace, '#6' ) ) . "\n===\n", '1.7' );
    230     }
    231216
    232217    /**
Note: See TracChangeset for help on using the changeset viewer.