3 * Defines constants and global variables that can be overridden, generally in wp-config.php.
9 * Defines initial WordPress constants
11 * @see wp_debug_mode()
15 * @global int $blog_id
17 function wp_initial_constants() {
21 * Constants for expressing human-readable data sizes in their respective number of bytes.
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 );
31 $current_limit = @ini_get( 'memory_limit' );
32 $current_limit_int = wp_convert_hr_to_bytes( $current_limit );
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' );
41 define( 'WP_MEMORY_LIMIT', '40M' );
45 if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
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 );
51 define( 'WP_MAX_MEMORY_LIMIT', '256M' );
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 );
61 if ( ! isset($blog_id) )
64 if ( !defined('WP_CONTENT_DIR') )
65 define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
67 // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
68 if ( !defined('WP_DEBUG') )
69 define( 'WP_DEBUG', false );
71 // Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for
72 // display_errors and not force errors to be displayed. Use false to force display_errors off.
73 if ( !defined('WP_DEBUG_DISPLAY') )
74 define( 'WP_DEBUG_DISPLAY', true );
76 // Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
77 if ( !defined('WP_DEBUG_LOG') )
78 define('WP_DEBUG_LOG', false);
80 if ( !defined('WP_CACHE') )
81 define('WP_CACHE', false);
83 // Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified,
84 // non-concatenated scripts and stylesheets.
85 if ( ! defined( 'SCRIPT_DEBUG' ) ) {
86 if ( ! empty( $GLOBALS['wp_version'] ) ) {
87 $develop_src = false !== strpos( $GLOBALS['wp_version'], '-src' );
92 define( 'SCRIPT_DEBUG', $develop_src );
98 if ( !defined('MEDIA_TRASH') )
99 define('MEDIA_TRASH', false);
101 if ( !defined('SHORTINIT') )
102 define('SHORTINIT', false);
104 // Constants for features added to WP that should short-circuit their plugin implementations
105 define( 'WP_FEATURE_BETTER_PASSWORDS', true );
108 * Constants for expressing human-readable intervals
109 * in their respective number of seconds.
111 * Please note that these values are approximate and are provided for convenience.
112 * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
113 * YEAR_IN_SECONDS does not take leap years into account.
115 * If you need more accuracy please consider using the DateTime class (https://secure.php.net/manual/en/class.datetime.php).
118 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
120 define( 'MINUTE_IN_SECONDS', 60 );
121 define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
122 define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
123 define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
124 define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
125 define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
130 * Defines plugin directory WordPress constants
132 * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
136 function wp_plugin_directory_constants() {
137 if ( !defined('WP_CONTENT_URL') )
138 define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
141 * Allows for the plugins directory to be moved from the default location.
145 if ( !defined('WP_PLUGIN_DIR') )
146 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
149 * Allows for the plugins directory to be moved from the default location.
153 if ( !defined('WP_PLUGIN_URL') )
154 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
157 * Allows for the plugins directory to be moved from the default location.
162 if ( !defined('PLUGINDIR') )
163 define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
166 * Allows for the mu-plugins directory to be moved from the default location.
170 if ( !defined('WPMU_PLUGIN_DIR') )
171 define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
174 * Allows for the mu-plugins directory to be moved from the default location.
178 if ( !defined('WPMU_PLUGIN_URL') )
179 define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
182 * Allows for the mu-plugins directory to be moved from the default location.
187 if ( !defined( 'MUPLUGINDIR' ) )
188 define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
192 * Defines cookie related WordPress constants
194 * Defines constants after multisite is loaded.
197 function wp_cookie_constants() {
199 * Used to guarantee unique hash cookies
203 if ( !defined( 'COOKIEHASH' ) ) {
204 $siteurl = get_site_option( 'siteurl' );
206 define( 'COOKIEHASH', md5( $siteurl ) );
208 define( 'COOKIEHASH', '' );
214 if ( !defined('USER_COOKIE') )
215 define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
220 if ( !defined('PASS_COOKIE') )
221 define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
226 if ( !defined('AUTH_COOKIE') )
227 define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
232 if ( !defined('SECURE_AUTH_COOKIE') )
233 define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
238 if ( !defined('LOGGED_IN_COOKIE') )
239 define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
244 if ( !defined('TEST_COOKIE') )
245 define('TEST_COOKIE', 'wordpress_test_cookie');
250 if ( !defined('COOKIEPATH') )
251 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
256 if ( !defined('SITECOOKIEPATH') )
257 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
262 if ( !defined('ADMIN_COOKIE_PATH') )
263 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
268 if ( !defined('PLUGINS_COOKIE_PATH') )
269 define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
274 if ( !defined('COOKIE_DOMAIN') )
275 define('COOKIE_DOMAIN', false);
279 * Defines cookie related WordPress constants
283 function wp_ssl_constants() {
287 if ( !defined( 'FORCE_SSL_ADMIN' ) ) {
288 if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
289 define( 'FORCE_SSL_ADMIN', true );
291 define( 'FORCE_SSL_ADMIN', false );
294 force_ssl_admin( FORCE_SSL_ADMIN );
300 if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) {
301 force_ssl_admin( true );
306 * Defines functionality related WordPress constants
310 function wp_functionality_constants() {
314 if ( !defined( 'AUTOSAVE_INTERVAL' ) )
315 define( 'AUTOSAVE_INTERVAL', 60 );
320 if ( !defined( 'EMPTY_TRASH_DAYS' ) )
321 define( 'EMPTY_TRASH_DAYS', 30 );
323 if ( !defined('WP_POST_REVISIONS') )
324 define('WP_POST_REVISIONS', true);
329 if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) )
330 define('WP_CRON_LOCK_TIMEOUT', 60); // In seconds
334 * Defines templating related WordPress constants
338 function wp_templating_constants() {
340 * Filesystem path to the current active template directory
343 define('TEMPLATEPATH', get_template_directory());
346 * Filesystem path to the current active template stylesheet directory
349 define('STYLESHEETPATH', get_stylesheet_directory());
352 * Slug of the default theme for this install.
353 * Used as the default theme when installing new sites.
354 * It will be used as the fallback if the current theme doesn't exist.
357 * @see WP_Theme::get_core_default_theme()
359 if ( !defined('WP_DEFAULT_THEME') )
360 define( 'WP_DEFAULT_THEME', 'twentysixteen' );