wppaste
WordPress

WP_Filesystem_ftpsockets

Since
2.5.0
Source
wp-admin/includes/class-wp-filesystem-ftpsockets.php:23
WordPress Filesystem Class for implementing FTP Sockets.

Compatibility

WordPress
since 2.5.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 2

$ftpftppublic
$optionsarraypublic

Methods · 27

Source code

class WP_Filesystem_ftpsockets extends WP_Filesystem_Base { 	/**	 * @since 2.5.0	 * @var ftp	 */	public $ftp; 	/**	 * @since 7.1.0	 * @var array	 * @phpstan-var Options	 */	public $options; 	/**	 * Constructor.	 *	 * @since 2.5.0	 *	 * @param array $opt {	 *     Array of connection options.	 *	 *     @type string $hostname Required. FTP server hostname.	 *     @type string $username Required. FTP username.	 *     @type string $password Required. FTP password.	 *     @type int $port Optional. FTP server port. Default 21.	 * }	 * @phpstan-param array{	 *     hostname: non-empty-string,	 *     username: non-empty-string,	 *     password: string,	 *     port?: non-negative-int,	 * }|null $opt	 */	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'];		}	}

Changelog

Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-wp-filesystem-ftpsockets.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.