post_type, $post_types, true ) ) { return; } $activitypub_post = new Post( $post ); $activity_type = false; if ( 'publish' === $new_status && 'publish' !== $old_status ) { $activity_type = 'Create'; } elseif ( 'publish' === $new_status ) { $activity_type = 'Update'; } elseif ( 'trash' === $new_status ) { $activity_type = 'Delete'; } if ( $activity_type ) { \wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_post, $activity_type ) ); \wp_schedule_single_event( \time(), sprintf( 'activitypub_send_%s_activity', \strtolower( $activity_type ) ), array( $activitypub_post ) ); } } /** * Update followers * * @return void */ public static function update_followers() { $followers = Followers::get_outdated_followers(); foreach ( $followers as $follower ) { $meta = get_remote_metadata_by_actor( $follower->get_url(), true ); if ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) { $follower->set_error( $meta ); } else { $follower->from_meta( $meta ); } $follower->update(); } } /** * Cleanup followers * * @return void */ public static function cleanup_followers() { $followers = Followers::get_faulty_followers(); foreach ( $followers as $follower ) { $meta = get_remote_metadata_by_actor( $follower->get_url(), true ); if ( is_tombstone( $meta ) ) { $follower->delete(); } elseif ( empty( $meta ) || ! is_array( $meta ) || is_wp_error( $meta ) ) { if ( 5 <= $follower->count_errors() ) { $follower->delete(); } else { $follower->set_error( $meta ); $follower->update(); } } else { $follower->reset_errors(); } } } /** * Schedule migration if DB-Version is not up to date. * * @return void */ public static function schedule_migration() { if ( ! \wp_next_scheduled( 'activitypub_schedule_migration' ) && ! Migration::is_latest_version() ) { \wp_schedule_single_event( \time(), 'activitypub_schedule_migration' ); } } }