Changeset 48535
- Timestamp:
- 07/21/2020 03:19:58 PM (4 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/class-wp-debug-data.php
r48125 r48535 519 519 'value' => ( is_array( $imagick_version ) ? $imagick_version['versionString'] : $imagick_version ), 520 520 ); 521 522 if ( ! function_exists( 'ini_get' ) ) { 523 $info['wp-media']['fields']['ini_get'] = array( 524 'label' => __( 'File upload settings' ), 525 'value' => sprintf( 526 /* translators: %s: ini_get() */ 527 __( 'Unable to determine some settings, as the %s function has been disabled.' ), 528 'ini_get()' 529 ), 530 'debug' => 'ini_get() is disabled', 531 ); 532 } else { 533 // Get the PHP ini directive values. 534 $post_max_size = ini_get( 'post_max_size' ); 535 $upload_max_size = ini_get( 'upload_max_filesize' ); 536 $max_file_uploads = ini_get( 'max_file_uploads' ); 537 $effective = min( parse_ini_size( $post_max_size ), parse_ini_size( $upload_max_size ) ); 538 539 // Add info in Media section. 540 $info['wp-media']['fields']['file_uploads'] = array( 541 'label' => __( 'File uploads' ), 542 'value' => empty( ini_get( 'file_uploads' ) ) ? __( 'Disabled' ) : __( 'Enabled' ), 543 'debug' => 'File uploads is turned off', 544 ); 545 $info['wp-media']['fields']['post_max_size'] = array( 546 'label' => __( 'Max size of post data allowed' ), 547 'value' => $post_max_size, 548 ); 549 $info['wp-media']['fields']['upload_max_filesize'] = array( 550 'label' => __( 'Max size of an uploaded file' ), 551 'value' => $upload_max_size, 552 ); 553 $info['wp-media']['fields']['upload_max'] = array( 554 'label' => __( 'Max effective file size' ), 555 'value' => size_format( $effective ), 556 ); 557 $info['wp-media']['fields']['max_file_uploads'] = array( 558 'label' => __( 'Max number of files allowed' ), 559 'value' => number_format( $max_file_uploads ), 560 ); 561 } 521 562 522 563 // If Imagick is used as our editor, provide some more information about its limitations. -
trunk/src/wp-admin/includes/class-wp-site-health.php
r48475 r48535 1951 1951 ); 1952 1952 } 1953 } 1954 1955 return $result; 1956 } 1957 1958 /** 1959 * Test if 'file_uploads' directive in PHP.ini is turned off 1960 * 1961 * @since 5.5.0 1962 * 1963 * @return array The test results. 1964 */ 1965 public function get_test_file_uploads() { 1966 $result = array( 1967 'label' => __( 'Files can be uploaded.' ), 1968 'status' => 'good', 1969 'badge' => array( 1970 'label' => __( 'Performance' ), 1971 'color' => 'blue', 1972 ), 1973 'description' => sprintf( 1974 '<p>%s</p>', 1975 sprintf( 1976 /* translators: %1$s: file_uploads %2$s: php.ini */ 1977 __( 'The %1$s directive in %2$s determines if uploading to is allowed in your WordPress.' ), 1978 '<code>file_uploads</code>', 1979 '<code>php.ini</code>' 1980 ) 1981 ), 1982 'actions' => '', 1983 'test' => 'file_uploads', 1984 ); 1985 1986 if ( ! function_exists( 'ini_get' ) ) { 1987 $result['status'] = 'critical'; 1988 $result['description'] .= sprintf( 1989 /* translators: %s: ini_get() */ 1990 __( 'The %s function has been disabled, some media settings are unavailable because of this.' ), 1991 '<code>ini_get()</code>' 1992 ); 1993 return $result; 1994 } 1995 1996 if ( empty( ini_get( 'file_uploads' ) ) ) { 1997 $result['status'] = 'critical'; 1998 $result['description'] .= sprintf( 1999 '<p>%s</p>', 2000 sprintf( 2001 /* translators: %1$s: file_uploads %2$s: 0 */ 2002 __( '%1$s is set to %2$s. You won\'t be able to upload files in your WordPress.' ), 2003 '<code>file_uploads</code>', 2004 '<code>0</code>' 2005 ) 2006 ); 2007 return $result; 2008 } 2009 2010 if ( parse_ini_size( ini_get( 'post_max_size' ) ) !== parse_ini_size( ini_get( 'upload_max_filesize' ) ) ) { 2011 $result['label'] = __( 'Mismatched "post_max_size" and "upload_max_filesize" values.' ); 2012 $result['status'] = 'recommended'; 2013 $result['description'] = sprintf( 2014 '<p>%s</p>', 2015 sprintf( 2016 /* translators: %1$s: post_max_size %2$s: upload_max_filesize */ 2017 __( 'The settings for %1$s and %2$s are not the same, this could cause some problems when trying to upload files.' ), 2018 '<code>post_max_size</code>', 2019 '<code>upload_max_filesize</code>' 2020 ) 2021 ); 2022 return $result; 1953 2023 } 1954 2024 … … 2026 2096 'test' => 'is_in_debug_mode', 2027 2097 ), 2098 'file_uploads' => array( 2099 'label' => __( 'File uploads' ), 2100 'test' => 'file_uploads', 2101 ), 2028 2102 ), 2029 2103 'async' => array( -
trunk/src/wp-includes/functions.php
r48473 r48535 475 475 476 476 return false; 477 } 478 479 /** 480 * Converts a shorthand byte string to bytes. 481 * 482 * Useful when needing to compare two byte strings for size differences. 483 * 484 * E.g. 485 * "1G" (1 Gigabyte) = 1073741824 486 * "10M" (10 Megabytes) = 10485760 487 * "1K" (1 Kilobyte) = 1024 488 * 489 * @since 5.5.0 490 * 491 * @param string $size_string Shorthand byte string 492 * @return int $size_string converted to numberic bytes. 493 */ 494 function parse_ini_size( $size_string ) { 495 $size_string = trim( $size_string ); 496 $last = strtolower( substr( $size_string, - 1 ) ); 497 $value = intval( $size_string ); 498 499 switch ( $last ) { 500 case 'g': 501 return (int) $value * GB_IN_BYTES; 502 case 'm': 503 return (int) $value * MB_IN_BYTES; 504 case 'k': 505 return (int) $value * KB_IN_BYTES; 506 default: 507 return (int) $value; 508 } 477 509 } 478 510
Note: See TracChangeset
for help on using the changeset viewer.