function mc_get_details_link($event) { if (is_numeric($event)) { $event = mc_get_event($event); } // if available, and not querying remotely, use permalink. $permalinks = apply_filters('mc_use_permalinks', get_option('mc_use_permalinks')); $permalinks = $permalinks === 1 || $permalinks === true || $permalinks === 'true' ? true : false; $details_link = mc_event_link($event); if ($event->event_post != 0 && get_option('mc_remote') != 'true' && $permalinks) { $details_link = add_query_arg('mc_id', $event->occur_id, get_permalink($event->event_post)); } else { if (get_option('mc_uri') != '' && _mc_is_url(get_option('mc_uri'))) { $details_link = mc_build_url(array('mc_id' => $event->occur_id), array('month', 'dy', 'yr', 'ltype', 'loc', 'mcat', 'format', 'feed', 'page_id', 'p', 'mcs', 'time', 'page'), get_option('mc_uri')); } } return apply_filters('mc_customize_details_link', $details_link, $event); }
function mc_external_link($link, $type = 'event') { if (!_mc_is_url($link)) { return "class='error-link'"; } $url = parse_url($link); $host = $url['host']; $site = parse_url(get_option('siteurl')); $known = $site['host']; if (strpos($host, $known) === false) { return true; } return false; }
function my_calendar_draw_event($event, $type = "calendar", $process_date, $time, $template = '') { // if event is not approved, return without processing if (get_option('mc_event_approve') == 'true' && (int) $event->event_approved !== 1) { return ''; } // if event ends at midnight today (e.g., very first thing of the day), exit without re-drawing if ($event->event_endtime == '00:00:00' && date('Y-m-d', strtotime($event->occur_end)) == $process_date && date('Y-m-d', strtotime($event->occur_begin)) != $process_date) { return ''; } if ($event->category_private == 1 && !is_user_logged_in()) { return ''; } // assign empty values to template sections $header = $address = $more = $author = $list_title = $title = $output = $container = $short = $description = $link = $vcal = $gcal = ''; $date_format = get_option('mc_date_format') != '' ? get_option('mc_date_format') : get_option('date_format'); $data = mc_create_tags($event); $templates = get_option('mc_templates'); $details = ''; if (mc_show_details($time, $type)) { $details = apply_filters('mc_custom_template', false, $data, $event, $type, $process_date, $time, $template); if ($details === false) { if ($template != '' && mc_file_exists(sanitize_file_name($template))) { $template = @file_get_contents(mc_get_file(sanitize_file_name($template))); $details = jd_draw_template($data, $template); } else { switch ($type) { case 'mini': $template = $templates['mini']; if (get_option('mc_use_mini_template') == 1) { $details = jd_draw_template($data, $template); } break; case 'list': $template = $templates['list']; if (get_option('mc_use_list_template') == 1) { $details = jd_draw_template($data, $template); } break; case 'single': $template = $templates['details']; if (get_option('mc_use_details_template') == 1) { $details = jd_draw_template($data, $template); } break; case 'calendar': default: $template = $templates['grid']; if (get_option('mc_use_grid_template') == 1) { $details = jd_draw_template($data, $template); } } } } } $mc_display_author = get_option('mc_display_author'); $display_map = get_option('mc_show_map'); $display_address = get_option('mc_show_address'); $uid = 'mc_' . $event->occur_id; $day_id = date('d', strtotime($process_date)); $image = mc_category_icon($event); $has_image = $image != '' ? ' has-image' : ''; $header .= "<div id='{$uid}-{$day_id}-{$type}' class='mc-{$uid} {$type}-event " . "mc_" . sanitize_title($event->category_name) . " vevent'>\n"; $title_template = $templates['title'] == '' ? '{title}' : $templates['title']; $event_title = jd_draw_template($data, $title_template); $event_title = $event_title == '' ? jd_draw_template($data, '{title}') : $event_title; //prevent empty titles if (strpos($event_title, 'href') === false && $type != 'mini' && $type != 'list') { if (get_option('mc_open_uri') == 'true') { $details_link = mc_get_details_link($event); $wrap = "<a href='{$details_link}' class='url summary{$has_image}'>"; $balance = "</a>"; } else { $wrap = "<a href='#{$uid}-{$day_id}-{$type}-details' class='url summary{$has_image}'>"; $balance = "</a>"; } } else { $wrap = $balance = ''; } $current_date = date_i18n(apply_filters('mc_date_format', $date_format, 'details'), strtotime($process_date)); $group_class = $event->event_span == 1 ? ' multidate group' . $event->event_group_id : ''; $heading_level = apply_filters('mc_heading_level_table', 'h3', $type, $time, $template); $inner_heading = apply_filters('mc_heading_inner_title', $wrap . $image . trim($event_title) . $balance, $event_title); $header .= $type != 'single' && $type != 'list' ? "<{$heading_level} class='event-title summary{$group_class}' id='{$uid}-{$day_id}-{$type}-title'>{$inner_heading}</{$heading_level}>\n" : ''; $event_title = $type == 'single' ? apply_filters('mc_single_event_title', $event_title, $event) : $event_title; $title = $type == 'single' && !is_singular('mc-events') ? "<h2 class='event-title summary'>{$image} {$event_title}</h2>\n" : ''; $title = apply_filters('mc_event_title', $title, $event, $event_title, $image); $header .= $title; if (mc_show_details($time, $type)) { $close = $type == 'calendar' || $type == 'mini' ? "<a href=\"#{$uid}-{$day_id}-{$type}\" aria-controls='{$uid}-{$day_id}-{$type}-details' class='mc-toggle mc-close close'><img src=\"" . plugin_dir_url(__FILE__) . "images/event-close.png\" alt='" . __('Close', 'my-calendar') . "' /></a>" : ''; if ($details === false) { // put together address information as vcard if ($display_address == 'true' || $display_map == 'true') { $address = mc_hcard($event, $display_address, $display_map); } // end vcard $time = mc_time_html($event, $type, $current_date); if ($type == "list") { $heading_level = apply_filters('mc_heading_level_list', 'h3', $type, $time, $template); $list_title = "<{$heading_level} class='event-title summary' id='{$uid}-{$day_id}-{$type}-title'>{$image}" . $event_title . "</{$heading_level}>\n"; } if ($mc_display_author == 'true') { if ($event->event_author != 0) { $e = get_userdata($event->event_author); $author = '<p class="event-author">' . __('Posted by', 'my-calendar') . ' <span class="author-name">' . $e->display_name . "</span></p>\n"; } } if (!isset($_GET['mc_id'])) { $details_label = mc_get_details_label($event, $data); $details_link = mc_get_details_link($event); if (_mc_is_url($details_link)) { $more = "<p class='mc_details'><a href='{$details_link}'>{$details_label}</a></p>\n"; } else { $more = ''; } } $more = apply_filters('mc_details_grid_link', $more, $event); // handle link expiration $event_link = mc_event_link($event); if (function_exists('mc_google_cal') && get_option('mc_show_gcal') == 'true') { $gcal_link = "<p class='gcal'>" . jd_draw_template($data, '{gcal_link}') . "</p>"; $gcal = $gcal_link; } if (function_exists('my_calendar_generate_vcal') && get_option('mc_show_event_vcal') == 'true') { $url = add_query_arg('vcal', $uid, home_url()); $vcal_link = "<p class='ical'><a rel='nofollow' href='{$url}'>" . __('iCal', 'my-calendar') . "</a></p>\n"; $vcal = $vcal_link; } $sizes = get_intermediate_image_sizes(); if (in_array('medium', $sizes)) { $default_size = 'medium'; } else { $default_size = 'thumbnail'; } $default_size = apply_filters('mc_default_image_size', $default_size); if (is_numeric($event->event_post) && $event->event_post != 0 && (isset($data[$default_size]) && $data[$default_size] != '')) { $atts = apply_filters('mc_post_thumbnail_atts', array('class' => 'mc-image photo')); $image = get_the_post_thumbnail($event->event_post, $default_size, $atts); } else { $image = $event->event_image != '' ? "<img src='{$event->event_image}' alt='' class='mc-image photo' />" : ''; } if (get_option('mc_desc') == 'true' || $type == 'single') { $description = get_option('mc_process_shortcodes') == 'true' ? apply_filters('the_content', stripcslashes($event->event_desc)) : wpautop(stripcslashes($event->event_desc), 1); $description = "<div class='longdesc'>{$description}</div>"; } if (get_option('mc_short') == 'true' && $type != 'single') { $short = get_option('mc_process_shortcodes') == 'true' ? apply_filters('the_content', stripcslashes($event->event_short)) : wpautop(stripcslashes($event->event_short), 1); $short = "<div class='shortdesc'>{$short}</div>"; } if (get_option('mc_event_registration') == 'true') { switch ($event->event_open) { case '0': $status = get_option('mc_event_closed'); break; case '1': $status = get_option('mc_event_open'); break; case '2': $status = ''; break; default: $status = ''; } } else { $status = ''; } $status = $status != '' ? "<p>{$status}</p>" : ''; $status = apply_filters('mc_registration_state', $status, $event); $return = $type == 'single' ? "<p><a href='" . get_option('mc_uri') . "'>" . __('View full calendar', 'my-calendar') . "</a></p>" : ''; if (!mc_show_details($time, $type)) { $description = $short = $status = ''; } if (get_option('mc_gmap') == 'true') { $map = is_singular('mc-event') || $type == 'single' ? mc_generate_map($event) : ''; } else { $map = ''; } if ($event_link != '' && get_option('mc_event_link') != 'false') { $is_external = mc_external_link($event_link); $external_class = $is_external ? "class='{$type}-link external'" : "class='{$type}-link'"; $link_template = isset($templates['link']) ? $templates['link'] : '{title}'; $link_text = jd_draw_template($data, $link_template); $link = "<p><a href='{$event_link}' {$external_class}>" . $link_text . "</a></p>"; } $details = "\n" . $close . $time . $list_title . $image . "<div class='location'>" . $map . $address . "</div>" . $description . $short . $link . $status . $author . "<div class='sharing'>" . $vcal . $gcal . $more . "</div>" . $return; } else { // if a custom template is in use $toggle = $type == 'calendar' || $type == 'mini' ? "<a href=\"#{$uid}-{$day_id}-{$type}\" aria-controls='{$uid}-{$day_id}-{$type}-details' class='mc-toggle mc-close close'><img src=\"" . plugin_dir_url(__FILE__) . "images/event-close.png\" alt='" . __('Close', 'my-calendar') . "' /></a>" : ''; $details = $toggle . $details . "\n"; } $img_class = $image != '' ? ' has-image' : ' no-image'; $container = "<div id='{$uid}-{$day_id}-{$type}-details' class='details{$img_class}' role='alert' aria-labelledby='{$uid}-{$day_id}-{$type}-title'>\n"; $container = apply_filters('mc_before_event', $container, $event, $type, $time); $details = $header . $container . $details; $details .= apply_filters('mc_after_event', '', $event, $type, $time); $details .= $close; // second close button $details .= "</div><!--ends .details--></div>"; $details = apply_filters('mc_event_content', $details, $event, $type, $time); } else { $details = $header . "</div>"; } return $details; }