wordpress-activitypub-event.../activitypub-event-transformers.php

74 lines
2.1 KiB
PHP
Raw Normal View History

2023-11-24 15:36:51 +01:00
<?php
/**
2023-11-25 12:05:12 +01:00
* Plugin Name: ActivityPub Transformers for Events
2023-11-24 15:36:51 +01:00
* Description: Custom ActivityPub Transformers for Events
* Plugin URI: https://event-federation.eu/
* Version: 1.0.0
* Author: André Menrath
* Author URI: https://graz.social/@linos
* Text Domain: activitypub-event-transformers
2023-12-04 19:27:57 +01:00
* License: AGPL-3.0-or-later
2023-11-24 15:36:51 +01:00
*
* ActivityPub tested up to: 1.2.0
*
* @package activitypub-event-transformer
2023-12-04 19:27:57 +01:00
* @license AGPL-3.0-or-later
2023-11-24 15:36:51 +01:00
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
2023-12-04 19:27:57 +01:00
* Register Event Transformers.
2023-11-24 15:36:51 +01:00
*
2023-12-04 19:27:57 +01:00
* Include fransformer class file and register the transformer class.
2023-11-24 15:36:51 +01:00
*
* @since 1.0.0
2023-12-22 19:07:59 +01:00
* @param \Activitypub\Transformer\Factory $factory ActivtiyPub transformers factory.
2023-11-24 15:36:51 +01:00
* @return void
*/
2023-12-22 19:07:59 +01:00
function register_event_transformers( $transformers_factory ) {
require_once __DIR__ . '/activitypub/transformer/class-tribe.php';
2023-12-22 19:07:59 +01:00
$transformers_factory->register( new \Tribe() );
2023-11-25 12:05:12 +01:00
require_once __DIR__ . '/activitypub/transformer/class-vs-event.php';
2023-12-22 19:07:59 +01:00
$transformers_factory->register( new \VS_Event() );
2023-11-24 15:36:51 +01:00
}
add_action( 'activitypub_transformers_register', 'register_event_transformers' );
2023-12-22 19:07:59 +01:00
// Filter be object class
add_filter( 'activitypub_transformer', function( $transformer, $object, $object_class ) {
if ( $object->post_type === 'event' ) {
require_once __DIR__ . '/activitypub/transformer/class-vs-event.php';
return new \VS_Event( $object );
}
return $transformer;
}, 10, 3 );
// TODO Below here is temporary code needed to do local testing atm.
// Add a filter for http_request_host_is_external
add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_external', 10, 3 );
// Your custom callback function
function custom_http_request_host_is_external( $is_external, $host, $url ) {
$is_external = true;
return $is_external;
}
// add_filter( 'rest_request_before_callbacks', 'change_relay_actor_to_blog_actor', 10, 3 );
// function change_relay_actor_to_blog_actor( $response, $handler, $request ) {
// }
// add_filters( 'https_ssl_verify', 'dont_verify_local_dev_https', 10, 3);
// function dont_verify_local_dev_https($url) {
// return false;
// }