Make WordPress Core


Ignore:
Timestamp:
03/15/2023 11:36:52 AM (19 months ago)
Author:
spacedmonkey
Message:

Widgets: Defer register inline script in WP_Widget_Custom_HTML and WP_Widget_Text.

In [41376] an inline script was added to push idBases for the custom html and text widgets. However, this script is not used unless the widget script is output in the widget screen / customizer. Deferring registering this script until it is needed, results in a faster server response times.

Props spacedmonkey, sakibmd, flixos90, westonruter.
Fixes #57864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/widgets/wpWidgetCustomHtml.php

    r54088 r55553  
    6868        $this->assertSame( 10, has_action( 'admin_footer-widgets.php', array( 'WP_Widget_Custom_HTML', 'render_control_template_scripts' ) ) );
    6969        $this->assertSame( 10, has_action( 'admin_head-widgets.php', array( 'WP_Widget_Custom_HTML', 'add_help_text' ) ) );
    70         $this->assertContains( 'wp.customHtmlWidgets.idBases.push( "custom_html" );', wp_scripts()->registered['custom-html-widgets']->extra['after'] );
    7170    }
    7271
Note: See TracChangeset for help on using the changeset viewer.