May 2017
Beginner to intermediate
536 pages
14h 25m
English
This technique is introduced in WordPress version 4.5 for adding additional scripts to an already registered script in your application. This is another way of conditionally adding scripts to your application files. Consider the following code:
wp_enqueue_script( 'wpwa-forum' ); $inline_js = 'jQuery(function($){ $("body").on("dblclick", ".wpwaf_img_prev" , function() { $(this).remove(); }); });'; wp_add_inline_script('wpwaf-forum', $inline_js);
In this scenario, we have already registered and enqueued the wpwa-forum script. Then, we add custom jQuery script into this file using the wp_add_inline_script function. The important thing is that we can register the script in one location and dynamically add other scripts ...
Read now
Unlock full access