Skip to content

Commit

Permalink
Merge pull request #18 from stellarwp/fix/windows-compat
Browse files Browse the repository at this point in the history
Ensure paths use `/` for Windows compatibility
  • Loading branch information
borkweb authored Aug 8, 2024
2 parents be4448d + 9dcc5cc commit 91064b7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Plugin Name: Assets
* Description: Asset library with a plugin bootstrap file for automated testing.
* Version: 1.2.6
* Version: 1.2.8
* Author: StellarWP
* Author URI: https://stellarwp.com
*/
10 changes: 8 additions & 2 deletions src/Assets/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,21 @@ public static function set_relative_asset_path( string $path ) {
* @return void
*/
public static function set_path( string $path ) {
$plugins_content_dir_position = strpos( $path, WP_PLUGIN_DIR );
$plugin_dir = WP_PLUGIN_DIR;

if ( DIRECTORY_SEPARATOR !== '/' ) {
$plugin_dir = str_replace( '/', DIRECTORY_SEPARATOR, $plugin_dir );
}

$plugins_content_dir_position = strpos( $path, $plugin_dir );
$themes_content_dir_position = strpos( $path, get_theme_root() );

if (
$plugins_content_dir_position === false
&& $themes_content_dir_position === false
) {
// Default to plugins.
$path = WP_PLUGIN_DIR . $path;
$path = $plugin_dir . $path;
} elseif ( $plugins_content_dir_position !== false ) {
$path = substr( $path, $plugins_content_dir_position );
} elseif ( $themes_content_dir_position !== false ) {
Expand Down

0 comments on commit 91064b7

Please sign in to comment.