Skip to content

Commit

Permalink
Add more cases for realpath usage
Browse files Browse the repository at this point in the history
  • Loading branch information
jorostoyanov committed May 5, 2022
1 parent 4814752 commit 61ceeee
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/Carbon_Fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,16 @@ public static function directory_to_url( $directory ) {
WP_PLUGIN_DIR => \plugins_url(), # If installed as a plugin
WP_CONTENT_DIR => \content_url(), # If anywhere in wp-content
ABSPATH => \site_url( '/' ), # If anywhere else within the WordPress installation

// Add plugins, content, and root paths with resolved symlinks,
// see https://github.com/htmlburger/carbon-fields/issues/1096
realpath( WP_PLUGIN_DIR ) => \plugins_url(),
realpath( WP_CONTENT_DIR ) => \content_url(),
realpath( ABSPATH ) => \site_url( '/' ),
);

foreach ( $possible_locations as $test_dir => $test_url ) {
$test_dir_normalized = realpath( str_replace( '\\' ,'/', $test_dir ) );
$test_dir_normalized = str_replace( '\\' ,'/', $test_dir );
$url = str_replace( $test_dir_normalized, $test_url, $url, $count );

if ( $count > 0 ) {
Expand Down

0 comments on commit 61ceeee

Please sign in to comment.