PageRenderTime 31ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/wp-includes/default-constants.php

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