From c8fc78ccdd4b5b143fb0f7a8622111f667be2a90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Menrath?= Date: Wed, 18 Sep 2024 21:26:53 +0200 Subject: [PATCH] small function name improvements --- .../activitypub/transformer/class-event.php | 15 ++++++++-- .../transformer/class-events-manager.php | 13 +-------- .../transformer/class-gatherpress.php | 13 +-------- .../transformer/class-the-events-calendar.php | 18 +++++++++++- .../transformer/class-vs-event-list.php | 28 +------------------ includes/admin/class-settings-page.php | 2 +- includes/class-setup.php | 6 ++-- includes/plugins/class-event-plugin.php | 2 +- includes/plugins/class-events-manager.php | 2 +- includes/plugins/class-gatherpress.php | 2 +- .../plugins/class-the-events-calendar.php | 2 +- includes/plugins/class-vs-event-list.php | 2 +- 12 files changed, 42 insertions(+), 63 deletions(-) diff --git a/includes/activitypub/transformer/class-event.php b/includes/activitypub/transformer/class-event.php index 02eda0c..16088bd 100644 --- a/includes/activitypub/transformer/class-event.php +++ b/includes/activitypub/transformer/class-event.php @@ -2,7 +2,7 @@ /** * Replace the default ActivityPub Transformer * - * @package activity-event-transformers + * @package Activitypub_Event_Extensions * @license AGPL-3.0-or-later */ @@ -46,10 +46,21 @@ class Event extends Post { * * @return string The Event Object-Type. */ - protected function get_object_type() { + protected function get_type() { return 'Event'; } + /** + * Returns the title of the event. + * + * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-name + * + * @return string The name. + */ + protected function get_name() { + return $this->wp_object->post_title; + } + /** * Extend the construction of the Post Transformer to also set the according taxonomy of the event post type. * diff --git a/includes/activitypub/transformer/class-events-manager.php b/includes/activitypub/transformer/class-events-manager.php index ccd2b13..e6b52bd 100644 --- a/includes/activitypub/transformer/class-events-manager.php +++ b/includes/activitypub/transformer/class-events-manager.php @@ -2,7 +2,7 @@ /** * ActivityPub Transformer for the plugin Very Simple Event List. * - * @package activity-event-transformers + * @package Activitypub_Event_Extensions * @license AGPL-3.0-or-later */ @@ -71,17 +71,6 @@ final class Events_Manager extends Event_Transformer { return array(); } - /** - * Returns the ActivityStreams 2.0 Object-Type for an Event. - * - * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event - * @since 1.0.0 - * @return string The Event Object-Type. - */ - protected function get_type() { - return 'Event'; - } - /** * Returns whether the even is online * diff --git a/includes/activitypub/transformer/class-gatherpress.php b/includes/activitypub/transformer/class-gatherpress.php index 6ff8b4d..c875ed1 100644 --- a/includes/activitypub/transformer/class-gatherpress.php +++ b/includes/activitypub/transformer/class-gatherpress.php @@ -2,7 +2,7 @@ /** * ActivityPub Transformer for the plugin Very Simple Event List. * - * @package activity-event-transformers + * @package Activitypub_Event_Extensions * @license AGPL-3.0-or-later */ @@ -85,17 +85,6 @@ final class GatherPress extends Event { return array( GatherPress_Event::POST_TYPE ); } - /** - * Returns the ActivityStreams 2.0 Object-Type for an Event. - * - * @see https://www.w3.org/TR/activitystreams-vocabulary/#dfn-event - * @since 1.0.0 - * @return string The Event Object-Type. - */ - protected function get_type() { - return 'Event'; - } - /** * Get the event location. * diff --git a/includes/activitypub/transformer/class-the-events-calendar.php b/includes/activitypub/transformer/class-the-events-calendar.php index 1c40e95..aa5a16b 100644 --- a/includes/activitypub/transformer/class-the-events-calendar.php +++ b/includes/activitypub/transformer/class-the-events-calendar.php @@ -2,7 +2,7 @@ /** * ActivityPub Tribe Transformer * - * @package activity-event-transformers + * @package Activitypub_Event_Extensions * @license AGPL-3.0-or-later */ @@ -62,6 +62,22 @@ final class The_Events_Calendar extends Event { return $categories[0]; } + /** + * Get the end time from the event object. + */ + protected function get_end_time() { + $date = date_create( $this->tribe_event->end_date, wp_timezone() ); + return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); + } + + /** + * Get the end time from the event object. + */ + protected function get_start_time() { + $date = date_create( $this->tribe_event->start_date, wp_timezone() ); + return \gmdate( 'Y-m-d\TH:i:s\Z', $date->getTimestamp() ); + } + /** * Get status of the tribe event * diff --git a/includes/activitypub/transformer/class-vs-event-list.php b/includes/activitypub/transformer/class-vs-event-list.php index a91e5f1..2f0cd56 100644 --- a/includes/activitypub/transformer/class-vs-event-list.php +++ b/includes/activitypub/transformer/class-vs-event-list.php @@ -2,7 +2,7 @@ /** * ActivityPub Transformer for the plugin Very Simple Event List. * - * @package activity-event-transformers + * @package Activitypub_Event_Extensions * @license AGPL-3.0-or-later */ @@ -48,32 +48,6 @@ final class VS_Event_List extends Event_Transformer { return 'activitypub-event-transformers/vs-event'; } - /** - * Get transformer title. - * - * Retrieve the transformers label. - * - * @since 1.0.0 - * @access public - * @return string Widget title. - */ - public function get_transformer_label(): string { - return 'VS Event'; - } - - /** - * Get supported post types. - * - * Retrieve the list of supported WordPress post types this transformer widget can handle. - * - * @since 1.0.0 - * @access public - * @return array Widget categories. - */ - public static function get_supported_post_types(): string { - return array( 'event' ); - } - /** * Returns the ActivityStreams 2.0 Object-Type for an Event. * diff --git a/includes/admin/class-settings-page.php b/includes/admin/class-settings-page.php index d96ea91..dbe5ed5 100644 --- a/includes/admin/class-settings-page.php +++ b/includes/admin/class-settings-page.php @@ -69,7 +69,7 @@ class Settings_Page { * @return array An array of Terms. */ private static function get_event_terms( $event_plugin ): array { - $taxonomy = $event_plugin::get_taxonomy(); + $taxonomy = $event_plugin::get_event_category_taxonomy(); if ( $taxonomy ) { $event_terms = get_terms( array( diff --git a/includes/class-setup.php b/includes/class-setup.php index fe4f55b..67f1999 100644 --- a/includes/class-setup.php +++ b/includes/class-setup.php @@ -65,8 +65,8 @@ class Setup { // deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ); // return; // }. - $this->active_event_plugins = self::detect_active_event_plugins(); - $this->activitypub_plugin_version = get_file_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php', array( 'Version' ) )[0]; + $this->active_event_plugins = self::detect_active_event_plugins(); + $this->activitypub_plugin_version = get_file_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php', array( 'Version' ) )[0]; $this->setup_hooks(); } @@ -236,7 +236,7 @@ class Setup { if ( $wp_object->post_type === $event_plugin->get_post_type() ) { $transformer_class = $event_plugin->get_activitypub_event_transformer_class(); if ( class_exists( $transformer_class ) ) { - return new $transformer_class( $wp_object, $event_plugin->get_taxonomy() ); + return new $transformer_class( $wp_object, $event_plugin->get_event_category_taxonomy() ); } } } diff --git a/includes/plugins/class-event-plugin.php b/includes/plugins/class-event-plugin.php index 25b753b..47a66bf 100644 --- a/includes/plugins/class-event-plugin.php +++ b/includes/plugins/class-event-plugin.php @@ -42,7 +42,7 @@ abstract class Event_Plugin { * * @return string */ - abstract public static function get_taxonomy(): string; + abstract public static function get_event_category_taxonomy(): string; /** * Returns the ID of the main settings page of the plugin. diff --git a/includes/plugins/class-events-manager.php b/includes/plugins/class-events-manager.php index 26a8926..319b2e8 100644 --- a/includes/plugins/class-events-manager.php +++ b/includes/plugins/class-events-manager.php @@ -54,7 +54,7 @@ final class Events_Manager extends Event_Plugin { * * @return string */ - public static function get_taxonomy(): string { + public static function get_event_category_taxonomy(): string { return defined( 'EM_TAXONOMY_CATEGORY' ) ? constant( 'EM_TAXONOMY_CATEGORY' ) : 'event-categories'; } } diff --git a/includes/plugins/class-gatherpress.php b/includes/plugins/class-gatherpress.php index 4754960..3575bbb 100644 --- a/includes/plugins/class-gatherpress.php +++ b/includes/plugins/class-gatherpress.php @@ -63,7 +63,7 @@ final class GatherPress extends Event_Plugin { * * @return string */ - public static function get_taxonomy(): string { + public static function get_event_category_taxonomy(): string { return class_exists( '\GatherPress\Core\Topic' ) ? \GatherPress\Core\Topic::TAXONOMY : 'gatherpress_topic'; } } diff --git a/includes/plugins/class-the-events-calendar.php b/includes/plugins/class-the-events-calendar.php index 21e4c69..1b77a61 100644 --- a/includes/plugins/class-the-events-calendar.php +++ b/includes/plugins/class-the-events-calendar.php @@ -55,7 +55,7 @@ final class The_Events_Calendar extends Event_plugin { * * @return string */ - public static function get_taxonomy(): string { + public static function get_event_category_taxonomy(): string { return class_exists( '\Tribe__Events__Main' ) ? \Tribe__Events__Main::TAXONOMY : 'tribe_events_cat'; } } diff --git a/includes/plugins/class-vs-event-list.php b/includes/plugins/class-vs-event-list.php index ff96a47..cdcafab 100644 --- a/includes/plugins/class-vs-event-list.php +++ b/includes/plugins/class-vs-event-list.php @@ -66,7 +66,7 @@ final class VS_Event_List extends Event_Plugin { * * @return string */ - public static function get_taxonomy(): string { + public static function get_event_category_taxonomy(): string { return 'event_cat'; } }