diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
index 6f64ffab5d..ada9c53c3f 100644
|
|
add_filter( 'widget_text_content', 'wptexturize' ); |
170 | 170 | add_filter( 'widget_text_content', 'convert_smilies', 20 ); |
171 | 171 | add_filter( 'widget_text_content', 'wpautop' ); |
172 | 172 | |
173 | | add_filter( 'widget_html_code_content', 'balanceTags' ); |
| 173 | add_filter( 'widget_custom_html_content', 'balanceTags' ); |
174 | 174 | |
175 | 175 | add_filter( 'date_i18n', 'wp_maybe_decline_date' ); |
176 | 176 | |
diff --git src/wp-includes/default-widgets.php src/wp-includes/default-widgets.php
index 32a908ac11..cdc6e9690b 100644
|
|
require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-tag-cloud.php' ); |
61 | 61 | /** WP_Nav_Menu_Widget class */ |
62 | 62 | require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' ); |
63 | 63 | |
64 | | /** WP_Widget_HTML_Code class */ |
65 | | require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-html-code.php' ); |
| 64 | /** WP_Widget_Custom_HTML class */ |
| 65 | require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-custom-html.php' ); |
diff --git src/wp-includes/widgets.php src/wp-includes/widgets.php
index b44048d641..fbbdcf5f55 100644
|
|
function wp_widgets_init() { |
1474 | 1474 | |
1475 | 1475 | register_widget( 'WP_Nav_Menu_Widget' ); |
1476 | 1476 | |
1477 | | register_widget( 'WP_Widget_HTML_Code' ); |
| 1477 | register_widget( 'WP_Widget_Custom_HTML' ); |
1478 | 1478 | |
1479 | 1479 | /** |
1480 | 1480 | * Fires after all default WordPress widgets have been registered. |
diff --git src/wp-includes/widgets/class-wp-widget-html-code.php src/wp-includes/widgets/class-wp-widget-custom-html.php
similarity index 77%
rename from src/wp-includes/widgets/class-wp-widget-html-code.php
rename to src/wp-includes/widgets/class-wp-widget-custom-html.php
index d16900183f..f6d28fd625 100644
old
|
new
|
|
1 | 1 | <?php |
2 | 2 | /** |
3 | | * Widget API: WP_Widget_HTML_Code class |
| 3 | * Widget API: WP_Widget_Custom_HTML class |
4 | 4 | * |
5 | 5 | * @package WordPress |
6 | 6 | * @subpackage Widgets |
… |
… |
|
8 | 8 | */ |
9 | 9 | |
10 | 10 | /** |
11 | | * Core class used to implement a HTML Code widget. |
| 11 | * Core class used to implement a Custom HTML widget. |
12 | 12 | * |
13 | 13 | * @since 4.8.1 |
14 | 14 | * |
15 | 15 | * @see WP_Widget |
16 | 16 | */ |
17 | | class WP_Widget_HTML_Code extends WP_Widget { |
| 17 | class WP_Widget_Custom_HTML extends WP_Widget { |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Default instance. |
… |
… |
class WP_Widget_HTML_Code extends WP_Widget { |
28 | 28 | ); |
29 | 29 | |
30 | 30 | /** |
31 | | * Sets up a new HTML Code widget instance. |
| 31 | * Sets up a new Custom HTML widget instance. |
32 | 32 | * |
33 | 33 | * @since 4.8.1 |
34 | 34 | */ |
35 | 35 | public function __construct() { |
36 | 36 | $widget_ops = array( |
37 | | 'classname' => 'widget_html_code', |
| 37 | 'classname' => 'widget_custom_html', |
38 | 38 | 'description' => __( 'Arbitrary HTML code.' ), |
39 | 39 | 'customize_selective_refresh' => true, |
40 | 40 | ); |
41 | 41 | $control_ops = array(); |
42 | | parent::__construct( 'html_code', __( 'HTML Code' ), $widget_ops, $control_ops ); |
| 42 | parent::__construct( 'custom_html', __( 'Custom HTML' ), $widget_ops, $control_ops ); |
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
46 | | * Outputs the content for the current HTML Code widget instance. |
| 46 | * Outputs the content for the current Custom HTML widget instance. |
47 | 47 | * |
48 | 48 | * @since 4.8.1 |
49 | 49 | * |
50 | 50 | * @param array $args Display arguments including 'before_title', 'after_title', |
51 | 51 | * 'before_widget', and 'after_widget'. |
52 | | * @param array $instance Settings for the current HTML Code widget instance. |
| 52 | * @param array $instance Settings for the current Custom HTML widget instance. |
53 | 53 | */ |
54 | 54 | public function widget( $args, $instance ) { |
55 | 55 | |
… |
… |
class WP_Widget_HTML_Code extends WP_Widget { |
61 | 61 | $content = $instance['content']; |
62 | 62 | |
63 | 63 | /** |
64 | | * Filters the content of the HTML Code widget. |
| 64 | * Filters the content of the Custom HTML widget. |
65 | 65 | * |
66 | 66 | * @since 4.8.1 |
67 | 67 | * |
68 | | * @param string $content The widget content. |
69 | | * @param array $instance Array of settings for the current widget. |
70 | | * @param WP_Widget_HTML_Code $this Current HTML Code widget instance. |
| 68 | * @param string $content The widget content. |
| 69 | * @param array $instance Array of settings for the current widget. |
| 70 | * @param WP_Widget_Custom_HTML $this Current Custom HTML widget instance. |
71 | 71 | */ |
72 | | $content = apply_filters( 'widget_html_code_content', $content, $instance, $this ); |
| 72 | $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this ); |
73 | 73 | |
74 | 74 | echo $args['before_widget']; |
75 | 75 | if ( ! empty( $title ) ) { |
… |
… |
class WP_Widget_HTML_Code extends WP_Widget { |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | | * Handles updating settings for the current HTML Code widget instance. |
| 83 | * Handles updating settings for the current Custom HTML widget instance. |
84 | 84 | * |
85 | 85 | * @since 4.8.1 |
86 | 86 | * |
… |
… |
class WP_Widget_HTML_Code extends WP_Widget { |
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
104 | | * Outputs the HTML Code widget settings form. |
| 104 | * Outputs the Custom HTML widget settings form. |
105 | 105 | * |
106 | 106 | * @since 4.8.1 |
107 | 107 | * |
diff --git tests/phpunit/tests/widgets/html-code-widget.php tests/phpunit/tests/widgets/custom-html-widget.php
similarity index 62%
rename from tests/phpunit/tests/widgets/html-code-widget.php
rename to tests/phpunit/tests/widgets/custom-html-widget.php
index 9ab5a18b94..3305d8ad35 100644
old
|
new
|
|
1 | 1 | <?php |
2 | 2 | /** |
3 | | * Unit tests covering WP_Widget_HTML_Code functionality. |
| 3 | * Unit tests covering WP_Widget_Custom_HTML functionality. |
4 | 4 | * |
5 | 5 | * @package WordPress |
6 | 6 | * @subpackage widgets |
7 | 7 | */ |
8 | 8 | |
9 | 9 | /** |
10 | | * Test wp-includes/widgets/class-wp-widget-html-code.php |
| 10 | * Test wp-includes/widgets/class-wp-widget-custom-html.php |
11 | 11 | * |
12 | 12 | * @group widgets |
13 | 13 | */ |
14 | | class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { |
| 14 | class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { |
15 | 15 | |
16 | 16 | /** |
17 | | * Args passed to the widget_html_code_content filter. |
| 17 | * Args passed to the widget_custom_html_content filter. |
18 | 18 | * |
19 | 19 | * @var array |
20 | 20 | */ |
21 | | protected $widget_html_code_content_args; |
| 21 | protected $widget_custom_html_content_args; |
| 22 | |
| 23 | /** |
| 24 | * Test constructor. |
| 25 | * |
| 26 | * @covers WP_Widget_Custom_HTML::__constructor |
| 27 | */ |
| 28 | function test_constructor() { |
| 29 | $widget = new WP_Widget_Custom_HTML(); |
| 30 | $this->assertEquals( 'custom_html', $widget->id_base ); |
| 31 | $this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] ); |
| 32 | $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); |
| 33 | } |
22 | 34 | |
23 | 35 | /** |
24 | 36 | * Test widget method. |
25 | 37 | * |
26 | | * @covers WP_Widget_HTML_Code::widget |
| 38 | * @covers WP_Widget_Custom_HTML::widget |
27 | 39 | */ |
28 | 40 | function test_widget() { |
29 | | $widget = new WP_Widget_HTML_Code(); |
| 41 | $widget = new WP_Widget_Custom_HTML(); |
30 | 42 | $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed"; |
31 | 43 | |
32 | 44 | $args = array( |
… |
… |
class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { |
40 | 52 | 'content' => $content, |
41 | 53 | ); |
42 | 54 | |
43 | | $this->assertEquals( 10, has_filter( 'widget_html_code_content', 'balanceTags' ) ); |
| 55 | $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) ); |
44 | 56 | |
45 | 57 | update_option( 'use_balanceTags', 0 ); |
46 | | add_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 ); |
| 58 | add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); |
47 | 59 | ob_start(); |
48 | | $this->widget_html_code_content_args = null; |
| 60 | $this->widget_custom_html_content_args = null; |
49 | 61 | $widget->widget( $args, $instance ); |
50 | 62 | $output = ob_get_clean(); |
51 | | $this->assertNotEmpty( $this->widget_html_code_content_args ); |
52 | | $this->assertContains( '[filter:widget_html_code_content]', $output ); |
| 63 | $this->assertNotEmpty( $this->widget_custom_html_content_args ); |
| 64 | $this->assertContains( '[filter:widget_custom_html_content]', $output ); |
53 | 65 | $this->assertNotContains( '<p>', $output ); |
54 | 66 | $this->assertNotContains( '<br>', $output ); |
55 | 67 | $this->assertNotContains( '</u>', $output ); |
56 | | $this->assertEquals( $instance, $this->widget_html_code_content_args[1] ); |
57 | | $this->assertSame( $widget, $this->widget_html_code_content_args[2] ); |
58 | | remove_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 ); |
| 68 | $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] ); |
| 69 | $this->assertSame( $widget, $this->widget_custom_html_content_args[2] ); |
| 70 | remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); |
59 | 71 | |
60 | 72 | update_option( 'use_balanceTags', 1 ); |
61 | 73 | ob_start(); |
… |
… |
class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { |
65 | 77 | } |
66 | 78 | |
67 | 79 | /** |
68 | | * Filters the content of the HTML Code widget. |
| 80 | * Filters the content of the Custom HTML widget. |
69 | 81 | * |
70 | | * @param string $widget_content The widget content. |
71 | | * @param array $instance Array of settings for the current widget. |
72 | | * @param WP_Widget_HTML_Code $widget Current HTML Code widget instance. |
| 82 | * @param string $widget_content The widget content. |
| 83 | * @param array $instance Array of settings for the current widget. |
| 84 | * @param WP_Widget_Custom_HTML $widget Current Custom HTML widget instance. |
73 | 85 | * @return string Widget content. |
74 | 86 | */ |
75 | | function filter_widget_html_code_content( $widget_content, $instance, $widget ) { |
76 | | $this->widget_html_code_content_args = func_get_args(); |
| 87 | function filter_widget_custom_html_content( $widget_content, $instance, $widget ) { |
| 88 | $this->widget_custom_html_content_args = func_get_args(); |
77 | 89 | |
78 | | $widget_content .= '[filter:widget_html_code_content]'; |
| 90 | $widget_content .= '[filter:widget_custom_html_content]'; |
79 | 91 | return $widget_content; |
80 | 92 | } |
81 | 93 | |
82 | 94 | /** |
83 | 95 | * Test update method. |
84 | 96 | * |
85 | | * @covers WP_Widget_HTML_Code::update |
| 97 | * @covers WP_Widget_Custom_HTML::update |
86 | 98 | */ |
87 | 99 | function test_update() { |
88 | | $widget = new WP_Widget_HTML_Code(); |
| 100 | $widget = new WP_Widget_Custom_HTML(); |
89 | 101 | $instance = array( |
90 | 102 | 'title' => "The\n<b>Title</b>", |
91 | 103 | 'content' => "The\n\n<b>Code</b>", |