WordPress at a glance

is_dynamic_sidebar() WP 1.0

Whether the dynamic sidebar is enabled and used by theme.

  • Global. Array. $wp_registered_widgets
  • Global. Array. $wp_registered_sidebars

No Hooks.

Return

true/false. True, if using widgets. False, if not using widgets.

Usage

is_dynamic_sidebar();

Code of is_dynamic_sidebar: wp-includes/widgets.php VER 4.9.8

<?php
function is_dynamic_sidebar() {
	global $wp_registered_widgets, $wp_registered_sidebars;
	$sidebars_widgets = get_option('sidebars_widgets');
	foreach ( (array) $wp_registered_sidebars as $index => $sidebar ) {
		if ( ! empty( $sidebars_widgets[ $index ] ) ) {
			foreach ( (array) $sidebars_widgets[$index] as $widget )
				if ( array_key_exists($widget, $wp_registered_widgets) )
					return true;
		}
	}
	return false;
}

Related Functions

From tag: Sidebar (widgets)

More from tag: Conditional tags (all)

More from Template Tags: Main Functions

No comments
    Hello, !     Log In . Register