WordPress.org

Make WordPress Core

Ticket #40907: 40907-rename.0.diff

File 40907-rename.0.diff, 10.0 KB (added by westonruter, 2 years ago)

https://github.com/xwp/wordpress-develop/pull/236

  • src/wp-includes/default-filters.php

    diff --git src/wp-includes/default-filters.php src/wp-includes/default-filters.php
    index 6f64ffab5d..ada9c53c3f 100644
    add_filter( 'widget_text_content', 'wptexturize' ); 
    170170add_filter( 'widget_text_content', 'convert_smilies',  20 );
    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' );
    176176
  • src/wp-includes/default-widgets.php

    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' ); 
    6161/** WP_Nav_Menu_Widget class */
    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' );
  • src/wp-includes/widgets.php

    diff --git src/wp-includes/widgets.php src/wp-includes/widgets.php
    index b44048d641..fbbdcf5f55 100644
    function wp_widgets_init() { 
    14741474
    14751475        register_widget( 'WP_Nav_Menu_Widget' );
    14761476
    1477         register_widget( 'WP_Widget_HTML_Code' );
     1477        register_widget( 'WP_Widget_Custom_HTML' );
    14781478
    14791479        /**
    14801480         * Fires after all default WordPress widgets have been registered.
  • src/wp-includes/widgets/

    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  
    11<?php
    22/**
    3  * Widget API: WP_Widget_HTML_Code class
     3 * Widget API: WP_Widget_Custom_HTML class
    44 *
    55 * @package WordPress
    66 * @subpackage Widgets
     
    88 */
    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
    1414 *
    1515 * @see WP_Widget
    1616 */
    17 class WP_Widget_HTML_Code extends WP_Widget {
     17class WP_Widget_Custom_HTML extends WP_Widget {
    1818
    1919        /**
    2020         * Default instance.
    class WP_Widget_HTML_Code extends WP_Widget { 
    2828        );
    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
    3434         */
    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
    4949         *
    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 ) {
    5555
    class WP_Widget_HTML_Code extends WP_Widget { 
    6161                $content = $instance['content'];
    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'];
    7575                if ( ! empty( $title ) ) {
    class WP_Widget_HTML_Code extends WP_Widget { 
    8080        }
    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
    8686         *
    class WP_Widget_HTML_Code extends WP_Widget { 
    101101        }
    102102
    103103        /**
    104          * Outputs the HTML Code widget settings form.
     104         * Outputs the Custom HTML widget settings form.
    105105         *
    106106         * @since 4.8.1
    107107         *
  • tests/phpunit/tests/widgets/

    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  
    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
    66 * @subpackage widgets
    77 */
    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
    3244                $args = array(
    class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { 
    4052                        'content' => $content,
    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 );
    6173                ob_start();
    class Test_WP_Widget_HTML_Code extends WP_UnitTestCase { 
    6577        }
    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        }
    8193
    8294        /**
    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>",
    91103                        'content' => "The\n\n<b>Code</b>",