Add Defer Attributes to WordPress Scripts with consistent versioning

Use the $wp_scripts, which is a global variable to get the version of a registered script. add_filter( ‘script_loader_tag’, ‘script_handler’, 10, 3 ); function script_handler( $tag, $handle, $src ) { // the following global contains all the information you need global $wp_scripts; $ver = $wp_scripts->registered[ $handle ]->ver; // do your thing } Note, this is exemplary.

wp localizing script not works

There are a few things wrong…the most pertinent of which is that the script that you’re going to localize with wp_localize_script() must be registered before you call wp_localize_script(). Secondly, your call to wp_enqueue_script( ‘reservation-scripts’ ) doesn’t provide the source (i.e., URL) for the script. Lastly, they way you are enqueueing jQuery is incorrect. So, if … Read more

Exclude external uri for css and js version

Declaring functions inside functions can lead to problems as explained here: https://stackoverflow.com/a/1631579/1228379 To solve the issue of remote files, you can use an additional parameter to indicate it is remote (or local) and call get_theme_file_uri/path accordingly. Alternatively, you can just call wp_enqueue_script/style directly and use standard version numbers, or simply save the files locally. In … Read more

jQuery not available to other scripts

You’ve got two copies of some inline script var $mcj = jQuery.noConflict(true); inside a commented section ‘mc_embed_signup’. The ‘true’ here is removeAll: removeAll Type: Boolean A Boolean indicating whether to remove all jQuery variables from the global scope (including jQuery itself). You should track down this script and try and understand what it’s trying to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)