2
0

(wordpress) Add lib_version prop in shortcode

Closes #1035
This commit is contained in:
Baptiste Arnaud
2023-11-30 17:25:37 +01:00
parent 8d413f0865
commit eeac493387
6 changed files with 19 additions and 9 deletions

View File

@ -13,6 +13,7 @@ import { useState } from 'react'
import { StandardSettings } from '../../../settings/StandardSettings'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import { env } from '@typebot.io/env'
import packageJson from '../../../../../../../../../../packages/embeds/js/package.json'
type Props = {
publicId: string
@ -76,7 +77,9 @@ const parseWordpressShortcode = ({
publicId: string
}) => {
return `[typebot typebot="${publicId}"${
isCloudProdInstance() ? '' : ` host="${env.NEXT_PUBLIC_VIEWER_URL[0]}"`
isCloudProdInstance()
? ''
: ` host="${env.NEXT_PUBLIC_VIEWER_URL[0]}" lib_version="${packageJson.version}"`
}${width ? ` width="${width}"` : ''}${height ? ` height="${height}"` : ''}]
`
}

View File

@ -87,7 +87,6 @@ const getCurrentUserMode = (
workspace: { members: { userId: string }[] }
}
) => {
if (user?.email === env.ADMIN_EMAIL) return 'read'
const collaborator = typebot.collaborators.find((c) => c.userId === user?.id)
const isMemberOfWorkspace = typebot.workspace.members.some(
(m) => m.userId === user?.id
@ -100,5 +99,6 @@ const getCurrentUserMode = (
return 'write'
if (collaborator) return 'read'
if (user?.email === env.ADMIN_EMAIL) return 'read'
return 'guest'
}

View File

@ -1,13 +1,13 @@
{
"name": "@typebot.io/wordpress",
"version": "3.4.2",
"version": "3.5.0",
"main": "index.js",
"repository": "https://github.com/baptisteArno/typebot.io",
"author": "baptisteArno",
"license": "AGPL-3.0-or-later",
"scripts": {
"deploy": "pnpm copy && pnpm commit",
"copy": "svn copy ./trunk ./tags/3.4.2",
"commit": "svn ci -m 'Affect v0.2.15 to Standard embed'"
"copy": "svn copy ./trunk ./tags/3.5.0",
"commit": "svn ci -m 'Add lib_version attr in shortcode'"
}
}

View File

@ -5,7 +5,7 @@ Requires at least: 5.0
Tested up to: 6.0
License: GPL 2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Stable Tag: 3.4.2
Stable Tag: 3.5.0
== Description ==
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
== Changelog ==
= 3.5.0 =
* Add the lib_version attribute in shortcode
= 3.4.2 =
* Affect v0.2.15 to Standard embed as well

View File

@ -91,7 +91,11 @@ class Typebot_Public
public function add_typebot_container($attributes = [])
{
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2.15/dist/web.js";
$lib_version = '0.2';
if(array_key_exists('lib_version', $attributes)) {
$lib_version = sanitize_text_field($attributes['lib_version']);
}
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/js@". $lib_version ."/dist/web.js";
$width = '100%';
$height = '500px';
$api_host = 'https://typebot.io';

View File

@ -3,7 +3,7 @@
/**
* Plugin Name: Typebot
* Description: Convert more with conversational forms
* Version: 3.4.2
* Version: 3.5.0
* Author: Typebot
* Author URI: http://typebot.io/
* License: GPL-2.0+
@ -16,7 +16,7 @@ if (!defined('WPINC')) {
die();
}
define('TYPEBOT_VERSION', '3.4.2');
define('TYPEBOT_VERSION', '3.5.0');
function activate_typebot()
{