wppaste
WordPress

WP_Customize_Header_Image_Control::render_content()

Source
wp-includes/customize/class-wp-customize-header-image-control.php:194

Compatibility

WordPress
core
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.

Performance profile

How much work a call to WP_Customize_Header_Image_Control::render_content() 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
58–100

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_filters()one call below WP_Customize_Header_Image_Control::render_content()

Further down the call graph this can also reach query, option, cache, serialize 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 · 4 distinct outcomes

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

WhenInstructionsCalls it makes
current_theme_supports() && !current_user_can()58–63->get_current_image_src(), get_theme_support(), absint(), get_theme_support(), absint(), current_theme_supports(), current_theme_supports(), _e(), _e(), current_user_can(), _ex(), _ex()
!current_theme_supports() && !current_user_can()65–74->get_current_image_src(), get_theme_support(), absint(), get_theme_support(), absint(), current_theme_supports(), current_theme_supports(), __(), printf(), _e(), current_user_can(), _ex(), _ex()
current_theme_supports() && current_user_can()83–89->get_current_image_src(), get_theme_support(), absint(), get_theme_support(), absint(), current_theme_supports(), current_theme_supports(), _e(), _e(), current_user_can(), esc_attr_e(), _e(), ->get_current_image_src(), esc_attr_e(), _e(), _ex(), _ex()
!current_theme_supports() && current_user_can()90–100->get_current_image_src(), get_theme_support(), absint(), get_theme_support(), absint(), current_theme_supports(), current_theme_supports(), __(), printf(), _e(), current_user_can(), esc_attr_e(), _e(), ->get_current_image_src(), esc_attr_e(), _e(), _ex(), _ex()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev12858–1008
8.512858–1008
8.412858–10082 fewer instructions than PHP 8.3
8.313058–1008
8.213058–1008
8.113058–1008
7.413058–1008

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

Source code

	public function render_content() {		$visibility = $this->get_current_image_src() ? '' : ' style="display:none" ';		$width      = absint( get_theme_support( 'custom-header', 'width' ) );		$height     = absint( get_theme_support( 'custom-header', 'height' ) );		?>		<div class="customize-control-content">			<?php			if ( current_theme_supports( 'custom-header', 'video' ) ) {				echo '<span class="customize-control-title">' . $this->label . '</span>';			}			?>			<div class="customize-control-notifications-container"></div>			<p class="customizer-section-intro customize-control-description">				<?php				if ( current_theme_supports( 'custom-header', 'video' ) ) {					_e( 'Click &#8220;Add Image&#8221; to upload an image file from your computer. Your theme works best with an image that matches the size of your video &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' );				} elseif ( $width && $height ) {					printf(						/* translators: %s: Header size in pixels. */						__( 'Click &#8220;Add Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header size of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),						sprintf( '<strong>%s &times; %s</strong>', $width, $height )					);				} elseif ( $width ) {					printf(						/* translators: %s: Header width in pixels. */						__( 'Click &#8220;Add Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),						sprintf( '<strong>%s</strong>', $width )					);				} else {					printf(						/* translators: %s: Header height in pixels. */						__( 'Click &#8220;Add Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),						sprintf( '<strong>%s</strong>', $height )					);				}				?>			</p>			<div class="current">				<label for="header_image-button">					<span class="customize-control-title">						<?php _e( 'Current header' ); ?>					</span>				</label>				<div class="container">				</div>			</div>			<div class="actions">				<?php if ( current_user_can( 'upload_files' ) ) : ?>				<button type="button"<?php echo $visibility; ?> class="button remove" aria-label="<?php esc_attr_e( 'Hide header image' ); ?>"><?php _e( 'Hide image' ); ?></button>				<button type="button" class="button new <?php echo ! $this->get_current_image_src() ? '' : 'customize-header-image-not-selected'; ?>" id="header_image-button" aria-label="<?php esc_attr_e( 'Add Header Image' ); ?>"><?php _e( 'Add Image' ); ?></button>				<?php endif; ?>			</div>			<div class="choices">				<span class="customize-control-title header-previously-uploaded">					<?php _ex( 'Previously uploaded', 'custom headers' ); ?>				</span>				<div class="uploaded">					<div class="list">					</div>				</div>				<span class="customize-control-title header-default">					<?php _ex( 'Suggested', 'custom headers' ); ?>				</span>				<div class="default">					<div class="list">					</div>				</div>			</div>		</div>		<?php	}

Changelog

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 6.9.7 tag, from src/wp-includes/customize/class-wp-customize-header-image-control.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.