From df3bd5ecb0216599abdc40af584d0905f5ea0c5b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 9 Jun 2020 15:29:57 +0000 Subject: [PATCH] Docs: Improve documentation for `is_active_sidebar()`. The function determines whether the sidebar contains widgets, not that it is loaded on the page. Props SUM1. Fixes #50347. git-svn-id: https://develop.svn.wordpress.org/trunk@47935 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/widgets.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/widgets.php b/src/wp-includes/widgets.php index 34efd13e5e..6e1ed5ad36 100644 --- a/src/wp-includes/widgets.php +++ b/src/wp-includes/widgets.php @@ -900,11 +900,13 @@ function is_active_widget( $callback = false, $widget_id = false, $id_base = fal * @global array $wp_registered_widgets * @global array $wp_registered_sidebars Registered sidebars. * - * @return bool True, if using widgets. False, if not using widgets. + * @return bool True if using widgets, false otherwise. */ 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 ) { @@ -914,11 +916,12 @@ function is_dynamic_sidebar() { } } } + return false; } /** - * Determines whether a sidebar is in use. + * Determines whether a sidebar contains widgets. * * For more information on this and similar theme functions, check out * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ @@ -927,7 +930,7 @@ function is_dynamic_sidebar() { * @since 2.8.0 * * @param string|int $index Sidebar name, id or number to check. - * @return bool true if the sidebar is in use, false otherwise. + * @return bool True if the sidebar has widgets, false otherwise. */ function is_active_sidebar( $index ) { $index = ( is_int( $index ) ) ? "sidebar-$index" : sanitize_title( $index );