From f0483a1928e67503d92ff7290844369911026d57 Mon Sep 17 00:00:00 2001 From: Matthias Pfefferle Date: Thu, 28 Feb 2019 19:31:22 +0100 Subject: [PATCH] only send Activites when ActivityPub is enabled for this post-type --- includes/class-activitypub.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/class-activitypub.php b/includes/class-activitypub.php index 7bf9fab..baf7d67 100644 --- a/includes/class-activitypub.php +++ b/includes/class-activitypub.php @@ -19,9 +19,9 @@ class Activitypub { add_post_type_support( 'post', 'activitypub' ); add_post_type_support( 'page', 'activitypub' ); - $post_types = get_post_types_by_support( 'activitypub' ); add_action( 'transition_post_status', array( '\Activitypub\Activitypub', 'schedule_post_activity' ), 10, 3 ); } + /** * Return a AS2 JSON version of an author, post or page * @@ -99,6 +99,12 @@ class Activitypub { return; } + // check if post-type supports ActivityPub + $post_types = get_post_types_by_support( 'activitypub' ); + if ( ! in_array( $post->post_type, $post_types, true ) ) { + return; + } + if ( 'publish' === $new_status && 'publish' !== $old_status ) { wp_schedule_single_event( time() + wp_rand( 0, 120 ), 'activitypub_send_post_activity', array( $post->ID ) ); } elseif ( 'publish' === $new_status ) {