PluginProbe
ActivityPub / 7.7.0
ActivityPub v7.7.0
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 +134 -224 1.3.07.7.0 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,30 +153,45 @@
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 );
193 + $content = \strip_shortcodes( $content );
224 194 $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
225 195
226 196 add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
227 197
@@ -228,17 +198,17 @@
228 198 return $content;
229 199 }
230 200
231 201 /**
232 - * Generates output for the 'ap_permalink' Shortcode
202 + * Generates output for the 'ap_permalink' Shortcode.
233 203 *
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.
204 + * @param array $attributes The Shortcode attributes.
205 + * @param string $content The ActivityPub post-content.
206 + * @param string $tag The tag/name of the Shortcode.
237 207 *
238 208 * @return string The post permalink.
239 209 */
240 - public static function permalink( $atts, $content, $tag ) {
210 + public static function permalink( $attributes, $content, $tag ) {
241 211 $item = self::get_item();
242 212
243 213 if ( ! $item ) {
244 214 return '';
@@ -243,36 +213,36 @@
243 213 if ( ! $item ) {
244 214 return '';
245 215 }
246 216
247 - $atts = shortcode_atts(
217 + $attributes = shortcode_atts(
248 218 array(
249 219 'type' => 'url',
250 220 ),
251 - $atts,
221 + $attributes,
252 222 $tag
253 223 );
254 224
255 - if ( 'url' === $atts['type'] ) {
225 + if ( 'html' !== $attributes['type'] ) {
256 226 return \esc_url( \get_permalink( $item->ID ) );
257 227 }
258 228
259 229 return \sprintf(
260 - '<a href="%1$s">%1$s</a>',
230 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
261 231 \esc_url( \get_permalink( $item->ID ) )
262 232 );
263 233 }
264 234
265 235 /**
266 - * Generates output for the 'ap_shortlink' Shortcode
236 + * Generates output for the 'ap_shortlink' Shortcode.
267 237 *
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.
238 + * @param array $attributes The Shortcode attributes.
239 + * @param string $content The ActivityPub post-content.
240 + * @param string $tag The tag/name of the Shortcode.
271 241 *
272 242 * @return string The post shortlink.
273 243 */
274 - public static function shortlink( $atts, $content, $tag ) {
244 + public static function shortlink( $attributes, $content, $tag ) {
275 245 $item = self::get_item();
276 246
277 247 if ( ! $item ) {
278 248 return '';
@@ -277,36 +247,36 @@
277 247 if ( ! $item ) {
278 248 return '';
279 249 }
280 250
281 - $atts = shortcode_atts(
251 + $attributes = shortcode_atts(
282 252 array(
283 253 'type' => 'url',
284 254 ),
285 - $atts,
255 + $attributes,
286 256 $tag
287 257 );
288 258
289 - if ( 'url' === $atts['type'] ) {
259 + if ( 'html' !== $attributes['type'] ) {
290 260 return \esc_url( \wp_get_shortlink( $item->ID ) );
291 261 }
292 262
293 263 return \sprintf(
294 - '<a href="%1$s">%1$s</a>',
264 + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>',
295 265 \esc_url( \wp_get_shortlink( $item->ID ) )
296 266 );
297 267 }
298 268
299 269 /**
300 - * Generates output for the 'ap_image' Shortcode
270 + * Generates output for the 'ap_image' Shortcode.
301 271 *
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.
272 + * @param array $attributes The Shortcode attributes.
273 + * @param string $content The ActivityPub post-content.
274 + * @param string $tag The tag/name of the Shortcode.
305 275 *
306 276 * @return string
307 277 */
308 - public static function image( $atts, $content, $tag ) {
278 + public static function image( $attributes, $content, $tag ) {
309 279 $item = self::get_item();
310 280
311 281 if ( ! $item ) {
312 282 return '';
@@ -311,13 +281,13 @@
311 281 if ( ! $item ) {
312 282 return '';
313 283 }
314 284
315 - $atts = shortcode_atts(
285 + $attributes = shortcode_atts(
316 286 array(
317 287 'type' => 'full',
318 288 ),
319 - $atts,
289 + $attributes,
320 290 $tag
321 291 );
322 292
323 293 $size = 'full';
@@ -322,13 +292,13 @@
322 292
323 293 $size = 'full';
324 294
325 295 if ( in_array(
326 - $atts['type'],
296 + $attributes['type'],
327 297 array( 'thumbnail', 'medium', 'large', 'full' ),
328 298 true
329 299 ) ) {
330 - $size = $atts['type'];
300 + $size = $attributes['type'];
331 301 }
332 302
333 303 $image = \get_the_post_thumbnail_url( $item->ID, $size );
334 304
@@ -339,52 +309,24 @@
339 309 return \esc_url( $image );
340 310 }
341 311
342 312 /**
343 - * Generates output for the 'ap_hashcats' Shortcode
313 + * Generates output for the 'ap_hashcats' Shortcode.
344 314 *
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.
315 + * @deprecated 7.0.0
348 316 *
349 317 * @return string The post categories as hashtags.
350 318 */
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 );
319 + public static function hashcats() {
320 + return '';
375 321 }
376 322
377 323 /**
378 - * Generates output for the 'ap_author' Shortcode
324 + * Generates output for the 'ap_author' Shortcode.
379 325 *
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 326 * @return string The author name.
385 327 */
386 - public static function author( $atts, $content, $tag ) {
328 + public static function author() {
387 329 $item = self::get_item();
388 330
389 331 if ( ! $item ) {
390 332 return '';
@@ -390,9 +332,9 @@
390 332 return '';
391 333 }
392 334
393 335 $author_id = \get_post_field( 'post_author', $item->ID );
394 - $name = \get_the_author_meta( 'display_name', $author_id );
336 + $name = \get_the_author_meta( 'display_name', $author_id );
395 337
396 338 if ( ! $name ) {
397 339 return '';
398 340 }
@@ -400,17 +342,13 @@
400 342 return wp_strip_all_tags( $name );
401 343 }
402 344
403 345 /**
404 - * Generates output for the 'ap_authorurl' Shortcode
346 + * Generates output for the 'ap_authorurl' Shortcode.
405 347 *
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 348 * @return string The author URL.
411 349 */
412 - public static function authorurl( $atts, $content, $tag ) {
350 + public static function authorurl() {
413 351 $item = self::get_item();
414 352
415 353 if ( ! $item ) {
416 354 return '';
@@ -416,9 +354,9 @@
416 354 return '';
417 355 }
418 356
419 357 $author_id = \get_post_field( 'post_author', $item->ID );
420 - $url = \get_the_author_meta( 'user_url', $author_id );
358 + $url = \get_the_author_meta( 'user_url', $author_id );
421 359
422 360 if ( ! $url ) {
423 361 return '';
424 362 }
@@ -426,56 +364,40 @@
426 364 return \esc_url( $url );
427 365 }
428 366
429 367 /**
430 - * Generates output for the 'ap_blogurl' Shortcode
368 + * Generates output for the 'ap_blogurl' Shortcode.
431 369 *
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 370 * @return string The site URL.
437 371 */
438 - public static function blogurl( $atts, $content, $tag ) {
372 + public static function blogurl() {
439 373 return \esc_url( \get_bloginfo( 'url' ) );
440 374 }
441 375
442 376 /**
443 - * Generates output for the 'ap_blogname' Shortcode
377 + * Generates output for the 'ap_blogname' Shortcode.
444 378 *
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 379 * @return string
450 380 */
451 - public static function blogname( $atts, $content, $tag ) {
381 + public static function blogname() {
452 382 return \wp_strip_all_tags( \get_bloginfo( 'name' ) );
453 383 }
454 384
455 385 /**
456 - * Generates output for the 'ap_blogdesc' Shortcode
386 + * Generates output for the 'ap_blogdesc' Shortcode.
457 387 *
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 388 * @return string The site description.
463 389 */
464 - public static function blogdesc( $atts, $content, $tag ) {
390 + public static function blogdesc() {
465 391 return \wp_strip_all_tags( \get_bloginfo( 'description' ) );
466 392 }
467 393
468 394 /**
469 - * Generates output for the 'ap_date' Shortcode
395 + * Generates output for the 'ap_date' Shortcode.
470 396 *
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 397 * @return string The post date.
476 398 */
477 - public static function date( $atts, $content, $tag ) {
399 + public static function date() {
478 400 $item = self::get_item();
479 401
480 402 if ( ! $item ) {
481 403 return '';
@@ -480,11 +402,10 @@
480 402 if ( ! $item ) {
481 403 return '';
482 404 }
483 405
484 - $datetime = \get_post_datetime( $item );
406 + $datetime = \get_post_datetime( $item );
485 407 $dateformat = \get_option( 'date_format' );
486 - $timeformat = \get_option( 'time_format' );
487 408
488 409 $date = $datetime->format( $dateformat );
489 410
490 411 if ( ! $date ) {
@@ -494,17 +415,13 @@
494 415 return $date;
495 416 }
496 417
497 418 /**
498 - * Generates output for the 'ap_time' Shortcode
419 + * Generates output for the 'ap_time' Shortcode.
499 420 *
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 421 * @return string The post time.
505 422 */
506 - public static function time( $atts, $content, $tag ) {
423 + public static function time() {
507 424 $item = self::get_item();
508 425
509 426 if ( ! $item ) {
510 427 return '';
@@ -510,13 +427,10 @@
510 427 return '';
511 428 }
512 429
513 430 $datetime = \get_post_datetime( $item );
514 - $dateformat = \get_option( 'date_format' );
515 - $timeformat = \get_option( 'time_format' );
431 + $date = $datetime->format( \get_option( 'time_format' ) );
516 432
517 - $date = $datetime->format( $timeformat );
518 -
519 433 if ( ! $date ) {
520 434 return '';
521 435 }
522 436
@@ -523,17 +437,13 @@
523 437 return $date;
524 438 }
525 439
526 440 /**
527 - * Generates output for the 'ap_datetime' Shortcode
441 + * Generates output for the 'ap_datetime' Shortcode.
528 442 *
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 443 * @return string The post date/time.
534 444 */
535 - public static function datetime( $atts, $content, $tag ) {
445 + public static function datetime() {
536 446 $item = self::get_item();
537 447
538 448 if ( ! $item ) {
539 449 return '';
@@ -538,13 +448,13 @@
538 448 if ( ! $item ) {
539 449 return '';
540 450 }
541 451
542 - $datetime = \get_post_datetime( $item );
543 - $dateformat = \get_option( 'date_format' );
544 - $timeformat = \get_option( 'time_format' );
452 + $datetime = \get_post_datetime( $item );
453 + $date_format = \get_option( 'date_format' );
454 + $time_format = \get_option( 'time_format' );
545 455
546 - $date = $datetime->format( $dateformat . ' @ ' . $timeformat );
456 + $date = $datetime->format( $date_format . ' @ ' . $time_format );
547 457
548 458 if ( ! $date ) {
549 459 return '';
550 460 }
@@ -557,9 +467,9 @@
557 467 *
558 468 * Checks if item (WP_Post) is "public", a supported post type
559 469 * and not password protected.
560 470 *
561 - * @return null|WP_Post The WordPress item.
471 + * @return null|\WP_Post The WordPress item.
562 472 */
563 473 protected static function get_item() {
564 474 $post = \get_post();
565 475