Add access modifiers to members and methods in WP_Filesystem_Base
. Add magic __get()
method for backwards compatibility.
See #27881, #22234. git-svn-id: https://develop.svn.wordpress.org/trunk@28487 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
6e09b1f167
commit
06672a6c5a
@ -19,7 +19,7 @@ class WP_Filesystem_Base {
|
||||
* @since 2.5.0
|
||||
* @var bool
|
||||
*/
|
||||
var $verbose = false;
|
||||
public $verbose = false;
|
||||
|
||||
/**
|
||||
* Cached list of local filepaths to mapped remote filepaths.
|
||||
@ -28,7 +28,7 @@ class WP_Filesystem_Base {
|
||||
* @since 2.7.0
|
||||
* @var array
|
||||
*/
|
||||
var $cache = array();
|
||||
private $cache = array();
|
||||
|
||||
/**
|
||||
* The Access method of the current connection, Set automatically.
|
||||
@ -37,12 +37,23 @@ class WP_Filesystem_Base {
|
||||
* @since 2.5.0
|
||||
* @var string
|
||||
*/
|
||||
var $method = '';
|
||||
public $method = '';
|
||||
|
||||
/**
|
||||
* Constructor (empty).
|
||||
*/
|
||||
function __construct() {}
|
||||
public function __construct() {}
|
||||
|
||||
/**
|
||||
* Make private properties readable for backwards compatibility
|
||||
*
|
||||
* @since 4.0.0
|
||||
* @param string $name
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get( $name ) {
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the path on the remote filesystem of ABSPATH.
|
||||
@ -52,7 +63,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function abspath() {
|
||||
public function abspath() {
|
||||
$folder = $this->find_folder(ABSPATH);
|
||||
// Perhaps the FTP folder is rooted at the WordPress install, Check for wp-includes folder in root, Could have some false positives, but rare.
|
||||
if ( ! $folder && $this->is_dir('/wp-includes') )
|
||||
@ -68,7 +79,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function wp_content_dir() {
|
||||
public function wp_content_dir() {
|
||||
return $this->find_folder(WP_CONTENT_DIR);
|
||||
}
|
||||
|
||||
@ -80,7 +91,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function wp_plugins_dir() {
|
||||
public function wp_plugins_dir() {
|
||||
return $this->find_folder(WP_PLUGIN_DIR);
|
||||
}
|
||||
|
||||
@ -93,7 +104,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $theme The Theme stylesheet or template for the directory.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function wp_themes_dir( $theme = false ) {
|
||||
public function wp_themes_dir( $theme = false ) {
|
||||
$theme_root = get_theme_root( $theme );
|
||||
|
||||
// Account for relative theme roots
|
||||
@ -111,7 +122,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function wp_lang_dir() {
|
||||
public function wp_lang_dir() {
|
||||
return $this->find_folder(WP_LANG_DIR);
|
||||
}
|
||||
|
||||
@ -132,7 +143,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function find_base_dir( $base = '.', $echo = false ) {
|
||||
public function find_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
@ -154,7 +165,7 @@ class WP_Filesystem_Base {
|
||||
* @param bool $echo True to display debug information.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function get_base_dir( $base = '.', $echo = false ) {
|
||||
public function get_base_dir( $base = '.', $echo = false ) {
|
||||
_deprecated_function(__FUNCTION__, '2.7', 'WP_Filesystem::abspath() or WP_Filesystem::wp_*_dir()' );
|
||||
$this->verbose = $echo;
|
||||
return $this->abspath();
|
||||
@ -172,7 +183,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $folder the folder to locate.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function find_folder( $folder ) {
|
||||
public function find_folder( $folder ) {
|
||||
|
||||
if ( isset( $this->cache[ $folder ] ) )
|
||||
return $this->cache[ $folder ];
|
||||
@ -241,7 +252,7 @@ class WP_Filesystem_Base {
|
||||
* @param bool $loop If the function has recursed, Internal use only.
|
||||
* @return string The location of the remote path.
|
||||
*/
|
||||
function search_for_folder( $folder, $base = '.', $loop = false ) {
|
||||
public function search_for_folder( $folder, $base = '.', $loop = false ) {
|
||||
if ( empty( $base ) || '.' == $base )
|
||||
$base = trailingslashit($this->cwd());
|
||||
|
||||
@ -308,7 +319,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file String filename.
|
||||
* @return string The *nix-style representation of permissions.
|
||||
*/
|
||||
function gethchmod( $file ){
|
||||
public function gethchmod( $file ){
|
||||
$perms = $this->getchmod($file);
|
||||
if (($perms & 0xC000) == 0xC000) // Socket
|
||||
$info = 's';
|
||||
@ -364,7 +375,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $mode string The *nix-style file permission.
|
||||
* @return int octal representation
|
||||
*/
|
||||
function getnumchmodfromh( $mode ) {
|
||||
public function getnumchmodfromh( $mode ) {
|
||||
$realmode = '';
|
||||
$legal = array('', 'w', 'r', 'x', '-');
|
||||
$attarray = preg_split('//', $mode);
|
||||
@ -393,7 +404,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $text String to test against.
|
||||
* @return bool true if string is binary, false otherwise.
|
||||
*/
|
||||
function is_binary( $text ) {
|
||||
public function is_binary( $text ) {
|
||||
return (bool) preg_match( '|[^\x20-\x7E]|', $text ); // chr(32)..chr(127)
|
||||
}
|
||||
|
||||
@ -409,7 +420,7 @@ class WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. If set True changes file owner recursivly. Defaults to False.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function chown( $file, $owner, $recursive = false ) {
|
||||
public function chown( $file, $owner, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -420,7 +431,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return bool True on success or false on failure (always true for WP_Filesystem_Direct).
|
||||
*/
|
||||
function connect() {
|
||||
public function connect() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -432,7 +443,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Name of the file to read.
|
||||
* @return string|bool Returns the read data or false on failure.
|
||||
*/
|
||||
function get_contents( $file ) {
|
||||
public function get_contents( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -444,7 +455,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to the file.
|
||||
* @return array|bool the file contents in an array or false on failure.
|
||||
*/
|
||||
function get_contents_array( $file ) {
|
||||
public function get_contents_array( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -458,7 +469,7 @@ class WP_Filesystem_Base {
|
||||
* @param int $mode Optional. The file permissions as octal number, usually 0644.
|
||||
* @return bool False on failure.
|
||||
*/
|
||||
function put_contents( $file, $contents, $mode = false ) {
|
||||
public function put_contents( $file, $contents, $mode = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -469,7 +480,7 @@ class WP_Filesystem_Base {
|
||||
*
|
||||
* @return string|bool The current working directory on success, or false on failure.
|
||||
*/
|
||||
function cwd() {
|
||||
public function cwd() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -481,7 +492,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $dir The new current directory.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function chdir( $dir ) {
|
||||
public function chdir( $dir ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -495,7 +506,7 @@ class WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function chgrp( $file, $group, $recursive = false ) {
|
||||
public function chgrp( $file, $group, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -509,7 +520,7 @@ class WP_Filesystem_Base {
|
||||
* @param bool $recursive Optional. If set True changes file group recursively. Defaults to False.
|
||||
* @return bool Returns true on success or false on failure.
|
||||
*/
|
||||
function chmod( $file, $mode = false, $recursive = false ) {
|
||||
public function chmod( $file, $mode = false, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -521,7 +532,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool Username of the user or false on error.
|
||||
*/
|
||||
function owner( $file ) {
|
||||
public function owner( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -533,7 +544,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to the file.
|
||||
* @return string|bool The group or false on error.
|
||||
*/
|
||||
function group( $file ) {
|
||||
public function group( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -550,7 +561,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return bool True if file copied successfully, False otherwise.
|
||||
*/
|
||||
function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
public function copy( $source, $destination, $overwrite = false, $mode = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -565,7 +576,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return bool True if file copied successfully, False otherwise.
|
||||
*/
|
||||
function move( $source, $destination, $overwrite = false ) {
|
||||
public function move( $source, $destination, $overwrite = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -581,7 +592,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return bool True if the file or directory was deleted, false on failure.
|
||||
*/
|
||||
function delete( $file, $recursive = false, $type = false ) {
|
||||
public function delete( $file, $recursive = false, $type = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -593,7 +604,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to file/directory.
|
||||
* @return bool Whether $file exists or not.
|
||||
*/
|
||||
function exists( $file ) {
|
||||
public function exists( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -605,7 +616,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file File path.
|
||||
* @return bool Whether $file is a file.
|
||||
*/
|
||||
function is_file( $file ) {
|
||||
public function is_file( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -617,7 +628,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $path Directory path.
|
||||
* @return bool Whether $path is a directory.
|
||||
*/
|
||||
function is_dir( $path ) {
|
||||
public function is_dir( $path ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -629,7 +640,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to file.
|
||||
* @return bool Whether $file is readable.
|
||||
*/
|
||||
function is_readable( $file ) {
|
||||
public function is_readable( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -641,7 +652,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $path Path to file/directory.
|
||||
* @return bool Whether $file is writable.
|
||||
*/
|
||||
function is_writable( $file ) {
|
||||
public function is_writable( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -653,7 +664,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to file.
|
||||
* @return int Unix timestamp representing last access time.
|
||||
*/
|
||||
function atime( $file ) {
|
||||
public function atime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -665,7 +676,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to file.
|
||||
* @return int Unix timestamp representing modification time.
|
||||
*/
|
||||
function mtime( $file ) {
|
||||
public function mtime( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -677,7 +688,7 @@ class WP_Filesystem_Base {
|
||||
* @param string $file Path to file.
|
||||
* @return int Size of the file in bytes.
|
||||
*/
|
||||
function size( $file ) {
|
||||
public function size( $file ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -695,7 +706,7 @@ class WP_Filesystem_Base {
|
||||
* Default 0.
|
||||
* @return bool Whether operation was successful or not.
|
||||
*/
|
||||
function touch( $file, $time = 0, $atime = 0 ) {
|
||||
public function touch( $file, $time = 0, $atime = 0 ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -713,7 +724,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return bool False if directory cannot be created, true otherwise.
|
||||
*/
|
||||
function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
public function mkdir( $path, $chmod = false, $chown = false, $chgrp = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -727,7 +738,7 @@ class WP_Filesystem_Base {
|
||||
* Default false.
|
||||
* @return bool Whether directory is deleted successfully or not.
|
||||
*/
|
||||
function rmdir( $path, $recursive = false ) {
|
||||
public function rmdir( $path, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -756,7 +767,7 @@ class WP_Filesystem_Base {
|
||||
* @type mixed 'files' If a directory and $recursive is true, contains another array of files.
|
||||
* }
|
||||
*/
|
||||
function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
public function dirlist( $path, $include_hidden = true, $recursive = false ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user