Last active
July 12, 2022 14:29
-
-
Save koen12344/39a0edfa60356550391245e08041cf44 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function pgmb_add_event_fields( $variables, $parent_post_id ) { | |
$event_start_date = get_post_meta( $parent_post_id, 'WooCommerceEventsDateTimestamp', true ); | |
$event_end_date = get_post_meta( $parent_post_id, 'WooCommerceEventsEndDateTimestamp', true ); | |
if ( ! $event_start_date || !$event_end_date ) { | |
return $variables; | |
} | |
$start_datetime = new \DateTime(); | |
$start_datetime->setTimestamp((int)$event_start_date); | |
// $start_datetime->setTimezone(wp_timezone()); | |
$end_datetime = new \DateTime(); | |
$end_datetime->setTimestamp((int)$event_end_date); | |
// $end_datetime->setTimezone(wp_timezone()); | |
$variables['%wc_event_start%'] = $start_datetime->format("Y-m-d H:i:s"); | |
$variables['%wc_event_end%'] = $end_datetime->format("Y-m-d H:i:s"); | |
return $variables; | |
} | |
add_filter( 'mbp_placeholder_variables', 'pgmb_add_event_fields', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment