Compare commits
7 commits
2257e86f0f
...
a66dc74577
Author | SHA1 | Date | |
---|---|---|---|
a66dc74577 | |||
516bfd33d8 | |||
c469b7a00e | |||
39632560ff | |||
f0b73d8674 | |||
7c9424526d | |||
f99f009e2e |
4 changed files with 28 additions and 23 deletions
|
@ -161,11 +161,19 @@ 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_time( $is_start_time = true ) {
|
||||
$time = $is_start_time ? $this->get_start_time() : $this->get_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 ) {
|
||||
if ( is_null( $time ) ) {
|
||||
return '';
|
||||
}
|
||||
|
@ -218,6 +226,9 @@ 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.
|
||||
|
@ -228,8 +239,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_time();
|
||||
$end_time = $this->format_time( false );
|
||||
$start_time = $this->format_start_time();
|
||||
$end_time = $this->format_end_time();
|
||||
$address = $this->format_address();
|
||||
|
||||
$formatted_items = array();
|
||||
|
@ -304,7 +315,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->get_actor_object()->get_followers(), // this fails on my machine
|
||||
)
|
||||
);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ final class Events_Manager extends Event_Transformer {
|
|||
* @access public
|
||||
* @return string Widget name.
|
||||
*/
|
||||
public function get_transformer_name() {
|
||||
public function get_transformer_name() { // todo can we remove this or is this in use?
|
||||
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() {
|
||||
public function get_transformer_label() { // todo can we remove this or is this in use?
|
||||
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() {
|
||||
public static function get_supported_post_types() { // todo can we remove this or is this in use?
|
||||
return array();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ final class GatherPress extends Event {
|
|||
*
|
||||
* @var Event
|
||||
*/
|
||||
protected $ap_object;
|
||||
protected $ap_object; // todo can we remove this or is this in use?
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
public static function get_supported_post_types() { // todo can we remove this or is this in use?
|
||||
return array( GatherPress_Event::POST_TYPE );
|
||||
}
|
||||
|
||||
|
@ -158,13 +158,9 @@ final class GatherPress extends Event {
|
|||
* @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();
|
||||
}
|
||||
$excerpt = $this->wp_object->post_excerpt
|
||||
?: get_post_meta( $this->wp_object->ID, 'event-summary', true )
|
||||
?: $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 );
|
||||
|
|
|
@ -28,7 +28,7 @@ final class VS_Event_List extends Event_Transformer {
|
|||
*
|
||||
* @var Event
|
||||
*/
|
||||
protected $ap_object;
|
||||
protected $ap_object; // todo can we remove this or is this in use?
|
||||
|
||||
/**
|
||||
* Get the event location.
|
||||
|
@ -113,10 +113,8 @@ 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 null;
|
||||
return parent::extract_excerpt(); // todo naming not uniform
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue