post_type === 'event' ) { * return new My_Event_Transformer( $object ); * } * return $transformer; * }, 10, 3 ); * * @param Base $transformer The transformer to use. * @param mixed $data The object to transform. * @param string $object_class The class of the object to transform. * * @return mixed The transformer to use. */ $transformer = \apply_filters( 'activitypub_transformer', null, $data, $class ); if ( $transformer ) { if ( ! \is_object( $transformer ) || ! $transformer instanceof Base ) { return new WP_Error( 'invalid_transformer', __( 'Invalid transformer', 'activitypub' ) ); } return $transformer; } // Use default transformer. switch ( $class ) { case 'WP_Post': if ( 'attachment' === $data->post_type ) { return new Attachment( $data ); } return new Post( $data ); case 'WP_Comment': return new Comment( $data ); default: return null; } } }