Skip to content

Instantly share code, notes, and snippets.

@tott
Created November 15, 2013 08:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tott/7481196 to your computer and use it in GitHub Desktop.
Save tott/7481196 to your computer and use it in GitHub Desktop.
validate if a path is a subfolder of WP_CONTENT_DIR
/**
* 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