mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-03-31 10:44:26 +00:00
Widgets: Make sure WP_Widget constructor creates a correct id_base value for a namespaced widget class.
The `id_base` value is used for the widget's `id` and `class` attributes and also for the option name which stores the widget settings (unless the widget specifies a custom `option_name` value). With this change, any backslashes in the `id_base` for a namespaced widget class are converted to hyphens, making it easier to style the output or target the widget with JavaScript. This also avoids a `preg_match(): Compilation failed` PHP warning from `next_widget_id_number()` on the Widgets screen, previously caused by unescaped backslashes. Props Mte90, hermpheus, rogerlos, welcher, SergeyBiryukov. Fixes #44098. git-svn-id: https://develop.svn.wordpress.org/trunk@50953 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
14
tests/phpunit/data/widgets/custom-widget-classes.php
Normal file
14
tests/phpunit/data/widgets/custom-widget-classes.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
namespace Test\Sub\Sub {
|
||||
|
||||
class Namespaced_Widget extends \WP_Widget {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class Non_Namespaced_Widget extends \WP_Widget {
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user