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

replace the DIRECTORY_SEPARATE with slash for other OS #23

Merged
merged 1 commit into from
Oct 21, 2024

Conversation

vodanh1213
Copy link
Contributor

This PR will ensure that if the OS is not *nix, then the DIRECTORY_SEPARATOR in the $path will be parsed correctly, along with the $plugin_dir.
Problem:

public static function set_path( string $path ) {
    $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() );
    ...
}

The $plugin_dir gets parsed, while the $path is still contains the different DS, which will make the check $plugins_content_dir_position = strpos( $path, $plugin_dir ); always false, such as C:\sites... vs C:/sites/...

@vodanh1213 vodanh1213 requested a review from borkweb October 21, 2024 12:43
@borkweb borkweb merged commit 2ba83d5 into main Oct 21, 2024
3 checks passed
@borkweb borkweb deleted the fix/windows-path-correctness branch October 21, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants