Changeset 40926
- Timestamp:
- 06/23/2017 11:59:23 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/default-filters.php
r40893 r40926 171 171 add_filter( 'widget_text_content', 'wpautop' ); 172 172 173 add_filter( 'widget_ html_code_content', 'balanceTags' );173 add_filter( 'widget_custom_html_content', 'balanceTags' ); 174 174 175 175 add_filter( 'date_i18n', 'wp_maybe_decline_date' ); -
trunk/src/wp-includes/default-widgets.php
r40893 r40926 62 62 require_once( ABSPATH . WPINC . '/widgets/class-wp-nav-menu-widget.php' ); 63 63 64 /** WP_Widget_ HTML_Codeclass */65 require_once( ABSPATH . WPINC . '/widgets/class-wp-widget- html-code.php' );64 /** WP_Widget_Custom_HTML class */ 65 require_once( ABSPATH . WPINC . '/widgets/class-wp-widget-custom-html.php' ); -
trunk/src/wp-includes/widgets.php
r40893 r40926 1475 1475 register_widget( 'WP_Nav_Menu_Widget' ); 1476 1476 1477 register_widget( 'WP_Widget_ HTML_Code' );1477 register_widget( 'WP_Widget_Custom_HTML' ); 1478 1478 1479 1479 /** -
trunk/src/wp-includes/widgets/class-wp-widget-custom-html.php
r40925 r40926 1 1 <?php 2 2 /** 3 * Widget API: WP_Widget_ HTML_Codeclass3 * Widget API: WP_Widget_Custom_HTML class 4 4 * 5 5 * @package WordPress … … 9 9 10 10 /** 11 * Core class used to implement a HTML Codewidget.11 * Core class used to implement a Custom HTML widget. 12 12 * 13 13 * @since 4.8.1 … … 15 15 * @see WP_Widget 16 16 */ 17 class WP_Widget_ HTML_Codeextends WP_Widget {17 class WP_Widget_Custom_HTML extends WP_Widget { 18 18 19 19 /** … … 29 29 30 30 /** 31 * Sets up a new HTML Codewidget instance.31 * Sets up a new Custom HTML widget instance. 32 32 * 33 33 * @since 4.8.1 … … 35 35 public function __construct() { 36 36 $widget_ops = array( 37 'classname' => 'widget_ html_code',37 'classname' => 'widget_custom_html', 38 38 'description' => __( 'Arbitrary HTML code.' ), 39 39 'customize_selective_refresh' => true, 40 40 ); 41 41 $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 ); 43 43 } 44 44 45 45 /** 46 * Outputs the content for the current HTML Codewidget instance.46 * Outputs the content for the current Custom HTML widget instance. 47 47 * 48 48 * @since 4.8.1 … … 50 50 * @param array $args Display arguments including 'before_title', 'after_title', 51 51 * 'before_widget', and 'after_widget'. 52 * @param array $instance Settings for the current HTML Codewidget instance.52 * @param array $instance Settings for the current Custom HTML widget instance. 53 53 */ 54 54 public function widget( $args, $instance ) { … … 62 62 63 63 /** 64 * Filters the content of the HTML Codewidget.64 * Filters the content of the Custom HTML widget. 65 65 * 66 66 * @since 4.8.1 67 67 * 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 Codewidget 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. 71 71 */ 72 $content = apply_filters( 'widget_ html_code_content', $content, $instance, $this );72 $content = apply_filters( 'widget_custom_html_content', $content, $instance, $this ); 73 73 74 74 echo $args['before_widget']; … … 81 81 82 82 /** 83 * Handles updating settings for the current HTML Codewidget instance.83 * Handles updating settings for the current Custom HTML widget instance. 84 84 * 85 85 * @since 4.8.1 … … 102 102 103 103 /** 104 * Outputs the HTML Codewidget settings form.104 * Outputs the Custom HTML widget settings form. 105 105 * 106 106 * @since 4.8.1 -
trunk/tests/phpunit/tests/widgets/custom-html-widget.php
r40925 r40926 1 1 <?php 2 2 /** 3 * Unit tests covering WP_Widget_ HTML_Codefunctionality.3 * Unit tests covering WP_Widget_Custom_HTML functionality. 4 4 * 5 5 * @package WordPress … … 8 8 9 9 /** 10 * Test wp-includes/widgets/class-wp-widget- html-code.php10 * Test wp-includes/widgets/class-wp-widget-custom-html.php 11 11 * 12 12 * @group widgets 13 13 */ 14 class Test_WP_Widget_ HTML_Codeextends WP_UnitTestCase {14 class Test_WP_Widget_Custom_HTML extends WP_UnitTestCase { 15 15 16 16 /** 17 * Args passed to the widget_ html_code_content filter.17 * Args passed to the widget_custom_html_content filter. 18 18 * 19 19 * @var array 20 20 */ 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 } 22 34 23 35 /** 24 36 * Test widget method. 25 37 * 26 * @covers WP_Widget_ HTML_Code::widget38 * @covers WP_Widget_Custom_HTML::widget 27 39 */ 28 40 function test_widget() { 29 $widget = new WP_Widget_ HTML_Code();41 $widget = new WP_Widget_Custom_HTML(); 30 42 $content = "<i>Custom HTML</i>\n\n<b>CODE</b>\nLast line.<u>unclosed"; 31 43 … … 41 53 ); 42 54 43 $this->assertEquals( 10, has_filter( 'widget_ html_code_content', 'balanceTags' ) );55 $this->assertEquals( 10, has_filter( 'widget_custom_html_content', 'balanceTags' ) ); 44 56 45 57 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 ); 47 59 ob_start(); 48 $this->widget_ html_code_content_args = null;60 $this->widget_custom_html_content_args = null; 49 61 $widget->widget( $args, $instance ); 50 62 $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 ); 53 65 $this->assertNotContains( '<p>', $output ); 54 66 $this->assertNotContains( '<br>', $output ); 55 67 $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 ); 59 71 60 72 update_option( 'use_balanceTags', 1 ); … … 66 78 67 79 /** 68 * Filters the content of the HTML Codewidget.80 * Filters the content of the Custom HTML widget. 69 81 * 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 Codewidget 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. 73 85 * @return string Widget content. 74 86 */ 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(); 77 89 78 $widget_content .= '[filter:widget_ html_code_content]';90 $widget_content .= '[filter:widget_custom_html_content]'; 79 91 return $widget_content; 80 92 } … … 83 95 * Test update method. 84 96 * 85 * @covers WP_Widget_ HTML_Code::update97 * @covers WP_Widget_Custom_HTML::update 86 98 */ 87 99 function test_update() { 88 $widget = new WP_Widget_ HTML_Code();100 $widget = new WP_Widget_Custom_HTML(); 89 101 $instance = array( 90 102 'title' => "The\n<b>Title</b>",
Note: See TracChangeset
for help on using the changeset viewer.