WordPress.org

Make WordPress Core

Ticket #24878: 24878.diff

File 24878.diff, 897 bytes (added by GaryJ, 6 years ago)

Adds is_registered_sidebar() to compliment register_sidebar() and unregister_sidebar().

  • wp-includes/widgets.php

     
    577577}
    578578
    579579/**
     580 * Checks if a sidebar is registered.
     581 *
     582 * @since  3.7.0
     583 *
     584 * @param string $name The ID of the sidebar when it was added.
     585 *
     586 * @return boolean True if the sidebar is registered, false otherwise.
     587 */
     588function is_registered_sidebar( $name ) {
     589        global $wp_registered_sidebars;
     590
     591        if ( isset( $wp_registered_sidebars[$name] ) )
     592                return true;
     593        return false;
     594}
     595
     596/**
    580597 * Removes a sidebar from the list.
    581598 *
    582599 * @since 2.2.0
     
    588605function unregister_sidebar( $name ) {
    589606        global $wp_registered_sidebars;
    590607
    591         if ( isset( $wp_registered_sidebars[$name] ) )
     608        if ( is_registered_sidebar( $name ) )
    592609                unset( $wp_registered_sidebars[$name] );
    593610}
    594611