|
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 bitsy |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
View Code Duplication |
if ( ! function_exists( 'bitsy_posted_on' ) ) : |
|
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Prints HTML with meta information for the current post-date/time and author. |
|
13
|
|
|
*/ |
|
14
|
|
|
function bitsy_posted_on() { |
|
15
|
|
|
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>'; |
|
16
|
|
|
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { |
|
|
|
|
|
|
17
|
|
|
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>'; |
|
18
|
|
|
} |
|
19
|
|
|
|
|
20
|
|
|
$time_string = sprintf( $time_string, |
|
21
|
|
|
esc_attr( get_the_date( 'c' ) ), |
|
|
|
|
|
|
22
|
|
|
esc_html( get_the_date() ), |
|
|
|
|
|
|
23
|
|
|
esc_attr( get_the_modified_date( 'c' ) ), |
|
|
|
|
|
|
24
|
|
|
esc_html( get_the_modified_date() ) |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
$posted_on = sprintf( |
|
28
|
|
|
/* translators: %s: post date. */ |
|
29
|
|
|
esc_html_x( 'Posted on %s', 'post date', 'bitsy' ), |
|
|
|
|
|
|
30
|
|
|
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' |
|
|
|
|
|
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
$byline = sprintf( |
|
34
|
|
|
/* translators: %s: post author. */ |
|
35
|
|
|
esc_html_x( 'by %s', 'post author', 'bitsy' ), |
|
36
|
|
|
'<span class="author vcard"><a class="url fn n" href="' . esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ) . '">' . esc_html( get_the_author() ) . '</a></span>' |
|
|
|
|
|
|
37
|
|
|
); |
|
38
|
|
|
|
|
39
|
|
|
echo '<span class="posted-on">' . $posted_on . '</span><span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. |
|
40
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
endif; |
|
43
|
|
|
|
|
44
|
|
View Code Duplication |
if ( ! function_exists( 'bitsy_entry_footer' ) ) : |
|
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Prints HTML with meta information for the categories, tags and comments. |
|
47
|
|
|
*/ |
|
48
|
|
|
function bitsy_entry_footer() { |
|
49
|
|
|
// Hide category and tag text for pages. |
|
50
|
|
|
if ( 'post' === get_post_type() ) { |
|
|
|
|
|
|
51
|
|
|
/* translators: used between list items, there is a space after the comma */ |
|
52
|
|
|
$categories_list = get_the_category_list( esc_html__( ', ', 'bitsy' ) ); |
|
|
|
|
|
|
53
|
|
|
if ( $categories_list ) { |
|
54
|
|
|
/* translators: 1: list of categories. */ |
|
55
|
|
|
printf( '<span class="cat-links">' . esc_html__( 'Posted in %1$s', 'bitsy' ) . '</span>', $categories_list ); // WPCS: XSS OK. |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/* translators: used between list items, there is a space after the comma */ |
|
59
|
|
|
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'bitsy' ) ); |
|
|
|
|
|
|
60
|
|
|
if ( $tags_list ) { |
|
61
|
|
|
/* translators: 1: list of tags. */ |
|
62
|
|
|
printf( '<span class="tags-links">' . esc_html__( 'Tagged %1$s', 'bitsy' ) . '</span>', $tags_list ); // WPCS: XSS OK. |
|
63
|
|
|
} |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
if ( ! isbitsyingle() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { |
|
|
|
|
|
|
67
|
|
|
echo '<span class="comments-link">'; |
|
68
|
|
|
comments_popup_link( |
|
|
|
|
|
|
69
|
|
|
sprintf( |
|
70
|
|
|
wp_kses( |
|
|
|
|
|
|
71
|
|
|
/* translators: %s: post title */ |
|
72
|
|
|
__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'bitsy' ), |
|
|
|
|
|
|
73
|
|
|
array( |
|
74
|
|
|
'span' => array( |
|
75
|
|
|
'class' => array(), |
|
76
|
|
|
), |
|
77
|
|
|
) |
|
78
|
|
|
), |
|
79
|
|
|
get_the_title() |
|
|
|
|
|
|
80
|
|
|
) |
|
81
|
|
|
); |
|
82
|
|
|
echo '</span>'; |
|
83
|
|
|
} |
|
84
|
|
|
|
|
85
|
|
|
edit_post_link( |
|
|
|
|
|
|
86
|
|
|
sprintf( |
|
87
|
|
|
wp_kses( |
|
88
|
|
|
/* translators: %s: Name of current post. Only visible to screen readers */ |
|
89
|
|
|
__( 'Edit <span class="screen-reader-text">%s</span>', 'bitsy' ), |
|
90
|
|
|
array( |
|
91
|
|
|
'span' => array( |
|
92
|
|
|
'class' => array(), |
|
93
|
|
|
), |
|
94
|
|
|
) |
|
95
|
|
|
), |
|
96
|
|
|
get_the_title() |
|
97
|
|
|
), |
|
98
|
|
|
'<span class="edit-link">', |
|
99
|
|
|
'</span>' |
|
100
|
|
|
); |
|
101
|
|
|
} |
|
102
|
|
|
endif; |
|
103
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.