test Map

‘mapbox.world-bright’,
‘width’ => ‘500’,
‘height’ => ‘300’,
‘frameborder’ => ‘0’,
‘lat’ => false,
‘lon’ => false,
‘z’ => false,
‘options’ => false
);
$atts = shortcode_atts($defaults, $atts);

foreach(array(‘width’, ‘height’, ‘frameborder’, ‘lat’, ‘lon’, ‘z’) as $k) {
if (!is_numeric($atts[$k])) {
$atts[$k] = $defaults[$k];
}
}
if (!preg_match(‘/^[-_.,\/a-zA-Z0-9]+$/’, $atts[‘layers’])) {
$atts[‘layers’] = $defaults[‘layers’];
}
if (!preg_match(‘/^[-_.,\/a-zA-Z0-9]+$/’, $atts[‘options’])) {
$atts[‘options’] = $defaults[‘options’];
}
extract($atts);

$uri = “https://a.tiles.mapbox.com/v3/{$layers}/mm”;

if ($options !== false) {
$uri .= “/{$options}”;
}

$uri .= ‘.html’;

if ($lat !== false && $lon !== false && $z !== false) {
$uri .= “#{$z}/{$lat}/{$lon}”;
}

return “

Klicken Sie auf den unteren Button, um den Inhalt von zu laden.

Inhalt laden

“;
}

function mapbox_shortcode_init() {
add_filter(‘content_save_pre’, ‘mapbox_shortcode_iframe_filter’);
}
add_action(‘init’, ‘mapbox_shortcode_init’);

function mapbox_shortcode_iframe_callback($matches) {
if (count($matches) > 1) {
$attr = array();
foreach (explode(‘ ‘, trim($matches[1])) as $value) {
list($k, $v) = explode(‘=’, $value);
$attr[trim($k)] = preg_replace(“/(‘|\”)/”, “”, $v);
}

if ($attr[‘src’]) {
if (preg_match(‘/http:\/\/a.tiles.mapbox.com\/v(2|3)\/([-_.,\/a-zA-Z0-9]+)\.html\#([-.\/0-9]+)/’, $attr[‘src’], $m)) {
list($layers, $api, $options) = explode(‘/’, $m[2]);
list($z, $lat, $lon) = explode(‘/’, $m[3]);

$ret = “

Klicken Sie auf den unteren Button, um den Inhalt von a.tiles.mapbox.com zu laden.

Inhalt laden

}’ height='{$attr[height]}'”;
$ret .= “]”;
return $ret;
}
}
}
return $matches[0];
}

function mapbox_shortcode_iframe_filter($content) {
return preg_replace_callback(‘/]+)>[^<]*<\/iframe>/’, ‘mapbox_shortcode_iframe_callback’, $content);
}

?>