Compare commits

...

2 commits

Author SHA1 Message Date
993fc2b24f phpsniffer happy
Some checks failed
PHP Code Checker / PHP Code Checker (pull_request) Failing after 33s
PHPUnit / PHPUnit – PHP 8.1 (pull_request) Successful in 1m0s
PHPUnit / PHPUnit – PHP 8.2 (pull_request) Successful in 1m3s
PHPUnit / PHPUnit – PHP 8.3 (pull_request) Successful in 1m1s
2024-09-29 15:31:07 +02:00
24844f57c1 remove old get_summary from gatherpress and event manager in favour of the new one in class-event 2024-09-29 15:00:13 +02:00
3 changed files with 4 additions and 44 deletions

View file

@ -174,7 +174,9 @@ abstract class Event extends Post {
} }
/** /**
* Compose a human readable formatted time from the parameter $time. * Compose a human readable formatted time.
*
* @param ?string $time The time which needs to be formatted
*/ */
private static function format_time( $time ) { private static function format_time( $time ) {
if ( is_null( $time ) ) { if ( is_null( $time ) ) {

View file

@ -150,23 +150,6 @@ final class Events_Manager extends Event_Transformer {
return count( $em_bookings->bookings ); return count( $em_bookings->bookings );
} }
/**
* Hardcoded function for generating a summary.
*/
public function get_summary(): ?string {
if ( $this->em_event->post_excerpt ) {
$excerpt = $this->em_event->post_excerpt;
} else {
$excerpt = $this->get_content();
}
$address = $this->em_event->get_location()->location_name;
$start_time = strtotime( $this->get_start_time() );
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$start_time_string = wp_date( $datetime_format, $start_time );
$summary = "📍 {$address}\n📅 {$start_time_string}\n\n{$excerpt}";
return $summary;
}
/** /**
* Get the event link as an ActivityPub Link object, but as an associative array. * Get the event link as an ActivityPub Link object, but as an associative array.
* *

View file

@ -129,31 +129,6 @@ final class GatherPress extends Event {
return $user->get_url(); return $user->get_url();
} }
/**
* Create a custom summary.
*
* It contains also the most important meta-information. The summary is often used when the
* ActivityPub object type 'Event' is not supported, e.g. in Mastodon.
*
* @return string $summary The custom event summary.
*/
public function get_summary(): string {
if ( $this->wp_object->excerpt ) {
$excerpt = $this->wp_object->post_excerpt;
} elseif ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
$excerpt = get_post_meta( $this->wp_object->ID, 'event-summary', true );
} else {
$excerpt = $this->get_content();
}
$address = get_post_meta( $this->wp_object->ID, 'event-location', true );
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', true );
$datetime_format = get_option( 'date_format' ) . ' ' . get_option( 'time_format' );
$start_time_string = wp_date( $datetime_format, $start_time );
$summary = "📍 {$address}\n📅 {$start_time_string}\n\n{$excerpt}";
return $summary;
}
/** /**
* Get the content. * Get the content.
*/ */