wp.customize.bind ready event not fired

Do not put the Customizer ready event handler inside of the jQuery event handler. The Customizer ready will trigger at jQuery ready, so you are adding the event handler too late. Just do: wp.customize.bind(‘ready’, function(){ console.log(‘ready’); }); Your JS needs to be enqueued with customize-controls script as its dependency. Enqueue at the customize_controls_enqueue_scripts action.

Any advantage of using wp_scripts and is_IE when enqueuing scripts

To extend on @gmazzap suggestion on not using globals when you can use wp_scripts(), there is a shortcut for wp_scripts() for adding conditional comments called wp_script_add_data and likewise wp_style_add_data for conditional styles. So the correct way to use conditionals as of WordPress 4.2 is like this: /** * IE enqueue HTML5shiv with conditionals * @link … Read more

How to dequeue a script?

There is a dequeue method available … I’m just not sure why it isn’t wrapped in a wp_dequeue_script() method. (I might create a ticket for this issue, actually) But yes, using wp_deregister_script will accomplish what you’re trying to do. Just remember, if you ever do want to use WP’s built-in jQuery later you’ll need to … Read more

wp_enqueue_script() not working at all

wp_enqueue_style and wp_enqueue_script accepts many parameters and it’s very important to use them in correct order otherwise these functions will fail. Here are complete set of parameters for each function. wp_enqueue_style( $handle, $src, $deps, $ver, $media ); wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); In your wp_enqueue_style you define $handle, $src correctly but $deps to … Read more

How to use wp.hooks.addAction() in React JS/Gutenberg?

How to use wp.hooks.addAction? It’s basically like so, just like you’ve attempted: // Hook to the hook_name action. wp.hooks.addAction( ‘hook_name’, ‘namespace’, function(){ console.log( ‘Foo Bar’ ); } ); // Trigger the hook_name action. wp.hooks.doAction( ‘hook_name’ ); Or for hooks which provides one or more parameters to the callback: // Hook to the hook_name action. wp.hooks.addAction( … Read more

How to configure WordPress to be able to use tag inside posts?

Add the following to your theme functions.php: function fb_change_mce_options($initArray) { $ext=”script[charset|defer|language|src|type]”; if ( isset( $initArray[‘extended_valid_elements’] ) ) { $initArray[‘extended_valid_elements’] .= ‘,’ . $ext; } else { $initArray[‘extended_valid_elements’] = $ext; } return $initArray; } add_filter(‘tiny_mce_before_init’, ‘fb_change_mce_options’);