WordPress at Your Fingertips
function is not described

WP_Filesystem_ftpsockets::__construct() public WP 2.5.0

Constructor.

{} It's a method of the class: WP_Filesystem_ftpsockets{}

No Hooks.

Return

null. Nothing.

Usage

$WP_Filesystem_ftpsockets = new WP_Filesystem_ftpsockets();
$WP_Filesystem_ftpsockets->__construct( $opt );
$opt(array)
-
Default: ''

Changelog

Since 2.5.0 Introduced.

Code of WP_Filesystem_ftpsockets::__construct() WP 5.8.2

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

	// Check if possible to use ftp functions.
	if ( ! include_once ABSPATH . 'wp-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'];
	}
}