Opened 6 years ago
Last modified 2 months 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-unit-tests needs-refresh |
| 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 (5)
#2
@
6 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
@
6 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.)
#4
@
2 months ago
- Keywords needs-refresh added; needs-testing removed
I attempted to apply the available patch against trunk (7.0-alpha-61215-src)
Changes can be applied to /wp-includes/widgets/class-wp-widget-custom-html.php but /tests/phpunit/tests/widgets/custom-html-widget.php file is not found in trunk, thus fails.
I'm guessing that the filename needs to be /tests/phpunit/tests/widgets/wpWidgetCustomHtml.php
Since the patch can not currently be tested, I have removed the needs-testing keyword and added needs-refresh.
@jasom Thanks for the report!
Yes, that div is added for any Custom HTML widget, after the
widget_custom_html_contentfilter.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_widgetandafter_widgetvalues:Adding a filter on the $args variable (similar to
wp_nav_menu_args) could allow themes and plugins to set thebefore_widgetandafter_widgetvalues 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).