Opened 5 years ago
Last modified 5 years ago
#49588 new feature request
Cannot remove <div class="textwidget custom-html-widget">
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | |
Component: | Widgets | Keywords: | has-patch needs-testing needs-unit-tests |
Focuses: | Cc: |
Description
I cannot remove wrapping class in html widget:
<div class="textwidget custom-html-widget">
...
</div>
It is defined here: https://github.com/WordPress/WordPress/blob/master/wp-includes/widgets/class-wp-widget-custom-html.php
I think it is job for some apply_filters
.
Do we really need another <div>
wrap? There can be <div>
wrap added by register_sidebar
or using widget_text
filter
Attachments (1)
Change History (4)
#2
@
5 years ago
I have read your reactions on this topic and my question: Is any other action expected from my side?
Note: This is my first WP issue report.
#3
@
5 years ago
@jasom Good question!
Your report should be enough, assuming I correctly recognized the issue from the description. Of course, if you want to continue with the discussion or other aspects of the topic as the ticket progresses, you are very welcome :)
(I'm still rather new to WordPress Trac, too. This would be the first time I've helped create a filter, and the first time I've even edited a unit test.)
@jasom Thanks for the report!
Yes, that div is added for any Custom HTML widget, after the
widget_custom_html_content
filter.Changesets [41115] and [41116] added classes to the HTML widget, but in different ways. I think the two would have been better as one change, without the extra div, to allow for empty
before_widget
andafter_widget
values:Adding a filter on the $args variable (similar to
wp_nav_menu_args
) could allow themes and plugins to set thebefore_widget
andafter_widget
values for all Custom HTML widgets.The patch here moves the div's classes into the replace function, and that function also uses the limit proposed in ticket:42998. The widget's unit test is updated (please check that), and the new filter probably should have unit tests as well (not yet included).