Changes from branches/3.1/wp-includes/functions.php at r18031 to trunk/wp-includes/functions.php at r18130
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r18031 r18130 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 ); … … 591 601 wp_protect_special_option( $option ); 592 602 603 /* 604 * FIXME the next two lines of code are not necessary and should be removed. 605 * @see http://core.trac.wordpress.org/ticket/13480 606 */ 593 607 if ( is_object($value) ) 594 $value = wp_clone($value);608 $value = clone $value; 595 609 596 610 $value = sanitize_option( $option, $value ); … … 1292 1306 1293 1307 $headers = wp_remote_retrieve_headers( $response ); 1294 $headers['response'] = $response['response']['code'];1308 $headers['response'] = wp_remote_retrieve_response_code( $response ); 1295 1309 1296 1310 // WP_HTTP no longer follows redirects for HEAD requests. … … 1307 1321 return $headers; 1308 1322 1309 fwrite( $out_fp, $response['body']);1323 fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); 1310 1324 fclose($out_fp); 1311 1325 clearstatcache(); … … 1369 1383 function build_query( $data ) { 1370 1384 return _http_build_query( $data, null, '&', '', false ); 1385 } 1386 1387 // from php.net (modified by Mark Jaquith to behave like the native PHP5 function) 1388 function _http_build_query($data, $prefix=null, $sep=null, $key='', $urlencode=true) { 1389 $ret = array(); 1390 1391 foreach ( (array) $data as $k => $v ) { 1392 if ( $urlencode) 1393 $k = urlencode($k); 1394 if ( is_int($k) && $prefix != null ) 1395 $k = $prefix.$k; 1396 if ( !empty($key) ) 1397 $k = $key . '%5B' . $k . '%5D'; 1398 if ( $v === NULL ) 1399 continue; 1400 elseif ( $v === FALSE ) 1401 $v = '0'; 1402 1403 if ( is_array($v) || is_object($v) ) 1404 array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); 1405 elseif ( $urlencode ) 1406 array_push($ret, $k.'='.urlencode($v)); 1407 else 1408 array_push($ret, $k.'='.$v); 1409 } 1410 1411 if ( NULL === $sep ) 1412 $sep = ini_get('arg_separator.output'); 1413 1414 return implode($sep, $ret); 1371 1415 } 1372 1416 … … 1513 1557 return false; 1514 1558 1515 return $response['body'];1559 return wp_remote_retrieve_body( $response ); 1516 1560 } 1517 1561 … … 1911 1955 * important to use nonce field in forms. 1912 1956 * 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 1957 * The $action and $name are optional, but if you want to have better security, 1919 1958 * it is strongly suggested to set those two parameters. It is easier to just … … 1939 1978 $name = esc_attr( $name ); 1940 1979 $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; 1980 1981 if ( $referer ) 1982 $nonce_field .= wp_referer_field( false ); 1983 1941 1984 if ( $echo ) 1942 1985 echo $nonce_field; 1943 1944 if ( $referer )1945 wp_referer_field( $echo );1946 1986 1947 1987 return $nonce_field; … … 2109 2149 2110 2150 return rtrim($base, '/') . '/' . ltrim($path, '/'); 2151 } 2152 2153 /** 2154 * Determines a writable directory for temporary files. 2155 * 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/ 2156 * 2157 * 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. 2158 * 2159 * @since 2.5.0 2160 * 2161 * @return string Writable temporary directory 2162 */ 2163 function get_temp_dir() { 2164 static $temp; 2165 if ( defined('WP_TEMP_DIR') ) 2166 return trailingslashit(WP_TEMP_DIR); 2167 2168 if ( $temp ) 2169 return trailingslashit($temp); 2170 2171 $temp = WP_CONTENT_DIR . '/'; 2172 if ( is_dir($temp) && @is_writable($temp) ) 2173 return $temp; 2174 2175 if ( function_exists('sys_get_temp_dir') ) { 2176 $temp = sys_get_temp_dir(); 2177 if ( @is_writable($temp) ) 2178 return trailingslashit($temp); 2179 } 2180 2181 $temp = ini_get('upload_tmp_dir'); 2182 if ( is_dir($temp) && @is_writable($temp) ) 2183 return trailingslashit($temp); 2184 2185 $temp = '/tmp/'; 2186 return $temp; 2111 2187 } 2112 2188 … … 2494 2570 'csv' => 'text/csv', 2495 2571 'tsv' => 'text/tab-separated-values', 2572 'ics' => 'text/calendar', 2496 2573 'rtx' => 'text/richtext', 2497 2574 'css' => 'text/css', … … 2784 2861 die(); 2785 2862 } 2863 2864 /** 2865 * Kill WordPress execution and display XML message with error message. 2866 * 2867 * This is the handler for wp_die when processing XMLRPC requests. 2868 * 2869 * @since 3.2.0 2870 * @access private 2871 * 2872 * @param string $message Error message. 2873 * @param string $title Error title. 2874 * @param string|array $args Optional arguements to control behaviour. 2875 */ 2876 function _xmlrpc_wp_die_handler( $message, $title = '', $args = array() ) { 2877 global $wp_xmlrpc_server; 2878 $defaults = array( 'response' => 500 ); 2879 2880 $r = wp_parse_args($args, $defaults); 2881 2882 if ( $wp_xmlrpc_server ) { 2883 $error = new IXR_Error( $r['response'] , $message); 2884 $wp_xmlrpc_server->output( $error->getXml() ); 2885 } 2886 die(); 2887 } 2888 2889 /** 2890 * Filter to enable special wp_die handler for xmlrpc requests. 2891 * 2892 * @since 3.2.0 2893 * @access private 2894 */ 2895 function _xmlrpc_wp_die_filter() { 2896 return '_xmlrpc_wp_die_handler'; 2897 } 2898 2786 2899 2787 2900 /** … … 3102 3215 3103 3216 /** 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 3217 * Determines if Widgets library should be loaded. 3119 3218 * … … 3251 3350 } 3252 3351 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 3352 } 3270 3353 … … 3564 3647 3565 3648 /** 3566 * Whether to force SSL used for the Administration Panels.3649 * Whether to force SSL used for the Administration Screens. 3567 3650 * 3568 3651 * @since 2.6.0 … … 3993 4076 */ 3994 4077 function wp_timezone_override_offset() { 3995 if ( !wp_timezone_supported() ) {3996 return false;3997 }3998 4078 if ( !$timezone_string = get_option( 'timezone_string' ) ) { 3999 4079 return false; … … 4006 4086 } 4007 4087 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 4088 } 4030 4089
Note: See TracChangeset
for help on using the changeset viewer.