WP_Filesystem_Direct::chown( string $file, mixed $owner, bool $recursive = false )
Changes file owner
Parameters
- $file
-
(Required) Path to the file.
- $owner
-
(Required) A user name or number.
- $recursive
-
(Optional) If set True changes file owner recursively.
Default value: false
Return
(bool) Returns true on success or false on failure.
Source
File: wp-admin/includes/class-wp-filesystem-direct.php
public function chown($file, $owner, $recursive = false) {
if ( ! $this->exists($file) )
return false;
if ( ! $recursive )
return @chown($file, $owner);
if ( ! $this->is_dir($file) )
return @chown($file, $owner);
// Is a directory, and we want recursive
$filelist = $this->dirlist($file);
foreach ($filelist as $filename) {
$this->chown($file . '/' . $filename, $owner, $recursive);
}
return true;
}