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