~canonical-sysadmins/wordpress/5.1

« back to all changes in this revision

Viewing changes to wp-content/themes/twentyseventeen/inc/custom-header.php

  • Committer: Barry Price
  • Date: 2019-02-22 03:51:26 UTC
  • mfrom: (1.2.12 upstream)
  • Revision ID: barry.price@canonical.com-20190222035126-o28k38qs8jfyjsxt
Merge WP5.1 from upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
         * @param array $args {
25
25
         *     An array of custom-header support arguments.
26
26
         *
27
 
         *     @type string $default-image              Default image of the header.
28
 
         *     @type string $default_text_color     Default color of the header text.
 
27
         *     @type string $default-image          Default image of the header.
29
28
         *     @type int    $width                  Width in pixels of the custom header image. Default 954.
30
29
         *     @type int    $height                 Height in pixels of the custom header image. Default 1300.
 
30
         *     @type string $flex-height            Flex support for height of header.
 
31
         *     @type string $video                  Video support for header.
31
32
         *     @type string $wp-head-callback       Callback function used to styles the header image and text
32
33
         *                                          displayed on the blog.
33
 
         *     @type string $flex-height                Flex support for height of header.
34
34
         * }
35
35
         */
36
 
        add_theme_support( 'custom-header', apply_filters( 'twentyseventeen_custom_header_args', array(
37
 
                'default-image'      => get_parent_theme_file_uri( '/assets/images/header.jpg' ),
38
 
                'width'              => 2000,
39
 
                'height'             => 1200,
40
 
                'flex-height'        => true,
41
 
                'video'              => true,
42
 
                'wp-head-callback'   => 'twentyseventeen_header_style',
43
 
        ) ) );
 
36
        add_theme_support(
 
37
                'custom-header',
 
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
        );
44
50
 
45
 
        register_default_headers( array(
46
 
                'default-image' => array(
47
 
                        'url'           => '%s/assets/images/header.jpg',
48
 
                        'thumbnail_url' => '%s/assets/images/header.jpg',
49
 
                        'description'   => __( 'Default Header Image', 'twentyseventeen' ),
50
 
                ),
51
 
        ) );
 
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
        );
52
60
}
53
61
add_action( 'after_setup_theme', 'twentyseventeen_custom_header_setup' );
54
62
 
55
63
if ( ! function_exists( 'twentyseventeen_header_style' ) ) :
56
 
/**
57
 
 * Styles the header image and text displayed on the blog.
58
 
 *
59
 
 * @see twentyseventeen_custom_header_setup().
60
 
 */
61
 
function twentyseventeen_header_style() {
62
 
        $header_text_color = get_header_textcolor();
63
 
 
64
 
        // If no custom options for text are set, let's bail.
65
 
        // get_header_textcolor() options: add_theme_support( 'custom-header' ) is default, hide text (returns 'blank') or any hex value.
66
 
        if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
67
 
                return;
68
 
        }
69
 
 
70
 
        // If we get this far, we have custom styles. Let's do this.
71
 
        ?>
72
 
        <style id="twentyseventeen-custom-header-styles" type="text/css">
73
 
        <?php
 
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
74
82
                // Has the text been hidden?
75
83
                if ( 'blank' === $header_text_color ) :
76
 
        ?>
 
84
                        ?>
77
85
                .site-title,
78
86
                .site-description {
79
87
                        position: absolute;
80
88
                        clip: rect(1px, 1px, 1px, 1px);
81
89
                }
82
 
        <?php
83
 
                // If the user has set a custom color for the text use that.
 
90
                        <?php
 
91
                        // If the user has set a custom color for the text use that.
84
92
                else :
85
 
        ?>
 
93
                        ?>
86
94
                .site-title a,
87
95
                .colors-dark .site-title a,
88
96
                .colors-custom .site-title a,
105
113
                }
106
114
        <?php endif; ?>
107
115
        </style>
108
 
        <?php
109
 
}
 
116
                <?php
 
117
        }
110
118
endif; // End of twentyseventeen_header_style.
111
119
 
112
120
/**
116
124
 * @return array The filtered video settings.
117
125
 */
118
126
function twentyseventeen_video_controls( $settings ) {
119
 
        $settings['l10n']['play'] = '<span class="screen-reader-text">' . __( 'Play background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'play' ) );
 
127
        $settings['l10n']['play']  = '<span class="screen-reader-text">' . __( 'Play background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'play' ) );
120
128
        $settings['l10n']['pause'] = '<span class="screen-reader-text">' . __( 'Pause background video', 'twentyseventeen' ) . '</span>' . twentyseventeen_get_svg( array( 'icon' => 'pause' ) );
121
129
        return $settings;
122
130
}