# activitypub/3.2.5/templates/post-json.php

ActivityPub, version 3.2.5. 26 lines.

- Page: https://pluginprobe.com/plugins/activitypub/3.2.5/code/templates/post-json.php
- Raw: https://pluginprobe.com/plugins/activitypub/3.2.5/raw/templates/post-json.php
- Modified: 2024-06-05T13:38:00+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/3.2.5/code/templates/post-json.php#L10-L20`.

```php
<?php
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
$post        = \get_post();
$transformer = \Activitypub\Transformer\Factory::get_transformer( $post );

if ( \is_wp_error( $transformer ) ) {
	\wp_die(
		esc_html( $transformer->get_error_message() ),
		404
	);
}


/*
 * Action triggerd prior to the ActivityPub profile being created and sent to the client
 */
\do_action( 'activitypub_json_post_pre' );

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

/*
 * Action triggerd after the ActivityPub profile has been created and sent to the client
 */
\do_action( 'activitypub_json_post_post' );

```
