Definition:
function wp_mkdir_p( $target ) {}
Recursive directory creation based on full path.
Will attempt to set permissions on folders.
Parameters
- string $target: Full path to attempt to create.
Return values
returns:Whether the path was created. True if path already exists.
Source code
function wp_mkdir_p( $target ) { // from php.net/mkdir user contributed notes $target = str_replace( '//', '/', $target ); // safe mode fails with a trailing slash under certain PHP versions. $target = rtrim($target, '/'); // Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. if ( empty($target) ) $target = '/'; if ( file_exists( $target ) ) return @is_dir( $target ); // Attempting to create the directory may clutter up our display. if ( @mkdir( $target ) ) { $stat = @stat( dirname( $target ) ); $dir_perms = $stat['mode'] & 0007777; // Get the permission bits. @chmod( $target, $dir_perms ); return true; } elseif ( is_dir( dirname( $target ) ) ) { return false; } // If the above failed, attempt to create the parent node, then try again. if ( ( $target != '/' ) && ( wp_mkdir_p( dirname( $target ) ) ) ) return wp_mkdir_p( $target ); return false; }
3917
No comments yet... Be the first to leave a reply!