Changeset 45611 for trunk/src/wp-includes/functions.php
- Timestamp:
- 07/09/2019 05:44:42 AM (7 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/functions.php (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r45602 r45611 98 98 $i = $timestamp_with_offset; 99 99 100 if ( false === $i) {100 if ( ! is_numeric( $i ) ) { 101 101 $i = current_time( 'timestamp', $gmt ); 102 102 } … … 178 178 } 179 179 } 180 $j = @gmdate( $dateformatstring, $i );180 $j = gmdate( $dateformatstring, $i ); 181 181 182 182 /** … … 225 225 226 226 // Match a format like 'j F Y' or 'j. F' 227 if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {227 if ( preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) { 228 228 229 229 foreach ( $months as $key => $month ) { … … 239 239 240 240 // Match a format like 'F jS' or 'F j' and change it to 'j F' 241 if ( @preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) {241 if ( preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) { 242 242 foreach ( $months as $key => $month ) { 243 243 $months[ $key ] = '#' . $month . ' (\d{1,2})(st|nd|rd|th)?#u'; … … 1259 1259 } 1260 1260 1261 @header( $status_header, true, $code ); 1261 if ( ! headers_sent() ) { 1262 header( $status_header, true, $code ); 1263 } 1262 1264 } 1263 1265 … … 1311 1313 */ 1312 1314 function nocache_headers() { 1315 if ( headers_sent() ) { 1316 return; 1317 } 1318 1313 1319 $headers = wp_get_nocache_headers(); 1314 1320 1315 1321 unset( $headers['Last-Modified'] ); 1316 1322 1317 // In PHP 5.3+, make sure we are not sending a Last-Modified header. 1318 if ( function_exists( 'header_remove' ) ) { 1319 @header_remove( 'Last-Modified' ); 1320 } else { 1321 // In PHP 5.2, send an empty Last-Modified header, but only as a 1322 // last resort to override a header already sent. #WP23021 1323 foreach ( headers_list() as $header ) { 1324 if ( 0 === stripos( $header, 'Last-Modified' ) ) { 1325 $headers['Last-Modified'] = ''; 1326 break; 1327 } 1328 } 1329 } 1323 header_remove( 'Last-Modified' ); 1330 1324 1331 1325 foreach ( $headers as $name => $field_value ) { 1332 @header( "{$name}: {$field_value}" );1326 header( "{$name}: {$field_value}" ); 1333 1327 } 1334 1328 } … … 1830 1824 $folder_parts = explode( '/', substr( $target, strlen( $target_parent ) + 1 ) ); 1831 1825 for ( $i = 1, $c = count( $folder_parts ); $i <= $c; $i++ ) { 1832 @chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms );1826 chmod( $target_parent . '/' . implode( '/', array_slice( $folder_parts, 0, $i ) ), $dir_perms ); 1833 1827 } 1834 1828 } … … 2422 2416 } 2423 2417 2424 $ifp = @ fopen( $new_file, 'wb' );2418 $ifp = @fopen( $new_file, 'wb' ); 2425 2419 if ( ! $ifp ) { 2426 2420 return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); 2427 2421 } 2428 2422 2429 @fwrite( $ifp, $bits );2423 fwrite( $ifp, $bits ); 2430 2424 fclose( $ifp ); 2431 2425 clearstatcache(); … … 2435 2429 $perms = $stat['mode'] & 0007777; 2436 2430 $perms = $perms & 0000666; 2437 @chmod( $new_file, $perms );2431 chmod( $new_file, $perms ); 2438 2432 clearstatcache(); 2439 2433 … … 2708 2702 $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; 2709 2703 } elseif ( function_exists( 'getimagesize' ) ) { 2710 $imagesize = getimagesize( $file );2704 $imagesize = @getimagesize( $file ); 2711 2705 $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; 2712 2706 } else { … … 3602 3596 $args[0] = _wp_json_prepare_data( $data ); 3603 3597 3598 // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged -- json_encode() errors are handled after this call 3604 3599 $json = @call_user_func_array( 'json_encode', $args ); 3605 3600 … … 3776 3771 */ 3777 3772 function wp_send_json( $response, $status_code = null ) { 3778 @header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); 3779 if ( null !== $status_code ) { 3780 status_header( $status_code ); 3781 } 3773 if ( ! headers_sent() ) { 3774 header( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ) ); 3775 if ( null !== $status_code ) { 3776 status_header( $status_code ); 3777 } 3778 } 3779 3782 3780 echo wp_json_encode( $response ); 3783 3781 … … 5727 5725 */ 5728 5726 function send_nosniff_header() { 5729 @header( 'X-Content-Type-Options: nosniff' );5727 header( 'X-Content-Type-Options: nosniff' ); 5730 5728 } 5731 5729 … … 5841 5839 */ 5842 5840 function send_frame_options_header() { 5843 @header( 'X-Frame-Options: SAMEORIGIN' );5841 header( 'X-Frame-Options: SAMEORIGIN' ); 5844 5842 } 5845 5843 … … 6415 6413 } 6416 6414 6417 $current_limit = @ini_get( 'memory_limit' );6415 $current_limit = ini_get( 'memory_limit' ); 6418 6416 $current_limit_int = wp_convert_hr_to_bytes( $current_limit ); 6419 6417 … … 6487 6485 6488 6486 if ( -1 === $filtered_limit_int || ( $filtered_limit_int > $wp_max_limit_int && $filtered_limit_int > $current_limit_int ) ) { 6489 if ( false !== @ini_set( 'memory_limit', $filtered_limit ) ) {6487 if ( false !== ini_set( 'memory_limit', $filtered_limit ) ) { 6490 6488 return $filtered_limit; 6491 6489 } else { … … 6493 6491 } 6494 6492 } elseif ( -1 === $wp_max_limit_int || $wp_max_limit_int > $current_limit_int ) { 6495 if ( false !== @ini_set( 'memory_limit', $wp_max_limit ) ) {6493 if ( false !== ini_set( 'memory_limit', $wp_max_limit ) ) { 6496 6494 return $wp_max_limit; 6497 6495 } else { … … 7180 7178 7181 7179 /** 7182 * Checks compatibility with the current WordPress version.7183 *7184 * @since 5.2.07185 *7186 * @param string $required Minimum required WordPress version.7187 * @return bool True if required version is compatible or empty, false if not.7188 */7180 * Checks compatibility with the current WordPress version. 7181 * 7182 * @since 5.2.0 7183 * 7184 * @param string $required Minimum required WordPress version. 7185 * @return bool True if required version is compatible or empty, false if not. 7186 */ 7189 7187 function is_wp_version_compatible( $required ) { 7190 7188 return empty( $required ) || version_compare( get_bloginfo( 'version' ), $required, '>=' );
Note: See TracChangeset
for help on using the changeset viewer.