Skip to content

Commit

Permalink
Merge pull request #267 from pfefferle/fix-publish
Browse files Browse the repository at this point in the history
fix #266
  • Loading branch information
pfefferle authored Feb 2, 2023
2 parents d4b1edc + 531bdc1 commit 376e371
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 30 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion activitypub.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
32 changes: 5 additions & 27 deletions includes/model/class-post.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;

Expand Down Expand Up @@ -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( '<a rel="tag" class="u-tag u-category" href="%s">#%s</a>', \get_tag_link( $tag ), $tag->slug );
}

return \implode( ' ', $hash_tags );
}
}
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions tests/test-class-activitypub-activity-dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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];
Expand Down

0 comments on commit 376e371

Please sign in to comment.