PluginProbe
ActivityPub / 8.0.2
ActivityPub v8.0.2
9.3.1 9.3.0 9.2.2 9.2.1 9.2.0 9.1.0 9.0.2 9.0.1 9.0.0 8.3.0 8.2.1 8.2.0 8.1.1 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.2.0 1.3.0 2.0.0 2.0.1 2.1.0 2.1.1 All 160 releases
← All changes | includes/class-shortcodes.php +136 -225 1.2.08.0.2 View file →
@@ -1,12 +1,19 @@
1 1 <?php
2 +/**
3 + * Shortcodes class file.
4 + *
5 + * @package Activitypub
6 + */
7 +
2 8 namespace Activitypub;
3 9
4 -use function Activitypub\esc_hashtag;
5 -
10 +/**
11 + * Shortcodes class.
12 + */
6 13 class Shortcodes {
7 14 /**
8 - * Register the shortcodes
15 + * Register the shortcodes.
9 16 */
10 17 public static function register() {
11 18 foreach ( get_class_methods( self::class ) as $shortcode ) {
12 19 if ( 'init' !== $shortcode ) {
@@ -15,9 +22,9 @@
15 22 }
16 23 }
17 24
18 25 /**
19 - * Unregister the shortcodes
26 + * Unregister the shortcodes.
20 27 */
21 28 public static function unregister() {
22 29 foreach ( get_class_methods( self::class ) as $shortcode ) {
23 30 if ( 'init' !== $shortcode ) {
@@ -26,17 +33,13 @@
26 33 }
27 34 }
28 35
29 36 /**
30 - * Generates output for the 'ap_hashtags' shortcode
37 + * Generates output for the 'ap_hashtags' shortcode.
31 38 *
32 - * @param array $atts The Shortcode attributes.
33 - * @param string $content The ActivityPub post-content.
34 - * @param string $tag The tag/name of the Shortcode.
35 - *
36 39 * @return string The post tags as hashtags.
37 40 */
38 - public static function hashtags( $atts, $content, $tag ) {
41 + public static function hashtags() {
39 42 $item = self::get_item();
40 43
41 44 if ( ! $item ) {
42 45 return '';
@@ -50,8 +53,13 @@
50 53
51 54 $hash_tags = array();
52 55
53 56 foreach ( $tags as $tag ) {
57 + // Tag can be empty.
58 + if ( ! $tag ) {
59 + continue;
60 + }
61 +
54 62 $hash_tags[] = \sprintf(
55 63 '<a rel="tag" class="hashtag u-tag u-category" href="%s">%s</a>',
56 64 \esc_url( \get_tag_link( $tag ) ),
57 65 esc_hashtag( $tag->name )
@@ -63,15 +71,15 @@
63 71
64 72 /**
65 73 * Generates output for the 'ap_title' Shortcode
66 74 *
67 - * @param array $atts The Shortcode attributes.
68 - * @param string $content The ActivityPub post-content.
69 - * @param string $tag The tag/name of the Shortcode.
75 + * @param array $attributes The Shortcode attributes.
76 + * @param string $content The ActivityPub post-content.
77 + * @param string $tag The tag/name of the Shortcode.
70 78 *
71 79 * @return string The post title.
72 80 */
73 - public static function title( $atts, $content, $tag ) {
81 + public static function title( $attributes, $content, $tag ) {
74 82 $item = self::get_item();
75 83
76 84 if ( ! $item ) {
77 85 return '';
@@ -76,21 +84,37 @@
76 84 if ( ! $item ) {
77 85 return '';
78 86 }
79 87
80 - return \wp_strip_all_tags( \get_the_title( $item->ID ), true );
88 + $title = \wp_strip_all_tags( \get_the_title( $item->ID ), true );
89 +
90 + if ( ! $title ) {
91 + return '';
92 + }
93 +
94 + $attributes = shortcode_atts(
95 + array( 'type' => 'plain' ),
96 + $attributes,
97 + $tag
98 + );
99 +
100 + if ( 'html' !== $attributes['type'] ) {
101 + return $title;
102 + }
103 +
104 + return sprintf( '<h2>%s</h2>', $title );
81 105 }
82 106
83 107 /**
84 108 * Generates output for the 'ap_excerpt' Shortcode
85 109 *
86 - * @param array $atts The Shortcode attributes.
87 - * @param string $content The ActivityPub post-content.
88 - * @param string $tag The tag/name of the Shortcode.
110 + * @param array $attributes The Shortcode attributes.
111 + * @param string $content The ActivityPub post-content.
112 + * @param string $tag The tag/name of the Shortcode.
89 113 *
90 114 * @return string The post excerpt.
91 115 */
92 - public static function excerpt( $atts, $content, $tag ) {
116 + public static function excerpt( $attributes, $content, $tag ) {
93 117 $item = self::get_item();
94 118
95 119 if ( ! $item ) {
96 120 return '';
@@ -95,105 +119,36 @@
95 119 if ( ! $item ) {
96 120 return '';
97 121 }
98 122
99 - $atts = shortcode_atts(
123 + $attributes = shortcode_atts(
100 124 array( 'length' => ACTIVITYPUB_EXCERPT_LENGTH ),
101 - $atts,
125 + $attributes,
102 126 $tag
103 127 );
104 128
105 - $excerpt_length = intval( $atts['length'] );
129 + $excerpt_length = intval( $attributes['length'] );
106 130
107 131 if ( 0 === $excerpt_length ) {
108 132 $excerpt_length = ACTIVITYPUB_EXCERPT_LENGTH;
109 133 }
110 134
111 - $excerpt = \get_post_field( 'post_excerpt', $item );
135 + $excerpt = generate_post_summary( $item, $excerpt_length );
112 136
113 - if ( '' === $excerpt ) {
114 -
115 - $content = \get_post_field( 'post_content', $item );
116 -
117 - // An empty string will make wp_trim_excerpt do stuff we do not want.
118 - if ( '' !== $content ) {
119 - $excerpt = \strip_shortcodes( $content );
120 -
121 - /** This filter is documented in wp-includes/post-template.php */
122 - $excerpt = \apply_filters( 'the_content', $excerpt );
123 - $excerpt = \str_replace( ']]>', ']]&gt;', $excerpt );
124 - }
125 - }
126 -
127 - // Strip out any remaining tags.
128 - $excerpt = \wp_strip_all_tags( $excerpt );
129 -
130 - /** This filter is documented in wp-includes/formatting.php */
131 - $excerpt_more = \apply_filters( 'excerpt_more', ' [...]' );
132 - $excerpt_more_len = strlen( $excerpt_more );
133 -
134 - // We now have a excerpt, but we need to check it's length, it may be longer than we want for two reasons:
135 - //
136 - // * The user has entered a manual excerpt which is longer that what we want.
137 - // * No manual excerpt exists so we've used the content which might be longer than we want.
138 - //
139 - // Either way, let's trim it up if we need too. Also, don't forget to take into account the more indicator
140 - // as part of the total length.
141 - //
142 -
143 - // Setup a variable to hold the current excerpts length.
144 - $current_excerpt_length = strlen( $excerpt );
145 -
146 - // Setup a variable to keep track of our target length.
147 - $target_excerpt_length = $excerpt_length - $excerpt_more_len;
148 -
149 - // Setup a variable to keep track of the current max length.
150 - $current_excerpt_max = $target_excerpt_length;
151 -
152 - // This is a loop since we can't calculate word break the string after 'the_excpert' filter has run (we would break
153 - // all kinds of html tags), so we have to cut the excerpt down a bit at a time until we hit our target length.
154 - while ( $current_excerpt_length > $target_excerpt_length && $current_excerpt_max > 0 ) {
155 - // Trim the excerpt based on wordwrap() positioning.
156 - // Note: we're using <br> as the linebreak just in case there are any newlines existing in the excerpt from the user.
157 - // There won't be any <br> left after we've run wp_strip_all_tags() in the code above, so they're
158 - // safe to use here. It won't be included in the final excerpt as the substr() will trim it off.
159 - $excerpt = substr( $excerpt, 0, strpos( wordwrap( $excerpt, $current_excerpt_max, '<br>' ), '<br>' ) );
160 -
161 - // If something went wrong, or we're in a language that wordwrap() doesn't understand,
162 - // just chop it off and don't worry about breaking in the middle of a word.
163 - if ( strlen( $excerpt ) > $excerpt_length - $excerpt_more_len ) {
164 - $excerpt = substr( $excerpt, 0, $current_excerpt_max );
165 - }
166 -
167 - // Add in the more indicator.
168 - $excerpt = $excerpt . $excerpt_more;
169 -
170 - // Run it through the excerpt filter which will add some html tags back in.
171 - $excerpt_filtered = apply_filters( 'the_excerpt', $excerpt );
172 -
173 - // Now set the current excerpt length to this new filtered length.
174 - $current_excerpt_length = strlen( $excerpt_filtered );
175 -
176 - // Check to see if we're over the target length.
177 - if ( $current_excerpt_length > $target_excerpt_length ) {
178 - // If so, remove 20 characters from the current max and run the loop again.
179 - $current_excerpt_max = $current_excerpt_max - 20;
180 - }
181 - }
182 -
137 + /** This filter is documented in wp-includes/post-template.php */
183 138 return \apply_filters( 'the_excerpt', $excerpt );
184 139 }
185 140
186 141 /**
187 - * Generates output for the 'ap_content' Shortcode
142 + * Generates output for the 'ap_content' Shortcode.
188 143 *
189 - * @param array $atts The Shortcode attributes.
190 - * @param string $content The ActivityPub post-content.
191 - * @param string $tag The tag/name of the Shortcode.
144 + * @param array $attributes The Shortcode attributes.
145 + * @param string $content The ActivityPub post-content.
146 + * @param string $tag The tag/name of the Shortcode.
192 147 *
193 148 * @return string The post content.
194 149 */
195 - public static function content( $atts, $content, $tag ) {
150 + public static function content( $attributes, $content, $tag ) {
196 151 $item = self::get_item();
197 152
198 153 if ( ! $item ) {
199 154 return '';
@@ -198,31 +153,47 @@
198 153 if ( ! $item ) {
199 154 return '';
200 155 }
201 156
202 - // prevent inception
157 + // Prevent inception.
203 158 remove_shortcode( 'ap_content' );
204 159
205 - $atts = shortcode_atts(
160 + $attributes = shortcode_atts(
206 161 array( 'apply_filters' => 'yes' ),
207 - $atts,
162 + $attributes,
208 163 $tag
209 164 );
210 165
211 - $content = \get_post_field( 'post_content', $item );
166 + $content = '';
212 167
213 - if ( 'yes' === $atts['apply_filters'] ) {
168 + if ( 'attachment' === $item->post_type ) {
169 + // Get title of attachment with fallback to alt text.
170 + $content = wp_get_attachment_caption( $item->ID );
171 + if ( empty( $content ) ) {
172 + $content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
173 + }
174 + }
175 +
176 + if ( empty( $content ) ) {
177 + $content = \get_post_field( 'post_content', $item );
178 + }
179 +
180 + if ( 'yes' === $attributes['apply_filters'] ) {
181 + /** This filter is documented in wp-includes/post-template.php */
214 182 $content = \apply_filters( 'the_content', $content );
215 183 } else {
216 - $content = do_blocks( $content );
217 - $content = wptexturize( $content );
218 - $content = wp_filter_content_tags( $content );
184 + if ( site_supports_blocks() ) {
185 + $content = \do_blocks( $content );
186 + }
187 + $content = \wptexturize( $content );
188 + $content = \wp_filter_content_tags( $content );
219 189 }
220 190
221 - // replace script and style elements
191 + // Replace script and style elements.
222 192 $content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
223 - $content = strip_shortcodes( $content );
224 - $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
193 + $content = \strip_shortcodes( $content );
194 + $content = Sanitize::clean_html( $content );
195 + $content = Sanitize::strip_whitespace( $content );
225 196
226 197 add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
227 198
228 199 return $content;
@@ -228,17 +199,17 @@
228 199 return $content;
229 200 }
230 201
231 202 /**
232 - * Generates output for the 'ap_permalink' Shortcode
203 + * Generates output for the 'ap_permalink' Shortcode.
233 204 *
234 - * @param array $atts The Shortcode attributes.
235 - * @param string $content The ActivityPub post-content.
236 - * @param string $tag The tag/name of the Shortcode.
205 + * @param array $attributes The Shortcode attributes.
206 + * @param string $content The ActivityPub post-content.
207 + * @param string $tag The tag/name of the Shortcode.
237 208 *
238 209 * @return string The post permalink.
239 210 */
240 - public static function permalink( $atts, $content, $tag ) {
211 + public static function permalink( $attributes, $content, $tag ) {
241 212 $item = self::get_item();
242 213
243 214 if ( ! $item ) {
244 215 return '';
@@ -243,36 +214,36 @@
243 214 if ( ! $item ) {
244 215 return '';
245 216 }
246 217
247 - $atts = shortcode_atts(
218 + $attributes = shortcode_atts(
248 219 array(
249 220 'type' => 'url',
250 221 ),
251 - $atts,
222 + $attributes,
252 223 $tag
253 224 );
254 225
255 - if ( 'url' === $atts['type'] ) {
226 + if ( 'html' !== $attributes['type'] ) {
256 227 return \esc_url( \get_permalink( $item->ID ) );
257 228 }
258 229
259 230 return \sprintf(
260 - '<a href="%1$s">%1$s</a>',
231 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
261 232 \esc_url( \get_permalink( $item->ID ) )
262 233 );
263 234 }
264 235
265 236 /**
266 - * Generates output for the 'ap_shortlink' Shortcode
237 + * Generates output for the 'ap_shortlink' Shortcode.
267 238 *
268 - * @param array $atts The Shortcode attributes.
269 - * @param string $content The ActivityPub post-content.
270 - * @param string $tag The tag/name of the Shortcode.
239 + * @param array $attributes The Shortcode attributes.
240 + * @param string $content The ActivityPub post-content.
241 + * @param string $tag The tag/name of the Shortcode.
271 242 *
272 243 * @return string The post shortlink.
273 244 */
274 - public static function shortlink( $atts, $content, $tag ) {
245 + public static function shortlink( $attributes, $content, $tag ) {
275 246 $item = self::get_item();
276 247
277 248 if ( ! $item ) {
278 249 return '';
@@ -277,36 +248,36 @@
277 248 if ( ! $item ) {
278 249 return '';
279 250 }
280 251
281 - $atts = shortcode_atts(
252 + $attributes = shortcode_atts(
282 253 array(
283 254 'type' => 'url',
284 255 ),
285 - $atts,
256 + $attributes,
286 257 $tag
287 258 );
288 259
289 - if ( 'url' === $atts['type'] ) {
260 + if ( 'html' !== $attributes['type'] ) {
290 261 return \esc_url( \wp_get_shortlink( $item->ID ) );
291 262 }
292 263
293 264 return \sprintf(
294 - '<a href="%1$s">%1$s</a>',
265 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
295 266 \esc_url( \wp_get_shortlink( $item->ID ) )
296 267 );
297 268 }
298 269
299 270 /**
300 - * Generates output for the 'ap_image' Shortcode
271 + * Generates output for the 'ap_image' Shortcode.
301 272 *
302 - * @param array $atts The Shortcode attributes.
303 - * @param string $content The ActivityPub post-content.
304 - * @param string $tag The tag/name of the Shortcode.
273 + * @param array $attributes The Shortcode attributes.
274 + * @param string $content The ActivityPub post-content.
275 + * @param string $tag The tag/name of the Shortcode.
305 276 *
306 277 * @return string
307 278 */
308 - public static function image( $atts, $content, $tag ) {
279 + public static function image( $attributes, $content, $tag ) {
309 280 $item = self::get_item();
310 281
311 282 if ( ! $item ) {
312 283 return '';
@@ -311,13 +282,13 @@
311 282 if ( ! $item ) {
312 283 return '';
313 284 }
314 285
315 - $atts = shortcode_atts(
286 + $attributes = shortcode_atts(
316 287 array(
317 288 'type' => 'full',
318 289 ),
319 - $atts,
290 + $attributes,
320 291 $tag
321 292 );
322 293
323 294 $size = 'full';
@@ -322,13 +293,13 @@
322 293
323 294 $size = 'full';
324 295
325 296 if ( in_array(
326 - $atts['type'],
297 + $attributes['type'],
327 298 array( 'thumbnail', 'medium', 'large', 'full' ),
328 299 true
329 300 ) ) {
330 - $size = $atts['type'];
301 + $size = $attributes['type'];
331 302 }
332 303
333 304 $image = \get_the_post_thumbnail_url( $item->ID, $size );
334 305
@@ -339,52 +310,24 @@
339 310 return \esc_url( $image );
340 311 }
341 312
342 313 /**
343 - * Generates output for the 'ap_hashcats' Shortcode
314 + * Generates output for the 'ap_hashcats' Shortcode.
344 315 *
345 - * @param array $atts The Shortcode attributes.
346 - * @param string $content The ActivityPub post-content.
347 - * @param string $tag The tag/name of the Shortcode.
316 + * @deprecated 7.0.0
348 317 *
349 318 * @return string The post categories as hashtags.
350 319 */
351 - public static function hashcats( $atts, $content, $tag ) {
352 - $item = self::get_item();
353 -
354 - if ( ! $item ) {
355 - return '';
356 - }
357 -
358 - $categories = \get_the_category( $item->ID );
359 -
360 - if ( ! $categories ) {
361 - return '';
362 - }
363 -
364 - $hash_tags = array();
365 -
366 - foreach ( $categories as $category ) {
367 - $hash_tags[] = \sprintf(
368 - '<a rel="tag" class="hashtag u-tag u-category" href="%s">%s</a>',
369 - \esc_url( \get_category_link( $category ) ),
370 - esc_hashtag( $category->name )
371 - );
372 - }
373 -
374 - return \implode( ' ', $hash_tags );
320 + public static function hashcats() {
321 + return '';
375 322 }
376 323
377 324 /**
378 - * Generates output for the 'ap_author' Shortcode
325 + * Generates output for the 'ap_author' Shortcode.
379 326 *
380 - * @param array $atts The Shortcode attributes.
381 - * @param string $content The ActivityPub post-content.
382 - * @param string $tag The tag/name of the Shortcode.
383 - *
384 327 * @return string The author name.
385 328 */
386 - public static function author( $atts, $content, $tag ) {
329 + public static function author() {
387 330 $item = self::get_item();
388 331
389 332 if ( ! $item ) {
390 333 return '';
@@ -390,9 +333,9 @@
390 333 return '';
391 334 }
392 335
393 336 $author_id = \get_post_field( 'post_author', $item->ID );
394 - $name = \get_the_author_meta( 'display_name', $author_id );
337 + $name = \get_the_author_meta( 'display_name', $author_id );
395 338
396 339 if ( ! $name ) {
397 340 return '';
398 341 }
@@ -400,17 +343,13 @@
400 343 return wp_strip_all_tags( $name );
401 344 }
402 345
403 346 /**
404 - * Generates output for the 'ap_authorurl' Shortcode
347 + * Generates output for the 'ap_authorurl' Shortcode.
405 348 *
406 - * @param array $atts The Shortcode attributes.
407 - * @param string $content The ActivityPub post-content.
408 - * @param string $tag The tag/name of the Shortcode.
409 - *
410 349 * @return string The author URL.
411 350 */
412 - public static function authorurl( $atts, $content, $tag ) {
351 + public static function authorurl() {
413 352 $item = self::get_item();
414 353
415 354 if ( ! $item ) {
416 355 return '';
@@ -416,9 +355,9 @@
416 355 return '';
417 356 }
418 357
419 358 $author_id = \get_post_field( 'post_author', $item->ID );
420 - $url = \get_the_author_meta( 'user_url', $author_id );
359 + $url = \get_the_author_meta( 'user_url', $author_id );
421 360
422 361 if ( ! $url ) {
423 362 return '';
424 363 }
@@ -426,56 +365,40 @@
426 365 return \esc_url( $url );
427 366 }
428 367
429 368 /**
430 - * Generates output for the 'ap_blogurl' Shortcode
369 + * Generates output for the 'ap_blogurl' Shortcode.
431 370 *
432 - * @param array $atts The Shortcode attributes.
433 - * @param string $content The ActivityPub post-content.
434 - * @param string $tag The tag/name of the Shortcode.
435 - *
436 371 * @return string The site URL.
437 372 */
438 - public static function blogurl( $atts, $content, $tag ) {
373 + public static function blogurl() {
439 374 return \esc_url( \get_bloginfo( 'url' ) );
440 375 }
441 376
442 377 /**
443 - * Generates output for the 'ap_blogname' Shortcode
378 + * Generates output for the 'ap_blogname' Shortcode.
444 379 *
445 - * @param array $atts The Shortcode attributes.
446 - * @param string $content The ActivityPub post-content.
447 - * @param string $tag The tag/name of the Shortcode.
448 - *
449 380 * @return string
450 381 */
451 - public static function blogname( $atts, $content, $tag ) {
382 + public static function blogname() {
452 383 return \wp_strip_all_tags( \get_bloginfo( 'name' ) );
453 384 }
454 385
455 386 /**
456 - * Generates output for the 'ap_blogdesc' Shortcode
387 + * Generates output for the 'ap_blogdesc' Shortcode.
457 388 *
458 - * @param array $atts The Shortcode attributes.
459 - * @param string $content The ActivityPub post-content.
460 - * @param string $tag The tag/name of the Shortcode.
461 - *
462 389 * @return string The site description.
463 390 */
464 - public static function blogdesc( $atts, $content, $tag ) {
391 + public static function blogdesc() {
465 392 return \wp_strip_all_tags( \get_bloginfo( 'description' ) );
466 393 }
467 394
468 395 /**
469 - * Generates output for the 'ap_date' Shortcode
396 + * Generates output for the 'ap_date' Shortcode.
470 397 *
471 - * @param array $atts The Shortcode attributes.
472 - * @param string $content The ActivityPub post-content.
473 - * @param string $tag The tag/name of the Shortcode.
474 - *
475 398 * @return string The post date.
476 399 */
477 - public static function date( $atts, $content, $tag ) {
400 + public static function date() {
478 401 $item = self::get_item();
479 402
480 403 if ( ! $item ) {
481 404 return '';
@@ -480,11 +403,10 @@
480 403 if ( ! $item ) {
481 404 return '';
482 405 }
483 406
484 - $datetime = \get_post_datetime( $item );
407 + $datetime = \get_post_datetime( $item );
485 408 $dateformat = \get_option( 'date_format' );
486 - $timeformat = \get_option( 'time_format' );
487 409
488 410 $date = $datetime->format( $dateformat );
489 411
490 412 if ( ! $date ) {
@@ -494,17 +416,13 @@
494 416 return $date;
495 417 }
496 418
497 419 /**
498 - * Generates output for the 'ap_time' Shortcode
420 + * Generates output for the 'ap_time' Shortcode.
499 421 *
500 - * @param array $atts The Shortcode attributes.
501 - * @param string $content The ActivityPub post-content.
502 - * @param string $tag The tag/name of the Shortcode.
503 - *
504 422 * @return string The post time.
505 423 */
506 - public static function time( $atts, $content, $tag ) {
424 + public static function time() {
507 425 $item = self::get_item();
508 426
509 427 if ( ! $item ) {
510 428 return '';
@@ -510,13 +428,10 @@
510 428 return '';
511 429 }
512 430
513 431 $datetime = \get_post_datetime( $item );
514 - $dateformat = \get_option( 'date_format' );
515 - $timeformat = \get_option( 'time_format' );
432 + $date = $datetime->format( \get_option( 'time_format' ) );
516 433
517 - $date = $datetime->format( $timeformat );
518 -
519 434 if ( ! $date ) {
520 435 return '';
521 436 }
522 437
@@ -523,17 +438,13 @@
523 438 return $date;
524 439 }
525 440
526 441 /**
527 - * Generates output for the 'ap_datetime' Shortcode
442 + * Generates output for the 'ap_datetime' Shortcode.
528 443 *
529 - * @param array $atts The Shortcode attributes.
530 - * @param string $content The ActivityPub post-content.
531 - * @param string $tag The tag/name of the Shortcode.
532 - *
533 444 * @return string The post date/time.
534 445 */
535 - public static function datetime( $atts, $content, $tag ) {
446 + public static function datetime() {
536 447 $item = self::get_item();
537 448
538 449 if ( ! $item ) {
539 450 return '';
@@ -538,13 +449,13 @@
538 449 if ( ! $item ) {
539 450 return '';
540 451 }
541 452
542 - $datetime = \get_post_datetime( $item );
543 - $dateformat = \get_option( 'date_format' );
544 - $timeformat = \get_option( 'time_format' );
453 + $datetime = \get_post_datetime( $item );
454 + $date_format = \get_option( 'date_format' );
455 + $time_format = \get_option( 'time_format' );
545 456
546 - $date = $datetime->format( $dateformat . ' @ ' . $timeformat );
457 + $date = $datetime->format( $date_format . ' @ ' . $time_format );
547 458
548 459 if ( ! $date ) {
549 460 return '';
550 461 }
@@ -557,9 +468,9 @@
557 468 *
558 469 * Checks if item (WP_Post) is "public", a supported post type
559 470 * and not password protected.
560 471 *
561 - * @return null|WP_Post The WordPress item.
472 + * @return null|\WP_Post The WordPress item.
562 473 */
563 474 protected static function get_item() {
564 475 $post = \get_post();
565 476