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