[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[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: | 2811 lines (97 kb) |
Included or required: | 14 times |
Referenced: | 0 times |
Includes or requires: | 3 files wp-admin/includes/class-wp-filesystem-base.php wp-admin/includes/template.php wp-admin/includes/class-pclzip.php |
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. |
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. |
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. param: bool $include_hidden Optional. Whether to include details of hidden ("." prefixed) files. |
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. |
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. |
wp_print_file_editor_templates() X-Ref |
Prints file editor templates (for plugins and themes). |
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 { |
wp_tempnam( $filename = '', $dir = '' ) X-Ref |
Returns a filename of a temporary unique file. Please note that the calling function must delete or move the file. 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. |
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. |
_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']`. |
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|null $time Optional. Time formatted in 'yyyy/mm'. Default null. |
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|null $time Optional. Time formatted in 'yyyy/mm'. Default null. |
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 delete or move 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. |
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, |
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. |
wp_trusted_keys() X-Ref |
Retrieves the list of signing keys trusted by WordPress. return: string[] Array of base64-encoded signing keys. |
wp_zip_file_is_valid( $file ) X-Ref |
Determines whether the given file is a valid ZIP file. This function does not test to ensure that a file exists. Non-existent files are not valid ZIPs, so those will also return false. return: bool Whether the file is a valid ZIP file. param: string $file Full path to the ZIP file. |
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. |
_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. |
_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. |
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. |
move_dir( $from, $to, $overwrite = false ) X-Ref |
Moves a directory from one location to another. Recursively invalidates OPcache on success. If the renaming failed, falls back to copy_dir(). Assumes that WP_Filesystem() has already been called and setup. This function is not designed to merge directories, copy_dir() should be used instead. return: true|WP_Error True on success, WP_Error on failure. param: string $from Source directory. param: string $to Destination directory. param: bool $overwrite Optional. Whether to overwrite the destination directory if it exists. |
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. |
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. |
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. |
wp_print_request_filesystem_credentials_modal() X-Ref |
Prints the filesystem credentials modal when needed. |
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. |
wp_opcache_invalidate_directory( $dir ) X-Ref |
Attempts to clear the opcode cache for a directory of files. param: string $dir The path to the directory for which the opcode cache is to be cleared. |
Generated : Sat Dec 21 08:20:01 2024 | Cross-referenced by PHPXref |