Skip to content

Commit 021dcb1

Browse files
committed
Widgets: Improve notice in Text widget's legacy mode.
Also fixes phpunit test which broke in [41132]. Props melchoyce, westonruter, gk.loveweb. See #41394, #35243, #40951, #40907. Fixes #41386. git-svn-id: https://develop.svn.wordpress.org/trunk@41134 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0cfe1b9 commit 021dcb1

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,11 @@ public function form( $instance ) {
360360
<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'] ); ?>"/>
361361
</p>
362362
<div class="notice inline notice-info notice-alt">
363-
<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>
363+
<?php if ( ! isset( $instance['visual'] ) ) : ?>
364+
<p><?php _e( 'This widget may contain code that may work better in the &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
365+
<?php else : ?>
366+
<p><?php _e( 'This widget may have contained code that may work better in the &#8220;Custom HTML&#8221; widget. If you haven&#8217;t yet, how about trying that widget instead?' ); ?></p>
367+
<?php endif; ?>
364368
</div>
365369
<p>
366370
<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>

tests/phpunit/tests/widgets/text-widget.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ function test_form() {
457457
$widget->form( $instance );
458458
$form = ob_get_clean();
459459
$this->assertContains( 'class="visual" type="hidden" value=""', $form );
460-
$this->assertNotContains( 'class="visual" type="hidden" value="1"', $form );
460+
$this->assertNotContains( 'class="visual" type="hidden" value="on"', $form );
461461

462462
$instance = array(
463463
'title' => 'Title',
@@ -468,7 +468,7 @@ function test_form() {
468468
ob_start();
469469
$widget->form( $instance );
470470
$form = ob_get_clean();
471-
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
471+
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
472472
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
473473

474474
$instance = array(
@@ -480,7 +480,7 @@ function test_form() {
480480
ob_start();
481481
$widget->form( $instance );
482482
$form = ob_get_clean();
483-
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
483+
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
484484
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
485485

486486
$instance = array(
@@ -493,7 +493,7 @@ function test_form() {
493493
ob_start();
494494
$widget->form( $instance );
495495
$form = ob_get_clean();
496-
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
496+
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
497497
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
498498
}
499499

0 commit comments

Comments
 (0)