From b1c90ff067c475e57bbbe98caab60694b63de5e4 Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Thu, 30 Apr 2009 04:26:34 +0000 Subject: [PATCH] Add is_active_sidebar(), props filosofo, fixes #4594 git-svn-id: https://develop.svn.wordpress.org/trunk@11134 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/widgets.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/wp-includes/widgets.php b/wp-includes/widgets.php index 35fe05f3bf..945af1ecc0 100644 --- a/wp-includes/widgets.php +++ b/wp-includes/widgets.php @@ -850,6 +850,23 @@ function is_dynamic_sidebar() { return false; } +/** + * Whether a sidebar is in use. + * + * @since 2.8 + * + * @param mixed $index, sidebar name, id or number to check. + * @return bool true if the sidebar is in use, false otherwise. + */ +function is_active_sidebar( $index ) { + $index = ( is_int($index) ) ? "sidebar-$index" : sanitize_title($index); + $sidebars_widgets = get_option( 'sidebars_widgets', array() ); + if ( isset($sidebars_widgets[$index]) && !empty($sidebars_widgets[$index]) ) + return true; + + return false; +} + /* Internal Functions */ /**