Skip to content

Commit

Permalink
adds do_shortcode in add popup to shape (bozdoz#205)
Browse files Browse the repository at this point in the history
Co-authored-by: bozdoz <[email protected]>
  • Loading branch information
bozdoz and bozdoz authored Feb 10, 2023
1 parent 5e52487 commit 93bb4d9
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions class.leaflet-map.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,20 +372,26 @@ public function add_popup_to_shape($atts, $content, $shape)

$message = empty($message) ?
(empty($content) ? '' : $content) : $message;

if (empty($message)) {
return;
}

// execute shortcodes if present:
// e.g. [leaflet-marker][some-shortcode][/leaflet-marker]
$message = do_shortcode($message);
$message = str_replace(array("\r\n", "\n", "\r"), '<br>', $message);
$message = addslashes($message);
$message = htmlspecialchars($message);
$visible = empty($visible)
? false
: filter_var($visible, FILTER_VALIDATE_BOOLEAN);

if (!empty($message)) {
echo "{$shape}.bindPopup(window.WPLeafletMapPlugin.unescape('{$message}'))";
if ($visible) {
echo ".openPopup()";
}
echo ";";
echo "{$shape}.bindPopup(window.WPLeafletMapPlugin.unescape('{$message}'))";
if ($visible) {
echo ".openPopup()";
}
echo ";";
}

/**
Expand Down

0 comments on commit 93bb4d9

Please sign in to comment.