Example #1
0
/**
 * generates an ical feed on init if url is correct
 */
function em_ical($regenerate = false)
{
    $cal_file_request = preg_match('/events.ics$/', $_SERVER['REQUEST_URI']);
    //are we askig for the ics file directly but doesn't exist?
    if ($cal_file_request || $regenerate) {
        ob_start();
        em_locate_template('templates/ical.php', true);
        $calendar = str_replace("\n", "\r\n", ob_get_clean());
        //get the contents to output and clean crlf issues
        $calendar = str_replace("\n\n", "\n", $calendar);
        //let's create a cache file
        /*
        if( get_option('dbem_regenerate_ical') || !file_exists(ABSPATH . "/events.ics") ){
        	$file = fopen( ABSPATH . "/events.ics", 'w');
        	if($file){
        		fwrite($file, $calendar, strlen($calendar));
        		fclose($file);
        		update_option('dbem_regenerate_ical',false);
        	}
        }
        */
        echo $calendar;
        die;
    }
}
Example #2
0
function em_ical_events()
{
    ob_start();
    em_locate_template('templates/ical.php', true);
    return preg_replace("/([^\r])\n/", "\$1\r\n", ob_get_clean());
    //get the contents to output and clean crlf issues
}
Example #3
0
 function the_content($content)
 {
     global $post, $EM_Event;
     if ($post->post_type == EM_POST_TYPE_EVENT) {
         if (is_archive() || is_search()) {
             if (get_option('dbem_cp_events_archive_formats')) {
                 $EM_Event = em_get_event($post);
                 $content = $EM_Event->output(get_option('dbem_event_list_item_format'));
             }
         } else {
             if (get_option('dbem_cp_events_formats') && !post_password_required()) {
                 $EM_Event = em_get_event($post);
                 ob_start();
                 em_locate_template('templates/event-single.php', true);
                 $content = ob_get_clean();
             } else {
                 $EM_Event = em_get_event($post);
                 if ($EM_Event->event_rsvp) {
                     $content .= $EM_Event->output('<h2>Bookings</h2>#_BOOKINGFORM');
                 }
             }
         }
     }
     return $content;
 }
Example #4
0
 function the_content($content)
 {
     global $wp_query, $EM_Tag;
     $EM_Tag = new EM_Tag($wp_query->queried_object);
     ob_start();
     em_locate_template('templates/tag-single.php', true);
     return ob_get_clean();
 }
Example #5
0
/**
 * Generates a map of locations that match given query attributes. Accepts any location query attributes. 
 * @param array $args
 * @return string
 */
function em_get_locations_map_shortcode($args)
{
    $args['width'] = !empty($args['width']) ? $args['width'] : 450;
    $args['height'] = !empty($args['height']) ? $args['height'] : 300;
    ob_start();
    em_locate_template('templates/map-global.php', true, array('args' => $args));
    return ob_get_clean();
}
Example #6
0
/**
 * Generates a map of locations that match given query attributes. Accepts any location query attributes. 
 * @param unknown_type $atts
 * @return string
 */
function em_get_locations_map_shortcode($atts)
{
    $clean_atts = EM_Locations::get_default_search($atts);
    $clean_atts['width'] = !empty($atts['width']) ? $atts['width'] : 450;
    $clean_atts['height'] = !empty($atts['height']) ? $atts['height'] : 300;
    ob_start();
    em_locate_template('templates/map-global.php', true, array('args' => $atts));
    return ob_get_clean();
}
 function the_content($content)
 {
     global $wp_query, $EM_Tag, $post, $em_tag_id;
     if (!empty($wp_query->em_tag_id) || $post->ID == get_option('dbem_tags_page') && !empty($em_tag_id)) {
         $EM_Tag = empty($wp_query->em_tag_id) ? em_get_tag($em_tag_id) : em_get_tag($wp_query->em_tag_id);
         ob_start();
         em_locate_template('templates/tag-single.php', true);
         return ob_get_clean();
     }
 }
Example #8
0
 function the_content($content)
 {
     global $wp_query, $EM_Category, $post;
     if (empty($post->ID)) {
         $EM_Category = new EM_Category($wp_query->queried_object);
         ob_start();
         em_locate_template('templates/category-single.php', true);
         return ob_get_clean();
     }
     return $content;
 }
 function the_content($content)
 {
     global $wp_query, $EM_Category, $post, $em_category_id;
     if (!empty($wp_query->em_category_id) || $post->ID == get_option('dbem_categories_page') && !empty($em_category_id)) {
         $EM_Category = empty($wp_query->em_category_id) ? em_get_category($em_category_id) : em_get_category($wp_query->em_category_id);
         ob_start();
         em_locate_template('templates/category-single.php', true);
         return ob_get_clean();
     }
     return $content;
 }
 public static function the_content($content)
 {
     global $wp_query, $EM_Tag, $post, $em_tag_id;
     $is_tags_page = $post->ID == get_option('dbem_tags_page');
     $tag_flag = !empty($wp_query->em_tag_id) || !empty($em_tag_id);
     if ($is_tags_page && $tag_flag || empty($post->ID) && $tag_flag) {
         $EM_Tag = empty($wp_query->em_tag_id) ? em_get_tag($em_tag_id) : em_get_tag($wp_query->em_tag_id);
         ob_start();
         em_locate_template('templates/tag-single.php', true);
         return ob_get_clean();
     }
     return $content;
 }
Example #11
0
/**
 * Generates an ics file for a single event 
 */
function em_ical_item()
{
    global $wpdb, $wp_query, $wp_rewrite;
    //check if we're outputting an ical feed
    if (!empty($wp_query) && $wp_query->get('ical')) {
        $execute_ical = false;
        $filename = 'events';
        $args = array();
        //single event
        if ($wp_query->get(EM_POST_TYPE_EVENT)) {
            $event_id = $wpdb->get_var('SELECT event_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get(EM_POST_TYPE_EVENT) . "' AND event_status=1 LIMIT 1");
            if (!empty($event_id)) {
                $filename = $wp_query->get(EM_POST_TYPE_EVENT);
                $args['event'] = $event_id;
            }
            //single location
        } elseif ($wp_query->get(EM_POST_TYPE_LOCATION)) {
            $location_id = $wpdb->get_var('SELECT location_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get(EM_POST_TYPE_LOCATION) . "' AND location_status=1 LIMIT 1");
            if (!empty($location_id)) {
                $filename = $wp_query->get(EM_POST_TYPE_LOCATION);
                $args['location'] = $location_id;
            }
            //taxonomies
        } else {
            $taxonomies = EM_Object::get_taxonomies();
            foreach ($taxonomies as $tax_arg => $taxonomy_info) {
                $taxonomy_term = $wp_query->get($taxonomy_info['query_var']);
                if ($taxonomy_term) {
                    $filename = $taxonomy_term;
                    $args[$tax_arg] = $taxonomy_term;
                }
            }
        }
        //only output the ical if we have a match from above
        if (count($args) > 0) {
            //send headers and output ical
            header('Content-type: text/calendar; charset=utf-8');
            header('Content-Disposition: inline; filename="' . $filename . '.ics"');
            em_locate_template('templates/ical.php', true, array('args' => $args));
            exit;
        } else {
            //no item exists, so redirect to original URL
            $url_to_redirect = preg_replace("/ical\\/\$/", '', esc_url_raw(add_query_arg(array('ical' => null))));
            wp_redirect($url_to_redirect, '302');
            exit;
        }
    }
}
Example #12
0
/**
 * Generates an ics file for a single event 
 */
function em_ical_event()
{
    global $wpdb, $wp_query;
    //add endpoints to events
    if (!empty($wp_query) && $wp_query->get(EM_POST_TYPE_EVENT) && $wp_query->get('ical')) {
        $event_id = $wpdb->get_var('SELECT event_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get(EM_POST_TYPE_EVENT) . "' AND event_status=1 LIMIT 1");
        if (!empty($event_id)) {
            global $EM_Event;
            $EM_Event = em_get_event($event_id);
            //send headers
            header('Content-type: text/calendar; charset=utf-8');
            header('Content-Disposition: inline; filename="' . $EM_Event->event_slug . '.ics"');
            em_locate_template('templates/ical.php', true);
            exit;
        }
    }
}
Example #13
0
 function the_content($content)
 {
     global $post, $EM_Location;
     if ($post->post_type == EM_POST_TYPE_LOCATION) {
         if (is_archive() || is_search()) {
             if (get_option('dbem_cp_locations_archive_formats')) {
                 $EM_Location = em_get_location($post);
                 $content = $EM_Location->output(get_option('dbem_location_list_item_format'));
             }
         } else {
             if (get_option('dbem_cp_locations_formats') && !post_password_required()) {
                 $EM_Location = em_get_location($post);
                 ob_start();
                 em_locate_template('templates/location-single.php', true);
                 $content = ob_get_clean();
             }
         }
     }
     return $content;
 }
 public function template_include($template)
 {
     if (is_post_type_archive('event')) {
         $new_template = em_locate_template('archive-event.php');
     }
     if (is_tax('event-category')) {
         $new_template = em_locate_template('taxonomy-event-category.php');
     }
     if (is_tax('event-location')) {
         $new_template = em_locate_template('taxonomy-event-location.php');
     }
     if (is_tax('event-organizer')) {
         $new_template = em_locate_template('taxonomy-event-organizer.php');
     }
     if (is_tax('event-tag')) {
         $new_template = em_locate_template('taxonomy-event-tag.php');
     }
     if (is_singular('event')) {
         $new_template = em_locate_template('single-event.php');
     }
     return apply_filters('em_template_include', !empty($new_template) ? $new_template : $template);
 }
Example #15
0
function em_admin_location($message = "")
{
    global $EM_Location, $EM_Notices;
    if (empty($EM_Location) || !is_object($EM_Location)) {
        $title = __('Add location', 'dbem');
        $EM_Location = new EM_Location();
    } else {
        $title = __('Edit location', 'dbem');
    }
    ?>
	<div class='wrap'>
		<div id='icon-edit' class='icon32'>
			<br/>
		</div>
		<h2><?php 
    echo $title;
    ?>
</h2>
		<?php 
    em_locate_template('forms/location-editor.php', true);
    ?>
	</div>
	<?php 
}
Example #16
0
<?php

/*
 * Default Events List Template
 * This page displays a list of events, called during the em_content() if this is an events list 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()
 * 
 */
if (get_option('dbem_events_page_search') && !defined('DOING_AJAX')) {
    em_locate_template('templates/events-search.php', true);
}
//TODO fine tune ajax searches - we have some pagination issues otherwise, due to search querystrings
if (get_option('dbem_events_page_ajax', defined('EM_AJAX_SEARCH'))) {
    echo "<div class='em-events-search-ajax'>";
}
$events_count = EM_Events::count(apply_filters('em_content_events_args', $args));
$args['limit'] = get_option('dbem_events_default_limit');
$args['page'] = !empty($_REQUEST['pno']) && is_numeric($_REQUEST['pno']) ? $_REQUEST['pno'] : 1;
if ($events_count > 0) {
    //If there's a search, let's change the pagination a little here
    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'search_events') {
        $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);
Example #17
0
    foreach (em_get_countries() as $country_key => $country_name) {
        ?>
					<option value="<?php 
        echo $country_key;
        ?>
" <?php 
        echo $EM_Location->location_country == $country_key || $EM_Location->location_country == '' && $EM_Location->location_id == '' && get_option('dbem_location_default_country') == $country_key ? 'selected="selected"' : '';
        ?>
><?php 
        echo $country_name;
        ?>
</option>
					<?php 
    }
    ?>
				</select><?php 
    echo $required;
    ?>
			</td>
		</tr>
	</table>
	<?php 
}
?>
	<?php 
if (get_option('dbem_gmap_is_active')) {
    em_locate_template('forms/map-container.php', true);
}
?>
	<br style="clear:both;" />
</div>
Example #18
0
													<td><?php 
                echo em_get_currency_symbol();
                ?>
0.00</td>
												</tr>
												<?php 
                do_action('em_bookings_admin_ticket_row', $EM_Ticket, $EM_Booking);
                ?>

												<?php 
            }
            ?>

											<?php 
        }
        ?>

										<?php 
    }
    ?>
function bp_em_meta_box_group()
{
    em_locate_template('forms/event/group.php', true);
}
Example #20
0
 /**
  * Will output a event in the format passed in $format by replacing placeholders within the format.
  * @param string $format
  * @param string $target
  * @return string
  */
 function output($format, $target = "html")
 {
     $event_string = $format;
     //Time place holder that doesn't show if empty.
     //TODO add filter here too
     preg_match_all('/#@?_\\{[^}]+\\}/', $format, $results);
     foreach ($results[0] as $result) {
         if (substr($result, 0, 3) == "#@_") {
             $date = 'end_date';
             $offset = 4;
         } else {
             $date = 'start_date';
             $offset = 3;
         }
         if ($date == 'end_date' && $this->event_end_date == $this->event_start_date) {
             $replace = __(apply_filters('em_event_output_placeholder', '', $this, $result, $target));
         } else {
             $replace = __(apply_filters('em_event_output_placeholder', mysql2date(substr($result, $offset, strlen($result) - ($offset + 1)), $this->{$date}), $this, $result, $target));
         }
         $event_string = str_replace($result, $replace, $event_string);
     }
     //This is for the custom attributes
     preg_match_all('/#_ATT\\{([^}]+)\\}(\\{([^}]+)\\})?/', $event_string, $results);
     $attributes = em_get_attributes();
     foreach ($results[0] as $resultKey => $result) {
         //Strip string of placeholder and just leave the reference
         $attRef = substr(substr($result, 0, strpos($result, '}')), 6);
         $attString = '';
         if (is_array($this->event_attributes) && array_key_exists($attRef, $this->event_attributes)) {
             $attString = $this->event_attributes[$attRef];
         } elseif (!empty($results[3][$resultKey])) {
             //Check to see if we have a second set of braces;
             $attString = $results[3][$resultKey];
         } elseif (!empty($attributes['values'][$attRef][0])) {
             $attString = $attributes['values'][$attRef][0];
         }
         $attString = apply_filters('em_event_output_placeholder', $attString, $this, $result, $target);
         $event_string = str_replace($result, $attString, $event_string);
     }
     //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', $event_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_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = $this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_bookings') {
                     //check if there's a booking, if not, remove this section of code.
                     $show_condition = !$this->event_rsvp && get_option('dbem_rsvp_enabled');
                 } elseif ($condition == 'no_location') {
                     //does this event have a valid location?
                     $show_condition = empty($this->location_id) || !$this->get_location()->location_status;
                 } elseif ($condition == 'has_location') {
                     //does this event have a valid location?
                     $show_condition = !empty($this->location_id) && $this->get_location()->location_status;
                 } elseif ($condition == 'has_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() != '';
                 } elseif ($condition == 'no_image') {
                     //does this event have an image?
                     $show_condition = $this->get_image_url() == '';
                 } elseif ($condition == 'has_time') {
                     //are the booking times different and not an all-day event
                     $show_condition = $this->event_start_time != $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'no_time') {
                     //are the booking times exactly the same and it's not an all-day event.
                     $show_condition = $this->event_start_time == $this->event_end_time && !$this->event_all_day;
                 } elseif ($condition == 'all_day') {
                     //is it an all day event
                     $show_condition = !empty($this->event_all_day);
                 } elseif ($condition == 'logged_in') {
                     //user is logged in
                     $show_condition = is_user_logged_in();
                 } elseif ($condition == 'not_logged_in') {
                     //not logged in
                     $show_condition = !is_user_logged_in();
                 } elseif ($condition == 'has_spaces') {
                     //there are still empty spaces
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() > 0;
                 } elseif ($condition == 'fully_booked') {
                     //event is fully booked
                     $show_condition = $this->event_rsvp && $this->get_bookings()->get_available_spaces() <= 0;
                 } elseif ($condition == 'bookings_open') {
                     //bookings are still open
                     $show_condition = $this->event_rsvp && $this->get_bookings()->is_open();
                 } elseif ($condition == 'bookings_closed') {
                     //bookings are still closed
                     $show_condition = $this->event_rsvp && !$this->get_bookings()->is_open();
                 } elseif ($condition == 'is_free' || $condition == 'is_free_now') {
                     //is it a free day event, if _now then free right now
                     $show_condition = !$this->event_rsvp || $this->is_free($condition == 'is_free_now');
                 } elseif ($condition == 'not_free' || $condition == 'not_free_now') {
                     //is it a paid event, if _now then paid right now
                     $show_condition = $this->event_rsvp && !$this->is_free($condition == 'not_free_now');
                 } elseif ($condition == 'is_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date != $this->event_end_date;
                 } elseif ($condition == 'not_long') {
                     //is it an all day event
                     $show_condition = $this->event_start_date == $this->event_end_date;
                 } elseif ($condition == 'is_past') {
                     //if event is past
                     if (get_option('dbem_events_current_are_past')) {
                         $show_condition = $this->start <= current_time('timestamp');
                     } else {
                         $show_condition = $this->end <= current_time('timestamp');
                     }
                 } elseif ($condition == 'is_future') {
                     //if event is upcoming
                     $show_condition = $this->start > current_time('timestamp');
                 } elseif ($condition == 'is_current') {
                     //if event is upcoming
                     $ts = current_time('timestamp');
                     $show_condition = $this->start <= $ts && $this->end >= $ts;
                 } elseif ($condition == 'is_recurrence') {
                     //if event is a recurrence
                     $show_condition = $this->is_recurrence();
                 } elseif ($condition == 'not_recurrence') {
                     //if event is not a recurrence
                     $show_condition = !$this->is_recurrence();
                 } elseif ($condition == 'is_private') {
                     //if event is a recurrence
                     $show_condition = $this->event_private == 1;
                 } elseif ($condition == 'not_private') {
                     //if event is not a recurrence
                     $show_condition = $this->event_private == 0;
                 } elseif (preg_match('/^has_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is in this category
                     $show_condition = has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^no_category_([a-zA-Z0-9_\\-]+)$/', $condition, $category_match)) {
                     //event is NOT in this category
                     $show_condition = !has_term($category_match[1], EM_TAXONOMY_CATEGORY, $this->post_id);
                 } elseif (preg_match('/^has_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event has this tag
                     $show_condition = has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 } elseif (preg_match('/^no_tag_([a-zA-Z0-9_\\-]+)$/', $condition, $tag_match)) {
                     //event doesn't have this tag
                     $show_condition = !has_term($tag_match[1], EM_TAXONOMY_TAG, $this->post_id);
                 }
                 //other potential ones - has_attribute_... no_attribute_... has_categories_...
                 $show_condition = apply_filters('em_event_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 = '';
                 }
                 $event_string = str_replace($conditionals[0][$key], apply_filters('em_event_output_condition', $replacement, $condition, $conditionals[0][$key], $this), $event_string);
             }
         }
     }
     //Now let's check out the placeholders.
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $event_string, $placeholders);
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $match = true;
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             //Event Details
             case '#_EVENTID':
                 $replace = $this->event_id;
                 break;
             case '#_EVENTPOSTID':
                 $replace = $this->post_id;
                 break;
             case '#_NAME':
                 //depreciated
             //depreciated
             case '#_EVENTNAME':
                 $replace = $this->event_name;
                 break;
             case '#_NOTES':
                 //depreciated
             //depreciated
             case '#_EXCERPT':
                 //depreciated
             //depreciated
             case '#_EVENTNOTES':
             case '#_EVENTEXCERPT':
                 $replace = $this->post_content;
                 if ($result == "#_EXCERPT" || $result == "#_EVENTEXCERPT") {
                     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(']]>', ']]&gt;', $replace);
                             $replace = wp_trim_words($replace, $excerpt_length, $excerpt_more);
                         }
                     }
                 }
                 break;
             case '#_EVENTIMAGEURL':
             case '#_EVENTIMAGE':
                 if ($this->get_image_url() != '') {
                     if ($result == '#_EVENTIMAGEURL') {
                         $replace = esc_url($this->image_url);
                     } else {
                         if (empty($placeholders[3][$key])) {
                             $replace = "<img src='" . esc_url($this->image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                         } else {
                             $image_size = explode(',', $placeholders[3][$key]);
                             $image_url = $this->image_url;
                             if (self::array_is_numeric($image_size) && count($image_size) > 1) {
                                 //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->event_name) . "' {$image_attr} />";
                                 } else {
                                     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 = "<img src='" . esc_url($image_url) . "' alt='" . esc_attr($this->event_name) . "'/>";
                             }
                         }
                     }
                 }
                 break;
                 //Times & Dates
             //Times & Dates
             case '#_24HSTARTTIME':
             case '#_24HENDTIME':
                 $time = $result == '#_24HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = substr($time, 0, 5);
                 break;
             case '#_12HSTARTTIME':
             case '#_12HENDTIME':
                 $time = $result == '#_12HSTARTTIME' ? $this->event_start_time : $this->event_end_time;
                 $replace = date('g:i A', strtotime($time));
                 break;
             case '#_EVENTTIMES':
                 //get format of time to show
                 if (!$this->event_all_day) {
                     $time_format = get_option('dbem_time_format') ? get_option('dbem_time_format') : get_option('time_format');
                     if ($this->event_start_time != $this->event_end_time) {
                         $replace = date_i18n($time_format, $this->start) . get_option('dbem_times_separator') . date_i18n($time_format, $this->end);
                     } else {
                         $replace = date_i18n($time_format, $this->start);
                     }
                 } else {
                     $replace = get_option('dbem_event_all_day_message');
                 }
                 break;
             case '#_EVENTDATES':
                 //get format of time to show
                 $date_format = get_option('dbem_date_format') ? get_option('dbem_date_format') : get_option('date_format');
                 if ($this->event_start_date != $this->event_end_date) {
                     $replace = date_i18n($date_format, $this->start) . get_option('dbem_dates_separator') . date_i18n($date_format, $this->end);
                 } else {
                     $replace = date_i18n($date_format, $this->start);
                 }
                 break;
                 //Links
             //Links
             case '#_EVENTPAGEURL':
                 //Depreciated
             //Depreciated
             case '#_LINKEDNAME':
                 //Depreciated
             //Depreciated
             case '#_EVENTURL':
                 //Just the URL
             //Just the URL
             case '#_EVENTLINK':
                 //HTML Link
                 $event_link = esc_url($this->get_permalink());
                 if ($result == '#_LINKEDNAME' || $result == '#_EVENTLINK') {
                     $replace = '<a href="' . $event_link . '" title="' . esc_attr($this->event_name) . '">' . esc_attr($this->event_name) . '</a>';
                 } else {
                     $replace = $event_link;
                 }
                 break;
             case '#_EDITEVENTURL':
             case '#_EDITEVENTLINK':
                 if ($this->can_manage('edit_events', 'edit_others_events')) {
                     $link = esc_url($this->get_edit_url());
                     if ($result == '#_EDITEVENTLINK') {
                         $replace = '<a href="' . $link . '">' . esc_html(sprintf(__('Edit Event', 'dbem'))) . '</a>';
                     } else {
                         $replace = $link;
                     }
                 }
                 break;
                 //Bookings
             //Bookings
             case '#_ADDBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_REMOVEBOOKINGFORM':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGFORM':
                 if (get_option('dbem_rsvp_enabled')) {
                     if (!defined('EM_XSS_BOOKINGFORM_FILTER') && locate_template('plugins/events-manager/placeholders/bookingform.php')) {
                         //xss fix for old overriden booking forms
                         add_filter('em_booking_form_action_url', 'esc_url');
                         define('EM_XSS_BOOKINGFORM_FILTER', true);
                     }
                     ob_start();
                     $template = em_locate_template('placeholders/bookingform.php', true, array('EM_Event' => $this));
                     EM_Bookings::enqueue_js();
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_BOOKINGBUTTON':
                 if (get_option('dbem_rsvp_enabled') && $this->event_rsvp) {
                     ob_start();
                     $template = em_locate_template('placeholders/bookingbutton.php', true, array('EM_Event' => $this));
                     $replace = ob_get_clean();
                 }
                 break;
             case '#_EVENTPRICERANGEALL':
                 $show_all_ticket_prices = true;
                 //continues below
             //continues below
             case '#_EVENTPRICERANGE':
                 //get the range of prices
                 $min = false;
                 $max = 0;
                 if ($this->get_bookings()->is_open() || !empty($show_all_ticket_prices)) {
                     foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                         /* @var $EM_Ticket EM_Ticket */
                         if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable') || !empty($show_all_ticket_prices)) {
                             if ($EM_Ticket->get_price() > $max) {
                                 $max = $EM_Ticket->get_price();
                             }
                             if ($EM_Ticket->get_price() < $min || $min === false) {
                                 $min = $EM_Ticket->get_price();
                             }
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 if ($min != $max) {
                     $replace = em_get_currency_formatted($min) . ' - ' . em_get_currency_formatted($max);
                 } else {
                     $replace = em_get_currency_formatted($min);
                 }
                 break;
             case '#_EVENTPRICEMIN':
                 //get the range of prices
                 $min = false;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() < $min || $min === false) {
                             $min = $EM_Ticket->get_price();
                         }
                     }
                 }
                 if ($min === false) {
                     $min = 0;
                 }
                 $replace = em_get_currency_formatted($min);
                 break;
             case '#_EVENTPRICEMAX':
                 //get the range of prices
                 $max = 0;
                 foreach ($this->get_tickets()->tickets as $EM_Ticket) {
                     /* @var $EM_Ticket EM_Ticket */
                     if ($EM_Ticket->is_available() || get_option('dbem_bookings_tickets_show_unavailable')) {
                         if ($EM_Ticket->get_price() > $max) {
                             $max = $EM_Ticket->get_price();
                         }
                     }
                 }
                 $replace = em_get_currency_formatted($max);
                 break;
             case '#_AVAILABLESEATS':
                 //Depreciated
             //Depreciated
             case '#_AVAILABLESPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_available_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_BOOKEDSEATS':
                 //Depreciated
             //Depreciated
             case '#_BOOKEDSPACES':
                 //This placeholder is actually a little misleading, as it'll consider reserved (i.e. pending) bookings as 'booked'
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_booked_spaces();
                     if (get_option('dbem_bookings_approval_reserved')) {
                         $replace += $this->get_bookings()->get_pending_spaces();
                     }
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_PENDINGSPACES':
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled')) {
                     $replace = $this->get_bookings()->get_pending_spaces();
                 } else {
                     $replace = "0";
                 }
                 break;
             case '#_SEATS':
                 //Depreciated
             //Depreciated
             case '#_SPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGSURL':
             case '#_BOOKINGSLINK':
                 if ($this->can_manage('manage_bookings', 'manage_others_bookings')) {
                     $bookings_link = esc_url($this->get_bookings_url());
                     if ($result == '#_BOOKINGSLINK') {
                         $replace = '<a href="' . $bookings_link . '" title="' . esc_attr($this->event_name) . '">' . esc_html($this->event_name) . '</a>';
                     } else {
                         $replace = $bookings_link;
                     }
                 }
                 break;
             case '#_BOOKINGSCUTOFF':
             case '#_BOOKINGSCUTOFFDATE':
             case '#_BOOKINGSCUTOFFTIME':
                 $replace = '';
                 if ($this->event_rsvp && get_option('dbem_rsvp_enabled') && !empty($this->rsvp_end)) {
                     $replace_format = get_option('dbem_date_format') . ' ' . get_option('dbem_time_format');
                     if ($result == '#_BOOKINGSCUTOFFDATE') {
                         $replace_format = get_option('dbem_date_format');
                     }
                     if ($result == '#_BOOKINGSCUTOFFTIME') {
                         $replace_format = get_option('dbem_time_format');
                     }
                     $replace = date($replace_format, $this->rsvp_end);
                 }
                 break;
                 //Contact Person
             //Contact Person
             case '#_CONTACTNAME':
             case '#_CONTACTPERSON':
                 //Depreciated (your call, I think name is better)
                 $replace = $this->get_contact()->display_name;
                 break;
             case '#_CONTACTUSERNAME':
                 $replace = $this->get_contact()->user_login;
                 break;
             case '#_CONTACTEMAIL':
             case '#_CONTACTMAIL':
                 //Depreciated
                 $replace = $this->get_contact()->user_email;
                 break;
             case '#_CONTACTURL':
                 $replace = $this->get_contact()->user_url;
                 break;
             case '#_CONTACTID':
                 $replace = $this->get_contact()->ID;
                 break;
             case '#_CONTACTPHONE':
                 $replace = $this->get_contact()->phone != '' ? $this->get_contact()->phone : __('N/A', 'dbem');
                 break;
             case '#_CONTACTAVATAR':
                 $replace = get_avatar($this->get_contact()->ID, $size = '50');
                 break;
             case '#_CONTACTPROFILELINK':
             case '#_CONTACTPROFILEURL':
                 if (function_exists('bp_core_get_user_domain')) {
                     $replace = bp_core_get_user_domain($this->get_contact()->ID);
                     if ($result == '#_CONTACTPROFILELINK') {
                         $replace = '<a href="' . esc_url($replace) . '">' . __('Profile', 'dbem') . '</a>';
                     }
                 }
                 break;
             case '#_CONTACTMETA':
                 if (!empty($placeholders[3][$key])) {
                     $replace = get_user_meta($this->event_owner, $placeholders[3][$key], true);
                 }
                 break;
             case '#_ATTENDEES':
                 ob_start();
                 $template = em_locate_template('placeholders/attendees.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeeslist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_ATTENDEESPENDINGLIST':
                 ob_start();
                 $template = em_locate_template('placeholders/attendeespendinglist.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Categories and Tags
             //Categories and Tags
             case '#_EVENTCATEGORIESIMAGES':
                 ob_start();
                 $template = em_locate_template('placeholders/eventcategoriesimages.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_EVENTTAGS':
                 ob_start();
                 $template = em_locate_template('placeholders/eventtags.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_CATEGORIES':
                 //depreciated
             //depreciated
             case '#_EVENTCATEGORIES':
                 ob_start();
                 $template = em_locate_template('placeholders/categories.php', true, array('EM_Event' => $this));
                 $replace = ob_get_clean();
                 break;
                 //Ical Stuff
             //Ical Stuff
             case '#_EVENTICALURL':
             case '#_EVENTICALLINK':
                 $replace = $this->get_ical_url();
                 if ($result == '#_EVENTICALLINK') {
                     $replace = '<a href="' . esc_url($replace) . '">iCal</a>';
                 }
                 break;
             case '#_EVENTGCALURL':
             case '#_EVENTGCALLINK':
                 //get dates in UTC/GMT time
                 if ($this->event_all_day && $this->event_start_date == $this->event_end_date) {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->start + 60 * 60 * 24), 'Ymd');
                 } else {
                     $dateStart = get_gmt_from_date(date('Y-m-d H:i:s', $this->start), 'Ymd\\THis\\Z');
                     $dateEnd = get_gmt_from_date(date('Y-m-d H:i:s', $this->end), 'Ymd\\THis\\Z');
                 }
                 //build url
                 $gcal_url = 'http://www.google.com/calendar/event?action=TEMPLATE&text=event_name&dates=start_date/end_date&details=post_content&location=location_name&trp=false&sprop=event_url&sprop=name:blog_name';
                 $gcal_url = str_replace('event_name', urlencode($this->event_name), $gcal_url);
                 $gcal_url = str_replace('start_date', urlencode($dateStart), $gcal_url);
                 $gcal_url = str_replace('end_date', urlencode($dateEnd), $gcal_url);
                 $gcal_url = str_replace('location_name', urlencode($this->output('#_LOCATION')), $gcal_url);
                 $gcal_url = str_replace('blog_name', urlencode(get_bloginfo()), $gcal_url);
                 $gcal_url = str_replace('event_url', urlencode($this->get_permalink()), $gcal_url);
                 //calculate URL length so we know how much we can work with to make a description.
                 if (!empty($this->post_excerpt)) {
                     $gcal_url_description = $this->post_excerpt;
                 } else {
                     $matches = explode('<!--more', $this->post_content);
                     $gcal_url_description = wp_kses_data($matches[0]);
                 }
                 $gcal_url_length = strlen($gcal_url) - 9;
                 if (strlen($gcal_url_description) + $gcal_url_length > 1350) {
                     $gcal_url_description = substr($gcal_url_description, 0, 1380 - $gcal_url_length - 3) . '...';
                 }
                 $gcal_url = str_replace('post_content', urlencode($gcal_url_description), $gcal_url);
                 //get the final url
                 $replace = $gcal_url;
                 if ($result == '#_EVENTGCALLINK') {
                     $img_url = 'www.google.com/calendar/images/ext/gc_button2.gif';
                     $img_url = is_ssl() ? 'https://' . $img_url : 'http://' . $img_url;
                     $replace = '<a href="' . esc_url($replace) . '" target="_blank"><img src="' . esc_url($img_url) . '" alt="0" border="0"></a>';
                 }
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_event_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('#_NOTES', '#_EVENTNOTES'))) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         } else {
             $new_placeholder = str_replace('#_', '__#', $full_result);
             //this will avoid repeated filters when locations/categories are parsed
             $event_string = str_replace($full_result, $new_placeholder, $event_string);
             $desc_replace[$new_placeholder] = $replacement;
         }
     }
     //Time placeholders
     foreach ($placeholders[1] as $result) {
         // matches all PHP START date and time placeholders
         if (preg_match('/^#[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#"), $this->start);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
         // matches all PHP END time placeholders for endtime
         if (preg_match('/^#@[dDjlNSwzWFmMntLoYyaABgGhHisueIOPTZcrU]$/', $result)) {
             $replace = date_i18n(ltrim($result, "#@"), $this->end);
             $replace = apply_filters('em_event_output_placeholder', $replace, $this, $result, $target);
             $event_string = str_replace($result, $replace, $event_string);
         }
     }
     //Now do dependent objects
     if (!empty($this->location_id) && $this->get_location()->location_status) {
         $event_string = $this->get_location()->output($event_string, $target);
     } else {
         $EM_Location = new EM_Location();
         $event_string = $EM_Location->output($event_string, $target);
     }
     //for backwards compat and easy use, take over the individual category placeholders with the frirst cat in th elist.
     $EM_Categories = $this->get_categories();
     if (count($EM_Categories->categories) > 0) {
         $EM_Category = $EM_Categories->get_first();
     }
     if (empty($EM_Category)) {
         $EM_Category = new EM_Category();
     }
     $event_string = $EM_Category->output($event_string, $target);
     //Finally, do the event 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) {
             $event_string = str_replace($full_result, $replacement, $event_string);
         }
     }
     //do some specific formatting
     //TODO apply this sort of formatting to any output() function
     if ($target == 'ical') {
         //strip html and escape characters
         $event_string = str_replace('\\', '\\\\', strip_tags($event_string));
         $event_string = str_replace(';', '\\;', $event_string);
         $event_string = str_replace(',', '\\,', $event_string);
         //remove and define line breaks in ical format
         $event_string = str_replace('\\\\n', '\\n', $event_string);
         $event_string = str_replace("\r\n", '\\n', $event_string);
         $event_string = str_replace("\n", '\\n', $event_string);
     }
     return apply_filters('em_event_output', $event_string, $this, $format, $target);
 }
 public static function meta_box_recurrence()
 {
     em_locate_template('forms/event/recurring-when.php', true);
 }
Example #22
0
 function output($format, $target = "html")
 {
     preg_match_all("/(#@?_?[A-Za-z0-9]+)({([^}]+)})?/", $format, $placeholders);
     foreach ($this->get_tickets() as $EM_Ticket) {
         /* @var $EM_Ticket EM_Ticket */
         break;
     }
     //Get first ticket for single ticket placeholders
     $output_string = $format;
     $replaces = array();
     foreach ($placeholders[1] as $key => $result) {
         $replace = '';
         $full_result = $placeholders[0][$key];
         switch ($result) {
             case '#_BOOKINGID':
                 $replace = $this->booking_id;
                 break;
             case '#_RESPNAME':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGNAME':
                 $replace = $this->get_person()->get_name();
                 break;
             case '#_RESPEMAIL':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGEMAIL':
                 $replace = $this->get_person()->user_email;
                 break;
             case '#_RESPPHONE':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGPHONE':
                 $replace = $this->get_person()->phone;
                 break;
             case '#_BOOKINGSPACES':
                 $replace = $this->get_spaces();
                 break;
             case '#_BOOKINGDATE':
                 $replace = $this->timestamp ? date_i18n(get_option('dbem_date_format'), $this->timestamp) : 'n/a';
                 break;
             case '#_BOOKINGTIME':
                 $replace = $this->timestamp ? date_i18n(get_option('dbem_time_format'), $this->timestamp) : 'n/a';
                 break;
             case '#_BOOKINGDATETIME':
                 $replace = $this->timestamp ? date_i18n(get_option('dbem_date_format') . ' ' . get_option('dbem_time_format'), $this->timestamp) : 'n/a';
                 break;
             case '#_BOOKINGLISTURL':
                 $replace = em_get_my_bookings_url();
                 break;
             case '#_COMMENT':
                 //Depreciated
             //Depreciated
             case '#_BOOKINGCOMMENT':
                 $replace = $this->booking_comment;
                 break;
                 $replace = $this->get_price(true);
                 //if there's tax, it'll be added here
                 break;
             case '#_BOOKINGPRICEWITHOUTTAX':
                 $replace = $this->format_price($this->get_price() - $this->get_price_taxes());
                 break;
             case '#_BOOKINGPRICETAX':
                 $replace = $this->get_price_taxes(true);
                 break;
             case '#_BOOKINGPRICEWITHTAX':
             case '#_BOOKINGPRICE':
                 $replace = $this->get_price(true);
                 break;
             case '#_BOOKINGTICKETNAME':
                 $replace = $EM_Ticket->name;
                 break;
             case '#_BOOKINGTICKETDESCRIPTION':
                 $replace = $EM_Ticket->description;
                 break;
             case '#_BOOKINGTICKETPRICEWITHTAX':
                 $replace = $this->format_price($EM_Ticket->get_price_without_tax() * (1 + $this->get_tax_rate() / 100));
                 break;
             case '#_BOOKINGTICKETPRICEWITHOUTTAX':
                 $replace = $EM_Ticket->get_price_without_tax(true);
                 break;
             case '#_BOOKINGTICKETTAX':
                 $replace = $this->format_price($EM_Ticket->get_price_without_tax() * ($this->get_tax_rate() / 100));
                 break;
             case '#_BOOKINGTICKETPRICE':
                 $replace = $EM_Ticket->get_price(true);
                 break;
             case '#_BOOKINGTICKETS':
                 ob_start();
                 em_locate_template('emails/bookingtickets.php', true, array('EM_Booking' => $this));
                 $replace = ob_get_clean();
                 break;
             case '#_BOOKINGSUMMARY':
                 ob_start();
                 em_locate_template('emails/bookingsummary.php', true, array('EM_Booking' => $this));
                 $replace = ob_get_clean();
                 break;
             default:
                 $replace = $full_result;
                 break;
         }
         $replaces[$full_result] = apply_filters('em_booking_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) {
         $output_string = str_replace($full_result, $replacement, $output_string);
     }
     //run event output too, since this is never run from within events and will not infinitely loop
     $output_string = $this->get_event()->output($output_string, $target);
     return apply_filters('em_booking_output', $output_string, $this, $format, $target);
 }
/**
 * Notify the blog admin of a new user, normally via email.
 *
 * @since 2.0
 */
function em_new_user_notification()
{
    global $em_temp_user_data;
    $user_id = $em_temp_user_data['user_id'];
    $plaintext_pass = $em_temp_user_data['user_pass'];
    //if you want you can disable this email from going out, and will still consider registration as successful.
    if (get_option('dbem_email_disable_registration')) {
        return true;
    }
    //Copied out of /wp-includes/pluggable.php
    $user = new WP_User($user_id);
    $user_login = stripslashes($user->user_login);
    $user_email = stripslashes($user->user_email);
    // The blogname option is escaped with esc_html on the way into the database in sanitize_option
    // we want to reverse this for the plain text arena of emails.
    $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES);
    $message = sprintf(__('New user registration on your blog %s:', 'dbem'), $blogname) . "\r\n\r\n";
    $message .= sprintf(__('Username: %s', 'dbem'), $user_login) . "\r\n\r\n";
    $message .= sprintf(__('E-mail: %s', 'dbem'), $user_email) . "\r\n";
    @wp_mail(get_option('admin_email'), sprintf(__('[%s] New User Registration', 'dbem'), $blogname), $message);
    if (empty($plaintext_pass)) {
        return;
    }
    //send email to user
    $message = get_option('dbem_bookings_email_registration_body');
    if (em_locate_template('emails/new-user.php')) {
        ob_start();
        em_locate_template('emails/new-user.php', true);
        $message = ob_get_clean();
    }
    $message = str_replace(array('%password%', '%username%'), array($plaintext_pass, $user_login), $message);
    global $EM_Mailer;
    return $EM_Mailer->send(get_option('dbem_bookings_email_registration_subject'), $message, $user_email);
}
Example #24
0
 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, "?") ? "&amp;" : "?";
                 $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);
 }
Example #25
0
/**
 * Determines whether to show event page or events page, and saves any updates to the event or events
 * @return null
 */
function bp_em_my_events_content()
{
    em_locate_template('buddypress/my-events.php', true);
}
Example #26
0
/**
 * Creates a grouped list of events by year, month, week or day
 * @since 4.213
 * @param array $args
 * @param string $format
 * @return string
 */
function em_get_events_list_grouped_shortcode($args = array(), $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
    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-grouped.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_grouped($args);
    }
    return $return;
}
Example #27
0
					</div>
				<?php 
        } else {
            ?>

					<p class="em-booking-form-details"><?php 
            echo get_option('dbem_booking_feedback_log_in');
            ?>
</p>
				<?php 
        }
        ?>

			</form>	
			<?php 
        if (!is_user_logged_in() && get_option('dbem_bookings_login_form')) {
            //User is not logged in, show login form (enabled on settings page)
            em_locate_template('forms/bookingform/login.php', true, array('EM_Event' => $EM_Event));
        }
        ?>

			<br class="clear" style="clear:left;" />  
		<?php 
    }
    ?>

	<?php 
}
?>

</div>
Example #28
0
 function export_csv()
 {
     global $EM_Event;
     if ($EM_Event->event_id != $this->event_id) {
         $event = $this->get_event();
         $event_name = $event->name;
     } else {
         $event_name = $EM_Event->name;
     }
     // The name of the file on the user's pc
     $file_name = sanitize_title($event_name) . "-bookings.csv";
     header("Content-Type: application/octet-stream");
     header("Content-Disposition: Attachment; filename={$file_name}");
     em_locate_template('templates/csv-event-bookings.php', true);
     exit;
 }
Example #29
0
/**
 * Filters for page content and if an event replaces it with the relevant event data.
 * @param $data
 * @return string
 */
function em_content($page_content)
{
    global $post, $wpdb, $wp_query, $EM_Event, $EM_Location, $EM_Category;
    if (empty($post)) {
        return $page_content;
    }
    //fix for any other plugins calling the_content outside the loop
    $events_page_id = get_option('dbem_events_page');
    $locations_page_id = get_option('dbem_locations_page');
    $categories_page_id = get_option('dbem_categories_page');
    $tags_page_id = get_option('dbem_tags_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');
    $my_bookings_page_id = get_option('dbem_my_bookings_page');
    //general defaults
    $args = array('owner' => false, 'pagination' => 1);
    $args['ajax'] = isset($args['ajax']) ? $args['ajax'] : !defined('EM_AJAX') || EM_AJAX;
    if (!post_password_required() && in_array($post->ID, array($events_page_id, $locations_page_id, $categories_page_id, $edit_bookings_page_id, $edit_events_page_id, $edit_locations_page_id, $my_bookings_page_id, $tags_page_id))) {
        $content = apply_filters('em_content_pre', '', $page_content);
        if (empty($content)) {
            ob_start();
            if ($post->ID == $events_page_id && $events_page_id != 0) {
                if (!empty($_REQUEST['calendar_day'])) {
                    //Events for a specific day
                    $args = EM_Events::get_post_search(array_merge($args, $_REQUEST));
                    em_locate_template('templates/calendar-day.php', true, array('args' => $args));
                } elseif (is_object($EM_Event)) {
                    em_locate_template('templates/event-single.php', true, array('args' => $args));
                } else {
                    // Multiple events page
                    $args['orderby'] = get_option('dbem_events_default_orderby');
                    $args['order'] = get_option('dbem_events_default_order');
                    if (get_option('dbem_display_calendar_in_events_page')) {
                        $args['long_events'] = 1;
                        em_locate_template('templates/events-calendar.php', true, array('args' => $args));
                    } else {
                        //Intercept search request, if defined
                        if (!empty($_REQUEST['action']) && ($_REQUEST['action'] == 'search_events' || $_REQUEST['action'] == 'search_events_grouped')) {
                            $args = EM_Events::get_post_search(array_merge($args, $_REQUEST));
                        }
                        if (empty($args['scope'])) {
                            $args['scope'] = get_option('dbem_events_page_scope');
                        }
                        if (get_option('dbem_events_page_search_form')) {
                            //load the search form and pass on custom arguments (from settings page)
                            $search_args = em_get_search_form_defaults();
                            em_locate_template('templates/events-search.php', true, array('args' => $search_args));
                        }
                        $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_events_default_limit');
                        if (!empty($args['ajax'])) {
                            echo '<div class="em-search-ajax">';
                        }
                        //AJAX wrapper open
                        if (get_option('dbem_event_list_groupby')) {
                            em_locate_template('templates/events-list-grouped.php', true, array('args' => $args));
                        } else {
                            em_locate_template('templates/events-list.php', true, array('args' => $args));
                        }
                        if (!empty($args['ajax'])) {
                            echo "</div>";
                        }
                        //AJAX wrapper close
                    }
                }
            } elseif ($post->ID == $locations_page_id && $locations_page_id != 0) {
                $args['orderby'] = get_option('dbem_locations_default_orderby');
                $args['order'] = get_option('dbem_locations_default_order');
                $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_locations_default_limit');
                if (EM_MS_GLOBAL && is_object($EM_Location)) {
                    em_locate_template('templates/location-single.php', true, array('args' => $args));
                } else {
                    //Intercept search request, if defined
                    if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'search_locations') {
                        $args = EM_Locations::get_post_search(array_merge($args, $_REQUEST));
                    }
                    if (get_option('dbem_locations_page_search_form')) {
                        //load the search form and pass on custom arguments (from settings page)
                        $search_args = em_get_search_form_defaults();
                        //remove date and category
                        $search_args['search_categories'] = $search_args['search_scope'] = false;
                        em_locate_template('templates/locations-search.php', true, array('args' => $search_args));
                    }
                    if (!empty($args['ajax'])) {
                        echo '<div class="em-search-ajax">';
                    }
                    //AJAX wrapper open
                    em_locate_template('templates/locations-list.php', true, array('args' => $args));
                    if (!empty($args['ajax'])) {
                        echo "</div>";
                    }
                    //AJAX wrapper close
                }
            } elseif ($post->ID == $categories_page_id && $categories_page_id != 0) {
                $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_categories_default_limit');
                if (!empty($args['ajax'])) {
                    echo '<div class="em-search-ajax">';
                }
                //AJAX wrapper open
                em_locate_template('templates/categories-list.php', true, array('args' => $args));
                if (!empty($args['ajax'])) {
                    echo "</div>";
                }
                //AJAX wrapper close
            } elseif ($post->ID == $tags_page_id && $tags_page_id != 0) {
                $args['limit'] = !empty($args['limit']) ? $args['limit'] : get_option('dbem_tags_default_limit');
                if (!empty($args['ajax'])) {
                    echo '<div class="em-search-ajax">';
                }
                //AJAX wrapper open
                em_locate_template('templates/tags-list.php', true, array('args' => $args));
                if (!empty($args['ajax'])) {
                    echo "</div>";
                }
                //AJAX wrapper close
            } elseif ($post->ID == $edit_events_page_id && $edit_events_page_id != 0) {
                em_events_admin();
            } elseif ($post->ID == $edit_locations_page_id && $edit_locations_page_id != 0) {
                em_locations_admin();
            } elseif ($post->ID == $my_bookings_page_id && $my_bookings_page_id != 0) {
                em_my_bookings();
            } elseif ($post->ID == $edit_bookings_page_id && $edit_bookings_page_id != 0) {
                em_bookings_admin();
            }
            $content = ob_get_clean();
            //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_content_page_title(''), get_option('dbem_title_html')) . $content;
            }
            //Now, we either replace CONTENTS or just replace the whole page
            if (preg_match('/CONTENTS/', $page_content)) {
                $content = str_replace('CONTENTS', $content, $page_content);
            }
            if (get_option('dbem_credits')) {
                $content .= '<p style="color:#999; font-size:11px;">Powered by <a href="http://wp-events-plugin.com" style="color:#999;" target="_blank">Events Manager</a></p>';
            }
        }
        return apply_filters('em_content', '<div id="em-wrapper">' . $content . '</div>');
    }
    return $page_content;
}
	<?php 
if (get_option('dbem_location_attributes_enabled')) {
    em_locate_template('forms/location/attributes-public.php', true);
}
?>
				
	<?php 
if ($EM_Location->can_manage('upload_event_images', 'upload_event_images')) {
    ?>
	<h3 class="location-form-image"><?php 
    esc_html_e('Location Image', 'dbem');
    ?>
</h3>
	<div class="inside location-form-image" style="padding:10px;">
		<?php 
    em_locate_template('forms/location/featured-image-public.php', true);
    ?>
	</div>
	<?php 
}
?>
	
	<?php 
do_action('em_front_location_form_footer');
?>
	
	<?php 
if (!empty($_REQUEST['redirect_to'])) {
    ?>
	<input type="hidden" name="redirect_to" value="<?php 
    echo esc_attr($_REQUEST['redirect_to']);