WP_Filesystem_SSH2::chgrp()publicWP 2.7.0

Changes the file group.

Method of the class: WP_Filesystem_SSH2{}

No Hooks.

Return

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

Usage

$WP_Filesystem_SSH2 = new WP_Filesystem_SSH2();
$WP_Filesystem_SSH2->chgrp( $file, $group, $recursive );
$file(string) (required)
Path to the file.
$group(string|int) (required)
A group name or number.
$recursive(true|false)
If set to true, changes file group recursively.
Default: false

Changelog

Since 2.7.0 Introduced.

WP_Filesystem_SSH2::chgrp() code WP 6.6.2

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

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

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