Add transormer for WP Event Manager, closes #54 #55
4 changed files with 30 additions and 17 deletions
|
@ -50,15 +50,17 @@
|
|||
"@test-vs-event-list",
|
||||
"@test-the-events-calendar",
|
||||
"@test-gatherpress",
|
||||
"@test-events-manager"
|
||||
"@test-events-manager",
|
||||
"@test-wp-event-manager"
|
||||
],
|
||||
"test-debug": [
|
||||
"@prepare-test",
|
||||
"@test-gatherpress"
|
||||
"@test-wp-event-manager"
|
||||
],
|
||||
"test-vs-event-list": "phpunit --filter=vs_event_list",
|
||||
"test-the-events-calendar": "phpunit --filter=the_events_calendar",
|
||||
"test-gatherpress": "phpunit --filter=gatherpress",
|
||||
"test-events-manager": "phpunit --filter=events_manager"
|
||||
"test-events-manager": "phpunit --filter=events_manager",
|
||||
"test-wp-event-manager": "phpunit --filter=wp_event_manager"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,20 +63,31 @@ final class WP_Event_Manager extends Event_Transformer {
|
|||
|
||||
/**
|
||||
* Get the end time from the events metadata.
|
||||
*
|
||||
* @return ?string The events end-datetime if is set, null otherwise.
|
||||
*/
|
||||
public function get_end_time(): ?string {
|
||||
$end_date = get_post_meta( $this->wp_object->ID, '_event_end_date', true );
|
||||
$end_datetime = new DateTime( $end_date );
|
||||
return \gmdate( 'Y-m-d\TH:i:s\Z', $end_datetime->getTimestamp() );
|
||||
$end_date = get_post_meta( $this->wp_object->ID, '_event_end_date', true );
|
||||
if ( $end_date ) {
|
||||
$end_datetime = new DateTime( $end_date );
|
||||
return \gmdate( 'Y-m-d\TH:i:s\Z', $end_datetime->getTimestamp() );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the end time from the events metadata.
|
||||
*/
|
||||
public function get_start_time(): string {
|
||||
$start_date = get_post_meta( $this->wp_object->ID, '_event_start_date', true );
|
||||
$start_datetime = new DateTime( $start_date );
|
||||
return \gmdate( 'Y-m-d\TH:i:s\Z', $start_datetime->getTimestamp() );
|
||||
$start_date = get_post_meta( $this->wp_object->ID, '_event_start_date', true );
|
||||
if ( ! is_numeric( $start_date ) ) {
|
||||
$start_datetime = new DateTime( $start_date );
|
||||
$start_timestamp = $start_datetime->getTimestamp();
|
||||
} else {
|
||||
$start_timestamp = (int) $start_date;
|
||||
}
|
||||
|
||||
return \gmdate( 'Y-m-d\TH:i:s\Z', $start_timestamp );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
@ -69,7 +69,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
@ -102,7 +102,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
@ -147,7 +147,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
@ -182,7 +182,7 @@ class Test_VS_Event_List extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'VSEL Test Event',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
|
|
@ -44,7 +44,7 @@ class Test_WP_Event_Manager extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'WP Event Manager TestEvent',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event_listing',
|
||||
'meta_input' => array(
|
||||
'event-start-date' => strtotime( '+10 days 15:00:00' ),
|
||||
|
@ -69,7 +69,7 @@ class Test_WP_Event_Manager extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'WP Event Manager TestEvent',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event_listing',
|
||||
'post_content' => 'Come to my WP Event Manager event!',
|
||||
'meta_input' => array(
|
||||
|
@ -104,7 +104,7 @@ class Test_WP_Event_Manager extends WP_UnitTestCase {
|
|||
$wp_post_id = wp_insert_post(
|
||||
array(
|
||||
'post_title' => 'WP Event Manager TestEvent',
|
||||
'post_status' => 'published',
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'event_listing',
|
||||
'post_content' => 'Come to my WP Event Manager event!',
|
||||
'meta_input' => array(
|
||||
|
|
Loading…
Reference in a new issue