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
698                     $index = $key;
699                     break;
700                }
701           }
702      }
703
704      $sidebars_widgets = wp_get_sidebars_widgets();
705      if ( empty( $wp_registered_sidebars[ $index ] ) || empty( $sidebars_widgets[ $index ] ) || ! is_array( $sidebars_widgets[ $index ] ) ) {
706           /** This action is documented in wp-includes/widget.php */
707           do_action( 'dynamic_sidebar_before', $index, false );
708           /** This action is documented in wp-includes/widget.php */
709           do_action( 'dynamic_sidebar_after', $index, false );
710           /** This filter is documented in wp-includes/widget.php */
711           return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
712      }
713
714      $sidebar = $wp_registered_sidebars[ $index ];
715
716      $sidebar['before_sidebar'] = sprintf( $sidebar['before_sidebar'], $sidebar['id'], $sidebar['class'] );
 
Line Code
721       * Note: The action also fires for empty sidebars, and on both the front end
722       * and back end, including the Inactive Widgets sidebar on the Widgets screen.
723       *
724       * @since 3.9.0
725       *
726       * @param int|string $index       Index, name, or ID of the dynamic sidebar.
727       * @param bool       $has_widgets Whether the sidebar is populated with widgets.
728       *                                Default true.
729       */
730      do_action( 'dynamic_sidebar_before', $index, true );
731
732      if ( ! is_admin() && ! empty( $sidebar['before_sidebar'] ) ) {
733           echo $sidebar['before_sidebar'];
734      }
735
736      $did_one = false;
737      foreach ( (array) $sidebars_widgets[ $index ] as $id ) {
738
739           if ( ! isset( $wp_registered_widgets[ $id ] ) ) {