[ Index ]

WordPress Cross Reference

title

Body

[close]

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

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

Defines 18 functions

  get_file_description()
  get_home_path()
  list_files()
  wp_tempnam()
  validate_file_to_edit()
  wp_handle_upload()
  wp_handle_upload_error()
  wp_handle_sideload()
  wp_handle_upload_error()
  download_url()
  verify_file_md5()
  unzip_file()
  _unzip_file_ziparchive()
  _unzip_file_pclzip()
  copy_dir()
  WP_Filesystem()
  get_filesystem_method()
  request_filesystem_credentials()

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 )   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 Full path to folder
param: int $levels (optional) Levels of folders to follow, Default: 100 (PHP Loop limit).
return: bool|array False on failure, Else array of files

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
param: string $dir (optional) Directory to store the file in
return: string a writable filename

validate_file_to_edit( $file, $allowed_files = '' )   X-Ref
Make sure that the file that was requested to edit, is allowed to be edited

Function will die if if you are not allowed to edit the file

param: string $file file the users is attempting to edit
param: array $allowed_files Array of allowed files to edit, $file must match an entry exactly
return: null

wp_handle_upload( &$file, $overrides = false, $time = null )   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: array $file Reference to a single element of $_FILES. Call the function once for each uploaded file.
param: array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
param: string $time Optional. Time formatted in 'yyyy/mm'.
return: array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).

wp_handle_upload_error( &$file, $message )   X-Ref
No description

wp_handle_sideload( &$file, $overrides = false, $time = null )   X-Ref
Handle sideloads, which is the process of retrieving a media item from another server instead of
a traditional media upload. This process involves sanitizing the filename, checking extensions
for mime type, and moving the file to the appropriate directory within the uploads directory.

param: array $file an array similar to that of a PHP $_FILES POST array
param: array $overrides Optional. An associative array of names=>values to override default variables with extract( $overrides, EXTR_OVERWRITE ).
param: string $time Optional. Time formatted in 'yyyy/mm'.
return: array On success, returns an associative array of file attributes. On failure, returns $overrides['upload_error_handler'](&$file, $message ) or array( 'error'=>$message ).

wp_handle_upload_error( &$file, $message )   X-Ref
No description

download_url( $url, $timeout = 300 )   X-Ref
Downloads a url to a local temporary file using the WordPress HTTP Class.
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: mixed WP_Error on failure, string Filename on success.

verify_file_md5( $filename, $expected_md5 )   X-Ref
Calculates and compares the MD5 of a file to it's 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, or a hex-encoded md5
return: bool|object WP_Error on failure, 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: mixed WP_Error on failure, True on success

_unzip_file_ziparchive($file, $to, $needed_dirs = array()   X-Ref
This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the ZipArchive class.
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: mixed WP_Error on failure, True on success

_unzip_file_pclzip($file, $to, $needed_dirs = array()   X-Ref
This function should not be called directly, use unzip_file instead. Attempts to unzip an archive using the PclZip library.
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: mixed WP_Error on failure, True on success

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: mixed WP_Error on failure, True on success.

WP_Filesystem( $args = false, $context = 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 'filesystem_method_file' filter.

param: array $args (optional) Connection args, These are passed directly to the WP_Filesystem_*() classes.
param: string $context (optional) Context for get_filesystem_method(), See function declaration for more information.
return: boolean false on failure, true on success

get_filesystem_method($args = array()   X-Ref
Determines which Filesystem Method to use.
The priority of the Transports are: Direct, SSH2, FTP PHP Extension, FTP Sockets (Via Sockets class, or fsockopen())

Note that the return value of this function can be overridden in 2 ways
- By defining FS_METHOD in your <code>wp-config.php</code> file
- By using the filesystem_method filter
Valid values for these are: 'direct', 'ssh', 'ftpext' or 'ftpsockets'
Plugins may also define a custom transport handler, See the WP_Filesystem function for more information.

param: array $args Connection details.
param: string $context Full path to the directory that is tested for being writable.
return: string The transport to use, see description for valid return values.

request_filesystem_credentials($form_post, $type = '', $error = false, $context = false, $extra_fields = null)   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 <code>request_filesystem_credentials</code> filter.

param: string $form_post the URL to post the form to
param: string $type the chosen Filesystem method in use
param: boolean $error if the current request has failed to connect
param: string $context The directory which is needed access to, The write-test will be performed on this directory by get_filesystem_method()
param: string $extra_fields Extra POST fields which should be checked for to be included in the post.
return: boolean False on failure. True on success.



Generated: Tue Mar 25 01:41:18 2014 WordPress honlapkészítés: online1.hu