WP_Widget_Custom_HTML::enqueue_admin_scripts() WordPress Method

This method is used to enqueue necessary admin scripts for the widget.

WP_Widget_Custom_HTML::enqueue_admin_scripts() #

Loads the required scripts and styles for the widget control.


Source

File: wp-includes/widgets/class-wp-widget-custom-html.php

207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
public function enqueue_admin_scripts() {
    $settings = wp_enqueue_code_editor(
        array(
            'type'       => 'text/html',
            'codemirror' => array(
                'indentUnit' => 2,
                'tabSize'    => 2,
            ),
        )
    );
 
    wp_enqueue_script( 'custom-html-widgets' );
    if ( empty( $settings ) ) {
        $settings = array(
            'disabled' => true,
        );
    }
    wp_add_inline_script( 'custom-html-widgets', sprintf( 'wp.customHtmlWidgets.init( %s );', wp_json_encode( $settings ) ), 'after' );
 
    $l10n = array(
        'errorNotice' => array(
            /* translators: %d: Error count. */
            'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ),
            /* translators: %d: Error count. */
            'plural'   => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ),
            // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.
        ),
    );
    wp_add_inline_script( 'custom-html-widgets', sprintf( 'jQuery.extend( wp.customHtmlWidgets.l10n, %s );', wp_json_encode( $l10n ) ), 'after' );
}


Top ↑

Changelog

Changelog
VersionDescription
4.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.