diff --git src/wp-includes/widgets/class-wp-widget-custom-html.php src/wp-includes/widgets/class-wp-widget-custom-html.php
index 5de618285f..1f84176112 100644
|
|
class WP_Widget_Custom_HTML extends WP_Widget { |
61 | 61 | /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ |
62 | 62 | $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ); |
63 | 63 | |
| 64 | // Prepare instance data that looks like a normal Text widget. |
| 65 | $simulated_text_widget_instance = $instance; |
| 66 | $simulated_text_widget_instance['text'] = $simulated_text_widget_instance['content']; |
| 67 | unset( $simulated_text_widget_instance['content'] ); |
| 68 | $simulated_text_widget_instance['filter'] = false; // Because wpautop is not applied. |
| 69 | |
64 | 70 | /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */ |
65 | | $content = apply_filters( 'widget_text', $instance['content'], $instance, $this ); |
| 71 | $content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this ); |
66 | 72 | |
67 | 73 | /** |
68 | 74 | * Filters the content of the Custom HTML widget. |
diff --git tests/phpunit/tests/widgets/custom-html-widget.php tests/phpunit/tests/widgets/custom-html-widget.php
index c7c2e91bf8..1e1e4dc676 100644
|
|
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { |
59 | 59 | 'content' => $content, |
60 | 60 | ); |
61 | 61 | |
| 62 | // Convert Custom HTML widget instance into Text widget instance data. |
| 63 | $text_widget_instance = array_merge( $instance, array( |
| 64 | 'filter' => false, |
| 65 | 'text' => $instance['content'], |
| 66 | ) ); |
| 67 | unset( $text_widget_instance['content'] ); |
| 68 | |
62 | 69 | update_option( 'use_balanceTags', 0 ); |
63 | 70 | add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); |
64 | 71 | add_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10, 3 ); |
… |
… |
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { |
73 | 80 | $this->assertNotContains( '<p>', $output ); |
74 | 81 | $this->assertNotContains( '<br>', $output ); |
75 | 82 | $this->assertNotContains( '</u>', $output ); |
76 | | $this->assertEquals( $instance, $this->widget_text_args[1] ); |
| 83 | $this->assertEquals( $text_widget_instance, $this->widget_text_args[1] ); |
77 | 84 | $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] ); |
78 | 85 | $this->assertSame( $widget, $this->widget_text_args[2] ); |
79 | 86 | $this->assertSame( $widget, $this->widget_custom_html_content_args[2] ); |
80 | | remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); |
| 87 | remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5 ); |
81 | 88 | remove_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10 ); |
82 | 89 | |
83 | 90 | update_option( 'use_balanceTags', 1 ); |