Changeset 2871061
- Timestamp:
- 02/25/2023 08:06:01 PM (3 years ago)
- Location:
- ryen-wp/trunk
- Files:
-
- 6 edited
-
README.txt (modified) (2 diffs)
-
admin/class-ryen-admin.php (modified) (1 diff)
-
admin/partials/ryen-admin-display.php (modified) (1 diff)
-
includes/class-ryen.php (modified) (1 diff)
-
public/class-ryen-public.php (modified) (1 diff)
-
ryen.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
ryen-wp/trunk/README.txt
r2869462 r2871061 6 6 License: GPL 2.0 7 7 License URI: http://www.gnu.org/licenses/gpl-2.0.txt 8 Stable Tag: 3. 0.18 Stable Tag: 3.1.1 9 9 10 10 Build beautiful conversational forms … … 27 27 28 28 == Changelog == 29 = 3.1.1 = 30 * Fix excluded pages when empty 31 * Breaking change! You will need to import the new code snippet again. 32 * Fix wp admin crash 33 * Introduce excluded pages input 34 29 35 = 3.0.1 = 30 36 * Fix flow not proceeding on unknown domains -
ryen-wp/trunk/admin/class-ryen-admin.php
r2869462 r2871061 27 27 { 28 28 register_setting('ryen', 'init_snippet'); 29 register_setting('ryen', 'excluded_pages'); 29 30 } 30 31 } -
ryen-wp/trunk/admin/partials/ryen-admin-display.php
r2869462 r2871061 12 12 <div style="display: flex; flex-direction: column"> 13 13 <label>If embedding as <strong>Popup</strong> or <strong>Bubble</strong>, paste the initialization snippet here:</label> 14 <textarea name="init_snippet" placeholder='Ryen.initPopup({ ryen: "https://ryen.org/my-ryen" });' style="min-height: 150px; padding: 0.5rem; margin-top: 1rem"><?php echo esc_attr(get_option('init_snippet')); ?></textarea> 14 <textarea name="init_snippet" style="min-height: 150px; padding: 0.5rem; margin-top: 1rem"><?php echo esc_attr(get_option('init_snippet')); ?></textarea> 15 </div> 16 17 <div style="display: flex; flex-direction: column; margin-top: 1rem"> 18 <label>Excluded pages (optionnal):</label> 19 <p style="color: gray">Example: /app/*, /user/*, /admin/settings</p> 20 <input name="excluded_pages" value="<?php echo esc_attr(get_option('excluded_pages')); ?>" style="padding: .5rem" /> 15 21 </div> 16 22 -
ryen-wp/trunk/includes/class-ryen.php
r2869462 r2871061 43 43 { 44 44 $plugin_admin = new Ryen_Admin($this->get_version()); 45 $this->loader->add_action('admin_enqueue_scripts', $plugin_admin, 'enqueue_styles');46 45 $this->loader->add_action('admin_menu', $plugin_admin, 'my_admin_menu'); 47 46 $this->loader->add_action('admin_init', $plugin_admin, 'register_ryen_settings'); -
ryen-wp/trunk/public/class-ryen-public.php
r2869462 r2871061 5 5 public function add_head_code() 6 6 { 7 function add_module_type($tag, $handle)7 function parse_wp_user() 8 8 { 9 if ('ryen' !== $handle) { 10 return $tag; 9 $wp_user = wp_get_current_user(); 10 echo '<script> 11 if(typeof window.ryenWpUser === "undefined"){ 12 window.ryenWpUser = { 13 wp_id:"' . 14 $wp_user->ID . 15 '", 16 wp_username:"' . 17 $wp_user->user_login . 18 '", 19 wp_email:"' . 20 $wp_user->user_email . 21 '", 22 wp_first_name:"' . 23 $wp_user->user_firstname . 24 '", 25 wp_last_name:"' . 26 $wp_user->user_lastname . 27 '", 28 } 11 29 } 12 $tag = str_replace( 13 '<script', 14 '<script type ="module"', 15 $tag 16 ); 17 return $tag; 30 </script>'; 18 31 } 19 32 20 wp_enqueue_script('ryen', 'whatever.js'); 21 add_filter('script_loader_tag', 'add_module_type', 10, 2); 22 wp_add_inline_script('ryen', $this->parse_wp_user()); 23 if (get_option('init_snippet') && get_option('init_snippet') !== '') { 24 wp_add_inline_script('ryen', get_option('init_snippet')); 25 wp_add_inline_script('ryen', 'Ryen.setPrefilledVariables({ ryenWpUser });'); 33 function ryen_script() 34 { 35 echo '<script type="module"> 36 import Ryen from "https://cdn.jsdelivr.net/npm/@ryen/js@0.0/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 $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(); 55 let windowPath = window.location.pathname; 56 if (excludePath.endsWith("*")) { 57 return !windowPath.startsWith(excludePath.slice(0, -1)); 58 } 59 if (excludePath.endsWith("/")) { 60 excludePath = path.slice(0, -1); 61 } 62 if (windowPath.endsWith("/")) { 63 windowPath = windowPath.slice(0, -1); 64 } 65 return windowPath !== excludePath; 66 })) { 67 ' . get_option('init_snippet') . ' 68 Ryen.setPrefilledVariables({ ryenWpUser }); 69 70 }'; 71 } 72 echo '</script>'; 26 73 } 27 } 28 29 private function parse_wp_user() 30 { 31 $wp_user = wp_get_current_user(); 32 return 'if(typeof window.ryenWpUser === "undefined"){ 33 window.ryenWpUser = { 34 wp_id:"' . 35 $wp_user->ID . 36 '", 37 wp_username:"' . 38 $wp_user->user_login . 39 '", 40 wp_email:"' . 41 $wp_user->user_email . 42 '", 43 wp_first_name:"' . 44 $wp_user->user_firstname . 45 '", 46 wp_last_name:"' . 47 $wp_user->user_lastname . 48 '", 49 } 50 }'; 74 add_action('wp_head', 'parse_wp_user'); 75 add_action('wp_footer', 'ryen_script'); 51 76 } 52 77 53 78 public function add_ryen_container($attributes = []) 54 79 { 55 $lib_url = "https://cdn.jsdelivr.net/npm/@ryen/js@0.0 .14/dist/web.js";80 $lib_url = "https://cdn.jsdelivr.net/npm/@ryen/js@0.0/dist/web.js"; 56 81 $width = '100%'; 57 82 $height = '500px'; -
ryen-wp/trunk/ryen.php
r2869462 r2871061 4 4 * Plugin Name: Ryen WP 5 5 * Description: Convert more with conversational forms 6 * Version: 3. 0.16 * Version: 3.1.1 7 7 * Author: Ryen 8 8 * Author URI: http://ryen.org/ … … 17 17 } 18 18 19 define('RYEN_VERSION', '3. 0.1');19 define('RYEN_VERSION', '3.1.1'); 20 20 21 21 function activate_ryen()
Note: See TracChangeset
for help on using the changeset viewer.