Add Support for Event Organiser #83

Merged
linos merged 11 commits from event-organiser into main 2024-11-30 12:26:42 +01:00
3 changed files with 29 additions and 5 deletions
Showing only changes of commit e981827e0a - Show all commits

View file

@ -20,18 +20,39 @@ use ActivityPub_Event_Bridge\Activitypub\Transformer\Event;
* @since 1.0.0
*/
final class Event_Organiser extends Event {
/**
* Extended constructor.
*
* The wp_object is overridden with a the wp_object with filters. This object
* also contains attributes specific to the Event organiser plugin like the
* occurrence id.
*
* @param WP_Post $wp_object The WordPress object.
* @param string $wp_taxonomy The taxonomy slug of the event post type.
*/
public function __construct( $wp_object, $wp_taxonomy ) {
parent::__construct( $wp_object, $wp_taxonomy );
$this->wp_object = get_posts(
array(
'ID' => $wp_object->ID,
'post_type' => 'event',
'suppress_filters' => false,
)
)[0];
}
/**
* Get the end time from the event object.
*/
protected function get_end_time(): ?string {
return eo_get_the_end( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID );
return eo_get_the_end( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id );
}
/**
* Get the end time from the event object.
*/
protected function get_start_time(): string {
return eo_get_the_start( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID );
return eo_get_the_start( 'Y-m-d\TH:i:s\Z', $this->wp_object->ID, $this->wp_object->occurrence_id );
}
/**

View file

@ -103,9 +103,9 @@ function _manually_load_plugin() {
$mec_factory->install();
}
if ( 'event-organiser' === $activitypub_event_bridge_integration_filter ) {
if ( 'event_organiser' === $activitypub_event_bridge_integration_filter ) {
require_once $plugin_dir . 'event-organiser/includes/event-organiser-install.php';
eventorganiser_install();
// eventorganiser_install();
}
// At last manually load our WordPress plugin.

View file

@ -15,7 +15,7 @@ class Test_Event_Organiser extends WP_UnitTestCase {
public function set_up() {
parent::set_up();
if ( ! class_exists( '\EO_Query_Result' ) ) {
if ( ! function_exists( 'eo_get_events' ) ) {
self::markTestSkipped( 'Event Organiser plugin is not active.' );
}
@ -50,6 +50,7 @@ class Test_Event_Organiser extends WP_UnitTestCase {
$post_data = array(
'post_title' => 'Unit Test Event',
'post_content' => 'Unit Test description.',
'post_status' => 'publish',
);
$post_id = eo_insert_event( $post_data, $event_data );
@ -59,6 +60,7 @@ class Test_Event_Organiser extends WP_UnitTestCase {
// Check that we got the right transformer.
$this->assertInstanceOf( \ActivityPub_Event_Bridge\Activitypub\Transformer\Event_Organiser::class, $transformer );
}
/**
@ -76,6 +78,7 @@ class Test_Event_Organiser extends WP_UnitTestCase {
$post_data = array(
'post_title' => 'Unit Test Event',
'post_content' => 'Unit Test description.',
'post_status' => 'publish',
);
$post_id = eo_insert_event( $post_data, $event_data );