Compare commits
No commits in common. "a66dc74577eb44baabfee489f53f3ef84dae7e38" and "2257e86f0f4cc570e235c807a2841ace4c7094e7" have entirely different histories.
a66dc74577
...
2257e86f0f
4 changed files with 23 additions and 28 deletions
|
@ -161,19 +161,11 @@ abstract class Event extends Post {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compose a human readable formatted start time.
|
* 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 {
|
protected function format_time( $is_start_time = true ) {
|
||||||
return $this->format_time( $this->get_start_time() );
|
$time = $is_start_time ? $this->get_start_time() : $this->get_end_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 ) ) {
|
if ( is_null( $time ) ) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
@ -226,9 +218,6 @@ abstract class Event extends Post {
|
||||||
* @return string $summary The custom event summary.
|
* @return string $summary The custom event summary.
|
||||||
*/
|
*/
|
||||||
public function get_summary(): ?string {
|
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 );
|
add_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ), 2 );
|
||||||
$excerpt = $this->extract_excerpt();
|
$excerpt = $this->extract_excerpt();
|
||||||
// BeforeFirstRelease: decide whether this should be a admin setting.
|
// 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' ) );
|
remove_filter( 'activitypub_object_content_template', array( self::class, 'remove_ap_permalink_from_template' ) );
|
||||||
|
|
||||||
$category = $this->format_category();
|
$category = $this->format_category();
|
||||||
$start_time = $this->format_start_time();
|
$start_time = $this->format_time();
|
||||||
$end_time = $this->format_end_time();
|
$end_time = $this->format_time( false );
|
||||||
$address = $this->format_address();
|
$address = $this->format_address();
|
||||||
|
|
||||||
$formatted_items = array();
|
$formatted_items = array();
|
||||||
|
@ -315,7 +304,7 @@ abstract class Event extends Post {
|
||||||
$activitypub_object->set_to(
|
$activitypub_object->set_to(
|
||||||
array(
|
array(
|
||||||
'https://www.w3.org/ns/activitystreams#Public',
|
'https://www.w3.org/ns/activitystreams#Public',
|
||||||
$this->get_actor_object()->get_followers(), // this fails on my machine
|
$this->get_actor_object()->get_followers(),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class Events_Manager extends Event_Transformer {
|
||||||
* @access public
|
* @access public
|
||||||
* @return string Widget name.
|
* @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';
|
return 'activitypub-event-transformers/events-manager';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ final class Events_Manager extends Event_Transformer {
|
||||||
* @access public
|
* @access public
|
||||||
* @return string Widget title.
|
* @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';
|
return 'Events Manager';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ final class Events_Manager extends Event_Transformer {
|
||||||
* @access public
|
* @access public
|
||||||
* @return array Widget categories.
|
* @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();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class GatherPress extends Event {
|
||||||
*
|
*
|
||||||
* @var Event
|
* @var Event
|
||||||
*/
|
*/
|
||||||
protected $ap_object; // todo can we remove this or is this in use?
|
protected $ap_object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The current GatherPress Event object.
|
* The current GatherPress Event object.
|
||||||
|
@ -69,7 +69,7 @@ final class GatherPress extends Event {
|
||||||
* @access public
|
* @access public
|
||||||
* @return array Widget categories.
|
* @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 );
|
return array( GatherPress_Event::POST_TYPE );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +158,13 @@ final class GatherPress extends Event {
|
||||||
* @return string $summary The custom event summary.
|
* @return string $summary The custom event summary.
|
||||||
*/
|
*/
|
||||||
public function get_summary(): string {
|
public function get_summary(): string {
|
||||||
$excerpt = $this->wp_object->post_excerpt
|
if ( $this->wp_object->excerpt ) {
|
||||||
?: get_post_meta( $this->wp_object->ID, 'event-summary', true )
|
$excerpt = $this->wp_object->post_excerpt;
|
||||||
?: $this->get_content();
|
} 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 );
|
$address = get_post_meta( $this->wp_object->ID, 'event-location', true );
|
||||||
$start_time = get_post_meta( $this->wp_object->ID, 'event-start-date', 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
|
* @var Event
|
||||||
*/
|
*/
|
||||||
protected $ap_object; // todo can we remove this or is this in use?
|
protected $ap_object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the event location.
|
* Get the event location.
|
||||||
|
@ -113,8 +113,10 @@ final class VS_Event_List extends Event_Transformer {
|
||||||
protected function get_excerpt(): ?string {
|
protected function get_excerpt(): ?string {
|
||||||
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
|
if ( get_post_meta( $this->wp_object->ID, 'event-summary', true ) ) {
|
||||||
return 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 {
|
} else {
|
||||||
return parent::extract_excerpt(); // todo naming not uniform
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue