WP_Filesystem_ftpsockets::connect() – Connects filesystem.

You appear to be a bot. Output may be restricted

Description

Connects filesystem.

Usage

$bool = WP_Filesystem_ftpsockets::connect();

Parameters

Returns

bool True on success, false on failure.

Source

File name: wordpress/wp-admin/includes/class-wp-filesystem-ftpsockets.php
Lines:

1 to 52 of 52
  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->WP_Filesystem_ftpsockets::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;
  }
 

 View on GitHub View on Trac