|
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 DesignFly |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
if ( ! function_exists( 'designfly_posted_on' ) ) : |
|
11
|
|
|
/** |
|
12
|
|
|
* Prints HTML with meta information for the current post-date/time. |
|
13
|
|
|
*/ |
|
14
|
|
|
function designfly_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( DATE_W3C ) ), |
|
|
|
|
|
|
22
|
|
|
esc_html( get_the_date() ), |
|
|
|
|
|
|
23
|
|
|
esc_attr( get_the_modified_date( DATE_W3C ) ), |
|
|
|
|
|
|
24
|
|
|
esc_html( get_the_modified_date() ) |
|
25
|
|
|
); |
|
26
|
|
|
|
|
27
|
|
|
$posted_on = sprintf( |
|
28
|
|
|
/* translators: %s: post date. */ |
|
29
|
|
|
esc_html_x( ' on %s', 'post date', 'designfly' ), |
|
|
|
|
|
|
30
|
|
|
'<a href="' . esc_url( get_permalink() ) . '" rel="bookmark">' . $time_string . '</a>' |
|
|
|
|
|
|
31
|
|
|
); |
|
32
|
|
|
|
|
33
|
|
|
echo '<span class="posted-on">' . $posted_on . '</span>'; // WPCS: XSS OK. |
|
34
|
|
|
|
|
35
|
|
|
} |
|
36
|
|
|
endif; |
|
37
|
|
|
|
|
38
|
|
|
if ( ! function_exists( 'designfly_posted_by' ) ) : |
|
39
|
|
|
/** |
|
40
|
|
|
* Prints HTML with meta information for the current author. |
|
41
|
|
|
*/ |
|
42
|
|
|
function designfly_posted_by() { |
|
43
|
|
|
$byline = sprintf( |
|
44
|
|
|
/* translators: %s: post author. */ |
|
45
|
|
|
esc_html_x( 'by %s', 'post author', 'designfly' ), |
|
|
|
|
|
|
46
|
|
|
'<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>' |
|
|
|
|
|
|
47
|
|
|
); |
|
48
|
|
|
|
|
49
|
|
|
echo '<span class="byline"> ' . $byline . '</span>'; // WPCS: XSS OK. |
|
50
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
endif; |
|
53
|
|
|
|
|
54
|
|
|
if ( ! function_exists( 'designfly_entry_footer' ) ) : |
|
55
|
|
|
/** |
|
56
|
|
|
* Prints HTML with meta information for the categories, tags and comments. |
|
57
|
|
|
*/ |
|
58
|
|
|
function designfly_entry_footer() { |
|
59
|
|
|
// Hide category and tag text for pages. |
|
60
|
|
|
if ( 'post' === get_post_type() ) { |
|
|
|
|
|
|
61
|
|
|
/* translators: used between list items, there is a space after the comma */ |
|
62
|
|
|
$categories_list = get_the_category_list( esc_html__( ', ', 'designfly' ) ); |
|
|
|
|
|
|
63
|
|
|
if ( $categories_list ) { |
|
64
|
|
|
/* translators: 1: list of categories. */ |
|
65
|
|
|
printf( '<span class="cat-links">' . esc_html__( 'Posted in: %1$s', 'designfly' ) . '</span>', $categories_list ); // WPCS: XSS OK. |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/* translators: used between list items, there is a space after the comma */ |
|
69
|
|
|
$tags_list = get_the_tag_list( '', esc_html_x( ', ', 'list item separator', 'designfly' ) ); |
|
|
|
|
|
|
70
|
|
|
if ( $tags_list ) { |
|
71
|
|
|
/* translators: 1: list of tags. */ |
|
72
|
|
|
printf( '<span class="tags-links">' . esc_html__( 'TAGS: %1$s', 'designfly' ) . '</span>', $tags_list ); // WPCS: XSS OK. |
|
73
|
|
|
} |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) ) { |
|
|
|
|
|
|
77
|
|
|
echo '<span class="comments-link">'; |
|
78
|
|
|
comments_popup_link( |
|
|
|
|
|
|
79
|
|
|
sprintf( |
|
80
|
|
|
wp_kses( |
|
|
|
|
|
|
81
|
|
|
/* translators: %s: post title */ |
|
82
|
|
|
__( 'Leave a Comment<span class="screen-reader-text"> on %s</span>', 'designfly' ), |
|
|
|
|
|
|
83
|
|
|
array( |
|
84
|
|
|
'span' => array( |
|
85
|
|
|
'class' => array(), |
|
86
|
|
|
), |
|
87
|
|
|
) |
|
88
|
|
|
), |
|
89
|
|
|
get_the_title() |
|
|
|
|
|
|
90
|
|
|
) |
|
91
|
|
|
); |
|
92
|
|
|
echo '</span>'; |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
// edit_post_link( |
|
96
|
|
|
// sprintf( |
|
97
|
|
|
// wp_kses( |
|
98
|
|
|
// __( 'Edit <span class="screen-reader-text">%s</span>', 'designfly' ), |
|
99
|
|
|
// array( |
|
100
|
|
|
// 'span' => array( |
|
101
|
|
|
// 'class' => array(), |
|
102
|
|
|
// ), |
|
103
|
|
|
// ) |
|
104
|
|
|
// ), |
|
105
|
|
|
// get_the_title() |
|
106
|
|
|
// ), |
|
107
|
|
|
// '<span class="edit-link">', |
|
108
|
|
|
// '</span>' |
|
109
|
|
|
// ); |
|
110
|
|
|
} |
|
111
|
|
|
endif; |
|
112
|
|
|
|
|
113
|
|
|
if ( ! function_exists( 'designfly_post_thumbnail' ) ) : |
|
114
|
|
|
/** |
|
115
|
|
|
* Displays an optional post thumbnail. |
|
116
|
|
|
* |
|
117
|
|
|
* Wraps the post thumbnail in an anchor element on index views, or a div |
|
118
|
|
|
* element when on single views. |
|
119
|
|
|
*/ |
|
120
|
|
|
function designfly_post_thumbnail() { |
|
121
|
|
|
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) { |
|
|
|
|
|
|
122
|
|
|
return; |
|
123
|
|
|
} |
|
124
|
|
|
|
|
125
|
|
|
if ( is_singular() ) : |
|
|
|
|
|
|
126
|
|
|
?> |
|
127
|
|
|
|
|
128
|
|
|
<div class="post-thumbnail"> |
|
129
|
|
|
<?php the_post_thumbnail(); ?> |
|
|
|
|
|
|
130
|
|
|
</div><!-- .post-thumbnail --> |
|
131
|
|
|
|
|
132
|
|
|
<?php else : ?> |
|
133
|
|
|
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true" tabindex="-1"> |
|
|
|
|
|
|
134
|
|
|
<?php |
|
135
|
|
|
the_post_thumbnail( 'post-thumbnail', array( |
|
136
|
|
|
'alt' => the_title_attribute( array( |
|
|
|
|
|
|
137
|
|
|
'echo' => false, |
|
138
|
|
|
) ), |
|
139
|
|
|
) ); |
|
140
|
|
|
?> |
|
141
|
|
|
</a> |
|
142
|
|
|
|
|
143
|
|
|
<?php |
|
144
|
|
|
endif; // End is_singular(). |
|
145
|
|
|
} |
|
146
|
|
|
endif; |
|
147
|
|
|
|
|
148
|
|
|
/** |
|
149
|
|
|
* Displays the pagination. |
|
150
|
|
|
* |
|
151
|
|
|
* Wraps the pagination in a div with id 'pagination' and echoes it out. |
|
152
|
|
|
* |
|
153
|
|
|
* @param $custom_query requires the query object to get pagination |
|
|
|
|
|
|
154
|
|
|
*/ |
|
155
|
|
|
function designfly_pagination_bar( $custom_query ) { |
|
156
|
|
|
|
|
157
|
|
|
$total_pages = $custom_query->max_num_pages; |
|
158
|
|
|
$big = 999999999; // need an unlikely integer |
|
159
|
|
|
|
|
160
|
|
|
if ( $total_pages > 1 ) { |
|
161
|
|
|
$current_page = max(1, get_query_var('paged')); |
|
|
|
|
|
|
162
|
|
|
|
|
163
|
|
|
$pages = paginate_links(array( |
|
|
|
|
|
|
164
|
|
|
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
|
|
|
|
|
165
|
|
|
'format' => '?paged=%#%', |
|
166
|
|
|
'current' => $current_page, |
|
167
|
|
|
'total' => $total_pages, |
|
168
|
|
|
'type' => 'array', |
|
169
|
|
|
'prev_text' => '<img class="pagination-arrow-left" src="' . get_template_directory_uri() . '/assets/images/pagination-arrow.png' . '" />', |
|
|
|
|
|
|
170
|
|
|
'next_text' => '<img class="pagination-arrow-right" src="' . get_template_directory_uri() . '/assets/images/pagination-arrow.png' . '" />', |
|
171
|
|
|
)); |
|
172
|
|
|
|
|
173
|
|
|
/* for echoing out with custom html tags */ |
|
174
|
|
|
if( is_array( $pages ) ) { |
|
175
|
|
|
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged'); |
|
|
|
|
|
|
176
|
|
|
echo '<div id="pagination">'; |
|
177
|
|
|
foreach ( $pages as $page ) { |
|
178
|
|
|
echo $page; |
|
179
|
|
|
} |
|
180
|
|
|
echo '</div>'; |
|
181
|
|
|
} |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
|
|
185
|
|
|
/** |
|
186
|
|
|
* Displays custom comments. |
|
187
|
|
|
* |
|
188
|
|
|
* @param $comment comment |
|
|
|
|
|
|
189
|
|
|
* @param $args standard arguments |
|
|
|
|
|
|
190
|
|
|
* @param $depth depth of the comments |
|
|
|
|
|
|
191
|
|
|
*/ |
|
192
|
|
|
function designfly_custom_comments($comment, $args, $depth) { |
|
193
|
|
|
|
|
194
|
|
|
if ( 'div' === $args['style'] ) { |
|
195
|
|
|
$tag = 'div'; |
|
196
|
|
|
$add_below = 'comment'; |
|
197
|
|
|
} else { |
|
198
|
|
|
$tag = 'li'; |
|
199
|
|
|
$add_below = 'div-comment'; |
|
200
|
|
|
} |
|
201
|
|
|
?> |
|
202
|
|
|
|
|
203
|
|
|
<<?php echo $tag ?> <?php comment_class( empty( $args['has_children'] ) ? '' : 'parent' ) ?> id="comment-<?php comment_ID() ?>"> |
|
|
|
|
|
|
204
|
|
|
<?php if ( 'div' != $args['style'] ) : ?> |
|
205
|
|
|
<div id="div-comment-<?php comment_ID() ?>" class="comment-body"> |
|
206
|
|
|
<?php endif; ?> |
|
207
|
|
|
|
|
208
|
|
|
<div class="comment-author vcard"> |
|
209
|
|
|
<?php printf( __( '<cite class="fn">%s</cite> <span class="says">said on </span>' ), get_comment_author_link() ); ?> |
|
|
|
|
|
|
210
|
|
|
</div> |
|
211
|
|
|
|
|
212
|
|
|
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ); ?>"> |
|
|
|
|
|
|
213
|
|
|
<?php |
|
214
|
|
|
/* translators: 1: date, 2: time */ |
|
215
|
|
|
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time() ); ?></a><?php edit_comment_link( __( '(Edit)' ), ' ', '' ); |
|
|
|
|
|
|
216
|
|
|
?> |
|
217
|
|
|
</div> |
|
218
|
|
|
|
|
219
|
|
|
<?php if ( $comment->comment_approved == '0' ) : ?> |
|
220
|
|
|
<em class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.' ); ?></em> |
|
|
|
|
|
|
221
|
|
|
<br /> |
|
222
|
|
|
<?php endif; ?> |
|
223
|
|
|
|
|
224
|
|
|
|
|
225
|
|
|
<?php comment_text(); ?> |
|
|
|
|
|
|
226
|
|
|
|
|
227
|
|
|
<div class="reply"> |
|
228
|
|
|
<?php comment_reply_link( array_merge( $args, array( 'add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?> |
|
|
|
|
|
|
229
|
|
|
</div> |
|
230
|
|
|
|
|
231
|
|
|
<?php if ( 'div' != $args['style'] ) : ?> |
|
232
|
|
|
</div> |
|
233
|
|
|
|
|
234
|
|
|
<?php endif; ?> |
|
235
|
|
|
<?php |
|
236
|
|
|
} |
|
237
|
|
|
|
|
238
|
|
|
|