wp_add_inline_style example


    public function editor_custom_color_variables() {
        if ( ! $this->switch_should_render() ) {
            return;
        }
        $background_color            = get_theme_mod( 'background_color', 'D1E4DD' );
        $should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', false );
        if ( $should_respect_color_scheme && Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) > 127 ) {
            // Add Dark Mode variable overrides.             wp_add_inline_style(
                'twenty-twenty-one-custom-color-overrides',
                '.is-dark-theme.is-dark-theme .editor-styles-wrapper { --global--color-background: var(--global--color-dark-gray); --global--color-primary: var(--global--color-light-gray); --global--color-secondary: var(--global--color-light-gray); --button--color-text: var(--global--color-background); --button--color-text-hover: var(--global--color-secondary); --button--color-text-active: var(--global--color-secondary); --button--color-background: var(--global--color-secondary); --button--color-background-active: var(--global--color-background); --global--color-border: #9ea1a7; --table--stripes-border-color: rgba(240, 240, 240, 0.15); --table--stripes-background-color: rgba(240, 240, 240, 0.15); }'
            );
        }
        wp_enqueue_script(
            'twentytwentyone-dark-mode-support-toggle',
            get_template_directory_uri() . '/assets/js/dark-mode-toggler.js',
            array(),
            '1.0.0',
            true
        );

        
/** * Appends the used global style duotone filter presets (CSS custom * properties) to the inline global styles CSS. * * Uses the declarations saved in earlier calls to self::enqueue_global_styles_preset. * * @since 6.3.0 */
    public static function output_global_styles() {
        if ( ! empty( self::$used_global_styles_presets ) ) {
            wp_add_inline_style( 'global-styles', self::get_global_styles_presets( self::$used_global_styles_presets ) );
        }
    }

    /** * Outputs all necessary SVG for duotone filters, CSS for classic themes. * * Uses the declarations saved in earlier calls to self::enqueue_global_styles_preset * and self::enqueue_custom_filter. * * @since 6.3.0 */
    

    add_filter( 'wp_theme_json_get_style_nodes', 'wp_filter_out_block_nodes' );

    $stylesheet = wp_get_global_stylesheet();

    if ( empty( $stylesheet ) ) {
        return;
    }

    wp_register_style( 'global-styles', false );
    wp_add_inline_style( 'global-styles', $stylesheet );
    wp_enqueue_style( 'global-styles' );

    // Add each block as an inline css.     wp_add_global_styles_for_blocks();
}

/** * Enqueues the global styles custom css defined via theme.json. * * @since 6.2.0 */
/** * Enqueues non-latin language styles. * * @since Twenty Twenty-One 1.0 * * @return void */
function twenty_twenty_one_non_latin_languages() {
    $custom_css = twenty_twenty_one_get_non_latin_css( 'front-end' );

    if ( $custom_css ) {
        wp_add_inline_style( 'twenty-twenty-one-style', $custom_css );
    }
}
add_action( 'wp_enqueue_scripts', 'twenty_twenty_one_non_latin_languages' );

// SVG Icons class. require get_template_directory() . '/classes/class-twenty-twenty-one-svg-icons.php';

// Custom color classes. require get_template_directory() . '/classes/class-twenty-twenty-one-custom-colors.php';
new Twenty_Twenty_One_Custom_Colors();



    /** * Customizer & frontend custom color variables. * * @since Twenty Twenty-One 1.0 * * @return void */
    public function custom_color_variables() {
        if ( 'd1e4dd' !== strtolower( get_theme_mod( 'background_color', 'D1E4DD' ) ) ) {
            wp_add_inline_style( 'twenty-twenty-one-style', $this->generate_custom_color_variables() );
        }
    }

    /** * Editor custom color variables. * * @since Twenty Twenty-One 1.0 * * @return void */
    public function editor_custom_color_variables() {
        

function wp_add_global_styles_for_blocks() {
    $tree        = WP_Theme_JSON_Resolver::get_merged_data();
    $block_nodes = $tree->get_styles_block_nodes();
    foreach ( $block_nodes as $metadata ) {
        $block_css = $tree->get_styles_for_block( $metadata );

        if ( ! wp_should_load_separate_core_block_assets() ) {
            wp_add_inline_style( 'global-styles', $block_css );
            continue;
        }

        $stylesheet_handle = 'global-styles';
        if ( isset( $metadata['name'] ) ) {
            /* * These block styles are added on block_render. * This hooks inline CSS to them so that they are loaded conditionally * based on whether or not the block is used on the page. */
            if ( str_starts_with( $metadata['name'], 'core/' ) ) {
                
Home | Imprint | This part of the site doesn't use cookies.