Skip to content

Commit

Permalink
TwentyFourteen Site Logo Support
Browse files Browse the repository at this point in the history
  • Loading branch information
bschneidewind committed Feb 15, 2025
1 parent 39f8ea3 commit 26bbd1b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/wp-content/themes/twentyfourteen/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ function twentyfourteen_setup() {
// Add RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );

// Enable support for custom logo.
add_theme_support(
'custom-logo',
array(
'height' => 40,
'width' => 164,
'flex-width' => true,
)
);

// Enable support for Post Thumbnails, and declare two sizes.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 672, 372, true );
Expand Down
3 changes: 3 additions & 0 deletions src/wp-content/themes/twentyfourteen/header.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@

<header id="masthead" class="site-header">
<div class="header-main">
<?php if ( has_custom_logo() ) : ?>
<div id="site-logo"><?php echo get_custom_logo(); ?></div>
<?php endif; ?>
<h1 class="site-title"><a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home"><?php bloginfo( 'name' ); ?></a></h1>

<div class="search-toggle">
Expand Down
16 changes: 16 additions & 0 deletions src/wp-content/themes/twentyfourteen/inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ function twentyfourteen_customize_register( $wp_customize ) {
'render_callback' => 'twentyfourteen_customize_partial_blogdescription',
)
);
$wp_customize->selective_refresh->add_partial(
'custom_logo',
array(
'selector' => '#site-logo',
'render_callback' => 'twentyfourteen_customize_partial_site_logo',
'container_inclusive' => false,
)
);
}

// Rename the label to "Site Title Color" because this only affects the site title in this theme.
Expand Down Expand Up @@ -120,6 +128,14 @@ function twentyfourteen_customize_partial_blogdescription() {
bloginfo( 'description' );
}

/**
* Render the site logo for the selective refresh partial.
*
* Doing it this way so we don't have issues with `render_callback`'s arguments.
*/
function twentyfourteen_customize_partial_site_logo() {
echo get_custom_logo();
}
/**
* Sanitize the Featured Content layout value.
*
Expand Down
12 changes: 11 additions & 1 deletion src/wp-content/themes/twentyfourteen/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,17 @@ span + .edit-link:before,
min-height: 48px;
padding: 0 10px;
}

#site-logo {
float: left;
margin: 4px 30px 0 0;
text-align: left;
}
#site-logo + .site-title {
clear: none;
}
#site-logo + .site-title + .site-description {
clear: none;
}
.site-title {
float: left;
font-size: 18px;
Expand Down

0 comments on commit 26bbd1b

Please sign in to comment.