Created
July 31, 2022 08:29
-
-
Save koen12344/88a580ba27f8bc77e203e13ce115fcf6 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_calendarize_it_fields( $variables, $parent_post_id ) { | |
$event_start_date = get_post_meta( $parent_post_id, 'fc_start_datetime', true ); | |
$event_end_date = get_post_meta( $parent_post_id, 'fc_end_datetime', true ); | |
if ( ! $event_start_date || !$event_end_date ) { | |
return $variables; | |
} | |
$start_datetime = new \DateTime($event_start_date); | |
$start_datetime->setTimezone(wp_timezone()); | |
$end_datetime = new \DateTime($event_end_date); | |
$end_datetime->setTimezone(wp_timezone()); | |
$variables['%ci_event_start%'] = $start_datetime->format("Y-m-d H:i:s"); | |
$variables['%ci_event_end%'] = $end_datetime->format("Y-m-d H:i:s"); | |
return $variables; | |
} | |
add_filter( 'mbp_placeholder_variables', 'pgmb_add_calendarize_it_fields', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment