Ejemplo n.º 1
0
 /**
  * will redirect old links to new link structures.
  */
 public static function redirection()
 {
     global $wpdb, $wp_query;
     if (is_object($wp_query) && $wp_query->get('em_redirect')) {
         //is this a querystring url?
         if ($wp_query->get('event_slug')) {
             $event = $wpdb->get_row('SELECT event_id, post_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='" . $wp_query->get('event_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
             if (!empty($event)) {
                 $EM_Event = em_get_event($event['event_id']);
                 $url = get_permalink($EM_Event->post_id);
             }
         } elseif ($wp_query->get('location_slug')) {
             $location = $wpdb->get_row('SELECT location_id, post_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='" . $wp_query->get('location_slug') . "' AND (blog_id=" . get_current_blog_id() . " OR blog_id IS NULL OR blog_id=0)", ARRAY_A);
             if (!empty($location)) {
                 $EM_Location = em_get_location($location['location_id']);
                 $url = get_permalink($EM_Location->post_id);
             }
         } elseif ($wp_query->get('category_slug')) {
             $url = get_term_link($wp_query->get('category_slug'), EM_TAXONOMY_CATEGORY);
         }
         if (!empty($url)) {
             wp_redirect($url, 301);
             exit;
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Changes necessary event properties when an event is instantiated.
  * Specifically, modifies the location id to the currently translated location if applicable.
  * @param EM_Event $EM_Event
  */
 public static function event_get_location($EM_Location, $EM_Event)
 {
     //check if location has a translation, if so load that one
     if ($EM_Location->location_id) {
         $translated_post_id = EM_ML::get_translated_post_id($EM_Location->post_id, EM_POST_TYPE_LOCATION);
         if ($translated_post_id && $EM_Location->post_id != $translated_post_id) {
             $EM_Location = em_get_location($translated_post_id, 'post_id');
         }
     }
     return $EM_Location;
 }
Ejemplo n.º 3
0
 public static function em_object_get_default_search($defaults, $array, $super_defaults)
 {
     if (!empty($defaults['location'])) {
         //check that this location ID is the original one, given that all events of any language will refer to the location_id of the original
         $EM_Location = em_get_location($defaults['location']);
         if (!EM_ML::is_original($EM_Location)) {
             $defaults['location'] = EM_ML::get_original_location($EM_Location)->location_id;
         }
     }
     return $defaults;
 }
Ejemplo n.º 4
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 static function columns_output($column)
 {
     global $post;
     $post = em_get_location($post);
     switch ($column) {
         case 'location-id':
             echo $post->location_id;
             break;
         case 'address':
             echo $post->location_address;
             break;
         case 'town':
             echo $post->location_town;
             break;
         case 'state':
             echo $post->location_state;
             break;
         case 'country':
             echo $post->location_country;
             break;
     }
 }
Ejemplo n.º 6
0
*/
global $EM_Event;
$rightNow = time();
$args = array('post_type' => 'event', 'posts_per_page' => -1, 'orderby' => 'meta_value_num', 'meta_key' => '_start_ts', 'meta_value' => $rightNow, 'meta_compare' => '>', 'order' => 'ASC');
$posts = new WP_Query($args);
header("Content-Type: application/rss+xml; charset=UTF-8");
echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
?>
<NewDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<?php 
if ($posts->have_posts()) {
    while ($posts->have_posts()) {
        $posts->the_post();
        // Get our event object; associated location object and metadata
        $EM_Event = em_get_event(get_the_ID());
        $EM_Location = em_get_location($EM_Event->location_id);
        $meta = get_post_custom();
        ?>
<DataSet1>
    <Title><?php 
        echo get_the_title();
        ?>
</Title>
    <Description><?php 
        echo strip_tags(get_the_content());
        ?>
</Description>
    <Location><?php 
        echo $EM_Location->location_name;
        if ($meta['Room'][0] != '') {
            echo ", " . $meta['Room'][0];
Ejemplo n.º 7
0
 /**
  * Returns the location object this event belongs to.
  * @return EM_Location
  */
 function get_location()
 {
     global $EM_Location;
     if (is_object($EM_Location) && $EM_Location->location_id == $this->location_id) {
         $this->location = $EM_Location;
     } else {
         if (!is_object($this->location) || $this->location->location_id != $this->location_id) {
             $this->location = apply_filters('em_event_get_location', em_get_location($this->location_id), $this);
         }
     }
     return $this->location;
 }
/**
 * This function will load an event into the global $EM_Event variable during page initialization, provided an event_id is given in the url via GET or POST.
 * global $EM_Recurrences also holds global array of recurrence objects when loaded in this instance for performance
 * All functions (admin and public) can now work off this object rather than it around via arguments.
 * @return null
 */
function em_load_event()
{
    global $EM_Event, $EM_Recurrences, $EM_Location, $EM_Person, $EM_Booking, $EM_Category, $EM_Ticket, $current_user;
    if (!defined('EM_LOADED')) {
        $EM_Recurrences = array();
        if (isset($_REQUEST['event_id']) && is_numeric($_REQUEST['event_id']) && !is_object($EM_Event)) {
            $EM_Event = new EM_Event($_REQUEST['event_id']);
        } elseif (isset($_REQUEST['post']) && (get_post_type($_REQUEST['post']) == 'event' || get_post_type($_REQUEST['post']) == 'event-recurring')) {
            $EM_Event = em_get_event($_REQUEST['post'], 'post_id');
        } elseif (!empty($_REQUEST['event_slug']) && EM_MS_GLOBAL && is_main_site() && !get_site_option('dbem_ms_global_events_links')) {
            // single event page for a subsite event being shown on the main blog
            global $wpdb;
            $matches = array();
            if (preg_match('/\\-([0-9]+)$/', $_REQUEST['event_slug'], $matches)) {
                $event_id = $matches[1];
            } else {
                $event_id = $wpdb->get_var('SELECT event_id FROM ' . EM_EVENTS_TABLE . " WHERE event_slug='{$_REQUEST['event_slug']}' AND blog_id!=" . get_current_blog_id());
            }
            $EM_Event = em_get_event($event_id);
        }
        if (isset($_REQUEST['location_id']) && is_numeric($_REQUEST['location_id']) && !is_object($EM_Location)) {
            $EM_Location = new EM_Location($_REQUEST['location_id']);
        } elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post']) == 'location') {
            $EM_Location = em_get_location($_REQUEST['post'], 'post_id');
        } elseif (!empty($_REQUEST['location_slug']) && EM_MS_GLOBAL && is_main_site() && !get_site_option('dbem_ms_global_locations_links')) {
            // single event page for a subsite event being shown on the main blog
            global $wpdb;
            $matches = array();
            if (preg_match('/\\-([0-9]+)$/', $_REQUEST['location_slug'], $matches)) {
                $location_id = $matches[1];
            } else {
                $location_id = $wpdb->get_var('SELECT location_id FROM ' . EM_LOCATIONS_TABLE . " WHERE location_slug='{$_REQUEST['location_slug']}' AND blog_id!=" . get_current_blog_id());
            }
            $EM_Location = em_get_location($location_id);
        }
        if (is_user_logged_in() || !empty($_REQUEST['person_id']) && is_numeric($_REQUEST['person_id'])) {
            //make the request id take priority, this shouldn't make it into unwanted objects if they use theobj::get_person().
            if (!empty($_REQUEST['person_id'])) {
                $EM_Person = new EM_Person($_REQUEST['person_id']);
            } else {
                $EM_Person = new EM_Person(get_current_user_id());
            }
        }
        if (isset($_REQUEST['booking_id']) && is_numeric($_REQUEST['booking_id']) && !is_object($_REQUEST['booking_id'])) {
            $EM_Booking = new EM_Booking($_REQUEST['booking_id']);
        }
        if (isset($_REQUEST['category_id']) && is_numeric($_REQUEST['category_id']) && !is_object($_REQUEST['category_id'])) {
            $EM_Category = new EM_Category($_REQUEST['category_id']);
        } elseif (isset($_REQUEST['category_slug']) && !is_object($EM_Category)) {
            $EM_Category = new EM_Category($_REQUEST['category_slug']);
        }
        if (isset($_REQUEST['ticket_id']) && is_numeric($_REQUEST['ticket_id']) && !is_object($_REQUEST['ticket_id'])) {
            $EM_Ticket = new EM_Ticket($_REQUEST['ticket_id']);
        }
        define('EM_LOADED', true);
    }
}
Ejemplo n.º 9
0
 /**
  * Returns the original EM_Location object from the provided EM_Location object
  * @param EM_Location|EM_Event $object
  * @return EM_Location|EM_Event
  */
 public static function get_original($object)
 {
     global $em_wpml_original_cache, $pagenow;
     if (!empty($em_wpml_original_cache[$object->blog_id][$object->post_id])) {
         //we have done this before....
         $original_post_id = $em_wpml_original_cache[$object->blog_id][$object->post_id];
         //retrieve cached ID
     } else {
         //find the original post id via WPML
         $original_post_id = SitePress::get_original_element_id($object->post_id, 'post_' . $object->post_type);
         //check a few admin specific stuff if a standard check didn't work, in case we're in the admin area translating via WPML
         if (empty($original_post_id) && is_admin()) {
             if (!empty($_REQUEST['trid'])) {
                 //we are adding a new translation belonging to a trid set
                 $original_post_id = SitePress::get_original_element_id_by_trid($_REQUEST['trid']);
             } elseif (!empty($_REQUEST['icl_translation_of'])) {
                 //a new translation has just been submitted
                 $translation_of = $_REQUEST['icl_translation_of'];
                 //could be a translation from another translation, e.g. try adding a translation from a second language
                 $original_post_id = SitePress::get_original_element_id($translation_of, 'post_' . $object->post_type);
             }
         }
     }
     //save to the cache (whether already saved or not)
     $em_wpml_original_cache[$object->blog_id][$object->post_id] = $original_post_id;
     //if the post_ids don't match then the original translation is different to the one passed on, so switch the $object to that translation
     if ($original_post_id != $object->post_id) {
         //get the EM_Event or EM_Location object
         if ($object->post_type == EM_POST_TYPE_EVENT) {
             $object = em_get_event($original_post_id, 'post_id');
         } elseif ($object->post_type == EM_POST_TYPE_LOCATION) {
             $object = em_get_location($original_post_id, 'post_id');
         }
     }
     return $object;
 }
 function untrashed_post($post_id)
 {
     if (get_post_type($post_id) == EM_POST_TYPE_LOCATION) {
         global $EM_Notices;
         $EM_Location = em_get_location($post_id, 'post_id');
         $EM_Location->set_status(1);
         $EM_Notices->remove_all();
         //no validation/notices needed
     }
 }
Ejemplo n.º 11
0
 /**
  * Returns an array of EM_Location objects
  * @param boolean $eventful
  * @param boolean $return_objects
  * @return array
  */
 public static function get($args = array(), $count = false)
 {
     global $wpdb;
     $events_table = EM_EVENTS_TABLE;
     $locations_table = EM_LOCATIONS_TABLE;
     $locations = array();
     //Quick version, we can accept an array of IDs, which is easy to retrieve
     if (self::array_is_numeric($args)) {
         //Array of numbers, assume they are event IDs to retreive
         //We can just get all the events here and return them
         $sql = "SELECT * FROM {$locations_table} WHERE location_id=" . implode(" OR location_id=", $args);
         $results = $wpdb->get_results($sql, ARRAY_A);
         $events = array();
         foreach ($results as $result) {
             $locations[$result['location_id']] = new EM_Location($result);
         }
         return apply_filters('em_locations_get', $locations, $args);
         //We return all the events matched as an EM_Event array.
     } elseif (is_numeric($args)) {
         //return an event in the usual array format
         return apply_filters('em_locations_get', array(new EM_Location($args)), $args);
     } elseif (is_array($args) && is_object(current($args)) && get_class(current($args)) == 'EM_Location') {
         return apply_filters('em_locations_get', $args, $args);
     }
     //We assume it's either an empty array or array of search arguments to merge with defaults
     $args = self::get_default_search($args);
     $limit = $args['limit'] && is_numeric($args['limit']) ? "LIMIT {$args['limit']}" : '';
     $offset = $limit != "" && is_numeric($args['offset']) ? "OFFSET {$args['offset']}" : '';
     //Get the default conditions
     $conditions = self::build_sql_conditions($args);
     //Put it all together
     $EM_Location = new EM_Location(0);
     //Empty class for strict message avoidance
     $fields = $locations_table . "." . implode(", {$locations_table}.", array_keys($EM_Location->fields));
     $where = count($conditions) > 0 ? " WHERE " . implode(" AND ", $conditions) : '';
     //Get ordering instructions
     $EM_Event = new EM_Event();
     //blank event for below
     $accepted_fields = $EM_Location->get_fields(true);
     $accepted_fields = array_merge($EM_Event->get_fields(true), $accepted_fields);
     $orderby = self::build_sql_orderby($args, $accepted_fields, get_option('dbem_events_default_order'));
     //Now, build orderby sql
     $orderby_sql = count($orderby) > 0 ? 'ORDER BY ' . implode(', ', $orderby) : '';
     $fields = $count ? $locations_table . '.location_id' : $locations_table . '.post_id';
     if (EM_MS_GLOBAL) {
         $selectors = $count ? 'COUNT(' . $locations_table . '.location_id)' : $locations_table . '.post_id, ' . $locations_table . '.blog_id';
     } else {
         $selectors = $count ? 'COUNT(' . $locations_table . '.location_id)' : $locations_table . '.post_id';
     }
     //Create the SQL statement and execute
     $sql = "\r\n\t\t\tSELECT {$selectors} FROM {$locations_table}\r\n\t\t\tLEFT JOIN {$events_table} ON {$locations_table}.location_id={$events_table}.location_id\r\n\t\t\t{$where}\r\n\t\t\tGROUP BY {$locations_table}.location_id\r\n\t\t\t{$orderby_sql}\r\n\t\t\t{$limit} {$offset}\r\n\t\t";
     //If we're only counting results, return the number of results
     if ($count) {
         return apply_filters('em_locations_get_array', count($wpdb->get_col($sql)), $args);
     }
     $results = $wpdb->get_results($sql, ARRAY_A);
     //If we want results directly in an array, why not have a shortcut here?
     if ($args['array'] == true) {
         return apply_filters('em_locations_get_array', $results, $args);
     }
     if (EM_MS_GLOBAL) {
         foreach ($results as $location) {
             if (empty($location['blog_id'])) {
                 $location['blog_id'] = get_current_site()->blog_id;
             }
             $locations[] = em_get_location($location['post_id'], $location['blog_id']);
         }
     } else {
         foreach ($results as $location) {
             $locations[] = em_get_location($location['post_id'], 'post_id');
         }
     }
     return apply_filters('em_locations_get', $locations, $args);
 }
Ejemplo n.º 12
0
 /**
  * Returns the location object this event belongs to.
  * @return EM_Location
  */
 function get_location()
 {
     global $EM_Location;
     if (is_object($EM_Location) && $EM_Location->location_id == $this->location_id) {
         $this->location = $EM_Location;
     } else {
         if (!is_object($this->location) || $this->location->location_id != $this->location_id) {
             $this->location = em_get_location($this->location_id);
         }
     }
     return $this->location;
 }
Ejemplo n.º 13
0
        $old_time_timestamp = strtotime($old_time);
        $new_time = date('h:iA', $old_time_timestamp);
        ?>
                                            <strong><?php 
        echo $new_date;
        ?>
</strong>
                                            <strong><?php 
        echo $new_time;
        ?>
</strong>
                                        </div>
                                        
                                        <div class="col-two pull-left">
                                        <?php 
        $location = em_get_location(get_post_meta($post->ID, '_location_id', true));
        if ($location->location_name != '') {
            ?>
                                        	<span>Location</span>
                                            <strong><?php 
            echo $location->location_name;
            ?>
</br>
                                            <?php 
            echo $location->location_address;
            ?>
</br>
                                            <?php 
            echo $location->location_town;
            ?>
, <?php 
Ejemplo n.º 14
0
    }
    ?>
				</select>
			</td>
		</tr>
	</table>
	<?php 
} else {
    ?>
	<table class="em-location-data">
		<?php 
    global $EM_Location;
    if ($EM_Event->location_id !== 0) {
        $EM_Location = $EM_Event->get_location();
    } elseif (get_option('dbem_default_location') > 0) {
        $EM_Location = em_get_location(get_option('dbem_default_location'));
    } else {
        $EM_Location = new EM_Location();
    }
    ?>
		<tr class="em-location-data-name">
			<th><?php 
    _e('Location Name:', 'events-manager');
    ?>
</th>
			<td>
				<input id='location-id' name='location_id' type='hidden' value='<?php 
    echo $EM_Location->location_id;
    ?>
' size='15' />
				<input id="location-name" type="text" name="location_name" value="<?php 
Ejemplo n.º 15
0
<div <?php 
post_class("teaser");
?>
>
  <?php 
// Date formats
$datebox_format = 'M \\<\\s\\p\\a\\n \\c\\l\\a\\s\\s=\\"\\d\\a\\t\\e\\-\\b\\i\\g\\"\\>j\\<\\/\\s\\p\\a\\n\\> Y';
$atc_format = 'Y-m-d H:i:s';
$loc_id = !empty($meta['_location_id']) ? $meta['_location_id'][0] : false;
if ($loc_id) {
    global $EM_Location;
    $location_obj;
    if (is_object($EM_Location) && $EM_Location->location_id == $loc_id) {
        $location_obj = $EM_Location;
    } else {
        $location_obj = apply_filters('em_event_get_location', em_get_location($loc_id));
    }
    $location = !is_object($location_obj) ? false : $location_obj->location_address . ', ' . $location_obj->location_town . ', ' . $location_obj->location_state . ' ' . $location_obj->location_postcode;
}
$start = !empty($meta['_start_ts']) ? $meta['_start_ts'][0] : 0;
$end = !empty($meta['_end_ts']) ? $meta['_end_ts'][0] : 0;
// d($meta);
$time = __("All day", 'proud-core');
if ($start && !empty($meta['_event_start_time']) && $meta['_event_start_time'][0] != "00:00:00") {
    $time = date_i18n('h:i a', $meta['_start_ts'][0]);
}
?>
  <div class="row">
    <div class="col-xs-3 col-md-2">
      <div class="date-box"><?php 
echo date_i18n($datebox_format, $start);
 public static function meta_boxes()
 {
     global $EM_Location, $post;
     //no need to proceed if we're not dealing with a location
     if ($post->post_type != EM_POST_TYPE_LOCATION) {
         return;
     }
     //since this is the first point when the admin area loads location stuff, we load our EM_Event here
     if (empty($EM_Location) && !empty($post)) {
         $EM_Location = em_get_location($post->ID, 'post_id');
     }
     add_meta_box('em-location-where', __('Where', 'dbem'), array('EM_Location_Post_Admin', 'meta_box_where'), EM_POST_TYPE_LOCATION, 'normal', 'high');
     //add_meta_box('em-location-metadump', __('EM_Location Meta Dump','dbem'), array('EM_Location_Post_Admin','meta_box_metadump'),EM_POST_TYPE_LOCATION, 'normal','high');
     if (get_option('dbem_location_attributes_enabled')) {
         add_meta_box('em-location-attributes', __('Attributes', 'dbem'), array('EM_Location_Post_Admin', 'meta_box_attributes'), EM_POST_TYPE_LOCATION, 'normal', 'default');
     }
 }
Ejemplo n.º 17
0
/**
 * Shows a single location according to given specifications. Accepts any event query attribute.
 * @param array $atts
 * @return string
 */
function em_get_location_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
    if (!empty($atts['location']) && is_numeric($atts['location'])) {
        $EM_Location = em_get_location($atts['location']);
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    } elseif (!empty($atts['post_id']) && is_numeric($atts['post_id'])) {
        $EM_Location = em_get_location($atts['post_id'], 'post_id');
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    }
}
Ejemplo n.º 18
0
 * Override this template by copying it to yourtheme/loop-event/location-details.php
 *
 * @author 	Digital Factory
 * @package Events Maker/Templates
 * @since 	1.2.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
?>

<div class="archive-meta entry-meta">

    <?php 
$location = em_get_location();
$location_details = $location->location_meta;
?>
    
    <?php 
if (!empty($location) && !is_wp_error($location)) {
    ?>
    
	    <?php 
    if (!empty($location_details['address'])) {
        ?>
	    	
	    	<div class="location-address"><strong><?php 
        echo __('Address', 'events-maker');
        ?>
:</strong> <?php 
Ejemplo n.º 19
0
<?php

/**
 * Event location image
 * 
 * Override this template by copying it to yourtheme/loop-event/location-image.php
 *
 * @author 	Digital Factory
 * @package Events Maker/Templates
 * @since 	1.6.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// exit if accessed directly
global $location;
// get the term if not set
$location = empty($location) ? em_get_location() : $location;
// image
if (!empty($location->location_meta['image'])) {
    $image_title = apply_filters('em_loop_event_location_thumbnail_title', esc_html($location->name));
    $image_link = apply_filters('em_loop_event_location_thumbnail_link', get_term_link(absint($location->term_id), esc_attr($location->taxonomy)));
    $size = apply_filters('em_loop_event_location_thumbnail_size', 'post-thumbnail');
    $attr = apply_filters('em_loop_event_location_thumbnail_attr', array('title' => $image_title));
    $image = wp_get_attachment_image($location->location_meta['image'], $size, $attr);
    echo apply_filters('em_loop_event_location_thumbnail_html', sprintf('<a href="%s" class="post-thumbnail term-thumbnail" title="%s" rel="bookmark">%s</a>', $image_link, $image_title, $image), $location);
}
Ejemplo n.º 20
0
 /**
  * Gets and EM_Event or EM_Location object of the desired language $lang for the passed EM_Event or EM_Location $object, returns same object if already in requested language.
  * If $language is false or not provided, another translation of $object should be returned with precedence for the main language of this blog if $object isn't in that language.
  * This function ouptut does not need to be filtered by a ML plugin if em_ml_get_tralsation_id is already filtered and efficiently provides an ID without loading the object too (otherwise object may be loaded twice unecessarily).
  * @uses EM_ML::get_translation_id()  
  * @param EM_Event|EM_Location $object
  * @param string $language Optional. WPLANG accepted value or false
  * @return EM_Event|EM_Location
  */
 public static function get_translation($object, $language = false)
 {
     $translated_id = self::get_translation_id($object, $language);
     $translated_object = $object;
     //return $object if the condition below isn't met
     if ($object->post_id != $translated_id) {
         if ($object->post_type == EM_POST_TYPE_EVENT) {
             $translated_object = em_get_event($translated_id, 'post_id');
         }
         if ($object->post_type == EM_POST_TYPE_LOCATION) {
             $translated_object = em_get_location($translated_id, 'post_id');
         }
     }
     return apply_filters('em_ml_get_translation', $translated_object, $object, $language);
 }
Ejemplo n.º 21
0
 /**
  * Google map shortcode.
  */
 public function google_map_shortcode($args)
 {
     $markers = array();
     $map_types = array('hybrid', 'roadmap', 'satellite', 'terrain');
     $booleans = array('on', 'off');
     $defaults = array('width' => '100%', 'height' => '300px', 'zoom' => 15, 'maptype' => 'roadmap', 'locations' => '', 'maptypecontrol' => 'on', 'zoomcontrol' => 'on', 'streetviewcontrol' => 'on', 'overviewmapcontrol' => 'off', 'pancontrol' => 'off', 'rotatecontrol' => 'off', 'scalecontrol' => 'off', 'draggable' => 'on', 'keyboardshortcuts' => 'on', 'scrollzoom' => 'on');
     $args = shortcode_atts($defaults, $args);
     $args['zoom'] = (int) $args['zoom'];
     if (!in_array(strtolower($args['maptype']), $map_types, TRUE)) {
         $args['maptype'] = $defaults['maptype'];
     }
     $args['maptype'] = strtoupper($args['maptype']);
     $args['maptypecontrol'] = $this->get_proper_arg($args['maptypecontrol'], $defaults['maptypecontrol'], $booleans);
     $args['zoomcontrol'] = $this->get_proper_arg($args['zoomcontrol'], $defaults['zoomcontrol'], $booleans);
     $args['streetviewcontrol'] = $this->get_proper_arg($args['streetviewcontrol'], $defaults['streetviewcontrol'], $booleans);
     $args['overviewmapcontrol'] = $this->get_proper_arg($args['overviewmapcontrol'], $defaults['overviewmapcontrol'], $booleans);
     $args['pancontrol'] = $this->get_proper_arg($args['pancontrol'], $defaults['pancontrol'], $booleans);
     $args['rotatecontrol'] = $this->get_proper_arg($args['rotatecontrol'], $defaults['rotatecontrol'], $booleans);
     $args['scalecontrol'] = $this->get_proper_arg($args['scalecontrol'], $defaults['scalecontrol'], $booleans);
     $args['draggable'] = $this->get_proper_arg($args['draggable'], $defaults['draggable'], $booleans);
     $args['keyboardshortcuts'] = $this->get_proper_arg($args['keyboardshortcuts'], $defaults['keyboardshortcuts'], $booleans);
     $args['scrollzoom'] = $this->get_proper_arg($args['scrollzoom'], $defaults['scrollzoom'], $booleans);
     // location ids
     $locations = $args['locations'] !== '' ? explode(',', $args['locations']) : '';
     if (is_array($locations) && !empty($locations)) {
         $locations_tmp = array();
         foreach ($locations as $location) {
             $locations_tmp[] = (int) $location;
         }
         foreach (array_unique($locations_tmp) as $location_id) {
             $location = em_get_location($location_id);
             if (!empty($location->location_meta['google_map']) && is_array($location->location_meta['google_map'])) {
                 $location->location_meta['name'] = $location->name;
                 $location->location_meta['latitude'] = $location->location_meta['google_map']['latitude'];
                 $location->location_meta['longitude'] = $location->location_meta['google_map']['longitude'];
                 $markers[] = $location->location_meta;
             } elseif (!empty($location->location_meta['latitude']) && !empty($location->location_meta['longitude'])) {
                 $location->location_meta['name'] = $location->name;
                 $markers[] = $location->location_meta;
             }
         }
     } elseif (is_tax('event-location') || in_array(get_post_type(), apply_filters('em_event_post_type', array('event'))) && is_single()) {
         $object = get_queried_object();
         // taxonomy page
         if (isset($object->term_id)) {
             $location = em_get_location($object->term_id);
             if (!empty($location->location_meta['google_map']) && is_array($location->location_meta['google_map'])) {
                 $location->location_meta['name'] = $location->name;
                 $location->location_meta['latitude'] = $location->location_meta['google_map']['latitude'];
                 $location->location_meta['longitude'] = $location->location_meta['google_map']['longitude'];
                 $markers[] = $location->location_meta;
             } elseif (!empty($location->location_meta['latitude']) && !empty($location->location_meta['longitude'])) {
                 $location->location_meta['name'] = $location->name;
                 $markers[] = $location->location_meta;
             }
         } elseif (isset($object->ID)) {
             $locations = em_get_locations_for($object->ID);
             if (is_array($locations) && !empty($locations)) {
                 foreach ($locations as $location) {
                     if (!empty($location->location_meta['google_map']) && is_array($location->location_meta['google_map'])) {
                         $location->location_meta['name'] = $location->name;
                         $location->location_meta['latitude'] = $location->location_meta['google_map']['latitude'];
                         $location->location_meta['longitude'] = $location->location_meta['google_map']['longitude'];
                         $markers[] = $location->location_meta;
                     } elseif (!empty($location->location_meta['latitude']) && !empty($location->location_meta['longitude'])) {
                         $location->location_meta['name'] = $location->name;
                         $markers[] = $location->location_meta;
                     }
                 }
             }
         }
     }
     wp_register_script('events-maker-google-maps', 'https://maps.googleapis.com/maps/api/js?sensor=false&language=' . substr(get_locale(), 0, 2));
     wp_register_script('events-maker-front-locations', EVENTS_MAKER_URL . '/js/front-locations.js', array('jquery', 'events-maker-google-maps'));
     wp_enqueue_script('events-maker-front-locations');
     wp_localize_script('events-maker-front-locations', 'emMapArgs', array('markers' => $markers, 'zoom' => $args['zoom'], 'mapTypeId' => $args['maptype'], 'mapTypeControl' => $args['maptypecontrol'], 'zoomControl' => $args['zoomcontrol'], 'streetViewControl' => $args['streetviewcontrol'], 'overviewMapControl' => $args['overviewmapcontrol'], 'panControl' => $args['pancontrol'], 'rotateControl' => $args['rotatecontrol'], 'scaleControl' => $args['scalecontrol'], 'draggable' => $args['draggable'], 'keyboardShortcuts' => $args['keyboardshortcuts'], 'scrollwheel' => $args['scrollzoom']));
     $html = '<div id="event-google-map" style="width: ' . $args['width'] . '; height: ' . $args['height'] . ';"></div>';
     return apply_filters('em_shortcode_google_map', $html);
 }
Ejemplo n.º 22
0
function em_migrate_uploads()
{
    //build array of images
    global $wpdb;
    $mime_types = array(1 => 'gif', 2 => 'jpg', 3 => 'png');
    require_once ABSPATH . "wp-admin" . '/includes/file.php';
    require_once ABSPATH . "wp-admin" . '/includes/image.php';
    $pattern = EM_IMAGE_DS == '/' ? EM_IMAGE_UPLOAD_DIR . '*/*' : EM_IMAGE_UPLOAD_DIR . '*';
    $files = glob($pattern);
    $file_array = array();
    foreach ($files as $file) {
        $matches = array();
        if (preg_match('/\\/(events|locations\\/)?(event|location)-([0-9]+).([a-zA-Z]{3})/', $file, $matches)) {
            $file_array[$matches[2]][$matches[3]] = array('file' => $file, 'url' => EM_IMAGE_UPLOAD_URI . $matches[1] . $matches[2] . '-' . $matches[3] . '.' . $matches[4], 'type' => 'image/' . $matches[4]);
        }
    }
    $result = array('success' => 0, 'fail' => 0);
    if (count($file_array) > 0) {
        foreach ($file_array as $type => $file_type) {
            foreach ($file_type as $id => $attachment) {
                if ($type == 'event') {
                    $post = em_get_event($id);
                } elseif ($type == 'location') {
                    $post = em_get_location($id);
                }
                if (!empty($post->ID)) {
                    $attachment_data = array('post_mime_type' => $attachment['type'], 'post_title' => $post->post_title, 'post_content' => '', 'post_status' => 'inherit');
                    $attachment_id = wp_insert_attachment($attachment_data, $attachment['file'], $post->ID);
                    $attachment_metadata = wp_generate_attachment_metadata($attachment_id, $attachment['file']);
                    wp_update_attachment_metadata($attachment_id, $attachment_metadata);
                    //delete the old attachment
                    update_post_meta($post->post_id, '_thumbnail_id', $attachment_id);
                    //is it recurring? If so add attachment to recurrences
                    if ($type == 'event' && $post->is_recurring()) {
                        $results = $wpdb->get_col('SELECT post_id FROM ' . EM_EVENTS_TABLE . ' WHERE recurrence_id=' . $post->event_id);
                        foreach ($results as $post_id) {
                            update_post_meta($post_id, '_thumbnail_id', $attachment_id);
                        }
                    }
                    $result['success']++;
                }
            }
        }
    }
    delete_option('dbem_migrate_images_nag');
    delete_option('dbem_migrate_images');
    return $result;
}
Ejemplo n.º 23
0
function em_map_meta_cap($caps, $cap, $user_id, $args)
{
    /* Handle event reads */
    if ('edit_event' == $cap || 'delete_event' == $cap || 'read_event' == $cap) {
        $EM_Event = em_get_event($args[0], 'post_id');
        $post_type = get_post_type_object($EM_Event->post_type);
        /* Set an empty array for the caps. */
        $caps = array();
        //Filter according to event caps
        switch ($cap) {
            case 'read_event':
                if ('private' != $EM_Event->post_status) {
                    $caps[] = 'read';
                } elseif ($user_id == $EM_Event->event_owner) {
                    $caps[] = 'read';
                } else {
                    $caps[] = $post_type->cap->read_private_posts;
                }
                break;
            case 'edit_event':
                if ($user_id == $EM_Event->event_owner) {
                    $caps[] = $post_type->cap->edit_posts;
                } else {
                    $caps[] = $post_type->cap->edit_others_posts;
                }
                break;
            case 'delete_event':
                if ($user_id == $EM_Event->event_owner) {
                    $caps[] = $post_type->cap->delete_posts;
                } else {
                    $caps[] = $post_type->cap->delete_others_posts;
                }
                break;
        }
    }
    if ('edit_recurring_event' == $cap || 'delete_recurring_event' == $cap || 'read_recurring_event' == $cap) {
        $EM_Event = em_get_event($args[0], 'post_id');
        $post_type = get_post_type_object($EM_Event->post_type);
        /* Set an empty array for the caps. */
        $caps = array();
        //Filter according to recurring_event caps
        switch ($cap) {
            case 'read_recurring_event':
                if ('private' != $EM_Event->post_status) {
                    $caps[] = 'read';
                } elseif ($user_id == $EM_Event->event_owner) {
                    $caps[] = 'read';
                } else {
                    $caps[] = $post_type->cap->read_private_posts;
                }
                break;
            case 'edit_recurring_event':
                if ($user_id == $EM_Event->event_owner) {
                    $caps[] = $post_type->cap->edit_posts;
                } else {
                    $caps[] = $post_type->cap->edit_others_posts;
                }
                break;
            case 'delete_recurring_event':
                if ($user_id == $EM_Event->event_owner) {
                    $caps[] = $post_type->cap->delete_posts;
                } else {
                    $caps[] = $post_type->cap->delete_others_posts;
                }
                break;
        }
    }
    if ('edit_location' == $cap || 'delete_location' == $cap || 'read_location' == $cap) {
        $EM_Location = em_get_location($args[0], 'post_id');
        $post_type = get_post_type_object($EM_Location->post_type);
        /* Set an empty array for the caps. */
        $caps = array();
        //Filter according to location caps
        switch ($cap) {
            case 'read_location':
                if ('private' != $EM_Location->post_status) {
                    $caps[] = 'read';
                } elseif ($user_id == $EM_Location->location_owner) {
                    $caps[] = 'read';
                } else {
                    $caps[] = $post_type->cap->read_private_posts;
                }
                break;
            case 'edit_location':
                if ($user_id == $EM_Location->location_owner) {
                    $caps[] = $post_type->cap->edit_posts;
                } else {
                    $caps[] = $post_type->cap->edit_others_posts;
                }
                break;
            case 'delete_location':
                if ($user_id == $EM_Location->location_owner) {
                    $caps[] = $post_type->cap->delete_posts;
                } else {
                    $caps[] = $post_type->cap->delete_others_posts;
                }
                break;
        }
    }
    /* Return the capabilities required by the user. */
    return $caps;
}
Ejemplo n.º 24
0
/**
 * Shows a single location according to given specifications. Accepts any event query attribute.
 * @param array $atts
 * @return string
 */
function em_get_location_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
    if (!empty($atts['location']) && is_numeric($atts['location'])) {
        $EM_Location = em_get_location($atts['location']);
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    } elseif (!empty($atts['post_id']) && is_numeric($atts['post_id'])) {
        $EM_Location = em_get_location($atts['post_id'], 'post_id');
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    }
    //no specific location or post id supplied, check globals
    global $EM_Location, $post;
    if (!empty($EM_Location)) {
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    } elseif ($post->post_type == EM_POST_TYPE_LOCATION) {
        $EM_Location = em_get_location($post->ID, 'post_id');
        return !empty($atts['format']) ? $EM_Location->output($atts['format']) : $EM_Location->output_single();
    }
}
Ejemplo n.º 25
0
<?php

/**
 * The template for location google map
 * 
 * Override this template by copying it to yourtheme/loop-event/google-map.php
 *
 * @author 	Digital Factory
 * @package Events Maker/Templates
 * @since 	1.2.0
 */
if (!defined('ABSPATH')) {
    exit;
}
// Exit if accessed directly
// locations
$locations = em_get_location(get_queried_object_id());
// locations available?
if (!isset($locations) || empty($locations)) {
    return;
}
?>

<?php 
$args = apply_filters('em_loop_event_google_map_args', array('width' => '100%', 'height' => '200px', 'zoom' => 15, 'maptype' => 'roadmap', 'maptypecontrol' => true, 'zoomcontrol' => true, 'streetviewcontrol' => true, 'overviewmapcontrol' => false, 'pancontrol' => false, 'rotatecontrol' => false, 'scalecontrol' => false, 'draggable' => true, 'keyboardshortcuts' => true, 'scrollzoom' => true));
em_display_google_map($args, $locations);
Ejemplo n.º 26
0
/**
 * Makes sure we're in "THE Loop", which is determinied by a flag set when the_post() (start) is first called, and when have_posts() (end) returns false.
 * @param string $data
 * @return string
 */
function em_wp_the_title($data, $id = null)
{
    global $post, $wp_query, $EM_Location, $EM_Event;
    if (empty($post)) {
        return $data;
    }
    //fix for any other plugins calling the_content outside the loop
    //because we're only editing the main title of the page here, we make sure we're in the main query
    if (is_main_query()) {
        $events_page_id = get_option('dbem_events_page');
        $locations_page_id = get_option('dbem_locations_page');
        $edit_events_page_id = get_option('dbem_edit_events_page');
        $edit_locations_page_id = get_option('dbem_edit_locations_page');
        $edit_bookings_page_id = get_option('dbem_edit_bookings_page');
        if (is_main_query() && !empty($post->ID) && in_array($post->ID, array($events_page_id, $locations_page_id, $edit_events_page_id, $edit_locations_page_id, $edit_bookings_page_id))) {
            if ($wp_query->in_the_loop) {
                return apply_filters('em_wp_the_title', em_content_page_title($data, $id));
            }
        } elseif (is_main_query() && is_single() && !empty($post->post_type)) {
            if ($post->post_type == EM_POST_TYPE_EVENT) {
                $EM_Event = em_get_event($post);
                return apply_filters('em_wp_the_title', $EM_Event->output($data));
            } elseif ($post->post_type == EM_POST_TYPE_LOCATION) {
                $EM_Location = em_get_location($post);
                return apply_filters('em_wp_the_title', $EM_Location->output($data));
            }
        }
    }
    return $data;
}
Ejemplo n.º 27
0
 /**
  * When an event is duplicated via WPML, we need to save the event meta via the EM_Event and EM_Location objects.
  * This way, it grabs the original translation meta and saves it into the duplicate via other hooks in EM_WPML_IO.
  * 
  * @param int $master_post_id
  * @param string $lang
  * @param array $post_array
  * @param int $id
  */
 public static function wpml_duplicate($master_post_id, $lang, $post_array, $id)
 {
     //check this is an event
     switch (get_post_type($id)) {
         case EM_POST_TYPE_EVENT:
             //WPML just duplicated an event into another language, so we simply need to load the event and resave it
             $EM_Event = em_get_event($id, 'post_id');
             $EM_Event->event_id = null;
             $EM_Event->save();
             break;
         case EM_POST_TYPE_LOCATION:
             $EM_Location = em_get_location($id, 'post_id');
             $EM_Location->location_id = null;
             $EM_Location->save();
             break;
     }
 }