2023-11-24 15:36:51 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2024-01-12 18:02:37 +01:00
|
|
|
* Plugin Name: ActivityPub Event Extensions
|
|
|
|
* Description: Custom ActivityPub Transformers and Integretions for common Event Plugins
|
2023-11-24 15:36:51 +01:00
|
|
|
* Plugin URI: https://event-federation.eu/
|
|
|
|
* Version: 1.0.0
|
|
|
|
* Author: André Menrath
|
|
|
|
* Author URI: https://graz.social/@linos
|
2024-01-12 18:02:37 +01:00
|
|
|
* Text Domain: activitypub-event-extensions
|
2023-12-04 19:27:57 +01:00
|
|
|
* License: AGPL-3.0-or-later
|
2023-11-24 15:36:51 +01:00
|
|
|
*
|
2024-01-12 18:02:37 +01:00
|
|
|
* ActivityPub tested up to: 2.0.1
|
|
|
|
*
|
|
|
|
* @package activitypub-event-extensions
|
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.
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2024-01-03 19:14:12 +01:00
|
|
|
* Add the custom transformers for the events of several WordPress event plugins.
|
|
|
|
*/
|
|
|
|
add_filter(
|
|
|
|
'activitypub_transformer',
|
2024-01-05 14:01:30 +01:00
|
|
|
function( $transformer, $wp_object, $object_class ) {
|
2024-01-05 21:18:34 +01:00
|
|
|
if ( 'WP_Post' != $object_class ) {
|
2024-01-05 14:01:30 +01:00
|
|
|
return $transformer;
|
|
|
|
}
|
|
|
|
|
2024-01-03 19:14:12 +01:00
|
|
|
/**
|
|
|
|
* VS Event List
|
|
|
|
* @see https://wordpress.org/plugins/very-simple-event-list/
|
|
|
|
*/
|
2024-01-05 21:18:34 +01:00
|
|
|
if ( class_exists( 'vsel_widget' ) && $wp_object->post_type === 'event' ) {
|
|
|
|
require_once __DIR__ . '/includes/activitypub/transformer/class-vs-event.php';
|
|
|
|
return new \VS_Event( $object );
|
|
|
|
}
|
2024-01-05 14:01:30 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Events manager
|
|
|
|
* @see https://wordpress.org/plugins/events-manager/
|
|
|
|
*/
|
2024-01-05 21:18:34 +01:00
|
|
|
if ( class_exists( 'EM_Events' ) && $wp_object->post_type === 'event' ) {
|
2024-01-05 14:01:30 +01:00
|
|
|
require_once __DIR__ . '/includes/activitypub/transformer/class-events-manager.php';
|
|
|
|
return new \Events_Manager( $wp_object );
|
2024-01-03 19:14:12 +01:00
|
|
|
}
|
2024-01-05 14:01:30 +01:00
|
|
|
|
2024-01-03 19:14:12 +01:00
|
|
|
// Return the default transformer.
|
2024-01-05 21:18:34 +01:00
|
|
|
|
2024-01-03 19:14:12 +01:00
|
|
|
return $transformer;
|
|
|
|
},
|
|
|
|
10,
|
|
|
|
3
|
|
|
|
);
|
|
|
|
|
2024-01-05 21:18:34 +01:00
|
|
|
require_once __DIR__ . '/admin/class-admin-notices.php';
|
|
|
|
new \Admin_Notices();
|
2024-01-04 11:25:29 +01:00
|
|
|
|
2024-01-03 19:31:01 +01:00
|
|
|
/**
|
|
|
|
* Add a filter for http_request_host_is_external
|
|
|
|
*
|
|
|
|
* TODO: Remove this.
|
|
|
|
*
|
|
|
|
* @todo This filter is temporary code needed to do local testing.
|
|
|
|
*/
|
|
|
|
add_filter( 'http_request_host_is_external', 'custom_http_request_host_is_external', 10, 3 );
|
2023-12-12 17:27:43 +01:00
|
|
|
|
2024-01-03 19:31:01 +01:00
|
|
|
// Your custom callback function
|
|
|
|
function custom_http_request_host_is_external( $is_external, $host, $url ) {
|
|
|
|
$is_external = true;
|
2023-12-12 17:27:43 +01:00
|
|
|
|
2024-01-03 19:31:01 +01:00
|
|
|
return $is_external;
|
|
|
|
}
|
2023-12-12 17:27:43 +01:00
|
|
|
|
2024-01-03 19:31:01 +01:00
|
|
|
/**
|
|
|
|
* Don't verify ssl certs for testing.
|
|
|
|
*
|
|
|
|
* TODO: Remove this.
|
|
|
|
*
|
|
|
|
* @todo This filter is temporary code needed to do local testing.
|
|
|
|
*/
|
|
|
|
add_filter( 'https_ssl_verify', 'dont_verify_local_dev_https', 10, 3 );
|
2023-12-12 17:27:43 +01:00
|
|
|
|
2024-01-03 19:31:01 +01:00
|
|
|
function dont_verify_local_dev_https( $url ) {
|
|
|
|
return false;
|
|
|
|
}
|