[ 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-path: inset(50%); 80 position: absolute; 81 } 82 <?php 83 // If the user has set a custom color for the text, use that. 84 elseif ( get_theme_support( 'custom-header', 'default-text-color' ) !== $text_color ) : 85 ?> 86 .site-title a { 87 color: #<?php echo esc_attr( $text_color ); ?>; 88 } 89 <?php endif; ?> 90 </style> 91 <?php 92 } 93 endif; // twentyfourteen_header_style() 94 95 96 if ( ! function_exists( 'twentyfourteen_admin_header_style' ) ) : 97 /** 98 * Style the header image displayed on the Appearance > Header screen. 99 * 100 * @see twentyfourteen_custom_header_setup() 101 * 102 * @since Twenty Fourteen 1.0 103 */ 104 function twentyfourteen_admin_header_style() { 105 ?> 106 <style type="text/css" id="twentyfourteen-admin-header-css"> 107 .appearance_page_custom-header #headimg { 108 background-color: #000; 109 border: none; 110 max-width: 1260px; 111 min-height: 48px; 112 } 113 #headimg h1 { 114 font-family: Lato, sans-serif; 115 font-size: 18px; 116 line-height: 48px; 117 margin: 0 0 0 30px; 118 } 119 .rtl #headimg h1 { 120 margin: 0 30px 0 0; 121 } 122 #headimg h1 a { 123 color: #fff; 124 text-decoration: none; 125 } 126 #headimg img { 127 vertical-align: middle; 128 } 129 </style> 130 <?php 131 } 132 endif; // twentyfourteen_admin_header_style() 133 134 if ( ! function_exists( 'twentyfourteen_admin_header_image' ) ) : 135 /** 136 * Create the custom header image markup displayed on the Appearance > Header screen. 137 * 138 * @see twentyfourteen_custom_header_setup() 139 * 140 * @since Twenty Fourteen 1.0 141 */ 142 function twentyfourteen_admin_header_image() { 143 ?> 144 <div id="headimg"> 145 <?php if ( get_header_image() ) : ?> 146 <img src="<?php header_image(); ?>" alt="" /> 147 <?php endif; ?> 148 <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> 149 </div> 150 <?php 151 } 152 endif; // twentyfourteen_admin_header_image() 153 154 155 if ( ! function_exists( 'twentyfourteen_header_image' ) ) : 156 /** 157 * Create the custom header image markup displayed. 158 * 159 * @see twentyfourteen_custom_header_setup() 160 * 161 * @since Twenty Fourteen 3.8 162 */ 163 function twentyfourteen_header_image() { 164 $custom_header = get_custom_header(); 165 $attrs = array( 166 'alt' => get_bloginfo( 'name', 'display' ), 167 'height' => $custom_header->height, 168 'width' => $custom_header->width, 169 ); 170 if ( function_exists( 'the_header_image_tag' ) ) { 171 the_header_image_tag( $attrs ); 172 return; 173 } 174 ?> 175 <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'] ); ?>" /> 176 <?php 177 } 178 endif; // twentyfourteen_header_image()
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated : Sat Feb 22 08:20:01 2025 | Cross-referenced by PHPXref |