Skip to content

Commit

Permalink
⚡ (wordpress) Add lib_version prop in shortcode
Browse files Browse the repository at this point in the history
Closes #1035
  • Loading branch information
baptisteArno committed Nov 30, 2023
1 parent 8d413f0 commit eeac493
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"` : ''}]
`
}
2 changes: 1 addition & 1 deletion apps/builder/src/features/typebot/api/getTypebot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -100,5 +99,6 @@ const getCurrentUserMode = (
return 'write'

if (collaborator) return 'read'
if (user?.email === env.ADMIN_EMAIL) return 'read'
return 'guest'
}
6 changes: 3 additions & 3 deletions packages/embeds/wordpress/package.json
Original file line number Diff line number Diff line change
@@ -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'"
}
}
5 changes: 4 additions & 1 deletion packages/embeds/wordpress/trunk/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ function typebot_script()

public function add_typebot_container($attributes = [])
{
$lib_url = "https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/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';
Expand Down
4 changes: 2 additions & 2 deletions packages/embeds/wordpress/trunk/typebot.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand All @@ -16,7 +16,7 @@
die();
}

define('TYPEBOT_VERSION', '3.4.2');
define('TYPEBOT_VERSION', '3.5.0');

function activate_typebot()
{
Expand Down

1 comment on commit eeac493

@vercel
Copy link

@vercel vercel bot commented on eeac493 Nov 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app
app.typebot.io

Please sign in to comment.