Title: wp_initial_constants
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_initial_constants()

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#see-also)
 * [Source](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#wp--skip-link--target)

Defines initial WordPress constants.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#see-also)󠁿

 * [wp_debug_mode()](https://developer.wordpress.org/reference/functions/wp_debug_mode/)

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#source)󠁿

    ```php
    function wp_initial_constants() {
    	global $blog_id, $wp_version;

    	/**#@+
    	 * Constants for expressing human-readable data sizes in their respective number of bytes.
    	 *
    	 * @since 4.4.0
    	 * @since 6.0.0 `PB_IN_BYTES`, `EB_IN_BYTES`, `ZB_IN_BYTES`, and `YB_IN_BYTES` were added.
    	 */
    	define( 'KB_IN_BYTES', 1024 );
    	define( 'MB_IN_BYTES', 1024 * KB_IN_BYTES );
    	define( 'GB_IN_BYTES', 1024 * MB_IN_BYTES );
    	define( 'TB_IN_BYTES', 1024 * GB_IN_BYTES );
    	define( 'PB_IN_BYTES', 1024 * TB_IN_BYTES );
    	define( 'EB_IN_BYTES', 1024 * PB_IN_BYTES );
    	define( 'ZB_IN_BYTES', 1024 * EB_IN_BYTES );
    	define( 'YB_IN_BYTES', 1024 * ZB_IN_BYTES );
    	/**#@-*/

    	// Start of run timestamp.
    	if ( ! defined( 'WP_START_TIMESTAMP' ) ) {
    		define( 'WP_START_TIMESTAMP', microtime( true ) );
    	}

    	$current_limit     = ini_get( 'memory_limit' );
    	$current_limit_int = wp_convert_hr_to_bytes( $current_limit );

    	// Define memory limits.
    	if ( ! defined( 'WP_MEMORY_LIMIT' ) ) {
    		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
    			define( 'WP_MEMORY_LIMIT', $current_limit );
    		} elseif ( is_multisite() ) {
    			define( 'WP_MEMORY_LIMIT', '64M' );
    		} else {
    			define( 'WP_MEMORY_LIMIT', '40M' );
    		}
    	}

    	if ( ! defined( 'WP_MAX_MEMORY_LIMIT' ) ) {
    		if ( false === wp_is_ini_value_changeable( 'memory_limit' ) ) {
    			define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
    		} elseif ( -1 === $current_limit_int || $current_limit_int > 256 * MB_IN_BYTES ) {
    			define( 'WP_MAX_MEMORY_LIMIT', $current_limit );
    		} elseif ( wp_convert_hr_to_bytes( WP_MEMORY_LIMIT ) > 256 * MB_IN_BYTES ) {
    			define( 'WP_MAX_MEMORY_LIMIT', WP_MEMORY_LIMIT );
    		} else {
    			define( 'WP_MAX_MEMORY_LIMIT', '256M' );
    		}
    	}

    	// Set memory limits.
    	$wp_limit_int = wp_convert_hr_to_bytes( WP_MEMORY_LIMIT );
    	if ( -1 !== $current_limit_int && ( -1 === $wp_limit_int || $wp_limit_int > $current_limit_int ) ) {
    		ini_set( 'memory_limit', WP_MEMORY_LIMIT );
    	}

    	if ( ! isset( $blog_id ) ) {
    		$blog_id = 1;
    	}

    	if ( ! defined( 'WP_CONTENT_DIR' ) ) {
    		define( 'WP_CONTENT_DIR', ABSPATH . 'wp-content' ); // No trailing slash, full paths only - WP_CONTENT_URL is defined further down.
    	}

    	/*
    	 * Add define( 'WP_DEVELOPMENT_MODE', 'core' ), or define( 'WP_DEVELOPMENT_MODE', 'plugin' ), or
    	 * define( 'WP_DEVELOPMENT_MODE', 'theme' ), or define( 'WP_DEVELOPMENT_MODE', 'all' ) to wp-config.php
    	 * to signify development mode for WordPress core, a plugin, a theme, or all three types respectively.
    	 */
    	if ( ! defined( 'WP_DEVELOPMENT_MODE' ) ) {
    		define( 'WP_DEVELOPMENT_MODE', '' );
    	}

    	// Add define( 'WP_DEBUG', true ); to wp-config.php to enable display of notices during development.
    	if ( ! defined( 'WP_DEBUG' ) ) {
    		if ( wp_get_development_mode() || 'development' === wp_get_environment_type() ) {
    			define( 'WP_DEBUG', true );
    		} else {
    			define( 'WP_DEBUG', false );
    		}
    	}

    	/*
    	 * Add define( 'WP_DEBUG_DISPLAY', null ); to wp-config.php to use the globally configured setting
    	 * for 'display_errors' and not force errors to be displayed. Use false to force 'display_errors' off.
    	 */
    	if ( ! defined( 'WP_DEBUG_DISPLAY' ) ) {
    		define( 'WP_DEBUG_DISPLAY', true );
    	}

    	// Add define( 'WP_DEBUG_LOG', true ); to enable error logging to wp-content/debug.log.
    	if ( ! defined( 'WP_DEBUG_LOG' ) ) {
    		define( 'WP_DEBUG_LOG', false );
    	}

    	if ( ! defined( 'WP_CACHE' ) ) {
    		define( 'WP_CACHE', false );
    	}

    	/*
    	 * Add define( 'SCRIPT_DEBUG', true ); to wp-config.php to enable loading of non-minified,
    	 * non-concatenated scripts and stylesheets.
    	 */
    	if ( ! defined( 'SCRIPT_DEBUG' ) ) {
    		if ( ! empty( $wp_version ) ) {
    			$develop_src = str_contains( $wp_version, '-src' );
    		} else {
    			$develop_src = false;
    		}

    		define( 'SCRIPT_DEBUG', $develop_src );
    	}

    	/**
    	 * Private
    	 */
    	if ( ! defined( 'MEDIA_TRASH' ) ) {
    		define( 'MEDIA_TRASH', false );
    	}

    	if ( ! defined( 'SHORTINIT' ) ) {
    		define( 'SHORTINIT', false );
    	}

    	// Constants for features added to WP that should short-circuit their plugin implementations.
    	define( 'WP_FEATURE_BETTER_PASSWORDS', true );

    	/**#@+
    	 * Constants for expressing human-readable intervals
    	 * in their respective number of seconds.
    	 *
    	 * Please note that these values are approximate and are provided for convenience.
    	 * For example, MONTH_IN_SECONDS wrongly assumes every month has 30 days and
    	 * YEAR_IN_SECONDS does not take leap years into account.
    	 *
    	 * If you need more accuracy please consider using the DateTime class (https://www.php.net/manual/en/class.datetime.php).
    	 *
    	 * @since 3.5.0
    	 * @since 4.4.0 Introduced `MONTH_IN_SECONDS`.
    	 */
    	define( 'MINUTE_IN_SECONDS', 60 );
    	define( 'HOUR_IN_SECONDS', 60 * MINUTE_IN_SECONDS );
    	define( 'DAY_IN_SECONDS', 24 * HOUR_IN_SECONDS );
    	define( 'WEEK_IN_SECONDS', 7 * DAY_IN_SECONDS );
    	define( 'MONTH_IN_SECONDS', 30 * DAY_IN_SECONDS );
    	define( 'YEAR_IN_SECONDS', 365 * DAY_IN_SECONDS );
    	/**#@-*/
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/default-constants.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/default-constants.php#L18)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/default-constants.php#L18-L165)

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_get_development_mode()](https://developer.wordpress.org/reference/functions/wp_get_development_mode/)`wp-includes/load.php` |

Retrieves the current development mode.

  | 
| [wp_get_environment_type()](https://developer.wordpress.org/reference/functions/wp_get_environment_type/)`wp-includes/load.php` |

Retrieves the current environment type.

  | 
| [wp_is_ini_value_changeable()](https://developer.wordpress.org/reference/functions/wp_is_ini_value_changeable/)`wp-includes/load.php` |

Determines whether a PHP ini value is changeable at runtime.

  | 
| [wp_convert_hr_to_bytes()](https://developer.wordpress.org/reference/functions/wp_convert_hr_to_bytes/)`wp-includes/load.php` |

Converts a shorthand byte value to an integer byte value.

  | 
| [is_multisite()](https://developer.wordpress.org/reference/functions/is_multisite/)`wp-includes/load.php` |

Determines whether Multisite is enabled.

  |

[Show 1 more](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_initial_constants/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.0.0](https://developer.wordpress.org/reference/since/3.0.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_initial_constants%2F)
before being able to contribute a note or feedback.