Merge pull request #267 from pfefferle/fix-publish

fix #266
This commit is contained in:
Matthias Pfefferle 2023-02-02 08:19:45 +01:00 committed by GitHub
commit 376e3713d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 30 deletions

View file

@ -4,7 +4,7 @@
**Tags:** OStatus, fediverse, activitypub, activitystream **Tags:** OStatus, fediverse, activitypub, activitystream
**Requires at least:** 4.7 **Requires at least:** 4.7
**Tested up to:** 6.1 **Tested up to:** 6.1
**Stable tag:** 0.16.0 **Stable tag:** 0.16.1
**Requires PHP:** 5.6 **Requires PHP:** 5.6
**License:** MIT **License:** MIT
**License URI:** http://opensource.org/licenses/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). 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 ### ### 0.16.0 ###
* Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk) * Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk)

View file

@ -3,7 +3,7 @@
* Plugin Name: ActivityPub * Plugin Name: ActivityPub
* Plugin URI: https://github.com/pfefferle/wordpress-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. * 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: Matthias Pfefferle
* Author URI: https://notiz.blog/ * Author URI: https://notiz.blog/
* License: MIT * License: MIT

View file

@ -369,10 +369,13 @@ class Post {
* @return string the content * @return string the content
*/ */
public function get_content() { public function get_content() {
global $post;
if ( $this->content ) { if ( $this->content ) {
return $this->content; return $this->content;
} }
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$post = $this->post; $post = $this->post;
$content = $this->get_post_content_template(); $content = $this->get_post_content_template();
@ -386,7 +389,7 @@ class Post {
$filtered_content = \apply_filters( 'activitypub_the_content', $content, $post ); $filtered_content = \apply_filters( 'activitypub_the_content', $content, $post );
$decoded_content = \html_entity_decode( $filtered_content, \ENT_QUOTES, 'UTF-8' ); $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; $this->content = $content;
@ -455,29 +458,4 @@ class Post {
return $content; 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 );
}
} }

View file

@ -4,7 +4,7 @@ Donate link: https://notiz.blog/donate/
Tags: OStatus, fediverse, activitypub, activitystream Tags: OStatus, fediverse, activitypub, activitystream
Requires at least: 4.7 Requires at least: 4.7
Tested up to: 6.1 Tested up to: 6.1
Stable tag: 0.16.0 Stable tag: 0.16.1
Requires PHP: 5.6 Requires PHP: 5.6
License: MIT License: MIT
License URI: http://opensource.org/licenses/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). 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 = = 0.16.0 =
* Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk) * Add "Outgoing Mentions" ([#213](https://github.com/pfefferle/wordpress-activitypub/pull/213)) props [@akirk](https://github.com/akirk)

View file

@ -30,6 +30,8 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$activitypub_post = new \Activitypub\Model\Post( $post ); $activitypub_post = new \Activitypub\Model\Post( $post );
\Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post ); \Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post );
$this->assertNotEmpty( $activitypub_post->get_content() );
$this->assertSame( 2, $pre_http_request->get_call_count() ); $this->assertSame( 2, $pre_http_request->get_call_count() );
$all_args = $pre_http_request->get_args(); $all_args = $pre_http_request->get_args();
$first_call_args = array_shift( $all_args ); $first_call_args = array_shift( $all_args );
@ -69,6 +71,8 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$activitypub_post = new \Activitypub\Model\Post( $post ); $activitypub_post = new \Activitypub\Model\Post( $post );
\Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post ); \Activitypub\Activity_Dispatcher::send_post_activity( $activitypub_post );
$this->assertNotEmpty( $activitypub_post->get_content() );
$this->assertSame( 1, $pre_http_request->get_call_count() ); $this->assertSame( 1, $pre_http_request->get_call_count() );
$all_args = $pre_http_request->get_args(); $all_args = $pre_http_request->get_args();
$first_call_args = $all_args[0]; $first_call_args = $all_args[0];