small function name improvements

This commit is contained in:
André Menrath 2024-09-18 21:26:53 +02:00
parent 4e2c1fb23a
commit c8fc78ccdd
12 changed files with 42 additions and 63 deletions

View file

@ -2,7 +2,7 @@
/** /**
* Replace the default ActivityPub Transformer * Replace the default ActivityPub Transformer
* *
* @package activity-event-transformers * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
@ -46,10 +46,21 @@ class Event extends Post {
* *
* @return string The Event Object-Type. * @return string The Event Object-Type.
*/ */
protected function get_object_type() { protected function get_type() {
return 'Event'; 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. * Extend the construction of the Post Transformer to also set the according taxonomy of the event post type.
* *

View file

@ -2,7 +2,7 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package activity-event-transformers * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
@ -71,17 +71,6 @@ final class Events_Manager extends Event_Transformer {
return array(); 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 * Returns whether the even is online
* *

View file

@ -2,7 +2,7 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package activity-event-transformers * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
@ -85,17 +85,6 @@ final class GatherPress extends Event {
return array( GatherPress_Event::POST_TYPE ); 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. * Get the event location.
* *

View file

@ -2,7 +2,7 @@
/** /**
* ActivityPub Tribe Transformer * ActivityPub Tribe Transformer
* *
* @package activity-event-transformers * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
@ -62,6 +62,22 @@ final class The_Events_Calendar extends Event {
return $categories[0]; 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 * Get status of the tribe event
* *

View file

@ -2,7 +2,7 @@
/** /**
* ActivityPub Transformer for the plugin Very Simple Event List. * ActivityPub Transformer for the plugin Very Simple Event List.
* *
* @package activity-event-transformers * @package Activitypub_Event_Extensions
* @license AGPL-3.0-or-later * @license AGPL-3.0-or-later
*/ */
@ -48,32 +48,6 @@ final class VS_Event_List extends Event_Transformer {
return 'activitypub-event-transformers/vs-event'; 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. * Returns the ActivityStreams 2.0 Object-Type for an Event.
* *

View file

@ -69,7 +69,7 @@ class Settings_Page {
* @return array An array of Terms. * @return array An array of Terms.
*/ */
private static function get_event_terms( $event_plugin ): array { private static function get_event_terms( $event_plugin ): array {
$taxonomy = $event_plugin::get_taxonomy(); $taxonomy = $event_plugin::get_event_category_taxonomy();
if ( $taxonomy ) { if ( $taxonomy ) {
$event_terms = get_terms( $event_terms = get_terms(
array( array(

View file

@ -65,8 +65,8 @@ class Setup {
// deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE ); // deactivate_plugins( ACTIVITYPUB_EVENT_EXTENSIONS_PLUGIN_FILE );
// return; // return;
// }. // }.
$this->active_event_plugins = self::detect_active_event_plugins(); $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->activitypub_plugin_version = get_file_data( WP_PLUGIN_DIR . '/activitypub/activitypub.php', array( 'Version' ) )[0];
$this->setup_hooks(); $this->setup_hooks();
} }
@ -236,7 +236,7 @@ class Setup {
if ( $wp_object->post_type === $event_plugin->get_post_type() ) { if ( $wp_object->post_type === $event_plugin->get_post_type() ) {
$transformer_class = $event_plugin->get_activitypub_event_transformer_class(); $transformer_class = $event_plugin->get_activitypub_event_transformer_class();
if ( class_exists( $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() );
} }
} }
} }

View file

@ -42,7 +42,7 @@ abstract class Event_Plugin {
* *
* @return string * @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. * Returns the ID of the main settings page of the plugin.

View file

@ -54,7 +54,7 @@ final class Events_Manager extends Event_Plugin {
* *
* @return string * @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'; return defined( 'EM_TAXONOMY_CATEGORY' ) ? constant( 'EM_TAXONOMY_CATEGORY' ) : 'event-categories';
} }
} }

View file

@ -63,7 +63,7 @@ final class GatherPress extends Event_Plugin {
* *
* @return string * @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'; return class_exists( '\GatherPress\Core\Topic' ) ? \GatherPress\Core\Topic::TAXONOMY : 'gatherpress_topic';
} }
} }

View file

@ -55,7 +55,7 @@ final class The_Events_Calendar extends Event_plugin {
* *
* @return string * @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'; return class_exists( '\Tribe__Events__Main' ) ? \Tribe__Events__Main::TAXONOMY : 'tribe_events_cat';
} }
} }

View file

@ -66,7 +66,7 @@ final class VS_Event_List extends Event_Plugin {
* *
* @return string * @return string
*/ */
public static function get_taxonomy(): string { public static function get_event_category_taxonomy(): string {
return 'event_cat'; return 'event_cat';
} }
} }