Make WordPress Core

Ticket #40951: 40951.13.diff

File 40951.13.diff, 2.3 KB (added by westonruter, 8 years ago)

https://github.com/xwp/wordpress-develop/pull/235/files/41b0538e20161f6cca85bb3dc87abdb581279a73..59949be0debee71d29150098a27a8cc335e062a1

  • src/wp-includes/widgets/class-wp-widget-text.php

    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 { 
    9595                }
    9696
    9797                $wpautop = ! empty( $instance['filter'] );
    98                 $has_line_breaks = ( false !== strpos( $instance['text'], "\n" ) );
     98                $has_line_breaks = ( false !== strpos( trim( $instance['text'] ), "\n" ) );
    9999
    100100                // If auto-paragraphs are not enabled and there are line breaks, then ensure legacy mode.
    101101                if ( ! $wpautop && $has_line_breaks ) {
    class WP_Widget_Text extends WP_Widget { 
    348348                                <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'] ); ?>"/>
    349349                        </p>
    350350                        <div class="notice inline notice-info notice-alt">
    351                                 <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>
     351                                <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>
    352352                        </div>
    353353                        <p>
    354354                                <label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
  • tests/phpunit/tests/widgets/text-widget.php

    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 { 
    266266                $this->assertFalse( $widget->is_legacy_instance( $instance ), 'Not legacy when text is empty.' );
    267267
    268268                $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(
    269281                        'text' => "One\nTwo",
    270282                        'filter' => false,
    271283                ) );