Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: dynamic_sidebar_has_widgets

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
1207      }
1208
1209      $sidebars_widgets = wp_get_sidebars_widgets();
1210      if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
1211           /** This action is documented in wp-includes/widgets.php */
1212           do_action( 'dynamic_sidebar_before', $index, false );
1213           /** This action is documented in wp-includes/widgets.php */
1214           do_action( 'dynamic_sidebar_after',  $index, false );
1215           /** This filter is documented in wp-includes/widgets.php */
1216           return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
1217      }
1218
1219      /**
1220       * Fires before widgets are rendered in a dynamic sidebar.
1221       *
1222       * Note: The action also fires for empty sidebars, and on both the front-end
1223       * and back-end, including the Inactive Widgets sidebar on the Widgets screen.
1224       *
1225       * @since 3.9.0
 
Line Code
1341       * Note: The filter is also evaluated for empty sidebars, and on both the front-end
1342       * and back-end, including the Inactive Widgets sidebar on the Widgets screen.
1343       *
1344       * @since 3.9.0
1345       *
1346       * @param bool       $did_one Whether at least one widget was rendered in the sidebar.
1347       *                            Default false.
1348       * @param int|string $index   Index, name, or ID of the dynamic sidebar.
1349       */
1350      return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
1351 }
1352
1353 /**
1354  * Whether widget is displayed on the front-end.
1355  *
1356  * Either $callback or $id_base can be used
1357  * $id_base is the first argument when extending WP_Widget class
1358  * Without the optional $widget_id parameter, returns the ID of the first sidebar
1359  * in which the first instance of the widget with the given callback or $id_base is found.