diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php index 6f64ffab5d..ada9c53c3f 100644 --- src/wp-includes/default-filters.php +++ src/wp-includes/default-filters.php @@ -170,7 +170,7 @@ add_filter( 'widget_text_content', 'wptexturize' ); add_filter( 'widget_text_content', 'convert_smilies', 20 ); add_filter( 'widget_text_content', 'wpautop' ); -add_filter( 'widget_html_code_content', 'balanceTags' ); +add_filter( 'widget_custom_html_content', 'balanceTags' ); add_filter( 'date_i18n', 'wp_maybe_decline_date' ); diff --git src/wp-includes/default-widgets.php src/wp-includes/default-widgets.php index 32a908ac11..cdc6e9690b 100644 --- src/wp-includes/default-widgets.php +++ src/wp-includes/default-widgets.php @@ -61,5 +61,5 @@ require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-tag-cloud.php' ); /** WP_Nav_Menu_Widget class */ require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' ); -/** WP_Widget_HTML_Code class */ -require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-html-code.php' ); +/** WP_Widget_Custom_HTML class */ +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 --- src/wp-includes/widgets.php +++ src/wp-includes/widgets.php @@ -1474,7 +1474,7 @@ function wp_widgets_init() { register_widget( 'WP_Nav_Menu_Widget' ); - register_widget( 'WP_Widget_HTML_Code' ); + register_widget( 'WP_Widget_Custom_HTML' ); /** * 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 --- src/wp-includes/widgets/class-wp-widget-html-code.php +++ src/wp-includes/widgets/class-wp-widget-custom-html.php @@ -1,6 +1,6 @@ 'widget_html_code', + 'classname' => 'widget_custom_html', 'description' => __( 'Arbitrary HTML code.' ), 'customize_selective_refresh' => true, ); $control_ops = array(); - parent::__construct( 'html_code', __( 'HTML Code' ), $widget_ops, $control_ops ); + parent::__construct( 'custom_html', __( 'Custom HTML' ), $widget_ops, $control_ops ); } /** - * Outputs the content for the current HTML Code widget instance. + * Outputs the content for the current Custom HTML widget instance. * * @since 4.8.1 * * @param array $args Display arguments including 'before_title', 'after_title', * 'before_widget', and 'after_widget'. - * @param array $instance Settings for the current HTML Code widget instance. + * @param array $instance Settings for the current Custom HTML widget instance. */ public function widget( $args, $instance ) { @@ -61,15 +61,15 @@ class WP_Widget_HTML_Code extends WP_Widget { $content = $instance['content']; /** - * Filters the content of the HTML Code widget. + * Filters the content of the Custom HTML widget. * * @since 4.8.1 * - * @param string $content The widget content. - * @param array $instance Array of settings for the current widget. - * @param WP_Widget_HTML_Code $this Current HTML Code widget instance. + * @param string $content The widget content. + * @param array $instance Array of settings for the current widget. + * @param WP_Widget_Custom_HTML $this Current Custom HTML widget instance. */ - $content = apply_filters( 'widget_html_code_content', $content, $instance, $this ); + $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this ); echo $args['before_widget']; if ( ! empty( $title ) ) { @@ -80,7 +80,7 @@ class WP_Widget_HTML_Code extends WP_Widget { } /** - * Handles updating settings for the current HTML Code widget instance. + * Handles updating settings for the current Custom HTML widget instance. * * @since 4.8.1 * @@ -101,7 +101,7 @@ class WP_Widget_HTML_Code extends WP_Widget { } /** - * Outputs the HTML Code widget settings form. + * Outputs the Custom HTML widget settings form. * * @since 4.8.1 * 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 --- tests/phpunit/tests/widgets/html-code-widget.php +++ tests/phpunit/tests/widgets/custom-html-widget.php @@ -1,32 +1,44 @@ assertEquals( 'custom_html', $widget->id_base ); + $this->assertEquals( 'widget_custom_html', $widget->widget_options['classname'] ); + $this->assertTrue( $widget->widget_options['customize_selective_refresh'] ); + } /** * Test widget method. * - * @covers WP_Widget_HTML_Code::widget + * @covers WP_Widget_Custom_HTML::widget */ function test_widget() { - $widget = new WP_Widget_HTML_Code(); + $widget = new WP_Widget_Custom_HTML(); $content = "Custom HTML\n\nCODE\nLast line.unclosed"; $args = array( @@ -40,22 +52,22 @@ class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { 'content' => $content, ); - $this->assertEquals( 10, has_filter( 'widget_html_code_content', 'balanceTags' ) ); + $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) ); update_option( 'use_balanceTags', 0 ); - add_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 ); + add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 ); ob_start(); - $this->widget_html_code_content_args = null; + $this->widget_custom_html_content_args = null; $widget->widget( $args, $instance ); $output = ob_get_clean(); - $this->assertNotEmpty( $this->widget_html_code_content_args ); - $this->assertContains( '[filter:widget_html_code_content]', $output ); + $this->assertNotEmpty( $this->widget_custom_html_content_args ); + $this->assertContains( '[filter:widget_custom_html_content]', $output ); $this->assertNotContains( '
', $output );
$this->assertNotContains( '
', $output );
$this->assertNotContains( '', $output );
- $this->assertEquals( $instance, $this->widget_html_code_content_args[1] );
- $this->assertSame( $widget, $this->widget_html_code_content_args[2] );
- remove_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );
+ $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] );
+ $this->assertSame( $widget, $this->widget_custom_html_content_args[2] );
+ remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
update_option( 'use_balanceTags', 1 );
ob_start();
@@ -65,27 +77,27 @@ class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
}
/**
- * Filters the content of the HTML Code widget.
+ * Filters the content of the Custom HTML widget.
*
- * @param string $widget_content The widget content.
- * @param array $instance Array of settings for the current widget.
- * @param WP_Widget_HTML_Code $widget Current HTML Code widget instance.
+ * @param string $widget_content The widget content.
+ * @param array $instance Array of settings for the current widget.
+ * @param WP_Widget_Custom_HTML $widget Current Custom HTML widget instance.
* @return string Widget content.
*/
- function filter_widget_html_code_content( $widget_content, $instance, $widget ) {
- $this->widget_html_code_content_args = func_get_args();
+ function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
+ $this->widget_custom_html_content_args = func_get_args();
- $widget_content .= '[filter:widget_html_code_content]';
+ $widget_content .= '[filter:widget_custom_html_content]';
return $widget_content;
}
/**
* Test update method.
*
- * @covers WP_Widget_HTML_Code::update
+ * @covers WP_Widget_Custom_HTML::update
*/
function test_update() {
- $widget = new WP_Widget_HTML_Code();
+ $widget = new WP_Widget_Custom_HTML();
$instance = array(
'title' => "The\nTitle",
'content' => "The\n\nCode",