WP_Filesystem_Base
- Since
- 2.5.0
- Source
wp-admin/includes/class-wp-filesystem-base.php:31
Base WordPress Filesystem class which Filesystem implementations extend.
Compatibility
- WordPress
- since 2.5.0
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Properties · 5
$verboseboolpublic- Whether to display debug data for the connection.
$cachearray<string,public- Cached list of local filepaths to mapped remote filepaths.
$methodstringpublic- The Access method of the current connection, Set automatically.
$errorsWP_Errorpublic$optionsarray<string,public
Methods · 39
- abspath()Returns the path on the remote filesystem of ABSPATH.
- wp_content_dir()Returns the path on the remote filesystem of WP_CONTENT_DIR.
- wp_plugins_dir()Returns the path on the remote filesystem of WP_PLUGIN_DIR.
- wp_themes_dir()Returns the path on the remote filesystem of the Themes Directory.
- wp_lang_dir()Returns the path on the remote filesystem of WP_LANG_DIR.
- find_base_dir()Locates a folder on the remote filesystem.
- get_base_dir()Locates a folder on the remote filesystem.
- find_folder()Locates a folder on the remote filesystem.
- search_for_folder()Locates a folder on the remote filesystem.
- gethchmod()Returns the *nix-style file permissions for a file.
- getchmod()Gets the permissions of the specified file or filepath in their octal format.
- getnumchmodfromh()Converts *nix-style file permissions to an octal number.
- is_binary()Determines if the string provided contains binary characters.
- chown()Changes the owner of a file or directory.
- connect()Connects filesystem.
- get_contents()Reads entire file into a string.
- get_contents_array()Reads entire file into an array.
- put_contents()Writes a string to a file.
- cwd()Gets the current working directory.
- chdir()Changes current directory.
- chgrp()Changes the file group.
- chmod()Changes filesystem permissions.
- owner()Gets the file owner.
- group()Gets the file's group.
- copy()Copies a file.
- move()Moves a file.
- delete()Deletes a file or directory.
- exists()Checks if a file or directory exists.
- is_file()Checks if resource is a file.
- is_dir()Checks if resource is a directory.
- is_readable()Checks if a file is readable.
- is_writable()Checks if a file or directory is writable.
- atime()Gets the file's last access time.
- mtime()Gets the file modification time.
- size()Gets the file size (in bytes).
- touch()Sets the access and modification times of a file.
- mkdir()Creates a directory.
- rmdir()Deletes a directory.
- dirlist()Gets details for files in a directory or a specific file.
Source code
#[AllowDynamicProperties]class WP_Filesystem_Base { /** * Whether to display debug data for the connection. * * @since 2.5.0 * @var bool */ public $verbose = false; /** * Cached list of local filepaths to mapped remote filepaths. * * @since 2.7.0 * @var array<string, string> */ public $cache = array(); /** * The Access method of the current connection, Set automatically. * * @since 2.5.0 * @var string */ public $method = ''; /** * @var WP_Error */ public $errors = null; /** * @var array<string, mixed> */ public $options = array(); /** * Returns the path on the remote filesystem of ABSPATH. * * @since 2.7.0 * * @return string|false The location of the remote path, or false on failure. */ 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( '/' . WPINC ) ) { $folder = '/'; } return $folder; } /** * Returns the path on the remote filesystem of WP_CONTENT_DIR. * * @since 2.7.0 * * @return string|false The location of the remote path, or false on failure. */ public function wp_content_dir() { return $this->find_folder( WP_CONTENT_DIR ); } /** * Returns the path on the remote filesystem of WP_PLUGIN_DIR. * * @since 2.7.0 * * @return string|false The location of the remote path, or false on failure. */ public function wp_plugins_dir() { return $this->find_folder( WP_PLUGIN_DIR ); }Changelog
Introduced in 2.5.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-admin/includes/class-wp-filesystem-base.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.