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