Make WordPress Themes

source: mavix-resort/1.0/inc/custom-header.php

Last change on this file was 299114, checked in by themedropbox, 5 days ago

New theme: Mavix Resort - 1.0

File size: 2.2 KB
Line 
1<?php
2/**
3 * Sample implementation of the Custom Header feature
4 *
5 * You can add an optional custom header image to header.php like so ...
6 *
7        <?php the_header_image_tag(); ?>
8 *
9 * @link https://developer.wordpress.org/themes/functionality/custom-headers/
10 *
11 * @package Mavix Resort
12 */
13
14/**
15 * Set up the WordPress core custom header feature.
16 *
17 * @uses mavix_resort_header_style()
18 */
19function mavix_resort_custom_header_setup() {
20        add_theme_support( 'custom-header', apply_filters( 'mavix_resort_custom_header_args', array(
21                'default-image'          => '',
22                'default-text-color'     => '000000',
23                'width'                  => 1920,
24                'height'                 => 1080,
25                'flex-height'            => true,
26                'wp-head-callback'       => 'mavix_resort_header_style',
27        ) ) );
28
29        // Register default headers.
30        register_default_headers( array(
31                'default-banner' => array(
32                        'url'           => '%s/assets/images/default-header.jpg',
33                        'thumbnail_url' => '%s/assets/images/default-header.jpg',
34                        'description'   => esc_html_x( 'Default Banner', 'header image description', 'mavix-resort' ),
35                ),
36
37        ) );
38}
39add_action( 'after_setup_theme', 'mavix_resort_custom_header_setup' );
40
41function mavix_resort_header_style() {
42        $mavix_resort_header_text_color = get_header_textcolor();
43
44        /*
45         * If no custom options for text are set, let's bail.
46         * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: HEADER_TEXTCOLOR.
47         */
48        if ( get_theme_support( 'custom-header', 'default-text-color' ) === $mavix_resort_header_text_color ) {
49                return;
50        }
51
52        // If we get this far, we have custom styles. Let's do this.
53        // Has the text been hidden?
54        if ( ! display_header_text() ) :
55                $mavix_resort_custom_css = ".site-title,
56                .site-description {
57                        position: absolute;
58                        clip: rect(1px, 1px, 1px, 1px);
59                }";
60        // If the user has set a custom color for the text use that.
61        else :
62                $mavix_resort_custom_css = ".site-title a {
63                        color: #" . esc_attr( $mavix_resort_header_text_color ) . "}";
64        endif;
65        wp_add_inline_style( 'mavix-resort-style', $mavix_resort_custom_css );
66}
67add_action( 'wp_enqueue_scripts', 'mavix_resort_header_style' );
Note: See TracBrowser for help on using the repository browser.