Skip to:
Content

BuddyPress.org

Changeset 9555


Ignore:
Timestamp:
02/24/2015 01:48:42 PM (12 years ago)
Author:
johnjamesjacoby
Message:

Core: Allow custom components to continue to have directory pages.

Fixes regression introduced in 2.2. Props imath. See #6244. (trunk)

Location:
trunk
Files:
2 edited

Legend:

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

    r9544 r9555  
    308308        }
    309309
    310         $current_components = buddypress()->active_components;
     310        $current_components       = buddypress()->active_components;
     311        $packaged_components      = array_flip( bp_core_get_packaged_component_ids() );
     312        $custom_active_components = array_diff_key( $current_components, $packaged_components );
    311313
    312314        switch ( $current_action ) {
     
    316318                                if ( ! isset( $submitted[ $retired_component ] ) ) {
    317319                                        unset( $current_components[ $retired_component ] );
     320
     321                                        // Make sure custom components does not contain a retired component
     322                                        if ( isset( $custom_active_components[ $retired_component ] ) ) {
     323                                                unset( $custom_active_components[ $retired_component ] );
     324                                        }
    318325                                }
    319326                        }
     
    331338        }
    332339
    333         return $components;
     340        // Active components is the list of packaged and custom components
     341        return array_merge( $components, $custom_active_components );
    334342}
    335343
  • trunk/tests/phpunit/testcases/admin/functions.php

    r9478 r9555  
    3939        }
    4040
     41        /**
     42         * @group bp_core_admin_get_active_components_from_submitted_settings
     43         */
    4144        public function test_bp_core_admin_get_active_components_from_submitted_settings() {
    4245                $get_action = isset( $_GET['action'] ) ? $_GET['action'] : null;
     
    123126
    124127        /**
     128         * @group BP6244
     129         * @group bp_core_admin_get_active_components_from_submitted_settings
     130         */
     131        public function test_bp_core_admin_get_active_components_from_submitted_settings_should_keep_custom_component_directory_page() {
     132                $bp = buddypress();
     133                $reset_active_components = $bp->active_components;
     134
     135                // Create and activate the foo component
     136                $bp->foo = new BP_Component;
     137                $bp->foo->id   = 'foo';
     138                $bp->foo->slug = 'foo';
     139                $bp->foo->name = 'Foo';
     140                $bp->active_components[ $bp->foo->id ] = 1;
     141                $new_page_ids = array( $bp->foo->id => $this->factory->post->create( array(
     142                        'post_type'  => 'page',
     143                        'post_title' => $bp->foo->name,
     144                        'post_name'  => $bp->foo->slug,
     145                ) ) );
     146
     147                $page_ids = array_merge( $new_page_ids, (array) bp_core_get_directory_page_ids() );
     148                bp_core_update_directory_page_ids( $page_ids );
     149
     150                $bp->active_components = bp_core_admin_get_active_components_from_submitted_settings( $reset_active_components );
     151                bp_core_add_page_mappings( $bp->active_components );
     152
     153                $this->assertContains( $bp->foo->id, array_keys( bp_core_get_directory_page_ids() ) );
     154
     155                // Reset buddypress() vars
     156                $bp->active_components = $reset_active_components;
     157        }
     158
     159        /**
    125160         * @group bp_core_activation_notice
    126161         */
Note: See TracChangeset for help on using the changeset viewer.