PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/default-constants.php

https://gitlab.com/Blueprint-Marketing/WordPress-1
PHP | 316 lines | 117 code | 43 blank | 156 comment | 47 complexity | 6898c13f367ea5fa5d3f83157c3e6a02 MD5 | raw file
  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. * Defines initial WordPress constants
  9. *
  10. * @see wp_debug_mode()
  11. *
  12. * @since 3.0.0
  13. */
  14. function wp_initial_constants() {
  15. global $blog_id;
  16. // set memory limits
  17. if ( !defined('WP_MEMORY_LIMIT') ) {
  18. if( is_multisite() ) {
  19. define('WP_MEMORY_LIMIT', '64M');
  20. } else {
  21. define('WP_MEMORY_LIMIT', '40M');
  22. }
  23. }
  24. if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
  25. define( 'WP_MAX_MEMORY_LIMIT', '256M' );
  26. }
  27. /**
  28. * The $blog_id global, which you can change in the config allows you to create a simple
  29. * multiple blog installation using just one WordPress and changing $blog_id around.
  30. *
  31. * @global int $blog_id
  32. * @since 2.0.0
  33. */
  34. if ( ! isset($blog_id) )
  35. $blog_id = 1;
  36. // set memory limits.
  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;
  45. if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || $current_limit_int < $wp_limit_int ) )
  46. @ini_set( 'memory_limit', WP_MEMORY_LIMIT );
  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. // Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
  51. if ( !defined('WP_DEBUG') )
  52. define( 'WP_DEBUG', false );
  53. // Add define('WP_DEBUG_DISPLAY', null); to wp-config.php use the globally configured setting for
  54. // display_errors and not force errors to be displayed. Use false to force display_errors off.
  55. if ( !defined('WP_DEBUG_DISPLAY') )
  56. define( 'WP_DEBUG_DISPLAY', true );
  57. // Add define('WP_DEBUG_LOG', true); to enable error logging to wp-content/debug.log.
  58. if ( !defined('WP_DEBUG_LOG') )
  59. define('WP_DEBUG_LOG', false);
  60. if ( !defined('WP_CACHE') )
  61. define('WP_CACHE', false);
  62. /**
  63. * Private
  64. */
  65. if ( !defined('MEDIA_TRASH') )
  66. define('MEDIA_TRASH', false);
  67. if ( !defined('SHORTINIT') )
  68. define('SHORTINIT', false);
  69. // Constants for expressing human-readable intervals
  70. // in their respective number of seconds.
  71. define( 'MINUTE_IN_SECONDS', 60 );
  72. define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
  73. define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
  74. define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
  75. define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
  76. }
  77. /**
  78. * Defines plugin directory WordPress constants
  79. *
  80. * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
  81. *
  82. * @since 3.0.0
  83. */
  84. function wp_plugin_directory_constants() {
  85. if ( !defined('WP_CONTENT_URL') )
  86. define( 'WP_CONTENT_URL', get_option('siteurl') . '/wp-content'); // full url - WP_CONTENT_DIR is defined further up
  87. /**
  88. * Allows for the plugins directory to be moved from the default location.
  89. *
  90. * @since 2.6.0
  91. */
  92. if ( !defined('WP_PLUGIN_DIR') )
  93. define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
  94. /**
  95. * Allows for the plugins directory to be moved from the default location.
  96. *
  97. * @since 2.6.0
  98. */
  99. if ( !defined('WP_PLUGIN_URL') )
  100. define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
  101. /**
  102. * Allows for the plugins directory to be moved from the default location.
  103. *
  104. * @since 2.1.0
  105. * @deprecated
  106. */
  107. if ( !defined('PLUGINDIR') )
  108. define( 'PLUGINDIR', 'wp-content/plugins' ); // Relative to ABSPATH. For back compat.
  109. /**
  110. * Allows for the mu-plugins directory to be moved from the default location.
  111. *
  112. * @since 2.8.0
  113. */
  114. if ( !defined('WPMU_PLUGIN_DIR') )
  115. define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
  116. /**
  117. * Allows for the mu-plugins directory to be moved from the default location.
  118. *
  119. * @since 2.8.0
  120. */
  121. if ( !defined('WPMU_PLUGIN_URL') )
  122. define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
  123. /**
  124. * Allows for the mu-plugins directory to be moved from the default location.
  125. *
  126. * @since 2.8.0
  127. * @deprecated
  128. */
  129. if ( !defined( 'MUPLUGINDIR' ) )
  130. define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
  131. }
  132. /**
  133. * Defines cookie related WordPress constants
  134. *
  135. * Defines constants after multisite is loaded. Cookie-related constants may be overridden in ms_network_cookies().
  136. * @since 3.0.0
  137. */
  138. function wp_cookie_constants() {
  139. /**
  140. * Used to guarantee unique hash cookies
  141. * @since 1.5
  142. */
  143. if ( !defined( 'COOKIEHASH' ) ) {
  144. $siteurl = get_site_option( 'siteurl' );
  145. if ( $siteurl )
  146. define( 'COOKIEHASH', md5( $siteurl ) );
  147. else
  148. define( 'COOKIEHASH', '' );
  149. }
  150. /**
  151. * @since 2.0.0
  152. */
  153. if ( !defined('USER_COOKIE') )
  154. define('USER_COOKIE', 'wordpressuser_' . COOKIEHASH);
  155. /**
  156. * @since 2.0.0
  157. */
  158. if ( !defined('PASS_COOKIE') )
  159. define('PASS_COOKIE', 'wordpresspass_' . COOKIEHASH);
  160. /**
  161. * @since 2.5.0
  162. */
  163. if ( !defined('AUTH_COOKIE') )
  164. define('AUTH_COOKIE', 'wordpress_' . COOKIEHASH);
  165. /**
  166. * @since 2.6.0
  167. */
  168. if ( !defined('SECURE_AUTH_COOKIE') )
  169. define('SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH);
  170. /**
  171. * @since 2.6.0
  172. */
  173. if ( !defined('LOGGED_IN_COOKIE') )
  174. define('LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH);
  175. /**
  176. * @since 2.3.0
  177. */
  178. if ( !defined('TEST_COOKIE') )
  179. define('TEST_COOKIE', 'wordpress_test_cookie');
  180. /**
  181. * @since 1.2.0
  182. */
  183. if ( !defined('COOKIEPATH') )
  184. define('COOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('home') . '/' ) );
  185. /**
  186. * @since 1.5.0
  187. */
  188. if ( !defined('SITECOOKIEPATH') )
  189. define('SITECOOKIEPATH', preg_replace('|https?://[^/]+|i', '', get_option('siteurl') . '/' ) );
  190. /**
  191. * @since 2.6.0
  192. */
  193. if ( !defined('ADMIN_COOKIE_PATH') )
  194. define( 'ADMIN_COOKIE_PATH', SITECOOKIEPATH . 'wp-admin' );
  195. /**
  196. * @since 2.6.0
  197. */
  198. if ( !defined('PLUGINS_COOKIE_PATH') )
  199. define( 'PLUGINS_COOKIE_PATH', preg_replace('|https?://[^/]+|i', '', WP_PLUGIN_URL) );
  200. /**
  201. * @since 2.0.0
  202. */
  203. if ( !defined('COOKIE_DOMAIN') )
  204. define('COOKIE_DOMAIN', false);
  205. }
  206. /**
  207. * Defines cookie related WordPress constants
  208. *
  209. * @since 3.0.0
  210. */
  211. function wp_ssl_constants() {
  212. /**
  213. * @since 2.6.0
  214. */
  215. if ( !defined('FORCE_SSL_ADMIN') )
  216. define('FORCE_SSL_ADMIN', false);
  217. force_ssl_admin(FORCE_SSL_ADMIN);
  218. /**
  219. * @since 2.6.0
  220. */
  221. if ( !defined('FORCE_SSL_LOGIN') )
  222. define('FORCE_SSL_LOGIN', false);
  223. force_ssl_login(FORCE_SSL_LOGIN);
  224. }
  225. /**
  226. * Defines functionality related WordPress constants
  227. *
  228. * @since 3.0.0
  229. */
  230. function wp_functionality_constants() {
  231. /**
  232. * @since 2.5.0
  233. */
  234. if ( !defined( 'AUTOSAVE_INTERVAL' ) )
  235. define( 'AUTOSAVE_INTERVAL', 60 );
  236. /**
  237. * @since 2.9.0
  238. */
  239. if ( !defined( 'EMPTY_TRASH_DAYS' ) )
  240. define( 'EMPTY_TRASH_DAYS', 30 );
  241. if ( !defined('WP_POST_REVISIONS') )
  242. define('WP_POST_REVISIONS', true);
  243. /**
  244. * @since 3.3.0
  245. */
  246. if ( !defined( 'WP_CRON_LOCK_TIMEOUT' ) )
  247. define('WP_CRON_LOCK_TIMEOUT', 60); // In seconds
  248. }
  249. /**
  250. * Defines templating related WordPress constants
  251. *
  252. * @since 3.0.0
  253. */
  254. function wp_templating_constants() {
  255. /**
  256. * Filesystem path to the current active template directory
  257. * @since 1.5.0
  258. */
  259. define('TEMPLATEPATH', get_template_directory());
  260. /**
  261. * Filesystem path to the current active template stylesheet directory
  262. * @since 2.1.0
  263. */
  264. define('STYLESHEETPATH', get_stylesheet_directory());
  265. /**
  266. * Slug of the default theme for this install.
  267. * Used as the default theme when installing new sites.
  268. * Will be used as the fallback if the current theme doesn't exist.
  269. * @since 3.0.0
  270. */
  271. if ( !defined('WP_DEFAULT_THEME') )
  272. define( 'WP_DEFAULT_THEME', 'twentyfourteen' );
  273. }