| @@ -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 ''; |
| @@ -76,9 +79,25 @@ | ||
| 76 | 79 | if ( ! $item ) { |
| 77 | 80 | return ''; |
| 78 | 81 | } |
| 79 | 82 | |
| 80 | - return \wp_strip_all_tags( \get_the_title( $item->ID ), true ); | |
| 83 | + $title = \wp_strip_all_tags( \get_the_title( $item->ID ), true ); | |
| 84 | + | |
| 85 | + if ( ! $title ) { | |
| 86 | + return ''; | |
| 87 | + } | |
| 88 | + | |
| 89 | + $atts = shortcode_atts( | |
| 90 | + array( 'type' => 'plain' ), | |
| 91 | + $atts, | |
| 92 | + $tag | |
| 93 | + ); | |
| 94 | + | |
| 95 | + if ( 'html' !== $atts['type'] ) { | |
| 96 | + return $title; | |
| 97 | + } | |
| 98 | + | |
| 99 | + return sprintf( '<h2>%s</h2>', $title ); | |
| 81 | 100 | } |
| 82 | 101 | |
| 83 | 102 | /** |
| 84 | 103 | * Generates output for the 'ap_excerpt' Shortcode |
| @@ -107,89 +126,16 @@ | ||
| 107 | 126 | if ( 0 === $excerpt_length ) { |
| 108 | 127 | $excerpt_length = ACTIVITYPUB_EXCERPT_LENGTH; |
| 109 | 128 | } |
| 110 | 129 | |
| 111 | - $excerpt = \get_post_field( 'post_excerpt', $item ); | |
| 130 | + $excerpt = generate_post_summary( $item, $excerpt_length ); | |
| 112 | 131 | |
| 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( ']]>', ']]>', $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', ' […]' ); | |
| 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 | - | |
| 132 | + /** This filter is documented in wp-includes/post-template.php */ | |
| 187 | 133 | return \apply_filters( 'the_excerpt', $excerpt ); |
| 188 | 134 | } |
| 189 | 135 | |
| 190 | 136 | /** |
| 191 | - * Generates output for the 'ap_content' Shortcode | |
| 137 | + * Generates output for the 'ap_content' Shortcode. | |
| 192 | 138 | * |
| 193 | 139 | * @param array $atts The Shortcode attributes. |
| 194 | 140 | * @param string $content The ActivityPub post-content. |
| 195 | 141 | * @param string $tag The tag/name of the Shortcode. |
| @@ -202,9 +148,9 @@ | ||
| 202 | 148 | if ( ! $item ) { |
| 203 | 149 | return ''; |
| 204 | 150 | } |
| 205 | 151 | |
| 206 | - // prevent inception | |
| 152 | + // Prevent inception. | |
| 207 | 153 | remove_shortcode( 'ap_content' ); |
| 208 | 154 | |
| 209 | 155 | $atts = shortcode_atts( |
| 210 | 156 | array( 'apply_filters' => 'yes' ), |
| @@ -214,29 +160,32 @@ | ||
| 214 | 160 | |
| 215 | 161 | $content = ''; |
| 216 | 162 | |
| 217 | 163 | if ( 'attachment' === $item->post_type ) { |
| 218 | - // get title of attachment with fallback to alt text. | |
| 164 | + // Get title of attachment with fallback to alt text. | |
| 219 | 165 | $content = wp_get_attachment_caption( $item->ID ); |
| 220 | 166 | if ( empty( $content ) ) { |
| 221 | 167 | $content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true ); |
| 222 | 168 | } |
| 223 | - } else { | |
| 169 | + } | |
| 170 | + | |
| 171 | + if ( empty( $content ) ) { | |
| 224 | 172 | $content = \get_post_field( 'post_content', $item ); |
| 173 | + } | |
| 225 | 174 | |
| 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 ); | |
| 232 | - } | |
| 175 | + if ( 'yes' === $atts['apply_filters'] ) { | |
| 176 | + /** This filter is documented in wp-includes/post-template.php */ | |
| 177 | + $content = \apply_filters( 'the_content', $content ); | |
| 178 | + } else { | |
| 179 | + $content = do_blocks( $content ); | |
| 180 | + $content = wptexturize( $content ); | |
| 181 | + $content = wp_filter_content_tags( $content ); | |
| 182 | + } | |
| 233 | 183 | |
| 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 | - } | |
| 184 | + // Replace script and style elements. | |
| 185 | + $content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content ); | |
| 186 | + $content = strip_shortcodes( $content ); | |
| 187 | + $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) ); | |
| 239 | 188 | |
| 240 | 189 | add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) ); |
| 241 | 190 | |
| 242 | 191 | return $content; |
| @@ -242,9 +191,9 @@ | ||
| 242 | 191 | return $content; |
| 243 | 192 | } |
| 244 | 193 | |
| 245 | 194 | /** |
| 246 | - * Generates output for the 'ap_permalink' Shortcode | |
| 195 | + * Generates output for the 'ap_permalink' Shortcode. | |
| 247 | 196 | * |
| 248 | 197 | * @param array $atts The Shortcode attributes. |
| 249 | 198 | * @param string $content The ActivityPub post-content. |
| 250 | 199 | * @param string $tag The tag/name of the Shortcode. |
| @@ -265,20 +214,20 @@ | ||
| 265 | 214 | $atts, |
| 266 | 215 | $tag |
| 267 | 216 | ); |
| 268 | 217 | |
| 269 | - if ( 'url' === $atts['type'] ) { | |
| 218 | + if ( 'html' !== $atts['type'] ) { | |
| 270 | 219 | return \esc_url( \get_permalink( $item->ID ) ); |
| 271 | 220 | } |
| 272 | 221 | |
| 273 | 222 | return \sprintf( |
| 274 | - '<a href="%1$s">%1$s</a>', | |
| 223 | + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>', | |
| 275 | 224 | \esc_url( \get_permalink( $item->ID ) ) |
| 276 | 225 | ); |
| 277 | 226 | } |
| 278 | 227 | |
| 279 | 228 | /** |
| 280 | - * Generates output for the 'ap_shortlink' Shortcode | |
| 229 | + * Generates output for the 'ap_shortlink' Shortcode. | |
| 281 | 230 | * |
| 282 | 231 | * @param array $atts The Shortcode attributes. |
| 283 | 232 | * @param string $content The ActivityPub post-content. |
| 284 | 233 | * @param string $tag The tag/name of the Shortcode. |
| @@ -299,20 +248,20 @@ | ||
| 299 | 248 | $atts, |
| 300 | 249 | $tag |
| 301 | 250 | ); |
| 302 | 251 | |
| 303 | - if ( 'url' === $atts['type'] ) { | |
| 252 | + if ( 'html' !== $atts['type'] ) { | |
| 304 | 253 | return \esc_url( \wp_get_shortlink( $item->ID ) ); |
| 305 | 254 | } |
| 306 | 255 | |
| 307 | 256 | return \sprintf( |
| 308 | - '<a href="%1$s">%1$s</a>', | |
| 257 | + '<a href="%1$s" class="status-link unhandled-link">%1$s</a>', | |
| 309 | 258 | \esc_url( \wp_get_shortlink( $item->ID ) ) |
| 310 | 259 | ); |
| 311 | 260 | } |
| 312 | 261 | |
| 313 | 262 | /** |
| 314 | - * Generates output for the 'ap_image' Shortcode | |
| 263 | + * Generates output for the 'ap_image' Shortcode. | |
| 315 | 264 | * |
| 316 | 265 | * @param array $atts The Shortcode attributes. |
| 317 | 266 | * @param string $content The ActivityPub post-content. |
| 318 | 267 | * @param string $tag The tag/name of the Shortcode. |
| @@ -353,17 +302,13 @@ | ||
| 353 | 302 | return \esc_url( $image ); |
| 354 | 303 | } |
| 355 | 304 | |
| 356 | 305 | /** |
| 357 | - * Generates output for the 'ap_hashcats' Shortcode | |
| 306 | + * Generates output for the 'ap_hashcats' Shortcode. | |
| 358 | 307 | * |
| 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. | |
| 362 | - * | |
| 363 | 308 | * @return string The post categories as hashtags. |
| 364 | 309 | */ |
| 365 | - public static function hashcats( $atts, $content, $tag ) { | |
| 310 | + public static function hashcats() { | |
| 366 | 311 | $item = self::get_item(); |
| 367 | 312 | |
| 368 | 313 | if ( ! $item ) { |
| 369 | 314 | return ''; |
| @@ -388,17 +333,13 @@ | ||
| 388 | 333 | return \implode( ' ', $hash_tags ); |
| 389 | 334 | } |
| 390 | 335 | |
| 391 | 336 | /** |
| 392 | - * Generates output for the 'ap_author' Shortcode | |
| 337 | + * Generates output for the 'ap_author' Shortcode. | |
| 393 | 338 | * |
| 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 | 339 | * @return string The author name. |
| 399 | 340 | */ |
| 400 | - public static function author( $atts, $content, $tag ) { | |
| 341 | + public static function author() { | |
| 401 | 342 | $item = self::get_item(); |
| 402 | 343 | |
| 403 | 344 | if ( ! $item ) { |
| 404 | 345 | return ''; |
| @@ -404,9 +345,9 @@ | ||
| 404 | 345 | return ''; |
| 405 | 346 | } |
| 406 | 347 | |
| 407 | 348 | $author_id = \get_post_field( 'post_author', $item->ID ); |
| 408 | - $name = \get_the_author_meta( 'display_name', $author_id ); | |
| 349 | + $name = \get_the_author_meta( 'display_name', $author_id ); | |
| 409 | 350 | |
| 410 | 351 | if ( ! $name ) { |
| 411 | 352 | return ''; |
| 412 | 353 | } |
| @@ -414,17 +355,13 @@ | ||
| 414 | 355 | return wp_strip_all_tags( $name ); |
| 415 | 356 | } |
| 416 | 357 | |
| 417 | 358 | /** |
| 418 | - * Generates output for the 'ap_authorurl' Shortcode | |
| 359 | + * Generates output for the 'ap_authorurl' Shortcode. | |
| 419 | 360 | * |
| 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 | 361 | * @return string The author URL. |
| 425 | 362 | */ |
| 426 | - public static function authorurl( $atts, $content, $tag ) { | |
| 363 | + public static function authorurl() { | |
| 427 | 364 | $item = self::get_item(); |
| 428 | 365 | |
| 429 | 366 | if ( ! $item ) { |
| 430 | 367 | return ''; |
| @@ -430,9 +367,9 @@ | ||
| 430 | 367 | return ''; |
| 431 | 368 | } |
| 432 | 369 | |
| 433 | 370 | $author_id = \get_post_field( 'post_author', $item->ID ); |
| 434 | - $url = \get_the_author_meta( 'user_url', $author_id ); | |
| 371 | + $url = \get_the_author_meta( 'user_url', $author_id ); | |
| 435 | 372 | |
| 436 | 373 | if ( ! $url ) { |
| 437 | 374 | return ''; |
| 438 | 375 | } |
| @@ -440,56 +377,40 @@ | ||
| 440 | 377 | return \esc_url( $url ); |
| 441 | 378 | } |
| 442 | 379 | |
| 443 | 380 | /** |
| 444 | - * Generates output for the 'ap_blogurl' Shortcode | |
| 381 | + * Generates output for the 'ap_blogurl' Shortcode. | |
| 445 | 382 | * |
| 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 | 383 | * @return string The site URL. |
| 451 | 384 | */ |
| 452 | - public static function blogurl( $atts, $content, $tag ) { | |
| 385 | + public static function blogurl() { | |
| 453 | 386 | return \esc_url( \get_bloginfo( 'url' ) ); |
| 454 | 387 | } |
| 455 | 388 | |
| 456 | 389 | /** |
| 457 | - * Generates output for the 'ap_blogname' Shortcode | |
| 390 | + * Generates output for the 'ap_blogname' Shortcode. | |
| 458 | 391 | * |
| 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 | 392 | * @return string |
| 464 | 393 | */ |
| 465 | - public static function blogname( $atts, $content, $tag ) { | |
| 394 | + public static function blogname() { | |
| 466 | 395 | return \wp_strip_all_tags( \get_bloginfo( 'name' ) ); |
| 467 | 396 | } |
| 468 | 397 | |
| 469 | 398 | /** |
| 470 | - * Generates output for the 'ap_blogdesc' Shortcode | |
| 399 | + * Generates output for the 'ap_blogdesc' Shortcode. | |
| 471 | 400 | * |
| 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 | 401 | * @return string The site description. |
| 477 | 402 | */ |
| 478 | - public static function blogdesc( $atts, $content, $tag ) { | |
| 403 | + public static function blogdesc() { | |
| 479 | 404 | return \wp_strip_all_tags( \get_bloginfo( 'description' ) ); |
| 480 | 405 | } |
| 481 | 406 | |
| 482 | 407 | /** |
| 483 | - * Generates output for the 'ap_date' Shortcode | |
| 408 | + * Generates output for the 'ap_date' Shortcode. | |
| 484 | 409 | * |
| 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 | 410 | * @return string The post date. |
| 490 | 411 | */ |
| 491 | - public static function date( $atts, $content, $tag ) { | |
| 412 | + public static function date() { | |
| 492 | 413 | $item = self::get_item(); |
| 493 | 414 | |
| 494 | 415 | if ( ! $item ) { |
| 495 | 416 | return ''; |
| @@ -494,11 +415,10 @@ | ||
| 494 | 415 | if ( ! $item ) { |
| 495 | 416 | return ''; |
| 496 | 417 | } |
| 497 | 418 | |
| 498 | - $datetime = \get_post_datetime( $item ); | |
| 419 | + $datetime = \get_post_datetime( $item ); | |
| 499 | 420 | $dateformat = \get_option( 'date_format' ); |
| 500 | - $timeformat = \get_option( 'time_format' ); | |
| 501 | 421 | |
| 502 | 422 | $date = $datetime->format( $dateformat ); |
| 503 | 423 | |
| 504 | 424 | if ( ! $date ) { |
| @@ -508,17 +428,13 @@ | ||
| 508 | 428 | return $date; |
| 509 | 429 | } |
| 510 | 430 | |
| 511 | 431 | /** |
| 512 | - * Generates output for the 'ap_time' Shortcode | |
| 432 | + * Generates output for the 'ap_time' Shortcode. | |
| 513 | 433 | * |
| 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 | 434 | * @return string The post time. |
| 519 | 435 | */ |
| 520 | - public static function time( $atts, $content, $tag ) { | |
| 436 | + public static function time() { | |
| 521 | 437 | $item = self::get_item(); |
| 522 | 438 | |
| 523 | 439 | if ( ! $item ) { |
| 524 | 440 | return ''; |
| @@ -523,10 +439,9 @@ | ||
| 523 | 439 | if ( ! $item ) { |
| 524 | 440 | return ''; |
| 525 | 441 | } |
| 526 | 442 | |
| 527 | - $datetime = \get_post_datetime( $item ); | |
| 528 | - $dateformat = \get_option( 'date_format' ); | |
| 443 | + $datetime = \get_post_datetime( $item ); | |
| 529 | 444 | $timeformat = \get_option( 'time_format' ); |
| 530 | 445 | |
| 531 | 446 | $date = $datetime->format( $timeformat ); |
| 532 | 447 | |
| @@ -537,17 +452,13 @@ | ||
| 537 | 452 | return $date; |
| 538 | 453 | } |
| 539 | 454 | |
| 540 | 455 | /** |
| 541 | - * Generates output for the 'ap_datetime' Shortcode | |
| 456 | + * Generates output for the 'ap_datetime' Shortcode. | |
| 542 | 457 | * |
| 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 | 458 | * @return string The post date/time. |
| 548 | 459 | */ |
| 549 | - public static function datetime( $atts, $content, $tag ) { | |
| 460 | + public static function datetime() { | |
| 550 | 461 | $item = self::get_item(); |
| 551 | 462 | |
| 552 | 463 | if ( ! $item ) { |
| 553 | 464 | return ''; |
| @@ -552,9 +463,9 @@ | ||
| 552 | 463 | if ( ! $item ) { |
| 553 | 464 | return ''; |
| 554 | 465 | } |
| 555 | 466 | |
| 556 | - $datetime = \get_post_datetime( $item ); | |
| 467 | + $datetime = \get_post_datetime( $item ); | |
| 557 | 468 | $dateformat = \get_option( 'date_format' ); |
| 558 | 469 | $timeformat = \get_option( 'time_format' ); |
| 559 | 470 | |
| 560 | 471 | $date = $datetime->format( $dateformat . ' @ ' . $timeformat ); |
| @@ -571,9 +482,9 @@ | ||
| 571 | 482 | * |
| 572 | 483 | * Checks if item (WP_Post) is "public", a supported post type |
| 573 | 484 | * and not password protected. |
| 574 | 485 | * |
| 575 | - * @return null|WP_Post The WordPress item. | |
| 486 | + * @return null|\WP_Post The WordPress item. | |
| 576 | 487 | */ |
| 577 | 488 | protected static function get_item() { |
| 578 | 489 | $post = \get_post(); |
| 579 | 490 | |