Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix get_file_uri() when using symlinks #44

Merged
merged 2 commits into from
Jun 30, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion inc/paths.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,14 @@ function get_file_uri( string $path ): string {
return get_theme_file_uri( theme_relative_path( $path ) );
}

return content_url( str_replace( WP_CONTENT_DIR, '', $path ) );
// If the path is inside WP_CONTENT_DIR then remove the asbilute path, passing to content_url().
joehoyle marked this conversation as resolved.
Show resolved Hide resolved
if ( strpos( $path, WP_CONTENT_DIR ) === 0 ) {
return content_url( str_replace( WP_CONTENT_DIR, '', $path ) );
}

// Attempt to use plugins_url on the path, if it's a plugin. This will also handle cases
// while $path is inside a symlink.
return plugins_url( basename( $path ), $path );
}

/**
Expand Down