@@ -24,6 +24,8 @@ public static function init() {
2424 }
2525
2626 \add_action ( 'transition_post_status ' , array ( '\Activitypub\Activitypub ' , 'schedule_post_activity ' ), 10 , 3 );
27+
28+ \add_action ( 'trash_post ' , array ( '\Activitypub\Activitypub ' , 'schedule_delete_activity ' ), 10 );
2729 }
2830
2931 /**
@@ -60,22 +62,22 @@ public static function render_json_template( $template ) {
6062 stristr ( $ accept_header , 'application/activity+json ' ) ||
6163 stristr ( $ accept_header , 'application/ld+json ' )
6264 ) {
63- return $ template ;
65+ return $ json_template ;
6466 }
6567
6668 // accept header as an array
6769 $ accept = \explode ( ', ' , trim ( $ accept_header ) );
6870
6971 if (
70- ! \in_array ( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams" ' , $ accept , true ) &&
71- ! \in_array ( 'application/activity+json ' , $ accept , true ) &&
72- ! \in_array ( 'application/ld+json ' , $ accept , true ) &&
73- ! \in_array ( 'application/json ' , $ accept , true )
72+ \in_array ( 'application/ld+json; profile="https://www.w3.org/ns/activitystreams" ' , $ accept , true ) ||
73+ \in_array ( 'application/activity+json ' , $ accept , true ) ||
74+ \in_array ( 'application/ld+json ' , $ accept , true ) ||
75+ \in_array ( 'application/json ' , $ accept , true )
7476 ) {
75- return $ template ;
77+ return $ json_template ;
7678 }
7779
78- return $ json_template ;
80+ return $ template ;
7981 }
8082
8183 /**
@@ -113,9 +115,11 @@ public static function schedule_post_activity( $new_status, $old_status, $post )
113115 }
114116
115117 if ( 'publish ' === $ new_status && 'publish ' !== $ old_status ) {
116- \wp_schedule_single_event ( time () + \wp_rand ( 0 , 120 ) , 'activitypub_send_post_activity ' , array ( $ post ->ID ) );
118+ \wp_schedule_single_event ( time (), 'activitypub_send_post_activity ' , array ( $ post ->ID ) );
117119 } elseif ( 'publish ' === $ new_status ) {
118- \wp_schedule_single_event ( time () + \wp_rand ( 0 , 120 ), 'activitypub_send_update_activity ' , array ( $ post ->ID ) );
120+ \wp_schedule_single_event ( time (), 'activitypub_send_update_activity ' , array ( $ post ->ID ) );
121+ } elseif ( 'trash ' === $ new_status ) {
122+ \wp_schedule_single_event ( time (), 'activitypub_send_delete_activity ' , array ( get_permalink ( $ post ) ) );
119123 }
120124 }
121125
0 commit comments