post_type, $post_types, true ) ) { return; } $type = false; if ( 'publish' === $new_status && 'publish' !== $old_status ) { $type = 'Create'; } elseif ( 'publish' === $new_status ) { $type = 'Update'; } elseif ( 'trash' === $new_status ) { $type = 'Delete'; } if ( ! $type ) { return; } // send User activities if ( ! is_user_disabled( $post->post_author ) ) { $activitypub_post = new Post( $post ); \wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_post, $type ) ); \wp_schedule_single_event( \time(), sprintf( 'activitypub_send_%s_activity', \strtolower( $type ) ), array( $activitypub_post ) ); } // send Blog-User activities if ( ! is_user_disabled( User_Factory::BLOG_USER_ID ) ) { $activitypub_post = new Post( $post, User_Factory::BLOG_USER_ID ); \wp_schedule_single_event( \time(), 'activitypub_send_activity', array( $activitypub_post, $type ) ); \wp_schedule_single_event( \time(), sprintf( 'activitypub_send_%s_activity', \strtolower( $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' ); } } }