WP_Customize_Themes_Section::render_template()
- Since
- 4.9.0
- Source
wp-includes/customize/class-wp-customize-themes-section.php:71
Description
The template is only rendered by PHP once, so all actions are prepared at once on the server side.
Compatibility
- WordPress
- since 4.9.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.
Performance profile
How much work a call to WP_Customize_Themes_Section::render_template() 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
- 47–50
- 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 50.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What one call costs · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Customize_Themes_Section::render_template() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
current_user_can() | 47 | current_user_can(), esc_attr_e(), ->filter_bar_content_template(), ->filter_drawer_content_template(), __(), __(), printf(), _e(), __(), __(), printf() |
!current_user_can() | 49–50 | current_user_can(), is_multisite(), esc_attr_e(), ->filter_bar_content_template(), ->filter_drawer_content_template(), __(), __(), printf(), _e(), __(), __(), printf() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 50 | 47–50 | 2 | |
| 8.5 | 50 | 47–50 | 2 | |
| 8.4 | 50 | 47–50 | 2 | 1 fewer instruction than PHP 8.3 |
| 8.3 | 51 | 48–51 | 2 | |
| 8.2 | 51 | 48–51 | 2 | |
| 8.1 | 51 | 48–51 | 2 | |
| 7.4 | 51 | 48–51 | 2 |
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
- current_user_can()Returns whether the current user has the specified capability.
- is_multisite()Determines whether Multisite is enabled.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
- __()Retrieves the translation of $text.
- _e()Displays translated text.
- WP_Customize_Themes_Section::filter_bar_content_template()Renders the filter bar portion of a themes section as a JS template.
- WP_Customize_Themes_Section::filter_drawer_content_template()Renders the filter drawer portion of a themes section as a JS template.
Source code
protected function render_template() { ?> <li id="accordion-section-{{ data.id }}" class="theme-section"> <button type="button" class="customize-themes-section-title themes-section-{{ data.id }}">{{ data.title }}</button> <?php if ( current_user_can( 'install_themes' ) || is_multisite() ) : // @todo Upload support. ?> <?php endif; ?> <div class="customize-themes-section themes-section-{{ data.id }} control-section-content themes-php"> <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div> <div class="theme-browser rendered"> <div class="customize-preview-header themes-filter-bar"> <?php $this->filter_bar_content_template(); ?> </div> <?php $this->filter_drawer_content_template(); ?> <div class="error unexpected-error" style="display: none; "> <p> <?php printf( /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ); ?> </p> </div> <ul class="themes"> </ul> <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p> <p class="no-themes-local"> <?php printf( /* translators: %s: "Search WordPress.org themes" button text. */ __( 'No themes found. Try a different search, or %s.' ), sprintf( '<button type="button" class="button-link search-dotorg-themes">%s</button>', __( 'Search WordPress.org themes' ) ) ); ?> </p> <p class="spinner"></p> </div> </div> </li> <?php }Changelog
Introduced in 4.9.0. 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 7.1.0 tag, from
src/wp-includes/customize/class-wp-customize-themes-section.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.