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