<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[45226] trunk/src/wp-admin/includes: Docs: Improve documentation for various `WP_Filesystem_Base` methods and extending classes.</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { white-space: pre-line; overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/45226">45226</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/45226","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>SergeyBiryukov</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2019-04-17 04:12:27 +0000 (Wed, 17 Apr 2019)</dd>
</dl>
<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Docs: Improve documentation for various `WP_Filesystem_Base` methods and extending classes.
Props jaydeep-rami, man4toman, SaeedFard, mukesh27, mohadeseghasemi, ebrahimzadeh, juiiee8487, SergeyBiryukov.
Fixes <a href="https://core.trac.wordpress.org/ticket/42227">#42227</a>, <a href="https://core.trac.wordpress.org/ticket/46806">#46806</a>, <a href="https://core.trac.wordpress.org/ticket/46840">#46840</a>. See <a href="https://core.trac.wordpress.org/ticket/46543">#46543</a>.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpadminincludesclasswpfilesystembasephp">trunk/src/wp-admin/includes/class-wp-filesystem-base.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpfilesystemdirectphp">trunk/src/wp-admin/includes/class-wp-filesystem-direct.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpfilesystemftpextphp">trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpfilesystemftpsocketsphp">trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php</a></li>
<li><a href="#trunksrcwpadminincludesclasswpfilesystemssh2php">trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpadminincludesclasswpfilesystembasephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-filesystem-base.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-filesystem-base.php 2019-04-17 02:08:51 UTC (rev 45225)
+++ trunk/src/wp-admin/includes/class-wp-filesystem-base.php 2019-04-17 04:12:27 UTC (rev 45226)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,11 +7,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Base WordPress Filesystem class for which Filesystem implementations extend
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Base WordPress Filesystem class which Filesystem implementations extend.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Filesystem_Base {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px"> * Whether to display debug data for the connection.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,7 +47,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> public $options = array();
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the path on the remote filesystem of ABSPATH.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the path on the remote filesystem of ABSPATH.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -62,7 +63,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the path on the remote filesystem of WP_CONTENT_DIR.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the path on the remote filesystem of WP_CONTENT_DIR.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -73,7 +74,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the path on the remote filesystem of WP_PLUGIN_DIR.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the path on the remote filesystem of WP_PLUGIN_DIR.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -84,11 +85,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the path on the remote filesystem of the Themes Directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the path on the remote filesystem of the Themes Directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $theme The Theme stylesheet or template for the directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string|false $theme Optional. The theme stylesheet or template for the directory.
+ * Default false.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return string The location of the remote path.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function wp_themes_dir( $theme = false ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -103,7 +105,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the path on the remote filesystem of WP_LANG_DIR.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the path on the remote filesystem of WP_LANG_DIR.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 3.2.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -114,7 +116,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Locate a folder on the remote filesystem.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Locates a folder on the remote filesystem.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() instead.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -136,7 +138,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Locate a folder on the remote filesystem.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Locates a folder on the remote filesystem.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @deprecated 2.7.0 use WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir() methods instead.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,10 +159,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Locate a folder on the remote filesystem.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Locates a folder on the remote filesystem.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Assumes that on Windows systems, Stripping off the Drive
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * letter is OK Sanitizes \\ to / in windows filepaths.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * letter is OK Sanitizes \\ to / in Windows filepaths.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -229,7 +231,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Locate a folder on the remote filesystem.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Locates a folder on the remote filesystem.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Expects Windows sanitized path.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -267,9 +269,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /*
</span><span class="cx" style="display: block; padding: 0 10px"> * Working from /home/ to /user/ to /wordpress/ see if that file exists within
</span><span class="cx" style="display: block; padding: 0 10px"> * the current folder, If it's found, change into it and follow through looking
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * for it. If it cant find WordPress down that route, it'll continue onto the next
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * for it. If it can't find WordPress down that route, it'll continue onto the next
</ins><span class="cx" style="display: block; padding: 0 10px"> * folder level, and see if that matches, and so on. If it reaches the end, and still
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * cant find it, it'll return false for the entire function.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * can't find it, it'll return false for the entire function.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $files[ $key ] ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -311,7 +313,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Return the *nix-style file permissions for a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Returns the *nix-style file permissions for a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * From the PHP documentation page for fileperms().
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -366,11 +368,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets the permissions of the specified file or filepath in their octal format
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the permissions of the specified file or filepath in their octal format.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string the last 3 characters of the octal number
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ *
+ * @param string $file Path to the file.
+ * @return string Mode of the file (the last 3 digits).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getchmod( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return '777';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -377,7 +380,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Convert *nix-style file permissions to a octal number.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Converts *nix-style file permissions to a octal number.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Converts '-rw-r--r--' to 0644
</span><span class="cx" style="display: block; padding: 0 10px"> * From "info at rvgate dot nl"'s comment on the PHP documentation for chmod()
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -417,12 +420,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Determine if the string provided contains binary characters.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Determines if the string provided contains binary characters.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.7.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $text String to test against.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool true if string is binary, false otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True if string is binary, false otherwise.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_binary( $text ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -429,16 +432,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change the ownership of a file / folder.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the owner of a file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Default behavior is to do nothing, override this in your subclass, if desired.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param mixed $owner A user name or number.
- * @param bool $recursive Optional. If set True changes file owner recursivly. Defaults to False.
- * @return bool Returns true on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to the file or directory.
+ * @param string|int $owner A user name or number.
+ * @param bool $recursive Optional. If set to true, changes file owner recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chown( $file, $owner, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,12 +449,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Connect filesystem.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Connects filesystem.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure (always true for WP_Filesystem_Direct).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connect() {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -457,13 +461,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Read entire file into a string.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into a string.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Name of the file to read.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return mixed|bool Returns the read data or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false Read data on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -470,13 +474,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Read entire file into an array.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into an array.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array|bool the file contents in an array or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false File contents in an array on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents_array( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -483,15 +487,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Write a string to a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Writes a string to a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Remote path to the file where to write the data.
- * @param string $contents The data to write.
- * @param int $mode Optional. The file permissions as octal number, usually 0644.
- * @return bool False on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Remote path to the file where to write the data.
+ * @param string $contents The data to write.
+ * @param int|false $mode Optional. The file permissions as octal number, usually 0644.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function put_contents( $file, $contents, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -498,12 +503,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the current working directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the current working directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool The current working directory on success, or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false The current working directory on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function cwd() {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -510,13 +515,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change current directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes current directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $dir The new current directory.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool|string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chdir( $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -523,15 +528,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change the file group.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the file group.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param mixed $group A group name or number.
- * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
- * @return bool|string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to the file.
+ * @param string|int $group A group name or number.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chgrp( $file, $group, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -538,15 +544,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change filesystem permissions.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes filesystem permissions.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
- * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
- * @return bool|string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to the file.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for directories. Default false.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chmod( $file, $mode = false, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -553,13 +561,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the file owner.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file owner.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool Username of the user or false on error.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false Username of the owner on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function owner( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -566,13 +574,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get the file's group.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's group.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool The group or false on error.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false The group on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function group( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -579,18 +587,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Copy a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copies a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source Path to the source file.
- * @param string $destination Path to the destination file.
- * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
- * Default false.
- * @param int $mode Optional. The permissions as octal number, usually 0644 for files, 0755 for dirs.
- * Default false.
- * @return bool True if file copied successfully, False otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for dirs. Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function copy( $source, $destination, $overwrite = false, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -597,7 +605,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Move a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Moves a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -606,7 +614,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $destination Path to the destination file.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
</span><span class="cx" style="display: block; padding: 0 10px"> * Default false.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool True if file copied successfully, False otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function move( $source, $destination, $overwrite = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -613,17 +621,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Delete a file or directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
- * Default false.
- * @param bool $type Type of resource. 'f' for file, 'd' for directory.
- * Default false.
- * @return bool True if the file or directory was deleted, false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to the file or directory.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $file, $recursive = false, $type = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -630,12 +638,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if a file or directory exists.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory exists.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to file/directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool Whether $file exists or not.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function exists( $file ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -643,7 +651,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if resource is a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -656,7 +664,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if resource is a directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -669,7 +677,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if a file is readable.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file is readable.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -682,12 +690,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Check if a file or directory is writable.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory is writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Path to file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @return bool Whether $file is writable.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_writable( $file ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -701,7 +709,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|bool Unix timestamp representing last access time.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return int|false Unix timestamp representing last access time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function atime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -714,7 +722,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|bool Unix timestamp representing modification time.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return int|false Unix timestamp representing modification time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mtime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -727,7 +735,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return int|bool Size of the file in bytes.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return int|false Size of the file in bytes on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function size( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -734,7 +742,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Set the access and modification times of a file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the access and modification times of a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * Note: If $file doesn't exist, it will be created.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -746,7 +754,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Default 0.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param int $atime Optional. Access time to set for file.
</span><span class="cx" style="display: block; padding: 0 10px"> * Default 0.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool Whether operation was successful or not.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function touch( $file, $time = 0, $atime = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -753,19 +761,19 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Create a directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Creates a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path Path for new directory.
- * @param mixed $chmod Optional. The permissions as octal number, (or False to skip chmod)
- * Default false.
- * @param mixed $chown Optional. A user name or number (or False to skip chown)
- * Default false.
- * @param mixed $chgrp Optional. A group name or number (or False to skip chgrp).
- * Default false.
- * @return bool False if directory cannot be created, true otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $path Path for new directory.
+ * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
+ * Default false.
+ * @param string|int $chown Optional. A user name or number (or false to skip chown).
+ * Default false.
+ * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -772,7 +780,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Delete a directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -780,7 +788,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @param string $path Path to directory.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $recursive Optional. Whether to recursively remove files/directories.
</span><span class="cx" style="display: block; padding: 0 10px"> * Default false.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool Whether directory is deleted successfully or not.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function rmdir( $path, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -787,7 +795,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Get details for files in a directory or a specific file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets details for files in a directory or a specific file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> * @abstract
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -797,10 +805,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * Default true.
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $recursive Optional. Whether to recursively include file details in nested directories.
</span><span class="cx" style="display: block; padding: 0 10px"> * Default false.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array|bool {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false {
</ins><span class="cx" style="display: block; padding: 0 10px"> * Array of files. False if unable to list directory contents.
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @type string $name Name of the file/directory.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @type string $name Name of the file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @type string $perms *nix representation of permissions.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type int $permsn Octal representation of permissions.
</span><span class="cx" style="display: block; padding: 0 10px"> * @type string $owner Owner name or ID.
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpfilesystemdirectphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-filesystem-direct.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-filesystem-direct.php 2019-04-17 02:08:51 UTC (rev 45225)
+++ trunk/src/wp-admin/includes/class-wp-filesystem-direct.php 2019-04-17 04:12:27 UTC (rev 45226)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -16,9 +16,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Filesystem_Direct extends WP_Filesystem_Base {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * constructor
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param mixed $arg ignored argument
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @param mixed $arg Not used.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $arg ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->method = 'direct';
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -26,10 +28,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Reads entire file into a string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into a string.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Name of the file to read.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool The function returns the read data or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false Read data on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @file_get_contents( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,10 +40,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Reads entire file into an array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into an array.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return array|bool the file contents in an array or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return array|false File contents in an array on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents_array( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @file( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -46,13 +52,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Write a string to a file
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Writes a string to a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Remote path to the file where to write the data.
- * @param string $contents The data to write.
- * @param int $mode Optional. The file permissions as octal number, usually 0644.
- * Default false.
- * @return bool False upon failure, true otherwise.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @param string $file Remote path to the file where to write the data.
+ * @param string $contents The data to write.
+ * @param int|false $mode Optional. The file permissions as octal number, usually 0644.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function put_contents( $file, $contents, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $fp = @fopen( $file, 'wb' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -80,9 +88,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets the current working directory
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the current working directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool the current working directory on success, or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @return string|false The current working directory on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function cwd() {
</span><span class="cx" style="display: block; padding: 0 10px"> return @getcwd();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -89,10 +99,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change directory
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes current directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $dir The new current directory.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool Returns true on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chdir( $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @chdir( $dir );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -99,12 +111,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Changes file group
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the file group.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param mixed $group A group name or number.
- * @param bool $recursive Optional. If set True changes file group recursively. Default false.
- * @return bool Returns true on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @param string|int $group A group name or number.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chgrp( $file, $group, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -127,13 +142,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Changes filesystem permissions
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes filesystem permissions.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param int $mode Optional. The permissions as octal number, usually 0644 for files,
- * 0755 for dirs. Default false.
- * @param bool $recursive Optional. If set True changes file group recursively. Default false.
- * @return bool Returns true on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for directories. Default false.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chmod( $file, $mode = false, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $mode ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -160,13 +178,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Changes file owner
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the owner of a file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
- * @param mixed $owner A user name or number.
- * @param bool $recursive Optional. If set True changes file owner recursively.
- * Default false.
- * @return bool Returns true on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
+ * @param string $file Path to the file or directory.
+ * @param string|int $owner A user name or number.
+ * @param bool $recursive Optional. If set to true, changes file owner recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chown( $file, $owner, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -187,10 +207,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets file owner
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file owner.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string|bool Username of the user or false on error.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string|false Username of the owner on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function owner( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $owneruid = @fileowner( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -205,12 +227,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Gets file permissions
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the permissions of the specified file or filepath in their octal format.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * FIXME does not handle errors in fileperms()
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $file Path to the file.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string Mode of the file (last 3 digits).
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @return string Mode of the file (the last 3 digits).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getchmod( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return substr( decoct( @fileperms( $file ) ), -3 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -217,8 +241,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string|false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's group.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false The group on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function group( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $gid = @filegroup( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -233,11 +261,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @param int $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copies a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for dirs. Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function copy( $source, $destination, $overwrite = false, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $overwrite && $this->exists( $destination ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -252,10 +286,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Moves a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function move( $source, $destination, $overwrite = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $overwrite && $this->exists( $destination ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -276,10 +315,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param bool $recursive
- * @param string $type
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a file or directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file or directory.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $file, $recursive = false, $type = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $file ) ) { // Some filesystems report this as /, which can cause non-expected recursive deletion of all files in the filesystem.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -313,23 +358,38 @@
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> return $retval;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory exists.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file exists or not.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function exists( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @file_exists( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file File path.
+ * @return bool Whether $file is a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_file( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @is_file( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Directory path.
+ * @return bool Whether $path is a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_dir( $path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @is_dir( $path );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -336,8 +396,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file is readable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return bool Whether $file is readable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_readable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @is_readable( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -344,8 +408,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory is writable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file is writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_writable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @is_writable( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -352,8 +420,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's last access time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing last access time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function atime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @fileatime( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -360,8 +432,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file modification time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing modification time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mtime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @filemtime( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -368,8 +444,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file size (in bytes).
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Size of the file in bytes on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function size( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @filesize( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -376,10 +456,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int $time
- * @param int $atime
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the access and modification times of a file.
+ *
+ * Note: If $file doesn't exist, it will be created.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @param int $time Optional. Modified time to set for file.
+ * Default 0.
+ * @param int $atime Optional. Access time to set for file.
+ * Default 0.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function touch( $file, $time = 0, $atime = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $time == 0 ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -392,11 +480,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param mixed $chmod
- * @param mixed $chown
- * @param mixed $chgrp
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Creates a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path for new directory.
+ * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
+ * Default false.
+ * @param string|int $chown Optional. A user name or number (or false to skip chown).
+ * Default false.
+ * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // Safe mode fails with a trailing slash under certain PHP versions.
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -423,9 +518,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory.
+ * @param bool $recursive Optional. Whether to recursively remove files/directories.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function rmdir( $path, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->delete( $path, $recursive );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -432,10 +532,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $include_hidden
- * @param bool $recursive
- * @return bool|array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets details for files in a directory or a specific file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory or file.
+ * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
+ * Default true.
+ * @param bool $recursive Optional. Whether to recursively include file details in nested directories.
+ * Default false.
+ * @return array|false {
+ * Array of files. False if unable to list directory contents.
+ *
+ * @type string $name Name of the file or directory.
+ * @type string $perms *nix representation of permissions.
+ * @type int $permsn Octal representation of permissions.
+ * @type string $owner Owner name or ID.
+ * @type int $size Size of file in bytes.
+ * @type int $lastmodunix Last modified unix timestamp.
+ * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
+ * @type int $time Last modified time.
+ * @type string $type Type of resource. 'f' for file, 'd' for directory.
+ * @type mixed $files If a directory and $recursive is true, contains another array of files.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function dirlist( $path, $include_hidden = true, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_file( $path ) ) {
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpfilesystemftpextphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php 2019-04-17 02:08:51 UTC (rev 45225)
+++ trunk/src/wp-admin/includes/class-wp-filesystem-ftpext.php 2019-04-17 04:12:27 UTC (rev 45226)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,9 +14,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see WP_Filesystem_Base
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Filesystem_FTPext extends WP_Filesystem_Base {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @since 2.5.0
+ * @var resource
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $link;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
+ *
+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $opt
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $opt = '' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -67,7 +76,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Connects filesystem.
+ *
+ * @since 2.5.0
+ *
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connect() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( isset( $this->options['ssl'] ) && $this->options['ssl'] && function_exists( 'ftp_ssl_connect' ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -110,12 +123,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves the file contents.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into a string.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Filename.
- * @return string|false File contents on success, false if no temp file could be opened,
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Name of the file to read.
+ * @return string|false Read data on success, false if no temporary file could be opened,
</ins><span class="cx" style="display: block; padding: 0 10px"> * or if the file couldn't be retrieved.
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents( $file ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -137,7 +150,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> while ( ! feof( $temp ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $contents .= fread( $temp, 8192 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $contents .= fread( $temp, 8 * KB_IN_BYTES );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> fclose( $temp );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -146,8 +159,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into an array.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return array|false File contents in an array on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents_array( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return explode( "\n", $this->get_contents( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -154,10 +171,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param string $contents
- * @param bool|int $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Writes a string to a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Remote path to the file where to write the data.
+ * @param string $contents The data to write.
+ * @param int|false $mode Optional. The file permissions as octal number, usually 0644.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function put_contents( $file, $contents, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $tempfile = wp_tempnam( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -194,7 +216,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the current working directory.
+ *
+ * @since 2.5.0
+ *
+ * @return string|false The current working directory on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function cwd() {
</span><span class="cx" style="display: block; padding: 0 10px"> $cwd = @ftp_pwd( $this->link );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -205,8 +231,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $dir
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes current directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $dir The new current directory.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chdir( $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @ftp_chdir( $this->link, $dir );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -213,10 +243,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int $mode
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes filesystem permissions.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for directories. Default false.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chmod( $file, $mode = false, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $mode ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -245,16 +281,25 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file owner.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false Username of the owner on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function owner( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="cx" style="display: block; padding: 0 10px"> return $dir[ $file ]['owner'];
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the permissions of the specified file or filepath in their octal format.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string Mode of the file (the last 3 digits).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getchmod( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,8 +307,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's group.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false The group on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function group( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,11 +320,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @param string|bool $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copies a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for dirs. Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function copy( $source, $destination, $overwrite = false, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $overwrite && $this->exists( $destination ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -289,10 +344,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Moves a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function move( $source, $destination, $overwrite = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return ftp_rename( $this->link, $source, $destination );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -299,10 +359,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param bool $recursive
- * @param string $type
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a file or directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file or directory.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $file, $recursive = false, $type = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,8 +391,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory exists.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file exists or not.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function exists( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $list = @ftp_nlist( $this->link, $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -339,8 +409,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file File path.
+ * @return bool Whether $file is a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_file( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->exists( $file ) && ! $this->is_dir( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -347,8 +421,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Directory path.
+ * @return bool Whether $path is a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_dir( $path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $cwd = $this->cwd();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -361,8 +439,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file is readable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return bool Whether $file is readable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_readable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -369,8 +451,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory is writable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file is writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_writable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -377,8 +463,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's last access time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing last access time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function atime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -385,8 +475,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file modification time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing modification time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mtime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return ftp_mdtm( $this->link, $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -393,8 +487,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file size (in bytes).
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Size of the file in bytes on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function size( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return ftp_size( $this->link, $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,8 +499,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the access and modification times of a file.
+ *
+ * Note: If $file doesn't exist, it will be created.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @param int $time Optional. Modified time to set for file.
+ * Default 0.
+ * @param int $atime Optional. Access time to set for file.
+ * Default 0.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function touch( $file, $time = 0, $atime = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -409,11 +517,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param mixed $chmod
- * @param mixed $chown
- * @param mixed $chgrp
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Creates a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path for new directory.
+ * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
+ * Default false.
+ * @param string|int $chown Optional. A user name or number (or false to skip chown).
+ * Default false.
+ * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $path = untrailingslashit( $path );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -429,9 +544,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory.
+ * @param bool $recursive Optional. Whether to recursively remove files/directories.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function rmdir( $path, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->delete( $path, $recursive );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -523,10 +643,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $include_hidden
- * @param bool $recursive
- * @return bool|array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets details for files in a directory or a specific file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory or file.
+ * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
+ * Default true.
+ * @param bool $recursive Optional. Whether to recursively include file details in nested directories.
+ * Default false.
+ * @return array|false {
+ * Array of files. False if unable to list directory contents.
+ *
+ * @type string $name Name of the file or directory.
+ * @type string $perms *nix representation of permissions.
+ * @type int $permsn Octal representation of permissions.
+ * @type string $owner Owner name or ID.
+ * @type int $size Size of file in bytes.
+ * @type int $lastmodunix Last modified unix timestamp.
+ * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
+ * @type int $time Last modified time.
+ * @type string $type Type of resource. 'f' for file, 'd' for directory.
+ * @type mixed $files If a directory and $recursive is true, contains another array of files.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_file( $path ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -537,13 +676,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> $pwd = @ftp_pwd( $this->link );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( ! @ftp_chdir( $this->link, $path ) ) { // Cant change to folder = folder doesn't exist
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( ! @ftp_chdir( $this->link, $path ) ) { // Can't change to folder = folder doesn't exist.
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> $list = @ftp_rawlist( $this->link, '-a', false );
</span><span class="cx" style="display: block; padding: 0 10px"> @ftp_chdir( $this->link, $pwd );
</span><span class="cx" style="display: block; padding: 0 10px">
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least)
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ if ( empty( $list ) ) { // Empty array = non-existent folder (real folder will show . at least).
</ins><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -585,6 +724,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Destructor.
+ *
+ * @since 2.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __destruct() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->link ) {
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpfilesystemftpsocketsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php 2019-04-17 02:08:51 UTC (rev 45225)
+++ trunk/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php 2019-04-17 04:12:27 UTC (rev 45226)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -14,12 +14,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> * @see WP_Filesystem_Base
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Filesystem_ftpsockets extends WP_Filesystem_Base {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
</ins><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var ftp
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $ftp;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
+ *
+ * @since 2.5.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $opt
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $opt = '' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,7 +65,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Connects filesystem.
+ *
+ * @since 2.5.0
+ *
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connect() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->ftp ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -111,13 +121,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Retrieves the file contents.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into a string.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><span class="cx" style="display: block; padding: 0 10px"> * @since 2.5.0
</span><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Filename.
- * @return string|false File contents on success, false if no temp file could be opened,
- * or if the file doesn't exist.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param string $file Name of the file to read.
+ * @return string|false Read data on success, false if no temporary file could be opened,
+ * or if the file couldn't be retrieved.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -148,7 +158,7 @@
</span><span class="cx" style="display: block; padding: 0 10px"> $contents = '';
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> while ( ! feof( $temphandle ) ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- $contents .= fread( $temphandle, 8192 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $contents .= fread( $temphandle, 8 * KB_IN_BYTES );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> fclose( $temphandle );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -157,8 +167,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into an array.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return array|false File contents in an array on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents_array( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return explode( "\n", $this->get_contents( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -165,10 +179,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param string $contents
- * @param int|bool $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Writes a string to a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Remote path to the file where to write the data.
+ * @param string $contents The data to write.
+ * @param int|false $mode Optional. The file permissions as octal number, usually 0644.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function put_contents( $file, $contents, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $temp = wp_tempnam( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -205,7 +224,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the current working directory.
+ *
+ * @since 2.5.0
+ *
+ * @return string|false The current working directory on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function cwd() {
</span><span class="cx" style="display: block; padding: 0 10px"> $cwd = $this->ftp->pwd();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -216,18 +239,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes current directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $dir The new current directory.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- public function chdir( $file ) {
- return $this->ftp->chdir( $file );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function chdir( $dir ) {
+ return $this->ftp->chdir( $dir );
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int|bool $mode
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes filesystem permissions.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for directories. Default false.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chmod( $file, $mode = false, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $mode ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -253,8 +286,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file owner.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false Username of the owner on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function owner( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,8 +299,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the permissions of the specified file or filepath in their octal format.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string Mode of the file (the last 3 digits).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getchmod( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -271,8 +312,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's group.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false The group on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function group( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $dir = $this->dirlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -280,11 +325,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @param int|bool $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copies a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for dirs. Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function copy( $source, $destination, $overwrite = false, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $overwrite && $this->exists( $destination ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -300,10 +351,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Moves a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function move( $source, $destination, $overwrite = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->ftp->rename( $source, $destination );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -310,10 +366,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param bool $recursive
- * @param string $type
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a file or directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to the file or directory.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $file, $recursive = false, $type = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( empty( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -330,8 +392,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory exists.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file exists or not.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function exists( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $list = $this->ftp->nlist( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -345,8 +411,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file File path.
+ * @return bool Whether $file is a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_file( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_dir( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -359,8 +429,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Directory path.
+ * @return bool Whether $path is a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_dir( $path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $cwd = $this->cwd();
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -372,8 +446,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file is readable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return bool Whether $file is readable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_readable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -380,8 +458,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory is writable.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file is writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_writable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return true;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -388,8 +470,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's last access time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing last access time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function atime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -396,8 +482,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file modification time.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing modification time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mtime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->ftp->mdtm( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -404,8 +494,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file size (in bytes).
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Size of the file in bytes on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function size( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->ftp->filesize( $file );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -412,10 +506,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int $time
- * @param int $atime
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the access and modification times of a file.
+ *
+ * Note: If $file doesn't exist, it will be created.
+ *
+ * @since 2.5.0
+ *
+ * @param string $file Path to file.
+ * @param int $time Optional. Modified time to set for file.
+ * Default 0.
+ * @param int $atime Optional. Access time to set for file.
+ * Default 0.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function touch( $file, $time = 0, $atime = 0 ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -422,11 +524,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param mixed $chmod
- * @param mixed $chown
- * @param mixed $chgrp
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Creates a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path for new directory.
+ * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
+ * Default false.
+ * @param string|int $chown Optional. A user name or number (or false to skip chown).
+ * Default false.
+ * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $path = untrailingslashit( $path );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -445,9 +554,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a directory.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory.
+ * @param bool $recursive Optional. Whether to recursively remove files/directories.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function rmdir( $path, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->delete( $path, $recursive );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -454,10 +568,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $include_hidden
- * @param bool $recursive
- * @return bool|array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets details for files in a directory or a specific file.
+ *
+ * @since 2.5.0
+ *
+ * @param string $path Path to directory or file.
+ * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
+ * Default true.
+ * @param bool $recursive Optional. Whether to recursively include file details in nested directories.
+ * Default false.
+ * @return array|false {
+ * Array of files. False if unable to list directory contents.
+ *
+ * @type string $name Name of the file or directory.
+ * @type string $perms *nix representation of permissions.
+ * @type int $permsn Octal representation of permissions.
+ * @type string $owner Owner name or ID.
+ * @type int $size Size of file in bytes.
+ * @type int $lastmodunix Last modified unix timestamp.
+ * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
+ * @type int $time Last modified time.
+ * @type string $type Type of resource. 'f' for file, 'd' for directory.
+ * @type mixed $files If a directory and $recursive is true, contains another array of files.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function dirlist( $path = '.', $include_hidden = true, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_file( $path ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -517,6 +650,9 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Destructor.
+ *
+ * @since 2.5.0
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __destruct() {
</span><span class="cx" style="display: block; padding: 0 10px"> $this->ftp->quit();
</span></span></pre></div>
<a id="trunksrcwpadminincludesclasswpfilesystemssh2php"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php 2019-04-17 02:08:51 UTC (rev 45225)
+++ trunk/src/wp-admin/includes/class-wp-filesystem-ssh2.php 2019-04-17 04:12:27 UTC (rev 45226)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -36,16 +36,28 @@
</span><span class="cx" style="display: block; padding: 0 10px"> class WP_Filesystem_SSH2 extends WP_Filesystem_Base {
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.7.0
+ * @var resource
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $link = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.7.0
</ins><span class="cx" style="display: block; padding: 0 10px"> * @var resource
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public $sftp_link;
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+
+ /**
+ * @since 2.7.0
+ * @var bool
+ */
</ins><span class="cx" style="display: block; padding: 0 10px"> public $keys = false;
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Constructor.
+ *
+ * @since 2.7.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param array $opt
</span><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function __construct( $opt = '' ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -109,7 +121,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Connects filesystem.
+ *
+ * @since 2.7.0
+ *
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function connect() {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->keys ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -193,6 +209,8 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.7.0
+ *
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string $command
</span><span class="cx" style="display: block; padding: 0 10px"> * @param bool $returnbool
</span><span class="cx" style="display: block; padding: 0 10px"> * @return bool|string True on success, false on failure. String if the command was executed, `$returnbool`
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -228,8 +246,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string|false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into a string.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Name of the file to read.
+ * @return string|false Read data on success, false if no temporary file could be opened,
+ * or if the file couldn't be retrieved.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return file_get_contents( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -236,8 +259,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Reads entire file into an array.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @return array|false File contents in an array on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function get_contents_array( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return file( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -244,10 +271,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param string $contents
- * @param bool|int $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Writes a string to a file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Remote path to the file where to write the data.
+ * @param string $contents The data to write.
+ * @param int|false $mode Optional. The file permissions as octal number, usually 0644.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function put_contents( $file, $contents, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $ret = file_put_contents( $this->sftp_path( $file ), $contents );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -262,7 +294,11 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the current working directory.
+ *
+ * @since 2.7.0
+ *
+ * @return string|false The current working directory on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function cwd() {
</span><span class="cx" style="display: block; padding: 0 10px"> $cwd = ssh2_sftp_realpath( $this->sftp_link, '.' );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -273,8 +309,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $dir
- * @return bool|string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes current directory.
+ *
+ * @since 2.7.0
+ *
+ * @param string $dir The new current directory.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chdir( $dir ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->run_command( 'cd ' . $dir, true );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -281,11 +321,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param string $group
- * @param bool $recursive
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the file group.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @param string|int $group A group name or number.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chgrp( $file, $group, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -298,10 +342,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int $mode
- * @param bool $recursive
- * @return bool|string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes filesystem permissions.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for directories. Default false.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chmod( $file, $mode = false, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -325,12 +375,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Change the ownership of a file / folder.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Changes the owner of a file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file Path to the file.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @since 2.7.0
+ *
+ * @param string $file Path to the file or directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> * @param string|int $owner A user name or number.
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param bool $recursive Optional. If set True changes file owner recursivly. Default False.
- * @return bool True on success or false on failure.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @param bool $recursive Optional. If set to true, changes file owner recursively.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function chown( $file, $owner, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $this->exists( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -343,8 +396,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string|false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file owner.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false Username of the owner on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function owner( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $owneruid = @fileowner( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -359,8 +416,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the permissions of the specified file or filepath in their octal format.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @return string Mode of the file (the last 3 digits).
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function getchmod( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return substr( decoct( @fileperms( $this->sftp_path( $file ) ) ), -3 );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -367,8 +428,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return string|false
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's group.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file.
+ * @return string|false The group on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function group( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $gid = @filegroup( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -383,11 +448,17 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @param int|bool $mode
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Copies a file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @param int|false $mode Optional. The permissions as octal number, usually 0644 for files,
+ * 0755 for dirs. Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function copy( $source, $destination, $overwrite = false, $mode = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( ! $overwrite && $this->exists( $destination ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -401,10 +472,15 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $source
- * @param string $destination
- * @param bool $overwrite
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Moves a file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $source Path to the source file.
+ * @param string $destination Path to the destination file.
+ * @param bool $overwrite Optional. Whether to overwrite the destination file if it exists.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function move( $source, $destination, $overwrite = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return @ssh2_sftp_rename( $this->sftp_link, $source, $destination );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -411,10 +487,16 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param bool $recursive
- * @param string|bool $type
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a file or directory.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to the file or directory.
+ * @param bool $recursive Optional. If set to true, changes file group recursively.
+ * Default false.
+ * @param string|false $type Type of resource. 'f' for file, 'd' for directory.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function delete( $file, $recursive = false, $type = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( 'f' == $type || $this->is_file( $file ) ) {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -433,8 +515,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory exists.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file exists or not.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function exists( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return file_exists( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -441,8 +527,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file File path.
+ * @return bool Whether $file is a file.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_file( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return is_file( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -449,8 +539,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if resource is a directory.
+ *
+ * @since 2.7.0
+ *
+ * @param string $path Directory path.
+ * @return bool Whether $path is a directory.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_dir( $path ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return is_dir( $this->sftp_path( $path ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -457,8 +551,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file is readable.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file.
+ * @return bool Whether $file is readable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_readable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return is_readable( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -465,8 +563,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Checks if a file or directory is writable.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file or directory.
+ * @return bool Whether $file is writable.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function is_writable( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> // PHP will base it's writable checks on system_user === file_owner, not ssh_user === file_owner
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -474,8 +576,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file's last access time.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing last access time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function atime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return fileatime( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -482,8 +588,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file modification time.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Unix timestamp representing modification time, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mtime( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return filemtime( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -490,8 +600,12 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @return int
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets the file size (in bytes).
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file.
+ * @return int|false Size of the file in bytes on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function size( $file ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return filesize( $this->sftp_path( $file ) );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -498,20 +612,35 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $file
- * @param int $time
- * @param int $atime
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Sets the access and modification times of a file.
+ *
+ * Note: Not implemented.
+ *
+ * @since 2.7.0
+ *
+ * @param string $file Path to file.
+ * @param int $time Optional. Modified time to set for file.
+ * Default 0.
+ * @param int $atime Optional. Access time to set for file.
+ * Default 0.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function touch( $file, $time = 0, $atime = 0 ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- //Not implemented.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ // Not implemented.
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param mixed $chmod
- * @param mixed $chown
- * @param mixed $chgrp
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Creates a directory.
+ *
+ * @since 2.7.0
+ *
+ * @param string $path Path for new directory.
+ * @param int|false $chmod Optional. The permissions as octal number (or false to skip chmod).
+ * Default false.
+ * @param string|int $chown Optional. A user name or number (or false to skip chown).
+ * Default false.
+ * @param string|int $chgrp Optional. A group name or number (or false to skip chgrp).
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> $path = untrailingslashit( $path );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -535,9 +664,14 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $recursive
- * @return bool
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Deletes a directory.
+ *
+ * @since 2.7.0
+ *
+ * @param string $path Path to directory.
+ * @param bool $recursive Optional. Whether to recursively remove files/directories.
+ * Default false.
+ * @return bool True on success, false on failure.
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function rmdir( $path, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> return $this->delete( $path, $recursive );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -544,10 +678,29 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px">
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * @param string $path
- * @param bool $include_hidden
- * @param bool $recursive
- * @return bool|array
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Gets details for files in a directory or a specific file.
+ *
+ * @since 2.7.0
+ *
+ * @param string $path Path to directory or file.
+ * @param bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files.
+ * Default true.
+ * @param bool $recursive Optional. Whether to recursively include file details in nested directories.
+ * Default false.
+ * @return array|false {
+ * Array of files. False if unable to list directory contents.
+ *
+ * @type string $name Name of the file or directory.
+ * @type string $perms *nix representation of permissions.
+ * @type int $permsn Octal representation of permissions.
+ * @type string $owner Owner name or ID.
+ * @type int $size Size of file in bytes.
+ * @type int $lastmodunix Last modified unix timestamp.
+ * @type mixed $lastmod Last modified month (3 letter) and day (without leading 0).
+ * @type int $time Last modified time.
+ * @type string $type Type of resource. 'f' for file, 'd' for directory.
+ * @type mixed $files If a directory and $recursive is true, contains another array of files.
+ * }
</ins><span class="cx" style="display: block; padding: 0 10px"> */
</span><span class="cx" style="display: block; padding: 0 10px"> public function dirlist( $path, $include_hidden = true, $recursive = false ) {
</span><span class="cx" style="display: block; padding: 0 10px"> if ( $this->is_file( $path ) ) {
</span></span></pre>
</div>
</div>
</body>
</html>