Plugin Directory

Changeset 2976975


Ignore:
Timestamp:
10/10/2023 10:56:47 AM (2 years ago)
Author:
dyonic
Message:

Import ryen lib v0.2 to get the new variable parser

Location:
ryen-wp/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ryen-wp/trunk/README.txt

    r2941402 r2976975  
    33Tags: ryen, forms, surveys, quizzes, form builder, survey builder, quiz builder, custom forms, mobile forms, payment forms, feedback forms, zendesk
    44Requires at least: 5.0
    5 Tested up to: 6.2
     5Tested up to: 6.3
    66License: GPL 2.0
    77License URI: http://www.gnu.org/licenses/gpl-2.0.txt
    8 Stable Tag: 3.1.11
     8Stable Tag: 3.4.0
    99
    1010== Description ==
     
    1616
    1717This plugin relies on Ryen which is a tool that allows you to create conversational forms and directly integrate them on your Wordpress site and on our Ryen JS library (https://cdn.jsdelivr.net/npm/@ryen/js).
    18 💁‍♂️ More information about Ryen: https://www.ryen.org
    19 👨🏼‍💻 How Ryen handles collected data: https://www.ryen.org/privacy
     18
     19💁‍♂️ More information about Ryen: https://ryen.org
     20👨🏼‍💻 How Ryen handles collected data: https://ryen.org/privacy
    2021👨🏼‍💻 jsDelivr Terms & Policies: https://www.jsdelivr.com/terms
    2122
     
    2627
    2728== Changelog ==
     29= 3.4.0 =
     30* Import ryen lib v0.2 to get the new variable parser
     31
     32= 3.3.0 =
     33* Fix loading with Gravity Forms and add query params exclusion
     34
     35= 3.2.0 =
     36* Update embed lib to 0.1
     37
    2838= 3.1.11 =
    2939* Automatically forward UTMs for standard embed
  • ryen-wp/trunk/admin/partials/ryen-admin-display.php

    r2876406 r2976975  
    1717        <div style="display: flex; flex-direction: column; margin-top: 1rem">
    1818          <label>Excluded pages (optional):</label>
    19           <p style="color: gray">Example: /app/*, /user/*, /admin/settings</p>
     19          <p style="color: gray">Example: /app/*, /user/*, /admin/settings, /app?param=*</p>
    2020          <input name="excluded_pages" value="<?php echo esc_attr(get_option('excluded_pages')); ?>" style="padding: .5rem" />
    2121        </div>
  • ryen-wp/trunk/public/class-ryen-public.php

    r2941402 r2976975  
    11<?php
    2 
    32class Ryen_Public
    43{
    5   public function add_head_code()
     4  public function __construct()
    65  {
    7     function parse_wp_user()
    8     {
    9       $wp_user = wp_get_current_user();
    10       echo '<script>
     6    add_action('wp_head', array($this, 'parse_wp_user'));
     7    add_action('wp_footer', array($this, 'ryen_script'));
     8  }
     9
     10  public function parse_wp_user()
     11  {
     12    $wp_user = wp_get_current_user();
     13    echo '<script>
    1114      if(typeof window.ryenWpUser === "undefined"){
    1215      window.ryenWpUser = {
    1316          "WP ID":"' .
    14         $wp_user->ID .
    15         '",
     17      $wp_user->ID .
     18      '",
    1619          "WP Username":"' .
    17         $wp_user->user_login .
    18         '",
     20      $wp_user->user_login .
     21      '",
    1922          "WP Email":"' .
    20         $wp_user->user_email .
    21         '",
     23      $wp_user->user_email .
     24      '",
    2225          "WP First name":"' .
    23         $wp_user->user_firstname .
    24         '",
     26      $wp_user->user_firstname .
     27      '",
    2528          "WP Last name":"' .
    26         $wp_user->user_lastname .
    27         '",
     29      $wp_user->user_lastname .
     30      '"
    2831        }
    2932      }
    3033      </script>';
     34  }
     35
     36  public function add_head_code()
     37  {
     38    $this->parse_wp_user();
     39  }
     40
     41  function ryen_script()
     42  {
     43    echo '<script type="module">import Ryen from "https://cdn.jsdelivr.net/npm/@ryen/js@0.2/dist/web.js";';
     44    if (
     45      get_option('excluded_pages') !== null &&
     46      get_option('excluded_pages') !== ''
     47    ) {
     48      $paths = explode(',', get_option('excluded_pages'));
     49      $arr_js = 'const ryenExcludePaths = [';
     50      foreach ($paths as $path) {
     51        $arr_js = $arr_js . '"' . $path . '",';
     52      }
     53      $arr_js = substr($arr_js, 0, -1) . '];';
     54      echo $arr_js;
     55    } else {
     56      echo 'const ryenExcludePaths = null;';
    3157    }
    3258
    33     function ryen_script()
    34     {
    35       echo '<script type="module">
    36       import Ryen from "https://cdn.jsdelivr.net/npm/@ryen/js@0.1/dist/web.js";';
    37       if (
    38         get_option('excluded_pages') !== null &&
    39         get_option('excluded_pages') !== ''
    40       ) {
    41         $paths = explode(',', get_option('excluded_pages'));
    42         $arr_js = 'const ryenExcludePaths = [';
    43         foreach ($paths as $path) {
    44           $arr_js = $arr_js . '"' . $path . '",';
    45         }
    46         $arr_js = substr($arr_js, 0, -1) . '];';
    47         echo esc_js($arr_js);
    48       } else {
    49         echo 'const ryenExcludePaths = null;';
    50       }
    51       if (get_option('init_snippet') && get_option('init_snippet') !== '') {
    52 
    53         echo 'if(!ryenExcludePaths || ryenExcludePaths.every((path) => {
    54           let excludePath = path.trim();
     59    if (get_option('init_snippet') && get_option('init_snippet') !== '') {
     60      echo 'if(!ryenExcludePaths || ryenExcludePaths.every((path) => {
     61          let [excludePath, excludeSearch] = path.trim().split("?");
     62          const excludeSearchParams = excludeSearch ? new URLSearchParams(excludeSearch) : null;
    5563                    let windowPath = window.location.pathname;
     64          let windowSearchParams = window.location.search.length > 0 ? new URLSearchParams(window.location.search) : null;
    5665                    if (excludePath.endsWith("*")) {
     66            if(excludeSearchParams){
     67              if(!windowSearchParams) return true
     68              return !windowPath.startsWith(excludePath.slice(0, -1)) || !Array.from(excludeSearchParams.keys()).every((key) => excludeSearchParams.get(key) === "*" || (excludeSearchParams.get(key) === windowSearchParams.get(key)));
     69            }
    5770                        return !windowPath.startsWith(excludePath.slice(0, -1));
    5871                    }
    5972                    if (excludePath.endsWith("/")) {
    60                         excludePath = path.slice(0, -1);
     73                        excludePath = excludePath.slice(0, -1);
    6174                    }
    6275                    if (windowPath.endsWith("/")) {
    6376                        windowPath = windowPath.slice(0, -1);
    64                     }
    65                     return windowPath !== excludePath;
     77                    }   
     78          if(excludeSearchParams){
     79            if(!windowSearchParams) return true
     80            return windowPath !== excludePath || !Array.from(excludeSearchParams.keys()).every((key) => excludeSearchParams.get(key) === "*" || (excludeSearchParams.get(key) === windowSearchParams.get(key)));
     81          } else {
     82            return windowPath !== excludePath;
     83          }
    6684                })) {
    6785          ' . get_option('init_snippet') . '
    6886          Ryen.setPrefilledVariables({ ...ryenWpUser });
    69          
    7087        }';
    71       }
    72       echo '</script>';
    7388    }
    74     add_action('wp_head', 'parse_wp_user');
    75     add_action('wp_footer', 'ryen_script');
     89    echo '</script>';
    7690  }
    7791
    7892  public function add_ryen_container($attributes = [])
    7993  {
    80     $lib_url = "https://cdn.jsdelivr.net/npm/@ryen/js@0.1/dist/web.js";
     94    $lib_url = "https://cdn.jsdelivr.net/npm/@ryen/js@0.2/dist/web.js";
    8195    $width = '100%';
    8296    $height = '500px';
  • ryen-wp/trunk/ryen.php

    r2941402 r2976975  
    44 * Plugin Name:       Ryen WP
    55 * Description:       Convert more with conversational forms
    6  * Version:           3.1.11
     6 * Version:           3.4.0
    77 * Author:            Ryen
    8  * Author URI:        http://ryen.org/
     8 * Author URI:        https://ryen.org/
    99 * License:           GPL-2.0+
    1010 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
     
    1717}
    1818
    19 define('RYEN_VERSION', '3.1.11');
     19define('RYEN_VERSION', '3.4.0');
    2020
    2121function activate_ryen()
Note: See TracChangeset for help on using the changeset viewer.