Opened 7 years ago
Closed 7 years ago
#7628 closed defect (bug) (fixed)
BuddyPress Theme compatibility not working properly when default_subnav_slug is not specified for a component
Reported by: | sbrajesh | Owned by: | djpaul |
---|---|---|---|
Milestone: | 3.0 | Priority: | normal |
Severity: | minor | Version: | |
Component: | Members | Keywords: | |
Cc: | sbrajesh |
Description
BuddyPress allows registering a component(nav) without specifying the default_subnav_slug. In the current implementation if you do not specify default_subnav_slug, the theme compatibility does not work properly.
It treats the component page as members directory instead of user section. The reason is the condition check in class-bp-members-theme-compat.php
Intstead of checking for directory first, It should test for the user first. I other words, changing the order of conditions in is_members() fixes the issue.
The code
public function is_members() { // Bail if not looking at the members component or a user's page. if ( ! bp_is_members_component() && ! bp_is_user() ) { return; } // Members Directory. if ( ! bp_current_action() && ! bp_current_item() ) { bp_update_is_directory( true, 'members' ); /** * Fires if looking at Members directory when needing theme compat. * * @since 1.5.0 */ do_action( 'bp_members_screen_index' ); add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) ); add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); // User page. } elseif ( bp_is_user() ) { // If we're on a single activity permalink page, we shouldn't use the members // template, so stop here! if ( bp_is_active( 'activity' ) && bp_is_single_activity() ) { return; } /** * Fires if looking at Members user page when needing theme compat. * * @since 1.5.0 */ do_action( 'bp_members_screen_display_profile' ); add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) ); add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post' ) ); add_filter( 'bp_replace_the_content', array( $this, 'single_dummy_content' ) ); } }
needs to be changed to this
public function is_members() { // Bail if not looking at the members component or a user's page. if ( ! bp_is_members_component() && ! bp_is_user() ) { return; } // User page. if ( bp_is_user() ) { // If we're on a single activity permalink page, we shouldn't use the members // template, so stop here! if ( bp_is_active( 'activity' ) && bp_is_single_activity() ) { return; } /** * Fires if looking at Members user page when needing theme compat. * * @since 1.5.0 */ do_action( 'bp_members_screen_display_profile' ); add_filter( 'bp_get_buddypress_template', array( $this, 'single_template_hierarchy' ) ); add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'single_dummy_post' ) ); add_filter( 'bp_replace_the_content', array( $this, 'single_dummy_content' ) ); // Members Directory. } elseif ( ! bp_current_action() && ! bp_current_item() ) { bp_update_is_directory( true, 'members' ); /** * Fires if looking at Members directory when needing theme compat. * * @since 1.5.0 */ do_action( 'bp_members_screen_index' ); add_filter( 'bp_get_buddypress_template', array( $this, 'directory_template_hierarchy' ) ); add_action( 'bp_template_include_reset_dummy_post_data', array( $this, 'directory_dummy_post' ) ); add_filter( 'bp_replace_the_content', array( $this, 'directory_content' ) ); } }
It will be nice to have a fix in 3.0
Thank you.
In 11748: