Widgets: Rename "HTML Code" widget to "Custom HTML" widget.
Correspondingly renames files, ID base from `html_code` to `custom_html`, and the filter from `widget_html_code_content` to `widget_custom_html_content`. See #40907. git-svn-id: https://develop.svn.wordpress.org/trunk@40926 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c1ff9b62f7
commit
d29e68fbda
@ -170,7 +170,7 @@ add_filter( 'widget_text_content', 'wptexturize' );
|
|||||||
add_filter( 'widget_text_content', 'convert_smilies', 20 );
|
add_filter( 'widget_text_content', 'convert_smilies', 20 );
|
||||||
add_filter( 'widget_text_content', 'wpautop' );
|
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' );
|
add_filter( 'date_i18n', 'wp_maybe_decline_date' );
|
||||||
|
|
||||||
|
@ -61,5 +61,5 @@ require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-tag-cloud.php' );
|
|||||||
/** WP_Nav_Menu_Widget class */
|
/** WP_Nav_Menu_Widget class */
|
||||||
require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' );
|
require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' );
|
||||||
|
|
||||||
/** WP_Widget_HTML_Code class */
|
/** WP_Widget_Custom_HTML class */
|
||||||
require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-html-code.php' );
|
require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-custom-html.php' );
|
||||||
|
@ -1474,7 +1474,7 @@ function wp_widgets_init() {
|
|||||||
|
|
||||||
register_widget( 'WP_Nav_Menu_Widget' );
|
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.
|
* Fires after all default WordPress widgets have been registered.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Widget API: WP_Widget_HTML_Code class
|
* Widget API: WP_Widget_Custom_HTML class
|
||||||
*
|
*
|
||||||
* @package WordPress
|
* @package WordPress
|
||||||
* @subpackage Widgets
|
* @subpackage Widgets
|
||||||
@ -8,13 +8,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core class used to implement a HTML Code widget.
|
* Core class used to implement a Custom HTML widget.
|
||||||
*
|
*
|
||||||
* @since 4.8.1
|
* @since 4.8.1
|
||||||
*
|
*
|
||||||
* @see WP_Widget
|
* @see WP_Widget
|
||||||
*/
|
*/
|
||||||
class WP_Widget_HTML_Code extends WP_Widget {
|
class WP_Widget_Custom_HTML extends WP_Widget {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default instance.
|
* Default instance.
|
||||||
@ -28,28 +28,28 @@ class WP_Widget_HTML_Code extends WP_Widget {
|
|||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets up a new HTML Code widget instance.
|
* Sets up a new Custom HTML widget instance.
|
||||||
*
|
*
|
||||||
* @since 4.8.1
|
* @since 4.8.1
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$widget_ops = array(
|
$widget_ops = array(
|
||||||
'classname' => 'widget_html_code',
|
'classname' => 'widget_custom_html',
|
||||||
'description' => __( 'Arbitrary HTML code.' ),
|
'description' => __( 'Arbitrary HTML code.' ),
|
||||||
'customize_selective_refresh' => true,
|
'customize_selective_refresh' => true,
|
||||||
);
|
);
|
||||||
$control_ops = array();
|
$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
|
* @since 4.8.1
|
||||||
*
|
*
|
||||||
* @param array $args Display arguments including 'before_title', 'after_title',
|
* @param array $args Display arguments including 'before_title', 'after_title',
|
||||||
* 'before_widget', and 'after_widget'.
|
* '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 ) {
|
public function widget( $args, $instance ) {
|
||||||
|
|
||||||
@ -61,15 +61,15 @@ class WP_Widget_HTML_Code extends WP_Widget {
|
|||||||
$content = $instance['content'];
|
$content = $instance['content'];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the content of the HTML Code widget.
|
* Filters the content of the Custom HTML widget.
|
||||||
*
|
*
|
||||||
* @since 4.8.1
|
* @since 4.8.1
|
||||||
*
|
*
|
||||||
* @param string $content The widget content.
|
* @param string $content The widget content.
|
||||||
* @param array $instance Array of settings for the current widget.
|
* @param array $instance Array of settings for the current widget.
|
||||||
* @param WP_Widget_HTML_Code $this Current HTML Code widget instance.
|
* @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'];
|
echo $args['before_widget'];
|
||||||
if ( ! empty( $title ) ) {
|
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
|
* @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
|
* @since 4.8.1
|
||||||
*
|
*
|
@ -1,32 +1,44 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Unit tests covering WP_Widget_HTML_Code functionality.
|
* Unit tests covering WP_Widget_Custom_HTML functionality.
|
||||||
*
|
*
|
||||||
* @package WordPress
|
* @package WordPress
|
||||||
* @subpackage widgets
|
* @subpackage widgets
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test wp-includes/widgets/class-wp-widget-html-code.php
|
* Test wp-includes/widgets/class-wp-widget-custom-html.php
|
||||||
*
|
*
|
||||||
* @group widgets
|
* @group widgets
|
||||||
*/
|
*/
|
||||||
class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
|
class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Args passed to the widget_html_code_content filter.
|
* Args passed to the widget_custom_html_content filter.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $widget_html_code_content_args;
|
protected $widget_custom_html_content_args;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test constructor.
|
||||||
|
*
|
||||||
|
* @covers WP_Widget_Custom_HTML::__constructor
|
||||||
|
*/
|
||||||
|
function test_constructor() {
|
||||||
|
$widget = new WP_Widget_Custom_HTML();
|
||||||
|
$this->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.
|
* Test widget method.
|
||||||
*
|
*
|
||||||
* @covers WP_Widget_HTML_Code::widget
|
* @covers WP_Widget_Custom_HTML::widget
|
||||||
*/
|
*/
|
||||||
function test_widget() {
|
function test_widget() {
|
||||||
$widget = new WP_Widget_HTML_Code();
|
$widget = new WP_Widget_Custom_HTML();
|
||||||
$content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
|
$content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
|
||||||
|
|
||||||
$args = array(
|
$args = array(
|
||||||
@ -40,22 +52,22 @@ class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
|
|||||||
'content' => $content,
|
'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 );
|
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();
|
ob_start();
|
||||||
$this->widget_html_code_content_args = null;
|
$this->widget_custom_html_content_args = null;
|
||||||
$widget->widget( $args, $instance );
|
$widget->widget( $args, $instance );
|
||||||
$output = ob_get_clean();
|
$output = ob_get_clean();
|
||||||
$this->assertNotEmpty( $this->widget_html_code_content_args );
|
$this->assertNotEmpty( $this->widget_custom_html_content_args );
|
||||||
$this->assertContains( '[filter:widget_html_code_content]', $output );
|
$this->assertContains( '[filter:widget_custom_html_content]', $output );
|
||||||
$this->assertNotContains( '<p>', $output );
|
$this->assertNotContains( '<p>', $output );
|
||||||
$this->assertNotContains( '<br>', $output );
|
$this->assertNotContains( '<br>', $output );
|
||||||
$this->assertNotContains( '</u>', $output );
|
$this->assertNotContains( '</u>', $output );
|
||||||
$this->assertEquals( $instance, $this->widget_html_code_content_args[1] );
|
$this->assertEquals( $instance, $this->widget_custom_html_content_args[1] );
|
||||||
$this->assertSame( $widget, $this->widget_html_code_content_args[2] );
|
$this->assertSame( $widget, $this->widget_custom_html_content_args[2] );
|
||||||
remove_filter( 'widget_html_code_content', array( $this, 'filter_widget_html_code_content' ), 5, 3 );
|
remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
|
||||||
|
|
||||||
update_option( 'use_balanceTags', 1 );
|
update_option( 'use_balanceTags', 1 );
|
||||||
ob_start();
|
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 string $widget_content The widget content.
|
||||||
* @param array $instance Array of settings for the current widget.
|
* @param array $instance Array of settings for the current widget.
|
||||||
* @param WP_Widget_HTML_Code $widget Current HTML Code widget instance.
|
* @param WP_Widget_Custom_HTML $widget Current Custom HTML widget instance.
|
||||||
* @return string Widget content.
|
* @return string Widget content.
|
||||||
*/
|
*/
|
||||||
function filter_widget_html_code_content( $widget_content, $instance, $widget ) {
|
function filter_widget_custom_html_content( $widget_content, $instance, $widget ) {
|
||||||
$this->widget_html_code_content_args = func_get_args();
|
$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;
|
return $widget_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test update method.
|
* Test update method.
|
||||||
*
|
*
|
||||||
* @covers WP_Widget_HTML_Code::update
|
* @covers WP_Widget_Custom_HTML::update
|
||||||
*/
|
*/
|
||||||
function test_update() {
|
function test_update() {
|
||||||
$widget = new WP_Widget_HTML_Code();
|
$widget = new WP_Widget_Custom_HTML();
|
||||||
$instance = array(
|
$instance = array(
|
||||||
'title' => "The\n<b>Title</b>",
|
'title' => "The\n<b>Title</b>",
|
||||||
'content' => "The\n\n<b>Code</b>",
|
'content' => "The\n\n<b>Code</b>",
|
Loading…
Reference in New Issue
Block a user