Widgets: Discount shortcodes and leading/trailing line breaks for triggering Text widget legacy mode.

Since plugin-added shortcode handling is just-in-time deferred to run after `wpautop`, there is no need to retain the presence of shortcodes to trigger legacy mode. Also updates Text widget legacy mode notice informing of Custom HTML widget.

Amends [41050].
Props westonruter, melchoyce.
Fixes #40951 for trunk.

Built from https://develop.svn.wordpress.org/trunk@41070


git-svn-id: http://core.svn.wordpress.org/trunk@40922 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-07-18 04:17:43 +00:00
parent 21f6d256b5
commit 770fb1b35c
2 changed files with 3 additions and 12 deletions

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-alpha-41065';
$wp_version = '4.9-alpha-41070';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

View File

@ -95,7 +95,7 @@ class WP_Widget_Text extends WP_Widget {
}
$wpautop = ! empty( $instance['filter'] );
$has_line_breaks = ( false !== strpos( $instance['text'], "\n" ) );
$has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) );
// If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode.
if ( ! $wpautop && $has_line_breaks ) {
@ -107,15 +107,6 @@ class WP_Widget_Text extends WP_Widget {
return true;
}
/*
* If a shortcode is present (with support added by a plugin), assume legacy mode
* since shortcodes would apply at the widget_text filter and thus be applied
* before wpautop runs at the widget_text_content filter.
*/
if ( preg_match( '/' . get_shortcode_regex() . '/', $instance['text'] ) ) {
return true;
}
// In the rare case that DOMDocument is not available we cannot reliably sniff content and so we assume legacy.
if ( ! class_exists( 'DOMDocument' ) ) {
// @codeCoverageIgnoreStart
@ -348,7 +339,7 @@ class WP_Widget_Text extends WP_Widget {
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>"/>
</p>
<div class="notice inline notice-info notice-alt">
<p><?php _e( 'This widget contains code that may work better in the new &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
<p><?php _e( 'This widget may contain code that may work better in the new &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
</div>
<p>
<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>