function mcs_show_receipt()
{
    $url = plugin_dir_url(__FILE__);
    $header = '<!DOCTYPE html>
<html dir="' . is_rtl() ? 'rtl' : 'ltr' . '" lang="' . get_bloginfo('language') . '">
<head>
	<meta charset="' . get_bloginfo('charset') . '" />
	<meta name="viewport" content="width=device-width" />
	<title>' . get_bloginfo('name') . ' - ' . __('My Calendar Submissions: Receipt', 'my-calendar') . '</title>
	<meta name="generator" content="My Calendar for WordPress" />
	<meta name="robots" content="noindex,nofollow" />';
    if (function_exists('mc_file_exists') && mc_file_exists('mcs-receipt.css')) {
        $stylesheet = mc_get_file('mcs-receipt.css', 'url');
    } else {
        $stylesheet = $url . "css/mcs-receipt.css";
    }
    $header .= "\n\t<!-- Copy mcs-receipt.css to your theme directory if you wish to replace the default print styles -->\n\t<link rel='stylesheet' href='{$stylesheet}' type='text/css' media='screen,print' />\n</head>\n<body>\n\t<div class='mcs-receipt'>\n";
    $logo = apply_filters('mcs_receipt_logo', sprintf('<h1><a href="%1$s">%2$s</a></h1>', home_url(), get_bloginfo('blogname')));
    $footer = "</div>\n</body>\n</html>";
    // verify validity of viewer
    if (isset($_GET['mcs_receipt']) && isset($_COOKIE['mcs_receipt']) && $_COOKIE['mcs_receipt'] == 'true') {
        global $wpdb;
        $receipt_id = $_GET['mcs_receipt'];
        $query = "SELECT * FROM " . my_calendar_payments_table() . " WHERE item_number = 1 AND txn_id = %s";
        $results = $wpdb->get_row($wpdb->prepare($query, $receipt_id), ARRAY_A);
        $template = '
			<h2>Payment Key Purchase Receipt</h2>
			
			<strong>Purchased By</strong><span> {first_name} {last_name}</span>
			<strong>Transaction ID</strong><span> {txn_id}</span>
			<strong>Payment Key</strong><span> {hash}</span>
			<strong>Payer Email</strong><span> {payer_email}</span>
			
			<strong>Amount Paid</strong><span> ${price}</span>
			<strong>Submissions Granted</strong><span> {total}</span>
			<strong>Submissions Remaining</strong><span> {quantity}</span>			
			<strong>Transaction Date</strong><span> {transaction_date}</span>
			<em><a href="javascript:window.print()">Print</a></em>';
        $template = apply_filters('mcs_receipt_template', $template, $results);
        $wrapper = apply_filters('mcs_receipt_header', $header, $receipt_id);
        $wrapper .= $logo;
        $wrapper .= jd_draw_template($results, $template);
        $wrapper .= apply_filters('mcs_receipt_header', $footer, $receipt_id);
        echo $wrapper;
        exit;
        // require entry of email address to view receipt... > place email into session data to avoid doing this first time?
        // display message noting that viewer will need to enter email to view receipt.
    } else {
        if (isset($_GET['mcs_receipt'])) {
            $body = "<form action='' method='POST'>\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<label for='mcs-email'>Your purchase email</label>: <input type='email' name='mcs_email' id='mcs-email' /> <input type='submit' name='mcs-verify' value='Verify' />\n\t\t\t\t\t</div>\n\t\t\t\t</form>";
            echo $header . $body . $footer;
            exit;
        }
    }
}
Ejemplo n.º 2
0
function mc_register_styles()
{
    global $wp_query;
    $stylesheet = mc_get_style_path(get_option('mc_css_file'), 'url');
    wp_register_style('my-calendar-style', $stylesheet);
    $admin_stylesheet = plugins_url('css/mc-admin.css', __FILE__);
    wp_register_style('my-calendar-admin-style', $admin_stylesheet);
    if (current_user_can('mc_manage_events')) {
        wp_enqueue_style('my-calendar-admin-style');
    }
    $this_post = $wp_query->get_queried_object();
    $id = is_object($this_post) && isset($this_post->ID) ? $this_post->ID : false;
    $js_array = get_option('mc_show_js') != '' ? explode(",", get_option('mc_show_js')) : array();
    $css_array = get_option('mc_show_css') != '' ? explode(",", get_option('mc_show_css')) : array();
    // check whether any scripts are actually enabled.
    if (get_option('mc_calendar_javascript') != 1 || get_option('mc_list_javascript') != 1 || get_option('mc_mini_javascript') != 1 || get_option('mc_ajax_javascript') != 1) {
        if (@in_array($id, $js_array) || get_option('mc_show_js') == '') {
            wp_enqueue_script('jquery');
            if (get_option('mc_gmap') == 'true') {
                wp_register_script('gmaps', "//maps.google.com/maps/api/js?sensor=true");
                wp_register_script('gmap3', plugins_url('js/gmap3.min.js', __FILE__), array('jquery'));
                wp_enqueue_script('gmaps');
                wp_enqueue_script('gmap3');
            }
        }
    }
    if (get_option('mc_use_styles') != 'true') {
        if (@in_array($id, $css_array) || get_option('mc_show_css') == '') {
            wp_enqueue_style('my-calendar-style');
        }
    }
    if (mc_is_tablet() && mc_file_exists('mc-tablet.css')) {
        $tablet = mc_get_file('mc-tablet.css');
        wp_register_style('my-calendar-tablet-style', $tablet);
        wp_enqueue_style('my-calendar-tablet-style');
    }
    if (mc_is_mobile() && mc_file_exists('mc-mobile.css')) {
        $mobile = mc_get_file('mc-mobile.css');
        wp_register_style('my-calendar-mobile-style', $mobile);
        wp_enqueue_style('my-calendar-mobile-style');
    }
    if (function_exists('mcs_submissions')) {
        $mcs = plugins_url('/my-calendar-submissions/mcs-styles.css');
        $mcs_ui = plugins_url('/my-calendar-submissions/css/smoothness/jquery-ui-1.8.23.custom.css');
        wp_register_style('my-calendar-submissions-ui-style', $mcs_ui);
        wp_enqueue_style('my-calendar-submissions-ui-style');
        wp_register_style('my-calendar-submissions-style', $mcs);
        wp_enqueue_style('my-calendar-submissions-style');
    }
}
Ejemplo n.º 3
0
function my_calendar_print()
{
    $url = plugin_dir_url(__FILE__);
    $time = isset($_GET['time']) ? $_GET['time'] : 'month';
    $category = isset($_GET['mcat']) ? $_GET['mcat'] : '';
    // these are sanitized elsewhere
    $ltype = isset($_GET['ltype']) ? $_GET['ltype'] : '';
    $lvalue = isset($_GET['lvalue']) ? $_GET['lvalue'] : '';
    header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset'));
    echo '<!DOCTYPE html>
<!--[if IE 7]>
<html id="ie7" dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '">
<![endif]-->
<!--[if IE 8]>
<html id="ie8" dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '">
<![endif]-->
<!--[if !(IE 6) | !(IE 7) | !(IE 8) ]><!-->
<html dir="' . get_bloginfo('text_direction') . '" lang="' . get_bloginfo('language') . '">
<!--<![endif]-->
<head>
<meta charset="' . get_bloginfo('charset') . '" />
<meta name="viewport" content="width=device-width" />
<title>' . get_bloginfo('name') . ' - ' . __('Calendar: Print View', 'my-calendar') . '</title>
<meta name="generator" content="My Calendar for WordPress" />
<meta name="robots" content="noindex,nofollow" />';
    if (mc_file_exists('css/mc-print.css')) {
        $stylesheet = mc_get_file('css/mc-print.css', 'url');
    } else {
        $stylesheet = $url . "css/mc-print.css";
    }
    echo "\n<!-- Copy mc-print.css to your theme directory if you wish to replace the default print styles -->\n<link rel='stylesheet' href='{$stylesheet}' type='text/css' media='screen,print' />\n</head>\n<body>\n";
    echo my_calendar('print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, '', '');
    $return_url = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? get_option('mc_uri') : home_url();
    $add = $_GET;
    unset($add['cid']);
    unset($add['feed']);
    $return_url = mc_build_url($add, array('feed', 'cid'), $return_url);
    echo "<p class='return'><a href='{$return_url}'>" . __('Return to site', 'my-calendar') . "</a></p>";
    echo '
</body>
</html>';
}
function mc_manage_categories()
{
    global $wpdb;
    $mcdb = $wpdb;
    ?>
	<h2><?php 
    _e('Manage Categories', 'my-calendar');
    ?>
</h2><?php 
    $co = !isset($_GET['co']) ? 1 : (int) $_GET['co'];
    switch ($co) {
        case 1:
            $cat_order = 'category_id';
            break;
        case 2:
            $cat_order = 'category_name';
            break;
        default:
            $cat_order = 'category_id';
    }
    // We pull the categories from the database
    $categories = $mcdb->get_results("SELECT * FROM " . my_calendar_categories_table() . " ORDER BY {$cat_order} ASC");
    if (!empty($categories)) {
        ?>
		<table class="widefat page fixed mc-categories" id="my-calendar-admin-table">
		<thead>
		<tr>
			<th scope="col"><?php 
        echo $co == 2 ? "<a href='" . admin_url("admin.php?page=my-calendar-categories&amp;co=1") . "'>" : '';
        _e('ID', 'my-calendar');
        echo $co == 2 ? '</a>' : '';
        ?>
</th>
			<th scope="col"><?php 
        echo $co == 1 ? "<a href='" . admin_url("admin.php?page=my-calendar-categories&amp;co=2") . "'>" : '';
        _e('Category Name', 'my-calendar');
        echo $co == 1 ? '</a>' : '';
        ?>
</th>
			<th scope="col"><?php 
        _e('Color/Icon', 'my-calendar');
        ?>
</th>
			<th scope="col"><?php 
        _e('Private', 'my-calendar');
        ?>
</th>
			<th scope="col"><?php 
        _e('Edit', 'my-calendar');
        ?>
</th>
			<th scope="col"><?php 
        _e('Delete', 'my-calendar');
        ?>
</th>
		</tr>
		</thead>
		<?php 
        $class = '';
        foreach ($categories as $cat) {
            $class = $class == 'alternate' ? '' : 'alternate';
            $icon_src = mc_file_exists($cat->category_icon) ? mc_get_file($cat->category_icon, 'url') : plugins_url('my-calendar/images/icons/' . $cat->category_icon);
            $background = strpos($cat->category_color, '#') !== 0 ? '#' : '' . $cat->category_color;
            $foreground = mc_inverse_color($background);
            ?>
		<tr class="<?php 
            echo $class;
            ?>
">
			<th scope="row"><?php 
            echo $cat->category_id;
            ?>
</th>
			<td><?php 
            echo stripslashes($cat->category_name);
            if ($cat->category_id == get_option('mc_default_category')) {
                echo ' ' . __('(Default)');
            }
            if ($cat->category_id == get_option('mc_skip_holidays_category')) {
                echo ' ' . __('(Holiday)');
            }
            ?>
</td>
			<td style="background-color:<?php 
            echo $background;
            ?>
;color: <?php 
            echo $foreground;
            ?>
"><img src="<?php 
            echo $icon_src;
            ?>
" alt=""/> <?php 
            echo $background;
            ?>
</td>
			<td><?php 
            echo $cat->category_private == 1 ? __('Yes', 'my-calendar') : __('No', 'my-calendar');
            ?>
</td>
			<td><a
				href="<?php 
            echo admin_url("admin.php?page=my-calendar-categories&amp;mode=edit&amp;category_id={$cat->category_id}");
            ?>
"
				class='edit'><?php 
            _e('Edit', 'my-calendar');
            ?>
</a></td><?php 
            if ($cat->category_id == 1) {
                echo '<td>' . __('N/A', 'my-calendar') . '</td>';
            } else {
                ?>
				<td><a
					href="<?php 
                echo admin_url("admin.php?page=my-calendar-categories&amp;mode=delete&amp;category_id={$cat->category_id}");
                ?>
"
					class="delete"
					onclick="return confirm('<?php 
                _e('Are you sure you want to delete this category?', 'my-calendar');
                ?>
')"><?php 
                _e('Delete', 'my-calendar');
                ?>
</a>
				</td><?php 
            }
            ?>
			</tr><?php 
        }
        ?>
		</table><?php 
    } else {
        echo '<p>' . __('There are no categories in the database - or something has gone wrong!', 'my-calendar') . '</p>';
    }
}
function my_calendar_upcoming_events($before = 'default', $after = 'default', $type = 'default', $category = 'default', $template = 'default', $substitute = '', $order = 'asc', $skip = 0, $show_today = 'yes', $author = 'default', $host = 'default', $ltype = '', $lvalue = '')
{
    global $default_template;
    $output = '';
    $widget_defaults = (array) get_option('mc_widget_defaults');
    $display_upcoming_type = $type == 'default' ? $widget_defaults['upcoming']['type'] : $type;
    $display_upcoming_type = $display_upcoming_type == '' ? 'event' : $display_upcoming_type;
    // Get number of units we should go into the future
    $after = $after == 'default' ? $widget_defaults['upcoming']['after'] : $after;
    $after = $after == '' ? 10 : $after;
    // Get number of units we should go into the past
    $before = $before == 'default' ? $widget_defaults['upcoming']['before'] : $before;
    $before = $before == '' ? 0 : $before;
    $category = $category == 'default' ? '' : $category;
    // allow reference by file to external template.
    if ($template != '' && mc_file_exists(sanitize_file_name($template))) {
        $template = @file_get_contents(mc_get_file(sanitize_file_name($template)));
    }
    $template = $template == 'default' ? $widget_defaults['upcoming']['template'] : $template;
    $template = $template == '' ? $default_template : $template;
    $no_event_text = $substitute == '' ? $widget_defaults['upcoming']['text'] : $substitute;
    $header = "<ul id='upcoming-events'>";
    $footer = "</ul>";
    if ($display_upcoming_type == "days" || $display_upcoming_type == "month" || $display_upcoming_type == 'month+1' || $display_upcoming_type == "year") {
        $temp_array = array();
        if ($display_upcoming_type == "days") {
            $from = date('Y-m-d', strtotime("-{$before} days"));
            $to = date('Y-m-d', strtotime("+{$after} days"));
        }
        if ($display_upcoming_type == "month") {
            $from = date('Y-m-1');
            $to = date('Y-m-t');
        }
        /* Yes, this is crude. But sometimes simplicity works best. There are only 12 possibilities, after all. */
        if ($display_upcoming_type == 'month+1') {
            $from = date('Y-m-1', strtotime('+1 month'));
            $to = date('Y-m-t', strtotime('+1 month'));
        }
        if ($display_upcoming_type == 'month+2') {
            $from = date('Y-m-1', strtotime('+2 month'));
            $to = date('Y-m-t', strtotime('+2 month'));
        }
        if ($display_upcoming_type == 'month+3') {
            $from = date('Y-m-1', strtotime('+3 month'));
            $to = date('Y-m-t', strtotime('+3 month'));
        }
        if ($display_upcoming_type == 'month+4') {
            $from = date('Y-m-1', strtotime('+4 month'));
            $to = date('Y-m-t', strtotime('+4 month'));
        }
        if ($display_upcoming_type == 'month+5') {
            $from = date('Y-m-1', strtotime('+5 month'));
            $to = date('Y-m-t', strtotime('+5 month'));
        }
        if ($display_upcoming_type == 'month+6') {
            $from = date('Y-m-1', strtotime('+6 month'));
            $to = date('Y-m-t', strtotime('+6 month'));
        }
        if ($display_upcoming_type == 'month+7') {
            $from = date('Y-m-1', strtotime('+7 month'));
            $to = date('Y-m-t', strtotime('+7 month'));
        }
        if ($display_upcoming_type == 'month+8') {
            $from = date('Y-m-1', strtotime('+8 month'));
            $to = date('Y-m-t', strtotime('+8 month'));
        }
        if ($display_upcoming_type == 'month+9') {
            $from = date('Y-m-1', strtotime('+9 month'));
            $to = date('Y-m-t', strtotime('+9 month'));
        }
        if ($display_upcoming_type == 'month+10') {
            $from = date('Y-m-1', strtotime('+10 month'));
            $to = date('Y-m-t', strtotime('+10 month'));
        }
        if ($display_upcoming_type == 'month+11') {
            $from = date('Y-m-1', strtotime('+11 month'));
            $to = date('Y-m-t', strtotime('+11 month'));
        }
        if ($display_upcoming_type == 'month+12') {
            $from = date('Y-m-1', strtotime('+12 month'));
            $to = date('Y-m-t', strtotime('+12 month'));
        }
        if ($display_upcoming_type == "year") {
            $from = date('Y-1-1');
            $to = date('Y-12-31');
        }
        $from = apply_filters('mc_upcoming_date_from', $from);
        $to = apply_filters('mc_upcoming_date_to', $to);
        $event_array = my_calendar_events($from, $to, $category, $ltype, $lvalue, 'upcoming', $author, $host);
        if (count($event_array) != 0) {
            foreach ($event_array as $key => $value) {
                if (is_array($value)) {
                    foreach ($value as $k => $v) {
                        $event = mc_create_tags($v);
                        if ($v->category_private == 1 && !is_user_logged_in()) {
                            // this event is private.
                        } else {
                            $temp_array[] = $event;
                        }
                    }
                }
            }
        }
        $i = 0;
        $last_item = $last_id = $last_date = '';
        $skips = array();
        foreach (reverse_array($temp_array, true, $order) as $details) {
            $item = jd_draw_template($details, $template);
            if ($i < $skip && $skip != 0) {
                $i++;
            } else {
                // if same group, and same date, use it.
                if ($details['group'] !== $last_id || $details['date'] == $last_date || $details['group'] == '0') {
                    if (!in_array($details['dateid'], $skips)) {
                        $output .= $item == $last_item ? '' : "<li>{$item}</li>";
                    }
                }
            }
            $skips[] = $details['dateid'];
            // prevent the same event from showing more than once.
            $last_id = $details['group'];
            // prevent group events from displaying in a row. Not if there are intervening events.
            $last_item = $item;
            $last_date = $details['date'];
        }
    } else {
        $caching = apply_filters('mc_cache_enabled', false);
        if ($caching) {
            $cache = get_transient('mc_cache_upcoming');
            $output .= "<!-- Cached -->";
            if ($cache) {
                if (isset($cache[$category])) {
                    $events = $cache[$category];
                } else {
                    $events = mc_get_all_events($category, $before, $after, $show_today, $author, $host, $ltype, $lvalue);
                    $cache[$category] = $events;
                    set_transient('mc_cache_upcoming', $cache, 60 * 30);
                }
            } else {
                $events = mc_get_all_events($category, $before, $after, $show_today, $author, $host, $ltype, $lvalue);
                $cache[$category] = $events;
                set_transient('mc_cache_upcoming', $cache, 60 * 30);
            }
        } else {
            $events = mc_get_all_events($category, $before, $after, $show_today, $author, $host, $ltype, $lvalue);
            // grab all events within reasonable proximity
        }
        $holiday_array = array();
        if (!get_option('mc_skip_holidays_category') || get_option('mc_skip_holidays_category') == '') {
            $holidays = array();
        } else {
            $holidays = mc_get_all_holidays($before, $after, $show_today);
            $holiday_array = mc_set_date_array($holidays);
        }
        if (is_array($events) && !empty($events)) {
            $event_array = mc_set_date_array($events);
            if (is_array($holidays) && count($holidays) > 0) {
                $event_array = mc_holiday_limit($event_array, $holiday_array);
                // if there are holidays, rejigger.
            }
        }
        if (!empty($event_array)) {
            $output .= mc_produce_upcoming_events($event_array, $template, 'list', $order, $skip, $before, $after, $show_today);
        } else {
            $output = '';
        }
    }
    if ($output != '') {
        $output = $header . $output . $footer;
        return $output;
    } else {
        return stripcslashes($no_event_text);
    }
}
function mc_register_styles()
{
    global $wp_query;
    $stylesheet = apply_filters('mc_registered_stylesheet', mc_get_style_path(get_option('mc_css_file'), 'url'));
    wp_register_style('my-calendar-reset', plugins_url('css/reset.css', __FILE__));
    wp_register_style('my-calendar-style', $stylesheet, array('dashicons', 'my-calendar-reset'));
    $admin_stylesheet = plugins_url('css/mc-admin.css', __FILE__);
    wp_register_style('my-calendar-admin-style', $admin_stylesheet);
    if (current_user_can('mc_manage_events')) {
        wp_enqueue_style('my-calendar-admin-style');
    }
    $this_post = $wp_query->get_queried_object();
    $id = is_object($this_post) && isset($this_post->ID) ? $this_post->ID : false;
    $js_array = get_option('mc_show_js') != '' ? explode(",", get_option('mc_show_js')) : array();
    $css_array = get_option('mc_show_css') != '' ? explode(",", get_option('mc_show_css')) : array();
    // check whether any scripts are actually enabled.
    if (get_option('mc_calendar_javascript') != 1 || get_option('mc_list_javascript') != 1 || get_option('mc_mini_javascript') != 1 || get_option('mc_ajax_javascript') != 1) {
        if (@in_array($id, $js_array) || get_option('mc_show_js') == '' || is_singular('mc-events')) {
            wp_enqueue_script('jquery');
            if (get_option('mc_gmap') == 'true') {
                $api_key = get_option('mc_gmap_api_key');
                if ($api_key) {
                    wp_enqueue_script('gmaps', "https://maps.googleapis.com/maps/api/js?key={$api_key}");
                    wp_enqueue_script('gmap3', plugins_url('js/gmap3.min.js', __FILE__), array('jquery'));
                }
            }
        }
    }
    if (get_option('mc_use_styles') != 'true') {
        if (@in_array($id, $css_array) || get_option('mc_show_css') == '') {
            wp_enqueue_style('my-calendar-style');
        }
    }
    if (mc_is_tablet() && mc_file_exists('mc-tablet.css')) {
        $tablet = mc_get_file('mc-tablet.css');
        wp_register_style('my-calendar-tablet-style', $tablet);
        wp_enqueue_style('my-calendar-tablet-style');
    }
    if (mc_is_mobile() && mc_file_exists('mc-mobile.css')) {
        $mobile = mc_get_file('mc-mobile.css');
        wp_register_style('my-calendar-mobile-style', $mobile);
        wp_enqueue_style('my-calendar-mobile-style');
    }
}
function my_calendar_todays_events($category = 'default', $template = 'default', $substitute = '', $author = 'all', $host = 'all', $date = false, $site = false)
{
    if ($site) {
        $site = $site == 'global' ? BLOG_ID_CURRENT_SITE : $site;
        switch_to_blog($site);
    }
    $caching = apply_filters('mc_cache_enabled', false);
    $todays_cache = $caching ? get_transient('mc_todays_cache') : '';
    if ($caching && is_array($todays_cache) && @$todays_cache[$category]) {
        return @$todays_cache[$category];
    }
    $args = array('category' => $category, 'template' => $template, 'substitute' => $substitute, 'author' => $author, 'host' => $host, 'date' => $date);
    $hash = md5(implode(',', $args));
    global $default_template;
    $output = '';
    // allow reference by file to external template.
    if ($template != '' && mc_file_exists(sanitize_file_name($template))) {
        $template = @file_get_contents(mc_get_file(sanitize_file_name($template)));
    }
    $defaults = get_option('mc_widget_defaults');
    $template = $template == 'default' ? $defaults['today']['template'] : $template;
    $template = $template == '' ? $default_template : $template;
    if (mc_key_exists($template)) {
        $template = mc_get_custom_template($template);
    }
    $category = $category == 'default' ? $defaults['today']['category'] : $category;
    $no_event_text = $substitute == '' ? $defaults['today']['text'] : $substitute;
    if ($date) {
        $from = $to = date('Y-m-d', strtotime($date));
    } else {
        $from = $to = date('Y-m-d', current_time('timestamp'));
    }
    $events = my_calendar_events($from, $to, $category, '', '', 'upcoming', $author, $host, '', $site);
    $today = isset($events[$from]) ? $events[$from] : false;
    $header = "<ul id='todays-events-{$hash}' class='todays-events'>";
    $footer = "</ul>";
    $groups = $todays_events = array();
    // quick loop through all events today to check for holidays
    if (is_array($today)) {
        foreach ($today as $e) {
            if ($e->category_private == 1 && !is_user_logged_in()) {
            } else {
                if (!in_array($e->event_group_id, $groups)) {
                    $event_details = mc_create_tags($e);
                    $ts = $e->ts_occur_begin;
                    $end = $e->ts_occur_end;
                    $now = current_time('timestamp');
                    $category = 'mc_' . sanitize_title($e->category_name);
                    if ($ts < $now && $end > $now) {
                        $class = 'on-now';
                    } else {
                        if ($now < $ts) {
                            $class = 'future-event';
                        } else {
                            if ($now > $ts) {
                                $class = 'past-event';
                            }
                        }
                    }
                    $prepend = apply_filters('mc_todays_events_before', "<li class='{$class} {$category}'>", $class, $category);
                    $append = apply_filters('mc_todays_events_after', "</li>");
                    if (get_option('mc_event_approve') == 'true') {
                        if ($e->event_approved != 0) {
                            $todays_events[$ts][] = $prepend . jd_draw_template($event_details, $template) . $append;
                        }
                    } else {
                        $todays_events[$ts][] = $prepend . jd_draw_template($event_details, $template) . $append;
                    }
                }
            }
        }
        $todays_events = apply_filters('mc_event_today', $todays_events, $events);
        foreach ($todays_events as $k => $t) {
            foreach ($t as $now) {
                $output .= $now;
            }
        }
        if (count($events) != 0) {
            $return = apply_filters('mc_todays_events_header', $header) . $output . apply_filters('mc_todays_events_footer', $footer);
        } else {
            $return = stripcslashes($no_event_text);
        }
        $time = strtotime(date('Y-m-d H:m:s', current_time('timestamp'))) - strtotime(date('Y-m-d', current_time('timestamp')));
        $time_remaining = 24 * 60 * 60 - $time;
        $todays_cache[$category] = $caching ? $return : '';
        if ($caching) {
            set_transient('mc_todays_cache', $todays_cache, $time_remaining);
        }
    } else {
        $return = stripcslashes($no_event_text);
    }
    if ($site) {
        restore_current_blog();
    }
    return get_option('mc_process_shortcodes') == 'true' ? do_shortcode($return) : $return;
}
function my_calendar_print()
{
    $url = plugin_dir_url(__FILE__);
    $time = isset($_GET['time']) ? $_GET['time'] : 'month';
    $category = isset($_GET['mcat']) ? $_GET['mcat'] : '';
    // these are sanitized elsewhere
    $ltype = isset($_GET['ltype']) ? $_GET['ltype'] : '';
    $lvalue = isset($_GET['lvalue']) ? $_GET['lvalue'] : '';
    header('Content-Type: ' . get_bloginfo('html_type') . '; charset=' . get_bloginfo('charset'));
    if (mc_file_exists('css/mc-print.css')) {
        $stylesheet = mc_get_file('css/mc-print.css', 'url');
    } else {
        $stylesheet = $url . "css/mc-print.css";
    }
    $rtl = is_rtl() ? 'rtl' : 'ltr';
    $head = '<!DOCTYPE html>
<html dir="' . $rtl . '" lang="' . get_bloginfo('language') . '">
<!--<![endif]-->
<head>
<meta charset="' . get_bloginfo('charset') . '" />
<meta name="viewport" content="width=device-width" />
<title>' . get_bloginfo('name') . ' - ' . __('Calendar: Print View', 'my-calendar') . '</title>
<meta name="generator" content="My Calendar for WordPress" />
<meta name="robots" content="noindex,nofollow" />
<!-- Copy mc-print.css to your theme directory if you wish to replace the default print styles -->
<link rel="stylesheet" href="' . $stylesheet . '" type="text/css" media="screen,print" />
</head>
<body>';
    echo $head;
    echo my_calendar('print', 'calendar', $category, $time, $ltype, $lvalue, 'mc-print-view', '', '', null, null, 'none', 'none');
    $return_url = get_option('mc_uri') != '' && !is_numeric(get_option('mc_uri')) ? get_option('mc_uri') : home_url();
    $return_url = apply_filters('mc_print_return_url', $return_url, $category, $time, $ltype, $lvalue);
    if (isset($_GET['href'])) {
        $ref_url = esc_url(urldecode($_GET['href']));
        if ($ref_url) {
            $return_url = $ref_url;
        }
    }
    $add = array_map('esc_sql', $_GET);
    unset($add['cid']);
    unset($add['feed']);
    unset($add['href']);
    $return_url = mc_build_url($add, array('feed', 'cid', 'href'), $return_url);
    echo "<p class='return'><a href='{$return_url}'>" . __('Return to calendar', 'my-calendar') . "</a></p>";
    echo '
</body>
</html>';
}