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