get_theme_mod example

echo '</div>';
        }

        echo '<div class="available-headers">';

        foreach ( $headers as $header_key => $header ) {
            $header_thumbnail = $header['thumbnail_url'];
            $header_url       = $header['url'];
            $header_alt_text  = empty( $header['alt_text'] ) ? '' : $header['alt_text'];

            echo '<div class="default-header">';
            echo '<label><input name="default-header" type="radio" value="' . esc_attr( $header_key ) . '" ' . checked( $header_urlget_theme_mod( 'header_image' ), false ) . ' />';
            $width = '';
            if ( ! empty( $header['attachment_id'] ) ) {
                $width = ' width="230"';
            }
            echo '<img src="' . esc_url( set_url_scheme( $header_thumbnail ) ) . '" alt="' . esc_attr( $header_alt_text ) . '"' . $width . ' /></label>';
            echo '</div>';
        }

        echo '<div class="clear"></div></div>';
    }

    
if ( is_array( $_sidebars_widgets ) ) {
        set_theme_mod(
            'sidebars_widgets',
            array(
                'time' => time(),
                'data' => $_sidebars_widgets,
            )
        );
    }

    $nav_menu_locations = get_theme_mod( 'nav_menu_locations' );
    update_option( 'theme_switch_menu_locations', $nav_menu_locations );

    if ( func_num_args() > 1 ) {
        $stylesheet = func_get_arg( 1 );
    }

    $old_theme = wp_get_theme();
    $new_theme = wp_get_theme( $stylesheet );
    $template  = $new_theme->get_template();

    if ( wp_is_recovery_mode() ) {
        
        if ( $this->admin_image_div_callback ) {
            call_user_func( $this->admin_image_div_callback );
        } else {
            $background_styles = '';
            $bgcolor           = get_background_color();
            if ( $bgcolor ) {
                $background_styles .= 'background-color: #' . $bgcolor . ';';
            }

            $background_image_thumb = get_background_image();
            if ( $background_image_thumb ) {
                $background_image_thumb = esc_url( set_url_scheme( get_theme_mod( 'background_image_thumb', str_replace( '%', '%%', $background_image_thumb ) ) ) );
                $background_position_x  = get_theme_mod( 'background_position_x', get_theme_support( 'custom-background', 'default-position-x' ) );
                $background_position_y  = get_theme_mod( 'background_position_y', get_theme_support( 'custom-background', 'default-position-y' ) );
                $background_size        = get_theme_mod( 'background_size', get_theme_support( 'custom-background', 'default-size' ) );
                $background_repeat      = get_theme_mod( 'background_repeat', get_theme_support( 'custom-background', 'default-repeat' ) );
                $background_attachment  = get_theme_mod( 'background_attachment', get_theme_support( 'custom-background', 'default-attachment' ) );

                // Background-image URL must be single quote, see below.                 $background_styles .= " background-image: url('$background_image_thumb');"
                . " background-size: $background_size;"
                . " background-position: $background_position_x $background_position_y;"
                . " background-repeat: $background_repeat;"
                .
<?php /** * Displays the site header. * * @package WordPress * @subpackage Twenty_Twenty_One * @since Twenty Twenty-One 1.0 */

$wrapper_classes  = 'site-header';
$wrapper_classes .= has_custom_logo() ? ' has-logo' : '';
$wrapper_classes .= ( true === get_theme_mod( 'display_title_and_tagline', true ) ) ? ' has-title-and-tagline' : '';
$wrapper_classes .= has_nav_menu( 'primary' ) ? ' has-menu' : '';
?> <header id="masthead" class="<?php echo esc_attr( $wrapper_classes ); ?>"> <?php get_template_part( 'template-parts/header/site-branding' ); ?> <?php get_template_part( 'template-parts/header/site-nav' ); ?> </header><!-- #masthead -->
<?php /** * Displays header site branding * * @package WordPress * @subpackage Twenty_Twenty_One * @since Twenty Twenty-One 1.0 */

$blog_info    = get_bloginfo( 'name' );
$description  = get_bloginfo( 'description', 'display' );
$show_title   = ( true === get_theme_mod( 'display_title_and_tagline', true ) );
$header_class = $show_title ? 'site-title' : 'screen-reader-text';

?> <?php if ( has_custom_logo() && $show_title ) : ?> <div class="site-logo"><?php the_custom_logo(); ?></div> <?php endif; ?> <div class="site-branding"> <?php if ( has_custom_logo() && ! $show_title ) : ?>

    public function generate_custom_color_variables( $context = null ) {

        $theme_css        = 'editor' === $context ? ':root .editor-styles-wrapper{' : ':root{';
        $background_color = get_theme_mod( 'background_color', 'D1E4DD' );

        if ( 'd1e4dd' !== strtolower( $background_color ) ) {
            $theme_css .= '--global--color-background: #' . $background_color . ';';
            $theme_css .= '--global--color-primary: ' . $this->custom_get_readable_color( $background_color ) . ';';
            $theme_css .= '--global--color-secondary: ' . $this->custom_get_readable_color( $background_color ) . ';';
            $theme_css .= '--button--color-background: ' . $this->custom_get_readable_color( $background_color ) . ';';
            $theme_css .= '--button--color-text-hover: ' . $this->custom_get_readable_color( $background_color ) . ';';

            if ( '#fff' === $this->custom_get_readable_color( $background_color ) ) {
                $theme_css .= '--table--stripes-border-color: rgba(240, 240, 240, 0.15);';
                $theme_css .= '--table--stripes-background-color: rgba(240, 240, 240, 0.15);';
            }
<?php single_post_title(); ?></h1> </header><!-- .page-header --> <?php endif; ?> <?php if ( have_posts() ) {

    // Load posts loop.     while ( have_posts() ) {
        the_post();

        get_template_part( 'template-parts/content/content', get_theme_mod( 'display_excerpt_or_full_post', 'excerpt' ) );
    }

    // Previous/next page navigation.     twenty_twenty_one_the_posts_navigation();

} else {

    // If no content, include the "No posts found" template.     get_template_part( 'template-parts/content/content-none' );

}


function has_custom_logo( $blog_id = 0 ) {
    $switched_blog = false;

    if ( is_multisite() && ! empty( $blog_id ) && get_current_blog_id() !== (int) $blog_id ) {
        switch_to_blog( $blog_id );
        $switched_blog = true;
    }

    $custom_logo_id = get_theme_mod( 'custom_logo' );

    if ( $switched_blog ) {
        restore_current_blog();
    }

    return (bool) $custom_logo_id;
}

/** * Returns a custom logo, linked to home unless the theme supports removing the link on the home page. * * @since 4.5.0 * @since 5.5.0 Added option to remove the link on the home page with `unlink-homepage-logo` theme support * for the `custom-logo` theme feature. * @since 5.5.1 Disabled lazy-loading by default. * * @param int $blog_id Optional. ID of the blog in question. Default is the ID of the current blog. * @return string Custom logo markup. */
$background_image = get_background_image();
            if ( $background_image && wp_get_attachment_url( $post->ID ) === $background_image ) {
                $media_states[] = __( 'Current Background Image' );
            }
        }
    }

    if ( (int) get_option( 'site_icon' ) === $post->ID ) {
        $media_states[] = __( 'Site Icon' );
    }

    if ( (int) get_theme_mod( 'custom_logo' ) === $post->ID ) {
        $media_states[] = __( 'Logo' );
    }

    /** * Filters the default media display states for items in the Media list table. * * @since 3.2.0 * @since 4.8.0 Added the `$post` parameter. * * @param string[] $media_states An array of media states. Default 'Header Image', * 'Background Image', 'Site Icon', 'Logo'. * @param WP_Post $post The current attachment object. */
/** * Enqueues editor custom color variables & scripts. * * @since Twenty Twenty-One 1.0 * * @return void */
    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',
            

function retrieve_widgets( $theme_changed = false ) {
    global $wp_registered_sidebars$sidebars_widgets$wp_registered_widgets;

    $registered_sidebars_keys = array_keys( $wp_registered_sidebars );
    $registered_widgets_ids   = array_keys( $wp_registered_widgets );

    if ( ! is_array( get_theme_mod( 'sidebars_widgets' ) ) ) {
        if ( empty( $sidebars_widgets ) ) {
            return array();
        }

        unset( $sidebars_widgets['array_version'] );

        $sidebars_widgets_keys = array_keys( $sidebars_widgets );
        sort( $sidebars_widgets_keys );
        sort( $registered_sidebars_keys );

        if ( $sidebars_widgets_keys === $registered_sidebars_keys ) {
            

    protected function get_root_value( $default_value = null ) {
        $id_base = $this->id_data['base'];
        if ( 'option' === $this->type ) {
            return get_option( $id_base$default_value );
        } elseif ( 'theme_mod' === $this->type ) {
            return get_theme_mod( $id_base$default_value );
        } else {
            /* * Any WP_Customize_Setting subclass implementing aggregate multidimensional * will need to override this method to obtain the data from the appropriate * location. */
            return $default_value;
        }
    }

    /** * Set the root value for a setting, especially for multidimensional ones. * * @since 4.4.0 * * @param mixed $value Value to set as root of multidimensional setting. * @return bool Whether the multidimensional root was updated successfully. */


/** * Retrieves all registered navigation menu locations and the menus assigned to them. * * @since 3.0.0 * * @return int[] Associative array of registered navigation menu IDs keyed by their * location name. If none are registered, an empty array. */
function get_nav_menu_locations() {
    $locations = get_theme_mod( 'nav_menu_locations' );
    return ( is_array( $locations ) ) ? $locations : array();
}

/** * Determines whether a registered nav menu location has a menu assigned to it. * * @since 3.0.0 * * @param string $location Menu location identifier. * @return bool Whether location has a menu. */
<?php if ( have_posts() ) : ?> <header class="page-header alignwide"> <?php the_archive_title( '<h1 class="page-title">', '</h1>' ); ?> <?php if ( $description ) : ?> <div class="archive-description"><?php echo wp_kses_post( wpautop( $description ) ); ?></div> <?php endif; ?> </header><!-- .page-header --> <?php while ( have_posts() ) : ?> <?php the_post(); ?> <?php get_template_part( 'template-parts/content/content', get_theme_mod( 'display_excerpt_or_full_post', 'excerpt' ) ); ?> <?php endwhile; ?> <?php twenty_twenty_one_the_posts_navigation(); ?> <?php else : ?> <?php get_template_part( 'template-parts/content/content-none' ); ?> <?php endif; ?> <?php get_footer();

                    );
                    ?> </ul><!-- .footer-navigation-wrapper --> </nav><!-- .footer-navigation --> <?php endif; ?> <div class="site-info"> <div class="site-name"> <?php if ( has_custom_logo() ) : ?> <div class="site-logo"><?php the_custom_logo(); ?></div> <?php else : ?> <?php if ( get_bloginfo( 'name' ) && get_theme_mod( 'display_title_and_tagline', true ) ) : ?> <?php if ( is_front_page() && ! is_paged() ) : ?> <?php bloginfo( 'name' ); ?> <?php else : ?> <a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a> <?php endif; ?> <?php endif; ?> <?php endif; ?> </div><!-- .site-name --> <?php             if ( function_exists( 'the_privacy_policy_link' ) ) {
                
Home | Imprint | This part of the site doesn't use cookies.