]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/default-constants.php
Wordpress 4.5.3-scripts
[autoinstalls/wordpress.git] / wp-includes / default-constants.php
1 <?php
2 /**
3  * Defines constants and global variables that can be overridden, generally in wp-config.php.
4  *
5  * @package WordPress
6  */
7
8 /**
9  * Defines initial WordPress constants
10  *
11  * @see wp_debug_mode()
12  *
13  * @since 3.0.0
14  *
15  * @global int $blog_id
16  */
17 function wp_initial_constants() {
18         global $blog_id;
19
20         // set memory limits
21         if ( !defined('WP_MEMORY_LIMIT') ) {
22                 if ( is_multisite() ) {
23                         define('WP_MEMORY_LIMIT', '64M');
24                 } else {
25                         define('WP_MEMORY_LIMIT', '40M');
26                 }
27         }
28
29         if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
30                 define( 'WP_MAX_MEMORY_LIMIT', '256M' );
31         }
32
33         if ( ! isset($blog_id) )
34                 $blog_id = 1;
35
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         if ( !defined('WP_CONTENT_DIR') )
51                 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
52
53         // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
54         if ( !defined('WP_DEBUG') )
55                 define( 'WP_DEBUG', false );
56
57         // Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for
58         // display_errors and not force errors to be displayed. Use false to force display_errors off.
59         if ( !defined('WP_DEBUG_DISPLAY') )
60                 define( 'WP_DEBUG_DISPLAY', true );
61
62         // Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
63         if ( !defined('WP_DEBUG_LOG') )
64                 define('WP_DEBUG_LOG', false);
65
66         if ( !defined('WP_CACHE') )
67                 define('WP_CACHE', false);
68
69         // Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified,
70         // non-concatenated scripts and stylesheets.
71         if ( ! defined( 'SCRIPT_DEBUG' ) ) {
72                 if ( ! empty( $GLOBALS['wp_version'] ) ) {
73                         $develop_src = false !== strpos( $GLOBALS['wp_version'], '-src' );
74                 } else {
75                         $develop_src = false;
76                 }
77
78                 define( 'SCRIPT_DEBUG', $develop_src );
79         }
80
81         /**
82          * Private
83          */
84         if ( !defined('MEDIA_TRASH') )
85                 define('MEDIA_TRASH', false);
86
87         if ( !defined('SHORTINIT') )
88                 define('SHORTINIT', false);
89
90         // Constants for features added to WP that should short-circuit their plugin implementations
91         define( 'WP_FEATURE_BETTER_PASSWORDS', true );
92
93         /**#@+
94          * Constants for expressing human-readable intervals
95          * in their respective number of seconds.
96          *
97          * Please note that these values are approximate and are provided for convenience.
98          * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
99          * YEAR_IN_SECONDS does not take leap years into account.
100          *
101          * If you need more accuracy please consider using the DateTime class (http://php.net/manual/class.datetime.php).
102          *
103          * @since 3.5.0
104          * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
105          */
106         define( 'MINUTE_IN_SECONDS', 60 );
107         define( 'HOUR_IN_SECONDS',   60 * MINUTE_IN_SECONDS );
108         define( 'DAY_IN_SECONDS',    24 * HOUR_IN_SECONDS   );
109         define( 'WEEK_IN_SECONDS',    7 * DAY_IN_SECONDS    );
110         define( 'MONTH_IN_SECONDS',  30 * DAY_IN_SECONDS    );
111         define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );
112         /**#@-*/
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 }
125
126 /**
127  * Defines plugin directory WordPress constants
128  *
129  * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
130  *
131  * @since 3.0.0
132  */
133 function wp_plugin_directory_constants() {
134         if ( !defined('WP_CONTENT_URL') )
135                 define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
136
137         /**
138          * Allows for the plugins directory to be moved from the default location.
139          *
140          * @since 2.6.0
141          */
142         if ( !defined('WP_PLUGIN_DIR') )
143                 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
144
145         /**
146          * Allows for the plugins directory to be moved from the default location.
147          *
148          * @since 2.6.0
149          */
150         if ( !defined('WP_PLUGIN_URL') )
151                 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
152
153         /**
154          * Allows for the plugins directory to be moved from the default location.
155          *
156          * @since 2.1.0
157          * @deprecated
158          */
159         if ( !defined('PLUGINDIR') )
160                 define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
161
162         /**
163          * Allows for the mu-plugins directory to be moved from the default location.
164          *
165          * @since 2.8.0
166          */
167         if ( !defined('WPMU_PLUGIN_DIR') )
168                 define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
169
170         /**
171          * Allows for the mu-plugins directory to be moved from the default location.
172          *
173          * @since 2.8.0
174          */
175         if ( !defined('WPMU_PLUGIN_URL') )
176                 define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
177
178         /**
179          * Allows for the mu-plugins directory to be moved from the default location.
180          *
181          * @since 2.8.0
182          * @deprecated
183          */
184         if ( !defined( 'MUPLUGINDIR' ) )
185                 define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
186 }
187
188 /**
189  * Defines cookie related WordPress constants
190  *
191  * Defines constants after multisite is loaded.
192  * @since 3.0.0
193  */
194 function wp_cookie_constants() {
195         /**
196          * Used to guarantee unique hash cookies
197          *
198          * @since 1.5.0
199          */
200         if ( !defined( 'COOKIEHASH' ) ) {
201                 $siteurl = get_site_option( 'siteurl' );
202                 if ( $siteurl )
203                         define( 'COOKIEHASH', md5( $siteurl ) );
204                 else
205                         define( 'COOKIEHASH', '' );
206         }
207
208         /**
209          * @since 2.0.0
210          */
211         if ( !defined('USER_COOKIE') )
212                 define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
213
214         /**
215          * @since 2.0.0
216          */
217         if ( !defined('PASS_COOKIE') )
218                 define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
219
220         /**
221          * @since 2.5.0
222          */
223         if ( !defined('AUTH_COOKIE') )
224                 define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
225
226         /**
227          * @since 2.6.0
228          */
229         if ( !defined('SECURE_AUTH_COOKIE') )
230                 define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
231
232         /**
233          * @since 2.6.0
234          */
235         if ( !defined('LOGGED_IN_COOKIE') )
236                 define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
237
238         /**
239          * @since 2.3.0
240          */
241         if ( !defined('TEST_COOKIE') )
242                 define('TEST_COOKIE', 'wordpress_test_cookie');
243
244         /**
245          * @since 1.2.0
246          */
247         if ( !defined('COOKIEPATH') )
248                 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
249
250         /**
251          * @since 1.5.0
252          */
253         if ( !defined('SITECOOKIEPATH') )
254                 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
255
256         /**
257          * @since 2.6.0
258          */
259         if ( !defined('ADMIN_COOKIE_PATH') )
260                 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
261
262         /**
263          * @since 2.6.0
264          */
265         if ( !defined('PLUGINS_COOKIE_PATH') )
266                 define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL)  );
267
268         /**
269          * @since 2.0.0
270          */
271         if ( !defined('COOKIE_DOMAIN') )
272                 define('COOKIE_DOMAIN', false);
273 }
274
275 /**
276  * Defines cookie related WordPress constants
277  *
278  * @since 3.0.0
279  */
280 function wp_ssl_constants() {
281         /**
282          * @since 2.6.0
283          */
284         if ( !defined( 'FORCE_SSL_ADMIN' ) ) {
285                 if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
286                         define( 'FORCE_SSL_ADMIN', true );
287                 } else {
288                         define( 'FORCE_SSL_ADMIN', false );
289                 }
290         }
291         force_ssl_admin( FORCE_SSL_ADMIN );
292
293         /**
294          * @since 2.6.0
295          * @deprecated 4.0.0
296          */
297         if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) {
298                 force_ssl_admin( true );
299         }
300 }
301
302 /**
303  * Defines functionality related WordPress constants
304  *
305  * @since 3.0.0
306  */
307 function wp_functionality_constants() {
308         /**
309          * @since 2.5.0
310          */
311         if ( !defined( 'AUTOSAVE_INTERVAL' ) )
312                 define( 'AUTOSAVE_INTERVAL', 60 );
313
314         /**
315          * @since 2.9.0
316          */
317         if ( !defined( 'EMPTY_TRASH_DAYS' ) )
318                 define( 'EMPTY_TRASH_DAYS', 30 );
319
320         if ( !defined('WP_POST_REVISIONS') )
321                 define('WP_POST_REVISIONS', true);
322
323         /**
324          * @since 3.3.0
325          */
326         if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) )
327                 define('WP_CRON_LOCK_TIMEOUT', 60);  // In seconds
328 }
329
330 /**
331  * Defines templating related WordPress constants
332  *
333  * @since 3.0.0
334  */
335 function wp_templating_constants() {
336         /**
337          * Filesystem path to the current active template directory
338          * @since 1.5.0
339          */
340         define('TEMPLATEPATH', get_template_directory());
341
342         /**
343          * Filesystem path to the current active template stylesheet directory
344          * @since 2.1.0
345          */
346         define('STYLESHEETPATH', get_stylesheet_directory());
347
348         /**
349          * Slug of the default theme for this install.
350          * Used as the default theme when installing new sites.
351          * It will be used as the fallback if the current theme doesn't exist.
352          *
353          * @since 3.0.0
354          * @see WP_Theme::get_core_default_theme()
355          */
356         if ( !defined('WP_DEFAULT_THEME') )
357                 define( 'WP_DEFAULT_THEME', 'twentysixteen' );
358
359 }