*/ // Exit if accessed directly if (!defined('ABSPATH')) { exit; } require_once LEAFLET_MAP__PLUGIN_DIR . 'shortcodes/class.shortcode.php'; /** * Leaflet Marker Shortcode Class */ class Leaflet_Marker_Shortcode extends Leaflet_Shortcode { /** * Get Script for Shortcode * * @param string $atts could be an array * @param string $content optional * * @return null */ protected function getHTML($atts='', $content=null) { if (!empty($atts)) { extract($atts); } if (!empty($address)) { include_once LEAFLET_MAP__PLUGIN_DIR . 'class.geocoder.php'; $location = new Leaflet_Geocoder( $address ); $lat = $location->lat; $lng = $location->lng; } /* add to user contributed lat lng */ $lat = empty($lat) ? ( empty($y) ? '0' : $y ) : $lat; $lng = empty($lng) ? ( empty($x) ? '0' : $x ) : $lng; $default_marker = 'L.marker'; if (isset($svg)) { $svg = filter_var($svg, FILTER_VALIDATE_BOOLEAN); if ($svg) { wp_enqueue_script('leaflet_svg_icon_js'); $default_marker = 'new L.SVGMarker'; } } // optional pluggable marker $default_marker = apply_filters('leaflet_map_marker', $default_marker); $options = array( 'draggable' => isset($draggable) ? $draggable : null, 'title' => isset($title) ? $title : null, 'alt' => isset($alt) ? $alt : null, 'zIndexOffset' => isset($zindexoffset) ? $zindexoffset : null, 'opacity' => isset($opacity) ? $opacity : null, 'iconUrl' => isset($iconurl) ? $iconurl : null, 'iconSize' => isset($iconsize) ? $iconsize : null, 'iconAnchor' => isset($iconanchor) ? $iconanchor : null, 'shadowUrl' => isset($shadowurl) ? $shadowurl : null, 'shadowSize' => isset($shadowsize) ? $shadowsize : null, 'shadowAnchor' => isset($shadowanchor) ? $shadowanchor : null, 'popupAnchor' => isset($popupanchor) ? $popupanchor : null, 'svg' => isset($svg) ? $svg : null, 'background' => isset($background) ? $background : null, 'iconClass' => isset($iconclass) ? $iconclass : null, 'color' => isset($color) ? $color : null ); $args = array( 'draggable' => FILTER_VALIDATE_BOOLEAN, 'title' => FILTER_SANITIZE_STRING, 'alt' => FILTER_SANITIZE_STRING, 'zIndexOffset' => FILTER_VALIDATE_INT, 'opacity' => FILTER_VALIDATE_FLOAT, 'iconUrl' => FILTER_SANITIZE_URL, 'shadowUrl' => FILTER_SANITIZE_URL, 'iconSize' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'iconAnchor' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'shadowSize' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'shadowAnchor' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'popupAnchor' => array( 'filter' => FILTER_SANITIZE_STRING, 'flags' => FILTER_FORCE_ARRAY ), 'svg' => FILTER_VALIDATE_BOOLEAN, 'background' => FILTER_SANITIZE_STRING, 'iconClass' => FILTER_SANITIZE_STRING, 'color' => FILTER_SANITIZE_STRING ); $options = $this->LM->json_sanitize($options, $args); if ($options === '[]') { $options = '{}'; } ob_start(); ?>