WP_Filesystem_SSH2::delete() – Deletes a file or directory.

You appear to be a bot. Output may be restricted

Description

Deletes a file or directory.

Usage

$bool = WP_Filesystem_SSH2::delete( $file, $recursive, $type );

Parameters

$file
( string ) required – Path to the file or directory.
$recursive
( bool ) optional – Optional. If set to true, deletes files and folders recursively. Default false.
$type
( string|false ) optional – Type of resource. 'f' for file, 'd' for directory. Default false.

Returns

bool True on success, false on failure.

Source

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

1 to 19 of 19
  public function delete( $file, $recursive = false, $type = false ) {
    if ( 'f' === $type || $this->WP_Filesystem_SSH2::is_file( $file ) ) {
      return ssh2_sftp_unlink( $this->sftp_link, $file );
    }

    if ( ! $recursive ) {
      return ssh2_sftp_rmdir( $this->sftp_link, $file );
    }

    $filelist = $this->WP_Filesystem_SSH2::dirlist( $file );

    if ( is_array( $filelist ) ) {
      foreach ( $filelist as $filename => $fileinfo ) {
        $this->WP_Filesystem_SSH2::delete( $file . '/' . $filename, $recursive, $fileinfo['type'] );
      }
    }

    return ssh2_sftp_rmdir( $this->sftp_link, $file );
  }
 

 View on GitHub View on Trac