WP_Styles::print_inline_style() WordPress Method

The WP_Styles::print_inline_style() method is used to print inline styles for a specific Wordpress stylesheet. This is useful for adding styles that are not present in the main stylesheet, or for overriding existing styles.

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

Prints extra CSS styles of a registered stylesheet.


Parameters

$handle

(string)(Required)The style's registered handle.

$display

(bool)(Optional) Whether to print the inline style instead of just returning it.

Default value: true


Top ↑

Return

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


Top ↑

Source

File: wp-includes/class.wp-styles.php

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

		if ( empty( $output ) ) {
			return false;
		}

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

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

		printf(
			"<style id='%s-inline-css'%s>\n%s\n</style>\n",
			esc_attr( $handle ),
			$this->type_attr,
			$output
		);

		return true;
	}


Top ↑

Changelog

Changelog
VersionDescription
3.3.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.