/** * 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; return EM_Map::get_global($atts); }
function output($format, $target = "html") { $location_string = $format; preg_match_all("/#_[A-Za-z]+/", $format, $placeholders); foreach ($placeholders[0] as $result) { $match = true; $replace = ''; switch ($result) { case '#_MAP': //Depreciated //Depreciated case '#_LOCATIONMAP': $replace = EM_Map::get_single(array('location' => $this)); 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 '#_LOCATIONURL': case '#_LOCATIONLINK': case '#_LOCATIONPAGEURL': //Depreciated $joiner = stristr(EM_URI, "?") ? "&" : "?"; $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; case '#_IMAGE': //Depreciated //Depreciated case '#_LOCATIONIMAGE': if ($this->image_url != '') { $replace = "<img src='" . $this->image_url . "' alt='" . $this->name . "'/>"; } 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 '#_LOCATIONID': $replace = $this->id; break; default: $match = false; break; } if ($match) { //if true, we've got a placeholder that needs replacing //TODO FILTER - placeholder filter $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); } } $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); }