PluginProbe
ActivityPub / 2.6.0
ActivityPub v2.6.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 +242 -137 9.2.02.6.0 View file →
@@ -1,45 +1,42 @@
1 1 <?php
2 -/**
3 - * Shortcodes class file.
4 - *
5 - * @package Activitypub
6 - */
2 +namespace Activitypub;
7 3
8 -namespace Activitypub;
4 +use function Activitypub\esc_hashtag;
9 5
10 -/**
11 - * Shortcodes class.
12 - */
13 6 class Shortcodes {
14 7 /**
15 - * Register the shortcodes.
8 + * Register the shortcodes
16 9 */
17 10 public static function register() {
18 - foreach ( \get_class_methods( self::class ) as $shortcode ) {
11 + foreach ( get_class_methods( self::class ) as $shortcode ) {
19 12 if ( 'init' !== $shortcode ) {
20 - \add_shortcode( 'ap_' . $shortcode, array( self::class, $shortcode ) );
13 + add_shortcode( 'ap_' . $shortcode, array( self::class, $shortcode ) );
21 14 }
22 15 }
23 16 }
24 17
25 18 /**
26 - * Unregister the shortcodes.
19 + * Unregister the shortcodes
27 20 */
28 21 public static function unregister() {
29 - foreach ( \get_class_methods( self::class ) as $shortcode ) {
22 + foreach ( get_class_methods( self::class ) as $shortcode ) {
30 23 if ( 'init' !== $shortcode ) {
31 - \remove_shortcode( 'ap_' . $shortcode );
24 + remove_shortcode( 'ap_' . $shortcode );
32 25 }
33 26 }
34 27 }
35 28
36 29 /**
37 - * Generates output for the 'ap_hashtags' shortcode.
30 + * Generates output for the 'ap_hashtags' shortcode
38 31 *
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 + *
39 36 * @return string The post tags as hashtags.
40 37 */
41 - public static function hashtags() {
38 + public static function hashtags( $atts, $content, $tag ) {
42 39 $item = self::get_item();
43 40
44 41 if ( ! $item ) {
45 42 return '';
@@ -53,13 +50,8 @@
53 50
54 51 $hash_tags = array();
55 52
56 53 foreach ( $tags as $tag ) {
57 - // Tag can be empty.
58 - if ( ! $tag ) {
59 - continue;
60 - }
61 -
62 54 $hash_tags[] = \sprintf(
63 55 '<a rel="tag" class="hashtag u-tag u-category" href="%s">%s</a>',
64 56 \esc_url( \get_tag_link( $tag ) ),
65 57 esc_hashtag( $tag->name )
@@ -71,15 +63,15 @@
71 63
72 64 /**
73 65 * Generates output for the 'ap_title' Shortcode
74 66 *
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.
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.
78 70 *
79 71 * @return string The post title.
80 72 */
81 - public static function title( $attributes, $content, $tag ) {
73 + public static function title( $atts, $content, $tag ) {
82 74 $item = self::get_item();
83 75
84 76 if ( ! $item ) {
85 77 return '';
@@ -84,37 +76,21 @@
84 76 if ( ! $item ) {
85 77 return '';
86 78 }
87 79
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 );
80 + return \wp_strip_all_tags( \get_the_title( $item->ID ), true );
105 81 }
106 82
107 83 /**
108 84 * Generates output for the 'ap_excerpt' Shortcode
109 85 *
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.
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.
113 89 *
114 90 * @return string The post excerpt.
115 91 */
116 - public static function excerpt( $attributes, $content, $tag ) {
92 + public static function excerpt( $atts, $content, $tag ) {
117 93 $item = self::get_item();
118 94
119 95 if ( ! $item ) {
120 96 return '';
@@ -119,36 +95,109 @@
119 95 if ( ! $item ) {
120 96 return '';
121 97 }
122 98
123 - $attributes = \shortcode_atts(
99 + $atts = shortcode_atts(
124 100 array( 'length' => ACTIVITYPUB_EXCERPT_LENGTH ),
125 - $attributes,
101 + $atts,
126 102 $tag
127 103 );
128 104
129 - $excerpt_length = \intval( $attributes['length'] );
105 + $excerpt_length = intval( $atts['length'] );
130 106
131 107 if ( 0 === $excerpt_length ) {
132 108 $excerpt_length = ACTIVITYPUB_EXCERPT_LENGTH;
133 109 }
134 110
135 - $excerpt = generate_post_summary( $item, $excerpt_length );
111 + $excerpt = \get_post_field( 'post_excerpt', $item );
136 112
137 - /** This filter is documented in wp-includes/post-template.php */
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 +
138 187 return \apply_filters( 'the_excerpt', $excerpt );
139 188 }
140 189
141 190 /**
142 - * Generates output for the 'ap_content' Shortcode.
191 + * Generates output for the 'ap_content' Shortcode
143 192 *
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.
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.
147 196 *
148 197 * @return string The post content.
149 198 */
150 - public static function content( $attributes, $content, $tag ) {
199 + public static function content( $atts, $content, $tag ) {
151 200 $item = self::get_item();
152 201
153 202 if ( ! $item ) {
154 203 return '';
@@ -153,14 +202,14 @@
153 202 if ( ! $item ) {
154 203 return '';
155 204 }
156 205
157 - // Prevent inception.
158 - \remove_shortcode( 'ap_content' );
206 + // prevent inception
207 + remove_shortcode( 'ap_content' );
159 208
160 - $attributes = \shortcode_atts(
209 + $atts = shortcode_atts(
161 210 array( 'apply_filters' => 'yes' ),
162 - $attributes,
211 + $atts,
163 212 $tag
164 213 );
165 214
166 215 $content = '';
@@ -165,49 +214,45 @@
165 214
166 215 $content = '';
167 216
168 217 if ( 'attachment' === $item->post_type ) {
169 - // Get title of attachment with fallback to alt text.
170 - $content = \wp_get_attachment_caption( $item->ID );
218 + // get title of attachment with fallback to alt text.
219 + $content = wp_get_attachment_caption( $item->ID );
171 220 if ( empty( $content ) ) {
172 - $content = \get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
221 + $content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
173 222 }
174 - }
175 -
176 - if ( empty( $content ) ) {
223 + } else {
177 224 $content = \get_post_field( 'post_content', $item );
178 - }
179 225
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 );
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 );
186 232 }
187 - $content = \wptexturize( $content );
188 - $content = \wp_filter_content_tags( $content );
233 +
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 ) );
189 238 }
190 239
191 - $content = \strip_shortcodes( $content );
192 - $content = Sanitize::clean_html( $content );
193 - $content = Sanitize::strip_whitespace( $content );
240 + add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
194 241
195 - \add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
196 -
197 242 return $content;
198 243 }
199 244
200 245 /**
201 - * Generates output for the 'ap_permalink' Shortcode.
246 + * Generates output for the 'ap_permalink' Shortcode
202 247 *
203 - * @param array $attributes The Shortcode attributes.
204 - * @param string $content The ActivityPub post-content.
205 - * @param string $tag The tag/name of the Shortcode.
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.
206 251 *
207 252 * @return string The post permalink.
208 253 */
209 - public static function permalink( $attributes, $content, $tag ) {
254 + public static function permalink( $atts, $content, $tag ) {
210 255 $item = self::get_item();
211 256
212 257 if ( ! $item ) {
213 258 return '';
@@ -212,17 +257,17 @@
212 257 if ( ! $item ) {
213 258 return '';
214 259 }
215 260
216 - $attributes = \shortcode_atts(
261 + $atts = shortcode_atts(
217 262 array(
218 263 'type' => 'url',
219 264 ),
220 - $attributes,
265 + $atts,
221 266 $tag
222 267 );
223 268
224 - if ( 'html' !== $attributes['type'] ) {
269 + if ( 'url' === $atts['type'] ) {
225 270 return \esc_url( \get_permalink( $item->ID ) );
226 271 }
227 272
228 273 return \sprintf(
@@ -231,17 +276,17 @@
231 276 );
232 277 }
233 278
234 279 /**
235 - * Generates output for the 'ap_shortlink' Shortcode.
280 + * Generates output for the 'ap_shortlink' Shortcode
236 281 *
237 - * @param array $attributes The Shortcode attributes.
238 - * @param string $content The ActivityPub post-content.
239 - * @param string $tag The tag/name of the Shortcode.
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.
240 285 *
241 286 * @return string The post shortlink.
242 287 */
243 - public static function shortlink( $attributes, $content, $tag ) {
288 + public static function shortlink( $atts, $content, $tag ) {
244 289 $item = self::get_item();
245 290
246 291 if ( ! $item ) {
247 292 return '';
@@ -246,17 +291,17 @@
246 291 if ( ! $item ) {
247 292 return '';
248 293 }
249 294
250 - $attributes = \shortcode_atts(
295 + $atts = shortcode_atts(
251 296 array(
252 297 'type' => 'url',
253 298 ),
254 - $attributes,
299 + $atts,
255 300 $tag
256 301 );
257 302
258 - if ( 'html' !== $attributes['type'] ) {
303 + if ( 'url' === $atts['type'] ) {
259 304 return \esc_url( \wp_get_shortlink( $item->ID ) );
260 305 }
261 306
262 307 return \sprintf(
@@ -265,17 +310,17 @@
265 310 );
266 311 }
267 312
268 313 /**
269 - * Generates output for the 'ap_image' Shortcode.
314 + * Generates output for the 'ap_image' Shortcode
270 315 *
271 - * @param array $attributes The Shortcode attributes.
272 - * @param string $content The ActivityPub post-content.
273 - * @param string $tag The tag/name of the Shortcode.
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.
274 319 *
275 320 * @return string
276 321 */
277 - public static function image( $attributes, $content, $tag ) {
322 + public static function image( $atts, $content, $tag ) {
278 323 $item = self::get_item();
279 324
280 325 if ( ! $item ) {
281 326 return '';
@@ -280,24 +325,24 @@
280 325 if ( ! $item ) {
281 326 return '';
282 327 }
283 328
284 - $attributes = \shortcode_atts(
329 + $atts = shortcode_atts(
285 330 array(
286 331 'type' => 'full',
287 332 ),
288 - $attributes,
333 + $atts,
289 334 $tag
290 335 );
291 336
292 337 $size = 'full';
293 338
294 - if ( \in_array(
295 - $attributes['type'],
339 + if ( in_array(
340 + $atts['type'],
296 341 array( 'thumbnail', 'medium', 'large', 'full' ),
297 342 true
298 343 ) ) {
299 - $size = $attributes['type'];
344 + $size = $atts['type'];
300 345 }
301 346
302 347 $image = \get_the_post_thumbnail_url( $item->ID, $size );
303 348
@@ -308,24 +353,52 @@
308 353 return \esc_url( $image );
309 354 }
310 355
311 356 /**
312 - * Generates output for the 'ap_hashcats' Shortcode.
357 + * Generates output for the 'ap_hashcats' Shortcode
313 358 *
314 - * @deprecated 7.0.0
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 362 *
316 363 * @return string The post categories as hashtags.
317 364 */
318 - public static function hashcats() {
319 - return '';
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 389 }
321 390
322 391 /**
323 - * Generates output for the 'ap_author' Shortcode.
392 + * Generates output for the 'ap_author' Shortcode
324 393 *
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 + *
325 398 * @return string The author name.
326 399 */
327 - public static function author() {
400 + public static function author( $atts, $content, $tag ) {
328 401 $item = self::get_item();
329 402
330 403 if ( ! $item ) {
331 404 return '';
@@ -331,23 +404,27 @@
331 404 return '';
332 405 }
333 406
334 407 $author_id = \get_post_field( 'post_author', $item->ID );
335 - $name = \get_the_author_meta( 'display_name', $author_id );
408 + $name = \get_the_author_meta( 'display_name', $author_id );
336 409
337 410 if ( ! $name ) {
338 411 return '';
339 412 }
340 413
341 - return \wp_strip_all_tags( $name );
414 + return wp_strip_all_tags( $name );
342 415 }
343 416
344 417 /**
345 - * Generates output for the 'ap_authorurl' Shortcode.
418 + * Generates output for the 'ap_authorurl' Shortcode
346 419 *
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 + *
347 424 * @return string The author URL.
348 425 */
349 - public static function authorurl() {
426 + public static function authorurl( $atts, $content, $tag ) {
350 427 $item = self::get_item();
351 428
352 429 if ( ! $item ) {
353 430 return '';
@@ -353,9 +430,9 @@
353 430 return '';
354 431 }
355 432
356 433 $author_id = \get_post_field( 'post_author', $item->ID );
357 - $url = \get_the_author_meta( 'user_url', $author_id );
434 + $url = \get_the_author_meta( 'user_url', $author_id );
358 435
359 436 if ( ! $url ) {
360 437 return '';
361 438 }
@@ -363,40 +440,56 @@
363 440 return \esc_url( $url );
364 441 }
365 442
366 443 /**
367 - * Generates output for the 'ap_blogurl' Shortcode.
444 + * Generates output for the 'ap_blogurl' Shortcode
368 445 *
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 + *
369 450 * @return string The site URL.
370 451 */
371 - public static function blogurl() {
452 + public static function blogurl( $atts, $content, $tag ) {
372 453 return \esc_url( \get_bloginfo( 'url' ) );
373 454 }
374 455
375 456 /**
376 - * Generates output for the 'ap_blogname' Shortcode.
457 + * Generates output for the 'ap_blogname' Shortcode
377 458 *
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 + *
378 463 * @return string
379 464 */
380 - public static function blogname() {
465 + public static function blogname( $atts, $content, $tag ) {
381 466 return \wp_strip_all_tags( \get_bloginfo( 'name' ) );
382 467 }
383 468
384 469 /**
385 - * Generates output for the 'ap_blogdesc' Shortcode.
470 + * Generates output for the 'ap_blogdesc' Shortcode
386 471 *
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 + *
387 476 * @return string The site description.
388 477 */
389 - public static function blogdesc() {
478 + public static function blogdesc( $atts, $content, $tag ) {
390 479 return \wp_strip_all_tags( \get_bloginfo( 'description' ) );
391 480 }
392 481
393 482 /**
394 - * Generates output for the 'ap_date' Shortcode.
483 + * Generates output for the 'ap_date' Shortcode
395 484 *
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 + *
396 489 * @return string The post date.
397 490 */
398 - public static function date() {
491 + public static function date( $atts, $content, $tag ) {
399 492 $item = self::get_item();
400 493
401 494 if ( ! $item ) {
402 495 return '';
@@ -401,10 +494,11 @@
401 494 if ( ! $item ) {
402 495 return '';
403 496 }
404 497
405 - $datetime = \get_post_datetime( $item );
498 + $datetime = \get_post_datetime( $item );
406 499 $dateformat = \get_option( 'date_format' );
500 + $timeformat = \get_option( 'time_format' );
407 501
408 502 $date = $datetime->format( $dateformat );
409 503
410 504 if ( ! $date ) {
@@ -414,13 +508,17 @@
414 508 return $date;
415 509 }
416 510
417 511 /**
418 - * Generates output for the 'ap_time' Shortcode.
512 + * Generates output for the 'ap_time' Shortcode
419 513 *
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 + *
420 518 * @return string The post time.
421 519 */
422 - public static function time() {
520 + public static function time( $atts, $content, $tag ) {
423 521 $item = self::get_item();
424 522
425 523 if ( ! $item ) {
426 524 return '';
@@ -426,10 +524,13 @@
426 524 return '';
427 525 }
428 526
429 527 $datetime = \get_post_datetime( $item );
430 - $date = $datetime->format( \get_option( 'time_format' ) );
528 + $dateformat = \get_option( 'date_format' );
529 + $timeformat = \get_option( 'time_format' );
431 530
531 + $date = $datetime->format( $timeformat );
532 +
432 533 if ( ! $date ) {
433 534 return '';
434 535 }
435 536
@@ -436,13 +537,17 @@
436 537 return $date;
437 538 }
438 539
439 540 /**
440 - * Generates output for the 'ap_datetime' Shortcode.
541 + * Generates output for the 'ap_datetime' Shortcode
441 542 *
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 + *
442 547 * @return string The post date/time.
443 548 */
444 - public static function datetime() {
549 + public static function datetime( $atts, $content, $tag ) {
445 550 $item = self::get_item();
446 551
447 552 if ( ! $item ) {
448 553 return '';
@@ -447,13 +552,13 @@
447 552 if ( ! $item ) {
448 553 return '';
449 554 }
450 555
451 - $datetime = \get_post_datetime( $item );
452 - $date_format = \get_option( 'date_format' );
453 - $time_format = \get_option( 'time_format' );
556 + $datetime = \get_post_datetime( $item );
557 + $dateformat = \get_option( 'date_format' );
558 + $timeformat = \get_option( 'time_format' );
454 559
455 - $date = $datetime->format( $date_format . ' @ ' . $time_format );
560 + $date = $datetime->format( $dateformat . ' @ ' . $timeformat );
456 561
457 562 if ( ! $date ) {
458 563 return '';
459 564 }
@@ -466,9 +571,9 @@
466 571 *
467 572 * Checks if item (WP_Post) is "public", a supported post type
468 573 * and not password protected.
469 574 *
470 - * @return null|\WP_Post The WordPress item.
575 + * @return null|WP_Post The WordPress item.
471 576 */
472 577 protected static function get_item() {
473 578 $post = \get_post();
474 579