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