YITH WooCommerce Ajax Search - Version 1.6.6

Version Description

  • Released: May 29, 2019 = Update: Plugin Core 3.2.1
Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.6.6
Comparing to
See all releases

Code changes from version 1.6.5 to 1.6.6

README.txt CHANGED
@@ -3,8 +3,8 @@
3
Contributors: yithemes
4
Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
Requires at least: 4.0.0
6
- Tested up to: 5.0
7
- Stable tag: 1.6.5
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -138,6 +138,9 @@ If you have created your own language pack for YITH WooCommerce Ajax Search, or
138
2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
140
== Changelog ==
141
= 1.6.5 - Released: Apr 23, 2019 =
142
Update: Plugin Core 3.1.29
143
3
Contributors: yithemes
4
Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
Requires at least: 4.0.0
6
+ Tested up to: 5.2
7
+ Stable tag: 1.6.6
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
138
2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
140
== Changelog ==
141
+ = 1.6.6 - Released: May 29, 2019 =
142
+ Update: Plugin Core 3.2.1
143
+
144
= 1.6.5 - Released: Apr 23, 2019 =
145
Update: Plugin Core 3.1.29
146
init.php CHANGED
@@ -3,7 +3,7 @@
3
* Plugin Name: YITH WooCommerce Ajax Search
4
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
* Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
- * Version: 1.6.5
7
* Author: YITH
8
* Author URI: https://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-search
@@ -67,7 +67,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
67
if ( defined( 'YITH_WCAS_VERSION' ) ){
68
return;
69
}else{
70
- define( 'YITH_WCAS_VERSION', '1.6.5' );
71
}
72
73
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
3
* Plugin Name: YITH WooCommerce Ajax Search
4
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
* Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
+ * Version: 1.6.6
7
* Author: YITH
8
* Author URI: https://yithemes.com/
9
* Text Domain: yith-woocommerce-ajax-search
67
if ( defined( 'YITH_WCAS_VERSION' ) ){
68
return;
69
}else{
70
+ define( 'YITH_WCAS_VERSION', '1.6.6' );
71
}
72
73
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
plugin-fw/init.php CHANGED
@@ -1,7 +1,7 @@
1
<?php
2
/**
3
* Framework Name: YIT Plugin Framework
4
- * Version: 3.1.29
5
* Author: YITHEMES
6
* Text Domain: yith-plugin-fw
7
* Domain Path: /languages/
@@ -29,7 +29,7 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
29
* @since 1.0.0
30
*/
31
function yit_maybe_plugin_fw_loader ( $plugin_path ) {
32
- global $plugin_fw_data;
33
34
$default_headers = array (
35
'Name' => 'Framework Name',
@@ -39,8 +39,9 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
39
'DomainPath' => 'Domain Path',
40
);
41
42
- $framework_data = get_file_data ( trailingslashit ( $plugin_path ) . 'plugin-fw/init.php', $default_headers );
43
- $plugin_fw_main_file = trailingslashit ( $plugin_path ) . 'plugin-fw/yit-plugin.php';
44
45
if ( ! empty( $plugin_fw_data ) ) {
46
foreach ( $plugin_fw_data as $version => $path ) {
@@ -51,7 +52,67 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
51
} else {
52
$plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
53
}
54
}
55
}
56
57
1
<?php
2
/**
3
* Framework Name: YIT Plugin Framework
4
+ * Version: 3.2.1
5
* Author: YITHEMES
6
* Text Domain: yith-plugin-fw
7
* Domain Path: /languages/
29
* @since 1.0.0
30
*/
31
function yit_maybe_plugin_fw_loader ( $plugin_path ) {
32
+ global $plugin_fw_data, $plugin_upgrade_fw_data;
33
34
$default_headers = array (
35
'Name' => 'Framework Name',
39
'DomainPath' => 'Domain Path',
40
);
41
42
+ $plugin_path = trailingslashit( $plugin_path );
43
+ $framework_data = get_file_data( $plugin_path . 'plugin-fw/init.php', $default_headers );
44
+ $plugin_fw_main_file = $plugin_path . 'plugin-fw/yit-plugin.php';
45
46
if ( ! empty( $plugin_fw_data ) ) {
47
foreach ( $plugin_fw_data as $version => $path ) {
52
} else {
53
$plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
54
}
55
+
56
+ //Check for license & upgrade classes
57
+ $upgrade_fw_init_file = $plugin_path . 'plugin-upgrade/init.php';
58
+ $framework_data = file_exists( $upgrade_fw_init_file ) ? get_file_data( $upgrade_fw_init_file, $default_headers ) : $framework_data;
59
+ $plugin_license_path = $plugin_upgrade_path = $plugin_path . 'plugin-upgrade';
60
+
61
+ if( ! file_exists( $plugin_upgrade_path ) ){
62
+ //Check the path for OLD plugin FW
63
+ if( file_exists( $plugin_path . 'plugin-fw/licence' ) ){
64
+ $plugin_license_path = $plugin_path . 'plugin-fw/licence';
65
+ $plugin_upgrade_path = $plugin_path . 'plugin-fw/';
66
+ }
67
+
68
+ else {
69
+ $plugin_upgrade_path = $plugin_license_path = false;
70
+ }
71
+ }
72
+
73
+ if( file_exists( $plugin_upgrade_path ) ){
74
+ if( ! empty( $plugin_upgrade_fw_data ) ){
75
+ foreach( $plugin_upgrade_fw_data as $version => $files ){
76
+ if( version_compare ( $version, $framework_data[ 'Version' ], '<' ) ){
77
+ $plugin_upgrade_fw_data = array ( $framework_data[ 'Version' ] => yit_get_upgrade_files( $plugin_license_path, $plugin_upgrade_path ) );
78
+ }
79
+ }
80
+ }
81
+
82
+ else {
83
+ $plugin_upgrade_fw_data = array ( $framework_data[ 'Version' ] => yit_get_upgrade_files( $plugin_license_path, $plugin_upgrade_path ) );
84
+ }
85
+ }
86
}
87
}
88
89
+ if( ! function_exists( 'yit_get_upgrade_files' ) ){
90
+ /**
91
+ * Retreive the core files to include to manage license and upgrade if exists
92
+ *
93
+ * @param $plugin_update_path file path
94
+ *
95
+ * @return array to files to include
96
+ */
97
+ function yit_get_upgrade_files( $plugin_license_path, $plugin_upgrade_path = '' ){
98
+ $to_include = array();
99
+
100
+ if( false ==! $plugin_license_path ){
101
+ $plugin_upgrade_path = empty( $plugin_upgrade_path ) ? $plugin_license_path : $plugin_upgrade_path;
102
+ $license_files = array(
103
+ '%yith-license-path%/lib/yit-licence.php',
104
+ '%yith-license-path%/lib/yit-plugin-licence.php',
105
+ '%yith-license-path%/lib/yit-theme-licence.php',
106
+ );
107
+
108
+ $upgrade_files = array( '%yith-upgrade-path%/lib/yit-plugin-upgrade.php' );
109
+
110
+ $to_include_license = str_replace( '%yith-license-path%', $plugin_license_path, $license_files );
111
+ $to_include_upgrade = str_replace( '%yith-upgrade-path%', $plugin_upgrade_path, $upgrade_files );
112
+
113
+ $to_include = array_merge( $to_include_license, $to_include_upgrade );
114
+ }
115
116
+ return $to_include;
117
+ }
118
+ }
plugin-fw/lib/yit-assets.php CHANGED
@@ -88,7 +88,6 @@ if ( !class_exists( 'YIT_Assets' ) ) {
88
) );
89
90
wp_enqueue_style( 'yith-plugin-fw-admin', YIT_CORE_PLUGIN_URL . '/assets/css/admin.css', array(), $this->version );
91
-
92
}
93
}
94
}
88
) );
89
90
wp_enqueue_style( 'yith-plugin-fw-admin', YIT_CORE_PLUGIN_URL . '/assets/css/admin.css', array(), $this->version );
91
}
92
}
93
}
plugin-fw/lib/yit-plugin-licence.php ADDED
@@ -0,0 +1,116 @@
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Plugin_Licence' ) ) {
16
+ /**
17
+ * YIT Licence Panel
18
+ *
19
+ * Setting Page to Manage Products
20
+ *
21
+ * @class YIT_Licence
22
+ * @package YITH
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ */
26
+ class YIT_Plugin_Licence {
27
+ /**
28
+ * @var object The single instance of the class
29
+ * @since 1.0
30
+ */
31
+ protected static $_instance = null;
32
+
33
+ /**
34
+ * Constructor
35
+ *
36
+ * @since 1.0
37
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
38
+ */
39
+ public function __construct() {
40
+ //Silence is golden
41
+ }
42
+
43
+ /**
44
+ * Premium products registration
45
+ *
46
+ * @param $init string | The products identifier
47
+ * @param $secret_key string | The secret key
48
+ * @param $product_id string | The product id
49
+ *
50
+ * @return void
51
+ *
52
+ * @since 1.0
53
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
54
+ */
55
+ public function register( $init, $secret_key, $product_id ){
56
+ if( ! function_exists( 'YITH_Plugin_Licence' ) ){
57
+ //Try to load YITH_Plugin_Licence class
58
+ yith_plugin_fw_load_update_and_licence_files();
59
+ }
60
+
61
+ YITH_Plugin_Licence()->register( $init, $secret_key, $product_id );
62
+ }
63
+
64
+ /**
65
+ * Main plugin Instance
66
+ *
67
+ * @static
68
+ * @return object Main instance
69
+ *
70
+ * @since 1.0
71
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
72
+ */
73
+ public static function instance() {
74
+ if ( is_null( self::$_instance ) ) {
75
+ self::$_instance = new self();
76
+ }
77
+
78
+ return self::$_instance;
79
+ }
80
+
81
+ /**
82
+ * Get license activation URL
83
+ *
84
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
85
+ * @since 3.0.17
86
+ */
87
+ public static function get_license_activation_url(){
88
+ return function_exists( 'YITH_Plugin_Licence' ) ? YITH_Plugin_Licence()->get_license_activation_url() : false;
89
+ }
90
+
91
+ /**
92
+ * Get protected array products
93
+ *
94
+ * @return mixed array
95
+ *
96
+ * @since 1.0
97
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
98
+ */
99
+ public function get_products() {
100
+ return function_exists( 'YITH_Plugin_Licence' ) ? YITH_Plugin_Licence()->get_products() : array();
101
+ }
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Main instance
107
+ *
108
+ * @return object
109
+ * @since 1.0
110
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
111
+ */
112
+ if ( !function_exists( 'YIT_Plugin_Licence' ) ) {
113
+ function YIT_Plugin_Licence() {
114
+ return YIT_Plugin_Licence::instance();
115
+ }
116
+ }
plugin-fw/lib/yit-theme-licence.php ADDED
@@ -0,0 +1,94 @@
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Theme_Licence' ) ) {
16
+ /**
17
+ * YIT Licence Panel
18
+ *
19
+ * Setting Page to Manage Products
20
+ *
21
+ * @class YIT_Licence
22
+ * @package YITH
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ */
26
+ class YIT_Theme_Licence {
27
+ /**
28
+ * @var object The single instance of the class
29
+ * @since 1.0
30
+ */
31
+ protected static $_instance = null;
32
+
33
+ /**
34
+ * Constructor
35
+ *
36
+ * @since 1.0
37
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
38
+ */
39
+ public function __construct() {
40
+ //Silence is golden
41
+ }
42
+
43
+ /**
44
+ * Premium products registration
45
+ *
46
+ * @param $init string | The products identifier
47
+ * @param $secret_key string | The secret key
48
+ * @param $product_id string | The product id
49
+ *
50
+ * @return void
51
+ *
52
+ * @since 1.0
53
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
54
+ */
55
+ public function register( $init, $secret_key, $product_id ){
56
+ if( ! function_exists( 'YITH_Theme_Licence' ) ){
57
+ //Try to load YITH_Theme_Licence class
58
+ yith_plugin_fw_load_update_and_licence_files();
59
+ }
60
+
61
+ YITH_Theme_Licence()->register( $init, $secret_key, $product_id );
62
+ }
63
+
64
+ /**
65
+ * Main plugin Instance
66
+ *
67
+ * @static
68
+ * @return object Main instance
69
+ *
70
+ * @since 1.0
71
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
72
+ */
73
+ public static function instance() {
74
+ if ( is_null( self::$_instance ) ) {
75
+ self::$_instance = new self();
76
+ }
77
+
78
+ return self::$_instance;
79
+ }
80
+ }
81
+ }
82
+
83
+ /**
84
+ * Main instance
85
+ *
86
+ * @return object
87
+ * @since 1.0
88
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
89
+ */
90
+ if ( !function_exists( 'YIT_Theme_Licence' ) ) {
91
+ function YIT_Theme_Licence() {
92
+ return YIT_Theme_Licence::instance();
93
+ }
94
+ }
plugin-fw/lib/yit-upgrade.php CHANGED
@@ -24,22 +24,6 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
24
* @see WP_Updater Class
25
*/
26
class YIT_Upgrade {
27
-
28
- /**
29
- * @var string XML notifier update
30
- */
31
- protected $_remote_url = 'https://update.yithemes.com/plugin-xml.php';
32
-
33
- /**
34
- * @var string api server url
35
- */
36
- protected $_package_url = 'https://yithemes.com';
37
-
38
- /**
39
- * @var array The registered plugins
40
- */
41
- protected $_plugins = array();
42
-
43
/**
44
* @var YIT_Upgrade The main instance
45
*/
@@ -52,56 +36,7 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
52
* @since 1.0
53
*/
54
public function __construct() {
55
- add_filter( 'upgrader_pre_download', array( $this, 'upgrader_pre_download' ), 10, 3 );
56
- add_action( 'update-custom_upgrade-plugin-multisite', array( $this, 'upgrade_plugin_multisite' ) );
57
-
58
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
59
-
60
- $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
61
- if ( $is_debug_enabled ) {
62
- $this->_package_url = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
63
- add_filter( 'block_local_requests', '__return_false' );
64
- }
65
-
66
- add_action( 'install_plugins_pre_plugin-information', array(
67
- $this,
68
- 'show_changelog_for_premium_plugins'
69
- ) );
70
- add_action( 'wp_ajax_yith_plugin_fw_get_premium_changelog', array(
71
- $this,
72
- 'show_changelog_for_premium_plugins'
73
- ) );
74
- }
75
-
76
- /**
77
- * show changelog for premium plugins
78
- *
79
- * @since 3.0.14
80
- */
81
- public function show_changelog_for_premium_plugins() {
82
- if ( isset( $_GET['plugin'] ) && isset( $_GET['section'] ) && 'changelog' === $_GET['section'] ) {
83
- $plugin_init = $_GET['plugin'];
84
- if ( isset( $this->_plugins[ $plugin_init ] ) ) {
85
- // this is YITH Premium Plugin
86
- if ( ! empty( $this->_plugins[ $plugin_init ]['info']['changelog'] ) ) {
87
- $plugin_name = $this->_plugins[ $plugin_init ]['info']['Name'];
88
- $changelog = $this->_plugins[ $plugin_init ]['info']['changelog'];
89
- $template = YIT_CORE_PLUGIN_TEMPLATE_PATH . '/upgrade/changelog.php';
90
- if ( file_exists( $template ) ) {
91
- include( $template );
92
- }
93
- die();
94
- }
95
- $error = __( 'An unexpected error occurred, please try again later. Thanks!', 'yith-plugin-fw' );
96
- $template = YIT_CORE_PLUGIN_TEMPLATE_PATH . '/upgrade/error.php';
97
- if ( file_exists( $template ) ) {
98
- include( $template );
99
- } else {
100
- echo "<p>$error</p>";
101
- }
102
- die();
103
- }
104
- }
105
}
106
107
/**
@@ -116,305 +51,12 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
116
* @author Andrea Grillo <andrea.grillo@yithemes.com>
117
*/
118
public function register( $plugin_slug, $plugin_init ) {
119
-
120
- if ( ! function_exists( 'get_plugins' ) ) {
121
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
122
- }
123
-
124
- $plugins = get_plugins();
125
- $plugin_info = $plugins[ $plugin_init ];
126
-
127
- $plugin = $this->_plugins[ $plugin_init ] = array(
128
- 'info' => $plugin_info,
129
- 'slug' => $plugin_slug,
130
- );
131
-
132
- $transient = 'yith_register_' . md5( $plugin_slug );
133
- if ( apply_filters( 'yith_register_delete_transient', false ) ) {
134
- delete_transient( $transient );
135
- }
136
- $info = get_transient( $transient );
137
- if ( false === $info || apply_filters( 'yith_register_delete_transient', false ) ) {
138
- $xml = $this->get_remote_url( $plugin );
139
- $remote_xml = wp_remote_get( $xml );
140
-
141
- $error = false;
142
- if ( ! is_wp_error( $remote_xml ) && isset( $remote_xml['response']['code'] ) && '200' == $remote_xml['response']['code'] ) {
143
- $plugin_remote_info = function_exists( 'simplexml_load_string' ) ? @simplexml_load_string( $remote_xml['body'] ) : false;
144
- if ( $plugin_remote_info ) {
145
- $info['Latest'] = (string) $plugin_remote_info->latest;
146
- $info['changelog'] = (string) $plugin_remote_info->changelog;
147
- if ( is_multisite() && current_user_can( 'update_plugins' ) ) {
148
- YIT_Plugin_Licence()->check( $plugin_slug, false );
149
- }
150
- set_transient( $transient, $info, DAY_IN_SECONDS );
151
- } else {
152
- $error = true;
153
- error_log( sprintf( 'SimpleXML error in %s:%s [plugin slug: %s]',
154
- __FILE__, __FUNCTION__, $plugin_slug ) );
155
- }
156
- } else {
157
- $error = true;
158
- }
159
-
160
- if ( $error ) {
161
- // If error, set empty value in the transient to prevent multiple requests
162
- $info = array( 'Latest' => '', 'changelog' => '' );
163
- set_transient( $transient, $info, HOUR_IN_SECONDS );
164
- }
165
- }
166
-
167
- $this->_plugins[ $plugin_init ]['info']['Latest'] = $info['Latest'];
168
- $this->_plugins[ $plugin_init ]['info']['changelog'] = $info['changelog'];
169
-
170
- /* === HOOKS === */
171
- if ( ! is_multisite() || is_plugin_active_for_network( $plugin_init ) ) {
172
- add_action( 'load-plugins.php', array( $this, 'remove_wp_plugin_update_row' ), 25 );
173
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
174
- } else if ( is_multisite() && current_user_can( 'update_plugins' ) ) {
175
- add_action( 'admin_enqueue_scripts', array( $this, 'multisite_updater_script' ) );
176
- }
177
- }
178
-
179
- /**
180
- * Add the multisite updater scripts
181
- *
182
- * @return void
183
- *
184
- * @since 1.0
185
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
186
- * @return bool
187
- */
188
- public function multisite_updater_script() {
189
- /* === If class YIT_Plugin_Licence doesn't exists, no YITH plugins enabled === */
190
- if( ! function_exists( 'YIT_Plugin_Licence' ) ){
191
- return false;
192
- }
193
-
194
- $update_url = $changelogs = $details_url = array();
195
- $strings = array(
196
- 'new_version' => __( 'There is a new version of %plugin_name% available.', 'yith-plugin-fw' ),
197
- 'latest' => __( 'View version %latest% details.', 'yith-plugin-fw' ),
198
- 'unavailable' => __( 'Automatic update is unavailable for this plugin,', 'yith-plugin-fw' ),
199
- 'activate' => __( 'please <a href="%activate_link%">activate</a> your copy of %plugin_name%.', 'yith-plugin-fw' ),
200
- 'update_now' => __( 'Update now.', 'yith-plugin-fw' ),
201
- 'version_issue' => __( '<br/><b>Please note:</b> You are using a higher version than the latest available one. </em>Please, make sure you\'ve downloaded the latest version of <em>%plugin_name%</em> from the only <a href="https://yithemes.com" target="_blank">YITH official website</a>, specifically, from your <a href="https://yithemes.com/my-account/recent-downloads/" target="_blank">Downloads page</a>. This is the only way to be sure the version you are using is 100% malware-free.', 'yith-plugin-fw' ),
202
- );
203
-
204
- foreach ( $this->_plugins as $init => $info ) {
205
- $update_url[ $init ] = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin-multisite&plugin=' ) . $init, 'upgrade-plugin-multisite_' . $init );
206
- $details_url[ $init ] = admin_url( 'admin-ajax.php?action=yith_plugin_fw_get_premium_changelog&tab=plugin-information&plugin=' . $init . '&section=changelog&TB_iframe=true&width=640&height=662' );
207
- }
208
-
209
- $localize_script_args = array(
210
- 'registered' => $this->_plugins,
211
- 'activated' => YIT_Plugin_Licence()->get_activated_products(),
212
- 'licence_activation_url' => YIT_Plugin_Licence()->get_licence_activation_page_url(),
213
- 'update_url' => $update_url,
214
- 'details_url' => $details_url,
215
- 'strings' => $strings,
216
- );
217
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
218
-
219
- if( defined( 'YIT_CORE_PLUGIN_URL' ) ){
220
- yit_enqueue_script( 'yit-multisite-updater', YIT_CORE_PLUGIN_URL . '/assets/js/multisite-updater' . $suffix . '.js', array( 'jquery' ), false, true );
221
- }
222
-
223
- wp_localize_script( 'yit-multisite-updater', 'plugins', $localize_script_args );
224
- }
225
-
226
- public function admin_enqueue_scripts() {
227
- global $pagenow;
228
- if ( 'plugins.php' === $pagenow && defined( 'YIT_CORE_PLUGIN_URL' ) ) {
229
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
230
- wp_enqueue_style( 'yit-upgrader', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrader.css' );
231
- wp_enqueue_script( 'yith-update-plugins', YIT_CORE_PLUGIN_URL . '/assets/js/yith-update-plugins' . $suffix . '.js', array( 'jquery' ), false, true );
232
-
233
- $update_plugins_localized = array(
234
- 'ajax_nonce' => wp_create_nonce( 'updates' ),
235
- 'ajaxurl' => admin_url( 'admin-ajax.php', 'relative' ),
236
- 'l10n' => array(
237
- /* translators: %s: Plugin name and version */
238
- 'updating' => _x( 'Updating %s...', 'plugin-fw', 'yith-plugin-fw' ), // No ellipsis.
239
- /* translators: %s: Plugin name and version */
240
- 'updated' => _x( '%s updated!', 'plugin-fw', 'yith-plugin-fw' ),
241
- /* translators: %s: Plugin name and version */
242
- 'failed' => _x( '%s update failed', 'plugin-fw', 'yith-plugin-fw' ),
243
- ),
244
- );
245
-
246
- wp_localize_script( 'yith-update-plugins', 'yith_plugin_fw', $update_plugins_localized );
247
- }
248
- }
249
-
250
- /**
251
- * Retrive the zip package file
252
- *
253
- * @param bool $reply Whether to bail without returning the package. Default false.
254
- * @param string $package The package file name.
255
- * @param \WP_Upgrader $upgrader WP_Upgrader instance.
256
- *
257
- * @return string | The download file
258
- *
259
- * @since 1.0
260
- * @see wp-admin/includes/class-wp-upgrader.php
261
- * @access public
262
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
263
- */
264
- public function upgrader_pre_download( $reply, $package, $upgrader ) {
265
- /* === If class YIT_Plugin_Licence doesn't exists, no YITH plugins enabled === */
266
- if( ! function_exists( 'YIT_Plugin_Licence' ) ){
267
- return $reply;
268
- }
269
-
270
- $plugin = false;
271
- $is_bulk = $upgrader->skin instanceof Bulk_Plugin_Upgrader_Skin;
272
- $is_bulk_ajax = $upgrader->skin instanceof WP_Ajax_Upgrader_Skin;
273
-
274
- if ( ! $is_bulk && ! $is_bulk_ajax ) {
275
- //Bulk Action: Support for old WordPress Version
276
- $plugin = isset( $upgrader->skin->plugin ) ? $upgrader->skin->plugin : false;
277
- }
278
-
279
- elseif( $is_bulk_ajax ){
280
- //Bulk Update for WordPress 4.9 or greater
281
- if( ! empty( $_POST['plugin'] ) ){
282
- $plugin = plugin_basename( sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) );
283
- }
284
- }
285
-
286
- else {
287
- //Bulk action upgrade
288
- $action_url = parse_url( $upgrader->skin->options['url'] );
289
- parse_str( rawurldecode( htmlspecialchars_decode( $action_url['query'] ) ), $output );
290
- $plugins = isset( $output['plugins'] ) ? $output['plugins'] : '';
291
- $plugins = explode( ',', $plugins );
292
- foreach ( $plugins as $plugin_init ) {
293
- $to_upgrade = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_init );
294
- if ( $to_upgrade['Name'] == $upgrader->skin->plugin_info['Name'] ) {
295
- $plugin = $plugin_init;
296
- }
297
- }
298
- }
299
-
300
- /**
301
- * It isn't YITH Premium plugins, please wordpress update it for me!
302
- */
303
- if ( ! $plugin ) {
304
- return $reply;
305
- }
306
-
307
- $plugin_info = YIT_Plugin_Licence()->get_product( $plugin );
308
-
309
- /**
310
- * False ? It isn't YITH Premium plugins, please wordpress update it for me!
311
- */
312
- if ( false === $plugin_info ) {
313
- return $reply;
314
- }
315
-
316
- $licence = YIT_Plugin_Licence()->get_licence();
317
- $product_id = $plugin_info['product_id'];
318
-
319
- if( empty( $licence[ $product_id ] ) ){
320
- return new WP_Error( 'license_not_valid', _x( 'You have to activate the plugin to benefit from automatic updates.', '[Update Plugin Message: License not enabled]', 'yith-plugin-fw' ) );
321
- }
322
-
323
- $args = array(
324
- 'email' => $licence[ $product_id ]['email'],
325
- 'licence_key' => $licence[ $product_id ]['licence_key'],
326
- 'product_id' => $plugin_info['product_id'],
327
- 'secret_key' => $plugin_info['secret_key'],
328
- 'instance' => YIT_Plugin_Licence()->get_home_url(),
329
- 'wc-api' => 'download-api',
330
- 'request' => 'download'
331
- );
332
-
333
- if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) {
334
- //Local file or remote?
335
- return $package;
336
- }
337
-
338
- if ( empty( $package ) ) {
339
- return new WP_Error( 'no_package', $upgrader->strings['no_package'] );
340
- }
341
-
342
- $upgrader->skin->feedback( 'downloading_package', __( 'YITH Repository', 'yith-plugin-fw' ) );
343
-
344
- $download_file = $this->_download_url( $package, $args );
345
-
346
- /**
347
- * Regenerate update_plugins transient
348
- */
349
- yith_plugin_fw_force_regenerate_plugin_update_transient();
350
-
351
- if ( is_wp_error( $download_file ) ) {
352
- return new WP_Error( 'download_failed', $upgrader->strings['download_failed'], $download_file->get_error_message() );
353
}
354
355
- return $download_file;
356
- }
357
-
358
- /**
359
- * Retrieve the temp filename
360
- *
361
- * @param string $url The package url
362
- * @param string $body The post data fields
363
- * @param int $timeout Execution timeout (default: 300)
364
- *
365
- * @return string | The temp filename
366
- *
367
- * @since 1.0
368
- * @see wp-admin/includes/class-wp-upgrader.php
369
- * @access protected
370
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
371
- */
372
- protected function _download_url( $url, $body, $timeout = 300 ) {
373
-
374
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
375
- if ( ! $url ) {
376
- return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.', 'yith-plugin-fw' ) );
377
- }
378
-
379
- $tmpfname = wp_tempnam( $url );
380
-
381
- $args = array(
382
- 'timeout' => $timeout,
383
- 'stream' => true,
384
- 'filename' => $tmpfname,
385
- 'body' => $body
386
- );
387
-
388
- if ( ! $tmpfname ) {
389
- return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.', 'yith-plugin-fw' ) );
390
- }
391
-
392
- $response = wp_safe_remote_post( $url, $args );
393
-
394
- if ( is_wp_error( $response ) ) {
395
- unlink( $tmpfname );
396
-
397
- return $response;
398
- }
399
-
400
- if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
401
- unlink( $tmpfname );
402
-
403
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
404
- }
405
-
406
- $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
407
-
408
- if ( $content_md5 ) {
409
- $md5_check = verify_file_md5( $tmpfname, $content_md5 );
410
- if ( is_wp_error( $md5_check ) ) {
411
- unlink( $tmpfname );
412
-
413
- return $md5_check;
414
- }
415
- }
416
-
417
- return $tmpfname;
418
}
419
420
/**
@@ -433,292 +75,6 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
433
434
return self::$_instance;
435
}
436
-
437
- /**
438
- * Delete the update plugins transient
439
- *
440
- * @return void
441
- *
442
- * @since 1.0
443
- * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
444
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
445
- * @deprecated From version 3.1.12
446
- */
447
- public function force_regenerate_update_transient() {
448
- delete_site_transient( 'update_plugins' );
449
- }
450
-
451
- /**
452
- * Check for plugins update
453
- *
454
- * If a new plugin version is available set it in the pre_set_site_transient_update_plugins hooks
455
- *
456
- * @param mixed $transient | update_plugins transient value
457
- * @param bool $save | Default: false. Set true to regenerate the update_transient plugins
458
- *
459
- * @return mixed $transient | The new update_plugins transient value
460
- *
461
- * @since 1.0
462
- * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
463
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
464
- */
465
- public function check_update( $transient, $save = false ) {
466
-
467
- foreach ( $this->_plugins as $init => $plugin ) {
468
- $plugin_slug = $this->_plugins[ $init ]['slug'];
469
- $xml = $this->get_remote_url( $plugin );
470
- $remote_xml = wp_remote_get( $xml );
471
-
472
- if ( ! is_wp_error( $remote_xml ) && isset( $remote_xml['response']['code'] ) && '200' == $remote_xml['response']['code'] ) {
473
-
474
- $plugin_remote_info = function_exists( 'simplexml_load_string' ) ? @simplexml_load_string( $remote_xml['body'] ) : false;
475
-
476
- if ( $plugin_remote_info ) {
477
- $wrong_current_version_check = version_compare( $plugin['info']['Version'], $plugin_remote_info->latest, '>' );
478
- $update_available = version_compare( $plugin_remote_info->latest, $plugin['info']['Version'], '>' );
479
-
480
- if ( ( $update_available || $wrong_current_version_check ) && ! isset( $transient->response[ $init ] ) ) {
481
-
482
- $package = YIT_Plugin_Licence()->check( $init ) ? $this->_package_url : null;
483
-
484
- $tested_up_to = (string) str_replace( '.x', '', $plugin_remote_info->{"up-to"} );
485
- $tested_up_to = preg_replace( '/-.*#x2F;', '', $tested_up_to );
486
- $wp_version = preg_replace( '/-.*#x2F;', '', get_bloginfo( 'version' ) );
487
-
488
- if( strpos( $wp_version, $tested_up_to ) !== false ){
489
- $tested_up_to = $wp_version;
490
- }
491
- $obj = new stdClass();
492
- $obj->slug = (string) $init;
493
- $obj->new_version = (string) $plugin_remote_info->latest;
494
- $obj->changelog = (string) $plugin_remote_info->changelog;
495
- $obj->package = $package;
496
- $obj->plugin = $init;
497
- $obj->tested = $tested_up_to;
498
-
499
- if( ! empty( $plugin_remote_info->icons ) ){
500
- $obj->icons = (array) $plugin_remote_info->icons;
501
- }
502
-
503
- $transient->response[ $init ] = $obj;
504
- }
505
-
506
- } else {
507
- error_log( sprintf( 'SimpleXML error in %s:%s [plugin slug: %s]',
508
- __FILE__, __FUNCTION__, $plugin_slug ) );
509
-
510
- return $transient;
511
- }
512
- }
513
- }
514
-
515
- if ( $save ) {
516
- set_site_transient( 'update_plugins', $transient );
517
- }
518
-
519
- return $transient;
520
- }
521
-
522
- /**
523
- * Add the plugin update row in plugin page
524
- *
525
- * @return void
526
- * @fire "in_theme_update_message-{$init}" action
527
- *
528
- * @since 1.0
529
- * @see after_plugin_row_{$init} action
530
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
531
- */
532
- public function plugin_update_row() {
533
-
534
- $current = get_site_transient( 'update_plugins' );
535
- $init = str_replace( 'after_plugin_row_', '', current_filter() );
536
- $update_now_class = apply_filters( 'yith_plugin_fw_update_now_class', '' );
537
- $update_now_class = trim( $update_now_class . ' yith-update-link update-link' );
538
-
539
- if ( ! isset( $current->response[ $init ] ) ) {
540
- return false;
541
- }
542
-
543
- /**
544
- * stdClass Object
545
- */
546
- $r = $current->response[ $init ];
547
-
548
- $changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
549
- $details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $init . '&section=changelog&TB_iframe=true&width=640&height=662' );
550
-
551
- /**
552
- * @see wp_plugin_update_rows() in wp-single\wp-admin\includes\update.php
553
- */
554
- $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
555
-
556
- global $wp_version;
557
- $is_wp_4_6 = version_compare( $wp_version, '4.6', '>=' );
558
-
559
- echo '<tr class="plugin-update-tr' . ( is_plugin_active( $init ) ? ' active' : '' ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">';
560
-
561
- echo '<div class="update-message' . ( $is_wp_4_6 ? ' notice inline notice-warning notice-alt' : '' ) . '">';
562
-
563
- echo( $is_wp_4_6 ? '<p>' : '' );
564
-
565
- if ( ! current_user_can( 'update_plugins' ) ) {
566
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button open-plugin-details-modal" title="%3$s">View version %4$s details</a>.', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
567
- }
568
-
569
- elseif ( is_plugin_active_for_network( $init ) ) {
570
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button open-plugin-details-modal" title="%3$s">View version %4$s details</a>. <em>You have to activate the plugin on a single site of the network to benefit from automatic updates.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
571
- }
572
-
573
- elseif ( empty( $r->package ) ) {
574
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button open-plugin-details-modal" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin, please <a href="%5$s" title="License activation">activate</a> your copy of %6s.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, YIT_Plugin_Licence()->get_licence_activation_page_url(), $this->_plugins[ $init ]['info']['Name'] );
575
- }
576
-
577
- else {
578
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button open-plugin-details-modal" title="%3$s">View version %4$s details</a> or <a href="%5$s" class="%6$s" data-plugin="%7$s" data-slug="%8$s" data-name="%1$s">update now</a>.', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $init, 'upgrade-plugin_' . $init ), $update_now_class, $init, $this->_plugins[ $init ]['slug'] );
579
- }
580
-
581
- if( version_compare( $this->_plugins[ $init ]['info']['Version'] , $r->new_version, '>' ) ){
582
- printf( __( '<br/><b>Please note:</b> You are using a higher version than the latest available one. </em>Please, make sure you\'ve downloaded the latest version of <em>%1$s</em> from the only <a href="https://yithemes.com" target="_blank">YITH official website</a>, specifically, from your <a href="https://yithemes.com/my-account/recent-downloads/" target="_blank">Downloads page</a>. This is the only way to be sure the version you are using is 100%% malware-free.', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, YIT_Plugin_Licence()->get_licence_activation_page_url(), $this->_plugins[ $init ]['info']['Name'] );
583
- }
584
-
585
-
586
- echo( $is_wp_4_6 ? '</p>' : '' );
587
-
588
- /**
589
- * Fires at the end of the update message container in each
590
- * row of the themes list table.
591
- *
592
- * The dynamic portion of the hook name, `$theme_key`, refers to
593
- * the theme slug as found in the WordPress.org themes repository.
594
- *
595
- * @since Wordpress 3.1.0
596
- * }
597
- */
598
- do_action( "in_theme_update_message-{$init}", $this->_plugins[ $init ], $r->changelog, $changelog_id );
599
-
600
- echo '</div></td></tr>';
601
- }
602
-
603
- /**
604
- * Remove the standard plugin_update_row
605
- *
606
- * Remove the standard plugin_update_row and Add a custom plugin update row in plugin page.
607
- *
608
- * @return void
609
- * @fire "in_theme_update_message-{$init}" action
610
- *
611
- * @since 1.0
612
- * @see after_plugin_row_{$init} action
613
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
614
- */
615
- public function remove_wp_plugin_update_row() {
616
- foreach ( $this->_plugins as $init => $plugin ) {
617
- remove_action( "after_plugin_row_{$init}", 'wp_plugin_update_row', 10 );
618
- add_action( "after_plugin_row_{$init}", array( $this, 'plugin_update_row' ) );
619
- }
620
- }
621
-
622
- public function in_theme_update_message( $plugin, $changelog, $changelog_id, $echo = true ) {
623
- $res = "<div id='{$changelog_id}' class='yit-plugin-changelog-wrapper'>
624
- <div class='yit-plugin-changelog'>
625
- <h2 class='yit-plugin-changelog-title'>{$plugin['info']['Name']} - Changelog</h2>
626
- <p>{$changelog}</p>
627
- </div>
628
- </div>";
629
-
630
- if ( $echo ) {
631
- echo $res;
632
- } else {
633
- return $res;
634
- }
635
- }
636
-
637
- /**
638
- * Auto-Update Plugin in multisite
639
- *
640
- * Manage the non standard upgrade-plugin-multisite action
641
- *
642
- * @return void
643
- *
644
- * @since 1.0
645
- * @see upgrade-plugin action
646
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
647
- */
648
- public function upgrade_plugin_multisite() {
649
-
650
- $plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
651
- $action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
652
-
653
- if ( 'upgrade-plugin-multisite' != $action ) {
654
- wp_die( __( 'You can\'t update the plugins for this site.', 'yith-plugin-fw' ) );
655
- }
656
-
657
- if ( ! current_user_can( 'update_plugins' ) ) {
658
- wp_die( __( 'You do not have sufficient permissions to update the plugins for this site.', 'yith-plugin-fw' ) );
659
- }
660
-
661
- $this->check_update( get_site_transient( 'update_plugins' ), true );
662
-
663
- check_admin_referer( 'upgrade-plugin-multisite_' . $plugin );
664
-
665
- $title = __( 'Update Plugin', 'yith-plugin-fw' );
666
- $parent_file = 'plugins.php';
667
- $submenu_file = 'plugins.php';
668
-
669
- wp_enqueue_script( 'updates' );
670
- require_once( ABSPATH . 'wp-admin/admin-header.php' );
671
-
672
- $nonce = 'upgrade-plugin-multisite_' . $plugin;
673
- $url = 'update.php?action=upgrade-plugin-multisite&plugin=' . urlencode( $plugin );
674
-
675
- $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
676
- $upgrader->upgrade( $plugin );
677
-
678
- include( ABSPATH . 'wp-admin/admin-footer.php' );
679
- }
680
-
681
- /**
682
- * Retreive the remote url with query string args
683
- *
684
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
685
- * @return string the remote url
686
- */
687
- public function get_remote_url( $plugin_info ) {
688
-
689
- $license = $is_membership_license = false;
690
- $slug = isset( $plugin_info['slug'] ) ? $plugin_info['slug'] : false;
691
-
692
- if( function_exists( 'YIT_Plugin_Licence' ) && false !== $slug ){
693
- //Get license for YITH Plugins
694
- $enabled_license = YIT_Plugin_Licence()->get_licence();
695
-
696
- if( isset( $enabled_license[ $slug ]['activated'] ) && false !== $enabled_license[ $slug ]['activated'] ){
697
- if( isset( $enabled_license[ $slug ]['licence_key'] ) ){
698
- $license = $enabled_license[ $slug ]['licence_key'];
699
- }
700
-
701
- if( isset( $enabled_license[ $slug ]['is_membership'] ) ){
702
- $is_membership_license = $enabled_license[ $slug ]['is_membership'];
703
- }
704
- }
705
- }
706
-
707
- $args = array(
708
- 'plugin' => $slug,
709
- 'instance' => md5( $_SERVER['SERVER_NAME'] ),
710
- 'license' => $license,
711
- 'is_membership_license' => $is_membership_license,
712
- 'server_ip' => $_SERVER['SERVER_ADDR'],
713
- 'version' => isset( $plugin_info['info']['Version'] ) ? $plugin_info['info']['Version'] : '1.0.0'
714
- );
715
-
716
- $args = apply_filters( 'yith_get_remove_url_args', $args );
717
-
718
- $url = add_query_arg( $args, $this->_remote_url );
719
-
720
- return $url;
721
- }
722
}
723
}
724
24
* @see WP_Updater Class
25
*/
26
class YIT_Upgrade {
27
/**
28
* @var YIT_Upgrade The main instance
29
*/
36
* @since 1.0
37
*/
38
public function __construct() {
39
+ //Silence is golden...
40
}
41
42
/**
51
* @author Andrea Grillo <andrea.grillo@yithemes.com>
52
*/
53
public function register( $plugin_slug, $plugin_init ) {
54
+ if( ! function_exists( 'YITH_Plugin_Upgrade' ) ){
55
+ //Try to load YITH_Plugin_Upgrade class
56
+ yith_plugin_fw_load_update_and_licence_files();
57
}
58
59
+ YITH_Plugin_Upgrade()->register( $plugin_slug, $plugin_init );
60
}
61
62
/**
75
76
return self::$_instance;
77
}
78
}
79
}
80
plugin-fw/licence/assets/css/yit-licence.css DELETED
@@ -1,461 +0,0 @@
1
- /* === Plugins Upgrader === */
2
-
3
- .yit-plugin-changelog-wrapper {
4
- display: none;
5
- }
6
-
7
- .yit-plugin-changelog-title {
8
- text-transform: uppercase;
9
- }
10
-
11
- .yit-plugin-changelog {
12
- height : calc(100% - 15px);
13
- width : calc(100% - 15px);
14
- overflow-x : hidden;
15
- overflow-y : auto;
16
- z-index : 999;
17
- background: #fcfcfc;
18
- }
19
-
20
- /* === Plugins Licence Activation === */
21
-
22
- .yit-container.product-licence-activation {
23
- font-family: 'Raleway', sans-serif;
24
- }
25
-
26
- .yit-container.product-licence-activation .to-active-wrapper {
27
- margin-bottom: 60px;
28
- max-width: 900px;
29
- }
30
-
31
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form {
32
- position: relative;
33
- border-color: #e1e1e1;
34
- border-style: solid;
35
- border-width: 0;
36
- }
37
-
38
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:first-child {
39
- border-top-width: 1px;
40
- }
41
-
42
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:last-child {
43
- border-bottom-width: 1px;
44
- }
45
-
46
- .yit-container.product-licence-activation .to-active-wrapper table.to-active-table {
47
- border-width: 0;
48
- border-spacing: 0;
49
- width: 100%;
50
- }
51
-
52
- .yit-container.product-licence-activation .message {
53
- display: none;
54
- line-height: normal;
55
- background: #ffffff url(../images/licence-error.png) 15px center no-repeat;
56
- padding-left: 65px;
57
- padding-right: 15px;
58
- width: 150px;
59
- }
60
-
61
- .yit-container.product-licence-activation .message-wrapper {
62
- height: 75px;
63
- display: none;
64
- position: absolute;
65
- top: 0;
66
- right: -250px;
67
- border: 1px solid #ff3838;
68
- }
69
-
70
- .yit-container.product-licence-activation .message-wrapper.visible {
71
- display: table;
72
- }
73
-
74
- .yit-container.product-licence-activation .message {
75
- display: table-cell;
76
- vertical-align: middle;
77
- }
78
-
79
- .yit-container.product-licence-activation .arrow-left:after,
80
- .yit-container.product-licence-activation .arrow-left:before {
81
- content: "";
82
- display: block;
83
- width: 0;
84
- height: 0;
85
- position: absolute;
86
- }
87
-
88
- .yit-container.product-licence-activation .arrow-left:before {
89
- border-top: 9px solid transparent;
90
- border-bottom: 9px solid transparent;
91
- border-right: 9px solid #ff3838;
92
- top: 26px;
93
- left: -9px;
94
- }
95
-
96
- .yit-container.product-licence-activation .arrow-left:after {
97
- border-top: 8px solid transparent;
98
- border-bottom: 8px solid transparent;
99
- border-right: 8px solid #fff;
100
- left: -8px;
101
- top: 27px;
102
- }
103
-
104
- .yit-container.product-licence-activation h2,
105
- .yit-container.product-licence-activation h3 {
106
- text-transform: uppercase;
107
- font-weight: 800;
108
- margin-bottom: 30px;
109
- }
110
-
111
- .yit-container.product-licence-activation h2 {
112
- color: #808a97;
113
- font-size: 25px;
114
- }
115
- .yit-container.product-licence-activation h3 {
116
- color: #313131;
117
- font-size: 15px;
118
- height: 20px;
119
- }
120
-
121
- .yit-container.product-licence-activation h3.to-active {
122
- height: 20px;
123
- position: relative;
124
- vertical-align: top;
125
- }
126
-
127
- .yit-container.product-licence-activation .spinner{
128
- vertical-align: -5px;
129
- float: none;
130
- }
131
-
132
- .yit-container.product-licence-activation .spinner.show{
133
- visibility: visible;
134
- }
135
-
136
- .yit-container.product-licence-activation .licence-check-section{
137
- margin-bottom: 20px;
138
- margin-top: 20px;
139
- background-color: #ffffff;
140
- padding: 10px;
141
- max-width: 670px;
142
- }
143
-
144
- .yit-container.product-licence-activation span.licence-label {
145
- font-weight: 500;
146
- color: #606060;
147
- margin-bottom: 20px;
148
- }
149
-
150
- .yit-container.product-licence-activation .button-licence {
151
- border: 0;
152
- font-size: 13px;
153
- text-transform: uppercase;
154
- background-color: #808a97;
155
- color: #fff;
156
- font-weight: 700;
157
- border-radius: 3px;
158
- cursor: pointer;
159
- text-decoration: none;
160
- padding: 5px 7px;
161
- -webkit-transition: background-color 0.3s ease;
162
- -moz-transition: background-color 0.3s ease;
163
- -ms-transition: background-color 0.3s ease;
164
- -o-transition: background-color 0.3s ease;
165
- transition: background-color 0.3s ease;
166
- }
167
-
168
- .yit-container.product-licence-activation .button-licence:hover {
169
- background-color: #4d5c6f;
170
- }
171
-
172
- .yit-container.product-licence-activation .button-licence.clicked {
173
- cursor: not-allowed;
174
- background-color: #e2e2e2 !important;
175
- }
176
-
177
- .yit-container.product-licence-activation .button-licence.licence-check {
178
- font-weight: 400;
179
- padding: 12px 19px;
180
- }
181
-
182
- .yit-container.product-licence-activation .button-licence.licence-deactive,
183
- .yit-container.product-licence-activation .button-licence.licence-renew {
184
- text-decoration: none;
185
- padding: 7px 12px;
186
- font-size: 9px;
187
- }
188
-
189
- .yit-container.product-licence-activation table:not(.expired-table) .button-licence.licence-renew {
190
- margin-left: 10px;
191
- }
192
-
193
- .yit-container.product-licence-activation .button-licence.licence-deactive:focus,
194
- .yit-container.product-licence-activation .button-licence.licence-renew:focus {
195
- box-shadow: none;
196
- }
197
-
198
- .yit-container.product-licence-activation table:not(.to-active-table) {
199
- width: auto;
200
- border: 1px solid #dcdcdc;
201
- border-spacing: 0;
202
- border-radius: 5px;
203
- border-collapse: separate;
204
- overflow: hidden;
205
- }
206
-
207
- .yit-container.product-licence-activation table:not(.to-active-table) th {
208
- border-bottom: 1px solid #dcdcdc;
209
- padding: 0 10px;
210
- }
211
-
212
- .yit-container.product-licence-activation table tbody tr td.product-licence-key {
213
- text-transform: lowercase;
214
- }
215
-
216
- .yit-container.product-licence-activation table:not(.to-active-table) td,
217
- .yit-container.product-licence-activation table:not(.to-active-table) th {
218
- border-right: 1px solid #dcdcdc;
219
- }
220
-
221
- .yit-container.product-licence-activation table:not(.to-active-table) th{
222
- color: #808a97;
223
- font-weight: bold;
224
- }
225
-
226
- .yit-container.product-licence-activation table td:last-child,
227
- .yit-container.product-licence-activation table th:last-child {
228
- border-right: 0;
229
- }
230
-
231
- .yit-container.product-licence-activation table thead tr {
232
- background-color: #f6f4f4;
233
- }
234
-
235
- .yit-container.product-licence-activation table tbody tr {
236
- background-color: #ffffff;
237
- }
238
-
239
- .yit-container.product-licence-activation table tbody tr:nth-child(2n) {
240
- background-color: #f4f4f4;
241
- }
242
-
243
- .yit-container.product-licence-activation table thead tr th {
244
- font-size: 11px;
245
- color: #313131;
246
- text-transform: uppercase;
247
- font-weight: bold;
248
- }
249
-
250
- .yit-container.product-licence-activation table thead tr,
251
- .yit-container.product-licence-activation table tbody tr {
252
- line-height: 60px;
253
- }
254
-
255
- .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-no-alt {
256
- color: #b20015;
257
- }
258
-
259
- .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-yes {
260
- color: #1ca800;
261
- }
262
-
263
- .yit-container.product-licence-activation table tbody tr td{
264
- text-align: center;
265
- line-height: 20px;
266
- padding: 10px 5px;
267
- }
268
-
269
- .yit-container.product-licence-activation .button-licence.licence-activation {
270
- padding: 12px 18px;
271
- }
272
-
273
- .yit-container.product-licence-activation .to-active-table tr {
274
- line-height: 75px;
275
- }
276
-
277
- .yit-container.product-licence-activation .to-active-table tr.product-row {
278
- background-color: transparent;
279
- -webkit-transition: all 0.3s ease;
280
- -moz-transition: all 0.3s ease;
281
- -ms-transition: all 0.3s ease;
282
- -o-transition: all 0.3s ease;
283
- transition: all 0.3s ease;
284
- }
285
-
286
- .yit-container.product-licence-activation .to-active-table tr.product-row.error {
287
- background-color: #ffdcdc;
288
- }
289
-
290
- .yit-container.product-licence-activation .to-active-table td {
291
- padding-right: 12px;
292
- width: 33%;
293
- }
294
-
295
- .yit-container.product-licence-activation td.product-name {
296
- color: #808a97;
297
- font-size: 12px;
298
- text-transform: uppercase;
299
- font-weight: bold;
300
- line-height: 20px;
301
- padding: 10px 20px;
302
- }
303
-
304
- .yit-container.product-licence-activation .to-active-table td.product-name {
305
- width: 20%;
306
- }
307
-
308
- .yit-container.product-licence-activation .to-active-table td.activate-button {
309
- width: 15%;
310
- position: relative;
311
- }
312
-
313
- .yit-container.product-licence-activation input[type=text],
314
- .yit-container.product-licence-activation input[type=email]{
315
- -webkit-transition: all 0.3s ease;
316
- -moz-transition: all 0.3s ease;
317
- -ms-transition: all 0.3s ease;
318
- -o-transition: all 0.3s ease;
319
- transition: all 0.3s ease;
320
-
321
- border: 1px solid #dcdcdc;
322
- padding: 0 15px;
323
- border-radius: 3px;
324
- height: 41px;
325
- width: 100%;
326
- }
327
-
328
- .yit-container.product-licence-activation input[type=text].require,
329
- .yit-container.product-licence-activation input[type=email].require {
330
- border: 1px solid #ff3838;
331
- }
332
-
333
- .yit-container.product-licence-activation input[type=text]:focus,
334
- .yit-container.product-licence-activation input[type=email]:focus{
335
- webkit-box-shadow: 0 0 1px rgba(30,140,190,.8);
336
- box-shadow: 0 0 1px rgba(30,140,190,.8);
337
- }
338
-
339
- .yit-container.product-licence-activation input[type=text],
340
- .yit-container.product-licence-activation input[type=email]{
341
- text-transform: uppercase;
342
- text-align: center;
343
- }
344
-
345
- .yit-container.product-licence-activation input[type=submit]:focus{
346
- outline: 0;
347
- }
348
-
349
- /* Licence FAQ */
350
- .yit-container.product-licence-activation .activation-faq {
351
- background: #ffffff;
352
- margin-bottom: 20px;
353
- border: 1px solid #dcdcdc;
354
- padding: 0 15px;
355
- border-radius: 3px;
356
- }
357
-
358
- .yit-container.product-licence-activation .activation-faq h3{
359
- color: #808a97;
360
- }
361
-
362
- #yith-licence-notice {
363
- margin-left: 0;
364
- visibility: hidden;
365
- min-height: 38px;
366
- max-width: 660px;
367
- }
368
-
369
- #yith-licence-notice.visible {
370
- visibility: visible;
371
- }
372
-
373
- #yith-licence-issue-how-to{
374
- margin: 20px 10px 20px 0;
375
- font-weight: 500;
376
- color: #606060;
377
- }
378
-
379
- #yith-licence-actions span.dashicons{
380
- line-height: 60px;
381
- }
382
-
383
- /* === Responsive === */
384
-
385
- @media (max-width: 767px) {
386
- .yit-container.product-licence-activation .activation-faq {
387
- margin-right: 5px;
388
- }
389
- }
390
-
391
- @media (max-width: 480px) {
392
- .yit-container.product-licence-activation .activation-faq {
393
- margin-right: 5px;
394
- }
395
- }
396
-
397
- @media (min-width: 768px) and (max-width: 992px) {
398
- .yit-container.product-licence-activation .button-licence.licence-deactive,
399
- .yit-container.product-licence-activation .button-licence.licence-renew {
400
- margin-bottom: 10px;
401
- display: block;
402
- margin-left: 0;
403
- padding: 5px 7px;
404
- }
405
-
406
- .yit-container.product-licence-activation .button-licence.licence-deactive {
407
- margin-bottom: 10px;
408
- }
409
-
410
- .yit-container.product-licence-activation table:not(.to-active-table) th {
411
- line-height: 20px;
412
- }
413
-
414
- .yit-container.product-licence-activation table tbody tr td {
415
- padding: 5px;
416
- }
417
-
418
- .yit-container.product-licence-activation .activation-faq {
419
- margin-right: 20px;
420
- }
421
- }
422
-
423
- @media (min-width: 980px) and (max-width: 1199px) {
424
- .yit-container.product-licence-activation .button-licence.licence-deactive,
425
- .yit-container.product-licence-activation .button-licence.licence-renew {
426
- display: block;
427
- margin-left: 0;
428
- padding: 5px 7px;
429
- }
430
-
431
- .yit-container.product-licence-activation .button-licence.licence-renew {
432
- margin-top: 10px;
433
- }
434
-
435
- .yit-container.product-licence-activation table:not(.to-active-table) th {
436
- line-height: 20px;
437
- }
438
-
439
- .yit-container.product-licence-activation table tbody tr td {
440
- padding: 5px;
441
- }
442
-
443
- .yit-container.product-licence-activation .activation-faq {
444
- width: 75%;
445
- }
446
- }
447
-
448
- @media (min-width: 1200px) {
449
- .yit-container.product-licence-activation{
450
- width: auto;
451
- }
452
-
453
- .yit-container.product-licence-activation .activation-faq {
454
- width: 50%;
455
- }
456
- }
457
-
458
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
459
- only screen and (-o-min-device-pixel-ratio: 3/2),
460
- only screen and (min--moz-device-pixel-ratio: 1.5),
461
- only screen and (min-device-pixel-ratio: 1.5) {}
plugin-fw/licence/assets/images/licence-error.png DELETED
Binary file
plugin-fw/licence/assets/js/yit-licence.js DELETED
@@ -1,215 +0,0 @@
1
- /**
2
- * This file belongs to the YIT Plugin Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
-
11
- ( function ( $ ) {
12
-
13
- /* === Licence API === */
14
-
15
- var licence_activation = function ( button ) {
16
- button.on( 'click', function ( e, button ) {
17
- e.preventDefault();
18
-
19
- var t = $( this ),
20
- form_id = t.data( 'formid' ),
21
- form = $( '#' + form_id ),
22
- data = form.serialize(),
23
- message = $( form ).find( '.message' ),
24
- message_wrapper = $( form ).find( '.message-wrapper' ),
25
- email = form.find( '.user-email' ),
26
- licence_key = form.find( '.licence-key' ),
27
- email_val = form.find( '.user-email' ).val(),
28
- licence_key_val = form.find( '.licence-key' ).val(),
29
- error = false,
30
- error_fields = new Array(),
31
- product_row = form.find( '.product-row' ),
32
- licence_activation = $( '.licence-activation' ),
33
- spinner = $( '#products-to-active' ).find( '.spinner' ),
34
- is_mail = function( val ){
35
- /* https://stackoverflow.com/questions/2855865/jquery-validate-e-mail-address-regex */
36
- var re = new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?#x2F;i);
37
- return re.test( val );
38
- };
39
-
40
- /* Init Input Fields */
41
- message.empty();
42
- message_wrapper.removeClass( 'visible' );
43
- email.removeClass( 'require' );
44
- licence_key.removeClass( 'require' );
45
- product_row.removeClass( 'error' );
46
- spinner.addClass( 'show' );
47
- t.add( licence_activation ).prop( "disabled", true ).addClass( 'clicked' );
48
-
49
- if ( '' === email_val || ! is_mail( email_val ) ) {
50
- error = true;
51
- email.addClass( 'require' );
52
-
53
- if( '' === email_val ){
54
- error_fields[ error_fields.length ] = licence_message.email;
55
- }
56
-
57
- else {
58
- error_fields[ error_fields.length ] = licence_message.email;
59
- }
60
-
61
- }
62
-
63
- if ( '' === licence_key_val ) {
64
- error = true;
65
- error_fields[ error_fields.length ] = licence_message.license_key;
66
- licence_key.addClass( 'require' );
67
- }
68
-
69
- if ( false === error ) {
70
- jQuery.ajax( {
71
- type : 'POST',
72
- url : typeof ajaxurl != 'undefined' ? ajaxurl : yith_ajax.url,
73
- data : data,
74
- success: function ( response ) {
75
-
76
- spinner.removeClass( 'show' );
77
- t.add( licence_activation ).prop( "disabled", false ).removeClass( 'clicked' );
78
-
79
- if ( true === response.activated ) {
80
- $( '.product-licence-activation' ).empty().replaceWith( response.template );
81
- licence_api();
82
- } else if ( false !== response && typeof response.error !== 'undefined' ) {
83
- message.text( response.error );
84
- message_wrapper.addClass( 'visible' );
85
- product_row.addClass( 'error' );
86
- } else {
87
- message.text( licence_message.server );
88
- message_wrapper.addClass( 'visible' );
89
- product_row.addClass( 'error' );
90
- }
91
-
92
- if ( typeof response.debug !== 'undefined' ) {
93
- console.log( response.debug );
94
- }
95
- }
96
- } );
97
- } else {
98
- if ( error_fields.length == 1 ) {
99
- message.text( licence_message.error.replace( '%field%', error_fields[ 0 ] ) );
100
- message_wrapper.addClass( 'visible' );
101
- product_row.addClass( 'error' );
102
- } else {
103
- var message_text = licence_message.errors;
104
- for ( var i = 0; i < error_fields.length; i++ ) {
105
- message_text = message_text.replace( '%field_' + ( i + 1 ) + '%', error_fields[ i ] );
106
- message_wrapper.addClass( 'visible' );
107
- }
108
- message.text( message_text );
109
- message_wrapper.addClass( 'visible' );
110
- product_row.addClass( 'error' );
111
- }
112
-
113
- spinner.removeClass( 'show' );
114
- t.add( licence_activation ).prop( "disabled", false ).removeClass( 'clicked' );
115
- }
116
- } );
117
- };
118
-
119
- var licence_update = function ( button ) {
120
- button.on( 'click', function ( e ) {
121
- e.preventDefault();
122
-
123
- var t = $( this ),
124
- form = $( '#licence-check-update' ),
125
- data = form.serialize();
126
-
127
- t.prop( "disabled", true ).addClass( 'clicked' );
128
- form.find( 'div.spinner' ).addClass( 'show' );
129
-
130
- jQuery.ajax( {
131
- type : 'POST',
132
- url : ajaxurl,
133
- data : data,
134
- success: function ( response ) {
135
- $( '.product-licence-activation' ).empty().replaceWith( response.template );
136
- licence_api();
137
- }
138
- } );
139
- } );
140
- };
141
-
142
- var licence_deactivate = function ( button ) {
143
- button.on( 'click', function ( e ) {
144
- e.preventDefault();
145
-
146
- var check = script_info.is_debug == true ? true : confirm( licence_message.are_you_sure );
147
-
148
- if ( check == true ) {
149
- var t = $( this ),
150
- licence_key = t.data( 'licence-key' ),
151
- licence_email = t.data( 'licence-email' ),
152
- product_init = t.data( 'product-init' ),
153
- action = t.data( 'action' ),
154
- renew = $( '.licence-renew' ),
155
- deactive = $( '.licence-deactive' ),
156
- message = $( '#yith-licence-notice' ),
157
- activated_table = $( '.activated-table' );
158
-
159
- t.add( renew ).add( deactive ).prop( "disabled", true ).addClass( 'clicked' );
160
- $( '#activated-products' ).find( '.spinner' ).addClass( 'show' );
161
-
162
- jQuery.ajax( {
163
- type : 'POST',
164
- url : ajaxurl,
165
- data : {
166
- action : action,
167
- licence_key : licence_key,
168
- email : licence_email,
169
- product_init: product_init
170
- },
171
- success: function ( response ) {
172
- message.css( 'maxWidth', activated_table.width() );
173
- if ( false == response ) {
174
- message.find( 'p.yith-licence-notice-message' ).html( licence_message.server );
175
- message.removeClass( 'notice-success' ).addClass( 'notice-error visible' );
176
- t.add( renew ).add( deactive ).add( renew ).prop( "disabled", false ).removeClass( 'clicked' );
177
- $( '#activated-products' ).find( '.spinner' ).removeClass( 'show' );
178
- }
179
-
180
- else {
181
- if ( false == response.activated ) {
182
- $( '.product-licence-activation' ).empty().replaceWith( response.template );
183
- licence_api();
184
- }
185
-
186
- if ( typeof response.error != 'undefined' ) {
187
- message.find( 'p.yith-licence-notice-message' ).html( response.error );
188
- message.removeClass( 'notice-success' ).addClass( 'notice-error visible' );
189
- t.add( renew ).add( deactive ).add( renew ).prop( "disabled", false ).removeClass( 'clicked' );
190
- $( '#activated-products' ).find( '.spinner' ).removeClass( 'show' );
191
- }
192
- }
193
- }
194
- } );
195
- }
196
- } );
197
- };
198
-
199
- var licence_api = function () {
200
- var button = $( '.licence-activation' ),
201
- check = $( '.licence-check' ),
202
- deactivated = $( '.licence-deactive' );
203
-
204
- licence_activation( button );
205
- licence_update( check );
206
- licence_deactivate( deactivated );
207
- };
208
-
209
- licence_api();
210
-
211
- $( 'body' ).on( 'click', '.yit-changelog-button', function ( e ) {
212
- $( '#TB_window' ).remove();
213
- } );
214
-
215
- } )( jQuery );
plugin-fw/licence/assets/js/yit-licence.min.js DELETED
@@ -1,8 +0,0 @@
1
- (function(b){var t=function(c){c.on("click",function(k,e){k.preventDefault();var c=b(this),a=c.data("formid"),d=b("#"+a),f=d.serialize(),h=b(d).find(".message"),g=b(d).find(".message-wrapper"),l=d.find(".user-email"),u=d.find(".licence-key"),v=d.find(".user-email").val(),t=d.find(".licence-key").val(),n=!1;a=[];var p=d.find(".product-row"),q=b(".licence-activation"),r=b("#products-to-active").find(".spinner");h.empty();g.removeClass("visible");l.removeClass("require");u.removeClass("require");p.removeClass("error");
2
- r.addClass("show");c.add(q).prop("disabled",!0).addClass("clicked");""!==v&&(new RegExp(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?#x2F;i)).test(v)||
3
- (n=!0,l.addClass("require"),a[a.length]=licence_message.email);""===t&&(n=!0,a[a.length]=licence_message.license_key,u.addClass("require"));if(!1===n)jQuery.ajax({type:"POST",url:"undefined"!=typeof ajaxurl?ajaxurl:yith_ajax.url,data:f,success:function(a){r.removeClass("show");c.add(q).prop("disabled",!1).removeClass("clicked");!0===a.activated?(b(".product-licence-activation").empty().replaceWith(a.template),m()):(!1!==a&&"undefined"!==typeof a.error?h.text(a.error):h.text(licence_message.server),
4
- g.addClass("visible"),p.addClass("error"));"undefined"!==typeof a.debug&&console.log(a.debug)}});else{if(1==a.length)h.text(licence_message.error.replace("%field%",a[0]));else{d=licence_message.errors;for(f=0;f<a.length;f++)d=d.replace("%field_"+(f+1)+"%",a[f]),g.addClass("visible");h.text(d)}g.addClass("visible");p.addClass("error");r.removeClass("show");c.add(q).prop("disabled",!1).removeClass("clicked")}})},w=function(c){c.on("click",function(c){c.preventDefault();c=b(this);var e=b("#licence-check-update"),
5
- k=e.serialize();c.prop("disabled",!0).addClass("clicked");e.find("div.spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:k,success:function(a){b(".product-licence-activation").empty().replaceWith(a.template);m()}})})},x=function(c){c.on("click",function(c){c.preventDefault();if(1==(1==script_info.is_debug?!0:confirm(licence_message.are_you_sure))){var e=b(this);c=e.data("licence-key");var k=e.data("licence-email"),a=e.data("product-init"),d=e.data("action"),f=b(".licence-renew"),
6
- h=b(".licence-deactive"),g=b("#yith-licence-notice"),l=b(".activated-table");e.add(f).add(h).prop("disabled",!0).addClass("clicked");b("#activated-products").find(".spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:{action:d,licence_key:c,email:k,product_init:a},success:function(a){g.css("maxWidth",l.width());0==a?(g.find("p.yith-licence-notice-message").html(licence_message.server),g.removeClass("notice-success").addClass("notice-error visible"),e.add(f).add(h).add(f).prop("disabled",
7
- !1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show")):(0==a.activated&&(b(".product-licence-activation").empty().replaceWith(a.template),m()),"undefined"!=typeof a.error&&(g.find("p.yith-licence-notice-message").html(a.error),g.removeClass("notice-success").addClass("notice-error visible"),e.add(f).add(h).add(f).prop("disabled",!1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show")))}})}})},m=function(){var c=b(".licence-activation"),
8
- k=b(".licence-check"),e=b(".licence-deactive");t(c);w(k);x(e)};m();b("body").on("click",".yit-changelog-button",function(c){b("#TB_window").remove()})})(jQuery);
plugin-fw/licence/lib/yit-licence.php DELETED
@@ -1,804 +0,0 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( !defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( !class_exists( 'YIT_Licence' ) ) {
16
- /**
17
- * YIT Licence Panel
18
- *
19
- * Setting Page to Manage Products
20
- *
21
- * @class YIT_Licence
22
- * @package YITH
23
- * @since 1.0
24
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
- */
26
- abstract class YIT_Licence {
27
-
28
- /**
29
- * @var mixed array The registered products info
30
- * @since 1.0
31
- */
32
- protected $_products = array();
33
-
34
- /**
35
- * @var array The settings require to add the submenu page "Activation"
36
- * @since 1.0
37
- */
38
- protected $_settings = array();
39
-
40
- /**
41
- * @var string Option name
42
- * @since 1.0
43
- */
44
- protected $_licence_option = 'yit_products_licence_activation';
45
-
46
- /**
47
- * @var string The yithemes api uri
48
- * @since 1.0
49
- */
50
- protected $_api_uri = 'https://yithemes.com';
51
-
52
- /**
53
- * @var string The yithemes api uri query args
54
- * @since 1.0
55
- */
56
- protected $_api_uri_query_args = '?wc-api=software-api&request=%request%';
57
-
58
-
59
- /**
60
- * @var string check for show extra info
61
- * @since 1.0
62
- */
63
- public $show_extra_info = false;
64
-
65
- /**
66
- * @var string check for show extra info
67
- * @since 1.0
68
- */
69
- public $show_renew_button = true;
70
-
71
- /**
72
- * Constructor
73
- *
74
- * @since 1.0
75
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
76
- */
77
- public function __construct() {
78
- $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
79
- if ( $is_debug_enabled ) {
80
- $this->_api_uri = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
81
- add_filter( 'block_local_requests', '__return_false' );
82
- }
83
-
84
- /* Style adn Script */
85
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
86
- if ( $is_debug_enabled ) {
87
- //show extra info and renew button in debug mode
88
- $this->show_extra_info = $this->show_renew_button = true;
89
- } else {
90
- $this->show_extra_info = ( defined( 'YIT_SHOW_EXTRA_LICENCE_INFO' ) && YIT_SHOW_EXTRA_LICENCE_INFO ) || ( ! empty( $_GET['yith_show_extra_license_info'] ) && 'yes' == $_GET['yith_show_extra_license_info'] );
91
- $this->show_renew_button = !( defined( 'YIT_HIDE_LICENCE_RENEW_BUTTON' ) && YIT_HIDE_LICENCE_RENEW_BUTTON );
92
- }
93
- }
94
-
95
- /**
96
- * Premium products registration
97
- *
98
- * @param $init string | The products identifier
99
- * @param $secret_key string | The secret key
100
- * @param $product_id string | The product id
101
- *
102
- * @return void
103
- *
104
- * @since 1.0
105
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
106
- */
107
- abstract public function register( $init, $secret_key, $product_id );
108
-
109
- /**
110
- * Get protected array products
111
- *
112
- * @return mixed array
113
- *
114
- * @since 1.0
115
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
116
- */
117
- public function get_products() {
118
- return $this->_products;
119
- }
120
-
121
- /**
122
- * Get The home url without protocol
123
- *
124
- * @return string the home url
125
- *
126
- * @since 1.0
127
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
128
- */
129
- public function get_home_url() {
130
- $home_url = home_url();
131
- $schemes = array( 'https://', 'http://', 'www.' );
132
-
133
- foreach ( $schemes as $scheme ) {
134
- $home_url = str_replace( $scheme, '', $home_url );
135
- }
136
-
137
- if ( strpos( $home_url, '?' ) !== false ) {
138
- list( $base, $query ) = explode( '?', $home_url, 2 );
139
- $home_url = $base;
140
- }
141
-
142
- $home_url = untrailingslashit( $home_url );
143
-
144
- return $home_url;
145
- }
146
-
147
- /**
148
- * Check if the request is ajax
149
- *
150
- * @return bool true if the request is ajax, false otherwise
151
- *
152
- * @since 1.0
153
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
154
- */
155
- public function is_ajax() {
156
- return defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
157
- }
158
-
159
- /**
160
- * Admin Enqueue Scripts
161
- *
162
- * @return void
163
- *
164
- * @since 1.0
165
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
166
- */
167
- public function admin_enqueue_scripts() {
168
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
169
- /**
170
- * Support to YIT Framework < 2.0
171
- */
172
- $script_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
173
- $style_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
174
-
175
- wp_register_script( 'yit-licence', $script_path . '/licence/assets/js/yit-licence' . $suffix . '.js', array( 'jquery' ), '1.0.0', true );
176
- wp_register_style( 'yit-theme-licence', $style_path . '/licence/assets/css/yit-licence.css' );
177
-
178
- /* Localize Scripts */
179
- wp_localize_script( 'yit-licence', 'licence_message', array(
180
- 'error' => sprintf( _x( 'Please, insert a valid %s', '%s = field name', 'yith-plugin-fw' ), '%field%' ), // sprintf must be used to avoid errors with '%field%' string in translation in .po file
181
- 'errors' => sprintf( __( 'Please, insert a valid %s and a valid %s', 'yith-plugin-fw' ), '%field_1%', '%field_2%' ),
182
- 'server' => __( 'Unable to contact the remote server, please try again later. Thanks!', 'yith-plugin-fw' ),
183
- 'email' => __( 'email address', 'yith-plugin-fw' ),
184
- 'license_key' => __( 'license key', 'yith-plugin-fw' ),
185
- 'are_you_sure' => __( 'Are you sure you want to deactivate the license for current site?', 'yith-plugin-fw' )
186
- )
187
- );
188
-
189
- wp_localize_script( 'yit-licence', 'script_info', array(
190
- 'is_debug' => defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG
191
- )
192
- );
193
-
194
- wp_localize_script( 'yit-licence', 'yith_ajax', array(
195
- 'url' => admin_url( 'admin-ajax.php', 'relative' )
196
- )
197
- );
198
-
199
- /* Enqueue Scripts only in Licence Activation page of plugins and themes */
200
- if ( strpos( get_current_screen()->id, 'yith_plugins_activation' ) !== false || strpos( get_current_screen()->id, 'yit_panel_license' ) !== false ) {
201
- wp_enqueue_script( 'yit-licence' );
202
- wp_enqueue_style( 'yit-theme-licence' );
203
- }
204
- }
205
-
206
- /**
207
- * Activate Plugins
208
- *
209
- * Send a request to API server to activate plugins
210
- *
211
- * @return void
212
- * @use wp_send_json
213
- *
214
- * @since 1.0
215
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
216
- */
217
- public function activate() {
218
- $product_init = $_REQUEST[ 'product_init' ];
219
- $product = $this->get_product( $product_init );
220
-
221
- $args = array(
222
- 'email' => urlencode( sanitize_email( $_REQUEST[ 'email' ] ) ),
223
- 'licence_key' => sanitize_text_field( $_REQUEST[ 'licence_key' ] ),
224
- 'product_id' => sanitize_text_field( $product[ 'product_id' ] ),
225
- 'secret_key' => sanitize_text_field( $product[ 'secret_key' ] ),
226
- 'instance' => $this->get_home_url()
227
- );
228
-
229
- $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'activation' ) ) );
230
- $timeout = apply_filters( 'yith_plugin_fw_licence_timeout', 30, __FUNCTION__ );
231
- $response = wp_remote_get( $api_uri, array( 'timeout' => $timeout ) );
232
-
233
- if ( is_wp_error( $response ) ) {
234
- $body = false;
235
- } else {
236
- $body = json_decode( $response[ 'body' ] );
237
- $body = is_object( $body ) ? get_object_vars( $body ) : false;
238
- }
239
-
240
- if ( $body && is_array( $body ) && isset( $body[ 'activated' ] ) && $body[ 'activated' ] ) {
241
-
242
- $option[ $product[ 'product_id' ] ] = array(
243
- 'email' => urldecode( $args[ 'email' ] ),
244
- 'licence_key' => $args[ 'licence_key' ],
245
- 'licence_expires' => $body[ 'licence_expires' ],
246
- 'message' => $body[ 'message' ],
247
- 'activated' => true,
248
- 'activation_limit' => $body[ 'activation_limit' ],
249
- 'activation_remaining' => $body[ 'activation_remaining' ],
250
- 'is_membership' => isset( $body[ 'is_membership' ] ) ? $body[ 'is_membership' ] : false,
251
- );
252
-
253
- /* === Check for other plugins activation === */
254
- $options = $this->get_licence();
255
- $options[ $product[ 'product_id' ] ] = $option[ $product[ 'product_id' ] ];
256
-
257
- update_option( $this->_licence_option, $options );
258
-
259
- /* === Update Plugin Licence Information === */
260
- yith_plugin_fw_force_regenerate_plugin_update_transient();
261
-
262
- /* === Licence Activation Template === */
263
- $body[ 'template' ] = $this->show_activation_panel( $this->get_response_code_message( 200 ) );
264
- }
265
-
266
- if ( !empty( $_REQUEST[ 'debug' ] ) ) {
267
- $body = is_array( $body ) ? $body : array();
268
- $body[ 'debug' ] = array( 'response' => $response );
269
- if ( 'print_r' === $_REQUEST[ 'debug' ] ) {
270
- $body[ 'debug' ] = print_r( $body[ 'debug' ], true );
271
- }
272
- }
273
-
274
- wp_send_json( $body );
275
- }
276
-
277
- /**
278
- * Deactivate Plugins
279
- *
280
- * Send a request to API server to activate plugins
281
- *
282
- * @return void
283
- * @use wp_send_json
284
- *
285
- * @since 1.0
286
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
287
- */
288
- public function deactivate() {
289
- $product_init = $_REQUEST[ 'product_init' ];
290
- $product = $this->get_product( $product_init );
291
-
292
- $args = array(
293
- 'email' => urlencode( sanitize_email( $_REQUEST[ 'email' ] ) ),
294
- 'licence_key' => sanitize_text_field( $_REQUEST[ 'licence_key' ] ),
295
- 'product_id' => sanitize_text_field( $product[ 'product_id' ] ),
296
- 'secret_key' => sanitize_text_field( $product[ 'secret_key' ] ),
297
- 'instance' => $this->get_home_url()
298
- );
299
-
300
- $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'deactivation' ) ) );
301
- $timeout = apply_filters( 'yith_plugin_fw_licence_timeout', 30, __FUNCTION__ );
302
- $response = wp_remote_get( $api_uri, array( 'timeout' => $timeout ) );
303
-
304
- if ( is_wp_error( $response ) ) {
305
- $body = false;
306
- } else {
307
- $body = json_decode( $response[ 'body' ] );
308
- $body = is_object( $body ) ? get_object_vars( $body ) : false;
309
- }
310
-
311
- if ( $body && is_array( $body ) ) {
312
- /* === Get License === */
313
- $options = $this->get_licence();
314
- if( isset( $body[ 'activated' ] ) && ! $body[ 'activated' ] && ! isset( $body[ 'error' ] ) ){
315
- $option[ $product[ 'product_id' ] ] = array(
316
- 'activated' => false,
317
- 'email' => urldecode( $args[ 'email' ] ),
318
- 'licence_key' => $args[ 'licence_key' ],
319
- 'licence_expires' => $body[ 'licence_expires' ],
320
- 'message' => $body[ 'message' ],
321
- 'activation_limit' => $body[ 'activation_limit' ],
322
- 'activation_remaining' => $body[ 'activation_remaining' ],
323
- 'is_membership' => isset( $body[ 'is_membership' ] ) ? $body[ 'is_membership' ] : false,
324
- );
325
-
326
- /* === Check for other plugins activation === */
327
- $options[ $product[ 'product_id' ] ] = $option[ $product[ 'product_id' ] ];