Changeset 41070
- Timestamp:
- 07/18/2017 04:16:16 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets/class-wp-widget-text.php
r41050 r41070 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. … … 105 105 // If an HTML comment is present, assume legacy mode. 106 106 if ( false !== strpos( $instance['text'], '<!--' ) ) { 107 return true;108 }109 110 /*111 * If a shortcode is present (with support added by a plugin), assume legacy mode112 * since shortcodes would apply at the widget_text filter and thus be applied113 * before wpautop runs at the widget_text_content filter.114 */115 if ( preg_match( '/' . get_shortcode_regex() . '/', $instance['text'] ) ) {116 107 return true; 117 108 } … … 349 340 </p> 350 341 <div class="notice inline notice-info notice-alt"> 351 <p><?php _e( 'This widget containscode that may work better in the new “Custom HTML” widget. How about trying that widget instead?' ); ?></p>342 <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 343 </div> 353 344 <p> -
trunk/tests/phpunit/tests/widgets/text-widget.php
r41050 r41070 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, … … 295 307 ) ); 296 308 $this->assertTrue( $widget->is_legacy_instance( $instance ), 'Legacy when HTML comment is present.' ); 297 298 $instance = array_merge( $base_instance, array(299 'text' => 'Here is a [gallery]',300 'filter' => true,301 ) );302 $this->assertTrue( $widget->is_legacy_instance( $instance ), 'Legacy mode when a shortcode is present.' );303 309 304 310 // Check text examples that will not migrate to TinyMCE.
Note: See TracChangeset
for help on using the changeset viewer.