wppaste
WordPress

install_theme_search_form( bool $type_selector = true )

Since
2.8.0
Source
wp-admin/includes/theme-install.php:91
Displays search form for searching themes.

Compatibility

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

$type_selectorbooloptional
Default: true

Performance profile

How much work a call to install_theme_search_form() 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
36–96

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

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 it touches

  • hookthird-party callbacksapply_filters()one call below install_theme_search_form()

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 · 18 distinct outcomes

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

WhenInstructionsCalls it makes
!isset($value)36_e(), esc_attr(), __(), submit_button()
!isset($value)42__(), _e(), esc_attr(), __(), submit_button()
always43wp_unslash(), _e(), esc_attr(), __(), submit_button()
always49wp_unslash(), __(), _e(), esc_attr(), __(), submit_button()
isset($value)50wp_unslash(), wp_unslash(), _e(), esc_attr(), __(), submit_button()
isset($value)56wp_unslash(), wp_unslash(), __(), _e(), esc_attr(), __(), submit_button()
!isset($value)67–74_e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
!isset($value)70–76_e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()
!isset($value)73–80__(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
always74–81wp_unslash(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
!isset($value)76–82__(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()
always77–83wp_unslash(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()
6 further outcomes, up to 96 instructions
always80–87wp_unslash(), __(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
isset($value)81–88wp_unslash(), wp_unslash(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
always83–89wp_unslash(), __(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()
isset($value)84–90wp_unslash(), wp_unslash(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()
isset($value)87–94wp_unslash(), wp_unslash(), __(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), esc_attr(), __(), submit_button()
isset($value)90–96wp_unslash(), wp_unslash(), __(), _e(), selected(), _e(), selected(), _e(), selected(), _ex(), _e(), esc_attr(), __(), submit_button()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev11036–9482 fewer instructions than PHP 8.5
8.511236–968
8.411236–968
8.311236–968
8.211236–9681 more instruction than PHP 8.1
8.111136–978
7.411136–978

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

  • wp_unslash()Removes slashes from a string or recursively removes slashes from strings within an array.
  • __()Retrieves the translation of $text.
  • _e()Displays translated text.
  • selected()Outputs the HTML selected attribute.
  • _ex()Displays translated string with gettext context.
  • esc_attr()Escaping for HTML attributes.
  • submit_button()Echoes a submit button, with provided text and appropriate class(es).

Used by · 1

Source code

function install_theme_search_form( $type_selector = true ) {	$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';	$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';	if ( ! $type_selector ) {		echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';	}	?><form id="search-themes" method="get">	<input type="hidden" name="tab" value="search" />	<?php if ( $type_selector ) : ?>	<label class="screen-reader-text" for="typeselector">		<?php		/* translators: Hidden accessibility text. */		_e( 'Type of search' );		?>	</label>	<select	name="type" id="typeselector">	<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option>	<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option>	<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option>	</select>	<label class="screen-reader-text" for="s">		<?php		switch ( $type ) {			case 'term':				/* translators: Hidden accessibility text. */				_e( 'Search by keyword' );				break;			case 'author':				/* translators: Hidden accessibility text. */				_e( 'Search by author' );				break;			case 'tag':				/* translators: Hidden accessibility text. */				_e( 'Search by tag' );				break;		}		?>	</label>	<?php else : ?>	<label class="screen-reader-text" for="s">		<?php		/* translators: Hidden accessibility text. */		_e( 'Search by keyword' );		?>	</label>	<?php endif; ?>	<input type="search" name="s" id="s" size="30" value="<?php echo esc_attr( $term ); ?>" autofocus="autofocus" />	<?php submit_button( __( 'Search' ), '', 'search', false ); ?></form>	<?php}

Changelog

Introduced in 2.8.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-admin/includes/theme-install.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.