diff --git src/wp-includes/widgets/class-wp-widget-text.php src/wp-includes/widgets/class-wp-widget-text.php
index ad4667bb0f..38eaef50e7 100644
|
|
class WP_Widget_Text extends WP_Widget { |
95 | 95 | } |
96 | 96 | |
97 | 97 | $wpautop = ! empty( $instance['filter'] ); |
98 | | $has_line_breaks = ( false !== strpos( $instance['text'], "\n" ) ); |
| 98 | $has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) ); |
99 | 99 | |
100 | 100 | // If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode. |
101 | 101 | if ( ! $wpautop && $has_line_breaks ) { |
… |
… |
class WP_Widget_Text extends WP_Widget { |
348 | 348 | <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'] ); ?>"/> |
349 | 349 | </p> |
350 | 350 | <div class="notice inline notice-info notice-alt"> |
351 | | <p><?php _e( 'This widget contains code that may work better in the new “Custom HTML” widget. How about trying that widget instead?' ); ?></p> |
| 351 | <p><?php _e( 'This widget may contain code that may work better in the new “Custom HTML” widget. How about trying that widget instead?' ); ?></p> |
352 | 352 | </div> |
353 | 353 | <p> |
354 | 354 | <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label> |
diff --git tests/phpunit/tests/widgets/text-widget.php tests/phpunit/tests/widgets/text-widget.php
index af3e2755f5..25e071eb23 100644
|
|
class Test_WP_Widget_Text extends WP_UnitTestCase { |
266 | 266 | $this->assertFalse( $widget->is_legacy_instance( $instance ), 'Not legacy when text is empty.' ); |
267 | 267 | |
268 | 268 | $instance = array_merge( $base_instance, array( |
| 269 | 'text' => "\nOne line", |
| 270 | 'filter' => false, |
| 271 | ) ); |
| 272 | $this->assertFalse( $widget->is_legacy_instance( $instance ), 'Not legacy when there is leading whitespace.' ); |
| 273 | |
| 274 | $instance = array_merge( $base_instance, array( |
| 275 | 'text' => "\nOne line\n\n", |
| 276 | 'filter' => false, |
| 277 | ) ); |
| 278 | $this->assertFalse( $widget->is_legacy_instance( $instance ), 'Not legacy when there is trailing whitespace.' ); |
| 279 | |
| 280 | $instance = array_merge( $base_instance, array( |
269 | 281 | 'text' => "One\nTwo", |
270 | 282 | 'filter' => false, |
271 | 283 | ) ); |