Question about the way that wp_register_script works

For the record this entirely the wrong thing to do. Themes should avoid (read never!) de-register the WordPress registered jQuery scripts (plug-ins should absolutely never do this). If a theme is to de-register the jquery script (to replace it) then it should re-register it properly: wp_register_script( ‘jquery’, ‘http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js’); Here-in lies the problem. The above is … Read more

Using multiple versions of jQuery while still calling it like WP likes

I found that it was better for me to use the latest jQuery version (which WordPress loads by default) and to treat the incompatibility issue by modifying the JS plugin files that were incompatible with the latest jQuery version. Note: The reason I chose this solution is because in most cases, JS plugin incompatibility with … Read more

Register script version not showing

I can verify this is working for me and it looks much like the code you’ve provided. Perhaps there is somewhere else you are defining your script. Can you give it a new handle name to check (‘custom-xyz’)? Also, can you test the output of filemtime to see what it’s outputting? I’ve added a “v” … Read more

Can’t move jQuery to footer

Not the best way but removing the default WordPress actions that allow any scripts in the document’s head can help: function md_footer_enqueue_scripts() { remove_action(‘wp_head’, ‘wp_print_scripts’); remove_action(‘wp_head’, ‘wp_print_head_scripts’, 9); remove_action(‘wp_head’, ‘wp_enqueue_scripts’, 1); } add_action(‘wp_enqueue_scripts’, ‘md_footer_enqueue_scripts’);`

Help with enqueing scripts in footer after init action

If you enqueue the script to the footer while the page is being rendered (after the “wp_head” hook), you will have to manually add wp_print_scripts (or wp_print_footer_scripts) to the wp_footer action, like this: wp_enqueue_script( ‘jquery-gallery’, null, array( ‘jquery’ ), null, true ); add_action( ‘wp_footer’, create_function( ”, ‘wp_print_scripts( “jquery-gallery” );’ ) );

Register script/style: Is it possible to customize the version query string via plugin?

Old answer (based on misconception that you wanted a cache buster): You can use add_query_arg() which adds/replaces query arguments. <?php /** * Plugin Name: wpse_84670 * Version: 0.0.1 * Description: replace script/style version with time as a cache buster */ /** * replace script or stylesheet version with current time * @param string $url the … Read more

changing function wp_register

Use the following filter named register: add_filter( ‘register’, ‘wpse_96892_register_link’ ); function wpse_96892_register_link( $link ) { if ( is_user_logged_in() ) return $link; return str_replace( // search array ( site_url(‘wp-login.php?action=register’, ‘login’), __(‘Register’) ), // replacements array ( site_url(‘/profile’), __(‘Profile Page’) ), $link ); }

wp_enqueue_script with dependencies doesn’t work

This is a bug in WordPress. https://core.trac.wordpress.org/ticket/35873 As far as I can see, it can currently be fixed with https://core.trac.wordpress.org/attachment/ticket/35873/35873.3.patch, if you are reading this some time later, it has probably already been fixed for your WordPress version. As a temporary workaround, set parent dependencies to both child and grandchild. This way grandchild.js will not … Read more