WP_Styles::do_item( string $handle, int|false $group = false )
Processes a style dependency.
Description
See also
Parameters
- $handle
-
(Required) The style's registered handle.
- $group
-
(Optional) Group level: level (int), no groups (false).<br>
Default value: false
Return
(bool) True on success, false on failure.
Source
File: wp-includes/class-wp-styles.php
public function do_item( $handle ) {
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 . '&' . $this->args[$handle] : $this->args[$handle];
/** This filter is documented in wp-includes/script-loader.php */
$ver = apply_filters( 'classicpress_asset_version', $ver, 'style', $handle );
if ( $this->do_concat ) {
if ( $this->in_default_dir($obj->src) && !isset($obj->extra['conditional']) && !isset($obj->extra['alt']) ) {
$this->concat .= "$handle,";
$this->concat_version .= "$handle$ver";
$this->print_code .= $this->print_inline_style( $handle, false );
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 ( ! $obj->src ) {
if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
$inline_style = sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
if ( $this->do_concat ) {
$this->print_html .= $inline_style;
} else {
echo $inline_style;
}
}
return true;
}
$href = $this->_css_href( $obj->src, $ver, $handle );
if ( ! $href ) {
return true;
}
$rel = isset($obj->extra['alt']) && $obj->extra['alt'] ? 'alternate stylesheet' : 'stylesheet';
$title = isset($obj->extra['title']) ? "title='" . esc_attr( $obj->extra['title'] ) . "'" : '';
/**
* Filters the HTML link tag of an enqueued style.
*
* @since WP-2.6.0
* @since WP-4.3.0 Introduced the `$href` parameter.
* @since WP-4.5.0 Introduced the `$media` parameter.
*
* @param string $html 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', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' media='$media' />\n", $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 = isset( $obj->extra['suffix'] ) ? $obj->extra['suffix'] : '';
$rtl_href = str_replace( "{$suffix}.css", "-rtl{$suffix}.css", $this->_css_href( $obj->src , $ver, "$handle-rtl" ));
} else {
$rtl_href = $this->_css_href( $obj->extra['rtl'], $ver, "$handle-rtl" );
}
/** This filter is documented in wp-includes/class.wp-styles.php */
$rtl_tag = apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-rtl-css' $title href='$rtl_href' type='text/css' media='$media' />\n", $handle, $rtl_href, $media );
if ( $obj->extra['rtl'] === 'replace' ) {
$tag = $rtl_tag;
} else {
$tag .= $rtl_tag;
}
}
$conditional_pre = $conditional_post = '';
if ( isset( $obj->extra['conditional'] ) && $obj->extra['conditional'] ) {
$conditional_pre = "<!--[if {$obj->extra['conditional']}]>\n";
$conditional_post = "<![endif]-->\n";
}
if ( $this->do_concat ) {
$this->print_html .= $conditional_pre;
$this->print_html .= $tag;
if ( $inline_style = $this->print_inline_style( $handle, false ) ) {
$this->print_html .= sprintf( "<style id='%s-inline-css' type='text/css'>\n%s\n</style>\n", esc_attr( $handle ), $inline_style );
}
$this->print_html .= $conditional_post;
} else {
echo $conditional_pre;
echo $tag;
$this->print_inline_style( $handle );
echo $conditional_post;
}
return true;
}
Changelog
Version | Description |
---|---|
5.5.0 | Added the $group parameter. |
2.6.0 | Introduced. |