diff --git a/wp-admin/includes/class-wp-filesystem-direct.php b/wp-admin/includes/class-wp-filesystem-direct.php
index 27703630c9..e4ec1acea2 100644
--- a/wp-admin/includes/class-wp-filesystem-direct.php
+++ b/wp-admin/includes/class-wp-filesystem-direct.php
@@ -116,9 +116,6 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
* @return bool Returns true on success or false on failure.
*/
function chmod($file, $mode = false, $recursive = false) {
- if ( ! $this->exists($file) )
- return false;
-
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
@@ -128,9 +125,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
return false;
}
- if ( ! $recursive )
- return @chmod($file, $mode);
- if ( ! $this->is_dir($file) )
+ if ( ! $recursive || ! $this->is_dir($file) )
return @chmod($file, $mode);
//Is a directory, and we want recursive
$file = trailingslashit($file);
@@ -298,17 +293,7 @@ class WP_Filesystem_Direct extends WP_Filesystem_Base {
}
function rmdir($path, $recursive = false) {
- //Currently unused and untested, Use delete() instead.
- if ( ! $recursive )
- return @rmdir($path);
- //recursive:
- $filelist = $this->dirlist($path);
- foreach ($filelist as $filename => $det) {
- if ( '/' == substr($filename, -1, 1) )
- $this->rmdir($path . '/' . $filename, $recursive);
- @rmdir($filename);
- }
- return @rmdir($path);
+ return $this->delete($path, $recursive);
}
function dirlist($path, $include_hidden = true, $recursive = false) {
diff --git a/wp-admin/includes/class-wp-filesystem-ftpext.php b/wp-admin/includes/class-wp-filesystem-ftpext.php
index 56cb83cd2d..9f6ca26284 100644
--- a/wp-admin/includes/class-wp-filesystem-ftpext.php
+++ b/wp-admin/includes/class-wp-filesystem-ftpext.php
@@ -142,9 +142,6 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false;
}
function chmod($file, $mode = false, $recursive = false) {
- if ( ! $this->exists($file) && ! $this->is_dir($file) )
- return false;
-
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
@@ -245,11 +242,9 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
return false;
}
function mkdir($path, $chmod = false, $chown = false, $chgrp = false) {
- if ( !ftp_mkdir($this->link, $path) )
+ if ( !ftp_mkdir($this->link, $path) )
return false;
- if ( ! $chmod )
- $chmod = FS_CHMOD_DIR;
- $this->chmod($path, $chmod);
+ $this->chmod($path);
if ( $chown )
$this->chown($path, $chown);
if ( $chgrp )
@@ -263,12 +258,15 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
function parselisting($line) {
static $is_windows;
if ( is_null($is_windows) )
- $is_windows = strpos( strtolower(ftp_systype($this->link)), 'win') !== false;
+ $is_windows = strpos( strtolower( ftp_systype($this->link) ), 'win') !== false;
- if ( $is_windows && preg_match("/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|
) +(.+)/", $line, $lucifer) ) {
+ if ( $is_windows && preg_match('/([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|) +(.+)/', $line, $lucifer) ) {
$b = array();
- if ( $lucifer[3] < 70 ) { $lucifer[3] +=2000; } else { $lucifer[3] += 1900; } // 4digit year fix
- $b['isdir'] = ($lucifer[7]=="");
+ if ( $lucifer[3] < 70 )
+ $lucifer[3] +=2000;
+ else
+ $lucifer[3] += 1900; // 4digit year fix
+ $b['isdir'] = ( $lucifer[7] == '');
if ( $b['isdir'] )
$b['type'] = 'd';
else
@@ -279,13 +277,14 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['year'] = $lucifer[3];
$b['hour'] = $lucifer[4];
$b['minute'] = $lucifer[5];
- $b['time'] = @mktime($lucifer[4]+(strcasecmp($lucifer[6],"PM")==0?12:0),$lucifer[5],0,$lucifer[1],$lucifer[2],$lucifer[3]);
+ $b['time'] = @mktime($lucifer[4] + (strcasecmp($lucifer[6], "PM") == 0 ? 12 : 0), $lucifer[5], 0, $lucifer[1], $lucifer[2], $lucifer[3]);
$b['am/pm'] = $lucifer[6];
$b['name'] = $lucifer[8];
- } else if (!$is_windows && $lucifer=preg_split("/[ ]/",$line,9,PREG_SPLIT_NO_EMPTY)) {
+ } elseif ( !$is_windows && $lucifer = preg_split('/[ ]/', $line, 9, PREG_SPLIT_NO_EMPTY)) {
//echo $line."\n";
- $lcount=count($lucifer);
- if ($lcount<8) return '';
+ $lcount = count($lucifer);
+ if ( $lcount < 8 )
+ return '';
$b = array();
$b['isdir'] = $lucifer[0]{0} === "d";
$b['islink'] = $lucifer[0]{0} === "l";
@@ -300,15 +299,15 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['owner'] = $lucifer[2];
$b['group'] = $lucifer[3];
$b['size'] = $lucifer[4];
- if ($lcount==8) {
- sscanf($lucifer[5],"%d-%d-%d",$b['year'],$b['month'],$b['day']);
- sscanf($lucifer[6],"%d:%d",$b['hour'],$b['minute']);
- $b['time'] = @mktime($b['hour'],$b['minute'],0,$b['month'],$b['day'],$b['year']);
+ if ( $lcount == 8 ) {
+ sscanf($lucifer[5], '%d-%d-%d', $b['year'], $b['month'], $b['day']);
+ sscanf($lucifer[6], '%d:%d', $b['hour'], $b['minute']);
+ $b['time'] = @mktime($b['hour'], $b['minute'], 0, $b['month'], $b['day'], $b['year']);
$b['name'] = $lucifer[7];
} else {
$b['month'] = $lucifer[5];
$b['day'] = $lucifer[6];
- if (preg_match("/([0-9]{2}):([0-9]{2})/",$lucifer[7],$l2)) {
+ if ( preg_match('/([0-9]{2}):([0-9]{2})/', $lucifer[7], $l2) ) {
$b['year'] = date("Y");
$b['hour'] = $l2[1];
$b['minute'] = $l2[2];
@@ -317,7 +316,7 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base {
$b['hour'] = 0;
$b['minute'] = 0;
}
- $b['time'] = strtotime(sprintf("%d %s %d %02d:%02d",$b['day'],$b['month'],$b['year'],$b['hour'],$b['minute']));
+ $b['time'] = strtotime( sprintf('%d %s %d %02d:%02d', $b['day'], $b['month'], $b['year'], $b['hour'], $b['minute']) );
$b['name'] = $lucifer[8];
}
}
diff --git a/wp-admin/includes/class-wp-filesystem-ftpsockets.php b/wp-admin/includes/class-wp-filesystem-ftpsockets.php
index a94ac71513..a945d20d0a 100644
--- a/wp-admin/includes/class-wp-filesystem-ftpsockets.php
+++ b/wp-admin/includes/class-wp-filesystem-ftpsockets.php
@@ -154,7 +154,6 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
function chmod($file, $mode = false, $recursive = false ) {
-
if ( ! $mode ) {
if ( $this->is_file($file) )
$mode = FS_CHMOD_FILE;
@@ -277,10 +276,7 @@ class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
}
function rmdir($path, $recursive = false ) {
- if ( ! $recursive )
- return $this->ftp->rmdir($path);
-
- return $this->ftp->mdel($path);
+ $this->delete($path, $recursive);
}
function dirlist($path = '.', $include_hidden = true, $recursive = false ) {