[ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Implement Custom Header functionality for Twenty Fourteen 4 * 5 * @package WordPress 6 * @subpackage Twenty_Fourteen 7 * @since Twenty Fourteen 1.0 8 */ 9 10 /** 11 * Set up the WordPress core custom header settings. 12 * 13 * @since Twenty Fourteen 1.0 14 * 15 * @uses twentyfourteen_header_style() 16 * @uses twentyfourteen_admin_header_style() 17 * @uses twentyfourteen_admin_header_image() 18 */ 19 function twentyfourteen_custom_header_setup() { 20 add_theme_support( 21 'custom-header', 22 /** 23 * Filters Twenty Fourteen custom-header support arguments. 24 * 25 * @since Twenty Fourteen 1.0 26 * 27 * @param array $args { 28 * An array of custom-header support arguments. 29 * 30 * @type bool $header_text Whether to display custom header text. Default false. 31 * @type int $width Width in pixels of the custom header image. Default 1260. 32 * @type int $height Height in pixels of the custom header image. Default 240. 33 * @type bool $flex_height Whether to allow flexible-height header images. Default true. 34 * @type string $admin_head_callback Callback function used to style the image displayed in 35 * the Appearance > Header screen. 36 * @type string $admin_preview_callback Callback function used to create the custom header markup in 37 * the Appearance > Header screen. 38 * } 39 */ 40 apply_filters( 41 'twentyfourteen_custom_header_args', 42 array( 43 'default-text-color' => 'fff', 44 'width' => 1260, 45 'height' => 240, 46 'flex-height' => true, 47 'wp-head-callback' => 'twentyfourteen_header_style', 48 'admin-head-callback' => 'twentyfourteen_admin_header_style', 49 'admin-preview-callback' => 'twentyfourteen_admin_header_image', 50 ) 51 ) 52 ); 53 } 54 add_action( 'after_setup_theme', 'twentyfourteen_custom_header_setup' ); 55 56 if ( ! function_exists( 'twentyfourteen_header_style' ) ) : 57 /** 58 * Styles the header image and text displayed on the blog 59 * 60 * @see twentyfourteen_custom_header_setup(). 61 */ 62 function twentyfourteen_header_style() { 63 $text_color = get_header_textcolor(); 64 65 // If no custom color for text is set, let's bail. 66 if ( display_header_text() && get_theme_support( 'custom-header', 'default-text-color' ) === $text_color ) { 67 return; 68 } 69 70 // If we get this far, we have custom styles. 71 ?> 72 <style type="text/css" id="twentyfourteen-header-css"> 73 <?php 74 // Has the text been hidden? 75 if ( ! display_header_text() ) : 76 ?> 77 .site-title, 78 .site-description { 79 clip: rect(1px 1px 1px 1px); /* IE7 */ 80 clip: rect(1px, 1px, 1px, 1px); 81 position: absolute; 82 } 83 <?php 84 // If the user has set a custom color for the text, use that. 85 elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) : 86 ?> 87 .site-title a { 88 color: #<?php echo esc_attr( $text_color ); ?>; 89 } 90 <?php endif; ?> 91 </style> 92 <?php 93 } 94 endif; // twentyfourteen_header_style() 95 96 97 if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : 98 /** 99 * Style the header image displayed on the Appearance > Header screen. 100 * 101 * @see twentyfourteen_custom_header_setup() 102 * 103 * @since Twenty Fourteen 1.0 104 */ 105 function twentyfourteen_admin_header_style() { 106 ?> 107 <style type="text/css" id="twentyfourteen-admin-header-css"> 108 .appearance_page_custom-header #headimg { 109 background-color: #000; 110 border: none; 111 max-width: 1260px; 112 min-height: 48px; 113 } 114 #headimg h1 { 115 font-family: Lato, sans-serif; 116 font-size: 18px; 117 line-height: 48px; 118 margin: 0 0 0 30px; 119 } 120 .rtl #headimg h1 { 121 margin: 0 30px 0 0; 122 } 123 #headimg h1 a { 124 color: #fff; 125 text-decoration: none; 126 } 127 #headimg img { 128 vertical-align: middle; 129 } 130 </style> 131 <?php 132 } 133 endif; // twentyfourteen_admin_header_style() 134 135 if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : 136 /** 137 * Create the custom header image markup displayed on the Appearance > Header screen. 138 * 139 * @see twentyfourteen_custom_header_setup() 140 * 141 * @since Twenty Fourteen 1.0 142 */ 143 function twentyfourteen_admin_header_image() { 144 ?> 145 <div id="headimg"> 146 <?php if ( get_header_image() ) : ?> 147 <img src="<?php header_image(); ?>" alt="" /> 148 <?php endif; ?> 149 <h1 class="displaying-header-text"><a id="name" style="<?php echo esc_attr( sprintf( 'color: #%s;', get_header_textcolor() ) ); ?>" onclick="return false;" href="<?php echo esc_url( home_url( '/' ) ); ?>" tabindex="-1"><?php bloginfo( 'name' ); ?></a></h1> 150 </div> 151 <?php 152 } 153 endif; // twentyfourteen_admin_header_image() 154 155 156 if ( ! function_exists( 'twentyfourteen_header_image' ) ) : 157 /** 158 * Create the custom header image markup displayed. 159 * 160 * @see twentyfourteen_custom_header_setup() 161 * 162 * @since Twenty Fourteen 3.8 163 */ 164 function twentyfourteen_header_image() { 165 $custom_header = get_custom_header(); 166 $attrs = array( 167 'alt' => get_bloginfo( 'name', 'display' ), 168 'height' => $custom_header->height, 169 'width' => $custom_header->width, 170 ); 171 if ( function_exists( 'the_header_image_tag' ) ) { 172 the_header_image_tag( $attrs ); 173 return; 174 } 175 ?> 176 <img src="<?php header_image(); ?>" width="<?php echo esc_attr( $attrs['width'] ); ?>" height="<?php echo esc_attr( $attrs['height'] ); ?>" alt="<?php echo esc_attr( $attrs['alt'] ); ?>" /> 177 <?php 178 } 179 endif; // twentyfourteen_header_image()
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sun Dec 22 08:20:01 2024 | Cross-referenced by PHPXref |