Skip to content

activitypub_transformer

github-actions[bot] edited this page Aug 7, 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 );

Auto-generated Example

add_filter(
   'activitypub_transformer',
    function(
        Activitypub\null|Base $transformer,
        Activitypub\mixed $data,
        string $object_class
    ) {
        // Your code here.
        return $transformer;
    },
    10,
    3
);

Parameters

  • 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.

Returns

Activitypub\mixed The transformer to use.

Files

\apply_filters( 'activitypub_transformer', null, $data, $class )

← All Hooks

Users

Developers

Clone this wiki locally