WP_Filesystem_SSH2::chown()publicWP 2.7.0

Changes the owner of a file or directory.

Метод класса: WP_Filesystem_SSH2{}

Хуков нет.

Возвращает

true|false. True on success, false on failure.

Использование

$WP_Filesystem_SSH2 = new WP_Filesystem_SSH2();
$WP_Filesystem_SSH2->chown( $file, $owner, $recursive );
$file(строка) (обязательный)
Path to the file or directory.
$owner(строка|int) (обязательный)
A user name or number.
$recursive(true|false)
If set to true, changes file owner recursively.
По умолчанию: false

Список изменений

С версии 2.7.0 Введена.

Код WP_Filesystem_SSH2::chown() WP 6.5.2

public function chown( $file, $owner, $recursive = false ) {
	if ( ! $this->exists( $file ) ) {
		return false;
	}

	if ( ! $recursive || ! $this->is_dir( $file ) ) {
		return $this->run_command( sprintf( 'chown %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
	}

	return $this->run_command( sprintf( 'chown -R %s %s', escapeshellarg( $owner ), escapeshellarg( $file ) ), true );
}