Ticket #26185: 26185.diff
File 26185.diff, 33.1 KB (added by , 11 years ago) |
---|
-
wp-includes/functions.php
69 69 70 70 /** 71 71 * Retrieve the date in localized format, based on timestamp. 72 *73 72 * If the locale specifies the locale month and weekday, then the locale will 74 73 * take over the format for the date. If it isn't, then the date format string 75 74 * will be used instead. … … 76 75 * 77 76 * @since 0.71 78 77 * 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 * 82 82 * @return string The date, translated if locale specifies it. 83 83 */ 84 84 function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { … … 159 159 /** 160 160 * Convert number of bytes largest unit bytes will fit into. 161 161 * 162 * It is easier to read 1 kB than 1024 bytes and 1MB than 1048576 bytes. Converts162 * It is easier to read 1KB than 1024 bytes and 1MB than 1048576 bytes. Converts 163 163 * number of bytes to human readable number by taking the number of that unit 164 164 * that the bytes will go into it. Supports TB value. 165 165 * … … 198 198 * 199 199 * @since 0.71 200 200 * 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 * 203 204 * @return array Keys are 'start' and 'end'. 204 205 */ 205 206 function get_weekstartend( $mysqlstring, $start_of_week = '' ) { … … 355 356 * 356 357 * @global string $post_default_title Default XMLRPC post title. 357 358 * 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. 360 361 */ 361 362 function xmlrpc_getposttitle( $content ) { 362 363 global $post_default_title; … … 381 382 * 382 383 * @global string $post_default_category Default XMLRPC post category. 383 384 * 384 * @param string $content XMLRPC XML Request content 385 * @param string $content XMLRPC XML Request content. 385 386 * @return string|array List of categories or category name. 386 387 */ 387 388 function xmlrpc_getpostcategory( $content ) { … … 402 403 * @subpackage XMLRPC 403 404 * @since 0.71 404 405 * 405 * @param string $content XMLRPC XML Request content 406 * @param string $content XMLRPC XML Request content. 406 407 * @return string XMLRPC XML Request content without title and category elements. 407 408 */ 408 409 function xmlrpc_removepostdata( $content ) { … … 413 414 } 414 415 415 416 /** 416 * Use RegEx to extract URLs from arbitrary content 417 * Use RegEx to extract URLs from arbitrary content. 417 418 * 418 419 * @since 3.7.0 419 420 * 420 421 * @param string $content 421 * @return array URLs found in passed string 422 * @return array URLs found in passed string. 422 423 */ 423 424 function wp_extract_urls( $content ) { 424 425 preg_match_all( … … 444 445 * 445 446 * @uses $wpdb 446 447 * 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. 449 450 */ 450 451 function do_enclose( $content, $post_ID ) { 451 452 global $wpdb; … … 591 592 * 592 593 * @since 0.71 593 594 * @uses $day Today 594 * @uses $previousday Previous day 595 * @uses $previousday Previous day. 595 596 * 596 597 * @return int 1 when new day, 0 if not a new day. 597 598 */ … … 616 617 * @since 2.3.0 617 618 * 618 619 * @param array $data URL-encode key/value pairs. 619 * @return string URL encoded string620 * @return string URL-encoded string. 620 621 */ 621 622 function build_query( $data ) { 622 623 return _http_build_query( $data, null, '&', '', false ); 623 624 } 624 625 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 */ 626 640 function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) { 627 641 $ret = array(); 628 642 … … 801 815 * 802 816 * @since 2.0.0 803 817 * 818 * @global $wp 819 * @global $wp_query 820 * @global $wp_the_query 821 * 804 822 * @param string $query_vars Default WP_Query arguments. 805 823 */ 806 824 function wp( $query_vars = '' ) { … … 816 834 * 817 835 * @since 2.3.0 818 836 * 837 * @global $wp_header_to_desc 838 * 819 839 * @param int $code HTTP status code. 820 840 * @return string Empty string if not found, or description if found. 821 841 */ … … 918 938 * Gets the header information to prevent caching. 919 939 * 920 940 * The several different headers cover the different ways cache prevention is handled 921 * by different browsers 941 * by different browsers. 922 942 * 923 943 * @since 2.8.0 924 944 * … … 987 1007 * 988 1008 * @since 2.0.0 989 1009 * 990 * @return int Number of database queries 1010 * @global $wpdb 1011 * 1012 * @return int Number of database queries. 991 1013 */ 992 1014 function get_num_queries() { 993 1015 global $wpdb; … … 999 1021 * 1000 1022 * @since 1.0.0 1001 1023 * 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. 1004 1026 */ 1005 1027 function bool_from_yn( $yn ) { 1006 1028 return ( strtolower( $yn ) == 'y' ); … … 1015 1037 * It is better to only have one hook for each feed. 1016 1038 * 1017 1039 * @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. 1019 1042 * @uses do_action() Calls 'do_feed_$feed' hook, if a hook exists for the feed. 1020 1043 */ 1021 1044 function do_feed() { … … 1135 1158 * Checks for the option siteurl for whether WordPress is installed. 1136 1159 * 1137 1160 * @since 2.1.0 1138 * @uses $wpdb1139 1161 * 1162 * @global $wpdb 1163 * 1140 1164 * @return bool Whether blog is already installed. 1141 1165 */ 1142 1166 function is_blog_installed() { … … 1289 1313 * @subpackage Security 1290 1314 * @since 2.0.4 1291 1315 * 1292 * @param bool $echo Whether to echo the original http referer 1316 * @param bool $echo Whether to echo the original http referer. 1293 1317 * @param string $jump_back_to Optional, default is 'current'. Can be 'previous' or page you want to jump back to. 1294 1318 * @return string Original referer field. 1295 1319 */ … … 1402 1426 * 1403 1427 * @since 2.5.0 1404 1428 * 1405 * @param string $path File path 1429 * @param string $path File path to check. 1406 1430 * @return bool True if path is absolute, false is not absolute. 1407 1431 */ 1408 1432 function path_is_absolute( $path ) { … … 1443 1467 * Determines a writable directory for temporary files. 1444 1468 * Function's preference is the return value of <code>sys_get_temp_dir()</code>, 1445 1469 * followed by your PHP temporary upload directory, followed by WP_CONTENT_DIR, 1446 * before finally defaulting to /tmp/ 1470 * before finally defaulting to /tmp/. 1447 1471 * 1448 1472 * In the event that this function does not find a writable location, 1449 1473 * It may be overridden by the <code>WP_TEMP_DIR</code> constant in … … 1451 1475 * 1452 1476 * @since 2.5.0 1453 1477 * 1454 * @return string Writable temporary directory 1478 * @return string Writable temporary directory. 1455 1479 */ 1456 1480 function get_temp_dir() { 1457 1481 static $temp; … … 1489 1513 * 1490 1514 * @since 3.6.0 1491 1515 * 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. 1494 1518 */ 1495 1519 function wp_is_writable( $path ) { 1496 1520 if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) … … 1500 1524 } 1501 1525 1502 1526 /** 1503 * Workaround for Windows bug in is_writable() function 1527 * Workaround for Windows bug in is_writable() function. 1504 1528 * 1505 1529 * PHP has issues with Windows ACL's for determine if a 1506 1530 * directory is writable or not, this works around them by … … 1512 1536 * 1513 1537 * @since 2.8.0 1514 1538 * 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. 1517 1541 */ 1518 1542 function win_is_writable( $path ) { 1519 1543 … … 1751 1775 * 1752 1776 * @since 2.0.0 1753 1777 * 1754 * @param string $name 1778 * @param string $name Name of the file to create. 1755 1779 * @param null $deprecated Never used. Set to null. 1756 * @param mixed $bits File content 1780 * @param mixed $bits File content. 1757 1781 * @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. 1759 1783 */ 1760 1784 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { 1761 1785 if ( !empty( $deprecated ) ) … … 1885 1909 * @since 3.0.0 1886 1910 * 1887 1911 * @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). 1889 1913 * @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. 1891 1915 */ 1892 1916 function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { 1893 1917 … … 1946 1970 * 1947 1971 * @since 3.5.0 1948 1972 * 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. 1951 1976 * 1952 1977 * @return array Array of mime types keyed by the file extension regex corresponding to those types. 1953 1978 */ … … 2052 2077 * 2053 2078 * @since 2.8.6 2054 2079 * 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. 2057 2082 * 2058 2083 * @param int|WP_User $user Optional. User to check. Defaults to current user. 2059 2084 * @return array Array of mime types keyed by the file extension regex corresponding to those types. … … 2127 2152 * Kill WordPress execution and display HTML message with error message. 2128 2153 * 2129 2154 * 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. 2131 2156 * 2132 2157 * @since 3.0.0 2133 2158 * @access private … … 2310 2335 * @since 3.2.0 2311 2336 * @access private 2312 2337 * 2338 * @global $wp_xmlrpc_server 2339 * 2313 2340 * @param string $message Error message. 2314 2341 * @param string $title Error title. 2315 2342 * @param string|array $args Optional arguments to control behavior. … … 2418 2445 * @package WordPress 2419 2446 * @since 2.2.0 2420 2447 * 2421 * @param string $url URL for the home location 2448 * @param string $url URL for the home location. 2422 2449 * @return string Homepage location. 2423 2450 */ 2424 2451 function _config_wp_home( $url = '' ) { … … 2439 2466 * @since 2.2.0 2440 2467 * 2441 2468 * @param string $url URL to set the WordPress site location. 2442 * @return string The WordPress Site URL 2469 * @return string The WordPress Site URL. 2443 2470 */ 2444 2471 function _config_wp_siteurl( $url = '' ) { 2445 2472 if ( defined( 'WP_SITEURL' ) ) … … 2590 2617 2591 2618 /** 2592 2619 * Merge user defined arguments into defaults array. 2593 *2594 2620 * This function is used throughout WordPress to allow for both string or array 2595 2621 * to be merged into another array. 2596 2622 * 2597 2623 * @since 2.2.0 2598 2624 * 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 * 2601 2628 * @return array Merged user defined values with defaults. 2602 2629 */ 2603 2630 function wp_parse_args( $args, $defaults = '' ) { … … 2618 2645 * 2619 2646 * @since 3.0.0 2620 2647 * 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. 2623 2650 */ 2624 2651 function wp_parse_id_list( $list ) { 2625 2652 if ( !is_array($list) ) … … 2633 2660 * 2634 2661 * @since 3.1.0 2635 2662 * 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. 2639 2666 */ 2640 2667 function wp_array_slice_assoc( $array, $keys ) { 2641 2668 $slice = array(); … … 2651 2678 * 2652 2679 * @since 3.0.0 2653 2680 * 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. 2656 2683 * @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. 2660 2688 */ 2661 2689 function wp_filter_object_list( $list, $args = array(), $operator = 'and', $field = false ) { 2662 2690 if ( ! is_array( $list ) ) … … 2675 2703 * 2676 2704 * @since 3.1.0 2677 2705 * 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. 2680 2708 * @param string $operator The logical operation to perform: 2681 2709 * 'AND' means all elements from the array must match; 2682 2710 * 'OR' means only one element needs to match; 2683 2711 * 'NOT' means no elements may match. 2684 2712 * The default is 'AND'. 2685 * @return array 2713 * @return array The filtered object list. 2686 2714 */ 2687 2715 function wp_list_filter( $list, $args = array(), $operator = 'AND' ) { 2688 2716 if ( ! is_array( $list ) ) … … 2719 2747 * 2720 2748 * @since 3.1.0 2721 2749 * 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. 2725 2753 */ 2726 2754 function wp_list_pluck( $list, $field ) { 2727 2755 foreach ( $list as $key => $value ) { … … 2794 2822 * in WordPress 2.5.0. 2795 2823 * 2796 2824 * @since 2.3.2 2797 * @ uses$wpdb2825 * @global $wpdb 2798 2826 */ 2799 2827 function dead_db() { 2800 2828 global $wpdb; … … 2832 2860 } 2833 2861 2834 2862 /** 2835 * Converts value to non negative integer.2863 * Converts value to non-negative integer. 2836 2864 * 2837 2865 * @since 2.5.0 2838 2866 * 2839 * @param mixed $maybeint Data you wish to have converted to a non negative integer2840 * @return int An non negative integer2867 * @param mixed $maybeint Data you wish to have converted to a non-negative integer. 2868 * @return int An non-negative integer. 2841 2869 */ 2842 2870 function absint( $maybeint ) { 2843 2871 return abs( intval( $maybeint ) ); … … 2851 2879 * 2852 2880 * @since 2.5.0 2853 2881 * 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. 2856 2884 */ 2857 2885 function url_is_accessable_via_ssl($url) 2858 2886 { … … 2899 2927 * @uses apply_filters() Calls 'deprecated_function_trigger_error' and expects boolean value of true to do 2900 2928 * trigger or false to not trigger error. 2901 2929 * 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. 2905 2933 */ 2906 2934 function _deprecated_function( $function, $version, $replacement = null ) { 2907 2935 … … 2944 2972 * @uses apply_filters() Calls 'deprecated_file_trigger_error' and expects boolean value of true to do 2945 2973 * trigger or false to not trigger error. 2946 2974 * 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. 2951 2979 */ 2952 2980 function _deprecated_file( $file, $version, $replacement = null, $message = '' ) { 2953 2981 … … 2977 3005 * used by comparing it to its default value or evaluating whether it is empty. 2978 3006 * For example: 2979 3007 * <code> 2980 * if ( ! empty($deprecated) )3008 * if ( ! empty( $deprecated ) ) 2981 3009 * _deprecated_argument( __FUNCTION__, '3.0' ); 2982 3010 * </code> 2983 3011 * … … 2997 3025 * @uses apply_filters() Calls 'deprecated_argument_trigger_error' and expects boolean value of true to do 2998 3026 * trigger or false to not trigger error. 2999 3027 * 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. 3002 3030 * @param string $message Optional. A message regarding the change. 3003 3031 */ 3004 3032 function _deprecated_argument( $function, $version, $message = null ) { … … 3079 3107 * 3080 3108 * @since 2.5.0 3081 3109 * 3082 * @param string $mod e.g. mod_rewrite3083 * @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. 3085 3113 */ 3086 3114 function apache_mod_loaded($mod, $default = false) { 3087 3115 global $is_apache; … … 3108 3136 * 3109 3137 * @since 2.8.0 3110 3138 * 3111 * @return bool 3139 * @return bool True if permalinks are supported, false if not supported. 3112 3140 */ 3113 3141 function iis7_supports_permalinks() { 3114 3142 global $is_iis7; … … 3132 3160 3133 3161 /** 3134 3162 * File validates against allowed set of defined rules. 3135 *3136 3163 * A return value of '1' means that the $file contains either '..' or './'. A 3137 3164 * return value of '2' means that the $file contains ':' after the first 3138 3165 * character. A return value of '3' means that the file is not in the allowed … … 3140 3167 * 3141 3168 * @since 1.2.0 3142 3169 * 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 * 3145 3173 * @return int 0 means nothing is wrong, greater than 0 means something was wrong. 3146 3174 */ 3147 3175 function validate_file( $file, $allowed_files = '' ) { … … 3227 3255 * 3228 3256 * @since 2.6.0 3229 3257 * 3230 * @return string 3258 * @return string The best-guess URL of the site. 3231 3259 */ 3232 3260 function wp_guess_url() { 3233 3261 if ( defined('WP_SITEURL') && '' != WP_SITEURL ) { … … 3281 3309 * @since 3.3.0 3282 3310 * 3283 3311 * @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. 3285 3313 */ 3286 3314 function wp_suspend_cache_addition( $suspend = null ) { 3287 3315 static $_suspend = false; … … 3301 3329 * 3302 3330 * @since 2.7.0 3303 3331 * 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. 3306 3334 */ 3307 3335 function wp_suspend_cache_invalidation($suspend = true) { 3308 3336 global $_wp_suspend_cache_invalidation; … … 3338 3366 * 3339 3367 * @since 3.7.0 3340 3368 * 3369 * @global $wpdb 3370 * 3341 3371 * @param int $network_id Optional. Network ID to test. Defaults to current network. 3342 3372 * @return bool True if $network_id is the main network, or if not running multisite. 3343 3373 */ … … 3377 3407 * @since 3.0.0 3378 3408 * @package WordPress 3379 3409 * 3380 * @return bool True if multisite and global terms enabled 3410 * @return bool True if multisite and global terms enabled. 3381 3411 */ 3382 3412 function global_terms_enabled() { 3383 3413 if ( ! is_multisite() ) … … 3401 3431 * 3402 3432 * @since 2.8.0 3403 3433 * 3404 * @return float|bool 3434 * @return float|bool Timezone offset; false if not set or if any errors. 3405 3435 */ 3406 3436 function wp_timezone_override_offset() { 3407 3437 if ( !$timezone_string = get_option( 'timezone_string' ) ) { … … 3423 3453 * 3424 3454 * @param array $a 3425 3455 * @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. 3427 3457 */ 3428 3458 function _wp_timezone_choice_usort_callback( $a, $b ) { 3429 3459 // Don't use translated versions of Etc … … 3468 3498 * 3469 3499 * @since 2.9.0 3470 3500 * 3471 * @param string $selected_zone Selected Zone 3472 * @return string 3501 * @param string $selected_zone Selected Zone. 3502 * @return string Formatted timezones. 3473 3503 */ 3474 3504 function wp_timezone_choice( $selected_zone ) { 3475 3505 static $mo_loaded = false; … … 3594 3624 3595 3625 /** 3596 3626 * Strip close comment and close php tags from file headers used by WP. 3597 * See http://core.trac.wordpress.org/ticket/84973598 3627 * 3599 3628 * @since 2.8.0 3629 * @link http://core.trac.wordpress.org/ticket/8497 3600 3630 * 3601 * @param string $str 3602 * @return string 3631 * @param string $str String to clean. 3632 * @return string The cleaned-up string. 3603 3633 */ 3604 3634 function _cleanup_header_comment($str) { 3605 3635 return trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $str)); … … 3609 3639 * Permanently deletes posts, pages, attachments, and comments which have been in the trash for EMPTY_TRASH_DAYS. 3610 3640 * 3611 3641 * @since 2.9.0 3642 * 3643 * @global $wpdb 3612 3644 */ 3613 3645 function wp_scheduled_delete() { 3614 3646 global $wpdb; … … 3653 3685 /** 3654 3686 * Retrieve metadata from a file. 3655 3687 * 3656 * Searches for metadata in the first 8 kiB 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. 3657 3689 * Each piece of metadata must be on its own line. Fields can not span multiple 3658 3690 * lines, the value will get cut at the end of the first line. 3659 3691 * 3660 * If the file data is not within that first 8 kiB, then the author should correct3692 * If the file data is not within that first 8KiB, then the author should correct 3661 3693 * their plugin file and move the data headers to the top. 3662 3694 * 3663 * @ seehttp://codex.wordpress.org/File_Header3695 * @link http://codex.wordpress.org/File_Header 3664 3696 * 3665 3697 * @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 3669 3707 */ 3670 3708 function get_file_data( $file, $default_headers, $context = '' ) { 3671 3709 // We don't need to write to the file, so just open for reading. 3672 3710 $fp = fopen( $file, 'r' ); 3673 3711 3674 // Pull only the first 8 kiB of the file in.3712 // Pull only the first 8KiB of the file in. 3675 3713 $file_data = fread( $fp, 8192 ); 3676 3714 3677 3715 // PHP will close file handle, but we are good citizens. … … 3704 3742 * 3705 3743 * @since 3.0.0 3706 3744 * @see __return_false() 3745 * 3707 3746 * @return bool true 3708 3747 */ 3709 3748 function __return_true() { … … 3717 3756 * 3718 3757 * @since 3.0.0 3719 3758 * @see __return_true() 3759 * 3720 3760 * @return bool false 3721 3761 */ 3722 3762 function __return_false() { … … 3729 3769 * Useful for returning 0 to filters easily. 3730 3770 * 3731 3771 * @since 3.0.0 3772 * 3732 3773 * @return int 0 3733 3774 */ 3734 3775 function __return_zero() { … … 3741 3782 * Useful for returning an empty array to filters easily. 3742 3783 * 3743 3784 * @since 3.0.0 3744 * @return array Empty array 3785 * 3786 * @return array Empty array. 3745 3787 */ 3746 3788 function __return_empty_array() { 3747 3789 return array(); … … 3753 3795 * Useful for returning null to filters easily. 3754 3796 * 3755 3797 * @since 3.4.0 3798 * 3756 3799 * @return null 3757 3800 */ 3758 3801 function __return_null() { … … 3766 3809 * 3767 3810 * @since 3.7.0 3768 3811 * @see __return_null() 3812 * 3769 3813 * @return string Empty string 3770 3814 */ 3771 3815 function __return_empty_string() { … … 3779 3823 * @link http://src.chromium.org/viewvc/chrome?view=rev&revision=6985 3780 3824 * 3781 3825 * @since 3.0.0 3782 * @return none3783 3826 */ 3784 3827 function send_nosniff_header() { 3785 3828 @header( 'X-Content-Type-Options: nosniff' ); … … 3790 3833 * 3791 3834 * @internal 3792 3835 * @since 3.0.0 3836 * 3793 3837 * @param string $column 3794 3838 * @return string 3795 3839 */ … … 3812 3856 /** 3813 3857 * Finds hierarchy loops using a callback function that maps object IDs to parent IDs. 3814 3858 * 3859 * @access private 3815 3860 * @since 3.1.0 3816 * @access private3817 3861 * 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. 3823 3868 */ 3824 3869 function wp_find_hierarchy_loop( $callback, $start, $start_parent, $callback_args = array() ) { 3825 3870 $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); … … 3836 3881 * For every step of the algorithm, the hare takes two steps and the tortoise one. 3837 3882 * If the hare ever laps the tortoise, there must be a loop. 3838 3883 * 3884 * @access private 3839 3885 * @since 3.1.0 3840 * @access private3841 3886 * 3842 * @param callback $callback function that accepts ( ID, callback_arg, ... ) and outputs parent_ID3843 * @param int $start The ID to start the loop check at3844 * @param array $override an array of ( ID => parent_ID, ... ) to use instead of $callback3845 * @param array $callback_args optional additional arguments to send to $callback3887 * @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. 3846 3891 * @param bool $_return_loop Return loop members or just detect presence of loop? 3847 3892 * 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_loop3893 * (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. 3850 3895 */ 3851 3896 function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { 3852 3897 $tortoise = $hare = $evanescent_hare = $start; … … 3881 3926 * @link https://developer.mozilla.org/en/the_x-frame-options_response_header 3882 3927 * 3883 3928 * @since 3.1.3 3884 * @return none3885 3929 */ 3886 3930 function send_frame_options_header() { 3887 3931 @header( 'X-Frame-Options: SAMEORIGIN' ); … … 3913 3957 * @link http://core.trac.wordpress.org/ticket/19589 3914 3958 * @since 3.4.0 3915 3959 * 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. 3919 3964 * @return string|array Either a string containing a reversed comma separated trace or an array of individual calls. 3920 3965 */ 3921 3966 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { … … 3953 3998 } 3954 3999 3955 4000 /** 3956 * Retrieve ids that are not already present in the cache4001 * Retrieve IDs that are not already present in the cache. 3957 4002 * 3958 4003 * @since 3.4.0 3959 4004 * 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. 3962 4007 * 3963 * @return array 4008 * @return array Cleaned up array of IDs. 3964 4009 */ 3965 4010 function _get_non_cached_ids( $object_ids, $cache_key ) { 3966 4011 $clean = array(); … … 3977 4022 /** 3978 4023 * Test if the current device has the capability to upload files. 3979 4024 * 4025 * @access private 3980 4026 * @since 3.4.0 3981 * @access private3982 4027 * 3983 * @return bool true|false4028 * @return bool True if the device allows uploads; false if not. 3984 4029 */ 3985 4030 function _device_can_upload() { 3986 4031 if ( ! wp_is_mobile() ) … … 3998 4043 } 3999 4044 4000 4045 /** 4001 * Test if a given path is a stream URL 4046 * Test if a given path is a stream URL. 4002 4047 * 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. 4005 4050 */ 4006 4051 function wp_is_stream( $path ) { 4007 4052 $wrappers = stream_get_wrappers(); … … 4011 4056 } 4012 4057 4013 4058 /** 4014 * Test if the supplied date is valid for the Gregorian calendar 4059 * Test if the supplied date is valid for the Gregorian calendar. 4015 4060 * 4016 4061 * @since 3.5.0 4062 * @see checkdate() 4017 4063 * 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. 4019 4070 */ 4020 4071 function wp_checkdate( $month, $day, $year, $source_date ) { 4021 4072 return apply_filters( 'wp_checkdate', checkdate( $month, $day, $year ), $source_date ); … … 4024 4075 /** 4025 4076 * Load the auth check for monitoring whether the user is still logged in. 4026 4077 * 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' );`. 4028 4079 * 4029 4080 * This is disabled for certain screens where a login screen could cause an 4030 4081 * inconvenient interruption. A filter called wp_auth_check_load can be used … … 4095 4146 4096 4147 /** 4097 4148 * Check whether a user is still logged in, for the heartbeat. 4098 *4099 4149 * Send a result that shows a log-in box if the user is no longer logged in, 4100 4150 * or if their cookie is within the grace period. 4101 4151 * 4102 4152 * @since 3.6.0 4153 * 4154 * @param array $response 4155 * @param $data 4156 * 4157 * @return array 4103 4158 */ 4104 4159 function wp_auth_check( $response, $data ) { 4105 4160 $response['wp-auth-check'] = is_user_logged_in() && empty( $GLOBALS['login_grace_period'] ); … … 4112 4167 * 2. Has no body but has a closing tag of the same name or 4113 4168 * 3. Contains a body and a closing tag of the same name 4114 4169 * 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. 4116 4171 * 4117 4172 * @since 3.6.0 4118 4173 * 4119 * @param string $tag An HTML tag name. Example: 'video' 4174 * @param string $tag An HTML tag name. Example: 'video'. 4120 4175 * @return string 4121 4176 */ 4122 4177 function get_tag_regex( $tag ) { … … 4132 4187 * @link http://core.trac.wordpress.org/ticket/23688 4133 4188 * @since 3.6.0 4134 4189 * 4135 * @param string A charset name4136 * @return string The canonical form of the charset 4190 * @param string $charset A charset name. 4191 * @return string The canonical form of the charset. 4137 4192 */ 4138 4193 function _canonical_charset( $charset ) { 4139 4194 if ( 'UTF-8' === $charset || 'utf-8' === $charset || 'utf8' === $charset ||