I have a snippet of code in a php (WordPress) page:
function vp_contact_popup_add_to_header()
{
// Register the style like this for a plugin:
wp_register_style( 'videopopup', plugins_url( '/code/css/videopopup.css', __FILE__ ),
array(), '20120208', 'all' );
// Register the script like this for a plugin:
wp_register_script( 'videopopup', plugins_url( '/code/js/videopopup.js', __FILE__ ) );
wp_enqueue_style("videopopup");
wp_enqueue_script("videopopup");
}
What I’m trying to do is to add something in there … like an extra clause to the javascript portion of that snippet, like this:
<script data-cfasync="false" src="/code/js/videopopup.js"></script>
So I want to somehow incorprate the data-cfasync=”false” into the php snippet, but I’m unsure how to do this. Any guidance would be truly appreciated!
I don’t see any way to do this using
wp_register_script()
orwp_enqueue_script()
. The only way I see to do this (except modifying the header file of the theme) is using the wp_print_scripts hook directly. You can do it like this:But heed the warning in the documentation that this should not be used directly.