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;
}