WP_Filesystem_Direct::mkdir
Creates a directory.
Method of the class: WP_Filesystem_Direct{}
No Hooks.
Returns
true|false. True on success, false on failure.
Usage
$WP_Filesystem_Direct = new WP_Filesystem_Direct(); $WP_Filesystem_Direct->mkdir( $path, $chmod, $chown, $chgrp );
- $path(string) (required)
- Path for new directory.
- $chmod(int|false)
- The permissions as octal number (or false to skip chmod).
Default:false - $chown(string|int|false)
- A user name or number (or false to skip chown).
Default:false - $chgrp(string|int|false)
- A group name or number (or false to skip chgrp).
Default:false
Changelog
| Since 2.5.0 | Introduced. |
WP_Filesystem_Direct::mkdir() WP Filesystem Direct::mkdir code WP 7.0
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
// Safe mode fails with a trailing slash under certain PHP versions.
$path = untrailingslashit( $path );
if ( empty( $path ) ) {
return false;
}
if ( ! $chmod ) {
$chmod = FS_CHMOD_DIR;
}
if ( ! @mkdir( $path ) ) {
return false;
}
$this->chmod( $path, $chmod );
if ( $chown ) {
$this->chown( $path, $chown );
}
if ( $chgrp ) {
$this->chgrp( $path, $chgrp );
}
return true;
}