WP_Widget_Text::render_control_template_scripts()
- Since
- 4.8.0, 4.9.0
- Source
wp-includes/widgets/class-wp-widget-text.php:527
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_Widget_Text::render_control_template_scripts() 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
- 31–63
- 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 68.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
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_Widget_Text::render_control_template_scripts() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$dismissed_pointers | 31 | get_current_user_id(), get_user_meta(), explode(), esc_html_e(), esc_html_e() |
| always | 44 | get_current_user_id(), get_user_meta(), explode(), esc_html_e(), _e(), _e(), _e(), esc_html_e() |
| always | 49–50 | get_current_user_id(), get_user_meta(), explode(), esc_html_e(), _e(), is_customize_preview(), _e(), _e(), esc_html_e() |
!$dismissed_pointers | 62–63 | get_current_user_id(), get_user_meta(), explode(), esc_html_e(), _e(), is_customize_preview(), _e(), _e(), _e(), _e(), _e(), esc_html_e() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 68 | 31–63 | 3 | |
| 8.5 | 68 | 31–63 | 3 | |
| 8.4 | 68 | 31–63 | 3 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 74 | 37–69 | 3 | |
| 8.2 | 74 | 37–69 | 3 | |
| 8.1 | 74 | 37–69 | 3 | |
| 7.4 | 74 | 37–69 | 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 · 5
- get_user_meta()Retrieves user meta field for a user.
- get_current_user_id()Gets the current user's ID.
- esc_html_e()Displays translated text that has been escaped for safe use in HTML output.
- _e()Displays translated text.
- is_customize_preview()Whether the site is being previewed in the Customizer.
Source code
public static function render_control_template_scripts() { $dismissed_pointers = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) ); ?> <script type="text/html" id="tmpl-widget-text-control-fields"> <# var elementIdPrefix = 'el' + String( Math.random() ).replace( /\D/g, '' ) + '_' #> <p> <label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label> <input id="{{ elementIdPrefix }}title" type="text" class="widefat title"> </p> <?php if ( ! in_array( 'text_widget_custom_html', $dismissed_pointers, true ) ) : ?> <div hidden class="wp-pointer custom-html-widget-pointer wp-pointer-top"> <div class="wp-pointer-content"> <h3><?php _e( 'New Custom HTML Widget' ); ?></h3> <?php if ( is_customize_preview() ) : ?> <p><?php _e( 'Did you know there is a “Custom HTML” widget now? You can find it by pressing the “<a class="add-widget" href="#">Add a Widget</a>” button and searching for “HTML”. Check it out to add some custom code to your site!' ); ?></p> <?php else : ?> <p><?php _e( 'Did you know there is a “Custom HTML” widget now? You can find it by scanning the list of available widgets on this screen. Check it out to add some custom code to your site!' ); ?></p> <?php endif; ?> <div class="wp-pointer-buttons"> <a class="close" href="#"><?php _e( 'Dismiss' ); ?></a> </div> </div> <div class="wp-pointer-arrow"> <div class="wp-pointer-arrow-inner"></div> </div> </div> <?php endif; ?> <?php if ( ! in_array( 'text_widget_paste_html', $dismissed_pointers, true ) ) : ?> <div hidden class="wp-pointer paste-html-pointer wp-pointer-top"> <div class="wp-pointer-content"> <h3><?php _e( 'Did you just paste HTML?' ); ?></h3> <p><?php _e( 'Hey there, looks like you just pasted HTML into the “Visual” tab of the Text widget. You may want to paste your code into the “Code” tab instead. Alternately, try out the new “Custom HTML” widget!' ); ?></p> <div class="wp-pointer-buttons"> <a class="close" href="#"><?php _e( 'Dismiss' ); ?></a> </div> </div> <div class="wp-pointer-arrow"> <div class="wp-pointer-arrow-inner"></div> </div> </div> <?php endif; ?> <p> <label for="{{ elementIdPrefix }}text" class="screen-reader-text"><?php /* translators: Hidden accessibility text. */ esc_html_e( 'Content:' ); ?></label> <textarea id="{{ elementIdPrefix }}text" class="widefat text wp-editor-area" style="height: 200px" rows="16" cols="20"></textarea> </p> </script> <?php }Changelog
Introduced in 4.8.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 6.9.7 tag, from
src/wp-includes/widgets/class-wp-widget-text.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.