WordPress at Your Fingertips
function is not described

WP_Filesystem_ftpsockets::connect() public WP 2.5.0

Connects filesystem.

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

No Hooks.

Return

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

Usage

$WP_Filesystem_ftpsockets = new WP_Filesystem_ftpsockets();
$WP_Filesystem_ftpsockets->connect();

Changelog

Since 2.5.0 Introduced.

Code of WP_Filesystem_ftpsockets::connect() WP 5.8.2

public function connect() {
	if ( ! $this->ftp ) {
		return false;
	}

	$this->ftp->setTimeout( FS_CONNECT_TIMEOUT );

	if ( ! $this->ftp->SetServer( $this->options['hostname'], $this->options['port'] ) ) {
		$this->errors->add(
			'connect',
			sprintf(
				/* translators: %s: hostname:port */
				__( 'Failed to connect to FTP Server %s' ),
				$this->options['hostname'] . ':' . $this->options['port']
			)
		);

		return false;
	}

	if ( ! $this->ftp->connect() ) {
		$this->errors->add(
			'connect',
			sprintf(
				/* translators: %s: hostname:port */
				__( 'Failed to connect to FTP Server %s' ),
				$this->options['hostname'] . ':' . $this->options['port']
			)
		);

		return false;
	}

	if ( ! $this->ftp->login( $this->options['username'], $this->options['password'] ) ) {
		$this->errors->add(
			'auth',
			sprintf(
				/* translators: %s: Username. */
				__( 'Username/Password incorrect for %s' ),
				$this->options['username']
			)
		);

		return false;
	}

	$this->ftp->SetType( FTP_BINARY );
	$this->ftp->Passive( true );
	$this->ftp->setTimeout( FS_TIMEOUT );

	return true;
}