1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Custom Header implementation |
4
|
|
|
* |
5
|
|
|
* @link http://codex.wordpress.org/Custom_Headers |
6
|
|
|
* |
7
|
|
|
* @package WordPress |
8
|
|
|
* @subpackage strip |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Setup the WordPress core custom header feature. |
13
|
|
|
* |
14
|
|
|
* @uses strip_header_style() |
15
|
|
|
* @uses strip_admin_header_style() |
16
|
|
|
* @uses strip_admin_header_image() |
17
|
|
|
* |
18
|
|
|
* @package strip |
19
|
|
|
*/ |
20
|
|
|
function strip_custom_header_setup() { |
21
|
|
|
add_theme_support( 'custom-header', apply_filters( 'strip_custom_header_args', array( |
22
|
|
|
'default-image' => get_template_directory_uri() . '/assets/images/Default-header.png', |
23
|
|
|
'default-text-color' => '000', |
24
|
|
|
'flex-width' => true, |
25
|
|
|
'width' => 1920, |
26
|
|
|
'height' => 320, |
27
|
|
|
'flex-height' => true, |
28
|
|
|
'wp-head-callback' => 'strip_header_style', |
29
|
|
|
'admin-head-callback' => 'strip_admin_header_style', |
30
|
|
|
'admin-preview-callback' => 'strip_admin_header_image', |
31
|
|
|
) ) ); |
32
|
|
|
/** |
33
|
|
|
* Register default header image |
34
|
|
|
*/ |
35
|
|
|
register_default_headers( array( |
36
|
|
|
'DefaultHeader' => array( |
37
|
|
|
'url' => get_template_directory_uri() . '/assets/images/Default-header.png', |
38
|
|
|
'thumbnail_url' => get_template_directory_uri() . '/assets/images/Default-header.png', |
39
|
|
|
'description' => _x( 'DefaultHeader', 'header image description', 'strip' ), |
40
|
|
|
), |
41
|
|
|
) |
42
|
|
|
); |
43
|
|
|
|
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
add_action( 'after_setup_theme', 'strip_custom_header_setup' ); |
47
|
|
|
|
48
|
|
|
if ( ! function_exists( 'strip_header_style' ) ) : |
49
|
|
|
/** |
50
|
|
|
* Styles the header image and text displayed on the blog |
51
|
|
|
* |
52
|
|
|
* @see strip_custom_header_setup(). |
53
|
|
|
*/ |
54
|
|
|
function strip_header_style() { |
55
|
|
|
|
56
|
|
|
/* Header text color. */ |
57
|
|
|
$header_text_color = get_header_textcolor(); |
58
|
|
|
|
59
|
|
|
/* Header image. */ |
60
|
|
|
$header_image = esc_url( get_header_image() ); |
61
|
|
|
|
62
|
|
|
/* Start header styles. */ |
63
|
|
|
$style = ''; |
64
|
|
|
|
65
|
|
|
/* Header image height. */ |
66
|
|
|
$header_height = get_custom_header()->height; |
|
|
|
|
67
|
|
|
|
68
|
|
|
/* Header image width. */ |
69
|
|
|
$header_width = get_custom_header()->width; |
|
|
|
|
70
|
|
|
|
71
|
|
|
/* When to show header image. */ |
72
|
|
|
$min_width = absint( apply_filters( 'strip_header_bg_show', 1 ) ); |
73
|
|
|
|
74
|
|
|
/* Background arguments. */ |
75
|
|
|
$background_arguments = esc_attr( apply_filters( 'strip_header_bg_arguments', 'no-repeat 50% 50%' ) ); |
76
|
|
|
|
77
|
|
|
if ( ! empty( $header_image ) ) { |
78
|
|
|
$style .= "@media screen and (min-width: {$min_width}px) { body.custom-header-image .site-header { background: url({$header_image}) {$background_arguments}; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } }"; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/* Site title styles. */ |
82
|
|
|
if ( display_header_text() ) { |
83
|
|
|
$style .= ".site-title, .site-title a, .site-description, .site-description a { color: #{$header_text_color} }"; |
84
|
|
|
$style .= ".site-title { border-color: #{$header_text_color} }"; |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
if ( ! display_header_text() ) { |
88
|
|
|
$style .= '.site-title, .site-title a, .site-description, .site-description a { clip: rect(1px, 1px, 1px, 1px); position: absolute; }'; |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/* Echo styles if it's not empty. */ |
92
|
|
|
if ( ! empty( $style ) ) { |
93
|
|
|
echo "\n" . '<style type="text/css" id="custom-header-css">' . trim( $style ) . '</style>' . "\n"; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
} |
97
|
|
|
endif; // strip_header_style. |
98
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.