*/
// 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://rawgit.com/bozdoz/567817310f102d169510d94306e4f464/raw/2fdb48dafafd4c8304ff051f49d9de03afb1718b/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;
// 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();
?>