[ Index ] |
PHP Cross Reference of WordPress |
[Source view] [Print] [Project Stats]
Filesystem API: Top-level functionality Functions for reading, writing, modifying, and deleting files on the file system. Includes functionality for theme-specific files as well as operations for uploading, archiving, and rendering output when necessary.
File Size: | 2557 lines (89 kb) |
Included or required: | 0 times |
Referenced: | 0 times |
Includes or requires: | 0 files |
get_file_description( $file ) X-Ref |
Gets the description for standard WordPress theme files. return: string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist. param: string $file Filesystem path or filename. since: 1.5.0 |
get_home_path() X-Ref |
Gets the absolute filesystem path to the root of the WordPress installation. return: string Full filesystem path to the root of the WordPress installation. since: 1.5.0 |
list_files( $folder = '', $levels = 100, $exclusions = array() X-Ref |
Returns a listing of all files in the specified folder and all subdirectories up to 100 levels deep. The depth of the recursiveness can be controlled by the $levels param. return: string[]|false Array of files on success, false on failure. param: string $folder Optional. Full path to folder. Default empty. param: int $levels Optional. Levels of folders to follow, Default 100 (PHP Loop limit). param: string[] $exclusions Optional. List of folders and files to skip. since: 2.6.0 since: 4.9.0 Added the `$exclusions` parameter. |
wp_get_plugin_file_editable_extensions( $plugin ) X-Ref |
Gets the list of file extensions that are editable in plugins. return: string[] Array of editable file extensions. param: string $plugin Path to the plugin file relative to the plugins directory. since: 4.9.0 |
wp_get_theme_file_editable_extensions( $theme ) X-Ref |
Gets the list of file extensions that are editable for a given theme. return: string[] Array of editable file extensions. param: WP_Theme $theme Theme object. since: 4.9.0 |
wp_print_file_editor_templates() X-Ref |
Prints file editor templates (for plugins and themes). since: 4.9.0 |
wp_edit_theme_plugin_file( $args ) X-Ref |
Attempts to edit a file for a theme or plugin. When editing a PHP file, loopback requests will be made to the admin and the homepage to attempt to see if there is a fatal error introduced. If so, the PHP change will be reverted. return: true|WP_Error True on success or `WP_Error` on failure. param: string[] $args { since: 4.9.0 |
wp_tempnam( $filename = '', $dir = '' ) X-Ref |
Returns a filename of a temporary unique file. Please note that the calling function must unlink() this itself. The filename is based off the passed parameter or defaults to the current unix timestamp, while the directory can either be passed as well, or by leaving it blank, default to a writable temporary directory. return: string A writable filename. param: string $filename Optional. Filename to base the Unique file off. Default empty. param: string $dir Optional. Directory to store the file in. Default empty. since: 2.6.0 |
validate_file_to_edit( $file, $allowed_files = array() X-Ref |
Makes sure that the file that was requested to be edited is allowed to be edited. Function will die if you are not allowed to edit the file. return: string|void Returns the file name on success, dies on failure. param: string $file File the user is attempting to edit. param: string[] $allowed_files Optional. Array of allowed files to edit. since: 1.5.0 |
_wp_handle_upload( &$file, $overrides, $time, $action ) X-Ref |
Handles PHP uploads in WordPress. Sanitizes file names, checks extensions for mime type, and moves the file to the appropriate directory within the uploads directory. return: array { param: array $file { param: array|false $overrides { param: string $time Time formatted in 'yyyy/mm'. param: string $action Expected value for `$_POST['action']`. since: 4.0.0 |
wp_handle_upload_error( &$file, $message ) X-Ref |
No description |
wp_handle_upload( &$file, $overrides = false, $time = null ) X-Ref |
Wrapper for _wp_handle_upload(). Passes the {@see 'wp_handle_upload'} action. return: array See _wp_handle_upload() for return value. param: array $file Reference to a single element of `$_FILES`. param: array|false $overrides Optional. An associative array of names => values param: string $time Optional. Time formatted in 'yyyy/mm'. Default null. since: 2.0.0 |
wp_handle_sideload( &$file, $overrides = false, $time = null ) X-Ref |
Wrapper for _wp_handle_upload(). Passes the {@see 'wp_handle_sideload'} action. return: array See _wp_handle_upload() for return value. param: array $file Reference to a single element of `$_FILES`. param: array|false $overrides Optional. An associative array of names => values param: string $time Optional. Time formatted in 'yyyy/mm'. Default null. since: 2.6.0 |
download_url( $url, $timeout = 300, $signature_verification = false ) X-Ref |
Downloads a URL to a local temporary file using the WordPress HTTP API. Please note that the calling function must unlink() the file. return: string|WP_Error Filename on success, WP_Error on failure. param: string $url The URL of the file to download. param: int $timeout The timeout for the request to download the file. param: bool $signature_verification Whether to perform Signature Verification. since: 2.5.0 since: 5.2.0 Signature Verification with SoftFail was added. since: 5.9.0 Support for Content-Disposition filename was added. |
verify_file_md5( $filename, $expected_md5 ) X-Ref |
Calculates and compares the MD5 of a file to its expected value. return: bool|WP_Error True on success, false when the MD5 format is unknown/unexpected, param: string $filename The filename to check the MD5 of. param: string $expected_md5 The expected MD5 of the file, either a base64-encoded raw md5, since: 3.7.0 |
verify_file_signature( $filename, $signatures, $filename_for_errors = false ) X-Ref |
Verifies the contents of a file against its ED25519 signature. return: bool|WP_Error True on success, false if verification not attempted, param: string $filename The file to validate. param: string|array $signatures A Signature provided for the file. param: string|false $filename_for_errors Optional. A friendly filename for errors. since: 5.2.0 |
wp_trusted_keys() X-Ref |
Retrieves the list of signing keys trusted by WordPress. return: string[] Array of base64-encoded signing keys. since: 5.2.0 |
unzip_file( $file, $to ) X-Ref |
Unzips a specified ZIP file to a location on the filesystem via the WordPress Filesystem Abstraction. Assumes that WP_Filesystem() has already been called and set up. Does not extract a root-level __MACOSX directory, if present. Attempts to increase the PHP memory limit to 256M before uncompressing. However, the most memory required shouldn't be much larger than the archive itself. return: true|WP_Error True on success, WP_Error on failure. param: string $file Full path and filename of ZIP archive. param: string $to Full path on the filesystem to extract archive to. since: 2.5.0 |
_unzip_file_ziparchive( $file, $to, $needed_dirs = array() X-Ref |
Attempts to unzip an archive using the ZipArchive class. This function should not be called directly, use `unzip_file()` instead. Assumes that WP_Filesystem() has already been called and set up. return: true|WP_Error True on success, WP_Error on failure. param: string $file Full path and filename of ZIP archive. param: string $to Full path on the filesystem to extract archive to. param: string[] $needed_dirs A partial list of required folders needed to be created. since: 3.0.0 |
_unzip_file_pclzip( $file, $to, $needed_dirs = array() X-Ref |
Attempts to unzip an archive using the PclZip library. This function should not be called directly, use `unzip_file()` instead. Assumes that WP_Filesystem() has already been called and set up. return: true|WP_Error True on success, WP_Error on failure. param: string $file Full path and filename of ZIP archive. param: string $to Full path on the filesystem to extract archive to. param: string[] $needed_dirs A partial list of required folders needed to be created. since: 3.0.0 |
copy_dir( $from, $to, $skip_list = array() X-Ref |
Copies a directory from one location to another via the WordPress Filesystem Abstraction. Assumes that WP_Filesystem() has already been called and setup. return: true|WP_Error True on success, WP_Error on failure. param: string $from Source directory. param: string $to Destination directory. param: string[] $skip_list An array of files/folders to skip copying. since: 2.5.0 |
WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false ) X-Ref |
Initializes and connects the WordPress Filesystem Abstraction classes. This function will include the chosen transport and attempt connecting. Plugins may add extra transports, And force WordPress to use them by returning the filename via the {@see 'filesystem_method_file'} filter. return: bool|null True on success, false on failure, param: array|false $args Optional. Connection args, These are passed param: string|false $context Optional. Context for get_filesystem_method(). param: bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. since: 2.5.0 |
get_filesystem_method( $args = array() X-Ref |
Determines which method to use for reading, writing, modifying, or deleting files on the filesystem. The priority of the transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or `fsockopen()`). Valid values for these are: 'direct', 'ssh2', 'ftpext' or 'ftpsockets'. The return value can be overridden by defining the `FS_METHOD` constant in `wp-config.php`, or filtering via {@see 'filesystem_method'}. return: string The transport to use, see description for valid return values. param: array $args Optional. Connection details. Default empty array. param: string $context Optional. Full path to the directory that is tested param: bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. since: 2.5.0 |
request_filesystem_credentials( $form_post, $type = '', $error = false, $context = '', $extra_fields = null, $allow_relaxed_file_ownership = false ) X-Ref |
Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem. All chosen/entered details are saved, excluding the password. Hostnames may be in the form of hostname:portnumber (eg: wordpress.org:2467) to specify an alternate FTP/SSH port. Plugins may override this form by returning true|false via the {@see 'request_filesystem_credentials'} filter. return: bool|array True if no filesystem credentials are required, param: string $form_post The URL to post the form to. param: string $type Optional. Chosen type of filesystem. Default empty. param: bool|WP_Error $error Optional. Whether the current request has failed param: string $context Optional. Full path to the directory that is tested param: array $extra_fields Optional. Extra `POST` fields to be checked param: bool $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. since: 2.5.0 since: 4.6.0 The `$context` parameter default changed from `false` to an empty string. |
wp_print_request_filesystem_credentials_modal() X-Ref |
Prints the filesystem credentials modal when needed. since: 4.2.0 |
wp_opcache_invalidate( $filepath, $force = false ) X-Ref |
Attempts to clear the opcode cache for an individual PHP file. This function can be called safely without having to check the file extension or availability of the OPcache extension. Whether or not invalidation is possible is cached to improve performance. return: bool True if opcache was invalidated for `$filepath`, or there was nothing to invalidate. param: string $filepath Path to the file, including extension, for which the opcode cache is to be cleared. param: bool $force Invalidate even if the modification time is not newer than the file in cache. since: 5.5.0 |
Generated: Thu Nov 21 01:00:03 2024 | Cross-referenced by PHPXref 0.7.1 |