Passed
Push — master ( 95836d...7727ff )
by SILENT
02:05
created

strip_entry_meta()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 18
nc 8
nop 0
dl 0
loc 25
rs 8.439
c 1
b 0
f 0
1
<?php
2
/**
3
 * Custom template tags for this theme
4
 *
5
 * Eventually, some of the functionality here could be replaced by core features.
6
 *
7
 * @package WordPress
8
 * @subpackage Strip
9
 */
10
11
/**
12
 * Add custom header image to header area
13
 */
14
function strip_header_background() {
15
	if ( get_header_image() ) {
0 ignored issues
show
Bug introduced by
The function get_header_image was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

15
	if ( /** @scrutinizer ignore-call */ get_header_image() ) {
Loading history...
16
		$css = '.site-branding { background-image: url(' . esc_url( get_header_image() ) . '); }';
0 ignored issues
show
Bug introduced by
The function esc_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
		$css = '.site-branding { background-image: url(' . /** @scrutinizer ignore-call */ esc_url( get_header_image() ) . '); }';
Loading history...
17
		wp_add_inline_style( 'strip-style', $css );
0 ignored issues
show
Bug introduced by
The function wp_add_inline_style was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
		/** @scrutinizer ignore-call */ 
18
  wp_add_inline_style( 'strip-style', $css );
Loading history...
18
	}
19
}
20
add_action( 'wp_enqueue_scripts', 'strip_header_background', 11 );
0 ignored issues
show
Bug introduced by
The function add_action was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

20
/** @scrutinizer ignore-call */ 
21
add_action( 'wp_enqueue_scripts', 'strip_header_background', 11 );
Loading history...
21
22
if ( ! function_exists( 'strip_entry_meta' ) ) :
23
	/**
24
	 * Prints HTML with meta information for the current post-date/time and author.
25
	 */
26
	function strip_entry_meta() {
27
		if ( is_sticky() && is_home() ) {
0 ignored issues
show
Bug introduced by
The function is_home was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
		if ( is_sticky() && /** @scrutinizer ignore-call */ is_home() ) {
Loading history...
Bug introduced by
The function is_sticky was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

27
		if ( /** @scrutinizer ignore-call */ is_sticky() && is_home() ) {
Loading history...
28
			printf(
29
				wp_kses( '<span class="featured-post"><a href="%1$s" title="%2$s" rel="bookmark">Sticky</a></span>', 'strip' ),
0 ignored issues
show
Bug introduced by
The function wp_kses was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

29
				/** @scrutinizer ignore-call */ 
30
    wp_kses( '<span class="featured-post"><a href="%1$s" title="%2$s" rel="bookmark">Sticky</a></span>', 'strip' ),
Loading history...
30
				esc_url( get_permalink() ),
0 ignored issues
show
Bug introduced by
The function esc_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
				/** @scrutinizer ignore-call */ 
31
    esc_url( get_permalink() ),
Loading history...
Bug introduced by
The function get_permalink was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

30
				esc_url( /** @scrutinizer ignore-call */ get_permalink() ),
Loading history...
31
				esc_attr( get_the_time() )
0 ignored issues
show
Bug introduced by
The function esc_attr was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
				/** @scrutinizer ignore-call */ 
32
    esc_attr( get_the_time() )
Loading history...
Bug introduced by
The function get_the_time was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

31
				esc_attr( /** @scrutinizer ignore-call */ get_the_time() )
Loading history...
32
			);
33
		}
34
35
		if ( 'post' === get_post_type() ) {
0 ignored issues
show
Bug introduced by
The function get_post_type was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
		if ( 'post' === /** @scrutinizer ignore-call */ get_post_type() ) {
Loading history...
36
			printf(
37
				wp_kses_post( '<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a></span><span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span>', 'strip' ),
0 ignored issues
show
Bug introduced by
The function wp_kses_post was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
				/** @scrutinizer ignore-call */ 
38
    wp_kses_post( '<span class="entry-date"><a href="%1$s" title="%2$s" rel="bookmark"><time datetime="%3$s">%4$s</time></a></span><span class="author vcard"><a class="url fn n" href="%5$s" title="%6$s" rel="author">%7$s</a></span>', 'strip' ),
Loading history...
38
				esc_url( get_permalink() ),
39
				esc_attr( get_the_time() ),
40
				esc_attr( get_the_date( 'c' ) ),
0 ignored issues
show
Bug introduced by
The function get_the_date was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

40
				esc_attr( /** @scrutinizer ignore-call */ get_the_date( 'c' ) ),
Loading history...
41
				get_the_date(),
42
				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
0 ignored issues
show
Bug introduced by
The function get_author_posts_url was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
				esc_url( /** @scrutinizer ignore-call */ get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
Loading history...
Bug introduced by
The function get_the_author_meta was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

42
				esc_url( get_author_posts_url( /** @scrutinizer ignore-call */ get_the_author_meta( 'ID' ) ) ),
Loading history...
43
				esc_attr( sprintf( __( 'View all posts by %s', 'strip' ), get_the_author() ) ),
0 ignored issues
show
Bug introduced by
The function __ was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
				esc_attr( sprintf( /** @scrutinizer ignore-call */ __( 'View all posts by %s', 'strip' ), get_the_author() ) ),
Loading history...
Bug introduced by
The function get_the_author was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
				esc_attr( sprintf( __( 'View all posts by %s', 'strip' ), /** @scrutinizer ignore-call */ get_the_author() ) ),
Loading history...
44
				get_the_author()
45
			);
46
		}
47
48
		$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'strip' ) );
0 ignored issues
show
Bug introduced by
The function get_the_tag_list was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
		$tags_list = /** @scrutinizer ignore-call */ get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'strip' ) );
Loading history...
Bug introduced by
The function _x was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

48
		$tags_list = get_the_tag_list( '', /** @scrutinizer ignore-call */ _x( ', ', 'Used between list items, there is a space after the comma.', 'strip' ) );
Loading history...
49
		if ( $tags_list ) {
50
			printf( '<span class="tags-links">' . esc_html( '%1$s', 'strip' ) . '</span>', $tags_list ); // WPCS: XSS OK.
0 ignored issues
show
Bug introduced by
The function esc_html was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

50
			printf( '<span class="tags-links">' . /** @scrutinizer ignore-call */ esc_html( '%1$s', 'strip' ) . '</span>', $tags_list ); // WPCS: XSS OK.
Loading history...
51
		}
52
	}
53
endif;
54
55
if ( ! function_exists( 'strip_term_description' ) ) :
56
	/**
57
	 * Display optional term description for category, tag and custom taxonomy pages.
58
	 *
59
	 * @since Strip 1.0
60
	 */
61
	function strip_term_description() {
62
		// Show an optional term description.
63
		$term_description = term_description();
0 ignored issues
show
Bug introduced by
The function term_description was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
		$term_description = /** @scrutinizer ignore-call */ term_description();
Loading history...
64
65
		if ( is_post_type_archive( 'comic' ) || is_category() || is_tag() || is_tax( 'story' ) && ! empty( $term_description ) ) :
0 ignored issues
show
Bug introduced by
The function is_tax was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
		if ( is_post_type_archive( 'comic' ) || is_category() || is_tag() || /** @scrutinizer ignore-call */ is_tax( 'story' ) && ! empty( $term_description ) ) :
Loading history...
Bug introduced by
The function is_category was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
		if ( is_post_type_archive( 'comic' ) || /** @scrutinizer ignore-call */ is_category() || is_tag() || is_tax( 'story' ) && ! empty( $term_description ) ) :
Loading history...
Bug introduced by
The function is_tag was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
		if ( is_post_type_archive( 'comic' ) || is_category() || /** @scrutinizer ignore-call */ is_tag() || is_tax( 'story' ) && ! empty( $term_description ) ) :
Loading history...
Bug introduced by
The function is_post_type_archive was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

65
		if ( /** @scrutinizer ignore-call */ is_post_type_archive( 'comic' ) || is_category() || is_tag() || is_tax( 'story' ) && ! empty( $term_description ) ) :
Loading history...
66
			printf( '<div class="taxonomy-description">%s</div>', $term_description, 'strip' ); // WPCS: XSS OK.
67
			endif;
68
	}
69
endif; // ends check for strip_term_description.
70
71
/**
72
 * Returns true if a blog has more than 1 category.
73
 *
74
 * @return bool
75
 */
76
function strip_categorized_blog() {
77
	$category_count = get_transient( 'strip_categories' );
0 ignored issues
show
Bug introduced by
The function get_transient was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

77
	$category_count = /** @scrutinizer ignore-call */ get_transient( 'strip_categories' );
Loading history...
78
79
	if ( false === $category_count ) {
80
		// Create an array of all the categories that are attached to posts.
81
		$categories = get_categories( array(
0 ignored issues
show
Bug introduced by
The function get_categories was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
		$categories = /** @scrutinizer ignore-call */ get_categories( array(
Loading history...
82
			'fields'     => 'ids',
83
			'hide_empty' => 1,
84
			// We only need to know if there is more than one category.
85
			'number'     => 2,
86
		) );
87
88
		// Count the number of categories that are attached to the posts.
89
		$category_count = count( $categories );
90
91
		set_transient( 'strip_categories', $category_count );
0 ignored issues
show
Bug introduced by
The function set_transient was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

91
		/** @scrutinizer ignore-call */ 
92
  set_transient( 'strip_categories', $category_count );
Loading history...
92
	}
93
94
	// Allow viewing case of 0 or 1 categories in post preview.
95
	if ( is_preview() ) {
0 ignored issues
show
Bug introduced by
The function is_preview was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

95
	if ( /** @scrutinizer ignore-call */ is_preview() ) {
Loading history...
96
		return true;
97
	}
98
99
	return $category_count > 1;
100
}
101
102
103
/**
104
 * Flush out the transients used in strip_categorized_blog.
105
 */
106
function strip_category_transient_flusher() {
107
	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
0 ignored issues
show
Bug introduced by
The constant DOING_AUTOSAVE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
108
		return;
109
	}
110
	// Like, beat it. Dig?
111
	delete_transient( 'strip_categories' );
0 ignored issues
show
Bug introduced by
The function delete_transient was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

111
	/** @scrutinizer ignore-call */ 
112
 delete_transient( 'strip_categories' );
Loading history...
112
}
113
add_action( 'edit_category', 'strip_category_transient_flusher' );
114
add_action( 'save_post',     'strip_category_transient_flusher' );
115
116
if ( ! function_exists( 'strip_the_custom_logo' ) ) :
117
	/**
118
	 * Displays the optional custom logo.
119
	 *
120
	 * Does nothing if the custom logo is not available.
121
	 *
122
	 * @since strip 1.0
123
	 */
124
	function strip_the_custom_logo() {
125
		if ( function_exists( 'the_custom_logo' ) ) {
126
			the_custom_logo();
127
		}
128
	}
129
endif;
130
131
/**
132
 * Get the first and last custom type post using get_boundary_post()
133
 *
134
 * @link https://core.trac.wordpress.org/ticket/27094
135
 *
136
 * @param bool   $in_same_term   Optional. Whether returned post should be in a same taxonomy term.
137
 * @param bool   $start          Optional. Whether to retrieve first or last post.
138
 * @param string $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
139
 * @return mixed Array containing the boundary post object if successful, null otherwise.
140
 */
141
function get_comic_boundary_post( $in_same_term, $start, $taxonomy ) {
142
	global $post;
143
	setup_postdata( $post );
0 ignored issues
show
Bug introduced by
The function setup_postdata was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

143
	/** @scrutinizer ignore-call */ 
144
 setup_postdata( $post );
Loading history...
144
	if ( ! taxonomy_exists( $taxonomy ) ) {
0 ignored issues
show
Bug introduced by
The function taxonomy_exists was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

144
	if ( ! /** @scrutinizer ignore-call */ taxonomy_exists( $taxonomy ) ) {
Loading history...
145
		return null;
146
	}
147
148
	$query_args = array(
149
		'post_type'              => 'comic',
150
		'posts_per_page'         => 1,
151
		'order'                  => $start ? 'ASC' : 'DESC',
152
		'no_found_rows'          => true,
153
		'update_post_term_cache' => false,
154
		'update_post_meta_cache' => false,
155
	);
156
157
	$term_array = array();
158
	if ( $in_same_term ) {
159
		if ( $in_same_term ) {
160
			$term_array = wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
0 ignored issues
show
Bug introduced by
The function wp_get_object_terms was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

160
			$term_array = /** @scrutinizer ignore-call */ wp_get_object_terms( $post->ID, $taxonomy, array( 'fields' => 'ids' ) );
Loading history...
161
		}
162
		$query_args['tax_query'] = array( array(
0 ignored issues
show
introduced by
Detected usage of tax_query, possible slow query.
Loading history...
introduced by
The first value in a multi-value array must be on a new line
Loading history...
163
			'taxonomy' => $taxonomy,
164
			'terms' => array_merge( $term_array ),
165
		),
166
		);
167
	}
168
169
	$get_posts = new wp_query;
0 ignored issues
show
Bug introduced by
The type wp_query was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
170
	return $get_posts -> query( $query_args );
171
}
172
173
/**
174
 * Link to the first comic post in same term
175
 */
176
function first_comic_link() {
177
	$first = get_comic_boundary_post( true, true, 'story' );
178
	apply_filters( 'the_title', $first[0]->post_title );
0 ignored issues
show
Bug introduced by
The function apply_filters was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

178
	/** @scrutinizer ignore-call */ 
179
 apply_filters( 'the_title', $first[0]->post_title );
Loading history...
179
180
	echo esc_html( get_permalink( $first[0]->ID ) );
0 ignored issues
show
Bug introduced by
The function get_permalink was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

180
	echo esc_html( /** @scrutinizer ignore-call */ get_permalink( $first[0]->ID ) );
Loading history...
Bug introduced by
The function esc_html was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

180
	echo /** @scrutinizer ignore-call */ esc_html( get_permalink( $first[0]->ID ) );
Loading history...
181
}
182
183
/**
184
 * Link to the last comic post in same term
185
 */
186
function last_comic_link() {
187
	$last = get_comic_boundary_post( true, false, 'story' );
188
	apply_filters( 'the_title', $last[0]->post_title );
0 ignored issues
show
Bug introduced by
The function apply_filters was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

188
	/** @scrutinizer ignore-call */ 
189
 apply_filters( 'the_title', $last[0]->post_title );
Loading history...
189
190
	echo esc_html( get_permalink( $last[0]->ID ) );
0 ignored issues
show
Bug introduced by
The function esc_html was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

190
	echo /** @scrutinizer ignore-call */ esc_html( get_permalink( $last[0]->ID ) );
Loading history...
Bug introduced by
The function get_permalink was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

190
	echo esc_html( /** @scrutinizer ignore-call */ get_permalink( $last[0]->ID ) );
Loading history...
191
}
192