-
Notifications
You must be signed in to change notification settings - Fork 82
activitypub_transformer
github-actions[bot] edited this page Aug 18, 2025
·
8 revisions
Filter the transformer for a given object.
Add your own transformer based on the object class or the object type.
Example usage:
// Filter be object class add_filter( 'activitypub_transformer', function( $transformer, $object, $object_class ) { if ( $object_class === 'WP_Post' ) { return new My_Post_Transformer( $object ); } return $transformer; }, 10, 3 );
// Filter be object type add_filter( 'activitypub_transformer', function( $transformer, $object, $object_class ) { if ( $object->post_type === 'event' ) { return new My_Event_Transformer( $object ); } return $transformer; }, 10, 3 );
/**
* Filter the transformer for a given object.
*
* Add your own transformer based on the object class or the object type.
*
* Example usage:
*
* // Filter be object class
* add_filter( 'activitypub_transformer', function( $transformer, $object, $object_class ) {
* if ( $object_class === 'WP_Post' ) {
* return new My_Post_Transformer( $object );
* }
* return $transformer;
* }, 10, 3 );
*
* // Filter be object type
* add_filter( 'activitypub_transformer', function( $transformer, $object, $object_class ) {
* if ( $object->post_type === 'event' ) {
* return new My_Event_Transformer( $object );
* }
* return $transformer;
* }, 10, 3 );.
*
* @param Activitypub\null|Base $transformer
* @param Activitypub\mixed $data
* @param string $object_class
* @return mixed The transformer to use.
*/
function my_activitypub_transformer_callback( Activitypub\null|Base $transformer, Activitypub\mixed $data, string $object_class ) {
// Your code here.
return $transformer;
}
add_filter( 'activitypub_transformer', 'my_activitypub_transformer_callback', 10, 3 );
-
Activitypub\null|Base
$transformer
The transformer to use. Default null. -
Activitypub\mixed
$data
The object to transform. -
string
$object_class
The class of the object to transform.
Activitypub\mixed
The transformer to use.
\apply_filters( 'activitypub_transformer', null, $data, $class )
Follow @[email protected] for updates and news.