WordPress at a glance

wp_custom_css_cb() WP 4.7.0

Displays <style> tag containing CSS styles added in "Additional CSS" pane of the Theme Customizer.

Before displaying, the code of the styles is sanitized with the strip_tags() function.

To get these CSS styles without displaying them, use wp_get_custom_css().

This function is called by WordPress automatically on wp_head action and output current theme styles.

Works based on: wp_get_custom_css()

No Hooks.

Return

Nothing (null).

Usage

wp_custom_css_cb();

Examples

#1 Additional CSS styles from Theme Customizer (from settings)

The following code is used by default in WordPress to display styles in the HEAD part of the document:

add_action( 'wp_head', 'wp_custom_css_cb', 101 );

I.E. WordPress automatically adds Additional styles for any theme!

Code of wp custom css cb: wp-includes/theme.php WP 5.2.2

<?php
function wp_custom_css_cb() {
	$styles = wp_get_custom_css();
	if ( $styles || is_customize_preview() ) :
		?>
		<style type="text/css" id="wp-custom-css">
			<?php echo strip_tags( $styles ); // Note that esc_html() cannot be used because `div &gt; span` is not interpreted properly. ?>
		</style>
		<?php
	endif;
}

Related Functions

From category: Other Theme Functions

No comments
    Hello, !     Log In . Register