/** * Returns a html list of events filtered by the array or query-string of arguments supplied. * @param array|string $args * @return string */ function em_get_events($args = array()) { if (is_string($args) && strpos($args, "=")) { // allows the use of arguments without breaking the legacy code $args = wp_parse_args($args, array()); } else { $args = (array) $args; } $args['ajax'] = isset($args['ajax']) ? $args['ajax'] : !defined('EM_AJAX') || EM_AJAX; $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit'); if (empty($args['format']) && empty($args['format_header']) && empty($args['format_footer'])) { ob_start(); if (!empty($args['ajax'])) { echo '<div class="em-search-ajax">'; } //open AJAX wrapper em_locate_template('templates/events-list.php', true, array('args' => $args)); if (!empty($args['ajax'])) { echo "</div>"; } //close AJAX wrapper $return = ob_get_clean(); } else { $return = EM_Events::output($args); } return $return; }
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(); }
/** * Shows a list of events according to given specifications. Accepts any event query attribute. * @param array $args * @return string */ function em_get_events_list_shortcode($args, $format = '') { $args = (array) $args; $args['ajax'] = isset($args['ajax']) ? $args['ajax'] : !defined('EM_AJAX') || EM_AJAX; $args['format'] = $format != '' || empty($args['format']) ? $format : $args['format']; $args['format'] = html_entity_decode($args['format']); //shortcode doesn't accept html $args['limit'] = isset($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit'); if (empty($args['format']) && empty($args['format_header']) && empty($args['format_footer'])) { ob_start(); if (!empty($args['ajax'])) { echo '<div class="em-search-ajax">'; } //open AJAX wrapper em_locate_template('templates/events-list.php', true, array('args' => $args)); if (!empty($args['ajax'])) { echo "</div>"; } //close AJAX wrapper $return = ob_get_clean(); } else { $args['ajax'] = false; $pno = !empty($_GET['pno']) && is_numeric($_GET['pno']) ? $_GET['pno'] : 1; $args['page'] = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : $pno; $return = EM_Events::output($args); } return $return; }
/** * Returns a html list of events filtered by the array or query-string of arguments supplied. * @param array|string $args * @return string */ function em_get_events($args = array()) { if (is_string($args) && strpos($args, "=")) { // allows the use of arguments without breaking the legacy code $defaults = EM_Events::get_default_search(); $args = wp_parse_args($args, $defaults); } return EM_Events::output($args); }
/** * Get past events * @return string HTML */ public static function getPastEvents() { return \EM_Events::output(array('format_header' => '<ul>', 'format' => '<li> <div>#_{j M Y}</div> <h3>#_EVENTNAME</h3> <div>#_EVENTNOTES</div> <a href="#_EVENTURL">En savoir plus</a> </li>', 'format_footer' => '</ul>', 'scope' => 'past', 'order' => 'DESC', 'limit' => 3, 'pagination' => true)); }
/** * Get past events. * * @return string HTML */ public static function getPastEvents() { return \EM_Events::output(['format_header' => '<ul class="eventList grid-3-medium-2-small-2-tiny-1">', 'format' => '<li class="eventItem"> <div class="eventDate">#_{j M Y}</div> <div class="eventImg"><a href="#_EVENTURL">#_EVENTIMAGE{372,372}</a></div> <h3 class="eventTitle"><a href="#_EVENTURL">#_EVENTNAME</a></h3> <div class="eventDesc">#_EVENTNOTES</div> </li>', 'format_footer' => '</ul>', 'scope' => 'past', 'order' => 'DESC', 'limit' => 3, 'pagination' => true]); }
/** * Shows a list of events according to given specifications. Accepts any event query attribute. * @param array $atts * @return string */ function em_get_events_list_shortcode($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['pno']) && is_numeric($_GET['pno']) ? $_GET['pno'] : $atts['page']; return EM_Events::output($atts); }
/** * TOTALLY DEPRECIATED (NOT ALTERNATIVE TAG) - Just use EM_Events::output, see below * @param unknown_type $limit * @param unknown_type $scope * @param unknown_type $order * @param unknown_type $format * @param unknown_type $echo * @param unknown_type $category * @return unknown_type */ function dbem_get_events_list($limit = "10", $scope = "future", $order = "ASC", $format = '', $echo = 1, $category = '') { if (strpos($limit, "=")) { // allows the use of arguments without breaking the legacy code $defaults = EM_Events::get_default_search(); $r = wp_parse_args($limit, $defaults); extract($r, EXTR_OVERWRITE); } $return = EM_Events::output(array('limit' => $limit, 'scope' => $scope, 'order' => $order, 'format' => $format, 'category' => $category)); if ($echo) { echo $return; } return $return; }
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); }
/** * Filters for page content and if an event replaces it with the relevant event data. * @param $data * @return string */ function em_content($content) { $events_page_id = get_option('dbem_events_page'); if (get_the_ID() == $events_page_id && $events_page_id != 0) { global $wpdb, $EM_Event; //TODO FILTER - filter em page content before placeholder replacing //TODO any loop should put the current $EM_Event etc. into the global variable //general defaults $args = array('orderby' => get_option('dbem_events_default_orderby'), 'order' => get_option('dbem_events_default_order'), 'owner' => false, 'pagination' => 1); if (!empty($_REQUEST['calendar_day'])) { //Events for a specific day $args['scope'] = $_REQUEST['calendar_day']; $page = !empty($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1; $events = EM_Events::get(apply_filters('em_content_calendar_day_args', $args)); //Get events first, so we know how many there are in advance if (count($events) > 1 || $page > 1 || get_option('dbem_display_calendar_day_single') == 1) { $args['limit'] = get_option('dbem_events_default_limit'); $args['offset'] = $args['limit'] * ($page - 1); $content = EM_Events::output($events, apply_filters('em_content_calendar_day_output_args', $args)); } elseif (count($events) == 1) { $EM_Event = $events[0]; $content = $EM_Event->output_single(); } else { $content = get_option('dbem_no_events_message'); } } elseif (!empty($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id'])) { //Just a single location $location = new EM_Location($_REQUEST['location_id']); $content = $location->output_single(); } elseif (!empty($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id'])) { // single event page $event = new EM_Event($_REQUEST['event_id']); $content = $event->output_single(); } elseif (!empty($_REQUEST['bookings_id'])) { //bookings page } else { // Multiple events page $scope = !empty($_REQUEST['scope']) ? EM_Object::sanitize($_REQUEST['scope']) : "future"; //If we have a $_GET['page'] var, use it to calculate the offset/limit ratios (safer than offset/limit get vars) $args['scope'] = $scope; if (!empty($_REQUEST['category_id'])) { $args['category'] = $_REQUEST['category_id']; } if (get_option('dbem_display_calendar_in_events_page')) { $args['full'] = 1; $args['long_events'] = get_option('dbem_full_calendar_long_events'); $content = EM_Calendar::output(apply_filters('em_content_calendar_args', $args)); } else { $args['limit'] = get_option('dbem_events_default_limit'); $args['page'] = !empty($_GET['page']) && is_numeric($_GET['page']) ? $_GET['page'] : 1; /*calculate event list time range */ $time_limit = get_option('dbem_events_page_time_limit'); if (is_numeric($time_limit) && $time_limit > 0) { $args['scope'] = date('Y-m-d') . "," . date('Y-m-t', strtotime('+' . ($time_limit - 1) . ' month')); } $content = EM_Events::output(apply_filters('em_content_events_args', $args)); } } //If disable rewrite flag is on, then we need to add a placeholder here if (get_option('dbem_disable_title_rewrites') == 1) { $content = str_replace('#_PAGETITLE', em_events_page_title(''), get_option('dbem_title_html')) . $content; } //TODO FILTER - filter em page content before display return apply_filters('em_content', '<div id="em-wrapper">' . $content . '</div>'); } return $content; }
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); 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() != '') { if ($result == '#_CATEGORYIMAGEURL') { $replace = $this->get_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 ($this->array_is_numeric($image_size) && count($image_size) > 1) { if (get_option('dbem_disable_timthumb') && $this->get_image_id()) { //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 $this->ms_global_switch(); $replace = wp_get_attachment_image($this->get_image_id(), $image_size); $this->ms_global_switch_back(); } else { $replace = "<img src='" . em_get_thumbnail_url($this->get_image_url(), $image_size[0], $image_size[1]) . "' alt='" . esc_attr($this->name) . "' width='{$image_size[0]}' height='{$image_size[1]}'/>"; } } 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 '#_CATEGORYSLUG': $replace = $this->slug; break; case '#_CATEGORYEVENTSPAST': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_CATEGORYEVENTSNEXT': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_CATEGORYEVENTSALL': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_CATEGORYPASTEVENTS': case '#_CATEGORYNEXTEVENTS': case '#_CATEGORYALLEVENTS': //convert depreciated 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); $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; default: $replace = $full_result; break; } $replace = apply_filters('em_category_output_placeholder', $replace, $this, $full_result, $target); //USE WITH CAUTION! THIS MIGHT GET RENAMED $category_string = str_replace($full_result, $replace, $category_string); } $name_filter = $target == "html" ? 'dbem_general' : 'dbem_general_rss'; //TODO remove dbem_ filters $category_string = str_replace('#_CATEGORY', apply_filters($name_filter, $this->name), $category_string); //Depreciated return apply_filters('em_category_output', $category_string, $this, $format, $target); }
<?php /* * Default Calendar day * This page displays a list of events or single event for a specific calendar day, called during the em_content() if this is an calendar day page. * You can override the default display settings pages by copying this file to yourthemefolder/plugins/events-manager/templates/ and modifying it however you need. * You can display events however you wish, there are a few variables made available to you: * * $args - the args passed onto EM_Events::output() * */ $args['scope'] = $_REQUEST['calendar_day']; $page = !empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) ? $_REQUEST['page'] : 1; $events = EM_Events::get(apply_filters('em_content_calendar_day_args', $args)); //Get events first, so we know how many there are in advance if (count($events) > 1 || $page > 1 || get_option('dbem_display_calendar_day_single') == 1) { $args['limit'] = get_option('dbem_events_default_limit'); $args['offset'] = $args['limit'] * ($page - 1); echo EM_Events::output($events, apply_filters('em_content_calendar_day_output_args', $args)); } elseif (count($events) == 1) { $EM_Event = $events[0]; echo $EM_Event->output_single(); } else { echo get_option('dbem_no_events_message'); }
echo get_post(get_post_thumbnail_id())->post_excerpt; echo "</p></figcaption>"; echo "</figure>"; } ?> <?php the_content(); ?> <section class="content-band" id="library-content"> <h1 class="content-band-title">Special events</h1> <?php echo EM_Events::output(array('limit' => 30, 'location' => $EM_Location->location_id, 'pagination' => 1)); ?> </section> </div> </div> <!-- end entry-content style --> </div> <!-- end .g-row --> </article> </div> <!-- end .inner-wrapper --> <?php
<ul class="events-list"> <?php $parameters = array('format' => '<li> <h6 class="event-start"> <time class="event-month" datetime="#M">#M</time> <time class="event-date" datetime="#j">#j</time> <time class="event-day" datetime="#D">#D</time> </h6> <h3 class="post-title event-title">#_EVENTLINK</h3> </li>'); // TODO: Add exclude site customization? if (!empty($eventnumber)) { $parameters['limit'] = $eventnumber; } $events = EM_Events::output($parameters); ?> <?php echo $events; ?> <li class="event-promo"><h3 class="promo-title"><a href="/events" title="Calendar">View all events</a></h3></li> </ul> </article> <?php } else { ?> <?php get_template_part('partials/error', 'plugin');
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); }
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) { foreach ($conditionals[1] as $key => $condition) { $format = str_replace($conditionals[0][$key], apply_filters('em_tag_output_condition', '', $condition, $conditionals[0][$key], $this), $format); } } $tag_string = $format; preg_match_all("/(#@?_?[A-Za-z0-9]+)({([a-zA-Z0-9,]+)})?/", $format, $placeholders); $replaces = array(); foreach ($placeholders[1] as $key => $result) { $match = true; $replace = ''; $full_result = $placeholders[0][$key]; switch ($result) { case '#_TAGNAME': $replace = $this->name; break; case '#_TAGID': $replace = $this->term_id; break; case '#_TAGLINK': case '#_TAGURL': $link = $this->get_url(); $replace = $result == '#_TAGURL' ? $link : '<a href="' . $link . '">' . esc_html($this->name) . '</a>'; break; case '#_TAGICALURL': case '#_TAGICALLINK': $replace = $this->get_ical_url(); if ($result == '#_TAGICALLINK') { $replace = '<a href="' . esc_url($replace) . '">iCal</a>'; } break; case '#_TAGRSSURL': case '#_TAGRSSLINK': $replace = $this->get_rss_url(); if ($result == '#_TAGRSSLINK') { $replace = '<a href="' . esc_url($replace) . '">RSS</a>'; } break; case '#_TAGNOTES': $replace = $this->description; break; case '#_TAGEVENTSPAST': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_TAGEVENTSNEXT': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_TAGEVENTSALL': //depreciated, erroneous documentation, left for compatability //depreciated, erroneous documentation, left for compatability case '#_TAGPASTEVENTS': case '#_TAGNEXTEVENTS': case '#_TAGALLEVENTS': //convert depreciated placeholders for compatability $result = $result == '#_TAGEVENTSPAST' ? '#_TAGPASTEVENTS' : $result; $result = $result == '#_TAGEVENTSNEXT' ? '#_TAGNEXTEVENTS' : $result; $result = $result == '#_TAGEVENTSALL' ? '#_TAGALLEVENTS' : $result; //forget it ever happened? :/ if ($result == '#_TAGPASTEVENTS') { $scope = 'past'; } elseif ($result == '#_TAGNEXTEVENTS') { $scope = 'future'; } else { $scope = 'all'; } $events_count = EM_Events::count(array('tag' => $this->term_id, 'scope' => $scope)); if ($events_count > 0) { $args = array('tag' => $this->term_id, 'scope' => $scope, 'pagination' => 1, 'ajax' => 0); $args['format_header'] = get_option('dbem_tag_event_list_item_header_format'); $args['format_footer'] = get_option('dbem_tag_event_list_item_footer_format'); $args['format'] = get_option('dbem_tag_event_list_item_format'); $args['limit'] = get_option('dbem_tag_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_tag_no_events_message'); } break; case '#_TAGNEXTEVENT': $events = EM_Events::get(array('tag' => $this->term_id, 'scope' => 'future', 'limit' => 1, 'orderby' => 'event_start_date,event_start_time')); $replace = get_option('dbem_tag_no_event_message'); foreach ($events as $EM_Event) { $replace = $EM_Event->output(get_option('dbem_tag_event_single_format')); } break; default: $replace = $full_result; break; } $replaces[$full_result] = apply_filters('em_tag_output_placeholder', $replace, $this, $full_result, $target); } krsort($replaces); foreach ($replaces as $full_result => $replacement) { $tag_string = str_replace($full_result, $replacement, $tag_string); } return apply_filters('em_tag_output', $tag_string, $this, $format, $target); }
$args['pagination'] = false; if (get_option('dbem_event_list_groupby')) { $args['mode'] = get_option('dbem_event_list_groupby'); $args['date_format'] = get_option('dbem_event_list_groupby_format'); echo em_events_list_grouped($args); } else { echo EM_Events::output($args); } //do some custom pagination (if needed/requested) if (!empty($args['limit']) && $events_count > $args['limit']) { //Show the pagination links (unless there's less than $limit events), note that we set em_search instead of search to prevent conflicts $search_args = array_merge(EM_Events::get_post_search(), array('pno' => '%PAGE%', 'action' => 'search_events', 'search' => null, 'em_search' => $args['search'])); $page_link_template = em_add_get_params($_SERVER['REQUEST_URI'], $search_args, false); //don't html encode, so em_paginate does its thing echo apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $args['limit'], $args['pno']), $page_link_template, $events_count, $args['limit'], $args['pno']); } } else { if (get_option('dbem_event_list_groupby')) { $args['mode'] = get_option('dbem_event_list_groupby'); $args['date_format'] = get_option('dbem_event_list_groupby_format'); echo em_events_list_grouped($args); } else { echo EM_Events::output($args); } } } else { echo get_option('dbem_no_events_message'); } if (get_option('dbem_events_page_ajax', defined('EM_AJAX_SEARCH'))) { echo "</div>"; }
* * $args - the args passed onto EM_Events::output() * */ $events = EM_Events::get(apply_filters('em_content_events_args', $args)); $args['limit'] = get_option('dbem_events_default_limit'); //since we are passing this info to an output function or template, we should get all the events first $args['page'] = !empty($_REQUEST['page']) && is_numeric($_REQUEST['page']) ? $_REQUEST['page'] : 1; $events_count = count($events); if (get_option('dbem_events_page_search')) { em_locate_template('templates/events-search.php', true); } if ($events_count > 0) { //If there's a search, let's change the pagination a little here if (!empty($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'search_events')) { $args['pagination'] = false; echo EM_Events::output($events, $args); //do some custom pagination (if needed/requested) if (!empty($args['limit']) && $events_count > $args['limit']) { //Show the pagination links (unless there's less than $limit events) $search_args = EM_Events::get_post_search() + array('page' => '%PAGE%', '_wpnonce' => $_REQUEST['_wpnonce']); $page_link_template = preg_replace('/(&|\\?)page=\\d+/i', '', $_SERVER['REQUEST_URI']); $page_link_template = em_add_get_params($page_link_template, $search_args); echo apply_filters('em_events_output_pagination', em_paginate($page_link_template, $events_count, $args['limit'], $args['page']), $page_link_template, $events_count, $args['limit'], $args['page']); } } else { echo EM_Events::output($events, $args); } } else { echo get_option('dbem_no_events_message'); }
"> <?php if (!empty($cell_data['events']) && count($cell_data['events']) > 0) { ?> <a href="<?php echo $cell_data['link']; ?> " title="<?php echo $cell_data['link_title']; ?> "><?php echo date('j', $cell_data['date']); ?> </a> <ul><?php echo EM_Events::output($cell_data['events'], array('format' => get_option('dbem_full_calendar_event_format'))); ?> </ul> <?php } else { ?> <?php echo date('j', $cell_data['date']); ?> <?php } ?> </td> <?php //create a new row once we reach the end of a table collumn $col_count = $col_count == $col_max ? 1 : $col_count + 1;
function charityEventsListing() { //#_EVENTTAGS $svgURL = get_template_directory_uri() . '/assets/svg/'; $eventStr = '<div class="event-listing"><div class="event_detail"> <figure>#_EVENTIMAGE</figure> <div class="event_date"> <strong>#_{d}</strong> <span>#_{M}</span> </div> </div> <div class="event_heading clearfix"> <h2><a href="#_EVENTURL">#_EVENTNAME</a></h2> <div class="event_time clearfix"> <div class="venue_block"> <div class="location-svg"> <img src="' . $svgURL . 'location.svg" alt="" class="svg"/> </div> <span>venue :</span> <strong>#_LOCATIONNAME</strong> </div> <div class="date_block"> <div class="date-svg"> <img src="' . $svgURL . 'calendar.svg" alt="" class="svg"/> </div> <span>date :</span> <strong>#_{d-m-Y}</strong> </div> <div class="time_block"> <div class="time-svg"> <img src="' . $svgURL . 'timer.svg" alt="" class="svg" /> </div> <span>Time :</span> <strong>#_12HENDTIME</strong> </div> </div> <div class="event_descriptions"> <p>#_EVENTEXCERPT</p> <a href="#_EVENTURL" class="btn btn-default">Read More</a> </div> </div></div>'; echo EM_Events::output(array('limit' => 3, 'orderby' => 'name', 'format' => $eventStr, 'pagination' => 1)); }
</a> <?php } ?> </p> <?php } } ?> <h4><?php _e("Events I'm Attending", 'events-manager'); ?> </h4> <?php $EM_Person = new EM_Person($bp->displayed_user->id); $EM_Bookings = $EM_Person->get_bookings(false, apply_filters('em_bp_attending_status', 1)); if (count($EM_Bookings->bookings) > 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; } echo EM_Events::output(array('event' => $event_ids)); } else { ?> <p><?php _e('Not attending any events yet.', 'events-manager'); ?> </p> <?php }
/** * Generate a grouped list of events by year, month, week or day. * @since 4.213 * @param array $args * @return string */ function em_get_events_list_grouped($args) { //Reset some args to include pagination for if pagination is requested. $args['limit'] = !empty($args['limit']) && is_numeric($args['limit']) ? $args['limit'] : false; $args['page'] = !empty($args['page']) && is_numeric($args['page']) ? $args['page'] : 1; $args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : $args['page']; $args['offset'] = ($args['page'] - 1) * $args['limit']; $args['orderby'] = 'event_start_date,event_start_time,event_name'; // must override this to display events in right cronology. //Reset some vars for counting events and displaying set arrays of events $atts = (array) $args; $atts['pagination'] = false; $atts['limit'] = false; $atts['page'] = false; $atts['offset'] = false; //decide what form of dates to show $EM_Events = EM_Events::get($args); $events_count = EM_Events::count($atts); ob_start(); switch ($args['mode']) { case 'yearly': //go through the events and put them into a monthly array $format = !empty($args['date_format']) ? $args['date_format'] : 'Y'; $events_dates = array(); foreach ($EM_Events as $EM_Event) { $events_dates[date_i18n($format, $EM_Event->start)][] = $EM_Event; } foreach ($events_dates as $year => $events) { echo '<h2>' . $year . '</h2>'; echo EM_Events::output($events, $atts); } break; case 'monthly': //go through the events and put them into a monthly array $format = !empty($args['date_format']) ? $args['date_format'] : 'M Y'; $events_dates = array(); foreach ($EM_Events as $EM_Event) { $events_dates[date_i18n($format, $EM_Event->start)][] = $EM_Event; } foreach ($events_dates as $month => $events) { echo '<h2>' . $month . '</h2>'; echo EM_Events::output($events, $atts); } break; case 'weekly': $format = !empty($args['date_format']) ? $args['date_format'] : get_option('date_format'); $events_dates = array(); foreach ($EM_Events as $EM_Event) { $start_of_week = get_option('start_of_week'); $day_of_week = date('w', $EM_Event->start); $day_of_week = date('w', $EM_Event->start); $offset = $day_of_week - $start_of_week; if ($offset < 0) { $offset += 7; } $offset = $offset * 60 * 60 * 24; //days in seconds $start_day = strtotime($EM_Event->start_date); $events_dates[$start_day - $offset][] = $EM_Event; } foreach ($events_dates as $event_day_ts => $events) { echo '<h2>' . date_i18n($format, $event_day_ts) . ' - ' . date_i18n($format, $event_day_ts + 60 * 60 * 24 * 6) . '</h2>'; echo EM_Events::output($events, $atts); } break; default: //daily //go through the events and put them into a daily array $format = !empty($args['date_format']) ? $args['date_format'] : get_option('date_format'); $events_dates = array(); foreach ($EM_Events as $EM_Event) { $events_dates[strtotime($EM_Event->start_date)][] = $EM_Event; } foreach ($events_dates as $event_day_ts => $events) { echo '<h2>' . date_i18n($format, $event_day_ts) . '</h2>'; echo EM_Events::output($events, $atts); } break; } if (!empty($args['limit']) && $events_count > $args['limit'] && (!empty($args['pagination']) || !isset($args['pagination']))) { //Show the pagination links (unless there's less than $limit events) $page_link_template = add_query_arg(array('pno' => '%PAGE%')); echo em_paginate($page_link_template, $events_count, $args['limit'], $args['page']); } return ob_get_clean(); }