GC_Filesystem_ftpsockets::__construct()

最后更新于:2021-11-27 19:47:14

GC_Filesystem_ftpsockets::__construct( array$opt=”)

Constructor.

参数

$opt

(array) (Optional)

Default value: ”

源文件

文件: gc-admin/includes/class-gc-filesystem-ftpsockets.php

	public function __construct( $opt = '' ) {
		$this->method = 'ftpsockets';
		$this->errors = new GC_Error();

		// Check if possible to use ftp functions.
		if ( ! include_once ABSPATH . 'gc-admin/includes/class-ftp.php' ) {
			return;
		}

		$this->ftp = new ftp();

		if ( empty( $opt['port'] ) ) {
			$this->options['port'] = 21;
		} else {
			$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'];
		}
	}