PluginProbe
ActivityPub / 7.8.2
ActivityPub v7.8.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 +138 -225 1.0.87.8.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 '';
@@ -389,9 +332,10 @@
389 332 if ( ! $item ) {
390 333 return '';
391 334 }
392 335
393 - $name = \get_the_author_meta( 'display_name', $item->post_author );
336 + $author_id = \get_post_field( 'post_author', $item->ID );
337 + $name = \get_the_author_meta( 'display_name', $author_id );
394 338
395 339 if ( ! $name ) {
396 340 return '';
397 341 }
@@ -399,17 +343,13 @@
399 343 return wp_strip_all_tags( $name );
400 344 }
401 345
402 346 /**
403 - * Generates output for the 'ap_authorurl' Shortcode
347 + * Generates output for the 'ap_authorurl' Shortcode.
404 348 *
405 - * @param array $atts The Shortcode attributes.
406 - * @param string $content The ActivityPub post-content.
407 - * @param string $tag The tag/name of the Shortcode.
408 - *
409 349 * @return string The author URL.
410 350 */
411 - public static function authorurl( $atts, $content, $tag ) {
351 + public static function authorurl() {
412 352 $item = self::get_item();
413 353
414 354 if ( ! $item ) {
415 355 return '';
@@ -414,9 +354,10 @@
414 354 if ( ! $item ) {
415 355 return '';
416 356 }
417 357
418 - $url = \get_the_author_meta( 'user_url', $item->post_author );
358 + $author_id = \get_post_field( 'post_author', $item->ID );
359 + $url = \get_the_author_meta( 'user_url', $author_id );
419 360
420 361 if ( ! $url ) {
421 362 return '';
422 363 }
@@ -424,56 +365,40 @@
424 365 return \esc_url( $url );
425 366 }
426 367
427 368 /**
428 - * Generates output for the 'ap_blogurl' Shortcode
369 + * Generates output for the 'ap_blogurl' Shortcode.
429 370 *
430 - * @param array $atts The Shortcode attributes.
431 - * @param string $content The ActivityPub post-content.
432 - * @param string $tag The tag/name of the Shortcode.
433 - *
434 371 * @return string The site URL.
435 372 */
436 - public static function blogurl( $atts, $content, $tag ) {
373 + public static function blogurl() {
437 374 return \esc_url( \get_bloginfo( 'url' ) );
438 375 }
439 376
440 377 /**
441 - * Generates output for the 'ap_blogname' Shortcode
378 + * Generates output for the 'ap_blogname' Shortcode.
442 379 *
443 - * @param array $atts The Shortcode attributes.
444 - * @param string $content The ActivityPub post-content.
445 - * @param string $tag The tag/name of the Shortcode.
446 - *
447 380 * @return string
448 381 */
449 - public static function blogname( $atts, $content, $tag ) {
382 + public static function blogname() {
450 383 return \wp_strip_all_tags( \get_bloginfo( 'name' ) );
451 384 }
452 385
453 386 /**
454 - * Generates output for the 'ap_blogdesc' Shortcode
387 + * Generates output for the 'ap_blogdesc' Shortcode.
455 388 *
456 - * @param array $atts The Shortcode attributes.
457 - * @param string $content The ActivityPub post-content.
458 - * @param string $tag The tag/name of the Shortcode.
459 - *
460 389 * @return string The site description.
461 390 */
462 - public static function blogdesc( $atts, $content, $tag ) {
391 + public static function blogdesc() {
463 392 return \wp_strip_all_tags( \get_bloginfo( 'description' ) );
464 393 }
465 394
466 395 /**
467 - * Generates output for the 'ap_date' Shortcode
396 + * Generates output for the 'ap_date' Shortcode.
468 397 *
469 - * @param array $atts The Shortcode attributes.
470 - * @param string $content The ActivityPub post-content.
471 - * @param string $tag The tag/name of the Shortcode.
472 - *
473 398 * @return string The post date.
474 399 */
475 - public static function date( $atts, $content, $tag ) {
400 + public static function date() {
476 401 $item = self::get_item();
477 402
478 403 if ( ! $item ) {
479 404 return '';
@@ -478,11 +403,10 @@
478 403 if ( ! $item ) {
479 404 return '';
480 405 }
481 406
482 - $datetime = \get_post_datetime( $item );
407 + $datetime = \get_post_datetime( $item );
483 408 $dateformat = \get_option( 'date_format' );
484 - $timeformat = \get_option( 'time_format' );
485 409
486 410 $date = $datetime->format( $dateformat );
487 411
488 412 if ( ! $date ) {
@@ -492,17 +416,13 @@
492 416 return $date;
493 417 }
494 418
495 419 /**
496 - * Generates output for the 'ap_time' Shortcode
420 + * Generates output for the 'ap_time' Shortcode.
497 421 *
498 - * @param array $atts The Shortcode attributes.
499 - * @param string $content The ActivityPub post-content.
500 - * @param string $tag The tag/name of the Shortcode.
501 - *
502 422 * @return string The post time.
503 423 */
504 - public static function time( $atts, $content, $tag ) {
424 + public static function time() {
505 425 $item = self::get_item();
506 426
507 427 if ( ! $item ) {
508 428 return '';
@@ -508,13 +428,10 @@
508 428 return '';
509 429 }
510 430
511 431 $datetime = \get_post_datetime( $item );
512 - $dateformat = \get_option( 'date_format' );
513 - $timeformat = \get_option( 'time_format' );
432 + $date = $datetime->format( \get_option( 'time_format' ) );
514 433
515 - $date = $datetime->format( $timeformat );
516 -
517 434 if ( ! $date ) {
518 435 return '';
519 436 }
520 437
@@ -521,17 +438,13 @@
521 438 return $date;
522 439 }
523 440
524 441 /**
525 - * Generates output for the 'ap_datetime' Shortcode
442 + * Generates output for the 'ap_datetime' Shortcode.
526 443 *
527 - * @param array $atts The Shortcode attributes.
528 - * @param string $content The ActivityPub post-content.
529 - * @param string $tag The tag/name of the Shortcode.
530 - *
531 444 * @return string The post date/time.
532 445 */
533 - public static function datetime( $atts, $content, $tag ) {
446 + public static function datetime() {
534 447 $item = self::get_item();
535 448
536 449 if ( ! $item ) {
537 450 return '';
@@ -536,13 +449,13 @@
536 449 if ( ! $item ) {
537 450 return '';
538 451 }
539 452
540 - $datetime = \get_post_datetime( $item );
541 - $dateformat = \get_option( 'date_format' );
542 - $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' );
543 456
544 - $date = $datetime->format( $dateformat . ' @ ' . $timeformat );
457 + $date = $datetime->format( $date_format . ' @ ' . $time_format );
545 458
546 459 if ( ! $date ) {
547 460 return '';
548 461 }
@@ -555,9 +468,9 @@
555 468 *
556 469 * Checks if item (WP_Post) is "public", a supported post type
557 470 * and not password protected.
558 471 *
559 - * @return null|WP_Post The WordPress item.
472 + * @return null|\WP_Post The WordPress item.
560 473 */
561 474 protected static function get_item() {
562 475 $post = \get_post();
563 476