diff --git a/.distignore b/.distignore
index 93fbfdb..782f2e8 100644
--- a/.distignore
+++ b/.distignore
@@ -22,6 +22,8 @@ bin
composer.json
composer.lock
docker-compose.yml
+docker-compose-test.yml
+Dockerfile
gulpfile.js
package.json
node_modules
diff --git a/README.md b/README.md
index 65d73c5..9de8b8f 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.15.0
+**Stable tag:** 0.16.2
**Requires PHP:** 5.6
**License:** MIT
**License URI:** http://opensource.org/licenses/MIT
@@ -88,9 +88,22 @@ 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).
-### v.next ###
+### 0.16.2 ###
-* Add configuration item for number of images to attach. props [@mexon](https://github.com/mexon)
+* Fix fatal error in outbox
+
+### 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)
+* Add configuration item for number of images to attach ([#248](https://github.com/pfefferle/wordpress-activitypub/pull/248)) props [@mexon](https://github.com/mexon)
+* Use shortcodes instead of custom templates, to setup the Activity Post-Content ([#250](https://github.com/pfefferle/wordpress-activitypub/pull/250)) props [@toolstack](https://github.com/toolstack)
+* Remove custom REST Server, because the needed changes are now merged into Core.
+* Fix hashtags ([#261](https://github.com/pfefferle/wordpress-activitypub/pull/261)) props [@akirk](https://github.com/akirk)
+* Change priorites, to maybe fix the hashtag issue
### 0.15.0 ###
diff --git a/activitypub.php b/activitypub.php
index d0ae3b6..f1f1e86 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.15.0
+ * Version: 0.16.2
* Author: Matthias Pfefferle
* Author URI: https://notiz.blog/
* License: MIT
@@ -90,14 +90,6 @@ function init() {
require_once \dirname( __FILE__ ) . '/includes/class-health-check.php';
\Activitypub\Health_Check::init();
- require_once \dirname( __FILE__ ) . '/includes/rest/class-server.php';
- \add_filter(
- 'wp_rest_server_class',
- function() {
- return '\Activitypub\Rest\Server';
- }
- );
-
if ( \WP_DEBUG ) {
require_once \dirname( __FILE__ ) . '/includes/debug.php';
}
diff --git a/includes/class-activity-dispatcher.php b/includes/class-activity-dispatcher.php
index 1135cc6..3ec317d 100644
--- a/includes/class-activity-dispatcher.php
+++ b/includes/class-activity-dispatcher.php
@@ -107,7 +107,7 @@ class Activity_Dispatcher {
$updated = \wp_date( 'Y-m-d\TH:i:s\Z', \strtotime( $activitypub_post->get_updated() ) );
$activitypub_activity = new \Activitypub\Model\Activity( 'Update', \Activitypub\Model\Activity::TYPE_FULL );
- $activitypub_activity->from_post( $activitypub_post->to_array() );
+ $activitypub_activity->from_post( $activitypub_post );
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
$activitypub_activity->set_to( $to );
@@ -125,12 +125,9 @@ class Activity_Dispatcher {
public static function send_delete_activity( $activitypub_post ) {
// get latest version of post
$user_id = $activitypub_post->get_post_author();
- $deleted = \current_time( 'Y-m-d\TH:i:s\Z', true );
- $activitypub_post->set_deleted( $deleted );
$activitypub_activity = new \Activitypub\Model\Activity( 'Delete', \Activitypub\Model\Activity::TYPE_FULL );
- $activitypub_activity->from_post( $activitypub_post->to_array() );
- $activitypub_activity->set_deleted( $deleted );
+ $activitypub_activity->from_post( $activitypub_post );
foreach ( \Activitypub\get_follower_inboxes( $user_id ) as $inbox => $to ) {
$activitypub_activity->set_to( $to );
diff --git a/includes/class-shortcodes.php b/includes/class-shortcodes.php
index b7243d5..b6fc4ad 100644
--- a/includes/class-shortcodes.php
+++ b/includes/class-shortcodes.php
@@ -191,9 +191,23 @@ class Shortcodes {
return '';
}
+ $atts = shortcode_atts(
+ array( 'apply_filters' => 'yes' ),
+ $atts,
+ $tag
+ );
+
$content = \get_post_field( 'post_content', $post );
- return \apply_filters( 'the_content', $content );
+ 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 );
+ }
+
+ return $content;
}
/**
diff --git a/includes/help.php b/includes/help.php
index 6039b9f..58339fb 100644
--- a/includes/help.php
+++ b/includes/help.php
@@ -9,14 +9,14 @@
'
' .
'[ap_title]
' .
'- ' . \wp_kses( __( 'The post\'s title.', 'activitypub' ), 'default' ) . '
' .
- '[ap_content]
' .
- '- ' . \wp_kses( __( 'The post\'s content.', 'activitypub' ), 'default' ) . '
' .
+ '[ap_content apply_filters="yes"]
' .
+ '- ' . \wp_kses( __( 'The post\'s content. With
apply_filters
you can decide if filters should be applied or not (default is yes
). The values can be yes
or no
. apply_filters
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
'[ap_excerpt lenght="400"]
' .
'- ' . \wp_kses( __( 'The post\'s excerpt (default 400 chars).
length
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
'[ap_permalink type="url"]
' .
- '- ' . \wp_kses( __( 'The post\'s permalink. Type can be either:
url
or html
(an <a /> tag). type
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
+ '- ' . \wp_kses( __( 'The post\'s permalink.
type
can be either: url
or html
(an <a /> tag). type
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
'[ap_shortlink type="url"]
' .
- '- ' . \wp_kses( __( 'The post\'s shortlink. Type can be either
url
or html
(an <a /> tag). I can recommend Hum, to prettify the Shortlinks. type
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
+ '- ' . \wp_kses( __( 'The post\'s shortlink.
type
can be either url
or html
(an <a /> tag). I can recommend Hum, to prettify the Shortlinks. type
attribute is optional.', 'activitypub' ), 'default' ) . ' ' .
'[ap_hashtags]
' .
'- ' . \wp_kses( __( 'The post\'s tags as hashtags.', 'activitypub' ), 'default' ) . '
' .
'[ap_hashcats]
' .
diff --git a/includes/model/class-post.php b/includes/model/class-post.php
index e1c4a0b..72eb157 100644
--- a/includes/model/class-post.php
+++ b/includes/model/class-post.php
@@ -148,17 +148,17 @@ class Post {
'attachment' => $this->get_attachments(),
'tag' => $this->get_tags(),
);
- if ( $this->replies ) {
- $array['replies'] = $this->replies;
+ if ( $this->replies ) { //has comments
+ $array['replies'] = $this->get_replies();
}
- if ( $this->deleted ) {
+ if ( $this->deleted ) { //is trash
$array['deleted'] = \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_modified_gmt ) );
$deleted_post_slug = \get_post_meta( $post->ID, 'activitypub_canonical_url', true );
if ( $deleted_post_slug ) {
$array['id'] = $deleted_post_slug;
}
}
- if ( $this->updated ) {
+ if ( $this->updated ) { //post_modified
$array['updated'] = \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_modified_gmt ) );
}
return \apply_filters( 'activitypub_post', $array );
@@ -188,7 +188,7 @@ class Post {
if ( 'trash' === get_post_status( $post ) && \get_post_meta( $post->ID, 'activitypub_canonical_url', true ) ) {
$object_id = \get_post_meta( $post->ID, 'activitypub_canonical_url', true );
} else {
- $object_id = \add_query_arg( //
+ $object_id = \add_query_arg(
array(
'p' => $post->ID,
),
@@ -317,7 +317,11 @@ class Post {
return $tags;
}
- public function generate_replies() {
+ public function get_replies() {
+ if ( $this->replies ) {
+ return $this->replies;
+ }
+
$replies = null;
if ( $this->post->comment_count > 0 ) {
$args = array(
@@ -358,6 +362,9 @@ class Post {
),
);
}
+
+ $this->replies = $replies;
+
return $replies;
}
@@ -435,11 +442,14 @@ class Post {
* @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.
@@ -452,7 +462,7 @@ class Post {
$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;
@@ -522,31 +532,6 @@ class Post {
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( '#%s', \get_tag_link( $tag ), $tag->slug );
- }
-
- return \implode( ' ', $hash_tags );
- }
-
/**
* Get deleted datetime
*/
@@ -554,7 +539,7 @@ class Post {
$post = $this->post;
$deleted = null;
if ( 'trash' === $post->post_status ) {
- $deleted = \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_modified_gmt ) );
+ $this->deleted = \gmdate( 'Y-m-d\TH:i:s\Z', \strtotime( $post->post_modified_gmt ) );
}
return $deleted;
}
diff --git a/includes/rest/class-outbox.php b/includes/rest/class-outbox.php
index 7eec5ac..615f06b 100644
--- a/includes/rest/class-outbox.php
+++ b/includes/rest/class-outbox.php
@@ -103,7 +103,7 @@ class Outbox {
foreach ( $posts as $post ) {
$activitypub_post = new \Activitypub\Model\Post( $post );
$activitypub_activity = new \Activitypub\Model\Activity( 'Create', \Activitypub\Model\Activity::TYPE_NONE );
- $activitypub_activity->from_post( $activitypub_post->to_array() );
+ $activitypub_activity->from_post( $activitypub_post );
$json->orderedItems[] = $activitypub_activity->to_array(); // phpcs:ignore
}
}
diff --git a/includes/rest/class-server.php b/includes/rest/class-server.php
deleted file mode 100644
index ac89dca..0000000
--- a/includes/rest/class-server.php
+++ /dev/null
@@ -1,35 +0,0 @@
-get_content_type();
-
- if ( ! $content_type ) {
- return parent::dispatch( $request );
- }
-
- // check for content-sub-types like 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
- if ( \preg_match( '/application\/([a-zA-Z+_-]+\+)json/', $content_type['value'] ) ) {
- $request->set_header( 'Content-Type', 'application/json' );
- }
-
- // make request filterable
- $request = \apply_filters( 'activitypub_pre_dispatch_request', $request );
-
- return parent::dispatch( $request );
- }
-}
diff --git a/readme.txt b/readme.txt
index e889ce9..ad6ad3d 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.15.0
+Stable tag: 0.16.2
Requires PHP: 5.6
License: MIT
License URI: http://opensource.org/licenses/MIT
@@ -88,10 +88,22 @@ 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).
-= v.next =
+= 0.16.2 =
-* Add configuration item for number of images to attach. props [@mexon](https://github.com/mexon)
-* Use shortcodes instead of custom templates, to setup the Activity Post-Content. props [@toolstack](https://github.com/toolstack)
+* Fix fatal error in outbox
+
+= 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)
+* Add configuration item for number of images to attach ([#248](https://github.com/pfefferle/wordpress-activitypub/pull/248)) props [@mexon](https://github.com/mexon)
+* Use shortcodes instead of custom templates, to setup the Activity Post-Content ([#250](https://github.com/pfefferle/wordpress-activitypub/pull/250)) props [@toolstack](https://github.com/toolstack)
+* Remove custom REST Server, because the needed changes are now merged into Core.
+* Fix hashtags ([#261](https://github.com/pfefferle/wordpress-activitypub/pull/261)) props [@akirk](https://github.com/akirk)
+* Change priorites, to maybe fix the hashtag issue
= 0.15.0 =
diff --git a/tests/test-class-activitypub-activity-dispatcher.php b/tests/test-class-activitypub-activity-dispatcher.php
index 6693ba1..dea7e38 100644
--- a/tests/test-class-activitypub-activity-dispatcher.php
+++ b/tests/test-class-activitypub-activity-dispatcher.php
@@ -30,6 +30,8 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$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 @@ class Test_Activitypub_Activity_Dispatcher extends ActivityPub_TestCase_Cache_HT
$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];