WP_Customize_Date_Time_Control::content_template()
- Since
- 4.9.0
- Source
wp-includes/customize/class-wp-customize-date-time-control.php:98
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_Date_Time_Control::content_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
- Moderate
- Scaling
- Constant
- Instructions
- 110–122
- Plugin surface
- None
- Called by
- 0
Reads stored settings via get_option(), cached per request but not free on a cold cache.
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 122.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- optionoption read or write
get_option()called directly - hookthird-party callbacks
apply_filters()one call below WP_Customize_Date_Time_Control::content_template() - cacheobject cache
wp_cache_get()one call below WP_Customize_Date_Time_Control::content_template() - serializeserialisation
maybe_unserialize()one call below WP_Customize_Date_Time_Control::content_template()
Further down the call graph this can also reach 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 · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Customize_Date_Time_Control::content_template() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 110 | ->json(), ->get_month_choices(), array_merge(), ->get_timezone_info(), get_option(), substr_count(), wp_json_encode(), esc_html_e(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), printf(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e() |
| always | 116 | ->json(), ->get_month_choices(), array_merge(), ->get_timezone_info(), get_option(), substr_count(), substr_count(), wp_json_encode(), esc_html_e(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), printf(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e() |
| always | 121–122 | ->json(), ->get_month_choices(), array_merge(), ->get_timezone_info(), get_option(), substr_count(), substr_count(), substr_count(), wp_json_encode(), esc_html_e(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), ob_start(), esc_html_e(), ob_get_clean(), printf(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e(), esc_html_e() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 122 | 110–122 | 3 | |
| 8.5 | 122 | 110–122 | 3 | |
| 8.4 | 122 | 110–122 | 3 | 18 fewer instructions than PHP 8.3 |
| 8.3 | 140 | 128–140 | 3 | |
| 8.2 | 140 | 128–140 | 3 | |
| 8.1 | 140 | 128–140 | 3 | |
| 7.4 | 140 | 128–140 | 3 |
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 · 6
- get_option()Retrieves an option value based on an option name.
- wp_json_encode()Encodes a variable into JSON, with some confidence checks.
- esc_html_e()Displays translated text that has been escaped for safe use in HTML output.
- WP_Customize_Date_Time_Control::json()Export data to JS.
- WP_Customize_Date_Time_Control::get_month_choices()Generate options for the month Select.
- WP_Customize_Date_Time_Control::get_timezone_info()Get timezone info.
Source code
public function content_template() { $data = array_merge( $this->json(), $this->get_month_choices() ); $timezone_info = $this->get_timezone_info(); $date_format = get_option( 'date_format' ); $date_format = preg_replace( '/(?<!\\\\)[Yyo]/', '%1$s', $date_format ); $date_format = preg_replace( '/(?<!\\\\)[FmMn]/', '%2$s', $date_format ); $date_format = preg_replace( '/(?<!\\\\)[jd]/', '%3$s', $date_format ); // Fallback to ISO date format if year, month, or day are missing from the date format. if ( 1 !== substr_count( $date_format, '%1$s' ) || 1 !== substr_count( $date_format, '%2$s' ) || 1 !== substr_count( $date_format, '%3$s' ) ) { $date_format = '%1$s-%2$s-%3$s'; } ?> <# _.defaults( data, <?php echo wp_json_encode( $data ); ?> ); #> <# var idPrefix = _.uniqueId( 'el' ) + '-'; #> <# if ( data.label ) { #> <span class="customize-control-title"> {{ data.label }} </span> <# } #> <div class="customize-control-notifications-container"></div> <# if ( data.description ) { #> <span class="description customize-control-description">{{ data.description }}</span> <# } #> <div class="date-time-fields {{ data.includeTime ? 'includes-time' : '' }}"> <fieldset class="day-row"> <legend class="title-day {{ ! data.includeTime ? 'screen-reader-text' : '' }}"><?php esc_html_e( 'Date' ); ?></legend> <div class="day-fields clear"> <?php ob_start(); ?> <label for="{{ idPrefix }}date-time-month" class="screen-reader-text"> <?php /* translators: Hidden accessibility text. */ esc_html_e( 'Month' ); ?> </label> <select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month"> <# _.each( data.month_choices, function( choice ) { if ( _.isObject( choice ) && ! _.isUndefined( choice.text ) && ! _.isUndefined( choice.value ) ) { text = choice.text; value = choice.value; } #> <option value="{{ value }}" > {{ text }} </option> <# } ); #> </select> <?php $month_field = trim( ob_get_clean() ); ?> <?php ob_start(); ?> <label for="{{ idPrefix }}date-time-day" class="screen-reader-text"> <?php /* translators: Hidden accessibility text. */ esc_html_e( 'Day' ); ?> </label> <input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day tiny-text" data-component="day" min="1" max="31" /> <?php $day_field = trim( ob_get_clean() ); ?> <?php ob_start(); ?> <label for="{{ idPrefix }}date-time-year" class="screen-reader-text"> <?php /* translators: Hidden accessibility text. */ esc_html_e( 'Year' ); ?> </label> <input id="{{ idPrefix }}date-time-year" type="number" size="4" autocomplete="off" class="date-input year tiny-text" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}"> <?php $year_field = trim( ob_get_clean() ); ?> <?php printf( $date_format, $year_field, $month_field, $day_field ); ?> </div> </fieldset> <# if ( data.includeTime ) { #> <fieldset class="time-row clear"> <legend class="title-time"><?php esc_html_e( 'Time' ); ?></legend> <div class="time-fields clear"> <label for="{{ idPrefix }}date-time-hour" class="screen-reader-text">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.0.4 tag, from
src/wp-includes/customize/class-wp-customize-date-time-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.