From 51ba6940484c5ef843a32a4e44cc10187f6a161d Mon Sep 17 00:00:00 2001 From: Jan Rohweder Date: Sun, 31 Mar 2024 15:23:40 +0700 Subject: [PATCH] Updated script tag to avoid loading issues of elements.js --- CHANGELOG.md | 2 +- README.txt | 4 ++-- wink.php | 19 ++++++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be9d3ad..dba996d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ Changelog of wink-wordpress-plugin. -## 1.4.14 (2024-02-26) +## 1.4.15 (2024-03-31) ### Other changes diff --git a/README.txt b/README.txt index d5470a2..8ada806 100644 --- a/README.txt +++ b/README.txt @@ -3,8 +3,8 @@ Contributors: MB-Jan, bjornharvold Tags: wink2travel, travel, hotel, booking, affiliate network Requires at least: 4.7 Tested up to: 6.4 -Stable tag: 1.4.14 -Version: 1.4.14 +Stable tag: 1.4.15 +Version: 1.4.15 Requires PHP: 7.4 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html diff --git a/wink.php b/wink.php index 6d5ddf2..04a3bb2 100644 --- a/wink.php +++ b/wink.php @@ -2,7 +2,7 @@ /** * Plugin Name: Wink Affiliate WordPress Plugin * Description: This plugin integrates your Wink affiliate account with WordPress. It integrates with Gutenberg, Elementor, Avada, WPBakery and as shortcodes. - * Version: 1.4.14 + * Version: 1.4.15 * Author: Wink * Author URI: https://wink.travel/ * License: GPL-3.0 @@ -40,7 +40,7 @@ function __construct() { //add_action('init', array( $this,'gutenbergBlockRegistration' ) ); // Adding Gutenberg Block add_action( 'wp_enqueue_scripts', array($this, 'loadScripts' )); // too resource intensive to search all pages for Wink elements. Scripts need to be added all the time. - add_filter( 'clean_url', array($this,'jsHelper'), 11, 1 ); // Helper to add attribute to js tag + add_filter( 'script_loader_tag', array($this,'jsHelper'), 11, 3 ); // Helper to add attribute to js tag add_action( 'admin_enqueue_scripts', array($this,'customizeScripts')); add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array($this,'settingsLink' )); @@ -69,21 +69,26 @@ function customizeScripts() { wp_enqueue_style( 'winkCustomizer', $this->pluginURL . 'css/customize.css', array(), $this->version ); } } - function jsHelper($url) { + function jsHelper($tag, $handle, $src) { $env = winkCore::environmentURL('js', $this->environmentVal); $optimize = array( - $env.'/elements.js?ver='.$this->version + 'wink-Elements', + 'wink-Elements-Poly', + 'wink-Elements-main' ); - if ( in_array( $url, $optimize ) ) { // this will be optimized - return "$url' defer data-cfasync='true"; + if ( in_array( $handle, $optimize ) ) { // this will be optimized + $tag = ''; } - return $url; + return $tag; } + function loadScripts() { if (!empty(get_option($this->clientIdKey, false))) { $env = winkCore::environmentURL('js', $this->environmentVal); wp_enqueue_style('wink',$env.'/styles.css',array(),$this->version); wp_enqueue_script('wink-Elements',$env.'/elements.js',array(),$this->version,true); + // wp_enqueue_script('wink-Elements-Poly',$env.'/polyfills.js',array(),$this->version,true); + // wp_enqueue_script('wink-Elements-main',$env.'/main.js',array(),$this->version,true); } } function adminNotice() {