function bp_em_events_content() { global $bp, $EM_Notices; echo $EM_Notices; ?> <h4><?php _e('My Events', 'dbem'); ?> </h4> <?php $events = EM_Events::get(array('owner' => $bp->displayed_user->id)); if (count($events) > 0) { $args = array('format_header' => get_option('dbem_bp_events_list_format_header'), 'format' => get_option('dbem_bp_events_list_format'), 'format_footer' => get_option('dbem_bp_events_list_format_footer'), 'owner' => $bp->displayed_user->id); echo EM_Events::output($events, $args); } else { ?> <p><?php _e('No Events', 'dbem'); ?> </p> <?php } ?> <h4><?php _e("Events I'm Attending", 'dbem'); ?> </h4> <?php bp_em_attending_content(); }
/** @see WP_Widget::widget */ function widget($args, $instance) { $instance = array_merge($this->defaults, $instance); $instance = $this->fix_scope($instance); // depcreciate echo $args['before_widget']; echo $args['before_title']; echo $instance['title']; echo $args['after_title']; if (is_numeric($instance['time_limit']) && $instance['time_limit'] > 0) { $instance['scope'] = date('Y-m-d') . "," . date('Y-m-t', strtotime('+' . ($instance['time_limit'] - 1) . ' month')); } $instance['owner'] = false; $events = EM_Events::get($instance); echo "<ul>"; $li_wrap = !preg_match('/^<li>/i', trim($instance['format'])); if (count($events) > 0) { foreach ($events as $event) { if ($li_wrap) { echo '<li>' . $event->output($instance['format']) . '</li>'; } else { echo $event->output($instance['format']); } } } else { echo '<li>' . __('No events', 'dbem') . '</li>'; } if (!empty($instance['all_events'])) { $events_link = !empty($instance['all_events_text']) ? em_get_link($instance['all_events_text']) : em_get_link(__('all events', 'dbem')); echo '<li>' . $events_link . '</li>'; } echo "</ul>"; echo $args['after_widget']; }
function mob_shortcode_countdown($atts) { $defaults = array('id' => 'countdown_' . uniqid(), 'day' => 0, 'month' => 0, 'year' => 0, 'hour' => 0, 'minutes' => 0, 'seconds' => 0, 'nextevent' => false, 'labels' => "['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds']", 'labels1' => "['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second']", 'compactLabels' => "['y', 'm', 'w', 'd']", 'whichLabels' => null, 'digits' => "['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']", 'timeSeparator' => ':', 'isRTL' => false, 'since' => null, 'timezone' => null, 'serverSync' => null, 'format' => 'dHMS', 'layout' => '', 'compact' => false, 'padZeroes' => false, 'significant' => 0, 'description' => '', 'expiryUrl' => null, 'alwaysExpire' => false, 'onExpiry' => null, 'onTick' => null, 'tickInterval' => 1); $a = shortcode_atts($defaults, $atts); if ($a['nextevent'] && class_exists('EM_Events')) { if ($events = EM_Events::get(array('limit' => 1))) { $datetime = strtotime($events[0]->event_start_date . ' ' . $events[0]->event_start_time); $a['day'] = date('j', $datetime); $a['month'] = date('n', $datetime); $a['year'] = date('Y', $datetime); $a['hour'] = date('G', $datetime); $a['minutes'] = intval(date('i', $datetime)); $a['seconds'] = intval(date('s', $datetime)); } } $return = '<div id="' . $a['id'] . '"></div><script type="text/javascript">jQuery(document).ready(function(){ jQuery(\'#' . $a['id'] . '\').countdown({'; foreach (array_diff_key($a, array('id' => '', 'day' => '', 'month' => '', 'year' => '', 'hour' => '', 'minutes' => '', 'seconds' => '')) as $k => $v) { if ($v != $defaults[$k] && $v != null && $v != false && !empty($v)) { $return .= $k . ':' . (substr($defaults[$k], 0, 1) == '[' || $defaults[$k] == null || is_numeric($defaults[$k]) || is_bool($defaults[$k]) ? $v : '"' . $v . '"') . ','; } } $return .= ' until: new Date(' . intval($a['year']) . ',' . intval($a['month'] - 1) . ',' . intval($a['day']) . ',' . intval($a['hour']) . ',' . intval($a['minutes']) . ',' . intval($a['seconds']) . '), }); });</script>'; if (isset($events[0]->event_slug)) { $return = '<a href="' . $events[0]->event_slug . '">' . $return . '</a>'; } return $return; }
/** * Run on cron and prep emails to go out */ public static function queue_emails() { global $EM_Event, $wpdb; //save old event in case already set $old_EM_Event = !empty($EM_Event) ? clone $EM_Event : null; //disable the current events are past rule add_filter('option_pre_dbem_events_current_are_past', 'em_emails_return_false', create_function('$a', 'return false;')); //For each event x days on $days = get_option('dbem_emp_emails_reminder_days', 1); $scope = $days > 0 ? date('Y-m-d', current_time('timestamp') + 86400 * $days) : date('Y-m-d', current_time('timestamp') + 86400); //make sure we don't get past events, only events starting that specific date $events_are_past = get_option('dbem_events_current_are_past'); update_option('dbem_events_current_are_past', true); $output_type = get_option('dbem_smtp_html') ? 'html' : 'email'; foreach (EM_Events::get(array('scope' => $scope, 'private' => 1, 'blog' => get_current_blog_id())) as $EM_Event) { /* @var $EM_Event EM_Event */ $emails = array(); //get ppl attending foreach ($EM_Event->get_bookings()->get_bookings()->bookings as $EM_Booking) { //get confirmed bookings /* @var $EM_Booking EM_Booking */ if (is_email($EM_Booking->get_person()->user_email)) { $subject = $EM_Booking->output(get_option('dbem_emp_emails_reminder_subject'), 'raw'); $message = $EM_Booking->output(get_option('dbem_emp_emails_reminder_body'), $output_type); $emails[] = array($EM_Booking->get_person()->user_email, $subject, $message, $EM_Booking->booking_id); } } if (count($emails) > 0) { $attachments = serialize(array()); if (get_option('dbem_emp_emails_reminder_ical')) { //create invite ical $upload_dir = wp_upload_dir(); if (file_exists(trailingslashit($upload_dir['basedir']) . "em-cache") || mkdir(trailingslashit($upload_dir['basedir']) . "em-cache")) { $icalfilename = trailingslashit($upload_dir['basedir']) . "em-cache/invite_" . $EM_Event->event_id . ".ics"; $icalfile = fopen($icalfilename, 'w+'); if ($icalfile) { ob_start(); em_locate_template('templates/ical.php', true, array('args' => array('event' => $EM_Event->event_id))); $icalcontent = preg_replace("/([^\r])\n/", "\$1\r\n", ob_get_clean()); fwrite($icalfile, $icalcontent); fclose($icalfile); $ical_file_array = array('name' => 'invite.ics', 'type' => 'text/calendar', 'path' => $icalfilename); $attachments = serialize(array($ical_file_array)); } } } foreach ($emails as $email) { $wpdb->insert(EM_EMAIL_QUEUE_TABLE, array('email' => $email[0], 'subject' => $email[1], 'body' => $email[2], 'attachment' => $attachments, 'event_id' => $EM_Event->event_id, 'booking_id' => $email[3])); } } } //cleanup update_option('dbem_events_current_are_past', $events_are_past); //reset previous current events are past setting $EM_Event = $old_EM_Event; //reset global remove_filter('option_pre_dbem_events_current_are_past', 'em_emails_return_false'); }
function em_rss() { global $post, $wp_query; if (!empty($_REQUEST['dbem_rss']) || is_object($post) && $post->ID == get_option('dbem_events_page') && $wp_query->get('rss')) { header("Content-type: text/xml"); ob_start(); echo "<?xml version='1.0'?>\n"; ?> <rss version="2.0"> <channel> <title><?php echo get_option('dbem_rss_main_title'); ?> </title> <link><?php echo get_permalink(get_option('dbem_events_page')); ?> </link> <description><?php echo get_option('dbem_rss_main_description'); ?> </description> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <generator>Weblog Editor 2.0</generator> <?php $description_format = str_replace(">", ">", str_replace("<", "<", get_option('dbem_rss_description_format'))); $events = EM_Events::get(array('limit' => 5, 'owner' => false)); foreach ($events as $event) { $description = $event->output(get_option('dbem_rss_description_format'), "rss"); $description = ent2ncr(convert_chars(strip_tags($description))); //Some RSS filtering ?> <item> <title><?php echo $event->output(get_option('dbem_rss_title_format'), "rss"); ?> </title> <link><?php echo $event->output('#_EVENTURL'); ?> </link> <description><?php echo $description; ?> </description> </item> <?php } ?> </channel> </rss> <?php echo apply_filters('em_rss', ob_get_clean()); die; } }
public function find($params) { $events = EM_Events::get(array('limit' => 0, 'offset' => 100)); $events = self::filter_events($events, $params); $events = array_slice($events, $params['offset']); $remaped_events = array(); foreach ($events as $event) { $remaped_events[] = $this->convert_to_se_event($event); } return $paged_posts = $this->add_paging_info($remaped_events, $params); }
/** @see WP_Widget::widget */ function widget($args, $instance) { $instance = array_merge($this->defaults, $instance); $instance = $this->fix_scope($instance); // depcreciate echo $args['before_widget']; if( !empty($instance['title']) ){ echo $args['before_title']; echo apply_filters('widget_title',$instance['title'], $instance, $this->id_base); echo $args['after_title']; } //remove owner searches $instance['owner'] = false; //legacy stuff //add li tags to old widgets that have no forced li wrappers if ( !preg_match('/^<li/i', trim($instance['format'])) ) $instance['format'] = '<li>'. $instance['format'] .'</li>'; if (!preg_match('/^<li/i', trim($instance['no_events_text'])) ) $instance['no_events_text'] = '<li>'.$instance['no_events_text'].'</li>'; //orderby fix for previous versions with old orderby values if( !array_key_exists($instance['orderby'], $this->em_orderby_options) ){ //replace old values $old_vals = array( 'name' => 'event_name', 'end_date' => 'event_end_date', 'start_date' => 'event_start_date', 'end_time' => 'event_end_time', 'start_time' => 'event_start_time' ); foreach($old_vals as $old_val => $new_val){ $instance['orderby'] = str_replace($old_val, $new_val, $instance['orderby']); } } //get events $events = EM_Events::get(apply_filters('em_widget_events_get_args',$instance)); //output events echo "<ul>"; if ( count($events) > 0 ){ foreach($events as $event){ echo $event->output( $instance['format'] ); } }else{ echo $instance['no_events_text']; } if ( !empty($instance['all_events']) ){ $events_link = (!empty($instance['all_events_text'])) ? em_get_link($instance['all_events_text']) : em_get_link(__('all events','charity')); echo '<li class="all-events-link">'.$events_link.'</li>'; } echo "</ul>"; echo $args['after_widget']; }
function EM_Events($args = array()) { if (is_array($args)) { if (is_object(current($args)) && get_class(current($args)) == 'EM_Event') { $this->events = $args; } else { $this->events = EM_Events::get($args); } } else { $this->events = EM_Events::get(); } do_action('em_events', $this); }
/** * export the data in selected format */ public function export() { $EM_Events = EM_Events::get(); $format = isset($_POST['exp_format']) ? wp_unslash($_POST['exp_format']) : ''; switch ($format) { case 'xCal': $this->exportXCal($EM_Events); break; case 'iCal': $this->exportICal($EM_Events); break; case 'Event Espresso': $this->exportEventEspresso($EM_Events); break; } }
/** @see WP_Widget::widget */ function widget($args, $instance) { $instance = array_merge($this->defaults, $instance); $instance = $this->fix_scope($instance); // depcreciate echo $args['before_widget']; if (!empty($instance['title'])) { echo $args['before_title']; echo apply_filters('widget_title', $instance['title'], $instance, $this->id_base); echo $args['after_title']; } $instance['owner'] = false; //orderby fix for previous versions with old orderby values if (!array_key_exists($instance['orderby'], $this->em_orderby_options)) { //replace old values $old_vals = array('name' => 'event_name', 'end_date' => 'event_end_date', 'start_date' => 'event_start_date', 'end_time' => 'event_end_time', 'start_time' => 'event_start_time'); foreach ($old_vals as $old_val => $new_val) { $instance['orderby'] = str_replace($old_val, $new_val, $instance['orderby']); } } $events = EM_Events::get(apply_filters('em_widget_events_get_args', $instance)); echo "<div id='events'>"; $li_wrap = !preg_match('/^<div class="item">/i', trim($instance['format'])); if (count($events) > 0) { foreach ($events as $event) { if ($li_wrap) { echo '<div class="item">' . $event->output($instance['format']) . '</div>'; } else { echo $event->output($instance['format']); } } } else { echo '<div class="item"><h4>' . $instance['no_events_text'] . '</h4></div>'; } if (!empty($instance['all_events'])) { $events_link = !empty($instance['all_events_text']) ? em_get_link($instance['all_events_text']) : em_get_link(__('all events', 'dbem')); echo '<div class="all-events-link">» ' . $events_link . '</div>'; } echo "</div>"; echo $args['after_widget']; }
function em_get_events_list_shortcode_all($atts, $format = '') { $atts = (array) $atts; $atts['format'] = $format != '' || empty($atts['format']) ? $format : $atts['format']; $atts['format'] = html_entity_decode($atts['format']); //shorcode doesn't accept html $atts['page'] = !empty($atts['page']) && is_numeric($atts['page']) ? $atts['page'] : 1; $atts['page'] = !empty($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : $atts['page']; // get recurrence events $atts['recurring'] = 1; $evts_recurring = EM_Events::get($atts); // get non-recurrence events $atts['recurring'] = 0; $evts = EM_Events::get($atts); // filter out the events that are instances of recurring events $non_recurrence_evts = array_filter($evts, 'is_no_recurrence'); // merge recurrence and non-recurring events $evts_all = array_merge($non_recurrence_evts, $evts_recurring); // sort them by start==start date+time usort($evts_all, 'evt_start_sort'); // return EM_Events::output($evts_all, $atts); }
/** * Returns true if there are any events that exist in the given scope (default is future events). * @param string $scope * @return boolean */ function em_are_events_available($scope = "future") { $scope = $scope == "" ? "future" : $scope; $events = EM_Events::get(array('limit' => 1, 'scope' => $scope)); return count($events) > 0; }
</link> <guid><?php echo $event_url; ?> </guid> <pubDate><?php echo get_gmt_from_date(date('Y-m-d H:i:s', $EM_Event->start), 'D, d M Y H:i:s +0000'); ?> </pubDate> <description><![CDATA[<?php echo $description; ?> ]]></description> </item> <?php $count++; } if ($rss_limit != 0 && $count >= $rss_limit) { //we've reached our limit, or showing one event only break; } else { //get next page of results $args['page']++; $EM_Events = EM_Events::get($args); } } ?> </channel> </rss>
function output($format, $target = "html") { preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals); if (count($conditionals[0]) > 0) { //Check if the language we want exists, if not we take the first language there foreach ($conditionals[1] as $key => $condition) { $format = str_replace($conditionals[0][$key], apply_filters('em_category_output_condition', '', $condition, $conditionals[0][$key], $this), $format); } } $category_string = $format; preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders); $replaces = array(); foreach ($placeholders[1] as $key => $result) { $replace = ''; $full_result = $placeholders[0][$key]; switch ($result) { case '#_CATEGORYNAME': $replace = $this->name; break; case '#_CATEGORYID': $replace = $this->term_id; break; case '#_CATEGORYNOTES': case '#_CATEGORYDESCRIPTION': $replace = $this->description; break; case '#_CATEGORYIMAGE': case '#_CATEGORYIMAGEURL': if ($this->get_image_url() != '') { $image_url = esc_url($this->get_image_url()); if ($result == '#_CATEGORYIMAGEURL') { $replace = $image_url; } else { if (empty($placeholders[3][$key])) { $replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>"; } else { $image_size = explode(',', $placeholders[3][$key]); if (self::array_is_numeric($image_size) && count($image_size) > 1) { if ($this->get_image_id()) { //get a thumbnail if (get_option('dbem_disable_thumbnails')) { $image_attr = ''; $image_args = array(); if (empty($image_size[1]) && !empty($image_size[0])) { $image_attr = 'width="' . $image_size[0] . '"'; $image_args['w'] = $image_size[0]; } elseif (empty($image_size[0]) && !empty($image_size[1])) { $image_attr = 'height="' . $image_size[1] . '"'; $image_args['h'] = $image_size[1]; } elseif (!empty($image_size[0]) && !empty($image_size[1])) { $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"'; $image_args = array('w' => $image_size[0], 'h' => $image_size[1]); } $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->name) . "' {$image_attr} />"; } else { //since we previously didn't store image ids along with the url to the image (since taxonomies don't allow normal featured images), sometimes we won't be able to do this, which is why we check there's a valid image id first self::ms_global_switch(); $replace = wp_get_attachment_image($this->get_image_id(), $image_size); self::ms_global_switch_back(); } } } else { $replace = "<img src='" . esc_url($this->get_image_url()) . "' alt='" . esc_attr($this->name) . "'/>"; } } } } break; case '#_CATEGORYCOLOR': $replace = $this->get_color(); break; case '#_CATEGORYLINK': case '#_CATEGORYURL': $link = $this->get_url(); $replace = $result == '#_CATEGORYURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>'; break; case '#_CATEGORYICALURL': case '#_CATEGORYICALLINK': $replace = $this->get_ical_url(); if ($result == '#_CATEGORYICALLINK') { $replace = '<a href="' . esc_url($replace) . '">iCal</a>'; } break; case '#_CATEGORYRSSURL': case '#_CATEGORYRSSLINK': $replace = $this->get_rss_url(); if ($result == '#_CATEGORYRSSLINK') { $replace = '<a href="' . esc_url($replace) . '">RSS</a>'; } break; case '#_CATEGORYSLUG': $replace = $this->slug; break; case '#_CATEGORYEVENTSPAST': //deprecated, erroneous documentation, left for compatability //deprecated, erroneous documentation, left for compatability case '#_CATEGORYEVENTSNEXT': //deprecated, erroneous documentation, left for compatability //deprecated, erroneous documentation, left for compatability case '#_CATEGORYEVENTSALL': //deprecated, erroneous documentation, left for compatability //deprecated, erroneous documentation, left for compatability case '#_CATEGORYPASTEVENTS': case '#_CATEGORYNEXTEVENTS': case '#_CATEGORYALLEVENTS': //convert deprecated placeholders for compatability $result = $result == '#_CATEGORYEVENTSPAST' ? '#_CATEGORYPASTEVENTS' : $result; $result = $result == '#_CATEGORYEVENTSNEXT' ? '#_CATEGORYNEXTEVENTS' : $result; $result = $result == '#_CATEGORYEVENTSALL' ? '#_CATEGORYALLEVENTS' : $result; //forget it ever happened? :/ if ($result == '#_CATEGORYPASTEVENTS') { $scope = 'past'; } elseif ($result == '#_CATEGORYNEXTEVENTS') { $scope = 'future'; } else { $scope = 'all'; } $events_count = EM_Events::count(array('category' => $this->term_id, 'scope' => $scope)); if ($events_count > 0) { $args = array('category' => $this->term_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0); $args['format_header'] = get_option('dbem_category_event_list_item_header_format'); $args['format_footer'] = get_option('dbem_category_event_list_item_footer_format'); $args['format'] = get_option('dbem_category_event_list_item_format'); $args['limit'] = get_option('dbem_category_event_list_limit'); $args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1; $replace = EM_Events::output($args); } else { $replace = get_option('dbem_category_no_events_message', '</ul>'); } break; case '#_CATEGORYNEXTEVENT': $events = EM_Events::get(array('category' => $this->term_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time')); $replace = get_option('dbem_category_no_event_message'); foreach ($events as $EM_Event) { $replace = $EM_Event->output(get_option('dbem_category_event_single_format')); } break; default: $replace = $full_result; break; } $replaces[$full_result] = apply_filters('em_category_output_placeholder', $replace, $this, $full_result, $target); } krsort($replaces); foreach ($replaces as $full_result => $replacement) { $category_string = str_replace($full_result, $replacement, $category_string); } return apply_filters('em_category_output', $category_string, $this, $format, $target); }
function output($format, $target = "html") { preg_match_all('/\\{([a-zA-Z0-9_]+)\\}([^{]+)\\{\\/[a-zA-Z0-9_]+\\}/', $format, $conditionals); if (count($conditionals[0]) > 0) { //Check if the language we want exists, if not we take the first language there foreach ($conditionals[1] as $key => $condition) { $format = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', '', $conditionals[0][$key], $condition, $this), $format); } } $location_string = $format; preg_match_all("/#_[A-Za-z]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { $match = true; $replace = ''; switch ($result) { case '#_LOCATIONID': $replace = $this->id; break; case '#_NAME': //Depreciated //Depreciated case '#_LOCATIONNAME': $replace = $this->name; break; case '#_ADDRESS': //Depreciated //Depreciated case '#_LOCATIONADDRESS': $replace = $this->address; break; case '#_TOWN': //Depreciated //Depreciated case '#_LOCATIONTOWN': $replace = $this->town; break; case '#_LOCATIONSTATE': $replace = $this->state; break; case '#_LOCATIONPOSTCODE': $replace = $this->postcode; break; case '#_LOCATIONREGION': $replace = $this->region; break; case '#_LOCATIONCOUNTRY': $replace = $this->get_country(); break; case '#_LOCATIONFULLLINE': $replace = $this->address . ', '; $replace = empty($this->town) ? '' : ', ' . $this->town; $replace = empty($this->state) ? '' : ', ' . $this->state; $replace = empty($this->postcode) ? '' : ', ' . $this->postcode; $replace = empty($this->region) ? '' : ', ' . $this->region; break; case '#_LOCATIONFULLBR': $replace = $this->address . '<br /> '; $replace = empty($this->town) ? '' : '<br /> ' . $this->town; $replace = empty($this->state) ? '' : '<br /> ' . $this->state; $replace = empty($this->postcode) ? '' : '<br /> ' . $this->postcode; $replace = empty($this->region) ? '' : '<br /> ' . $this->region; break; case '#_MAP': //Depreciated //Depreciated case '#_LOCATIONMAP': ob_start(); $template = em_locate_template('placeholders/locationmap.php', true, array('EM_Location' => $this)); $replace = ob_get_clean(); break; case '#_DESCRIPTION': //Depreciated //Depreciated case '#_EXCERPT': //Depreciated //Depreciated case '#_LOCATIONNOTES': case '#_LOCATIONEXCERPT': $replace = $this->description; if ($result == "#_EXCERPT" || $result == "#_LOCATIONEXCERPT") { $matches = explode('<!--more', $this->description); $replace = $matches[0]; } break; case '#_LOCATIONIMAGE': if ($this->image_url != '') { $replace = "<img src='" . $this->image_url . "' alt='" . $this->name . "'/>"; } break; case '#_LOCATIONURL': case '#_LOCATIONLINK': case '#_LOCATIONPAGEURL': //Depreciated $joiner = stristr(EM_URI, "?") ? "&" : "?"; $link = EM_URI . $joiner . "location_id=" . $this->id; $replace = $result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL' ? $link : '<a href="' . $link . '">' . $this->name . '</a>'; break; case '#_PASTEVENTS': //Depreciated //Depreciated case '#_LOCATIONPASTEVENTS': case '#_NEXTEVENTS': //Depreciated //Depreciated case '#_LOCATIONNEXTEVENTS': case '#_ALLEVENTS': //Depreciated //Depreciated case '#_LOCATIONALLEVENTS': if ($result == '#_PASTEVENTS' || $result == '#_LOCATIONPASTEVENTS') { $scope = 'past'; } elseif ($result == '#_NEXTEVENTS' || $result == '#_LOCATIONNEXTEVENTS') { $scope = 'future'; } else { $scope = 'all'; } $events = EM_Events::get(array('location' => $this->id, 'scope' => $scope)); if (count($events) > 0) { foreach ($events as $event) { $replace .= $event->output(get_option('dbem_location_event_list_item_format')); } } else { $replace = get_option('dbem_location_no_events_message'); } break; default: $match = false; break; } if ($match) { //if true, we've got a placeholder that needs replacing $replace = apply_filters('em_location_output_placeholder', $replace, $this, $result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED $location_string = str_replace($result, $replace, $location_string); } else { $custom_replace = apply_filters('em_location_output_placeholder', $replace, $this, $result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED if ($custom_replace != $replace) { $location_string = str_replace($result, $custom_replace, $location_string); } } } $name_filter = $target == "html" ? 'dbem_general' : 'dbem_general_rss'; //TODO remove dbem_ filters $location_string = str_replace('#_LOCATION', apply_filters($name_filter, $this->name), $location_string); //Depreciated return apply_filters('em_location_output', $location_string, $this, $format, $target); }
function output($format, $target = "html") { $location_string = $format; //First let's do some conditional placeholder removals for ($i = 0; $i < EM_CONDITIONAL_RECURSIONS; $i++) { //you can add nested recursions by modifying this setting in your wp_options table preg_match_all('/\\{([a-zA-Z0-9_]+)\\}(.+?)\\{\\/\\1\\}/s', $location_string, $conditionals); if (count($conditionals[0]) > 0) { //Check if the language we want exists, if not we take the first language there foreach ($conditionals[1] as $key => $condition) { $show_condition = false; if ($condition == 'has_loc_image') { //does this event have an image? $show_condition = $this->get_image_url() != ''; } elseif ($condition == 'no_loc_image') { //does this event have an image? $show_condition = $this->get_image_url() == ''; } $show_condition = apply_filters('em_location_output_show_condition', $show_condition, $condition, $conditionals[0][$key], $this); if ($show_condition) { //calculate lengths to delete placeholders $placeholder_length = strlen($condition) + 2; $replacement = substr($conditionals[0][$key], $placeholder_length, strlen($conditionals[0][$key]) - ($placeholder_length * 2 + 1)); } else { $replacement = ''; } $location_string = str_replace($conditionals[0][$key], apply_filters('em_location_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $location_string); } } } //This is for the custom attributes preg_match_all('/#_LATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $location_string, $results); foreach ($results[0] as $resultKey => $result) { //Strip string of placeholder and just leave the reference $attRef = substr(substr($result, 0, strpos($result, '}')), 7); $attString = ''; if (is_array($this->location_attributes) && array_key_exists($attRef, $this->location_attributes) && !empty($this->location_attributes[$attRef])) { $attString = $this->location_attributes[$attRef]; } elseif (!empty($results[3][$resultKey])) { //Check to see if we have a second set of braces; $attString = $results[3][$resultKey]; } $attString = apply_filters('em_location_output_placeholder', $attString, $this, $result, $target); $location_string = str_replace($result, $attString, $location_string); } preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $location_string, $placeholders); $replaces = array(); foreach ($placeholders[1] as $key => $result) { $replace = ''; $full_result = $placeholders[0][$key]; switch ($result) { case '#_LOCATIONID': $replace = $this->location_id; break; case '#_LOCATIONPOSTID': $replace = $this->post_id; break; case '#_NAME': //Depricated //Depricated case '#_LOCATION': //Depricated //Depricated case '#_LOCATIONNAME': $replace = $this->location_name; break; case '#_ADDRESS': //Depricated //Depricated case '#_LOCATIONADDRESS': $replace = $this->location_address; break; case '#_TOWN': //Depricated //Depricated case '#_LOCATIONTOWN': $replace = $this->location_town; break; case '#_LOCATIONSTATE': $replace = $this->location_state; break; case '#_LOCATIONPOSTCODE': $replace = $this->location_postcode; break; case '#_LOCATIONREGION': $replace = $this->location_region; break; case '#_LOCATIONCOUNTRY': $replace = $this->get_country(); break; case '#_LOCATIONFULLLINE': $replace = $this->location_address; $replace .= empty($this->location_town) ? '' : ', ' . $this->location_town; $replace .= empty($this->location_state) ? '' : ', ' . $this->location_state; $replace .= empty($this->location_postcode) ? '' : ', ' . $this->location_postcode; $replace .= empty($this->location_region) ? '' : ', ' . $this->location_region; break; case '#_LOCATIONFULLBR': $replace = $this->location_address; $replace .= empty($this->location_town) ? '' : '<br />' . $this->location_town; $replace .= empty($this->location_state) ? '' : '<br />' . $this->location_state; $replace .= empty($this->location_postcode) ? '' : '<br />' . $this->location_postcode; $replace .= empty($this->location_region) ? '' : '<br />' . $this->location_region; break; case '#_MAP': //Depricated (but will remain) //Depricated (but will remain) case '#_LOCATIONMAP': ob_start(); $args = array(); if (!empty($placeholders[3][$key])) { $dimensions = explode(',', $placeholders[3][$key]); if (!empty($dimensions[0])) { $args['width'] = $dimensions[0]; } if (!empty($dimensions[1])) { $args['height'] = $dimensions[1]; } } $template = em_locate_template('placeholders/locationmap.php', true, array('args' => $args, 'EM_Location' => $this)); $replace = ob_get_clean(); break; case '#_LOCATIONLONGITUDE': $replace = $this->location_longitude; break; case '#_LOCATIONLATITUDE': $replace = $this->location_latitude; break; case '#_DESCRIPTION': //Depricated //Depricated case '#_EXCERPT': //Depricated //Depricated case '#_LOCATIONNOTES': case '#_LOCATIONEXCERPT': $replace = $this->post_content; if ($result == "#_EXCERPT" || $result == "#_LOCATIONEXCERPT") { if (!empty($this->post_excerpt)) { $replace = $this->post_excerpt; } else { $excerpt_length = 55; $excerpt_more = apply_filters('em_excerpt_more', ' ' . '[...]'); if (!empty($placeholders[3][$key])) { $trim = true; $ph_args = explode(',', $placeholders[3][$key]); if (is_numeric($ph_args[0])) { $excerpt_length = $ph_args[0]; } if (!empty($ph_args[1])) { $excerpt_more = $ph_args[1]; } } if (preg_match('/<!--more(.*?)?-->/', $replace, $matches)) { $content = explode($matches[0], $replace, 2); $replace = force_balance_tags($content[0]); } if (!empty($trim)) { //shorten content by supplied number - copied from wp_trim_excerpt $replace = strip_shortcodes($replace); $replace = str_replace(']]>', ']]>', $replace); $replace = wp_trim_words($replace, $excerpt_length, $excerpt_more); } } } break; case '#_LOCATIONIMAGEURL': case '#_LOCATIONIMAGE': if ($this->get_image_url() != '') { $image_url = esc_url($this->get_image_url()); if ($result == '#_LOCATIONIMAGEURL') { $replace = $this->get_image_url(); } else { if (empty($placeholders[3][$key])) { $replace = "<img src='" . $image_url . "' alt='" . esc_attr($this->location_name) . "'/>"; } else { $image_size = explode(',', $placeholders[3][$key]); if (self::array_is_numeric($image_size) && count($image_size) > 1) { if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) { //get a thumbnail if (get_option('dbem_disable_thumbnails')) { $image_attr = ''; $image_args = array(); if (empty($image_size[1]) && !empty($image_size[0])) { $image_attr = 'width="' . $image_size[0] . '"'; $image_args['w'] = $image_size[0]; } elseif (empty($image_size[0]) && !empty($image_size[1])) { $image_attr = 'height="' . $image_size[1] . '"'; $image_args['h'] = $image_size[1]; } elseif (!empty($image_size[0]) && !empty($image_size[1])) { $image_attr = 'width="' . $image_size[0] . '" height="' . $image_size[1] . '"'; $image_args = array('w' => $image_size[0], 'h' => $image_size[1]); } $replace = "<img src='" . esc_url(em_add_get_params($image_url, $image_args)) . "' alt='" . esc_attr($this->location_name) . "' {$image_attr} />"; } else { //location belongs to another blog, so switch blog then call the default wp fucntion if (EM_MS_GLOBAL && get_current_blog_id() != $this->blog_id) { switch_to_blog($this->blog_id); $switch_back = true; } $replace = get_the_post_thumbnail($this->ID, $image_size); if (!empty($switch_back)) { restore_current_blog(); } } } else { $replace = get_the_post_thumbnail($this->ID, $image_size); } } else { $replace = "<img src='" . $image_url . "' alt='" . esc_attr($this->location_name) . "'/>"; } } } } break; case '#_LOCATIONURL': case '#_LOCATIONLINK': case '#_LOCATIONPAGEURL': //Depricated $link = esc_url($this->get_permalink()); $replace = $result == '#_LOCATIONURL' || $result == '#_LOCATIONPAGEURL' ? $link : '<a href="' . $link . '" title="' . esc_attr($this->location_name) . '">' . esc_html($this->location_name) . '</a>'; break; case '#_LOCATIONEDITURL': case '#_LOCATIONEDITLINK': if ($this->can_manage('edit_locations', 'edit_others_locations')) { $link = esc_url($this->get_edit_url()); $replace = $result == '#_LOCATIONEDITURL' ? $link : '<a href="' . $link . '" title="' . esc_attr($this->location_name) . '">' . esc_html(sprintf(__('Edit Location', 'dbem'))) . '</a>'; } break; case '#_LOCATIONICALURL': case '#_LOCATIONICALLINK': $replace = $this->get_ical_url(); if ($result == '#_LOCATIONICALLINK') { $replace = '<a href="' . esc_url($replace) . '">iCal</a>'; } break; case '#_LOCATIONRSSURL': case '#_LOCATIONRSSLINK': $replace = $this->get_rss_url(); if ($result == '#_LOCATIONRSSLINK') { $replace = '<a href="' . esc_url($replace) . '">RSS</a>'; } break; case '#_PASTEVENTS': //Depricated //Depricated case '#_LOCATIONPASTEVENTS': case '#_NEXTEVENTS': //Depricated //Depricated case '#_LOCATIONNEXTEVENTS': case '#_ALLEVENTS': //Depricated //Depricated case '#_LOCATIONALLEVENTS': //TODO: add limit to lists of events //convert depreciated placeholders for compatability $result = $result == '#_PASTEVENTS' ? '#_LOCATIONPASTEVENTS' : $result; $result = $result == '#_NEXTEVENTS' ? '#_LOCATIONNEXTEVENTS' : $result; $result = $result == '#_ALLEVENTS' ? '#_LOCATIONALLEVENTS' : $result; //forget it ever happened? :/ if ($result == '#_LOCATIONPASTEVENTS') { $scope = 'past'; } elseif ($result == '#_LOCATIONNEXTEVENTS') { $scope = 'future'; } else { $scope = 'all'; } $events_count = EM_Events::count(array('location' => $this->location_id, 'scope' => $scope)); if ($events_count > 0) { $args = array('location' => $this->location_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0); $args['format_header'] = get_option('dbem_location_event_list_item_header_format'); $args['format_footer'] = get_option('dbem_location_event_list_item_footer_format'); $args['format'] = get_option('dbem_location_event_list_item_format'); $args['limit'] = get_option('dbem_location_event_list_limit'); $args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1; $replace = EM_Events::output($args); } else { $replace = get_option('dbem_location_no_events_message'); } break; case '#_LOCATIONNEXTEVENT': $events = EM_Events::get(array('location' => $this->location_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time')); $replace = get_option('dbem_location_no_event_message'); foreach ($events as $EM_Event) { $replace = $EM_Event->output(get_option('dbem_location_event_single_format')); } break; default: $replace = $full_result; break; } $replaces[$full_result] = apply_filters('em_location_output_placeholder', $replace, $this, $full_result, $target); } //sort out replacements so that during replacements shorter placeholders don't overwrite longer varieties. krsort($replaces); foreach ($replaces as $full_result => $replacement) { if (!in_array($full_result, array('#_DESCRIPTION', '#_LOCATIONNOTES'))) { $location_string = str_replace($full_result, $replacement, $location_string); } else { $desc_replace[$full_result] = $replacement; } } //Finally, do the location notes, so that previous placeholders don't get replaced within the content, which may use shortcodes if (!empty($desc_replace)) { foreach ($desc_replace as $full_result => $replacement) { $location_string = str_replace($full_result, $replacement, $location_string); } } return apply_filters('em_location_output', $location_string, $this, $format, $target); }
/** * Delete events when you delete a user. */ function bp_em_remove_data($user_id) { $EM_Events = EM_Events::get(array('scope' => 'all', 'owner' => $user_id, 'status' => false)); EM_Events::delete($EM_Events); }
</div> </section> <section id="pconferencias" class="pconferencias proximas"> <section class="cuadro"> <div class="titulos uppercase"> <p>Próximas <span> Conferencias </span> </div> <div class="conferenciasWrapper"> <?php if (class_exists('EM_Events')) { $EM_Events = EM_Events::get(array('orderby' => 'event_start_date', 'category' => 'conferencias', 'scope' => 'future')); foreach ($EM_Events as $EM_Event) { ?> <div class="itemCuadro"> <p class="titulo uppercase"><?php echo $EM_Event->event_name; ?> </p> <p>SEDE: <?php echo $EM_Event->output("#_LOCATIONNAME"); ?> </p> <p><?php echo $EM_Event->output("#_LOCATIONADDRESS");
/** * Removes all reoccurring events. * @param $recurrence_id * @return null */ function delete_events() { global $wpdb; do_action('em_event_delete_events_pre', $this); //So we don't do something we'll regret later, we could just supply the get directly into the delete, but this is safer $result = false; if ($this->can_manage('delete_events', 'delete_others_events')) { $EM_Events = EM_Events::get(array('recurrence_id' => $this->id)); $event_ids = array(); foreach ($EM_Events as $EM_Event) { if ($EM_Event->recurrence_id == $this->id) { $event_ids[] = $EM_Event->id; //ONLY ADD if id's match - hard coded } } $result = EM_Events::delete($event_ids); } return apply_filters('delete_events', $result, $this); }
/** * If event is recurring, set recurrences to same status as template * @param $status */ function set_status_events($status) { //give sub events same status $events_array = EM_Events::get(array('recurrence_id' => $this->post_id, 'scope' => 'all', 'status' => false)); foreach ($events_array as $EM_Event) { /* @var $EM_Event EM_Event */ if ($EM_Event->recurrence_id == $this->event_id) { $EM_Event->set_status($status); } } }
echo esc_html(get_option('dbem_rss_main_description')); ?> </description> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <pubDate><?php echo get_option('em_rss_pubdate', date('D, d M Y H:i:s T')); ?> </pubDate> <atom:link href="<?php echo esc_attr(EM_RSS_URI); ?> " rel="self" type="application/rss+xml" /> <?php $description_format = str_replace(">", ">", str_replace("<", "<", get_option('dbem_rss_description_format'))); //$EM_Events = new EM_Events( array('limit'=>5, 'owner'=>false) ); $EM_Events = EM_Events::get(array('scope' => 'future', 'owner' => false)); foreach ($EM_Events as $EM_Event) { /* @var $EM_Event EM_Event */ $description = $EM_Event->output(get_option('dbem_rss_description_format'), "rss"); $description = ent2ncr(convert_chars($description)); //Some RSS filtering $event_url = $EM_Event->output('#_EVENTURL'); ?> <item> <title><?php echo $EM_Event->output(get_option('dbem_rss_title_format'), "rss"); ?> </title> <link><?php echo $event_url; ?>
/** * Determines whether to show event page or events page, and saves any updates to the event or events * @return null */ function em_bookings_events_table() { //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc) global $wpdb; global $EM_Event; $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem')); $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table'; $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : ''; $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC'; $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20; //Default limit $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1; $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0; $scope = $action_scope && !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future'; // No action, only showing the events list switch ($scope) { case "past": $title = __('Past Events', 'dbem'); break; case "all": $title = __('All Events', 'dbem'); break; default: $title = __('Future Events', 'dbem'); $scope = "future"; } $owner = !current_user_can('manage_others_bookings') ? get_current_user_id() : false; $events = EM_Events::get(array('scope' => $scope, 'limit' => $limit, 'offset' => $offset, 'order' => $order, 'bookings' => true, 'owner' => $owner)); $events_count = EM_Events::count(array('scope' => $scope, 'limit' => 0, 'order' => $order, 'bookings' => true, 'owner' => $owner)); $use_events_end = get_option('dbem_use_event_end'); ?> <div class="wrap em_bookings_events_table em_obj"> <form id="posts-filter" action="" method="get"> <input type="hidden" name="em_obj" value="em_bookings_events_table" /> <?php if (!empty($_GET['page'])) { ?> <input type='hidden' name='page' value='events-manager-bookings' /> <?php } ?> <div class="tablenav"> <div class="alignleft actions"> <!-- <select name="action"> <option value="-1" selected="selected"><?php esc_html_e('Bulk Actions'); ?> </option> <option value="deleteEvents"><?php esc_html_e('Delete selected', 'dbem'); ?> </option> </select> <input type="submit" value="<?php esc_html_e('Apply'); ?> " name="doaction2" id="doaction2" class="button-secondary action" /> --> <select name="scope"> <?php foreach ($scope_names as $key => $value) { $selected = ""; if ($key == $scope) { $selected = "selected='selected'"; } echo "<option value='{$key}' {$selected}>{$value}</option> "; } ?> </select> <input id="post-query-submit" class="button-secondary" type="submit" value="<?php esc_html_e('Filter'); ?> " /> </div> <!-- <div class="view-switch"> <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a> </div> --> <?php if ($events_count >= $limit) { $events_nav = em_admin_paginate($events_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_events_table')); echo $events_nav; } ?> </div> <?php if (empty($events)) { // TODO localize _e('no events', 'dbem'); } else { ?> <div class='table-wrap'> <table class="widefat"> <thead> <tr> <th><?php esc_html_e('Event', 'dbem'); ?> </th> <th><?php esc_html_e('Date and time', 'dbem'); ?> </th> </tr> </thead> <tbody> <?php $rowno = 0; foreach ($events as $event) { /* @var $event EM_Event */ $rowno++; $class = $rowno % 2 ? ' class="alternate"' : ''; // FIXME set to american $localised_start_date = date_i18n(get_option('date_format'), $event->start); $localised_end_date = date_i18n(get_option('date_format'), $event->end); $style = ""; $today = date("Y-m-d"); if ($event->start_date < $today && $event->end_date < $today) { $style = "style ='background-color: #FADDB7;'"; } ?> <tr <?php echo "{$class} {$style}"; ?> > <td> <strong> <?php echo $event->output('#_BOOKINGSLINK'); ?> </strong> – <?php esc_html_e("Booked Spaces", 'dbem'); ?> : <?php echo $event->get_bookings()->get_booked_spaces() . "/" . $event->get_spaces(); ?> <?php if (get_option('dbem_bookings_approval') == 1) { ?> | <?php esc_html_e("Pending", 'dbem'); ?> : <?php echo $event->get_bookings()->get_pending_spaces(); ?> <?php } ?> </td> <td> <?php echo $localised_start_date; ?> <?php echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : ''; ?> – <?php //TODO Should 00:00 - 00:00 be treated as an all day event? echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <?php } // end of table ?> <div class='tablenav'> <div class="alignleft actions"> <br class='clear' /> </div> <?php if (!empty($events_nav) && $events_count >= $limit) { ?> <div class="tablenav-pages"> <?php echo $events_nav; ?> </div> <?php } ?> <br class='clear' /> </div> </form> </div> <?php }
public static function get($args) { global $wpdb; $calendar_array = array(); $calendar_array['cells'] = array(); $args = apply_filters('em_calendar_get_args', $args); $original_args = $args; $args = self::get_default_search($args); $full = $args['full']; //For ZDE, don't delete pls $month = $args['month']; $year = $args['year']; $long_events = $args['long_events']; $limit = $args['limit']; //limit arg will be used per day and not for events search $week_starts_on_sunday = get_option('dbem_week_starts_sunday'); $start_of_week = get_option('start_of_week'); if (!(is_numeric($month) && $month <= 12 && $month > 0)) { $month = date('m', current_time('timestamp')); } if (!is_numeric($year)) { $year = date('Y', current_time('timestamp')); } // Get the first day of the month $month_start = mktime(0, 0, 0, $month, 1, $year); $calendar_array['month_start'] = $month_start; // Get friendly month name $month_name = date('M', $month_start); // Figure out which day of the week // the month starts on. $month_start_day = date('D', $month_start); switch ($month_start_day) { case "Sun": $offset = 0; break; case "Mon": $offset = 1; break; case "Tue": $offset = 2; break; case "Wed": $offset = 3; break; case "Thu": $offset = 4; break; case "Fri": $offset = 5; break; case "Sat": $offset = 6; break; } //We need to go back to the WP defined day when the week started, in case the event day is near the end $offset -= $start_of_week; if ($offset < 0) { $offset += 7; } // determine how many days are in the last month. $month_last = $month - 1; $month_next = $month + 1; $calendar_array['month_next'] = $month_next; $year_last = $year; $year_next = $year; $calendar_array['year_next'] = $year_next; if ($month == 1) { $month_last = 12; $year_last = $year - 1; } elseif ($month == 12) { $month_next = 1; $year_next = $year + 1; } $calendar_array['month_last'] = $month_last; $calendar_array['year_last'] = $year_last; $num_days_last = self::days_in_month($month_last, $year_last); // determine how many days are in the current month. $num_days_current = self::days_in_month($month, $year); // Build an array for the current days // in the month for ($i = 1; $i <= $num_days_current; $i++) { $num_days_array[] = mktime(0, 0, 0, $month, $i, $year); } // Build an array for the number of days // in last month for ($i = 1; $i <= $num_days_last; $i++) { $num_days_last_array[] = mktime(0, 0, 0, $month_last, $i, $year_last); } // If the $offset from the starting day of the // week happens to be Sunday, $offset would be 0, // so don't need an offset correction. if ($offset > 0) { $offset_correction = array_slice($num_days_last_array, -$offset, $offset); $new_count = array_merge($offset_correction, $num_days_array); $offset_count = count($offset_correction); } else { // The else statement is to prevent building the $offset array. $offset_count = 0; $new_count = $num_days_array; } // count how many days we have with the two // previous arrays merged together $current_num = count($new_count); // Since we will have 5 HTML table rows (TR) // with 7 table data entries (TD) // we need to fill in 35 TDs // so, we will have to figure out // how many days to appened to the end // of the final array to make it 35 days. if (!empty($args['number_of_weeks']) && is_numeric($args['number_of_weeks'])) { $num_weeks = $args['number_of_weeks']; } elseif ($current_num > 35) { $num_weeks = 6; } else { $num_weeks = 5; } $outset = $num_weeks * 7 - $current_num; // Outset Correction for ($i = 1; $i <= $outset; $i++) { $new_count[] = mktime(0, 0, 0, $month_next, $i, $year_next); } // Now let's "chunk" the $all_days array // into weeks. Each week has 7 days // so we will array_chunk it into 7 days. $weeks = array_chunk($new_count, 7); //Get an array of arguments that don't include default valued args $link_args = self::get_link_args($args); $previous_url = "?ajaxCalendar=1&mo={$month_last}&yr={$year_last}&{$link_args}"; $next_url = "?ajaxCalendar=1&mo={$month_next}&yr={$year_next}&{$link_args}"; $weekdays = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); if (!empty($args['full'])) { if (get_option('dbem_full_calendar_abbreviated_weekdays')) { $weekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); } $day_initials_length = get_option('dbem_full_calendar_initials_length'); } else { if (get_option('dbem_small_calendar_abbreviated_weekdays')) { $weekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); } $day_initials_length = get_option('dbem_small_calendar_initials_length'); } for ($n = 0; $n < $start_of_week; $n++) { $last_day = array_shift($weekdays); $weekdays[] = $last_day; } $days_initials_array = array(); foreach ($weekdays as $weekday) { $days_initials_array[] = self::translate_and_trim($weekday, $day_initials_length); } $calendar_array['links'] = array('previous_url' => $previous_url, 'next_url' => $next_url); $calendar_array['row_headers'] = $days_initials_array; // Now we break each key of the array // into a week and create a new table row for each // week with the days of that week in the table data $i = 0; $current_date = date('Y-m-d', current_time('timestamp')); $week_count = 0; foreach ($weeks as $week) { foreach ($week as $d) { $date = date('Y-m-d', $d); $calendar_array['cells'][$date] = array('date' => $d, 'events' => array(), 'events_count' => 0); //set it up so we have the exact array of dates to be filled if ($i < $offset_count) { //if it is PREVIOUS month $calendar_array['cells'][$date]['type'] = 'pre'; } if ($i >= $offset_count && $i < $num_weeks * 7 - $outset) { // if it is THIS month if ($current_date == $date) { $calendar_array['cells'][$date]['type'] = 'today'; } } elseif ($outset > 0) { //if it is NEXT month if ($i >= $num_weeks * 7 - $outset) { $calendar_array['cells'][$date]['type'] = 'post'; } } $i++; } $week_count++; } //query the database for events in this time span with $offset days before and $outset days after this month to account for these cells in the calendar $scope_datetime_start = new DateTime("{$year}-{$month}-1"); $scope_datetime_end = new DateTime($scope_datetime_start->format('Y-m-t')); $scope_datetime_start->modify("-{$offset} days"); $scope_datetime_end->modify("+{$outset} days"); //we have two methods here, one for high-volume event sites i.e. many thousands of events per month, and another for thousands or less per month. $args['array'] = true; //we're getting an array first to avoid extra queries during object creation unset($args['month']); unset($args['year']); unset($args['limit']); //limits in the events search won't help if (defined('EM_CALENDAR_OPT') && EM_CALENDAR_OPT) { //here we loop through each day, query that specific date, and then compile a list of event objects //in this mode the count will never be accurate, we're grabing at most (31 + 14 days) * (limit + 1) events to reduce memory loads $args['limit'] = $limit + 1; $scope_datetime_loop = $scope_datetime_start->format('U'); $events = array(); while ($scope_datetime_loop <= $scope_datetime_end->format('U')) { $args['scope'] = date('Y-m-d', $scope_datetime_loop); foreach (EM_Events::get($args) as $event) { $events[$event['event_id']] = $event; } $scope_datetime_loop += 86400; //add a day } } else { //just load all the events for this time-range $args['scope'] = array($scope_datetime_start->format('Y-m-d'), $scope_datetime_end->format('Y-m-d')); $events = EM_Events::get($args); } //back to what it was $args['month'] = $month; $args['year'] = $year; $args['limit'] = $limit; $event_format = get_option('dbem_full_calendar_event_format'); $event_title_format = get_option('dbem_small_calendar_event_title_format'); $event_title_separator_format = get_option('dbem_small_calendar_event_title_separator'); $eventful_days = array(); $eventful_days_count = array(); if ($events) { //Go through the events and slot them into the right d-m index foreach ($events as $event) { $event = apply_filters('em_calendar_output_loop_start', $event); if ($long_events) { //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day $event_start_ts = strtotime($event['event_start_date']); $event_end_ts = strtotime($event['event_end_date']); $event_end_ts = $event_end_ts > $scope_datetime_end->format('U') ? $scope_datetime_end->format('U') : $event_end_ts; while ($event_start_ts <= $event_end_ts) { //we loop until the last day of our time-range, not the end date of the event, which could be in a year //Ensure date is within event dates and also within the limits of events to show per day, if so add to eventful days array $event_eventful_date = date('Y-m-d', $event_start_ts); if (empty($eventful_days_count[$event_eventful_date]) || !$limit || $eventful_days_count[$event_eventful_date] < $limit) { //now we know this is an event that'll be used, convert it to an object $EM_Event = EM_MS_GLOBAL ? em_get_event($event['post_id'], $event['blog_id']) : ($EM_Event = em_get_event($event['post_id'], 'post_id')); if (empty($eventful_days[$event_eventful_date]) || !is_array($eventful_days[$event_eventful_date])) { $eventful_days[$event_eventful_date] = array(); } //add event to array with a corresponding timestamp for sorting of times including long and all-day events $event_ts_marker = $EM_Event->event_all_day ? 0 : (int) strtotime($event_eventful_date . ' ' . $EM_Event->event_start_time); while (!empty($eventful_days[$event_eventful_date][$event_ts_marker])) { $event_ts_marker++; //add a second } $eventful_days[$event_eventful_date][$event_ts_marker] = $EM_Event; } //count events for that day $eventful_days_count[$event_eventful_date] = empty($eventful_days_count[$event_eventful_date]) ? 1 : $eventful_days_count[$event_eventful_date] + 1; $event_start_ts += 86400; //add a day } } else { //Only show events on the day that they start $event_eventful_date = $event['event_start_date']; if (empty($eventful_days_count[$event_eventful_date]) || !$limit || $eventful_days_count[$event_eventful_date] < $limit) { $EM_Event = EM_MS_GLOBAL ? em_get_event($event['post_id'], $event['blog_id']) : em_get_event($event['post_id'], 'post_id'); if (empty($eventful_days[$event_eventful_date]) || !is_array($eventful_days[$event_eventful_date])) { $eventful_days[$event_eventful_date] = array(); } //add event to array with a corresponding timestamp for sorting of times including long and all-day events $event_ts_marker = $EM_Event->event_all_day ? 0 : (int) $EM_Event->start; while (!empty($eventful_days[$event_eventful_date][$event_ts_marker])) { $event_ts_marker++; //add a second } $eventful_days[$event_eventful_date][$event_ts_marker] = $EM_Event; } //count events for that day $eventful_days_count[$event['event_start_date']] = empty($eventful_days_count[$event['event_start_date']]) ? 1 : $eventful_days_count[$event['event_start_date']] + 1; } } } //generate a link argument string containing event search only $day_link_args = self::get_link_args(array_intersect_key($original_args, EM_Events::get_post_search($args, true))); foreach ($eventful_days as $day_key => $events) { if (array_key_exists($day_key, $calendar_array['cells'])) { //Get link title for this date $events_titles = array(); foreach ($events as $event) { if (!$limit || count($events_titles) < $limit) { $events_titles[] = $event->output($event_title_format); } else { $events_titles[] = get_option('dbem_display_calendar_events_limit_msg'); break; } } $calendar_array['cells'][$day_key]['link_title'] = implode($event_title_separator_format, $events_titles); //Get the link to this calendar day global $wp_rewrite; if ($eventful_days_count[$day_key] > 1 || !get_option('dbem_calendar_direct_links')) { if (get_option("dbem_events_page") > 0) { $event_page_link = get_permalink(get_option("dbem_events_page")); //PAGE URI OF EM } else { if ($wp_rewrite->using_permalinks()) { $event_page_link = trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/'; //don't use EM_URI here, since ajax calls this before EM_URI is defined. } else { $event_page_link = trailingslashit(home_url()) . '?post_type=' . EM_POST_TYPE_EVENT; //don't use EM_URI here, since ajax calls this before EM_URI is defined. } } if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) { $calendar_array['cells'][$day_key]['link'] = trailingslashit($event_page_link) . $day_key . "/"; if (!empty($day_link_args)) { $calendar_array['cells'][$day_key]['link'] .= '?' . $day_link_args; } } else { $joiner = stristr($event_page_link, "?") ? "&" : "?"; $calendar_array['cells'][$day_key]['link'] = $event_page_link . $joiner . "calendar_day=" . $day_key; if (!empty($day_link_args)) { $calendar_array['cells'][$day_key]['link'] .= '&' . $day_link_args; } } } else { foreach ($events as $EM_Event) { $calendar_array['cells'][$day_key]['link'] = $EM_Event->get_permalink(); } } //Add events to array $calendar_array['cells'][$day_key]['events_count'] = $eventful_days_count[$day_key]; $calendar_array['cells'][$day_key]['events'] = $events; } } return apply_filters('em_calendar_get', $calendar_array, $args); }
<?php do_action('em_template_my_bookings_header'); global $wpdb, $current_user, $EM_Notices, $EM_Person; if (is_user_logged_in()) { $EM_Person = new EM_Person(get_current_user_id()); $EM_Bookings = $EM_Person->get_bookings(); $bookings_count = count($EM_Bookings->bookings); if ($bookings_count > 0) { //Get events here in one query to speed things up $event_ids = array(); foreach ($EM_Bookings as $EM_Booking) { $event_ids[] = $EM_Booking->event_id; } $EM_Events = EM_Events::get($event_ids); } $limit = !empty($_GET['limit']) ? $_GET['limit'] : 20; //Default limit $page = !empty($_GET['pno']) ? $_GET['pno'] : 1; $offset = $page > 1 ? ($page - 1) * $limit : 0; echo $EM_Notices; ?> <div class='em-my-bookings'> <!-- <ul class="subsubsub"> <li> <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> | </li> </ul> --> <?php
/** * Generates a "widget" table of confirmed bookings for a specific event. * * @param int $event_id */ function em_bookings_person_table() { global $wpdb, $current_user, $EM_Person; if (!is_object($EM_Person)) { return false; } $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_confirmed_table'; $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : ''; $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC'; $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20; //Default limit $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1; $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0; $bookings = $EM_Person->get_bookings(); $bookings_count = count($bookings); if ($bookings_count > 0) { //Get events here in one query to speed things up foreach ($bookings as $EM_Booking) { $event_ids[] = $EM_Booking->event_id; } $events = EM_Events::get($event_ids); } ?> <div class='wrap em_bookings_pending_table em_obj'> <form id='bookings-filter' method='get' action='<?php bloginfo('wpurl'); ?> /wp-admin/edit.php'> <input type="hidden" name="em_obj" value="em_bookings_pending_table" /> <!-- <ul class="subsubsub"> <li> <a href='edit.php?post_type=post' class="current">All <span class="count">(1)</span></a> | </li> </ul> <p class="search-box"> <label class="screen-reader-text" for="post-search-input"><?php _e('Search'); ?> :</label> <input type="text" id="post-search-input" name="em_search" value="<?php echo !empty($_GET['em_search']) ? $_GET['em_search'] : ''; ?> " /> <input type="submit" value="<?php _e('Search'); ?> " class="button" /> </p> --> <?php if ($bookings_count >= $limit) { ?> <div class='tablenav'> <!-- <div class="alignleft actions"> <select name="action"> <option value="-1" selected="selected"> <?php _e('Bulk Actions'); ?> </option> <option value="approve"> <?php _e('Approve', 'dbem'); ?> </option> <option value="decline"> <?php _e('Decline', 'dbem'); ?> </option> </select> <input type="submit" id="post-query-submit" value="Filter" class="button-secondary" /> </div> --> <!-- <div class="view-switch"> <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a> </div> --> <?php if ($bookings_count >= $limit) { $bookings_nav = em_admin_paginate($bookings_count, $limit, $page, array('em_ajax' => 0, 'em_obj' => 'em_bookings_confirmed_table')); echo $bookings_nav; } ?> <div class="clear"></div> </div> <?php } ?> <div class="clear"></div> <?php if ($bookings_count > 0) { ?> <div class='table-wrap'> <table id='dbem-bookings-table' class='widefat post '> <thead> <tr> <th class='manage-column column-cb check-column' scope='col'> <input class='select-all' type="checkbox" value='1' /> </th> <th class='manage-column' scope='col'>Event</th> <th class='manage-column' scope='col'>Spaces</th> <th class='manage-column' scope='col'>Status</th> <th class='manage-column' scope='col'> </th> </tr> </thead> <tbody> <?php $rowno = 0; $event_count = 0; foreach ($bookings as $EM_Booking) { $EM_Event = $events[$EM_Booking->event_id]; if ($EM_Event->can_manage('edit_events', 'edit_others_events') && ($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) { $rowno++; ?> <tr> <th scope="row" class="check-column" style="padding:7px 0px 7px;"><input type='checkbox' value='<?php echo $EM_Booking->id; ?> ' name='bookings[]'/></th> <td><a class="row-title" href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-bookings&event_id=<?php echo $EM_Event->id; ?> "><?php echo $EM_Event->name; ?> </a></td> <td><?php echo $EM_Booking->get_spaces(); ?> </td> <td><?php echo $EM_Booking->status_array[$EM_Booking->status]; ?> </td> <td> <?php $unapprove_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_unapprove', 'bookings' => $EM_Booking->id)); $approve_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_approve', 'bookings' => $EM_Booking->id)); $reject_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_reject', 'bookings' => $EM_Booking->id)); $delete_url = em_add_get_params($_SERVER['REQUEST_URI'], array('action' => 'bookings_delete', 'bookings' => $EM_Booking->id)); ?> <?php if (get_option('dbem_bookings_approval') && $EM_Booking->status == 0) { ?> <a class="em-bookings-approve" href="<?php echo $approve_url; ?> "><?php _e('Approve', 'dbem'); ?> </a> | <?php } ?> <?php if (get_option('dbem_bookings_approval') && $EM_Booking->status == 1) { ?> <a class="em-bookings-unapprove" href="<?php echo $unapprove_url; ?> "><?php _e('Unapprove', 'dbem'); ?> </a> | <?php } ?> <?php if ($EM_Booking->status == 2) { ?> <a class="em-bookings-approve" href="<?php echo $approve_url; ?> "><?php _e('Restore', 'dbem'); ?> </a> | <?php } ?> <?php if ($EM_Booking->status == 0 || $EM_Booking->status == 1) { ?> <a class="em-bookings-reject" href="<?php echo $reject_url; ?> "><?php _e('Reject', 'dbem'); ?> </a> | <?php } ?> <a class="em-bookings-edit" href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-bookings&booking_id=<?php echo $EM_Booking->id; ?> "><?php _e('Edit/View', 'dbem'); ?> </a> | <span class="trash"><a class="em-bookings-delete" href="<?php echo $delete_url; ?> "><?php _e('Delete', 'dbem'); ?> </a></span> </td> </tr> <?php } $event_count++; } ?> </tbody> </table> </div> <?php } else { ?> <?php _e('No confirmed bookings.', 'dbem'); ?> <?php } ?> </form> <?php if (!empty($bookings_nav) && $bookings >= $limit) { ?> <div class='tablenav'> <?php echo $bookings_nav; ?> <div class="clear"></div> </div> <?php } ?> </div> <?php }
/** * Determines whether to show event page or events page, and saves any updates to the event or events * @return null */ function em_bookings_events_table() { //TODO Simplify panel for events, use form flags to detect certain actions (e.g. submitted, etc) global $wpdb; global $EM_Event; $scope_names = array('past' => __('Past events', 'dbem'), 'all' => __('All events', 'dbem'), 'future' => __('Future events', 'dbem')); $action_scope = !empty($_REQUEST['em_obj']) && $_REQUEST['em_obj'] == 'em_bookings_events_table'; $action = $action_scope && !empty($_GET['action']) ? $_GET['action'] : ''; $order = $action_scope && !empty($_GET['order']) ? $_GET['order'] : 'ASC'; $limit = $action_scope && !empty($_GET['limit']) ? $_GET['limit'] : 20; //Default limit $page = $action_scope && !empty($_GET['pno']) ? $_GET['pno'] : 1; $offset = $action_scope && $page > 1 ? ($page - 1) * $limit : 0; $scope = $action_scope && !empty($_GET['scope']) && array_key_exists($_GET['scope'], $scope_names) ? $_GET['scope'] : 'future'; // No action, only showing the events list switch ($scope) { case "past": $title = __('Past Events', 'dbem'); break; case "all": $title = __('All Events', 'dbem'); break; default: $title = __('Future Events', 'dbem'); $scope = "future"; } $events = EM_Events::get(array('scope' => $scope, 'limit' => 0, 'order' => $order, 'rsvp' => true)); $events_count = count($events); $use_events_end = get_option('dbem_use_event_end'); ?> <div class="wrap em_bookings_events_table em_obj"> <form id="posts-filter" action="<?php echo $_SERVER['REQUEST_URI']; ?> " method="get"> <input type="hidden" name="em_obj" value="em_bookings_events_table" /> <?php if (!empty($_GET['page'])) { ?> <input type='hidden' name='page' value='events-manager-bookings' /> <?php } ?> <ul class="subsubsub"> <li><a href='#' class="current"><?php _e('Total', 'dbem'); ?> <span class="count">(<?php echo count($events); ?> )</span></a></li> </ul> <div class="tablenav"> <div class="alignleft actions"> <!-- <select name="action"> <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?> </option> <option value="deleteEvents"><?php _e('Delete selected', 'dbem'); ?> </option> </select> <input type="submit" value="<?php _e('Apply'); ?> " name="doaction2" id="doaction2" class="button-secondary action" /> --> <select name="scope"> <?php foreach ($scope_names as $key => $value) { $selected = ""; if ($key == $scope) { $selected = "selected='selected'"; } echo "<option value='{$key}' {$selected}>{$value}</option> "; } ?> </select> <input id="post-query-submit" class="button-secondary" type="submit" value="<?php _e('Filter'); ?> " /> </div> <!-- <div class="view-switch"> <a href="/wp-admin/edit.php?mode=list"><img class="current" id="view-switch-list" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="List View" alt="List View" name="view-switch-list" /></a> <a href="/wp-admin/edit.php?mode=excerpt"><img id="view-switch-excerpt" src="http://wordpress.lan/wp-includes/images/blank.gif" width="20" height="20" title="Excerpt View" alt="Excerpt View" name="view-switch-excerpt" /></a> </div> --> <?php if ($events_count >= $limit) { $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], array('pno' => '%PAGE%', 'em_ajax' => 0, 'em_obj' => 'em_bookings_events_table')); $events_nav = em_admin_paginate($page_link_template, $events_count, $limit, $page, 5); echo $events_nav; } ?> <br class="clear" /> </div> <?php if (empty($events)) { // TODO localize _e('no events', 'dbem'); } else { ?> <div class='table-wrap'> <table class="widefat"> <thead> <tr> <th class='manage-column column-cb check-column' scope='col'> <input class='select-all' type="checkbox" value='1' /> </th> <th><?php _e('Event', 'dbem'); ?> </th> <th><?php _e('Date and time', 'dbem'); ?> </th> </tr> </thead> <tbody> <?php $rowno = 0; $event_count = 0; foreach ($events as $event) { /* @var $event EM_Event */ if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) { $rowno++; $class = $rowno % 2 ? ' class="alternate"' : ''; // FIXME set to american $localised_start_date = date_i18n('D d M Y', $event->start); $localised_end_date = date_i18n('D d M Y', $event->end); $style = ""; $today = date("Y-m-d"); if ($event->start_date < $today && $event->end_date < $today) { $style = "style ='background-color: #FADDB7;'"; } ?> <tr <?php echo "{$class} {$style}"; ?> > <td> <input type='checkbox' class='row-selector' value='<?php echo $event->id; ?> ' name='events[]' /> </td> <td> <strong> <a class="row-title" href="<?php bloginfo('wpurl'); ?> /wp-admin/admin.php?page=events-manager-bookings&event_id=<?php echo $event->id; ?> "><?php echo $event->name; ?> </a> </strong> – <?php _e("Booked Seats", 'dbem'); ?> : <?php echo $event->get_bookings()->get_booked_seats() . "/" . $event->seats; ?> <?php if (get_option('dbem_bookings_approval') == 1) { ?> | <?php _e("Pending", 'dbem'); ?> : <?php echo $event->get_bookings()->get_pending_seats(); ?> <?php } ?> </td> <td> <?php echo $localised_start_date; ?> <?php echo $localised_end_date != $localised_start_date ? " - {$localised_end_date}" : ''; ?> – <?php //TODO Should 00:00 - 00:00 be treated as an all day event? echo substr($event->start_time, 0, 5) . " - " . substr($event->end_time, 0, 5); ?> </td> </tr> <?php } $event_count++; } ?> </tbody> </table> </div> <?php } // end of table ?> <div class='tablenav'> <div class="alignleft actions"> <br class='clear' /> </div> <?php if (!empty($events_nav)) { ?> <div class="tablenav-pages"> <?php echo $events_nav; ?> </div> <?php } ?> <br class='clear' /> </div> </form> </div> <?php }
public static function untrash_post($post_id) { if (get_post_type($post_id) == 'event-recurring') { global $wpdb; //set a constant so we know this event doesn't need 'saving' if (!defined('UNTRASHING_' . $post_id)) { define('UNTRASHING_' . $post_id, true); } $EM_Event = em_get_event($post_id, 'post_id'); $events_array = EM_Events::get(array('recurrence_id' => $EM_Event->event_id, 'scope' => 'all', 'status' => 'all')); foreach ($events_array as $event) { /* @var $event EM_Event */ if ($EM_Event->event_id == $event->recurrence_id) { wp_untrash_post($event->post_id); } } } }
public function page_event_manager_plugin($item_xml) { global $counter; // get the blog meta value $header = find_xml_value($item_xml, 'header'); $eventview = find_xml_value($item_xml, 'eventview'); $event_layout = find_xml_value($item_xml, 'event-layout'); $num_fetch = find_xml_value($item_xml, 'num-fetch'); $category = find_xml_value($item_xml, 'category'); $num_excerpt = find_xml_value($item_xml, 'num-excerpt'); $event_type = find_xml_value($item_xml, 'eventtype'); if (empty($paged)) { $paged = get_query_var('page') ? get_query_var('page') : 1; } $select_layout_cp = ''; $color_scheme = ''; $cp_general_settings = get_option('general_settings'); if ($cp_general_settings != '') { $cp_logo = new DOMDocument(); $cp_logo->loadXML($cp_general_settings); $select_layout_cp = find_xml_value($cp_logo->documentElement, 'select_layout_cp'); $color_scheme = find_xml_value($cp_logo->documentElement, 'color_scheme'); } //Event Type Condition if ($event_type == 'All Events') { $event_type = 'all'; } else { if ($event_type == 'Upcoming Events') { $event_type = 'future'; } else { if ($event_type == 'Past Events') { $event_type = 'past'; } else { } } } //Category All if ($category == '0') { $category = ''; } echo '<h2 class="h-style">' . $header . '</h2>'; //Event View if ($eventview == 'Listing View') { wp_reset_query(); wp_reset_postdata(); global $EM_Events, $bp; $limit = $num_fetch; //Default limit $page = !empty($_GET['pno']) ? $_GET['pno'] : 1; $offset = $page > 1 ? ($page - 1) * $limit : 0; $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC'; $EM_Events = EM_Events::get(array('category' => $category, 'group' => 'this', 'scope' => $event_type, 'limit' => $limit, 'order' => $order, 'pagination' => '1')); $events_count = count($EM_Events); $rowno = 0; $event_count = 0; echo '<div class="calender-box event-listing"> <div class="event-wrapper-cp">'; foreach ($EM_Events as $event) { /* @var $event EM_Event */ if (($rowno < $limit || empty($limit)) && ($event_count >= $offset || $offset === 0)) { $rowno++; $class = $rowno % 2 ? 'alternate' : ''; // FIXME set to american $localised_start_date = date_i18n(get_option('dbem_date_format'), $event->start); $localised_end_date = date_i18n(get_option('dbem_date_format'), $event->end); //print_r($event); $style = ""; $today = date("Y-m-d"); //print_R($event); if (!empty($event->location_id->name)) { $location_summary = "<b>" . $event->get_location()->name . "</b><br/>" . $event->get_location()->address . " - " . $event->get_location()->town; } else { $location_summary = ''; } if ($event->start_date < $today && $event->end_date < $today) { $class .= " past"; } //Check pending approval events if (!$event->status) { $class .= " pending"; } //echo $event->start; $event_month_alpha = date('M', $event->start); $event_day = date('d', $event->start); $event_element_id = $counter . $event->event_id; //condition for event location lat long //echo $event->start; $event_month_alpha = date('M', $event->start); $event_day = date('d', $event->start); //Get Date in Parts $event_year = date('Y', $event->start); $event_month = date('m', $event->start); $event_month_alpha = date('M', $event->start); $event_day = date('d', $event->start); //Change time format $event_start_time_count = date("G,i,s", strtotime($event->start_time)); //'options'=>array('1'=>'1 Column','2'=>'2 Columns','3'=>'3 Columns','4'=>'4 Columns'), //Empty Classes $span_class = ''; $count_val = '1'; $first_class = ''; $clear_class = ''; //if not Column 1 or Full Width then! if ($event_layout != '1 Column') { //Condition to manage Event Layouts if ($event_layout == '2 Columns') { $span_class = "span6"; $count_val = 2; } else { if ($event_layout == '3 Columns') { $span_class = "span4"; $count_val = 3; } else { if ($event_layout == '4 Columns') { $span_class = "span3"; $count_val = 4; } else { } } } //Count the events in row then break the line if ($event_count % $count_val == 0) { $first_class = 'first'; $clear_class = "<div class='clear'></div>"; } else { } //clear div echo $clear_class; ?> <div class="latest-event-box <?php echo $first_class; ?> <?php echo $span_class; ?> "> <div class="frame"> <?php echo get_the_post_thumbnail($event->post_id, array(260, 300)); ?> <div class="date"><strong class="dat"><?php echo $event_day; ?> </strong><strong class="mnt"><?php echo $event_month_alpha; ?> </strong></div> <div class="caption"> <h4><a href="<?php echo $event->guid; ?> "><?php echo substr($event->event_name, 0, 20); ?> </a></h4> <div class="text-box"> <p><?php echo mb_substr($event->post_content, 0, $num_excerpt); ?> </p> </div> </div> <div class="inner-area"> <div class="timer-box"> <div id="count_<?php echo $counter . $event->event_id; ?> " class="defaultCountdown"></div> </div> <div class="text-area"> <strong class="title"><a href="<?php echo $event->guid; ?> "><?php if (strlen($event->event_name) > 23) { echo substr($event->event_name, 0, 23) . '...'; } else { echo $event->event_name; } ?> </a></strong> <ul> <li><a href="<?php echo $event->guid; ?> "><span><i class="fa fa-user"></i></span><strong><?php echo get_the_author(); ?> </strong></a></li> <li><a href="<?php echo $event->guid; ?> "><span><i class="fa fa-calendar"></i></span><strong><?php echo date(get_option('date_format'), $event->start); ?> </strong></a></li> <li><a href="<?php echo $event->guid; ?> "><span><i class="fa fa-map-marker"></i></span><strong><?php echo $event->get_location()->location_name; ?> <br> <?php echo $event->get_location()->location_town; ?> </strong></a></li> </ul> <a class="btn-participate" href="<?php echo $event->guid; ?> "> <?php if (!empty($event->bookings)) { if ($event->can_manage('manage_bookings', 'manage_others_bookings') && get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1) { ?> <?php echo __("Bookings", 'dbem'); ?> – <?php _e("Booked", 'dbem'); ?> : <?php echo $event->get_bookings()->get_booked_spaces() . "/" . $event->get_spaces(); ?> <?php if (get_option('dbem_bookings_approval') == 1) { ?> | <?php _e("Pending", 'dbem'); ?> : <?php echo $event->get_bookings()->get_pending_spaces(); ?> <?php } } } else { _e('No Bookings', 'crunchpress'); } ?> </a> </div> </div> </div> <?php wp_enqueue_style('cp-countdown', CP_PATH_URL . '/frontend/css/jquery.countdown.css'); //Load Style wp_register_script('cp-countdown', CP_PATH_URL . '/frontend/js/jquery_countdown.js', false, '1.0', true); wp_enqueue_script('cp-countdown'); ?> <script> jQuery(document).ready(function($){ //CountDown Element if($('#count_<?php echo $counter . $event->event_id; ?> ').length){ var austDay = new Date(); austDay = new Date(<?php echo $event_year; ?> , <?php echo $event_month; ?> -1, <?php echo $event_day; ?> ,<?php echo $event_start_time_count; ?> ); $('#count_<?php echo $counter . $event->event_id; ?> ').countdown({ labels: ['<?php _e('Years', 'crunchpress'); ?> ', '<?php _e('Months', 'crunchpress'); ?> ', '<?php _e('Weeks', 'crunchpress'); ?> ', '<?php _e('Days', 'crunchpress'); ?> ', '<?php _e('HRS', 'crunchpress'); ?> ', '<?php _e('MINS', 'crunchpress'); ?> ', '<?php _e('SEC', 'crunchpress'); ?> '], until: austDay }); $('#year').text(austDay.getFullYear()); } }); </script> </div> <?php } else { ?> <!-- Latest Event Box Start--> <div class="<?php echo trim($class); ?> cp-box-event-more" <?php echo $style; ?> id="event_<?php echo $event->event_id; ?> "> <div class="event-listing-box row-fluid"> <div class="frame span5"> <?php $thumbnail_id = get_post_thumbnail_id($event->post_id); $image_thumb = wp_get_attachment_image_src($thumbnail_id, array(360, 300)); if ($image_thumb[1] == '360' and $image_thumb[2] == '300') { ?> <a href="<?php echo $event->guid; ?> "><?php echo get_the_post_thumbnail($event->post_id, array(360, 300)); ?> </a> <?php } ?> <div class="date-box-02"> <strong class="date"><?php echo $event_day; ?> </strong> <strong class="mnt"><?php echo $event_month; ?> </strong> </div> <div class="caption"> <div class="timer-section"> <div id="count_<?php echo $counter . $event->event_id; ?> " class="defaultCountdown"></div> </div> <a class="btn-participate" href="<?php echo $event->guid; ?> "> <?php if (!empty($event->bookings)) { if ($event->can_manage('manage_bookings', 'manage_others_bookings') && get_option('dbem_rsvp_enabled') == 1 && $event->rsvp == 1) { ?> <?php echo __("Bookings", 'dbem'); ?> – <?php _e("Booked", 'dbem'); ?> : <?php echo $event->get_bookings()->get_booked_spaces() . "/" . $event->get_spaces(); ?> <?php if (get_option('dbem_bookings_approval') == 1) { ?> | <?php _e("Pending", 'dbem'); ?> : <?php echo $event->get_bookings()->get_pending_spaces(); ?> <?php } } } else { _e('No Bookings', 'crunchpress'); } ?> </a> </div> </div> <div class="text-box span7"> <h2><a href="<?php echo $event->guid; ?> "><?php echo $event->event_name; ?> </a></h2> <p><?php echo mb_substr($event->post_content, 0, $num_excerpt); ?> </p> <?php if (strlen($event->post_content > $num_excerpt)) { ?> <a href="<?php echo $event->guid; ?> " class="readmore"><?php echo __('Read More', 'crunchpress'); ?> </a><?php } ?> <div class="detail-row"> <a href="#"><i class="fa fa-user"></i><?php _e('John Doe', 'crunchpress'); ?> </a> <a href="#"><i class="fa fa-map-marker"></i><?php if ($event->location_id != 0) { echo $event->get_location()->address; } else { _e('Location Disabled', 'crunchpress'); } ?> </a> </div> </div> </div> <script> jQuery(document).ready(function($){ //CountDown Element if($('#count_<?php echo $counter . $event->event_id; ?> ').length){ var austDay = new Date(); austDay = new Date(<?php echo $event_year; ?> , <?php echo $event_month; ?> -1, <?php echo $event_day; ?> ,<?php echo $event_start_time_count; ?> ); $('#count_<?php echo $counter . $event->event_id; ?> ').countdown({ //labels: ['<?php _e('Years', 'crunchpress'); ?> ', '<?php _e('Months', 'crunchpress'); ?> ', '<?php _e('Weeks', 'crunchpress'); ?> ', '<?php _e('Days', 'crunchpress'); ?> ', '<?php _e('Hours', 'crunchpress'); ?> ', '<?php _e('Minutes', 'crunchpress'); ?> ', '<?php _e('Seconds', 'crunchpress'); ?> '], labels: ['<?php _e('Years', 'crunchpress'); ?> ', '<?php _e('Months', 'crunchpress'); ?> ', '<?php _e('Weeks', 'crunchpress'); ?> ', '<?php _e('Days', 'crunchpress'); ?> ', '<?php _e('HRS', 'crunchpress'); ?> ', '<?php _e('MINS', 'crunchpress'); ?> ', '<?php _e('SEC', 'crunchpress'); ?> '], until: austDay }); $('#year').text(austDay.getFullYear()); } }); </script> </div> <?php } } $event_count++; } echo '</div></div>'; echo '<div class="cp_load fadeIn">'; // $link = em_add_get_params($_SERVER['REQUEST_URI'], array('pno'=>'%PAGE%'), false); //don't html encode, so em_paginate does its thing // echo em_paginate( $link, $events_count, $limit, $page); // if( find_xml_value($item_xml, "pagination") == "Theme-Custom" ){ // pagination(); // } echo '</div>'; } else { global $EM_Events, $bp; $order = !empty($_REQUEST['order']) ? $_REQUEST['order'] : 'ASC'; $limit = $num_fetch; //Default limit $offset = $paged > 1 ? ($paged - 1) * $limit : 0; $EM_Events = EM_Events::get(array('category' => '', 'group' => 'this', 'scope' => 'all', 'limit' => '100', 'order' => 'ASC')); $events_count = count($EM_Events); $rowno = 0; $event_count = 0; wp_enqueue_style('cp-calender-view', CP_PATH_URL . '/framework/javascript/fullcalendar/fullcalendar.css'); ?> <script> jQuery(document).ready(function($) { var date = new Date(); $('#calendar_view-<?php echo $counter; ?> ').fullCalendar({ editable: false, header: { left: 'prev,next', center: 'title', right: '' }, buttonText: { prev: "<span class='fc-text-arrow'>Previous Month</span>", next: "<span class='fc-text-arrow'>Next Month</span>", }, disableDragging: true, events: [ <?php foreach ($EM_Events as $event) { // FIXME set to american $localised_start_date = date_i18n(get_option('dbem_date_format'), $event->start); $localised_end_date = date_i18n(get_option('dbem_date_format'), $event->end); $style = ""; $today = date("Y-m-d"); //$location_summary = "<b>" . $event->get_location()->name . "</b><br/>" . $event->get_location()->address . " - " . $event->get_location()->town; if ($event->start_date < $today && $event->end_date < $today) { $class .= " past"; } //Check pending approval events if (!$event->status) { $class .= " pending"; } //echo $event->start; $event_month_alpha = date('M', $event->start); $event_day = date('d', $event->start); $hour_start = date("H", strtotime($event->start_time)); $mint_start = date("i", strtotime($event->start_time)); $hour_end = date("H", strtotime($event->end_time)); $mint_end = date("i", strtotime($event->end_time)); //Start From $year_from = date("Y", $event->start); $month_from = date("m", $event->start); $day_from = date("d", $event->start); //Ends on $year_to = date("Y", $event->end); $month_to = date("m", $event->end); $day_to = date("d", $event->end); ?> { title: '<?php echo html_entity_decode(mb_substr($event->event_name, 0, 30)) . '....'; ?> ', start: new Date(<?php echo $year_from; ?> , <?php echo $month_from; ?> -1, <?php echo $day_from; ?> , <?php echo $hour_start; ?> , <?php echo $mint_start; ?> ), end: new Date(<?php echo $year_to; ?> , <?php echo $month_to; ?> -1, <?php echo $day_to; ?> , <?php echo $hour_end; ?> , <?php echo $mint_end; ?> ), url: '<?php echo html_entity_decode($event->guid); ?> ', allDay: false }, <?php $event_count++; } ?> ] }); }); </script> <div id="calendar_view-<?php echo $counter; ?> "></div> <?php } }
/** * Filter for titles when on event pages * @param $data * @return string */ function em_content_page_title($original_content, $id = null) { global $EM_Event, $EM_Location, $EM_Category, $wp_query, $post; if (empty($post)) { return $original_content; } //fix for any other plugins calling the_content outside the loop if ($id && $id !== $post->ID) { return $original_content; } $events_page_id = get_option('dbem_events_page'); $locations_page_id = get_option('dbem_locations_page'); $edit_events_page_id = get_option('dbem_edit_events_page'); $edit_locations_page_id = get_option('dbem_edit_locations_page'); $edit_bookings_page_id = get_option('dbem_edit_bookings_page'); if (!empty($post->ID) && in_array($post->ID, array($events_page_id, $locations_page_id, $edit_events_page_id, $edit_locations_page_id, $edit_bookings_page_id))) { //override the titles with this filter if needed, preventing the following code from being run $content = apply_filters('em_content_page_title_pre', '', $original_content); if (empty($content)) { $content = $original_content; //leave untouched by default if ($post->ID == $events_page_id) { if (!empty($_REQUEST['calendar_day'])) { $events = EM_Events::get(array('limit' => 2, 'scope' => $_REQUEST['calendar_day'], 'owner' => false)); if (count($events) != 1 || get_option('dbem_display_calendar_day_single') == 1) { //We only support dates for the calendar day list title, so we do a simple filter for the supplied calendar_day $content = get_option('dbem_list_date_title'); preg_match_all("/#[A-Za-z0-9]+/", $content, $placeholders); foreach ($placeholders[0] as $placeholder) { // matches all PHP date and time placeholders if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $placeholder)) { $content = str_replace($placeholder, mysql2date(ltrim($placeholder, "#"), $_REQUEST['calendar_day']), $content); } } } else { $event = array_shift($events); $content = $event->output(get_option('dbem_event_page_title_format')); } } elseif (EM_MS_GLOBAL && is_object($EM_Event) && !get_option('dbem_ms_global_events_links')) { // single event page $content = $EM_Event->output(get_option('dbem_event_page_title_format')); } } elseif ($post->ID == $locations_page_id) { if (EM_MS_GLOBAL && is_object($EM_Location) && get_option('dbem_ms_global_locations_links')) { $content = $EM_Location->output(get_option('dbem_location_page_title_format')); } } elseif ($post->ID == $edit_events_page_id) { if (!empty($_REQUEST['action']) && ($_REQUEST['action'] = 'edit')) { if (is_object($EM_Event) && $EM_Event->event_id) { if ($EM_Event->is_recurring()) { $content = __("Reschedule Events", 'dbem') . " '{$EM_Event->event_name}'"; } else { $content = __("Edit Event", 'dbem') . " '" . $EM_Event->event_name . "'"; } } else { $content = __('Add Event', 'dbem'); } } } elseif ($post->ID == $edit_locations_page_id) { if (!empty($_REQUEST['action']) && ($_REQUEST['action'] = 'edit')) { if (empty($EM_Location) || !is_object($EM_Location)) { $content = __('Add Location', 'dbem'); } else { $content = __('Edit Location', 'dbem'); } } } elseif ($post->ID == $edit_bookings_page_id) { if (is_object($EM_Event)) { $content = $EM_Event->name . ' - ' . $original_content; } } return apply_filters('em_content_page_title', $content); } } return $original_content; }
function get($args) { global $wpdb; $calendar_array = array(); $calendar_array['cells'] = array(); $original_args = $args; $args = self::get_default_search($args); $full = $args['full']; //For ZDE, don't delete pls $month = $args['month']; $year = $args['year']; $long_events = $args['long_events']; $week_starts_on_sunday = get_option('dbem_week_starts_sunday'); $start_of_week = get_option('start_of_week'); if (!(is_numeric($month) && $month <= 12 && $month > 0)) { $month = date('m'); } if (!is_numeric($year)) { $year = date('Y'); } // Get the first day of the month $month_start = mktime(0, 0, 0, $month, 1, $year); $calendar_array['month_start'] = $month_start; // Get friendly month name $month_name = date('M', $month_start); // Figure out which day of the week // the month starts on. $month_start_day = date('D', $month_start); switch ($month_start_day) { case "Sun": $offset = 0; break; case "Mon": $offset = 1; break; case "Tue": $offset = 2; break; case "Wed": $offset = 3; break; case "Thu": $offset = 4; break; case "Fri": $offset = 5; break; case "Sat": $offset = 6; break; } //We need to go back to the WP defined day when the week started, in case the event day is near the end $offset -= $start_of_week; if ($offset < 0) { $offset += 7; } // determine how many days are in the last month. $month_last = $month - 1; $month_next = $month + 1; $calendar_array['month_next'] = $month_next; $year_last = $year; $year_next = $year; $calendar_array['year_next'] = $year_next; if ($month == 1) { $month_last = 12; $year_last = $year - 1; } elseif ($month == 12) { $month_next = 1; $year_next = $year + 1; } $calendar_array['month_last'] = $month_last; $calendar_array['year_last'] = $year_last; $num_days_last = self::days_in_month($month_last, $year_last); // determine how many days are in the current month. $num_days_current = self::days_in_month($month, $year); // Build an array for the current days // in the month for ($i = 1; $i <= $num_days_current; $i++) { $num_days_array[] = mktime(0, 0, 0, $month, $i, $year); } // Build an array for the number of days // in last month for ($i = 1; $i <= $num_days_last; $i++) { $num_days_last_array[] = mktime(0, 0, 0, $month_last, $i, $year_last); } // If the $offset from the starting day of the // week happens to be Sunday, $offset would be 0, // so don't need an offset correction. if ($offset > 0) { $offset_correction = array_slice($num_days_last_array, -$offset, $offset); $new_count = array_merge($offset_correction, $num_days_array); $offset_count = count($offset_correction); } else { // The else statement is to prevent building the $offset array. $offset_count = 0; $new_count = $num_days_array; } // count how many days we have with the two // previous arrays merged together $current_num = count($new_count); // Since we will have 5 HTML table rows (TR) // with 7 table data entries (TD) // we need to fill in 35 TDs // so, we will have to figure out // how many days to appened to the end // of the final array to make it 35 days. if ($current_num > 35) { $num_weeks = 6; $outset = 42 - $current_num; } elseif ($current_num < 35) { $num_weeks = 5; $outset = 35 - $current_num; } if ($current_num == 35) { $num_weeks = 5; $outset = 0; } // Outset Correction for ($i = 1; $i <= $outset; $i++) { $new_count[] = mktime(0, 0, 0, $month_next, $i, $year_next); } // Now let's "chunk" the $all_days array // into weeks. Each week has 7 days // so we will array_chunk it into 7 days. $weeks = array_chunk($new_count, 7); //Get an array of arguments that don't include default valued args $link_args = self::get_link_args($args); $previous_url = "?ajaxCalendar=1&mo={$month_last}&yr={$year_last}&{$link_args}"; $next_url = "?ajaxCalendar=1&mo={$month_next}&yr={$year_next}&{$link_args}"; $weekdays = array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); if (!empty($args['full'])) { if (get_option('dbem_full_calendar_abbreviated_weekdays')) { $weekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); } $day_initials_length = get_option('dbem_full_calendar_initials_length'); } else { if (get_option('dbem_small_calendar_abbreviated_weekdays')) { $weekdays = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); } $day_initials_length = get_option('dbem_small_calendar_initials_length'); } for ($n = 0; $n < $start_of_week; $n++) { $last_day = array_shift($weekdays); $weekdays[] = $last_day; } $days_initials_array = array(); foreach ($weekdays as $weekday) { $days_initials_array[] = self::translate_and_trim($weekday, $day_initials_length); } $calendar_array['links'] = array('previous_url' => $previous_url, 'next_url' => $next_url); $calendar_array['row_headers'] = $days_initials_array; // Now we break each key of the array // into a week and create a new table row for each // week with the days of that week in the table data $i = 0; $current_date = date('Y-m-d', current_time('timestamp')); $week_count = 0; foreach ($weeks as $week) { foreach ($week as $d) { $date = date('Y-m-d', $d); $calendar_array['cells'][$date] = array('date' => $d); //set it up so we have the exact array of dates to be filled if ($i < $offset_count) { //if it is PREVIOUS month $calendar_array['cells'][$date]['type'] = 'pre'; } if ($i >= $offset_count && $i < $num_weeks * 7 - $outset) { // if it is THIS month if ($current_date == $date) { $calendar_array['cells'][$date]['type'] = 'today'; } } elseif ($outset > 0) { //if it is NEXT month if ($i >= $num_weeks * 7 - $outset) { $calendar_array['cells'][$date]['type'] = 'post'; } } $i++; } $week_count++; } // query the database for events in this time span if ($month == 1) { $month_pre = 12; $month_post = 2; $year_pre = $year - 1; $year_post = $year; } elseif ($month == 12) { $month_pre = 11; $month_post = 1; $year_pre = $year; $year_post = $year + 1; } else { $month_pre = $month - 1; $month_post = $month + 1; $year_pre = $year; $year_post = $year; } $args['year'] = array($year_pre, $year_post); $args['month'] = array($month_pre, $month_post); $events = EM_Events::get($args); $event_format = get_option('dbem_full_calendar_event_format'); $event_title_format = get_option('dbem_small_calendar_event_title_format'); $event_title_separator_format = get_option('dbem_small_calendar_event_title_separator'); $eventful_days = array(); if ($events) { //Go through the events and slot them into the right d-m index foreach ($events as $event) { $event = apply_filters('em_calendar_output_loop_start', $event); if ($long_events) { //If $long_events is set then show a date as eventful if there is an multi-day event which runs during that day $event_start_date = strtotime($event->start_date); $event_end_date = mktime(0, 0, 0, $month_post, date('t', $event_start_date), $year_post); if ($event_end_date == '') { $event_end_date = $event_start_date; } while ($event_start_date <= $event->end) { //Ensure date is within event dates, if so add to eventful days array $event_eventful_date = date('Y-m-d', $event_start_date); if (array_key_exists($event_eventful_date, $eventful_days) && is_array($eventful_days[$event_eventful_date])) { $eventful_days[$event_eventful_date][] = $event; } else { $eventful_days[$event_eventful_date] = array($event); } $event_start_date += 86400; //add a day } } else { //Only show events on the day that they start if (isset($eventful_days[$event->event_start_date]) && is_array($eventful_days[$event->event_start_date])) { $eventful_days[$event->event_start_date][] = $event; } else { $eventful_days[$event->event_start_date] = array($event); } } } } //generate a link argument string containing event search only $day_link_args = self::get_link_args(array_intersect_key($original_args, EM_Events::get_post_search($args, true))); foreach ($eventful_days as $day_key => $events) { if (array_key_exists($day_key, $calendar_array['cells'])) { //Get link title for this date $events_titles = array(); foreach ($events as $event) { if (!get_option('dbem_display_calendar_events_limit') || count($events_titles) < get_option('dbem_display_calendar_events_limit')) { $events_titles[] = $event->output($event_title_format); } else { $events_titles[] = get_option('dbem_display_calendar_events_limit_msg'); break; } } $calendar_array['cells'][$day_key]['link_title'] = implode($event_title_separator_format, $events_titles); //Get the link to this calendar day global $wp_rewrite; if (count($events) > 1 || !get_option('dbem_calendar_direct_links')) { if (get_option("dbem_events_page") > 0) { $event_page_link = get_permalink(get_option("dbem_events_page")); //PAGE URI OF EM } else { if ($wp_rewrite->using_permalinks()) { $event_page_link = trailingslashit(home_url()) . EM_POST_TYPE_EVENT_SLUG . '/'; //don't use EM_URI here, since ajax calls this before EM_URI is defined. } else { $event_page_link = trailingslashit(home_url()) . '?post_type=' . EM_POST_TYPE_EVENT; //don't use EM_URI here, since ajax calls this before EM_URI is defined. } } if ($wp_rewrite->using_permalinks() && !defined('EM_DISABLE_PERMALINKS')) { $calendar_array['cells'][$day_key]['link'] = trailingslashit($event_page_link) . $day_key . "/"; if (!empty($day_link_args)) { $calendar_array['cells'][$day_key]['link'] .= '?' . $day_link_args; } } else { $joiner = stristr($event_page_link, "?") ? "&" : "?"; $calendar_array['cells'][$day_key]['link'] = $event_page_link . $joiner . "calendar_day=" . $day_key; if (!empty($day_link_args)) { $calendar_array['cells'][$day_key]['link'] .= '&' . $day_link_args; } } } else { foreach ($events as $EM_Event) { $calendar_array['cells'][$day_key]['link'] = $EM_Event->get_permalink(); } } //Add events to array $calendar_array['cells'][$day_key]['events'] = $events; } } return apply_filters('em_calendar_get', $calendar_array, $args); }