Make WordPress Core

Ticket #41394: 41394.0.diff

File 41394.0.diff, 2.9 KB (added by westonruter, 8 years ago)
  • src/wp-includes/widgets/class-wp-widget-custom-html.php

    diff --git src/wp-includes/widgets/class-wp-widget-custom-html.php src/wp-includes/widgets/class-wp-widget-custom-html.php
    index 5de618285f..1f84176112 100644
    class WP_Widget_Custom_HTML extends WP_Widget { 
    6161                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
    6262                $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    6363
     64                // Prepare instance data that looks like a normal Text widget.
     65                $simulated_text_widget_instance = $instance;
     66                $simulated_text_widget_instance['text'] = $simulated_text_widget_instance['content'];
     67                unset( $simulated_text_widget_instance['content'] );
     68                $simulated_text_widget_instance['filter'] = false; // Because wpautop is not applied.
     69
    6470                /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
    65                 $content = apply_filters( 'widget_text', $instance['content'], $instance, $this );
     71                $content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this );
    6672
    6773                /**
    6874                 * Filters the content of the Custom HTML widget.
  • tests/phpunit/tests/widgets/custom-html-widget.php

    diff --git tests/phpunit/tests/widgets/custom-html-widget.php tests/phpunit/tests/widgets/custom-html-widget.php
    index c7c2e91bf8..1e1e4dc676 100644
    class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 
    5959                        'content' => $content,
    6060                );
    6161
     62                // Convert Custom HTML widget instance into Text widget instance data.
     63                $text_widget_instance = array_merge( $instance, array(
     64                        'filter' => false,
     65                        'text' => $instance['content'],
     66                ) );
     67                unset( $text_widget_instance['content'] );
     68
    6269                update_option( 'use_balanceTags', 0 );
    6370                add_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
    6471                add_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10, 3 );
    class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 
    7380                $this->assertNotContains( '<p>', $output );
    7481                $this->assertNotContains( '<br>', $output );
    7582                $this->assertNotContains( '</u>', $output );
    76                 $this->assertEquals( $instance, $this->widget_text_args[1] );
     83                $this->assertEquals( $text_widget_instance, $this->widget_text_args[1] );
    7784                $this->assertEquals( $instance, $this->widget_custom_html_content_args[1] );
    7885                $this->assertSame( $widget, $this->widget_text_args[2] );
    7986                $this->assertSame( $widget, $this->widget_custom_html_content_args[2] );
    80                 remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5, 3 );
     87                remove_filter( 'widget_custom_html_content', array( $this, 'filter_widget_custom_html_content' ), 5 );
    8188                remove_filter( 'widget_text', array( $this, 'filter_widget_text' ), 10 );
    8289
    8390                update_option( 'use_balanceTags', 1 );