| 1 | | <?php |
| 2 | | /** |
| 3 | | * @package WordPress |
| 4 | | * @subpackage Twenty_Fourteen |
| 5 | | */ |
| 6 | | |
| 7 | | /** |
| 8 | | * Setup the WordPress core custom header feature. |
| 9 | | * |
| 10 | | * Use add_theme_support to register support for WordPress 3.4+ |
| 11 | | * as well as provide backward compatibility for previous versions. |
| 12 | | * Use feature detection of wp_get_theme() which was introduced |
| 13 | | * in WordPress 3.4. |
| 14 | | * |
| 15 | | * @todo Rework this function to remove WordPress 3.4 support when WordPress 3.6 is released. |
| 16 | | * |
| 17 | | * @uses twentyfourteen_header_style() |
| 18 | | * @uses twentyfourteen_admin_header_style() |
| 19 | | * @uses twentyfourteen_admin_header_image() |
| 20 | | * |
| 21 | | * @package WordPress |
| 22 | | * @subpackage Twenty_Fourteen |
| 23 | | */ |
| 24 | | function twentyfourteen_custom_header_setup() { |
| 25 | | add_theme_support( 'custom-header', apply_filters( 'twentyfourteen_custom_header_args', array( |
| 26 | | 'default-text-color' => 'fff', |
| 27 | | 'width' => 1260, |
| 28 | | 'height' => 240, |
| 29 | | 'flex-height' => true, |
| 30 | | 'wp-head-callback' => 'twentyfourteen_header_style', |
| 31 | | 'admin-head-callback' => 'twentyfourteen_admin_header_style', |
| 32 | | 'admin-preview-callback' => 'twentyfourteen_admin_header_image', |
| 33 | | ) ) ); |
| 34 | | |
| 35 | | } |
| 36 | | add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); |
| 37 | | |
| 38 | | if ( ! function_exists( 'twentyfourteen_header_style' ) ) : |
| 39 | | /** |
| 40 | | * Styles the header image and text displayed on the blog |
| 41 | | * |
| 42 | | * @see twentyfourteen_custom_header_setup(). |
| 43 | | * |
| 44 | | */ |
| 45 | | function twentyfourteen_header_style() { |
| 46 | | $header_text_color = get_header_textcolor(); |
| 47 | | |
| 48 | | // If no custom options for text are set, let's bail |
| 49 | | // $header_text_color options: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value |
| 50 | | if ( HEADER_TEXTCOLOR == $header_text_color ) |
| 51 | | return; |
| 52 | | // If we get this far, we have custom styles. Let's do this. |
| 53 | | ?> |
| 54 | | <style type="text/css"> |
| 55 | | <?php |
| 56 | | // Has the text been hidden? |
| 57 | | if ( 'blank' == $header_text_color ) : |
| 58 | | ?> |
| 59 | | .site-title { |
| 60 | | position: absolute !important; |
| 61 | | clip: rect(1px 1px 1px 1px); /* IE6, IE7 */ |
| 62 | | clip: rect(1px, 1px, 1px, 1px); |
| 63 | | } |
| 64 | | <?php |
| 65 | | // If the user has set a custom color for the text use that |
| 66 | | else : |
| 67 | | ?> |
| 68 | | .site-title a { |
| 69 | | color: #<?php echo $header_text_color; ?> !important; |
| 70 | | } |
| 71 | | <?php endif; ?> |
| 72 | | </style> |
| 73 | | <?php |
| 74 | | } |
| 75 | | endif; // twentyfourteen_header_style |
| 76 | | |
| 77 | | if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : |
| 78 | | /** |
| 79 | | * Styles the header image displayed on the Appearance > Header admin panel. |
| 80 | | * |
| 81 | | * @see twentyfourteen_custom_header_setup(). |
| 82 | | * |
| 83 | | */ |
| 84 | | function twentyfourteen_admin_header_style() { |
| 85 | | ?> |
| 86 | | <style type="text/css"> |
| 87 | | .appearance_page_custom-header #headimg { |
| 88 | | background-color: #000; |
| 89 | | border: none; |
| 90 | | max-width: 1230px; |
| 91 | | min-height: 48px; |
| 92 | | } |
| 93 | | #headimg h1 { |
| 94 | | font-family: lato, sans-serif; |
| 95 | | font-size: 18px; |
| 96 | | line-height: 1.3333333333; |
| 97 | | margin: 12px 0 12px 27px; |
| 98 | | } |
| 99 | | #headimg h1 a { |
| 100 | | color: #fff; |
| 101 | | text-decoration: none; |
| 102 | | } |
| 103 | | #headimg img { |
| 104 | | vertical-align: middle; |
| 105 | | } |
| 106 | | </style> |
| 107 | | <?php |
| 108 | | } |
| 109 | | endif; // twentyfourteen_admin_header_style |
| 110 | | |
| 111 | | if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : |
| 112 | | /** |
| 113 | | * Custom header image markup displayed on the Appearance > Header admin panel. |
| 114 | | * |
| 115 | | * @see twentyfourteen_custom_header_setup(). |
| 116 | | * |
| 117 | | */ |
| 118 | | function twentyfourteen_admin_header_image() { |
| 119 | | $header_image = get_header_image(); |
| 120 | | ?> |
| 121 | | <div id="headimg"> |
| 122 | | <?php if ( ! empty( $header_image ) ) : ?> |
| 123 | | <img src="<?php echo esc_url( $header_image ); ?>" alt=""> |
| 124 | | <?php endif; ?> |
| 125 | | <h1 class="displaying-header-text"><a id="name"<?php echo sprintf( ' style="color:#%s;"', get_header_textcolor() ); ?> onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php bloginfo( 'name' ); ?></a></h1> |
| 126 | | </div> |
| 127 | | <?php |
| 128 | | } |
| 129 | | endif; // twentyfourteen_admin_header_image |