- // set memory limits
- if ( !defined('WP_MEMORY_LIMIT') ) {
- if ( is_multisite() ) {
- define('WP_MEMORY_LIMIT', '64M');
+ /**#@+
+ * Constants for expressing human-readable data sizes in their respective number of bytes.
+ *
+ * @since 4.4.0
+ */
+ define( 'KB_IN_BYTES', 1024 );
+ define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
+ define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
+ define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );
+ /**#@-*/
+
+ $current_limit = @ini_get( 'memory_limit' );
+ $current_limit_int = wp_convert_hr_to_bytes( $current_limit );
+
+ // Define memory limits.
+ if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
+ if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
+ define( 'WP_MEMORY_LIMIT', $current_limit );
+ } elseif ( is_multisite() ) {
+ define( 'WP_MEMORY_LIMIT', '64M' );