only send Activites when ActivityPub is enabled for this post-type

This commit is contained in:
Matthias Pfefferle 2019-02-28 19:31:22 +01:00
parent 50d068b51a
commit f0483a1928

View file

@ -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 ) {