[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-admin/includes/ -> file.php (summary)

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: 2385 lines (85 kb)
Included or required: 7 times
Referenced: 0 times
Includes or requires: 2 files
 wp-admin/includes/class-pclzip.php
 wp-admin/includes/class-wp-filesystem-base.php

Defines 27 functions

  get_file_description()
  get_home_path()
  list_files()
  wp_get_plugin_file_editable_extensions()
  wp_get_theme_file_editable_extensions()
  wp_print_file_editor_templates()
  wp_edit_theme_plugin_file()
  wp_tempnam()
  validate_file_to_edit()
  _wp_handle_upload()
  wp_handle_upload_error()
  wp_handle_upload()
  wp_handle_sideload()
  download_url()
  verify_file_md5()
  unzip_file()
  _unzip_file_ziparchive()
  _unzip_file_pclzip()
  copy_dir()
  WP_Filesystem()
  get_filesystem_method()
  request_filesystem_credentials()
  wp_print_request_filesystem_credentials_modal()
  wp_privacy_generate_personal_data_export_group_html()
  wp_privacy_generate_personal_data_export_file()
  wp_privacy_send_personal_data_export_email()
  wp_privacy_process_personal_data_export_page()

Functions
Functions that are not part of a class:

get_file_description( $file )   X-Ref
Get the description for standard WordPress theme files and other various standard
WordPress files

param: string $file Filesystem path or filename
return: string Description of file from $wp_file_descriptions or basename of $file if description doesn't exist.

get_home_path()   X-Ref
Get 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.

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.
return: bool|string[] False on failure, else array of files.

wp_get_plugin_file_editable_extensions( $plugin )   X-Ref
Get list of file extensions that are editable in plugins.

param: string $plugin Path to the plugin file relative to the plugins directory.
return: string[] Array of editable file extensions.

wp_get_theme_file_editable_extensions( $theme )   X-Ref
Get list of file extensions that are editable for a given theme.

param: WP_Theme $theme Theme object.
return: string[] Array of editable file extensions.

wp_print_file_editor_templates()   X-Ref
Print file editor templates (for plugins and themes).


wp_edit_theme_plugin_file( $args )   X-Ref
Attempt 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.

param: string[] $args {
return: true|WP_Error True on success or `WP_Error` on failure.

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.

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.
return: string a writable filename

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.

param: string   $file          File the user is attempting to edit.
param: string[] $allowed_files Optional. Array of allowed files to edit. `$file` must match an entry exactly.
return: string|void Returns the file name on success, dies on failure.

_wp_handle_upload( &$file, $overrides, $time, $action )   X-Ref
Handle PHP uploads in WordPress, sanitizing file names, checking extensions for mime type,
and moving the file to the appropriate directory within the uploads directory.

param: string[]       $file      Reference to a single element of `$_FILES`. Call the function once for each uploaded file.
param: string[]|false $overrides An associative array of names => values to override default variables. Default false.
param: string         $time      Time formatted in 'yyyy/mm'.
param: string         $action    Expected value for `$_POST['action']`.
return: string[] On success, returns an associative array of file attributes. On failure, returns

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.

param: array      $file      Reference to a single element of `$_FILES`. Call the function once for
param: array|bool $overrides Optional. An associative array of names=>values to override default
param: string     $time      Optional. Time formatted in 'yyyy/mm'. Default null.
return: array On success, returns an associative array of file attributes. On failure, returns

wp_handle_sideload( &$file, $overrides = false, $time = null )   X-Ref
Wrapper for _wp_handle_upload().

Passes the {@see 'wp_handle_sideload'} action.

param: array      $file      An array similar to that of a PHP `$_FILES` POST array
param: array|bool $overrides Optional. An associative array of names=>values to override default
param: string     $time      Optional. Time formatted in 'yyyy/mm'. Default null.
return: array On success, returns an associative array of file attributes. On failure, returns

download_url( $url, $timeout = 300 )   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.

param: string $url  The URL of the file to download.
param: int $timeout The timeout for the request to download the file. Default 300 seconds.
return: string|WP_Error Filename on success, WP_Error on failure.

verify_file_md5( $filename, $expected_md5 )   X-Ref
Calculates and compares the MD5 of a file to its expected value.

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,
return: bool|WP_Error True on success, false when the MD5 format is unknown/unexpected,

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.

param: string $file Full path and filename of ZIP archive.
param: string $to   Full path on the filesystem to extract archive to.
return: true|WP_Error True on success, WP_Error on failure.

_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.

param: string $file       Full path and filename of ZIP archive.
param: string $to         Full path on the filesystem to extract archive to.
param: array $needed_dirs A partial list of required folders needed to be created.
return: true|WP_Error True on success, WP_Error on failure.

_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.

param: string $file       Full path and filename of ZIP archive.
param: string $to         Full path on the filesystem to extract archive to.
param: array $needed_dirs A partial list of required folders needed to be created.
return: true|WP_Error True on success, WP_Error on failure.

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.

param: string $from     Source directory.
param: string $to       Destination directory.
param: array $skip_list A list of files/folders to skip copying.
return: true|WP_Error True on success, WP_Error on failure.

WP_Filesystem( $args = false, $context = false, $allow_relaxed_file_ownership = false )   X-Ref
Initialises 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.

param: array|false  $args                         Optional. Connection args, These are passed directly to
param: string|false $context                      Optional. Context for get_filesystem_method(). Default false.
param: bool         $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
return: bool|null True on success, false on failure, null if the filesystem method class file does not exist.

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'}.

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.
return: string The transport to use, see description for valid return values.

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.

param: string $form_post                    The URL to post the form to.
param: string $type                         Optional. Chosen type of filesystem. Default empty.
param: bool   $error                        Optional. Whether the current request has failed to connect.
param: string $context                      Optional. Full path to the directory that is tested for being
param: array  $extra_fields                 Optional. Extra `POST` fields to be checked for inclusion in
param: bool   $allow_relaxed_file_ownership Optional. Whether to allow Group/World writable. Default false.
return: bool True on success, false on failure.

wp_print_request_filesystem_credentials_modal()   X-Ref
Print the filesystem credentials modal when needed.


wp_privacy_generate_personal_data_export_group_html( $group_data )   X-Ref
Generate a single group for the personal data export report.

param: array $group_data {
return: string The HTML for this group and its items.

wp_privacy_generate_personal_data_export_file( $request_id )   X-Ref
Generate the personal data export file.

param: int $request_id The export request ID.

wp_privacy_send_personal_data_export_email( $request_id )   X-Ref
Send an email to the user with a link to the personal data export file

param: int $request_id The request ID for this personal data export.
return: true|WP_Error True on success or `WP_Error` on failure.

wp_privacy_process_personal_data_export_page( $response, $exporter_index, $email_address, $page, $request_id, $send_as_email, $exporter_key )   X-Ref
Intercept personal data exporter page ajax responses in order to assemble the personal data export file.

param: array  $response        The response from the personal data exporter for the given page.
param: int    $exporter_index  The index of the personal data exporter. Begins at 1.
param: string $email_address   The email address of the user whose personal data this is.
param: int    $page            The page of personal data for this exporter. Begins at 1.
param: int    $request_id      The request ID for this personal data export.
param: bool   $send_as_email   Whether the final results of the export should be emailed to the user.
param: string $exporter_key    The slug (key) of the exporter.
return: array The filtered response.



Generated: Fri Sep 21 08:20:01 2018 Cross-referenced by PHPXref 0.7