*/ // Exit if accessed directly if (!defined('ABSPATH')) { exit; } require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; /** * GeoJSON Shortcode Class */ class Leaflet_Geojson_Shortcode extends Leaflet_Shortcode { /** * Default src for geoJSON * * @var string $default_src */ public static $default_src = 'https://gist.githubusercontent.com/bozdoz/064a7101b95a324e8852fe9381ab9a18/raw/03f4f54b13a3a7e256732760a8b679818d9d36fc/map.geojson'; /** * How leaflet renders the src * * @var string $type */ public static $type = 'json'; /** * Get Script for Shortcode * * @param string $atts could be an array * @param string $content could be an array * * @return string HTML */ protected function getHTML($atts='', $content=null) { // need to get the called class to extend above variables $class = self::getClass(); if ($atts) { extract($atts); } wp_enqueue_script('leaflet_ajax_geojson_js'); if ($content) { $content = str_replace(array("\r\n", "\n", "\r"), '
', $content); $content = htmlspecialchars($content); } /* only required field for geojson; accept either src or source */ $source = empty($source) ? '' : $source; $src = empty($src) ? $class::$default_src : $src; $src = empty($source) ? $src : $source; $style_json = $this->LM->get_style_json($atts); $fitbounds = empty($fitbounds) ? 0 : $fitbounds; $circleMarker = empty($circleMarker) ? 0 : $circleMarker; // shortcode content becomes popup text $content_text = empty($content) ? '' : $content; // alternatively, the popup_text attribute works as popup text $popup_text = empty($popup_text) ? '' : $popup_text; // choose which one takes priority (content_text) $popup_text = empty($content_text) ? $popup_text : $content_text; $popup_property = empty($popup_property) ? '' : $popup_property; $popup_text = trim($popup_text); ob_start(); ?>