Completed
Branch dev (0b2b90)
by Eric
01:41
created

custom-header.php ➔ bitsy_custom_header_setup()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
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 bitsy
12
 */
13
14
/**
15
 * Set up the WordPress core custom header feature.
16
 *
17
 * @uses bitsy_header_style()
18
 */
19
function bitsy_custom_header_setup() {
20
	add_theme_support( 'custom-header', apply_filters( 'bitsy_custom_header_args', array(
21
		'default-image'          => '',
22
		'default-text-color'     => '000000',
23
		'width'                  => 1000,
24
		'height'                 => 250,
25
		'flex-height'            => true,
26
		'wp-head-callback'       => 'bitsy_header_style',
27
	) ) );
28
}
29
add_action( 'after_setup_theme', 'bitsy_custom_header_setup' );
30
31
if ( ! function_exists( 'bitsy_header_style' ) ) :
0 ignored issues
show
Coding Style introduced by
Please always use braces to surround the code block of IF statements.
Loading history...
32
/**
33
 * Styles the header image and text displayed on the blog.
34
 *
35
 * @see bitsy_custom_header_setup().
36
 */
37
function bitsy_header_style() {
38
	$header_text_color = get_header_textcolor();
39
40
		/*
41
		 * If no custom options for text are set, let's bail.
42
		 * get_header_textcolor() options: Any hex value, 'blank' to hide text. Default: add_theme_support( 'custom-header' ).
43
		 */
44
		if ( get_theme_support( 'custom-header', 'default-text-color' ) === $header_text_color ) {
45
			return;
46
		}
47
48
	// If we get this far, we have custom styles. Let's do this.
49
	?>
50
	<style type="text/css">
51
	<?php
52
		// Has the text been hidden?
53
		if ( ! display_header_text() ) :
0 ignored issues
show
Coding Style introduced by
Please always use braces to surround the code block of IF statements.
Loading history...
54
	?>
55
		.site-title,
56
		.site-description {
57
			position: absolute;
58
			clip: rect(1px, 1px, 1px, 1px);
59
		}
60
	<?php
61
		// If the user has set a custom color for the text use that.
62
		else :
0 ignored issues
show
Coding Style introduced by
Please always use braces to surround the code block of ELSE statements.
Loading history...
63
	?>
64
		.site-title a,
65
		.site-description {
66
			color: #<?php echo esc_attr( $header_text_color ); ?>;
67
		}
68
	<?php endif; ?>
69
	</style>
70
	<?php
71
}
72
endif;
73