only send Activites when ActivityPub is enabled for this post-type
This commit is contained in:
parent
50d068b51a
commit
f0483a1928
1 changed files with 7 additions and 1 deletions
|
@ -19,9 +19,9 @@ class Activitypub {
|
||||||
add_post_type_support( 'post', 'activitypub' );
|
add_post_type_support( 'post', 'activitypub' );
|
||||||
add_post_type_support( 'page', '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 );
|
add_action( 'transition_post_status', array( '\Activitypub\Activitypub', 'schedule_post_activity' ), 10, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a AS2 JSON version of an author, post or page
|
* Return a AS2 JSON version of an author, post or page
|
||||||
*
|
*
|
||||||
|
@ -99,6 +99,12 @@ class Activitypub {
|
||||||
return;
|
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 ) {
|
if ( 'publish' === $new_status && 'publish' !== $old_status ) {
|
||||||
wp_schedule_single_event( time() + wp_rand( 0, 120 ), 'activitypub_send_post_activity', array( $post->ID ) );
|
wp_schedule_single_event( time() + wp_rand( 0, 120 ), 'activitypub_send_post_activity', array( $post->ID ) );
|
||||||
} elseif ( 'publish' === $new_status ) {
|
} elseif ( 'publish' === $new_status ) {
|
||||||
|
|
Loading…
Reference in a new issue