wppaste
WordPress

WP_Debug_Data::get_wp_constants(): array<string,

Since
6.7.0
Source
wp-admin/includes/class-wp-debug-data.php:1501
Gets the WordPress constants section of the debug data.

Compatibility

WordPress
since 6.7.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.

Return value

array<string,
string|array> The WordPress constants debug data.

Performance profile

How much work a call to WP_Debug_Data::get_wp_constants() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Trivial

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
196–213

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 328.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What one call costs · 6 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Debug_Data::get_wp_constants() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE') && defined('WP_HOME') && defined('WP_SITEURL') && defined('DB_CHARSET')196–202__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE')198–205__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE')200–207__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE')202–209__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE')204–211__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()
!defined('CONCATENATE_SCRIPTS') && !defined('COMPRESS_SCRIPTS') && !defined('COMPRESS_CSS') && !defined('WP_ENVIRONMENT_TYPE') && !defined('DB_COLLATE') && !defined('WP_HOME') && !defined('WP_SITEURL') && !defined('DB_CHARSET')206–213__(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __(), __()

This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev307192–2042721 fewer instructions than PHP 8.5
8.5328196–21327
8.4328196–21327
8.3328196–21327
8.2328196–21327
8.1328196–2132710 fewer instructions than PHP 7.4
7.4338201–21627

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 1

  • __()Retrieves the translation of $text.

Used by · 1

Source code

	private static function get_wp_constants(): array {		// Check if WP_DEBUG_LOG is set.		$wp_debug_log_value = __( 'Disabled' );		if ( is_string( WP_DEBUG_LOG ) ) {			$wp_debug_log_value = WP_DEBUG_LOG;		} elseif ( WP_DEBUG_LOG ) {			$wp_debug_log_value = __( 'Enabled' );		} 		// Check CONCATENATE_SCRIPTS.		if ( defined( 'CONCATENATE_SCRIPTS' ) ) {			$concatenate_scripts       = CONCATENATE_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );			$concatenate_scripts_debug = CONCATENATE_SCRIPTS ? 'true' : 'false';		} else {			$concatenate_scripts       = __( 'Undefined' );			$concatenate_scripts_debug = 'undefined';		} 		// Check COMPRESS_SCRIPTS.		if ( defined( 'COMPRESS_SCRIPTS' ) ) {			$compress_scripts       = COMPRESS_SCRIPTS ? __( 'Enabled' ) : __( 'Disabled' );			$compress_scripts_debug = COMPRESS_SCRIPTS ? 'true' : 'false';		} else {			$compress_scripts       = __( 'Undefined' );			$compress_scripts_debug = 'undefined';		} 		// Check COMPRESS_CSS.		if ( defined( 'COMPRESS_CSS' ) ) {			$compress_css       = COMPRESS_CSS ? __( 'Enabled' ) : __( 'Disabled' );			$compress_css_debug = COMPRESS_CSS ? 'true' : 'false';		} else {			$compress_css       = __( 'Undefined' );			$compress_css_debug = 'undefined';		} 		// Check WP_ENVIRONMENT_TYPE.		if ( defined( 'WP_ENVIRONMENT_TYPE' ) ) {			$wp_environment_type       = WP_ENVIRONMENT_TYPE ? WP_ENVIRONMENT_TYPE : __( 'Empty value' );			$wp_environment_type_debug = WP_ENVIRONMENT_TYPE;		} else {			$wp_environment_type       = __( 'Undefined' );			$wp_environment_type_debug = 'undefined';		} 		// Check DB_COLLATE.		if ( defined( 'DB_COLLATE' ) ) {			$db_collate       = DB_COLLATE ? DB_COLLATE : __( 'Empty value' );			$db_collate_debug = DB_COLLATE;		} else {			$db_collate       = __( 'Undefined' );			$db_collate_debug = 'undefined';		} 		$fields = array(			'ABSPATH'             => array(				'label'   => 'ABSPATH',				'value'   => ABSPATH,				'private' => true,			),			'WP_HOME'             => array(				'label' => 'WP_HOME',				'value' => ( defined( 'WP_HOME' ) ? WP_HOME : __( 'Undefined' ) ),				'debug' => ( defined( 'WP_HOME' ) ? WP_HOME : 'undefined' ),			),			'WP_SITEURL'          => array(				'label' => 'WP_SITEURL',				'value' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : __( 'Undefined' ) ),				'debug' => ( defined( 'WP_SITEURL' ) ? WP_SITEURL : 'undefined' ),			),			'WP_CONTENT_DIR'      => array(				'label' => 'WP_CONTENT_DIR',				'value' => WP_CONTENT_DIR,			),			'WP_PLUGIN_DIR'       => array(				'label' => 'WP_PLUGIN_DIR',				'value' => WP_PLUGIN_DIR,			),			'WP_MEMORY_LIMIT'     => array(				'label' => 'WP_MEMORY_LIMIT',

Changelog

Introduced in 6.7.0. One change between 6.7.7 and 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

7.0.4
Return type changed from array to array<string,.verified against source
6.7.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-admin/includes/class-wp-debug-data.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.