[wp-trac] [WordPress Trac] #41392: Theme styles for Text widget do not apply to Custom HTML widget
WordPress Trac
noreply at wordpress.org
Fri Jul 21 18:32:16 UTC 2017
#41392: Theme styles for Text widget do not apply to Custom HTML widget
--------------------------+--------------------------
Reporter: westonruter | Owner: westonruter
Type: defect (bug) | Status: reopened
Priority: normal | Milestone: 4.8.1
Component: Widgets | Version: trunk
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
--------------------------+--------------------------
Changes (by westonruter):
* keywords: has-patch fixed-major => has-patch
Comment:
I just realized that themes are not just targeting `.textwidget`. They are
_also_ selecting the parent element, `.widget_text`.. And actually, core
themes use both, about half and half.
Text widget looks like this in Twenty Seventeen: [attachment:properly-
styled-text-widget-in-twentyseventeen.png]
The same HTML looks quite wrong in the Custom HTML widget in Twenty
Seventeen: [attachment:misstyled-custom-html-widget-in-
twentyseventeen.png]
The best way I can think of to fix this up is to inject the `widget_text`
class name to appear alongside the `widget_custom_html` class name, like
so when printing out:
{{{#!diff
--- src/wp-includes/widgets/class-wp-widget-custom-html.php
+++ src/wp-includes/widgets/class-wp-widget-custom-html.php
@@ -75,6 +75,9 @@ class WP_Widget_Custom_HTML extends WP_Widget {
*/
$content = apply_filters( 'widget_custom_html_content',
$content, $instance, $this );
+ // Inject the Text widget's container class name alongside
this widget's class name for theme styling compatibility.
+// $args['before_widget'] = str_replace( $this->id_base, "
$this->id_base widget_text", $args['before_widget'] );
+
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title .
$args['after_title'];
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41392#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list