Skip to content

Instantly share code, notes, and snippets.

@senlin
Last active Dec 21, 2015
Embed
What would you like to do?
child2013 inc/custom-header.php, child2013 functions.php and child2013 style.css - see WP TIPS http://wpti.ps/?p=347
<?php
/**
* Implements a custom header for Child2013.
* See http://codex.wordpress.org/Custom_Headers
*
* @package WordPress
* @subpackage Twenty_Thirteen
* @since Twenty Thirteen 1.0
*/
function child2013_custom_header_setup() {
$args = array(
// Text color and image (empty to use none).
'default-text-color' => '220e10',
'default-image' => '%s/images/headers/circle.png',
// Set height and width, with a maximum value for the width.
'height' => 230,
'width' => 1600,
// Callbacks for styling the header and the admin preview.
'wp-head-callback' => 'child2013_header_style',
);
add_theme_support( 'custom-header', $args );
/*
* Default custom headers packaged with the theme.
* %s is a placeholder for the theme template directory URI.
*/
register_default_headers( array(
'circle' => array(
'url' => '%s/images/headers/circle.png',
'thumbnail_url' => '%s/images/headers/circle-thumbnail.png',
'description' => _x( 'Circle', 'header image description', 'twentythirteen' )
),
'diamond' => array(
'url' => '%s/images/headers/diamond.png',
'thumbnail_url' => '%s/images/headers/diamond-thumbnail.png',
'description' => _x( 'Diamond', 'header image description', 'twentythirteen' )
),
'star' => array(
'url' => '%s/images/headers/star.png',
'thumbnail_url' => '%s/images/headers/star-thumbnail.png',
'description' => _x( 'Star', 'header image description', 'twentythirteen' )
),
) );
}
add_action( 'after_setup_theme', 'child2013_custom_header_setup', 1 );
function child2013_header_style() {
$header_image = get_header_image();
$text_color = get_header_textcolor();
// If no custom options for text are set, let's bail.
if ( empty( $header_image ) && $text_color == get_theme_support( 'custom-header', 'default-text-color' ) )
return;
// If we get this far, we have custom styles.
?>
<style type="text/css" id="child2013-header-css">
<?php
if ( ! empty( $header_image ) ) :
?>
.site-header {
background: url(<?php header_image(); ?>) no-repeat scroll top;
background-size: 1600px auto;
}
@media (max-width: 767px) {
.site-header {
background-size: 768px auto;
}
}
@media (max-width: 359px) {
.site-header {
background-size: 360px auto;
}
}
<?php
endif;
// Has the text been hidden?
if ( ! display_header_text() ) :
?>
.site-title,
.site-description {
position: absolute;
clip: rect(1px 1px 1px 1px); /* IE7 */
clip: rect(1px, 1px, 1px, 1px);
}
<?php
if ( empty( $header_image ) ) :
?>
.site-header .home-link {
min-height: 0;
}
<?php
endif;
// If the user has set a custom color for the text, use that.
elseif ( $text_color != get_theme_support( 'custom-header', 'default-text-color' ) ) :
?>
.site-title,
.site-description {
color: #<?php echo esc_attr( $text_color ); ?>;
}
<?php endif; ?>
</style>
<?php
}
<?php
/**
* Adds support for a custom header image.
*/
require get_stylesheet_directory() . '/inc/custom-header.php';
/*
Theme Name: Child2013
Theme URI: http://wp36.local
Description: Child theme for the Twenty Thirteen theme
Author: Piet Bos
Author URI: http://senlinonline.com/
Template: twentythirteen
Version: 0.1.0
*/
@import url("../twentythirteen/style.css");
@media (max-width: 767px) {
.site-header .home-link {
min-height: 0;
}
.site-title {
font-size: 36px;
padding: 8px 0 10px;
}
.site-description {
font-size: 22px;
}
}
@media (max-width: 359px) {
.site-title {
font-weight: normal;
}
.site-description {
clip: rect(1px, 1px, 1px, 1px);
position: absolute;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment