Skip to:
Content

BuddyPress.org

Changeset 10746


Ignore:
Timestamp:
05/12/2016 06:05:27 PM (8 years ago)
Author:
djpaul
Message:

Core: modify bp_locate_template() to support loading templates in code executed inside the wp-admin scope.

The recent Emails and Avatars changes showed a weakness in the function where we were unable to load BuddyPress templates inside wp-admin because the constants WP_USE_THEMES and DOING_AJAX are falsey. These checks were introduced in r7842 and r7837, seemingly to prevent errors during PHPUnit runs.

As our test environment has improved over the intervening years and because none of our tests are currently producing errors when these checks are removed, we can safely revert them and give ourselves a more flexible function.

Fixes #6914

Props DJPaul, imath

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-template-loader.php

    r10594 r10746  
    124124    do_action( 'bp_locate_template', $located, $template_name, $template_names, $template_locations, $load, $require_once );
    125125
    126     // Maybe load the template if one was located.
    127     $use_themes = defined( 'WP_USE_THEMES' ) && WP_USE_THEMES;
    128     $doing_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX;
    129 
    130126    /**
    131127     * Filter here to allow/disallow template loading.
     
    135131     * @param bool $value True to load the template, false otherwise.
    136132     */
    137     $load_template = (bool) apply_filters( 'bp_locate_template_and_load', $use_themes || $doing_ajax );
    138 
    139     if ( $load_template && ( true == $load ) && ! empty( $located ) ) {
     133    $load_template = (bool) apply_filters( 'bp_locate_template_and_load', true );
     134
     135    if ( $load_template && $load && ! empty( $located ) ) {
    140136        load_template( $located, $require_once );
    141137    }
Note: See TracChangeset for help on using the changeset viewer.