This commit is contained in:
André Menrath 2024-12-01 16:28:29 +01:00
parent cacfb2a730
commit b10b377b1e
4 changed files with 136 additions and 2 deletions

View file

@ -0,0 +1,73 @@
<?php
/**
* ActivityPub Transformer for the WordPress plugin Event Post.
*
* @link https://wordpress.org/plugins/event-post
* @package ActivityPub_Event_Bridge
* @license AGPL-3.0-or-later
*/
namespace ActivityPub_Event_Bridge\Activitypub\Transformer;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
use Activitypub\Activity\Extended_Object\Place;
use Activitypub\Transformer\Post;
use ActivityPub_Event_Bridge\Activitypub\Transformer\Event;
/**
* ActivityPub Transformer for Event Organiser.
*
* @since 1.0.0
*/
final class Event_Post extends Post {
/**
* Whether this is an event post.
*
* @var bool
*/
private $is_event_post = false;
/**
* Constructor
*
* @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 );
$is_event_post = ! empty( get_post_meta( $wp_object->ID, 'event_begin', true ) );
}
/**
* Get the type.
*/
protected function get_type() {
return $this->is_event_post ? 'Event' : Post::get_type();
}
/**
* Get the end time from the event object.
*/
protected function get_end_time(): ?string {
$end_time = get_post_meta( $this->wp_object->ID, 'event_end', true );
return $end_time;
}
/**
* Get the end time from the event object.
*/
protected function get_start_time(): string {
$start_time = get_post_meta( $this->wp_object->ID, 'event_begin', true );
return $start_time;
}
/**
* Get location from the event object.
*/
protected function get_location(): ?Place {
return null;
}
}

View file

@ -28,7 +28,6 @@ use DateTime;
* [ ] do add Cancelled reason in the content.
*/
abstract class Event extends Post {
/**
* The WordPress event taxonomy.
*
@ -43,7 +42,7 @@ abstract class Event extends Post {
*
* @return string The Event Object-Type.
*/
protected function get_type(): string {
protected function get_type() {
return 'Event';
}

View file

@ -134,6 +134,7 @@ class Setup {
'\ActivityPub_Event_Bridge\Plugins\Modern_Events_Calendar_Lite',
'\ActivityPub_Event_Bridge\Plugins\EventPrime',
'\ActivityPub_Event_Bridge\Plugins\Event_Organiser',
'\ActivityPub_Event_Bridge\Plugins\Event_Post',
);
/**

View file

@ -0,0 +1,61 @@
<?php
/**
* Event Post.
*
* Defines all the necessary meta information for the integration of
* the WordPress plugin "Event Post".
*
* @link https://wordpress.org/plugins/event-post.
* @package ActivityPub_Event_Bridge
* @since 1.0.0
*/
namespace ActivityPub_Event_Bridge\Plugins;
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit; // @codeCoverageIgnore
/**
* Interface for a supported event plugin.
*
* This interface defines which information is necessary for a supported event plugin.
*
* @since 1.0.0
*/
final class Event_Post extends Event_plugin {
/**
* Returns the full plugin file.
*
* @return string
*/
public static function get_plugin_file(): string {
return 'event-post/eventpost.php';
}
/**
* Returns the event post type of the plugin.
*
* @return string
*/
public static function get_post_type(): string {
return 'post';
}
/**
* Returns the IDs of the admin pages of the plugin.
*
* @return array The settings page urls.
*/
public static function get_settings_pages(): array {
return array( 'event-post-settings' );
}
/**
* Returns the taxonomy used for the plugin's event categories.
*
* @return string
*/
public static function get_event_category_taxonomy(): string {
return 'category';
}
}