Widgets: Improve theme styling compatibility for Custom HTML widget by adding content container with textwidget class and widget_text class on widget wrapper element.

The same styling from the Text widget should apply to the Custom HTML widget since users are expected to copy HTML from the (legacy) Text widget into the latter.

Merges [41115] and partially [41116] onto 4.8 branch.
Amends [40893].
See #40907.
Fixes #41392 for 4.8.1.

Built from https://develop.svn.wordpress.org/branches/4.8@41117


git-svn-id: http://core.svn.wordpress.org/branches/4.8@40957 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-07-21 21:17:37 +00:00
parent 6ce522414f
commit 96da852a31
2 changed files with 6 additions and 1 deletions

View File

@ -133,11 +133,16 @@ 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'] = preg_replace( '/(?<=\sclass=["\'])/', 'widget_text ', $args['before_widget'] );
echo $args['before_widget'];
if ( ! empty( $title ) ) {
echo $args['before_title'] . $title . $args['after_title'];
}
echo '<div class="textwidget custom-html-widget">'; // The textwidget class is for theme styling compatibility.
echo $content;
echo '</div>';
echo $args['after_widget'];
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8.1-beta1-41098';
$wp_version = '4.8.1-beta1-41117';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.