WordPress.org

Make WordPress Core


Ignore:
Timestamp:
05/24/2021 09:50:30 AM (6 months ago)
Author:
SergeyBiryukov
Message:

Widgets: Make sure WP_Widget constructor creates a correct classname value for a namespaced widget class.

This reverts the changes to id_base from [50953] due to backward compatibility concerns, and instead focuses on the id and class attributes specifically.

With this change, any backslashes in the id or class attributes for a namespaced widget class are converted to underscores, making it easier to style the output or target the widget with JavaScript.

Follow-up to [50953].

Fixes #44098.

File:
1 edited

Legend:

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

    r50953 r50961  
    165165        } else {
    166166            $id_base = preg_replace( '/(wp_)?widget_/', '', strtolower( get_class( $this ) ) );
    167             $id_base = str_replace( '\\', '-', $id_base );
    168167        }
    169168
     
    174173            $widget_options,
    175174            array(
    176                 'classname'                   => $this->option_name,
     175                'classname'                   => str_replace( '\\', '_', $this->option_name ),
    177176                'customize_selective_refresh' => false,
    178177            )
Note: See TracChangeset for help on using the changeset viewer.