wp/wp-includes/default-constants.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     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  *
       
    15  * @global int    $blog_id    The current site ID.
       
    16  * @global string $wp_version The WordPress version string.
    14  */
    17  */
    15 function wp_initial_constants() {
    18 function wp_initial_constants() {
    16 	global $blog_id;
    19 	global $blog_id;
    17 
    20 
    18 	// set memory limits
    21 	/**#@+
    19 	if ( !defined('WP_MEMORY_LIMIT') ) {
    22 	 * Constants for expressing human-readable data sizes in their respective number of bytes.
    20 		if( is_multisite() ) {
    23 	 *
    21 			define('WP_MEMORY_LIMIT', '64M');
    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 	$current_limit     = @ini_get( 'memory_limit' );
       
    33 	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );
       
    34 
       
    35 	// Define memory limits.
       
    36 	if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
       
    37 		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
       
    38 			define( 'WP_MEMORY_LIMIT', $current_limit );
       
    39 		} elseif ( is_multisite() ) {
       
    40 			define( 'WP_MEMORY_LIMIT', '64M' );
    22 		} else {
    41 		} else {
    23 			define('WP_MEMORY_LIMIT', '40M');
    42 			define( 'WP_MEMORY_LIMIT', '40M' );
    24 		}
    43 		}
    25 	}
    44 	}
    26 
    45 
    27 	if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
    46 	if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
    28 		define( 'WP_MAX_MEMORY_LIMIT', '256M' );
    47 		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
    29 	}
    48 			define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
    30 
    49 		} elseif ( -1 === $current_limit_int || $current_limit_int > 268435456 /* = 256M */ ) {
    31 	/**
    50 			define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
    32 	 * The $blog_id global, which you can change in the config allows you to create a simple
    51 		} else {
    33 	 * multiple blog installation using just one WordPress and changing $blog_id around.
    52 			define( 'WP_MAX_MEMORY_LIMIT', '256M' );
    34 	 *
    53 		}
    35 	 * @global int $blog_id
    54 	}
    36 	 * @since 2.0.0
    55 
    37 	 */
    56 	// Set memory limits.
       
    57 	$wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
       
    58 	if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) {
       
    59 		@ini_set( 'memory_limit', WP_MEMORY_LIMIT );
       
    60 	}
       
    61 
    38 	if ( ! isset($blog_id) )
    62 	if ( ! isset($blog_id) )
    39 		$blog_id = 1;
    63 		$blog_id = 1;
    40 
       
    41 	// set memory limits.
       
    42 	if ( function_exists( 'memory_get_usage' ) ) {
       
    43 		$current_limit = @ini_get( 'memory_limit' );
       
    44 		$current_limit_int = intval( $current_limit );
       
    45 		if ( false !== strpos( $current_limit, 'G' ) )
       
    46 			$current_limit_int *= 1024;
       
    47 		$wp_limit_int = intval( WP_MEMORY_LIMIT );
       
    48 		if ( false !== strpos( WP_MEMORY_LIMIT, 'G' ) )
       
    49 			$wp_limit_int *= 1024;
       
    50 
       
    51 		if ( -1 != $current_limit && ( -1 == WP_MEMORY_LIMIT || $current_limit_int < $wp_limit_int ) )
       
    52 			@ini_set( 'memory_limit', WP_MEMORY_LIMIT );
       
    53 	}
       
    54 
    64 
    55 	if ( !defined('WP_CONTENT_DIR') )
    65 	if ( !defined('WP_CONTENT_DIR') )
    56 		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
    66 		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // no trailing slash, full paths only - WP_CONTENT_URL is defined further down
    57 
    67 
    58 	// Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
    68 	// Add define('WP_DEBUG', true); to wp-config.php to enable display of notices during development.
    69 		define('WP_DEBUG_LOG', false);
    79 		define('WP_DEBUG_LOG', false);
    70 
    80 
    71 	if ( !defined('WP_CACHE') )
    81 	if ( !defined('WP_CACHE') )
    72 		define('WP_CACHE', false);
    82 		define('WP_CACHE', false);
    73 
    83 
       
    84 	// Add define('SCRIPT_DEBUG', true); to wp-config.php to enable loading of non-minified,
       
    85 	// non-concatenated scripts and stylesheets.
       
    86 	if ( ! defined( 'SCRIPT_DEBUG' ) ) {
       
    87 		if ( ! empty( $GLOBALS['wp_version'] ) ) {
       
    88 			$develop_src = false !== strpos( $GLOBALS['wp_version'], '-src' );
       
    89 		} else {
       
    90 			$develop_src = false;
       
    91 		}
       
    92 
       
    93 		define( 'SCRIPT_DEBUG', $develop_src );
       
    94 	}
       
    95 
    74 	/**
    96 	/**
    75 	 * Private
    97 	 * Private
    76 	 */
    98 	 */
    77 	if ( !defined('MEDIA_TRASH') )
    99 	if ( !defined('MEDIA_TRASH') )
    78 		define('MEDIA_TRASH', false);
   100 		define('MEDIA_TRASH', false);
    79 
   101 
    80 	if ( !defined('SHORTINIT') )
   102 	if ( !defined('SHORTINIT') )
    81 		define('SHORTINIT', false);
   103 		define('SHORTINIT', false);
    82 
   104 
    83 	// Constants for expressing human-readable intervals
   105 	// Constants for features added to WP that should short-circuit their plugin implementations
    84 	// in their respective number of seconds.
   106 	define( 'WP_FEATURE_BETTER_PASSWORDS', true );
       
   107 
       
   108 	/**#@+
       
   109 	 * Constants for expressing human-readable intervals
       
   110 	 * in their respective number of seconds.
       
   111 	 *
       
   112 	 * Please note that these values are approximate and are provided for convenience.
       
   113 	 * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
       
   114 	 * YEAR_IN_SECONDS does not take leap years into account.
       
   115 	 *
       
   116 	 * If you need more accuracy please consider using the DateTime class (https://secure.php.net/manual/en/class.datetime.php).
       
   117 	 *
       
   118 	 * @since 3.5.0
       
   119 	 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
       
   120 	 */
    85 	define( 'MINUTE_IN_SECONDS', 60 );
   121 	define( 'MINUTE_IN_SECONDS', 60 );
    86 	define( 'HOUR_IN_SECONDS',   60 * MINUTE_IN_SECONDS );
   122 	define( 'HOUR_IN_SECONDS',   60 * MINUTE_IN_SECONDS );
    87 	define( 'DAY_IN_SECONDS',    24 * HOUR_IN_SECONDS   );
   123 	define( 'DAY_IN_SECONDS',    24 * HOUR_IN_SECONDS   );
    88 	define( 'WEEK_IN_SECONDS',    7 * DAY_IN_SECONDS    );
   124 	define( 'WEEK_IN_SECONDS',    7 * DAY_IN_SECONDS    );
       
   125 	define( 'MONTH_IN_SECONDS',  30 * DAY_IN_SECONDS    );
    89 	define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );
   126 	define( 'YEAR_IN_SECONDS',  365 * DAY_IN_SECONDS    );
       
   127 	/**#@-*/
    90 }
   128 }
    91 
   129 
    92 /**
   130 /**
    93  * Defines plugin directory WordPress constants
   131  * Defines plugin directory WordPress constants
    94  *
   132  *
   310 	 * @since 2.1.0
   348 	 * @since 2.1.0
   311 	 */
   349 	 */
   312 	define('STYLESHEETPATH', get_stylesheet_directory());
   350 	define('STYLESHEETPATH', get_stylesheet_directory());
   313 
   351 
   314 	/**
   352 	/**
   315 	 * Slug of the default theme for this install.
   353 	 * Slug of the default theme for this installation.
   316 	 * Used as the default theme when installing new sites.
   354 	 * Used as the default theme when installing new sites.
   317 	 * Will be used as the fallback if the current theme doesn't exist.
   355 	 * It will be used as the fallback if the current theme doesn't exist.
       
   356 	 *
   318 	 * @since 3.0.0
   357 	 * @since 3.0.0
       
   358 	 * @see WP_Theme::get_core_default_theme()
   319 	 */
   359 	 */
   320 	if ( !defined('WP_DEFAULT_THEME') )
   360 	if ( !defined('WP_DEFAULT_THEME') )
   321 		define( 'WP_DEFAULT_THEME', 'twentyfifteen' );
   361 		define( 'WP_DEFAULT_THEME', 'twentyseventeen' );
   322 
   362 
   323 }
   363 }