diff --git src/wp-includes/functions.php src/wp-includes/functions.php
index 3ac8b13..d9963a5 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 wp_upload_dir( $time = null ) {
|
| 1655 | 1697 | $dir .= $subdir; |
| 1656 | 1698 | $url .= $subdir; |
| 1657 | 1699 | |
| | 1700 | /** |
| | 1701 | * Filter the uploads directory data. |
| | 1702 | * |
| | 1703 | * @since 2.0.0 |
| | 1704 | * |
| | 1705 | * @param array $uploads Array of upload directory data with keys of `path`, `url`, `subdir`, |
| | 1706 | * `basedir` and `error`. |
| | 1707 | */ |
| 1658 | 1708 | $uploads = apply_filters( 'upload_dir', |
| 1659 | 1709 | array( |
| 1660 | 1710 | 'path' => $dir, |
| … |
… |
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
| 1780 | 1830 | if ( $upload['error'] !== false ) |
| 1781 | 1831 | return $upload; |
| 1782 | 1832 | |
| | 1833 | /** |
| | 1834 | * Filter whether upload bits produces an error. |
| | 1835 | * |
| | 1836 | * If it is an error, then filter should not return an array. |
| | 1837 | * |
| | 1838 | * @since 3.0.0 |
| | 1839 | * |
| | 1840 | * @param array $upload_bits_error Array with keys for `name`, `bits` and `time`. |
| | 1841 | */ |
| 1783 | 1842 | $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); |
| 1784 | 1843 | if ( !is_array( $upload_bits_error ) ) { |
| 1785 | 1844 | $upload[ 'error' ] = $upload_bits_error; |
| … |
… |
function wp_upload_bits( $name, $deprecated, $bits, $time = null ) {
|
| 1831 | 1890 | */ |
| 1832 | 1891 | function wp_ext2type( $ext ) { |
| 1833 | 1892 | $ext = strtolower( $ext ); |
| | 1893 | |
| | 1894 | /** |
| | 1895 | * Filter file type based on the extension name. |
| | 1896 | * |
| | 1897 | * @since 2.5.0 |
| | 1898 | * |
| | 1899 | * @param array $ext2type Multi-dimensional array with extensions for the default keys of |
| | 1900 | * `image`, `audio`, `video`, `document`, `spreadsheet`, `interactive`, |
| | 1901 | * `text`, `archive` and `code`. |
| | 1902 | */ |
| 1834 | 1903 | $ext2type = apply_filters( 'ext2type', array( |
| 1835 | 1904 | 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), |
| 1836 | 1905 | '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 | 1984 | |
| 1916 | 1985 | // If getimagesize() knows what kind of image it really is and if the real MIME doesn't match the claimed MIME |
| 1917 | 1986 | 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 |
| | 1987 | /** |
| | 1988 | * Filter a simplified array of MIMEs that getimagesize() can detect and their extensions. |
| | 1989 | * |
| | 1990 | * You shouldn't need to use this filter, but it's here just in case. |
| | 1991 | * |
| | 1992 | * @since 3.0.0 |
| | 1993 | * |
| | 1994 | * @param array $mime_to_ext Array of image MIMEs to extensions. |
| | 1995 | */ |
| 1920 | 1996 | $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( |
| 1921 | 1997 | 'image/jpeg' => 'jpg', |
| 1922 | 1998 | 'image/png' => 'png', |
| … |
… |
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
| 1942 | 2018 | } |
| 1943 | 2019 | } |
| 1944 | 2020 | |
| 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 ) |
| | 2021 | /** |
| | 2022 | * Filter to let plugins try and validate other types of files. |
| | 2023 | * |
| | 2024 | * Should return an array in the style of: |
| | 2025 | * `array( 'ext' => $ext, 'type' => $type, 'proper_filename' => $proper_filename )` |
| | 2026 | * |
| | 2027 | * @since 3.0.0 |
| | 2028 | * |
| | 2029 | * @param array $wp_check_filetype_and_ext Array with keys of `ext`, `type` and |
| | 2030 | * `proper_filename`. |
| | 2031 | * @param string $file Full path to the file. |
| | 2032 | * @param string $filename The name of the file (may differ from $file due to |
| | 2033 | * `$file` being in a tmp directory). |
| | 2034 | * @param array $mimes Key is the file extension with value as the mime |
| | 2035 | * type. |
| | 2036 | */ |
| 1947 | 2037 | return apply_filters( 'wp_check_filetype_and_ext', compact( 'ext', 'type', 'proper_filename' ), $file, $filename, $mimes ); |
| 1948 | 2038 | } |
| 1949 | 2039 | |
| … |
… |
function wp_check_filetype_and_ext( $file, $filename, $mimes = null ) {
|
| 1958 | 2048 | * @return array Array of mime types keyed by the file extension regex corresponding to those types. |
| 1959 | 2049 | */ |
| 1960 | 2050 | function wp_get_mime_types() { |
| 1961 | | // Accepted MIME types are set here as PCRE unless provided. |
| | 2051 | |
| | 2052 | /** |
| | 2053 | * Filter list of MIME types and file extensions. |
| | 2054 | * |
| | 2055 | * Accepted MIME types are set here as PCRE unless provided. |
| | 2056 | * |
| | 2057 | * @since 3.5.0 |
| | 2058 | * |
| | 2059 | * @param array $wp_get_mime_types MIME types keyed by the file extension regex corresponding to those types. |
| | 2060 | */ |
| 1962 | 2061 | return apply_filters( 'mime_types', array( |
| 1963 | 2062 | // Image formats |
| 1964 | 2063 | 'jpg|jpeg|jpe' => 'image/jpeg', |
| … |
… |
function get_allowed_mime_types( $user = null ) {
|
| 2075 | 2174 | if ( empty( $unfiltered ) ) |
| 2076 | 2175 | unset( $t['htm|html'] ); |
| 2077 | 2176 | |
| | 2177 | /** |
| | 2178 | * Filter list of allowed MIME types and file extensions. |
| | 2179 | * |
| | 2180 | * @since 2.0.0 |
| | 2181 | * |
| | 2182 | * @param array $t MIME types keyed by the file extension regex corresponding to |
| | 2183 | * those types. `swf` and `exe` removed from full list. `htm|html` also |
| | 2184 | * removed depending on `$user` capabilities. |
| | 2185 | * @param int|WP_User|null $user User ID, User object or null if not provided (indicates current |
| | 2186 | * user). |
| | 2187 | */ |
| 2078 | 2188 | return apply_filters( 'upload_mimes', $t, $user ); |
| 2079 | 2189 | } |
| 2080 | 2190 | |
| … |
… |
function wp_nonce_ays( $action ) {
|
| 2120 | 2230 | */ |
| 2121 | 2231 | function wp_die( $message = '', $title = '', $args = array() ) { |
| 2122 | 2232 | if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
| | 2233 | /** |
| | 2234 | * Filter callback function when in `DOING_AJAX` context during `wp_die()`. |
| | 2235 | * |
| | 2236 | * @since 3.4.0 |
| | 2237 | * |
| | 2238 | * @param string $function Callback function name. |
| | 2239 | */ |
| 2123 | 2240 | $function = apply_filters( 'wp_die_ajax_handler', '_ajax_wp_die_handler' ); |
| 2124 | 2241 | elseif ( defined( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) |
| | 2242 | /** |
| | 2243 | * Filter callback function when in `XMLRPC_REQUEST` context during `wp_die()`. |
| | 2244 | * |
| | 2245 | * @since 3.4.0 |
| | 2246 | * |
| | 2247 | * @param string $function Callback function name. |
| | 2248 | */ |
| 2125 | 2249 | $function = apply_filters( 'wp_die_xmlrpc_handler', '_xmlrpc_wp_die_handler' ); |
| 2126 | 2250 | else |
| | 2251 | /** |
| | 2252 | * Filter callback function when not in `DOING_AJAX` or `XMLRPC_REQUEST` contexts during |
| | 2253 | * `wp_die()`. |
| | 2254 | * |
| | 2255 | * @since 3.0.0 |
| | 2256 | * |
| | 2257 | * @param string $function Callback function name. |
| | 2258 | */ |
| 2127 | 2259 | $function = apply_filters( 'wp_die_handler', '_default_wp_die_handler' ); |
| 2128 | 2260 | |
| 2129 | 2261 | call_user_func( $function, $message, $title, $args ); |
| … |
… |
function wp_list_pluck( $list, $field ) {
|
| 2746 | 2878 | * @uses add_action() Calls '_admin_menu' hook with 'wp_widgets_add_menu' value. |
| 2747 | 2879 | */ |
| 2748 | 2880 | function wp_maybe_load_widgets() { |
| | 2881 | /** |
| | 2882 | * Filter if Widgets library should be loaded. |
| | 2883 | * |
| | 2884 | * @since 2.8.0 |
| | 2885 | * |
| | 2886 | * @param bool $wp_maybe_load_widgets Default is true. |
| | 2887 | */ |
| 2749 | 2888 | if ( ! apply_filters('load_default_widgets', true) ) |
| 2750 | 2889 | return; |
| 2751 | 2890 | require_once( ABSPATH . WPINC . '/default-widgets.php' ); |
| … |
… |
function _deprecated_function( $function, $version, $replacement = null ) {
|
| 2907 | 3046 | |
| 2908 | 3047 | do_action( 'deprecated_function_run', $function, $replacement, $version ); |
| 2909 | 3048 | |
| 2910 | | // Allow plugin to filter the output error trigger |
| | 3049 | /** |
| | 3050 | * Filter the deprecated function output error trigger. |
| | 3051 | * |
| | 3052 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| | 3053 | * error. |
| | 3054 | * |
| | 3055 | * @since 2.5.0 |
| | 3056 | * |
| | 3057 | * @param bool $deprecated_function_trigger_error Default is true. |
| | 3058 | */ |
| 2911 | 3059 | if ( WP_DEBUG && apply_filters( 'deprecated_function_trigger_error', true ) ) { |
| 2912 | 3060 | if ( function_exists( '__' ) ) { |
| 2913 | 3061 | if ( ! is_null( $replacement ) ) |
| … |
… |
function _deprecated_file( $file, $version, $replacement = null, $message = '' )
|
| 2951 | 3099 | |
| 2952 | 3100 | do_action( 'deprecated_file_included', $file, $replacement, $version, $message ); |
| 2953 | 3101 | |
| 2954 | | // Allow plugin to filter the output error trigger |
| | 3102 | /** |
| | 3103 | * Filter the deprecated file output error trigger. |
| | 3104 | * |
| | 3105 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| | 3106 | * error. |
| | 3107 | * |
| | 3108 | * @since 2.5.0 |
| | 3109 | * |
| | 3110 | * @param bool $deprecated_file_trigger_error Default is true. |
| | 3111 | */ |
| 2955 | 3112 | if ( WP_DEBUG && apply_filters( 'deprecated_file_trigger_error', true ) ) { |
| 2956 | 3113 | $message = empty( $message ) ? '' : ' ' . $message; |
| 2957 | 3114 | if ( function_exists( '__' ) ) { |
| … |
… |
function _deprecated_argument( $function, $version, $message = null ) {
|
| 3001 | 3158 | |
| 3002 | 3159 | do_action( 'deprecated_argument_run', $function, $message, $version ); |
| 3003 | 3160 | |
| 3004 | | // Allow plugin to filter the output error trigger |
| | 3161 | /** |
| | 3162 | * Filter the deprecated argument output error trigger. |
| | 3163 | * |
| | 3164 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| | 3165 | * error. |
| | 3166 | * |
| | 3167 | * @since 3.0.0 |
| | 3168 | * |
| | 3169 | * @param bool $deprecated_argument_trigger_error Default is true. |
| | 3170 | */ |
| 3005 | 3171 | if ( WP_DEBUG && apply_filters( 'deprecated_argument_trigger_error', true ) ) { |
| 3006 | 3172 | if ( function_exists( '__' ) ) { |
| 3007 | 3173 | if ( ! is_null( $message ) ) |
| … |
… |
function _doing_it_wrong( $function, $message, $version ) {
|
| 3041 | 3207 | |
| 3042 | 3208 | do_action( 'doing_it_wrong_run', $function, $message, $version ); |
| 3043 | 3209 | |
| 3044 | | // Allow plugin to filter the output error trigger |
| | 3210 | /** |
| | 3211 | * Filter the "doing it wrong" output error trigger. |
| | 3212 | * |
| | 3213 | * Allows plugins to override if just the `WP_DEBUG` being true is sufficient to trigger the |
| | 3214 | * error. |
| | 3215 | * |
| | 3216 | * @since 3.1.0 |
| | 3217 | * |
| | 3218 | * @param bool $doing_it_wrong_trigger_error Default is true. |
| | 3219 | */ |
| 3045 | 3220 | if ( WP_DEBUG && apply_filters( 'doing_it_wrong_trigger_error', true ) ) { |
| 3046 | 3221 | if ( function_exists( '__' ) ) { |
| 3047 | 3222 | $version = is_null( $version ) ? '' : sprintf( __( '(This message was added in version %s.)' ), $version ); |
| … |
… |
function iis7_supports_permalinks() {
|
| 3121 | 3296 | $supports_permalinks = class_exists('DOMDocument') && isset($_SERVER['IIS_UrlRewriteModule']) && ( php_sapi_name() == 'cgi-fcgi' ); |
| 3122 | 3297 | } |
| 3123 | 3298 | |
| | 3299 | /** |
| | 3300 | * Filter if IIS 7+ supports pretty permalinks. |
| | 3301 | * |
| | 3302 | * @since 2.8.0 |
| | 3303 | * |
| | 3304 | * @param bool $iis7_supports_permalinks True if permalinks are supported, false otherwise. |
| | 3305 | */ |
| 3124 | 3306 | return apply_filters('iis7_supports_permalinks', $supports_permalinks); |
| 3125 | 3307 | } |
| 3126 | 3308 | |
| … |
… |
function global_terms_enabled() {
|
| 3378 | 3560 | |
| 3379 | 3561 | static $global_terms = null; |
| 3380 | 3562 | if ( is_null( $global_terms ) ) { |
| | 3563 | |
| | 3564 | /** |
| | 3565 | * Filter to short circuit whether global terms are enabled. |
| | 3566 | * |
| | 3567 | * @since 3.0.0 |
| | 3568 | * |
| | 3569 | * @param null $global_terms_enabled Expects a filter to return a truthy or falsy value. |
| | 3570 | */ |
| 3381 | 3571 | $filter = apply_filters( 'global_terms_enabled', null ); |
| 3382 | 3572 | if ( ! is_null( $filter ) ) |
| 3383 | 3573 | $global_terms = (bool) $filter; |
| … |
… |
function get_file_data( $file, $default_headers, $context = '' ) {
|
| 3673 | 3863 | // Make sure we catch CR-only line endings. |
| 3674 | 3864 | $file_data = str_replace( "\r", "\n", $file_data ); |
| 3675 | 3865 | |
| | 3866 | /** |
| | 3867 | * Filter extra file headers by context. |
| | 3868 | * |
| | 3869 | * The dynamic part of the hook, `$context`, comes directly from the `$context` function |
| | 3870 | * argument. If the value is the default empty string, this filter will not be called. |
| | 3871 | * |
| | 3872 | * @since 2.9.0 |
| | 3873 | * |
| | 3874 | * @param array $extra_context_headers Empty array by default. |
| | 3875 | */ |
| 3676 | 3876 | if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) { |
| 3677 | 3877 | $extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values |
| 3678 | 3878 | $all_headers = array_merge( $extra_headers, (array) $default_headers ); |
| … |
… |
function wp_allowed_protocols() {
|
| 3894 | 4094 | |
| 3895 | 4095 | if ( empty( $protocols ) ) { |
| 3896 | 4096 | $protocols = array( 'http', 'https', 'ftp', 'ftps', 'mailto', 'news', 'irc', 'gopher', 'nntp', 'feed', 'telnet', 'mms', 'rtsp', 'svn', 'tel', 'fax', 'xmpp' ); |
| | 4097 | /** |
| | 4098 | * Filter the list of protocols allowed in HTML atributes. |
| | 4099 | * |
| | 4100 | * @since 3.0.0 |
| | 4101 | * |
| | 4102 | * @param array $protocols Array of allowed protocols e.g. `http`, `ftp`, `tel` and more. |
| | 4103 | */ |
| 3897 | 4104 | $protocols = apply_filters( 'kses_allowed_protocols', $protocols ); |
| 3898 | 4105 | } |
| 3899 | 4106 | |
| … |
… |
function wp_auth_check_html() {
|
| 4058 | 4265 | if ( $same_domain && force_ssl_login() && ! force_ssl_admin() ) |
| 4059 | 4266 | $same_domain = false; |
| 4060 | 4267 | |
| 4061 | | // Let plugins change this if they know better. |
| | 4268 | /** |
| | 4269 | * Filter the auth check same domain. |
| | 4270 | * |
| | 4271 | * @since 3.6.0 |
| | 4272 | * |
| | 4273 | * @param bool $same_domain True if current domain matches login URL domain. If force SSL login |
| | 4274 | * is true and force SSL admin is false, this value becomes false. |
| | 4275 | */ |
| 4062 | 4276 | $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); |
| 4063 | 4277 | $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; |
| 4064 | 4278 | |