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 if ( !defined('WP_MEMORY_LIMIT') ) {
22 if ( is_multisite() ) {
23 define('WP_MEMORY_LIMIT', '64M');
25 define('WP_MEMORY_LIMIT', '40M');
29 if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
30 define( 'WP_MAX_MEMORY_LIMIT', '256M' );
33 if ( ! isset($blog_id) )
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;
46 if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || $current_limit_int < $wp_limit_int ) )
47 @ini_set( 'memory_limit', WP_MEMORY_LIMIT );
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
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 );
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 );
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);
66 if ( !defined('WP_CACHE') )
67 define('WP_CACHE', false);
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' );
78 define( 'SCRIPT_DEBUG', $develop_src );
84 if ( !defined('MEDIA_TRASH') )
85 define('MEDIA_TRASH', false);
87 if ( !defined('SHORTINIT') )
88 define('SHORTINIT', false);
90 // Constants for features added to WP that should short-circuit their plugin implementations
91 define( 'WP_FEATURE_BETTER_PASSWORDS', true );
94 * Constants for expressing human-readable intervals
95 * in their respective number of seconds.
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.
101 * If you need more accuracy please consider using the DateTime class (http://php.net/manual/class.datetime.php).
104 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
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 );
115 * Constants for expressing human-readable data sizes in their respective number of bytes.
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 );
127 * Defines plugin directory WordPress constants
129 * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
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
138 * Allows for the plugins directory to be moved from the default location.
142 if ( !defined('WP_PLUGIN_DIR') )
143 define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
146 * Allows for the plugins directory to be moved from the default location.
150 if ( !defined('WP_PLUGIN_URL') )
151 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
154 * Allows for the plugins directory to be moved from the default location.
159 if ( !defined('PLUGINDIR') )
160 define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
163 * Allows for the mu-plugins directory to be moved from the default location.
167 if ( !defined('WPMU_PLUGIN_DIR') )
168 define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
171 * Allows for the mu-plugins directory to be moved from the default location.
175 if ( !defined('WPMU_PLUGIN_URL') )
176 define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
179 * Allows for the mu-plugins directory to be moved from the default location.
184 if ( !defined( 'MUPLUGINDIR' ) )
185 define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
189 * Defines cookie related WordPress constants
191 * Defines constants after multisite is loaded.
194 function wp_cookie_constants() {
196 * Used to guarantee unique hash cookies
200 if ( !defined( 'COOKIEHASH' ) ) {
201 $siteurl = get_site_option( 'siteurl' );
203 define( 'COOKIEHASH', md5( $siteurl ) );
205 define( 'COOKIEHASH', '' );
211 if ( !defined('USER_COOKIE') )
212 define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
217 if ( !defined('PASS_COOKIE') )
218 define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
223 if ( !defined('AUTH_COOKIE') )
224 define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
229 if ( !defined('SECURE_AUTH_COOKIE') )
230 define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
235 if ( !defined('LOGGED_IN_COOKIE') )
236 define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
241 if ( !defined('TEST_COOKIE') )
242 define('TEST_COOKIE', 'wordpress_test_cookie');
247 if ( !defined('COOKIEPATH') )
248 define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
253 if ( !defined('SITECOOKIEPATH') )
254 define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
259 if ( !defined('ADMIN_COOKIE_PATH') )
260 define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
265 if ( !defined('PLUGINS_COOKIE_PATH') )
266 define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
271 if ( !defined('COOKIE_DOMAIN') )
272 define('COOKIE_DOMAIN', false);
276 * Defines cookie related WordPress constants
280 function wp_ssl_constants() {
284 if ( !defined( 'FORCE_SSL_ADMIN' ) ) {
285 if ( 'https' === parse_url( get_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
286 define( 'FORCE_SSL_ADMIN', true );
288 define( 'FORCE_SSL_ADMIN', false );
291 force_ssl_admin( FORCE_SSL_ADMIN );
297 if ( defined( 'FORCE_SSL_LOGIN' ) && FORCE_SSL_LOGIN ) {
298 force_ssl_admin( true );
303 * Defines functionality related WordPress constants
307 function wp_functionality_constants() {
311 if ( !defined( 'AUTOSAVE_INTERVAL' ) )
312 define( 'AUTOSAVE_INTERVAL', 60 );
317 if ( !defined( 'EMPTY_TRASH_DAYS' ) )
318 define( 'EMPTY_TRASH_DAYS', 30 );
320 if ( !defined('WP_POST_REVISIONS') )
321 define('WP_POST_REVISIONS', true);
326 if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) )
327 define('WP_CRON_LOCK_TIMEOUT', 60); // In seconds
331 * Defines templating related WordPress constants
335 function wp_templating_constants() {
337 * Filesystem path to the current active template directory
340 define('TEMPLATEPATH', get_template_directory());
343 * Filesystem path to the current active template stylesheet directory
346 define('STYLESHEETPATH', get_stylesheet_directory());
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.
354 * @see WP_Theme::get_core_default_theme()
356 if ( !defined('WP_DEFAULT_THEME') )
357 define( 'WP_DEFAULT_THEME', 'twentysixteen' );