Title: WP_Styles::do_item
Published: April 25, 2014
Last modified: August 20, 2026

---

# WP_Styles::do_item( string $handle, int|false $group = false ): bool

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#description)
    - [See also](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#see-also)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#changelog)

Processes a style dependency.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#description)󠁿

### 󠀁[See also](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#see-also)󠁿

 * [WP_Dependencies::do_item()](https://developer.wordpress.org/reference/classes/WP_Dependencies/do_item/)

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#parameters)󠁿

 `$handle`stringrequired

The style’s registered handle.

`$group`int|falseoptional

Group level: level (int), no groups (false).

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#return)󠁿

 bool True on success, false on failure.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#source)󠁿

    ```php
    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 . '&amp;' . $this->args[ $handle ] : $this->args[ $handle ];
    	}

    	$src          = $obj->src;
    	$inline_style = $this->print_inline_style( $handle, false );

    	if ( $inline_style ) {
    		$processor = new WP_HTML_Tag_Processor( '<style></style>' );
    		$processor->next_tag();
    		$processor->set_attribute( 'id', "{$handle}-inline-css" );
    		$processor->set_modifiable_text( "\n{$inline_style}\n" );
    		$inline_style_tag = "{$processor->get_updated_html()}\n";
    	} else {
    		$inline_style_tag = '';
    	}

    	if ( $this->do_concat ) {
    		if ( is_string( $src ) && $this->in_default_dir( $src ) && ! isset( $obj->extra['alt'] ) ) {
    			$this->concat         .= "$handle,";
    			$this->concat_version .= "$handle$ver";

    			$this->print_code .= $inline_style;

    			return true;
    		}
    	}

    	$media = $obj->args ?? '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, $obj->ver, $handle );
    	if ( ! $href ) {
    		return true;
    	}

    	$rel   = isset( $obj->extra['alt'] ) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
    	$title = $obj->extra['title'] ?? '';

    	$tag = sprintf(
    		"<link rel='%s' id='%s-css'%s href='%s' media='%s' />\n",
    		$rel,
    		esc_attr( $handle ),
    		$title ? sprintf( " title='%s'", esc_attr( $title ) ) : '',
    		$href,
    		esc_attr( $media )
    	);

    	/**
    	 * Filters the HTML link tag of an enqueued style.
    	 *
    	 * @since 2.6.0
    	 * @since 4.3.0 Introduced the `$href` parameter.
    	 * @since 4.5.0 Introduced the `$media` parameter.
    	 *
    	 * @param string $tag    The link tag for the enqueued style.
    	 * @param string $handle The style's registered handle.
    	 * @param string $href   The stylesheet's source URL.
    	 * @param string $media  The stylesheet's media attribute.
    	 */
    	$tag = apply_filters( 'style_loader_tag', $tag, $handle, $href, $media );

    	if ( 'rtl' === $this->text_direction && isset( $obj->extra['rtl'] ) && $obj->extra['rtl'] ) {
    		if ( is_bool( $obj->extra['rtl'] ) || 'replace' === $obj->extra['rtl'] ) {
    			$suffix   = $obj->extra['suffix'] ?? '';
    			$rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $src, $ver, "$handle-rtl" ) );
    		} else {
    			$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
    		}

    		$rtl_tag = sprintf(
    			"<link rel='%s' id='%s-rtl-css'%s href='%s' media='%s' />\n",
    			$rel,
    			esc_attr( $handle ),
    			$title ? sprintf( " title='%s'", esc_attr( $title ) ) : '',
    			$rtl_href,
    			esc_attr( $media )
    		);

    		/** This filter is documented in wp-includes/class-wp-styles.php */
    		$rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media );

    		if ( 'replace' === $obj->extra['rtl'] ) {
    			$tag = $rtl_tag;
    		} else {
    			$tag .= $rtl_tag;
    		}
    	}

    	if ( $this->do_concat ) {
    		$this->print_html .= $tag;
    		if ( $inline_style_tag ) {
    			$this->print_html .= $inline_style_tag;
    		}
    	} else {
    		echo $tag;
    		$this->print_inline_style( $handle );
    	}

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes_class-wp-styles-php-2/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-styles.php#L137)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-styles.php#L137-L265)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#hooks)󠁿

 [apply_filters( ‘style_loader_tag’, string $tag, string $handle, string $href, string $media )](https://developer.wordpress.org/reference/hooks/style_loader_tag/)

Filters the HTML link tag of an enqueued style.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_HTML_Tag_Processor::__construct()](https://developer.wordpress.org/reference/classes/wp_html_tag_processor/__construct/)`wp-includes/html-api/class-wp-html-tag-processor.php` |

Constructor.

  | 
| [WP_Styles::print_inline_style()](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/)`wp-includes/class-wp-styles.php` |

Prints extra CSS styles of a registered stylesheet.

  | 
| [WP_Styles::in_default_dir()](https://developer.wordpress.org/reference/classes/wp_styles/in_default_dir/)`wp-includes/class-wp-styles.php` |

Whether a handle’s source is in a default directory.

  | 
| [WP_Styles::_css_href()](https://developer.wordpress.org/reference/classes/wp_styles/_css_href/)`wp-includes/class-wp-styles.php` |

Generates an enqueued style’s fully-qualified URL.

  | 
| [WP_Dependencies::do_item()](https://developer.wordpress.org/reference/classes/wp_dependencies/do_item/)`wp-includes/class-wp-dependencies.php` |

Processes a dependency.

  | 
| [esc_attr()](https://developer.wordpress.org/reference/functions/esc_attr/)`wp-includes/formatting.php` |

Escaping for HTML attributes.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  |

[Show 2 more](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_styles/do_item/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.5.0](https://developer.wordpress.org/reference/since/5.5.0/) | Added the `$group` parameter. | 
| [2.6.0](https://developer.wordpress.org/reference/since/2.6.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_styles%2Fdo_item%2F)
before being able to contribute a note or feedback.