Changes from branches/3.1/wp-includes/functions.php at r18031 to trunk/wp-includes/functions.php at r18321
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r18031 r18321 85 85 global $wp_locale; 86 86 $i = $unixtimestamp; 87 // Sanity check for PHP 5.1.0- 88 if ( false === $i || intval($i) < 0) {87 88 if ( false === $i ) { 89 89 if ( ! $gmt ) 90 90 $i = current_time( 'timestamp' ); … … 121 121 $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); 122 122 $timezone_formats_re = implode( '|', $timezone_formats ); 123 if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) && wp_timezone_supported()) {123 if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) { 124 124 $timezone_string = get_option( 'timezone_string' ); 125 125 if ( $timezone_string ) { … … 289 289 return false; 290 290 $data = trim( $data ); 291 if ( preg_match( '/^s:[0-9]+:.*;$/s', $data ) ) // this should fetch all serialized strings 291 $length = strlen( $data ); 292 if ( $length < 4 ) 293 return false; 294 elseif ( ':' !== $data[1] ) 295 return false; 296 elseif ( ';' !== $data[$length-1] ) 297 return false; 298 elseif ( $data[0] !== 's' ) 299 return false; 300 elseif ( '"' !== $data[$length-2] ) 301 return false; 302 else 292 303 return true; 293 return false;294 304 } 295 305 … … 510 520 511 521 if ( is_object($newvalue) ) 512 $newvalue = wp_clone($newvalue);522 $newvalue = clone $newvalue; 513 523 514 524 $newvalue = sanitize_option( $option, $newvalue ); … … 592 602 593 603 if ( is_object($value) ) 594 $value = wp_clone($value);604 $value = clone $value; 595 605 596 606 $value = sanitize_option( $option, $value ); … … 1292 1302 1293 1303 $headers = wp_remote_retrieve_headers( $response ); 1294 $headers['response'] = $response['response']['code'];1304 $headers['response'] = wp_remote_retrieve_response_code( $response ); 1295 1305 1296 1306 // WP_HTTP no longer follows redirects for HEAD requests. … … 1307 1317 return $headers; 1308 1318 1309 fwrite( $out_fp, $response['body']);1319 fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); 1310 1320 fclose($out_fp); 1311 1321 clearstatcache(); … … 1369 1379 function build_query( $data ) { 1370 1380 return _http_build_query( $data, null, '&', '', false ); 1381 } 1382 1383 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function) 1384 function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) { 1385 $ret = array(); 1386 1387 foreach ( (array) $data as $k => $v ) { 1388 if ( $urlencode) 1389 $k = urlencode($k); 1390 if ( is_int($k) && $prefix != null ) 1391 $k = $prefix.$k; 1392 if ( !empty($key) ) 1393 $k = $key . '%5B' . $k . '%5D'; 1394 if ( $v === NULL ) 1395 continue; 1396 elseif ( $v === FALSE ) 1397 $v = '0'; 1398 1399 if ( is_array($v) || is_object($v) ) 1400 array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); 1401 elseif ( $urlencode ) 1402 array_push($ret, $k.'='.urlencode($v)); 1403 else 1404 array_push($ret, $k.'='.$v); 1405 } 1406 1407 if ( NULL === $sep ) 1408 $sep = ini_get('arg_separator.output'); 1409 1410 return implode($sep, $ret); 1371 1411 } 1372 1412 … … 1513 1553 return false; 1514 1554 1515 return $response['body'];1555 return wp_remote_retrieve_body( $response ); 1516 1556 } 1517 1557 … … 1911 1951 * important to use nonce field in forms. 1912 1952 * 1913 * If you set $echo to true and set $referer to true, then you will need to1914 * retrieve the {@link wp_referer_field() wp referer field}. If you have the1915 * $referer set to true and are echoing the nonce field, it will also echo the1916 * referer field.1917 *1918 1953 * The $action and $name are optional, but if you want to have better security, 1919 1954 * it is strongly suggested to set those two parameters. It is easier to just … … 1939 1974 $name = esc_attr( $name ); 1940 1975 $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; 1976 1977 if ( $referer ) 1978 $nonce_field .= wp_referer_field( false ); 1979 1941 1980 if ( $echo ) 1942 1981 echo $nonce_field; 1943 1944 if ( $referer )1945 wp_referer_field( $echo );1946 1982 1947 1983 return $nonce_field; … … 2109 2145 2110 2146 return rtrim($base, '/') . '/' . ltrim($path, '/'); 2147 } 2148 2149 /** 2150 * Determines a writable directory for temporary files. 2151 * Function's preference is to WP_CONTENT_DIR followed by the return value of <code>sys_get_temp_dir()</code>, before finally defaulting to /tmp/ 2152 * 2153 * In the event that this function does not find a writable location, It may be overridden by the <code>WP_TEMP_DIR</code> constant in your <code>wp-config.php</code> file. 2154 * 2155 * @since 2.5.0 2156 * 2157 * @return string Writable temporary directory 2158 */ 2159 function get_temp_dir() { 2160 static $temp; 2161 if ( defined('WP_TEMP_DIR') ) 2162 return trailingslashit(WP_TEMP_DIR); 2163 2164 if ( $temp ) 2165 return trailingslashit($temp); 2166 2167 $temp = WP_CONTENT_DIR . '/'; 2168 if ( is_dir($temp) && @is_writable($temp) ) 2169 return $temp; 2170 2171 if ( function_exists('sys_get_temp_dir') ) { 2172 $temp = sys_get_temp_dir(); 2173 if ( @is_writable($temp) ) 2174 return trailingslashit($temp); 2175 } 2176 2177 $temp = ini_get('upload_tmp_dir'); 2178 if ( is_dir($temp) && @is_writable($temp) ) 2179 return trailingslashit($temp); 2180 2181 $temp = '/tmp/'; 2182 return $temp; 2111 2183 } 2112 2184 … … 2494 2566 'csv' => 'text/csv', 2495 2567 'tsv' => 'text/tab-separated-values', 2568 'ics' => 'text/calendar', 2496 2569 'rtx' => 'text/richtext', 2497 2570 'css' => 'text/css', … … 2784 2857 die(); 2785 2858 } 2859 2860 /** 2861 * Kill WordPress execution and display XML message with error message. 2862 * 2863 * This is the handler for wp_die when processing XMLRPC requests. 2864 * 2865 * @since 3.2.0 2866 * @access private 2867 * 2868 * @param string $message Error message. 2869 * @param string $title Error title. 2870 * @param string|array $args Optional arguements to control behaviour. 2871 */ 2872 function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { 2873 global $wp_xmlrpc_server; 2874 $defaults = array( 'response' => 500 ); 2875 2876 $r = wp_parse_args($args, $defaults); 2877 2878 if ( $wp_xmlrpc_server ) { 2879 $error = new IXR_Error( $r['response'] , $message); 2880 $wp_xmlrpc_server->output( $error->getXml() ); 2881 } 2882 die(); 2883 } 2884 2885 /** 2886 * Filter to enable special wp_die handler for xmlrpc requests. 2887 * 2888 * @since 3.2.0 2889 * @access private 2890 */ 2891 function _xmlrpc_wp_die_filter() { 2892 return '_xmlrpc_wp_die_handler'; 2893 } 2894 2786 2895 2787 2896 /** … … 3102 3211 3103 3212 /** 3104 * Determines if default embed handlers should be loaded.3105 *3106 * Checks to make sure that the embeds library hasn't already been loaded. If3107 * it hasn't, then it will load the embeds library.3108 *3109 * @since 2.9.03110 */3111 function wp_maybe_load_embeds() {3112 if ( ! apply_filters('load_default_embeds', true) )3113 return;3114 require_once( ABSPATH . WPINC . '/default-embeds.php' );3115 }3116 3117 /**3118 3213 * Determines if Widgets library should be loaded. 3119 3214 * … … 3251 3346 } 3252 3347 return false; 3253 }3254 3255 /**3256 * Secure URL, if available or the given URL.3257 *3258 * @since 2.5.03259 *3260 * @param string $url Complete URL path with transport.3261 * @return string Secure or regular URL path.3262 */3263 function atom_service_url_filter($url)3264 {3265 if ( url_is_accessable_via_ssl($url) )3266 return preg_replace( '/^http:\/\//', 'https://', $url );3267 else3268 return $url;3269 3348 } 3270 3349 … … 3564 3643 3565 3644 /** 3566 * Whether to force SSL used for the Administration Panels.3645 * Whether to force SSL used for the Administration Screens. 3567 3646 * 3568 3647 * @since 2.6.0 … … 3993 4072 */ 3994 4073 function wp_timezone_override_offset() { 3995 if ( !wp_timezone_supported() ) {3996 return false;3997 }3998 4074 if ( !$timezone_string = get_option( 'timezone_string' ) ) { 3999 4075 return false; … … 4006 4082 } 4007 4083 return round( timezone_offset_get( $timezone_object, $datetime_object ) / 3600, 2 ); 4008 }4009 4010 /**4011 * Check for PHP timezone support4012 *4013 * @since 2.9.04014 *4015 * @return bool4016 */4017 function wp_timezone_supported() {4018 $support = false;4019 if (4020 function_exists( 'date_create' ) &&4021 function_exists( 'date_default_timezone_set' ) &&4022 function_exists( 'timezone_identifiers_list' ) &&4023 function_exists( 'timezone_open' ) &&4024 function_exists( 'timezone_offset_get' )4025 ) {4026 $support = true;4027 }4028 return apply_filters( 'timezone_support', $support );4029 4084 } 4030 4085
Note: See TracChangeset
for help on using the changeset viewer.