• Hi,

    I need to know how to extract only the map from this shortcode function. I would rather it not be a function if possible, and then I call some php to display the map.

    if (!function_exists('espresso_venue_details_sc')) {
    
    	function espresso_venue_details_sc($atts) {
    
    		global $wpdb, $this_event_id;
    
    		empty($atts) ? '' : extract($atts);
    
    		//Outside wrapper
    		$outside_wrapper_class = isset($outside_wrapper_class) ? 'class="' . $outside_wrapper_class . '"' : 'class="col-md-6"';
    		$wrapper_start = isset($outside_wrapper) ? '<' . $outside_wrapper . ' ' . $outside_wrapper_class : '<div ' . $outside_wrapper_class;
    		$wrapper_end = isset($outside_wrapper) ? '</' . $outside_wrapper . '>' : '</div>';
    
    		//Image class
    		$image_class = isset($image_class) ? 'class="' . $image_class . '"' : 'class="venue_image"';
    		$image_wrapper_class = isset($image_wrapper_class) ? 'class="' . $image_wrapper_class . '"' : 'class="image_wrapper"';
    		$image_wrapper_start = isset($image_wrapper) ? '<' . $image_wrapper . ' ' . $image_wrapper_class : '<p ' . $image_wrapper_class . '>';
    		$image_wrapper_end = isset($image_wrapper) ? '</' . $image_wrapper . '>' : '</p>';
    
    		//Venue title
    		$title_class = isset($title_class) ? 'class="' . $title_class . '"' : 'class="venue_name"';
    		$title_wrapper_start = isset($title_wrapper) ? '<' . $title_wrapper . ' ' . $title_class : '<h3 ' . $title_class;
    		$title_wrapper_end = isset($title_wrapper) ? '</' . $title_wrapper . '>' : '</h3>';
    
    		//Inside wrappers
    		$inside_wrapper_class = isset($inside_wrapper_class) ? 'class="' . $inside_wrapper_class . '"' : 'class="venue_details"';
    		$inside_wrapper_before = isset($inside_wrapper) ? '<' . $inside_wrapper . ' ' . $inside_wrapper_class . '>' : '<p ' . $inside_wrapper_class . '>';
    		$inside_wrapper_after = isset($inside_wrapper) ? '</' . $inside_wrapper . '>' : '</p>';
    
    		//Map image class
    		$map_image_class = isset($map_image_class) ? 'class="' . $map_image_class . '"' : 'class="venue_map_image"';
    		$map_image_wrapper_class = isset($map_image_wrapper_class) ? 'class="' . $map_image_wrapper_class . '">' : 'class="map_image_wrapper">';
    		$map_image_wrapper_start = isset($map_image_wrapper) ? '<' . $map_image_wrapper . ' ' . $map_image_wrapper_class : '<p ' . $map_image_wrapper_class;
    		$map_image_wrapper_end = isset($map_image_wrapper) ? '</' . $map_image_wrapper . '>' : '</p>';
    
    		//Google Map link text
    		$show_google_map_link = isset($show_google_map_link) && $show_google_map_link == 'false' ? false : true;
    		$map_link_text = isset($map_link_text) ? $map_link_text : __('Map and Directions', 'event_espresso');
    
    		//Show Google map image?
    		$show_map_image = isset($show_map_image) && $show_map_image == 'false' ? false : true;
    
    		//Show title?
    		$show_title = isset($show_title) && $show_title == 'false' ? false : true;
    
    		//Show image?
    		$show_image = isset($show_image) && $show_image == 'false' ? false : true;
    
    		//Show the description?
    		$show_description = isset($show_description) && $show_description == 'false' ? false : true;
    
    		//Show address details?
    		$show_address = isset($show_address) && $show_address == 'false' ? false : true;
    
    		//Show additional details
    		$show_additional_details = isset($show_additional_details) && $show_additional_details == 'false' ? false : true;
    
    		$FROM = " FROM ";
    		$order_by = isset($order_by) && $order_by != '' ? " ORDER BY " . $order_by . " ASC " : " ORDER BY name ASC ";
    		$limit = isset( $limit ) && $limit > 0 ? " LIMIT 0," . $limit . " " : '';
    
    		$using_id = false;
    		//Find the event id
    		if (isset($id) && $id > 0) {
    
    		} elseif (isset($event_id)) {
    			$event_id = $event_id; //Check to see if the event is used in the shortcode parameter
    			$using_id = true;
    		} elseif (isset($this_event_id)) {
    			$event_id = $this_event_id; //Check to see if the global event id is being used
    			$using_id = true;
    		} elseif (isset($_REQUEST['event_id'])) {
    			$event_id = $_REQUEST['event_id']; //If the first two are not being used, then get the event id from the url
    			$using_id = true;
    		}
    
    		$sql = "SELECT ev.* ";
    
    		if ($using_id == true) {
    			$sql .= " $FROM " . EVENTS_DETAIL_TABLE . " e ";
    			$sql .= " LEFT JOIN " . EVENTS_VENUE_REL_TABLE . " vr ON e.id = vr.event_id ";
    			$FROM = " LEFT JOIN ";
    		}
    
    		$sql .= " $FROM " . EVENTS_VENUE_TABLE . " ev ";
    
    		if ($using_id == true) {
    			$sql .= " ON vr.venue_id = ev.id ";
    		}
    
    		if (isset($id) && $id > 0) {
    			$sql .= " WHERE ev.id = '" . $id . "' ";
    		} elseif (isset($event_id) && $event_id > 0) {
    			$sql .= " WHERE e.id ='" . $event_id . "' ";
    		} else {
    			$sql .= " GROUP BY ev.name ";
    		}
    
    		if ($using_id == false) {
    			$sql .= $order_by;
    			$sql .= $limit;
    		}
    		//echo $sql ;
    
    		$venues = $wpdb->get_results($sql);
    
    		$num_rows = $wpdb->num_rows;
    		if ($num_rows > 0) {
    			$html = '';
    			foreach ($venues as $venue) {
    				$venue_id = $venue->id;
    				$meta = unserialize($venue->meta);
    
    				//Google map link creation
    				$google_map_link = espresso_google_map_link(array('address' => $venue->address, 'city' => $venue->city, 'state' => $venue->state, 'zip' => $venue->zip, 'country' => $venue->country, 'text' => $map_link_text, 'type' => 'text'));
    
    				//Google map image creation
    				if ($show_map_image != false) {
    					$map_w = isset($map_w) ? $map_w : 420;
    					$map_h = isset($map_h) ? $map_h : 420;
    					$google_map_image = espresso_google_map_link(array('id' => $venue_id, 'map_image_class' => $map_image_class, 'address' => $venue->address, 'city' => $venue->city, 'state' => $venue->state, 'zip' => $venue->zip, 'country' => $venue->country, 'text' => $map_link_text, 'type' => 'map', 'map_h' => $map_h, 'map_w' => $map_w));
    				}
    
    				//Build the venue title
    				if ($show_title != false) {
    					$html .= '<div class="col-md-6">';
    					$html .= '<img src="/wp-content/themes/hnh/img/venue.png">';
    					$html .= '<h5>Venue</h5>';
    					$html .= $venue->name != '' ? $title_wrapper_start . '>' . stripslashes_deep($venue->name) . $title_wrapper_end : '';
    					$html .= '</div>';
    				}
    
    				//Build the venue image
    				//if ($show_image != false) {
    				//	$html .= $meta['image'] != '' ? $image_wrapper_start . '<img id="venue_image_' . $venue_id . '" ' . $image_class . ' src="' . stripslashes_deep($meta['image']) . '" />' . $image_wrapper_end : '';
    				//}
    
    				//Build the description
    				//if ($show_description != false) {
    				//	$html .= $meta['description'] != '' ? espresso_format_content($meta['description']) : '';
    				//}
    
    				//Build the address details
    				if ($show_address != false) {
    					$html .= '<div class="col-md-6">';
    				//	$html .= $inside_wrapper_before;
    					$html .= '<img src="/wp-content/themes/hnh/img/location.png">';
    					$html .= '<h5>Location</h5>';
    					$html .= $venue->address != '' ? stripslashes_deep($venue->address) . '<br />' : '';
    				//	$html .= $venue->address2 != '' ? stripslashes_deep($venue->address2) . '<br />' : '';
    					$html .= $venue->city != '' ? stripslashes_deep($venue->city) . '<br />' : '';
    				//	$html .= $venue->state != '' ? stripslashes_deep($venue->state) . '<br />' : '';
    				//	$html .= $venue->zip != '' ? stripslashes_deep($venue->zip) . '<br />' : '';
    				//	$html .= $venue->country != '' ? stripslashes_deep($venue->country) . '<br />' : '';
    				//	$html .= $show_google_map_link != false ? $google_map_link : '';
    				//	$html .= $inside_wrapper_after;
    					$html .= '</div>';
    				}
    
    				//Build the additional details
    				if ($show_additional_details != false) {
    					$html .= $inside_wrapper_before;
    				//	$html .= $meta['website'] != '' ? __('Website:', 'event_espresso') . ' <a href="' . stripslashes_deep($meta['website']) . '" target="_blank">' . stripslashes_deep($meta['website']) . '</a><br />' : '';
    				//	$html .= $meta['contact'] != '' ? __('Contact:', 'event_espresso') . ' ' . stripslashes_deep($meta['contact']) . '<br />' : '';
    				//	$html .= $meta['phone'] != '' ? __('Phone:', 'event_espresso') . ' ' . stripslashes_deep($meta['phone']) . '<br />' : '';
    				//	$html .= $meta['twitter'] != '' ? __('Twitter:', 'event_espresso') . ' <a href="http://twitter.com/#!/' . stripslashes_deep($meta['twitter']) . '" target="_blank">@' . stripslashes_deep($meta['twitter']) . '</a><br />' : '';
    					$html .= $inside_wrapper_after;
    				}
    
    				//Build the venue image
    				//if ($show_map_image != false) {
    				//	$html .= $map_image_wrapper_start . $google_map_image . $map_image_wrapper_end;
    				//}
    			}
    		}
    		//ob_start();
    		return $wrapper_start . ' id="venue_id_' . $venue_id . '">' . $html . $wrapper_end;
    		//$buffer = ob_get_contents();
    		//ob_end_clean();
    		//return $buffer;
    	}
    
    }
    add_shortcode('ESPRESSO_VENUE', 'espresso_venue_details_sc');

    If anyone is able to help I’d appreciate it.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Event Espresso Map Only’ is closed to new replies.