Make WordPress Core


Ignore:
Timestamp:
10/13/2015 01:32:27 AM (9 years ago)
Author:
wonderboymusic
Message:

Widgets: add a function, is_registered_sidebar() - helps us avoid touching the $wp_registered_sidebars global.

Props GaryJ, wonderboymusic.
Fixes #24878.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-widgets.php

    r34563 r35102  
    366366            }
    367367
    368             $is_registered_sidebar = isset( $wp_registered_sidebars[ $sidebar_id ] );
     368            $is_registered_sidebar = is_registered_sidebar( $sidebar_id );
    369369            $is_inactive_widgets   = ( 'wp_inactive_widgets' === $sidebar_id );
    370370            $is_active_sidebar     = ( $is_registered_sidebar && ! $is_inactive_widgets );
     
    11031103     * @access public
    11041104     *
    1105      * @global array $wp_registered_sidebars
    1106      *
    11071105     * @param bool   $is_active  Whether the sidebar is active.
    11081106     * @param string $sidebar_id Sidebar ID.
     
    11101108     */
    11111109    public function tally_sidebars_via_is_active_sidebar_calls( $is_active, $sidebar_id ) {
    1112         if ( isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] ) ) {
     1110        if ( is_registered_sidebar( $sidebar_id ) ) {
    11131111            $this->rendered_sidebars[] = $sidebar_id;
    11141112        }
     
    11311129     * @access public
    11321130     *
    1133      * @global array $wp_registered_sidebars
    1134      *
    11351131     * @param bool   $has_widgets Whether the current sidebar has widgets.
    11361132     * @param string $sidebar_id  Sidebar ID.
     
    11381134     */
    11391135    public function tally_sidebars_via_dynamic_sidebar_calls( $has_widgets, $sidebar_id ) {
    1140         if ( isset( $GLOBALS['wp_registered_sidebars'][$sidebar_id] ) ) {
     1136        if ( is_registered_sidebar( $sidebar_id ) ) {
    11411137            $this->rendered_sidebars[] = $sidebar_id;
    11421138        }
Note: See TracChangeset for help on using the changeset viewer.