@@ -31,6 +31,8 @@ public static function init() {
31
31
\add_action ( 'init ' , array ( self ::class, 'register_post_types ' ), 11 );
32
32
\add_action ( 'init ' , array ( self ::class, 'register_oembed_providers ' ), 11 );
33
33
34
+ \add_action ( 'rest_api_init ' , array ( self ::class, 'register_ap_actor_rest_field ' ) );
35
+
34
36
\add_filter ( 'template_include ' , array ( self ::class, 'render_activitypub_template ' ), 99 );
35
37
\add_action ( 'template_redirect ' , array ( self ::class, 'template_redirect ' ) );
36
38
\add_filter ( 'redirect_canonical ' , array ( self ::class, 'redirect_canonical ' ), 10 , 2 );
@@ -806,6 +808,32 @@ public static function register_post_types() {
806
808
\do_action ( 'activitypub_after_register_post_type ' );
807
809
}
808
810
811
+ /**
812
+ * Register REST field for ap_actor posts.
813
+ */
814
+ public static function register_ap_actor_rest_field () {
815
+ \register_rest_field (
816
+ Actors::POST_TYPE ,
817
+ 'activitypub_json ' ,
818
+ array (
819
+ /**
820
+ * Get the raw post content without WordPress content filtering.
821
+ *
822
+ * @param array $response Prepared response array.
823
+ * @return string The raw post content.
824
+ */
825
+ 'get_callback ' => function ( $ response ) {
826
+ return \get_post_field ( 'post_content ' , $ response ['id ' ] );
827
+ },
828
+ 'schema ' => array (
829
+ 'description ' => 'Raw ActivityPub JSON data without WordPress content filtering ' ,
830
+ 'type ' => 'string ' ,
831
+ 'context ' => array ( 'view ' , 'edit ' ),
832
+ ),
833
+ )
834
+ );
835
+ }
836
+
809
837
/**
810
838
* Add the 'activitypub' capability to users who can publish posts.
811
839
*
0 commit comments