Version Description
- Released: Sep 26, 2018 =
- Update: Plugin Core 3.0.23
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Ajax Search |
Version | 1.5.9 |
Comparing to | |
See all releases |
Code changes from version 1.5.8 to 1.5.9
- README.txt +4 -1
- class.yith-wcas-admin.php +1 -1
- init.php +3 -3
- plugin-fw/init.php +2 -2
- plugin-fw/lib/yit-plugin-panel.php +6 -3
- plugin-fw/lib/yit-plugin-subpanel.php +3 -2
- plugin-fw/lib/yit-upgrade.php +641 -594
- plugin-fw/yit-functions.php +22 -13
README.txt
CHANGED
@@ -4,7 +4,7 @@ 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: 4.9
|
7 |
-
Stable tag: 1.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.5.8 - Released: Jun 28, 2018 =
|
142 |
* Update: Plugin Core 3.0.21
|
143 |
* Fix: Fixed compatibility class loading
|
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: 4.9
|
7 |
+
Stable tag: 1.5.9
|
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.5.9 - Released: Sep 26, 2018 =
|
142 |
+
* Update: Plugin Core 3.0.23
|
143 |
+
|
144 |
= 1.5.8 - Released: Jun 28, 2018 =
|
145 |
* Update: Plugin Core 3.0.21
|
146 |
* Fix: Fixed compatibility class loading
|
class.yith-wcas-admin.php
CHANGED
@@ -133,7 +133,7 @@ if( !class_exists( 'YITH_WCAS_Admin' ) ) {
|
|
133 |
'menu_title' => __( 'Ajax Search', 'yith-woocommerce-ajax-search' ),
|
134 |
'capability' => 'manage_options',
|
135 |
'parent' => '',
|
136 |
-
'parent_page' => '
|
137 |
'page' => $this->_panel_page,
|
138 |
'admin-tabs' => $admin_tabs,
|
139 |
'options-path' => YITH_WCAS_DIR . '/plugin-options'
|
133 |
'menu_title' => __( 'Ajax Search', 'yith-woocommerce-ajax-search' ),
|
134 |
'capability' => 'manage_options',
|
135 |
'parent' => '',
|
136 |
+
'parent_page' => 'yith_plugin_panel',
|
137 |
'page' => $this->_panel_page,
|
138 |
'admin-tabs' => $admin_tabs,
|
139 |
'options-path' => YITH_WCAS_DIR . '/plugin-options'
|
init.php
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
/**
|
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
|
6 |
-
* Version: 1.5.
|
7 |
* Author: YITHEMES
|
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.5.
|
71 |
}
|
72 |
|
73 |
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
|
2 |
/**
|
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">Find new awesome plugins on <strong>YITH</strong></a>.
|
6 |
+
* Version: 1.5.9
|
7 |
* Author: YITHEMES
|
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.5.9' );
|
71 |
}
|
72 |
|
73 |
if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
|
plugin-fw/init.php
CHANGED
@@ -1,13 +1,13 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
-
* Version: 3.0.
|
5 |
* Author: YITHEMES
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
8 |
*
|
9 |
* @author Your Inspiration Themes
|
10 |
-
* @version 3.0.
|
11 |
*/
|
12 |
/**
|
13 |
* This file belongs to the YIT Plugin Framework.
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
+
* Version: 3.0.23
|
5 |
* Author: YITHEMES
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
8 |
*
|
9 |
* @author Your Inspiration Themes
|
10 |
+
* @version 3.0.23
|
11 |
*/
|
12 |
/**
|
13 |
* This file belongs to the YIT Plugin Framework.
|
plugin-fw/lib/yit-plugin-panel.php
CHANGED
@@ -156,8 +156,11 @@ if ( !class_exists( 'YIT_Plugin_Panel' ) ) {
|
|
156 |
$capability = apply_filters( 'yit_plugin_panel_menu_page_capability', 'manage_options' );
|
157 |
$show = apply_filters( 'yit_plugin_panel_menu_page_show', true );
|
158 |
|
159 |
-
// YITH
|
160 |
-
|
|
|
|
|
|
|
161 |
}
|
162 |
}
|
163 |
|
@@ -203,7 +206,7 @@ if ( !class_exists( 'YIT_Plugin_Panel' ) ) {
|
|
203 |
wp_enqueue_script( 'yith-plugin-fw-fields' );
|
204 |
}
|
205 |
|
206 |
-
if ( ( 'admin.php' == $pagenow &&
|
207 |
wp_enqueue_media();
|
208 |
wp_enqueue_style( 'yit-plugin-style' );
|
209 |
wp_enqueue_script( 'yit-plugin-panel' );
|
156 |
$capability = apply_filters( 'yit_plugin_panel_menu_page_capability', 'manage_options' );
|
157 |
$show = apply_filters( 'yit_plugin_panel_menu_page_show', true );
|
158 |
|
159 |
+
// YITH text must not be translated
|
160 |
+
if ( !!$show ) {
|
161 |
+
add_menu_page( 'yith_plugin_panel', 'YITH', $capability, 'yith_plugin_panel', null, YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png', $position );
|
162 |
+
$admin_page_hooks[ 'yith_plugin_panel' ] = 'yith-plugins'; // prevent issues for backward compatibility
|
163 |
+
}
|
164 |
}
|
165 |
}
|
166 |
|
206 |
wp_enqueue_script( 'yith-plugin-fw-fields' );
|
207 |
}
|
208 |
|
209 |
+
if ( ( 'admin.php' == $pagenow && yith_plugin_fw_is_panel() ) || apply_filters( 'yit_plugin_panel_asset_loading', false ) ) {
|
210 |
wp_enqueue_media();
|
211 |
wp_enqueue_style( 'yit-plugin-style' );
|
212 |
wp_enqueue_script( 'yit-plugin-panel' );
|
plugin-fw/lib/yit-plugin-subpanel.php
CHANGED
@@ -18,7 +18,7 @@ if ( !class_exists( 'YIT_Plugin_SubPanel' ) ) {
|
|
18 |
*
|
19 |
* Setting Page to Manage Plugins
|
20 |
*
|
21 |
-
* @class
|
22 |
* @package Yithemes
|
23 |
* @since 1.0
|
24 |
* @author Your Inspiration Themes
|
@@ -98,7 +98,8 @@ if ( !class_exists( 'YIT_Plugin_SubPanel' ) ) {
|
|
98 |
|
99 |
if ( !isset( $admin_page_hooks[ 'yith_plugin_panel' ] ) ) {
|
100 |
$position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
|
101 |
-
add_menu_page( 'yith_plugin_panel', 'YITH
|
|
|
102 |
}
|
103 |
|
104 |
add_submenu_page( 'yith_plugin_panel', $this->settings[ 'label' ], $this->settings[ 'label' ], 'manage_options', $this->settings[ 'page' ], array( $this, 'yit_panel' ) );
|
18 |
*
|
19 |
* Setting Page to Manage Plugins
|
20 |
*
|
21 |
+
* @class YIT_Plugin_Panel
|
22 |
* @package Yithemes
|
23 |
* @since 1.0
|
24 |
* @author Your Inspiration Themes
|
98 |
|
99 |
if ( !isset( $admin_page_hooks[ 'yith_plugin_panel' ] ) ) {
|
100 |
$position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
|
101 |
+
add_menu_page( 'yith_plugin_panel', 'YITH', 'nosuchcapability', 'yith_plugin_panel', null, $logo, $position );
|
102 |
+
$admin_page_hooks[ 'yith_plugin_panel' ] = 'yith-plugins'; // prevent issues for backward compatibility
|
103 |
}
|
104 |
|
105 |
add_submenu_page( 'yith_plugin_panel', $this->settings[ 'label' ], $this->settings[ 'label' ], 'manage_options', $this->settings[ 'page' ], array( $this, 'yit_panel' ) );
|
plugin-fw/lib/yit-upgrade.php
CHANGED
@@ -7,610 +7,657 @@
|
|
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 |
-
if ( !defined( 'ABSPATH' ) ) {
|
11 |
-
|
12 |
} // Exit if accessed directly
|
13 |
|
14 |
-
if ( !class_exists( 'YIT_Upgrade' ) ) {
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
<div class='yit-plugin-changelog'>
|
545 |
<h2 class='yit-plugin-changelog-title'>{$plugin['info']['Name']} - Changelog</h2>
|
546 |
<p>{$changelog}</p>
|
547 |
</div>
|
548 |
</div>";
|
549 |
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
}
|
602 |
|
603 |
-
if ( !function_exists( 'YIT_Upgrade' ) ) {
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
}
|
615 |
|
616 |
/**
|
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 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
exit;
|
12 |
} // Exit if accessed directly
|
13 |
|
14 |
+
if ( ! class_exists( 'YIT_Upgrade' ) ) {
|
15 |
+
/**
|
16 |
+
* YIT Upgrade
|
17 |
+
*
|
18 |
+
* Notify and Update plugin
|
19 |
+
*
|
20 |
+
* @class YIT_Upgrade
|
21 |
+
* @package Yithemes
|
22 |
+
* @since 1.0
|
23 |
+
* @author Your Inspiration Themes
|
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 |
+
*/
|
46 |
+
protected static $_instance;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Construct
|
50 |
+
*
|
51 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
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 |
+
/**
|
108 |
+
* Main plugin Instance
|
109 |
+
*
|
110 |
+
* @param $plugin_slug | string The plugin slug
|
111 |
+
* @param $plugin_init | string The plugin init file
|
112 |
+
*
|
113 |
+
* @return void
|
114 |
+
*
|
115 |
+
* @since 1.0
|
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 = @simplexml_load_string( $remote_xml['body'] );
|
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 |
+
*/
|
187 |
+
public function multisite_updater_script() {
|
188 |
+
$update_url = $changelogs = $details_url = array();
|
189 |
+
$strings = array(
|
190 |
+
'new_version' => __( 'There is a new version of %plugin_name% available.', 'yith-plugin-fw' ),
|
191 |
+
'latest' => __( 'View version %latest% details.', 'yith-plugin-fw' ),
|
192 |
+
'unavailable' => __( 'Automatic update is unavailable for this plugin,', 'yith-plugin-fw' ),
|
193 |
+
'activate' => __( 'please <a href="%activate_link%">activate</a> your copy of %plugin_name%.', 'yith-plugin-fw' ),
|
194 |
+
'update_now' => __( 'Update now.', 'yith-plugin-fw' )
|
195 |
+
|
196 |
+
);
|
197 |
+
|
198 |
+
foreach ( $this->_plugins as $init => $info ) {
|
199 |
+
$update_url[ $init ] = wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin-multisite&plugin=' ) . $init, 'upgrade-plugin-multisite_' . $init );
|
200 |
+
$details_url[ $init ] = admin_url( 'admin-ajax.php?action=yith_plugin_fw_get_premium_changelog&tab=plugin-information&plugin=' . $init . '§ion=changelog&TB_iframe=true&width=640&height=662' );
|
201 |
+
}
|
202 |
+
|
203 |
+
$localize_script_args = array(
|
204 |
+
'registered' => $this->_plugins,
|
205 |
+
'activated' => YIT_Plugin_Licence()->get_activated_products(),
|
206 |
+
'licence_activation_url' => YIT_Plugin_Licence()->get_licence_activation_page_url(),
|
207 |
+
'update_url' => $update_url,
|
208 |
+
'details_url' => $details_url,
|
209 |
+
'strings' => $strings,
|
210 |
+
);
|
211 |
+
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
212 |
+
yit_enqueue_script( 'yit-multisite-updater', YIT_CORE_PLUGIN_URL . '/assets/js/multisite-updater' . $suffix . '.js', array( 'jquery' ), false, true );
|
213 |
+
|
214 |
+
wp_localize_script( 'yit-multisite-updater', 'plugins', $localize_script_args );
|
215 |
+
}
|
216 |
+
|
217 |
+
public function admin_enqueue_scripts() {
|
218 |
+
global $pagenow;
|
219 |
+
if ( 'plugins.php' === $pagenow ) {
|
220 |
+
wp_enqueue_style( 'yit-upgrader', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrader.css' );
|
221 |
+
}
|
222 |
+
}
|
223 |
+
|
224 |
+
/**
|
225 |
+
* Retrive the zip package file
|
226 |
+
*
|
227 |
+
* @param bool $reply Whether to bail without returning the package. Default false.
|
228 |
+
* @param string $package The package file name.
|
229 |
+
* @param \WP_Upgrader $upgrader WP_Upgrader instance.
|
230 |
+
*
|
231 |
+
* @return string | The download file
|
232 |
+
*
|
233 |
+
* @since 1.0
|
234 |
+
* @see wp-admin/includes/class-wp-upgrader.php
|
235 |
+
* @access public
|
236 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
237 |
+
*/
|
238 |
+
public function upgrader_pre_download( $reply, $package, $upgrader ) {
|
239 |
+
$plugin = false;
|
240 |
+
$is_bulk = $upgrader->skin instanceof Bulk_Plugin_Upgrader_Skin;
|
241 |
+
|
242 |
+
if ( ! $is_bulk ) {
|
243 |
+
$plugin = isset( $upgrader->skin->plugin ) ? $upgrader->skin->plugin : false;
|
244 |
+
} else {
|
245 |
+
//Bulk action upgrade
|
246 |
+
$action_url = parse_url( $upgrader->skin->options['url'] );
|
247 |
+
parse_str( rawurldecode( htmlspecialchars_decode( $action_url['query'] ) ), $output );
|
248 |
+
$plugins = isset( $output['plugins'] ) ? $output['plugins'] : '';
|
249 |
+
$plugins = explode( ',', $plugins );
|
250 |
+
foreach ( $plugins as $plugin_init ) {
|
251 |
+
$to_upgrade = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_init );
|
252 |
+
if ( $to_upgrade['Name'] == $upgrader->skin->plugin_info['Name'] ) {
|
253 |
+
$plugin = $plugin_init;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
}
|
257 |
+
|
258 |
+
/**
|
259 |
+
* It isn't YITH Premium plugins, please wordpress update it for me!
|
260 |
+
*/
|
261 |
+
if ( ! $plugin ) {
|
262 |
+
return $reply;
|
263 |
+
}
|
264 |
+
|
265 |
+
$plugin_info = YIT_Plugin_Licence()->get_product( $plugin );
|
266 |
+
|
267 |
+
/**
|
268 |
+
* False ? It isn't YITH Premium plugins, please wordpress update it for me!
|
269 |
+
*/
|
270 |
+
if ( false === $plugin_info ) {
|
271 |
+
return $reply;
|
272 |
+
}
|
273 |
+
|
274 |
+
$licence = YIT_Plugin_Licence()->get_licence();
|
275 |
+
$product_id = $plugin_info['product_id'];
|
276 |
+
$args = array(
|
277 |
+
'email' => $licence[ $product_id ]['email'],
|
278 |
+
'licence_key' => $licence[ $product_id ]['licence_key'],
|
279 |
+
'product_id' => $plugin_info['product_id'],
|
280 |
+
'secret_key' => $plugin_info['secret_key'],
|
281 |
+
'instance' => YIT_Plugin_Licence()->get_home_url(),
|
282 |
+
'wc-api' => 'download-api',
|
283 |
+
'request' => 'download'
|
284 |
+
);
|
285 |
+
|
286 |
+
if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) {
|
287 |
+
//Local file or remote?
|
288 |
+
return $package;
|
289 |
+
}
|
290 |
+
|
291 |
+
if ( empty( $package ) ) {
|
292 |
+
return new WP_Error( 'no_package', $upgrader->strings['no_package'] );
|
293 |
+
}
|
294 |
+
|
295 |
+
$upgrader->skin->feedback( 'downloading_package', __( 'YITH Repository', 'yith-plugin-fw' ) );
|
296 |
+
|
297 |
+
$download_file = $this->_download_url( $package, $args );
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Regenerate update_plugins transient
|
301 |
+
*/
|
302 |
+
$this->force_regenerate_update_transient();
|
303 |
+
|
304 |
+
if ( is_wp_error( $download_file ) ) {
|
305 |
+
return new WP_Error( 'download_failed', $upgrader->strings['download_failed'], $download_file->get_error_message() );
|
306 |
+
}
|
307 |
+
|
308 |
+
return $download_file;
|
309 |
+
}
|
310 |
+
|
311 |
+
/**
|
312 |
+
* Retrive the temp filename
|
313 |
+
*
|
314 |
+
* @param string $url The package url
|
315 |
+
* @param string $body The post data fields
|
316 |
+
* @param int $timeout Execution timeout (default: 300)
|
317 |
+
*
|
318 |
+
* @return string | The temp filename
|
319 |
+
*
|
320 |
+
* @since 1.0
|
321 |
+
* @see wp-admin/includes/class-wp-upgrader.php
|
322 |
+
* @access protected
|
323 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
324 |
+
*/
|
325 |
+
protected function _download_url( $url, $body, $timeout = 300 ) {
|
326 |
+
|
327 |
+
//WARNING: The file is not automatically deleted, The script must unlink() the file.
|
328 |
+
if ( ! $url ) {
|
329 |
+
return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.', 'yit' ) );
|
330 |
+
}
|
331 |
+
|
332 |
+
$tmpfname = wp_tempnam( $url );
|
333 |
+
|
334 |
+
$args = array(
|
335 |
+
'timeout' => $timeout,
|
336 |
+
'stream' => true,
|
337 |
+
'filename' => $tmpfname,
|
338 |
+
'body' => $body
|
339 |
+
);
|
340 |
+
|
341 |
+
if ( ! $tmpfname ) {
|
342 |
+
return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.', 'yit' ) );
|
343 |
+
}
|
344 |
+
|
345 |
+
$response = wp_safe_remote_post( $url, $args );
|
346 |
+
|
347 |
+
if ( is_wp_error( $response ) ) {
|
348 |
+
unlink( $tmpfname );
|
349 |
+
|
350 |
+
return $response;
|
351 |
+
}
|
352 |
+
|
353 |
+
if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
|
354 |
+
unlink( $tmpfname );
|
355 |
+
|
356 |
+
return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
|
357 |
+
}
|
358 |
+
|
359 |
+
$content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
|
360 |
+
|
361 |
+
if ( $content_md5 ) {
|
362 |
+
$md5_check = verify_file_md5( $tmpfname, $content_md5 );
|
363 |
+
if ( is_wp_error( $md5_check ) ) {
|
364 |
+
unlink( $tmpfname );
|
365 |
+
|
366 |
+
return $md5_check;
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
return $tmpfname;
|
371 |
+
}
|
372 |
+
|
373 |
+
/**
|
374 |
+
* Main plugin Instance
|
375 |
+
*
|
376 |
+
* @static
|
377 |
+
* @return object Main instance
|
378 |
+
*
|
379 |
+
* @since 1.0
|
380 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
381 |
+
*/
|
382 |
+
public static function instance() {
|
383 |
+
if ( is_null( self::$_instance ) ) {
|
384 |
+
self::$_instance = new self();
|
385 |
+
}
|
386 |
+
|
387 |
+
return self::$_instance;
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Delete the update plugins transient
|
392 |
+
*
|
393 |
+
* @return void
|
394 |
+
*
|
395 |
+
* @since 1.0
|
396 |
+
* @see update_plugins transient and pre_set_site_transient_update_plugins hooks
|
397 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
398 |
+
*/
|
399 |
+
public function force_regenerate_update_transient() {
|
400 |
+
delete_site_transient( 'update_plugins' );
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Check for plugins update
|
405 |
+
*
|
406 |
+
* If a new plugin version is available set it in the pre_set_site_transient_update_plugins hooks
|
407 |
+
*
|
408 |
+
* @param mixed $transient | update_plugins transient value
|
409 |
+
* @param bool $save | Default: false. Set true to regenerate the update_transient plugins
|
410 |
+
*
|
411 |
+
* @return mixed $transient | The new update_plugins transient value
|
412 |
+
*
|
413 |
+
* @since 1.0
|
414 |
+
* @see update_plugins transient and pre_set_site_transient_update_plugins hooks
|
415 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
416 |
+
*/
|
417 |
+
public function check_update( $transient, $save = false ) {
|
418 |
+
|
419 |
+
foreach ( $this->_plugins as $init => $plugin ) {
|
420 |
+
$plugin_slug = $this->_plugins[ $init ]['slug'];
|
421 |
+
$xml = $this->get_remote_url( $plugin );
|
422 |
+
$remote_xml = wp_remote_get( $xml );
|
423 |
+
|
424 |
+
if ( ! is_wp_error( $remote_xml ) && isset( $remote_xml['response']['code'] ) && '200' == $remote_xml['response']['code'] ) {
|
425 |
+
|
426 |
+
$plugin_remote_info = @simplexml_load_string( $remote_xml['body'] );
|
427 |
+
|
428 |
+
if ( $plugin_remote_info ) {
|
429 |
+
|
430 |
+
if ( version_compare( $plugin_remote_info->latest, $plugin['info']['Version'], '>' ) && ! isset( $transient->response[ $init ] ) ) {
|
431 |
+
|
432 |
+
$package = YIT_Plugin_Licence()->check( $init ) ? $this->_package_url : null;
|
433 |
+
|
434 |
+
$obj = new stdClass();
|
435 |
+
$obj->slug = (string) $init;
|
436 |
+
$obj->new_version = (string) $plugin_remote_info->latest;
|
437 |
+
$obj->changelog = (string) $plugin_remote_info->changelog;
|
438 |
+
$obj->package = $package;
|
439 |
+
$obj->plugin = $init;
|
440 |
+
$transient->response[ $init ] = $obj;
|
441 |
+
}
|
442 |
+
|
443 |
+
} else {
|
444 |
+
error_log( sprintf( 'SimpleXML error in %s:%s [plugin slug: %s]',
|
445 |
+
__FILE__, __FUNCTION__, $plugin_slug ) );
|
446 |
+
|
447 |
+
return $transient;
|
448 |
+
}
|
449 |
+
}
|
450 |
+
}
|
451 |
+
|
452 |
+
if ( $save ) {
|
453 |
+
set_site_transient( 'update_plugins', $transient );
|
454 |
+
}
|
455 |
+
|
456 |
+
return $transient;
|
457 |
+
}
|
458 |
+
|
459 |
+
/**
|
460 |
+
* Add the plugin update row in plugin page
|
461 |
+
*
|
462 |
+
* @return void
|
463 |
+
* @fire "in_theme_update_message-{$init}" action
|
464 |
+
*
|
465 |
+
* @since 1.0
|
466 |
+
* @see after_plugin_row_{$init} action
|
467 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
468 |
+
*/
|
469 |
+
public function plugin_update_row() {
|
470 |
+
|
471 |
+
$current = get_site_transient( 'update_plugins' );
|
472 |
+
$init = str_replace( 'after_plugin_row_', '', current_filter() );
|
473 |
+
|
474 |
+
if ( ! isset( $current->response[ $init ] ) ) {
|
475 |
+
return false;
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* stdClass Object
|
480 |
+
*/
|
481 |
+
$r = $current->response[ $init ];
|
482 |
+
|
483 |
+
$changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
|
484 |
+
$details_url = self_admin_url( 'plugin-install.php?tab=plugin-information&plugin=' . $init . '§ion=changelog&TB_iframe=true&width=640&height=662' );
|
485 |
+
|
486 |
+
/**
|
487 |
+
* @see wp_plugin_update_rows() in wp-single\wp-admin\includes\update.php
|
488 |
+
*/
|
489 |
+
$wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
|
490 |
+
|
491 |
+
if ( is_network_admin() || ! is_multisite() || true ) {
|
492 |
+
global $wp_version;
|
493 |
+
$is_wp_4_6 = version_compare( $wp_version, '4.6', '>=' );
|
494 |
+
|
495 |
+
echo '<tr class="plugin-update-tr' . ( is_plugin_active( $init ) ? ' active' : '' ) . '"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange">';
|
496 |
+
|
497 |
+
echo '<div class="update-message' . ( $is_wp_4_6 ? ' notice inline notice-warning notice-alt' : '' ) . '">';
|
498 |
+
|
499 |
+
echo( $is_wp_4_6 ? '<p>' : '' );
|
500 |
+
|
501 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
502 |
+
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 );
|
503 |
+
} elseif ( is_plugin_active_for_network( $init ) ) {
|
504 |
+
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 );
|
505 |
+
} elseif ( empty( $r->package ) ) {
|
506 |
+
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'] );
|
507 |
+
} else {
|
508 |
+
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">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 ) );
|
509 |
+
}
|
510 |
+
|
511 |
+
echo( $is_wp_4_6 ? '</p>' : '' );
|
512 |
+
|
513 |
+
/**
|
514 |
+
* Fires at the end of the update message container in each
|
515 |
+
* row of the themes list table.
|
516 |
+
*
|
517 |
+
* The dynamic portion of the hook name, `$theme_key`, refers to
|
518 |
+
* the theme slug as found in the WordPress.org themes repository.
|
519 |
+
*
|
520 |
+
* @since Wordpress 3.1.0
|
521 |
+
* }
|
522 |
+
*/
|
523 |
+
do_action( "in_theme_update_message-{$init}", $this->_plugins[ $init ], $r->changelog, $changelog_id );
|
524 |
+
|
525 |
+
echo '</div></td></tr>';
|
526 |
+
}
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* Remove the standard plugin_update_row
|
531 |
+
*
|
532 |
+
* Remove the standard plugin_update_row and Add a custom plugin update row in plugin page.
|
533 |
+
*
|
534 |
+
* @return void
|
535 |
+
* @fire "in_theme_update_message-{$init}" action
|
536 |
+
*
|
537 |
+
* @since 1.0
|
538 |
+
* @see after_plugin_row_{$init} action
|
539 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
540 |
+
*/
|
541 |
+
public function remove_wp_plugin_update_row() {
|
542 |
+
foreach ( $this->_plugins as $init => $plugin ) {
|
543 |
+
remove_action( "after_plugin_row_{$init}", 'wp_plugin_update_row', 10 );
|
544 |
+
add_action( "after_plugin_row_{$init}", array( $this, 'plugin_update_row' ) );
|
545 |
+
//add_action( "in_theme_update_message-{$init}", array( $this, 'in_theme_update_message' ), 10, 3 );
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
public function in_theme_update_message( $plugin, $changelog, $changelog_id, $echo = true ) {
|
550 |
+
$res = "<div id='{$changelog_id}' class='yit-plugin-changelog-wrapper'>
|
551 |
<div class='yit-plugin-changelog'>
|
552 |
<h2 class='yit-plugin-changelog-title'>{$plugin['info']['Name']} - Changelog</h2>
|
553 |
<p>{$changelog}</p>
|
554 |
</div>
|
555 |
</div>";
|
556 |
|
557 |
+
if ( $echo ) {
|
558 |
+
echo $res;
|
559 |
+
} else {
|
560 |
+
return $res;
|
561 |
+
}
|
562 |
+
}
|
563 |
+
|
564 |
+
/**
|
565 |
+
* Auto-Update Plugin in multisite
|
566 |
+
*
|
567 |
+
* Manage the non standard upgrade-plugin-multisite action
|
568 |
+
*
|
569 |
+
* @return void
|
570 |
+
*
|
571 |
+
* @since 1.0
|
572 |
+
* @see upgrade-plugin action
|
573 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
574 |
+
*/
|
575 |
+
public function upgrade_plugin_multisite() {
|
576 |
+
|
577 |
+
$plugin = isset( $_REQUEST['plugin'] ) ? trim( $_REQUEST['plugin'] ) : '';
|
578 |
+
$action = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : '';
|
579 |
+
|
580 |
+
if ( 'upgrade-plugin-multisite' != $action ) {
|
581 |
+
wp_die( __( 'You can\'t update the plugins for this site.', 'yith-plugin-fw' ) );
|
582 |
+
}
|
583 |
+
|
584 |
+
if ( ! current_user_can( 'update_plugins' ) ) {
|
585 |
+
wp_die( __( 'You do not have sufficient permissions to update the plugins for this site.', 'yith-plugin-fw' ) );
|
586 |
+
}
|
587 |
+
|
588 |
+
$this->check_update( get_site_transient( 'update_plugins' ), true );
|
589 |
+
|
590 |
+
check_admin_referer( 'upgrade-plugin-multisite_' . $plugin );
|
591 |
+
|
592 |
+
$title = __( 'Update Plugin', 'yith-plugin-fw' );
|
593 |
+
$parent_file = 'plugins.php';
|
594 |
+
$submenu_file = 'plugins.php';
|
595 |
+
|
596 |
+
wp_enqueue_script( 'updates' );
|
597 |
+
require_once( ABSPATH . 'wp-admin/admin-header.php' );
|
598 |
+
|
599 |
+
$nonce = 'upgrade-plugin-multisite_' . $plugin;
|
600 |
+
$url = 'update.php?action=upgrade-plugin-multisite&plugin=' . urlencode( $plugin );
|
601 |
+
|
602 |
+
$upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
|
603 |
+
$upgrader->upgrade( $plugin );
|
604 |
+
|
605 |
+
include( ABSPATH . 'wp-admin/admin-footer.php' );
|
606 |
+
}
|
607 |
+
|
608 |
+
/**
|
609 |
+
* Retreive the remote url with query string args
|
610 |
+
*
|
611 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
612 |
+
* @return string the remote url
|
613 |
+
*/
|
614 |
+
public function get_remote_url( $plugin_info ) {
|
615 |
+
|
616 |
+
$license = $is_membership_license = false;
|
617 |
+
$slug = isset( $plugin_info['slug'] ) ? $plugin_info['slug'] : false;
|
618 |
+
|
619 |
+
if( function_exists( 'YIT_Plugin_Licence' ) && false !== $slug ){
|
620 |
+
//Get license for YITH Plugins
|
621 |
+
$enabled_license = YIT_Plugin_Licence()->get_licence();
|
622 |
+
|
623 |
+
if( isset( $enabled_license[ $slug ]['licence_key'] ) ){
|
624 |
+
$license = $enabled_license[ $slug ]['licence_key'];
|
625 |
+
}
|
626 |
+
|
627 |
+
if( isset( $enabled_license[ $slug ]['is_membership'] ) ){
|
628 |
+
$is_membership_license = $enabled_license[ $slug ]['is_membership'];
|
629 |
+
}
|
630 |
+
}
|
631 |
+
|
632 |
+
$args = array(
|
633 |
+
'plugin' => $slug,
|
634 |
+
'instance' => md5( $_SERVER['SERVER_NAME'] ),
|
635 |
+
'license' => $license,
|
636 |
+
'is_membership_license' => $is_membership_license,
|
637 |
+
'server_ip' => $_SERVER['SERVER_ADDR'],
|
638 |
+
'version' => isset( $plugin_info['info']['Version'] ) ? $plugin_info['info']['Version'] : '1.0.0'
|
639 |
+
);
|
640 |
+
|
641 |
+
$args = apply_filters( 'yith_get_remove_url_args', $args );
|
642 |
+
|
643 |
+
$url = add_query_arg( $args, $this->_remote_url );
|
644 |
+
|
645 |
+
return $url;
|
646 |
+
}
|
647 |
+
}
|
648 |
}
|
649 |
|
650 |
+
if ( ! function_exists( 'YIT_Upgrade' ) ) {
|
651 |
+
/**
|
652 |
+
* Main instance of plugin
|
653 |
+
*
|
654 |
+
* @return YIT_Upgrade
|
655 |
+
* @since 1.0
|
656 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
657 |
+
*/
|
658 |
+
function YIT_Upgrade() {
|
659 |
+
return YIT_Upgrade::instance();
|
660 |
+
}
|
661 |
}
|
662 |
|
663 |
/**
|
plugin-fw/yit-functions.php
CHANGED
@@ -282,7 +282,7 @@ if ( !function_exists( 'yit_plugin_get_attachment_id' ) ) {
|
|
282 |
continue;
|
283 |
}
|
284 |
|
285 |
-
foreach ( (array)$meta[ 'sizes' ] as $size => $values ) {
|
286 |
if ( $values[ 'file' ] == $file && $url == str_replace( 'https://', 'http://', array_shift( wp_get_attachment_image_src( $id, $size ) ) ) ) {
|
287 |
|
288 |
return $id;
|
@@ -484,7 +484,7 @@ if ( !function_exists( 'yit_registered_sidebars' ) ) {
|
|
484 |
$return = array( '' => '' );
|
485 |
}
|
486 |
|
487 |
-
foreach ( ( array )$wp_registered_sidebars as $the_ ) {
|
488 |
$return[ $the_[ 'name' ] ] = $the_[ 'name' ];
|
489 |
}
|
490 |
|
@@ -1140,15 +1140,24 @@ if ( !function_exists( 'yith_plugin_fw_get_version' ) ) {
|
|
1140 |
}
|
1141 |
}
|
1142 |
|
1143 |
-
if ( !
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
continue;
|
283 |
}
|
284 |
|
285 |
+
foreach ( (array) $meta[ 'sizes' ] as $size => $values ) {
|
286 |
if ( $values[ 'file' ] == $file && $url == str_replace( 'https://', 'http://', array_shift( wp_get_attachment_image_src( $id, $size ) ) ) ) {
|
287 |
|
288 |
return $id;
|
484 |
$return = array( '' => '' );
|
485 |
}
|
486 |
|
487 |
+
foreach ( ( array ) $wp_registered_sidebars as $the_ ) {
|
488 |
$return[ $the_[ 'name' ] ] = $the_[ 'name' ];
|
489 |
}
|
490 |
|
1140 |
}
|
1141 |
}
|
1142 |
|
1143 |
+
if ( !function_exists( 'yith_get_premium_support_url' ) ) {
|
1144 |
+
//@TODO: To Remove
|
1145 |
+
/**
|
1146 |
+
* Return the url for My Account > Support dashboard
|
1147 |
+
*
|
1148 |
+
* @return string The complete string, if the main string is not empty or null
|
1149 |
+
* @since 2.0.0
|
1150 |
+
*/
|
1151 |
+
function yith_get_premium_support_url() {
|
1152 |
+
return 'https://yithemes.com/my-account/support/dashboard/';
|
1153 |
+
}
|
1154 |
}
|
1155 |
+
|
1156 |
+
if ( !function_exists( 'yith_plugin_fw_is_panel' ) ) {
|
1157 |
+
function yith_plugin_fw_is_panel() {
|
1158 |
+
$panel_screen_id = 'yith-plugins_page';
|
1159 |
+
$screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
|
1160 |
+
|
1161 |
+
return $screen instanceof WP_Screen && strpos( $screen->id, $panel_screen_id ) !== false;
|
1162 |
+
}
|
1163 |
+
}
|