函数原型
is_dynamic_sidebar(): bool
函数描述
Determines whether the dynamic sidebar is enabled and used by the theme.
是否弃用
未弃用
函数参数
无
函数返回值
bool True if using widgets, false otherwise.
函数位置
File: wp-includes/widgets.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;
}
源码链接
变更日志
| Version | Description |
|---|---|
| 2.2.0 | Introduced. |

