Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: dynamic_sidebar_before

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
1149                     $index = $key;
1150                     break;
1151                }
1152           }
1153      }
1154
1155      $sidebars_widgets = wp_get_sidebars_widgets();
1156      if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
1157           /** This action is documented in wp-includes/widgets.php */
1158           do_action( 'dynamic_sidebar_before', $index, false );
1159           /** This action is documented in wp-includes/widgets.php */
1160           do_action( 'dynamic_sidebar_after',  $index, false );
1161           /** This filter is documented in wp-includes/widgets.php */
1162           return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
1163      }
1164
1165      /**
1166       * Fires before widgets are rendered in a dynamic sidebar.
1167       *
1168       * Note: The action also fires for empty sidebars, and on both the front-end
1169       * and back-end, including the Inactive Widgets sidebar on the Widgets screen.
1170       *
1171       * @since 3.9.0
1172       *
1173       * @param int|string $index       Index, name, or ID of the dynamic sidebar.
1174       * @param bool       $has_widgets Whether the sidebar is populated with widgets.
1175       *                                Default true.
1176       */
1177      do_action( 'dynamic_sidebar_before', $index, true );
1178      $sidebar = $wp_registered_sidebars[$index];
1179
1180      $did_one = false;
1181      foreach ( (array) $sidebars_widgets[$index] as $id ) {
1182
1183           if ( !isset($wp_registered_widgets[$id]) ) continue;
1184
1185           $params = array_merge(
1186                array( array_merge( $sidebar, array('widget_id' => $id, 'widget_name' => $wp_registered_widgets[$id]['name']) ) ),