wppaste
WordPress

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
Processes a style dependency.

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

Touches nothing outside its own arguments.

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
42–194

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 257.

Plugin surface
1 hook

Third-party callbacks on 'style_loader_tag' run inside this call, and their cost is not bounded by anything here.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • hookthird-party callbacksapply_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 · 70 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.

WhenInstructionsCalls it makes
::do_item() && !$obj && !isset($handle) && !isset($value) && !isset($obj)42–46::do_item(), ->print_inline_style()
::do_item() && !$obj && !isset($handle) && !isset($value)46–54::do_item(), ->print_inline_style(), ->in_default_dir()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)48::do_item(), ->print_inline_style(), ->_css_href()
::do_item() && !$obj && !isset($handle) && !isset($value)48–57::do_item(), ->print_inline_style(), esc_attr()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)52–56::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href()
::do_item() && !$obj && !isset($handle) && !isset($value) && isset($obj)52–60::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr()
::do_item() && !isset($handle) && !isset($value)54–59::do_item(), ->print_inline_style(), esc_attr(), ->_css_href()
::do_item() && !$obj && !isset($handle) && !isset($value)57–65::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir()
::do_item() && !isset($handle) && !isset($value) && isset($obj)58–62::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href()
::do_item() && !$obj && !isset($handle) && !isset($value) && isset($obj)59–63::do_item(), ->print_inline_style(), esc_attr(), esc_attr()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)63–67::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href()
::do_item() && !$obj && !isset($handle) && !isset($value) && isset($obj)63–71::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr()
58 further outcomes, up to 194 instructions
::do_item() && !isset($handle) && !isset($value) && isset($obj)65::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href()
::do_item() && !isset($handle) && !isset($value) && isset($obj)69–73::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)91–106::do_item(), ->print_inline_style(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)92–109::do_item(), ->print_inline_style(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)95–109::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)96–112::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($value)97–112::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value)98–115::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)100–114::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)101–117::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && !isset($value) && isset($obj)101–115::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && isset($obj)102–118::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)104–118::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)105–121::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle)106–121::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)106–120::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle)107–124::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && !isset($value) && !isset($obj)107–123::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($value) && isset($obj)108–118::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && isset($obj)109–121::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)110–124::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)111–127::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && !isset($value) && isset($obj)112–126::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($value) && isset($obj)113–129::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)115–129::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)116–132::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && isset($obj)117–127::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)118–130::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && isset($obj)121–135::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)122–138::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)142–161::do_item(), ->print_inline_style(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)143–164::do_item(), ->print_inline_style(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)146–165::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)147–168::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle)148–168::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle)149–171::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)151–170::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)152–173::do_item(), ->print_inline_style(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)152–171::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)153–174::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)155–174::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)156–177::do_item(), ->print_inline_style(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle)157–177::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)157–176::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle)158–180::do_item(), ->print_inline_style(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)158–179::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)159–174::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)160–177::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)161–180::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)162–183::do_item(), ->print_inline_style(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)163–182::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)164–185::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && !isset($obj)166–185::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && !isset($obj)167–188::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)168–183::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)169–186::do_item(), ->print_inline_style(), esc_attr(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()
::do_item() && !isset($handle) && isset($obj)172–191::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters(), ->print_inline_style()
::do_item() && !isset($handle) && isset($obj)173–194::do_item(), ->print_inline_style(), esc_attr(), ->in_default_dir(), esc_attr(), ->_css_href(), esc_attr(), apply_filters(), ->_css_href(), apply_filters()

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

PHPCompiledExecutedBranchesNotes
8.6-dev25742–19429
8.525742–19429
8.425742–19429
8.325742–19429
8.225742–19429
8.125742–194296 fewer instructions than PHP 7.4
7.426343–19629

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:

  1. apply_filters( style_loader_tag )filterline 251 (+100 into the body)

    Filters the HTML link tag of an enqueued style.

  2. apply_filters( style_loader_tag )filterline 272 (+121 into the body)

    Filters the HTML link tag of an enqueued style.

Uses · 6

Source code

	public function do_item( $handle, $group = false ) {		if ( ! parent::do_item( $handle ) ) {			return false;		} 		$obj = $this->registered[ $handle ]; 		if ( null === $obj->ver ) {			$ver = '';		} else {			$ver = $obj->ver ? $obj->ver : $this->default_version;		} 		if ( isset( $this->args[ $handle ] ) ) {			$ver = $ver ? $ver . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];		} 		$src                   = $obj->src;		$ie_conditional_prefix = '';		$ie_conditional_suffix = '';		$conditional           = isset( $obj->extra['conditional'] ) ? $obj->extra['conditional'] : ''; 		if ( $conditional ) {			$ie_conditional_prefix = "<!--[if {$conditional}]>\n";			$ie_conditional_suffix = "<![endif]-->\n";		} 		$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 ) && ! $conditional && ! isset( $obj->extra['alt'] ) ) {				$this->concat         .= "$handle,";				$this->concat_version .= "$handle$ver"; 				$this->print_code .= $inline_style; 				return true;			}		} 		if ( isset( $obj->args ) ) {			$media = esc_attr( $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'] ) ? sprintf( " title='%s'", esc_attr( $obj->extra['title'] ) ) : ''; 		$tag = sprintf(			"<link rel='%s' id='%s-css'%s href='%s'%s media='%s' />\n",

Changelog

Introduced in 2.6.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

5.5.0
Added the $group parameter.from the docblock
2.6.0
Introduced.from the docblock

About this page

Parsed data
Generated from the wordpress-develop 6.8.8 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.