Re: create subnav not working with child theme
here are my code :
it work on bp default theme but going to mainpage after click Profile when using child theme.
anyone know the problem? thanks
/
/
function bp_badge_setup_nav() {
global $bp;
$profile_link = $bp->loggedin_user->domain . $bp->profile->slug . ‘/’;
/* Create sub nav item for this component */
bp_core_new_subnav_item( array(
‘name’ => __( ‘Badge’, ‘bp-badge’ ),
‘slug’ => ‘badge’,
‘parent_slug’ => $bp->profile->slug,
‘parent_url’ => $profile_link,
‘screen_function’ => ‘bp_badge_screen’,
‘position’ => 50,
‘user_has_access’ => bp_is_my_profile()
) );
}
add_action( ‘wp’, ‘bp_badge_setup_nav’, 2);
add_action( ‘admin_menu’, ‘bp_badge_setup_nav’, 2 );
/
/
function bp_badge_load_template_filter( $found_template, $templates ) {
global $bp;
if ( $bp->current_component != $bp->profile->slug && $bp->current_action !
‘badge’)
return $found_template;
foreach ( (array) $templates as $template ) {
if ( file_exists( STYLESHEETPATH . ‘/’ . $template ) )
$filtered_templates[] = STYLESHEETPATH . ‘/’ . $template;
else
$filtered_templates[] = dirname( __FILE__ ) . ‘/templates/’ . $template;
}
$found_template = $filtered_templates[0];
return apply_filters( ‘bp_badge_load_template_filter’, $found_template );
}
add_filter( ‘bp_located_template’, ‘bp_badge_load_template_filter’, 10, 2 );
/
/
function bp_badge_screen() {
global $bp;
/* Add a do action here, so your component can be extended by others. */
do_action( ‘bp_badge_screen’ );
/* This is going to look in wp-content/plugins/[plugin-name]/includes/templates/ first */
bp_core_load_template( apply_filters( ‘bp_badge_template_screen’, ‘badge/screen’ ) );
}