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