diff --git a/README.md b/README.md index 1e405f89..a8a80011 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ **Tags:** OStatus, fediverse, activitypub, activitystream **Requires at least:** 4.7 **Tested up to:** 6.1 -**Stable tag:** 0.16.0 +**Stable tag:** 0.16.1 **Requires PHP:** 5.6 **License:** MIT **License URI:** http://opensource.org/licenses/MIT @@ -88,6 +88,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides. Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). +### 0.16.1 ### + +* Fix "update and create, posts appear blank on Mastodon" issue + ### 0.16.0 ### * Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk) diff --git a/activitypub.php b/activitypub.php index cc07f5d4..b6595208 100644 --- a/activitypub.php +++ b/activitypub.php @@ -3,7 +3,7 @@ * Plugin Name: ActivityPub * Plugin URI: https://github.com/pfefferle/wordpress-activitypub/ * Description: The ActivityPub protocol is a decentralized social networking protocol based upon the ActivityStreams 2.0 data format. - * Version: 0.16.0 + * Version: 0.16.1 * Author: Matthias Pfefferle * Author URI: https://notiz.blog/ * License: MIT diff --git a/includes/model/class-post.php b/includes/model/class-post.php index 543a8903..ed7f4534 100644 --- a/includes/model/class-post.php +++ b/includes/model/class-post.php @@ -369,11 +369,14 @@ public function get_object_type() { * @return string the content */ public function get_content() { + global $post; + if ( $this->content ) { return $this->content; } - $post = $this->post; + // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + $post = $this->post; $content = $this->get_post_content_template(); // Fill in the shortcodes. @@ -386,7 +389,7 @@ public function get_content() { $filtered_content = \apply_filters( 'activitypub_the_content', $content, $post ); $decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' ); - $content = \trim( \preg_replace( '/[\n\r]/', '', $content ) ); + $content = \trim( \preg_replace( '/[\n\r\t]/', '', $content ) ); $this->content = $content; @@ -455,29 +458,4 @@ public static function upgrade_post_content_template() { return $content; } - - /** - * Adds all tags as hashtags to the post/summary content - * - * @param string $content - * @param WP_Post $post - * - * @return string - */ - public function get_the_mentions() { - $post = $this->post; - $tags = \get_the_tags( $post->ID ); - - if ( ! $tags ) { - return ''; - } - - $hash_tags = array(); - - foreach ( $tags as $tag ) { - $hash_tags[] = \sprintf( '', \get_tag_link( $tag ), $tag->slug ); - } - - return \implode( ' ', $hash_tags ); - } } diff --git a/readme.txt b/readme.txt index cb22943b..4e729ef2 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/ Tags: OStatus, fediverse, activitypub, activitystream Requires at least: 4.7 Tested up to: 6.1 -Stable tag: 0.16.0 +Stable tag: 0.16.1 Requires PHP: 5.6 License: MIT License URI: http://opensource.org/licenses/MIT @@ -88,6 +88,10 @@ Where 'blog' is the path to the subdirectory at which your blog resides. Project maintained on GitHub at [pfefferle/wordpress-activitypub](https://github.com/pfefferle/wordpress-activitypub). += 0.16.1 = + +* Fix "update and create, posts appear blank on Mastodon" issue + = 0.16.0 = * Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk) diff --git a/tests/test-class-activitypub-activity-dispatcher.php b/tests/test-class-activitypub-activity-dispatcher.php index 6693ba1a..dea7e38c 100644 --- a/tests/test-class-activitypub-activity-dispatcher.php +++ b/tests/test-class-activitypub-activity-dispatcher.php @@ -30,6 +30,8 @@ public function test_dispatch_activity() { $activitypub_post = new \Activitypub\Model\Post( $post ); \Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post ); + $this->assertNotEmpty( $activitypub_post->get_content() ); + $this->assertSame( 2, $pre_http_request->get_call_count() ); $all_args = $pre_http_request->get_args(); $first_call_args = array_shift( $all_args ); @@ -69,6 +71,8 @@ function( $mentions ) { $activitypub_post = new \Activitypub\Model\Post( $post ); \Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post ); + $this->assertNotEmpty( $activitypub_post->get_content() ); + $this->assertSame( 1, $pre_http_request->get_call_count() ); $all_args = $pre_http_request->get_args(); $first_call_args = $all_args[0];