Skip to:
Content

BuddyPress.org

Ticket #4081: active_components-normalization.patch

File active_components-normalization.patch, 1.7 KB (added by chrisbliss18, 8 years ago)

Normalize the data structure of the $bp->active_components variable

  • bp-core/bp-core-loader.php

     
    7777                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
    7878
    7979                        // Setup the active components
    80                         $active_components     = array_flip( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ) );
     80                        $active_components = array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) );
    8181
    8282                        // Loop through active components and set the values
    83                         $bp->active_components = array_map( '__return_true', $active_components );
     83                        foreach ( $active_components as $active_component )
     84                                $bp->active_components[$active_component] = 1;
    8485
    8586                        // Set the active component global
    8687                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
     
    9293                        $bp->deactivated_components = array();
    9394
    9495                        // Setup the active components
    95                         $active_components     = array_flip( array_values( array_merge( $bp->optional_components, $bp->required_components ) ) );
     96                        $active_components = array_merge( $bp->optional_components, $bp->required_components );
    9697
    9798                        // Loop through active components and set the values
    98                         $bp->active_components = array_map( '__return_true', $active_components );
     99                        foreach ( $active_components as $active_component )
     100                                $bp->active_components[$active_component] = 1;
    99101
    100102                        // Set the active component global
    101103                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );