~canonical-sysadmins/wordpress/4.8.1

« back to all changes in this revision

Viewing changes to wp-includes/default-constants.php

  • Committer: Barry Price
  • Date: 2016-08-17 04:50:12 UTC
  • mfrom: (1.1.18 upstream)
  • Revision ID: barry.price@canonical.com-20160817045012-qfui81zhqnqv2ba9
Merge WP4.6 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
function wp_initial_constants() {
18
18
        global $blog_id;
19
19
 
20
 
        // set memory limits
21
 
        if ( !defined('WP_MEMORY_LIMIT') ) {
22
 
                if ( is_multisite() ) {
23
 
                        define('WP_MEMORY_LIMIT', '64M');
 
20
        /**#@+
 
21
         * Constants for expressing human-readable data sizes in their respective number of bytes.
 
22
         *
 
23
         * @since 4.4.0
 
24
         */
 
25
        define( 'KB_IN_BYTES', 1024 );
 
26
        define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
 
27
        define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
 
28
        define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );
 
29
        /**#@-*/
 
30
 
 
31
        $current_limit     = @ini_get( 'memory_limit' );
 
32
        $current_limit_int = wp_convert_hr_to_bytes( $current_limit );
 
33
 
 
34
        // Define memory limits.
 
35
        if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
 
36
                if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
 
37
                        define( 'WP_MEMORY_LIMIT', $current_limit );
 
38
                } elseif ( is_multisite() ) {
 
39
                        define( 'WP_MEMORY_LIMIT', '64M' );
24
40
                } else {
25
 
                        define('WP_MEMORY_LIMIT', '40M');
 
41
                        define( 'WP_MEMORY_LIMIT', '40M' );
26
42
                }
27
43
        }
28
44
 
29
45
        if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
30
 
                define( 'WP_MAX_MEMORY_LIMIT', '256M' );
 
46
                if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
 
47
                        define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
 
48
                } elseif ( -1 === $current_limit_int || $current_limit_int > 268435456 /* = 256M */ ) {
 
49
                        define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
 
50
                } else {
 
51
                        define( 'WP_MAX_MEMORY_LIMIT', '256M' );
 
52
                }
 
53
        }
 
54
 
 
55
        // Set memory limits.
 
56
        $wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
 
57
        if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) {
 
58
                @ini_set( 'memory_limit', WP_MEMORY_LIMIT );
31
59
        }
32
60
 
33
61
        if ( ! isset($blog_id) )
34
62
                $blog_id = 1;
35
63
 
36
 
        // set memory limits.
37
 
        if ( function_exists( 'memory_get_usage' ) ) {
38
 
                $current_limit = @ini_get( 'memory_limit' );
39
 
                $current_limit_int = intval( $current_limit );
40
 
                if ( false !== strpos( $current_limit, 'G' ) )
41
 
                        $current_limit_int *= 1024;
42
 
                $wp_limit_int = intval( WP_MEMORY_LIMIT );
43
 
                if ( false !== strpos( WP_MEMORY_LIMIT, 'G' ) )
44
 
                        $wp_limit_int *= 1024;
45
 
 
46
 
                if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || $current_limit_int < $wp_limit_int ) )
47
 
                        @ini_set( 'memory_limit', WP_MEMORY_LIMIT );
48
 
        }
49
 
 
50
64
        if ( !defined('WP_CONTENT_DIR') )
51
65
                define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
52
66
 
98
112
         * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
99
113
         * YEAR_IN_SECONDS does not take leap years into account.
100
114
         *
101
 
         * If you need more accuracy please consider using the DateTime class (http://php.net/manual/class.datetime.php).
 
115
         * If you need more accuracy please consider using the DateTime class (https://secure.php.net/manual/en/class.datetime.php).
102
116
         *
103
117
         * @since 3.5.0
104
118
         * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
110
124
        define( 'MONTH_IN_SECONDS',  30 * DAY_IN_SECONDS    );
111
125
        define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );
112
126
        /**#@-*/
113
 
 
114
 
        /**#@+
115
 
         * Constants for expressing human-readable data sizes in their respective number of bytes.
116
 
         *
117
 
         * @since 4.4.0
118
 
         */
119
 
        define( 'KB_IN_BYTES', 1024 );
120
 
        define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
121
 
        define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
122
 
        define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );
123
 
        /**#@-*/
124
127
}
125
128
 
126
129
/**