Last active
August 29, 2015 13:55
-
-
Save sidharrell/8738915 to your computer and use it in GitHub Desktop.
patch for non-standard date formats with php >= 5.3
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
function espresso_ical_prepare_by_meta($meta, $title = '', $image = '', $link_only = FALSE) { | |
global $org_options, $wpdb; | |
do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); | |
if ( !empty($org_options['display_ical_download']) && $org_options['display_ical_download'] == 'N' || !isset($org_options['display_ical_download']) ){ | |
return; | |
} | |
$start_date_object = DateTime::createFromFormat(get_option('date_format').' G:i', $meta['start_date'] . ' ' . $meta['start_time']); | |
$start_date = !empty($start_date_object) ? $start_date_object->getTimestamp() : ''; | |
$end_date_object = DateTime::createFromFormat(get_option('date_format').' G:i', $meta['end_date'] . ' ' . $meta['end_time']); | |
$end_date = !empty($end_date_object) ? $end_date_object->getTimestamp() : ''; | |
$title = empty($text) ? __('iCal Import', 'event_espresso') : $title; | |
$image = empty($image) ? '<img src="'.EVENT_ESPRESSO_PLUGINFULLURL . 'images/icons/calendar_link.png">' : $image; | |
if ($link_only == TRUE){ | |
$image = $title; | |
} | |
$array = array( | |
'iCal' => 'true', | |
'currentyear' => date('Y'), | |
'currentmonth' => date('m'), | |
'currentday' => date('d'), | |
'currenttime' => date('His'), | |
'event_id' => $meta['event_id'], | |
'registration_id' => !empty($meta['registration_id']) ? $meta['registration_id'] : $_SESSION['espresso_session']['id'], | |
'contact_email' => $meta['contact_email'], | |
'startyear' => date('Y', $start_date), | |
'startmonth' => date('m', $start_date), | |
'startday' => date('d', $start_date), | |
'starttime' => date('His', $start_date), | |
'endyear' => date('Y', $end_date), | |
'endmonth' => date('m', $end_date), | |
'endday' => date('d', $end_date), | |
'endtime' => date('His', $end_date), | |
'event_summary' => stripslashes($meta['event_name']), | |
//'event_description' => espresso_format_content(stripslashes($meta['event_desc'])), | |
'eereg_url' => espresso_reg_url($meta['event_id']), | |
'site_url' => site_url(), | |
'organization' => $org_options['organization'], | |
'location' => str_replace(array('<br>','<br />'), ' ', $meta['location']), | |
); | |
$url = add_query_arg( $array, site_url() ); | |
$html = '<a href="' . wp_kses($url, '') . '" id="espresso_ical_' . $meta['event_id'] . '" class="espresso_ical_link" title="' . $title . '">' . $image . '</a>'; | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment