Skip to content

Commit

Permalink
⚡ (wordpress) Add the lib_version attribute to wp admin panel
Browse files Browse the repository at this point in the history
Closes
  • Loading branch information
baptisteArno committed Apr 11, 2024
1 parent 6594c56 commit f550870
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ import {
Link,
Stack,
Text,
Code,
} from '@chakra-ui/react'
import { BubbleProps } from '@typebot.io/nextjs'
import { useState } from 'react'
import { BubbleSettings } from '../../../settings/BubbleSettings/BubbleSettings'
import { parseApiHostValue, parseInitBubbleCode } from '../../../snippetParsers'
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 = {
publicId: string
Expand Down Expand Up @@ -52,6 +57,14 @@ export const WordpressBubbleInstructions = ({ publicId }: Props) => {
<ExternalLinkIcon mx="2px" />
</Link>
</ListItem>
<ListItem>
Set <Code>Library version</Code> to{' '}
<Code>
{isCloudProdInstance()
? typebotCloudLibraryVersion
: packageJson.version}
</Code>
</ListItem>
<ListItem>
<Stack spacing={4}>
<BubbleSettings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import {
Link,
Stack,
Text,
Code,
} from '@chakra-ui/react'
import { useState } from 'react'
import { PopupSettings } from '../../../settings/PopupSettings'
import { parseInitPopupCode } from '../../../snippetParsers/popup'
import { parseApiHostValue } from '../../../snippetParsers'
import { isCloudProdInstance } from '@/helpers/isCloudProdInstance'
import packageJson from '../../../../../../../../../../packages/embeds/js/package.json'

const typebotCloudLibraryVersion = '0.2'

type Props = {
publicId: string
Expand Down Expand Up @@ -42,6 +47,14 @@ export const WordpressPopupInstructions = ({
<ExternalLinkIcon mx="2px" />
</Link>
</ListItem>
<ListItem>
Set <Code>Library version</Code> to{' '}
<Code>
{isCloudProdInstance()
? typebotCloudLibraryVersion
: packageJson.version}
</Code>
</ListItem>
<ListItem>
<Stack spacing={4}>
<PopupSettings
Expand Down
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.5.0",
"version": "3.6.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.5.0",
"commit": "svn ci -m 'Add lib_version attr in shortcode'"
"copy": "svn copy ./trunk ./tags/3.6.0",
"commit": "svn ci -m 'Add lib_version attr in admin panel'"
}
}
8 changes: 6 additions & 2 deletions packages/embeds/wordpress/trunk/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
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
Requires at least: 5.0
Tested up to: 6.0
Tested up to: 6.5
License: GPL 2.0
License URI: http://www.gnu.org/licenses/gpl-2.0.txt
Stable Tag: 3.5.0
Stable Tag: 3.6.0

== Description ==
Collect 4x more responses with conversational apps using Typebot.
Expand All @@ -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
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 ==
= 3.5.0 =
* Add the lib_version attribute in shortcode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function typebot_settings_callback()

public function register_typebot_settings()
{
register_setting('typebot', 'lib_version');
register_setting('typebot', 'init_snippet');
register_setting('typebot', 'excluded_pages');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
settings_fields('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">
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function add_head_code()

function typebot_script()
{
echo '<script type="module">import Typebot from "https://cdn.jsdelivr.net/npm/@typebot.io/[email protected]/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 (
get_option('excluded_pages') !== null &&
get_option('excluded_pages') !== ''
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.5.0
* Version: 3.6.0
* Author: Typebot
* Author URI: http://typebot.io/
* License: GPL-2.0+
Expand All @@ -16,7 +16,7 @@
die();
}

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

function activate_typebot()
{
Expand Down

0 comments on commit f550870

Please sign in to comment.