author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 18:28:13 +0200 | |
changeset 9 | 177826044cd9 |
parent 7 | cf61fcea0001 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
3 |
* WordPress Post Template Functions. |
|
4 |
* |
|
5 |
* Gets content for the current post in the loop. |
|
6 |
* |
|
7 |
* @package WordPress |
|
8 |
* @subpackage Template |
|
9 |
*/ |
|
10 |
||
11 |
/** |
|
12 |
* Display the ID of the current item in the WordPress Loop. |
|
13 |
* |
|
14 |
* @since 0.71 |
|
15 |
*/ |
|
16 |
function the_ID() { |
|
17 |
echo get_the_ID(); |
|
18 |
} |
|
19 |
||
20 |
/** |
|
21 |
* Retrieve the ID of the current item in the WordPress Loop. |
|
22 |
* |
|
23 |
* @since 2.1.0 |
|
24 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
* @return int|false The ID of the current item in the WordPress Loop. False if $post is not set. |
0 | 26 |
*/ |
27 |
function get_the_ID() { |
|
5 | 28 |
$post = get_post(); |
29 |
return ! empty( $post ) ? $post->ID : false; |
|
0 | 30 |
} |
31 |
||
32 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* Display or retrieve the current post title with optional markup. |
0 | 34 |
* |
35 |
* @since 0.71 |
|
36 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* @param string $before Optional. Markup to prepend to the title. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
* @param string $after Optional. Markup to append to the title. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
* @param bool $echo Optional. Whether to echo or return the title. Default true for echo. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* @return string|void Current post title if $echo is false. |
0 | 41 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
function the_title( $before = '', $after = '', $echo = true ) { |
0 | 43 |
$title = get_the_title(); |
44 |
||
9 | 45 |
if ( strlen( $title ) == 0 ) { |
0 | 46 |
return; |
9 | 47 |
} |
0 | 48 |
|
49 |
$title = $before . $title . $after; |
|
50 |
||
9 | 51 |
if ( $echo ) { |
0 | 52 |
echo $title; |
9 | 53 |
} else { |
0 | 54 |
return $title; |
9 | 55 |
} |
0 | 56 |
} |
57 |
||
58 |
/** |
|
59 |
* Sanitize the current title when retrieving or displaying. |
|
60 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
* Works like the_title(), except the parameters can be in a string or |
0 | 62 |
* an array. See the function for what can be override in the $args parameter. |
63 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
* The title before it is displayed will have the tags stripped and esc_attr() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
* before it is passed to the user or displayed. The default as with the_title(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
* is to display the title. |
0 | 67 |
* |
68 |
* @since 2.3.0 |
|
69 |
* |
|
5 | 70 |
* @param string|array $args { |
71 |
* Title attribute arguments. Optional. |
|
72 |
* |
|
73 |
* @type string $before Markup to prepend to the title. Default empty. |
|
74 |
* @type string $after Markup to append to the title. Default empty. |
|
75 |
* @type bool $echo Whether to echo or return the title. Default true for echo. |
|
76 |
* @type WP_Post $post Current post object to retrieve the title for. |
|
77 |
* } |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
* @return string|void String when echo is false. |
0 | 79 |
*/ |
80 |
function the_title_attribute( $args = '' ) { |
|
9 | 81 |
$defaults = array( |
82 |
'before' => '', |
|
83 |
'after' => '', |
|
84 |
'echo' => true, |
|
85 |
'post' => get_post(), |
|
86 |
); |
|
87 |
$r = wp_parse_args( $args, $defaults ); |
|
0 | 88 |
|
5 | 89 |
$title = get_the_title( $r['post'] ); |
0 | 90 |
|
5 | 91 |
if ( strlen( $title ) == 0 ) { |
0 | 92 |
return; |
5 | 93 |
} |
0 | 94 |
|
5 | 95 |
$title = $r['before'] . $title . $r['after']; |
96 |
$title = esc_attr( strip_tags( $title ) ); |
|
0 | 97 |
|
5 | 98 |
if ( $r['echo'] ) { |
0 | 99 |
echo $title; |
5 | 100 |
} else { |
0 | 101 |
return $title; |
5 | 102 |
} |
0 | 103 |
} |
104 |
||
105 |
/** |
|
106 |
* Retrieve post title. |
|
107 |
* |
|
108 |
* If the post is protected and the visitor is not an admin, then "Protected" |
|
109 |
* will be displayed before the post title. If the post is private, then |
|
110 |
* "Private" will be located before the post title. |
|
111 |
* |
|
112 |
* @since 0.71 |
|
113 |
* |
|
5 | 114 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
0 | 115 |
* @return string |
116 |
*/ |
|
117 |
function get_the_title( $post = 0 ) { |
|
118 |
$post = get_post( $post ); |
|
119 |
||
120 |
$title = isset( $post->post_title ) ? $post->post_title : ''; |
|
9 | 121 |
$id = isset( $post->ID ) ? $post->ID : 0; |
0 | 122 |
|
123 |
if ( ! is_admin() ) { |
|
124 |
if ( ! empty( $post->post_password ) ) { |
|
5 | 125 |
|
126 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
* Filters the text prepended to the post title for protected posts. |
5 | 128 |
* |
129 |
* The filter is only applied on the front end. |
|
130 |
* |
|
131 |
* @since 2.8.0 |
|
132 |
* |
|
133 |
* @param string $prepend Text displayed before the post title. |
|
134 |
* Default 'Protected: %s'. |
|
135 |
* @param WP_Post $post Current post object. |
|
136 |
*/ |
|
137 |
$protected_title_format = apply_filters( 'protected_title_format', __( 'Protected: %s' ), $post ); |
|
9 | 138 |
$title = sprintf( $protected_title_format, $title ); |
5 | 139 |
} elseif ( isset( $post->post_status ) && 'private' == $post->post_status ) { |
140 |
||
141 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
* Filters the text prepended to the post title of private posts. |
5 | 143 |
* |
144 |
* The filter is only applied on the front end. |
|
145 |
* |
|
146 |
* @since 2.8.0 |
|
147 |
* |
|
148 |
* @param string $prepend Text displayed before the post title. |
|
149 |
* Default 'Private: %s'. |
|
150 |
* @param WP_Post $post Current post object. |
|
151 |
*/ |
|
152 |
$private_title_format = apply_filters( 'private_title_format', __( 'Private: %s' ), $post ); |
|
9 | 153 |
$title = sprintf( $private_title_format, $title ); |
0 | 154 |
} |
155 |
} |
|
156 |
||
5 | 157 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
* Filters the post title. |
5 | 159 |
* |
160 |
* @since 0.71 |
|
161 |
* |
|
162 |
* @param string $title The post title. |
|
163 |
* @param int $id The post ID. |
|
164 |
*/ |
|
0 | 165 |
return apply_filters( 'the_title', $title, $id ); |
166 |
} |
|
167 |
||
168 |
/** |
|
169 |
* Display the Post Global Unique Identifier (guid). |
|
170 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
* The guid will appear to be a link, but should not be used as a link to the |
0 | 172 |
* post. The reason you should not use it as a link, is because of moving the |
173 |
* blog across domains. |
|
174 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
* URL is escaped to make it XML-safe. |
0 | 176 |
* |
177 |
* @since 1.5.0 |
|
178 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
* @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. |
0 | 180 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
function the_guid( $post = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
$post = get_post( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
$guid = isset( $post->guid ) ? get_the_guid( $post ) : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
$id = isset( $post->ID ) ? $post->ID : 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
186 |
|
5 | 187 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
* Filters the escaped Global Unique Identifier (guid) of the post. |
5 | 189 |
* |
190 |
* @since 4.2.0 |
|
191 |
* |
|
192 |
* @see get_the_guid() |
|
193 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
* @param string $guid Escaped Global Unique Identifier (guid) of the post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
* @param int $id The post ID. |
5 | 196 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
echo apply_filters( 'the_guid', $guid, $id ); |
0 | 198 |
} |
199 |
||
200 |
/** |
|
201 |
* Retrieve the Post Global Unique Identifier (guid). |
|
202 |
* |
|
203 |
* The guid will appear to be a link, but should not be used as an link to the |
|
204 |
* post. The reason you should not use it as a link, is because of moving the |
|
205 |
* blog across domains. |
|
206 |
* |
|
207 |
* @since 1.5.0 |
|
208 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
209 |
* @param int|WP_Post $post Optional. Post ID or post object. Default is global $post. |
0 | 210 |
* @return string |
211 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
function get_the_guid( $post = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
$post = get_post( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
$guid = isset( $post->guid ) ? $post->guid : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
$id = isset( $post->ID ) ? $post->ID : 0; |
0 | 217 |
|
5 | 218 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
* Filters the Global Unique Identifier (guid) of the post. |
5 | 220 |
* |
221 |
* @since 1.5.0 |
|
222 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
* @param string $guid Global Unique Identifier (guid) of the post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
* @param int $id The post ID. |
5 | 225 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
226 |
return apply_filters( 'get_the_guid', $guid, $id ); |
0 | 227 |
} |
228 |
||
229 |
/** |
|
230 |
* Display the post content. |
|
231 |
* |
|
232 |
* @since 0.71 |
|
233 |
* |
|
234 |
* @param string $more_link_text Optional. Content for when there is more text. |
|
5 | 235 |
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. |
0 | 236 |
*/ |
9 | 237 |
function the_content( $more_link_text = null, $strip_teaser = false ) { |
0 | 238 |
$content = get_the_content( $more_link_text, $strip_teaser ); |
5 | 239 |
|
240 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
* Filters the post content. |
5 | 242 |
* |
243 |
* @since 0.71 |
|
244 |
* |
|
245 |
* @param string $content Content of the current post. |
|
246 |
*/ |
|
0 | 247 |
$content = apply_filters( 'the_content', $content ); |
248 |
$content = str_replace( ']]>', ']]>', $content ); |
|
249 |
echo $content; |
|
250 |
} |
|
251 |
||
252 |
/** |
|
253 |
* Retrieve the post content. |
|
254 |
* |
|
255 |
* @since 0.71 |
|
9 | 256 |
* @since 5.2.0 Added the `$post` parameter. |
0 | 257 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
* @global int $page Page number of a single post/page. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
259 |
* @global int $more Boolean indicator for whether single post/page is being viewed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
* @global bool $preview Whether post/page is in preview mode. |
9 | 261 |
* @global array $pages Array of all pages in post/page. Each array element contains |
262 |
* part of the content separated by the `<!--nextpage-->` tag. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
263 |
* @global int $multipage Boolean indicator for whether multiple pages are in play. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
264 |
* |
9 | 265 |
* @param string $more_link_text Optional. Content for when there is more text. |
266 |
* @param bool $strip_teaser Optional. Strip teaser content before the more text. Default is false. |
|
267 |
* @param WP_Post|object|int $post Optional. WP_Post instance or Post ID/object. Default is null. |
|
0 | 268 |
* @return string |
269 |
*/ |
|
9 | 270 |
function get_the_content( $more_link_text = null, $strip_teaser = false, $post = null ) { |
0 | 271 |
global $page, $more, $preview, $pages, $multipage; |
272 |
||
9 | 273 |
$_post = get_post( $post ); |
274 |
||
275 |
if ( ! ( $_post instanceof WP_Post ) ) { |
|
276 |
return ''; |
|
277 |
} |
|
278 |
||
279 |
if ( null === $post ) { |
|
280 |
$elements = compact( 'page', 'more', 'preview', 'pages', 'multipage' ); |
|
281 |
} else { |
|
282 |
$elements = generate_postdata( $_post ); |
|
283 |
} |
|
0 | 284 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
if ( null === $more_link_text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
$more_link_text = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
'<span aria-label="%1$s">%2$s</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
/* translators: %s: Name of current post */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
__( 'Continue reading %s' ), |
9 | 291 |
the_title_attribute( |
292 |
array( |
|
293 |
'echo' => false, |
|
294 |
'post' => $_post, |
|
295 |
) |
|
296 |
) |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
297 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
298 |
__( '(more…)' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
299 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
300 |
} |
0 | 301 |
|
9 | 302 |
$output = ''; |
0 | 303 |
$has_teaser = false; |
304 |
||
305 |
// If post password required and it doesn't match the cookie. |
|
9 | 306 |
if ( post_password_required( $_post ) ) { |
307 |
return get_the_password_form( $_post ); |
|
308 |
} |
|
0 | 309 |
|
9 | 310 |
if ( $elements['page'] > count( $elements['pages'] ) ) { // if the requested page doesn't exist |
311 |
$elements['page'] = count( $elements['pages'] ); // give them the highest numbered page that DOES exist |
|
312 |
} |
|
0 | 313 |
|
9 | 314 |
$page_no = $elements['page']; |
315 |
$content = $elements['pages'][ $page_no - 1 ]; |
|
0 | 316 |
if ( preg_match( '/<!--more(.*?)?-->/', $content, $matches ) ) { |
9 | 317 |
if ( has_block( 'more', $content ) ) { |
318 |
// Remove the core/more block delimiters. They will be left over after $content is split up. |
|
319 |
$content = preg_replace( '/<!-- \/?wp:more(.*?) -->/', '', $content ); |
|
320 |
} |
|
321 |
||
0 | 322 |
$content = explode( $matches[0], $content, 2 ); |
9 | 323 |
|
324 |
if ( ! empty( $matches[1] ) && ! empty( $more_link_text ) ) { |
|
0 | 325 |
$more_link_text = strip_tags( wp_kses_no_null( trim( $matches[1] ) ) ); |
9 | 326 |
} |
0 | 327 |
|
328 |
$has_teaser = true; |
|
329 |
} else { |
|
330 |
$content = array( $content ); |
|
331 |
} |
|
332 |
||
9 | 333 |
if ( false !== strpos( $_post->post_content, '<!--noteaser-->' ) && ( ! $elements['multipage'] || $elements['page'] == 1 ) ) { |
0 | 334 |
$strip_teaser = true; |
9 | 335 |
} |
0 | 336 |
|
337 |
$teaser = $content[0]; |
|
338 |
||
9 | 339 |
if ( $elements['more'] && $strip_teaser && $has_teaser ) { |
0 | 340 |
$teaser = ''; |
9 | 341 |
} |
0 | 342 |
|
343 |
$output .= $teaser; |
|
344 |
||
345 |
if ( count( $content ) > 1 ) { |
|
9 | 346 |
if ( $elements['more'] ) { |
347 |
$output .= '<span id="more-' . $_post->ID . '"></span>' . $content[1]; |
|
0 | 348 |
} else { |
9 | 349 |
if ( ! empty( $more_link_text ) ) { |
5 | 350 |
|
351 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
* Filters the Read More link text. |
5 | 353 |
* |
354 |
* @since 2.8.0 |
|
355 |
* |
|
356 |
* @param string $more_link_element Read More link element. |
|
357 |
* @param string $more_link_text Read More text. |
|
358 |
*/ |
|
9 | 359 |
$output .= apply_filters( 'the_content_more_link', ' <a href="' . get_permalink( $_post ) . "#more-{$_post->ID}\" class=\"more-link\">$more_link_text</a>", $more_link_text ); |
360 |
} |
|
0 | 361 |
$output = force_balance_tags( $output ); |
362 |
} |
|
363 |
} |
|
364 |
||
365 |
return $output; |
|
366 |
} |
|
367 |
||
368 |
/** |
|
369 |
* Display the post excerpt. |
|
370 |
* |
|
371 |
* @since 0.71 |
|
372 |
*/ |
|
373 |
function the_excerpt() { |
|
5 | 374 |
|
375 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
* Filters the displayed post excerpt. |
5 | 377 |
* |
378 |
* @since 0.71 |
|
379 |
* |
|
380 |
* @see get_the_excerpt() |
|
381 |
* |
|
382 |
* @param string $post_excerpt The post excerpt. |
|
383 |
*/ |
|
384 |
echo apply_filters( 'the_excerpt', get_the_excerpt() ); |
|
0 | 385 |
} |
386 |
||
387 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* Retrieves the post excerpt. |
0 | 389 |
* |
390 |
* @since 0.71 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
* @since 4.5.0 Introduced the `$post` parameter. |
0 | 392 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
* @return string Post excerpt. |
0 | 395 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
396 |
function get_the_excerpt( $post = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
if ( is_bool( $post ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
_deprecated_argument( __FUNCTION__, '2.3.0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
} |
0 | 400 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
$post = get_post( $post ); |
5 | 402 |
if ( empty( $post ) ) { |
403 |
return ''; |
|
404 |
} |
|
0 | 405 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
if ( post_password_required( $post ) ) { |
0 | 407 |
return __( 'There is no excerpt because this is a protected post.' ); |
408 |
} |
|
409 |
||
5 | 410 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
* Filters the retrieved post excerpt. |
5 | 412 |
* |
413 |
* @since 1.2.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
* @since 4.5.0 Introduced the `$post` parameter. |
5 | 415 |
* |
416 |
* @param string $post_excerpt The post excerpt. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
* @param WP_Post $post Post object. |
5 | 418 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
return apply_filters( 'get_the_excerpt', $post->post_excerpt, $post ); |
0 | 420 |
} |
421 |
||
422 |
/** |
|
9 | 423 |
* Determines whether the post has a custom excerpt. |
424 |
* |
|
425 |
* For more information on this and similar theme functions, check out |
|
426 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
427 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
0 | 428 |
* |
429 |
* @since 2.3.0 |
|
430 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
* @return bool True if the post has a custom excerpt, false otherwise. |
0 | 433 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
function has_excerpt( $post = 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
$post = get_post( $post ); |
9 | 436 |
return ( ! empty( $post->post_excerpt ) ); |
0 | 437 |
} |
438 |
||
439 |
/** |
|
9 | 440 |
* Displays the classes for the post container element. |
0 | 441 |
* |
442 |
* @since 2.7.0 |
|
443 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
* @param string|array $class One or more classes to add to the class list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
* @param int|WP_Post $post_id Optional. Post ID or post object. Defaults to the global `$post`. |
0 | 446 |
*/ |
447 |
function post_class( $class = '', $post_id = null ) { |
|
448 |
// Separates classes with a single space, collates classes for post DIV |
|
449 |
echo 'class="' . join( ' ', get_post_class( $class, $post_id ) ) . '"'; |
|
450 |
} |
|
451 |
||
452 |
/** |
|
9 | 453 |
* Retrieves an array of the class names for the post container element. |
0 | 454 |
* |
5 | 455 |
* The class names are many. If the post is a sticky, then the 'sticky' |
456 |
* class name. The class 'hentry' is always added to each post. If the post has a |
|
457 |
* post thumbnail, 'has-post-thumbnail' is added as a class. For each taxonomy that |
|
458 |
* the post belongs to, a class will be added of the format '{$taxonomy}-{$slug}' - |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* eg 'category-foo' or 'my_custom_taxonomy-bar'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* The 'post_tag' taxonomy is a special |
9 | 462 |
* case; the class has the 'tag-' prefix instead of 'post_tag-'. All class names are |
463 |
* passed through the filter, {@see 'post_class'}, with the list of class names, followed by |
|
5 | 464 |
* $class parameter value, with the post ID as the last parameter. |
0 | 465 |
* |
466 |
* @since 2.7.0 |
|
9 | 467 |
* @since 4.2.0 Custom taxonomy class names were added. |
0 | 468 |
* |
9 | 469 |
* @param string|string[] $class Space-separated string or array of class names to add to the class list. |
470 |
* @param int|WP_Post $post_id Optional. Post ID or post object. |
|
471 |
* @return string[] Array of class names. |
|
0 | 472 |
*/ |
473 |
function get_post_class( $class = '', $post_id = null ) { |
|
5 | 474 |
$post = get_post( $post_id ); |
0 | 475 |
|
476 |
$classes = array(); |
|
477 |
||
5 | 478 |
if ( $class ) { |
479 |
if ( ! is_array( $class ) ) { |
|
480 |
$class = preg_split( '#\s+#', $class ); |
|
481 |
} |
|
482 |
$classes = array_map( 'esc_attr', $class ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
// Ensure that we always coerce class to being an array. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
$class = array(); |
5 | 486 |
} |
487 |
||
488 |
if ( ! $post ) { |
|
0 | 489 |
return $classes; |
5 | 490 |
} |
0 | 491 |
|
492 |
$classes[] = 'post-' . $post->ID; |
|
9 | 493 |
if ( ! is_admin() ) { |
0 | 494 |
$classes[] = $post->post_type; |
9 | 495 |
} |
0 | 496 |
$classes[] = 'type-' . $post->post_type; |
497 |
$classes[] = 'status-' . $post->post_status; |
|
498 |
||
499 |
// Post Format |
|
500 |
if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
|
501 |
$post_format = get_post_format( $post->ID ); |
|
502 |
||
9 | 503 |
if ( $post_format && ! is_wp_error( $post_format ) ) { |
0 | 504 |
$classes[] = 'format-' . sanitize_html_class( $post_format ); |
9 | 505 |
} else { |
0 | 506 |
$classes[] = 'format-standard'; |
9 | 507 |
} |
0 | 508 |
} |
509 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
$post_password_required = post_password_required( $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
// Post requires password. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
if ( $post_password_required ) { |
0 | 514 |
$classes[] = 'post-password-required'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
} elseif ( ! empty( $post->post_password ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
$classes[] = 'post-password-protected'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
518 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
519 |
// Post thumbnails. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
if ( current_theme_supports( 'post-thumbnails' ) && has_post_thumbnail( $post->ID ) && ! is_attachment( $post ) && ! $post_password_required ) { |
5 | 521 |
$classes[] = 'has-post-thumbnail'; |
522 |
} |
|
0 | 523 |
|
524 |
// sticky for Sticky Posts |
|
5 | 525 |
if ( is_sticky( $post->ID ) ) { |
526 |
if ( is_home() && ! is_paged() ) { |
|
527 |
$classes[] = 'sticky'; |
|
528 |
} elseif ( is_admin() ) { |
|
529 |
$classes[] = 'status-sticky'; |
|
530 |
} |
|
531 |
} |
|
0 | 532 |
|
533 |
// hentry for hAtom compliance |
|
534 |
$classes[] = 'hentry'; |
|
535 |
||
5 | 536 |
// All public taxonomies |
537 |
$taxonomies = get_taxonomies( array( 'public' => true ) ); |
|
538 |
foreach ( (array) $taxonomies as $taxonomy ) { |
|
539 |
if ( is_object_in_taxonomy( $post->post_type, $taxonomy ) ) { |
|
540 |
foreach ( (array) get_the_terms( $post->ID, $taxonomy ) as $term ) { |
|
541 |
if ( empty( $term->slug ) ) { |
|
542 |
continue; |
|
543 |
} |
|
544 |
||
545 |
$term_class = sanitize_html_class( $term->slug, $term->term_id ); |
|
546 |
if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { |
|
547 |
$term_class = $term->term_id; |
|
548 |
} |
|
549 |
||
550 |
// 'post_tag' uses the 'tag' prefix for backward compatibility. |
|
551 |
if ( 'post_tag' == $taxonomy ) { |
|
552 |
$classes[] = 'tag-' . $term_class; |
|
553 |
} else { |
|
554 |
$classes[] = sanitize_html_class( $taxonomy . '-' . $term_class, $taxonomy . '-' . $term->term_id ); |
|
555 |
} |
|
556 |
} |
|
0 | 557 |
} |
558 |
} |
|
559 |
||
5 | 560 |
$classes = array_map( 'esc_attr', $classes ); |
0 | 561 |
|
5 | 562 |
/** |
9 | 563 |
* Filters the list of CSS class names for the current post. |
5 | 564 |
* |
565 |
* @since 2.7.0 |
|
566 |
* |
|
9 | 567 |
* @param string[] $classes An array of post class names. |
568 |
* @param string[] $class An array of additional class names added to the post. |
|
569 |
* @param int $post_id The post ID. |
|
5 | 570 |
*/ |
571 |
$classes = apply_filters( 'post_class', $classes, $class, $post->ID ); |
|
0 | 572 |
|
5 | 573 |
return array_unique( $classes ); |
0 | 574 |
} |
575 |
||
576 |
/** |
|
9 | 577 |
* Displays the class names for the body element. |
0 | 578 |
* |
579 |
* @since 2.8.0 |
|
580 |
* |
|
9 | 581 |
* @param string|string[] $class Space-separated string or array of class names to add to the class list. |
0 | 582 |
*/ |
583 |
function body_class( $class = '' ) { |
|
9 | 584 |
// Separates class names with a single space, collates class names for body element |
0 | 585 |
echo 'class="' . join( ' ', get_body_class( $class ) ) . '"'; |
586 |
} |
|
587 |
||
588 |
/** |
|
9 | 589 |
* Retrieves an array of the class names for the body element. |
0 | 590 |
* |
591 |
* @since 2.8.0 |
|
592 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
* @global WP_Query $wp_query |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
* |
9 | 595 |
* @param string|string[] $class Space-separated string or array of class names to add to the class list. |
596 |
* @return string[] Array of class names. |
|
0 | 597 |
*/ |
598 |
function get_body_class( $class = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
global $wp_query; |
0 | 600 |
|
601 |
$classes = array(); |
|
602 |
||
9 | 603 |
if ( is_rtl() ) { |
0 | 604 |
$classes[] = 'rtl'; |
9 | 605 |
} |
0 | 606 |
|
9 | 607 |
if ( is_front_page() ) { |
0 | 608 |
$classes[] = 'home'; |
9 | 609 |
} |
610 |
if ( is_home() ) { |
|
0 | 611 |
$classes[] = 'blog'; |
9 | 612 |
} |
613 |
if ( is_privacy_policy() ) { |
|
614 |
$classes[] = 'privacy-policy'; |
|
615 |
} |
|
616 |
if ( is_archive() ) { |
|
0 | 617 |
$classes[] = 'archive'; |
9 | 618 |
} |
619 |
if ( is_date() ) { |
|
0 | 620 |
$classes[] = 'date'; |
9 | 621 |
} |
0 | 622 |
if ( is_search() ) { |
623 |
$classes[] = 'search'; |
|
624 |
$classes[] = $wp_query->posts ? 'search-results' : 'search-no-results'; |
|
625 |
} |
|
9 | 626 |
if ( is_paged() ) { |
0 | 627 |
$classes[] = 'paged'; |
9 | 628 |
} |
629 |
if ( is_attachment() ) { |
|
0 | 630 |
$classes[] = 'attachment'; |
9 | 631 |
} |
632 |
if ( is_404() ) { |
|
0 | 633 |
$classes[] = 'error404'; |
9 | 634 |
} |
0 | 635 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
if ( is_singular() ) { |
9 | 637 |
$post_id = $wp_query->get_queried_object_id(); |
638 |
$post = $wp_query->get_queried_object(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
$post_type = $post->post_type; |
0 | 640 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
if ( is_page_template() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
$classes[] = "{$post_type}-template"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
$template_slug = get_page_template_slug( $post_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
$template_parts = explode( '/', $template_slug ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
foreach ( $template_parts as $part ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( array( '.', '/' ), '-', basename( $part, '.php' ) ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
$classes[] = "{$post_type}-template-" . sanitize_html_class( str_replace( '.', '-', $template_slug ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
$classes[] = "{$post_type}-template-default"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
} |
0 | 654 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
if ( is_single() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
$classes[] = 'single'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
if ( isset( $post->post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
$classes[] = 'single-' . sanitize_html_class( $post->post_type, $post_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
$classes[] = 'postid-' . $post_id; |
0 | 660 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
// Post Format |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
if ( post_type_supports( $post->post_type, 'post-formats' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
$post_format = get_post_format( $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
|
9 | 665 |
if ( $post_format && ! is_wp_error( $post_format ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
$classes[] = 'single-format-' . sanitize_html_class( $post_format ); |
9 | 667 |
} else { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
$classes[] = 'single-format-standard'; |
9 | 669 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
} |
0 | 671 |
} |
672 |
} |
|
673 |
||
674 |
if ( is_attachment() ) { |
|
9 | 675 |
$mime_type = get_post_mime_type( $post_id ); |
0 | 676 |
$mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' ); |
9 | 677 |
$classes[] = 'attachmentid-' . $post_id; |
678 |
$classes[] = 'attachment-' . str_replace( $mime_prefix, '', $mime_type ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
679 |
} elseif ( is_page() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
680 |
$classes[] = 'page'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
682 |
$page_id = $wp_query->get_queried_object_id(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
|
9 | 684 |
$post = get_post( $page_id ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
$classes[] = 'page-id-' . $page_id; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
|
9 | 688 |
if ( get_pages( |
689 |
array( |
|
690 |
'parent' => $page_id, |
|
691 |
'number' => 1, |
|
692 |
) |
|
693 |
) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
$classes[] = 'page-parent'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
if ( $post->post_parent ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
$classes[] = 'page-child'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
$classes[] = 'parent-pageid-' . $post->post_parent; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
} |
0 | 701 |
} |
702 |
} elseif ( is_archive() ) { |
|
703 |
if ( is_post_type_archive() ) { |
|
704 |
$classes[] = 'post-type-archive'; |
|
705 |
$post_type = get_query_var( 'post_type' ); |
|
9 | 706 |
if ( is_array( $post_type ) ) { |
0 | 707 |
$post_type = reset( $post_type ); |
9 | 708 |
} |
0 | 709 |
$classes[] = 'post-type-archive-' . sanitize_html_class( $post_type ); |
5 | 710 |
} elseif ( is_author() ) { |
9 | 711 |
$author = $wp_query->get_queried_object(); |
0 | 712 |
$classes[] = 'author'; |
713 |
if ( isset( $author->user_nicename ) ) { |
|
714 |
$classes[] = 'author-' . sanitize_html_class( $author->user_nicename, $author->ID ); |
|
715 |
$classes[] = 'author-' . $author->ID; |
|
716 |
} |
|
717 |
} elseif ( is_category() ) { |
|
9 | 718 |
$cat = $wp_query->get_queried_object(); |
0 | 719 |
$classes[] = 'category'; |
720 |
if ( isset( $cat->term_id ) ) { |
|
5 | 721 |
$cat_class = sanitize_html_class( $cat->slug, $cat->term_id ); |
722 |
if ( is_numeric( $cat_class ) || ! trim( $cat_class, '-' ) ) { |
|
723 |
$cat_class = $cat->term_id; |
|
724 |
} |
|
725 |
||
726 |
$classes[] = 'category-' . $cat_class; |
|
0 | 727 |
$classes[] = 'category-' . $cat->term_id; |
728 |
} |
|
729 |
} elseif ( is_tag() ) { |
|
9 | 730 |
$tag = $wp_query->get_queried_object(); |
0 | 731 |
$classes[] = 'tag'; |
5 | 732 |
if ( isset( $tag->term_id ) ) { |
733 |
$tag_class = sanitize_html_class( $tag->slug, $tag->term_id ); |
|
734 |
if ( is_numeric( $tag_class ) || ! trim( $tag_class, '-' ) ) { |
|
735 |
$tag_class = $tag->term_id; |
|
736 |
} |
|
737 |
||
738 |
$classes[] = 'tag-' . $tag_class; |
|
739 |
$classes[] = 'tag-' . $tag->term_id; |
|
0 | 740 |
} |
741 |
} elseif ( is_tax() ) { |
|
742 |
$term = $wp_query->get_queried_object(); |
|
743 |
if ( isset( $term->term_id ) ) { |
|
5 | 744 |
$term_class = sanitize_html_class( $term->slug, $term->term_id ); |
745 |
if ( is_numeric( $term_class ) || ! trim( $term_class, '-' ) ) { |
|
746 |
$term_class = $term->term_id; |
|
747 |
} |
|
748 |
||
0 | 749 |
$classes[] = 'tax-' . sanitize_html_class( $term->taxonomy ); |
5 | 750 |
$classes[] = 'term-' . $term_class; |
0 | 751 |
$classes[] = 'term-' . $term->term_id; |
752 |
} |
|
753 |
} |
|
754 |
} |
|
755 |
||
9 | 756 |
if ( is_user_logged_in() ) { |
0 | 757 |
$classes[] = 'logged-in'; |
9 | 758 |
} |
0 | 759 |
|
760 |
if ( is_admin_bar_showing() ) { |
|
761 |
$classes[] = 'admin-bar'; |
|
762 |
$classes[] = 'no-customize-support'; |
|
763 |
} |
|
764 |
||
9 | 765 |
if ( current_theme_supports( 'custom-background' ) |
766 |
&& ( get_background_color() !== get_theme_support( 'custom-background', 'default-color' ) || get_background_image() ) ) { |
|
0 | 767 |
$classes[] = 'custom-background'; |
9 | 768 |
} |
0 | 769 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
if ( has_custom_logo() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
$classes[] = 'wp-custom-logo'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
|
9 | 774 |
if ( current_theme_supports( 'responsive-embeds' ) ) { |
775 |
$classes[] = 'wp-embed-responsive'; |
|
776 |
} |
|
777 |
||
0 | 778 |
$page = $wp_query->get( 'page' ); |
779 |
||
9 | 780 |
if ( ! $page || $page < 2 ) { |
0 | 781 |
$page = $wp_query->get( 'paged' ); |
9 | 782 |
} |
0 | 783 |
|
5 | 784 |
if ( $page && $page > 1 && ! is_404() ) { |
0 | 785 |
$classes[] = 'paged-' . $page; |
786 |
||
9 | 787 |
if ( is_single() ) { |
0 | 788 |
$classes[] = 'single-paged-' . $page; |
9 | 789 |
} elseif ( is_page() ) { |
0 | 790 |
$classes[] = 'page-paged-' . $page; |
9 | 791 |
} elseif ( is_category() ) { |
0 | 792 |
$classes[] = 'category-paged-' . $page; |
9 | 793 |
} elseif ( is_tag() ) { |
0 | 794 |
$classes[] = 'tag-paged-' . $page; |
9 | 795 |
} elseif ( is_date() ) { |
0 | 796 |
$classes[] = 'date-paged-' . $page; |
9 | 797 |
} elseif ( is_author() ) { |
0 | 798 |
$classes[] = 'author-paged-' . $page; |
9 | 799 |
} elseif ( is_search() ) { |
0 | 800 |
$classes[] = 'search-paged-' . $page; |
9 | 801 |
} elseif ( is_post_type_archive() ) { |
0 | 802 |
$classes[] = 'post-type-paged-' . $page; |
9 | 803 |
} |
0 | 804 |
} |
805 |
||
806 |
if ( ! empty( $class ) ) { |
|
9 | 807 |
if ( ! is_array( $class ) ) { |
0 | 808 |
$class = preg_split( '#\s+#', $class ); |
9 | 809 |
} |
0 | 810 |
$classes = array_merge( $classes, $class ); |
811 |
} else { |
|
812 |
// Ensure that we always coerce class to being an array. |
|
813 |
$class = array(); |
|
814 |
} |
|
815 |
||
816 |
$classes = array_map( 'esc_attr', $classes ); |
|
817 |
||
5 | 818 |
/** |
9 | 819 |
* Filters the list of CSS body class names for the current post or page. |
5 | 820 |
* |
821 |
* @since 2.8.0 |
|
822 |
* |
|
9 | 823 |
* @param string[] $classes An array of body class names. |
824 |
* @param string[] $class An array of additional class names added to the body. |
|
5 | 825 |
*/ |
826 |
$classes = apply_filters( 'body_class', $classes, $class ); |
|
827 |
||
828 |
return array_unique( $classes ); |
|
0 | 829 |
} |
830 |
||
831 |
/** |
|
832 |
* Whether post requires password and correct password has been provided. |
|
833 |
* |
|
834 |
* @since 2.7.0 |
|
835 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
836 |
* @param int|WP_Post|null $post An optional post. Global $post used if not provided. |
0 | 837 |
* @return bool false if a password is not required or the correct password cookie is present, true otherwise. |
838 |
*/ |
|
839 |
function post_password_required( $post = null ) { |
|
9 | 840 |
$post = get_post( $post ); |
0 | 841 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
842 |
if ( empty( $post->post_password ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
843 |
/** This filter is documented in wp-includes/post-template.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
844 |
return apply_filters( 'post_password_required', false, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
845 |
} |
0 | 846 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
847 |
if ( ! isset( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
848 |
/** This filter is documented in wp-includes/post-template.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
849 |
return apply_filters( 'post_password_required', true, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
850 |
} |
0 | 851 |
|
5 | 852 |
require_once ABSPATH . WPINC . '/class-phpass.php'; |
0 | 853 |
$hasher = new PasswordHash( 8, true ); |
854 |
||
855 |
$hash = wp_unslash( $_COOKIE[ 'wp-postpass_' . COOKIEHASH ] ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
856 |
if ( 0 !== strpos( $hash, '$P$B' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
857 |
$required = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
858 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
859 |
$required = ! $hasher->CheckPassword( $post->post_password, $hash ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
860 |
} |
0 | 861 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
* Filters whether a post requires the user to supply a password. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
* @since 4.7.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
866 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
867 |
* @param bool $required Whether the user needs to supply a password. True if password has not been |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
868 |
* provided or is incorrect, false if password has been supplied or is not required. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
869 |
* @param WP_Post $post Post data. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
870 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
871 |
return apply_filters( 'post_password_required', $required, $post ); |
0 | 872 |
} |
873 |
||
5 | 874 |
// |
875 |
// Page Template Functions for usage in Themes |
|
876 |
// |
|
0 | 877 |
|
878 |
/** |
|
879 |
* The formatted output of a list of pages. |
|
880 |
* |
|
9 | 881 |
* Displays page links for paginated posts (i.e. including the `<!--nextpage-->` |
0 | 882 |
* Quicktag one or more times). This tag must be within The Loop. |
883 |
* |
|
884 |
* @since 1.2.0 |
|
9 | 885 |
* @since 5.1.0 Added the `aria_current` argument. |
0 | 886 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
887 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
* @global int $numpages |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
* @global int $multipage |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
* @global int $more |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
* |
5 | 892 |
* @param string|array $args { |
893 |
* Optional. Array or string of default arguments. |
|
894 |
* |
|
895 |
* @type string $before HTML or text to prepend to each link. Default is `<p> Pages:`. |
|
896 |
* @type string $after HTML or text to append to each link. Default is `</p>`. |
|
897 |
* @type string $link_before HTML or text to prepend to each link, inside the `<a>` tag. |
|
898 |
* Also prepended to the current item, which is not linked. Default empty. |
|
899 |
* @type string $link_after HTML or text to append to each Pages link inside the `<a>` tag. |
|
900 |
* Also appended to the current item, which is not linked. Default empty. |
|
9 | 901 |
* @type string $aria_current The value for the aria-current attribute. Possible values are 'page', |
902 |
* 'step', 'location', 'date', 'time', 'true', 'false'. Default is 'page'. |
|
5 | 903 |
* @type string $next_or_number Indicates whether page numbers should be used. Valid values are number |
904 |
* and next. Default is 'number'. |
|
905 |
* @type string $separator Text between pagination links. Default is ' '. |
|
906 |
* @type string $nextpagelink Link text for the next page link, if available. Default is 'Next Page'. |
|
907 |
* @type string $previouspagelink Link text for the previous page link, if available. Default is 'Previous Page'. |
|
908 |
* @type string $pagelink Format string for page numbers. The % in the parameter string will be |
|
909 |
* replaced with the page number, so 'Page %' generates "Page 1", "Page 2", etc. |
|
910 |
* Defaults to '%', just the page number. |
|
911 |
* @type int|bool $echo Whether to echo or not. Accepts 1|true or 0|false. Default 1|true. |
|
912 |
* } |
|
0 | 913 |
* @return string Formatted output in HTML. |
914 |
*/ |
|
915 |
function wp_link_pages( $args = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
global $page, $numpages, $multipage, $more; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
|
0 | 918 |
$defaults = array( |
9 | 919 |
'before' => '<p class="post-nav-links">' . __( 'Pages:' ), |
0 | 920 |
'after' => '</p>', |
921 |
'link_before' => '', |
|
922 |
'link_after' => '', |
|
9 | 923 |
'aria_current' => 'page', |
0 | 924 |
'next_or_number' => 'number', |
925 |
'separator' => ' ', |
|
926 |
'nextpagelink' => __( 'Next page' ), |
|
927 |
'previouspagelink' => __( 'Previous page' ), |
|
928 |
'pagelink' => '%', |
|
9 | 929 |
'echo' => 1, |
0 | 930 |
); |
931 |
||
5 | 932 |
$params = wp_parse_args( $args, $defaults ); |
933 |
||
934 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
935 |
* Filters the arguments used in retrieving page links for paginated posts. |
5 | 936 |
* |
937 |
* @since 3.0.0 |
|
938 |
* |
|
939 |
* @param array $params An array of arguments for page links for paginated posts. |
|
940 |
*/ |
|
941 |
$r = apply_filters( 'wp_link_pages_args', $params ); |
|
0 | 942 |
|
943 |
$output = ''; |
|
944 |
if ( $multipage ) { |
|
5 | 945 |
if ( 'number' == $r['next_or_number'] ) { |
946 |
$output .= $r['before']; |
|
0 | 947 |
for ( $i = 1; $i <= $numpages; $i++ ) { |
5 | 948 |
$link = $r['link_before'] . str_replace( '%', $i, $r['pagelink'] ) . $r['link_after']; |
949 |
if ( $i != $page || ! $more && 1 == $page ) { |
|
0 | 950 |
$link = _wp_link_page( $i ) . $link . '</a>'; |
9 | 951 |
} elseif ( $i === $page ) { |
952 |
$link = '<span class="post-page-numbers current" aria-current="' . esc_attr( $r['aria_current'] ) . '">' . $link . '</span>'; |
|
5 | 953 |
} |
954 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
* Filters the HTML output of individual page number links. |
5 | 956 |
* |
957 |
* @since 3.6.0 |
|
958 |
* |
|
959 |
* @param string $link The page number HTML output. |
|
960 |
* @param int $i Page number for paginated posts' page links. |
|
961 |
*/ |
|
0 | 962 |
$link = apply_filters( 'wp_link_pages_link', $link, $i ); |
5 | 963 |
|
964 |
// Use the custom links separator beginning with the second link. |
|
965 |
$output .= ( 1 === $i ) ? ' ' : $r['separator']; |
|
966 |
$output .= $link; |
|
0 | 967 |
} |
5 | 968 |
$output .= $r['after']; |
0 | 969 |
} elseif ( $more ) { |
5 | 970 |
$output .= $r['before']; |
9 | 971 |
$prev = $page - 1; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
972 |
if ( $prev > 0 ) { |
5 | 973 |
$link = _wp_link_page( $prev ) . $r['link_before'] . $r['previouspagelink'] . $r['link_after'] . '</a>'; |
974 |
||
975 |
/** This filter is documented in wp-includes/post-template.php */ |
|
976 |
$output .= apply_filters( 'wp_link_pages_link', $link, $prev ); |
|
0 | 977 |
} |
5 | 978 |
$next = $page + 1; |
979 |
if ( $next <= $numpages ) { |
|
980 |
if ( $prev ) { |
|
981 |
$output .= $r['separator']; |
|
982 |
} |
|
983 |
$link = _wp_link_page( $next ) . $r['link_before'] . $r['nextpagelink'] . $r['link_after'] . '</a>'; |
|
984 |
||
985 |
/** This filter is documented in wp-includes/post-template.php */ |
|
986 |
$output .= apply_filters( 'wp_link_pages_link', $link, $next ); |
|
0 | 987 |
} |
5 | 988 |
$output .= $r['after']; |
0 | 989 |
} |
990 |
} |
|
991 |
||
5 | 992 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
* Filters the HTML output of page links for paginated posts. |
5 | 994 |
* |
995 |
* @since 3.6.0 |
|
996 |
* |
|
997 |
* @param string $output HTML output of paginated posts' page links. |
|
998 |
* @param array $args An array of arguments. |
|
999 |
*/ |
|
1000 |
$html = apply_filters( 'wp_link_pages', $output, $args ); |
|
0 | 1001 |
|
5 | 1002 |
if ( $r['echo'] ) { |
1003 |
echo $html; |
|
1004 |
} |
|
1005 |
return $html; |
|
0 | 1006 |
} |
1007 |
||
1008 |
/** |
|
1009 |
* Helper function for wp_link_pages(). |
|
1010 |
* |
|
1011 |
* @since 3.1.0 |
|
1012 |
* @access private |
|
1013 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
* @global WP_Rewrite $wp_rewrite |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
* |
0 | 1016 |
* @param int $i Page number. |
1017 |
* @return string Link. |
|
1018 |
*/ |
|
1019 |
function _wp_link_page( $i ) { |
|
1020 |
global $wp_rewrite; |
|
9 | 1021 |
$post = get_post(); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
$query_args = array(); |
0 | 1023 |
|
1024 |
if ( 1 == $i ) { |
|
1025 |
$url = get_permalink(); |
|
1026 |
} else { |
|
9 | 1027 |
if ( '' == get_option( 'permalink_structure' ) || in_array( $post->post_status, array( 'draft', 'pending' ) ) ) { |
0 | 1028 |
$url = add_query_arg( 'page', $i, get_permalink() ); |
9 | 1029 |
} elseif ( 'page' == get_option( 'show_on_front' ) && get_option( 'page_on_front' ) == $post->ID ) { |
1030 |
$url = trailingslashit( get_permalink() ) . user_trailingslashit( "$wp_rewrite->pagination_base/" . $i, 'single_paged' ); |
|
1031 |
} else { |
|
1032 |
$url = trailingslashit( get_permalink() ) . user_trailingslashit( $i, 'single_paged' ); |
|
1033 |
} |
|
0 | 1034 |
} |
1035 |
||
5 | 1036 |
if ( is_preview() ) { |
1037 |
||
1038 |
if ( ( 'draft' !== $post->post_status ) && isset( $_GET['preview_id'], $_GET['preview_nonce'] ) ) { |
|
9 | 1039 |
$query_args['preview_id'] = wp_unslash( $_GET['preview_id'] ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
$query_args['preview_nonce'] = wp_unslash( $_GET['preview_nonce'] ); |
5 | 1041 |
} |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
$url = get_preview_post_link( $post, $query_args, $url ); |
5 | 1044 |
} |
1045 |
||
9 | 1046 |
return '<a href="' . esc_url( $url ) . '" class="post-page-numbers">'; |
0 | 1047 |
} |
1048 |
||
1049 |
// |
|
1050 |
// Post-meta: Custom per-post fields. |
|
1051 |
// |
|
1052 |
||
1053 |
/** |
|
1054 |
* Retrieve post custom meta data field. |
|
1055 |
* |
|
1056 |
* @since 1.5.0 |
|
1057 |
* |
|
1058 |
* @param string $key Meta data key name. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1059 |
* @return false|string|array Array of values or single value, if only one element exists. False will be returned if key does not exist. |
0 | 1060 |
*/ |
1061 |
function post_custom( $key = '' ) { |
|
1062 |
$custom = get_post_custom(); |
|
1063 |
||
9 | 1064 |
if ( ! isset( $custom[ $key ] ) ) { |
0 | 1065 |
return false; |
9 | 1066 |
} elseif ( 1 == count( $custom[ $key ] ) ) { |
1067 |
return $custom[ $key ][0]; |
|
1068 |
} else { |
|
1069 |
return $custom[ $key ]; |
|
1070 |
} |
|
0 | 1071 |
} |
1072 |
||
1073 |
/** |
|
9 | 1074 |
* Display a list of post custom fields. |
0 | 1075 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1076 |
* @since 1.2.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1077 |
* |
0 | 1078 |
* @internal This will probably change at some point... |
1079 |
*/ |
|
1080 |
function the_meta() { |
|
1081 |
if ( $keys = get_post_custom_keys() ) { |
|
9 | 1082 |
$li_html = ''; |
0 | 1083 |
foreach ( (array) $keys as $key ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
$keyt = trim( $key ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
if ( is_protected_meta( $keyt, 'post' ) ) { |
0 | 1086 |
continue; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1087 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
$values = array_map( 'trim', get_post_custom_values( $key ) ); |
9 | 1090 |
$value = implode( $values, ', ' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1091 |
|
9 | 1092 |
$html = sprintf( |
1093 |
"<li><span class='post-meta-key'>%s</span> %s</li>\n", |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
/* translators: %s: Post custom field name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1095 |
sprintf( _x( '%s:', 'Post custom field name' ), $key ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
$value |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
); |
5 | 1098 |
|
1099 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
* Filters the HTML output of the li element in the post custom fields list. |
5 | 1101 |
* |
1102 |
* @since 2.2.0 |
|
1103 |
* |
|
1104 |
* @param string $html The HTML output for the li element. |
|
1105 |
* @param string $key Meta key. |
|
1106 |
* @param string $value Meta value. |
|
1107 |
*/ |
|
9 | 1108 |
$li_html .= apply_filters( 'the_meta_key', $html, $key, $value ); |
0 | 1109 |
} |
9 | 1110 |
|
1111 |
if ( $li_html ) { |
|
1112 |
echo "<ul class='post-meta'>\n{$li_html}</ul>\n"; |
|
1113 |
} |
|
0 | 1114 |
} |
1115 |
} |
|
1116 |
||
1117 |
// |
|
1118 |
// Pages |
|
1119 |
// |
|
1120 |
||
1121 |
/** |
|
9 | 1122 |
* Retrieve or display a list of pages as a dropdown (select list). |
0 | 1123 |
* |
1124 |
* @since 2.1.0 |
|
5 | 1125 |
* @since 4.2.0 The `$value_field` argument was added. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
* @since 4.3.0 The `$class` argument was added. |
0 | 1127 |
* |
9 | 1128 |
* @see get_pages() |
1129 |
* |
|
5 | 1130 |
* @param array|string $args { |
9 | 1131 |
* Optional. Array or string of arguments to generate a page dropdown. See `get_pages()` for additional arguments. |
5 | 1132 |
* |
1133 |
* @type int $depth Maximum depth. Default 0. |
|
1134 |
* @type int $child_of Page ID to retrieve child pages of. Default 0. |
|
1135 |
* @type int|string $selected Value of the option that should be selected. Default 0. |
|
1136 |
* @type bool|int $echo Whether to echo or return the generated markup. Accepts 0, 1, |
|
1137 |
* or their bool equivalents. Default 1. |
|
1138 |
* @type string $name Value for the 'name' attribute of the select element. |
|
1139 |
* Default 'page_id'. |
|
1140 |
* @type string $id Value for the 'id' attribute of the select element. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
* @type string $class Value for the 'class' attribute of the select element. Default: none. |
5 | 1142 |
* Defaults to the value of `$name`. |
1143 |
* @type string $show_option_none Text to display for showing no pages. Default empty (does not display). |
|
1144 |
* @type string $show_option_no_change Text to display for "no change" option. Default empty (does not display). |
|
1145 |
* @type string $option_none_value Value to use when no page is selected. Default empty. |
|
1146 |
* @type string $value_field Post field used to populate the 'value' attribute of the option |
|
1147 |
* elements. Accepts any valid post field. Default 'ID'. |
|
1148 |
* } |
|
0 | 1149 |
* @return string HTML content, if not displaying. |
1150 |
*/ |
|
5 | 1151 |
function wp_dropdown_pages( $args = '' ) { |
0 | 1152 |
$defaults = array( |
9 | 1153 |
'depth' => 0, |
1154 |
'child_of' => 0, |
|
1155 |
'selected' => 0, |
|
1156 |
'echo' => 1, |
|
1157 |
'name' => 'page_id', |
|
1158 |
'id' => '', |
|
1159 |
'class' => '', |
|
1160 |
'show_option_none' => '', |
|
1161 |
'show_option_no_change' => '', |
|
1162 |
'option_none_value' => '', |
|
1163 |
'value_field' => 'ID', |
|
0 | 1164 |
); |
1165 |
||
1166 |
$r = wp_parse_args( $args, $defaults ); |
|
1167 |
||
9 | 1168 |
$pages = get_pages( $r ); |
0 | 1169 |
$output = ''; |
1170 |
// Back-compat with old system where both id and name were based on $name argument |
|
5 | 1171 |
if ( empty( $r['id'] ) ) { |
1172 |
$r['id'] = $r['name']; |
|
1173 |
} |
|
0 | 1174 |
|
5 | 1175 |
if ( ! empty( $pages ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
$class = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
if ( ! empty( $r['class'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1178 |
$class = " class='" . esc_attr( $r['class'] ) . "'"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
$output = "<select name='" . esc_attr( $r['name'] ) . "'" . $class . " id='" . esc_attr( $r['id'] ) . "'>\n"; |
5 | 1182 |
if ( $r['show_option_no_change'] ) { |
1183 |
$output .= "\t<option value=\"-1\">" . $r['show_option_no_change'] . "</option>\n"; |
|
1184 |
} |
|
1185 |
if ( $r['show_option_none'] ) { |
|
1186 |
$output .= "\t<option value=\"" . esc_attr( $r['option_none_value'] ) . '">' . $r['show_option_none'] . "</option>\n"; |
|
1187 |
} |
|
1188 |
$output .= walk_page_dropdown_tree( $pages, $r['depth'], $r ); |
|
0 | 1189 |
$output .= "</select>\n"; |
1190 |
} |
|
1191 |
||
5 | 1192 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1193 |
* Filters the HTML output of a list of pages as a drop down. |
5 | 1194 |
* |
1195 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1196 |
* @since 4.4.0 `$r` and `$pages` added as arguments. |
5 | 1197 |
* |
1198 |
* @param string $output HTML output for drop down list of pages. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1199 |
* @param array $r The parsed arguments array. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1200 |
* @param array $pages List of WP_Post objects returned by `get_pages()` |
9 | 1201 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
$html = apply_filters( 'wp_dropdown_pages', $output, $r, $pages ); |
0 | 1203 |
|
5 | 1204 |
if ( $r['echo'] ) { |
1205 |
echo $html; |
|
1206 |
} |
|
1207 |
return $html; |
|
0 | 1208 |
} |
1209 |
||
1210 |
/** |
|
9 | 1211 |
* Retrieve or display a list of pages (or hierarchical post type items) in list (li) format. |
0 | 1212 |
* |
1213 |
* @since 1.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1214 |
* @since 4.7.0 Added the `item_spacing` argument. |
0 | 1215 |
* |
5 | 1216 |
* @see get_pages() |
1217 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
* @global WP_Query $wp_query |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
* |
5 | 1220 |
* @param array|string $args { |
9 | 1221 |
* Optional. Array or string of arguments to generate a list of pages. See `get_pages()` for additional arguments. |
5 | 1222 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
* @type int $child_of Display only the sub-pages of a single page by ID. Default 0 (all pages). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* @type string $authors Comma-separated list of author IDs. Default empty (all authors). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
* @type string $date_format PHP date format to use for the listed pages. Relies on the 'show_date' parameter. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* Default is the value of 'date_format' option. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* @type int $depth Number of levels in the hierarchy of pages to include in the generated list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
* Accepts -1 (any depth), 0 (all pages), 1 (top-level pages only), and n (pages to |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
* the given n depth). Default 0. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
* @type bool $echo Whether or not to echo the list of pages. Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
* @type string $exclude Comma-separated list of page IDs to exclude. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1232 |
* @type array $include Comma-separated list of page IDs to include. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
* @type string $link_after Text or HTML to follow the page link label. Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
* @type string $link_before Text or HTML to precede the page link label. Default null. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
* @type string $post_type Post type to query for. Default 'page'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
* @type string|array $post_status Comma-separated list or array of post statuses to include. Default 'publish'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
* @type string $show_date Whether to display the page publish or modified date for each page. Accepts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
* 'modified' or any other value. An empty value hides the date. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
* @type string $sort_column Comma-separated list of column names to sort the pages by. Accepts 'post_author', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
* 'post_date', 'post_title', 'post_name', 'post_modified', 'post_modified_gmt', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1241 |
* 'menu_order', 'post_parent', 'ID', 'rand', or 'comment_count'. Default 'post_title'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
* @type string $title_li List heading. Passing a null or empty value will result in no heading, and the list |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1243 |
* will not be wrapped with unordered list `<ul>` tags. Default 'Pages'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
* @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' or 'discard'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
* Default 'preserve'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1246 |
* @type Walker $walker Walker instance to use for listing pages. Default empty (Walker_Page). |
5 | 1247 |
* } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1248 |
* @return string|void HTML list of pages. |
0 | 1249 |
*/ |
5 | 1250 |
function wp_list_pages( $args = '' ) { |
0 | 1251 |
$defaults = array( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
'depth' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
'show_date' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
'date_format' => get_option( 'date_format' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
'child_of' => 0, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
'exclude' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
'title_li' => __( 'Pages' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
'echo' => 1, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1259 |
'authors' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
'sort_column' => 'menu_order, post_title', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
'link_before' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1262 |
'link_after' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1263 |
'item_spacing' => 'preserve', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
'walker' => '', |
0 | 1265 |
); |
1266 |
||
1267 |
$r = wp_parse_args( $args, $defaults ); |
|
1268 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1269 |
if ( ! in_array( $r['item_spacing'], array( 'preserve', 'discard' ), true ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1270 |
// invalid value, fall back to default. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
$r['item_spacing'] = $defaults['item_spacing']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1273 |
|
9 | 1274 |
$output = ''; |
0 | 1275 |
$current_page = 0; |
1276 |
||
1277 |
// sanitize, mostly to keep spaces out |
|
5 | 1278 |
$r['exclude'] = preg_replace( '/[^0-9,]/', '', $r['exclude'] ); |
0 | 1279 |
|
1280 |
// Allow plugins to filter an array of excluded pages (but don't put a nullstring into the array) |
|
5 | 1281 |
$exclude_array = ( $r['exclude'] ) ? explode( ',', $r['exclude'] ) : array(); |
1282 |
||
1283 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
* Filters the array of pages to exclude from the pages list. |
5 | 1285 |
* |
1286 |
* @since 2.1.0 |
|
1287 |
* |
|
1288 |
* @param array $exclude_array An array of page IDs to exclude. |
|
1289 |
*/ |
|
1290 |
$r['exclude'] = implode( ',', apply_filters( 'wp_list_pages_excludes', $exclude_array ) ); |
|
0 | 1291 |
|
1292 |
// Query pages. |
|
1293 |
$r['hierarchical'] = 0; |
|
9 | 1294 |
$pages = get_pages( $r ); |
0 | 1295 |
|
5 | 1296 |
if ( ! empty( $pages ) ) { |
1297 |
if ( $r['title_li'] ) { |
|
0 | 1298 |
$output .= '<li class="pagenav">' . $r['title_li'] . '<ul>'; |
5 | 1299 |
} |
0 | 1300 |
global $wp_query; |
5 | 1301 |
if ( is_page() || is_attachment() || $wp_query->is_posts_page ) { |
1302 |
$current_page = get_queried_object_id(); |
|
1303 |
} elseif ( is_singular() ) { |
|
1304 |
$queried_object = get_queried_object(); |
|
1305 |
if ( is_post_type_hierarchical( $queried_object->post_type ) ) { |
|
1306 |
$current_page = $queried_object->ID; |
|
1307 |
} |
|
1308 |
} |
|
0 | 1309 |
|
5 | 1310 |
$output .= walk_page_tree( $pages, $r['depth'], $current_page, $r ); |
1311 |
||
1312 |
if ( $r['title_li'] ) { |
|
0 | 1313 |
$output .= '</ul></li>'; |
5 | 1314 |
} |
0 | 1315 |
} |
1316 |
||
5 | 1317 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
* Filters the HTML output of the pages to list. |
5 | 1319 |
* |
1320 |
* @since 1.5.1 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
* @since 4.4.0 `$pages` added as arguments. |
5 | 1322 |
* |
1323 |
* @see wp_list_pages() |
|
1324 |
* |
|
1325 |
* @param string $output HTML output of the pages list. |
|
1326 |
* @param array $r An array of page-listing arguments. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
* @param array $pages List of WP_Post objects returned by `get_pages()` |
5 | 1328 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
$html = apply_filters( 'wp_list_pages', $output, $r, $pages ); |
0 | 1330 |
|
5 | 1331 |
if ( $r['echo'] ) { |
1332 |
echo $html; |
|
1333 |
} else { |
|
1334 |
return $html; |
|
1335 |
} |
|
0 | 1336 |
} |
1337 |
||
1338 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1339 |
* Displays or retrieves a list of pages with an optional home link. |
0 | 1340 |
* |
9 | 1341 |
* The arguments are listed below and part of the arguments are for wp_list_pages() function. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1342 |
* Check that function for more info on those arguments. |
0 | 1343 |
* |
1344 |
* @since 2.7.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
* @since 4.4.0 Added `menu_id`, `container`, `before`, `after`, and `walker` arguments. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
* @since 4.7.0 Added the `item_spacing` argument. |
0 | 1347 |
* |
5 | 1348 |
* @param array|string $args { |
9 | 1349 |
* Optional. Array or string of arguments to generate a page menu. See `wp_list_pages()` for additional arguments. |
5 | 1350 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
* @type string $sort_column How to sort the list of pages. Accepts post column names. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
* Default 'menu_order, post_title'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1353 |
* @type string $menu_id ID for the div containing the page list. Default is empty string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* @type string $menu_class Class to use for the element containing the page list. Default 'menu'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* @type string $container Element to use for the element containing the page list. Default 'div'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* @type bool $echo Whether to echo the list or return it. Accepts true (echo) or false (return). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1357 |
* Default true. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1358 |
* @type int|bool|string $show_home Whether to display the link to the home page. Can just enter the text |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1359 |
* you'd like shown for the home link. 1|true defaults to 'Home'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1360 |
* @type string $link_before The HTML or text to prepend to $show_home text. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1361 |
* @type string $link_after The HTML or text to append to $show_home text. Default empty. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
* @type string $before The HTML or text to prepend to the menu. Default is '<ul>'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1363 |
* @type string $after The HTML or text to append to the menu. Default is '</ul>'. |
9 | 1364 |
* @type string $item_spacing Whether to preserve whitespace within the menu's HTML. Accepts 'preserve' |
1365 |
* or 'discard'. Default 'discard'. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1366 |
* @type Walker $walker Walker instance to use for listing pages. Default empty (Walker_Page). |
5 | 1367 |
* } |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1368 |
* @return string|void HTML menu |
0 | 1369 |
*/ |
1370 |
function wp_page_menu( $args = array() ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1371 |
$defaults = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1372 |
'sort_column' => 'menu_order, post_title', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1373 |
'menu_id' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1374 |
'menu_class' => 'menu', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1375 |
'container' => 'div', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1376 |
'echo' => true, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1377 |
'link_before' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1378 |
'link_after' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1379 |
'before' => '<ul>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1380 |
'after' => '</ul>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1381 |
'item_spacing' => 'discard', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1382 |
'walker' => '', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
); |
9 | 1384 |
$args = wp_parse_args( $args, $defaults ); |
5 | 1385 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1386 |
if ( ! in_array( $args['item_spacing'], array( 'preserve', 'discard' ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1387 |
// invalid value, fall back to default. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1388 |
$args['item_spacing'] = $defaults['item_spacing']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1389 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
if ( 'preserve' === $args['item_spacing'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
$t = "\t"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
$n = "\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
$t = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
$n = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
|
5 | 1399 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
* Filters the arguments used to generate a page-based menu. |
5 | 1401 |
* |
1402 |
* @since 2.7.0 |
|
1403 |
* |
|
1404 |
* @see wp_page_menu() |
|
1405 |
* |
|
1406 |
* @param array $args An array of page menu arguments. |
|
1407 |
*/ |
|
0 | 1408 |
$args = apply_filters( 'wp_page_menu_args', $args ); |
1409 |
||
1410 |
$menu = ''; |
|
1411 |
||
1412 |
$list_args = $args; |
|
1413 |
||
1414 |
// Show Home in the menu |
|
9 | 1415 |
if ( ! empty( $args['show_home'] ) ) { |
1416 |
if ( true === $args['show_home'] || '1' === $args['show_home'] || 1 === $args['show_home'] ) { |
|
1417 |
$text = __( 'Home' ); |
|
1418 |
} else { |
|
0 | 1419 |
$text = $args['show_home']; |
9 | 1420 |
} |
0 | 1421 |
$class = ''; |
9 | 1422 |
if ( is_front_page() && ! is_paged() ) { |
0 | 1423 |
$class = 'class="current_page_item"'; |
9 | 1424 |
} |
0 | 1425 |
$menu .= '<li ' . $class . '><a href="' . home_url( '/' ) . '">' . $args['link_before'] . $text . $args['link_after'] . '</a></li>'; |
1426 |
// If the front page is a page, add it to the exclude list |
|
9 | 1427 |
if ( get_option( 'show_on_front' ) == 'page' ) { |
1428 |
if ( ! empty( $list_args['exclude'] ) ) { |
|
0 | 1429 |
$list_args['exclude'] .= ','; |
1430 |
} else { |
|
1431 |
$list_args['exclude'] = ''; |
|
1432 |
} |
|
9 | 1433 |
$list_args['exclude'] .= get_option( 'page_on_front' ); |
0 | 1434 |
} |
1435 |
} |
|
1436 |
||
9 | 1437 |
$list_args['echo'] = false; |
0 | 1438 |
$list_args['title_li'] = ''; |
9 | 1439 |
$menu .= wp_list_pages( $list_args ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1440 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
$container = sanitize_text_field( $args['container'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
// Fallback in case `wp_nav_menu()` was called without a container. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
if ( empty( $container ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
$container = 'div'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1448 |
if ( $menu ) { |
0 | 1449 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
// wp_nav_menu doesn't set before and after |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
if ( isset( $args['fallback_cb'] ) && |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
'wp_page_menu' === $args['fallback_cb'] && |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
'ul' !== $container ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
$args['before'] = "<ul>{$n}"; |
9 | 1455 |
$args['after'] = '</ul>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1456 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
$menu = $args['before'] . $menu . $args['after']; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
} |
0 | 1460 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1461 |
$attrs = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
if ( ! empty( $args['menu_id'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
$attrs .= ' id="' . esc_attr( $args['menu_id'] ) . '"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1466 |
if ( ! empty( $args['menu_class'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
$attrs .= ' class="' . esc_attr( $args['menu_class'] ) . '"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
$menu = "<{$container}{$attrs}>" . $menu . "</{$container}>{$n}"; |
5 | 1471 |
|
1472 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
* Filters the HTML output of a page-based menu. |
5 | 1474 |
* |
1475 |
* @since 2.7.0 |
|
1476 |
* |
|
1477 |
* @see wp_page_menu() |
|
1478 |
* |
|
1479 |
* @param string $menu The HTML output. |
|
1480 |
* @param array $args An array of arguments. |
|
1481 |
*/ |
|
0 | 1482 |
$menu = apply_filters( 'wp_page_menu', $menu, $args ); |
9 | 1483 |
if ( $args['echo'] ) { |
0 | 1484 |
echo $menu; |
9 | 1485 |
} else { |
0 | 1486 |
return $menu; |
9 | 1487 |
} |
0 | 1488 |
} |
1489 |
||
1490 |
// |
|
1491 |
// Page helpers |
|
1492 |
// |
|
1493 |
||
1494 |
/** |
|
1495 |
* Retrieve HTML list content for page list. |
|
1496 |
* |
|
1497 |
* @uses Walker_Page to create HTML list content. |
|
1498 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1499 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1500 |
* @param array $pages |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1501 |
* @param int $depth |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1502 |
* @param int $current_page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1503 |
* @param array $r |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1504 |
* @return string |
0 | 1505 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1506 |
function walk_page_tree( $pages, $depth, $current_page, $r ) { |
9 | 1507 |
if ( empty( $r['walker'] ) ) { |
0 | 1508 |
$walker = new Walker_Page; |
9 | 1509 |
} else { |
0 | 1510 |
$walker = $r['walker']; |
9 | 1511 |
} |
0 | 1512 |
|
1513 |
foreach ( (array) $pages as $page ) { |
|
9 | 1514 |
if ( $page->post_parent ) { |
0 | 1515 |
$r['pages_with_children'][ $page->post_parent ] = true; |
9 | 1516 |
} |
0 | 1517 |
} |
1518 |
||
9 | 1519 |
$args = array( $pages, $depth, $r, $current_page ); |
1520 |
return call_user_func_array( array( $walker, 'walk' ), $args ); |
|
0 | 1521 |
} |
1522 |
||
1523 |
/** |
|
1524 |
* Retrieve HTML dropdown (select) content for page list. |
|
1525 |
* |
|
1526 |
* @uses Walker_PageDropdown to create HTML dropdown content. |
|
1527 |
* @since 2.1.0 |
|
1528 |
* @see Walker_PageDropdown::walk() for parameters and return description. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1530 |
* @return string |
0 | 1531 |
*/ |
1532 |
function walk_page_dropdown_tree() { |
|
1533 |
$args = func_get_args(); |
|
9 | 1534 |
if ( empty( $args[2]['walker'] ) ) { // the user's options are the third parameter |
0 | 1535 |
$walker = new Walker_PageDropdown; |
9 | 1536 |
} else { |
0 | 1537 |
$walker = $args[2]['walker']; |
9 | 1538 |
} |
0 | 1539 |
|
9 | 1540 |
return call_user_func_array( array( $walker, 'walk' ), $args ); |
0 | 1541 |
} |
1542 |
||
1543 |
// |
|
1544 |
// Attachments |
|
1545 |
// |
|
1546 |
||
1547 |
/** |
|
1548 |
* Display an attachment page link using an image or icon. |
|
1549 |
* |
|
1550 |
* @since 2.0.0 |
|
1551 |
* |
|
5 | 1552 |
* @param int|WP_Post $id Optional. Post ID or post object. |
1553 |
* @param bool $fullsize Optional, default is false. Whether to use full size. |
|
1554 |
* @param bool $deprecated Deprecated. Not used. |
|
1555 |
* @param bool $permalink Optional, default is false. Whether to include permalink. |
|
0 | 1556 |
*/ |
1557 |
function the_attachment_link( $id = 0, $fullsize = false, $deprecated = false, $permalink = false ) { |
|
9 | 1558 |
if ( ! empty( $deprecated ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1559 |
_deprecated_argument( __FUNCTION__, '2.5.0' ); |
9 | 1560 |
} |
0 | 1561 |
|
9 | 1562 |
if ( $fullsize ) { |
1563 |
echo wp_get_attachment_link( $id, 'full', $permalink ); |
|
1564 |
} else { |
|
1565 |
echo wp_get_attachment_link( $id, 'thumbnail', $permalink ); |
|
1566 |
} |
|
0 | 1567 |
} |
1568 |
||
1569 |
/** |
|
1570 |
* Retrieve an attachment page link using an image or icon, if possible. |
|
1571 |
* |
|
1572 |
* @since 2.5.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1573 |
* @since 4.4.0 The `$id` parameter can now accept either a post ID or `WP_Post` object. |
0 | 1574 |
* |
5 | 1575 |
* @param int|WP_Post $id Optional. Post ID or post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1576 |
* @param string|array $size Optional. Image size. Accepts any valid image size, or an array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1577 |
* of width and height values in pixels (in that order). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1578 |
* Default 'thumbnail'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1579 |
* @param bool $permalink Optional, Whether to add permalink to image. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1580 |
* @param bool $icon Optional. Whether the attachment is an icon. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1581 |
* @param string|false $text Optional. Link text to use. Activated by passing a string, false otherwise. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1582 |
* Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1583 |
* @param array|string $attr Optional. Array or string of attributes. Default empty. |
0 | 1584 |
* @return string HTML content. |
1585 |
*/ |
|
5 | 1586 |
function wp_get_attachment_link( $id = 0, $size = 'thumbnail', $permalink = false, $icon = false, $text = false, $attr = '' ) { |
0 | 1587 |
$_post = get_post( $id ); |
1588 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1589 |
if ( empty( $_post ) || ( 'attachment' !== $_post->post_type ) || ! $url = wp_get_attachment_url( $_post->ID ) ) { |
0 | 1590 |
return __( 'Missing Attachment' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1591 |
} |
0 | 1592 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1593 |
if ( $permalink ) { |
0 | 1594 |
$url = get_attachment_link( $_post->ID ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1595 |
} |
0 | 1596 |
|
5 | 1597 |
if ( $text ) { |
0 | 1598 |
$link_text = $text; |
5 | 1599 |
} elseif ( $size && 'none' != $size ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1600 |
$link_text = wp_get_attachment_image( $_post->ID, $size, $icon, $attr ); |
5 | 1601 |
} else { |
0 | 1602 |
$link_text = ''; |
5 | 1603 |
} |
0 | 1604 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1605 |
if ( '' === trim( $link_text ) ) { |
0 | 1606 |
$link_text = $_post->post_title; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1607 |
} |
0 | 1608 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1609 |
if ( '' === trim( $link_text ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1610 |
$link_text = esc_html( pathinfo( get_attached_file( $_post->ID ), PATHINFO_FILENAME ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1611 |
} |
5 | 1612 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1613 |
* Filters a retrieved attachment page link. |
5 | 1614 |
* |
1615 |
* @since 2.7.0 |
|
9 | 1616 |
* @since 5.1.0 Added the $attr parameter. |
5 | 1617 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1618 |
* @param string $link_html The page link HTML output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1619 |
* @param int $id Post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1620 |
* @param string|array $size Size of the image. Image size or array of width and height values (in that order). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1621 |
* Default 'thumbnail'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1622 |
* @param bool $permalink Whether to add permalink to image. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1623 |
* @param bool $icon Whether to include an icon. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1624 |
* @param string|bool $text If string, will be link text. Default false. |
9 | 1625 |
* @param array|string $attr Array or string of attributes. Default empty. |
5 | 1626 |
*/ |
9 | 1627 |
return apply_filters( 'wp_get_attachment_link', "<a href='" . esc_url( $url ) . "'>$link_text</a>", $id, $size, $permalink, $icon, $text, $attr ); |
0 | 1628 |
} |
1629 |
||
1630 |
/** |
|
5 | 1631 |
* Wrap attachment in paragraph tag before content. |
0 | 1632 |
* |
1633 |
* @since 2.0.0 |
|
1634 |
* |
|
1635 |
* @param string $content |
|
1636 |
* @return string |
|
1637 |
*/ |
|
9 | 1638 |
function prepend_attachment( $content ) { |
0 | 1639 |
$post = get_post(); |
1640 |
||
9 | 1641 |
if ( empty( $post->post_type ) || $post->post_type != 'attachment' ) { |
0 | 1642 |
return $content; |
9 | 1643 |
} |
0 | 1644 |
|
5 | 1645 |
if ( wp_attachment_is( 'video', $post ) ) { |
1646 |
$meta = wp_get_attachment_metadata( get_the_ID() ); |
|
1647 |
$atts = array( 'src' => wp_get_attachment_url() ); |
|
1648 |
if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) { |
|
9 | 1649 |
$atts['width'] = (int) $meta['width']; |
5 | 1650 |
$atts['height'] = (int) $meta['height']; |
1651 |
} |
|
1652 |
if ( has_post_thumbnail() ) { |
|
1653 |
$atts['poster'] = wp_get_attachment_url( get_post_thumbnail_id() ); |
|
1654 |
} |
|
1655 |
$p = wp_video_shortcode( $atts ); |
|
1656 |
} elseif ( wp_attachment_is( 'audio', $post ) ) { |
|
1657 |
$p = wp_audio_shortcode( array( 'src' => wp_get_attachment_url() ) ); |
|
1658 |
} else { |
|
1659 |
$p = '<p class="attachment">'; |
|
1660 |
// show the medium sized image representation of the attachment if available, and link to the raw file |
|
9 | 1661 |
$p .= wp_get_attachment_link( 0, 'medium', false ); |
5 | 1662 |
$p .= '</p>'; |
1663 |
} |
|
1664 |
||
1665 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1666 |
* Filters the attachment markup to be prepended to the post content. |
5 | 1667 |
* |
1668 |
* @since 2.0.0 |
|
1669 |
* |
|
1670 |
* @see prepend_attachment() |
|
1671 |
* |
|
1672 |
* @param string $p The attachment HTML output. |
|
1673 |
*/ |
|
1674 |
$p = apply_filters( 'prepend_attachment', $p ); |
|
0 | 1675 |
|
1676 |
return "$p\n$content"; |
|
1677 |
} |
|
1678 |
||
1679 |
// |
|
1680 |
// Misc |
|
1681 |
// |
|
1682 |
||
1683 |
/** |
|
1684 |
* Retrieve protected post password form content. |
|
1685 |
* |
|
1686 |
* @since 1.0.0 |
|
5 | 1687 |
* |
1688 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
|
0 | 1689 |
* @return string HTML content for password form for password protected post. |
1690 |
*/ |
|
1691 |
function get_the_password_form( $post = 0 ) { |
|
9 | 1692 |
$post = get_post( $post ); |
1693 |
$label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); |
|
0 | 1694 |
$output = '<form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="post-password-form" method="post"> |
1695 |
<p>' . __( 'This content is password protected. To view it please enter your password below:' ) . '</p> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1696 |
<p><label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" /></label> <input type="submit" name="Submit" value="' . esc_attr_x( 'Enter', 'post password form' ) . '" /></p></form> |
0 | 1697 |
'; |
5 | 1698 |
|
1699 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1700 |
* Filters the HTML output for the protected post password form. |
5 | 1701 |
* |
1702 |
* If modifying the password field, please note that the core database schema |
|
1703 |
* limits the password field to 20 characters regardless of the value of the |
|
1704 |
* size attribute in the form input. |
|
1705 |
* |
|
1706 |
* @since 2.7.0 |
|
1707 |
* |
|
1708 |
* @param string $output The password form HTML output. |
|
1709 |
*/ |
|
0 | 1710 |
return apply_filters( 'the_password_form', $output ); |
1711 |
} |
|
1712 |
||
1713 |
/** |
|
9 | 1714 |
* Determines whether currently in a page template. |
0 | 1715 |
* |
1716 |
* This template tag allows you to determine if you are in a page template. |
|
5 | 1717 |
* You can optionally provide a template name or array of template names |
1718 |
* and then the check will be specific to that template. |
|
0 | 1719 |
* |
9 | 1720 |
* For more information on this and similar theme functions, check out |
1721 |
* the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ |
|
1722 |
* Conditional Tags} article in the Theme Developer Handbook. |
|
1723 |
* |
|
0 | 1724 |
* @since 2.5.0 |
5 | 1725 |
* @since 4.2.0 The `$template` parameter was changed to also accept an array of page templates. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1726 |
* @since 4.7.0 Now works with any post type, not just pages. |
0 | 1727 |
* |
5 | 1728 |
* @param string|array $template The specific template name or array of templates to match. |
0 | 1729 |
* @return bool True on success, false on failure. |
1730 |
*/ |
|
1731 |
function is_page_template( $template = '' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1732 |
if ( ! is_singular() ) { |
0 | 1733 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1734 |
} |
0 | 1735 |
|
1736 |
$page_template = get_page_template_slug( get_queried_object_id() ); |
|
1737 |
||
9 | 1738 |
if ( empty( $template ) ) { |
0 | 1739 |
return (bool) $page_template; |
9 | 1740 |
} |
0 | 1741 |
|
9 | 1742 |
if ( $template == $page_template ) { |
0 | 1743 |
return true; |
9 | 1744 |
} |
0 | 1745 |
|
5 | 1746 |
if ( is_array( $template ) ) { |
1747 |
if ( ( in_array( 'default', $template, true ) && ! $page_template ) |
|
1748 |
|| in_array( $page_template, $template, true ) |
|
1749 |
) { |
|
1750 |
return true; |
|
1751 |
} |
|
1752 |
} |
|
1753 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1754 |
return ( 'default' === $template && ! $page_template ); |
0 | 1755 |
} |
1756 |
||
1757 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1758 |
* Get the specific template name for a given post. |
0 | 1759 |
* |
1760 |
* @since 3.4.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1761 |
* @since 4.7.0 Now works with any post type, not just pages. |
0 | 1762 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1763 |
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1764 |
* @return string|false Page template filename. Returns an empty string when the default page template |
9 | 1765 |
* is in use. Returns false if the post does not exist. |
0 | 1766 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1767 |
function get_page_template_slug( $post = null ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1768 |
$post = get_post( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1769 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1770 |
if ( ! $post ) { |
0 | 1771 |
return false; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1772 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1773 |
|
0 | 1774 |
$template = get_post_meta( $post->ID, '_wp_page_template', true ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1775 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1776 |
if ( ! $template || 'default' == $template ) { |
0 | 1777 |
return ''; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1778 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1779 |
|
0 | 1780 |
return $template; |
1781 |
} |
|
1782 |
||
1783 |
/** |
|
1784 |
* Retrieve formatted date timestamp of a revision (linked to that revisions's page). |
|
1785 |
* |
|
1786 |
* @since 2.6.0 |
|
1787 |
* |
|
1788 |
* @param int|object $revision Revision ID or revision object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1789 |
* @param bool $link Optional, default is true. Link to revisions's page? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1790 |
* @return string|false i18n formatted datetimestamp or localized 'Current Revision'. |
0 | 1791 |
*/ |
1792 |
function wp_post_revision_title( $revision, $link = true ) { |
|
9 | 1793 |
if ( ! $revision = get_post( $revision ) ) { |
0 | 1794 |
return $revision; |
9 | 1795 |
} |
0 | 1796 |
|
9 | 1797 |
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) { |
0 | 1798 |
return false; |
9 | 1799 |
} |
0 | 1800 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1801 |
/* translators: revision date format, see https://secure.php.net/date */ |
5 | 1802 |
$datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1803 |
/* translators: %s: revision date */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1804 |
$autosavef = __( '%s [Autosave]' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1805 |
/* translators: %s: revision date */ |
9 | 1806 |
$currentf = __( '%s [Current Revision]' ); |
0 | 1807 |
|
1808 |
$date = date_i18n( $datef, strtotime( $revision->post_modified ) ); |
|
9 | 1809 |
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) { |
0 | 1810 |
$date = "<a href='$link'>$date</a>"; |
9 | 1811 |
} |
0 | 1812 |
|
9 | 1813 |
if ( ! wp_is_post_revision( $revision ) ) { |
0 | 1814 |
$date = sprintf( $currentf, $date ); |
9 | 1815 |
} elseif ( wp_is_post_autosave( $revision ) ) { |
0 | 1816 |
$date = sprintf( $autosavef, $date ); |
9 | 1817 |
} |
0 | 1818 |
|
1819 |
return $date; |
|
1820 |
} |
|
1821 |
||
1822 |
/** |
|
1823 |
* Retrieve formatted date timestamp of a revision (linked to that revisions's page). |
|
1824 |
* |
|
1825 |
* @since 3.6.0 |
|
1826 |
* |
|
1827 |
* @param int|object $revision Revision ID or revision object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1828 |
* @param bool $link Optional, default is true. Link to revisions's page? |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1829 |
* @return string|false gravatar, user, i18n formatted datetimestamp or localized 'Current Revision'. |
0 | 1830 |
*/ |
1831 |
function wp_post_revision_title_expanded( $revision, $link = true ) { |
|
9 | 1832 |
if ( ! $revision = get_post( $revision ) ) { |
0 | 1833 |
return $revision; |
9 | 1834 |
} |
0 | 1835 |
|
9 | 1836 |
if ( ! in_array( $revision->post_type, array( 'post', 'page', 'revision' ) ) ) { |
0 | 1837 |
return false; |
9 | 1838 |
} |
0 | 1839 |
|
1840 |
$author = get_the_author_meta( 'display_name', $revision->post_author ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1841 |
/* translators: revision date format, see https://secure.php.net/date */ |
5 | 1842 |
$datef = _x( 'F j, Y @ H:i:s', 'revision date format' ); |
0 | 1843 |
|
1844 |
$gravatar = get_avatar( $revision->post_author, 24 ); |
|
1845 |
||
1846 |
$date = date_i18n( $datef, strtotime( $revision->post_modified ) ); |
|
9 | 1847 |
if ( $link && current_user_can( 'edit_post', $revision->ID ) && $link = get_edit_post_link( $revision->ID ) ) { |
0 | 1848 |
$date = "<a href='$link'>$date</a>"; |
9 | 1849 |
} |
0 | 1850 |
|
1851 |
$revision_date_author = sprintf( |
|
1852 |
/* translators: post revision title: 1: author avatar, 2: author name, 3: time ago, 4: date */ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1853 |
__( '%1$s %2$s, %3$s ago (%4$s)' ), |
0 | 1854 |
$gravatar, |
1855 |
$author, |
|
1856 |
human_time_diff( strtotime( $revision->post_modified ), current_time( 'timestamp' ) ), |
|
1857 |
$date |
|
1858 |
); |
|
1859 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1860 |
/* translators: %s: revision date with author avatar */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1861 |
$autosavef = __( '%s [Autosave]' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1862 |
/* translators: %s: revision date with author avatar */ |
9 | 1863 |
$currentf = __( '%s [Current Revision]' ); |
0 | 1864 |
|
9 | 1865 |
if ( ! wp_is_post_revision( $revision ) ) { |
0 | 1866 |
$revision_date_author = sprintf( $currentf, $revision_date_author ); |
9 | 1867 |
} elseif ( wp_is_post_autosave( $revision ) ) { |
0 | 1868 |
$revision_date_author = sprintf( $autosavef, $revision_date_author ); |
9 | 1869 |
} |
0 | 1870 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1871 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1872 |
* Filters the formatted author and date for a revision. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1873 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1874 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1875 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1876 |
* @param string $revision_date_author The formatted string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1877 |
* @param WP_Post $revision The revision object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1878 |
* @param bool $link Whether to link to the revisions page, as passed into |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1879 |
* wp_post_revision_title_expanded(). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1880 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1881 |
return apply_filters( 'wp_post_revision_title_expanded', $revision_date_author, $revision, $link ); |
0 | 1882 |
} |
1883 |
||
1884 |
/** |
|
9 | 1885 |
* Display a list of a post's revisions. |
0 | 1886 |
* |
1887 |
* Can output either a UL with edit links or a TABLE with diff interface, and |
|
1888 |
* restore action links. |
|
1889 |
* |
|
1890 |
* @since 2.6.0 |
|
1891 |
* |
|
5 | 1892 |
* @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post. |
1893 |
* @param string $type 'all' (default), 'revision' or 'autosave' |
|
0 | 1894 |
*/ |
1895 |
function wp_list_post_revisions( $post_id = 0, $type = 'all' ) { |
|
9 | 1896 |
if ( ! $post = get_post( $post_id ) ) { |
0 | 1897 |
return; |
9 | 1898 |
} |
0 | 1899 |
|
1900 |
// $args array with (parent, format, right, left, type) deprecated since 3.6 |
|
1901 |
if ( is_array( $type ) ) { |
|
9 | 1902 |
$type = ! empty( $type['type'] ) ? $type['type'] : $type; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1903 |
_deprecated_argument( __FUNCTION__, '3.6.0' ); |
0 | 1904 |
} |
1905 |
||
9 | 1906 |
if ( ! $revisions = wp_get_post_revisions( $post->ID ) ) { |
0 | 1907 |
return; |
9 | 1908 |
} |
0 | 1909 |
|
1910 |
$rows = ''; |
|
1911 |
foreach ( $revisions as $revision ) { |
|
9 | 1912 |
if ( ! current_user_can( 'read_post', $revision->ID ) ) { |
0 | 1913 |
continue; |
9 | 1914 |
} |
0 | 1915 |
|
1916 |
$is_autosave = wp_is_post_autosave( $revision ); |
|
9 | 1917 |
if ( ( 'revision' === $type && $is_autosave ) || ( 'autosave' === $type && ! $is_autosave ) ) { |
0 | 1918 |
continue; |
9 | 1919 |
} |
0 | 1920 |
|
1921 |
$rows .= "\t<li>" . wp_post_revision_title_expanded( $revision ) . "</li>\n"; |
|
1922 |
} |
|
1923 |
||
1924 |
echo "<div class='hide-if-js'><p>" . __( 'JavaScript must be enabled to use this feature.' ) . "</p></div>\n"; |
|
1925 |
||
1926 |
echo "<ul class='post-revisions hide-if-no-js'>\n"; |
|
1927 |
echo $rows; |
|
9 | 1928 |
echo '</ul>'; |
0 | 1929 |
} |