wppaste
WordPress

_wp_die_process_input( string|WP_Error $message, string $title = '', string|array $args = array() ): array

Since
5.1.0
Source
wp-includes/functions.php:4354
Processes arguments passed to wp_die() consistently for its handlers.

Compatibility

WordPress
since 5.1.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.

Parameters

$messagestring|WP_Error
Error message or WP_Error object.
$titlestringoptional
Error title. Default empty string.Default: ''
$argsstring|arrayoptional
Arguments to control behavior. Default empty array.Default: array()

Return value

array
Processed arguments.
  • $0string

    Error message.
  • $1string

    Error title.
  • $2array

    Arguments to control behavior.

Performance profile

How much work a call to _wp_die_process_input() 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
33–116

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
7

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

What it touches

  • hookthird-party callbacksdo_action()one call below _wp_die_process_input()

Further down the call graph this can also reach option, cache, serialize, query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 36 distinct outcomes

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

WhenInstructionsCalls it makes
!function_exists()33–40wp_parse_args(), function_exists(), function_exists()
!function_exists() && empty($args)36–46wp_parse_args(), function_exists(), function_exists(), function_exists()
function_exists()37–47wp_parse_args(), function_exists(), is_wp_error(), function_exists()
empty($args)39–51wp_parse_args(), function_exists(), function_exists(), function_exists(), is_rtl()
!function_exists() && !empty($args)40–47wp_parse_args(), function_exists(), function_exists(), _canonical_charset()
empty($title)40–44wp_parse_args(), function_exists(), function_exists(), __()
empty($args)40–53wp_parse_args(), function_exists(), is_wp_error(), function_exists(), function_exists()
!function_exists() && !empty($args)43–53wp_parse_args(), function_exists(), function_exists(), function_exists(), _canonical_charset()
empty($title) && empty($args)43–50wp_parse_args(), function_exists(), function_exists(), __(), function_exists()
function_exists() && empty($args)43–58wp_parse_args(), function_exists(), is_wp_error(), function_exists(), function_exists(), is_rtl()
function_exists() && !empty($args)44–54wp_parse_args(), function_exists(), is_wp_error(), function_exists(), _canonical_charset()
function_exists() && empty($title)44–51wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __()
24 further outcomes, up to 116 instructions
!empty($args)46–58wp_parse_args(), function_exists(), function_exists(), function_exists(), is_rtl(), _canonical_charset()
empty($title) && empty($args)46–55wp_parse_args(), function_exists(), function_exists(), __(), function_exists(), is_rtl()
!empty($args) && empty($title)47–51wp_parse_args(), function_exists(), function_exists(), __(), _canonical_charset()
!empty($args)47–60wp_parse_args(), function_exists(), is_wp_error(), function_exists(), function_exists(), _canonical_charset()
empty($title) && empty($args)47–57wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __(), function_exists()
!empty($args) && empty($title)50–57wp_parse_args(), function_exists(), function_exists(), __(), function_exists(), _canonical_charset()
function_exists() && !empty($args)50–65wp_parse_args(), function_exists(), is_wp_error(), function_exists(), function_exists(), is_rtl(), _canonical_charset()
function_exists() && empty($title) && empty($args)50–62wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __(), function_exists(), is_rtl()
function_exists() && !empty($args) && empty($title)51–58wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __(), _canonical_charset()
!empty($args) && empty($title)53–62wp_parse_args(), function_exists(), function_exists(), __(), function_exists(), is_rtl(), _canonical_charset()
!empty($args) && empty($title)54–64wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __(), function_exists(), _canonical_charset()
function_exists() && !empty($args) && empty($title)57–69wp_parse_args(), function_exists(), is_wp_error(), function_exists(), __(), function_exists(), is_rtl(), _canonical_charset()
function_exists() && is_wp_error() && !empty($message)62–94wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists()
is_wp_error() && !empty($message)65–100wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), function_exists()
function_exists() && is_wp_error() && !empty($message)68–105wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), function_exists(), is_rtl()
function_exists() && is_wp_error() && !empty($message) && !empty($args)69–101wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), _canonical_charset()
function_exists() && is_wp_error() && !empty($message) && empty($title)69–98wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __()
is_wp_error() && !empty($message) && !empty($args)72–107wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), function_exists(), _canonical_charset()
is_wp_error() && !empty($message) && empty($title)72–104wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __(), function_exists()
function_exists() && is_wp_error() && !empty($message) && !empty($args)75–112wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), function_exists(), is_rtl(), _canonical_charset()
function_exists() && is_wp_error() && !empty($message) && empty($title)75–109wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __(), function_exists(), is_rtl()
function_exists() && is_wp_error() && !empty($message) && !empty($args) && empty($title)76–105wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __(), _canonical_charset()
is_wp_error() && !empty($message) && !empty($args) && empty($title)79–111wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __(), function_exists(), _canonical_charset()
function_exists() && is_wp_error() && !empty($message) && !empty($args) && empty($title)82–116wp_parse_args(), function_exists(), is_wp_error(), array_values(), function_exists(), __(), function_exists(), is_rtl(), _canonical_charset()

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-dev15033–115261 fewer instruction than PHP 8.5
8.515133–11626
8.415133–11626
8.315133–11626
8.215133–11626
8.115133–11626
7.415133–11626

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 · 5

  • wp_parse_args()Merges user defined arguments into defaults array.
  • is_wp_error()Checks whether the given variable is a WordPress Error.
  • __()Retrieves the translation of $text.
  • is_rtl()Determines whether the current locale is right-to-left (RTL).
  • _canonical_charset()Retrieves a canonical form of the provided charset appropriate for passing to PHP functions such as htmlspecialchars() and charset HTML attributes.

Used by · 7

Source code

function _wp_die_process_input( $message, $title = '', $args = array() ) {	$defaults = array(		'response'          => 0,		'code'              => '',		'exit'              => true,		'back_link'         => false,		'link_url'          => '',		'link_text'         => '',		'text_direction'    => '',		'charset'           => 'utf-8',		'additional_errors' => array(),	); 	$args = wp_parse_args( $args, $defaults ); 	if ( function_exists( 'is_wp_error' ) && is_wp_error( $message ) ) {		if ( ! empty( $message->errors ) ) {			$errors = array();			foreach ( (array) $message->errors as $error_code => $error_messages ) {				foreach ( (array) $error_messages as $error_message ) {					$errors[] = array(						'code'    => $error_code,						'message' => $error_message,						'data'    => $message->get_error_data( $error_code ),					);				}			} 			$message = $errors[0]['message'];			if ( empty( $args['code'] ) ) {				$args['code'] = $errors[0]['code'];			}			if ( empty( $args['response'] ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['status'] ) ) {				$args['response'] = $errors[0]['data']['status'];			}			if ( empty( $title ) && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['title'] ) ) {				$title = $errors[0]['data']['title'];			}			if ( WP_DEBUG_DISPLAY && is_array( $errors[0]['data'] ) && ! empty( $errors[0]['data']['error'] ) ) {				$args['error_data'] = $errors[0]['data']['error'];			} 			unset( $errors[0] );			$args['additional_errors'] = array_values( $errors );		} else {			$message = '';		}	} 	$have_gettext = function_exists( '__' ); 	// The $title and these specific $args must always have a non-empty value.	if ( empty( $args['code'] ) ) {		$args['code'] = 'wp_die';	}	if ( empty( $args['response'] ) ) {		$args['response'] = 500;	}	if ( empty( $title ) ) {		$title = $have_gettext ? __( 'WordPress › Error' ) : 'WordPress › Error';	}	if ( empty( $args['text_direction'] ) || ! in_array( $args['text_direction'], array( 'ltr', 'rtl' ), true ) ) {		$args['text_direction'] = 'ltr';		if ( function_exists( 'is_rtl' ) && is_rtl() ) {			$args['text_direction'] = 'rtl';		}	} 	if ( ! empty( $args['charset'] ) ) {		$args['charset'] = _canonical_charset( $args['charset'] );	} 	return array( $message, $title, $args );}

Changelog

Introduced in 5.1.0. Unchanged from 6.7.7 through 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.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/functions.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.