function my_calendar($name, $format, $category, $time = 'month', $ltype = '', $lvalue = '', $id = 'jd-calendar', $template = '', $content = '', $author = null, $host = null, $above = '', $below = '') { check_my_calendar(); apply_filters("debug", "my_calendar( {$name} ) draw"); $mc_toporder = array('nav', 'toggle', 'jump', 'print', 'timeframe'); $mc_bottomorder = array('key', 'feeds'); if ($above != '' || $below != '') { $aboves = $above == 'none' ? array() : array_map('trim', explode(',', $above)); $belows = $below == 'none' ? array() : array_map('trim', explode(',', $below)); } else { $aboves = $mc_toporder; $belows = $mc_bottomorder; } $used = array_merge($aboves, $belows); if (isset($_GET['format']) && in_array($_GET['format'], array('list', 'mini'))) { $format = esc_attr($_GET['format']); } else { $format = esc_attr($format); } if (isset($_GET['time']) && in_array($_GET['time'], array('day', 'week', 'month')) && $format != 'mini') { $time = esc_attr($_GET['time']); } else { $time = esc_attr($time); } global $wpdb; $mcdb = $wpdb; $offset = 60 * 60 * get_option('gmt_offset'); if (get_option('mc_remote') == 'true' && function_exists('mc_remote_db')) { $mcdb = mc_remote_db(); } $my_calendar_body = ''; /* filter */ if ($time == 'day') { $format = 'list'; } $args = array('name' => $name, 'format' => $format, 'category' => $category, 'above' => $above, 'below' => $below, 'time' => $time, 'ltype' => $ltype, 'lvalue' => $lvalue, 'author' => $author, 'id' => $id); $my_calendar_body .= apply_filters('mc_before_calendar', '', $args); $main_class = $name != '' ? sanitize_title($name) : 'all'; $cid = isset($_GET['cid']) ? esc_attr(strip_tags($_GET['cid'])) : $main_class; // mc body wrapper $mc_wrapper = "<div id=\"{$id}\" class=\"mc-main {$format} {$time} {$main_class}\" aria-live='assertive' aria-atomic='true'>"; $mc_closer = "</div>"; if (get_option('mc_convert') == 'true') { $format = mc_is_mobile() ? 'list' : $format; } $format = apply_filters('mc_display_format', $format, $args); $date_format = get_option('mc_date_format') != '' ? get_option('mc_date_format') : get_option('date_format'); if (isset($_GET['mc_id']) && $format != 'mini') { // single event, main calendar only. $mc_id = (int) $_GET['mc_id']; $my_calendar_body .= mc_get_event($mc_id, 'html'); } else { if ($category == "") { $category = null; } // Deal with the week not starting on a monday $name_days = array(__('<abbr title="Sunday">Sun</abbr>', 'my-calendar'), __('<abbr title="Monday">Mon</abbr>', 'my-calendar'), __('<abbr title="Tuesday">Tues</abbr>', 'my-calendar'), __('<abbr title="Wednesday">Wed</abbr>', 'my-calendar'), __('<abbr title="Thursday">Thur</abbr>', 'my-calendar'), __('<abbr title="Friday">Fri</abbr>', 'my-calendar'), __('<abbr title="Saturday">Sat</abbr>', 'my-calendar')); $abbrevs = array('sun', 'mon', 'tues', 'wed', 'thur', 'fri', 'sat'); if ($format == "mini") { $name_days = array(__('<abbr title="Sunday">S</abbr>', 'my-calendar'), __('<abbr title="Monday">M</abbr>', 'my-calendar'), __('<abbr title="Tuesday">T</abbr>', 'my-calendar'), __('<abbr title="Wednesday">W</abbr>', 'my-calendar'), __('<abbr title="Thursday">T</abbr>', 'my-calendar'), __('<abbr title="Friday">F</abbr>', 'my-calendar'), __('<abbr title="Saturday">S</abbr>', 'my-calendar')); } $start_of_week = get_option('start_of_week') == 1 ? 1 : 7; // convert start of week to ISO 8601 (Monday/Sunday) $end_of_week = $start_of_week == 1 ? 7 : 6; $start_of_week = get_option('mc_show_weekends') == 'true' ? $start_of_week : 1; //$start_of_week = ( $start_of_week==1||$start_of_week==0)?$start_of_week:0; if ($start_of_week == '1') { $first = array_shift($name_days); $afirst = array_shift($abbrevs); $name_days[] = $first; $abbrevs[] = $afirst; } // If we don't pass arguments we want a calendar that is relevant to today (current time period) $c_m = 0; if (isset($_GET['dy']) && $main_class == $cid && ($time == 'day' || $time == 'week')) { // $c_day = (int) $_GET['dy']; } else { if ($time == 'week') { $dm = first_day_of_week(); $c_day = $dm[0]; $c_m = $dm[1]; } else { if ($time == 'day') { $c_day = date("d", time() + $offset); } else { $c_day = 1; } } } if (isset($_GET['month']) && $main_class == $cid) { $c_month = (int) $_GET['month']; if (!isset($_GET['dy'])) { $c_day = 1; } } else { $xnow = date('Y-m-d', time() + $offset); $c_month = $c_m == 0 ? date("m", time() + $offset) : date("m", strtotime($xnow . ' -1 month')); } $is_start_of_week = date('N', current_time('timestamp')) == get_option('start_of_week') ? true : false; if (isset($_GET['yr']) && $main_class == $cid) { $c_year = (int) $_GET['yr']; } else { // weeks suck. seriously. if (date("Y", current_time('timestamp')) == date("Y", strtotime(date('Y-m-d', current_time('timestamp')) . '- 6 days')) || $is_start_of_week) { $c_year = date("Y", current_time('timestamp')); } else { $c_year = date("Y", current_time('timestamp')) - 1; } } // Years get funny if we exceed 3000, so we use this check if (!($c_year <= 3000 && $c_year >= 0)) { // No valid year causes the calendar to default to today $c_year = date("Y", time() + $offset); $c_month = date("m", time() + $offset); $c_day = date("d", time() + $offset); } if (!(isset($_GET['yr']) || isset($_GET['month']) || isset($_GET['dy']))) { $c_year = apply_filters('mc_filter_year', $c_year, $args); $c_month = apply_filters('mc_filter_month', $c_month, $args); $c_day = apply_filters('mc_filter_day', $c_day, $args); } $c_day = $c_day == 0 ? 1 : $c_day; // c_day can't equal 0. $n_month = $c_month + 1 > 12 ? 1 : $c_month + 1; $p_month = $c_month - 1 < 1 ? 12 : $c_month - 1; $current_date = mktime(0, 0, 0, $c_month, $c_day, $c_year); $c_month = str_pad($c_month, 2, '0', STR_PAD_LEFT); $n_month = str_pad($n_month, 2, '0', STR_PAD_LEFT); $p_month = str_pad($p_month, 2, '0', STR_PAD_LEFT); //echo "<p>Debug:<br />Day: $c_day<br />Month: $c_month<br />Year: $c_year<br />Date: ".date('Y-m-d',$current_date)."</p>"; $num = get_option('mc_show_months') - 1; // the value is total months to show; need additional months to show. if ($format == "list" && $time != 'week') { // grid calendar can't show multiple months if ($num > 0 && $time != 'day' && $time != 'week') { $from = date('Y-m-d', mktime(0, 0, 0, $c_month, 1, $c_year)); $next = strtotime("+{$num} months", mktime(0, 0, 0, $c_month, 1, $c_year)); $last = date('t', $next); $to = date('Y-m', $next) . '-' . $last; } else { $from = date('Y-m-d', mktime(0, 0, 0, $c_month, 1, $c_year)); $to = date('Y-m-d', mktime(0, 0, 0, $c_month, date('t', mktime(0, 0, 0, $c_month, 1, $c_year)), $c_year)); } $this_dates = array('from' => $from, 'to' => $to); } else { $this_dates = mc_date_array($current_date, $time, $num); } $from = $this_dates['from']; $to = $this_dates['to']; //echo "<pre>$num $from, $to ($c_month,$c_day,$c_year)</pre>"; apply_filters("debug", "my_calendar( {$name} ) pre get events"); $event_array = my_calendar_events($from, $to, $category, $ltype, $lvalue, 'calendar', $author, $host); $no_events = empty($event_array) ? true : false; apply_filters("debug", "my_calendar( {$name} ) post get events"); // define navigation element strings $timeframe = $nav = $feeds = $jump = $mc_topnav = $mc_bottomnav = ''; // setup print link $add = array('time' => $time, 'ltype' => $ltype, 'lvalue' => $lvalue, 'mcat' => $category, 'yr' => $c_year, 'month' => $c_month, 'dy' => $c_day, 'cid' => 'print'); $subtract = array(); if ($ltype == '') { $subtract[] = 'ltype'; unset($add['ltype']); } if ($lvalue == '') { $subtract[] = 'lvalue'; unset($add['lvalue']); } if ($category == 'all') { $subtract[] = 'mcat'; unset($add['mcat']); } $mc_print_url = mc_build_url($add, $subtract, mc_feed_base() . 'my-calendar-print'); $print = "<div class='mc-print'><a href='{$mc_print_url}'>" . __('Print View', 'my-calendar') . "</a></div>"; // set up format toggle $toggle = in_array('toggle', $used) ? mc_format_toggle($format, 'yes') : ''; // set up time toggle if (in_array('timeframe', $used)) { // if dy parameter not set, use today's date instead of first day of month. if (isset($_GET['dy'])) { $weeks_day = first_day_of_week($current_date); } else { $weeks_day = first_day_of_week(current_time('timestamp')); } $day = $weeks_day[0]; if (isset($_GET['time']) && $_GET['time'] == 'day') { // don't adjust day if viewing day format } else { if ($day > 20) { $day = date('j', strtotime("{$from} + 1 week")); } } $timeframe = mc_time_toggle($format, $time, 'yes', $day, $c_month, $c_year); } // set up category key $key = in_array('key', $used) ? my_category_key($category) : ''; // set up navigation links if (in_array('nav', $used)) { $pLink = my_calendar_prev_link($c_year, $c_month, $c_day, $format, $time); $nLink = my_calendar_next_link($c_year, $c_month, $c_day, $format, $time); $prevLink = mc_build_url(array('yr' => $pLink['yr'], 'month' => $pLink['month'], 'dy' => $pLink['day'], 'cid' => $main_class), array()); $nextLink = mc_build_url(array('yr' => $nLink['yr'], 'month' => $nLink['month'], 'dy' => $nLink['day'], 'cid' => $main_class), array()); $previous_link = apply_filters('mc_previous_link', ' <li class="my-calendar-prev"><a href="' . $prevLink . '" rel="' . $id . '">' . $pLink['label'] . '</a></li>', $pLink); $next_link = apply_filters('mc_next_link', ' <li class="my-calendar-next"><a href="' . $nextLink . '" rel="' . $id . '">' . $nLink['label'] . '</a></li>', $nLink); $nav = ' <div class="my-calendar-nav"> <ul> ' . $previous_link . ' ' . $next_link . ' </ul> </div>'; } // set up rss feeds if ($format != 'mini') { $ical_m = isset($_GET['month']) ? (int) $_GET['month'] : date('n'); $ical_y = isset($_GET['yr']) ? (int) $_GET['yr'] : date('Y'); $feeds = mc_rss_links($ical_y, $ical_m, $nLink); } // set up date switcher if (in_array('jump', $used)) { $jump = $time != 'week' && $time != 'day' ? mc_build_date_switcher($format, $main_class) : ''; } // set up above-calendar order of fields if (get_option('mc_topnav') != '') { $mc_toporder = explode(',', get_option('mc_topnav')); } if ($above != '') { $mc_toporder = explode(',', $above); } foreach ($mc_toporder as $value) { if ($value != 'none') { $value = trim($value); $mc_topnav .= ${$value}; } } if ($mc_topnav != '') { $mc_topnav = '<div class="my-calendar-header">' . $mc_topnav . '</div>'; } if (get_option('mc_bottomnav') != '') { $mc_bottomorder = explode(',', get_option('mc_bottomnav')); } if ($below != '') { $mc_bottomorder = explode(',', $below); } foreach ($mc_bottomorder as $value) { if ($value != 'none' && $value != 'stop') { $value = trim($value); $mc_bottomnav .= ${$value}; } } if ($mc_bottomnav != '') { $mc_bottomnav = "<div class='mc_bottomnav'>{$mc_bottomnav}</div>"; } if ($time == 'day') { apply_filters("debug", "my_calendar( {$name} ) pre single-day parsing"); $my_calendar_body .= "<div class='mc-main {$format} {$time}'>" . $mc_topnav; // single day uses independent cycling. $dayclass = strtolower(date_i18n('D', mktime(0, 0, 0, $c_month, $c_day, $c_year))); $from = $to = "{$c_year}-{$c_month}-{$c_day}"; //echo "<p>Debug: $from, $to, $category, $ltype, $lvalue, $author</p>"; $events = my_calendar_grab_events($from, $to, $category, $ltype, $lvalue, 'calendar', $author, $host); if (!get_option('mc_skip_holidays_category') || get_option('mc_skip_holidays_category') == '') { $holidays = array(); } else { $holidays = my_calendar_grab_events($from, $to, get_option('mc_skip_holidays_category'), $ltype, $lvalue, 'calendar', $author, $host, 'holidays'); } //echo "<pre>".print_r($events,1)."</pre>"; $events_class = mc_events_class($events); $dateclass = mc_dateclass(time() + $offset, mktime(0, 0, 0, $c_month, $c_day, $c_year)); $mc_events = ''; if (is_array($events) && count($events) > 0) { if (is_array($holidays) && count($holidays) > 0) { $mc_events .= my_calendar_draw_events($holidays, $format, $from, $time, $template); } else { $mc_events .= my_calendar_draw_events($events, $format, $from, $time, $template); } } else { $mc_events .= __('No events scheduled for today!', 'my-calendar'); } $heading_level = apply_filters('mc_heading_level', 'h3', $format, $time, $template); $my_calendar_body .= "\n\t\t\t\t<{$heading_level} class='mc-single'>" . date_i18n(apply_filters('mc_date_format', $date_format, 'grid'), strtotime("{$c_year}-{$c_month}-{$c_day}")) . "</{$heading_level}>" . ' <div id="mc-day" class="' . $dayclass . ' ' . $dateclass . ' ' . $events_class . '">' . "{$mc_events}\n</div>\n\t\t\t</div>"; apply_filters("debug", "my_calendar( {$name} ) post single-day parsing"); } else { apply_filters("debug", "my_calendar( {$name} ) pre full parsing"); // if showing multiple months, figure out how far we're going. $num_months = $time == 'week' ? 1 : get_option('mc_show_months'); $through_date = mktime(0, 0, 0, $c_month + ($num_months - 1), $c_day, $c_year); $month_format = get_option('mc_month_format') == '' ? 'F Y' : get_option('mc_month_format'); $current_date_header = date_i18n($month_format, $current_date); $current_month_header = date('Y', $current_date) == date('Y', $through_date) ? date_i18n('F', $current_date) : date_i18n('F Y', $current_date); $through_month_header = date_i18n($month_format, $through_date); // Adjust the days of the week if week start is not Monday $and = __("and", 'my-calendar'); $category_label = $category != "" && $category != "all" ? str_replace("|", " {$and} ", $category) . ' ' : ''; // Add the calendar table and heading $caption_text = ' ' . stripslashes(trim(get_option('mc_caption'))); // this option should be replaced JCD TODO $my_calendar_body .= $mc_topnav; if ($format == "calendar" || $format == "mini") { $my_calendar_body .= "\n<table class=\"my-calendar-table\">\n"; $values = array('date' => date('Y-m-d', $current_date)); $week_template = get_option('mc_week_caption') != '' ? get_option('mc_week_caption') : 'Week of {date format="M jS"}'; $week_caption = jd_draw_template($values, stripslashes($week_template)); $caption_heading = $time != 'week' ? $current_date_header . $caption_text : $week_caption . $caption_text; $my_calendar_body .= "<caption class=\"my-calendar-{$time}\">" . $caption_heading . "</caption>\n"; } else { // determine which header text to show depending on number of months displayed; if ($time != 'week' && $time != 'day') { $list_heading = $num_months <= 1 ? __('Events in', 'my-calendar') . ' ' . $current_date_header . $caption_text . "\n" : $current_month_header . '–' . $through_month_header . $caption_text; } else { $values = array('date' => date('Y-m-d', $current_date)); $list_heading = jd_draw_template($values, stripslashes(get_option('mc_week_caption'))); } $my_calendar_body .= "<h3 class=\"my-calendar-{$time}\">{$list_heading}</h3>\n"; } // If not a valid time or layout format, skip. if (in_array($format, array('calendar', 'mini', 'list')) && in_array($time, array('day', 'week', 'month'))) { // If in a calendar format, print the headings of the days of the week if ($format == "list") { if ($id == 'jd-calendar') { $list_id = 'calendar-list'; } else { $list_id = "list-{$id}"; } $my_calendar_body .= "<ul id='{$list_id}' class='mc-list'>"; } else { $my_calendar_body .= "<thead>\n<tr>\n"; for ($i = 0; $i <= 6; $i++) { if ($start_of_week == 0) { $class = $i < 6 && $i > 0 ? 'day-heading' : 'weekend-heading'; } else { $class = $i < 5 ? 'day-heading' : 'weekend-heading'; } $dayclass = strtolower(strip_tags($abbrevs[$i])); if ($class == 'weekend-heading' && get_option('mc_show_weekends') == 'true' || $class != 'weekend-heading') { $my_calendar_body .= "<th scope='col' class='{$class} {$dayclass}'>" . $name_days[$i] . "</th>\n"; } } $my_calendar_body .= "\n</tr>\n</thead>\n<tbody>"; } $odd = 'odd'; // get and display all the events $show_all = false; // show all dates in list format. if ($no_events && $format == "list" && $show_all == false) { // if there are no events in list format, just display that info. $no_events = $content == '' ? __('There are no events scheduled during this period.', 'my-calendar') : $content; $my_calendar_body .= "<li class='no-events'>{$no_events}</li>"; } else { $start = strtotime($from); $end = strtotime($to); do { $date = date('Y-m-d', $start); $enddate = date('Y-m-d', $end); $is_weekend = date('N', $start) < 6 ? false : true; if (get_option('mc_show_weekends') == 'true' || get_option('mc_show_weekends') != 'true' && !$is_weekend) { if (date('N', $start) == $start_of_week && $format != "list") { $my_calendar_body .= "<tr>"; } // date-based classes $monthclass = date('n', $start) == $c_month || $time != 'month' ? '' : 'nextmonth'; $dateclass = mc_dateclass(time() + $offset, $start); $dayclass = strtolower(date_i18n('D', $start)); $week_format = get_option('mc_week_format') == '' ? 'M j, \'y' : get_option('mc_week_format'); $week_date_format = date_i18n($week_format, $start); $thisday_heading = $time == 'week' ? "<small>{$week_date_format}</small>" : date('j', $start); $events = isset($event_array[$date]) ? $event_array[$date] : array(); if (!empty($events)) { $event_output = my_calendar_draw_events($events, $format, $date, $time, $template); if ($event_output === true) { $event_output = ' '; } $events_class = $event_output != '' ? mc_events_class($events) : 'no-events'; if ($format == 'mini' && $event_output != '') { if (get_option('mc_open_day_uri') == 'true' || get_option('mc_open_day_uri') == 'false') { // yes, this is weird. it's from some old settings... $target = array('yr' => date('Y', $start), 'month' => date('m', $start), 'dy' => date('j', $start), 'time' => 'day'); if ($category != '') { $target['mcat'] = $category; } $day_url = mc_build_url($target, array('month', 'dy', 'yr', 'ltype', 'loc', 'mcat', 'cid', 'mc_id'), apply_filters('mc_modify_day_uri', get_option('mc_uri'))); $link = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? $day_url : '#'; } else { $atype = str_replace('anchor', '', get_option('mc_open_day_uri')); $ad = str_pad(date('j', $start), 2, '0', STR_PAD_LEFT); // need to match format in ID $am = str_pad($c_month, 2, '0', STR_PAD_LEFT); $date_url = mc_build_url(array('yr' => $c_year, 'month' => $c_month, 'dy' => date('j', $start)), array('month', 'dy', 'yr', 'ltype', 'loc', 'mcat', 'cid', 'mc_id'), get_option('mc_mini_uri')); $link = get_option('mc_mini_uri') != '' ? $date_url . '#' . $atype . '-' . $c_year . '-' . $am . '-' . $ad : '#'; } $element = "a href='{$link}'"; $close = 'a'; $trigger = 'trigger'; } else { $element = 'span'; $close = 'span'; $trigger = ''; } // set up events if ($is_weekend && get_option('mc_show_weekends') == 'true' || !$is_weekend) { $weekend_class = $is_weekend ? 'weekend' : ''; if ($format == "list") { if (get_option('mc_list_javascript') != 1) { $is_anchor = "<a href='#'>"; $is_close_anchor = "</a>"; } else { $is_anchor = $is_close_anchor = ""; } if (get_option('mc_show_list_info') == 'true') { $title = ' - ' . $is_anchor . mc_list_title($events) . $is_close_anchor; } else { $title = ''; } //if ( $monthclass != 'nextmonth' ) { // only show current month in list view. if ($event_output != '') { $my_calendar_body .= "\n\t\t\t\t\t\t\t\t\t\t\t\t<li id='{$format}-{$date}' class='mc-events {$dayclass} {$dateclass} {$events_class} {$odd}'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<strong class=\"event-date\">{$is_anchor}" . date_i18n(apply_filters('mc_date_format', $date_format, 'list'), $start) . "{$is_close_anchor}" . "{$title}</strong>" . $event_output . "\n\t\t\t\t\t\t\t\t\t\t\t\t</li>"; $odd = $odd == 'odd' ? 'even' : 'odd'; } //} } else { $my_calendar_body .= "\n\t\t\t\t\t\t\t\t\t\t\t\t<td id='{$format}-{$date}' class='{$dayclass} {$dateclass} {$weekend_class} {$monthclass} {$events_class} day-with-date'>" . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t<{$element} class='mc-date {$trigger}'>{$thisday_heading}</{$close}>" . $event_output . "\n\t\t\t\t\t\t\t\t\t\t\t\t</td>\n"; } } } else { // set up no events if ($format != "list") { $weekend_class = $is_weekend ? 'weekend' : ''; $my_calendar_body .= "\n\t\t\t\t\t\t\t\t\t\t\t\t<td class='no-events {$dayclass} {$dateclass} {$weekend_class} {$monthclass} day-with-date'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class='mc-date no-events'>{$thisday_heading}</span>\n\t\t\t\t\t\t\t\t\t\t\t\t</td>\n"; } else { if ($show_all == true) { $my_calendar_body .= "\n\t\t\t\t\t\t\t\t\t\t\t<li id='{$format}-{$date}' class='no-events {$dayclass} {$dateclass} {$events_class} {$odd}'>\n\t\t\t\t\t\t\t\t\t\t\t\t<strong class=\"event-date\">{$is_anchor}" . date_i18n($date_format, $start) . "{$is_close_anchor}</strong></li>"; $odd = $odd == 'odd' ? 'even' : 'odd'; } } } if (date('N', $start) == $end_of_week && $format != "list") { $my_calendar_body .= "</tr>\n"; // end of 'is beginning of week' } } $start = strtotime("+1 day", $start); } while ($start <= $end); } $my_calendar_body .= $format == "list" ? "\n</ul>" : "\n</tbody>\n</table>"; } else { if (!in_array($format, array('list', 'calendar', 'mini'))) { $my_calendar_body .= "<p class='mc-error-format'>" . __("Unrecognized calendar format. Please use one of 'list', 'calendar', or 'mini'.", 'my-calendar') . "</p>"; } if (!in_array($time, array('day', 'week', 'month'))) { $my_calendar_body .= "<p class='mc-error-time'>" . __("Unrecognized calendar time period. Please use one of 'day', 'week', or 'month'.", 'my-calendar') . "</p>"; } } $my_calendar_body .= $mc_bottomnav; apply_filters("debug", "my_calendar( {$name} ) post full parsing"); } } // The actual printing is done by the shortcode function. $my_calendar_body .= apply_filters('mc_after_calendar', '', $args); apply_filters("debug", "my_calendar( {$name} ) draw completed"); return $mc_wrapper . apply_filters('my_calendar_body', $my_calendar_body) . $mc_closer; }
function my_calendar($name, $format, $category, $time = 'month', $ltype = '', $lvalue = '', $id = '', $template = '', $content = '', $author = null, $host = null, $above = '', $below = '', $syear = false, $smonth = false, $sday = false, $source = 'shortcode', $site = false) { if ($site) { $site = $site == 'global' ? BLOG_ID_CURRENT_SITE : $site; switch_to_blog($site); } check_my_calendar(); // category key needs to receive the original category settings. $original_category = $category; $category = isset($_GET['mcat']) ? (int) $_GET['mcat'] : $category; $mc_toporder = array('nav', 'toggle', 'jump', 'print', 'timeframe'); $mc_bottomorder = array('key', 'feeds'); if ($above != '' || $below != '') { $aboves = $above == 'none' ? array() : array_map('trim', explode(',', $above)); $belows = $below == 'none' ? array() : array_map('trim', explode(',', $below)); } else { $aboves = $mc_toporder; $belows = $mc_bottomorder; } $used = array_merge($aboves, $belows); if (isset($_GET['format']) && in_array($_GET['format'], array('list', 'mini')) && $format != 'mini') { $format = esc_attr($_GET['format']); } else { $format = esc_attr($format); } if (isset($_GET['time']) && in_array($_GET['time'], array('day', 'week', 'month', 'month+1')) && $format != 'mini') { $time = esc_attr($_GET['time']); } else { $time = esc_attr($time); } $offset = 60 * 60 * get_option('gmt_offset'); $my_calendar_body = ''; /* filter */ if ($time == 'day') { $format = 'list'; } $args = array('name' => $name, 'format' => $format, 'category' => $category, 'above' => $above, 'below' => $below, 'time' => $time, 'ltype' => $ltype, 'lvalue' => $lvalue, 'author' => $author, 'id' => $id, 'above' => $above, 'below' => $below, 'host' => $host, 'syear' => $syear, 'smonth' => $smonth, 'sday' => $sday); // args used in Md5 hash cannot include 'time' or 'format', since those can be changed by navigation. $hash_args = array('name' => $name, 'category' => $category, 'above' => $above, 'below' => $below, 'ltype' => $ltype, 'lvalue' => $lvalue, 'author' => $author, 'id' => $id, 'above' => $above, 'below' => $below, 'host' => $host, 'syear' => $syear, 'smonth' => $smonth, 'sday' => $sday); $hash = md5(implode(',', $hash_args)); $my_calendar_body .= apply_filters('mc_before_calendar', '', $args); $id = !$id ? "mc-{$hash}" : $id; $main_class = $id != '' ? sanitize_title($id) : 'all'; $cid = isset($_GET['cid']) ? esc_attr(strip_tags($_GET['cid'])) : $main_class; if (get_option('mc_convert') == 'true') { $format = mc_is_mobile() && $format == 'calendar' ? 'list' : $format; } else { if (get_option('mc_convert') == 'mini') { $format = mc_is_mobile() ? 'mini' : $format; } } $format = apply_filters('mc_display_format', $format, $args); // mc body wrapper $mc_wrapper = "<div id=\"{$id}\" class=\"mc-main {$format} {$time} {$main_class}\" aria-live='assertive' aria-atomic='true'>"; $mc_closer = "</div>"; $date_format = get_option('mc_date_format') != '' ? get_option('mc_date_format') : get_option('date_format'); if (isset($_GET['mc_id']) && $source != 'widget') { // single event, main calendar only. $mc_id = is_numeric($_GET['mc_id']) ? $_GET['mc_id'] : false; if ($mc_id) { $my_calendar_body .= mc_get_event($mc_id, 'html'); } } else { if ($category == "") { $category = 'all'; } // Deal with the week not starting on a monday $name_days = array("<abbr title='" . date_i18n('l', strtotime('Sunday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Sunday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Sunday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Monday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Monday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Monday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Tuesday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Tuesday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Tuesday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Wednesday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Wednesday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Wednesday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Thursday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Thursday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Thursday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Friday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Friday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Friday')) . "</span>", "<abbr title='" . date_i18n('l', strtotime('Saturday')) . "' aria-hidden='true'>" . date_i18n('D', strtotime('Saturday')) . "</abbr><span class='screen-reader-text'>" . date_i18n('l', strtotime('Saturday')) . "</span>"); $abbrevs = array('sun', 'mon', 'tues', 'wed', 'thur', 'fri', 'sat'); if ($format == 'mini') { // PHP doesn't have a single letter abbreviation, so this has to be a translatable. $name_days = array("<span aria-hidden='true'>" . __('<abbr title="Sunday">S</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Sunday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Monday">M</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Monday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Tuesday">T</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Tuesday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Wednesday">W</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Wednesday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Thursday">T</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Thursday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Friday">F</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Friday')) . "</span>", "<span aria-hidden='true'>" . __('<abbr title="Saturday">S</abbr>', 'my-calendar') . "</span><span class='screen-reader-text'>" . date_i18n('l', strtotime('Saturday')) . "</span>"); } $start_of_week = get_option('start_of_week') == 1 ? 1 : 7; // convert start of week to ISO 8601 (Monday/Sunday) $end_of_week = $start_of_week == 1 ? 7 : 6; $start_of_week = get_option('mc_show_weekends') == 'true' ? $start_of_week : 1; //$start_of_week = ( $start_of_week==1||$start_of_week==0)?$start_of_week:0; if ($start_of_week == '1') { $first = array_shift($name_days); $afirst = array_shift($abbrevs); $name_days[] = $first; $abbrevs[] = $afirst; } // If we don't pass arguments we want a calendar that is relevant to today (current time period) $c_m = 0; if (isset($_GET['dy']) && $main_class == $cid && ($time == 'day' || $time == 'week')) { // $c_day = (int) $_GET['dy']; } else { if ($time == 'week') { $dm = first_day_of_week(); $c_day = $dm[0]; $c_m = $dm[1]; } else { if ($time == 'day') { $c_day = date("d", time() + $offset); } else { $c_day = 1; } } } if (isset($_GET['month']) && $main_class == $cid) { $c_month = (int) $_GET['month']; if (!isset($_GET['dy'])) { $c_day = 1; } } else { $xnow = date('Y-m-d', time() + $offset); $c_month = $c_m == 0 ? date("m", time() + $offset) : date("m", strtotime($xnow . ' -1 month')); } $is_start_of_week = date('N', current_time('timestamp')) == get_option('start_of_week') ? true : false; if (isset($_GET['yr']) && $main_class == $cid) { $c_year = (int) $_GET['yr']; } else { // weeks suck. seriously. if ($time == 'week' && !isset($_GET['dy'])) { if ($is_start_of_week) { $c_year = date("Y", current_time('timestamp')); } else { $current_year = date('Y', current_time('timestamp')); $c_year = $dm[1] == 0 ? $current_year : false; if (!$c_year) { $c_year = date('Y', strtotime('-1 month')) == $current_year ? $current_year : $current_year - 1; } } } else { $c_year = date("Y", current_time('timestamp')); } } // Years get funny if we exceed 3000, so we use this check if (!($c_year <= 3000 && $c_year >= 0)) { // No valid year causes the calendar to default to today $c_year = date("Y", time() + $offset); $c_month = date("m", time() + $offset); $c_day = date("d", time() + $offset); } if (!(isset($_GET['yr']) || isset($_GET['month']) || isset($_GET['dy']))) { // month/year based on shortcode $shortcode_month = $smonth != false ? $smonth : $c_month; $shortcode_year = $syear != false ? $syear : $c_year; $shortcode_day = $sday != false ? $sday : $c_day; // override with filters $c_year = apply_filters('mc_filter_year', $shortcode_year, $args); $c_month = apply_filters('mc_filter_month', $shortcode_month, $args); $c_day = apply_filters('mc_filter_day', $shortcode_day, $args); } $c_day = $c_day == 0 ? 1 : $c_day; // c_day can't equal 0. $current_date = mktime(0, 0, 0, $c_month, $c_day, $c_year); $c_month = str_pad($c_month, 2, '0', STR_PAD_LEFT); $mc_show_months = apply_filters('mc_show_months', get_option('mc_show_months'), $args); $num = $mc_show_months - 1; // the value is total months to show; need additional months to show. if ($format == "list" && $time != 'week') { // grid calendar can't show multiple months if ($num > 0 && $time != 'day' && $time != 'week') { // grid calendar date calculation if ($time == 'month+1') { $from = date('Y-m-d', strtotime('+1 month', mktime(0, 0, 0, $c_month, 1, $c_year))); $next = strtotime("+{$num} months", strtotime('+1 month', mktime(0, 0, 0, $c_month, 1, $c_year))); } else { $from = date('Y-m-d', mktime(0, 0, 0, $c_month, 1, $c_year)); $next = strtotime("+{$num} months", mktime(0, 0, 0, $c_month, 1, $c_year)); } $last = date('t', $next); $to = date('Y-m', $next) . '-' . $last; } else { $from = date('Y-m-d', mktime(0, 0, 0, $c_month, 1, $c_year)); $to = date('Y-m-d', mktime(0, 0, 0, $c_month, date('t', mktime(0, 0, 0, $c_month, 1, $c_year)), $c_year)); } $this_dates = array('from' => $from, 'to' => $to); } else { $this_dates = mc_date_array($current_date, $time); } $from = apply_filters('mc_from_date', $this_dates['from']); $to = apply_filters('mc_to_date', $this_dates['to']); $event_array = my_calendar_events($from, $to, $category, $ltype, $lvalue, 'calendar', $author, $host, '', $site); $no_events = empty($event_array) ? true : false; // define navigation element strings // These variables are used by reference {$value} $timeframe = $print = $toggle = $nav = $feeds = $jump = $mc_topnav = $mc_bottomnav = ''; // setup print link $add = array('time' => $time, 'ltype' => $ltype, 'lvalue' => $lvalue, 'mcat' => $category, 'yr' => $c_year, 'month' => $c_month, 'dy' => $c_day, 'href' => urlencode(mc_get_current_url())); $subtract = array(); if ($ltype == '') { $subtract[] = 'ltype'; unset($add['ltype']); } if ($lvalue == '') { $subtract[] = 'lvalue'; unset($add['lvalue']); } if ($category == 'all') { $subtract[] = 'mcat'; unset($add['mcat']); } $print_add = array_merge($add, array('cid' => 'mc-print-view')); $mc_print_url = mc_build_url($print_add, $subtract, home_url()); $print = "<div class='mc-print'><a href='{$mc_print_url}'>" . __('Print<span class="maybe-hide"> View</span>', 'my-calendar') . "</a></div>"; // set up format toggle $toggle = in_array('toggle', $used) ? mc_format_toggle($format, 'yes', $time) : ''; // set up time toggle if (in_array('timeframe', $used)) { // if dy parameter not set, use today's date instead of first day of month. if (isset($_GET['dy'])) { $current_day = absint($_GET['dy']); $current_set = mktime(0, 0, 0, $c_month, $current_day, $c_year); if (date('N', $current_set) == $start_of_week) { $weeks_day = first_day_of_week($current_set); } else { $weeks_day = first_day_of_week($current_date); } } else { $weeks_day = first_day_of_week(current_time('timestamp')); } $day = $weeks_day[0]; if (isset($_GET['time']) && $_GET['time'] == 'day') { // don't adjust day if viewing day format } else { if (!isset($_GET['dy']) && $day > 20) { $day = date('j', strtotime("{$from} + 1 week")); } } $timeframe = mc_time_toggle($format, $time, 'yes', $day, $c_month, $c_year); } // set up category key $key = in_array('key', $used) ? my_category_key($original_category) : ''; // set up navigation links if (in_array('nav', $used)) { $pLink = my_calendar_prev_link($c_year, $c_month, $c_day, $format, $time, $mc_show_months); $nLink = my_calendar_next_link($c_year, $c_month, $c_day, $format, $time, $mc_show_months); $prevLink = mc_build_url(array('yr' => $pLink['yr'], 'month' => $pLink['month'], 'dy' => $pLink['day'], 'cid' => $main_class), array()); $nextLink = mc_build_url(array('yr' => $nLink['yr'], 'month' => $nLink['month'], 'dy' => $nLink['day'], 'cid' => $main_class), array()); $previous_link = apply_filters('mc_previous_link', '<li class="my-calendar-prev"><a href="' . $prevLink . '" rel="nofollow" data-rel="' . $id . '">' . $pLink['label'] . '</a></li>', $pLink); $next_link = apply_filters('mc_next_link', '<li class="my-calendar-next"><a href="' . $nextLink . '" rel="nofollow" data-rel="' . $id . '">' . $nLink['label'] . '</a></li>', $nLink); $nav = ' <div class="my-calendar-nav"> <ul> ' . $previous_link . $next_link . ' </ul> </div>'; } // set up rss feeds if (in_array('feeds', $used)) { $ical_m = isset($_GET['month']) ? (int) $_GET['month'] : date('n'); $ical_y = isset($_GET['yr']) ? (int) $_GET['yr'] : date('Y'); if (!isset($nLink)) { $nLink = my_calendar_next_link($c_year, $c_month, $c_day, $format, $time, $mc_show_months); } $feeds = mc_rss_links($ical_y, $ical_m, $nLink, $add, $subtract); } // set up date switcher if (in_array('jump', $used)) { $jump = $time != 'week' ? mc_build_date_switcher($format, $main_class, $time) : ''; } // set up above-calendar order of fields if (get_option('mc_topnav') != '') { $mc_toporder = explode(',', get_option('mc_topnav')); } if ($above != '') { $mc_toporder = explode(',', $above); } foreach ($mc_toporder as $value) { if ($value != 'none' && in_array($value, $used)) { $value = trim($value); $mc_topnav .= @${$value}; } } if ($mc_topnav != '') { $mc_topnav = '<div class="my-calendar-header">' . $mc_topnav . '</div>'; } if (get_option('mc_bottomnav') != '') { $mc_bottomorder = explode(',', get_option('mc_bottomnav')); } if ($below != '') { $mc_bottomorder = explode(',', $below); } foreach ($mc_bottomorder as $value) { if ($value != 'none' && $value != 'stop' && in_array($value, $used)) { $value = trim($value); $mc_bottomnav .= @${$value}; } } if ($mc_bottomnav != '') { $mc_bottomnav = "<div class='mc_bottomnav'>{$mc_bottomnav}</div>"; } if ($time == 'day') { $my_calendar_body .= "<div class='mc-main {$format} {$time}'>" . $mc_topnav; // single day uses independent cycling. $dayclass = strtolower(date('D', mktime(0, 0, 0, $c_month, $c_day, $c_year))); $from = $to = "{$c_year}-{$c_month}-{$c_day}"; //echo "<p>Debug: $from, $to, $category, $ltype, $lvalue, $author</p>"; $events = my_calendar_grab_events($from, $to, $category, $ltype, $lvalue, 'calendar', $author, $host, null, '', $site); if (!get_option('mc_skip_holidays_category') || get_option('mc_skip_holidays_category') == '') { $holidays = array(); } else { $holidays = my_calendar_grab_events($from, $to, get_option('mc_skip_holidays_category'), $ltype, $lvalue, 'calendar', $author, $host, 'holidays', '', $site); } $events_class = mc_events_class($events, $from); $dateclass = mc_dateclass(time() + $offset, mktime(0, 0, 0, $c_month, $c_day, $c_year)); $mc_events = ''; if (is_array($events) && count($events) > 0) { if (is_array($holidays) && count($holidays) > 0) { $mc_events .= my_calendar_draw_events($holidays, $format, $from, $time, $template); } else { $mc_events .= my_calendar_draw_events($events, $format, $from, $time, $template); } } else { $mc_events .= __('No events scheduled for today!', 'my-calendar'); } $hl = apply_filters('mc_heading_level', 'h3', $format, $time, $template); $datetime = date_i18n(apply_filters('mc_date_format', $date_format, $format, $time), strtotime("{$c_year}-{$c_month}-{$c_day}")); $my_calendar_body .= "\r\n\t\t\t\t<{$hl} class='mc-single'>" . apply_filters('mc_heading', $datetime, $format, $time) . "</{$hl}>" . ' <div id="mc-day" class="' . esc_attr($dayclass . ' ' . $dateclass . ' ' . $events_class) . '">' . "{$mc_events}\n</div>\r\n\t\t\t</div>"; } else { // if showing multiple months, figure out how far we're going. $num_months = $time == 'week' ? 1 : $mc_show_months; $through_date = mktime(0, 0, 0, $c_month + ($num_months - 1), $c_day, $c_year); $month_format = get_option('mc_month_format') == '' ? 'F Y' : get_option('mc_month_format'); if ($time == 'month+1') { $current_date_header = date_i18n($month_format, strtotime('+1 month', $current_date)); } else { $current_date_header = date_i18n($month_format, $current_date); } $current_month_header = date('Y', $current_date) == date('Y', $through_date) ? date_i18n('F', $current_date) : date_i18n('F Y', $current_date); $through_month_header = date_i18n($month_format, $through_date); $values = array('date' => date('Y-m-d', $current_date)); // Add the calendar table and heading $caption_text = ' ' . stripslashes(trim(get_option('mc_caption'))); $my_calendar_body .= $mc_topnav; if ($format == "calendar" || $format == "mini") { $table = apply_filters('mc_grid_wrapper', 'table', $format); $my_calendar_body .= "\n<{$table} class=\"my-calendar-table\">\n"; $week_template = get_option('mc_week_caption') != '' ? get_option('mc_week_caption') : 'Week of {date format="M jS"}'; $week_caption = jd_draw_template($values, stripslashes($week_template)); $caption_heading = $time != 'week' ? $current_date_header . $caption_text : $week_caption . $caption_text; $caption = apply_filters('mc_grid_caption', 'caption', $format); $my_calendar_body .= "<{$caption} class=\"heading my-calendar-{$time}\">" . $caption_heading . "</{$caption}>\n"; } else { // determine which header text to show depending on number of months displayed; if ($time != 'week' && $time != 'day') { $list_heading = $num_months <= 1 ? $current_date_header . $caption_text . "\n" : $current_month_header . '–' . $through_month_header . $caption_text; $list_heading = sprintf(__('Events in %s', 'my-calendar'), $list_heading); } else { $list_heading = jd_draw_template($values, stripslashes(get_option('mc_week_caption'))); } $h2 = apply_filters('mc_list_header_level', 'h2'); $my_calendar_body .= "<{$h2} class=\"heading my-calendar-{$time}\">{$list_heading}</{$h2}>\n"; } // If not a valid time or layout format, skip. if (in_array($format, array('calendar', 'mini', 'list')) && in_array($time, array('day', 'week', 'month', 'month+1'))) { $tr = apply_filters('mc_grid_week_wrapper', 'tr', $format); $th = apply_filters('mc_grid_header_wrapper', 'th', $format); $close_th = $th == 'th' ? 'th' : $th; $th .= $th == 'th' ? ' scope="col"' : ''; // If in a calendar format, print the headings of the days of the week if ($format == "list") { $my_calendar_body .= "<ul id='list-{$id}' class='mc-list'>"; } else { $my_calendar_body .= $tr == 'tr' ? "<thead>\n" : '<div class="mc-table-body">'; $my_calendar_body .= "<{$tr} class='mc-row'>\n"; for ($i = 0; $i <= 6; $i++) { if ($start_of_week == 0) { $class = $i < 6 && $i > 0 ? 'day-heading' : 'weekend-heading'; } else { $class = $i < 5 ? 'day-heading' : 'weekend-heading'; } $dayclass = strtolower(strip_tags($abbrevs[$i])); if ($class == 'weekend-heading' && get_option('mc_show_weekends') == 'true' || $class != 'weekend-heading') { $my_calendar_body .= "<{$th} class='{$class} {$dayclass}'>" . $name_days[$i] . "</{$close_th}>\n"; } } $my_calendar_body .= "\n</{$tr}>\n"; $my_calendar_body .= $tr == 'tr' ? "</thead>\n<tbody>" : ''; } $odd = 'odd'; // get and display all the events $show_all = false; // show all dates in list format. if ($no_events && $format == "list" && $show_all == false) { // if there are no events in list format, just display that info. $no_events = $content == '' ? __('There are no events scheduled during this period.', 'my-calendar') : $content; $my_calendar_body .= "<li class='mc-events no-events'>{$no_events}</li>"; } else { $start = strtotime($from); $end = strtotime($to); do { $date = date('Y-m-d', $start); $is_weekend = date('N', $start) < 6 ? false : true; if (get_option('mc_show_weekends') == 'true' || get_option('mc_show_weekends') != 'true' && !$is_weekend) { if (date('N', $start) == $start_of_week && $format != "list") { $my_calendar_body .= "<{$tr} class='mc-row'>"; } // date-based classes $monthclass = date('n', $start) == $c_month || $time != 'month' ? '' : 'nextmonth'; $dateclass = mc_dateclass(time() + $offset, $start); $dayclass = strtolower(date_i18n('D', $start)); $week_format = get_option('mc_week_format') == '' ? 'M j, \'y' : get_option('mc_week_format'); $week_date_format = date_i18n($week_format, $start); $thisday_heading = $time == 'week' ? "<small>{$week_date_format}</small>" : date('j', $start); $events = isset($event_array[$date]) ? $event_array[$date] : array(); $events_class = mc_events_class($events, $date); if (get_option('mc_list_javascript') != 1) { $is_anchor = "<button type='button' class='mc-text-button'>"; $is_close_anchor = "</button>"; } else { $is_anchor = $is_close_anchor = ""; } $td = apply_filters('mc_grid_day_wrapper', 'td', $format); if (!empty($events)) { $hide_nextmonth = apply_filters('mc_hide_nextmonth', false); if ($hide_nextmonth == true && $monthclass == 'nextmonth') { $event_output = ' '; } else { $event_output = my_calendar_draw_events($events, $format, $date, $time, $template); } if ($event_output === true) { $event_output = ' '; } if ($format == 'mini' && $event_output != '') { if (get_option('mc_open_day_uri') == 'true' || get_option('mc_open_day_uri') == 'false') { // yes, this is weird. it's from some old settings... $target = array('yr' => date('Y', $start), 'month' => date('m', $start), 'dy' => date('j', $start), 'time' => 'day'); if ($category != '') { $target['mcat'] = $category; } $day_url = mc_build_url($target, array('month', 'dy', 'yr', 'ltype', 'loc', 'mcat', 'cid', 'mc_id'), apply_filters('mc_modify_day_uri', get_option('mc_uri'))); $link = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? $day_url : '#'; } else { $atype = str_replace('anchor', '', get_option('mc_open_day_uri')); $ad = str_pad(date('j', $start), 2, '0', STR_PAD_LEFT); // need to match format in ID $am = str_pad($c_month, 2, '0', STR_PAD_LEFT); $date_url = mc_build_url(array('yr' => $c_year, 'month' => $c_month, 'dy' => date('j', $start)), array('month', 'dy', 'yr', 'ltype', 'loc', 'mcat', 'cid', 'mc_id'), get_option('mc_mini_uri')); $link = esc_url(get_option('mc_mini_uri') != '' ? $date_url . '#' . $atype . '-' . $c_year . '-' . $am . '-' . $ad : '#'); } $element = "a href='{$link}'"; $close = 'a'; $trigger = 'trigger'; } else { $element = 'span'; $close = 'span'; $trigger = ''; } // set up events if ($is_weekend && get_option('mc_show_weekends') == 'true' || !$is_weekend) { $weekend_class = $is_weekend ? 'weekend' : ''; if ($format == "list") { if (get_option('mc_show_list_info') == 'true') { $title = ' - ' . $is_anchor . "<span class='mc-list-details'>" . mc_list_title($events) . "</span>" . $is_close_anchor; } else { $title = ''; } if ($event_output != '') { $my_calendar_body .= "\r\n\t\t\t\t\t\t\t\t\t\t\t\t<li id='{$format}-{$date}' class='mc-events " . esc_attr("{$dayclass} {$dateclass} {$events_class} {$odd}") . "'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<strong class=\"event-date\">{$is_anchor}" . date_i18n(apply_filters('mc_date_format', $date_format, 'list'), $start) . "{$is_close_anchor}" . "{$title}</strong>" . $event_output . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t</li>"; $odd = $odd == 'odd' ? 'even' : 'odd'; } } else { $my_calendar_body .= "\r\n\t\t\t\t\t\t\t\t\t\t\t\t<{$td} id='{$format}-{$date}' class='" . esc_attr("{$dayclass} {$dateclass} {$weekend_class} {$monthclass} {$events_class}") . " day-with-date'>" . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<{$element} class='mc-date {$trigger}'><span aria-hidden='true'>{$thisday_heading}</span><span class='screen-reader-text'>" . date_i18n(get_option('mc_date_format'), strtotime($date)) . "</span></{$close}>" . $event_output . "\r\n\t\t\t\t\t\t\t\t\t\t\t\t</{$td}>\n"; } } } else { // set up no events if ($format != "list") { $weekend_class = $is_weekend ? 'weekend' : ''; $my_calendar_body .= "\r\n\t\t\t\t\t\t\t\t\t\t\t\t<{$td} class='no-events {$dayclass} {$dateclass} {$weekend_class} {$monthclass} day-with-date'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class='mc-date no-events'><span aria-hidden='true'>{$thisday_heading}</span><span class='screen-reader-text'>" . date_i18n(get_option('mc_date_format'), strtotime($date)) . "</span></span>\r\n\t\t\t\t\t\t\t\t\t\t\t\t</{$td}>\n"; } else { if ($show_all == true) { $my_calendar_body .= "\r\n\t\t\t\t\t\t\t\t\t\t\t<li id='{$format}-{$date}' class='no-events {$dayclass} {$dateclass} {$events_class} {$odd}'>\r\n\t\t\t\t\t\t\t\t\t\t\t\t<strong class=\"event-date\">{$is_anchor}" . date_i18n($date_format, $start) . "{$is_close_anchor}</strong></li>"; $odd = $odd == 'odd' ? 'even' : 'odd'; } } } if (date('N', $start) == $end_of_week && $format != "list") { $my_calendar_body .= "</{$tr}>\n"; // end of 'is beginning of week' } } $start = strtotime("+1 day", $start); } while ($start <= $end); } $table = apply_filters('mc_grid_wrapper', 'table', $format); $end = $table == 'table' ? "\n</tbody>\n</table>" : "</div></{$table}>"; $my_calendar_body .= $format == "list" ? "\n</ul>" : $end; } else { // only show error message if user has permissions if (current_user_can('manage_options')) { if (!in_array($format, array('list', 'calendar', 'mini'))) { $yours = sprintf(esc_html__("Your format: %s", 'my-calendar'), $format); $my_calendar_body .= "<p class='mc-error-format'>" . __("Unrecognized calendar format. Please use one of 'list', 'calendar', or 'mini'.", 'my-calendar') . "{$yours}</p>"; } if (!in_array($time, array('day', 'week', 'month', 'month+1'))) { $yours = sprintf(esc_html__("Your time period: %s", 'my-calendar'), $time); $my_calendar_body .= "<p class='mc-error-time'>" . __("Unrecognized calendar time period. Please use one of 'day', 'week', or 'month'.", 'my-calendar') . "{$yours}</p>"; } } } $my_calendar_body .= $mc_bottomnav; } } // The actual printing is done by the shortcode function. $my_calendar_body .= apply_filters('mc_after_calendar', '', $args); if ($site) { restore_current_blog(); } return $mc_wrapper . apply_filters('my_calendar_body', $my_calendar_body) . $mc_closer; }