Filter hook 'style_loader_tag'

in WP Core File wp-includes/class-wp-styles.php at line 272

View Source

style_loader_tag

Filter Hook
Description
Filters the HTML link tag of an enqueued style.

Hook Information

File Location wp-includes/class-wp-styles.php View on GitHub
Hook Type Filter
Line Number 272

Hook Parameters

Type Name Description
string $tag The link tag for the enqueued style.
string $handle The style's registered handle.
string $href The stylesheet's source URL.
string $media The stylesheet's media attribute.

Usage Examples

Basic Usage
<?php
// Hook into style_loader_tag
add_filter('style_loader_tag', 'my_custom_filter', 10, 4);

function my_custom_filter($tag, $handle, $href, $media) {
    // Your custom filtering logic here
    return $tag;
}

Source Code Context

wp-includes/class-wp-styles.php:272 - How this hook is used in WordPress core
<?php
 267  				$this->type_attr,
 268  				$media
 269  			);
 270  
 271  			/** This filter is documented in wp-includes/class-wp-styles.php */
 272  			$rtl_tag = apply_filters( 'style_loader_tag', $rtl_tag, $handle, $rtl_href, $media );
 273  
 274  			if ( 'replace' === $obj->extra['rtl'] ) {
 275  				$tag = $rtl_tag;
 276  			} else {
 277  				$tag .= $rtl_tag;

PHP Documentation

<?php
/**
		 * 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.
		 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/class-wp-styles.php
Related Hooks

Related hooks will be displayed here in future updates.