WP_Scripts example


function wp_scripts() {
    global $wp_scripts;

    if ( ! ( $wp_scripts instanceof WP_Scripts ) ) {
        $wp_scripts = new WP_Scripts();
    }

    return $wp_scripts;
}

/** * Helper function to output a _doing_it_wrong message when applicable. * * @ignore * @since 4.2.0 * @since 5.5.0 Added the `$handle` parameter. * * @param string $function_name Function name. * @param string $handle Optional. Name of the script or stylesheet that was * registered or enqueued too early. Default empty. */

function _wp_get_iframed_editor_assets() {
    global $wp_styles$wp_scripts$pagenow;

    // Keep track of the styles and scripts instance to restore later.     $current_wp_styles  = $wp_styles;
    $current_wp_scripts = $wp_scripts;

    // Create new instances to collect the assets.     $wp_styles  = new WP_Styles();
    $wp_scripts = new WP_Scripts();

    /* * Register all currently registered styles and scripts. The actions that * follow enqueue assets, but don't necessarily register them. */
    $wp_styles->registered  = $current_wp_styles->registered;
    $wp_scripts->registered = $current_wp_scripts->registered;

    /* * We generally do not need reset styles for the iframed editor. * However, if it's a classic theme, margins will be added to every block, * which is reset specifically for list items, so classic themes rely on * these reset styles. */
if ( ! empty( $url ) ) {
    $wp_customize->set_preview_url( wp_unslash( $url ) );
}
if ( ! empty( $return ) ) {
    $wp_customize->set_return_url( wp_unslash( $return ) );
}
if ( ! empty( $autofocus ) && is_array( $autofocus ) ) {
    $wp_customize->set_autofocus( wp_unslash( $autofocus ) );
}

$registered             = $wp_scripts->registered;
$wp_scripts             = new WP_Scripts();
$wp_scripts->registered = $registered;

add_action( 'customize_controls_print_scripts', 'print_head_scripts', 20 );
add_action( 'customize_controls_print_footer_scripts', '_wp_footer_scripts' );
add_action( 'customize_controls_print_styles', 'print_admin_styles', 20 );

/** * Fires when Customizer controls are initialized, before scripts are enqueued. * * @since 3.4.0 */
header( "$protocol 400 Bad Request" );
    exit;
}

require ABSPATH . 'wp-admin/includes/noop.php';
require ABSPATH . WPINC . '/script-loader.php';
require ABSPATH . WPINC . '/version.php';

$expires_offset = 31536000; // 1 year. $out            = '';

$wp_scripts = new WP_Scripts();
wp_default_scripts( $wp_scripts );
wp_default_packages_vendor( $wp_scripts );
wp_default_packages_scripts( $wp_scripts );

if ( isset( $_SERVER['HTTP_IF_NONE_MATCH'] ) && stripslashes( $_SERVER['HTTP_IF_NONE_MATCH'] ) === $wp_version ) {
    header( "$protocol 304 Not Modified" );
    exit;
}

foreach ( $load as $handle ) {
    if ( ! array_key_exists( $handle$wp_scripts->registered ) ) {
        
Home | Imprint | This part of the site doesn't use cookies.