From e515926de3474da761f06bc5ca0037ff7d4ca761 Mon Sep 17 00:00:00 2001 From: strarsis Date: Fri, 24 Mar 2017 20:17:06 +0100 Subject: [PATCH 1/2] Update minit-assets.php --- include/minit-assets.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/include/minit-assets.php b/include/minit-assets.php index 477a3f4..14f4fc9 100644 --- a/include/minit-assets.php +++ b/include/minit-assets.php @@ -230,21 +230,17 @@ protected function get_asset_relative_path( $handle ) { return false; } - // Remove protocol reference from the local base URL - $base_url = preg_replace( '/^(https?:)/i', '', $this->handler->base_url ); + $arr = explode(plugins_url(), $item_url); + $url_rel = $arr[1]; - // Check if this is a local asset which we can include - $src_parts = explode( $base_url, $item_url ); - - if ( empty( $src_parts ) ) { + if ( empty( $url_rel ) ) { return false; } - // Get the trailing part of the local URL - $maybe_relative = array_pop( $src_parts ); + $path_abs = WP_PLUGIN_DIR . $url_rel; - if ( file_exists( ABSPATH . $maybe_relative ) ) { - return $maybe_relative; + if ( file_exists( $path_abs ) ) { + return $path_abs; // TODO: trailing path of the local URL? } return false; From ff31d8230bd623de390eb6f3a531b6fae03a5ef7 Mon Sep 17 00:00:00 2001 From: strarsis Date: Fri, 24 Mar 2017 20:49:57 +0100 Subject: [PATCH 2/2] Update minit-assets.php --- include/minit-assets.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/include/minit-assets.php b/include/minit-assets.php index 14f4fc9..d5661dd 100644 --- a/include/minit-assets.php +++ b/include/minit-assets.php @@ -230,17 +230,23 @@ protected function get_asset_relative_path( $handle ) { return false; } - $arr = explode(plugins_url(), $item_url); - $url_rel = $arr[1]; + // plugins + $path_rel_plugin = explode(plugins_url(), $item_url)[1]; + $path_abs = WP_PLUGIN_DIR . $path_rel_plugin; - if ( empty( $url_rel ) ) { + if(empty($path_rel_plugin)) { + // theme + $path_rel_theme = explode(get_template_directory_uri(), $item_url)[1]; + $path_abs = get_template_directory() . $path_rel_theme; + } + + if ( empty( $path_rel_plugin ) && empty( $path_rel_theme ) ) { return false; } - $path_abs = WP_PLUGIN_DIR . $url_rel; if ( file_exists( $path_abs ) ) { - return $path_abs; // TODO: trailing path of the local URL? + return $path_abs; } return false;