Make WordPress Core

Changeset 40926


Ignore:
Timestamp:
06/23/2017 11:59:23 PM (7 years ago)
Author:
westonruter
Message:

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.

Location:
trunk
Files:
3 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/default-filters.php

    r40893 r40926  
    171171add_filter( 'widget_text_content', 'wpautop'              );
    172172
    173 add_filter( 'widget_html_code_content', 'balanceTags' );
     173add_filter( 'widget_custom_html_content', 'balanceTags' );
    174174
    175175add_filter( 'date_i18n', 'wp_maybe_decline_date' );
  • trunk/src/wp-includes/default-widgets.php

    r40893 r40926  
    6262require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' );
    6363
    64 /** WP_Widget_HTML_Code class */
    65 require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-html-code.php' );
     64/** WP_Widget_Custom_HTML class */
     65require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-custom-html.php' );
  • trunk/src/wp-includes/widgets.php

    r40893 r40926  
    14751475    register_widget( 'WP_Nav_Menu_Widget' );
    14761476
    1477     register_widget( 'WP_Widget_HTML_Code' );
     1477    register_widget( 'WP_Widget_Custom_HTML' );
    14781478
    14791479    /**
  • trunk/src/wp-includes/widgets/class-wp-widget-custom-html.php

    r40925 r40926  
    11<?php
    22/**
    3  * Widget API: WP_Widget_HTML_Code class
     3 * Widget API: WP_Widget_Custom_HTML class
    44 *
    55 * @package WordPress
     
    99
    1010/**
    11  * Core class used to implement a HTML Code widget.
     11 * Core class used to implement a Custom HTML widget.
    1212 *
    1313 * @since 4.8.1
     
    1515 * @see WP_Widget
    1616 */
    17 class WP_Widget_HTML_Code extends WP_Widget {
     17class WP_Widget_Custom_HTML extends WP_Widget {
    1818
    1919    /**
     
    2929
    3030    /**
    31      * Sets up a new HTML Code widget instance.
     31     * Sets up a new Custom HTML widget instance.
    3232     *
    3333     * @since 4.8.1
     
    3535    public function __construct() {
    3636        $widget_ops = array(
    37             'classname' => 'widget_html_code',
     37            'classname' => 'widget_custom_html',
    3838            'description' => __( 'Arbitrary HTML code.' ),
    3939            'customize_selective_refresh' => true,
    4040        );
    4141        $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 );
    4343    }
    4444
    4545    /**
    46      * Outputs the content for the current HTML Code widget instance.
     46     * Outputs the content for the current Custom HTML widget instance.
    4747     *
    4848     * @since 4.8.1
     
    5050     * @param array $args     Display arguments including 'before_title', 'after_title',
    5151     *                        '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.
    5353     */
    5454    public function widget( $args, $instance ) {
     
    6262
    6363        /**
    64          * Filters the content of the HTML Code widget.
     64         * Filters the content of the Custom HTML widget.
    6565         *
    6666         * @since 4.8.1
    6767         *
    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.
    7171         */
    72         $content = apply_filters( 'widget_html_code_content', $content, $instance, $this );
     72        $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this );
    7373
    7474        echo $args['before_widget'];
     
    8181
    8282    /**
    83      * Handles updating settings for the current HTML Code widget instance.
     83     * Handles updating settings for the current Custom HTML widget instance.
    8484     *
    8585     * @since 4.8.1
     
    102102
    103103    /**
    104      * Outputs the HTML Code widget settings form.
     104     * Outputs the Custom HTML widget settings form.
    105105     *
    106106     * @since 4.8.1
  • trunk/tests/phpunit/tests/widgets/custom-html-widget.php

    r40925 r40926  
    11<?php
    22/**
    3  * Unit tests covering WP_Widget_HTML_Code functionality.
     3 * Unit tests covering WP_Widget_Custom_HTML functionality.
    44 *
    55 * @package    WordPress
     
    88
    99/**
    10  * Test wp-includes/widgets/class-wp-widget-html-code.php
     10 * Test wp-includes/widgets/class-wp-widget-custom-html.php
    1111 *
    1212 * @group widgets
    1313 */
    14 class Test_WP_Widget_HTML_Code extends WP_UnitTestCase {
     14class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase {
    1515
    1616    /**
    17      * Args passed to the widget_html_code_content filter.
     17     * Args passed to the widget_custom_html_content filter.
    1818     *
    1919     * @var array
    2020     */
    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    }
    2234
    2335    /**
    2436     * Test widget method.
    2537     *
    26      * @covers WP_Widget_HTML_Code::widget
     38     * @covers WP_Widget_Custom_HTML::widget
    2739     */
    2840    function test_widget() {
    29         $widget = new WP_Widget_HTML_Code();
     41        $widget = new WP_Widget_Custom_HTML();
    3042        $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed";
    3143
     
    4153        );
    4254
    43         $this->assertEquals( 10, has_filter( 'widget_html_code_content', 'balanceTags' ) );
     55        $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) );
    4456
    4557        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 );
    4759        ob_start();
    48         $this->widget_html_code_content_args = null;
     60        $this->widget_custom_html_content_args = null;
    4961        $widget->widget( $args, $instance );
    5062        $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 );
    5365        $this->assertNotContains( '<p>', $output );
    5466        $this->assertNotContains( '<br>', $output );
    5567        $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 );
    5971
    6072        update_option( 'use_balanceTags', 1 );
     
    6678
    6779    /**
    68      * Filters the content of the HTML Code widget.
     80     * Filters the content of the Custom HTML widget.
    6981     *
    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.
    7385     * @return string Widget content.
    7486     */
    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();
    7789
    78         $widget_content .= '[filter:widget_html_code_content]';
     90        $widget_content .= '[filter:widget_custom_html_content]';
    7991        return $widget_content;
    8092    }
     
    8395     * Test update method.
    8496     *
    85      * @covers WP_Widget_HTML_Code::update
     97     * @covers WP_Widget_Custom_HTML::update
    8698     */
    8799    function test_update() {
    88         $widget = new WP_Widget_HTML_Code();
     100        $widget = new WP_Widget_Custom_HTML();
    89101        $instance = array(
    90102            'title'   => "The\n<b>Title</b>",
Note: See TracChangeset for help on using the changeset viewer.