mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 14:20:15 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@50961 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -164,7 +164,6 @@ class WP_Widget {
|
||||
$id_base = strtolower( $id_base );
|
||||
} else {
|
||||
$id_base = preg_replace( '/(wp_)?widget_/', '', strtolower( get_class( $this ) ) );
|
||||
$id_base = str_replace( '\\', '-', $id_base );
|
||||
}
|
||||
|
||||
$this->id_base = $id_base;
|
||||
@@ -173,7 +172,7 @@ class WP_Widget {
|
||||
$this->widget_options = wp_parse_args(
|
||||
$widget_options,
|
||||
array(
|
||||
'classname' => $this->option_name,
|
||||
'classname' => str_replace( '\\', '_', $this->option_name ),
|
||||
'customize_selective_refresh' => false,
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user