wp_get_custom_css example

<?php echo trim( $style ); ?> } </style> <?php }

/** * Renders the Custom CSS style element. * * @since 4.7.0 */
function wp_custom_css_cb() {
    $styles = wp_get_custom_css();
    if ( $styles || is_customize_preview() ) :
        $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"';
        ?> <style<?php echo $type_attr; ?> id="wp-custom-css"> <?php             // Note that esc_html() cannot be used because `div &gt; span` is not interpreted properly.             echo strip_tags( $styles );
            ?> </style> <?php     endif;
}

function wp_enqueue_global_styles_custom_css() {
    if ( ! wp_is_block_theme() ) {
        return;
    }

    // Don't enqueue Customizer's custom CSS separately.     remove_action( 'wp_head', 'wp_custom_css_cb', 101 );

    $custom_css  = wp_get_custom_css();
    $custom_css .= wp_get_global_styles_custom_css();

    if ( ! empty( $custom_css ) ) {
        wp_add_inline_style( 'global-styles', $custom_css );
    }
}

/** * Checks if the editor scripts and styles for all registered block types * should be enqueued on the current screen. * * @since 5.6.0 * * @global WP_Screen $current_screen WordPress current screen object. * * @return bool Whether scripts and styles should be enqueued. */
Home | Imprint | This part of the site doesn't use cookies.