Title: WP_Styles::print_inline_style
Published: April 25, 2014
Last modified: May 20, 2026

---

# WP_Styles::print_inline_style( string $handle, bool $display = true ): string|bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?output_format=md#wp--skip-link--target)

Prints extra CSS styles of a registered stylesheet.

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

 `$handle`stringrequired

The style’s registered handle.

`$display`booloptional

Whether to print the inline style instead of just returning it.

Default:`true`

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

 string|bool False if no data exists, inline styles if `$display` is true, true 
otherwise.

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

    ```php
    public function print_inline_style( $handle, $display = true ) {
    	$output = $this->get_data( $handle, 'after' );

    	if ( empty( $output ) || ! is_array( $output ) ) {
    		return false;
    	}

    	if ( ! $this->do_concat ) {

    		// Obtain the original `src` for a stylesheet possibly inlined by wp_maybe_inline_styles().
    		$inlined_src = $this->get_data( $handle, 'inlined_src' );

    		// If there's only one `after` inline style, and that inline style had been inlined, then use the $inlined_src
    		// as the sourceURL. Otherwise, if there is more than one inline `after` style associated with the handle,
    		// then resort to using the handle to construct the sourceURL since there isn't a single source.
    		if ( count( $output ) === 1 && is_string( $inlined_src ) && strlen( $inlined_src ) > 0 ) {
    			$source_url = esc_url_raw( $inlined_src );
    		} else {
    			$source_url = rawurlencode( "{$handle}-inline-css" );
    		}

    		$output[] = sprintf(
    			'/*# sourceURL=%s */',
    			$source_url
    		);
    	}

    	$output = implode( "\n", $output );

    	if ( ! $display ) {
    		return $output;
    	}

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

    	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.0/src/wp-includes/class-wp-styles.php#L302)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-styles.php#L302-L342)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_styles/print_inline_style/?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.

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

Sanitizes a URL for database or redirect usage.

  |

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

Processes a style dependency.

  |

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

| Version | Description | 
| [3.3.0](https://developer.wordpress.org/reference/since/3.3.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%2Fprint_inline_style%2F)
before being able to contribute a note or feedback.