Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
function tryCustomizeDependency() {
try {
wp.customize.bind( 'ready', function() {
console.info( 'ready' );
} );
console.info( 'PASS' );
} catch( e ) {
console.error( 'FAIL' );
}
}
<?php
/**
* Plugin Name: Test case for WP Trac #36392: wp_add_inline_script() breaks script dependency order when using script loader (no SCRIPT_DEBUG)
* Plugin URL: https://core.trac.wordpress.org/ticket/36392
*/
add_action( 'wp_default_scripts', function( WP_Scripts $wp_scripts ) {
$handle = 'customize-dependency';
$src = plugin_dir_url( __FILE__ ) . 'customize-dependency.js';
$deps = array( 'customize-controls' );
$wp_scripts->add( $handle, $src, $deps );
} );
add_action( 'customize_controls_enqueue_scripts', function() {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {
trigger_error( 'Set SCRIPT_DEBUG to false to replicate the issue.', E_USER_WARNING );
}
$handle = 'customize-dependency';
wp_enqueue_script( $handle );
wp_add_inline_script( $handle, 'tryCustomizeDependency()' );
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.