WP_Filesystem_ftpsockets::__construct
Constructor.
Метод класса: WP_Filesystem_ftpsockets{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$WP_Filesystem_ftpsockets = new WP_Filesystem_ftpsockets(); $WP_Filesystem_ftpsockets->__construct( $opt );
- $opt(массив)
Array of connection options.
По умолчанию:
null-
hostname(строка)
Required. FTP server hostname. -
username(строка)
Required. FTP username. -
password(строка)
Required. FTP password. - port(int)
Optional. FTP server port.
По умолчанию: 21
-
Список изменений
| С версии 2.5.0 | Введена. |
Код WP_Filesystem_ftpsockets::__construct() WP Filesystem ftpsockets:: construct WP 7.1.2
public function __construct( $opt = null ) {
$this->method = 'ftpsockets';
$this->errors = new WP_Error();
$this->options = array(
'port' => 21,
'hostname' => '',
'username' => '',
'password' => '',
);
// Check if possible to use ftp functions.
if ( ! require_once ABSPATH . 'wp-admin/includes/class-ftp.php' ) {
return;
}
$this->ftp = new ftp();
if ( ! is_array( $opt ) ) {
$opt = array();
}
if ( ! empty( $opt['port'] ) ) {
$this->options['port'] = (int) $opt['port'];
}
if ( empty( $opt['hostname'] ) ) {
$this->errors->add( 'empty_hostname', __( 'FTP hostname is required' ) );
} else {
$this->options['hostname'] = $opt['hostname'];
}
// Check if the options provided are OK.
if ( empty( $opt['username'] ) ) {
$this->errors->add( 'empty_username', __( 'FTP username is required' ) );
} else {
$this->options['username'] = $opt['username'];
}
if ( empty( $opt['password'] ) ) {
$this->errors->add( 'empty_password', __( 'FTP password is required' ) );
} else {
$this->options['password'] = $opt['password'];
}
}