WordPress.org

Make WordPress Core

Ticket #37893: 37893.1.patch

File 37893.1.patch, 1.4 KB (added by PieWP, 3 years ago)

Improves numeric matching

  • wp-includes/widgets.php

     
    278278 * Removes a sidebar from the list.
    279279 *
    280280 * @since 2.2.0
     281 * @since x.y.0 The `$name` parameter was changed to also accept a numeric sidebar ID.
    281282 *
    282283 * @global array $wp_registered_sidebars Stores the new sidebar in this array by sidebar ID.
    283284 *
    284  * @param string $name The ID of the sidebar when it was added.
     285 * @param string|int $name The ID of the sidebar when it was registered.
    285286 */
    286287function unregister_sidebar( $name ) {
    287288        global $wp_registered_sidebars;
    288289
     290        $name = ( is_numeric($name) ) ? "sidebar-$name" : sanitize_title($name);
    289291        unset( $wp_registered_sidebars[ $name ] );
    290292}
    291293
     
    296298 *
    297299 * @global array $wp_registered_sidebars Registered sidebars.
    298300 *
    299  * @param string|int $sidebar_id The ID of the sidebar when it was registered.
     301 * @param string|int $name The ID of the sidebar when it was registered.
    300302 * @return bool True if the sidebar is registered, false otherwise.
    301303 */
    302 function is_registered_sidebar( $sidebar_id ) {
     304function is_registered_sidebar( $name ) {
    303305        global $wp_registered_sidebars;
    304306
    305         return isset( $wp_registered_sidebars[ $sidebar_id ] );
     307        $name = ( is_numeric($name) ) ? "sidebar-$name" : sanitize_title($name);
     308        return isset( $wp_registered_sidebars[ $name ] );
    306309}
    307310
    308311/**