# activitypub/8.1.1/templates/activitypub-json.php

ActivityPub, version 8.1.1. 26 lines.

- Page: https://pluginprobe.com/plugins/activitypub/8.1.1/code/templates/activitypub-json.php
- Raw: https://pluginprobe.com/plugins/activitypub/8.1.1/raw/templates/activitypub-json.php
- Modified: 2025-04-01T15:20:20+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/activitypub/8.1.1/code/templates/activitypub-json.php#L10-L20`.

```php
<?php
/**
 * ActivityPub JSON template.
 *
 * @package Activitypub
 */

$object = \Activitypub\Query::get_instance()->get_activitypub_object();

/**
 * Fires before an ActivityPub object is generated and sent to the client.
 *
 * @param object $object The ActivityPub object.
 */
\do_action( 'activitypub_json_pre', $object );

\header( 'Content-Type: application/activity+json' );
echo $object->to_json(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped

/**
 * Fires after an ActivityPub object is generated and sent to the client.
 *
 * @param object $object The ActivityPub object.
 */
\do_action( 'activitypub_json_post', $object );

```
