⚡ (wp) Add custom api host for WP plugin
This commit is contained in:
@ -14,6 +14,8 @@ import { useState } from 'react'
|
|||||||
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
|
||||||
import { parseInitBubbleCode } from '../../../snippetParsers'
|
import { parseInitBubbleCode } from '../../../snippetParsers'
|
||||||
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
|
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
|
||||||
|
import { isCloudProdInstance } from '@/utils/helpers'
|
||||||
|
import { env, getViewerUrl } from 'utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
publicId: string
|
publicId: string
|
||||||
@ -29,6 +31,9 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
|
|||||||
|
|
||||||
const initCode = parseInitBubbleCode({
|
const initCode = parseInitBubbleCode({
|
||||||
typebot: publicId,
|
typebot: publicId,
|
||||||
|
apiHost: isCloudProdInstance
|
||||||
|
? undefined
|
||||||
|
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
||||||
theme: {
|
theme: {
|
||||||
...theme,
|
...theme,
|
||||||
chatWindow: {
|
chatWindow: {
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { PopupSettings } from '../../../settings/PopupSettings'
|
import { PopupSettings } from '../../../settings/PopupSettings'
|
||||||
import { parseInitPopupCode } from '../../../snippetParsers/popup'
|
import { parseInitPopupCode } from '../../../snippetParsers/popup'
|
||||||
|
import { isCloudProdInstance } from '@/utils/helpers'
|
||||||
|
import { env, getViewerUrl } from 'utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
publicId: string
|
publicId: string
|
||||||
@ -20,6 +22,9 @@ export const WordpressPopupInstructions = ({ publicId }: Props) => {
|
|||||||
|
|
||||||
const initCode = parseInitPopupCode({
|
const initCode = parseInitPopupCode({
|
||||||
typebot: publicId,
|
typebot: publicId,
|
||||||
|
apiHost: isCloudProdInstance
|
||||||
|
? undefined
|
||||||
|
: env('VIEWER_INTERNAL_URL') ?? getViewerUrl(),
|
||||||
autoShowDelay,
|
autoShowDelay,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@ import {
|
|||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { StandardSettings } from '../../../settings/StandardSettings'
|
import { StandardSettings } from '../../../settings/StandardSettings'
|
||||||
|
import { isCloudProdInstance } from '@/utils/helpers'
|
||||||
|
import { env, getViewerUrl } from 'utils'
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
publicId: string
|
publicId: string
|
||||||
@ -73,8 +75,10 @@ const parseWordpressShortcode = ({
|
|||||||
height?: string
|
height?: string
|
||||||
publicId: string
|
publicId: string
|
||||||
}) => {
|
}) => {
|
||||||
return `[typebot typebot="${publicId}"${width ? ` width="${width}"` : ''}${
|
return `[typebot typebot="${publicId}"${
|
||||||
height ? ` height="${height}"` : ''
|
isCloudProdInstance
|
||||||
}]
|
? ''
|
||||||
|
: ` apiHost="${env('VIEWER_INTERNAL_URL') ?? getViewerUrl()}"`
|
||||||
|
}${width ? ` width="${width}"` : ''}${height ? ` height="${height}"` : ''}]
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,10 @@ You can use these variables anywhere on your typebot. For more informations, che
|
|||||||
|
|
||||||
There is an a box where there is a list of URLs it localises, one of them was ‘https://cdn.jsdelivr.net’. This URL should be removed from it since it is used to import the embed library.
|
There is an a box where there is a list of URLs it localises, one of them was ‘https://cdn.jsdelivr.net’. This URL should be removed from it since it is used to import the embed library.
|
||||||
|
|
||||||
|
## You have litespeed with cache enabled
|
||||||
|
|
||||||
|
Make sure to insert `web.js` and `typebot` in the JS Excludes textbox and JS Deferred Excludes under Tuning Settings.
|
||||||
|
|
||||||
### You have a cache plugin
|
### You have a cache plugin
|
||||||
|
|
||||||
Plugins like WP Rocket prevent Typebot to work.
|
Plugins like WP Rocket prevent Typebot to work.
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "wordpress",
|
"name": "wordpress",
|
||||||
"version": "3.1.3",
|
"version": "3.1.4",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "https://github.com/baptisteArno/typebot.io",
|
"repository": "https://github.com/baptisteArno/typebot.io",
|
||||||
"author": "baptisteArno",
|
"author": "baptisteArno",
|
||||||
@ -11,7 +11,7 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"deploy": "pnpm copy && pnpm commit",
|
"deploy": "pnpm copy && pnpm commit",
|
||||||
"copy": "svn copy ./trunk ./tags/3.1.3",
|
"copy": "svn copy ./trunk ./tags/3.1.4",
|
||||||
"commit": "svn ci -m 'Update plugin metadata and readme'"
|
"commit": "svn ci -m 'Support for custom apiHost'"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ Requires at least: 5.0
|
|||||||
Tested up to: 6.0
|
Tested up to: 6.0
|
||||||
License: GPL 2.0
|
License: GPL 2.0
|
||||||
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
||||||
Stable Tag: 3.1.3
|
Stable Tag: 3.1.4
|
||||||
|
|
||||||
== Description ==
|
== Description ==
|
||||||
Collect 4x more responses with conversational apps using Typebot.
|
Collect 4x more responses with conversational apps using Typebot.
|
||||||
@ -24,6 +24,9 @@ This plugin relies on Typebot which is a tool that allows you to create conversa
|
|||||||
3. Activate your Typebot with the "Typebot" admin button located in the sidebar
|
3. Activate your Typebot with the "Typebot" admin button located in the sidebar
|
||||||
|
|
||||||
== Changelog ==
|
== Changelog ==
|
||||||
|
= 3.1.4 =
|
||||||
|
* Support for apiHost field in shortcode
|
||||||
|
|
||||||
= 3.1.1 =
|
= 3.1.1 =
|
||||||
* Fix excluded pages when empty
|
* Fix excluded pages when empty
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ class Typebot_Public
|
|||||||
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js";
|
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.0/dist/web.js";
|
||||||
$width = '100%';
|
$width = '100%';
|
||||||
$height = '500px';
|
$height = '500px';
|
||||||
|
$api_host = 'https://api.typebot.io';
|
||||||
if (array_key_exists('width', $attributes)) {
|
if (array_key_exists('width', $attributes)) {
|
||||||
$width = sanitize_text_field($attributes['width']);
|
$width = sanitize_text_field($attributes['width']);
|
||||||
}
|
}
|
||||||
@ -89,6 +90,9 @@ class Typebot_Public
|
|||||||
if (array_key_exists('typebot', $attributes)) {
|
if (array_key_exists('typebot', $attributes)) {
|
||||||
$typebot = sanitize_text_field($attributes['typebot']);
|
$typebot = sanitize_text_field($attributes['typebot']);
|
||||||
}
|
}
|
||||||
|
if (array_key_exists('apiHost', $attributes)) {
|
||||||
|
$api_host = sanitize_text_field($attributes['apiHost']);
|
||||||
|
}
|
||||||
if (!$typebot) {
|
if (!$typebot) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -97,7 +101,7 @@ class Typebot_Public
|
|||||||
|
|
||||||
$bot_initializer = '<script type="module">
|
$bot_initializer = '<script type="module">
|
||||||
import Typebot from "' . $lib_url . '"
|
import Typebot from "' . $lib_url . '"
|
||||||
Typebot.initStandard({ id: "' . $id . '", typebot: "' . $typebot . '", prefilledVariables: { typebotWpUser } });</script>';
|
Typebot.initStandard({ apiHost: "' . $api_host . '", id: "' . $id . '", typebot: "' . $typebot . '", prefilledVariables: { typebotWpUser } });</script>';
|
||||||
|
|
||||||
return '<typebot-standard id="' . $id . '" style="width: ' . $width . '; height: ' . $height . ';"></typebot-standard>' . $bot_initializer;
|
return '<typebot-standard id="' . $id . '" style="width: ' . $width . '; height: ' . $height . ';"></typebot-standard>' . $bot_initializer;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
/**
|
/**
|
||||||
* Plugin Name: Typebot
|
* Plugin Name: Typebot
|
||||||
* Description: Convert more with conversational forms
|
* Description: Convert more with conversational forms
|
||||||
* Version: 3.1.2
|
* Version: 3.1.4
|
||||||
* Author: Typebot
|
* Author: Typebot
|
||||||
* Author URI: http://typebot.io/
|
* Author URI: http://typebot.io/
|
||||||
* License: GPL-2.0+
|
* License: GPL-2.0+
|
||||||
@ -16,7 +16,7 @@ if (!defined('WPINC')) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
define('TYPEBOT_VERSION', '3.1.2');
|
define('TYPEBOT_VERSION', '3.1.4');
|
||||||
|
|
||||||
function activate_typebot()
|
function activate_typebot()
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user