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