Compare commits

..

No commits in common. "a66dc74577eb44baabfee489f53f3ef84dae7e38" and "2257e86f0f4cc570e235c807a2841ace4c7094e7" have entirely different histories.

4 changed files with 23 additions and 28 deletions

View file

@ -161,19 +161,11 @@ abstract class Event extends Post {
/**
* Compose a human readable formatted start time.
*
* @param bool $is_start_time Whether format the events start or end time.
*/
protected function format_start_time(): string {
return $this->format_time( $this->get_start_time() );
}
/**
* Compose a human readable formatted end time.
*/
protected function format_end_time(): string {
return $this->format_time( $this->get_end_time() );
}
static private function format_time( $time ) {
protected function format_time( $is_start_time = true ) {
$time = $is_start_time ? $this->get_start_time() : $this->get_end_time();
if ( is_null( $time ) ) {
return '';
}
@ -226,9 +218,6 @@ abstract class Event extends Post {
* @return string $summary The custom event summary.
*/
public function get_summary(): ?string {
// this will result in race conditions and is imho a bad idea
// - either use the (userdefined) template of the activitypub plugin as it is
// - or implement our own templating (based on the activitypub plugin templates / by reusing their code heavily)
add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2 );
$excerpt = $this->extract_excerpt();
// BeforeFirstRelease: decide whether this should be a admin setting.
@ -239,8 +228,8 @@ abstract class Event extends Post {
remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) );
$category = $this->format_category();
$start_time = $this->format_start_time();
$end_time = $this->format_end_time();
$start_time = $this->format_time();
$end_time = $this->format_time( false );
$address = $this->format_address();
$formatted_items = array();
@ -315,7 +304,7 @@ abstract class Event extends Post {
$activitypub_object->set_to(
array(
'https://www.w3.org/ns/activitystreams#Public',
$this->get_actor_object()->get_followers(), // this fails on my machine
$this->get_actor_object()->get_followers(),
)
);

View file

@ -45,7 +45,7 @@ final class Events_Manager extends Event_Transformer {
* @access public
* @return string Widget name.
*/
public function get_transformer_name() { // todo can we remove this or is this in use?
public function get_transformer_name() {
return 'activitypub-event-transformers/events-manager';
}
@ -58,7 +58,7 @@ final class Events_Manager extends Event_Transformer {
* @access public
* @return string Widget title.
*/
public function get_transformer_label() { // todo can we remove this or is this in use?
public function get_transformer_label() {
return 'Events Manager';
}
@ -71,7 +71,7 @@ final class Events_Manager extends Event_Transformer {
* @access public
* @return array Widget categories.
*/
public static function get_supported_post_types() { // todo can we remove this or is this in use?
public static function get_supported_post_types() {
return array();
}

View file

@ -29,7 +29,7 @@ final class GatherPress extends Event {
*
* @var Event
*/
protected $ap_object; // todo can we remove this or is this in use?
protected $ap_object;
/**
* The current GatherPress Event object.
@ -69,7 +69,7 @@ final class GatherPress extends Event {
* @access public
* @return array Widget categories.
*/
public static function get_supported_post_types() { // todo can we remove this or is this in use?
public static function get_supported_post_types() {
return array( GatherPress_Event::POST_TYPE );
}
@ -158,9 +158,13 @@ final class GatherPress extends Event {
* @return string $summary The custom event summary.
*/
public function get_summary(): string {
$excerpt = $this->wp_object->post_excerpt
?: get_post_meta( $this->wp_object->ID, 'event-summary', true )
?: $this->get_content();
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 );

View file

@ -28,7 +28,7 @@ final class VS_Event_List extends Event_Transformer {
*
* @var Event
*/
protected $ap_object; // todo can we remove this or is this in use?
protected $ap_object;
/**
* Get the event location.
@ -113,8 +113,10 @@ final class VS_Event_List extends Event_Transformer {
protected function get_excerpt(): ?string {
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
return get_post_meta( $this->wp_object->ID, 'event-summary', true );
} elseif ( $this->wp_object->excerpt ) {
return $this->wp_object->post_excerpt;
} else {
return parent::extract_excerpt(); // todo naming not uniform
return null;
}
}
}