/** * Returns a non-associative array of four links for the month view of the * calendar: * previous year, previous month, next month, and next year. * Each element is an associative array containing the link's enabled status * ['enabled'], CSS class ['class'], text ['text'] and value to assign to * link's href ['href']. * * @param array $args Current request arguments * * @return array Array of links */ function get_month_pagination_links($args) { $links = array(); $local_date = Ai1ec_Time_Utility::gmt_to_local($args['exact_date']); $bits = Ai1ec_Time_Utility::gmgetdate($local_date); // ================= // = Previous year = // ================= // Align date to first of month, month offset applied, 1 year behind. $local_date = gmmktime(0, 0, 0, $bits['mon'] + $args['month_offset'], 1, $bits['year'] - 1); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-prev-year', 'text' => '<i class="icon-double-angle-left"></i> ' . Ai1ec_Time_Utility::date_i18n('Y', $local_date, true), 'href' => $href->generate_href()); // ================== // = Previous month = // ================== // Align date to first of month, month offset applied, 1 month behind. $local_date = gmmktime(0, 0, 0, $bits['mon'] + $args['month_offset'] - 1, 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-prev-month', 'text' => '<i class="icon-angle-left"></i> ' . Ai1ec_Time_Utility::date_i18n('M', $local_date, true), 'href' => $href->generate_href()); // ====================== // = Minical datepicker = // ====================== // Align date to first of month, month offset applied. $local_date = gmmktime(0, 0, 0, $bits['mon'] + $args['month_offset'], 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $links[] = Ai1ec_View_Factory::create_datepicker_link($args, $args['exact_date']); // ============== // = Next month = // ============== // Align date to first of month, month offset applied, 1 month ahead. $local_date = gmmktime(0, 0, 0, $bits['mon'] + $args['month_offset'] + 1, 1, $bits['year']); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-next-month', 'text' => Ai1ec_Time_Utility::date_i18n('M', $local_date, true) . ' <i class="icon-angle-right"></i>', 'href' => $href->generate_href()); // ============= // = Next year = // ============= // Align date to first of month, month offset applied, 1 year ahead. $local_date = gmmktime(0, 0, 0, $bits['mon'] + $args['month_offset'], 1, $bits['year'] + 1); $args['exact_date'] = Ai1ec_Time_Utility::local_to_gmt($local_date); $href = Ai1ec_View_Factory::create_href_helper_instance($args); $links[] = array('enabled' => true, 'class' => 'ai1ec-next-year', 'text' => Ai1ec_Time_Utility::date_i18n('Y', $local_date, true) . ' <i class="icon-double-angle-right"></i>', 'href' => $href->generate_href()); return $links; }
?> " <?php echo $data_type; ?> > <?php if ($show_year_in_agenda_dates) { ?> <?php echo Ai1ec_Time_Utility::date_i18n('F j, Y (l)', $timestamp); ?> <?php } else { ?> <?php echo Ai1ec_Time_Utility::date_i18n('F j (l)', $timestamp); ?> <?php } ?> </a><!--/.ai1ec-load-view--> </div><!--/.ai1ec-date-title--> <div class="ai1ec-date-events"> <?php foreach ($date_info['events'] as $category) { ?> <?php foreach ($category as $event) { ?> <div class="clearfix ai1ec-event ai1ec-event-id-<?php
echo Ai1ec_Time_Utility::date_i18n('M', $timestamp, true); ?> </div> <div class="ai1ec-day"><?php echo Ai1ec_Time_Utility::date_i18n('j', $timestamp, true); ?> </div> <div class="ai1ec-weekday"><?php echo Ai1ec_Time_Utility::date_i18n('D', $timestamp, true); ?> </div> <?php if ($show_year_in_agenda_dates) { ?> <div class="ai1ec-year"><?php echo Ai1ec_Time_Utility::date_i18n('Y', $timestamp, true); ?> </div> <?php } ?> </a><!--/.ai1ec-date-title--> <div class="ai1ec-date-events"> <?php foreach ($date_info['events'] as $category) { ?> <?php foreach ($category as $event) { ?> <div class="ai1ec-event ai1ec-event-id-<?php
/** * Return the embedded day view of the calendar, optionally filtered by * event categories and tags. * * @param array $args associative array with any of these elements: * int oneday_offset => specifies which day to display relative to the * current day * array cat_ids => restrict events returned to the given set of * event category slugs * array tag_ids => restrict events returned to the given set of * event tag names * array post_ids => restrict events returned to the given set of * post IDs * * @return string returns string of view output */ function get_oneday_view($args) { global $ai1ec_view_helper, $ai1ec_events_helper, $ai1ec_calendar_helper, $ai1ec_settings; $defaults = array('oneday_offset' => 0, 'cat_ids' => array(), 'tag_ids' => array(), 'post_ids' => array(), 'exact_date' => Ai1ec_Time_Utility::current_time()); $args = wp_parse_args($args, $defaults); // Localize requested date and get components. $local_date = Ai1ec_Time_Utility::gmt_to_local($args['exact_date']); $bits = Ai1ec_Time_Utility::gmgetdate($local_date); // Apply day offset. $day_shift = 0 + $args['oneday_offset']; // Now align date to start of day (midnight). $local_date = gmmktime(0, 0, 0, $bits['mon'], $bits['mday'] + $day_shift, $bits['year']); $cell_array = $ai1ec_calendar_helper->get_oneday_cell_array($local_date, array('cat_ids' => $args['cat_ids'], 'tag_ids' => $args['tag_ids'], 'post_ids' => $args['post_ids'])); // Create pagination links. $pagination_links = $ai1ec_calendar_helper->get_oneday_pagination_links($args); $pagination_links = $ai1ec_view_helper->get_theme_view('pagination.php', array('links' => $pagination_links, 'data_type' => $args['data_type'])); $date_format = Ai1ec_Meta::get_option('date_format', 'l, M j, Y'); $title = Ai1ec_Time_Utility::date_i18n($date_format, $local_date, true); $time_format = Ai1ec_Meta::get_option('time_format', 'g a'); // Calculate today marker's position. $now = Ai1ec_Time_Utility::current_time(); $now = Ai1ec_Time_Utility::gmt_to_local($now); $now_text = $ai1ec_events_helper->get_short_time($now, false); $now = Ai1ec_Time_Utility::gmgetdate($now); $now = $now['hours'] * 60 + $now['minutes']; $view_args = array('title' => $title, 'type' => 'oneday', 'cell_array' => $cell_array, 'show_location_in_title' => $ai1ec_settings->show_location_in_title, 'now_top' => $now, 'now_text' => $now_text, 'pagination_links' => $pagination_links, 'post_ids' => join(',', $args['post_ids']), 'time_format' => $time_format, 'done_allday_label' => false, 'done_grid' => false, 'data_type' => $args['data_type'], 'data_type_events' => ''); if ($ai1ec_settings->ajaxify_events_in_web_widget) { $view_args['data_type_events'] = $args['data_type']; } // Add navigation if requested. $view_args['navigation'] = $args['no_navigation'] ? '' : $ai1ec_view_helper->get_theme_view('navigation.php', $view_args); return apply_filters('ai1ec_get_oneday_view', $ai1ec_view_helper->get_theme_view('oneday.php', $view_args), $view_args); }
?> <div class="ai1ec-grid-container"> <?php for ($hour = 0; $hour < 24; $hour++) { ?> <div class="ai1ec-hour-marker <?php if ($hour >= 8 && $hour < 18) { echo 'ai1ec-business-hour'; } ?> " style="top: <?php echo $hour * 60; ?> px;"> <div><?php echo esc_html(Ai1ec_Time_Utility::date_i18n($time_format, gmmktime($hour, 0), true)); ?> </div> </div> <?php for ($quarter = 1; $quarter < 4; $quarter++) { ?> <div class="ai1ec-quarter-marker" style="top: <?php echo $hour * 60 + $quarter * 15; ?> px;"></div> <?php } ?> <?php }
/** * _ending_sentence function * * Ends rrule to text sentence * * @internal * * @return void **/ function _ending_sentence(&$txt, &$rc) { if ($until = $rc->getUntil()) { if (!is_int($until)) { $until = strtotime($until); } $txt .= ' ' . sprintf(__('until %s', AI1EC_PLUGIN_NAME), Ai1ec_Time_Utility::date_i18n(Ai1ec_Meta::get_option('date_format'), $until, true)); } else { if ($count = $rc->getCount()) { $txt .= ' ' . sprintf(__('for %d occurrences', AI1EC_PLUGIN_NAME), $count); } else { $txt .= ', ' . __('forever', AI1EC_PLUGIN_NAME); } } }
/** * post_updated_messages function * * Filter success messages returned by WordPress when an event post is * updated/saved. */ function post_updated_messages($messages) { global $post, $post_ID; $messages[AI1EC_POST_TYPE] = array(0 => '', 1 => sprintf(__('Event updated. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME), esc_url(get_permalink($post_ID))), 2 => __('Custom field updated.', AI1EC_PLUGIN_NAME), 3 => __('Custom field deleted.', AI1EC_PLUGIN_NAME), 4 => __('Event updated.', AI1EC_PLUGIN_NAME), 5 => isset($_GET['revision']) ? sprintf(__('Event restored to revision from %s', AI1EC_PLUGIN_NAME), wp_post_revision_title((int) $_GET['revision'], false)) : false, 6 => sprintf(__('Event published. <a href="%s">View event</a>', AI1EC_PLUGIN_NAME), esc_url(get_permalink($post_ID))), 7 => __('Event saved.'), 8 => sprintf(__('Event submitted. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID)))), 9 => sprintf(__('Event scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview event</a>', AI1EC_PLUGIN_NAME), Ai1ec_Time_Utility::date_i18n(__('M j, Y @ G:i', AI1EC_PLUGIN_NAME), strtotime($post->post_date)), esc_url(get_permalink($post_ID))), 10 => sprintf(__('Event draft updated. <a target="_blank" href="%s">Preview event</a>', AI1EC_PLUGIN_NAME), esc_url(add_query_arg('preview', 'true', get_permalink($post_ID))))); return $messages; }
/** * This is the CRON function which sends emails * */ public function send_notifications_for_events() { global $ai1ec_settings; if (!$ai1ec_settings->enable_user_event_notifications) { return false; } $notifications = Ai1ec_Meta::get_option(self::SAVED_NOTIFICATIONS, array()); foreach ($notifications as $event_id => $instances) { foreach ($instances as $instance_id => $notifications_to_send) { try { $event = new Ai1ec_Event($event_id, $instance_id); } catch (Ai1ec_Event_Not_Found $excpt) { unset($notifications[$event_id]); continue 2; } $subject = $ai1ec_settings->user_upcoming_event_mail_subject; $message = $ai1ec_settings->user_upcoming_event_mail_body; if (true === $this->check_if_notification_should_be_sent_for_event($event)) { $event_url = get_permalink($event->post_id); if (0 !== (int) $instance_id) { $event_url .= $instance_id; } $translations = array('[event_title]' => $event->post->post_title, '[event_start]' => Ai1ec_Time_Utility::date_i18n('D, d M Y H:i', Ai1ec_Time_Utility::gmt_to_local($event->start)), '[event_url]' => $event_url, '[site_title]' => get_bloginfo('name'), '[site_url]' => site_url()); foreach ($notifications_to_send as $recipient => $details) { $notification = Ai1ec_Notification_Factory::create_notification_instance(array($recipient), $message, Ai1ec_Notification_Factory::EMAIL_NOTIFICATION, $subject); $notification->set_translations($translations); $notification->send(); // unset the notification unset($notifications[$event_id][$instance_id][$recipient]); } } // after sending the mail, unset the instance id if all // mail have been sent if (empty($notifications[$event_id][$instance_id])) { unset($notifications[$event_id][$instance_id]); } } if (empty($notifications[$event_id])) { unset($notifications[$event_id]); } } return update_option(self::SAVED_NOTIFICATIONS, $notifications); }