Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions inc/class.embed.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ private function embed($atts): string
$output .= '<script>var customCalUrl = "' . $atts['customCalInstance'] . '";</script>';
break;
case 3:
$output = $this->get_floating_popup_embed_script($atts['url'], $atts['text']);
$output = $this->get_floating_popup_embed_script($atts['url'], $atts['text'], $atts['customCalInstance']);
break;
default:
$output = '<div id="calcom-embed"></div>';
Expand Down Expand Up @@ -77,14 +77,22 @@ public function get_inline_embed_script($url, $custom_cal_url): string
*
* @param $url Booking link
* @param $text Button text
* @param $custom_cal_url Custom cal.com URL (if self-hosted instance is used)
* @return string
*/
public function get_floating_popup_embed_script($url, $text): string
public function get_floating_popup_embed_script($url, $text, $custom_cal_url): string
{
$button_text = strlen($text) > 0 ? '"buttonText":"' . $text . '"' : '';
$script = '<script>
var customCalUrl = "' . $custom_cal_url . '";
addEventListener("DOMContentLoaded", (event) => {
Cal("floatingButton", {"calLink":"' . $url . '"' . (strlen($button_text) == 0 ? "" : "," . $button_text) . '});
if(customCalUrl.length == 0) {
Cal("floatingButton", {"calLink":"' . $url . '"});
}
else {
Cal("floatingButton", {"calLink":"' . $url . '","calOrigin":customCalUrl});
}
});
</script>';

Expand Down