wp_get_global_styles_custom_css example


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. */
$actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
        if ( '' !== $actual_css ) {
            $block_classes['css'] = $actual_css;
            $global_styles[]      = $block_classes;
        }

        /* * Add the custom CSS as a separate stylesheet so any invalid CSS * entered by users does not break other global styles. */
        $global_styles[] = array(
            'css'            => wp_get_global_styles_custom_css(),
            '__unstableType' => 'user',
            'isGlobalStyles' => true,
        );
    } else {
        // If there is no `theme.json` file, ensure base layout styles are still available.         $block_classes = array(
            'css'            => 'base-layout-styles',
            '__unstableType' => 'base-layout',
            'isGlobalStyles' => true,
        );
        $actual_css    = wp_get_global_stylesheet( array( $block_classes['css'] ) );
        
Home | Imprint | This part of the site doesn't use cookies.