Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 12 years ago

Last modified 11 years ago

#2616 closed enhancement (worksforme)

Add a hook to unregister Sidebars in BP-Default from Child Theme functions.php

Reported by: bowromir's profile Bowromir Owned by:
Milestone: 1.5 Priority: normal
Severity: normal Version:
Component: Core Keywords: sidebar register, bp-default, child theme
Cc: Bowromir

Description

I would like to see a hook added to the Parent Theme to allow Child Themes to deregister the Sidebar. The hook would be as follows:

/* Register the widget columns */
register_sidebars( 
	array(
		'name' => 'Sidebar',
		'before_widget' => '<div id="widgetbox" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widgettitle">',
		'after_title' => '</h3>'
	)
	add_action( 'widgets_init', 'childtheme_sidebars' );
);

The sidebars can be added or removed with:

//functions.php im Child-Theme
function unregister_sidebar() {
    unregister_sidebar('Sidebar');
}
add_action( 'childtheme_sidebars', 'unregister_sidebar' )

This would make it easier to keep the widget area clean for the site admin.

Change History (6)

#1 @Bowromir
12 years ago

Small typo made.. the first code should be:

/* Register the widget columns */
register_sidebars( 
	array(
		'name' => 'Sidebar',
		'before_widget' => '<div id="%1$s" class="widget %2$s">',
		'after_widget' => '</div>',
		'before_title' => '<h3 class="widgettitle">',
		'after_title' => '</h3>'
	)
	add_action( 'widgets_init', 'childtheme_sidebars' );
);

#2 @Bowromir
12 years ago

  • Cc Bowromir added

#3 @DJPaul
12 years ago

I would expect that the call to unregister_sidebar in yor child theme's functions.php would work?

#4 @boonebgorges
12 years ago

  • Milestone changed from 1.3 to Future Release

#5 @boonebgorges
12 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

Actually, I take back that milestone change. Put the following in your child theme to unregister bp-default's sidebar:

function unregister_bp_sidebar() {
	unregister_sidebar( 'sidebar-1' );
}
add_action( 'wp_head', 'unregister_bp_sidebar' );

I'm not entirely sure why it has to be hooked so late in the process ('wp_head') but it does.

#6 @johnjamesjacoby
11 years ago

  • Keywords changed from sidebar, register, bp-default, child theme to sidebar register, bp-default, child theme
  • Milestone changed from Future Release to 1.5
  • Severity set to normal

Moving closed ticket out of Future Release.

Note: See TracTickets for help on using tickets.