block_core_image_print_lightbox_overlay()
- Since
- 6.5.0
- Source
wp-includes/blocks/image.php:323
Compatibility
- WordPress
- since 6.5.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 block_core_image_print_lightbox_overlay() 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
- 48–68
- 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 it touches
- hookthird-party callbacks
apply_filters()one call below block_core_image_print_lightbox_overlay()
Further down the call graph this can also reach option, cache, serialize, transient and query. 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 block_core_image_print_lightbox_overlay() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!wp_theme_has_theme_json() | 48 | esc_attr__(), esc_attr__(), esc_attr_x(), esc_attr_x(), wp_theme_has_theme_json() |
wp_theme_has_theme_json() && empty($global_styles_color) | 56 | esc_attr__(), esc_attr__(), esc_attr_x(), esc_attr_x(), wp_theme_has_theme_json(), wp_get_global_styles() |
wp_theme_has_theme_json() | 62 | esc_attr__(), esc_attr__(), esc_attr_x(), esc_attr_x(), wp_theme_has_theme_json(), wp_get_global_styles(), esc_attr() |
wp_theme_has_theme_json() && !empty($global_styles_color) | 68 | esc_attr__(), esc_attr__(), esc_attr_x(), esc_attr_x(), wp_theme_has_theme_json(), wp_get_global_styles(), esc_attr(), esc_attr() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 68 instructions, 48–68 executed per call, 3 branches. The work does not change between versions.
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
- esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
- esc_attr_x()Translates string with gettext context, and escapes it for safe use in an attribute.
- wp_theme_has_theme_json()Checks whether a theme or its parent has a theme.json file.
- wp_get_global_styles()Gets the styles resulting of merging core, theme, and user data.
- esc_attr()Escaping for HTML attributes.
Source code
function block_core_image_print_lightbox_overlay() { $dialog_label = esc_attr__( 'Enlarged images' ); $close_button_text = esc_attr__( 'Close' ); $prev_button_text = esc_attr_x( 'Previous', 'previous image in lightbox' ); $next_button_text = esc_attr_x( 'Next', 'next image in lightbox' ); $close_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" focusable="false"><path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z"></path></svg>'; $prev_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"><path d="M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"></path></svg>'; $next_button_icon = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="28" height="28" aria-hidden="true" focusable="false"><path d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z"></path></svg>'; // If the current theme does NOT have a `theme.json`, or the colors are not // defined, it needs to set the background color & close button color to some // default values because it can't get them from the Global Styles. $background_color = '#fff'; $close_button_color = '#000'; if ( wp_theme_has_theme_json() ) { $global_styles_color = wp_get_global_styles( array( 'color' ) ); if ( ! empty( $global_styles_color['background'] ) ) { $background_color = esc_attr( $global_styles_color['background'] ); } if ( ! empty( $global_styles_color['text'] ) ) { $close_button_color = esc_attr( $global_styles_color['text'] ); } } echo <<<HTML <div class="wp-lightbox-overlay zoom" aria-label="{$dialog_label}" data-wp-interactive="core/image" data-wp-router-region='{ "id": "core/image-overlay", "attachTo": "body" }' data-wp-key="wp-lightbox-overlay" data-wp-context='{}' data-wp-bind--role="state.roleAttribute" data-wp-bind--aria-label="state.ariaLabel" data-wp-bind--aria-modal="state.ariaModal" data-wp-class--active="state.overlayEnabled" data-wp-class--show-closing-animation="state.overlayOpened" data-wp-watch---focus="callbacks.setOverlayFocus" data-wp-watch---inert="callbacks.setInertElements" data-wp-on--keydown="actions.handleKeydown" data-wp-on--touchstart="actions.handleTouchStart" data-wp-on--touchmove="actions.handleTouchMove" data-wp-on--touchend="actions.handleTouchEnd" data-wp-on--click="actions.hideLightbox" data-wp-on-window--resize="callbacks.setOverlayStyles" data-wp-on-window--scroll="actions.handleScroll" data-wp-bind--style="state.overlayStyles" tabindex="-1" > <button type="button" style="fill:{$close_button_color}" class="wp-lightbox-close-button" data-wp-bind--aria-label="state.closeButtonAriaLabel"> <span class="wp-lightbox-close-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$close_button_icon}</span> <span class="wp-lightbox-close-text" data-wp-bind--hidden="!state.hasNavigationText">{$close_button_text}</span> </button> <button type="button" style="fill:{$close_button_color}" class="wp-lightbox-navigation-button wp-lightbox-navigation-button-prev" data-wp-bind--hidden="!state.hasNavigation" data-wp-on--click="actions.showPreviousImage" data-wp-bind--aria-label="state.prevButtonAriaLabel"> <span class="wp-lightbox-navigation-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$prev_button_icon}</span> <span class="wp-lightbox-navigation-text" data-wp-bind--hidden="!state.hasNavigationText">{$prev_button_text}</span> </button> <div class="lightbox-image-container"> <figure data-wp-bind--class="state.selectedImage.figureClassNames" data-wp-bind--style="state.figureStyles"> <img data-wp-bind--alt="state.selectedImage.alt" data-wp-bind--class="state.selectedImage.imgClassNames" data-wp-bind--style="state.imgStyles" data-wp-bind--src="state.selectedImage.currentSrc"> </figure> </div> <div class="lightbox-image-container"> <figure data-wp-bind--class="state.selectedImage.figureClassNames" data-wp-bind--style="state.figureStyles"> <img data-wp-bind--alt="state.selectedImage.alt" data-wp-bind--class="state.selectedImage.imgClassNames" data-wp-bind--style="state.imgStyles" data-wp-bind--src="state.enlargedSrc" data-wp-bind--srcset="state.enlargedSrcset" sizes="100vw" > </figure> </div> <button type="button" style="fill:{$close_button_color}" class="wp-lightbox-navigation-button wp-lightbox-navigation-button-next" data-wp-bind--hidden="!state.hasNavigation" data-wp-on--click="actions.showNextImage" data-wp-bind--aria-label="state.nextButtonAriaLabel"> <span class="wp-lightbox-navigation-text" data-wp-bind--hidden="!state.hasNavigationText">{$next_button_text}</span> <span class="wp-lightbox-navigation-icon" data-wp-bind--hidden="!state.hasNavigationIcon">{$next_button_icon}</span> </button> <div data-wp-text="state.ariaLabel" aria-live="polite" aria-atomic="true" class="screen-reader-text"></div> <div class="scrim" style="background-color: {$background_color}" aria-hidden="true"></div>Changelog
Introduced in 6.5.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/blocks/image.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.