X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/5d244c8fd9a27c9f89dd08da2af6fbc67d4fce63..refs/tags/wordpress-4.3:/wp-includes/functions.php diff --git a/wp-includes/functions.php b/wp-includes/functions.php index d903349c..30fac474 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -78,6 +78,8 @@ function current_time( $type, $gmt = 0 ) { * * @since 0.71 * + * @global WP_Locale $wp_locale + * * @param string $dateformatstring Format to display the date. * @param bool|int $unixtimestamp Optional. Unix timestamp. Default false. * @param bool $gmt Optional. Whether to use GMT timezone. Default false. @@ -161,6 +163,8 @@ function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { * * @since 2.3.0 * + * @global WP_Locale $wp_locale + * * @param int $number The number to convert based on locale. * @param int $decimals Optional. Precision of the number of decimal places. Default 0. * @return string Converted number in string format. @@ -182,7 +186,7 @@ function number_format_i18n( $number, $decimals = 0 ) { /** * Convert number of bytes largest unit bytes will fit into. * - * It is easier to read 1kB than 1024 bytes and 1MB than 1048576 bytes. Converts + * It is easier to read 1 kB than 1024 bytes and 1 MB than 1048576 bytes. Converts * number of bytes to human readable number by taking the number of that unit * that the bytes will go into it. Supports TB value. * @@ -206,11 +210,14 @@ function size_format( $bytes, $decimals = 0 ) { 'GB' => 1073741824, // pow( 1024, 3) 'MB' => 1048576, // pow( 1024, 2) 'kB' => 1024, // pow( 1024, 1) - 'B ' => 1, // pow( 1024, 0) + 'B' => 1, // pow( 1024, 0) ); - foreach ( $quant as $unit => $mag ) - if ( doubleval($bytes) >= $mag ) + + foreach ( $quant as $unit => $mag ) { + if ( doubleval( $bytes ) >= $mag ) { return number_format_i18n( $bytes / $mag, $decimals ) . ' ' . $unit; + } + } return false; } @@ -378,6 +385,7 @@ function maybe_serialize( $data ) { // Double serialization is required for backward compatibility. // See https://core.trac.wordpress.org/ticket/12930 + // Also the world will end. See WP 3.6.1. if ( is_serialized( $data, false ) ) return serialize( $data ); @@ -487,10 +495,10 @@ function wp_extract_urls( $content ) { * * @since 1.5.0 * - * @see $wpdb + * @global wpdb $wpdb * * @param string $content Post Content. - * @param int $post_ID Post ID. + * @param int $post_ID Post ID. */ function do_enclose( $content, $post_ID ) { global $wpdb; @@ -700,7 +708,7 @@ function _http_build_query( $data, $prefix = null, $sep = null, $key = '', $urle $k = $key . '%5B' . $k . '%5D'; if ( $v === null ) continue; - elseif ( $v === FALSE ) + elseif ( $v === false ) $v = '0'; if ( is_array($v) || is_object($v) ) @@ -778,8 +786,9 @@ function add_query_arg() { wp_parse_str( $query, $qs ); $qs = urlencode_deep( $qs ); // this re-URL-encodes things that were already in the query string if ( is_array( $args[0] ) ) { - $kayvees = $args[0]; - $qs = array_merge( $qs, $kayvees ); + foreach ( $args[0] as $k => $v ) { + $qs[ $k ] = $v; + } } else { $qs[ $args[0] ] = $args[1]; } @@ -866,7 +875,11 @@ function wp_remote_fopen( $uri ) { * * @since 2.0.0 * - * @param string $query_vars Default WP_Query arguments. + * @global WP $wp_locale + * @global WP_Query $wp_query + * @global WP_Query $wp_the_query + * + * @param string|array $query_vars Default WP_Query arguments. */ function wp( $query_vars = '' ) { global $wp, $wp_query, $wp_the_query; @@ -881,6 +894,8 @@ function wp( $query_vars = '' ) { * * @since 2.3.0 * + * @global array $wp_header_to_desc + * * @param int $code HTTP status code. * @return string Empty string if not found, or description if found. */ @@ -1120,7 +1135,7 @@ function bool_from_yn( $yn ) { * * @since 2.1.0 * - * @uses $wp_query Used to tell if the use a comment feed. + * @global WP_Query $wp_query Used to tell if the use a comment feed. */ function do_feed() { global $wp_query; @@ -1434,7 +1449,7 @@ function wp_get_referer() { $ref = false; if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) $ref = wp_unslash( $_REQUEST['_wp_http_referer'] ); - else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) + elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) $ref = wp_unslash( $_SERVER['HTTP_REFERER'] ); if ( $ref && $ref !== wp_unslash( $_SERVER['REQUEST_URI'] ) ) @@ -1469,7 +1484,7 @@ function wp_mkdir_p( $target ) { $wrapper = null; // Strip the protocol. - if( wp_is_stream( $target ) ) { + if ( wp_is_stream( $target ) ) { list( $wrapper, $target ) = explode( '://', $target, 2 ); } @@ -1477,7 +1492,7 @@ function wp_mkdir_p( $target ) { $target = str_replace( '//', '/', $target ); // Put the wrapper back on the target. - if( $wrapper !== null ) { + if ( $wrapper !== null ) { $target = $wrapper . '://' . $target; } @@ -1513,7 +1528,7 @@ function wp_mkdir_p( $target ) { */ if ( $dir_perms != ( $dir_perms & ~umask() ) ) { $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); - for ( $i = 1; $i <= count( $folder_parts ); $i++ ) { + for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) { @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms ); } } @@ -1601,10 +1616,12 @@ function wp_normalize_path( $path ) { * * @since 2.5.0 * + * @staticvar string $temp + * * @return string Writable temporary directory. */ function get_temp_dir() { - static $temp; + static $temp = ''; if ( defined('WP_TEMP_DIR') ) return trailingslashit(WP_TEMP_DIR); @@ -1625,8 +1642,7 @@ function get_temp_dir() { if ( is_dir( $temp ) && wp_is_writable( $temp ) ) return $temp; - $temp = '/tmp/'; - return $temp; + return '/tmp/'; } /** @@ -1667,11 +1683,11 @@ function wp_is_writable( $path ) { */ function win_is_writable( $path ) { - if ( $path[strlen( $path ) - 1] == '/' ) // if it looks like a directory, check a random file within the directory + if ( $path[strlen( $path ) - 1] == '/' ) { // if it looks like a directory, check a random file within the directory return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp'); - else if ( is_dir( $path ) ) // If it's a directory (and not a file) check a random file within the directory + } elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); - + } // check tmp file for read/write capabilities $should_delete_tmp_file = !file_exists( $path ); $f = @fopen( $path, 'a' ); @@ -1996,8 +2012,7 @@ function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { * @since 2.5.0 * * @param string $ext The extension to search. - * @return string|null The file type, example: audio, video, document, spreadsheet, etc. - * Null if not found. + * @return string|void The file type, example: audio, video, document, spreadsheet, etc. */ function wp_ext2type( $ext ) { $ext = strtolower( $ext ); @@ -2016,7 +2031,7 @@ function wp_ext2type( $ext ) { 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), - 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd' ), + 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), @@ -2027,8 +2042,6 @@ function wp_ext2type( $ext ) { foreach ( $ext2type as $type => $exts ) if ( in_array( $ext, $exts ) ) return $type; - - return null; } /** @@ -2080,7 +2093,6 @@ function wp_check_filetype( $filename, $mimes = null ) { * if original $filename is valid. */ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { - $proper_filename = false; // Do basic extension validation and MIME mapping @@ -2153,6 +2165,7 @@ function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { * Retrieve list of mime types and file extensions. * * @since 3.5.0 + * @since 4.2.0 Support was added for GIMP (xcf) files. * * @return array Array of mime types keyed by the file extension regex corresponding to those types. */ @@ -2174,7 +2187,7 @@ function wp_get_mime_types() { 'gif' => 'image/gif', 'png' => 'image/png', 'bmp' => 'image/bmp', - 'tif|tiff' => 'image/tiff', + 'tiff|tif' => 'image/tiff', 'ico' => 'image/x-icon', // Video formats. 'asf|asx' => 'video/x-ms-asf', @@ -2224,6 +2237,7 @@ function wp_get_mime_types() { '7z' => 'application/x-7z-compressed', 'exe' => 'application/x-msdownload', 'psd' => 'application/octet-stream', + 'xcf' => 'application/octet-stream', // MS Office formats. 'doc' => 'application/msword', 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', @@ -2467,6 +2481,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { > + <?php echo $title ?>