Plugin Directory

Changeset 3255883


Ignore:
Timestamp:
03/14/2025 12:11:56 PM (13 months ago)
Author:
DaveFX
Message:

Deploy from Git

Location:
share-one/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • share-one/trunk/build/index.asset.php

    r3157916 r3255883  
    1 <?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks'), 'version' => '6c2e18a49c2bc1d29a01');
     1<?php return array('dependencies' => array('react-jsx-runtime', 'wp-block-editor', 'wp-blocks'), 'version' => '1699766586bc711261c5');
  • share-one/trunk/build/index.js

    r3157916 r3255883  
    1 (()=>{"use strict";const e=window.wp.blocks,o=window.wp.blockEditor,s=window.ReactJSXRuntime;(0,e.registerBlockType)("share-one/wall-of-love",{title:"Share.one - Wall of Love",icon:"heart",category:"widgets",edit(){const e=Math.random().toString(36).substring(7),{serverUrl:i,uuid:r}=shareOneData;return setTimeout((()=>{const o=`${i}/walloflove/${r}.js?div_id=${e}`,s=document.createElement("script");s.src=o,s.defer=!0,document.body.appendChild(s)}),1e3),(0,s.jsx)("div",{...(0,o.useBlockProps)(),children:r?(0,s.jsx)("p",{id:e}):(0,s.jsx)("p",{children:(0,s.jsx)("em",{children:"No UUID defined in Share.one settings."})})})},save:()=>(0,s.jsx)("div",{...o.useBlockProps.save(),children:(0,s.jsx)("p",{children:"[share_one_wall_of_love]"})})})})();
     1(()=>{"use strict";const e=window.wp.blocks,i=window.wp.blockEditor,t=window.ReactJSXRuntime;(0,e.registerBlockType)("share-one/wall-of-love",{title:"Share.one - Wall of Love",icon:"heart",category:"widgets",edit(){const e=Math.random().toString(36).substring(7),{serverUrl:s,uuid:r}=shareOneData;return setTimeout((()=>{const i=`${s}/walloflove/${r}.js?div_id=${e}`,t=document.createElement("script");t.src=i,t.defer=!0,document.body.appendChild(t)}),1e3),(0,t.jsx)("div",{...(0,i.useBlockProps)(),children:r?(0,t.jsx)("p",{id:e}):(0,t.jsx)("p",{children:(0,t.jsx)("em",{children:"No UUID defined in Share.one settings."})})})},save:()=>(0,t.jsx)("div",{...i.useBlockProps.save(),children:(0,t.jsx)("p",{children:"[share_one_wall_of_love]"})})}),(0,e.registerBlockType)("share-one/catch-widget",{title:"Share.one - Inline Catch widget",icon:"heart",category:"widgets",edit(){const e=Math.random().toString(36).substring(7),{serverUrl:s,uuid:r}=shareOneData;return setTimeout((()=>{const i=`${s}/inline-widget/${r}.js?div_id=${e}`,t=document.createElement("script");t.src=i,t.defer=!0,document.body.appendChild(t)}),1e3),(0,t.jsx)("div",{...(0,i.useBlockProps)(),children:r?(0,t.jsx)("p",{id:e}):(0,t.jsx)("p",{children:(0,t.jsx)("em",{children:"No UUID defined in Share.one settings."})})})},save:()=>(0,t.jsx)("div",{...i.useBlockProps.save(),children:(0,t.jsx)("p",{children:"[share_one_catch_widget]"})})})})();
  • share-one/trunk/package.json

    r3157916 r3255883  
    11{
    22  "name": "share-one",
    3   "version": "1.0.0",
    4   "main": "index.js",
     3  "version": "1.1.0",
     4  "main": "build/index.js",
    55  "scripts": {
    66    "build": "wp-scripts build",
  • share-one/trunk/readme.txt

    r3157916 r3255883  
    33Requires at least: 6.0
    44Tested up to: 6.6.1
    5 Stable tag: 1.0.1
     5Stable tag: 1.1.0
    66Requires PHP: 8.0
    77License: GPLv3 or later
     
    2121== Changelog ==
    2222
     23= 1.1.0 =
     24
     25* New: Added support to render the inline Catch widget.
     26
    2327= 1.0.1 =
    2428
  • share-one/trunk/share-one.php

    r3157916 r3255883  
    33Plugin Name: Share.one
    44Description: Show professional video testimonials by Share.one in an easy way
    5 Version: 1.0.1
     5Version: 1.1.0
    66Author: Share.one
    77Author URI: https://www.share.one/
     
    1313}
    1414
    15 const SHARE_ONE_PLUGIN_VERSION = '1.0.1';
     15const SHARE_ONE_PLUGIN_VERSION = '1.1.0';
    1616
    1717// Define the option name for the UUID and script toggle
     
    9595
    9696                <div class="share-one-setting">
     97                    <label>Inline catch widget</label>
     98                    <p>
     99                        After saving your settings, you can use the following shortcode to render an inline catch widget in the contents of
     100                        any page or post in your website:
     101                    </p>
     102                    <code>[share_one_catch_widget]</code>
     103                    <p>
     104                        You can also use the Share.one Inline CATCH Gutenberg block to add the it to your
     105                        pages and posts.
     106                    </p>
     107                </div>
     108
     109                <div class="share-one-setting">
    97110                    <label>Wall of Love</label>
    98111                    <p>
     
    149162add_shortcode( 'share_one_wall_of_love', 'share_one_render_wall_of_love_shortcode' );
    150163
     164// Shortcode to render the Wall of Love JS snippet
     165function share_one_render_catch_widget_shortcode() {
     166    $uuid         = esc_attr( get_option( SHARE_ONE_OPTION_UUID ) );
     167    $catch_server = esc_attr( get_option( SHARE_ONE_OPTION_CATCH_SERVER ) );
     168
     169    $div_id = uniqid('share-one-inline-catch-', true);
     170
     171    if ( $uuid ) {
     172        wp_enqueue_script( $div_id, $catch_server . '/inline-widget/' . $uuid . '.js?div_id=' . $div_id, array(), SHARE_ONE_PLUGIN_VERSION, array( 'strategy' => 'defer' ) );
     173        return "<div id='" . $div_id . "'></div>";
     174    }
     175
     176    return '';
     177}
     178
     179add_shortcode( 'share_one_catch_widget', 'share_one_render_catch_widget_shortcode' );
     180
     181
    151182// Register Gutenberg block
    152 function share_one_register_gutenberg_block() {
     183function share_one_register_gutenberg_blocks() {
    153184    // Automatically load dependencies and version
    154185    $asset_file = include( plugin_dir_path( __FILE__ ) . 'build/index.asset.php' );
    155186
    156187    wp_register_script(
    157         'share-one-wall-of-love-block',
     188        'share-one-blocks',
    158189        plugins_url( 'build/index.js', __FILE__ ),
    159190        $asset_file['dependencies'],
     
    167198
    168199    // Pass the UUID to the block script
    169     wp_localize_script( 'share-one-wall-of-love-block', 'shareOneData', array(
     200    wp_localize_script( 'share-one-blocks', 'shareOneData', array(
    170201        'serverUrl' => $server_url,
    171202        'uuid'      => $uuid,
     
    173204
    174205    register_block_type( 'share-one/wall-of-love', array(
    175         'editor_script' => 'share-one-wall-of-love-block',
     206        'editor_script' => 'share-one-blocks',
    176207    ) );
    177 }
    178 
    179 add_action( 'init', 'share_one_register_gutenberg_block' );
    180 
    181 // Include the Elementor widget file
    182 include_once plugin_dir_path( __FILE__ ) . 'wall-of-love-elementor-widget.php';
     208
     209    register_block_type( 'share-one/catch-widget', array(
     210        'editor_script' => 'share-one-blocks',
     211    ) );
     212
     213}
     214add_action( 'init', 'share_one_register_gutenberg_blocks' );
    183215
    184216function share_one_register_elementor_widget() {
     217    \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Share_One_Inline_Catch_Widget() );
    185218    \Elementor\Plugin::instance()->widgets_manager->register_widget_type( new \Share_One_Wall_of_Love_Widget() );
    186219}
    187220
    188 add_action( 'elementor/widgets/widgets_registered', 'share_one_register_elementor_widget' );
    189 
     221// If Elementor class exists
     222if ( class_exists( '\Elementor\Widget_Base' ) ) {
     223    // Include the Elementor widget file
     224    include_once plugin_dir_path( __FILE__ ) . 'inline-catch-elementor-widget.php';
     225
     226    // Include the Elementor widget file
     227    include_once plugin_dir_path( __FILE__ ) . 'wall-of-love-elementor-widget.php';
     228
     229    add_action( 'elementor/widgets/widgets_registered', 'share_one_register_elementor_widget' );
     230}
     231
     232
  • share-one/trunk/src/index.js

    r3157916 r3255883  
    3535    },
    3636});
     37
     38registerBlockType('share-one/catch-widget', {
     39    title: 'Share.one - Inline Catch widget',
     40    icon: 'heart',
     41    category: 'widgets',
     42    edit() {
     43        const randomId = Math.random().toString(36).substring(7);
     44        const { serverUrl, uuid } = shareOneData;
     45        setTimeout(() => {
     46            const widget_js_url = `${serverUrl}/inline-widget/${uuid}.js?div_id=${randomId}`;
     47            const script = document.createElement('script');
     48            script.src = widget_js_url;
     49            script.defer = true;
     50            document.body.appendChild(script);
     51        }, 1000);
     52
     53        return (
     54            <div {...useBlockProps()}>
     55                {uuid ? (
     56                    <p id={randomId}></p>
     57                ) : (
     58                    <p><em>No UUID defined in Share.one settings.</em></p>
     59                )}
     60            </div>
     61        );
     62    },
     63    save() {
     64        return (
     65            <div {...useBlockProps.save()}>
     66                <p>[share_one_catch_widget]</p>
     67            </div>
     68        );
     69    },
     70});
Note: See TracChangeset for help on using the changeset viewer.