2
0

(wordpress) Add the lib_version attribute to wp admin panel

Closes
This commit is contained in:
Baptiste Arnaud
2024-04-11 11:48:27 +02:00
parent 6594c56adf
commit f5508701fc
8 changed files with 45 additions and 8 deletions

View File

@ -8,12 +8,17 @@ import {
Link, Link,
Stack, Stack,
Text, Text,
Code,
} from '@chakra-ui/react' } from '@chakra-ui/react'
import { BubbleProps } from '@typebot.io/nextjs' import { BubbleProps } from '@typebot.io/nextjs'
import { useState } from 'react' import { useState } from 'react'
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings' import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
import { parseApiHostValue, parseInitBubbleCode } from '../../../snippetParsers' import { parseApiHostValue, parseInitBubbleCode } from '../../../snippetParsers'
import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions' import { parseDefaultBubbleTheme } from '../../Javascript/instructions/JavascriptBubbleInstructions'
import packageJson from '../../../../../../../../../../packages/embeds/js/package.json'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
const typebotCloudLibraryVersion = '0.2'
type Props = { type Props = {
publicId: string publicId: string
@ -52,6 +57,14 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
<ExternalLinkIcon mx="2px" /> <ExternalLinkIcon mx="2px" />
</Link> </Link>
</ListItem> </ListItem>
<ListItem>
Set <Code>Library version</Code> to{' '}
<Code>
{isCloudProdInstance()
? typebotCloudLibraryVersion
: packageJson.version}
</Code>
</ListItem>
<ListItem> <ListItem>
<Stack spacing={4}> <Stack spacing={4}>
<BubbleSettings <BubbleSettings

View File

@ -7,11 +7,16 @@ import {
Link, Link,
Stack, Stack,
Text, Text,
Code,
} from '@chakra-ui/react' } from '@chakra-ui/react'
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 { parseApiHostValue } from '../../../snippetParsers' import { parseApiHostValue } from '../../../snippetParsers'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import packageJson from '../../../../../../../../../../packages/embeds/js/package.json'
const typebotCloudLibraryVersion = '0.2'
type Props = { type Props = {
publicId: string publicId: string
@ -42,6 +47,14 @@ export const WordpressPopupInstructions = ({
<ExternalLinkIcon mx="2px" /> <ExternalLinkIcon mx="2px" />
</Link> </Link>
</ListItem> </ListItem>
<ListItem>
Set <Code>Library version</Code> to{' '}
<Code>
{isCloudProdInstance()
? typebotCloudLibraryVersion
: packageJson.version}
</Code>
</ListItem>
<ListItem> <ListItem>
<Stack spacing={4}> <Stack spacing={4}>
<PopupSettings <PopupSettings

View File

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

View File

@ -2,10 +2,10 @@
Contributors: baptisteArno Contributors: baptisteArno
Tags: typebot, forms, surveys, quizzes, form builder, survey builder, quiz builder, custom forms, mobile forms, payment forms, order forms, feedback forms, enquiry forms, stripe, dropbox, google sheets, mailchimp, salesforce, hubspot, activecampaign, infusionsoft, asana, hipchat, slack, trello, zendesk Tags: typebot, forms, surveys, quizzes, form builder, survey builder, quiz builder, custom forms, mobile forms, payment forms, order forms, feedback forms, enquiry forms, stripe, dropbox, google sheets, mailchimp, salesforce, hubspot, activecampaign, infusionsoft, asana, hipchat, slack, trello, zendesk
Requires at least: 5.0 Requires at least: 5.0
Tested up to: 6.0 Tested up to: 6.5
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.5.0 Stable Tag: 3.6.0
== Description == == Description ==
Collect 4x more responses with conversational apps using Typebot. Collect 4x more responses with conversational apps using Typebot.
@ -23,6 +23,10 @@ This plugin relies on Typebot which is a tool that allows you to create conversa
2. Activate the plugin through the Plugins menu in WordPress 2. Activate the plugin through the Plugins menu in WordPress
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 ==
= 3.6.0 =
* Add the lib_version attribute to wp admin panel
== Changelog == == Changelog ==
= 3.5.0 = = 3.5.0 =
* Add the lib_version attribute in shortcode * Add the lib_version attribute in shortcode

View File

@ -25,6 +25,7 @@ class Typebot_Admin
public function register_typebot_settings() public function register_typebot_settings()
{ {
register_setting('typebot', 'lib_version');
register_setting('typebot', 'init_snippet'); register_setting('typebot', 'init_snippet');
register_setting('typebot', 'excluded_pages'); register_setting('typebot', 'excluded_pages');
} }

View File

@ -9,6 +9,11 @@
settings_fields('typebot'); settings_fields('typebot');
do_settings_sections('typebot'); do_settings_sections('typebot');
?> ?>
<div style="display: flex; flex-direction: column">
<label>Library version:</label>
<input name="lib_version" value="<?php echo esc_attr(get_option('lib_version') !== null && get_option('lib_version') !== '' ? get_option('lib_version') : '0.2'); ?>" style="padding: .5rem" />
</div>
<div style="display: flex; flex-direction: column"> <div style="display: flex; flex-direction: column">
<label>If embedding as <strong>Popup</strong> or <strong>Bubble</strong>, paste the initialization snippet here:</label> <label>If embedding as <strong>Popup</strong> or <strong>Bubble</strong>, paste the initialization snippet here:</label>
<textarea name="init_snippet" style="min-height: 150px; padding: 0.5rem; margin-top: 1rem"><?php echo esc_attr(get_option('init_snippet')); ?></textarea> <textarea name="init_snippet" style="min-height: 150px; padding: 0.5rem; margin-top: 1rem"><?php echo esc_attr(get_option('init_snippet')); ?></textarea>

View File

@ -40,7 +40,8 @@ class Typebot_Public
function typebot_script() function typebot_script()
{ {
echo '<script type="module">import Typebot from "https://cdn.jsdelivr.net/npm/@typebot.io/js@0.2.15/dist/web.js";'; $lib_version = get_option('lib_version') !== null && get_option('lib_version') !== '' ? get_option('lib_version') : '0.2';
echo '<script type="module">import Typebot from "https://cdn.jsdelivr.net/npm/@typebot.io/js@'.$lib_version.'/dist/web.js";';
if ( if (
get_option('excluded_pages') !== null && get_option('excluded_pages') !== null &&
get_option('excluded_pages') !== '' get_option('excluded_pages') !== ''

View File

@ -3,7 +3,7 @@
/** /**
* Plugin Name: Typebot * Plugin Name: Typebot
* Description: Convert more with conversational forms * Description: Convert more with conversational forms
* Version: 3.5.0 * Version: 3.6.0
* 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.5.0'); define('TYPEBOT_VERSION', '3.6.0');
function activate_typebot() function activate_typebot()
{ {