Last active
August 1, 2019 19:07
-
-
Save macariojames/655c760d13ece75a40c8114cef996257 to your computer and use it in GitHub Desktop.
Wordpress: register and enqueue of scripts, use wp_localize_script to get current theme images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for the JS file that needs theme images | |
// append rest of directory | |
// could add multiple variables if wanted inside array | |
// ~mj | |
wp_localize_script( | |
'main', // $handle | |
'WPURLS', | |
array( | |
'siteurl' => print_dir('images') // instead of custom function print_dir(), you can put the path of your images directory | |
) | |
); | |
// the gist for my custom print_dir() function used above: | |
https://gist.github.com/macariojames/fced3f8bc6bb65634ea4a642c6f4e571 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment