WP_Filesystem_SSH2::run_command
Метод класса: WP_Filesystem_SSH2{}
Хуков нет.
Возвращает
true|false|Строку. True on success, false on failure. String if the command was executed, $returnbool is false (default), and data from the resulting stream was retrieved.
Использование
$WP_Filesystem_SSH2 = new WP_Filesystem_SSH2(); $WP_Filesystem_SSH2->run_command( $command, $returnbool );
- $command(строка) (обязательный)
- .
- $returnbool(true|false)
- .
По умолчанию:false
Список изменений
| С версии 2.7.0 | Введена. |
Код WP_Filesystem_SSH2::run_command() WP Filesystem SSH2::run command WP 6.9.4
public function run_command( $command, $returnbool = false ) {
if ( ! $this->link ) {
return false;
}
$stream = ssh2_exec( $this->link, $command );
if ( ! $stream ) {
$this->errors->add(
'command',
sprintf(
/* translators: %s: Command. */
__( 'Unable to perform command: %s' ),
$command
)
);
} else {
stream_set_blocking( $stream, true );
stream_set_timeout( $stream, FS_TIMEOUT );
$data = stream_get_contents( $stream );
fclose( $stream );
if ( $returnbool ) {
return ( false === $data ) ? false : '' !== trim( $data );
} else {
return $data;
}
}
return false;
}