예제 #1
0
    function em_display_event_locations($post_id = 0)
    {
        $post_id = (int) (empty($post_id) ? get_the_ID() : $post_id);
        if (empty($post_id)) {
            return false;
        }
        $locations = em_get_locations_for($post_id);
        if (empty($locations) || is_wp_error($locations)) {
            return false;
        }
        ?>

		<?php 
        $output = get_the_term_list($post_id, 'event-location', __('<strong>Location: </strong>', 'events-maker'), ', ', '');
        ?>

		<div class="entry-meta">

			<span class="term-list event-location cat-links">

			<?php 
        if (is_single()) {
            ?>

				<?php 
            $event_display_options = get_post_meta($post_id, '_event_display_options', true);
            // event display options
            ?>

				<?php 
            if (isset($event_display_options['display_location_details']) && $event_display_options['display_location_details'] == true) {
                ?>

					<?php 
                $output = __('<strong>Location: </strong>', 'events-maker');
                foreach ($locations as $term) {
                    $output .= '<span class="single-location term-' . $term->term_id . '">';
                    $term_link = get_term_link($term->slug, 'event-location');
                    if (is_wp_error($term_link)) {
                        continue;
                    }
                    $output .= '<a href="' . $term_link . '" class="location">' . $term->name . '</a> ';
                    // Location details
                    $location_fields = em_get_event_location_fields();
                    $location_details = $term->location_meta;
                    if ($location_details) {
                        // backward compatibility
                        if (isset($location_details['latitude'])) {
                            unset($location_details['latitude']);
                        }
                        if (isset($location_details['longitude'])) {
                            unset($location_details['longitude']);
                        }
                        // filter data
                        foreach ($location_fields as $key => $field) {
                            if (!in_array($field['type'], array('text', 'url', 'email', 'select')) || empty($location_details[$key])) {
                                unset($location_details[$key]);
                            }
                        }
                    }
                    if ($location_details) {
                        $output .= '<span class="location-details">(' . implode(' ', $location_details) . ')</span>';
                    }
                    $output .= '</span>';
                }
                ?>

				<?php 
            }
            ?>

			<?php 
        }
        ?>

			<?php 
        echo $output;
        ?>

			</span>

		</div>

		<?php 
    }
예제 #2
0
if (!defined('ABSPATH')) {
    exit;
}
// exit if accessed directly
global $location;
// get the term if not set
$location = empty($location) ? em_get_location() : $location;
?>

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

	<?php 
if (!empty($location) && !is_wp_error($location)) {
    ?>

		<?php 
    // location fields
    $location_fields = em_get_event_location_fields();
    $location_details = apply_filters('em_loop_event_location_details', isset($location->location_meta) ? $location->location_meta : '');
    if (!empty($location_fields) && !empty($location_details)) {
        foreach ($location_fields as $key => $field) {
            // field value
            $field['value'] = !empty($location_details[$key]) ? $location_details[$key] : '';
            // field
            echo em_event_taxonomy_field($key, $field);
        }
    }
}
?>

</div>