updated plugin ActivityPub version 5.8.0

This commit is contained in:
2025-04-29 21:19:06 +00:00
committed by Gitium
parent 19dfd317cc
commit fdfbf76539
166 changed files with 14119 additions and 7163 deletions

View File

@ -54,6 +54,11 @@ class Shortcodes {
$hash_tags = array();
foreach ( $tags as $tag ) {
// Tag can be empty.
if ( ! $tag ) {
continue;
}
$hash_tags[] = \sprintf(
'<a rel="tag" class="hashtag u-tag u-category" href="%s">%s</a>',
\esc_url( \get_tag_link( $tag ) ),
@ -67,16 +72,36 @@ class Shortcodes {
/**
* Generates output for the 'ap_title' Shortcode
*
* @param array $atts The Shortcode attributes.
* @param string $content The ActivityPub post-content.
* @param string $tag The tag/name of the Shortcode.
*
* @return string The post title.
*/
public static function title() {
public static function title( $atts, $content, $tag ) {
$item = self::get_item();
if ( ! $item ) {
return '';
}
return \wp_strip_all_tags( \get_the_title( $item->ID ), true );
$title = \wp_strip_all_tags( \get_the_title( $item->ID ), true );
if ( ! $title ) {
return '';
}
$atts = shortcode_atts(
array( 'type' => 'plain' ),
$atts,
$tag
);
if ( 'html' !== $atts['type'] ) {
return $title;
}
return sprintf( '<h2>%s</h2>', $title );
}
/**
@ -109,6 +134,7 @@ class Shortcodes {
$excerpt = generate_post_summary( $item, $excerpt_length );
/** This filter is documented in wp-includes/post-template.php */
return \apply_filters( 'the_excerpt', $excerpt );
}
@ -145,23 +171,28 @@ class Shortcodes {
if ( empty( $content ) ) {
$content = get_post_meta( $item->ID, '_wp_attachment_image_alt', true );
}
} else {
$content = \get_post_field( 'post_content', $item );
if ( 'yes' === $atts['apply_filters'] ) {
$content = \apply_filters( 'the_content', $content );
} else {
$content = do_blocks( $content );
$content = wptexturize( $content );
$content = wp_filter_content_tags( $content );
}
// Replace script and style elements.
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
$content = strip_shortcodes( $content );
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
}
if ( empty( $content ) ) {
$content = \get_post_field( 'post_content', $item );
}
if ( 'yes' === $atts['apply_filters'] ) {
/** This filter is documented in wp-includes/post-template.php */
$content = \apply_filters( 'the_content', $content );
} else {
if ( site_supports_blocks() ) {
$content = \do_blocks( $content );
}
$content = \wptexturize( $content );
$content = \wp_filter_content_tags( $content );
}
// Replace script and style elements.
$content = \preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $content );
$content = \strip_shortcodes( $content );
$content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) );
add_shortcode( 'ap_content', array( 'Activitypub\Shortcodes', 'content' ) );
return $content;
@ -191,7 +222,7 @@ class Shortcodes {
$tag
);
if ( 'url' === $atts['type'] ) {
if ( 'html' !== $atts['type'] ) {
return \esc_url( \get_permalink( $item->ID ) );
}
@ -225,7 +256,7 @@ class Shortcodes {
$tag
);
if ( 'url' === $atts['type'] ) {
if ( 'html' !== $atts['type'] ) {
return \esc_url( \wp_get_shortlink( $item->ID ) );
}