[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> default-constants.php (source)

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


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7