Skip to:
Content

BuddyPress.org

Changeset 8830


Ignore:
Timestamp:
08/13/2014 07:56:31 PM (10 years ago)
Author:
r-a-y
Message:

Fix bp_is_current_component_core() to reference BP core components.

bp_is_current_component_core() is a function that is meant to check
whether the current component is a BP bundled core component. This is done
by grabbing bp_get_option( 'bp-active-components' ), which is supposed to
hold only BP core components. However, if a plugin manually saves its
component in the 'bp-active-components' DB option, our function will
now check this 3rd-party component as well, which is incorrect.

To address this issue, this commit introduces bp_core_get_components(),
which is a hardcoded array of BP core components, and references this
function in bp_is_current_component_core(). This ensures that only
BP core components are checked.

See #5552.

Location:
trunk/src/bp-core
Files:
2 edited

Legend:

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

    r8707 r8830  
    337337
    338338/** Directory *****************************************************************/
     339
     340/**
     341 * Returns an array of core components.
     342 *
     343 * @since BuddyPress (2.1.0)
     344 *
     345 * @return array
     346 */
     347function bp_core_get_components() {
     348    return array(
     349        'activity',
     350        'members',
     351        'groups',
     352        'blogs',
     353        'xprofile',
     354        'friends',
     355        'messages',
     356        'settings',
     357        'notifications',
     358        'forums',
     359    );
     360}
    339361
    340362/**
  • trunk/src/bp-core/bp-core-template.php

    r8705 r8830  
    15381538 */
    15391539function bp_is_current_component_core() {
    1540     $retval            = false;
    1541     $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
    1542 
    1543     foreach ( array_keys( $active_components ) as $active_component ) {
     1540    $retval = false;
     1541
     1542    foreach ( bp_core_get_components() as $active_component ) {
    15441543        if ( bp_is_current_component( $active_component ) ) {
    15451544            $retval = true;
Note: See TracChangeset for help on using the changeset viewer.