Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/changelog/2063-from-description
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fixed

Switches ActivityPub summaries to plain text for better compatibility.
2 changes: 1 addition & 1 deletion includes/class-hashtag.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static function init() {
* @return array The filtered activity object array.
*/
public static function filter_activity_object( $activity ) {
if ( ! empty( $activity['summary'] ) ) {
if ( ! empty( $activity['summary'] ) && is_actor( $activity ) ) {
$activity['summary'] = self::the_content( $activity['summary'] );
}

Expand Down
2 changes: 1 addition & 1 deletion includes/class-link.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function init() {
* @return array Rhe activity object array.
*/
public static function filter_activity_object( $activity ) {
if ( ! empty( $activity['summary'] ) ) {
if ( ! empty( $activity['summary'] ) && is_actor( $activity ) ) {
$activity['summary'] = self::the_content( $activity['summary'] );
}

Expand Down
4 changes: 4 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1237,8 +1237,12 @@ function generate_post_summary( $post, $length = 500 ) {
$content = $content[0] . ' ' . $excerpt_more;
}

/*
There is no proper support for HTML in ActivityPub summaries yet.
// This filter is documented in wp-includes/post-template.php.
return \apply_filters( 'the_excerpt', $content );
*/
return $content;
}

/**
Expand Down
26 changes: 13 additions & 13 deletions tests/includes/class-test-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,94 +605,94 @@ public function get_post_summary_data() {
array(
'post_excerpt' => 'Hello World',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Greek Excerpt',
array(
'post_excerpt' => 'Τι μπορεί να σου συμβεί σε μια βόλτα για να αγοράσεις μια βαλίτσα για τα ταξίδια σου; Όλα είναι πιθανά αν έχεις ανοιχτές τις "κεραίες" σου!',
),
'<p>Τι μπορεί να σου συμβεί σε μια βόλτα για να αγοράσεις μια βαλίτσα για τα ταξίδια σου; Όλα είναι πιθανά αν έχεις ανοιχτές τις &#8220;κεραίες&#8221; σου!</p>' . PHP_EOL,
'Τι μπορεί να σου συμβεί σε μια βόλτα για να αγοράσεις μια βαλίτσα για τα ταξίδια σου; Όλα είναι πιθανά αν έχεις ανοιχτές τις "κεραίες" σου!',
),
array(
'Content',
array(
'post_content' => 'Hello World',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Content with more tag',
array(
'post_content' => 'Hello World <!--more--> More',
),
'<p>Hello World […]</p>' . PHP_EOL,
'Hello World […]',
),
array(
'Excerpt with shortcode',
array(
'post_excerpt' => 'Hello World [activitypub_test_shortcode]',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Content with shortcode',
array(
'post_content' => 'Hello World [activitypub_test_shortcode]',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Excerpt more than limit',
array(
'post_excerpt' => 'Hello World Hello World Hello World Hello World Hello World',
),
'<p>Hello World Hello World Hello World Hello World Hello World</p>' . PHP_EOL,
'Hello World Hello World Hello World Hello World Hello World',
10,
),
array(
'Content more than limit',
array(
'post_content' => 'Hello World Hello World Hello World Hello World Hello World',
),
'<p>Hello […]</p>' . PHP_EOL,
'Hello […]',
10,
),
array(
'Content more than limit with more tag',
array(
'post_content' => 'Hello World Hello <!--more--> World Hello World Hello World Hello World',
),
'<p>Hello World Hello […]</p>' . PHP_EOL,
'Hello World Hello […]',
1,
),
array(
'Test HTML content',
array(
'post_content' => '<p>Hello World</p>',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Test HTML content with anchor',
array(
'post_content' => 'Hello <a href="https://example.com">World</a>',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Test HTML excerpt',
array(
'post_excerpt' => '<p>Hello World</p>',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
array(
'Test HTML excerpt with anchor',
array(
'post_excerpt' => 'Hello <a href="https://example.com">World</a>',
),
'<p>Hello World</p>' . PHP_EOL,
'Hello World',
),
);
}
Expand Down
Loading