WP_Customize_Header_Image_Control::render_content()
- Source
wp-includes/customize/class-wp-customize-header-image-control.php:200
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
- Scaling
- Constant
- Instructions
- 58–93
- Plugin surface
- None
- Called by
- 0
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 120.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_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.
| When | Instructions | Calls 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() | 77–82 | ->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(), esc_attr_e(), _e(), _ex(), _ex() |
!current_theme_supports() && current_user_can() | 84–93 | ->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(), esc_attr_e(), _e(), _ex(), _ex() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 120 | 58–93 | 7 | |
| 8.5 | 120 | 58–93 | 7 | |
| 8.4 | 120 | 58–93 | 7 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 122 | 58–93 | 7 | |
| 8.2 | 122 | 58–93 | 7 | |
| 8.1 | 122 | 58–93 | 7 | |
| 7.4 | 122 | 58–93 | 7 |
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
- absint()Converts a value to non-negative integer.
- get_theme_support()Gets the theme support arguments passed when registering that support.
- current_theme_supports()Checks a theme's support for a given feature.
- _e()Displays translated text.
- __()Retrieves the translation of $text.
- current_user_can()Returns whether the current user has the specified capability.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
- _ex()Displays translated string with gettext context.
- WP_Customize_Header_Image_Control::get_current_image_src()
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 “Add Image” to upload an image file from your computer. Your theme works best with an image that matches the size of your video — you’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 “Add Image” to upload an image file from your computer. Your theme works best with an image with a header size of %s pixels — you’ll be able to crop your image once you upload it for a perfect fit.' ), sprintf( '<strong>%s × %s</strong>', $width, $height ) ); } elseif ( $width ) { printf( /* translators: %s: Header width in pixels. */ __( 'Click “Add Image” to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels — you’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 “Add Image” to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels — you’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" 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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.8.8 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.