WP_Styles::do_item( string $handle, int|false $group = false ): bool
- Since
- 2.6.0, 5.5.0
- Source
wp-includes/class-wp-styles.php:151
Compatibility
- WordPress
- since 5.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.
Parameters
$handlestring- The style's registered handle.
$groupint|falseoptional- Group level: level (int), no groups (false).
Default false.Default:false
Return value
bool- True on success, false on failure.
Performance profile
How much work a call to WP_Styles::do_item() 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
- 38–188
- Plugin surface
- 1 hook
- 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 258.
Third-party callbacks on 'style_loader_tag' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
apply_filters()called directly
Further down the call graph this can also reach option, cache, serialize, 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 · 28 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost WP_Styles::do_item() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
::do_item() && !$obj && !isset($handle) | 38–43 | ::do_item(), ->print_inline_style() |
::do_item() && !$obj && !isset($handle) && !->in_default_dir() | 42–47 | ::do_item(), ->print_inline_style(), ->in_default_dir() |
::do_item() && !isset($handle) | 44–45 | ::do_item(), ->print_inline_style(), ->_css_href() |
::do_item() && !isset($handle) && !->in_default_dir() | 48–49 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href() |
::do_item() && !isset($handle) | 92–107 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) | 93–106 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) | 96–112 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) | 97–111 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) | 98–113 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) | 99–112 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) | 102–118 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) | 103–117 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
16 further outcomes, up to 187 instructions
::do_item() && !isset($handle) && isset($value) | 151–171 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 152–170 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 155–176 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 156–175 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 157–177 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 157–177 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 158–176 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 158–176 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 161–182 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 161–182 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 162–181 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 162–181 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 163–183 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 164–182 | ::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
::do_item() && !isset($handle) && isset($value) | 167–188 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters() |
::do_item() && !isset($handle) && isset($value) | 168–187 | ::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->_css_href(), esc_attr(), esc_attr(), esc_attr(), apply_filters(), ->print_inline_style() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 258 | 38–188 | 30 | |
| 8.5 | 258 | 38–188 | 30 | |
| 8.4 | 258 | 38–188 | 30 | 2 fewer instructions than PHP 8.3 |
| 8.3 | 260 | 38–190 | 30 | |
| 8.2 | 260 | 38–190 | 30 | |
| 8.1 | 260 | 38–190 | 30 | 6 fewer instructions than PHP 7.4 |
| 7.4 | 266 | 39–193 | 30 |
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.
Hooks and filters fired · 2
2 hooks fire while WP_Styles::do_item() runs, in this order:
- apply_filters( style_loader_tag )filterline 245 (+94 into the body)
Filters the HTML link tag of an enqueued style.
- apply_filters( style_loader_tag )filterline 266 (+115 into the body)
Filters the HTML link tag of an enqueued style.
Uses · 6
- esc_attr()Escaping for HTML attributes.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- WP_Dependencies::do_item()Processes a dependency.
- WP_Styles::print_inline_style()Prints extra CSS styles of a registered stylesheet.
- WP_Styles::in_default_dir()Whether a handle's source is in a default directory.
- WP_Styles::_css_href()Generates an enqueued style's fully-qualified URL.
Source code
public function do_item( $handle, $group = false ) { if ( ! parent::do_item( $handle ) ) { return false; } $obj = $this->registered[ $handle ]; if ( $obj->extra['conditional'] ?? false ) { return false; } if ( null === $obj->ver ) { $ver = ''; } else { $ver = $obj->ver ? $obj->ver : $this->default_version; } if ( isset( $this->args[ $handle ] ) ) { $ver = $ver ? $ver . '&' . $this->args[ $handle ] : $this->args[ $handle ]; } $src = $obj->src; $inline_style = $this->print_inline_style( $handle, false ); if ( $inline_style ) { $inline_style_tag = sprintf( "<style id='%s-inline-css'%s>\n%s\n</style>\n", esc_attr( $handle ), $this->type_attr, $inline_style ); } else { $inline_style_tag = ''; } if ( $this->do_concat ) { if ( $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) { $this->concat .= "$handle,"; $this->concat_version .= "$handle$ver"; $this->print_code .= $inline_style; return true; } } if ( isset( $obj->args ) ) { $media = $obj->args; } else { $media = 'all'; } // A single item may alias a set of items, by having dependencies, but no source. if ( ! $src ) { if ( $inline_style_tag ) { if ( $this->do_concat ) { $this->print_html .= $inline_style_tag; } else { echo $inline_style_tag; } } return true; } $href = $this->_css_href( $src, $ver, $handle ); if ( ! $href ) { return true; } $rel = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet'; $title = isset( $obj->extra['title'] ) ? $obj->extra['title'] : ''; $tag = sprintf( "<link rel='%s' id='%s-css'%s href='%s'%s media='%s' />\n", $rel, esc_attr( $handle ), $title ? sprintf( " title='%s'", esc_attr( $title ) ) : '', $href, $this->type_attr, esc_attr( $media )Changelog
Introduced in 2.6.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$group parameter.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/class-wp-styles.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.