wordpress-activitypub-event.../includes/activitypub/transformer/class-eventprime.php
André Menrath aa353c3795
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 52s
PHPUnit / PHPUnit – PHP 7.4 (pull_request) Successful in 1m8s
PHPUnit / PHPUnit – PHP 8.0 (pull_request) Successful in 1m4s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m6s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m12s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m9s
add basic venue support and tests for eventprime
2024-11-25 19:06:11 +01:00

78 lines
1.8 KiB
PHP

<?php
/**
* ActivityPub Transformer for the plugin EventPrime.
*
* @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_Event_Bridge\Activitypub\Transformer\Event;
/**
* ActivityPub Transformer for VS Event
*
* @since 1.0.0
*/
final class EventPrime extends Event {
/**
* Get the end time from the event object.
*/
protected function get_end_time(): ?string {
$timestamp = get_post_meta( $this->wp_object->ID, 'em_end_date', true );
if ( $timestamp ) {
return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp );
} else {
return null;
}
}
/**
* Get the end time from the event object.
*/
protected function get_start_time(): string {
$timestamp = get_post_meta( $this->wp_object->ID, 'em_start_date', true );
if ( $timestamp ) {
return \gmdate( 'Y-m-d\TH:i:s\Z', $timestamp );
} else {
return '';
}
}
/**
* Get location from the event object.
*/
protected function get_location(): ?Place {
$venue_term_id = get_post_meta( $this->wp_object->ID, 'em_venue', true );
if ( ! $venue_term_id ) {
return null;
}
$venue = wp_get_post_terms( $this->wp_object->ID, 'em_venue' );
if ( empty( $venue ) ) {
return null;
} else {
$venue = $venue[0];
}
$place = new Place();
$place->set_name( $venue->name );
$place->set_content( $venue->description );
$address = get_term_meta( $venue->term_id, 'em_address', true );
$display_address = get_term_meta( $venue->term_id, 'em_display_address_on_frontend', true );
if ( $address && $display_address ) {
$place->set_address( get_term_meta( $venue->term_id, 'em_address', true ) );
}
return $place;
}
}