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
This commit is contained in:
Weston Ruter 2017-07-24 23:10:06 +00:00
parent 0cfe1b9136
commit 021dcb13a1
2 changed files with 9 additions and 5 deletions

View File

@ -360,7 +360,11 @@ 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 may contain code that may work better in the new &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
<?php if ( ! isset( $instance['visual'] ) ) : ?>
<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>
<?php else : ?>
<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>
<?php endif; ?>
</div>
<p>
<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>

View File

@ -457,7 +457,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase {
$widget->form( $instance );
$form = ob_get_clean();
$this->assertContains( 'class="visual" type="hidden" value=""', $form );
$this->assertNotContains( 'class="visual" type="hidden" value="1"', $form );
$this->assertNotContains( 'class="visual" type="hidden" value="on"', $form );
$instance = array(
'title' => 'Title',
@ -468,7 +468,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase {
ob_start();
$widget->form( $instance );
$form = ob_get_clean();
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
$instance = array(
@ -480,7 +480,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase {
ob_start();
$widget->form( $instance );
$form = ob_get_clean();
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
$instance = array(
@ -493,7 +493,7 @@ class Test_WP_Widget_Text extends WP_UnitTestCase {
ob_start();
$widget->form( $instance );
$form = ob_get_clean();
$this->assertContains( 'class="visual" type="hidden" value="1"', $form );
$this->assertContains( 'class="visual" type="hidden" value="on"', $form );
$this->assertNotContains( 'class="visual" type="hidden" value=""', $form );
}