phpdoc for general functions. See #5639 props jacobsantos.

git-svn-id: https://develop.svn.wordpress.org/trunk@8606 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Peter Westwood 2008-08-10 16:45:50 +00:00
parent fa3d304307
commit a6e4e79f3a

View File

@ -86,7 +86,7 @@ function mysql2date( $dateformatstring, $mysqlstring, $translate = true ) {
*
* @param string $type Either 'mysql' or 'timestamp'.
* @param int|bool $gmt Optional. Whether to use $gmt offset. Default is false.
* @return unknown
* @return int|string String if $type is 'gmt', int if $type is 'timestamp'.
*/
function current_time( $type, $gmt = 0 ) {
switch ( $type ) {
@ -176,7 +176,7 @@ function number_format_i18n( $number, $decimals = null ) {
*
* @param int|string $bytes Number of bytes. Note max integer size for integers.
* @param int $decimals Precision of number of decimal places.
* @return unknown
* @return bool|string False on failure. Number string on success.
*/
function size_format( $bytes, $decimals = null ) {
$quant = array(
@ -317,6 +317,9 @@ function is_serialized_string( $data ) {
* There is a second filter called 'option_$option' with the $option being
* replaced with the option name. This gives the value as the only parameter.
*
* If the option was serialized, when the option was added and, or updated, then
* it will be unserialized, when it is returned.
*
* @since 1.5.0
* @package WordPress
* @subpackage Option
@ -379,7 +382,8 @@ function get_option( $setting ) {
/**
* Protect WordPress special option from being modified.
*
* Will die if $option is in protected list.
* Will die if $option is in protected list. Protected options are 'alloptions'
* and 'notoptions' options.
*
* @since 2.2.0
* @package WordPress
@ -473,6 +477,10 @@ function wp_load_alloptions() {
/**
* Update the value of an option that was already added.
*
* You do not need to serialize values, if the value needs to be serialize, then
* it will be serialized before it is inserted into the database. Remember,
* resources can not be serialized or added as an option.
*
* If the option does not exist, then the option will be added with the option
* value, but you will not be able to set whether it is autoloaded. If you want
* to set whether an option autoloaded, then you need to use the add_option().
@ -539,6 +547,10 @@ function update_option( $option_name, $newvalue ) {
/**
* Add a new option.
*
* You do not need to serialize values, if the value needs to be serialize, then
* it will be serialized before it is inserted into the database. Remember,
* resources can not be serialized or added as an option.
*
* You can create options without values and then add values later. Does not
* check whether the option has already been added, but does check that you
* aren't adding a protected WordPress option. Care should be taken to not name
@ -602,7 +614,7 @@ function add_option( $name, $value = '', $deprecated = '', $autoload = 'yes' ) {
*
* @package WordPress
* @subpackage Option
* @since unknown
* @since 1.2.0
*
* @param string $name Option name to remove.
* @return bool True, if succeed. False, if failure.
@ -634,6 +646,8 @@ function delete_option( $name ) {
/**
* Serialize data, if needed.
*
* @since 2.0.5
*
* @param mixed $data Data that might be serialized.
* @return mixed A scalar data
*/
@ -653,7 +667,7 @@ function maybe_serialize( $data ) {
* Searches for all of the links, strips them out of the content, and places
* them at the bottom of the content with numbers.
*
* @since unknown
* @since 0.71
*
* @param string $content Content to get links
* @return string HTML stripped out of content with links at the bottom.
@ -685,7 +699,7 @@ function make_url_footnote( $content ) {
*
* @package WordPress
* @subpackage XMLRPC
* @since unknown
* @since 0.71
*
* @global string $post_default_title Default XMLRPC post title.
*
@ -713,7 +727,7 @@ function xmlrpc_getposttitle( $content ) {
*
* @package WordPress
* @subpackage XMLRPC
* @since unknown
* @since 0.71
*
* @global string $post_default_category Default XMLRPC post category.
*
@ -736,7 +750,7 @@ function xmlrpc_getpostcategory( $content ) {
*
* @package WordPress
* @subpackage XMLRPC
* @since unknown
* @since 0.71
*
* @param string $content XMLRPC XML Request content
* @return string XMLRPC XML Request content without title and category elements.
@ -757,7 +771,7 @@ function xmlrpc_removepostdata( $content ) {
* @see fopen() for mode options.
* @package WordPress
* @subpackage Debug
* @since unknown
* @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param string $filename File path to debug file.
@ -782,7 +796,7 @@ function debug_fopen( $filename, $mode ) {
*
* @package WordPress
* @subpackage Debug
* @since unknown
* @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param resource $fp File handle for debugging file.
@ -802,7 +816,7 @@ function debug_fwrite( $fp, $string ) {
*
* @package WordPress
* @subpackage Debug
* @since unknown
* @since 0.71
* @uses $debug Used for whether debugging is enabled.
*
* @param resource $fp Debug File handle.
@ -813,6 +827,19 @@ function debug_fclose( $fp ) {
fclose( $fp );
}
/**
* {@internal Missing Short Description}}
*
* {@internal Missing Long Description}}
*
* @package WordPress
* @since 1.5.0
*
* @uses $wpdb
*
* @param string $content
* @param int $post_ID Post ID
*/
function do_enclose( $content, $post_ID ) {
global $wpdb;
include_once( ABSPATH . WPINC . '/class-IXR.php' );
@ -865,7 +892,7 @@ function do_enclose( $content, $post_ID ) {
* If $file_path is a writable filename, this will do a GET request and write
* the file to that path.
*
* @since unknown
* @since 2.5.0
*
* @param string $url
* @param string|bool $file_path Optional. File path to write request to.
@ -983,7 +1010,7 @@ function is_new_day() {
* @link http://us2.php.net/manual/en/function.http-build-query.php more on what
* http_build_query() does.
*
* @since unknown
* @since 2.3.0
*
* @param array $data URL-encode key/value pairs.
* @return string URL encoded string
@ -1096,6 +1123,7 @@ function remove_query_arg( $key, $query=false ) {
* Walks the array while sanitizing the contents.
*
* @uses $wpdb Used to sanitize values
* @since 0.71
*
* @param array $array Array to used to walk while sanitizing contents.
* @return array Sanitized $array.
@ -1119,7 +1147,7 @@ function add_magic_quotes( $array ) {
* Tries to retrieve the HTTP content with fopen first and then using cURL, if
* fopen can't be used.
*
* @since unknown
* @since 1.5.1
*
* @param string $uri URI/URL of web page to retrieve.
* @return string HTTP content.
@ -1244,7 +1272,7 @@ function get_status_header_desc( $code ) {
/**
* Set HTTP status header.
*
* @since unknown
* @since 2.0.0
* @uses apply_filters() Calls 'status_header' on status header string, HTTP
* HTTP code, HTTP code description, and protocol string as separate
* parameters.
@ -1458,6 +1486,8 @@ function is_blog_installed() {
/**
* Retrieve URL with nonce added to URL query.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param string $actionurl URL to add nonce action
@ -1469,6 +1499,39 @@ function wp_nonce_url( $actionurl, $action = -1 ) {
return wp_specialchars( add_query_arg( '_wpnonce', wp_create_nonce( $action ), $actionurl ) );
}
/**
* Retrieve or display nonce hidden field for forms.
*
* The nonce field is used to validate that the contents of the form came from
* the location on the current site and not somewhere else. The nonce does not
* offer absolute protection, but should protect against most cases. It is very
* important to use nonce field in forms.
*
* If you set $echo to true and set $referer to true, then you will need to
* retrieve the {@link wp_referer_field() wp referer field}. If you have the
* $referer set to true and are echoing the nonce field, it will also echo the
* referer field.
*
* The $action and $name are optional, but if you want to have better security,
* it is strongly suggested to set those two parameters. It is easier to just
* call the function without any parameters, because validation of the nonce
* doesn't require any parameters, but since crackers know what the default is
* it won't be difficult for them to find a way around your nonce and cause
* damage.
*
* The input name will be whatever $name value you gave. The input value will be
* the nonce creation value.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param string $action Optional. Action name.
* @param string $name Optional. Nonce name.
* @param bool $referer Optional, default true. Whether to set the referer field for validation.
* @param bool $echo Optional, default true. Whether to display or return hidden form field.
* @return string Nonce field.
*/
function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $echo = true ) {
$name = attribute_escape( $name );
$nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />';
@ -1481,6 +1544,19 @@ function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true , $ec
return $nonce_field;
}
/**
* Retrieve or display referer hidden field for forms.
*
* The referer link is the current Request URI from the server super global. The
* input name is '_wp_http_referer', in case you wanted to check manually.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param bool $echo Whether to echo or return the referer field.
* @return string Referer field.
*/
function wp_referer_field( $echo = true) {
$ref = attribute_escape( $_SERVER['REQUEST_URI'] );
$referer_field = '<input type="hidden" name="_wp_http_referer" value="'. $ref . '" />';
@ -1490,6 +1566,21 @@ function wp_referer_field( $echo = true) {
return $referer_field;
}
/**
* Retrieve or display original referer hidden field for forms.
*
* The input name is '_wp_original_http_referer' and will be either the same
* value of {@link wp_referer_field()}, if that was posted already or it will
* be the current page, if it doesn't exist.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param bool $echo Whether to echo the original http referer
* @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
* @return string Original referer field.
*/
function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
$jump_back_to = ( 'previous' == $jump_back_to ) ? wp_get_referer() : $_SERVER['REQUEST_URI'];
$ref = ( wp_get_original_referer() ) ? wp_get_original_referer() : $jump_back_to;
@ -1499,6 +1590,15 @@ function wp_original_referer_field( $echo = true, $jump_back_to = 'current' ) {
return $orig_referer_field;
}
/**
* Retrieve referer from '_wp_http_referer', HTTP referer, or current page respectively.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @return string|bool False on failure. Referer URL on success.
*/
function wp_get_referer() {
$ref = '';
if ( ! empty( $_REQUEST['_wp_http_referer'] ) )
@ -1511,13 +1611,31 @@ function wp_get_referer() {
return false;
}
/**
* Retrieve original referer that was posted, if it exists.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @return string|bool False if no original referer or original referer if set.
*/
function wp_get_original_referer() {
if ( !empty( $_REQUEST['_wp_original_http_referer'] ) )
return $_REQUEST['_wp_original_http_referer'];
return false;
}
/**
* Recursive directory creation based on full path.
*
* Will attempt to set permissions on folders.
*
* @since 2.0.1
*
* @param string $target Full path to attempt to create.
* @return bool Whether the path was created or not. True if path already exists.
*/
function wp_mkdir_p( $target ) {
// from php.net/mkdir user contributed notes
$target = str_replace( '//', '/', $target );
@ -1544,7 +1662,7 @@ function wp_mkdir_p( $target ) {
/**
* Test if a give filesystem path is absolute ('/foo/bar', 'c:\windows').
*
* @since unknown
* @since 2.5.0
*
* @param string $path File path
* @return bool True if path is absolute, false is not absolute.
@ -1570,7 +1688,7 @@ function path_is_absolute( $path ) {
*
* If the $path is absolute, then it the full path is returned.
*
* @since unknown
* @since 2.5.0
*
* @param string $base
* @param string $path
@ -1584,14 +1702,37 @@ function path_join( $base, $path ) {
}
/**
* Get an array containing the current upload directory's path and url, or an error message.
* Get an array containing the current upload directory's path and url.
*
* {@internal Missing Long Description}}
* Checks the 'upload_path' option, which should be from the web root folder,
* and if it isn't empty it will be used. If it is empty, then the path will be
* 'WP_CONTENT_DIR/uploads'. If the 'UPLOADS' constant is defined, then it will
* override the 'upload_path' option and 'WP_CONTENT_DIR/uploads' path.
*
* The upload URL path is set either by the 'upload_url_path' option or by using
* the 'WP_CONTENT_URL' constant and appending '/uploads' to the path.
*
* If the 'uploads_use_yearmonth_folders' is set to true (checkbox if checked in
* the administration settings panel), then the time will be used. The format
* will be year first and then month.
*
* If the path couldn't be created, then an error will be returned with the key
* 'error' containing the error message. The error suggests that the parent
* directory is not writable by the server.
*
* On success, the returned array will have many indices:
* 'path' - base directory and sub directory or full path to upload directory.
* 'url' - base url and sub directory or absolute URL to upload directory.
* 'subdir' - sub directory if uploads use year/month folders option is on.
* 'basedir' - path without subdir.
* 'baseurl' - URL path without subdir.
* 'error' - set to false.
*
* @since 2.0.0
* @uses apply_filters() Calls 'upload_dir' on returned array.
*
* @param unknown_type $time
* @return unknown
* @param string $time Optional. Time formatted in 'yyyy/mm'.
* @return array See above for description.
*/
function wp_upload_dir( $time = null ) {
$siteurl = get_option( 'siteurl' );
@ -1647,14 +1788,19 @@ function wp_upload_dir( $time = null ) {
/**
* Get a filename that is sanitized and unique for the given directory.
*
* {@internal Missing Long Description}}
* If the filename is not unique, then a number will be added to the filename
* before the extension, and will continue adding numbers until the filename is
* unique.
*
* The callback must accept two parameters, the first one is the directory and
* the second is the filename. The callback must be a function.
*
* @since 2.5
*
* @param string $dir
* @param string $filename
* @param string $unique_filename_callback Function name
* @return unknown
* @param string $unique_filename_callback Function name, must be a function.
* @return string New filename, if given wasn't unique.
*/
function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) {
$filename = strtolower( $filename );
@ -1693,6 +1839,29 @@ function wp_unique_filename( $dir, $filename, $unique_filename_callback = null )
return $filename;
}
/**
* Create a file in the upload folder with given content.
*
* If there is an error, then the key 'error' will exist with the error message.
* If success, then the key 'file' will have the unique file path, the 'url' key
* will have the link to the new file. and the 'error' key will be set to false.
*
* This function will not move an uploaded file to the upload folder. It will
* create a new file with the content in $bits parameter. If you move the upload
* file, read the content of the uploaded file, and then you can give the
* filename and content to this function, which will add it to the upload
* folder.
*
* The permissions will be set on the new file automatically by this function.
*
* @since 2.0.0
*
* @param string $name
* @param null $deprecated Not used. Set to null.
* @param mixed $bits File content
* @param string $time Optional. Time formatted in 'yyyy/mm'.
* @return array
*/
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
if ( empty( $name ) )
return array( 'error' => __( "Empty filename" ) );
@ -1736,7 +1905,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
* Retrieve the file type based on the extension name.
*
* @package WordPress
* @since unknown
* @since 2.5.0
* @uses apply_filters() Calls 'ext2type' hook on default supported types.
*
* @param string $ext The extension to search.
@ -1849,6 +2018,8 @@ function wp_check_filetype( $filename, $mimes = null ) {
* hook are the localized "Are you sure you want to do this?" message with the
* extra text (the text after the underscore).
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param string $action Nonce action.
@ -1925,6 +2096,8 @@ function wp_explain_nonce( $action ) {
* If the action has the nonce explain message, then it will be displayed along
* with the "Are you sure?" message.
*
* @package WordPress
* @subpackage Security
* @since 2.0.4
*
* @param string $action The nonce action.
@ -2251,7 +2424,7 @@ function wp_ob_end_flush_all() {
* wp-admin/setup-config.php We must globalise $wpdb to ensure that it is
* defined globally by the inline code in wp-db.php.
*
* @since 2.5
* @since 2.5.0
* @global $wpdb WordPress Database Object
*/
function require_wp_db() {
@ -2273,7 +2446,10 @@ function require_wp_db() {
* search engines from caching the message. Custom DB messages should do the
* same.
*
* @since 2.5
* This function was backported to the the WordPress 2.3.2, but originally was
* added in WordPress 2.5.0.
*
* @since 2.3.2
* @uses $wpdb
*/
function dead_db() {
@ -2312,7 +2488,7 @@ function dead_db() {
/**
* Converts value to positive integer.
*
* @since 2.5
* @since 2.5.0
*
* @param mixed $maybeint Data you wish to have convered to an absolute integer
* @return int An absolute integer
@ -2327,7 +2503,7 @@ function absint( $maybeint ) {
* Determines if blog can be accessed over SSL by using cURL to access the site
* using the https in the siteurl. Requires cURL extension to work correctly.
*
* @since 2.5
* @since 2.5.0
*
* @return bool Whether or not SSL access is available
*/
@ -2357,7 +2533,7 @@ function url_is_accessable_via_ssl($url)
/**
* Secure URL, if available or the given URL.
*
* @since 2.5
* @since 2.5.0
*
* @param string $url Complete URL path with transport.
* @return string Secure or regular URL path.
@ -2384,7 +2560,7 @@ function atom_service_url_filter($url)
*
* @package WordPress
* @package Debug
* @since 2.5
* @since 2.5.0
* @access private
*
* @uses do_action() Calls 'deprecated_function_run' and passes the function name and what to use instead.
@ -2421,7 +2597,7 @@ function _deprecated_function($function, $version, $replacement=null) {
*
* @package WordPress
* @package Debug
* @since 2.5
* @since 2.5.0
* @access private
*
* @uses do_action() Calls 'deprecated_file_included' and passes the file name and what to use instead.
@ -2447,7 +2623,7 @@ function _deprecated_file($file, $version, $replacement=null) {
/**
* Is the server running earlier than 1.5.0 version of lighttpd
*
* @since unknown
* @since 2.5.0
*
* @return bool Whether the server is running lighttpd < 1.5.0
*/
@ -2460,7 +2636,7 @@ function is_lighttpd_before_150() {
/**
* Does the specified module exist in the apache config?
*
* @since unknown
* @since 2.5.0
*
* @param string $mod e.g. mod_rewrite
* @param bool $default The default return value if the module is not found
@ -2494,7 +2670,7 @@ function apache_mod_loaded($mod, $default = false) {
* character. A return value of '3' means that the file is not in the allowed
* files list.
*
* @since 2.6
* @since 1.2.0
*
* @param string $file File path.
* @param array $allowed_files List of allowed files.
@ -2519,7 +2695,7 @@ function validate_file( $file, $allowed_files = '' ) {
/**
* Determine if SSL is used.
*
* @since 2.6
* @since 2.6.0
*
* @return bool True if SSL, false if not used.
*/
@ -2530,7 +2706,7 @@ function is_ssl() {
/**
* Whether SSL login should be forced.
*
* @since 2.6
* @since 2.6.0
*
* @param string|bool $force Optional.
* @return bool True if forced, false if not forced.
@ -2550,7 +2726,7 @@ function force_ssl_login($force = '') {
/**
* Whether to force SSL used for the Administration Panels.
*
* @since 2.6
* @since 2.6.0
*
* @param string|bool $force
* @return bool True if forced, false if not forced.
@ -2573,7 +2749,7 @@ function force_ssl_admin($force = '') {
* Will remove wp-admin links to retrieve only return URLs not in the wp-admin
* directory.
*
* @since 2.6
* @since 2.6.0
*
* @return string
*/