PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/wp-includes/default-constants.php

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