Created
November 15, 2013 08:49
-
-
Save tott/7481196 to your computer and use it in GitHub Desktop.
validate if a path is a subfolder of WP_CONTENT_DIR
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Validate that a given path is a child of the WP_CONTENT_DIR | |
* @param string $path path to check | |
* @return boolean true/false | |
*/ | |
function sav_path_is_valid( $path ) { | |
if ( !defined( WP_CONTENT_DIR ) ) | |
return false; | |
$start = 0; | |
$end = strlen( WP_CONTENT_DIR ); | |
if ( substr( realpath( $path ), $start, $end ) != WP_CONTENT_DIR ) | |
return false; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment