Make WordPress Core

Ticket #26185: 26185.diff

File 26185.diff, 33.1 KB (added by morganestes, 11 years ago)
  • wp-includes/functions.php

     
    6969
    7070/**
    7171 * Retrieve the date in localized format, based on timestamp.
    72  *
    7372 * If the locale specifies the locale month and weekday, then the locale will
    7473 * take over the format for the date. If it isn't, then the date format string
    7574 * will be used instead.
     
    7675 *
    7776 * @since 0.71
    7877 *
    79  * @param string $dateformatstring Format to display the date.
    80  * @param int $unixtimestamp Optional. Unix timestamp.
    81  * @param bool $gmt Optional, default is false. Whether to convert to GMT for time.
     78 * @param string   $dateformatstring Format to display the date.
     79 * @param bool|int $unixtimestamp    Optional. Unix timestamp.
     80 * @param bool     $gmt              Optional, default is false. Whether to convert to GMT for time.
     81 *
    8282 * @return string The date, translated if locale specifies it.
    8383 */
    8484function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) {
     
    159159/**
    160160 * Convert number of bytes largest unit bytes will fit into.
    161161 *
    162  * It is easier to read 1kB than 1024 bytes and 1MB than 1048576 bytes. Converts
     162 * It is easier to read 1KB than 1024 bytes and 1MB than 1048576 bytes. Converts
    163163 * number of bytes to human readable number by taking the number of that unit
    164164 * that the bytes will go into it. Supports TB value.
    165165 *
     
    198198 *
    199199 * @since 0.71
    200200 *
    201  * @param string $mysqlstring Date or datetime field type from mysql.
    202  * @param int $start_of_week Optional. Start of the week as an integer.
     201 * @param string     $mysqlstring   Date or datetime field type from mysql.
     202 * @param int|string $start_of_week Optional. Start of the week as an integer.
     203 *
    203204 * @return array Keys are 'start' and 'end'.
    204205 */
    205206function get_weekstartend( $mysqlstring, $start_of_week = '' ) {
     
    355356 *
    356357 * @global string $post_default_title Default XMLRPC post title.
    357358 *
    358  * @param string $content XMLRPC XML Request content
    359  * @return string Post title
     359 * @param string $content XMLRPC XML Request content.
     360 * @return string Post title.
    360361 */
    361362function xmlrpc_getposttitle( $content ) {
    362363        global $post_default_title;
     
    381382 *
    382383 * @global string $post_default_category Default XMLRPC post category.
    383384 *
    384  * @param string $content XMLRPC XML Request content
     385 * @param string $content XMLRPC XML Request content.
    385386 * @return string|array List of categories or category name.
    386387 */
    387388function xmlrpc_getpostcategory( $content ) {
     
    402403 * @subpackage XMLRPC
    403404 * @since 0.71
    404405 *
    405  * @param string $content XMLRPC XML Request content
     406 * @param string $content XMLRPC XML Request content.
    406407 * @return string XMLRPC XML Request content without title and category elements.
    407408 */
    408409function xmlrpc_removepostdata( $content ) {
     
    413414}
    414415
    415416/**
    416  * Use RegEx to extract URLs from arbitrary content
     417 * Use RegEx to extract URLs from arbitrary content.
    417418 *
    418419 * @since 3.7.0
    419420 *
    420421 * @param string $content
    421  * @return array URLs found in passed string
     422 * @return array URLs found in passed string.
    422423 */
    423424function wp_extract_urls( $content ) {
    424425        preg_match_all(
     
    444445 *
    445446 * @uses $wpdb
    446447 *
    447  * @param string $content Post Content
    448  * @param int $post_ID Post ID
     448 * @param string $content Post Content.
     449 * @param int $post_ID Post ID.
    449450 */
    450451function do_enclose( $content, $post_ID ) {
    451452        global $wpdb;
     
    591592 *
    592593 * @since 0.71
    593594 * @uses $day Today
    594  * @uses $previousday Previous day
     595 * @uses $previousday Previous day.
    595596 *
    596597 * @return int 1 when new day, 0 if not a new day.
    597598 */
     
    616617 * @since 2.3.0
    617618 *
    618619 * @param array $data URL-encode key/value pairs.
    619  * @return string URL encoded string
     620 * @return string URL-encoded string.
    620621 */
    621622function build_query( $data ) {
    622623        return _http_build_query( $data, null, '&', '', false );
    623624}
    624625
    625 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function)
     626/**
     627 * From php.net (modified by Mark Jaquith to behave like the native PHP5 function).
     628 *
     629 * @since 3.2.0
     630 * @link http://us1.php.net/manual/en/function.http-build-query.php
     631 *
     632 * @param array|object          $data An array or object of data. Converted to array.
     633 * @param string  $prefix Optional. Numeric index. If set, start parameter numbering with it.
     634 * @param string  $sep Optional. Argument separator; defaults to 'arg_separator.output'.
     635 * @param string        $key Optional. Used to prefix key name.
     636 * @param bool          $urlencode Optional. Whether to use {@link urlencode()} in the result.
     637 *
     638 * @return string The query string.
     639 */
    626640function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) {
    627641        $ret = array();
    628642
     
    801815 *
    802816 * @since 2.0.0
    803817 *
     818 * @global $wp
     819 * @global $wp_query
     820 * @global $wp_the_query
     821 *
    804822 * @param string $query_vars Default WP_Query arguments.
    805823 */
    806824function wp( $query_vars = '' ) {
     
    816834 *
    817835 * @since 2.3.0
    818836 *
     837 * @global $wp_header_to_desc
     838 *
    819839 * @param int $code HTTP status code.
    820840 * @return string Empty string if not found, or description if found.
    821841 */
     
    918938 * Gets the header information to prevent caching.
    919939 *
    920940 * The several different headers cover the different ways cache prevention is handled
    921  * by different browsers
     941 * by different browsers.
    922942 *
    923943 * @since 2.8.0
    924944 *
     
    9871007 *
    9881008 * @since 2.0.0
    9891009 *
    990  * @return int Number of database queries
     1010 * @global $wpdb
     1011 *
     1012 * @return int Number of database queries.
    9911013 */
    9921014function get_num_queries() {
    9931015        global $wpdb;
     
    9991021 *
    10001022 * @since 1.0.0
    10011023 *
    1002  * @param string $yn Character string containing either 'y' or 'n'
    1003  * @return bool True if yes, false on anything else
     1024 * @param string $yn Character string containing either 'y' or 'n'.
     1025 * @return bool True if yes, false on anything else.
    10041026 */
    10051027function bool_from_yn( $yn ) {
    10061028        return ( strtolower( $yn ) == 'y' );
     
    10151037 * It is better to only have one hook for each feed.
    10161038 *
    10171039 * @since 2.1.0
    1018  * @uses $wp_query Used to tell if the use a comment feed.
     1040 *
     1041 * @global $wp_query Used to tell if the use a comment feed.
    10191042 * @uses do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed.
    10201043 */
    10211044function do_feed() {
     
    11351158 * Checks for the option siteurl for whether WordPress is installed.
    11361159 *
    11371160 * @since 2.1.0
    1138  * @uses $wpdb
    11391161 *
     1162 * @global $wpdb
     1163 *
    11401164 * @return bool Whether blog is already installed.
    11411165 */
    11421166function is_blog_installed() {
     
    12891313 * @subpackage Security
    12901314 * @since 2.0.4
    12911315 *
    1292  * @param bool $echo Whether to echo the original http referer
     1316 * @param bool $echo Whether to echo the original http referer.
    12931317 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to.
    12941318 * @return string Original referer field.
    12951319 */
     
    14021426 *
    14031427 * @since 2.5.0
    14041428 *
    1405  * @param string $path File path
     1429 * @param string $path File path to check.
    14061430 * @return bool True if path is absolute, false is not absolute.
    14071431 */
    14081432function path_is_absolute( $path ) {
     
    14431467 * Determines a writable directory for temporary files.
    14441468 * Function's preference is the return value of <code>sys_get_temp_dir()</code>,
    14451469 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR,
    1446  * before finally defaulting to /tmp/
     1470 * before finally defaulting to /tmp/.
    14471471 *
    14481472 * In the event that this function does not find a writable location,
    14491473 * It may be overridden by the <code>WP_TEMP_DIR</code> constant in
     
    14511475 *
    14521476 * @since 2.5.0
    14531477 *
    1454  * @return string Writable temporary directory
     1478 * @return string Writable temporary directory.
    14551479 */
    14561480function get_temp_dir() {
    14571481        static $temp;
     
    14891513 *
    14901514 * @since 3.6.0
    14911515 *
    1492  * @param string $path
    1493  * @return bool
     1516 * @param string $path Path to directory to check.
     1517 * @return bool True if writable, false if not writable.
    14941518 */
    14951519function wp_is_writable( $path ) {
    14961520        if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) )
     
    15001524}
    15011525
    15021526/**
    1503  * Workaround for Windows bug in is_writable() function
     1527 * Workaround for Windows bug in is_writable() function.
    15041528 *
    15051529 * PHP has issues with Windows ACL's for determine if a
    15061530 * directory is writable or not, this works around them by
     
    15121536 *
    15131537 * @since 2.8.0
    15141538 *
    1515  * @param string $path
    1516  * @return bool
     1539 * @param string $path Path to directory to check.
     1540 * @return bool True if writable, false if not writable.
    15171541 */
    15181542function win_is_writable( $path ) {
    15191543
     
    17511775 *
    17521776 * @since 2.0.0
    17531777 *
    1754  * @param string $name
     1778 * @param string $name Name of the file to create.
    17551779 * @param null $deprecated Never used. Set to null.
    1756  * @param mixed $bits File content
     1780 * @param mixed $bits File content.
    17571781 * @param string $time Optional. Time formatted in 'yyyy/mm'.
    1758  * @return array
     1782 * @return array On success: file path and url; on error: error details.
    17591783 */
    17601784function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
    17611785        if ( !empty( $deprecated ) )
     
    18851909 * @since 3.0.0
    18861910 *
    18871911 * @param string $file Full path to the file.
    1888  * @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory)
     1912 * @param string $filename The name of the file (may differ from $file due to $file being in a tmp directory).
    18891913 * @param array $mimes Optional. Key is the file extension with value as the mime type.
    1890  * @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid
     1914 * @return array Values for the extension, MIME, and either a corrected filename or false if original $filename is valid.
    18911915 */
    18921916function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
    18931917
     
    19461970 *
    19471971 * @since 3.5.0
    19481972 *
    1949  * @uses apply_filters() Calls 'mime_types' on returned array. This filter should
    1950  * be used to add types, not remove them. To remove types use the upload_mimes filter.
     1973 * @uses apply_filters() Calls 'mime_types' on returned array.
     1974 *                                                                                       This filter should be used to add types, not remove them.
     1975 *                                                                                       To remove types use the upload_mimes filter.
    19511976 *
    19521977 * @return array Array of mime types keyed by the file extension regex corresponding to those types.
    19531978 */
     
    20522077 *
    20532078 * @since 2.8.6
    20542079 *
    2055  * @uses apply_filters() Calls 'upload_mimes' on returned array
    2056  * @uses wp_get_upload_mime_types() to fetch the list of mime types
     2080 * @uses apply_filters() Calls 'upload_mimes' on returned array.
     2081 * @uses wp_get_upload_mime_types() to fetch the list of mime types.
    20572082 *
    20582083 * @param int|WP_User $user Optional. User to check. Defaults to current user.
    20592084 * @return array Array of mime types keyed by the file extension regex corresponding to those types.
     
    21272152 * Kill WordPress execution and display HTML message with error message.
    21282153 *
    21292154 * This is the default handler for wp_die if you want a custom one for your
    2130  * site then you can overload using the wp_die_handler filter in wp_die
     2155 * site then you can overload using the wp_die_handler filter in wp_die.
    21312156 *
    21322157 * @since 3.0.0
    21332158 * @access private
     
    23102335 * @since 3.2.0
    23112336 * @access private
    23122337 *
     2338 * @global $wp_xmlrpc_server
     2339 *
    23132340 * @param string $message Error message.
    23142341 * @param string $title Error title.
    23152342 * @param string|array $args Optional arguments to control behavior.
     
    24182445 * @package WordPress
    24192446 * @since 2.2.0
    24202447 *
    2421  * @param string $url URL for the home location
     2448 * @param string $url URL for the home location.
    24222449 * @return string Homepage location.
    24232450 */
    24242451function _config_wp_home( $url = '' ) {
     
    24392466 * @since 2.2.0
    24402467 *
    24412468 * @param string $url URL to set the WordPress site location.
    2442  * @return string The WordPress Site URL
     2469 * @return string The WordPress Site URL.
    24432470 */
    24442471function _config_wp_siteurl( $url = '' ) {
    24452472        if ( defined( 'WP_SITEURL' ) )
     
    25902617
    25912618/**
    25922619 * Merge user defined arguments into defaults array.
    2593  *
    25942620 * This function is used throughout WordPress to allow for both string or array
    25952621 * to be merged into another array.
    25962622 *
    25972623 * @since 2.2.0
    25982624 *
    2599  * @param string|array $args Value to merge with $defaults
    2600  * @param array $defaults Array that serves as the defaults.
     2625 * @param string|array $args     Value to merge with $defaults.
     2626 * @param array|string $defaults Optional. Array that serves as the defaults.
     2627 *
    26012628 * @return array Merged user defined values with defaults.
    26022629 */
    26032630function wp_parse_args( $args, $defaults = '' ) {
     
    26182645 *
    26192646 * @since 3.0.0
    26202647 *
    2621  * @param array|string $list
    2622  * @return array Sanitized array of IDs
     2648 * @param array|string $list List of IDs.
     2649 * @return array Sanitized array of IDs.
    26232650 */
    26242651function wp_parse_id_list( $list ) {
    26252652        if ( !is_array($list) )
     
    26332660 *
    26342661 * @since 3.1.0
    26352662 *
    2636  * @param array $array The original array
    2637  * @param array $keys The list of keys
    2638  * @return array The array slice
     2663 * @param array $array The original array.
     2664 * @param array $keys The list of keys.
     2665 * @return array The array slice.
    26392666 */
    26402667function wp_array_slice_assoc( $array, $keys ) {
    26412668        $slice = array();
     
    26512678 *
    26522679 * @since 3.0.0
    26532680 *
    2654  * @param array $list An array of objects to filter
    2655  * @param array $args An array of key => value arguments to match against each object
     2681 * @param array $list An array of objects to filter.
     2682 * @param array $args An array of key => value arguments to match against each object.
    26562683 * @param string $operator The logical operation to perform. 'or' means only one element
    2657  *      from the array needs to match; 'and' means all elements must match. The default is 'and'.
    2658  * @param bool|string $field A field from the object to place instead of the entire object
    2659  * @return array A list of objects or object fields
     2684 *                                                                                               from the array needs to match; 'and' means all elements must match.
     2685 *                                                                                               The default is 'and'.
     2686 * @param bool|string $field A field from the object to place instead of the entire object.
     2687 * @return array A list of objects or object fields.
    26602688 */
    26612689function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) {
    26622690        if ( ! is_array( $list ) )
     
    26752703 *
    26762704 * @since 3.1.0
    26772705 *
    2678  * @param array $list An array of objects to filter
    2679  * @param array $args An array of key => value arguments to match against each object
     2706 * @param array $list An array of objects to filter.
     2707 * @param array $args An array of key => value arguments to match against each object.
    26802708 * @param string $operator The logical operation to perform:
    26812709 *    'AND' means all elements from the array must match;
    26822710 *    'OR' means only one element needs to match;
    26832711 *    'NOT' means no elements may match.
    26842712 *   The default is 'AND'.
    2685  * @return array
     2713 * @return array The filtered object list.
    26862714 */
    26872715function wp_list_filter( $list, $args = array(), $operator = 'AND' ) {
    26882716        if ( ! is_array( $list ) )
     
    27192747 *
    27202748 * @since 3.1.0
    27212749 *
    2722  * @param array $list A list of objects or arrays
    2723  * @param int|string $field A field from the object to place instead of the entire object
    2724  * @return array
     2750 * @param array $list A list of objects or arrays.
     2751 * @param int|string $field A field from the object to place instead of the entire object.
     2752 * @return array The filtered $list.
    27252753 */
    27262754function wp_list_pluck( $list, $field ) {
    27272755        foreach ( $list as $key => $value ) {
     
    27942822 * in WordPress 2.5.0.
    27952823 *
    27962824 * @since 2.3.2
    2797  * @uses $wpdb
     2825 * @global $wpdb
    27982826 */
    27992827function dead_db() {
    28002828        global $wpdb;
     
    28322860}
    28332861
    28342862/**
    2835  * Converts value to nonnegative integer.
     2863 * Converts value to non-negative integer.
    28362864 *
    28372865 * @since 2.5.0
    28382866 *
    2839  * @param mixed $maybeint Data you wish to have converted to a nonnegative integer
    2840  * @return int An nonnegative integer
     2867 * @param mixed $maybeint Data you wish to have converted to a non-negative integer.
     2868 * @return int An non-negative integer.
    28412869 */
    28422870function absint( $maybeint ) {
    28432871        return abs( intval( $maybeint ) );
     
    28512879 *
    28522880 * @since 2.5.0
    28532881 *
    2854  * @param string $url
    2855  * @return bool Whether SSL access is available
     2882 * @param string $url The URL of the blog to check.
     2883 * @return bool Whether SSL access is available.
    28562884 */
    28572885function url_is_accessable_via_ssl($url)
    28582886{
     
    28992927 * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do
    29002928 *   trigger or false to not trigger error.
    29012929 *
    2902  * @param string $function The function that was called
    2903  * @param string $version The version of WordPress that deprecated the function
    2904  * @param string $replacement Optional. The function that should have been called
     2930 * @param string $function The function that was called.
     2931 * @param string $version The version of WordPress that deprecated the function.
     2932 * @param string $replacement Optional. The function that should have been called.
    29052933 */
    29062934function _deprecated_function( $function, $version, $replacement = null ) {
    29072935
     
    29442972 * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do
    29452973 *   trigger or false to not trigger error.
    29462974 *
    2947  * @param string $file The file that was included
    2948  * @param string $version The version of WordPress that deprecated the file
    2949  * @param string $replacement Optional. The file that should have been included based on ABSPATH
    2950  * @param string $message Optional. A message regarding the change
     2975 * @param string $file The file that was included.
     2976 * @param string $version The version of WordPress that deprecated the file.
     2977 * @param string $replacement Optional. The file that should have been included based on ABSPATH.
     2978 * @param string $message Optional. A message regarding the change.
    29512979 */
    29522980function _deprecated_file( $file, $version, $replacement = null, $message = '' ) {
    29532981
     
    29773005 * used by comparing it to its default value or evaluating whether it is empty.
    29783006 * For example:
    29793007 * <code>
    2980  * if ( !empty($deprecated) )
     3008 * if ( ! empty( $deprecated ) )
    29813009 *      _deprecated_argument( __FUNCTION__, '3.0' );
    29823010 * </code>
    29833011 *
     
    29973025 * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do
    29983026 *   trigger or false to not trigger error.
    29993027 *
    3000  * @param string $function The function that was called
    3001  * @param string $version The version of WordPress that deprecated the argument used
     3028 * @param string $function The function that was called.
     3029 * @param string $version The version of WordPress that deprecated the argument used.
    30023030 * @param string $message Optional. A message regarding the change.
    30033031 */
    30043032function _deprecated_argument( $function, $version, $message = null ) {
     
    30793107 *
    30803108 * @since 2.5.0
    30813109 *
    3082  * @param string $mod e.g. mod_rewrite
    3083  * @param bool $default The default return value if the module is not found
    3084  * @return bool
     3110 * @param string $mod Module to check, e.g. mod_rewrite.
     3111 * @param bool $default The default return value if the module is not found.
     3112 * @return bool True if module loaded, false if not loaded.
    30853113 */
    30863114function apache_mod_loaded($mod, $default = false) {
    30873115        global $is_apache;
     
    31083136 *
    31093137 * @since 2.8.0
    31103138 *
    3111  * @return bool
     3139 * @return bool True if permalinks are supported, false if not supported.
    31123140 */
    31133141function iis7_supports_permalinks() {
    31143142        global $is_iis7;
     
    31323160
    31333161/**
    31343162 * File validates against allowed set of defined rules.
    3135  *
    31363163 * A return value of '1' means that the $file contains either '..' or './'. A
    31373164 * return value of '2' means that the $file contains ':' after the first
    31383165 * character. A return value of '3' means that the file is not in the allowed
     
    31403167 *
    31413168 * @since 1.2.0
    31423169 *
    3143  * @param string $file File path.
    3144  * @param array $allowed_files List of allowed files.
     3170 * @param string       $file          File path.
     3171 * @param array|string $allowed_files Optional. List of allowed files.
     3172 *
    31453173 * @return int 0 means nothing is wrong, greater than 0 means something was wrong.
    31463174 */
    31473175function validate_file( $file, $allowed_files = '' ) {
     
    32273255 *
    32283256 * @since 2.6.0
    32293257 *
    3230  * @return string
     3258 * @return string The best-guess URL of the site.
    32313259 */
    32323260function wp_guess_url() {
    32333261        if ( defined('WP_SITEURL') && '' != WP_SITEURL ) {
     
    32813309 * @since 3.3.0
    32823310 *
    32833311 * @param bool $suspend Optional. Suspends additions if true, re-enables them if false.
    3284  * @return bool The current suspend setting
     3312 * @return bool The current suspend setting.
    32853313 */
    32863314function wp_suspend_cache_addition( $suspend = null ) {
    32873315        static $_suspend = false;
     
    33013329 *
    33023330 * @since 2.7.0
    33033331 *
    3304  * @param bool $suspend Whether to suspend or enable cache invalidation
    3305  * @return bool The current suspend setting
     3332 * @param bool $suspend Whether to suspend or enable cache invalidation.
     3333 * @return bool The current suspend setting.
    33063334 */
    33073335function wp_suspend_cache_invalidation($suspend = true) {
    33083336        global $_wp_suspend_cache_invalidation;
     
    33383366 *
    33393367 * @since 3.7.0
    33403368 *
     3369 * @global $wpdb
     3370 *
    33413371 * @param int $network_id Optional. Network ID to test. Defaults to current network.
    33423372 * @return bool True if $network_id is the main network, or if not running multisite.
    33433373 */
     
    33773407 * @since 3.0.0
    33783408 * @package WordPress
    33793409 *
    3380  * @return bool True if multisite and global terms enabled
     3410 * @return bool True if multisite and global terms enabled.
    33813411 */
    33823412function global_terms_enabled() {
    33833413        if ( ! is_multisite() )
     
    34013431 *
    34023432 * @since 2.8.0
    34033433 *
    3404  * @return float|bool
     3434 * @return float|bool Timezone offset; false if not set or if any errors.
    34053435 */
    34063436function wp_timezone_override_offset() {
    34073437        if ( !$timezone_string = get_option( 'timezone_string' ) ) {
     
    34233453 *
    34243454 * @param array $a
    34253455 * @param array $b
    3426  * @return int
     3456 * @return int Less than 0 if $ is greater, 0 if equal, greater than 0 if $b is greater.
    34273457 */
    34283458function _wp_timezone_choice_usort_callback( $a, $b ) {
    34293459        // Don't use translated versions of Etc
     
    34683498 *
    34693499 * @since 2.9.0
    34703500 *
    3471  * @param string $selected_zone Selected Zone
    3472  * @return string
     3501 * @param string $selected_zone Selected Zone.
     3502 * @return string Formatted timezones.
    34733503 */
    34743504function wp_timezone_choice( $selected_zone ) {
    34753505        static $mo_loaded = false;
     
    35943624
    35953625/**
    35963626 * Strip close comment and close php tags from file headers used by WP.
    3597  * See http://core.trac.wordpress.org/ticket/8497
    35983627 *
    35993628 * @since 2.8.0
     3629 * @link http://core.trac.wordpress.org/ticket/8497
    36003630 *
    3601  * @param string $str
    3602  * @return string
     3631 * @param string $str String to clean.
     3632 * @return string The cleaned-up string.
    36033633 */
    36043634function _cleanup_header_comment($str) {
    36053635        return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));
     
    36093639 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS.
    36103640 *
    36113641 * @since 2.9.0
     3642 *
     3643 * @global $wpdb
    36123644 */
    36133645function wp_scheduled_delete() {
    36143646        global $wpdb;
     
    36533685/**
    36543686 * Retrieve metadata from a file.
    36553687 *
    3656  * Searches for metadata in the first 8kiB of a file, such as a plugin or theme.
     3688 * Searches for metadata in the first 8KiB of a file, such as a plugin or theme.
    36573689 * Each piece of metadata must be on its own line. Fields can not span multiple
    36583690 * lines, the value will get cut at the end of the first line.
    36593691 *
    3660  * If the file data is not within that first 8kiB, then the author should correct
     3692 * If the file data is not within that first 8KiB, then the author should correct
    36613693 * their plugin file and move the data headers to the top.
    36623694 *
    3663  * @see http://codex.wordpress.org/File_Header
     3695 * @link http://codex.wordpress.org/File_Header
    36643696 *
    36653697 * @since 2.9.0
    3666  * @param string $file Path to the file
    3667  * @param array $default_headers List of headers, in the format array('HeaderKey' => 'Header Name')
    3668  * @param string $context If specified adds filter hook "extra_{$context}_headers"
     3698 *
     3699 * @param string $file Path to the file.
     3700 * @param array $default_headers {
     3701 *              An array of header values in themes and plugins.
     3702 *
     3703 *              @type string $key HeaderKey. Accepts string 'Header Name'.
     3704 * }
     3705 * @param string $context If specified adds filter hook "extra_{$context}_headers".
     3706 * @return array
    36693707 */
    36703708function get_file_data( $file, $default_headers, $context = '' ) {
    36713709        // We don't need to write to the file, so just open for reading.
    36723710        $fp = fopen( $file, 'r' );
    36733711
    3674         // Pull only the first 8kiB of the file in.
     3712        // Pull only the first 8KiB of the file in.
    36753713        $file_data = fread( $fp, 8192 );
    36763714
    36773715        // PHP will close file handle, but we are good citizens.
     
    37043742 *
    37053743 * @since 3.0.0
    37063744 * @see __return_false()
     3745 *
    37073746 * @return bool true
    37083747 */
    37093748function __return_true() {
     
    37173756 *
    37183757 * @since 3.0.0
    37193758 * @see __return_true()
     3759 *
    37203760 * @return bool false
    37213761 */
    37223762function __return_false() {
     
    37293769 * Useful for returning 0 to filters easily.
    37303770 *
    37313771 * @since 3.0.0
     3772 *
    37323773 * @return int 0
    37333774 */
    37343775function __return_zero() {
     
    37413782 * Useful for returning an empty array to filters easily.
    37423783 *
    37433784 * @since 3.0.0
    3744  * @return array Empty array
     3785 *
     3786 * @return array Empty array.
    37453787 */
    37463788function __return_empty_array() {
    37473789        return array();
     
    37533795 * Useful for returning null to filters easily.
    37543796 *
    37553797 * @since 3.4.0
     3798 *
    37563799 * @return null
    37573800 */
    37583801function __return_null() {
     
    37663809 *
    37673810 * @since 3.7.0
    37683811 * @see __return_null()
     3812 *
    37693813 * @return string Empty string
    37703814 */
    37713815function __return_empty_string() {
     
    37793823 * @link http://src.chromium.org/viewvc/chrome?view=rev&revision=6985
    37803824 *
    37813825 * @since 3.0.0
    3782  * @return none
    37833826 */
    37843827function send_nosniff_header() {
    37853828        @header( 'X-Content-Type-Options: nosniff' );
     
    37903833 *
    37913834 * @internal
    37923835 * @since 3.0.0
     3836 *
    37933837 * @param string $column
    37943838 * @return string
    37953839 */
     
    38123856/**
    38133857 * Finds hierarchy loops using a callback function that maps object IDs to parent IDs.
    38143858 *
     3859 * @access private
    38153860 * @since 3.1.0
    3816  * @access private
    38173861 *
    3818  * @param callback $callback function that accepts ( ID, $callback_args ) and outputs parent_ID
    3819  * @param int $start The ID to start the loop check at
    3820  * @param int $start_parent the parent_ID of $start to use instead of calling $callback( $start ). Use null to always use $callback
    3821  * @param array $callback_args optional additional arguments to send to $callback
    3822  * @return array IDs of all members of loop
     3862 * @param callback $callback function that accepts ( ID, $callback_args ) and outputs parent_ID.
     3863 * @param int $start The ID to start the loop check.
     3864 * @param int $start_parent the parent_ID of $start to use instead of calling $callback( $start ).
     3865 *              Use null to always use $callback.
     3866 * @param array $callback_args optional additional arguments to send to $callback.
     3867 * @return array IDs of all members of loop.
    38233868 */
    38243869function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) {
    38253870        $override = is_null( $start_parent ) ? array() : array( $start => $start_parent );
     
    38363881 * For every step of the algorithm, the hare takes two steps and the tortoise one.
    38373882 * If the hare ever laps the tortoise, there must be a loop.
    38383883 *
     3884 * @access private
    38393885 * @since 3.1.0
    3840  * @access private
    38413886 *
    3842  * @param callback $callback function that accepts ( ID, callback_arg, ... ) and outputs parent_ID
    3843  * @param int $start The ID to start the loop check at
    3844  * @param array $override an array of ( ID => parent_ID, ... ) to use instead of $callback
    3845  * @param array $callback_args optional additional arguments to send to $callback
     3887 * @param callback $callback Function that accepts ( ID, callback_arg, ... ) and outputs parent_ID.
     3888 * @param int $start The ID to start the loop check.
     3889 * @param array $override An array of ( ID => parent_ID, ... ) to use instead of $callback.
     3890 * @param array $callback_args Optional. Additional arguments to send to $callback.
    38463891 * @param bool $_return_loop Return loop members or just detect presence of loop?
    38473892 *             Only set to true if you already know the given $start is part of a loop
    3848  *             (otherwise the returned array might include branches)
    3849  * @return mixed scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if $_return_loop
     3893 *             (otherwise the returned array might include branches).
     3894 * @return mixed Scalar ID of some arbitrary member of the loop, or array of IDs of all members of loop if $_return_loop.
    38503895 */
    38513896function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) {
    38523897        $tortoise = $hare = $evanescent_hare = $start;
     
    38813926 * @link https://developer.mozilla.org/en/the_x-frame-options_response_header
    38823927 *
    38833928 * @since 3.1.3
    3884  * @return none
    38853929 */
    38863930function send_frame_options_header() {
    38873931        @header( 'X-Frame-Options: SAMEORIGIN' );
     
    39133957 * @link http://core.trac.wordpress.org/ticket/19589
    39143958 * @since 3.4.0
    39153959 *
    3916  * @param string $ignore_class A class to ignore all function calls within - useful when you want to just give info about the callee
    3917  * @param int $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue
    3918  * @param bool $pretty Whether or not you want a comma separated string or raw array returned
     3960 * @param string $ignore_class A class to ignore all function calls within -
     3961 *              useful when you want to just give info about the callee.
     3962 * @param int $skip_frames A number of stack frames to skip - useful for unwinding back to the source of the issue.
     3963 * @param bool $pretty Whether or not you want a comma separated string or raw array returned.
    39193964 * @return string|array Either a string containing a reversed comma separated trace or an array of individual calls.
    39203965 */
    39213966function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) {
     
    39533998}
    39543999
    39554000/**
    3956  * Retrieve ids that are not already present in the cache
     4001 * Retrieve IDs that are not already present in the cache.
    39574002 *
    39584003 * @since 3.4.0
    39594004 *
    3960  * @param array $object_ids ID list
    3961  * @param string $cache_key The cache bucket to check against
     4005 * @param array $object_ids ID list.
     4006 * @param string $cache_key The cache bucket to check against.
    39624007 *
    3963  * @return array
     4008 * @return array Cleaned up array of IDs.
    39644009 */
    39654010function _get_non_cached_ids( $object_ids, $cache_key ) {
    39664011        $clean = array();
     
    39774022/**
    39784023 * Test if the current device has the capability to upload files.
    39794024 *
     4025 * @access private
    39804026 * @since 3.4.0
    3981  * @access private
    39824027 *
    3983  * @return bool true|false
     4028 * @return bool True if the device allows uploads; false if not.
    39844029 */
    39854030function _device_can_upload() {
    39864031        if ( ! wp_is_mobile() )
     
    39984043}
    39994044
    40004045/**
    4001  * Test if a given path is a stream URL
     4046 * Test if a given path is a stream URL.
    40024047 *
    4003  * @param string $path The resource path or URL
    4004  * @return bool True if the path is a stream URL
     4048 * @param string $path The resource path or URL.
     4049 * @return bool True if the path is a stream URL.
    40054050 */
    40064051function wp_is_stream( $path ) {
    40074052        $wrappers = stream_get_wrappers();
     
    40114056}
    40124057
    40134058/**
    4014  * Test if the supplied date is valid for the Gregorian calendar
     4059 * Test if the supplied date is valid for the Gregorian calendar.
    40154060 *
    40164061 * @since 3.5.0
     4062 * @see checkdate()
    40174063 *
    4018  * @return bool true|false
     4064 * @param int $month
     4065 * @param int $day
     4066 * @param int $year
     4067 * @param $source_date
     4068 *
     4069 * @return bool True if valid date, false if not valid date.
    40194070 */
    40204071function wp_checkdate( $month, $day, $year, $source_date ) {
    40214072        return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date );
     
    40244075/**
    40254076 * Load the auth check for monitoring whether the user is still logged in.
    40264077 *
    4027  * Can be disabled with remove_action( 'admin_enqueue_scripts', 'wp_auth_check_load' );
     4078 * Can be disabled with `remove_action( 'admin_enqueue_scripts', 'wp_auth_check_load' );`.
    40284079 *
    40294080 * This is disabled for certain screens where a login screen could cause an
    40304081 * inconvenient interruption. A filter called wp_auth_check_load can be used
     
    40954146
    40964147/**
    40974148 * Check whether a user is still logged in, for the heartbeat.
    4098  *
    40994149 * Send a result that shows a log-in box if the user is no longer logged in,
    41004150 * or if their cookie is within the grace period.
    41014151 *
    41024152 * @since 3.6.0
     4153 *
     4154 * @param array $response
     4155 * @param       $data
     4156 *
     4157 * @return array
    41034158 */
    41044159function wp_auth_check( $response, $data ) {
    41054160        $response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] );
     
    41124167 * 2. Has no body but has a closing tag of the same name or
    41134168 * 3. Contains a body and a closing tag of the same name
    41144169 *
    4115  * Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML
     4170 * Note: this RegEx does not balance inner tags and does not attempt to produce valid HTML.
    41164171 *
    41174172 * @since 3.6.0
    41184173 *
    4119  * @param string $tag An HTML tag name. Example: 'video'
     4174 * @param string $tag An HTML tag name. Example: 'video'.
    41204175 * @return string
    41214176 */
    41224177function get_tag_regex( $tag ) {
     
    41324187 * @link http://core.trac.wordpress.org/ticket/23688
    41334188 * @since 3.6.0
    41344189 *
    4135  * @param string A charset name
    4136  * @return string The canonical form of the charset
     4190 * @param string $charset A charset name.
     4191 * @return string The canonical form of the charset.
    41374192 */
    41384193function _canonical_charset( $charset ) {
    41394194        if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset ||