diff --git src/wp-admin/js/widgets/text-widgets.js src/wp-admin/js/widgets/text-widgets.js
index 692a0642c9..bb19f2ffb2 100644
|
|
wp.textWidgets = ( function( $ ) { |
4 | 4 | 'use strict'; |
5 | 5 | |
6 | 6 | var component = { |
7 | | dismissedPointers: [] |
| 7 | dismissedPointers: [], |
| 8 | idBases: [ 'text' ] |
8 | 9 | }; |
9 | 10 | |
10 | 11 | /** |
… |
… |
wp.textWidgets = ( function( $ ) { |
357 | 358 | widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); // Note: '.form' appears in the customizer, whereas 'form' on the widgets admin screen. |
358 | 359 | |
359 | 360 | idBase = widgetForm.find( '> .id_base' ).val(); |
360 | | if ( 'text' !== idBase ) { |
| 361 | if ( -1 === component.idBases.indexOf( idBase ) ) { |
361 | 362 | return; |
362 | 363 | } |
363 | 364 | |
… |
… |
wp.textWidgets = ( function( $ ) { |
424 | 425 | } |
425 | 426 | |
426 | 427 | idBase = widgetForm.find( '> .widget-control-actions > .id_base' ).val(); |
427 | | if ( 'text' !== idBase ) { |
| 428 | if ( -1 === component.idBases.indexOf( idBase ) ) { |
428 | 429 | return; |
429 | 430 | } |
430 | 431 | |
… |
… |
wp.textWidgets = ( function( $ ) { |
461 | 462 | widgetForm = widgetContainer.find( '> .widget-inside > .form, > .widget-inside > form' ); |
462 | 463 | |
463 | 464 | idBase = widgetForm.find( '> .id_base' ).val(); |
464 | | if ( 'text' !== idBase ) { |
| 465 | if ( -1 === component.idBases.indexOf( idBase ) ) { |
465 | 466 | return; |
466 | 467 | } |
467 | 468 | |
diff --git src/wp-includes/widgets/class-wp-widget-text.php src/wp-includes/widgets/class-wp-widget-text.php
index c28ed1f317..4062f1c503 100644
|
|
class WP_Widget_Text extends WP_Widget { |
55 | 55 | } |
56 | 56 | $this->registered = true; |
57 | 57 | |
| 58 | wp_add_inline_script( 'text-widgets', sprintf( 'wp.textWidgets.idBases.push( %s );', wp_json_encode( $this->id_base ) ) ); |
| 59 | |
58 | 60 | // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). |
59 | 61 | add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); |
60 | 62 | |
diff --git tests/phpunit/tests/widgets/text-widget.php tests/phpunit/tests/widgets/text-widget.php
index 41aadb6af7..cadd47fd37 100644
|
|
class Test_WP_Widget_Text extends WP_UnitTestCase { |
65 | 65 | |
66 | 66 | $this->assertEquals( 10, has_action( 'admin_print_scripts-widgets.php', array( $widget, 'enqueue_admin_scripts' ) ) ); |
67 | 67 | $this->assertEquals( 10, has_action( 'admin_footer-widgets.php', array( $widget, 'render_control_template_scripts' ) ) ); |
| 68 | $this->assertContains( 'wp.textWidgets.idBases.push( "text" );', wp_scripts()->registered['text-widgets']->extra['after'] ); |
68 | 69 | } |
69 | 70 | |
70 | 71 | /** |