diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index 3ac8b13..adc087c 100644
|
|
function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { |
140 | 140 | } |
141 | 141 | } |
142 | 142 | $j = @$datefunc( $dateformatstring, $i ); |
143 | | // allow plugins to redo this entirely for languages with untypical grammars |
| 143 | |
| 144 | /** |
| 145 | * Filter date to allow plugins to redo this entirely for languages with untypical grammars. |
| 146 | * |
| 147 | * @since 2.8.0 |
| 148 | * |
| 149 | * @param string $j Formatted date string. |
| 150 | * @param string $req_format Format to display the date. |
| 151 | * @param bool $gmt Whether to convert to GMT for time. |
| 152 | */ |
144 | 153 | $j = apply_filters('date_i18n', $j, $req_format, $i, $gmt); |
145 | 154 | return $j; |
146 | 155 | } |
… |
… |
function date_i18n( $dateformatstring, $unixtimestamp = false, $gmt = false ) { |
157 | 166 | function number_format_i18n( $number, $decimals = 0 ) { |
158 | 167 | global $wp_locale; |
159 | 168 | $formatted = number_format( $number, absint( $decimals ), $wp_locale->number_format['decimal_point'], $wp_locale->number_format['thousands_sep'] ); |
| 169 | |
| 170 | /** |
| 171 | * Filter number formatted based on the locale. |
| 172 | * |
| 173 | * @since 2.8.0 |
| 174 | * |
| 175 | * @param string $formatted Converted number in string format. |
| 176 | */ |
160 | 177 | return apply_filters( 'number_format_i18n', $formatted ); |
161 | 178 | } |
162 | 179 | |
… |
… |
function status_header( $code ) { |
917 | 934 | $protocol = 'HTTP/1.0'; |
918 | 935 | $status_header = "$protocol $code $description"; |
919 | 936 | if ( function_exists( 'apply_filters' ) ) |
| 937 | |
| 938 | /** |
| 939 | * Filter a status header. |
| 940 | * |
| 941 | * @since 2.2.0 |
| 942 | * |
| 943 | * @param string $status_header Status header. |
| 944 | * @param int $code HTTP status code. |
| 945 | * @param string $description Description for the status code, empty string if not found. |
| 946 | * @param string $protocol Server protocol. |
| 947 | */ |
920 | 948 | $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); |
921 | 949 | |
922 | 950 | @header( $status_header, true, $code ); |
… |
… |
function wp_get_nocache_headers() { |
940 | 968 | ); |
941 | 969 | |
942 | 970 | if ( function_exists('apply_filters') ) { |
| 971 | |
| 972 | /** |
| 973 | * Filter the cache-controlling headers. |
| 974 | * |
| 975 | * @since 2.8.0 |
| 976 | * |
| 977 | * @param array $headers { |
| 978 | * Header names and field values. |
| 979 | * |
| 980 | * @type string $Expires Expires header. |
| 981 | * @type string $Cache-Control Cache-Control header. |
| 982 | * @type string $Pragma Pragma header. |
| 983 | * } |
| 984 | */ |
943 | 985 | $headers = (array) apply_filters('nocache_headers', $headers); |
944 | 986 | } |
945 | 987 | $headers['Last-Modified'] = false; |
… |
… |
function do_feed() { |
1041 | 1083 | if ( ! has_action( $hook ) ) |
1042 | 1084 | wp_die( __( 'ERROR: This is not a valid feed template.' ), '', array( 'response' => 404 ) ); |
1043 | 1085 | |
| 1086 | /** |
| 1087 | * Fires contextually for each feed. |
| 1088 | * |
| 1089 | * Hook name is `do_feed_{$feed}`. |
| 1090 | * |
| 1091 | * @since 2.1.0 |
| 1092 | * |
| 1093 | * @param bool $is_comment_feed True if feed is a comment feed. |
| 1094 | */ |
1044 | 1095 | do_action( $hook, $wp_query->is_comment_feed ); |
1045 | 1096 | } |
1046 | 1097 | |
… |
… |
function do_feed_atom( $for_comments ) { |
1102 | 1153 | function do_robots() { |
1103 | 1154 | header( 'Content-Type: text/plain; charset=utf-8' ); |
1104 | 1155 | |
| 1156 | /** |
| 1157 | * Fires when displaying the robots.txt file. |
| 1158 | * |
| 1159 | * @since 2.1.0 |
| 1160 | */ |
1105 | 1161 | do_action( 'do_robotstxt' ); |
1106 | 1162 | |
1107 | 1163 | $output = "User-agent: *\n"; |
… |
… |
function wp_upload_dir( $time = null ) { |
1655 | 1711 | $dir .= $subdir; |
1656 | 1712 | $url .= $subdir; |
1657 | 1713 | |
| 1714 | /** |
| 1715 | * Filter the uploads directory data. |
| 1716 | * |
| 1717 | * @since 2.0.0 |
| 1718 | * |
| 1719 | * @param array $uploads Array of upload directory data with keys of `path`, `url`, `subdir`, |
| 1720 | * `basedir` and `error`. |
| 1721 | */ |
1658 | 1722 | $uploads = apply_filters( 'upload_dir', |
1659 | 1723 | array( |
1660 | 1724 | 'path' => $dir, |
… |
… |
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { |
1780 | 1844 | if ( $upload['error'] !== false ) |
1781 | 1845 | return $upload; |
1782 | 1846 | |
| 1847 | /** |
| 1848 | * Filter whether upload bits produces an error. |
| 1849 | * |
| 1850 | * If it is an error, then filter should not return an array. |
| 1851 | * |
| 1852 | * @since 3.0.0 |
| 1853 | * |
| 1854 | * @param array $upload_bits_error Array with keys for `name`, `bits` and `time`. |
| 1855 | */ |
1783 | 1856 | $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); |
1784 | 1857 | if ( !is_array( $upload_bits_error ) ) { |
1785 | 1858 | $upload[ 'error' ] = $upload_bits_error; |
… |
… |
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { |
1831 | 1904 | */ |
1832 | 1905 | function wp_ext2type( $ext ) { |
1833 | 1906 | $ext = strtolower( $ext ); |
| 1907 | |
| 1908 | /** |
| 1909 | * Filter file type based on the extension name. |
| 1910 | * |
| 1911 | * @since 2.5.0 |
| 1912 | * |
| 1913 | * @param array $ext2type Multi-dimensional array with extensions for the default keys of |
| 1914 | * `image`, `audio`, `video`, `document`, `spreadsheet`, `interactive`, |
| 1915 | * `text`, `archive` and `code`. |
| 1916 | */ |
1834 | 1917 | $ext2type = apply_filters( 'ext2type', array( |
1835 | 1918 | 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), |
1836 | 1919 | 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), |
… |
… |
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { |
1915 | 1998 | |
1916 | 1999 | // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME |
1917 | 2000 | if ( !empty($imgstats['mime']) && $imgstats['mime'] != $type ) { |
1918 | | // This is a simplified array of MIMEs that getimagesize() can detect and their extensions |
1919 | | // You shouldn't need to use this filter, but it's here just in case |
| 2001 | /** |
| 2002 | * Filter a simplified array of MIMEs that getimagesize() can detect and their extensions. |
| 2003 | * |
| 2004 | * You shouldn't need to use this filter, but it's here just in case. |
| 2005 | * |
| 2006 | * @since 3.0.0 |
| 2007 | * |
| 2008 | * @param array $mime_to_ext Array of image MIMEs to extensions. |
| 2009 | */ |
1920 | 2010 | $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( |
1921 | 2011 | 'image/jpeg' => 'jpg', |
1922 | 2012 | 'image/png' => 'png', |
… |
… |
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { |
1942 | 2032 | } |
1943 | 2033 | } |
1944 | 2034 | |
1945 | | // Let plugins try and validate other types of files |
1946 | | // Should return an array in the style of array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename ) |
| 2035 | /** |
| 2036 | * Filter to let plugins try and validate other types of files. |
| 2037 | * |
| 2038 | * Should return an array in the style of: |
| 2039 | * `array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename )` |
| 2040 | * |
| 2041 | * @since 3.0.0 |
| 2042 | * |
| 2043 | * @param array $wp_check_filetype_and_ext Array with keys of `ext`, `type` and |
| 2044 | * `proper_filename`. |
| 2045 | * @param string $file Full path to the file. |
| 2046 | * @param string $filename The name of the file (may differ from $file due to |
| 2047 | * `$file` being in a tmp directory). |
| 2048 | * @param array $mimes Key is the file extension with value as the mime |
| 2049 | * type. |
| 2050 | */ |
1947 | 2051 | return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes ); |
1948 | 2052 | } |
1949 | 2053 | |
… |
… |
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) { |
1958 | 2062 | * @return array Array of mime types keyed by the file extension regex corresponding to those types. |
1959 | 2063 | */ |
1960 | 2064 | function wp_get_mime_types() { |
1961 | | // Accepted MIME types are set here as PCRE unless provided. |
| 2065 | |
| 2066 | /** |
| 2067 | * Filter list of MIME types and file extensions. |
| 2068 | * |
| 2069 | * Accepted MIME types are set here as PCRE unless provided. |
| 2070 | * |
| 2071 | * @since 3.5.0 |
| 2072 | * |
| 2073 | * @param array $wp_get_mime_types MIME types keyed by the file extension regex corresponding to those types. |
| 2074 | */ |
1962 | 2075 | return apply_filters( 'mime_types', array( |
1963 | 2076 | // Image formats |
1964 | 2077 | 'jpg|jpeg|jpe' => 'image/jpeg', |
… |
… |
function get_allowed_mime_types( $user = null ) { |
2075 | 2188 | if ( empty( $unfiltered ) ) |
2076 | 2189 | unset( $t['htm|html'] ); |
2077 | 2190 | |
| 2191 | /** |
| 2192 | * Filter list of allowed MIME types and file extensions. |
| 2193 | * |
| 2194 | * @since 2.0.0 |
| 2195 | * |
| 2196 | * @param array $t MIME types keyed by the file extension regex corresponding to |
| 2197 | * those types. `swf` and `exe` removed from full list. `htm|html` also |
| 2198 | * removed depending on `$user` capabilities. |
| 2199 | * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current |
| 2200 | * user). |
| 2201 | */ |
2078 | 2202 | return apply_filters( 'upload_mimes', $t, $user ); |
2079 | 2203 | } |
2080 | 2204 | |
… |
… |
function wp_nonce_ays( $action ) { |
2120 | 2244 | */ |
2121 | 2245 | function wp_die( $message = '', $title = '', $args = array() ) { |
2122 | 2246 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| 2247 | /** |
| 2248 | * Filter callback function when in `DOING_AJAX` context during `wp_die()`. |
| 2249 | * |
| 2250 | * @since 3.4.0 |
| 2251 | * |
| 2252 | * @param string $function Callback function name. |
| 2253 | */ |
2123 | 2254 | $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); |
2124 | 2255 | elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) |
| 2256 | /** |
| 2257 | * Filter callback function when in `XMLRPC_REQUEST` context during `wp_die()`. |
| 2258 | * |
| 2259 | * @since 3.4.0 |
| 2260 | * |
| 2261 | * @param string $function Callback function name. |
| 2262 | */ |
2125 | 2263 | $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); |
2126 | 2264 | else |
| 2265 | /** |
| 2266 | * Filter callback function when not in `DOING_AJAX` or `XMLRPC_REQUEST` contexts during |
| 2267 | * `wp_die()`. |
| 2268 | * |
| 2269 | * @since 3.0.0 |
| 2270 | * |
| 2271 | * @param string $function Callback function name. |
| 2272 | */ |
2127 | 2273 | $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); |
2128 | 2274 | |
2129 | 2275 | call_user_func( $function, $message, $title, $args ); |
… |
… |
function wp_list_pluck( $list, $field ) { |
2746 | 2892 | * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value. |
2747 | 2893 | */ |
2748 | 2894 | function wp_maybe_load_widgets() { |
| 2895 | /** |
| 2896 | * Filter if Widgets library should be loaded. |
| 2897 | * |
| 2898 | * @since 2.8.0 |
| 2899 | * |
| 2900 | * @param bool $wp_maybe_load_widgets Default is true. |
| 2901 | */ |
2749 | 2902 | if ( ! apply_filters('load_default_widgets', true) ) |
2750 | 2903 | return; |
2751 | 2904 | require_once( ABSPATH . WPINC . '/default-widgets.php' ); |
… |
… |
function url_is_accessable_via_ssl($url) |
2905 | 3058 | */ |
2906 | 3059 | function _deprecated_function( $function, $version, $replacement = null ) { |
2907 | 3060 | |
| 3061 | /** |
| 3062 | * Fires when a function is marked as deprecated. |
| 3063 | * |
| 3064 | * @since 2.5.0 |
| 3065 | * |
| 3066 | * @param string $function The function that was called. |
| 3067 | * @param string $replacement The function that should have been called. |
| 3068 | * @param string $version The version of WordPress that deprecated the function. |
| 3069 | */ |
2908 | 3070 | do_action( 'deprecated_function_run', $function, $replacement, $version ); |
2909 | 3071 | |
2910 | | // Allow plugin to filter the output error trigger |
| 3072 | /** |
| 3073 | * Filter the deprecated function output error trigger. |
| 3074 | * |
| 3075 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| 3076 | * error. |
| 3077 | * |
| 3078 | * @since 2.5.0 |
| 3079 | * |
| 3080 | * @param bool $deprecated_function_trigger_error Default is true. |
| 3081 | */ |
2911 | 3082 | if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { |
2912 | 3083 | if ( function_exists( '__' ) ) { |
2913 | 3084 | if ( ! is_null( $replacement ) ) |
… |
… |
function _deprecated_function( $function, $version, $replacement = null ) { |
2949 | 3120 | */ |
2950 | 3121 | function _deprecated_file( $file, $version, $replacement = null, $message = '' ) { |
2951 | 3122 | |
| 3123 | /** |
| 3124 | * Fires when a file is marked as deprecated. |
| 3125 | * |
| 3126 | * @since 2.5.0 |
| 3127 | * |
| 3128 | * @param string $file The file that was called. |
| 3129 | * @param string $replacement The file that should have been included based on ABSPATH. |
| 3130 | * @param string $version The version of WordPress that deprecated the file. |
| 3131 | * @param string $message A message regarding the change. |
| 3132 | */ |
2952 | 3133 | do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); |
2953 | 3134 | |
2954 | | // Allow plugin to filter the output error trigger |
| 3135 | /** |
| 3136 | * Filter the deprecated file output error trigger. |
| 3137 | * |
| 3138 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| 3139 | * error. |
| 3140 | * |
| 3141 | * @since 2.5.0 |
| 3142 | * |
| 3143 | * @param bool $deprecated_file_trigger_error Default is true. |
| 3144 | */ |
2955 | 3145 | if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { |
2956 | 3146 | $message = empty( $message ) ? '' : ' ' . $message; |
2957 | 3147 | if ( function_exists( '__' ) ) { |
… |
… |
function _deprecated_file( $file, $version, $replacement = null, $message = '' ) |
2999 | 3189 | */ |
3000 | 3190 | function _deprecated_argument( $function, $version, $message = null ) { |
3001 | 3191 | |
| 3192 | /** |
| 3193 | * Fires when an argument is marked as deprecated. |
| 3194 | * |
| 3195 | * @since 3.0.0 |
| 3196 | * |
| 3197 | * @param string $function The function that was called. |
| 3198 | * @param string $message A message regarding the change. |
| 3199 | * @param string $version The version of WordPress that deprecated the argument used. |
| 3200 | */ |
3002 | 3201 | do_action( 'deprecated_argument_run', $function, $message, $version ); |
3003 | 3202 | |
3004 | | // Allow plugin to filter the output error trigger |
| 3203 | /** |
| 3204 | * Filter the deprecated argument output error trigger. |
| 3205 | * |
| 3206 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| 3207 | * error. |
| 3208 | * |
| 3209 | * @since 3.0.0 |
| 3210 | * |
| 3211 | * @param bool $deprecated_argument_trigger_error Default is true. |
| 3212 | */ |
3005 | 3213 | if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { |
3006 | 3214 | if ( function_exists( '__' ) ) { |
3007 | 3215 | if ( ! is_null( $message ) ) |
… |
… |
function _deprecated_argument( $function, $version, $message = null ) { |
3039 | 3247 | */ |
3040 | 3248 | function _doing_it_wrong( $function, $message, $version ) { |
3041 | 3249 | |
| 3250 | /** |
| 3251 | * Fires when something is marked as being called incorrectly. |
| 3252 | * |
| 3253 | * @since 3.1.0 |
| 3254 | * |
| 3255 | * @param string $function The function that was called. |
| 3256 | * @param string $message A message explaining what has been done incorrectly. |
| 3257 | * @param string $version The version of WordPress where the message was added. |
| 3258 | */ |
3042 | 3259 | do_action( 'doing_it_wrong_run', $function, $message, $version ); |
3043 | 3260 | |
3044 | | // Allow plugin to filter the output error trigger |
| 3261 | /** |
| 3262 | * Filter the "doing it wrong" output error trigger. |
| 3263 | * |
| 3264 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| 3265 | * error. |
| 3266 | * |
| 3267 | * @since 3.1.0 |
| 3268 | * |
| 3269 | * @param bool $doing_it_wrong_trigger_error Default is true. |
| 3270 | */ |
3045 | 3271 | if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { |
3046 | 3272 | if ( function_exists( '__' ) ) { |
3047 | 3273 | $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); |
… |
… |
function iis7_supports_permalinks() { |
3121 | 3347 | $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); |
3122 | 3348 | } |
3123 | 3349 | |
| 3350 | /** |
| 3351 | * Filter if IIS 7+ supports pretty permalinks. |
| 3352 | * |
| 3353 | * @since 2.8.0 |
| 3354 | * |
| 3355 | * @param bool $iis7_supports_permalinks True if permalinks are supported, false otherwise. |
| 3356 | */ |
3124 | 3357 | return apply_filters('iis7_supports_permalinks', $supports_permalinks); |
3125 | 3358 | } |
3126 | 3359 | |
… |
… |
function global_terms_enabled() { |
3378 | 3611 | |
3379 | 3612 | static $global_terms = null; |
3380 | 3613 | if ( is_null( $global_terms ) ) { |
| 3614 | |
| 3615 | /** |
| 3616 | * Filter to short circuit whether global terms are enabled. |
| 3617 | * |
| 3618 | * @since 3.0.0 |
| 3619 | * |
| 3620 | * @param null $global_terms_enabled Expects a filter to return a truthy or falsy value. |
| 3621 | */ |
3381 | 3622 | $filter = apply_filters( 'global_terms_enabled', null ); |
3382 | 3623 | if ( ! is_null( $filter ) ) |
3383 | 3624 | $global_terms = (bool) $filter; |
… |
… |
function get_file_data( $file, $default_headers, $context = '' ) { |
3673 | 3914 | // Make sure we catch CR-only line endings. |
3674 | 3915 | $file_data = str_replace( "\r", "\n", $file_data ); |
3675 | 3916 | |
| 3917 | /** |
| 3918 | * Filter extra file headers by context. |
| 3919 | * |
| 3920 | * The dynamic part of the hook, `$context`, comes directly from the `$context` function |
| 3921 | * argument. If the value is the default empty string, this filter will not be called. |
| 3922 | * |
| 3923 | * @since 2.9.0 |
| 3924 | * |
| 3925 | * @param array $extra_context_headers Empty array by default. |
| 3926 | */ |
3676 | 3927 | if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) { |
3677 | 3928 | $extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values |
3678 | 3929 | $all_headers = array_merge( $extra_headers, (array) $default_headers ); |
… |
… |
function wp_allowed_protocols() { |
3894 | 4145 | |
3895 | 4146 | if ( empty( $protocols ) ) { |
3896 | 4147 | $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp' ); |
| 4148 | /** |
| 4149 | * Filter the list of protocols allowed in HTML atributes. |
| 4150 | * |
| 4151 | * @since 3.0.0 |
| 4152 | * |
| 4153 | * @param array $protocols Array of allowed protocols e.g. `http`, `ftp`, `tel` and more. |
| 4154 | */ |
3897 | 4155 | $protocols = apply_filters( 'kses_allowed_protocols', $protocols ); |
3898 | 4156 | } |
3899 | 4157 | |
… |
… |
function wp_auth_check_html() { |
4058 | 4316 | if ( $same_domain && force_ssl_login() && ! force_ssl_admin() ) |
4059 | 4317 | $same_domain = false; |
4060 | 4318 | |
4061 | | // Let plugins change this if they know better. |
| 4319 | /** |
| 4320 | * Filter the auth check same domain. |
| 4321 | * |
| 4322 | * @since 3.6.0 |
| 4323 | * |
| 4324 | * @param bool $same_domain True if current domain matches login URL domain. If force SSL login |
| 4325 | * is true and force SSL admin is false, this value becomes false. |
| 4326 | */ |
4062 | 4327 | $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); |
4063 | 4328 | $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; |
4064 | 4329 | |