Пример #1
0
            <!-- Page header, display venue title-->
                
                <?php 
$venue_id = get_queried_object_id();
?>
                
                <h2 class="chesterRed entry">
                    <?php 
printf(__('Galas at %s', 'eventorganiser'), '<span>' . eo_get_venue_name($venue_id) . '</span>');
?>
                </h2>
                
                <hr>
            
                <?php 
if ($venue_description = eo_get_venue_description($venue_id)) {
    echo '<div class="venue-archive-meta">' . $venue_description . '</div>';
}
?>
        
                <!-- Display the venue map. If you specify a class, ensure that class has height/width dimensions-->
                <?php 
if (eo_venue_has_latlng($venue_id)) {
    echo eo_get_venue_map($venue_id, array('width' => '100%'));
}
?>
                
                <hr>
                             
            <?php 
eo_get_template_part('eo-loop-events');
/**
* Prints the name of the description of an event.
* Can be used inside the loop to output the 
* venue id of the current event.
* @since 1.0.0
* @uses eo_get_venue_description()
*
* @param int|string $venue_slug_or_id The venue ID (as an integer) or slug (as a string). Uses venue of current event if empty.
*/
function eo_venue_description($venue_slug_or_id = '')
{
    echo eo_get_venue_description($venue_slug_or_id);
}
		<div id="content" role="main">

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

				<!---- Page header, display venue title-->
				<header class="page-header">	
				<h1 class="page-title"><?php 
    printf(__('Events at: %s', 'eventorganiser'), '<span>' . eo_get_venue_name() . '</span>');
    ?>
</h1>

				<?php 
    //Get the description and print it if it exists
    $venue_description = eo_get_venue_description();
    if (!empty($venue_description)) {
        ?>
							<!---- If the venue has a description display it-->
							<div class="venue-archive-meta">
								<?php 
        echo $venue_description;
        ?>
							</div>
						<?php 
    }
    ?>
		
				<!-- Display the venue map. If you specify a class, ensure that class has height/width dimensions-->
				<?php 
    echo do_shortcode('[eo_venue_map width="100%"]');
function eventorganiser_update_venue_meta_cache($terms, $tax)
{
    if (is_array($tax) && !in_array('event-venue', $tax)) {
        return $terms;
    }
    if (!is_array($tax) && $tax != 'event-venue') {
        return $terms;
    }
    $single = false;
    if (!is_array($terms)) {
        $single = true;
        $terms = array($terms);
    }
    if (empty($terms)) {
        return $terms;
    }
    $term_ids = wp_list_pluck($terms, 'term_id');
    update_meta_cache('eo_venue', $term_ids);
    $fields = array('venue_address', 'venue_postal', 'venue_country', 'venue_lng', 'venue_lat', 'venue_description');
    //Backwards compatible. Depreciated - use the functions, not properties.
    foreach ($terms as $term) {
        if (!is_object($term)) {
            continue;
        }
        $term_id = (int) $term->term_id;
        if (!isset($term->venue_address)) {
            $address = eo_get_venue_address($term_id);
            $term->venue_address = isset($address['address']) ? $address['address'] : '';
            $term->venue_postal = isset($address['postcode']) ? $address['postcode'] : '';
            $term->venue_country = isset($address['country']) ? $address['country'] : '';
        }
        if (!isset($term->venue_lat) || !isset($term->venue_lng)) {
            $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6);
            $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6);
        }
        if (!isset($term->venue_description)) {
            $term->venue_description = eo_get_venue_description($term_id);
        }
    }
    if ($single) {
        return $terms[0];
    }
    return $terms;
}
function eventorganiser_search_venues()
{
    // Query the venues with the given term
    $value = trim(esc_attr($_GET["term"]));
    $venues = eo_get_venues(array('search' => $value));
    foreach ($venues as $venue) {
        $term_id = (int) $venue->term_id;
        if (!isset($term->venue_address)) {
            $address = eo_get_venue_address($term_id);
            $term->venue_address = isset($address['address']) ? $address['address'] : '';
            $term->venue_postal = isset($address['postcode']) ? $address['postcode'] : '';
            $term->venue_country = isset($address['country']) ? $address['country'] : '';
        }
        if (!isset($term->venue_lat) || !isset($term->venue_lng)) {
            $term->venue_lat = number_format(floatval(eo_get_venue_lat($term_id)), 6);
            $term->venue_lng = number_format(floatval(eo_get_venue_lng($term_id)), 6);
        }
        if (!isset($term->venue_description)) {
            $term->venue_description = eo_get_venue_description($term_id);
        }
    }
    $novenue = array('term_id' => 0, 'name' => __('No Venue', 'eventorganiser'));
    $venues = array_merge(array($novenue), $venues);
    //echo JSON to page
    $response = $_GET["callback"] . "(" . json_encode($venues) . ")";
    echo $response;
    exit;
}
    /**
     * Display form for creating / editing venues
     *
     * @since 1.0.0
     */
    function edit_form($venue = false)
    {
        $venue = get_term_by('slug', $venue, 'event-venue');
        $term_id = isset($venue->term_id) ? (int) $venue->term_id : 0;
        $do = $this->current_action() == 'edit' ? 'update' : 'add';
        $nonce = $do == 'update' ? 'eventorganiser_update_venue_' . $venue->slug : 'eventorganiser_add_venue';
        if ($this->current_action() == 'edit') {
            ?>
		<h2>
			<?php 
            _e('Edit Venue', 'eventorganiser');
            ?>
			<a href="edit.php?post_type=event&page=venues&action=create" class="add-new-h2"><?php 
            _ex('Add New', 'post');
            ?>
</a>
		</h2>

	<?php 
        } else {
            ?>
		<h2><?php 
            _e('Add New Venue', 'eventorganiser');
            ?>
 </h2>

	<?php 
        }
        ?>

	<form name="venuedetails" id="eo_venue_form" method="post" action="<?php 
        echo site_url('wp-admin/edit.php?post_type=event&page=venues');
        ?>
">  
		<input type="hidden" name="action" value="<?php 
        echo $do;
        ?>
"> 
		<input type="hidden" name="eo_venue[venue_id]" value="<?php 
        echo $term_id;
        ?>
">  
		<input type="hidden" name="event-venue" value="<?php 
        echo isset($venue->slug) ? $venue->slug : '';
        ?>
">  

		<?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
		<?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
		<?php 
        wp_nonce_field($nonce);
        ?>

		<div id="poststuff" class="metabox-holder has-right-sidebar">
			<?php 
        do_action('add_meta_boxes_event_page_venues', $venue);
        ?>
			<?php 
        do_action('add_meta_boxes', 'event_page_venues', $venue);
        ?>


			<div id="side-info-column" class="inner-sidebar">
				<?php 
        do_meta_boxes('', 'side', $venue);
        ?>
			</div>	

			<div id="post-body">
				<div id="post-body-content">
					<div id="titlediv"><?php 
        eventorganiser_venue_title($venue);
        ?>
</div>

					<div class="postbox " id="venue_address">
						<div class="handlediv" title="Click to toggle"><br></div>
						<h3 class="hndle"><span><?php 
        _e('Venue Location', 'eventorganiser');
        ?>
</span></h3>
						<div class="inside"><?php 
        eventorganiser_venue_location($venue);
        ?>
</div>
					</div><!-- .postbox -->

					<div id="<?php 
        echo user_can_richedit() ? 'postdivrich' : 'postdiv';
        ?>
" class="venue_description postarea">
						<?php 
        wp_editor(eo_get_venue_description($term_id), 'content', array('textarea_name' => 'eo_venue[description]', 'dfw' => false, 'tabindex' => 1));
        ?>
					</div>

					<?php 
        do_meta_boxes('', 'normal', $venue);
        ?>
					<?php 
        do_meta_boxes('', 'advanced', $venue);
        ?>

		 		</div><!-- #post-body-content -->
		 	</div><!-- #post-body -->
		</div><!-- #poststuff -->
	</form> 	
	<?php 
    }