wp/wp-includes/default-constants.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
     4  *
     4  *
     5  * @package WordPress
     5  * @package WordPress
     6  */
     6  */
     7 
     7 
     8 /**
     8 /**
     9  * Defines initial WordPress constants
     9  * Defines initial WordPress constants.
    10  *
    10  *
    11  * @see wp_debug_mode()
    11  * @see wp_debug_mode()
    12  *
    12  *
    13  * @since 3.0.0
    13  * @since 3.0.0
    14  *
    14  *
    32 	// Start of run timestamp.
    32 	// Start of run timestamp.
    33 	if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
    33 	if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
    34 		define( 'WP_START_TIMESTAMP', microtime( true ) );
    34 		define( 'WP_START_TIMESTAMP', microtime( true ) );
    35 	}
    35 	}
    36 
    36 
    37 	$current_limit     = @ini_get( 'memory_limit' );
    37 	$current_limit     = ini_get( 'memory_limit' );
    38 	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
    38 	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
    39 
    39 
    40 	// Define memory limits.
    40 	// Define memory limits.
    41 	if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    41 	if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    42 		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
    42 		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
    59 	}
    59 	}
    60 
    60 
    61 	// Set memory limits.
    61 	// Set memory limits.
    62 	$wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
    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 ) ) {
    63 	if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) {
    64 		@ini_set( 'memory_limit', WP_MEMORY_LIMIT );
    64 		ini_set( 'memory_limit', WP_MEMORY_LIMIT );
    65 	}
    65 	}
    66 
    66 
    67 	if ( ! isset( $blog_id ) ) {
    67 	if ( ! isset( $blog_id ) ) {
    68 		$blog_id = 1;
    68 		$blog_id = 1;
    69 	}
    69 	}
    70 
    70 
    71 	if ( ! defined( 'WP_CONTENT_DIR' ) ) {
    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
    72 		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // No trailing slash, full paths only - WP_CONTENT_URL is defined further down.
    73 	}
    73 	}
    74 
    74 
    75 	// Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development.
    75 	// Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development.
    76 	if ( ! defined( 'WP_DEBUG' ) ) {
    76 	if ( ! defined( 'WP_DEBUG' ) ) {
    77 		define( 'WP_DEBUG', false );
    77 		if ( 'development' === wp_get_environment_type() ) {
    78 	}
    78 			define( 'WP_DEBUG', true );
    79 
    79 		} else {
    80 	// Add define( 'WP_DEBUG_DISPLAY', null ); to wp-config.php use the globally configured setting for
    80 			define( 'WP_DEBUG', false );
    81 	// display_errors and not force errors to be displayed. Use false to force display_errors off.
    81 		}
       
    82 	}
       
    83 
       
    84 	// Add define( 'WP_DEBUG_DISPLAY', null ); to wp-config.php to use the globally configured setting
       
    85 	// for 'display_errors' and not force errors to be displayed. Use false to force 'display_errors' off.
    82 	if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
    86 	if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
    83 		define( 'WP_DEBUG_DISPLAY', true );
    87 		define( 'WP_DEBUG_DISPLAY', true );
    84 	}
    88 	}
    85 
    89 
    86 	// Add define( 'WP_DEBUG_LOG', true ); to enable error logging to wp-content/debug.log.
    90 	// Add define( 'WP_DEBUG_LOG', true ); to enable error logging to wp-content/debug.log.
   113 
   117 
   114 	if ( ! defined( 'SHORTINIT' ) ) {
   118 	if ( ! defined( 'SHORTINIT' ) ) {
   115 		define( 'SHORTINIT', false );
   119 		define( 'SHORTINIT', false );
   116 	}
   120 	}
   117 
   121 
   118 	// Constants for features added to WP that should short-circuit their plugin implementations
   122 	// Constants for features added to WP that should short-circuit their plugin implementations.
   119 	define( 'WP_FEATURE_BETTER_PASSWORDS', true );
   123 	define( 'WP_FEATURE_BETTER_PASSWORDS', true );
   120 
   124 
   121 	/**#@+
   125 	/**#@+
   122 	 * Constants for expressing human-readable intervals
   126 	 * Constants for expressing human-readable intervals
   123 	 * in their respective number of seconds.
   127 	 * in their respective number of seconds.
   124 	 *
   128 	 *
   125 	 * Please note that these values are approximate and are provided for convenience.
   129 	 * 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
   130 	 * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
   127 	 * YEAR_IN_SECONDS does not take leap years into account.
   131 	 * YEAR_IN_SECONDS does not take leap years into account.
   128 	 *
   132 	 *
   129 	 * If you need more accuracy please consider using the DateTime class (https://secure.php.net/manual/en/class.datetime.php).
   133 	 * If you need more accuracy please consider using the DateTime class (https://www.php.net/manual/en/class.datetime.php).
   130 	 *
   134 	 *
   131 	 * @since 3.5.0
   135 	 * @since 3.5.0
   132 	 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
   136 	 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
   133 	 */
   137 	 */
   134 	define( 'MINUTE_IN_SECONDS', 60 );
   138 	define( 'MINUTE_IN_SECONDS', 60 );
   139 	define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
   143 	define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
   140 	/**#@-*/
   144 	/**#@-*/
   141 }
   145 }
   142 
   146 
   143 /**
   147 /**
   144  * Defines plugin directory WordPress constants
   148  * Defines plugin directory WordPress constants.
   145  *
   149  *
   146  * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in
   150  * Defines must-use plugin directory constants, which may be overridden in the sunrise.php drop-in.
   147  *
   151  *
   148  * @since 3.0.0
   152  * @since 3.0.0
   149  */
   153  */
   150 function wp_plugin_directory_constants() {
   154 function wp_plugin_directory_constants() {
   151 	if ( ! defined( 'WP_CONTENT_URL' ) ) {
   155 	if ( ! defined( 'WP_CONTENT_URL' ) ) {
   152 		define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); // full url - WP_CONTENT_DIR is defined further up
   156 		define( 'WP_CONTENT_URL', get_option( 'siteurl' ) . '/wp-content' ); // Full URL - WP_CONTENT_DIR is defined further up.
   153 	}
   157 	}
   154 
   158 
   155 	/**
   159 	/**
   156 	 * Allows for the plugins directory to be moved from the default location.
   160 	 * Allows for the plugins directory to be moved from the default location.
   157 	 *
   161 	 *
   158 	 * @since 2.6.0
   162 	 * @since 2.6.0
   159 	 */
   163 	 */
   160 	if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
   164 	if ( ! defined( 'WP_PLUGIN_DIR' ) ) {
   161 		define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
   165 		define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // Full path, no trailing slash.
   162 	}
   166 	}
   163 
   167 
   164 	/**
   168 	/**
   165 	 * Allows for the plugins directory to be moved from the default location.
   169 	 * Allows for the plugins directory to be moved from the default location.
   166 	 *
   170 	 *
   167 	 * @since 2.6.0
   171 	 * @since 2.6.0
   168 	 */
   172 	 */
   169 	if ( ! defined( 'WP_PLUGIN_URL' ) ) {
   173 	if ( ! defined( 'WP_PLUGIN_URL' ) ) {
   170 		define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // full url, no trailing slash
   174 		define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' ); // Full URL, no trailing slash.
   171 	}
   175 	}
   172 
   176 
   173 	/**
   177 	/**
   174 	 * Allows for the plugins directory to be moved from the default location.
   178 	 * Allows for the plugins directory to be moved from the default location.
   175 	 *
   179 	 *
   184 	 * Allows for the mu-plugins directory to be moved from the default location.
   188 	 * Allows for the mu-plugins directory to be moved from the default location.
   185 	 *
   189 	 *
   186 	 * @since 2.8.0
   190 	 * @since 2.8.0
   187 	 */
   191 	 */
   188 	if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) {
   192 	if ( ! defined( 'WPMU_PLUGIN_DIR' ) ) {
   189 		define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // full path, no trailing slash
   193 		define( 'WPMU_PLUGIN_DIR', WP_CONTENT_DIR . '/mu-plugins' ); // Full path, no trailing slash.
   190 	}
   194 	}
   191 
   195 
   192 	/**
   196 	/**
   193 	 * Allows for the mu-plugins directory to be moved from the default location.
   197 	 * Allows for the mu-plugins directory to be moved from the default location.
   194 	 *
   198 	 *
   195 	 * @since 2.8.0
   199 	 * @since 2.8.0
   196 	 */
   200 	 */
   197 	if ( ! defined( 'WPMU_PLUGIN_URL' ) ) {
   201 	if ( ! defined( 'WPMU_PLUGIN_URL' ) ) {
   198 		define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // full url, no trailing slash
   202 		define( 'WPMU_PLUGIN_URL', WP_CONTENT_URL . '/mu-plugins' ); // Full URL, no trailing slash.
   199 	}
   203 	}
   200 
   204 
   201 	/**
   205 	/**
   202 	 * Allows for the mu-plugins directory to be moved from the default location.
   206 	 * Allows for the mu-plugins directory to be moved from the default location.
   203 	 *
   207 	 *
   208 		define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
   212 		define( 'MUPLUGINDIR', 'wp-content/mu-plugins' ); // Relative to ABSPATH. For back compat.
   209 	}
   213 	}
   210 }
   214 }
   211 
   215 
   212 /**
   216 /**
   213  * Defines cookie related WordPress constants
   217  * Defines cookie-related WordPress constants.
   214  *
   218  *
   215  * Defines constants after multisite is loaded.
   219  * Defines constants after multisite is loaded.
   216  *
   220  *
   217  * @since 3.0.0
   221  * @since 3.0.0
   218  */
   222  */
   219 function wp_cookie_constants() {
   223 function wp_cookie_constants() {
   220 	/**
   224 	/**
   221 	 * Used to guarantee unique hash cookies
   225 	 * Used to guarantee unique hash cookies.
   222 	 *
   226 	 *
   223 	 * @since 1.5.0
   227 	 * @since 1.5.0
   224 	 */
   228 	 */
   225 	if ( ! defined( 'COOKIEHASH' ) ) {
   229 	if ( ! defined( 'COOKIEHASH' ) ) {
   226 		$siteurl = get_site_option( 'siteurl' );
   230 		$siteurl = get_site_option( 'siteurl' );
   342 		force_ssl_admin( true );
   346 		force_ssl_admin( true );
   343 	}
   347 	}
   344 }
   348 }
   345 
   349 
   346 /**
   350 /**
   347  * Defines functionality related WordPress constants
   351  * Defines functionality-related WordPress constants.
   348  *
   352  *
   349  * @since 3.0.0
   353  * @since 3.0.0
   350  */
   354  */
   351 function wp_functionality_constants() {
   355 function wp_functionality_constants() {
   352 	/**
   356 	/**
   353 	 * @since 2.5.0
   357 	 * @since 2.5.0
   354 	 */
   358 	 */
   355 	if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) {
   359 	if ( ! defined( 'AUTOSAVE_INTERVAL' ) ) {
   356 		define( 'AUTOSAVE_INTERVAL', 60 );
   360 		define( 'AUTOSAVE_INTERVAL', MINUTE_IN_SECONDS );
   357 	}
   361 	}
   358 
   362 
   359 	/**
   363 	/**
   360 	 * @since 2.9.0
   364 	 * @since 2.9.0
   361 	 */
   365 	 */
   369 
   373 
   370 	/**
   374 	/**
   371 	 * @since 3.3.0
   375 	 * @since 3.3.0
   372 	 */
   376 	 */
   373 	if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) {
   377 	if ( ! defined( 'WP_CRON_LOCK_TIMEOUT' ) ) {
   374 		define( 'WP_CRON_LOCK_TIMEOUT', 60 );  // In seconds
   378 		define( 'WP_CRON_LOCK_TIMEOUT', MINUTE_IN_SECONDS );
   375 	}
   379 	}
   376 }
   380 }
   377 
   381 
   378 /**
   382 /**
   379  * Defines templating related WordPress constants
   383  * Defines templating-related WordPress constants.
   380  *
   384  *
   381  * @since 3.0.0
   385  * @since 3.0.0
   382  */
   386  */
   383 function wp_templating_constants() {
   387 function wp_templating_constants() {
   384 	/**
   388 	/**
   385 	 * Filesystem path to the current active template directory
   389 	 * Filesystem path to the current active template directory.
   386 	 *
   390 	 *
   387 	 * @since 1.5.0
   391 	 * @since 1.5.0
   388 	 */
   392 	 */
   389 	define( 'TEMPLATEPATH', get_template_directory() );
   393 	define( 'TEMPLATEPATH', get_template_directory() );
   390 
   394 
   391 	/**
   395 	/**
   392 	 * Filesystem path to the current active template stylesheet directory
   396 	 * Filesystem path to the current active template stylesheet directory.
   393 	 *
   397 	 *
   394 	 * @since 2.1.0
   398 	 * @since 2.1.0
   395 	 */
   399 	 */
   396 	define( 'STYLESHEETPATH', get_stylesheet_directory() );
   400 	define( 'STYLESHEETPATH', get_stylesheet_directory() );
   397 
   401 
   399 	 * Slug of the default theme for this installation.
   403 	 * Slug of the default theme for this installation.
   400 	 * Used as the default theme when installing new sites.
   404 	 * Used as the default theme when installing new sites.
   401 	 * It will be used as the fallback if the current theme doesn't exist.
   405 	 * It will be used as the fallback if the current theme doesn't exist.
   402 	 *
   406 	 *
   403 	 * @since 3.0.0
   407 	 * @since 3.0.0
       
   408 	 *
   404 	 * @see WP_Theme::get_core_default_theme()
   409 	 * @see WP_Theme::get_core_default_theme()
   405 	 */
   410 	 */
   406 	if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
   411 	if ( ! defined( 'WP_DEFAULT_THEME' ) ) {
   407 		define( 'WP_DEFAULT_THEME', 'twentynineteen' );
   412 		define( 'WP_DEFAULT_THEME', 'twentytwenty' );
   408 	}
   413 	}
   409 
   414 
   410 }
   415 }