Changeset 42343 for trunk/src/wp-includes/functions.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/functions.php
r42261 r42343 25 25 */ 26 26 function mysql2date( $format, $date, $translate = true ) { 27 if ( empty( $date ) ) 27 if ( empty( $date ) ) { 28 28 return false; 29 30 if ( 'G' == $format ) 29 } 30 31 if ( 'G' == $format ) { 31 32 return strtotime( $date . ' +0000' ); 33 } 32 34 33 35 $i = strtotime( $date ); 34 36 35 if ( 'U' == $format ) 37 if ( 'U' == $format ) { 36 38 return $i; 37 38 if ( $translate ) 39 } 40 41 if ( $translate ) { 39 42 return date_i18n( $format, $i ); 40 else43 } else { 41 44 return date( $format, $i ); 45 } 42 46 } 43 47 … … 101 105 $req_format = $dateformatstring; 102 106 103 if ( ( ! empty( $wp_locale->month ) ) && ( !empty( $wp_locale->weekday ) ) ) {104 $datemonth = $wp_locale->get_month( date( 'm', $i ) );105 $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth );106 $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) );107 $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday );108 $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) );107 if ( ( ! empty( $wp_locale->month ) ) && ( ! empty( $wp_locale->weekday ) ) ) { 108 $datemonth = $wp_locale->get_month( date( 'm', $i ) ); 109 $datemonth_abbrev = $wp_locale->get_month_abbrev( $datemonth ); 110 $dateweekday = $wp_locale->get_weekday( date( 'w', $i ) ); 111 $dateweekday_abbrev = $wp_locale->get_weekday_abbrev( $dateweekday ); 112 $datemeridiem = $wp_locale->get_meridiem( date( 'a', $i ) ); 109 113 $datemeridiem_capital = $wp_locale->get_meridiem( date( 'A', $i ) ); 110 $dateformatstring = ' '.$dateformatstring;111 $dateformatstring = preg_replace( "/([^\\\])D/", "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring );112 $dateformatstring = preg_replace( "/([^\\\])F/", "\\1" . backslashit( $datemonth ), $dateformatstring );113 $dateformatstring = preg_replace( "/([^\\\])l/", "\\1" . backslashit( $dateweekday ), $dateformatstring );114 $dateformatstring = preg_replace( "/([^\\\])M/", "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring );115 $dateformatstring = preg_replace( "/([^\\\])a/", "\\1" . backslashit( $datemeridiem ), $dateformatstring );116 $dateformatstring = preg_replace( "/([^\\\])A/", "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring );117 118 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) - 1 );119 } 120 $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' );114 $dateformatstring = ' ' . $dateformatstring; 115 $dateformatstring = preg_replace( '/([^\\\])D/', "\\1" . backslashit( $dateweekday_abbrev ), $dateformatstring ); 116 $dateformatstring = preg_replace( '/([^\\\])F/', "\\1" . backslashit( $datemonth ), $dateformatstring ); 117 $dateformatstring = preg_replace( '/([^\\\])l/', "\\1" . backslashit( $dateweekday ), $dateformatstring ); 118 $dateformatstring = preg_replace( '/([^\\\])M/', "\\1" . backslashit( $datemonth_abbrev ), $dateformatstring ); 119 $dateformatstring = preg_replace( '/([^\\\])a/', "\\1" . backslashit( $datemeridiem ), $dateformatstring ); 120 $dateformatstring = preg_replace( '/([^\\\])A/', "\\1" . backslashit( $datemeridiem_capital ), $dateformatstring ); 121 122 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) - 1 ); 123 } 124 $timezone_formats = array( 'P', 'I', 'O', 'T', 'Z', 'e' ); 121 125 $timezone_formats_re = implode( '|', $timezone_formats ); 122 126 if ( preg_match( "/$timezone_formats_re/", $dateformatstring ) ) { … … 124 128 if ( $timezone_string ) { 125 129 $timezone_object = timezone_open( $timezone_string ); 126 $date_object = date_create( null, $timezone_object );130 $date_object = date_create( null, $timezone_object ); 127 131 foreach ( $timezone_formats as $timezone_format ) { 128 132 if ( false !== strpos( $dateformatstring, $timezone_format ) ) { 129 $formatted = date_format( $date_object, $timezone_format );130 $dateformatstring = ' ' .$dateformatstring;133 $formatted = date_format( $date_object, $timezone_format ); 134 $dateformatstring = ' ' . $dateformatstring; 131 135 $dateformatstring = preg_replace( "/([^\\\])$timezone_format/", "\\1" . backslashit( $formatted ), $dateformatstring ); 132 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) - 1 );136 $dateformatstring = substr( $dateformatstring, 1, strlen( $dateformatstring ) - 1 ); 133 137 } 134 138 } … … 304 308 $weekday = date( 'w', $day ); 305 309 306 if ( ! is_numeric($start_of_week) )310 if ( ! is_numeric( $start_of_week ) ) { 307 311 $start_of_week = get_option( 'start_of_week' ); 308 309 if ( $weekday < $start_of_week ) 312 } 313 314 if ( $weekday < $start_of_week ) { 310 315 $weekday += 7; 316 } 311 317 312 318 // The most recent week start day on or before $day. … … 327 333 */ 328 334 function maybe_unserialize( $original ) { 329 if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in335 if ( is_serialized( $original ) ) { // don't attempt to unserialize data that wasn't serialized going in 330 336 return @unserialize( $original ); 337 } 331 338 return $original; 332 339 } … … 350 357 } 351 358 $data = trim( $data ); 352 359 if ( 'N;' == $data ) { 353 360 return true; 354 361 } … … 368 375 $brace = strpos( $data, '}' ); 369 376 // Either ; or } must exist. 370 if ( false === $semicolon && false === $brace ) 377 if ( false === $semicolon && false === $brace ) { 371 378 return false; 379 } 372 380 // But neither must be in the first X characters. 373 if ( false !== $semicolon && $semicolon < 3 ) 381 if ( false !== $semicolon && $semicolon < 3 ) { 374 382 return false; 375 if ( false !== $brace && $brace < 4 ) 383 } 384 if ( false !== $brace && $brace < 4 ) { 376 385 return false; 386 } 377 387 } 378 388 $token = $data[0]; 379 389 switch ( $token ) { 380 case 's' 390 case 's': 381 391 if ( $strict ) { 382 392 if ( '"' !== substr( $data, -2, 1 ) ) { … … 387 397 } 388 398 // or else fall through 389 case 'a' 390 case 'O' 399 case 'a': 400 case 'O': 391 401 return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); 392 case 'b' 393 case 'i' 394 case 'd' 402 case 'b': 403 case 'i': 404 case 'd': 395 405 $end = $strict ? '$' : ''; 396 406 return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); … … 437 447 */ 438 448 function maybe_serialize( $data ) { 439 if ( is_array( $data ) || is_object( $data ) ) 449 if ( is_array( $data ) || is_object( $data ) ) { 440 450 return serialize( $data ); 451 } 441 452 442 453 // Double serialization is required for backward compatibility. 443 454 // See https://core.trac.wordpress.org/ticket/12930 444 455 // Also the world will end. See WP 3.6.1. 445 if ( is_serialized( $data, false ) ) 456 if ( is_serialized( $data, false ) ) { 446 457 return serialize( $data ); 458 } 447 459 448 460 return $data; … … 523 535 preg_match_all( 524 536 "#([\"']?)(" 525 . "(?:([\w-]+:)?//?)"526 . "[^\s()<>]+"527 . "[.]"528 . "(?:"529 . "\([\w\d]+\)|"530 . "(?:"537 . '(?:([\w-]+:)?//?)' 538 . '[^\s()<>]+' 539 . '[.]' 540 . '(?:' 541 . '\([\w\d]+\)|' 542 . '(?:' 531 543 . "[^`!()\[\]{};:'\".,<>«»“”‘’\s]|" 532 . "(?:[:]\d+)?/?"533 . ")+"534 . ")"544 . '(?:[:]\d+)?/?' 545 . ')+' 546 . ')' 535 547 . ")\\1#", 536 548 $content, … … 571 583 foreach ( $pung as $link_test ) { 572 584 if ( ! in_array( $link_test, $post_links_temp ) ) { // link no longer in post 573 $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%') );574 foreach ( $mids as $mid ) 585 $mids = $wpdb->get_col( $wpdb->prepare( "SELECT meta_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $link_test ) . '%' ) ); 586 foreach ( $mids as $mid ) { 575 587 delete_metadata_by_mid( 'post', $mid ); 588 } 576 589 } 577 590 } 578 591 579 592 foreach ( (array) $post_links_temp as $link_test ) { 580 if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already593 if ( ! in_array( $link_test, $pung ) ) { // If we haven't pung it already 581 594 $test = @parse_url( $link_test ); 582 if ( false === $test ) 595 if ( false === $test ) { 583 596 continue; 584 if ( isset( $test['query'] ) ) 597 } 598 if ( isset( $test['query'] ) ) { 585 599 $post_links[] = $link_test; 586 elseif ( isset($test['path']) && ( $test['path'] != '/' ) && ($test['path'] != '' ) )600 } elseif ( isset( $test['path'] ) && ( $test['path'] != '/' ) && ( $test['path'] != '' ) ) { 587 601 $post_links[] = $link_test; 602 } 588 603 } 589 604 } … … 603 618 604 619 foreach ( (array) $post_links as $url ) { 605 if ( $url != '' && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) {606 607 if ( $headers = wp_get_http_headers( $url ) ) {608 $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0;609 $type = isset( $headers['content-type'] ) ? $headers['content-type'] : '';620 if ( $url != '' && ! $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE post_id = %d AND meta_key = 'enclosure' AND meta_value LIKE %s", $post_ID, $wpdb->esc_like( $url ) . '%' ) ) ) { 621 622 if ( $headers = wp_get_http_headers( $url ) ) { 623 $len = isset( $headers['content-length'] ) ? (int) $headers['content-length'] : 0; 624 $type = isset( $headers['content-type'] ) ? $headers['content-type'] : ''; 610 625 $allowed_types = array( 'video', 'audio' ); 611 626 … … 615 630 if ( false !== $url_parts ) { 616 631 $extension = pathinfo( $url_parts['path'], PATHINFO_EXTENSION ); 617 if ( ! empty( $extension ) ) {632 if ( ! empty( $extension ) ) { 618 633 foreach ( wp_get_mime_types() as $exts => $mime ) { 619 634 if ( preg_match( '!^(' . $exts . ')$!i', $extension ) ) { … … 625 640 } 626 641 627 if ( in_array( substr( $type, 0, strpos( $type, "/") ), $allowed_types ) ) {642 if ( in_array( substr( $type, 0, strpos( $type, '/' ) ), $allowed_types ) ) { 628 643 add_post_meta( $post_ID, 'enclosure', "$url\n$len\n$mime\n" ); 629 644 } … … 643 658 */ 644 659 function wp_get_http_headers( $url, $deprecated = false ) { 645 if ( ! empty( $deprecated ) )660 if ( ! empty( $deprecated ) ) { 646 661 _deprecated_argument( __FUNCTION__, '2.7.0' ); 662 } 647 663 648 664 $response = wp_safe_remote_head( $url ); 649 665 650 if ( is_wp_error( $response ) ) 666 if ( is_wp_error( $response ) ) { 651 667 return false; 668 } 652 669 653 670 return wp_remote_retrieve_headers( $response ); … … 667 684 function is_new_day() { 668 685 global $currentday, $previousday; 669 if ( $currentday != $previousday ) 686 if ( $currentday != $previousday ) { 670 687 return 1; 671 else688 } else { 672 689 return 0; 690 } 673 691 } 674 692 … … 683 701 * @see _http_build_query() Used to build the query 684 702 * @link https://secure.php.net/manual/en/function.http-build-query.php for more on what 685 * 703 * http_build_query() does. 686 704 * 687 705 * @param array $data URL-encode key/value pairs. … … 714 732 715 733 foreach ( (array) $data as $k => $v ) { 716 if ( $urlencode) 717 $k = urlencode($k); 718 if ( is_int($k) && $prefix != null ) 719 $k = $prefix.$k; 720 if ( !empty($key) ) 734 if ( $urlencode ) { 735 $k = urlencode( $k ); 736 } 737 if ( is_int( $k ) && $prefix != null ) { 738 $k = $prefix . $k; 739 } 740 if ( ! empty( $key ) ) { 721 741 $k = $key . '%5B' . $k . '%5D'; 722 if ( $v === null ) 742 } 743 if ( $v === null ) { 723 744 continue; 724 elseif ( $v === false )745 } elseif ( $v === false ) { 725 746 $v = '0'; 726 727 if ( is_array($v) || is_object($v) ) 728 array_push($ret,_http_build_query($v, '', $sep, $k, $urlencode)); 729 elseif ( $urlencode ) 730 array_push($ret, $k.'='.urlencode($v)); 731 else 732 array_push($ret, $k.'='.$v); 733 } 734 735 if ( null === $sep ) 736 $sep = ini_get('arg_separator.output'); 737 738 return implode($sep, $ret); 747 } 748 749 if ( is_array( $v ) || is_object( $v ) ) { 750 array_push( $ret, _http_build_query( $v, '', $sep, $k, $urlencode ) ); 751 } elseif ( $urlencode ) { 752 array_push( $ret, $k . '=' . urlencode( $v ) ); 753 } else { 754 array_push( $ret, $k . '=' . $v ); 755 } 756 } 757 758 if ( null === $sep ) { 759 $sep = ini_get( 'arg_separator.output' ); 760 } 761 762 return implode( $sep, $ret ); 739 763 } 740 764 … … 777 801 $args = func_get_args(); 778 802 if ( is_array( $args[0] ) ) { 779 if ( count( $args ) < 2 || false === $args[1] ) 803 if ( count( $args ) < 2 || false === $args[1] ) { 780 804 $uri = $_SERVER['REQUEST_URI']; 781 else805 } else { 782 806 $uri = $args[1]; 807 } 783 808 } else { 784 if ( count( $args ) < 3 || false === $args[2] ) 809 if ( count( $args ) < 3 || false === $args[2] ) { 785 810 $uri = $_SERVER['REQUEST_URI']; 786 else811 } else { 787 812 $uri = $args[2]; 788 } 789 790 if ( $frag = strstr( $uri, '#' ) ) 813 } 814 } 815 816 if ( $frag = strstr( $uri, '#' ) ) { 791 817 $uri = substr( $uri, 0, -strlen( $frag ) ); 792 else818 } else { 793 819 $frag = ''; 820 } 794 821 795 822 if ( 0 === stripos( $uri, 'http://' ) ) { 796 823 $protocol = 'http://'; 797 $uri = substr( $uri, 7 );824 $uri = substr( $uri, 7 ); 798 825 } elseif ( 0 === stripos( $uri, 'https://' ) ) { 799 826 $protocol = 'https://'; 800 $uri = substr( $uri, 8 );827 $uri = substr( $uri, 8 ); 801 828 } else { 802 829 $protocol = ''; … … 805 832 if ( strpos( $uri, '?' ) !== false ) { 806 833 list( $base, $query ) = explode( '?', $uri, 2 ); 807 $base .= '?';834 $base .= '?'; 808 835 } elseif ( $protocol || strpos( $uri, '=' ) === false ) { 809 $base = $uri . '?';836 $base = $uri . '?'; 810 837 $query = ''; 811 838 } else { 812 $base = '';839 $base = ''; 813 840 $query = $uri; 814 841 } … … 825 852 826 853 foreach ( $qs as $k => $v ) { 827 if ( $v === false ) 828 unset( $qs[$k] ); 854 if ( $v === false ) { 855 unset( $qs[ $k ] ); 856 } 829 857 } 830 858 … … 848 876 function remove_query_arg( $key, $query = false ) { 849 877 if ( is_array( $key ) ) { // removing multiple keys 850 foreach ( $key as $k ) 878 foreach ( $key as $k ) { 851 879 $query = add_query_arg( $k, false, $query ); 880 } 852 881 return $query; 853 882 } … … 910 939 foreach ( (array) $array as $k => $v ) { 911 940 if ( is_array( $v ) ) { 912 $array[ $k] = add_magic_quotes( $v );941 $array[ $k ] = add_magic_quotes( $v ); 913 942 } else { 914 $array[ $k] = addslashes( $v );943 $array[ $k ] = addslashes( $v ); 915 944 } 916 945 } … … 931 960 $parsed_url = @parse_url( $uri ); 932 961 933 if ( ! $parsed_url || !is_array( $parsed_url ) )962 if ( ! $parsed_url || ! is_array( $parsed_url ) ) { 934 963 return false; 935 936 $options = array(); 964 } 965 966 $options = array(); 937 967 $options['timeout'] = 10; 938 968 939 969 $response = wp_safe_remote_get( $uri, $options ); 940 970 941 if ( is_wp_error( $response ) ) 971 if ( is_wp_error( $response ) ) { 942 972 return false; 973 } 943 974 944 975 return wp_remote_retrieve_body( $response ); … … 960 991 $wp->main( $query_vars ); 961 992 962 if ( ! isset($wp_the_query) )993 if ( ! isset( $wp_the_query ) ) { 963 994 $wp_the_query = $wp_query; 995 } 964 996 } 965 997 … … 982 1014 $code = absint( $code ); 983 1015 984 if ( ! isset( $wp_header_to_desc ) ) {1016 if ( ! isset( $wp_header_to_desc ) ) { 985 1017 $wp_header_to_desc = array( 986 1018 100 => 'Continue', … … 1051 1083 } 1052 1084 1053 if ( isset( $wp_header_to_desc[ $code] ) )1054 return $wp_header_to_desc[ $code];1055 else1085 if ( isset( $wp_header_to_desc[ $code ] ) ) { 1086 return $wp_header_to_desc[ $code ]; 1087 } else { 1056 1088 return ''; 1089 } 1057 1090 } 1058 1091 … … 1077 1110 } 1078 1111 1079 $protocol = wp_get_server_protocol();1112 $protocol = wp_get_server_protocol(); 1080 1113 $status_header = "$protocol $code $description"; 1081 if ( function_exists( 'apply_filters' ) ) 1114 if ( function_exists( 'apply_filters' ) ) { 1082 1115 1083 1116 /** … … 1092 1125 */ 1093 1126 $status_header = apply_filters( 'status_header', $status_header, $code, $description, $protocol ); 1127 } 1094 1128 1095 1129 @header( $status_header, true, $code ); … … 1108 1142 function wp_get_nocache_headers() { 1109 1143 $headers = array( 1110 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT',1144 'Expires' => 'Wed, 11 Jan 1984 05:00:00 GMT', 1111 1145 'Cache-Control' => 'no-cache, must-revalidate, max-age=0', 1112 1146 ); 1113 1147 1114 if ( function_exists( 'apply_filters') ) {1148 if ( function_exists( 'apply_filters' ) ) { 1115 1149 /** 1116 1150 * Filters the cache-controlling headers. … … 1163 1197 } 1164 1198 1165 foreach ( $headers as $name => $field_value ) 1166 @header("{$name}: {$field_value}"); 1199 foreach ( $headers as $name => $field_value ) { 1200 @header( "{$name}: {$field_value}" ); 1201 } 1167 1202 } 1168 1203 … … 1175 1210 $expiresOffset = 10 * DAY_IN_SECONDS; 1176 1211 1177 header( "Content-Type: text/javascript; charset=". get_bloginfo( 'charset' ) );1178 header( "Vary: Accept-Encoding"); // Handle proxies1179 header( "Expires: " . gmdate( "D, d M Y H:i:s", time() + $expiresOffset ) . " GMT");1212 header( 'Content-Type: text/javascript; charset=' . get_bloginfo( 'charset' ) ); 1213 header( 'Vary: Accept-Encoding' ); // Handle proxies 1214 header( 'Expires: ' . gmdate( 'D, d M Y H:i:s', time() + $expiresOffset ) . ' GMT' ); 1180 1215 } 1181 1216 … … 1228 1263 $feed = preg_replace( '/^_+/', '', $feed ); 1229 1264 1230 if ( $feed == '' || $feed == 'feed' ) 1265 if ( $feed == '' || $feed == 'feed' ) { 1231 1266 $feed = get_default_feed(); 1267 } 1232 1268 1233 1269 if ( ! has_action( "do_feed_{$feed}" ) ) { … … 1282 1318 */ 1283 1319 function do_feed_rss2( $for_comments ) { 1284 if ( $for_comments ) 1320 if ( $for_comments ) { 1285 1321 load_template( ABSPATH . WPINC . '/feed-rss2-comments.php' ); 1286 else1322 } else { 1287 1323 load_template( ABSPATH . WPINC . '/feed-rss2.php' ); 1324 } 1288 1325 } 1289 1326 … … 1298 1335 */ 1299 1336 function do_feed_atom( $for_comments ) { 1300 if ( $for_comments)1301 load_template( ABSPATH . WPINC . '/feed-atom-comments.php' );1302 else1337 if ( $for_comments ) { 1338 load_template( ABSPATH . WPINC . '/feed-atom-comments.php' ); 1339 } else { 1303 1340 load_template( ABSPATH . WPINC . '/feed-atom.php' ); 1341 } 1304 1342 } 1305 1343 … … 1328 1366 } else { 1329 1367 $site_url = parse_url( site_url() ); 1330 $path = ( !empty( $site_url['path'] ) ) ? $site_url['path'] : '';1331 $output .= "Disallow: $path/wp-admin/\n";1332 $output .= "Allow: $path/wp-admin/admin-ajax.php\n";1368 $path = ( ! empty( $site_url['path'] ) ) ? $site_url['path'] : ''; 1369 $output .= "Disallow: $path/wp-admin/\n"; 1370 $output .= "Allow: $path/wp-admin/admin-ajax.php\n"; 1333 1371 } 1334 1372 … … 1366 1404 * cached, oh well. 1367 1405 */ 1368 if ( wp_cache_get( 'is_blog_installed' ) ) 1406 if ( wp_cache_get( 'is_blog_installed' ) ) { 1369 1407 return true; 1408 } 1370 1409 1371 1410 $suppress = $wpdb->suppress_errors(); … … 1374 1413 } 1375 1414 // If siteurl is not set to autoload, check it specifically 1376 if ( ! isset( $alloptions['siteurl'] ) )1415 if ( ! isset( $alloptions['siteurl'] ) ) { 1377 1416 $installed = $wpdb->get_var( "SELECT option_value FROM $wpdb->options WHERE option_name = 'siteurl'" ); 1378 else1417 } else { 1379 1418 $installed = $alloptions['siteurl']; 1419 } 1380 1420 $wpdb->suppress_errors( $suppress ); 1381 1421 1382 $installed = ! empty( $installed );1422 $installed = ! empty( $installed ); 1383 1423 wp_cache_set( 'is_blog_installed', $installed ); 1384 1424 1385 if ( $installed ) 1425 if ( $installed ) { 1386 1426 return true; 1427 } 1387 1428 1388 1429 // If visiting repair.php, return true and let it take over. 1389 if ( defined( 'WP_REPAIRING' ) ) 1430 if ( defined( 'WP_REPAIRING' ) ) { 1390 1431 return true; 1432 } 1391 1433 1392 1434 $suppress = $wpdb->suppress_errors(); … … 1400 1442 foreach ( $wp_tables as $table ) { 1401 1443 // The existence of custom user tables shouldn't suggest an insane state or prevent a clean installation. 1402 if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) 1444 if ( defined( 'CUSTOM_USER_TABLE' ) && CUSTOM_USER_TABLE == $table ) { 1403 1445 continue; 1404 if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) 1446 } 1447 if ( defined( 'CUSTOM_USER_META_TABLE' ) && CUSTOM_USER_META_TABLE == $table ) { 1405 1448 continue; 1406 1407 if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) 1449 } 1450 1451 if ( ! $wpdb->get_results( "DESCRIBE $table;" ) ) { 1408 1452 continue; 1453 } 1409 1454 1410 1455 // One or more tables exist. We are insane. … … 1470 1515 * @return string Nonce field HTML markup. 1471 1516 */ 1472 function wp_nonce_field( $action = -1, $name = "_wpnonce", $referer = true, $echo = true ) {1473 $name = esc_attr( $name );1517 function wp_nonce_field( $action = -1, $name = '_wpnonce', $referer = true, $echo = true ) { 1518 $name = esc_attr( $name ); 1474 1519 $nonce_field = '<input type="hidden" id="' . $name . '" name="' . $name . '" value="' . wp_create_nonce( $action ) . '" />'; 1475 1520 1476 if ( $referer ) 1521 if ( $referer ) { 1477 1522 $nonce_field .= wp_referer_field( false ); 1478 1479 if ( $echo ) 1523 } 1524 1525 if ( $echo ) { 1480 1526 echo $nonce_field; 1527 } 1481 1528 1482 1529 return $nonce_field; … … 1495 1542 */ 1496 1543 function wp_referer_field( $echo = true ) { 1497 $referer_field = '<input type="hidden" name="_wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />';1498 1499 if ( $echo ) 1544 $referer_field = '<input type="hidden" name="_wp_http_referer" value="' . esc_attr( wp_unslash( $_SERVER['REQUEST_URI'] ) ) . '" />'; 1545 1546 if ( $echo ) { 1500 1547 echo $referer_field; 1548 } 1501 1549 return $referer_field; 1502 1550 } … … 1521 1569 } 1522 1570 $orig_referer_field = '<input type="hidden" name="_wp_original_http_referer" value="' . esc_attr( $ref ) . '" />'; 1523 if ( $echo ) 1571 if ( $echo ) { 1524 1572 echo $orig_referer_field; 1573 } 1525 1574 return $orig_referer_field; 1526 1575 } … … 1561 1610 if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) { 1562 1611 return wp_unslash( $_REQUEST['_wp_http_referer'] ); 1563 } else 1612 } elseif ( ! empty( $_SERVER['HTTP_REFERER'] ) ) { 1564 1613 return wp_unslash( $_SERVER['HTTP_REFERER'] ); 1565 1614 } … … 1576 1625 */ 1577 1626 function wp_get_original_referer() { 1578 if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) 1627 if ( ! empty( $_REQUEST['_wp_original_http_referer'] ) && function_exists( 'wp_validate_redirect' ) ) { 1579 1628 return wp_validate_redirect( wp_unslash( $_REQUEST['_wp_original_http_referer'] ), false ); 1629 } 1580 1630 return false; 1581 1631 } … … 1611 1661 * Use rtrim() instead of untrailingslashit to avoid formatting.php dependency. 1612 1662 */ 1613 $target = rtrim( $target, '/');1614 if ( empty( $target) )1663 $target = rtrim( $target, '/' ); 1664 if ( empty( $target ) ) { 1615 1665 $target = '/'; 1616 1617 if ( file_exists( $target ) ) 1666 } 1667 1668 if ( file_exists( $target ) ) { 1618 1669 return @is_dir( $target ); 1670 } 1619 1671 1620 1672 // We need to find the permissions of the parent folder that exists and inherit that. … … 1665 1717 * a symbolic link. 1666 1718 */ 1667 if ( realpath( $path) == $path )1719 if ( realpath( $path ) == $path ) { 1668 1720 return true; 1669 1670 if ( strlen($path) == 0 || $path[0] == '.' ) 1721 } 1722 1723 if ( strlen( $path ) == 0 || $path[0] == '.' ) { 1671 1724 return false; 1725 } 1672 1726 1673 1727 // Windows allows absolute paths like this. 1674 if ( preg_match( '#^[a-zA-Z]:\\\\#', $path) )1728 if ( preg_match( '#^[a-zA-Z]:\\\\#', $path ) ) { 1675 1729 return true; 1730 } 1676 1731 1677 1732 // A path starting with / or \ is absolute; anything else is relative. … … 1692 1747 */ 1693 1748 function path_join( $base, $path ) { 1694 if ( path_is_absolute( $path) )1749 if ( path_is_absolute( $path ) ) { 1695 1750 return $path; 1696 1697 return rtrim($base, '/') . '/' . ltrim($path, '/'); 1751 } 1752 1753 return rtrim( $base, '/' ) . '/' . ltrim( $path, '/' ); 1698 1754 } 1699 1755 … … 1740 1796 function get_temp_dir() { 1741 1797 static $temp = ''; 1742 if ( defined('WP_TEMP_DIR') ) 1743 return trailingslashit(WP_TEMP_DIR); 1744 1745 if ( $temp ) 1798 if ( defined( 'WP_TEMP_DIR' ) ) { 1799 return trailingslashit( WP_TEMP_DIR ); 1800 } 1801 1802 if ( $temp ) { 1746 1803 return trailingslashit( $temp ); 1747 1748 if ( function_exists('sys_get_temp_dir') ) { 1804 } 1805 1806 if ( function_exists( 'sys_get_temp_dir' ) ) { 1749 1807 $temp = sys_get_temp_dir(); 1750 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) 1808 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { 1751 1809 return trailingslashit( $temp ); 1752 } 1753 1754 $temp = ini_get('upload_tmp_dir'); 1755 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) 1810 } 1811 } 1812 1813 $temp = ini_get( 'upload_tmp_dir' ); 1814 if ( @is_dir( $temp ) && wp_is_writable( $temp ) ) { 1756 1815 return trailingslashit( $temp ); 1816 } 1757 1817 1758 1818 $temp = WP_CONTENT_DIR . '/'; 1759 if ( is_dir( $temp ) && wp_is_writable( $temp ) ) 1819 if ( is_dir( $temp ) && wp_is_writable( $temp ) ) { 1760 1820 return $temp; 1821 } 1761 1822 1762 1823 return '/tmp/'; … … 1777 1838 */ 1778 1839 function wp_is_writable( $path ) { 1779 if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) 1840 if ( 'WIN' === strtoupper( substr( PHP_OS, 0, 3 ) ) ) { 1780 1841 return win_is_writable( $path ); 1781 else1842 } else { 1782 1843 return @is_writable( $path ); 1844 } 1783 1845 } 1784 1846 … … 1801 1863 function win_is_writable( $path ) { 1802 1864 1803 if ( $path[ strlen( $path ) - 1] == '/' ) { // if it looks like a directory, check a random file within the directory1804 return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' );1865 if ( $path[ strlen( $path ) - 1 ] == '/' ) { // if it looks like a directory, check a random file within the directory 1866 return win_is_writable( $path . uniqid( mt_rand() ) . '.tmp' ); 1805 1867 } elseif ( is_dir( $path ) ) { // If it's a directory (and not a file) check a random file within the directory 1806 1868 return win_is_writable( $path . '/' . uniqid( mt_rand() ) . '.tmp' ); 1807 1869 } 1808 1870 // check tmp file for read/write capabilities 1809 $should_delete_tmp_file = ! file_exists( $path );1810 $f = @fopen( $path, 'a' );1811 if ( $f === false ) 1871 $should_delete_tmp_file = ! file_exists( $path ); 1872 $f = @fopen( $path, 'a' ); 1873 if ( $f === false ) { 1812 1874 return false; 1875 } 1813 1876 fclose( $f ); 1814 if ( $should_delete_tmp_file ) 1877 if ( $should_delete_tmp_file ) { 1815 1878 unlink( $path ); 1879 } 1816 1880 return true; 1817 1881 } … … 1929 1993 */ 1930 1994 function _wp_upload_dir( $time = null ) { 1931 $siteurl = get_option( 'siteurl' );1995 $siteurl = get_option( 'siteurl' ); 1932 1996 $upload_path = trim( get_option( 'upload_path' ) ); 1933 1997 … … 1941 2005 } 1942 2006 1943 if ( ! $url = get_option( 'upload_url_path' ) ) {1944 if ( empty( $upload_path) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) )2007 if ( ! $url = get_option( 'upload_url_path' ) ) { 2008 if ( empty( $upload_path ) || ( 'wp-content/uploads' == $upload_path ) || ( $upload_path == $dir ) ) { 1945 2009 $url = WP_CONTENT_URL . '/uploads'; 1946 else2010 } else { 1947 2011 $url = trailingslashit( $siteurl ) . $upload_path; 2012 } 1948 2013 } 1949 2014 … … 1970 2035 */ 1971 2036 1972 if ( defined( 'MULTISITE' ) ) 2037 if ( defined( 'MULTISITE' ) ) { 1973 2038 $ms_dir = '/sites/' . get_current_blog_id(); 1974 else2039 } else { 1975 2040 $ms_dir = '/' . get_current_blog_id(); 2041 } 1976 2042 1977 2043 $dir .= $ms_dir; … … 1993 2059 */ 1994 2060 1995 if ( defined( 'BLOGUPLOADDIR' ) ) 2061 if ( defined( 'BLOGUPLOADDIR' ) ) { 1996 2062 $dir = untrailingslashit( BLOGUPLOADDIR ); 1997 else2063 } else { 1998 2064 $dir = ABSPATH . UPLOADS; 2065 } 1999 2066 $url = trailingslashit( $siteurl ) . 'files'; 2000 2067 } … … 2007 2074 if ( get_option( 'uploads_use_yearmonth_folders' ) ) { 2008 2075 // Generate the yearly and monthly dirs 2009 if ( ! $time )2076 if ( ! $time ) { 2010 2077 $time = current_time( 'mysql' ); 2011 $y = substr( $time, 0, 4 ); 2012 $m = substr( $time, 5, 2 ); 2078 } 2079 $y = substr( $time, 0, 4 ); 2080 $m = substr( $time, 5, 2 ); 2013 2081 $subdir = "/$y/$m"; 2014 2082 } … … 2046 2114 function wp_unique_filename( $dir, $filename, $unique_filename_callback = null ) { 2047 2115 // Sanitize the file name before we begin processing. 2048 $filename = sanitize_file_name( $filename);2116 $filename = sanitize_file_name( $filename ); 2049 2117 2050 2118 // Separate the filename into a name and extension. 2051 $ext = pathinfo( $filename, PATHINFO_EXTENSION );2119 $ext = pathinfo( $filename, PATHINFO_EXTENSION ); 2052 2120 $name = pathinfo( $filename, PATHINFO_BASENAME ); 2053 2121 if ( $ext ) { … … 2070 2138 2071 2139 // Change '.ext' to lower case. 2072 if ( $ext && strtolower( $ext) != $ext ) {2073 $ext2 = strtolower($ext);2074 $filename2 = preg_replace( '|' . preg_quote( $ext) . '$|', $ext2, $filename );2140 if ( $ext && strtolower( $ext ) != $ext ) { 2141 $ext2 = strtolower( $ext ); 2142 $filename2 = preg_replace( '|' . preg_quote( $ext ) . '$|', $ext2, $filename ); 2075 2143 2076 2144 // Check for both lower and upper case extension or image sub-sizes may be overwritten. 2077 while ( file_exists( $dir . "/$filename") || file_exists($dir . "/$filename2") ) {2145 while ( file_exists( $dir . "/$filename" ) || file_exists( $dir . "/$filename2" ) ) { 2078 2146 $new_number = (int) $number + 1; 2079 $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename );2080 $filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 );2081 $number = $new_number;2147 $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-$new_number$ext", $filename ); 2148 $filename2 = str_replace( array( "-$number$ext2", "$number$ext2" ), "-$new_number$ext2", $filename2 ); 2149 $number = $new_number; 2082 2150 } 2083 2151 … … 2100 2168 $filename = "$filename-" . $new_number; 2101 2169 } else { 2102 $filename = str_replace( array( "-$number$ext", "$number$ext" ), "-". $new_number . $ext, $filename );2170 $filename = str_replace( array( "-$number$ext", "$number$ext" ), '-' . $new_number . $ext, $filename ); 2103 2171 } 2104 2172 $number = $new_number; … … 2134 2202 */ 2135 2203 function wp_upload_bits( $name, $deprecated, $bits, $time = null ) { 2136 if ( ! empty( $deprecated ) )2204 if ( ! empty( $deprecated ) ) { 2137 2205 _deprecated_argument( __FUNCTION__, '2.0.0' ); 2138 2139 if ( empty( $name ) ) 2206 } 2207 2208 if ( empty( $name ) ) { 2140 2209 return array( 'error' => __( 'Empty filename' ) ); 2210 } 2141 2211 2142 2212 $wp_filetype = wp_check_filetype( $name ); 2143 if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) 2213 if ( ! $wp_filetype['ext'] && ! current_user_can( 'unfiltered_upload' ) ) { 2144 2214 return array( 'error' => __( 'Sorry, this file type is not permitted for security reasons.' ) ); 2215 } 2145 2216 2146 2217 $upload = wp_upload_dir( $time ); 2147 2218 2148 if ( $upload['error'] !== false ) 2219 if ( $upload['error'] !== false ) { 2149 2220 return $upload; 2221 } 2150 2222 2151 2223 /** … … 2159 2231 * @param mixed $upload_bits_error An array of upload bits data, or a non-array error to return. 2160 2232 */ 2161 $upload_bits_error = apply_filters( 'wp_upload_bits', array( 'name' => $name, 'bits' => $bits, 'time' => $time ) ); 2162 if ( !is_array( $upload_bits_error ) ) { 2163 $upload[ 'error' ] = $upload_bits_error; 2233 $upload_bits_error = apply_filters( 2234 'wp_upload_bits', array( 2235 'name' => $name, 2236 'bits' => $bits, 2237 'time' => $time, 2238 ) 2239 ); 2240 if ( ! is_array( $upload_bits_error ) ) { 2241 $upload['error'] = $upload_bits_error; 2164 2242 return $upload; 2165 2243 } … … 2169 2247 $new_file = $upload['path'] . "/$filename"; 2170 2248 if ( ! wp_mkdir_p( dirname( $new_file ) ) ) { 2171 if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) 2249 if ( 0 === strpos( $upload['basedir'], ABSPATH ) ) { 2172 2250 $error_path = str_replace( ABSPATH, '', $upload['basedir'] ) . $upload['subdir']; 2173 else2251 } else { 2174 2252 $error_path = basename( $upload['basedir'] ) . $upload['subdir']; 2253 } 2175 2254 2176 2255 $message = sprintf( … … 2183 2262 2184 2263 $ifp = @ fopen( $new_file, 'wb' ); 2185 if ( ! $ifp ) 2264 if ( ! $ifp ) { 2186 2265 return array( 'error' => sprintf( __( 'Could not write file %s' ), $new_file ) ); 2266 } 2187 2267 2188 2268 @fwrite( $ifp, $bits ); … … 2191 2271 2192 2272 // Set correct file permissions 2193 $stat = @ stat( dirname( $new_file ) );2273 $stat = @ stat( dirname( $new_file ) ); 2194 2274 $perms = $stat['mode'] & 0007777; 2195 2275 $perms = $perms & 0000666; … … 2201 2281 2202 2282 /** This filter is documented in wp-admin/includes/file.php */ 2203 return apply_filters( 'wp_handle_upload', array( 'file' => $new_file, 'url' => $url, 'type' => $wp_filetype['type'], 'error' => false ), 'sideload' ); 2283 return apply_filters( 2284 'wp_handle_upload', array( 2285 'file' => $new_file, 2286 'url' => $url, 2287 'type' => $wp_filetype['type'], 2288 'error' => false, 2289 ), 'sideload' 2290 ); 2204 2291 } 2205 2292 … … 2216 2303 2217 2304 $ext2type = wp_get_ext_types(); 2218 foreach ( $ext2type as $type => $exts ) 2219 if ( in_array( $ext, $exts ) ) 2305 foreach ( $ext2type as $type => $exts ) { 2306 if ( in_array( $ext, $exts ) ) { 2220 2307 return $type; 2308 } 2309 } 2221 2310 } 2222 2311 … … 2233 2322 */ 2234 2323 function wp_check_filetype( $filename, $mimes = null ) { 2235 if ( empty( $mimes) )2324 if ( empty( $mimes ) ) { 2236 2325 $mimes = get_allowed_mime_types(); 2326 } 2237 2327 $type = false; 2238 $ext = false;2328 $ext = false; 2239 2329 2240 2330 foreach ( $mimes as $ext_preg => $mime_match ) { … … 2242 2332 if ( preg_match( $ext_preg, $filename, $ext_matches ) ) { 2243 2333 $type = $mime_match; 2244 $ext = $ext_matches[1];2334 $ext = $ext_matches[1]; 2245 2335 break; 2246 2336 } … … 2274 2364 // Do basic extension validation and MIME mapping 2275 2365 $wp_filetype = wp_check_filetype( $filename, $mimes ); 2276 $ext = $wp_filetype['ext'];2277 $type = $wp_filetype['type'];2366 $ext = $wp_filetype['ext']; 2367 $type = $wp_filetype['type']; 2278 2368 2279 2369 // We can't do any further validation without a file to work with … … 2298 2388 * @param array $mime_to_ext Array of image mime types and their matching extensions. 2299 2389 */ 2300 $mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array( 2301 'image/jpeg' => 'jpg', 2302 'image/png' => 'png', 2303 'image/gif' => 'gif', 2304 'image/bmp' => 'bmp', 2305 'image/tiff' => 'tif', 2306 ) ); 2390 $mime_to_ext = apply_filters( 2391 'getimagesize_mimes_to_exts', array( 2392 'image/jpeg' => 'jpg', 2393 'image/png' => 'png', 2394 'image/gif' => 'gif', 2395 'image/bmp' => 'bmp', 2396 'image/tiff' => 'tif', 2397 ) 2398 ); 2307 2399 2308 2400 // Replace whatever is after the last period in the filename with the correct extension … … 2311 2403 array_pop( $filename_parts ); 2312 2404 $filename_parts[] = $mime_to_ext[ $real_mime ]; 2313 $new_filename = implode( '.', $filename_parts );2405 $new_filename = implode( '.', $filename_parts ); 2314 2406 2315 2407 if ( $new_filename != $filename ) { … … 2318 2410 // Redefine the extension / MIME 2319 2411 $wp_filetype = wp_check_filetype( $new_filename, $mimes ); 2320 $ext = $wp_filetype['ext'];2321 $type = $wp_filetype['type'];2412 $ext = $wp_filetype['ext']; 2413 $type = $wp_filetype['type']; 2322 2414 } else { 2323 2415 // Reset $real_mime and try validating again. … … 2329 2421 // Validate files that didn't get validated during previous checks. 2330 2422 if ( $type && ! $real_mime && extension_loaded( 'fileinfo' ) ) { 2331 $finfo = finfo_open( FILEINFO_MIME_TYPE );2423 $finfo = finfo_open( FILEINFO_MIME_TYPE ); 2332 2424 $real_mime = finfo_file( $finfo, $file ); 2333 2425 finfo_close( $finfo ); … … 2381 2473 if ( is_callable( 'exif_imagetype' ) ) { 2382 2474 $imagetype = exif_imagetype( $file ); 2383 $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false;2475 $mime = ( $imagetype ) ? image_type_to_mime_type( $imagetype ) : false; 2384 2476 } elseif ( function_exists( 'getimagesize' ) ) { 2385 2477 $imagesize = getimagesize( $file ); 2386 $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false;2478 $mime = ( isset( $imagesize['mime'] ) ) ? $imagesize['mime'] : false; 2387 2479 } else { 2388 2480 $mime = false; … … 2415 2507 * corresponding to those types. 2416 2508 */ 2417 return apply_filters( 'mime_types', array( 2418 // Image formats. 2419 'jpg|jpeg|jpe' => 'image/jpeg', 2420 'gif' => 'image/gif', 2421 'png' => 'image/png', 2422 'bmp' => 'image/bmp', 2423 'tiff|tif' => 'image/tiff', 2424 'ico' => 'image/x-icon', 2425 // Video formats. 2426 'asf|asx' => 'video/x-ms-asf', 2427 'wmv' => 'video/x-ms-wmv', 2428 'wmx' => 'video/x-ms-wmx', 2429 'wm' => 'video/x-ms-wm', 2430 'avi' => 'video/avi', 2431 'divx' => 'video/divx', 2432 'flv' => 'video/x-flv', 2433 'mov|qt' => 'video/quicktime', 2434 'mpeg|mpg|mpe' => 'video/mpeg', 2435 'mp4|m4v' => 'video/mp4', 2436 'ogv' => 'video/ogg', 2437 'webm' => 'video/webm', 2438 'mkv' => 'video/x-matroska', 2439 '3gp|3gpp' => 'video/3gpp', // Can also be audio 2440 '3g2|3gp2' => 'video/3gpp2', // Can also be audio 2441 // Text formats. 2442 'txt|asc|c|cc|h|srt' => 'text/plain', 2443 'csv' => 'text/csv', 2444 'tsv' => 'text/tab-separated-values', 2445 'ics' => 'text/calendar', 2446 'rtx' => 'text/richtext', 2447 'css' => 'text/css', 2448 'htm|html' => 'text/html', 2449 'vtt' => 'text/vtt', 2450 'dfxp' => 'application/ttaf+xml', 2451 // Audio formats. 2452 'mp3|m4a|m4b' => 'audio/mpeg', 2453 'ra|ram' => 'audio/x-realaudio', 2454 'wav' => 'audio/wav', 2455 'ogg|oga' => 'audio/ogg', 2456 'mid|midi' => 'audio/midi', 2457 'wma' => 'audio/x-ms-wma', 2458 'wax' => 'audio/x-ms-wax', 2459 'mka' => 'audio/x-matroska', 2460 // Misc application formats. 2461 'rtf' => 'application/rtf', 2462 'js' => 'application/javascript', 2463 'pdf' => 'application/pdf', 2464 'swf' => 'application/x-shockwave-flash', 2465 'class' => 'application/java', 2466 'tar' => 'application/x-tar', 2467 'zip' => 'application/zip', 2468 'gz|gzip' => 'application/x-gzip', 2469 'rar' => 'application/rar', 2470 '7z' => 'application/x-7z-compressed', 2471 'exe' => 'application/x-msdownload', 2472 'psd' => 'application/octet-stream', 2473 'xcf' => 'application/octet-stream', 2474 // MS Office formats. 2475 'doc' => 'application/msword', 2476 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 2477 'wri' => 'application/vnd.ms-write', 2478 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 2479 'mdb' => 'application/vnd.ms-access', 2480 'mpp' => 'application/vnd.ms-project', 2481 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 2482 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 2483 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 2484 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 2485 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 2486 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 2487 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 2488 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 2489 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 2490 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 2491 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 2492 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 2493 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 2494 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 2495 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 2496 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 2497 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 2498 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 2499 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 2500 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 2501 'oxps' => 'application/oxps', 2502 'xps' => 'application/vnd.ms-xpsdocument', 2503 // OpenOffice formats. 2504 'odt' => 'application/vnd.oasis.opendocument.text', 2505 'odp' => 'application/vnd.oasis.opendocument.presentation', 2506 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 2507 'odg' => 'application/vnd.oasis.opendocument.graphics', 2508 'odc' => 'application/vnd.oasis.opendocument.chart', 2509 'odb' => 'application/vnd.oasis.opendocument.database', 2510 'odf' => 'application/vnd.oasis.opendocument.formula', 2511 // WordPerfect formats. 2512 'wp|wpd' => 'application/wordperfect', 2513 // iWork formats. 2514 'key' => 'application/vnd.apple.keynote', 2515 'numbers' => 'application/vnd.apple.numbers', 2516 'pages' => 'application/vnd.apple.pages', 2517 ) ); 2509 return apply_filters( 2510 'mime_types', array( 2511 // Image formats. 2512 'jpg|jpeg|jpe' => 'image/jpeg', 2513 'gif' => 'image/gif', 2514 'png' => 'image/png', 2515 'bmp' => 'image/bmp', 2516 'tiff|tif' => 'image/tiff', 2517 'ico' => 'image/x-icon', 2518 // Video formats. 2519 'asf|asx' => 'video/x-ms-asf', 2520 'wmv' => 'video/x-ms-wmv', 2521 'wmx' => 'video/x-ms-wmx', 2522 'wm' => 'video/x-ms-wm', 2523 'avi' => 'video/avi', 2524 'divx' => 'video/divx', 2525 'flv' => 'video/x-flv', 2526 'mov|qt' => 'video/quicktime', 2527 'mpeg|mpg|mpe' => 'video/mpeg', 2528 'mp4|m4v' => 'video/mp4', 2529 'ogv' => 'video/ogg', 2530 'webm' => 'video/webm', 2531 'mkv' => 'video/x-matroska', 2532 '3gp|3gpp' => 'video/3gpp', // Can also be audio 2533 '3g2|3gp2' => 'video/3gpp2', // Can also be audio 2534 // Text formats. 2535 'txt|asc|c|cc|h|srt' => 'text/plain', 2536 'csv' => 'text/csv', 2537 'tsv' => 'text/tab-separated-values', 2538 'ics' => 'text/calendar', 2539 'rtx' => 'text/richtext', 2540 'css' => 'text/css', 2541 'htm|html' => 'text/html', 2542 'vtt' => 'text/vtt', 2543 'dfxp' => 'application/ttaf+xml', 2544 // Audio formats. 2545 'mp3|m4a|m4b' => 'audio/mpeg', 2546 'ra|ram' => 'audio/x-realaudio', 2547 'wav' => 'audio/wav', 2548 'ogg|oga' => 'audio/ogg', 2549 'mid|midi' => 'audio/midi', 2550 'wma' => 'audio/x-ms-wma', 2551 'wax' => 'audio/x-ms-wax', 2552 'mka' => 'audio/x-matroska', 2553 // Misc application formats. 2554 'rtf' => 'application/rtf', 2555 'js' => 'application/javascript', 2556 'pdf' => 'application/pdf', 2557 'swf' => 'application/x-shockwave-flash', 2558 'class' => 'application/java', 2559 'tar' => 'application/x-tar', 2560 'zip' => 'application/zip', 2561 'gz|gzip' => 'application/x-gzip', 2562 'rar' => 'application/rar', 2563 '7z' => 'application/x-7z-compressed', 2564 'exe' => 'application/x-msdownload', 2565 'psd' => 'application/octet-stream', 2566 'xcf' => 'application/octet-stream', 2567 // MS Office formats. 2568 'doc' => 'application/msword', 2569 'pot|pps|ppt' => 'application/vnd.ms-powerpoint', 2570 'wri' => 'application/vnd.ms-write', 2571 'xla|xls|xlt|xlw' => 'application/vnd.ms-excel', 2572 'mdb' => 'application/vnd.ms-access', 2573 'mpp' => 'application/vnd.ms-project', 2574 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 2575 'docm' => 'application/vnd.ms-word.document.macroEnabled.12', 2576 'dotx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 2577 'dotm' => 'application/vnd.ms-word.template.macroEnabled.12', 2578 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 2579 'xlsm' => 'application/vnd.ms-excel.sheet.macroEnabled.12', 2580 'xlsb' => 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 2581 'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 2582 'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12', 2583 'xlam' => 'application/vnd.ms-excel.addin.macroEnabled.12', 2584 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 2585 'pptm' => 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 2586 'ppsx' => 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 2587 'ppsm' => 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12', 2588 'potx' => 'application/vnd.openxmlformats-officedocument.presentationml.template', 2589 'potm' => 'application/vnd.ms-powerpoint.template.macroEnabled.12', 2590 'ppam' => 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 2591 'sldx' => 'application/vnd.openxmlformats-officedocument.presentationml.slide', 2592 'sldm' => 'application/vnd.ms-powerpoint.slide.macroEnabled.12', 2593 'onetoc|onetoc2|onetmp|onepkg' => 'application/onenote', 2594 'oxps' => 'application/oxps', 2595 'xps' => 'application/vnd.ms-xpsdocument', 2596 // OpenOffice formats. 2597 'odt' => 'application/vnd.oasis.opendocument.text', 2598 'odp' => 'application/vnd.oasis.opendocument.presentation', 2599 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 2600 'odg' => 'application/vnd.oasis.opendocument.graphics', 2601 'odc' => 'application/vnd.oasis.opendocument.chart', 2602 'odb' => 'application/vnd.oasis.opendocument.database', 2603 'odf' => 'application/vnd.oasis.opendocument.formula', 2604 // WordPerfect formats. 2605 'wp|wpd' => 'application/wordperfect', 2606 // iWork formats. 2607 'key' => 'application/vnd.apple.keynote', 2608 'numbers' => 'application/vnd.apple.numbers', 2609 'pages' => 'application/vnd.apple.pages', 2610 ) 2611 ); 2518 2612 } 2519 2613 … … 2537 2631 * of file types. 2538 2632 */ 2539 return apply_filters( 'ext2type', array( 2540 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), 2541 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 2542 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), 2543 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), 2544 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), 2545 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), 2546 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), 2547 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ), 2548 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), 2549 ) ); 2633 return apply_filters( 2634 'ext2type', array( 2635 'image' => array( 'jpg', 'jpeg', 'jpe', 'gif', 'png', 'bmp', 'tif', 'tiff', 'ico' ), 2636 'audio' => array( 'aac', 'ac3', 'aif', 'aiff', 'm3a', 'm4a', 'm4b', 'mka', 'mp1', 'mp2', 'mp3', 'ogg', 'oga', 'ram', 'wav', 'wma' ), 2637 'video' => array( '3g2', '3gp', '3gpp', 'asf', 'avi', 'divx', 'dv', 'flv', 'm4v', 'mkv', 'mov', 'mp4', 'mpeg', 'mpg', 'mpv', 'ogm', 'ogv', 'qt', 'rm', 'vob', 'wmv' ), 2638 'document' => array( 'doc', 'docx', 'docm', 'dotm', 'odt', 'pages', 'pdf', 'xps', 'oxps', 'rtf', 'wp', 'wpd', 'psd', 'xcf' ), 2639 'spreadsheet' => array( 'numbers', 'ods', 'xls', 'xlsx', 'xlsm', 'xlsb' ), 2640 'interactive' => array( 'swf', 'key', 'ppt', 'pptx', 'pptm', 'pps', 'ppsx', 'ppsm', 'sldx', 'sldm', 'odp' ), 2641 'text' => array( 'asc', 'csv', 'tsv', 'txt' ), 2642 'archive' => array( 'bz2', 'cab', 'dmg', 'gz', 'rar', 'sea', 'sit', 'sqx', 'tar', 'tgz', 'zip', '7z' ), 2643 'code' => array( 'css', 'htm', 'html', 'php', 'js' ), 2644 ) 2645 ); 2550 2646 } 2551 2647 … … 2563 2659 2564 2660 unset( $t['swf'], $t['exe'] ); 2565 if ( function_exists( 'current_user_can' ) ) 2661 if ( function_exists( 'current_user_can' ) ) { 2566 2662 $unfiltered = $user ? user_can( $user, 'unfiltered_html' ) : current_user_can( 'unfiltered_html' ); 2663 } 2567 2664 2568 2665 if ( empty( $unfiltered ) ) { … … 2600 2697 get_bloginfo( 'name' ) 2601 2698 ); 2602 $html .= '</p><p>';2699 $html .= '</p><p>'; 2603 2700 $redirect_to = isset( $_REQUEST['redirect_to'] ) ? $_REQUEST['redirect_to'] : ''; 2604 $html .= sprintf(2701 $html .= sprintf( 2605 2702 /* translators: %s: logout URL */ 2606 2703 __( 'Do you really want to <a href="%s">log out</a>?' ), … … 2611 2708 if ( wp_get_referer() ) { 2612 2709 $html .= '</p><p>'; 2613 $html .= sprintf( '<a href="%s">%s</a>', 2710 $html .= sprintf( 2711 '<a href="%s">%s</a>', 2614 2712 esc_url( remove_query_arg( 'updated', wp_get_referer() ) ), 2615 2713 __( 'Please try again.' ) … … 2711 2809 function _default_wp_die_handler( $message, $title = '', $args = array() ) { 2712 2810 $defaults = array( 'response' => 500 ); 2713 $r = wp_parse_args($args, $defaults);2714 2715 $have_gettext = function_exists( '__');2811 $r = wp_parse_args( $args, $defaults ); 2812 2813 $have_gettext = function_exists( '__' ); 2716 2814 2717 2815 if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) { 2718 2816 if ( empty( $title ) ) { 2719 2817 $error_data = $message->get_error_data(); 2720 if ( is_array( $error_data ) && isset( $error_data['title'] ) ) 2818 if ( is_array( $error_data ) && isset( $error_data['title'] ) ) { 2721 2819 $title = $error_data['title']; 2820 } 2722 2821 } 2723 2822 $errors = $message->get_error_messages(); 2724 2823 switch ( count( $errors ) ) { 2725 case 0:2726 $message = '';2727 break;2728 case 1:2729 $message = "<p>{$errors[0]}</p>";2730 break;2731 default:2732 $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>";2733 break;2824 case 0: 2825 $message = ''; 2826 break; 2827 case 1: 2828 $message = "<p>{$errors[0]}</p>"; 2829 break; 2830 default: 2831 $message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $errors ) . "</li>\n\t</ul>"; 2832 break; 2734 2833 } 2735 2834 } elseif ( is_string( $message ) ) { … … 2738 2837 2739 2838 if ( isset( $r['back_link'] ) && $r['back_link'] ) { 2740 $back_text = $have_gettext ? __('« Back') : '« Back';2741 $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>";2839 $back_text = $have_gettext ? __( '« Back' ) : '« Back'; 2840 $message .= "\n<p><a href='javascript:history.back()'>$back_text</a></p>"; 2742 2841 } 2743 2842 2744 2843 if ( ! did_action( 'admin_head' ) ) : 2745 if ( ! headers_sent() ) {2844 if ( ! headers_sent() ) { 2746 2845 status_header( $r['response'] ); 2747 2846 nocache_headers(); … … 2749 2848 } 2750 2849 2751 if ( empty($title) ) 2752 $title = $have_gettext ? __('WordPress › Error') : 'WordPress › Error'; 2850 if ( empty( $title ) ) { 2851 $title = $have_gettext ? __( 'WordPress › Error' ) : 'WordPress › Error'; 2852 } 2753 2853 2754 2854 $text_direction = 'ltr'; 2755 if ( isset( $r['text_direction']) && 'rtl' == $r['text_direction'] )2855 if ( isset( $r['text_direction'] ) && 'rtl' == $r['text_direction'] ) { 2756 2856 $text_direction = 'rtl'; 2757 elseif ( function_exists( 'is_rtl' ) && is_rtl() )2857 } elseif ( function_exists( 'is_rtl' ) && is_rtl() ) { 2758 2858 $text_direction = 'rtl'; 2759 2760 if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { 2761 $dir_attr = get_language_attributes(); 2762 } else { 2763 $dir_attr = "dir='$text_direction'"; 2764 } 2859 } 2860 2861 if ( function_exists( 'language_attributes' ) && function_exists( 'is_rtl' ) ) { 2862 $dir_attr = get_language_attributes(); 2863 } else { 2864 $dir_attr = "dir='$text_direction'"; 2865 } 2765 2866 ?> 2766 2867 <!DOCTYPE html> … … 2774 2875 } 2775 2876 ?> 2776 <title><?php echo $title ?></title>2877 <title><?php echo $title; ?></title> 2777 2878 <style type="text/css"> 2778 2879 html { … … 2822 2923 a:focus { 2823 2924 color: #124964; 2824 2825 2925 -webkit-box-shadow: 2926 0 0 0 1px #5b9dd9, 2826 2927 0 0 2px 1px rgba(30, 140, 190, .8); 2827 2828 2928 box-shadow: 2929 0 0 0 1px #5b9dd9, 2829 2930 0 0 2px 1px rgba(30, 140, 190, .8); 2830 2931 outline: none; … … 2852 2953 -webkit-box-shadow: 0 1px 0 #ccc; 2853 2954 box-shadow: 0 1px 0 #ccc; 2854 2955 vertical-align: top; 2855 2956 } 2856 2957 … … 2878 2979 background: #eee; 2879 2980 border-color: #999; 2880 2881 2882 2883 2884 2981 -webkit-box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); 2982 box-shadow: inset 0 2px 5px -3px rgba( 0, 0, 0, 0.5 ); 2983 -webkit-transform: translateY(1px); 2984 -ms-transform: translateY(1px); 2985 transform: translateY(1px); 2885 2986 } 2886 2987 … … 2919 3020 $defaults = array( 'response' => 500 ); 2920 3021 2921 $r = wp_parse_args( $args, $defaults);3022 $r = wp_parse_args( $args, $defaults ); 2922 3023 2923 3024 if ( $wp_xmlrpc_server ) { 2924 $error = new IXR_Error( $r['response'] , $message);3025 $error = new IXR_Error( $r['response'], $message ); 2925 3026 $wp_xmlrpc_server->output( $error->getXml() ); 2926 3027 } … … 2944 3045 'response' => 200, 2945 3046 ); 2946 $r = wp_parse_args( $args, $defaults );3047 $r = wp_parse_args( $args, $defaults ); 2947 3048 2948 3049 if ( ! headers_sent() && null !== $r['response'] ) { … … 2950 3051 } 2951 3052 2952 if ( is_scalar( $message ) ) 3053 if ( is_scalar( $message ) ) { 2953 3054 die( (string) $message ); 3055 } 2954 3056 die( '0' ); 2955 3057 } … … 2966 3068 */ 2967 3069 function _scalar_wp_die_handler( $message = '' ) { 2968 if ( is_scalar( $message ) ) 3070 if ( is_scalar( $message ) ) { 2969 3071 die( (string) $message ); 3072 } 2970 3073 die(); 2971 3074 } … … 3004 3107 // ... unless we're in an old version of PHP, and json_encode() returned 3005 3108 // a string containing 'null'. Then we need to do more sanity checking. 3006 if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) 3109 if ( false !== $json && ( version_compare( PHP_VERSION, '5.5', '>=' ) || false === strpos( $json, 'null' ) ) ) { 3007 3110 return $json; 3008 3111 } … … 3180 3283 3181 3284 if ( wp_doing_ajax() ) { 3182 wp_die( '', '', array( 3183 'response' => null, 3184 ) ); 3285 wp_die( 3286 '', '', array( 3287 'response' => null, 3288 ) 3289 ); 3185 3290 } else { 3186 3291 die; … … 3200 3305 $response = array( 'success' => true ); 3201 3306 3202 if ( isset( $data ) ) 3307 if ( isset( $data ) ) { 3203 3308 $response['data'] = $data; 3309 } 3204 3310 3205 3311 wp_send_json( $response, $status_code ); … … 3229 3335 foreach ( $data->errors as $code => $messages ) { 3230 3336 foreach ( $messages as $message ) { 3231 $result[] = array( 'code' => $code, 'message' => $message ); 3337 $result[] = array( 3338 'code' => $code, 3339 'message' => $message, 3340 ); 3232 3341 } 3233 3342 } … … 3280 3389 */ 3281 3390 function _config_wp_home( $url = '' ) { 3282 if ( defined( 'WP_HOME' ) ) 3391 if ( defined( 'WP_HOME' ) ) { 3283 3392 return untrailingslashit( WP_HOME ); 3393 } 3284 3394 return $url; 3285 3395 } … … 3301 3411 */ 3302 3412 function _config_wp_siteurl( $url = '' ) { 3303 if ( defined( 'WP_SITEURL' ) ) 3413 if ( defined( 'WP_SITEURL' ) ) { 3304 3414 return untrailingslashit( WP_SITEURL ); 3415 } 3305 3416 return $url; 3306 3417 } … … 3336 3447 if ( is_rtl() ) { 3337 3448 $mce_init['directionality'] = 'rtl'; 3338 $mce_init['rtl_ui'] = true;3449 $mce_init['rtl_ui'] = true; 3339 3450 3340 3451 if ( ! empty( $mce_init['plugins'] ) && strpos( $mce_init['plugins'], 'directionality' ) === false ) { … … 3377 3488 3378 3489 // don't bother setting up smilies if they are disabled 3379 if ( ! get_option( 'use_smilies' ) )3490 if ( ! get_option( 'use_smilies' ) ) { 3380 3491 return; 3381 3382 if ( !isset( $wpsmiliestrans ) ) { 3492 } 3493 3494 if ( ! isset( $wpsmiliestrans ) ) { 3383 3495 $wpsmiliestrans = array( 3384 ':mrgreen:' => 'mrgreen.png',3385 ':neutral:' => "\xf0\x9f\x98\x90",3386 ':twisted:' => "\xf0\x9f\x98\x88",3387 ':arrow:'=> "\xe2\x9e\xa1",3388 ':shock:'=> "\xf0\x9f\x98\xaf",3389 ':smile:'=> "\xf0\x9f\x99\x82",3390 ':???:'=> "\xf0\x9f\x98\x95",3391 ':cool:'=> "\xf0\x9f\x98\x8e",3392 ':evil:'=> "\xf0\x9f\x91\xbf",3393 ':grin:'=> "\xf0\x9f\x98\x80",3394 ':idea:'=> "\xf0\x9f\x92\xa1",3395 ':oops:'=> "\xf0\x9f\x98\xb3",3396 ':razz:'=> "\xf0\x9f\x98\x9b",3397 ':roll:'=> "\xf0\x9f\x99\x84",3398 ':wink:'=> "\xf0\x9f\x98\x89",3399 ':cry:'=> "\xf0\x9f\x98\xa5",3400 ':eek:'=> "\xf0\x9f\x98\xae",3401 ':lol:'=> "\xf0\x9f\x98\x86",3402 ':mad:'=> "\xf0\x9f\x98\xa1",3403 ':sad:'=> "\xf0\x9f\x99\x81",3404 '8-)'=> "\xf0\x9f\x98\x8e",3405 '8-O'=> "\xf0\x9f\x98\xaf",3406 ':-('=> "\xf0\x9f\x99\x81",3407 ':-)'=> "\xf0\x9f\x99\x82",3408 ':-?'=> "\xf0\x9f\x98\x95",3409 ':-D'=> "\xf0\x9f\x98\x80",3410 ':-P'=> "\xf0\x9f\x98\x9b",3411 ':-o'=> "\xf0\x9f\x98\xae",3412 ':-x'=> "\xf0\x9f\x98\xa1",3413 ':-|'=> "\xf0\x9f\x98\x90",3414 ';-)'=> "\xf0\x9f\x98\x89",3415 // This one transformation breaks regular text with frequency.3416 // '8)' => "\xf0\x9f\x98\x8e",3417 '8O'=> "\xf0\x9f\x98\xaf",3418 ':('=> "\xf0\x9f\x99\x81",3419 ':)'=> "\xf0\x9f\x99\x82",3420 ':?'=> "\xf0\x9f\x98\x95",3421 ':D'=> "\xf0\x9f\x98\x80",3422 ':P'=> "\xf0\x9f\x98\x9b",3423 ':o'=> "\xf0\x9f\x98\xae",3424 ':x'=> "\xf0\x9f\x98\xa1",3425 ':|'=> "\xf0\x9f\x98\x90",3426 ';)'=> "\xf0\x9f\x98\x89",3427 ':!:'=> "\xe2\x9d\x97",3428 ':?:'=> "\xe2\x9d\x93",3496 ':mrgreen:' => 'mrgreen.png', 3497 ':neutral:' => "\xf0\x9f\x98\x90", 3498 ':twisted:' => "\xf0\x9f\x98\x88", 3499 ':arrow:' => "\xe2\x9e\xa1", 3500 ':shock:' => "\xf0\x9f\x98\xaf", 3501 ':smile:' => "\xf0\x9f\x99\x82", 3502 ':???:' => "\xf0\x9f\x98\x95", 3503 ':cool:' => "\xf0\x9f\x98\x8e", 3504 ':evil:' => "\xf0\x9f\x91\xbf", 3505 ':grin:' => "\xf0\x9f\x98\x80", 3506 ':idea:' => "\xf0\x9f\x92\xa1", 3507 ':oops:' => "\xf0\x9f\x98\xb3", 3508 ':razz:' => "\xf0\x9f\x98\x9b", 3509 ':roll:' => "\xf0\x9f\x99\x84", 3510 ':wink:' => "\xf0\x9f\x98\x89", 3511 ':cry:' => "\xf0\x9f\x98\xa5", 3512 ':eek:' => "\xf0\x9f\x98\xae", 3513 ':lol:' => "\xf0\x9f\x98\x86", 3514 ':mad:' => "\xf0\x9f\x98\xa1", 3515 ':sad:' => "\xf0\x9f\x99\x81", 3516 '8-)' => "\xf0\x9f\x98\x8e", 3517 '8-O' => "\xf0\x9f\x98\xaf", 3518 ':-(' => "\xf0\x9f\x99\x81", 3519 ':-)' => "\xf0\x9f\x99\x82", 3520 ':-?' => "\xf0\x9f\x98\x95", 3521 ':-D' => "\xf0\x9f\x98\x80", 3522 ':-P' => "\xf0\x9f\x98\x9b", 3523 ':-o' => "\xf0\x9f\x98\xae", 3524 ':-x' => "\xf0\x9f\x98\xa1", 3525 ':-|' => "\xf0\x9f\x98\x90", 3526 ';-)' => "\xf0\x9f\x98\x89", 3527 // This one transformation breaks regular text with frequency. 3528 // '8)' => "\xf0\x9f\x98\x8e", 3529 '8O' => "\xf0\x9f\x98\xaf", 3530 ':(' => "\xf0\x9f\x99\x81", 3531 ':)' => "\xf0\x9f\x99\x82", 3532 ':?' => "\xf0\x9f\x98\x95", 3533 ':D' => "\xf0\x9f\x98\x80", 3534 ':P' => "\xf0\x9f\x98\x9b", 3535 ':o' => "\xf0\x9f\x98\xae", 3536 ':x' => "\xf0\x9f\x98\xa1", 3537 ':|' => "\xf0\x9f\x98\x90", 3538 ';)' => "\xf0\x9f\x98\x89", 3539 ':!:' => "\xe2\x9d\x97", 3540 ':?:' => "\xe2\x9d\x93", 3429 3541 ); 3430 3542 } … … 3440 3552 * @param array $wpsmiliestrans List of the smilies. 3441 3553 */ 3442 $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans);3443 3444 if ( count($wpsmiliestrans) == 0) {3554 $wpsmiliestrans = apply_filters( 'smilies', $wpsmiliestrans ); 3555 3556 if ( count( $wpsmiliestrans ) == 0 ) { 3445 3557 return; 3446 3558 } … … 3451 3563 * expression used below is first-match 3452 3564 */ 3453 krsort( $wpsmiliestrans);3565 krsort( $wpsmiliestrans ); 3454 3566 3455 3567 $spaces = wp_spaces_regexp(); … … 3460 3572 $subchar = ''; 3461 3573 foreach ( (array) $wpsmiliestrans as $smiley => $img ) { 3462 $firstchar = substr( $smiley, 0, 1);3463 $rest = substr($smiley, 1);3574 $firstchar = substr( $smiley, 0, 1 ); 3575 $rest = substr( $smiley, 1 ); 3464 3576 3465 3577 // new subpattern? 3466 if ( $firstchar != $subchar) {3467 if ( $subchar != '') {3578 if ( $firstchar != $subchar ) { 3579 if ( $subchar != '' ) { 3468 3580 $wp_smiliessearch .= ')(?=' . $spaces . '|$)'; // End previous "subpattern" 3469 3581 $wp_smiliessearch .= '|(?<=' . $spaces . '|^)'; // Begin another "subpattern" 3470 3582 } 3471 $subchar = $firstchar;3472 $wp_smiliessearch .= preg_quote( $firstchar, '/') . '(?:';3583 $subchar = $firstchar; 3584 $wp_smiliessearch .= preg_quote( $firstchar, '/' ) . '(?:'; 3473 3585 } else { 3474 3586 $wp_smiliessearch .= '|'; 3475 3587 } 3476 $wp_smiliessearch .= preg_quote( $rest, '/');3588 $wp_smiliessearch .= preg_quote( $rest, '/' ); 3477 3589 } 3478 3590 … … 3495 3607 */ 3496 3608 function wp_parse_args( $args, $defaults = '' ) { 3497 if ( is_object( $args ) ) 3609 if ( is_object( $args ) ) { 3498 3610 $r = get_object_vars( $args ); 3499 elseif ( is_array( $args ) )3611 } elseif ( is_array( $args ) ) { 3500 3612 $r =& $args; 3501 else3613 } else { 3502 3614 wp_parse_str( $args, $r ); 3503 3504 if ( is_array( $defaults ) ) 3615 } 3616 3617 if ( is_array( $defaults ) ) { 3505 3618 return array_merge( $defaults, $r ); 3619 } 3506 3620 return $r; 3507 3621 } … … 3516 3630 */ 3517 3631 function wp_parse_id_list( $list ) { 3518 if ( !is_array($list) ) 3519 $list = preg_split('/[\s,]+/', $list); 3520 3521 return array_unique(array_map('absint', $list)); 3632 if ( ! is_array( $list ) ) { 3633 $list = preg_split( '/[\s,]+/', $list ); 3634 } 3635 3636 return array_unique( array_map( 'absint', $list ) ); 3522 3637 } 3523 3638 … … 3553 3668 function wp_array_slice_assoc( $array, $keys ) { 3554 3669 $slice = array(); 3555 foreach ( $keys as $key ) 3556 if ( isset( $array[ $key ] ) ) 3670 foreach ( $keys as $key ) { 3671 if ( isset( $array[ $key ] ) ) { 3557 3672 $slice[ $key ] = $array[ $key ]; 3673 } 3674 } 3558 3675 3559 3676 return $slice; … … 3573 3690 } 3574 3691 3575 $keys = array_keys( $data );3692 $keys = array_keys( $data ); 3576 3693 $string_keys = array_filter( $keys, 'is_string' ); 3577 3694 return count( $string_keys ) === 0; … … 3719 3836 global $submenu; 3720 3837 3721 if ( ! current_theme_supports( 'widgets' ) ) 3838 if ( ! current_theme_supports( 'widgets' ) ) { 3722 3839 return; 3840 } 3723 3841 3724 3842 $submenu['themes.php'][7] = array( __( 'Widgets' ), 'edit_theme_options', 'widgets.php' ); … … 3735 3853 function wp_ob_end_flush_all() { 3736 3854 $levels = ob_get_level(); 3737 for ( $i=0; $i<$levels; $i++)3855 for ( $i = 0; $i < $levels; $i++ ) { 3738 3856 ob_end_flush(); 3857 } 3739 3858 } 3740 3859 … … 3769 3888 3770 3889 // If installing or in the admin, provide the verbose message. 3771 if ( wp_installing() || defined( 'WP_ADMIN' ) ) 3772 wp_die($wpdb->error); 3890 if ( wp_installing() || defined( 'WP_ADMIN' ) ) { 3891 wp_die( $wpdb->error ); 3892 } 3773 3893 3774 3894 // Otherwise, be terse. … … 3851 3971 if ( ! is_null( $replacement ) ) { 3852 3972 /* translators: 1: PHP function name, 2: version number, 3: alternative function name */ 3853 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $function, $version, $replacement ) );3973 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $function, $version, $replacement ) ); 3854 3974 } else { 3855 3975 /* translators: 1: PHP function name, 2: version number */ 3856 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );3976 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version ) ); 3857 3977 } 3858 3978 } else { … … 3913 4033 if ( ! empty( $parent_class ) ) { 3914 4034 /* translators: 1: PHP class name, 2: PHP parent class name, 3: version number, 4: __construct() method */ 3915 trigger_error( sprintf( __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ), 3916 $class, $parent_class, $version, '<pre>__construct()</pre>' ) ); 4035 trigger_error( 4036 sprintf( 4037 __( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.' ), 4038 $class, $parent_class, $version, '<pre>__construct()</pre>' 4039 ) 4040 ); 3917 4041 } else { 3918 4042 /* translators: 1: PHP class name, 2: version number, 3: __construct() method */ 3919 trigger_error( sprintf( __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), 3920 $class, $version, '<pre>__construct()</pre>' ) ); 4043 trigger_error( 4044 sprintf( 4045 __( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), 4046 $class, $version, '<pre>__construct()</pre>' 4047 ) 4048 ); 3921 4049 } 3922 4050 } else { 3923 4051 if ( ! empty( $parent_class ) ) { 3924 trigger_error( sprintf( 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.', 3925 $class, $parent_class, $version, '<pre>__construct()</pre>' ) ); 4052 trigger_error( 4053 sprintf( 4054 'The called constructor method for %1$s in %2$s is <strong>deprecated</strong> since version %3$s! Use %4$s instead.', 4055 $class, $parent_class, $version, '<pre>__construct()</pre>' 4056 ) 4057 ); 3926 4058 } else { 3927 trigger_error( sprintf( 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 3928 $class, $version, '<pre>__construct()</pre>' ) ); 4059 trigger_error( 4060 sprintf( 4061 'The called constructor method for %1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.', 4062 $class, $version, '<pre>__construct()</pre>' 4063 ) 4064 ); 3929 4065 } 3930 4066 } … … 3979 4115 if ( ! is_null( $replacement ) ) { 3980 4116 /* translators: 1: PHP file name, 2: version number, 3: alternative file name */ 3981 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.'), $file, $version, $replacement ) . $message );4117 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.' ), $file, $version, $replacement ) . $message ); 3982 4118 } else { 3983 4119 /* translators: 1: PHP file name, 2: version number */ 3984 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.'), $file, $version ) . $message );4120 trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $file, $version ) . $message ); 3985 4121 } 3986 4122 } else { … … 4005 4141 * } 4006 4142 * 4007 *4008 4143 * There is a hook deprecated_argument_run that will be called that can be used 4009 4144 * to get the backtrace up to what file and function used the deprecated … … 4043 4178 if ( ! is_null( $message ) ) { 4044 4179 /* translators: 1: PHP function name, 2: version number, 3: optional message regarding the change */ 4045 trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s'), $function, $version, $message ) );4180 trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s! %3$s' ), $function, $version, $message ) ); 4046 4181 } else { 4047 4182 /* translators: 1: PHP function name, 2: version number */ 4048 trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.'), $function, $version ) );4183 trigger_error( sprintf( __( '%1$s was called with an argument that is <strong>deprecated</strong> since version %2$s with no alternative available.' ), $function, $version ) ); 4049 4184 } 4050 4185 } else { … … 4155 4290 } 4156 4291 /* translators: %s: Codex URL */ 4157 $message .= ' ' . sprintf( __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), 4292 $message .= ' ' . sprintf( 4293 __( 'Please see <a href="%s">Debugging in WordPress</a> for more information.' ), 4158 4294 __( 'https://codex.wordpress.org/Debugging_in_WordPress' ) 4159 4295 ); … … 4166 4302 $version = sprintf( '(This message was added in version %s.)', $version ); 4167 4303 } 4168 $message .= sprintf( ' Please see <a href="%s">Debugging in WordPress</a> for more information.', 4304 $message .= sprintf( 4305 ' Please see <a href="%s">Debugging in WordPress</a> for more information.', 4169 4306 'https://codex.wordpress.org/Debugging_in_WordPress' 4170 4307 ); … … 4182 4319 */ 4183 4320 function is_lighttpd_before_150() { 4184 $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] )? $_SERVER['SERVER_SOFTWARE'] : '' );4185 $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : '';4321 $server_parts = explode( '/', isset( $_SERVER['SERVER_SOFTWARE'] ) ? $_SERVER['SERVER_SOFTWARE'] : '' ); 4322 $server_parts[1] = isset( $server_parts[1] ) ? $server_parts[1] : ''; 4186 4323 return 'lighttpd' == $server_parts[0] && -1 == version_compare( $server_parts[1], '1.5.0' ); 4187 4324 } … … 4198 4335 * @return bool Whether the specified module is loaded. 4199 4336 */ 4200 function apache_mod_loaded( $mod, $default = false) {4337 function apache_mod_loaded( $mod, $default = false ) { 4201 4338 global $is_apache; 4202 4339 4203 if ( ! $is_apache )4340 if ( ! $is_apache ) { 4204 4341 return false; 4342 } 4205 4343 4206 4344 if ( function_exists( 'apache_get_modules' ) ) { 4207 4345 $mods = apache_get_modules(); 4208 if ( in_array( $mod, $mods) )4346 if ( in_array( $mod, $mods ) ) { 4209 4347 return true; 4348 } 4210 4349 } elseif ( function_exists( 'phpinfo' ) && false === strpos( ini_get( 'disable_functions' ), 'phpinfo' ) ) { 4211 4350 ob_start(); 4212 phpinfo( 8);4351 phpinfo( 8 ); 4213 4352 $phpinfo = ob_get_clean(); 4214 if ( false !== strpos($phpinfo, $mod) ) 4215 return true; 4353 if ( false !== strpos( $phpinfo, $mod ) ) { 4354 return true; 4355 } 4216 4356 } 4217 4357 return $default; … … 4241 4381 * via ISAPI then pretty permalinks will not work. 4242 4382 */ 4243 $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule']) && ( PHP_SAPI == 'cgi-fcgi' );4383 $supports_permalinks = class_exists( 'DOMDocument', false ) && isset( $_SERVER['IIS_UrlRewriteModule'] ) && ( PHP_SAPI == 'cgi-fcgi' ); 4244 4384 } 4245 4385 … … 4286 4426 4287 4427 // Files not in the allowed file list are not allowed: 4288 if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) 4428 if ( ! empty( $allowed_files ) && ! in_array( $file, $allowed_files ) ) { 4289 4429 return 3; 4430 } 4290 4431 4291 4432 // Absolute Windows drive paths are not allowed: 4292 if ( ':' == substr( $file, 1, 1 ) )4433 if ( ':' == substr( $file, 1, 1 ) ) { 4293 4434 return 2; 4435 } 4294 4436 4295 4437 return 0; … … 4309 4451 static $forced = false; 4310 4452 4311 if ( ! is_null( $force ) ) {4453 if ( ! is_null( $force ) ) { 4312 4454 $old_forced = $forced; 4313 $forced = $force;4455 $forced = $force; 4314 4456 return $old_forced; 4315 4457 } … … 4329 4471 */ 4330 4472 function wp_guess_url() { 4331 if ( defined( 'WP_SITEURL') && '' != WP_SITEURL ) {4473 if ( defined( 'WP_SITEURL' ) && '' != WP_SITEURL ) { 4332 4474 $url = WP_SITEURL; 4333 4475 } else { 4334 $abspath_fix = str_replace( '\\', '/', ABSPATH );4476 $abspath_fix = str_replace( '\\', '/', ABSPATH ); 4335 4477 $script_filename_dir = dirname( $_SERVER['SCRIPT_FILENAME'] ); 4336 4478 … … 4339 4481 $path = preg_replace( '#/(wp-admin/.*|wp-login.php)#i', '', $_SERVER['REQUEST_URI'] ); 4340 4482 4341 // The request is for a file in ABSPATH4483 // The request is for a file in ABSPATH 4342 4484 } elseif ( $script_filename_dir . '/' == $abspath_fix ) { 4343 4485 // Strip off any file/query params in the path … … 4349 4491 $directory = str_replace( ABSPATH, '', $script_filename_dir ); 4350 4492 // Strip off the sub directory, and any file/query params 4351 $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '' 4493 $path = preg_replace( '#/' . preg_quote( $directory, '#' ) . '/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ); 4352 4494 } elseif ( false !== strpos( $abspath_fix, $script_filename_dir ) ) { 4353 4495 // Request is hitting a file above ABSPATH 4354 4496 $subdirectory = substr( $abspath_fix, strpos( $abspath_fix, $script_filename_dir ) + strlen( $script_filename_dir ) ); 4355 4497 // Strip off any file/query params from the path, appending the sub directory to the installation 4356 $path = preg_replace( '#/[^/]*$#i', '' 4498 $path = preg_replace( '#/[^/]*$#i', '', $_SERVER['REQUEST_URI'] ) . $subdirectory; 4357 4499 } else { 4358 4500 $path = $_SERVER['REQUEST_URI']; … … 4361 4503 4362 4504 $schema = is_ssl() ? 'https://' : 'http://'; // set_url_scheme() is not defined yet 4363 $url = $schema . $_SERVER['HTTP_HOST'] . $path;4364 } 4365 4366 return rtrim( $url, '/');4505 $url = $schema . $_SERVER['HTTP_HOST'] . $path; 4506 } 4507 4508 return rtrim( $url, '/' ); 4367 4509 } 4368 4510 … … 4387 4529 static $_suspend = false; 4388 4530 4389 if ( is_bool( $suspend ) ) 4531 if ( is_bool( $suspend ) ) { 4390 4532 $_suspend = $suspend; 4533 } 4391 4534 4392 4535 return $_suspend; … … 4410 4553 global $_wp_suspend_cache_invalidation; 4411 4554 4412 $current_suspend = $_wp_suspend_cache_invalidation;4555 $current_suspend = $_wp_suspend_cache_invalidation; 4413 4556 $_wp_suspend_cache_invalidation = $suspend; 4414 4557 return $current_suspend; … … 4505 4648 $main_network_id = 1; 4506 4649 } else { 4507 $_networks = get_networks( array( 'fields' => 'ids', 'number' => 1 ) ); 4650 $_networks = get_networks( 4651 array( 4652 'fields' => 'ids', 4653 'number' => 1, 4654 ) 4655 ); 4508 4656 $main_network_id = array_shift( $_networks ); 4509 4657 } … … 4529 4677 */ 4530 4678 function global_terms_enabled() { 4531 if ( ! is_multisite() ) 4679 if ( ! is_multisite() ) { 4532 4680 return false; 4681 } 4533 4682 4534 4683 static $global_terms = null; … … 4546 4695 */ 4547 4696 $filter = apply_filters( 'global_terms_enabled', null ); 4548 if ( ! is_null( $filter ) ) 4697 if ( ! is_null( $filter ) ) { 4549 4698 $global_terms = (bool) $filter; 4550 else4699 } else { 4551 4700 $global_terms = (bool) get_site_option( 'global_terms_enabled', false ); 4701 } 4552 4702 } 4553 4703 return $global_terms; … … 4564 4714 */ 4565 4715 function wp_timezone_override_offset() { 4566 if ( ! $timezone_string = get_option( 'timezone_string' ) ) {4716 if ( ! $timezone_string = get_option( 'timezone_string' ) ) { 4567 4717 return false; 4568 4718 } … … 4640 4790 static $mo_loaded = false, $locale_loaded = null; 4641 4791 4642 $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific' );4792 $continents = array( 'Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific' ); 4643 4793 4644 4794 // Load translations for continents and cities. 4645 4795 if ( ! $mo_loaded || $locale !== $locale_loaded ) { 4646 4796 $locale_loaded = $locale ? $locale : get_locale(); 4647 $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';4797 $mofile = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo'; 4648 4798 unload_textdomain( 'continents-cities' ); 4649 4799 load_textdomain( 'continents-cities', $mofile ); … … 4654 4804 foreach ( timezone_identifiers_list() as $zone ) { 4655 4805 $zone = explode( '/', $zone ); 4656 if ( ! in_array( $zone[0], $continents ) ) {4806 if ( ! in_array( $zone[0], $continents ) ) { 4657 4807 continue; 4658 4808 } 4659 4809 4660 4810 // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later 4661 $exists = array(4811 $exists = array( 4662 4812 0 => ( isset( $zone[0] ) && $zone[0] ), 4663 4813 1 => ( isset( $zone[1] ) && $zone[1] ), … … 4674 4824 't_continent' => ( $exists[3] ? translate( str_replace( '_', ' ', $zone[0] ), 'continents-cities' ) : '' ), 4675 4825 't_city' => ( $exists[4] ? translate( str_replace( '_', ' ', $zone[1] ), 'continents-cities' ) : '' ), 4676 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ) 4826 't_subcity' => ( $exists[5] ? translate( str_replace( '_', ' ', $zone[2] ), 'continents-cities' ) : '' ), 4677 4827 ); 4678 4828 } … … 4696 4846 4697 4847 // Continent optgroup 4698 if ( ! isset( $zonen[$key - 1] ) || $zonen[$key - 1]['continent'] !== $zone['continent'] ) {4699 $label = $zone['t_continent'];4700 $structure[] = '<optgroup label="' . esc_attr( $label ) .'">';4848 if ( ! isset( $zonen[ $key - 1 ] ) || $zonen[ $key - 1 ]['continent'] !== $zone['continent'] ) { 4849 $label = $zone['t_continent']; 4850 $structure[] = '<optgroup label="' . esc_attr( $label ) . '">'; 4701 4851 } 4702 4852 … … 4705 4855 4706 4856 $display = $zone['t_city']; 4707 if ( ! empty( $zone['subcity'] ) ) {4857 if ( ! empty( $zone['subcity'] ) ) { 4708 4858 // Add the subcity to the value 4709 $value[] = $zone['subcity'];4859 $value[] = $zone['subcity']; 4710 4860 $display .= ' - ' . $zone['t_subcity']; 4711 4861 } … … 4713 4863 4714 4864 // Build the value 4715 $value = join( '/', $value );4865 $value = join( '/', $value ); 4716 4866 $selected = ''; 4717 4867 if ( $value === $selected_zone ) { 4718 4868 $selected = 'selected="selected" '; 4719 4869 } 4720 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . "</option>";4870 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $value ) . '">' . esc_html( $display ) . '</option>'; 4721 4871 4722 4872 // Close continent optgroup 4723 if ( ! empty( $zone['city'] ) && ( !isset($zonen[$key + 1]) || (isset( $zonen[$key + 1] ) && $zonen[$key + 1]['continent'] !== $zone['continent']) ) ) {4873 if ( ! empty( $zone['city'] ) && ( ! isset( $zonen[ $key + 1 ] ) || ( isset( $zonen[ $key + 1 ] ) && $zonen[ $key + 1 ]['continent'] !== $zone['continent'] ) ) ) { 4724 4874 $structure[] = '</optgroup>'; 4725 4875 } … … 4727 4877 4728 4878 // Do UTC 4729 $structure[] = '<optgroup label="' . esc_attr__( 'UTC' ) .'">';4730 $selected = '';4731 if ( 'UTC' === $selected_zone ) 4879 $structure[] = '<optgroup label="' . esc_attr__( 'UTC' ) . '">'; 4880 $selected = ''; 4881 if ( 'UTC' === $selected_zone ) { 4732 4882 $selected = 'selected="selected" '; 4733 $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __('UTC') . '</option>'; 4883 } 4884 $structure[] = '<option ' . $selected . 'value="' . esc_attr( 'UTC' ) . '">' . __( 'UTC' ) . '</option>'; 4734 4885 $structure[] = '</optgroup>'; 4735 4886 4736 4887 // Do manual UTC offsets 4737 $structure[] = '<optgroup label="'. esc_attr__( 'Manual Offsets' ) .'">'; 4738 $offset_range = array (-12, -11.5, -11, -10.5, -10, -9.5, -9, -8.5, -8, -7.5, -7, -6.5, -6, -5.5, -5, -4.5, -4, -3.5, -3, -2.5, -2, -1.5, -1, -0.5, 4739 0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 5.75, 6, 6.5, 7, 7.5, 8, 8.5, 8.75, 9, 9.5, 10, 10.5, 11, 11.5, 12, 12.75, 13, 13.75, 14); 4888 $structure[] = '<optgroup label="' . esc_attr__( 'Manual Offsets' ) . '">'; 4889 $offset_range = array( 4890 -12, 4891 -11.5, 4892 -11, 4893 -10.5, 4894 -10, 4895 -9.5, 4896 -9, 4897 -8.5, 4898 -8, 4899 -7.5, 4900 -7, 4901 -6.5, 4902 -6, 4903 -5.5, 4904 -5, 4905 -4.5, 4906 -4, 4907 -3.5, 4908 -3, 4909 -2.5, 4910 -2, 4911 -1.5, 4912 -1, 4913 -0.5, 4914 0, 4915 0.5, 4916 1, 4917 1.5, 4918 2, 4919 2.5, 4920 3, 4921 3.5, 4922 4, 4923 4.5, 4924 5, 4925 5.5, 4926 5.75, 4927 6, 4928 6.5, 4929 7, 4930 7.5, 4931 8, 4932 8.5, 4933 8.75, 4934 9, 4935 9.5, 4936 10, 4937 10.5, 4938 11, 4939 11.5, 4940 12, 4941 12.75, 4942 13, 4943 13.75, 4944 14, 4945 ); 4740 4946 foreach ( $offset_range as $offset ) { 4741 if ( 0 <= $offset ) 4947 if ( 0 <= $offset ) { 4742 4948 $offset_name = '+' . $offset; 4743 else4949 } else { 4744 4950 $offset_name = (string) $offset; 4951 } 4745 4952 4746 4953 $offset_value = $offset_name; 4747 $offset_name = str_replace(array('.25','.5','.75'), array(':15',':30',':45'), $offset_name);4748 $offset_name = 'UTC' . $offset_name;4954 $offset_name = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $offset_name ); 4955 $offset_name = 'UTC' . $offset_name; 4749 4956 $offset_value = 'UTC' . $offset_value; 4750 $selected = '';4751 if ( $offset_value === $selected_zone ) 4957 $selected = ''; 4958 if ( $offset_value === $selected_zone ) { 4752 4959 $selected = 'selected="selected" '; 4753 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . "</option>"; 4960 } 4961 $structure[] = '<option ' . $selected . 'value="' . esc_attr( $offset_value ) . '">' . esc_html( $offset_name ) . '</option>'; 4754 4962 4755 4963 } … … 4771 4979 */ 4772 4980 function _cleanup_header_comment( $str ) { 4773 return trim( preg_replace("/\s*(?:\*\/|\?>).*/", '', $str));4981 return trim( preg_replace( '/\s*(?:\*\/|\?>).*/', '', $str ) ); 4774 4982 } 4775 4983 … … 4789 4997 $delete_timestamp = time() - ( DAY_IN_SECONDS * EMPTY_TRASH_DAYS ); 4790 4998 4791 $posts_to_delete = $wpdb->get_results( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp), ARRAY_A);4999 $posts_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); 4792 5000 4793 5001 foreach ( (array) $posts_to_delete as $post ) { 4794 5002 $post_id = (int) $post['post_id']; 4795 if ( ! $post_id )5003 if ( ! $post_id ) { 4796 5004 continue; 4797 4798 $del_post = get_post($post_id); 4799 4800 if ( !$del_post || 'trash' != $del_post->post_status ) { 4801 delete_post_meta($post_id, '_wp_trash_meta_status'); 4802 delete_post_meta($post_id, '_wp_trash_meta_time'); 5005 } 5006 5007 $del_post = get_post( $post_id ); 5008 5009 if ( ! $del_post || 'trash' != $del_post->post_status ) { 5010 delete_post_meta( $post_id, '_wp_trash_meta_status' ); 5011 delete_post_meta( $post_id, '_wp_trash_meta_time' ); 4803 5012 } else { 4804 wp_delete_post( $post_id);4805 } 4806 } 4807 4808 $comments_to_delete = $wpdb->get_results( $wpdb->prepare("SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp), ARRAY_A);5013 wp_delete_post( $post_id ); 5014 } 5015 } 5016 5017 $comments_to_delete = $wpdb->get_results( $wpdb->prepare( "SELECT comment_id FROM $wpdb->commentmeta WHERE meta_key = '_wp_trash_meta_time' AND meta_value < %d", $delete_timestamp ), ARRAY_A ); 4809 5018 4810 5019 foreach ( (array) $comments_to_delete as $comment ) { 4811 5020 $comment_id = (int) $comment['comment_id']; 4812 if ( ! $comment_id )5021 if ( ! $comment_id ) { 4813 5022 continue; 4814 4815 $del_comment = get_comment($comment_id); 4816 4817 if ( !$del_comment || 'trash' != $del_comment->comment_approved ) { 4818 delete_comment_meta($comment_id, '_wp_trash_meta_time'); 4819 delete_comment_meta($comment_id, '_wp_trash_meta_status'); 5023 } 5024 5025 $del_comment = get_comment( $comment_id ); 5026 5027 if ( ! $del_comment || 'trash' != $del_comment->comment_approved ) { 5028 delete_comment_meta( $comment_id, '_wp_trash_meta_time' ); 5029 delete_comment_meta( $comment_id, '_wp_trash_meta_status' ); 4820 5030 } else { 4821 5031 wp_delete_comment( $del_comment ); … … 4869 5079 if ( $context && $extra_headers = apply_filters( "extra_{$context}_headers", array() ) ) { 4870 5080 $extra_headers = array_combine( $extra_headers, $extra_headers ); // keys equal values 4871 $all_headers = array_merge( $extra_headers, (array) $default_headers );5081 $all_headers = array_merge( $extra_headers, (array) $default_headers ); 4872 5082 } else { 4873 5083 $all_headers = $default_headers; … … 4875 5085 4876 5086 foreach ( $all_headers as $field => $regex ) { 4877 if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) 5087 if ( preg_match( '/^[ \t\/*#@]*' . preg_quote( $regex, '/' ) . ':(.*)$/mi', $file_data, $match ) && $match[1] ) { 4878 5088 $all_headers[ $field ] = _cleanup_header_comment( $match[1] ); 4879 else5089 } else { 4880 5090 $all_headers[ $field ] = ''; 5091 } 4881 5092 } 4882 5093 … … 4991 5202 function _wp_mysql_week( $column ) { 4992 5203 switch ( $start_of_week = (int) get_option( 'start_of_week' ) ) { 4993 case 1:4994 return "WEEK( $column, 1 )";4995 case 2:4996 case 3:4997 case 4:4998 case 5:4999 case 6:5000 return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )";5001 case 0:5002 default:5003 return "WEEK( $column, 0 )";5204 case 1: 5205 return "WEEK( $column, 1 )"; 5206 case 2: 5207 case 3: 5208 case 4: 5209 case 5: 5210 case 6: 5211 return "WEEK( DATE_SUB( $column, INTERVAL $start_of_week DAY ), 0 )"; 5212 case 0: 5213 default: 5214 return "WEEK( $column, 0 )"; 5004 5215 } 5005 5216 } … … 5021 5232 $override = is_null( $start_parent ) ? array() : array( $start => $start_parent ); 5022 5233 5023 if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) )5234 if ( ! $arbitrary_loop_member = wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override, $callback_args ) ) { 5024 5235 return array(); 5236 } 5025 5237 5026 5238 return wp_find_hierarchy_loop_tortoise_hare( $callback, $arbitrary_loop_member, $override, $callback_args, true ); … … 5049 5261 function wp_find_hierarchy_loop_tortoise_hare( $callback, $start, $override = array(), $callback_args = array(), $_return_loop = false ) { 5050 5262 $tortoise = $hare = $evanescent_hare = $start; 5051 $return = array();5263 $return = array(); 5052 5264 5053 5265 // Set evanescent_hare to one past hare … … 5056 5268 $tortoise 5057 5269 && 5058 ( $evanescent_hare = isset( $override[ $hare] ) ? $override[$hare] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) )5270 ( $evanescent_hare = isset( $override[ $hare ] ) ? $override[ $hare ] : call_user_func_array( $callback, array_merge( array( $hare ), $callback_args ) ) ) 5059 5271 && 5060 ( $hare = isset( $override[ $evanescent_hare] ) ? $override[$evanescent_hare] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) )5272 ( $hare = isset( $override[ $evanescent_hare ] ) ? $override[ $evanescent_hare ] : call_user_func_array( $callback, array_merge( array( $evanescent_hare ), $callback_args ) ) ) 5061 5273 ) { 5062 if ( $_return_loop ) 5063 $return[$tortoise] = $return[$evanescent_hare] = $return[$hare] = true; 5274 if ( $_return_loop ) { 5275 $return[ $tortoise ] = $return[ $evanescent_hare ] = $return[ $hare ] = true; 5276 } 5064 5277 5065 5278 // tortoise got lapped - must be a loop 5066 if ( $tortoise == $evanescent_hare || $tortoise == $hare ) 5279 if ( $tortoise == $evanescent_hare || $tortoise == $hare ) { 5067 5280 return $_return_loop ? $return : $tortoise; 5281 } 5068 5282 5069 5283 // Increment tortoise by one step 5070 $tortoise = isset( $override[ $tortoise] ) ? $override[$tortoise] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) );5284 $tortoise = isset( $override[ $tortoise ] ) ? $override[ $tortoise ] : call_user_func_array( $callback, array_merge( array( $tortoise ), $callback_args ) ); 5071 5285 } 5072 5286 … … 5140 5354 */ 5141 5355 function wp_debug_backtrace_summary( $ignore_class = null, $skip_frames = 0, $pretty = true ) { 5142 if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) 5356 if ( version_compare( PHP_VERSION, '5.2.5', '>=' ) ) { 5143 5357 $trace = debug_backtrace( false ); 5144 else5358 } else { 5145 5359 $trace = debug_backtrace(); 5146 5147 $caller = array(); 5360 } 5361 5362 $caller = array(); 5148 5363 $check_class = ! is_null( $ignore_class ); 5149 5364 $skip_frames++; // skip this function … … 5153 5368 $skip_frames--; 5154 5369 } elseif ( isset( $call['class'] ) ) { 5155 if ( $check_class && $ignore_class == $call['class'] ) 5370 if ( $check_class && $ignore_class == $call['class'] ) { 5156 5371 continue; // Filter out calls 5372 } 5157 5373 5158 5374 $caller[] = "{$call['class']}{$call['type']}{$call['function']}"; … … 5161 5377 $caller[] = "{$call['function']}('{$call['args'][0]}')"; 5162 5378 } elseif ( in_array( $call['function'], array( 'include', 'include_once', 'require', 'require_once' ) ) ) { 5163 $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ) 5379 $caller[] = $call['function'] . "('" . str_replace( array( WP_CONTENT_DIR, ABSPATH ), '', $call['args'][0] ) . "')"; 5164 5380 } else { 5165 5381 $caller[] = $call['function']; … … 5167 5383 } 5168 5384 } 5169 if ( $pretty ) 5385 if ( $pretty ) { 5170 5386 return join( ', ', array_reverse( $caller ) ); 5171 else5387 } else { 5172 5388 return $caller; 5389 } 5173 5390 } 5174 5391 … … 5188 5405 foreach ( $object_ids as $id ) { 5189 5406 $id = (int) $id; 5190 if ( ! wp_cache_get( $id, $cache_key ) ) {5407 if ( ! wp_cache_get( $id, $cache_key ) ) { 5191 5408 $clean[] = $id; 5192 5409 } … … 5205 5422 */ 5206 5423 function _device_can_upload() { 5207 if ( ! wp_is_mobile() ) 5424 if ( ! wp_is_mobile() ) { 5208 5425 return true; 5426 } 5209 5427 5210 5428 $ua = $_SERVER['HTTP_USER_AGENT']; 5211 5429 5212 if ( strpos( $ua, 'iPhone') !== false5213 || strpos( $ua, 'iPad') !== false5214 || strpos( $ua, 'iPod') !== false ) {5430 if ( strpos( $ua, 'iPhone' ) !== false 5431 || strpos( $ua, 'iPad' ) !== false 5432 || strpos( $ua, 'iPod' ) !== false ) { 5215 5433 return preg_match( '#OS ([\d_]+) like Mac OS X#', $ua, $version ) && version_compare( $version[1], '6', '>=' ); 5216 5434 } … … 5228 5446 */ 5229 5447 function wp_is_stream( $path ) { 5230 $wrappers = stream_get_wrappers();5231 $wrappers_re = '(' . join( '|', $wrappers) . ')';5448 $wrappers = stream_get_wrappers(); 5449 $wrappers_re = '(' . join( '|', $wrappers ) . ')'; 5232 5450 5233 5451 return preg_match( "!^$wrappers_re://!", $path ) === 1; … … 5271 5489 */ 5272 5490 function wp_auth_check_load() { 5273 if ( ! is_admin() && ! is_user_logged_in() ) 5491 if ( ! is_admin() && ! is_user_logged_in() ) { 5274 5492 return; 5275 5276 if ( defined( 'IFRAME_REQUEST' ) ) 5493 } 5494 5495 if ( defined( 'IFRAME_REQUEST' ) ) { 5277 5496 return; 5497 } 5278 5498 5279 5499 $screen = get_current_screen(); 5280 5500 $hidden = array( 'update', 'update-network', 'update-core', 'update-core-network', 'upgrade', 'upgrade-network', 'network' ); 5281 $show = ! in_array( $screen->id, $hidden );5501 $show = ! in_array( $screen->id, $hidden ); 5282 5502 5283 5503 /** … … 5307 5527 */ 5308 5528 function wp_auth_check_html() { 5309 $login_url = wp_login_url();5529 $login_url = wp_login_url(); 5310 5530 $current_domain = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST']; 5311 $same_domain = ( strpos( $login_url, $current_domain ) === 0 );5531 $same_domain = ( strpos( $login_url, $current_domain ) === 0 ); 5312 5532 5313 5533 /** … … 5319 5539 */ 5320 5540 $same_domain = apply_filters( 'wp_auth_check_same_domain', $same_domain ); 5321 $wrap_class = $same_domain ? 'hidden' : 'hidden fallback';5541 $wrap_class = $same_domain ? 'hidden' : 'hidden fallback'; 5322 5542 5323 5543 ?> … … 5329 5549 5330 5550 if ( $same_domain ) { 5331 $login_src = add_query_arg( array( 5332 'interim-login' => '1', 5333 'wp_lang' => get_user_locale(), 5334 ), $login_url ); 5551 $login_src = add_query_arg( 5552 array( 5553 'interim-login' => '1', 5554 'wp_lang' => get_user_locale(), 5555 ), $login_url 5556 ); 5335 5557 ?> 5336 5558 <div id="wp-auth-check-form" class="loading" data-src="<?php echo esc_url( $login_src ); ?>"></div> … … 5340 5562 ?> 5341 5563 <div class="wp-auth-fallback"> 5342 <p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e( 'Session expired'); ?></b></p>5343 <p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e( 'Please log in again.'); ?></a>5344 <?php _e( 'The login page will open in a new window. After logging in you can close it and return to this page.'); ?></p>5564 <p><b class="wp-auth-fallback-expired" tabindex="0"><?php _e( 'Session expired' ); ?></b></p> 5565 <p><a href="<?php echo esc_url( $login_url ); ?>" target="_blank"><?php _e( 'Please log in again.' ); ?></a> 5566 <?php _e( 'The login page will open in a new window. After logging in you can close it and return to this page.' ); ?></p> 5345 5567 </div> 5346 5568 </div> … … 5384 5606 */ 5385 5607 function get_tag_regex( $tag ) { 5386 if ( empty( $tag ) ) 5608 if ( empty( $tag ) ) { 5387 5609 return; 5610 } 5388 5611 return sprintf( '<%1$s[^<]*(?:>[\s\S]*<\/%1$s>|\s*\/>)', tag_escape( $tag ) ); 5389 5612 } … … 5402 5625 */ 5403 5626 function _canonical_charset( $charset ) { 5404 if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset ) ) {5627 if ( 'utf-8' === strtolower( $charset ) || 'utf8' === strtolower( $charset ) ) { 5405 5628 5406 5629 return 'UTF-8'; … … 5442 5665 */ 5443 5666 function mbstring_binary_safe_encoding( $reset = false ) { 5444 static $encodings = array();5667 static $encodings = array(); 5445 5668 static $overloaded = null; 5446 5669 5447 if ( is_null( $overloaded ) ) 5670 if ( is_null( $overloaded ) ) { 5448 5671 $overloaded = function_exists( 'mb_internal_encoding' ) && ( ini_get( 'mbstring.func_overload' ) & 2 ); 5449 5450 if ( false === $overloaded ) 5672 } 5673 5674 if ( false === $overloaded ) { 5451 5675 return; 5676 } 5452 5677 5453 5678 if ( ! $reset ) { … … 5686 5911 */ 5687 5912 function wp_generate_uuid4() { 5688 return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', 5913 return sprintf( 5914 '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', 5689 5915 mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), 5690 5916 mt_rand( 0, 0xffff ), … … 5769 5995 5770 5996 /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */ 5771 $email_change_text = __( 'Hi, 5997 $email_change_text = __( 5998 'Hi, 5772 5999 5773 6000 This notice confirms that the admin email address was changed on ###SITENAME###. … … 5779 6006 Regards, 5780 6007 All at ###SITENAME### 5781 ###SITEURL###' ); 6008 ###SITEURL###' 6009 ); 5782 6010 5783 6011 $email_change_email = array( … … 5816 6044 $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] ); 5817 6045 $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] ); 5818 $email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] ); 5819 $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); 5820 5821 wp_mail( $email_change_email['to'], sprintf( 5822 $email_change_email['subject'], 5823 $site_name 5824 ), $email_change_email['message'], $email_change_email['headers'] ); 5825 } 6046 $email_change_email['message'] = str_replace( '###SITENAME###', $site_name, $email_change_email['message'] ); 6047 $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] ); 6048 6049 wp_mail( 6050 $email_change_email['to'], sprintf( 6051 $email_change_email['subject'], 6052 $site_name 6053 ), $email_change_email['message'], $email_change_email['headers'] 6054 ); 6055 }
Note: See TracChangeset
for help on using the changeset viewer.