Skip to:
Content

BuddyPress.org

Ticket #7654: 7654-2.diff

File 7654-2.diff, 5.9 KB (added by DJPaul, 6 years ago)
  • src/bp-core/admin/bp-core-admin-components.php

    diff --git a/src/bp-core/admin/bp-core-admin-components.php b/src/bp-core/admin/bp-core-admin-components.php
    index 79f20d6db..7cbad26d1 100644
    a b function bp_core_admin_components_options() { 
    5151
    5252        // Declare local variables.
    5353        $deactivated_components = array();
    54 
    55         /**
    56          * Filters the array of available components.
    57          *
    58          * @since 1.5.0
    59          *
    60          * @param mixed $value Active components.
    61          */
    62         $active_components      = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
     54        $active_components = bp_core_get_active_components();
    6355
    6456        // The default components (if none are previously selected).
    6557        $default_components = array(
  • src/bp-core/admin/bp-core-admin-schema.php

    diff --git a/src/bp-core/admin/bp-core-admin-schema.php b/src/bp-core/admin/bp-core-admin-schema.php
    index 02a410ba9..438859549 100644
    a b function bp_core_install( $active_components = false ) { 
    2626
    2727        // If no components passed, get all the active components from the main site.
    2828        if ( empty( $active_components ) ) {
    29 
    30                 /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
    31                 $active_components = apply_filters( 'bp_active_components', bp_get_option( 'bp-active-components' ) );
     29                $active_components = bp_core_get_active_components();
    3230        }
    3331
    3432        // Install Activity Streams even when inactive (to store last_activity data).
  • src/bp-core/bp-core-functions.php

    diff --git a/src/bp-core/bp-core-functions.php b/src/bp-core/bp-core-functions.php
    index d88db32d9..51ffbf1c9 100644
    a b function bp_core_get_components( $type = 'all' ) { 
    25272527        return apply_filters( 'bp_core_get_components', $components, $type );
    25282528}
    25292529
     2530/**
     2531 * Return a list of active components.
     2532 *
     2533 * @since 3.0.0
     2534 *
     2535 * @return array Active components.
     2536 */
     2537function bp_core_get_active_components() {
     2538        $active_components = bp_get_option( 'bp-active-components' );
     2539
     2540        /**
     2541         * Filters the list of active components.
     2542         *
     2543         * @since 1.5.0
     2544         *
     2545         * @param array $active_components Array of active component information.
     2546         */
     2547        return apply_filters( 'bp_active_components', $active_components );
     2548}
     2549
     2550/**
     2551 * Return a list of inactive (or "deactivated") components.
     2552 *
     2553 * @since 3.0.0
     2554 *
     2555 * @return array Inactive components.
     2556 */
     2557function bp_core_get_inactive_components() {
     2558        $inactive_components = array_values(
     2559                array_diff(
     2560                        array_values(
     2561                                array_merge( $bp->optional_components, $bp->required_components )
     2562                        ),
     2563                        array_keys(
     2564                                bp_core_get_active_components()
     2565                        )
     2566                )
     2567        );
     2568
     2569        /**
     2570         * Filters the list of inactive (or "deactivated") components.
     2571         *
     2572         * The filter is named "deactivated" rather than "inactive" for backwards compatibility reasons.
     2573         *
     2574         * @since 3.0.0
     2575         *
     2576         * @param array $inactive_components Inactive components.
     2577         */
     2578        return apply_filters( 'bp_deactivated_components', $inactive_components );
     2579}
     2580
    25302581/** Nav Menu ******************************************************************/
    25312582
    25322583/**
  • src/bp-core/classes/class-bp-core.php

    diff --git a/src/bp-core/classes/class-bp-core.php b/src/bp-core/classes/class-bp-core.php
    index 2afcf77c8..70af4cfd9 100644
    a b class BP_Core extends BP_Component { 
    7676                 */
    7777                $bp->required_components = apply_filters( 'bp_required_components', array( 'members' ) );
    7878
    79                 // Get a list of activated components.
    80                 if ( $active_components = bp_get_option( 'bp-active-components' ) ) {
     79                $active_components      = bp_core_get_active_components();
     80                $deactivated_components = bp_get_option( 'bp-deactivated-components' );
    8181
    82                         /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
    83                         $bp->active_components      = apply_filters( 'bp_active_components', $active_components );
     82                if ( $active_components ) {
     83                        $bp->active_components = $active_components;
    8484
    8585                        /**
    8686                         * Filters the deactivated components.
    class BP_Core extends BP_Component { 
    9292                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', array_values( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_keys( $bp->active_components ) ) ) );
    9393
    9494                // Pre 1.5 Backwards compatibility.
    95                 } elseif ( $deactivated_components = bp_get_option( 'bp-deactivated-components' ) ) {
     95                } elseif ( $deactivated_components ) {
    9696
    9797                        // Trim off namespace and filename.
    9898                        foreach ( array_keys( (array) $deactivated_components ) as $component ) {
    9999                                $trimmed[] = str_replace( '.php', '', str_replace( 'bp-', '', $component ) );
    100100                        }
    101101
    102                         /** This filter is documented in bp-core/bp-core-loader.php */
     102                        /** This filter is documented in bp-core/bp-core-functions.php */
    103103                        $bp->deactivated_components = apply_filters( 'bp_deactivated_components', $trimmed );
    104104
    105105                        // Setup the active components.
    106106                        $active_components     = array_fill_keys( array_diff( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), array_values( $bp->deactivated_components ) ), '1' );
    107107
    108                         /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
     108                        /** This filter is documented in bp-core/bp-core-functions.php */
    109109                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
    110110
    111111                // Default to all components active.
    class BP_Core extends BP_Component { 
    117117                        // Setup the active components.
    118118                        $active_components     = array_fill_keys( array_values( array_merge( $bp->optional_components, $bp->required_components ) ), '1' );
    119119
    120                         /** This filter is documented in bp-core/admin/bp-core-admin-components.php */
     120                        /** This filter is documented in bp-core/bp-core-functions.php */
    121121                        $bp->active_components = apply_filters( 'bp_active_components', $bp->active_components );
    122122                }
    123123