2
0

fix(wp): 🐛 Standard embed when window is loaded

This commit is contained in:
Baptiste Arnaud
2022-05-18 12:30:51 -07:00
parent ac278b9916
commit ad69cc5264
4 changed files with 30 additions and 15 deletions

View File

@ -263,6 +263,16 @@ class Typebot_Public
}
$container_id = 'typebot-container-' . $this->generateRandomString(4);
$bot_initializer =
'var typebot = Typebot.initContainer("' .
$container_id .
'",{
hiddenVariables: typebotWpUser,
url: "' .
$url .
'",
})';
return '<script>' .
$this->parse_wp_user() .
'</script>' .
@ -279,15 +289,17 @@ class Typebot_Public
'"
></div>
<script>
if(document.readyState == "complete"){
' .
$bot_initializer .
'
} else {
window.addEventListener("load",(event) => {
var typebot = Typebot.initContainer("' .
$container_id .
'",{
hiddenVariables: typebotWpUser,
url: "' .
$url .
'",
})})
' .
$bot_initializer .
'
})
}
</script>';
}