Created
November 19, 2018 13:04
-
-
Save billrobbins/745770cd462d26f62e64c8c0e237626d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function wpwa_legendary_enqueue_hashed_js() { | |
| $dirJS = new DirectoryIterator(get_stylesheet_directory() . '/static/js'); | |
| foreach ($dirJS as $file) { | |
| if (pathinfo($file, PATHINFO_EXTENSION) === 'js') { | |
| $fullName = basename($file); | |
| $name = substr(basename($fullName), 0, strpos(basename($fullName), '.')); | |
| switch($name) { | |
| case 'app': | |
| $deps = array('vendor'); | |
| break; | |
| case 'vendor': | |
| $deps = array('manifest'); | |
| break; | |
| default: | |
| $deps = null; | |
| break; | |
| } | |
| wp_enqueue_script( $name, get_template_directory_uri() . '/static/js/' . $fullName, $deps, null, true ); | |
| } | |
| } | |
| } | |
| add_action( 'wp_enqueue_scripts', 'wpwa_legendary_enqueue_hashed_js', 0 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment