Completed
Push — master ( bf1080...d99bb1 )
by Md. Mozahidur
04:04
created

inc/custom-header.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 23 and the first side effect is on line 33.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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 if ( get_header_image() ) : ?>
8
	<a href="<?php echo esc_url( home_url( '/' ) ); ?>" rel="home">
9
		<img src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" height="<?php echo esc_attr( get_custom_header()->height ); ?>" alt="">
10
	</a>
11
	<?php endif; // End header image check. ?>
12
 *
13
 * @link https://developer.wordpress.org/themes/functionality/custom-headers/
14
 *
15
 * @package Lighthouse
16
 */
17
18
/**
19
 * Set up the WordPress core custom header feature.
20
 *
21
 * @uses lighthouse_header_style()
22
 */
23
function lighthouse_custom_header_setup() {
24
	add_theme_support( 'custom-header', apply_filters( 'lighthouse_custom_header_args', array(
25
		'default-image'          => '',
26
		'default-text-color'     => '000000',
27
		'width'                  => 1000,
28
		'height'                 => 250,
29
		'flex-height'            => true,
30
		'wp-head-callback'       => 'lighthouse_header_style',
31
	) ) );
32
}
33
add_action( 'after_setup_theme', 'lighthouse_custom_header_setup' );
34
35
if ( ! function_exists( 'lighthouse_header_style' ) ) :
36
/**
37
 * Styles the header image and text displayed on the blog.
38
 *
39
 * @see lighthouse_custom_header_setup().
40
 */
41
function lighthouse_header_style() {
42
	$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 ( HEADER_TEXTCOLOR === $header_text_color ) {
49
		return;
50
	}
51
52
	// If we get this far, we have custom styles. Let's do this.
53
	?>
54
	<style type="text/css">
55
	<?php
56
		// Has the text been hidden?
57
		if ( ! display_header_text() ) :
58
	?>
59
		.site-title,
60
		.site-description {
61
			position: absolute;
62
			clip: rect(1px, 1px, 1px, 1px);
63
		}
64
	<?php
65
		// If the user has set a custom color for the text use that.
66
		else :
67
	?>
68
		.site-title a,
69
		.site-description {
70
			color: #<?php echo esc_attr( $header_text_color ); ?>;
71
		}
72
	<?php endif; ?>
73
	</style>
74
	<?php
75
}
76
endif;
77