Last active
February 6, 2017 20:26
-
-
Save crstauf/22f8c1c19d614f1858bffb67dab3f73f 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 get_theme_asset_uri( $theme_file_path ) { | |
| // https://gist.github.com/crstauf/22f8c1c19d614f1858bffb67dab3f73f, v2.1 | |
| if ( false === stripos( $theme_file_path, '.min.' ) ) | |
| return trailingslashit( get_stylesheet_directory_uri() ) . $theme_file_path; | |
| $debug = SCRIPT_DEBUG; | |
| if ( false === SCRIPT_DEBUG ) { | |
| if ( false !== strpos( $theme_file_path, '.js' ) ) | |
| $debug = !defined( 'COMPRESS_SCRIPTS' ) | |
| || !COMPRESS_SCRIPTS; | |
| else | |
| $debug = !defined( 'COMPRESS_CSS' ) | |
| || !COMPRESS_CSS; | |
| } | |
| $path = trailingslashit( get_stylesheet_directory() ); | |
| $uri = trailingslashit( get_stylesheet_directory_uri() ); | |
| if ( | |
| false === $debug | |
| && file_exists( $path . $theme_file_path ) | |
| ) | |
| return $uri . $theme_file_path; | |
| if ( file_exists( $path . str_replace( '.min.', '.', $theme_file_path ) ) ) | |
| return $uri . str_replace( '.min.', '.', $theme_file_path ); | |
| return $uri . $theme_file_path; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment