[ Index ] |
PHP Cross Reference of WordPress |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Custom header implementation 4 * 5 * @link https://codex.wordpress.org/Custom_Headers 6 * 7 * @package WordPress 8 * @subpackage Twenty_Seventeen 9 * @since Twenty Seventeen 1.0 10 */ 11 12 /** 13 * Set up the WordPress core custom header feature. 14 * 15 * @uses twentyseventeen_header_style() 16 */ 17 function twentyseventeen_custom_header_setup() { 18 19 add_theme_support( 20 'custom-header', 21 /** 22 * Filters Twenty Seventeen custom-header support arguments. 23 * 24 * @since Twenty Seventeen 1.0 25 * 26 * @param array $args { 27 * An array of custom-header support arguments. 28 * 29 * @type string $default-image Default image of the header. 30 * @type int $width Width in pixels of the custom header image. Default 954. 31 * @type int $height Height in pixels of the custom header image. Default 1300. 32 * @type string $flex-height Flex support for height of header. 33 * @type string $video Video support for header. 34 * @type string $wp-head-callback Callback function used to styles the header image and text 35 * displayed on the blog. 36 * } 37 */ 38 apply_filters( 39 'twentyseventeen_custom_header_args', 40 array( 41 'default-image' => get_parent_theme_file_uri( '/assets/images/header.jpg' ), 42 'width' => 2000, 43 'height' => 1200, 44 'flex-height' => true, 45 'video' => true, 46 'wp-head-callback' => 'twentyseventeen_header_style', 47 ) 48 ) 49 ); 50 51 register_default_headers( 52 array( 53 'default-image' => array( 54 'url' => '%s/assets/images/header.jpg', 55 'thumbnail_url' => '%s/assets/images/header.jpg', 56 'description' => __( 'Default Header Image', 'twentyseventeen' ), 57 ), 58 ) 59 ); 60 } 61 add_action( 'after_setup_theme', 'twentyseventeen_custom_header_setup' ); 62 63 if ( ! function_exists( 'twentyseventeen_header_style' ) ) : 64 /** 65 * Styles the header image and text displayed on the blog. 66 * 67 * @see twentyseventeen_custom_header_setup(). 68 */ 69 function twentyseventeen_header_style() { 70 $header_text_color = get_header_textcolor(); 71 72 // If no custom options for text are set, let's bail. 73 // get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value. 74 if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) { 75 return; 76 } 77 78 // If we get this far, we have custom styles. Let's do this. 79 ?> 80 <style id="twentyseventeen-custom-header-styles" type="text/css"> 81 <?php 82 // Has the text been hidden? 83 if ( 'blank' === $header_text_color ) : 84 ?> 85 .site-title, 86 .site-description { 87 position: absolute; 88 clip: rect(1px, 1px, 1px, 1px); 89 } 90 <?php 91 // If the user has set a custom color for the text use that. 92 else : 93 ?> 94 .site-title a, 95 .colors-dark .site-title a, 96 .colors-custom .site-title a, 97 body.has-header-image .site-title a, 98 body.has-header-video .site-title a, 99 body.has-header-image.colors-dark .site-title a, 100 body.has-header-video.colors-dark .site-title a, 101 body.has-header-image.colors-custom .site-title a, 102 body.has-header-video.colors-custom .site-title a, 103 .site-description, 104 .colors-dark .site-description, 105 .colors-custom .site-description, 106 body.has-header-image .site-description, 107 body.has-header-video .site-description, 108 body.has-header-image.colors-dark .site-description, 109 body.has-header-video.colors-dark .site-description, 110 body.has-header-image.colors-custom .site-description, 111 body.has-header-video.colors-custom .site-description { 112 color: #<?php echo esc_attr( $header_text_color ); ?>; 113 } 114 <?php endif; ?> 115 </style> 116 <?php 117 } 118 endif; // End of twentyseventeen_header_style(). 119 120 /** 121 * Customize video play/pause button in the custom header. 122 * 123 * @param array $settings Video settings. 124 * @return array The filtered video settings. 125 */ 126 function twentyseventeen_video_controls( $settings ) { 127 $settings['l10n']['play'] = '<span class="screen-reader-text">' . __( 'Play background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'play' ) ); 128 $settings['l10n']['pause'] = '<span class="screen-reader-text">' . __( 'Pause background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'pause' ) ); 129 return $settings; 130 } 131 add_filter( 'header_video_settings', 'twentyseventeen_video_controls' );
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Dec 3 01:00:02 2024 | Cross-referenced by PHPXref 0.7.1 |