retrieve(); wp_send_json_success(); } /** * Get the Application actor via FEP-2677. * * @param string $domain The domain without scheme. * @return bool|string The URL/ID of the application actor, false if not found. */ public static function get_application_actor( $domain ) { $result = wp_remote_get( 'https://' . $domain . '/.well-known/nodeinfo' ); if ( is_wp_error( $result ) ) { return false; } $body = wp_remote_retrieve_body( $result ); $nodeinfo = json_decode( $body, true ); // Check if 'links' exists and is an array. if ( isset( $nodeinfo['links'] ) && is_array( $nodeinfo['links'] ) ) { foreach ( $nodeinfo['links'] as $link ) { // Check if this link matches the application actor rel. if ( isset( $link['rel'] ) && 'https://www.w3.org/ns/activitystreams#Application' === $link['rel'] ) { if ( is_string( $link['href'] ) ) { return $link['href']; } break; } } } // Return false if no application actor is found. return false; } /** * Add the ActivityPub template for EventPrime. * * @param string $template The path to the template object. * @return string The new path to the JSON template. */ public static function redirect_activitypub_requests_for_cached_external_events( $template ) { if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { return $template; } if ( ! is_activitypub_request() ) { return $template; } if ( ! \is_singular() ) { return $template; } global $post; if ( 'gatherpress_event' !== $post->post_type ) { return $template; } if ( ! str_starts_with( \get_site_url(), $post->guid ) ) { \wp_redirect( $post->guid, 301 ); exit; } return $template; } }