Version Description
- [Enhancement] Add trial plans
Download this release
Release Info
Developer | GreenTreeLabs |
Plugin | Image Photo Gallery Final Tiles Grid |
Version | 3.3.32 |
Comparing to | |
See all releases |
Code changes from version 3.3.30 to 3.3.32
- FinalTilesGalleryLite.php +17 -10
- admin/include/edit-gallery.php +4 -28
- admin/include/fields.php +18 -0
- admin/include/image-list.php +4 -1
- admin/scripts/final-tiles-gallery-admin.js +3 -1
- freemius/LICENSE.txt +620 -286
- freemius/README.md +1 -1
- freemius/assets/css/admin/account.css +1 -1
- freemius/assets/css/admin/affiliation.css +1 -0
- freemius/assets/css/admin/common.css +2 -2
- freemius/assets/css/admin/connect.css +1 -1
- freemius/assets/css/admin/index.php +3 -0
- freemius/assets/css/customizer.css +1 -0
- freemius/assets/css/index.php +3 -0
- freemius/assets/img/index.php +3 -0
- freemius/assets/img/theme-icon.png +0 -0
- freemius/assets/js/index.php +3 -0
- freemius/assets/scss/_load.scss +4 -4
- freemius/assets/scss/_mixins.scss +0 -13
- freemius/assets/scss/_start.scss +3 -3
- freemius/assets/scss/_vars.scss +5 -5
- freemius/assets/scss/admin/_themes.scss +21 -0
- freemius/assets/scss/admin/account.scss +6 -0
- freemius/assets/scss/admin/affiliation.scss +97 -0
- freemius/assets/scss/admin/common.scss +217 -172
- freemius/assets/scss/admin/connect.scss +520 -471
- freemius/assets/scss/admin/index.php +3 -0
- freemius/assets/scss/customizer.scss +125 -0
- freemius/assets/scss/index.php +3 -0
- freemius/composer.json +10 -0
- freemius/config.php +3 -2
- freemius/gulpfile.js +167 -0
- freemius/includes/class-freemius-abstract.php +2 -2
- freemius/includes/class-freemius.php +14305 -12315
- freemius/includes/class-fs-api.php +557 -557
- freemius/includes/class-fs-logger.php +1 -1
- freemius/includes/class-fs-plugin-updater.php +711 -682
- freemius/includes/class-fs-security.php +1 -1
- freemius/includes/customizer/class-fs-customizer-support-section.php +102 -0
- freemius/includes/customizer/class-fs-customizer-upsell-control.php +157 -0
- freemius/includes/customizer/index.php +3 -0
- freemius/includes/debug/class-fs-debug-bar-panel.php +6 -6
- freemius/includes/debug/debug-bar-start.php +3 -3
- freemius/includes/entities/class-fs-affiliate-terms.php +128 -0
- freemius/includes/entities/class-fs-affiliate.php +84 -0
- freemius/includes/entities/class-fs-billing.php +1 -1
- freemius/includes/entities/class-fs-entity.php +4 -4
- freemius/includes/entities/class-fs-payment.php +1 -1
- freemius/includes/entities/class-fs-plugin-info.php +1 -1
- freemius/includes/entities/class-fs-plugin-license.php +1 -1
- freemius/includes/entities/class-fs-plugin-plan.php +1 -1
- freemius/includes/entities/class-fs-plugin-tag.php +1 -1
- freemius/includes/entities/class-fs-plugin.php +24 -1
- freemius/includes/entities/class-fs-pricing.php +1 -1
- freemius/includes/entities/class-fs-scope-entity.php +1 -1
- freemius/includes/entities/class-fs-site.php +1 -1
- freemius/includes/entities/class-fs-subscription.php +1 -1
- freemius/includes/entities/class-fs-user.php +1 -1
- freemius/includes/fs-core-functions.php +505 -629
FinalTilesGalleryLite.php
CHANGED
@@ -5,13 +5,13 @@
|
|
5 |
* Plugin URI: https://www.final-tiles-gallery.com
|
6 |
* Description: Wordpress Plugin for creating responsive image galleries. By: GreenTreeLabs
|
7 |
* Author: Green Tree Labs
|
8 |
-
* Version: 3.3.
|
9 |
* Author URI: https://www.greentreelabs.net
|
10 |
*
|
11 |
* @fs_premium_only /lightbox-pro/
|
12 |
*
|
13 |
*/
|
14 |
-
define( "FTGVERSION", "3.3.
|
15 |
/*
|
16 |
Changelog:
|
17 |
3.3.30
|
@@ -262,7 +262,9 @@ Changelog:
|
|
262 |
Page with support request instructions
|
263 |
Page with instructions
|
264 |
*/
|
265 |
-
|
|
|
|
|
266 |
// Create a helper function for easy SDK access.
|
267 |
function ftg_fs()
|
268 |
{
|
@@ -277,13 +279,17 @@ if ( !function_exists( 'ftg_fs' ) ) {
|
|
277 |
'type' => 'plugin',
|
278 |
'public_key' => 'pk_d0e075b84d491d510a1d0a21087af',
|
279 |
'is_premium' => false,
|
280 |
-
'is_premium_only' => false,
|
281 |
'has_addons' => false,
|
282 |
'has_paid_plans' => true,
|
|
|
|
|
|
|
|
|
|
|
283 |
'menu' => array(
|
284 |
'slug' => 'ftg-lite-gallery-admin',
|
285 |
'contact' => false,
|
286 |
-
'support' =>
|
287 |
),
|
288 |
'is_live' => true,
|
289 |
) );
|
@@ -291,12 +297,13 @@ if ( !function_exists( 'ftg_fs' ) ) {
|
|
291 |
|
292 |
return $ftg_fs;
|
293 |
}
|
294 |
-
|
|
|
|
|
|
|
|
|
295 |
}
|
296 |
-
|
297 |
-
ftg_fs();
|
298 |
-
// Signal that SDK was initiated.
|
299 |
-
do_action( 'ftg_fs_loaded' );
|
300 |
define( "FTG_PLAN", "free" );
|
301 |
if ( !class_exists( 'FinalTiles_Gallery' ) ) {
|
302 |
class FinalTiles_Gallery
|
5 |
* Plugin URI: https://www.final-tiles-gallery.com
|
6 |
* Description: Wordpress Plugin for creating responsive image galleries. By: GreenTreeLabs
|
7 |
* Author: Green Tree Labs
|
8 |
+
* Version: 3.3.32
|
9 |
* Author URI: https://www.greentreelabs.net
|
10 |
*
|
11 |
* @fs_premium_only /lightbox-pro/
|
12 |
*
|
13 |
*/
|
14 |
+
define( "FTGVERSION", "3.3.32" );
|
15 |
/*
|
16 |
Changelog:
|
17 |
3.3.30
|
262 |
Page with support request instructions
|
263 |
Page with instructions
|
264 |
*/
|
265 |
+
// Create a helper function for easy SDK access.
|
266 |
+
|
267 |
+
if ( !function_exists( "ftg_fs" ) ) {
|
268 |
// Create a helper function for easy SDK access.
|
269 |
function ftg_fs()
|
270 |
{
|
279 |
'type' => 'plugin',
|
280 |
'public_key' => 'pk_d0e075b84d491d510a1d0a21087af',
|
281 |
'is_premium' => false,
|
|
|
282 |
'has_addons' => false,
|
283 |
'has_paid_plans' => true,
|
284 |
+
'trial' => array(
|
285 |
+
'days' => 14,
|
286 |
+
'is_require_payment' => false,
|
287 |
+
),
|
288 |
+
'has_affiliation' => 'all',
|
289 |
'menu' => array(
|
290 |
'slug' => 'ftg-lite-gallery-admin',
|
291 |
'contact' => false,
|
292 |
+
'support' => false,
|
293 |
),
|
294 |
'is_live' => true,
|
295 |
) );
|
297 |
|
298 |
return $ftg_fs;
|
299 |
}
|
300 |
+
|
301 |
+
// Init Freemius.
|
302 |
+
ftg_fs();
|
303 |
+
// Signal that SDK was initiated.
|
304 |
+
do_action( 'ftg_fs_loaded' );
|
305 |
}
|
306 |
+
|
|
|
|
|
|
|
307 |
define( "FTG_PLAN", "free" );
|
308 |
if ( !class_exists( 'FinalTiles_Gallery' ) ) {
|
309 |
class FinalTiles_Gallery
|
admin/include/edit-gallery.php
CHANGED
@@ -84,7 +84,7 @@ if ( !function_exists( 'ftg_p' ) ) {
|
|
84 |
|
85 |
global $ftg_parent_page ;
|
86 |
global $ftg_fields ;
|
87 |
-
$filters =
|
88 |
//print_r($gallery);
|
89 |
$idx = 0;
|
90 |
function ftgSortByName( $a, $b )
|
@@ -1179,33 +1179,9 @@ ftg_p( $gallery, "wp_field_caption" );
|
|
1179 |
alert("Cannot set this effect if 'Caption full height' is switched off.");
|
1180 |
}
|
1181 |
});
|
1182 |
-
|
1183 |
-
var post_types = $("[name=ftg_post_types]").val().split(',');
|
1184 |
-
$.each(post_types, function () {
|
1185 |
-
if(this.length && $("[name=post_types][value="+ this +"]").length)
|
1186 |
-
$("[name=post_types][value="+ this +"]").get(0).checked = true;
|
1187 |
-
});
|
1188 |
-
|
1189 |
-
var post_taxonomy = $("[name=ftg_post_taxonomies]").val().split(',');
|
1190 |
-
$.each(post_taxonomy, function () {
|
1191 |
-
if(this.length) {
|
1192 |
-
var t = this.split('|');
|
1193 |
-
console.log(t[0], t[1]);
|
1194 |
-
var el = $('[data-taxonomy="' + t[0] + '"][value=\"' + t[1] + '\"]');
|
1195 |
-
if(el.length)
|
1196 |
-
el.get(0).checked = true;
|
1197 |
-
}
|
1198 |
-
});
|
1199 |
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
$.each(woo_categories, function () {
|
1204 |
-
if(this.length) {
|
1205 |
-
var el = $("[name=woo_cat][value="+ this +"]");
|
1206 |
-
if(el.length)
|
1207 |
-
el.get(0).checked = true;
|
1208 |
-
}
|
1209 |
-
});
|
1210 |
})(jQuery);
|
1211 |
</script>
|
84 |
|
85 |
global $ftg_parent_page ;
|
86 |
global $ftg_fields ;
|
87 |
+
$filters = array();
|
88 |
//print_r($gallery);
|
89 |
$idx = 0;
|
90 |
function ftgSortByName( $a, $b )
|
1179 |
alert("Cannot set this effect if 'Caption full height' is switched off.");
|
1180 |
}
|
1181 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1182 |
|
1183 |
+
<?php
|
1184 |
+
?>
|
1185 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1186 |
})(jQuery);
|
1187 |
</script>
|
admin/include/fields.php
CHANGED
@@ -329,6 +329,24 @@ $this->addField( "General", "filter", array(
|
|
329 |
"proCall" => true,
|
330 |
"excludeFrom" => array( "dashboard", "shortcode" ),
|
331 |
) );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
332 |
$this->addField( "General", "gridCellSize", array(
|
333 |
"name" => "Size of the grid",
|
334 |
"type" => "number",
|
329 |
"proCall" => true,
|
330 |
"excludeFrom" => array( "dashboard", "shortcode" ),
|
331 |
) );
|
332 |
+
|
333 |
+
if ( ftg_fs()->is_plan_or_trial( 'ultimate' ) ) {
|
334 |
+
$this->addField( "General", "filterClick", array(
|
335 |
+
"name" => "Reload Page on filter click",
|
336 |
+
"type" => "toggle",
|
337 |
+
"description" => "Turn this feature ON if you want to use filters with most lightboxes",
|
338 |
+
"proCall" => false,
|
339 |
+
"excludeFrom" => array(),
|
340 |
+
) );
|
341 |
+
$this->addField( "General", "allFilterLabel", array(
|
342 |
+
"name" => "Text for 'All' filter",
|
343 |
+
"type" => "text",
|
344 |
+
"description" => "Write here the label for the 'All' filter",
|
345 |
+
"proCall" => false,
|
346 |
+
"excludeFrom" => array(),
|
347 |
+
) );
|
348 |
+
}
|
349 |
+
|
350 |
$this->addField( "General", "gridCellSize", array(
|
351 |
"name" => "Size of the grid",
|
352 |
"type" => "number",
|
admin/include/image-list.php
CHANGED
@@ -2,13 +2,16 @@
|
|
2 |
|
3 |
if(isset($gallery))
|
4 |
{
|
5 |
-
$active_filters =
|
|
|
|
|
6 |
}
|
7 |
|
8 |
?>
|
9 |
<?php foreach($imageResults as $image) {
|
10 |
$sizes = FinalTiles_Gallery::get_image_size_links($image->imageId);
|
11 |
$thumb = "";
|
|
|
12 |
if($image->type == 'image')
|
13 |
$thumb = array_key_exists("150x150", $sizes) ? $sizes["150x150"] : $image->imagePath;
|
14 |
else
|
2 |
|
3 |
if(isset($gallery))
|
4 |
{
|
5 |
+
$active_filters = "";
|
6 |
+
if (ftg_fs()->is_plan_or_trial('ultimate'))
|
7 |
+
$active_filters = explode('|', $gallery->filters);
|
8 |
}
|
9 |
|
10 |
?>
|
11 |
<?php foreach($imageResults as $image) {
|
12 |
$sizes = FinalTiles_Gallery::get_image_size_links($image->imageId);
|
13 |
$thumb = "";
|
14 |
+
|
15 |
if($image->type == 'image')
|
16 |
$thumb = array_key_exists("150x150", $sizes) ? $sizes["150x150"] : $image->imagePath;
|
17 |
else
|
admin/scripts/final-tiles-gallery-admin.js
CHANGED
@@ -513,7 +513,9 @@ var FTG = function($) {
|
|
513 |
var $panel = $("#video-panel-model");
|
514 |
$('#video-panel-action').val('edit');
|
515 |
|
516 |
-
var filters =
|
|
|
|
|
517 |
$(".video-filters", $panel).empty();
|
518 |
for (var i = 0; i < filters.length; i++) {
|
519 |
if ($.trim(filters[i]).length > 0) {
|
513 |
var $panel = $("#video-panel-model");
|
514 |
$('#video-panel-action').val('edit');
|
515 |
|
516 |
+
var filters = "";
|
517 |
+
if($(".gallery-filters [name=ftg_filters]").val())
|
518 |
+
filters = $(".gallery-filters [name=ftg_filters]").val().split('|');
|
519 |
$(".video-filters", $panel).empty();
|
520 |
for (var i = 0; i < filters.length; i++) {
|
521 |
if ($.trim(filters[i]).length > 0) {
|
freemius/LICENSE.txt
CHANGED
@@ -1,281 +1,622 @@
|
|
1 |
-
GNU GENERAL PUBLIC LICENSE
|
2 |
-
Version
|
3 |
|
4 |
-
Copyright (C)
|
5 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
Everyone is permitted to copy and distribute verbatim copies
|
7 |
of this license document, but changing it is not allowed.
|
8 |
|
9 |
Preamble
|
10 |
|
11 |
-
The
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
19 |
your programs, too.
|
20 |
|
21 |
When we speak of free software, we are referring to freedom, not
|
22 |
price. Our General Public Licenses are designed to make sure that you
|
23 |
have the freedom to distribute copies of free software (and charge for
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
|
28 |
-
To protect your rights, we need to
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
|
33 |
For example, if you distribute copies of such a program, whether
|
34 |
-
gratis or for a fee, you must
|
35 |
-
you
|
36 |
-
source code. And you must show them these terms so they
|
37 |
-
rights.
|
38 |
-
|
39 |
-
|
40 |
-
(
|
41 |
-
distribute and/or modify
|
42 |
-
|
43 |
-
|
44 |
-
that
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
|
56 |
The precise terms and conditions for copying, distribution and
|
57 |
modification follow.
|
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 |
this License.
|
196 |
|
197 |
-
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
200 |
otherwise) that contradict the conditions of this License, they do not
|
201 |
-
excuse you from the conditions of this License. If you cannot
|
202 |
-
|
203 |
-
License and any other pertinent obligations, then as a consequence you
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
any
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
impose that choice.
|
225 |
-
|
226 |
-
This section is intended to make thoroughly clear what is believed to
|
227 |
-
be a consequence of the rest of this License.
|
228 |
-
|
229 |
-
8. If the distribution and/or use of the Program is restricted in
|
230 |
-
certain countries either by patents or by copyrighted interfaces, the
|
231 |
-
original copyright holder who places the Program under this License
|
232 |
-
may add an explicit geographical distribution limitation excluding
|
233 |
-
those countries, so that distribution is permitted only in or among
|
234 |
-
countries not thus excluded. In such case, this License incorporates
|
235 |
-
the limitation as if written in the body of this License.
|
236 |
-
|
237 |
-
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
-
of the General Public License from time to time. Such new versions will
|
239 |
be similar in spirit to the present version, but may differ in detail to
|
240 |
address new problems or concerns.
|
241 |
|
242 |
-
Each version is given a distinguishing version number. If the
|
243 |
-
specifies a version
|
244 |
-
later version", you have the
|
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 |
END OF TERMS AND CONDITIONS
|
281 |
|
@@ -287,15 +628,15 @@ free software which everyone can redistribute and change under these terms.
|
|
287 |
|
288 |
To do so, attach the following notices to the program. It is safest
|
289 |
to attach them to the start of each source file to most effectively
|
290 |
-
|
291 |
the "copyright" line and a pointer to where the full notice is found.
|
292 |
|
293 |
-
{
|
294 |
-
Copyright (C) {year} {
|
295 |
|
296 |
-
This program is free software
|
297 |
it under the terms of the GNU General Public License as published by
|
298 |
-
the Free Software Foundation
|
299 |
(at your option) any later version.
|
300 |
|
301 |
This program is distributed in the hope that it will be useful,
|
@@ -303,38 +644,31 @@ the "copyright" line and a pointer to where the full notice is found.
|
|
303 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
GNU General Public License for more details.
|
305 |
|
306 |
-
You should have received a copy of the GNU General Public License
|
307 |
-
with this program
|
308 |
-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
|
310 |
Also add information on how to contact you by electronic and paper mail.
|
311 |
|
312 |
-
If the program
|
313 |
-
when it starts in an interactive mode:
|
314 |
|
315 |
-
|
316 |
-
|
317 |
This is free software, and you are welcome to redistribute it
|
318 |
under certain conditions; type `show c' for details.
|
319 |
|
320 |
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
-
parts of the General Public License. Of course,
|
322 |
-
be
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
This General Public License does not permit incorporating your program into
|
336 |
-
proprietary programs. If your program is a subroutine library, you may
|
337 |
-
consider it more useful to permit linking proprietary applications with the
|
338 |
-
library. If this is what you want to do, use the GNU Lesser General
|
339 |
-
Public License instead of this License.
|
340 |
-
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 3, 29 June 2007
|
3 |
|
4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
|
|
5 |
Everyone is permitted to copy and distribute verbatim copies
|
6 |
of this license document, but changing it is not allowed.
|
7 |
|
8 |
Preamble
|
9 |
|
10 |
+
The GNU General Public License is a free, copyleft license for
|
11 |
+
software and other kinds of works.
|
12 |
+
|
13 |
+
The licenses for most software and other practical works are designed
|
14 |
+
to take away your freedom to share and change the works. By contrast,
|
15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
16 |
+
share and change all versions of a program--to make sure it remains free
|
17 |
+
software for all its users. We, the Free Software Foundation, use the
|
18 |
+
GNU General Public License for most of our software; it applies also to
|
19 |
+
any other work released this way by its authors. You can apply it to
|
20 |
your programs, too.
|
21 |
|
22 |
When we speak of free software, we are referring to freedom, not
|
23 |
price. Our General Public Licenses are designed to make sure that you
|
24 |
have the freedom to distribute copies of free software (and charge for
|
25 |
+
them if you wish), that you receive source code or can get it if you
|
26 |
+
want it, that you can change the software or use pieces of it in new
|
27 |
+
free programs, and that you know you can do these things.
|
28 |
|
29 |
+
To protect your rights, we need to prevent others from denying you
|
30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
31 |
+
certain responsibilities if you distribute copies of the software, or if
|
32 |
+
you modify it: responsibilities to respect the freedom of others.
|
33 |
|
34 |
For example, if you distribute copies of such a program, whether
|
35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
36 |
+
freedoms that you received. You must make sure that they, too, receive
|
37 |
+
or can get the source code. And you must show them these terms so they
|
38 |
+
know their rights.
|
39 |
+
|
40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
43 |
+
|
44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
45 |
+
that there is no warranty for this free software. For both users' and
|
46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
47 |
+
changed, so that their problems will not be attributed erroneously to
|
48 |
+
authors of previous versions.
|
49 |
+
|
50 |
+
Some devices are designed to deny users access to install or run
|
51 |
+
modified versions of the software inside them, although the manufacturer
|
52 |
+
can do so. This is fundamentally incompatible with the aim of
|
53 |
+
protecting users' freedom to change the software. The systematic
|
54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
56 |
+
have designed this version of the GPL to prohibit the practice for those
|
57 |
+
products. If such problems arise substantially in other domains, we
|
58 |
+
stand ready to extend this provision to those domains in future versions
|
59 |
+
of the GPL, as needed to protect the freedom of users.
|
60 |
+
|
61 |
+
Finally, every program is threatened constantly by software patents.
|
62 |
+
States should not allow patents to restrict development and use of
|
63 |
+
software on general-purpose computers, but in those that do, we wish to
|
64 |
+
avoid the special danger that patents applied to a free program could
|
65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
66 |
+
patents cannot be used to render the program non-free.
|
67 |
|
68 |
The precise terms and conditions for copying, distribution and
|
69 |
modification follow.
|
70 |
|
71 |
+
TERMS AND CONDITIONS
|
72 |
+
|
73 |
+
0. Definitions.
|
74 |
+
|
75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
76 |
+
|
77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
78 |
+
works, such as semiconductor masks.
|
79 |
+
|
80 |
+
"The Program" refers to any copyrightable work licensed under this
|
81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
82 |
+
"recipients" may be individuals or organizations.
|
83 |
+
|
84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
85 |
+
in a fashion requiring copyright permission, other than the making of an
|
86 |
+
exact copy. The resulting work is called a "modified version" of the
|
87 |
+
earlier work or a work "based on" the earlier work.
|
88 |
+
|
89 |
+
A "covered work" means either the unmodified Program or a work based
|
90 |
+
on the Program.
|
91 |
+
|
92 |
+
To "propagate" a work means to do anything with it that, without
|
93 |
+
permission, would make you directly or secondarily liable for
|
94 |
+
infringement under applicable copyright law, except executing it on a
|
95 |
+
computer or modifying a private copy. Propagation includes copying,
|
96 |
+
distribution (with or without modification), making available to the
|
97 |
+
public, and in some countries other activities as well.
|
98 |
+
|
99 |
+
To "convey" a work means any kind of propagation that enables other
|
100 |
+
parties to make or receive copies. Mere interaction with a user through
|
101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
102 |
+
|
103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
104 |
+
to the extent that it includes a convenient and prominently visible
|
105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
106 |
+
tells the user that there is no warranty for the work (except to the
|
107 |
+
extent that warranties are provided), that licensees may convey the
|
108 |
+
work under this License, and how to view a copy of this License. If
|
109 |
+
the interface presents a list of user commands or options, such as a
|
110 |
+
menu, a prominent item in the list meets this criterion.
|
111 |
+
|
112 |
+
1. Source Code.
|
113 |
+
|
114 |
+
The "source code" for a work means the preferred form of the work
|
115 |
+
for making modifications to it. "Object code" means any non-source
|
116 |
+
form of a work.
|
117 |
+
|
118 |
+
A "Standard Interface" means an interface that either is an official
|
119 |
+
standard defined by a recognized standards body, or, in the case of
|
120 |
+
interfaces specified for a particular programming language, one that
|
121 |
+
is widely used among developers working in that language.
|
122 |
+
|
123 |
+
The "System Libraries" of an executable work include anything, other
|
124 |
+
than the work as a whole, that (a) is included in the normal form of
|
125 |
+
packaging a Major Component, but which is not part of that Major
|
126 |
+
Component, and (b) serves only to enable use of the work with that
|
127 |
+
Major Component, or to implement a Standard Interface for which an
|
128 |
+
implementation is available to the public in source code form. A
|
129 |
+
"Major Component", in this context, means a major essential component
|
130 |
+
(kernel, window system, and so on) of the specific operating system
|
131 |
+
(if any) on which the executable work runs, or a compiler used to
|
132 |
+
produce the work, or an object code interpreter used to run it.
|
133 |
+
|
134 |
+
The "Corresponding Source" for a work in object code form means all
|
135 |
+
the source code needed to generate, install, and (for an executable
|
136 |
+
work) run the object code and to modify the work, including scripts to
|
137 |
+
control those activities. However, it does not include the work's
|
138 |
+
System Libraries, or general-purpose tools or generally available free
|
139 |
+
programs which are used unmodified in performing those activities but
|
140 |
+
which are not part of the work. For example, Corresponding Source
|
141 |
+
includes interface definition files associated with source files for
|
142 |
+
the work, and the source code for shared libraries and dynamically
|
143 |
+
linked subprograms that the work is specifically designed to require,
|
144 |
+
such as by intimate data communication or control flow between those
|
145 |
+
subprograms and other parts of the work.
|
146 |
+
|
147 |
+
The Corresponding Source need not include anything that users
|
148 |
+
can regenerate automatically from other parts of the Corresponding
|
149 |
+
Source.
|
150 |
+
|
151 |
+
The Corresponding Source for a work in source code form is that
|
152 |
+
same work.
|
153 |
+
|
154 |
+
2. Basic Permissions.
|
155 |
+
|
156 |
+
All rights granted under this License are granted for the term of
|
157 |
+
copyright on the Program, and are irrevocable provided the stated
|
158 |
+
conditions are met. This License explicitly affirms your unlimited
|
159 |
+
permission to run the unmodified Program. The output from running a
|
160 |
+
covered work is covered by this License only if the output, given its
|
161 |
+
content, constitutes a covered work. This License acknowledges your
|
162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
163 |
+
|
164 |
+
You may make, run and propagate covered works that you do not
|
165 |
+
convey, without conditions so long as your license otherwise remains
|
166 |
+
in force. You may convey covered works to others for the sole purpose
|
167 |
+
of having them make modifications exclusively for you, or provide you
|
168 |
+
with facilities for running those works, provided that you comply with
|
169 |
+
the terms of this License in conveying all material for which you do
|
170 |
+
not control copyright. Those thus making or running the covered works
|
171 |
+
for you must do so exclusively on your behalf, under your direction
|
172 |
+
and control, on terms that prohibit them from making any copies of
|
173 |
+
your copyrighted material outside their relationship with you.
|
174 |
+
|
175 |
+
Conveying under any other circumstances is permitted solely under
|
176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
177 |
+
makes it unnecessary.
|
178 |
+
|
179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
180 |
+
|
181 |
+
No covered work shall be deemed part of an effective technological
|
182 |
+
measure under any applicable law fulfilling obligations under article
|
183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
184 |
+
similar laws prohibiting or restricting circumvention of such
|
185 |
+
measures.
|
186 |
+
|
187 |
+
When you convey a covered work, you waive any legal power to forbid
|
188 |
+
circumvention of technological measures to the extent such circumvention
|
189 |
+
is effected by exercising rights under this License with respect to
|
190 |
+
the covered work, and you disclaim any intention to limit operation or
|
191 |
+
modification of the work as a means of enforcing, against the work's
|
192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
193 |
+
technological measures.
|
194 |
+
|
195 |
+
4. Conveying Verbatim Copies.
|
196 |
+
|
197 |
+
You may convey verbatim copies of the Program's source code as you
|
198 |
+
receive it, in any medium, provided that you conspicuously and
|
199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
200 |
+
keep intact all notices stating that this License and any
|
201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
202 |
+
keep intact all notices of the absence of any warranty; and give all
|
203 |
+
recipients a copy of this License along with the Program.
|
204 |
+
|
205 |
+
You may charge any price or no price for each copy that you convey,
|
206 |
+
and you may offer support or warranty protection for a fee.
|
207 |
+
|
208 |
+
5. Conveying Modified Source Versions.
|
209 |
+
|
210 |
+
You may convey a work based on the Program, or the modifications to
|
211 |
+
produce it from the Program, in the form of source code under the
|
212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
213 |
+
|
214 |
+
a) The work must carry prominent notices stating that you modified
|
215 |
+
it, and giving a relevant date.
|
216 |
+
|
217 |
+
b) The work must carry prominent notices stating that it is
|
218 |
+
released under this License and any conditions added under section
|
219 |
+
7. This requirement modifies the requirement in section 4 to
|
220 |
+
"keep intact all notices".
|
221 |
+
|
222 |
+
c) You must license the entire work, as a whole, under this
|
223 |
+
License to anyone who comes into possession of a copy. This
|
224 |
+
License will therefore apply, along with any applicable section 7
|
225 |
+
additional terms, to the whole of the work, and all its parts,
|
226 |
+
regardless of how they are packaged. This License gives no
|
227 |
+
permission to license the work in any other way, but it does not
|
228 |
+
invalidate such permission if you have separately received it.
|
229 |
+
|
230 |
+
d) If the work has interactive user interfaces, each must display
|
231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
233 |
+
work need not make them do so.
|
234 |
+
|
235 |
+
A compilation of a covered work with other separate and independent
|
236 |
+
works, which are not by their nature extensions of the covered work,
|
237 |
+
and which are not combined with it such as to form a larger program,
|
238 |
+
in or on a volume of a storage or distribution medium, is called an
|
239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
240 |
+
used to limit the access or legal rights of the compilation's users
|
241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
242 |
+
in an aggregate does not cause this License to apply to the other
|
243 |
+
parts of the aggregate.
|
244 |
+
|
245 |
+
6. Conveying Non-Source Forms.
|
246 |
+
|
247 |
+
You may convey a covered work in object code form under the terms
|
248 |
+
of sections 4 and 5, provided that you also convey the
|
249 |
+
machine-readable Corresponding Source under the terms of this License,
|
250 |
+
in one of these ways:
|
251 |
+
|
252 |
+
a) Convey the object code in, or embodied in, a physical product
|
253 |
+
(including a physical distribution medium), accompanied by the
|
254 |
+
Corresponding Source fixed on a durable physical medium
|
255 |
+
customarily used for software interchange.
|
256 |
+
|
257 |
+
b) Convey the object code in, or embodied in, a physical product
|
258 |
+
(including a physical distribution medium), accompanied by a
|
259 |
+
written offer, valid for at least three years and valid for as
|
260 |
+
long as you offer spare parts or customer support for that product
|
261 |
+
model, to give anyone who possesses the object code either (1) a
|
262 |
+
copy of the Corresponding Source for all the software in the
|
263 |
+
product that is covered by this License, on a durable physical
|
264 |
+
medium customarily used for software interchange, for a price no
|
265 |
+
more than your reasonable cost of physically performing this
|
266 |
+
conveying of source, or (2) access to copy the
|
267 |
+
Corresponding Source from a network server at no charge.
|
268 |
+
|
269 |
+
c) Convey individual copies of the object code with a copy of the
|
270 |
+
written offer to provide the Corresponding Source. This
|
271 |
+
alternative is allowed only occasionally and noncommercially, and
|
272 |
+
only if you received the object code with such an offer, in accord
|
273 |
+
with subsection 6b.
|
274 |
+
|
275 |
+
d) Convey the object code by offering access from a designated
|
276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
277 |
+
Corresponding Source in the same way through the same place at no
|
278 |
+
further charge. You need not require recipients to copy the
|
279 |
+
Corresponding Source along with the object code. If the place to
|
280 |
+
copy the object code is a network server, the Corresponding Source
|
281 |
+
may be on a different server (operated by you or a third party)
|
282 |
+
that supports equivalent copying facilities, provided you maintain
|
283 |
+
clear directions next to the object code saying where to find the
|
284 |
+
Corresponding Source. Regardless of what server hosts the
|
285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
286 |
+
available for as long as needed to satisfy these requirements.
|
287 |
+
|
288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
289 |
+
you inform other peers where the object code and Corresponding
|
290 |
+
Source of the work are being offered to the general public at no
|
291 |
+
charge under subsection 6d.
|
292 |
+
|
293 |
+
A separable portion of the object code, whose source code is excluded
|
294 |
+
from the Corresponding Source as a System Library, need not be
|
295 |
+
included in conveying the object code work.
|
296 |
+
|
297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
298 |
+
tangible personal property which is normally used for personal, family,
|
299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
302 |
+
product received by a particular user, "normally used" refers to a
|
303 |
+
typical or common use of that class of product, regardless of the status
|
304 |
+
of the particular user or of the way in which the particular user
|
305 |
+
actually uses, or expects or is expected to use, the product. A product
|
306 |
+
is a consumer product regardless of whether the product has substantial
|
307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
308 |
+
the only significant mode of use of the product.
|
309 |
+
|
310 |
+
"Installation Information" for a User Product means any methods,
|
311 |
+
procedures, authorization keys, or other information required to install
|
312 |
+
and execute modified versions of a covered work in that User Product from
|
313 |
+
a modified version of its Corresponding Source. The information must
|
314 |
+
suffice to ensure that the continued functioning of the modified object
|
315 |
+
code is in no case prevented or interfered with solely because
|
316 |
+
modification has been made.
|
317 |
+
|
318 |
+
If you convey an object code work under this section in, or with, or
|
319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
320 |
+
part of a transaction in which the right of possession and use of the
|
321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
322 |
+
fixed term (regardless of how the transaction is characterized), the
|
323 |
+
Corresponding Source conveyed under this section must be accompanied
|
324 |
+
by the Installation Information. But this requirement does not apply
|
325 |
+
if neither you nor any third party retains the ability to install
|
326 |
+
modified object code on the User Product (for example, the work has
|
327 |
+
been installed in ROM).
|
328 |
+
|
329 |
+
The requirement to provide Installation Information does not include a
|
330 |
+
requirement to continue to provide support service, warranty, or updates
|
331 |
+
for a work that has been modified or installed by the recipient, or for
|
332 |
+
the User Product in which it has been modified or installed. Access to a
|
333 |
+
network may be denied when the modification itself materially and
|
334 |
+
adversely affects the operation of the network or violates the rules and
|
335 |
+
protocols for communication across the network.
|
336 |
+
|
337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
338 |
+
in accord with this section must be in a format that is publicly
|
339 |
+
documented (and with an implementation available to the public in
|
340 |
+
source code form), and must require no special password or key for
|
341 |
+
unpacking, reading or copying.
|
342 |
+
|
343 |
+
7. Additional Terms.
|
344 |
+
|
345 |
+
"Additional permissions" are terms that supplement the terms of this
|
346 |
+
License by making exceptions from one or more of its conditions.
|
347 |
+
Additional permissions that are applicable to the entire Program shall
|
348 |
+
be treated as though they were included in this License, to the extent
|
349 |
+
that they are valid under applicable law. If additional permissions
|
350 |
+
apply only to part of the Program, that part may be used separately
|
351 |
+
under those permissions, but the entire Program remains governed by
|
352 |
+
this License without regard to the additional permissions.
|
353 |
+
|
354 |
+
When you convey a copy of a covered work, you may at your option
|
355 |
+
remove any additional permissions from that copy, or from any part of
|
356 |
+
it. (Additional permissions may be written to require their own
|
357 |
+
removal in certain cases when you modify the work.) You may place
|
358 |
+
additional permissions on material, added by you to a covered work,
|
359 |
+
for which you have or can give appropriate copyright permission.
|
360 |
+
|
361 |
+
Notwithstanding any other provision of this License, for material you
|
362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
363 |
+
that material) supplement the terms of this License with terms:
|
364 |
+
|
365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
366 |
+
terms of sections 15 and 16 of this License; or
|
367 |
+
|
368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
369 |
+
author attributions in that material or in the Appropriate Legal
|
370 |
+
Notices displayed by works containing it; or
|
371 |
+
|
372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
373 |
+
requiring that modified versions of such material be marked in
|
374 |
+
reasonable ways as different from the original version; or
|
375 |
+
|
376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
377 |
+
authors of the material; or
|
378 |
+
|
379 |
+
e) Declining to grant rights under trademark law for use of some
|
380 |
+
trade names, trademarks, or service marks; or
|
381 |
+
|
382 |
+
f) Requiring indemnification of licensors and authors of that
|
383 |
+
material by anyone who conveys the material (or modified versions of
|
384 |
+
it) with contractual assumptions of liability to the recipient, for
|
385 |
+
any liability that these contractual assumptions directly impose on
|
386 |
+
those licensors and authors.
|
387 |
+
|
388 |
+
All other non-permissive additional terms are considered "further
|
389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
390 |
+
received it, or any part of it, contains a notice stating that it is
|
391 |
+
governed by this License along with a term that is a further
|
392 |
+
restriction, you may remove that term. If a license document contains
|
393 |
+
a further restriction but permits relicensing or conveying under this
|
394 |
+
License, you may add to a covered work material governed by the terms
|
395 |
+
of that license document, provided that the further restriction does
|
396 |
+
not survive such relicensing or conveying.
|
397 |
+
|
398 |
+
If you add terms to a covered work in accord with this section, you
|
399 |
+
must place, in the relevant source files, a statement of the
|
400 |
+
additional terms that apply to those files, or a notice indicating
|
401 |
+
where to find the applicable terms.
|
402 |
+
|
403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
404 |
+
form of a separately written license, or stated as exceptions;
|
405 |
+
the above requirements apply either way.
|
406 |
+
|
407 |
+
8. Termination.
|
408 |
+
|
409 |
+
You may not propagate or modify a covered work except as expressly
|
410 |
+
provided under this License. Any attempt otherwise to propagate or
|
411 |
+
modify it is void, and will automatically terminate your rights under
|
412 |
+
this License (including any patent licenses granted under the third
|
413 |
+
paragraph of section 11).
|
414 |
+
|
415 |
+
However, if you cease all violation of this License, then your
|
416 |
+
license from a particular copyright holder is reinstated (a)
|
417 |
+
provisionally, unless and until the copyright holder explicitly and
|
418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
419 |
+
holder fails to notify you of the violation by some reasonable means
|
420 |
+
prior to 60 days after the cessation.
|
421 |
+
|
422 |
+
Moreover, your license from a particular copyright holder is
|
423 |
+
reinstated permanently if the copyright holder notifies you of the
|
424 |
+
violation by some reasonable means, this is the first time you have
|
425 |
+
received notice of violation of this License (for any work) from that
|
426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
427 |
+
your receipt of the notice.
|
428 |
+
|
429 |
+
Termination of your rights under this section does not terminate the
|
430 |
+
licenses of parties who have received copies or rights from you under
|
431 |
+
this License. If your rights have been terminated and not permanently
|
432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
433 |
+
material under section 10.
|
434 |
+
|
435 |
+
9. Acceptance Not Required for Having Copies.
|
436 |
+
|
437 |
+
You are not required to accept this License in order to receive or
|
438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
440 |
+
to receive a copy likewise does not require acceptance. However,
|
441 |
+
nothing other than this License grants you permission to propagate or
|
442 |
+
modify any covered work. These actions infringe copyright if you do
|
443 |
+
not accept this License. Therefore, by modifying or propagating a
|
444 |
+
covered work, you indicate your acceptance of this License to do so.
|
445 |
+
|
446 |
+
10. Automatic Licensing of Downstream Recipients.
|
447 |
+
|
448 |
+
Each time you convey a covered work, the recipient automatically
|
449 |
+
receives a license from the original licensors, to run, modify and
|
450 |
+
propagate that work, subject to this License. You are not responsible
|
451 |
+
for enforcing compliance by third parties with this License.
|
452 |
+
|
453 |
+
An "entity transaction" is a transaction transferring control of an
|
454 |
+
organization, or substantially all assets of one, or subdividing an
|
455 |
+
organization, or merging organizations. If propagation of a covered
|
456 |
+
work results from an entity transaction, each party to that
|
457 |
+
transaction who receives a copy of the work also receives whatever
|
458 |
+
licenses to the work the party's predecessor in interest had or could
|
459 |
+
give under the previous paragraph, plus a right to possession of the
|
460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
461 |
+
the predecessor has it or can get it with reasonable efforts.
|
462 |
+
|
463 |
+
You may not impose any further restrictions on the exercise of the
|
464 |
+
rights granted or affirmed under this License. For example, you may
|
465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
466 |
+
rights granted under this License, and you may not initiate litigation
|
467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
468 |
+
any patent claim is infringed by making, using, selling, offering for
|
469 |
+
sale, or importing the Program or any portion of it.
|
470 |
+
|
471 |
+
11. Patents.
|
472 |
+
|
473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
474 |
+
License of the Program or a work on which the Program is based. The
|
475 |
+
work thus licensed is called the contributor's "contributor version".
|
476 |
+
|
477 |
+
A contributor's "essential patent claims" are all patent claims
|
478 |
+
owned or controlled by the contributor, whether already acquired or
|
479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
480 |
+
by this License, of making, using, or selling its contributor version,
|
481 |
+
but do not include claims that would be infringed only as a
|
482 |
+
consequence of further modification of the contributor version. For
|
483 |
+
purposes of this definition, "control" includes the right to grant
|
484 |
+
patent sublicenses in a manner consistent with the requirements of
|
485 |
this License.
|
486 |
|
487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
488 |
+
patent license under the contributor's essential patent claims, to
|
489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
490 |
+
propagate the contents of its contributor version.
|
491 |
+
|
492 |
+
In the following three paragraphs, a "patent license" is any express
|
493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
494 |
+
(such as an express permission to practice a patent or covenant not to
|
495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
496 |
+
party means to make such an agreement or commitment not to enforce a
|
497 |
+
patent against the party.
|
498 |
+
|
499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
500 |
+
and the Corresponding Source of the work is not available for anyone
|
501 |
+
to copy, free of charge and under the terms of this License, through a
|
502 |
+
publicly available network server or other readily accessible means,
|
503 |
+
then you must either (1) cause the Corresponding Source to be so
|
504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
506 |
+
consistent with the requirements of this License, to extend the patent
|
507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
508 |
+
actual knowledge that, but for the patent license, your conveying the
|
509 |
+
covered work in a country, or your recipient's use of the covered work
|
510 |
+
in a country, would infringe one or more identifiable patents in that
|
511 |
+
country that you have reason to believe are valid.
|
512 |
+
|
513 |
+
If, pursuant to or in connection with a single transaction or
|
514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
515 |
+
covered work, and grant a patent license to some of the parties
|
516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
517 |
+
or convey a specific copy of the covered work, then the patent license
|
518 |
+
you grant is automatically extended to all recipients of the covered
|
519 |
+
work and works based on it.
|
520 |
+
|
521 |
+
A patent license is "discriminatory" if it does not include within
|
522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
524 |
+
specifically granted under this License. You may not convey a covered
|
525 |
+
work if you are a party to an arrangement with a third party that is
|
526 |
+
in the business of distributing software, under which you make payment
|
527 |
+
to the third party based on the extent of your activity of conveying
|
528 |
+
the work, and under which the third party grants, to any of the
|
529 |
+
parties who would receive the covered work from you, a discriminatory
|
530 |
+
patent license (a) in connection with copies of the covered work
|
531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
532 |
+
for and in connection with specific products or compilations that
|
533 |
+
contain the covered work, unless you entered into that arrangement,
|
534 |
+
or that patent license was granted, prior to 28 March 2007.
|
535 |
+
|
536 |
+
Nothing in this License shall be construed as excluding or limiting
|
537 |
+
any implied license or other defenses to infringement that may
|
538 |
+
otherwise be available to you under applicable patent law.
|
539 |
+
|
540 |
+
12. No Surrender of Others' Freedom.
|
541 |
+
|
542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
543 |
otherwise) that contradict the conditions of this License, they do not
|
544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
546 |
+
License and any other pertinent obligations, then as a consequence you may
|
547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
548 |
+
to collect a royalty for further conveying from those to whom you convey
|
549 |
+
the Program, the only way you could satisfy both those terms and this
|
550 |
+
License would be to refrain entirely from conveying the Program.
|
551 |
+
|
552 |
+
13. Use with the GNU Affero General Public License.
|
553 |
+
|
554 |
+
Notwithstanding any other provision of this License, you have
|
555 |
+
permission to link or combine any covered work with a work licensed
|
556 |
+
under version 3 of the GNU Affero General Public License into a single
|
557 |
+
combined work, and to convey the resulting work. The terms of this
|
558 |
+
License will continue to apply to the part which is the covered work,
|
559 |
+
but the special requirements of the GNU Affero General Public License,
|
560 |
+
section 13, concerning interaction through a network will apply to the
|
561 |
+
combination as such.
|
562 |
+
|
563 |
+
14. Revised Versions of this License.
|
564 |
+
|
565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
566 |
+
the GNU General Public License from time to time. Such new versions will
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
567 |
be similar in spirit to the present version, but may differ in detail to
|
568 |
address new problems or concerns.
|
569 |
|
570 |
+
Each version is given a distinguishing version number. If the
|
571 |
+
Program specifies that a certain numbered version of the GNU General
|
572 |
+
Public License "or any later version" applies to it, you have the
|
573 |
+
option of following the terms and conditions either of that numbered
|
574 |
+
version or of any later version published by the Free Software
|
575 |
+
Foundation. If the Program does not specify a version number of the
|
576 |
+
GNU General Public License, you may choose any version ever published
|
577 |
+
by the Free Software Foundation.
|
578 |
+
|
579 |
+
If the Program specifies that a proxy can decide which future
|
580 |
+
versions of the GNU General Public License can be used, that proxy's
|
581 |
+
public statement of acceptance of a version permanently authorizes you
|
582 |
+
to choose that version for the Program.
|
583 |
+
|
584 |
+
Later license versions may give you additional or different
|
585 |
+
permissions. However, no additional obligations are imposed on any
|
586 |
+
author or copyright holder as a result of your choosing to follow a
|
587 |
+
later version.
|
588 |
+
|
589 |
+
15. Disclaimer of Warranty.
|
590 |
+
|
591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
599 |
+
|
600 |
+
16. Limitation of Liability.
|
601 |
+
|
602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
610 |
+
SUCH DAMAGES.
|
611 |
+
|
612 |
+
17. Interpretation of Sections 15 and 16.
|
613 |
+
|
614 |
+
If the disclaimer of warranty and limitation of liability provided
|
615 |
+
above cannot be given local legal effect according to their terms,
|
616 |
+
reviewing courts shall apply local law that most closely approximates
|
617 |
+
an absolute waiver of all civil liability in connection with the
|
618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
619 |
+
copy of the Program in return for a fee.
|
620 |
|
621 |
END OF TERMS AND CONDITIONS
|
622 |
|
628 |
|
629 |
To do so, attach the following notices to the program. It is safest
|
630 |
to attach them to the start of each source file to most effectively
|
631 |
+
state the exclusion of warranty; and each file should have at least
|
632 |
the "copyright" line and a pointer to where the full notice is found.
|
633 |
|
634 |
+
{one line to give the program's name and a brief idea of what it does.}
|
635 |
+
Copyright (C) {year} {name of author}
|
636 |
|
637 |
+
This program is free software: you can redistribute it and/or modify
|
638 |
it under the terms of the GNU General Public License as published by
|
639 |
+
the Free Software Foundation, either version 3 of the License, or
|
640 |
(at your option) any later version.
|
641 |
|
642 |
This program is distributed in the hope that it will be useful,
|
644 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
645 |
GNU General Public License for more details.
|
646 |
|
647 |
+
You should have received a copy of the GNU General Public License
|
648 |
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
649 |
|
650 |
Also add information on how to contact you by electronic and paper mail.
|
651 |
|
652 |
+
If the program does terminal interaction, make it output a short
|
653 |
+
notice like this when it starts in an interactive mode:
|
654 |
|
655 |
+
{project} Copyright (C) {year} {fullname}
|
656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
657 |
This is free software, and you are welcome to redistribute it
|
658 |
under certain conditions; type `show c' for details.
|
659 |
|
660 |
The hypothetical commands `show w' and `show c' should show the appropriate
|
661 |
+
parts of the General Public License. Of course, your program's commands
|
662 |
+
might be different; for a GUI interface, you would use an "about box".
|
663 |
+
|
664 |
+
You should also get your employer (if you work as a programmer) or school,
|
665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
667 |
+
<http://www.gnu.org/licenses/>.
|
668 |
+
|
669 |
+
The GNU General Public License does not permit incorporating your program
|
670 |
+
into proprietary programs. If your program is a subroutine library, you
|
671 |
+
may consider it more useful to permit linking proprietary applications with
|
672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
673 |
+
Public License instead of this License. But first, please read
|
674 |
+
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
|
|
|
|
|
|
|
|
|
|
|
freemius/README.md
CHANGED
@@ -164,7 +164,7 @@ Add logic which will only be available in your premium plugin version AND will o
|
|
164 |
```php
|
165 |
<?php
|
166 |
// This "if" block will be auto removed from the Free version.
|
167 |
-
if ( my_prefix_fs()->
|
168 |
// ... logic related to Professional plan and higher plans ...
|
169 |
}
|
170 |
?>
|
164 |
```php
|
165 |
<?php
|
166 |
// This "if" block will be auto removed from the Free version.
|
167 |
+
if ( my_prefix_fs()->is_plan_or_trial__premium_only('professional') ) {
|
168 |
// ... logic related to Professional plan and higher plans ...
|
169 |
}
|
170 |
?>
|
freemius/assets/css/admin/account.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .button i.dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
|
1 |
+
#fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account h3 .dashicons{width:26px;height:26px;font-size:1.3em}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .button i.dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}#fs_account_details .button-group{float:right}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons thead{white-space:nowrap}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
|
freemius/assets/css/admin/affiliation.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
@charset "UTF-8";#fs_affiliation_content_wrapper #messages{margin-top:25px}#fs_affiliation_content_wrapper h3{font-size:24px;padding:0;margin-left:0}#fs_affiliation_content_wrapper ul li{box-sizing:border-box;list-style-type:none}#fs_affiliation_content_wrapper ul li:before{content:'✓';margin-right:10px;font-weight:bold}#fs_affiliation_content_wrapper p:not(.description),#fs_affiliation_content_wrapper li,#fs_affiliation_content_wrapper label{font-size:16px !important;line-height:26px !important}#fs_affiliation_content_wrapper .button{margin-top:20px;margin-bottom:7px;line-height:35px;height:40px;font-size:16px}#fs_affiliation_content_wrapper .button#cancel_button{margin-right:5px}#fs_affiliation_content_wrapper form .input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form .input-container .input-label{font-weight:bold;display:block;width:100%}#fs_affiliation_content_wrapper form .input-container.input-container-text label,#fs_affiliation_content_wrapper form .input-container.input-container-text input,#fs_affiliation_content_wrapper form .input-container.input-container-text textarea{display:block}#fs_affiliation_content_wrapper form .input-container #add_domain,#fs_affiliation_content_wrapper form .input-container .remove-domain{text-decoration:none;display:inline-block;margin-top:3px}#fs_affiliation_content_wrapper form .input-container #add_domain:focus,#fs_affiliation_content_wrapper form .input-container .remove-domain:focus{box-shadow:none}#fs_affiliation_content_wrapper form .input-container #add_domain.disabled,#fs_affiliation_content_wrapper form .input-container .remove-domain.disabled{color:#aaa;cursor:default}#fs_affiliation_content_wrapper form #extra_domains_container .description{margin-top:0;position:relative;top:-4px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container{margin-bottom:15px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain{display:inline-block;margin-right:5px}#fs_affiliation_content_wrapper form #extra_domains_container .extra-domain-input-container .domain:last-of-type{margin-bottom:0}
|
freemius/assets/css/admin/common.css
CHANGED
@@ -1,2 +1,2 @@
|
|
1 |
-
#iframe{line-height:0;font-size:0}.fs-full-size-wrapper{margin:
|
2 |
-
.fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;box-shadow:
|
1 |
+
.theme-browser .theme .fs-premium-theme-badge{position:absolute;top:10px;right:0;background:#71ae00;color:#fff;text-transform:uppercase;padding:5px 10px;-moz-border-radius:3px 0 0 3px;-webkit-border-radius:3px 0 0 3px;border-radius:3px 0 0 3px;font-weight:bold;border-right:0;-moz-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);box-shadow:0 2px 1px -1px rgba(0,0,0,0.3);font-size:1.1em}#iframe{line-height:0;font-size:0}.fs-full-size-wrapper{margin:40px 0 -65px -20px}@media (max-width: 600px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
|
2 |
+
.fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;top:100%;bottom:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}div.fs-notice.updated,div.fs-notice.success,div.fs-notice.promotion{display:block !important}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;-moz-box-shadow:0 2px 2px rgba(6,113,6,0.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,0.3);box-shadow:0 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}.fs-secure-notice a.fs-security-proof{color:green;text-decoration:none}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 600px){.fs-secure-notice{display:none}}@media screen and (max-width: 500px){#fs_promo_tab{display:none}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}.fs-ajax-spinner{border:0;width:20px;height:20px;margin-right:5px;vertical-align:sub;display:inline-block;background:url("../../../../../../../wp-admin/images/wpspin_light-2x.gif");background-size:contain}.wrap.fs-section h2{text-align:left}
|
freemius/assets/css/admin/connect.css
CHANGED
@@ -1 +1 @@
|
|
1 |
-
#fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
|
1 |
+
#fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}#fs_theme_connect_wrapper{position:fixed;top:0;height:100%;width:100%;z-index:99990;background:rgba(0,0,0,0.75);text-align:center;overflow-y:auto}#fs_theme_connect_wrapper:before{content:"";display:inline-block;vertical-align:middle;height:100%}#fs_theme_connect_wrapper>button.close{color:white;cursor:pointer;height:40px;width:40px;position:absolute;right:0;border:0;background-color:transparent;top:32px}#fs_theme_connect_wrapper #fs_connect{top:0;text-align:left;display:inline-block;vertical-align:middle;margin-top:52px;margin-bottom:20px}#fs_theme_connect_wrapper #fs_connect .fs-terms{background:rgba(140,140,140,0.64)}#fs_theme_connect_wrapper #fs_connect .fs-terms,#fs_theme_connect_wrapper #fs_connect .fs-terms a{color:#c5c5c5}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
|
freemius/assets/css/admin/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/assets/css/customizer.css
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
#fs_customizer_upsell .fs-customizer-plan{padding:10px 20px 20px 20px;border-radius:3px;background:#fff}#fs_customizer_upsell .fs-customizer-plan h2{position:relative;margin:0;line-height:2em;text-transform:uppercase}#fs_customizer_upsell .fs-customizer-plan h2 .button-link{top:-2px}#fs_customizer_upsell .fs-feature{position:relative}#fs_customizer_upsell .dashicons-yes{color:#0085ba;font-size:2em;vertical-align:bottom;margin-left:-7px;margin-right:10px}.rtl #fs_customizer_upsell .dashicons-yes{margin-left:10px;margin-right:-7px}#fs_customizer_upsell .dashicons-editor-help{color:#bbb;cursor:help}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{opacity:0;visibility:hidden;-moz-transition:opacity 0.3s ease-in-out;-o-transition:opacity 0.3s ease-in-out;-ms-transition:opacity 0.3s ease-in-out;-webkit-transition:opacity 0.3s ease-in-out;transition:opacity 0.3s ease-in-out;position:absolute;background:#000;color:#fff;font-family:'arial', serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:0;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);line-height:1.3em;font-weight:bold;text-align:left}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc{text-align:right}#fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{content:' ';display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:#000 transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl #fs_customizer_upsell .dashicons-editor-help .fs-feature-desc::after{right:21px;left:auto}#fs_customizer_upsell .dashicons-editor-help:hover .fs-feature-desc{visibility:visible;opacity:1}#fs_customizer_upsell .button-primary{display:block;text-align:center;margin-top:10px}#fs_customizer_support{display:block !important}#fs_customizer_support .button{float:right}#fs_customizer_support .button-group{width:100%;display:block;margin-top:10px}#fs_customizer_support .button-group .button{float:none;width:50%;text-align:center}
|
freemius/assets/css/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/assets/img/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/assets/img/theme-icon.png
ADDED
Binary file
|
freemius/assets/js/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/assets/scss/_load.scss
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
@import 'mixins';
|
2 |
-
@import "vars";
|
3 |
-
@import "functions";
|
4 |
-
@import "colors";
|
1 |
+
@import 'mixins';
|
2 |
+
@import "vars";
|
3 |
+
@import "functions";
|
4 |
+
@import "colors";
|
freemius/assets/scss/_mixins.scss
CHANGED
@@ -132,19 +132,6 @@ $useIEFilters: 0;
|
|
132 |
}
|
133 |
}
|
134 |
|
135 |
-
/*@mixin rgba-bg ($hex, $alpha, $ie: $useIEFilters) {
|
136 |
-
@if $ie == 1 {
|
137 |
-
background-color: none;
|
138 |
-
$hexopac: ie-hex-str(rgba($hex, $alpha));
|
139 |
-
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}}');
|
140 |
-
-ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}'));
|
141 |
-
}
|
142 |
-
@else {
|
143 |
-
background-color: $hex;
|
144 |
-
background-color: rgba($hex, $alpha);
|
145 |
-
}
|
146 |
-
}*/
|
147 |
-
|
148 |
@mixin perspective($perspective) {
|
149 |
-moz-perspective: $perspective;
|
150 |
-ms-perspective: $perspective;
|
132 |
}
|
133 |
}
|
134 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
@mixin perspective($perspective) {
|
136 |
-moz-perspective: $perspective;
|
137 |
-ms-perspective: $perspective;
|
freemius/assets/scss/_start.scss
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
@import "vars";
|
2 |
-
@import "colors";
|
3 |
-
@import "mixins";
|
4 |
@import "functions";
|
1 |
+
@import "vars";
|
2 |
+
@import "colors";
|
3 |
+
@import "mixins";
|
4 |
@import "functions";
|
freemius/assets/scss/_vars.scss
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
-
$is_production: true;
|
2 |
-
|
3 |
-
$img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
|
4 |
-
|
5 |
-
$layout_width: 960px;
|
6 |
$admin_mobile_max_width: 782px;
|
1 |
+
$is_production: true;
|
2 |
+
|
3 |
+
$img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
|
4 |
+
|
5 |
+
$layout_width: 960px;
|
6 |
$admin_mobile_max_width: 782px;
|
freemius/assets/scss/admin/_themes.scss
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.theme-browser
|
2 |
+
{
|
3 |
+
.theme
|
4 |
+
{
|
5 |
+
.fs-premium-theme-badge
|
6 |
+
{
|
7 |
+
position: absolute;
|
8 |
+
top: 10px;
|
9 |
+
right: 0;
|
10 |
+
background: $fs-logo-green-color;
|
11 |
+
color: #fff;
|
12 |
+
text-transform: uppercase;
|
13 |
+
padding: 5px 10px;
|
14 |
+
@include border-radius(3px 0 0 3px);
|
15 |
+
font-weight: bold;
|
16 |
+
border-right: 0;
|
17 |
+
@include box-shadow(0 2px 1px -1px rgba(0, 0, 0, .3));
|
18 |
+
font-size: 1.1em;
|
19 |
+
}
|
20 |
+
}
|
21 |
+
}
|
freemius/assets/scss/admin/account.scss
CHANGED
@@ -15,6 +15,12 @@
|
|
15 |
margin: 0 0 12px 0;
|
16 |
line-height: 1.4;
|
17 |
border-bottom: 1px solid #F1F1F1;
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
i.dashicons
|
15 |
margin: 0 0 12px 0;
|
16 |
line-height: 1.4;
|
17 |
border-bottom: 1px solid #F1F1F1;
|
18 |
+
|
19 |
+
.dashicons {
|
20 |
+
width: 26px;
|
21 |
+
height: 26px;
|
22 |
+
font-size: 1.3em;
|
23 |
+
}
|
24 |
}
|
25 |
|
26 |
i.dashicons
|
freemius/assets/scss/admin/affiliation.scss
ADDED
@@ -0,0 +1,97 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import "../start";
|
2 |
+
|
3 |
+
#fs_affiliation_content_wrapper {
|
4 |
+
#messages {
|
5 |
+
margin-top: 25px;
|
6 |
+
}
|
7 |
+
|
8 |
+
h3 {
|
9 |
+
font-size: 24px;
|
10 |
+
padding: 0;
|
11 |
+
margin-left: 0;
|
12 |
+
}
|
13 |
+
|
14 |
+
ul {
|
15 |
+
li {
|
16 |
+
@include box-sizing(border-box);
|
17 |
+
list-style-type: none;
|
18 |
+
|
19 |
+
&:before {
|
20 |
+
content: '✓';
|
21 |
+
margin-right: 10px;
|
22 |
+
font-weight: bold;
|
23 |
+
}
|
24 |
+
}
|
25 |
+
}
|
26 |
+
|
27 |
+
p:not(.description), li, label {
|
28 |
+
font-size: 16px !important;
|
29 |
+
line-height: 26px !important;
|
30 |
+
}
|
31 |
+
|
32 |
+
.button {
|
33 |
+
margin-top: 20px;
|
34 |
+
margin-bottom: 7px;
|
35 |
+
line-height: 35px;
|
36 |
+
height: 40px;
|
37 |
+
font-size: 16px;
|
38 |
+
|
39 |
+
&#cancel_button {
|
40 |
+
margin-right: 5px;
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
form {
|
45 |
+
.input-container {
|
46 |
+
.input-label {
|
47 |
+
font-weight: bold;
|
48 |
+
display: block;
|
49 |
+
width: 100%;
|
50 |
+
}
|
51 |
+
|
52 |
+
&.input-container-text {
|
53 |
+
label, input, textarea {
|
54 |
+
display: block;
|
55 |
+
}
|
56 |
+
}
|
57 |
+
|
58 |
+
margin-bottom: 15px;
|
59 |
+
|
60 |
+
#add_domain, .remove-domain {
|
61 |
+
text-decoration: none;
|
62 |
+
display: inline-block;
|
63 |
+
margin-top: 3px;
|
64 |
+
|
65 |
+
&:focus {
|
66 |
+
box-shadow: none;
|
67 |
+
}
|
68 |
+
|
69 |
+
&.disabled {
|
70 |
+
color: #aaa;
|
71 |
+
cursor: default;
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
#extra_domains_container {
|
77 |
+
.description {
|
78 |
+
margin-top: 0;
|
79 |
+
position: relative;
|
80 |
+
top: -4px;
|
81 |
+
}
|
82 |
+
|
83 |
+
.extra-domain-input-container {
|
84 |
+
margin-bottom: 15px;
|
85 |
+
|
86 |
+
.domain {
|
87 |
+
display: inline-block;
|
88 |
+
margin-right: 5px;
|
89 |
+
|
90 |
+
&:last-of-type {
|
91 |
+
margin-bottom: 0;
|
92 |
+
}
|
93 |
+
}
|
94 |
+
}
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
freemius/assets/scss/admin/common.scss
CHANGED
@@ -1,173 +1,218 @@
|
|
1 |
-
@import "../start";
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
}
|
1 |
+
@import "../start";
|
2 |
+
@import "themes";
|
3 |
+
|
4 |
+
#iframe
|
5 |
+
{
|
6 |
+
line-height: 0;
|
7 |
+
font-size: 0;
|
8 |
+
}
|
9 |
+
|
10 |
+
.fs-full-size-wrapper
|
11 |
+
{
|
12 |
+
margin: 40px 0 -65px -20px;
|
13 |
+
|
14 |
+
@media (max-width: 600px) {
|
15 |
+
margin: 0 0 -65px -10px;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
|
19 |
+
.fs-notice
|
20 |
+
{
|
21 |
+
position: relative;
|
22 |
+
|
23 |
+
&.fs-has-title
|
24 |
+
{
|
25 |
+
margin-bottom: 30px !important;
|
26 |
+
}
|
27 |
+
|
28 |
+
&.success
|
29 |
+
{
|
30 |
+
color: green;
|
31 |
+
// font-weight: normal;
|
32 |
+
}
|
33 |
+
|
34 |
+
&.promotion
|
35 |
+
{
|
36 |
+
border-color: $fs-notice-promotion-border-color !important;
|
37 |
+
background-color: $fs-notice-promotion-bkg !important;
|
38 |
+
}
|
39 |
+
|
40 |
+
.fs-notice-body
|
41 |
+
{
|
42 |
+
margin: .5em 0;
|
43 |
+
padding: 2px;
|
44 |
+
}
|
45 |
+
|
46 |
+
.fs-close
|
47 |
+
{
|
48 |
+
// position: absolute;
|
49 |
+
// top: 2px;
|
50 |
+
// bottom: 2px;
|
51 |
+
// right: 2px;
|
52 |
+
// min-width: 100px;
|
53 |
+
// text-align: center;
|
54 |
+
// padding-right: 2px;
|
55 |
+
cursor: pointer;
|
56 |
+
color: #aaa;
|
57 |
+
float: right;
|
58 |
+
|
59 |
+
&:hover
|
60 |
+
{
|
61 |
+
color: #666;
|
62 |
+
// background: #A9A9A9;
|
63 |
+
}
|
64 |
+
|
65 |
+
> *
|
66 |
+
{
|
67 |
+
margin-top: 7px;
|
68 |
+
display: inline-block;
|
69 |
+
}
|
70 |
+
}
|
71 |
+
|
72 |
+
label.fs-plugin-title
|
73 |
+
{
|
74 |
+
background: rgba(0, 0, 0, 0.3);
|
75 |
+
color: #fff;
|
76 |
+
padding: 2px 10px;
|
77 |
+
position: absolute;
|
78 |
+
top: 100%;
|
79 |
+
bottom: auto;
|
80 |
+
right: auto;
|
81 |
+
@include border-radius(0 0 3px 3px);
|
82 |
+
left: 10px;
|
83 |
+
font-size: 12px;
|
84 |
+
font-weight: bold;
|
85 |
+
cursor: auto;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
div.fs-notice
|
90 |
+
{
|
91 |
+
&.updated,
|
92 |
+
&.success,
|
93 |
+
&.promotion
|
94 |
+
{
|
95 |
+
display: block !important;
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
.rtl .fs-notice
|
100 |
+
{
|
101 |
+
.fs-close
|
102 |
+
{
|
103 |
+
// left: 2px;
|
104 |
+
// right: auto;
|
105 |
+
// padding-right: 0;
|
106 |
+
// padding-left: 2px;
|
107 |
+
float: left;
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
.fs-secure-notice
|
112 |
+
{
|
113 |
+
position: fixed;
|
114 |
+
top: 32px;
|
115 |
+
left: 160px;
|
116 |
+
right: 0;
|
117 |
+
background: rgb(235, 253, 235);
|
118 |
+
padding: 10px 20px;
|
119 |
+
color: green;
|
120 |
+
z-index: 9999;
|
121 |
+
@include box-shadow(0 2px 2px rgba(6, 113, 6, 0.3));
|
122 |
+
@include opacity(0.95);
|
123 |
+
|
124 |
+
&:hover
|
125 |
+
{
|
126 |
+
@include opacity(1);
|
127 |
+
}
|
128 |
+
|
129 |
+
a.fs-security-proof
|
130 |
+
{
|
131 |
+
color: green;
|
132 |
+
text-decoration: none;
|
133 |
+
}
|
134 |
+
}
|
135 |
+
|
136 |
+
@media screen and (max-width: 960px) {
|
137 |
+
.fs-secure-notice
|
138 |
+
{
|
139 |
+
left: 36px;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
@media screen and (max-width: 600px) {
|
144 |
+
.fs-secure-notice
|
145 |
+
{
|
146 |
+
display: none;
|
147 |
+
}
|
148 |
+
}
|
149 |
+
|
150 |
+
@media screen and (max-width: 500px) {
|
151 |
+
#fs_promo_tab
|
152 |
+
{
|
153 |
+
display: none;
|
154 |
+
}
|
155 |
+
}
|
156 |
+
|
157 |
+
@media screen and (max-width: 782px) {
|
158 |
+
.fs-secure-notice
|
159 |
+
{
|
160 |
+
left: 0;
|
161 |
+
top: 46px;
|
162 |
+
text-align: center;
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
span.fs-submenu-item.fs-sub:before
|
167 |
+
{
|
168 |
+
// Add small arrow.
|
169 |
+
content: '\21B3';
|
170 |
+
padding: 0 5px;
|
171 |
+
}
|
172 |
+
|
173 |
+
.rtl
|
174 |
+
{
|
175 |
+
span.fs-submenu-item.fs-sub:before
|
176 |
+
{
|
177 |
+
// Add small RTL arrow.
|
178 |
+
content: '\21B2';
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
.fs-submenu-item
|
183 |
+
{
|
184 |
+
&.pricing
|
185 |
+
{
|
186 |
+
&.upgrade-mode
|
187 |
+
{
|
188 |
+
color: greenyellow;
|
189 |
+
}
|
190 |
+
|
191 |
+
&.trial-mode
|
192 |
+
{
|
193 |
+
color: #83e2ff;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
|
198 |
+
#adminmenu .update-plugins.fs-trial
|
199 |
+
{
|
200 |
+
background-color: #00b9eb;
|
201 |
+
}
|
202 |
+
.fs-ajax-spinner
|
203 |
+
{
|
204 |
+
border: 0;
|
205 |
+
width: 20px;
|
206 |
+
height: 20px;
|
207 |
+
margin-right: 5px;
|
208 |
+
vertical-align: sub;
|
209 |
+
display: inline-block;
|
210 |
+
background: url('../../../../../../../wp-admin/images/wpspin_light-2x.gif');
|
211 |
+
background-size: contain;
|
212 |
+
}
|
213 |
+
|
214 |
+
.wrap.fs-section {
|
215 |
+
h2 {
|
216 |
+
text-align: left;
|
217 |
+
}
|
218 |
}
|
freemius/assets/scss/admin/connect.scss
CHANGED
@@ -1,471 +1,520 @@
|
|
1 |
-
@import "../start";
|
2 |
-
|
3 |
-
$form_width: 480px;
|
4 |
-
|
5 |
-
#fs_connect
|
6 |
-
{
|
7 |
-
width: $form_width;
|
8 |
-
@include box-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));
|
9 |
-
margin: 20px 0;
|
10 |
-
|
11 |
-
@media screen and (max-width: ($form_width - 1)) {
|
12 |
-
@include box-shadow(none);
|
13 |
-
width: auto;
|
14 |
-
margin: 0 0 0 -10px;
|
15 |
-
}
|
16 |
-
|
17 |
-
.fs-content
|
18 |
-
{
|
19 |
-
background: #fff;
|
20 |
-
padding: 15px 20px;
|
21 |
-
|
22 |
-
.fs-error {
|
23 |
-
background: snow;
|
24 |
-
color: $fs-logo-magenta-color;
|
25 |
-
border: 1px solid $fs-logo-magenta-color;
|
26 |
-
@include box-shadow(0 1px 1px 0 rgba(0,0,0,.1));
|
27 |
-
text-align: center;
|
28 |
-
padding: 5px;
|
29 |
-
margin-bottom: 10px;
|
30 |
-
}
|
31 |
-
|
32 |
-
p
|
33 |
-
{
|
34 |
-
margin: 0;
|
35 |
-
padding: 0;
|
36 |
-
font-size: 1.2em;
|
37 |
-
}
|
38 |
-
}
|
39 |
-
|
40 |
-
.fs-license-key-container {
|
41 |
-
position: relative;
|
42 |
-
width: 280px;
|
43 |
-
margin: 10px auto 0 auto;
|
44 |
-
|
45 |
-
input {
|
46 |
-
width: 100%;
|
47 |
-
}
|
48 |
-
|
49 |
-
.dashicons {
|
50 |
-
position: absolute;
|
51 |
-
top: 5px;
|
52 |
-
right: 5px;
|
53 |
-
}
|
54 |
-
}
|
55 |
-
|
56 |
-
.fs-actions
|
57 |
-
{
|
58 |
-
padding: 10px 20px;
|
59 |
-
background: #C0C7CA;
|
60 |
-
|
61 |
-
.button
|
62 |
-
{
|
63 |
-
padding: 0 10px 1px;
|
64 |
-
line-height: 35px;
|
65 |
-
height: 37px;
|
66 |
-
font-size: 16px;
|
67 |
-
margin-bottom: 0;
|
68 |
-
|
69 |
-
.dashicons
|
70 |
-
{
|
71 |
-
font-size: 37px;
|
72 |
-
margin-left: -8px;
|
73 |
-
margin-right: 12px;
|
74 |
-
}
|
75 |
-
|
76 |
-
&.button-primary
|
77 |
-
{
|
78 |
-
padding-right: 15px;
|
79 |
-
padding-left: 15px;
|
80 |
-
|
81 |
-
&:after
|
82 |
-
{
|
83 |
-
content: ' \279C';
|
84 |
-
}
|
85 |
-
|
86 |
-
&.fs-loading
|
87 |
-
{
|
88 |
-
&:after
|
89 |
-
{
|
90 |
-
content: '';
|
91 |
-
}
|
92 |
-
}
|
93 |
-
}
|
94 |
-
|
95 |
-
&.button-secondary
|
96 |
-
{
|
97 |
-
float: right;
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
// .fs-skip
|
102 |
-
// {
|
103 |
-
// line-height: 38px;
|
104 |
-
// vertical-align: middle;
|
105 |
-
// text-decoration: none;
|
106 |
-
// margin-left: 10px;
|
107 |
-
// }
|
108 |
-
}
|
109 |
-
|
110 |
-
&.fs-anonymous-disabled
|
111 |
-
{
|
112 |
-
.fs-actions
|
113 |
-
{
|
114 |
-
.button.button-primary
|
115 |
-
{
|
116 |
-
width: 100%;
|
117 |
-
}
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
.fs-permissions
|
122 |
-
{
|
123 |
-
padding: 10px 20px;
|
124 |
-
background: #FEFEFE;
|
125 |
-
// background: #F1F1F1;
|
126 |
-
@include transition(background 0.5s ease);
|
127 |
-
|
128 |
-
.fs-license-sync-disclaimer {
|
129 |
-
text-align: center;
|
130 |
-
margin-top: 0;
|
131 |
-
}
|
132 |
-
|
133 |
-
.fs-trigger
|
134 |
-
{
|
135 |
-
font-size: 0.9em;
|
136 |
-
text-decoration: none;
|
137 |
-
text-align: center;
|
138 |
-
display: block;
|
139 |
-
}
|
140 |
-
|
141 |
-
ul
|
142 |
-
{
|
143 |
-
height: 0;
|
144 |
-
overflow: hidden;
|
145 |
-
margin: 0;
|
146 |
-
|
147 |
-
li
|
148 |
-
{
|
149 |
-
margin-bottom: 12px;
|
150 |
-
|
151 |
-
&:last-child
|
152 |
-
{
|
153 |
-
margin-bottom: 0;
|
154 |
-
}
|
155 |
-
|
156 |
-
i.dashicons
|
157 |
-
{
|
158 |
-
float: left;
|
159 |
-
font-size: 40px;
|
160 |
-
width: 40px;
|
161 |
-
height: 40px;
|
162 |
-
}
|
163 |
-
|
164 |
-
div
|
165 |
-
{
|
166 |
-
margin-left: 55px;
|
167 |
-
|
168 |
-
span
|
169 |
-
{
|
170 |
-
font-weight: bold;
|
171 |
-
text-transform: uppercase;
|
172 |
-
color: #23282d;
|
173 |
-
}
|
174 |
-
|
175 |
-
p
|
176 |
-
{
|
177 |
-
margin: 2px 0 0 0;
|
178 |
-
}
|
179 |
-
}
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
&.fs-open
|
184 |
-
{
|
185 |
-
background: #fff;
|
186 |
-
|
187 |
-
ul
|
188 |
-
{
|
189 |
-
height: auto;
|
190 |
-
margin: 20px 20px 10px 20px;
|
191 |
-
}
|
192 |
-
}
|
193 |
-
|
194 |
-
@media screen and (max-width: ($form_width - 1)) {
|
195 |
-
background: #fff;
|
196 |
-
|
197 |
-
.fs-trigger
|
198 |
-
{
|
199 |
-
display: none;
|
200 |
-
}
|
201 |
-
|
202 |
-
ul
|
203 |
-
{
|
204 |
-
height: auto;
|
205 |
-
margin: 20px;
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
|
210 |
-
.fs-freemium-licensing {
|
211 |
-
padding: 8px;
|
212 |
-
// background: #0085BA;
|
213 |
-
background: #777;
|
214 |
-
color: #fff;
|
215 |
-
|
216 |
-
p {
|
217 |
-
text-align: center;
|
218 |
-
display: block;
|
219 |
-
margin: 0;
|
220 |
-
padding: 0;
|
221 |
-
}
|
222 |
-
|
223 |
-
a {
|
224 |
-
color: #C2EEFF;
|
225 |
-
text-decoration: underline;
|
226 |
-
}
|
227 |
-
}
|
228 |
-
|
229 |
-
$icon_size: 80px;
|
230 |
-
$wp_logo_padding: $icon_size / 10;
|
231 |
-
$icons_top: 10px;
|
232 |
-
|
233 |
-
.fs-visual
|
234 |
-
{
|
235 |
-
padding: 12px;
|
236 |
-
line-height: 0;
|
237 |
-
background: #fafafa;
|
238 |
-
height: $icon_size;
|
239 |
-
position: relative;
|
240 |
-
|
241 |
-
.fs-site-icon
|
242 |
-
{
|
243 |
-
position: absolute;
|
244 |
-
left: 20px;
|
245 |
-
top: $icons_top;
|
246 |
-
}
|
247 |
-
|
248 |
-
.fs-connect-logo
|
249 |
-
{
|
250 |
-
position: absolute;
|
251 |
-
right: 20px;
|
252 |
-
top: $icons_top;
|
253 |
-
}
|
254 |
-
|
255 |
-
.fs-plugin-icon
|
256 |
-
{
|
257 |
-
position: absolute;
|
258 |
-
top: $icons_top;
|
259 |
-
left: 50%;
|
260 |
-
margin-left: - ($icon_size / 2);
|
261 |
-
}
|
262 |
-
|
263 |
-
.fs-plugin-icon,
|
264 |
-
.fs-site-icon,
|
265 |
-
img,
|
266 |
-
object
|
267 |
-
{
|
268 |
-
width: $icon_size;
|
269 |
-
height: $icon_size;
|
270 |
-
}
|
271 |
-
|
272 |
-
.dashicons-wordpress
|
273 |
-
{
|
274 |
-
font-size: $icon_size - ($wp_logo_padding * 2);
|
275 |
-
background: $wordpress_color;
|
276 |
-
color: #fff;
|
277 |
-
width: $icon_size - ($wp_logo_padding * 2);
|
278 |
-
height: $icon_size - ($wp_logo_padding * 2);
|
279 |
-
padding: $wp_logo_padding;
|
280 |
-
}
|
281 |
-
|
282 |
-
.dashicons-plus
|
283 |
-
{
|
284 |
-
position: absolute;
|
285 |
-
top: 50%;
|
286 |
-
font-size: 30px;
|
287 |
-
margin-top: -10px;
|
288 |
-
color: #bbb;
|
289 |
-
|
290 |
-
&.fs-first
|
291 |
-
{
|
292 |
-
left: 28%;
|
293 |
-
}
|
294 |
-
&.fs-second
|
295 |
-
{
|
296 |
-
left: 65%;
|
297 |
-
}
|
298 |
-
}
|
299 |
-
|
300 |
-
.fs-plugin-icon,
|
301 |
-
.fs-connect-logo,
|
302 |
-
.fs-site-icon
|
303 |
-
{
|
304 |
-
border: 1px solid #ccc;
|
305 |
-
padding: 1px;
|
306 |
-
background: #fff;
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
.fs-terms
|
311 |
-
{
|
312 |
-
text-align: center;
|
313 |
-
font-size: 0.85em;
|
314 |
-
padding: 5px;
|
315 |
-
background: rgba(0, 0, 0, 0.05);
|
316 |
-
|
317 |
-
&, a
|
318 |
-
{
|
319 |
-
color: #999;
|
320 |
-
}
|
321 |
-
|
322 |
-
a
|
323 |
-
{
|
324 |
-
text-decoration: none;
|
325 |
-
}
|
326 |
-
}
|
327 |
-
}
|
328 |
-
|
329 |
-
.rtl
|
330 |
-
{
|
331 |
-
#fs_connect
|
332 |
-
{
|
333 |
-
.fs-actions
|
334 |
-
{
|
335 |
-
padding: 10px 20px;
|
336 |
-
background: #C0C7CA;
|
337 |
-
|
338 |
-
.button
|
339 |
-
{
|
340 |
-
.dashicons
|
341 |
-
{
|
342 |
-
font-size: 37px;
|
343 |
-
margin-left: -8px;
|
344 |
-
margin-right: 12px;
|
345 |
-
}
|
346 |
-
|
347 |
-
&.button-primary
|
348 |
-
{
|
349 |
-
&:after
|
350 |
-
{
|
351 |
-
content: ' \000bb';
|
352 |
-
}
|
353 |
-
|
354 |
-
&.fs-loading
|
355 |
-
{
|
356 |
-
&:after
|
357 |
-
{
|
358 |
-
content: '';
|
359 |
-
}
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
&.button-secondary
|
364 |
-
{
|
365 |
-
float: left;
|
366 |
-
}
|
367 |
-
}
|
368 |
-
}
|
369 |
-
|
370 |
-
.fs-permissions
|
371 |
-
{
|
372 |
-
ul
|
373 |
-
{
|
374 |
-
li
|
375 |
-
{
|
376 |
-
div
|
377 |
-
{
|
378 |
-
margin-right: 55px;
|
379 |
-
margin-left: 0;
|
380 |
-
}
|
381 |
-
|
382 |
-
i.dashicons
|
383 |
-
{
|
384 |
-
float: right;
|
385 |
-
}
|
386 |
-
|
387 |
-
}
|
388 |
-
}
|
389 |
-
}
|
390 |
-
|
391 |
-
.fs-visual
|
392 |
-
{
|
393 |
-
.fs-site-icon
|
394 |
-
{
|
395 |
-
right: 20px;
|
396 |
-
left: auto;
|
397 |
-
}
|
398 |
-
|
399 |
-
.fs-connect-logo
|
400 |
-
{
|
401 |
-
right: auto;
|
402 |
-
left: 20px;
|
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 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import "../start";
|
2 |
+
|
3 |
+
$form_width: 480px;
|
4 |
+
|
5 |
+
#fs_connect
|
6 |
+
{
|
7 |
+
width: $form_width;
|
8 |
+
@include box-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));
|
9 |
+
margin: 20px 0;
|
10 |
+
|
11 |
+
@media screen and (max-width: ($form_width - 1)) {
|
12 |
+
@include box-shadow(none);
|
13 |
+
width: auto;
|
14 |
+
margin: 0 0 0 -10px;
|
15 |
+
}
|
16 |
+
|
17 |
+
.fs-content
|
18 |
+
{
|
19 |
+
background: #fff;
|
20 |
+
padding: 15px 20px;
|
21 |
+
|
22 |
+
.fs-error {
|
23 |
+
background: snow;
|
24 |
+
color: $fs-logo-magenta-color;
|
25 |
+
border: 1px solid $fs-logo-magenta-color;
|
26 |
+
@include box-shadow(0 1px 1px 0 rgba(0,0,0,.1));
|
27 |
+
text-align: center;
|
28 |
+
padding: 5px;
|
29 |
+
margin-bottom: 10px;
|
30 |
+
}
|
31 |
+
|
32 |
+
p
|
33 |
+
{
|
34 |
+
margin: 0;
|
35 |
+
padding: 0;
|
36 |
+
font-size: 1.2em;
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
.fs-license-key-container {
|
41 |
+
position: relative;
|
42 |
+
width: 280px;
|
43 |
+
margin: 10px auto 0 auto;
|
44 |
+
|
45 |
+
input {
|
46 |
+
width: 100%;
|
47 |
+
}
|
48 |
+
|
49 |
+
.dashicons {
|
50 |
+
position: absolute;
|
51 |
+
top: 5px;
|
52 |
+
right: 5px;
|
53 |
+
}
|
54 |
+
}
|
55 |
+
|
56 |
+
.fs-actions
|
57 |
+
{
|
58 |
+
padding: 10px 20px;
|
59 |
+
background: #C0C7CA;
|
60 |
+
|
61 |
+
.button
|
62 |
+
{
|
63 |
+
padding: 0 10px 1px;
|
64 |
+
line-height: 35px;
|
65 |
+
height: 37px;
|
66 |
+
font-size: 16px;
|
67 |
+
margin-bottom: 0;
|
68 |
+
|
69 |
+
.dashicons
|
70 |
+
{
|
71 |
+
font-size: 37px;
|
72 |
+
margin-left: -8px;
|
73 |
+
margin-right: 12px;
|
74 |
+
}
|
75 |
+
|
76 |
+
&.button-primary
|
77 |
+
{
|
78 |
+
padding-right: 15px;
|
79 |
+
padding-left: 15px;
|
80 |
+
|
81 |
+
&:after
|
82 |
+
{
|
83 |
+
content: ' \279C';
|
84 |
+
}
|
85 |
+
|
86 |
+
&.fs-loading
|
87 |
+
{
|
88 |
+
&:after
|
89 |
+
{
|
90 |
+
content: '';
|
91 |
+
}
|
92 |
+
}
|
93 |
+
}
|
94 |
+
|
95 |
+
&.button-secondary
|
96 |
+
{
|
97 |
+
float: right;
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
// .fs-skip
|
102 |
+
// {
|
103 |
+
// line-height: 38px;
|
104 |
+
// vertical-align: middle;
|
105 |
+
// text-decoration: none;
|
106 |
+
// margin-left: 10px;
|
107 |
+
// }
|
108 |
+
}
|
109 |
+
|
110 |
+
&.fs-anonymous-disabled
|
111 |
+
{
|
112 |
+
.fs-actions
|
113 |
+
{
|
114 |
+
.button.button-primary
|
115 |
+
{
|
116 |
+
width: 100%;
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
120 |
+
|
121 |
+
.fs-permissions
|
122 |
+
{
|
123 |
+
padding: 10px 20px;
|
124 |
+
background: #FEFEFE;
|
125 |
+
// background: #F1F1F1;
|
126 |
+
@include transition(background 0.5s ease);
|
127 |
+
|
128 |
+
.fs-license-sync-disclaimer {
|
129 |
+
text-align: center;
|
130 |
+
margin-top: 0;
|
131 |
+
}
|
132 |
+
|
133 |
+
.fs-trigger
|
134 |
+
{
|
135 |
+
font-size: 0.9em;
|
136 |
+
text-decoration: none;
|
137 |
+
text-align: center;
|
138 |
+
display: block;
|
139 |
+
}
|
140 |
+
|
141 |
+
ul
|
142 |
+
{
|
143 |
+
height: 0;
|
144 |
+
overflow: hidden;
|
145 |
+
margin: 0;
|
146 |
+
|
147 |
+
li
|
148 |
+
{
|
149 |
+
margin-bottom: 12px;
|
150 |
+
|
151 |
+
&:last-child
|
152 |
+
{
|
153 |
+
margin-bottom: 0;
|
154 |
+
}
|
155 |
+
|
156 |
+
i.dashicons
|
157 |
+
{
|
158 |
+
float: left;
|
159 |
+
font-size: 40px;
|
160 |
+
width: 40px;
|
161 |
+
height: 40px;
|
162 |
+
}
|
163 |
+
|
164 |
+
div
|
165 |
+
{
|
166 |
+
margin-left: 55px;
|
167 |
+
|
168 |
+
span
|
169 |
+
{
|
170 |
+
font-weight: bold;
|
171 |
+
text-transform: uppercase;
|
172 |
+
color: #23282d;
|
173 |
+
}
|
174 |
+
|
175 |
+
p
|
176 |
+
{
|
177 |
+
margin: 2px 0 0 0;
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
&.fs-open
|
184 |
+
{
|
185 |
+
background: #fff;
|
186 |
+
|
187 |
+
ul
|
188 |
+
{
|
189 |
+
height: auto;
|
190 |
+
margin: 20px 20px 10px 20px;
|
191 |
+
}
|
192 |
+
}
|
193 |
+
|
194 |
+
@media screen and (max-width: ($form_width - 1)) {
|
195 |
+
background: #fff;
|
196 |
+
|
197 |
+
.fs-trigger
|
198 |
+
{
|
199 |
+
display: none;
|
200 |
+
}
|
201 |
+
|
202 |
+
ul
|
203 |
+
{
|
204 |
+
height: auto;
|
205 |
+
margin: 20px;
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
.fs-freemium-licensing {
|
211 |
+
padding: 8px;
|
212 |
+
// background: #0085BA;
|
213 |
+
background: #777;
|
214 |
+
color: #fff;
|
215 |
+
|
216 |
+
p {
|
217 |
+
text-align: center;
|
218 |
+
display: block;
|
219 |
+
margin: 0;
|
220 |
+
padding: 0;
|
221 |
+
}
|
222 |
+
|
223 |
+
a {
|
224 |
+
color: #C2EEFF;
|
225 |
+
text-decoration: underline;
|
226 |
+
}
|
227 |
+
}
|
228 |
+
|
229 |
+
$icon_size: 80px;
|
230 |
+
$wp_logo_padding: $icon_size / 10;
|
231 |
+
$icons_top: 10px;
|
232 |
+
|
233 |
+
.fs-visual
|
234 |
+
{
|
235 |
+
padding: 12px;
|
236 |
+
line-height: 0;
|
237 |
+
background: #fafafa;
|
238 |
+
height: $icon_size;
|
239 |
+
position: relative;
|
240 |
+
|
241 |
+
.fs-site-icon
|
242 |
+
{
|
243 |
+
position: absolute;
|
244 |
+
left: 20px;
|
245 |
+
top: $icons_top;
|
246 |
+
}
|
247 |
+
|
248 |
+
.fs-connect-logo
|
249 |
+
{
|
250 |
+
position: absolute;
|
251 |
+
right: 20px;
|
252 |
+
top: $icons_top;
|
253 |
+
}
|
254 |
+
|
255 |
+
.fs-plugin-icon
|
256 |
+
{
|
257 |
+
position: absolute;
|
258 |
+
top: $icons_top;
|
259 |
+
left: 50%;
|
260 |
+
margin-left: - ($icon_size / 2);
|
261 |
+
}
|
262 |
+
|
263 |
+
.fs-plugin-icon,
|
264 |
+
.fs-site-icon,
|
265 |
+
img,
|
266 |
+
object
|
267 |
+
{
|
268 |
+
width: $icon_size;
|
269 |
+
height: $icon_size;
|
270 |
+
}
|
271 |
+
|
272 |
+
.dashicons-wordpress
|
273 |
+
{
|
274 |
+
font-size: $icon_size - ($wp_logo_padding * 2);
|
275 |
+
background: $wordpress_color;
|
276 |
+
color: #fff;
|
277 |
+
width: $icon_size - ($wp_logo_padding * 2);
|
278 |
+
height: $icon_size - ($wp_logo_padding * 2);
|
279 |
+
padding: $wp_logo_padding;
|
280 |
+
}
|
281 |
+
|
282 |
+
.dashicons-plus
|
283 |
+
{
|
284 |
+
position: absolute;
|
285 |
+
top: 50%;
|
286 |
+
font-size: 30px;
|
287 |
+
margin-top: -10px;
|
288 |
+
color: #bbb;
|
289 |
+
|
290 |
+
&.fs-first
|
291 |
+
{
|
292 |
+
left: 28%;
|
293 |
+
}
|
294 |
+
&.fs-second
|
295 |
+
{
|
296 |
+
left: 65%;
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
.fs-plugin-icon,
|
301 |
+
.fs-connect-logo,
|
302 |
+
.fs-site-icon
|
303 |
+
{
|
304 |
+
border: 1px solid #ccc;
|
305 |
+
padding: 1px;
|
306 |
+
background: #fff;
|
307 |
+
}
|
308 |
+
}
|
309 |
+
|
310 |
+
.fs-terms
|
311 |
+
{
|
312 |
+
text-align: center;
|
313 |
+
font-size: 0.85em;
|
314 |
+
padding: 5px;
|
315 |
+
background: rgba(0, 0, 0, 0.05);
|
316 |
+
|
317 |
+
&, a
|
318 |
+
{
|
319 |
+
color: #999;
|
320 |
+
}
|
321 |
+
|
322 |
+
a
|
323 |
+
{
|
324 |
+
text-decoration: none;
|
325 |
+
}
|
326 |
+
}
|
327 |
+
}
|
328 |
+
|
329 |
+
.rtl
|
330 |
+
{
|
331 |
+
#fs_connect
|
332 |
+
{
|
333 |
+
.fs-actions
|
334 |
+
{
|
335 |
+
padding: 10px 20px;
|
336 |
+
background: #C0C7CA;
|
337 |
+
|
338 |
+
.button
|
339 |
+
{
|
340 |
+
.dashicons
|
341 |
+
{
|
342 |
+
font-size: 37px;
|
343 |
+
margin-left: -8px;
|
344 |
+
margin-right: 12px;
|
345 |
+
}
|
346 |
+
|
347 |
+
&.button-primary
|
348 |
+
{
|
349 |
+
&:after
|
350 |
+
{
|
351 |
+
content: ' \000bb';
|
352 |
+
}
|
353 |
+
|
354 |
+
&.fs-loading
|
355 |
+
{
|
356 |
+
&:after
|
357 |
+
{
|
358 |
+
content: '';
|
359 |
+
}
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
&.button-secondary
|
364 |
+
{
|
365 |
+
float: left;
|
366 |
+
}
|
367 |
+
}
|
368 |
+
}
|
369 |
+
|
370 |
+
.fs-permissions
|
371 |
+
{
|
372 |
+
ul
|
373 |
+
{
|
374 |
+
li
|
375 |
+
{
|
376 |
+
div
|
377 |
+
{
|
378 |
+
margin-right: 55px;
|
379 |
+
margin-left: 0;
|
380 |
+
}
|
381 |
+
|
382 |
+
i.dashicons
|
383 |
+
{
|
384 |
+
float: right;
|
385 |
+
}
|
386 |
+
|
387 |
+
}
|
388 |
+
}
|
389 |
+
}
|
390 |
+
|
391 |
+
.fs-visual
|
392 |
+
{
|
393 |
+
.fs-site-icon
|
394 |
+
{
|
395 |
+
right: 20px;
|
396 |
+
left: auto;
|
397 |
+
}
|
398 |
+
|
399 |
+
.fs-connect-logo
|
400 |
+
{
|
401 |
+
right: auto;
|
402 |
+
left: 20px;
|
403 |
+
}
|
404 |
+
}
|
405 |
+
}
|
406 |
+
}
|
407 |
+
|
408 |
+
#fs_theme_connect_wrapper {
|
409 |
+
position: fixed;
|
410 |
+
top: 0;
|
411 |
+
height: 100%;
|
412 |
+
width: 100%;
|
413 |
+
z-index: 99990;
|
414 |
+
background: rgba(0, 0, 0, 0.75);
|
415 |
+
text-align: center;
|
416 |
+
overflow-y: auto;
|
417 |
+
|
418 |
+
&:before {
|
419 |
+
content: "";
|
420 |
+
display: inline-block;
|
421 |
+
vertical-align: middle;
|
422 |
+
height: 100%;
|
423 |
+
}
|
424 |
+
|
425 |
+
> button.close {
|
426 |
+
color: white;
|
427 |
+
cursor: pointer;
|
428 |
+
height: 40px;
|
429 |
+
width: 40px;
|
430 |
+
position: absolute;
|
431 |
+
right: 0;
|
432 |
+
border: 0;
|
433 |
+
background-color: transparent;
|
434 |
+
top: 32px;
|
435 |
+
}
|
436 |
+
|
437 |
+
#fs_connect {
|
438 |
+
top: 0;
|
439 |
+
text-align: left;
|
440 |
+
display: inline-block;
|
441 |
+
vertical-align: middle;
|
442 |
+
margin-top: 52px;
|
443 |
+
margin-bottom: 20px;
|
444 |
+
|
445 |
+
.fs-terms
|
446 |
+
{
|
447 |
+
background: rgba(140, 140, 140, 0.64);
|
448 |
+
|
449 |
+
&, a
|
450 |
+
{
|
451 |
+
color: #c5c5c5;
|
452 |
+
}
|
453 |
+
}
|
454 |
+
}
|
455 |
+
}
|
456 |
+
|
457 |
+
.wp-pointer-content
|
458 |
+
{
|
459 |
+
#fs_connect
|
460 |
+
{
|
461 |
+
margin: 0;
|
462 |
+
@include box-shadow(none);
|
463 |
+
}
|
464 |
+
}
|
465 |
+
|
466 |
+
.fs-opt-in-pointer
|
467 |
+
{
|
468 |
+
.wp-pointer-content
|
469 |
+
{
|
470 |
+
padding: 0;
|
471 |
+
}
|
472 |
+
|
473 |
+
&.wp-pointer-top
|
474 |
+
{
|
475 |
+
.wp-pointer-arrow
|
476 |
+
{
|
477 |
+
border-bottom-color: #dfdfdf;
|
478 |
+
}
|
479 |
+
.wp-pointer-arrow-inner
|
480 |
+
{
|
481 |
+
border-bottom-color: #fafafa;
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
&.wp-pointer-bottom
|
486 |
+
{
|
487 |
+
.wp-pointer-arrow
|
488 |
+
{
|
489 |
+
border-top-color: #dfdfdf;
|
490 |
+
}
|
491 |
+
.wp-pointer-arrow-inner
|
492 |
+
{
|
493 |
+
border-top-color: #fafafa;
|
494 |
+
}
|
495 |
+
}
|
496 |
+
|
497 |
+
&.wp-pointer-left
|
498 |
+
{
|
499 |
+
.wp-pointer-arrow
|
500 |
+
{
|
501 |
+
border-right-color: #dfdfdf;
|
502 |
+
}
|
503 |
+
.wp-pointer-arrow-inner
|
504 |
+
{
|
505 |
+
border-right-color: #fafafa;
|
506 |
+
}
|
507 |
+
}
|
508 |
+
|
509 |
+
&.wp-pointer-right
|
510 |
+
{
|
511 |
+
.wp-pointer-arrow
|
512 |
+
{
|
513 |
+
border-left-color: #dfdfdf;
|
514 |
+
}
|
515 |
+
.wp-pointer-arrow-inner
|
516 |
+
{
|
517 |
+
border-left-color: #fafafa;
|
518 |
+
}
|
519 |
+
}
|
520 |
+
}
|
freemius/assets/scss/admin/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/assets/scss/customizer.scss
ADDED
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import "start";
|
2 |
+
|
3 |
+
#fs_customizer_upsell {
|
4 |
+
.fs-customizer-plan {
|
5 |
+
padding: 10px 20px 20px 20px;
|
6 |
+
border-radius: 3px;
|
7 |
+
background: #fff;
|
8 |
+
|
9 |
+
h2 {
|
10 |
+
position: relative;
|
11 |
+
margin: 0;
|
12 |
+
line-height: 2em;
|
13 |
+
text-transform: uppercase;
|
14 |
+
|
15 |
+
.button-link {
|
16 |
+
top: -2px;
|
17 |
+
}
|
18 |
+
}
|
19 |
+
}
|
20 |
+
|
21 |
+
.fs-feature {
|
22 |
+
position: relative;
|
23 |
+
}
|
24 |
+
|
25 |
+
.dashicons-yes {
|
26 |
+
color: #0085ba;
|
27 |
+
font-size: 2em;
|
28 |
+
vertical-align: bottom;
|
29 |
+
margin-left: -7px;
|
30 |
+
margin-right: 10px;
|
31 |
+
|
32 |
+
.rtl & {
|
33 |
+
margin-left: 10px;
|
34 |
+
margin-right: -7px;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
|
38 |
+
.dashicons-editor-help
|
39 |
+
{
|
40 |
+
color: #bbb;
|
41 |
+
cursor: help;
|
42 |
+
|
43 |
+
$tooltip-color: #000;
|
44 |
+
|
45 |
+
.fs-feature-desc {
|
46 |
+
opacity: 0;
|
47 |
+
visibility: hidden;
|
48 |
+
@include transition(opacity 0.3s ease-in-out);
|
49 |
+
|
50 |
+
position: absolute;
|
51 |
+
background: $tooltip-color;
|
52 |
+
color: #fff;
|
53 |
+
font-family: 'arial', serif;
|
54 |
+
font-size: 12px;
|
55 |
+
padding: 10px;
|
56 |
+
z-index: 999999;
|
57 |
+
bottom: 100%;
|
58 |
+
margin-bottom: 5px;
|
59 |
+
left: 0;
|
60 |
+
right: 0;
|
61 |
+
@include border-radius(5px);
|
62 |
+
@include box-shadow(1px 1px 1px rgba(0,0,0,0.2));
|
63 |
+
line-height: 1.3em;
|
64 |
+
font-weight: bold;
|
65 |
+
text-align: left;
|
66 |
+
|
67 |
+
.rtl &
|
68 |
+
{
|
69 |
+
text-align: right;
|
70 |
+
}
|
71 |
+
|
72 |
+
&::after {
|
73 |
+
content: ' ';
|
74 |
+
display: block;
|
75 |
+
width: 0;
|
76 |
+
height: 0;
|
77 |
+
border-style: solid;
|
78 |
+
border-width: 5px 5px 0 5px;
|
79 |
+
border-color: $tooltip-color transparent transparent transparent;
|
80 |
+
position: absolute;
|
81 |
+
top: 100%;
|
82 |
+
left: 21px;
|
83 |
+
|
84 |
+
.rtl & {
|
85 |
+
right: 21px;
|
86 |
+
left: auto;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
|
91 |
+
&:hover {
|
92 |
+
.fs-feature-desc {
|
93 |
+
visibility: visible;
|
94 |
+
opacity: 1;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
.button-primary {
|
100 |
+
display: block;
|
101 |
+
text-align: center;
|
102 |
+
margin-top: 10px;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
#fs_customizer_support
|
107 |
+
{
|
108 |
+
display: block !important;
|
109 |
+
|
110 |
+
.button {
|
111 |
+
float: right;
|
112 |
+
}
|
113 |
+
|
114 |
+
.button-group {
|
115 |
+
width: 100%;
|
116 |
+
display: block;
|
117 |
+
margin-top: 10px;
|
118 |
+
|
119 |
+
.button {
|
120 |
+
float: none;
|
121 |
+
width: 50%;
|
122 |
+
text-align: center;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
}
|
freemius/assets/scss/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/composer.json
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "freemius/wordpress-sdk",
|
3 |
+
"description": "Freemius WordPress SDK",
|
4 |
+
"keywords": ["freemius", "wordpress", "plugin", "sdk"],
|
5 |
+
"homepage": "https://freemius.com",
|
6 |
+
"license": "GPL-3.0",
|
7 |
+
"require": {
|
8 |
+
"php": ">=5.2"
|
9 |
+
}
|
10 |
+
}
|
freemius/config.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
@@ -126,6 +126,7 @@
|
|
126 |
/**
|
127 |
* Domain / URL / Address
|
128 |
*/
|
|
|
129 |
define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
|
130 |
define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
|
131 |
|
@@ -230,7 +231,7 @@
|
|
230 |
}
|
231 |
|
232 |
if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
|
233 |
-
define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius:8080' );
|
234 |
}
|
235 |
|
236 |
if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
126 |
/**
|
127 |
* Domain / URL / Address
|
128 |
*/
|
129 |
+
define( 'WP_FS__ROOT_DOMAIN_PRODUCTION', 'freemius.com' );
|
130 |
define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
|
131 |
define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
|
132 |
|
231 |
}
|
232 |
|
233 |
if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
|
234 |
+
define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius-local.com:8080' );
|
235 |
}
|
236 |
|
237 |
if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
|
freemius/gulpfile.js
ADDED
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
var gulp = require('gulp');
|
2 |
+
var path = require('path');
|
3 |
+
var filesystem = require('fs');
|
4 |
+
var wpPot = require('gulp-wp-pot');
|
5 |
+
var gettext = require('gulp-gettext');
|
6 |
+
var sort = require('gulp-sort');
|
7 |
+
var pofill = require('gulp-pofill');
|
8 |
+
var rename = require('gulp-rename');
|
9 |
+
var clean = require('gulp-clean');
|
10 |
+
|
11 |
+
var languagesFolder = './languages/';
|
12 |
+
|
13 |
+
var options = require('./transifex-config.json');
|
14 |
+
|
15 |
+
function getFolders(dir) {
|
16 |
+
return filesystem.readdirSync(dir)
|
17 |
+
.filter(function (file) {
|
18 |
+
return filesystem.statSync(path.join(dir, file)).isDirectory();
|
19 |
+
});
|
20 |
+
}
|
21 |
+
|
22 |
+
var transifex = require('gulp-transifex').createClient(options);
|
23 |
+
|
24 |
+
// Create POT out of i18n.php.
|
25 |
+
gulp.task('prepare-source', function () {
|
26 |
+
gulp.src('**/*.php')
|
27 |
+
.pipe(sort())
|
28 |
+
.pipe(wpPot({
|
29 |
+
destFile : 'freemius.pot',
|
30 |
+
package : 'freemius',
|
31 |
+
bugReport : 'https://github.com/Freemius/wordpress-sdk/issues',
|
32 |
+
lastTranslator : 'Vova Feldman <vova@freemius.com>',
|
33 |
+
team : 'Freemius Team <admin@freemius.com>',
|
34 |
+
/*gettextMethods: {
|
35 |
+
instances: ['this', '_fs'],
|
36 |
+
methods: [
|
37 |
+
'get_text_inline'
|
38 |
+
]
|
39 |
+
},*/
|
40 |
+
gettextFunctions: [
|
41 |
+
{name: 'get_text_inline'},
|
42 |
+
|
43 |
+
{name: 'fs_text_inline'},
|
44 |
+
{name: 'fs_echo_inline'},
|
45 |
+
{name: 'fs_esc_js_inline'},
|
46 |
+
{name: 'fs_esc_attr_inline'},
|
47 |
+
{name: 'fs_esc_attr_echo_inline'},
|
48 |
+
{name: 'fs_esc_html_inline'},
|
49 |
+
{name: 'fs_esc_html_echo_inline'},
|
50 |
+
|
51 |
+
{name: 'get_text_x_inline', context: 2},
|
52 |
+
{name: 'fs_text_x_inline', context: 2},
|
53 |
+
{name: 'fs_echo_x_inline', context: 2},
|
54 |
+
{name: 'fs_esc_attr_x_inline', context: 2},
|
55 |
+
{name: 'fs_esc_js_x_inline', context: 2},
|
56 |
+
{name: 'fs_esc_js_echo_x_inline', context: 2},
|
57 |
+
{name: 'fs_esc_html_x_inline', context: 2},
|
58 |
+
{name: 'fs_esc_html_echo_x_inline', context: 2}
|
59 |
+
/*,
|
60 |
+
|
61 |
+
|
62 |
+
{name: '_fs_text'},
|
63 |
+
{name: '_fs_x', context: 2},
|
64 |
+
{name: '_fs_echo'},
|
65 |
+
{name: '_fs_esc_attr'},
|
66 |
+
{name: '_fs_esc_attr_echo'},
|
67 |
+
{name: '_fs_esc_html'},
|
68 |
+
{name: '_fs_esc_html_echo'},
|
69 |
+
{name: '_fs_ex', context: 2},
|
70 |
+
{name: '_fs_esc_attr_x', context: 2},
|
71 |
+
{name: '_fs_esc_html_x', context: 2},
|
72 |
+
|
73 |
+
{name: '_fs_n', plural: 2},
|
74 |
+
{name: '_fs_n_noop', plural: 2},
|
75 |
+
{name: '_fs_nx', plural: 2, context: 4},
|
76 |
+
{name: '_fs_nx_noop', plural: 2, context: 3}*/
|
77 |
+
]
|
78 |
+
}))
|
79 |
+
.pipe(gulp.dest(languagesFolder + 'freemius.pot'));
|
80 |
+
|
81 |
+
// Create English PO out of the POT.
|
82 |
+
return gulp.src(languagesFolder + 'freemius.pot')
|
83 |
+
.pipe(pofill({
|
84 |
+
items: function (item) {
|
85 |
+
// If msgstr is empty, use identity translation
|
86 |
+
if (!item.msgstr.length) {
|
87 |
+
item.msgstr = [''];
|
88 |
+
}
|
89 |
+
if (!item.msgstr[0]) {
|
90 |
+
item.msgstr[0] = item.msgid;
|
91 |
+
}
|
92 |
+
return item;
|
93 |
+
}
|
94 |
+
}))
|
95 |
+
.pipe(rename('freemius-en.po'))
|
96 |
+
.pipe(gulp.dest(languagesFolder));
|
97 |
+
});
|
98 |
+
|
99 |
+
// Push updated po resource to transifex.
|
100 |
+
gulp.task('update-transifex', ['prepare-source'], function () {
|
101 |
+
return gulp.src(languagesFolder + 'freemius-en.po')
|
102 |
+
.pipe(transifex.pushResource());
|
103 |
+
});
|
104 |
+
|
105 |
+
// Download latest *.po translations.
|
106 |
+
gulp.task('download-translations', ['update-transifex'], function () {
|
107 |
+
return gulp.src(languagesFolder + 'freemius-en.po')
|
108 |
+
.pipe(transifex.pullResource());
|
109 |
+
});
|
110 |
+
|
111 |
+
// Move translations to languages root.
|
112 |
+
gulp.task('prepare-translations', ['download-translations'], function () {
|
113 |
+
var folders = getFolders(languagesFolder);
|
114 |
+
|
115 |
+
return folders.map(function (folder) {
|
116 |
+
return gulp.src(path.join(languagesFolder, folder, 'freemius-en.po'))
|
117 |
+
.pipe(rename('freemius-' + folder + '.po'))
|
118 |
+
.pipe(gulp.dest(languagesFolder));
|
119 |
+
});
|
120 |
+
});
|
121 |
+
|
122 |
+
// Feel up empty translations with English.
|
123 |
+
gulp.task('translations-feelup', ['prepare-translations'], function () {
|
124 |
+
return gulp.src(languagesFolder + '*.po')
|
125 |
+
.pipe(pofill({
|
126 |
+
items: function (item) {
|
127 |
+
// If msgstr is empty, use identity translation
|
128 |
+
if (0 == item.msgstr.length) {
|
129 |
+
item.msgstr = [''];
|
130 |
+
}
|
131 |
+
if (0 == item.msgstr[0].length) {
|
132 |
+
// item.msgid[0] = item.msgid;
|
133 |
+
item.msgstr[0] = item.msgid;
|
134 |
+
}
|
135 |
+
return item;
|
136 |
+
}
|
137 |
+
}))
|
138 |
+
.pipe(gulp.dest(languagesFolder));
|
139 |
+
});
|
140 |
+
|
141 |
+
// Cleanup temporary translation folders.
|
142 |
+
gulp.task('cleanup', ['prepare-translations'], function () {
|
143 |
+
var folders = getFolders(languagesFolder);
|
144 |
+
|
145 |
+
return folders.map(function (folder) {
|
146 |
+
return gulp.src(path.join(languagesFolder, folder), {read: false})
|
147 |
+
.pipe(clean());
|
148 |
+
});
|
149 |
+
});
|
150 |
+
|
151 |
+
// Compile *.po to *.mo binaries for usage.
|
152 |
+
gulp.task('compile-translations', ['translations-feelup'], function () {
|
153 |
+
// Compile POs to MOs.
|
154 |
+
return gulp.src(languagesFolder + '*.po')
|
155 |
+
.pipe(gettext())
|
156 |
+
.pipe(gulp.dest(languagesFolder))
|
157 |
+
});
|
158 |
+
|
159 |
+
gulp.task('default', [], function () {
|
160 |
+
gulp.run('prepare-source');
|
161 |
+
gulp.run('update-transifex');
|
162 |
+
gulp.run('download-translations');
|
163 |
+
gulp.run('prepare-translations');
|
164 |
+
gulp.run('translations-feelup');
|
165 |
+
gulp.run('cleanup');
|
166 |
+
gulp.run('compile-translations');
|
167 |
+
});
|
freemius/includes/class-freemius-abstract.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.7
|
7 |
*/
|
8 |
|
@@ -594,4 +594,4 @@
|
|
594 |
abstract function is_business();
|
595 |
|
596 |
#endregion
|
597 |
-
}
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.7
|
7 |
*/
|
8 |
|
594 |
abstract function is_business();
|
595 |
|
596 |
#endregion
|
597 |
+
}
|
freemius/includes/class-freemius.php
CHANGED
@@ -1,12315 +1,14305 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package Freemius
|
4 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
-
* @since 1.0.3
|
7 |
-
*/
|
8 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
-
exit;
|
10 |
-
}
|
11 |
-
|
12 |
-
// "final class"
|
13 |
-
class Freemius extends Freemius_Abstract {
|
14 |
-
/**
|
15 |
-
* SDK Version
|
16 |
-
*
|
17 |
-
* @var string
|
18 |
-
*/
|
19 |
-
public $version = WP_FS__SDK_VERSION;
|
20 |
-
|
21 |
-
#region Plugin Info
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @since 1.0.1
|
25 |
-
*
|
26 |
-
* @var string
|
27 |
-
*/
|
28 |
-
private $_slug;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* @since 1.0.0
|
32 |
-
*
|
33 |
-
* @var string
|
34 |
-
*/
|
35 |
-
private $_plugin_basename;
|
36 |
-
/**
|
37 |
-
* @since 1.0.0
|
38 |
-
*
|
39 |
-
* @var string
|
40 |
-
*/
|
41 |
-
private $_free_plugin_basename;
|
42 |
-
/**
|
43 |
-
* @since 1.0.0
|
44 |
-
*
|
45 |
-
* @var string
|
46 |
-
*/
|
47 |
-
private $_plugin_dir_path;
|
48 |
-
/**
|
49 |
-
* @since 1.0.0
|
50 |
-
*
|
51 |
-
* @var string
|
52 |
-
*/
|
53 |
-
private $_plugin_dir_name;
|
54 |
-
/**
|
55 |
-
* @since 1.0.0
|
56 |
-
*
|
57 |
-
* @var string
|
58 |
-
*/
|
59 |
-
private $_plugin_main_file_path;
|
60 |
-
/**
|
61 |
-
* @var string[]
|
62 |
-
*/
|
63 |
-
private $_plugin_data;
|
64 |
-
/**
|
65 |
-
* @since 1.0.9
|
66 |
-
*
|
67 |
-
* @var string
|
68 |
-
*/
|
69 |
-
private $_plugin_name;
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
*
|
82 |
-
*
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
*
|
89 |
-
* @var bool If false,
|
90 |
-
*/
|
91 |
-
private $
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @since 1.0.9
|
95 |
-
* @var bool
|
96 |
-
*/
|
97 |
-
private $
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @since 1.
|
101 |
-
* @var bool Hints the SDK if plugin
|
102 |
-
*/
|
103 |
-
private $
|
104 |
-
|
105 |
-
/**
|
106 |
-
* @since 1.1.
|
107 |
-
* @var bool Hints the SDK if plugin
|
108 |
-
*/
|
109 |
-
private $
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @since 1.
|
113 |
-
* @var bool Hints the SDK if plugin have
|
114 |
-
*/
|
115 |
-
private $
|
116 |
-
|
117 |
-
/**
|
118 |
-
* @since 1.2.1.6
|
119 |
-
* @var bool Hints the SDK if plugin
|
120 |
-
*/
|
121 |
-
private $
|
122 |
-
|
123 |
-
/**
|
124 |
-
* @since 1.
|
125 |
-
* @var bool Hints the SDK if
|
126 |
-
*/
|
127 |
-
private $
|
128 |
-
|
129 |
-
/**
|
130 |
-
* @since 1.
|
131 |
-
* @var
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
* @
|
138 |
-
*
|
139 |
-
*/
|
140 |
-
private $
|
141 |
-
|
142 |
-
/**
|
143 |
-
* @since 1.
|
144 |
-
* @var bool Hints the SDK if the
|
145 |
-
*/
|
146 |
-
private $
|
147 |
-
|
148 |
-
/**
|
149 |
-
* @since 1.0.7
|
150 |
-
* @var bool Hints the SDK if the plugin is
|
151 |
-
*/
|
152 |
-
private $
|
153 |
-
|
154 |
-
/**
|
155 |
-
* @since 1.
|
156 |
-
* @var
|
157 |
-
*/
|
158 |
-
private $
|
159 |
-
|
160 |
-
/**
|
161 |
-
* @
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
*
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
/**
|
172 |
-
* @since 1.
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
/**
|
178 |
-
* @since 1.0.
|
179 |
-
*
|
180 |
-
* @var
|
181 |
-
*/
|
182 |
-
private $
|
183 |
-
/**
|
184 |
-
* @since 1.
|
185 |
-
*
|
186 |
-
* @var
|
187 |
-
*/
|
188 |
-
private $
|
189 |
-
/**
|
190 |
-
* @since 1.0.
|
191 |
-
*
|
192 |
-
* @var
|
193 |
-
*/
|
194 |
-
private $
|
195 |
-
/**
|
196 |
-
* @since 1.
|
197 |
-
*
|
198 |
-
* @var
|
199 |
-
*/
|
200 |
-
private $
|
201 |
-
/**
|
202 |
-
* @since 1.0.1
|
203 |
-
*
|
204 |
-
* @var
|
205 |
-
*/
|
206 |
-
private $
|
207 |
-
/**
|
208 |
-
* @since 1.0.
|
209 |
-
*
|
210 |
-
* @var
|
211 |
-
*/
|
212 |
-
private $
|
213 |
-
/**
|
214 |
-
* @
|
215 |
-
*
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
/**
|
220 |
-
* @since 1.0.
|
221 |
-
*
|
222 |
-
* @var
|
223 |
-
*/
|
224 |
-
private $
|
225 |
-
|
226 |
-
|
227 |
-
* @
|
228 |
-
*/
|
229 |
-
private $
|
230 |
-
|
231 |
-
/**
|
232 |
-
* @since 1.1
|
233 |
-
*
|
234 |
-
* @var
|
235 |
-
*/
|
236 |
-
private
|
237 |
-
|
238 |
-
/**
|
239 |
-
* @var
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
*
|
246 |
-
* @
|
247 |
-
*/
|
248 |
-
private static $
|
249 |
-
|
250 |
-
/**
|
251 |
-
* @var
|
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 |
-
$this->
|
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 |
-
if (
|
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 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
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 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
/**
|
634 |
-
* @author Vova Feldman (@svovaf)
|
635 |
-
* @since 1.
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
*
|
666 |
-
*
|
667 |
-
*
|
668 |
-
*
|
669 |
-
*
|
670 |
-
*
|
671 |
-
*
|
672 |
-
*
|
673 |
-
*
|
674 |
-
*
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
*
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
if (
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
}
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
|
815 |
-
|
816 |
-
|
817 |
-
|
818 |
-
);
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
if (
|
894 |
-
|
895 |
-
}
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
-
|
955 |
-
|
956 |
-
|
957 |
-
|
958 |
-
|
959 |
-
|
960 |
-
|
961 |
-
|
962 |
-
|
963 |
-
|
964 |
-
|
965 |
-
|
966 |
-
/**
|
967 |
-
*
|
968 |
-
*
|
969 |
-
*
|
970 |
-
|
971 |
-
|
972 |
-
|
973 |
-
|
974 |
-
|
975 |
-
|
976 |
-
|
977 |
-
$
|
978 |
-
|
979 |
-
|
980 |
-
|
981 |
-
|
982 |
-
|
983 |
-
|
984 |
-
|
985 |
-
|
986 |
-
|
987 |
-
|
988 |
-
|
989 |
-
|
990 |
-
|
991 |
-
|
992 |
-
|
993 |
-
|
994 |
-
|
995 |
-
|
996 |
-
|
997 |
-
|
998 |
-
|
999 |
-
|
1000 |
-
|
1001 |
-
|
1002 |
-
|
1003 |
-
|
1004 |
-
|
1005 |
-
|
1006 |
-
|
1007 |
-
|
1008 |
-
|
1009 |
-
|
1010 |
-
|
1011 |
-
|
1012 |
-
|
1013 |
-
|
1014 |
-
|
1015 |
-
|
1016 |
-
|
1017 |
-
|
1018 |
-
|
1019 |
-
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
|
1024 |
-
|
1025 |
-
|
1026 |
-
|
1027 |
-
|
1028 |
-
|
1029 |
-
|
1030 |
-
|
1031 |
-
|
1032 |
-
|
1033 |
-
|
1034 |
-
|
1035 |
-
|
1036 |
-
|
1037 |
-
|
1038 |
-
*
|
1039 |
-
*
|
1040 |
-
|
1041 |
-
|
1042 |
-
|
1043 |
-
|
1044 |
-
$
|
1045 |
-
|
1046 |
-
|
1047 |
-
|
1048 |
-
|
1049 |
-
|
1050 |
-
|
1051 |
-
|
1052 |
-
|
1053 |
-
|
1054 |
-
|
1055 |
-
|
1056 |
-
|
1057 |
-
|
1058 |
-
|
1059 |
-
|
1060 |
-
|
1061 |
-
|
1062 |
-
|
1063 |
-
|
1064 |
-
|
1065 |
-
|
1066 |
-
|
1067 |
-
|
1068 |
-
|
1069 |
-
|
1070 |
-
|
1071 |
-
|
1072 |
-
|
1073 |
-
|
1074 |
-
|
1075 |
-
|
1076 |
-
|
1077 |
-
|
1078 |
-
|
1079 |
-
|
1080 |
-
|
1081 |
-
*
|
1082 |
-
*
|
1083 |
-
* @
|
1084 |
-
*
|
1085 |
-
*
|
1086 |
-
* @
|
1087 |
-
*
|
1088 |
-
*
|
1089 |
-
|
1090 |
-
|
1091 |
-
|
1092 |
-
|
1093 |
-
|
1094 |
-
|
1095 |
-
$
|
1096 |
-
|
1097 |
-
|
1098 |
-
|
1099 |
-
|
1100 |
-
|
1101 |
-
|
1102 |
-
|
1103 |
-
|
1104 |
-
|
1105 |
-
|
1106 |
-
|
1107 |
-
|
1108 |
-
|
1109 |
-
|
1110 |
-
|
1111 |
-
|
1112 |
-
|
1113 |
-
|
1114 |
-
|
1115 |
-
|
1116 |
-
|
1117 |
-
|
1118 |
-
|
1119 |
-
|
1120 |
-
|
1121 |
-
|
1122 |
-
|
1123 |
-
|
1124 |
-
|
1125 |
-
|
1126 |
-
|
1127 |
-
|
1128 |
-
|
1129 |
-
|
1130 |
-
|
1131 |
-
|
1132 |
-
|
1133 |
-
|
1134 |
-
|
1135 |
-
|
1136 |
-
|
1137 |
-
|
1138 |
-
|
1139 |
-
|
1140 |
-
|
1141 |
-
|
1142 |
-
|
1143 |
-
|
1144 |
-
|
1145 |
-
|
1146 |
-
|
1147 |
-
|
1148 |
-
|
1149 |
-
|
1150 |
-
|
1151 |
-
|
1152 |
-
|
1153 |
-
|
1154 |
-
|
1155 |
-
|
1156 |
-
|
1157 |
-
|
1158 |
-
|
1159 |
-
|
1160 |
-
|
1161 |
-
|
1162 |
-
|
1163 |
-
|
1164 |
-
|
1165 |
-
|
1166 |
-
|
1167 |
-
|
1168 |
-
|
1169 |
-
|
1170 |
-
|
1171 |
-
|
1172 |
-
|
1173 |
-
|
1174 |
-
|
1175 |
-
|
1176 |
-
|
1177 |
-
|
1178 |
-
|
1179 |
-
|
1180 |
-
|
1181 |
-
|
1182 |
-
|
1183 |
-
|
1184 |
-
|
1185 |
-
|
1186 |
-
|
1187 |
-
|
1188 |
-
|
1189 |
-
|
1190 |
-
|
1191 |
-
|
1192 |
-
|
1193 |
-
|
1194 |
-
|
1195 |
-
|
1196 |
-
|
1197 |
-
|
1198 |
-
|
1199 |
-
|
1200 |
-
|
1201 |
-
|
1202 |
-
|
1203 |
-
|
1204 |
-
|
1205 |
-
|
1206 |
-
|
1207 |
-
|
1208 |
-
|
1209 |
-
|
1210 |
-
|
1211 |
-
|
1212 |
-
|
1213 |
-
|
1214 |
-
|
1215 |
-
|
1216 |
-
|
1217 |
-
|
1218 |
-
|
1219 |
-
|
1220 |
-
|
1221 |
-
|
1222 |
-
|
1223 |
-
|
1224 |
-
|
1225 |
-
|
1226 |
-
|
1227 |
-
|
1228 |
-
|
1229 |
-
|
1230 |
-
|
1231 |
-
|
1232 |
-
|
1233 |
-
|
1234 |
-
|
1235 |
-
|
1236 |
-
|
1237 |
-
|
1238 |
-
|
1239 |
-
|
1240 |
-
|
1241 |
-
|
1242 |
-
|
1243 |
-
|
1244 |
-
|
1245 |
-
|
1246 |
-
|
1247 |
-
|
1248 |
-
|
1249 |
-
|
1250 |
-
|
1251 |
-
|
1252 |
-
|
1253 |
-
|
1254 |
-
|
1255 |
-
*
|
1256 |
-
*
|
1257 |
-
*
|
1258 |
-
* @
|
1259 |
-
*
|
1260 |
-
*
|
1261 |
-
|
1262 |
-
|
1263 |
-
|
1264 |
-
|
1265 |
-
|
1266 |
-
|
1267 |
-
|
1268 |
-
|
1269 |
-
|
1270 |
-
|
1271 |
-
|
1272 |
-
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
$
|
1276 |
-
|
1277 |
-
|
1278 |
-
|
1279 |
-
|
1280 |
-
|
1281 |
-
|
1282 |
-
|
1283 |
-
|
1284 |
-
|
1285 |
-
|
1286 |
-
|
1287 |
-
|
1288 |
-
|
1289 |
-
|
1290 |
-
|
1291 |
-
|
1292 |
-
|
1293 |
-
|
1294 |
-
|
1295 |
-
|
1296 |
-
|
1297 |
-
|
1298 |
-
|
1299 |
-
|
1300 |
-
|
1301 |
-
|
1302 |
-
$
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
1308 |
-
|
1309 |
-
|
1310 |
-
|
1311 |
-
|
1312 |
-
|
1313 |
-
|
1314 |
-
|
1315 |
-
|
1316 |
-
|
1317 |
-
|
1318 |
-
|
1319 |
-
|
1320 |
-
|
1321 |
-
|
1322 |
-
|
1323 |
-
|
1324 |
-
|
1325 |
-
|
1326 |
-
|
1327 |
-
|
1328 |
-
|
1329 |
-
|
1330 |
-
|
1331 |
-
|
1332 |
-
|
1333 |
-
|
1334 |
-
|
1335 |
-
|
1336 |
-
|
1337 |
-
|
1338 |
-
|
1339 |
-
}
|
1340 |
-
|
1341 |
-
|
1342 |
-
|
1343 |
-
|
1344 |
-
|
1345 |
-
|
1346 |
-
|
1347 |
-
|
1348 |
-
|
1349 |
-
|
1350 |
-
|
1351 |
-
|
1352 |
-
|
1353 |
-
|
1354 |
-
|
1355 |
-
|
1356 |
-
|
1357 |
-
|
1358 |
-
|
1359 |
-
|
1360 |
-
|
1361 |
-
|
1362 |
-
|
1363 |
-
|
1364 |
-
|
1365 |
-
|
1366 |
-
|
1367 |
-
|
1368 |
-
|
1369 |
-
|
1370 |
-
|
1371 |
-
|
1372 |
-
|
1373 |
-
|
1374 |
-
|
1375 |
-
|
1376 |
-
|
1377 |
-
|
1378 |
-
|
1379 |
-
|
1380 |
-
|
1381 |
-
|
1382 |
-
|
1383 |
-
|
1384 |
-
|
1385 |
-
|
1386 |
-
|
1387 |
-
|
1388 |
-
|
1389 |
-
|
1390 |
-
|
1391 |
-
|
1392 |
-
|
1393 |
-
|
1394 |
-
|
1395 |
-
|
1396 |
-
|
1397 |
-
|
1398 |
-
|
1399 |
-
|
1400 |
-
|
1401 |
-
|
1402 |
-
|
1403 |
-
|
1404 |
-
|
1405 |
-
|
1406 |
-
|
1407 |
-
|
1408 |
-
|
1409 |
-
|
1410 |
-
|
1411 |
-
|
1412 |
-
|
1413 |
-
|
1414 |
-
|
1415 |
-
|
1416 |
-
|
1417 |
-
|
1418 |
-
|
1419 |
-
|
1420 |
-
|
1421 |
-
|
1422 |
-
|
1423 |
-
|
1424 |
-
|
1425 |
-
|
1426 |
-
|
1427 |
-
|
1428 |
-
|
1429 |
-
|
1430 |
-
|
1431 |
-
|
1432 |
-
|
1433 |
-
|
1434 |
-
|
1435 |
-
|
1436 |
-
|
1437 |
-
|
1438 |
-
|
1439 |
-
|
1440 |
-
|
1441 |
-
|
1442 |
-
|
1443 |
-
|
1444 |
-
|
1445 |
-
|
1446 |
-
|
1447 |
-
|
1448 |
-
|
1449 |
-
|
1450 |
-
|
1451 |
-
|
1452 |
-
|
1453 |
-
|
1454 |
-
|
1455 |
-
|
1456 |
-
|
1457 |
-
|
1458 |
-
false
|
1459 |
-
$
|
1460 |
-
|
1461 |
-
|
1462 |
-
|
1463 |
-
|
1464 |
-
|
1465 |
-
|
1466 |
-
|
1467 |
-
|
1468 |
-
|
1469 |
-
|
1470 |
-
|
1471 |
-
|
1472 |
-
|
1473 |
-
|
1474 |
-
|
1475 |
-
|
1476 |
-
|
1477 |
-
|
1478 |
-
|
1479 |
-
|
1480 |
-
|
1481 |
-
|
1482 |
-
|
1483 |
-
|
1484 |
-
|
1485 |
-
|
1486 |
-
|
1487 |
-
|
1488 |
-
|
1489 |
-
|
1490 |
-
|
1491 |
-
|
1492 |
-
|
1493 |
-
|
1494 |
-
|
1495 |
-
|
1496 |
-
|
1497 |
-
|
1498 |
-
|
1499 |
-
|
1500 |
-
|
1501 |
-
|
1502 |
-
|
1503 |
-
|
1504 |
-
|
1505 |
-
|
1506 |
-
|
1507 |
-
|
1508 |
-
|
1509 |
-
|
1510 |
-
|
1511 |
-
|
1512 |
-
|
1513 |
-
|
1514 |
-
|
1515 |
-
|
1516 |
-
|
1517 |
-
|
1518 |
-
|
1519 |
-
|
1520 |
-
|
1521 |
-
|
1522 |
-
|
1523 |
-
|
1524 |
-
|
1525 |
-
|
1526 |
-
|
1527 |
-
}
|
1528 |
-
|
1529 |
-
/**
|
1530 |
-
* @author
|
1531 |
-
* @since 1.2.
|
1532 |
-
|
1533 |
-
|
1534 |
-
|
1535 |
-
|
1536 |
-
|
1537 |
-
|
1538 |
-
)
|
1539 |
-
|
1540 |
-
|
1541 |
-
|
1542 |
-
|
1543 |
-
|
1544 |
-
|
1545 |
-
|
1546 |
-
|
1547 |
-
|
1548 |
-
|
1549 |
-
|
1550 |
-
|
1551 |
-
|
1552 |
-
|
1553 |
-
|
1554 |
-
|
1555 |
-
|
1556 |
-
|
1557 |
-
|
1558 |
-
|
1559 |
-
|
1560 |
-
|
1561 |
-
|
1562 |
-
|
1563 |
-
|
1564 |
-
|
1565 |
-
|
1566 |
-
|
1567 |
-
|
1568 |
-
* @
|
1569 |
-
*
|
1570 |
-
|
1571 |
-
|
1572 |
-
|
1573 |
-
|
1574 |
-
|
1575 |
-
|
1576 |
-
|
1577 |
-
|
1578 |
-
|
1579 |
-
|
1580 |
-
}
|
1581 |
-
|
1582 |
-
|
1583 |
-
|
1584 |
-
* @
|
1585 |
-
*
|
1586 |
-
|
1587 |
-
|
1588 |
-
|
1589 |
-
|
1590 |
-
|
1591 |
-
|
1592 |
-
|
1593 |
-
|
1594 |
-
|
1595 |
-
|
1596 |
-
|
1597 |
-
|
1598 |
-
|
1599 |
-
|
1600 |
-
|
1601 |
-
|
1602 |
-
|
1603 |
-
|
1604 |
-
|
1605 |
-
|
1606 |
-
|
1607 |
-
|
1608 |
-
|
1609 |
-
|
1610 |
-
|
1611 |
-
|
1612 |
-
|
1613 |
-
|
1614 |
-
|
1615 |
-
|
1616 |
-
|
1617 |
-
|
1618 |
-
|
1619 |
-
|
1620 |
-
|
1621 |
-
|
1622 |
-
|
1623 |
-
|
1624 |
-
|
1625 |
-
|
1626 |
-
|
1627 |
-
|
1628 |
-
|
1629 |
-
|
1630 |
-
|
1631 |
-
|
1632 |
-
|
1633 |
-
|
1634 |
-
|
1635 |
-
|
1636 |
-
|
1637 |
-
|
1638 |
-
|
1639 |
-
|
1640 |
-
|
1641 |
-
|
1642 |
-
|
1643 |
-
|
1644 |
-
|
1645 |
-
|
1646 |
-
|
1647 |
-
|
1648 |
-
|
1649 |
-
|
1650 |
-
*
|
1651 |
-
*
|
1652 |
-
*
|
1653 |
-
|
1654 |
-
|
1655 |
-
|
1656 |
-
|
1657 |
-
|
1658 |
-
|
1659 |
-
|
1660 |
-
|
1661 |
-
|
1662 |
-
|
1663 |
-
|
1664 |
-
|
1665 |
-
|
1666 |
-
|
1667 |
-
|
1668 |
-
|
1669 |
-
|
1670 |
-
|
1671 |
-
|
1672 |
-
|
1673 |
-
|
1674 |
-
return
|
1675 |
-
|
1676 |
-
|
1677 |
-
|
1678 |
-
|
1679 |
-
|
1680 |
-
|
1681 |
-
|
1682 |
-
|
1683 |
-
*
|
1684 |
-
|
1685 |
-
|
1686 |
-
|
1687 |
-
|
1688 |
-
|
1689 |
-
|
1690 |
-
|
1691 |
-
if (
|
1692 |
-
|
1693 |
-
|
1694 |
-
|
1695 |
-
|
1696 |
-
|
1697 |
-
|
1698 |
-
|
1699 |
-
|
1700 |
-
|
1701 |
-
|
1702 |
-
|
1703 |
-
|
1704 |
-
|
1705 |
-
|
1706 |
-
|
1707 |
-
|
1708 |
-
|
1709 |
-
|
1710 |
-
|
1711 |
-
|
1712 |
-
|
1713 |
-
|
1714 |
-
|
1715 |
-
|
1716 |
-
|
1717 |
-
|
1718 |
-
|
1719 |
-
|
1720 |
-
|
1721 |
-
|
1722 |
-
|
1723 |
-
|
1724 |
-
$
|
1725 |
-
|
1726 |
-
|
1727 |
-
|
1728 |
-
|
1729 |
-
|
1730 |
-
|
1731 |
-
|
1732 |
-
|
1733 |
-
|
1734 |
-
|
1735 |
-
|
1736 |
-
|
1737 |
-
|
1738 |
-
|
1739 |
-
|
1740 |
-
|
1741 |
-
|
1742 |
-
|
1743 |
-
|
1744 |
-
|
1745 |
-
|
1746 |
-
|
1747 |
-
|
1748 |
-
|
1749 |
-
|
1750 |
-
|
1751 |
-
|
1752 |
-
|
1753 |
-
|
1754 |
-
|
1755 |
-
|
1756 |
-
|
1757 |
-
|
1758 |
-
|
1759 |
-
);
|
1760 |
-
|
1761 |
-
|
1762 |
-
|
1763 |
-
|
1764 |
-
|
1765 |
-
|
1766 |
-
|
1767 |
-
|
1768 |
-
|
1769 |
-
|
1770 |
-
|
1771 |
-
|
1772 |
-
|
1773 |
-
|
1774 |
-
|
1775 |
-
|
1776 |
-
|
1777 |
-
|
1778 |
-
|
1779 |
-
|
1780 |
-
|
1781 |
-
|
1782 |
-
)
|
1783 |
-
|
1784 |
-
|
1785 |
-
|
1786 |
-
|
1787 |
-
|
1788 |
-
|
1789 |
-
|
1790 |
-
|
1791 |
-
|
1792 |
-
|
1793 |
-
|
1794 |
-
|
1795 |
-
|
1796 |
-
|
1797 |
-
|
1798 |
-
|
1799 |
-
|
1800 |
-
|
1801 |
-
|
1802 |
-
|
1803 |
-
|
1804 |
-
|
1805 |
-
|
1806 |
-
|
1807 |
-
|
1808 |
-
|
1809 |
-
|
1810 |
-
|
1811 |
-
|
1812 |
-
|
1813 |
-
|
1814 |
-
*
|
1815 |
-
* @
|
1816 |
-
*
|
1817 |
-
*
|
1818 |
-
* @param
|
1819 |
-
|
1820 |
-
|
1821 |
-
|
1822 |
-
|
1823 |
-
|
1824 |
-
|
1825 |
-
|
1826 |
-
|
1827 |
-
|
1828 |
-
|
1829 |
-
|
1830 |
-
|
1831 |
-
|
1832 |
-
|
1833 |
-
|
1834 |
-
|
1835 |
-
|
1836 |
-
|
1837 |
-
|
1838 |
-
|
1839 |
-
|
1840 |
-
|
1841 |
-
|
1842 |
-
|
1843 |
-
|
1844 |
-
//
|
1845 |
-
|
1846 |
-
|
1847 |
-
|
1848 |
-
$
|
1849 |
-
|
1850 |
-
|
1851 |
-
|
1852 |
-
|
1853 |
-
|
1854 |
-
|
1855 |
-
|
1856 |
-
|
1857 |
-
|
1858 |
-
|
1859 |
-
|
1860 |
-
|
1861 |
-
|
1862 |
-
|
1863 |
-
|
1864 |
-
|
1865 |
-
|
1866 |
-
|
1867 |
-
|
1868 |
-
|
1869 |
-
|
1870 |
-
|
1871 |
-
|
1872 |
-
|
1873 |
-
|
1874 |
-
|
1875 |
-
|
1876 |
-
|
1877 |
-
|
1878 |
-
|
1879 |
-
|
1880 |
-
|
1881 |
-
|
1882 |
-
|
1883 |
-
|
1884 |
-
|
1885 |
-
|
1886 |
-
|
1887 |
-
|
1888 |
-
|
1889 |
-
|
1890 |
-
|
1891 |
-
|
1892 |
-
|
1893 |
-
|
1894 |
-
|
1895 |
-
|
1896 |
-
|
1897 |
-
|
1898 |
-
|
1899 |
-
|
1900 |
-
|
1901 |
-
|
1902 |
-
|
1903 |
-
|
1904 |
-
|
1905 |
-
|
1906 |
-
|
1907 |
-
|
1908 |
-
|
1909 |
-
|
1910 |
-
|
1911 |
-
|
1912 |
-
|
1913 |
-
|
1914 |
-
|
1915 |
-
|
1916 |
-
|
1917 |
-
|
1918 |
-
|
1919 |
-
|
1920 |
-
|
1921 |
-
|
1922 |
-
|
1923 |
-
|
1924 |
-
|
1925 |
-
|
1926 |
-
*
|
1927 |
-
* @
|
1928 |
-
|
1929 |
-
|
1930 |
-
|
1931 |
-
|
1932 |
-
|
1933 |
-
return;
|
1934 |
-
}
|
1935 |
-
|
1936 |
-
|
1937 |
-
|
1938 |
-
|
1939 |
-
|
1940 |
-
|
1941 |
-
//
|
1942 |
-
|
1943 |
-
|
1944 |
-
|
1945 |
-
|
1946 |
-
|
1947 |
-
|
1948 |
-
|
1949 |
-
|
1950 |
-
|
1951 |
-
|
1952 |
-
|
1953 |
-
|
1954 |
-
|
1955 |
-
|
1956 |
-
|
1957 |
-
|
1958 |
-
|
1959 |
-
|
1960 |
-
|
1961 |
-
|
1962 |
-
|
1963 |
-
|
1964 |
-
|
1965 |
-
|
1966 |
-
|
1967 |
-
|
1968 |
-
|
1969 |
-
|
1970 |
-
|
1971 |
-
|
1972 |
-
|
1973 |
-
|
1974 |
-
|
1975 |
-
|
1976 |
-
|
1977 |
-
|
1978 |
-
|
1979 |
-
|
1980 |
-
|
1981 |
-
|
1982 |
-
|
1983 |
-
|
1984 |
-
|
1985 |
-
|
1986 |
-
|
1987 |
-
|
1988 |
-
|
1989 |
-
|
1990 |
-
|
1991 |
-
|
1992 |
-
|
1993 |
-
|
1994 |
-
|
1995 |
-
|
1996 |
-
|
1997 |
-
|
1998 |
-
|
1999 |
-
|
2000 |
-
|
2001 |
-
|
2002 |
-
|
2003 |
-
|
2004 |
-
|
2005 |
-
|
2006 |
-
|
2007 |
-
|
2008 |
-
|
2009 |
-
|
2010 |
-
|
2011 |
-
|
2012 |
-
|
2013 |
-
|
2014 |
-
|
2015 |
-
|
2016 |
-
|
2017 |
-
|
2018 |
-
|
2019 |
-
|
2020 |
-
|
2021 |
-
|
2022 |
-
|
2023 |
-
|
2024 |
-
|
2025 |
-
|
2026 |
-
|
2027 |
-
|
2028 |
-
|
2029 |
-
|
2030 |
-
|
2031 |
-
|
2032 |
-
|
2033 |
-
|
2034 |
-
|
2035 |
-
|
2036 |
-
|
2037 |
-
|
2038 |
-
|
2039 |
-
|
2040 |
-
|
2041 |
-
|
2042 |
-
|
2043 |
-
|
2044 |
-
|
2045 |
-
|
2046 |
-
|
2047 |
-
|
2048 |
-
|
2049 |
-
|
2050 |
-
|
2051 |
-
|
2052 |
-
|
2053 |
-
|
2054 |
-
|
2055 |
-
|
2056 |
-
|
2057 |
-
|
2058 |
-
|
2059 |
-
|
2060 |
-
|
2061 |
-
|
2062 |
-
|
2063 |
-
|
2064 |
-
|
2065 |
-
|
2066 |
-
|
2067 |
-
|
2068 |
-
|
2069 |
-
|
2070 |
-
|
2071 |
-
|
2072 |
-
|
2073 |
-
|
2074 |
-
|
2075 |
-
|
2076 |
-
|
2077 |
-
|
2078 |
-
|
2079 |
-
|
2080 |
-
|
2081 |
-
|
2082 |
-
|
2083 |
-
|
2084 |
-
|
2085 |
-
|
2086 |
-
|
2087 |
-
|
2088 |
-
|
2089 |
-
|
2090 |
-
|
2091 |
-
|
2092 |
-
|
2093 |
-
|
2094 |
-
|
2095 |
-
|
2096 |
-
|
2097 |
-
|
2098 |
-
|
2099 |
-
|
2100 |
-
|
2101 |
-
|
2102 |
-
|
2103 |
-
|
2104 |
-
|
2105 |
-
|
2106 |
-
|
2107 |
-
|
2108 |
-
|
2109 |
-
|
2110 |
-
|
2111 |
-
|
2112 |
-
|
2113 |
-
|
2114 |
-
|
2115 |
-
|
2116 |
-
|
2117 |
-
|
2118 |
-
|
2119 |
-
|
2120 |
-
|
2121 |
-
|
2122 |
-
|
2123 |
-
|
2124 |
-
|
2125 |
-
|
2126 |
-
|
2127 |
-
|
2128 |
-
|
2129 |
-
|
2130 |
-
|
2131 |
-
|
2132 |
-
|
2133 |
-
|
2134 |
-
|
2135 |
-
|
2136 |
-
|
2137 |
-
|
2138 |
-
|
2139 |
-
|
2140 |
-
|
2141 |
-
|
2142 |
-
|
2143 |
-
|
2144 |
-
|
2145 |
-
|
2146 |
-
|
2147 |
-
|
2148 |
-
|
2149 |
-
|
2150 |
-
|
2151 |
-
|
2152 |
-
|
2153 |
-
|
2154 |
-
|
2155 |
-
|
2156 |
-
|
2157 |
-
|
2158 |
-
|
2159 |
-
|
2160 |
-
|
2161 |
-
|
2162 |
-
|
2163 |
-
|
2164 |
-
|
2165 |
-
|
2166 |
-
|
2167 |
-
|
2168 |
-
|
2169 |
-
|
2170 |
-
|
2171 |
-
|
2172 |
-
|
2173 |
-
|
2174 |
-
|
2175 |
-
|
2176 |
-
|
2177 |
-
|
2178 |
-
|
2179 |
-
|
2180 |
-
|
2181 |
-
|
2182 |
-
|
2183 |
-
|
2184 |
-
|
2185 |
-
|
2186 |
-
|
2187 |
-
|
2188 |
-
|
2189 |
-
|
2190 |
-
|
2191 |
-
|
2192 |
-
|
2193 |
-
|
2194 |
-
|
2195 |
-
|
2196 |
-
|
2197 |
-
|
2198 |
-
|
2199 |
-
|
2200 |
-
|
2201 |
-
|
2202 |
-
|
2203 |
-
|
2204 |
-
|
2205 |
-
|
2206 |
-
);
|
2207 |
-
|
2208 |
-
$this->
|
2209 |
-
|
2210 |
-
|
2211 |
-
'
|
2212 |
-
|
2213 |
-
|
2214 |
-
|
2215 |
-
|
2216 |
-
|
2217 |
-
|
2218 |
-
|
2219 |
-
|
2220 |
-
}
|
2221 |
-
|
2222 |
-
/**
|
2223 |
-
*
|
2224 |
-
*
|
2225 |
-
* @author Vova Feldman (@svovaf)
|
2226 |
-
* @since 1.
|
2227 |
-
|
2228 |
-
|
2229 |
-
|
2230 |
-
|
2231 |
-
|
2232 |
-
|
2233 |
-
$
|
2234 |
-
|
2235 |
-
if ( $
|
2236 |
-
$this->
|
2237 |
-
|
2238 |
-
|
2239 |
-
|
2240 |
-
|
2241 |
-
|
2242 |
-
|
2243 |
-
|
2244 |
-
}
|
2245 |
-
|
2246 |
-
|
2247 |
-
|
2248 |
-
|
2249 |
-
|
2250 |
-
|
2251 |
-
|
2252 |
-
|
2253 |
-
|
2254 |
-
|
2255 |
-
|
2256 |
-
|
2257 |
-
|
2258 |
-
|
2259 |
-
|
2260 |
-
|
2261 |
-
|
2262 |
-
|
2263 |
-
|
2264 |
-
|
2265 |
-
|
2266 |
-
|
2267 |
-
|
2268 |
-
|
2269 |
-
|
2270 |
-
|
2271 |
-
|
2272 |
-
|
2273 |
-
|
2274 |
-
|
2275 |
-
|
2276 |
-
|
2277 |
-
|
2278 |
-
|
2279 |
-
|
2280 |
-
|
2281 |
-
|
2282 |
-
|
2283 |
-
|
2284 |
-
|
2285 |
-
|
2286 |
-
|
2287 |
-
|
2288 |
-
|
2289 |
-
|
2290 |
-
|
2291 |
-
|
2292 |
-
|
2293 |
-
|
2294 |
-
|
2295 |
-
|
2296 |
-
|
2297 |
-
|
2298 |
-
|
2299 |
-
|
2300 |
-
|
2301 |
-
|
2302 |
-
|
2303 |
-
|
2304 |
-
|
2305 |
-
|
2306 |
-
|
2307 |
-
|
2308 |
-
$
|
2309 |
-
$
|
2310 |
-
|
2311 |
-
|
2312 |
-
|
2313 |
-
|
2314 |
-
|
2315 |
-
|
2316 |
-
|
2317 |
-
|
2318 |
-
|
2319 |
-
|
2320 |
-
|
2321 |
-
);
|
2322 |
-
|
2323 |
-
|
2324 |
-
|
2325 |
-
|
2326 |
-
|
2327 |
-
|
2328 |
-
|
2329 |
-
|
2330 |
-
|
2331 |
-
|
2332 |
-
|
2333 |
-
|
2334 |
-
|
2335 |
-
|
2336 |
-
|
2337 |
-
|
2338 |
-
|
2339 |
-
|
2340 |
-
|
2341 |
-
|
2342 |
-
|
2343 |
-
|
2344 |
-
|
2345 |
-
|
2346 |
-
|
2347 |
-
|
2348 |
-
|
2349 |
-
|
2350 |
-
|
2351 |
-
|
2352 |
-
|
2353 |
-
|
2354 |
-
|
2355 |
-
|
2356 |
-
|
2357 |
-
|
2358 |
-
|
2359 |
-
|
2360 |
-
|
2361 |
-
|
2362 |
-
|
2363 |
-
|
2364 |
-
|
2365 |
-
|
2366 |
-
|
2367 |
-
|
2368 |
-
|
2369 |
-
|
2370 |
-
|
2371 |
-
|
2372 |
-
|
2373 |
-
|
2374 |
-
|
2375 |
-
|
2376 |
-
|
2377 |
-
|
2378 |
-
|
2379 |
-
|
2380 |
-
|
2381 |
-
|
2382 |
-
|
2383 |
-
|
2384 |
-
|
2385 |
-
|
2386 |
-
|
2387 |
-
|
2388 |
-
|
2389 |
-
|
2390 |
-
|
2391 |
-
|
2392 |
-
|
2393 |
-
|
2394 |
-
|
2395 |
-
|
2396 |
-
|
2397 |
-
|
2398 |
-
|
2399 |
-
|
2400 |
-
|
2401 |
-
|
2402 |
-
|
2403 |
-
|
2404 |
-
|
2405 |
-
|
2406 |
-
|
2407 |
-
|
2408 |
-
|
2409 |
-
|
2410 |
-
|
2411 |
-
|
2412 |
-
'
|
2413 |
-
|
2414 |
-
|
2415 |
-
|
2416 |
-
|
2417 |
-
|
2418 |
-
|
2419 |
-
|
2420 |
-
|
2421 |
-
|
2422 |
-
|
2423 |
-
|
2424 |
-
|
2425 |
-
|
2426 |
-
|
2427 |
-
|
2428 |
-
|
2429 |
-
|
2430 |
-
|
2431 |
-
|
2432 |
-
|
2433 |
-
|
2434 |
-
|
2435 |
-
|
2436 |
-
|
2437 |
-
|
2438 |
-
|
2439 |
-
|
2440 |
-
|
2441 |
-
|
2442 |
-
|
2443 |
-
|
2444 |
-
|
2445 |
-
|
2446 |
-
|
2447 |
-
|
2448 |
-
|
2449 |
-
|
2450 |
-
$
|
2451 |
-
|
2452 |
-
$
|
2453 |
-
|
2454 |
-
|
2455 |
-
|
2456 |
-
|
2457 |
-
|
2458 |
-
|
2459 |
-
|
2460 |
-
|
2461 |
-
|
2462 |
-
|
2463 |
-
|
2464 |
-
|
2465 |
-
|
2466 |
-
|
2467 |
-
|
2468 |
-
|
2469 |
-
|
2470 |
-
|
2471 |
-
|
2472 |
-
|
2473 |
-
|
2474 |
-
|
2475 |
-
|
2476 |
-
|
2477 |
-
|
2478 |
-
|
2479 |
-
|
2480 |
-
|
2481 |
-
|
2482 |
-
|
2483 |
-
|
2484 |
-
|
2485 |
-
|
2486 |
-
|
2487 |
-
|
2488 |
-
|
2489 |
-
|
2490 |
-
|
2491 |
-
|
2492 |
-
|
2493 |
-
|
2494 |
-
|
2495 |
-
|
2496 |
-
|
2497 |
-
|
2498 |
-
|
2499 |
-
|
2500 |
-
|
2501 |
-
|
2502 |
-
|
2503 |
-
|
2504 |
-
|
2505 |
-
|
2506 |
-
|
2507 |
-
|
2508 |
-
|
2509 |
-
|
2510 |
-
|
2511 |
-
|
2512 |
-
|
2513 |
-
|
2514 |
-
|
2515 |
-
|
2516 |
-
|
2517 |
-
|
2518 |
-
|
2519 |
-
|
2520 |
-
|
2521 |
-
|
2522 |
-
|
2523 |
-
|
2524 |
-
|
2525 |
-
|
2526 |
-
|
2527 |
-
|
2528 |
-
|
2529 |
-
|
2530 |
-
|
2531 |
-
|
2532 |
-
|
2533 |
-
|
2534 |
-
|
2535 |
-
|
2536 |
-
|
2537 |
-
|
2538 |
-
|
2539 |
-
|
2540 |
-
|
2541 |
-
|
2542 |
-
|
2543 |
-
|
2544 |
-
|
2545 |
-
|
2546 |
-
|
2547 |
-
|
2548 |
-
|
2549 |
-
|
2550 |
-
|
2551 |
-
|
2552 |
-
|
2553 |
-
|
2554 |
-
|
2555 |
-
|
2556 |
-
|
2557 |
-
|
2558 |
-
|
2559 |
-
|
2560 |
-
|
2561 |
-
|
2562 |
-
|
2563 |
-
|
2564 |
-
|
2565 |
-
|
2566 |
-
|
2567 |
-
|
2568 |
-
|
2569 |
-
|
2570 |
-
|
2571 |
-
|
2572 |
-
|
2573 |
-
|
2574 |
-
|
2575 |
-
|
2576 |
-
|
2577 |
-
|
2578 |
-
|
2579 |
-
|
2580 |
-
|
2581 |
-
|
2582 |
-
|
2583 |
-
|
2584 |
-
|
2585 |
-
|
2586 |
-
sprintf(
|
2587 |
-
|
2588 |
-
|
2589 |
-
|
2590 |
-
|
2591 |
-
|
2592 |
-
|
2593 |
-
|
2594 |
-
|
2595 |
-
|
2596 |
-
|
2597 |
-
|
2598 |
-
|
2599 |
-
|
2600 |
-
|
2601 |
-
|
2602 |
-
|
2603 |
-
|
2604 |
-
|
2605 |
-
|
2606 |
-
|
2607 |
-
|
2608 |
-
|
2609 |
-
|
2610 |
-
|
2611 |
-
|
2612 |
-
|
2613 |
-
|
2614 |
-
|
2615 |
-
|
2616 |
-
|
2617 |
-
|
2618 |
-
|
2619 |
-
|
2620 |
-
|
2621 |
-
|
2622 |
-
|
2623 |
-
|
2624 |
-
|
2625 |
-
|
2626 |
-
|
2627 |
-
|
2628 |
-
|
2629 |
-
|
2630 |
-
|
2631 |
-
|
2632 |
-
|
2633 |
-
|
2634 |
-
|
2635 |
-
|
2636 |
-
|
2637 |
-
|
2638 |
-
|
2639 |
-
|
2640 |
-
|
2641 |
-
|
2642 |
-
|
2643 |
-
|
2644 |
-
|
2645 |
-
|
2646 |
-
|
2647 |
-
|
2648 |
-
|
2649 |
-
|
2650 |
-
|
2651 |
-
|
2652 |
-
|
2653 |
-
|
2654 |
-
|
2655 |
-
|
2656 |
-
|
2657 |
-
|
2658 |
-
|
2659 |
-
|
2660 |
-
|
2661 |
-
|
2662 |
-
|
2663 |
-
|
2664 |
-
|
2665 |
-
|
2666 |
-
|
2667 |
-
|
2668 |
-
|
2669 |
-
|
2670 |
-
|
2671 |
-
|
2672 |
-
|
2673 |
-
|
2674 |
-
|
2675 |
-
|
2676 |
-
|
2677 |
-
|
2678 |
-
|
2679 |
-
|
2680 |
-
|
2681 |
-
|
2682 |
-
|
2683 |
-
|
2684 |
-
|
2685 |
-
|
2686 |
-
|
2687 |
-
|
2688 |
-
|
2689 |
-
|
2690 |
-
|
2691 |
-
|
2692 |
-
|
2693 |
-
|
2694 |
-
|
2695 |
-
|
2696 |
-
|
2697 |
-
|
2698 |
-
|
2699 |
-
|
2700 |
-
|
2701 |
-
|
2702 |
-
|
2703 |
-
|
2704 |
-
|
2705 |
-
|
2706 |
-
$
|
2707 |
-
|
2708 |
-
|
2709 |
-
|
2710 |
-
|
2711 |
-
|
2712 |
-
|
2713 |
-
|
2714 |
-
|
2715 |
-
|
2716 |
-
$
|
2717 |
-
|
2718 |
-
|
2719 |
-
|
2720 |
-
|
2721 |
-
|
2722 |
-
|
2723 |
-
|
2724 |
-
|
2725 |
-
|
2726 |
-
|
2727 |
-
|
2728 |
-
|
2729 |
-
$this->
|
2730 |
-
|
2731 |
-
|
2732 |
-
|
2733 |
-
|
2734 |
-
|
2735 |
-
|
2736 |
-
|
2737 |
-
|
2738 |
-
|
2739 |
-
|
2740 |
-
|
2741 |
-
|
2742 |
-
|
2743 |
-
|
2744 |
-
|
2745 |
-
|
2746 |
-
|
2747 |
-
|
2748 |
-
|
2749 |
-
*
|
2750 |
-
|
2751 |
-
|
2752 |
-
|
2753 |
-
|
2754 |
-
|
2755 |
-
|
2756 |
-
|
2757 |
-
|
2758 |
-
|
2759 |
-
|
2760 |
-
|
2761 |
-
|
2762 |
-
|
2763 |
-
|
2764 |
-
|
2765 |
-
|
2766 |
-
|
2767 |
-
|
2768 |
-
|
2769 |
-
|
2770 |
-
|
2771 |
-
|
2772 |
-
|
2773 |
-
|
2774 |
-
|
2775 |
-
|
2776 |
-
|
2777 |
-
|
2778 |
-
|
2779 |
-
|
2780 |
-
|
2781 |
-
|
2782 |
-
|
2783 |
-
|
2784 |
-
|
2785 |
-
|
2786 |
-
|
2787 |
-
|
2788 |
-
*
|
2789 |
-
*
|
2790 |
-
*
|
2791 |
-
*
|
2792 |
-
*
|
2793 |
-
*
|
2794 |
-
*
|
2795 |
-
*
|
2796 |
-
*
|
2797 |
-
* @
|
2798 |
-
|
2799 |
-
|
2800 |
-
|
2801 |
-
|
2802 |
-
|
2803 |
-
$
|
2804 |
-
|
2805 |
-
|
2806 |
-
|
2807 |
-
|
2808 |
-
|
2809 |
-
|
2810 |
-
|
2811 |
-
|
2812 |
-
|
2813 |
-
|
2814 |
-
|
2815 |
-
|
2816 |
-
|
2817 |
-
|
2818 |
-
|
2819 |
-
|
2820 |
-
|
2821 |
-
|
2822 |
-
|
2823 |
-
|
2824 |
-
|
2825 |
-
|
2826 |
-
|
2827 |
-
|
2828 |
-
|
2829 |
-
|
2830 |
-
|
2831 |
-
|
2832 |
-
|
2833 |
-
|
2834 |
-
|
2835 |
-
|
2836 |
-
|
2837 |
-
|
2838 |
-
|
2839 |
-
|
2840 |
-
|
2841 |
-
|
2842 |
-
|
2843 |
-
|
2844 |
-
|
2845 |
-
|
2846 |
-
|
2847 |
-
|
2848 |
-
|
2849 |
-
|
2850 |
-
|
2851 |
-
|
2852 |
-
|
2853 |
-
|
2854 |
-
|
2855 |
-
|
2856 |
-
|
2857 |
-
|
2858 |
-
|
2859 |
-
|
2860 |
-
|
2861 |
-
|
2862 |
-
|
2863 |
-
|
2864 |
-
|
2865 |
-
|
2866 |
-
|
2867 |
-
|
2868 |
-
|
2869 |
-
|
2870 |
-
|
2871 |
-
|
2872 |
-
|
2873 |
-
|
2874 |
-
|
2875 |
-
|
2876 |
-
|
2877 |
-
|
2878 |
-
|
2879 |
-
|
2880 |
-
|
2881 |
-
|
2882 |
-
|
2883 |
-
|
2884 |
-
|
2885 |
-
|
2886 |
-
|
2887 |
-
//
|
2888 |
-
|
2889 |
-
|
2890 |
-
|
2891 |
-
|
2892 |
-
|
2893 |
-
|
2894 |
-
|
2895 |
-
|
2896 |
-
|
2897 |
-
|
2898 |
-
|
2899 |
-
|
2900 |
-
|
2901 |
-
|
2902 |
-
|
2903 |
-
'
|
2904 |
-
|
2905 |
-
|
2906 |
-
|
2907 |
-
|
2908 |
-
|
2909 |
-
|
2910 |
-
|
2911 |
-
|
2912 |
-
|
2913 |
-
|
2914 |
-
|
2915 |
-
|
2916 |
-
|
2917 |
-
|
2918 |
-
|
2919 |
-
|
2920 |
-
|
2921 |
-
|
2922 |
-
|
2923 |
-
|
2924 |
-
|
2925 |
-
|
2926 |
-
|
2927 |
-
|
2928 |
-
|
2929 |
-
|
2930 |
-
|
2931 |
-
|
2932 |
-
|
2933 |
-
|
2934 |
-
|
2935 |
-
|
2936 |
-
|
2937 |
-
|
2938 |
-
|
2939 |
-
|
2940 |
-
|
2941 |
-
|
2942 |
-
|
2943 |
-
|
2944 |
-
|
2945 |
-
|
2946 |
-
|
2947 |
-
|
2948 |
-
|
2949 |
-
|
2950 |
-
|
2951 |
-
|
2952 |
-
|
2953 |
-
|
2954 |
-
|
2955 |
-
|
2956 |
-
'
|
2957 |
-
|
2958 |
-
|
2959 |
-
)
|
2960 |
-
|
2961 |
-
|
2962 |
-
|
2963 |
-
|
2964 |
-
|
2965 |
-
|
2966 |
-
|
2967 |
-
|
2968 |
-
|
2969 |
-
|
2970 |
-
|
2971 |
-
|
2972 |
-
|
2973 |
-
|
2974 |
-
|
2975 |
-
|
2976 |
-
|
2977 |
-
|
2978 |
-
|
2979 |
-
|
2980 |
-
|
2981 |
-
|
2982 |
-
|
2983 |
-
|
2984 |
-
|
2985 |
-
|
2986 |
-
|
2987 |
-
|
2988 |
-
|
2989 |
-
|
2990 |
-
|
2991 |
-
|
2992 |
-
|
2993 |
-
|
2994 |
-
|
2995 |
-
|
2996 |
-
|
2997 |
-
|
2998 |
-
|
2999 |
-
|
3000 |
-
|
3001 |
-
|
3002 |
-
|
3003 |
-
|
3004 |
-
|
3005 |
-
|
3006 |
-
|
3007 |
-
|
3008 |
-
|
3009 |
-
|
3010 |
-
|
3011 |
-
|
3012 |
-
|
3013 |
-
|
3014 |
-
|
3015 |
-
|
3016 |
-
|
3017 |
-
|
3018 |
-
|
3019 |
-
|
3020 |
-
|
3021 |
-
|
3022 |
-
|
3023 |
-
|
3024 |
-
|
3025 |
-
|
3026 |
-
|
3027 |
-
|
3028 |
-
|
3029 |
-
|
3030 |
-
|
3031 |
-
|
3032 |
-
|
3033 |
-
|
3034 |
-
|
3035 |
-
|
3036 |
-
|
3037 |
-
|
3038 |
-
|
3039 |
-
|
3040 |
-
|
3041 |
-
|
3042 |
-
|
3043 |
-
|
3044 |
-
|
3045 |
-
|
3046 |
-
|
3047 |
-
|
3048 |
-
|
3049 |
-
|
3050 |
-
|
3051 |
-
|
3052 |
-
|
3053 |
-
|
3054 |
-
|
3055 |
-
|
3056 |
-
|
3057 |
-
|
3058 |
-
|
3059 |
-
|
3060 |
-
|
3061 |
-
|
3062 |
-
|
3063 |
-
|
3064 |
-
|
3065 |
-
|
3066 |
-
|
3067 |
-
|
3068 |
-
|
3069 |
-
|
3070 |
-
|
3071 |
-
|
3072 |
-
|
3073 |
-
|
3074 |
-
|
3075 |
-
|
3076 |
-
|
3077 |
-
|
3078 |
-
|
3079 |
-
|
3080 |
-
|
3081 |
-
|
3082 |
-
|
3083 |
-
|
3084 |
-
|
3085 |
-
|
3086 |
-
|
3087 |
-
|
3088 |
-
|
3089 |
-
|
3090 |
-
|
3091 |
-
|
3092 |
-
|
3093 |
-
|
3094 |
-
|
3095 |
-
|
3096 |
-
|
3097 |
-
|
3098 |
-
|
3099 |
-
|
3100 |
-
|
3101 |
-
|
3102 |
-
|
3103 |
-
|
3104 |
-
|
3105 |
-
|
3106 |
-
|
3107 |
-
|
3108 |
-
|
3109 |
-
|
3110 |
-
|
3111 |
-
|
3112 |
-
|
3113 |
-
|
3114 |
-
|
3115 |
-
|
3116 |
-
|
3117 |
-
|
3118 |
-
);
|
3119 |
-
}
|
3120 |
-
|
3121 |
-
|
3122 |
-
|
3123 |
-
|
3124 |
-
|
3125 |
-
|
3126 |
-
|
3127 |
-
|
3128 |
-
|
3129 |
-
|
3130 |
-
|
3131 |
-
|
3132 |
-
|
3133 |
-
|
3134 |
-
|
3135 |
-
|
3136 |
-
|
3137 |
-
|
3138 |
-
|
3139 |
-
|
3140 |
-
|
3141 |
-
|
3142 |
-
|
3143 |
-
|
3144 |
-
|
3145 |
-
|
3146 |
-
|
3147 |
-
|
3148 |
-
|
3149 |
-
|
3150 |
-
|
3151 |
-
|
3152 |
-
|
3153 |
-
|
3154 |
-
|
3155 |
-
|
3156 |
-
|
3157 |
-
|
3158 |
-
|
3159 |
-
|
3160 |
-
|
3161 |
-
|
3162 |
-
|
3163 |
-
|
3164 |
-
|
3165 |
-
|
3166 |
-
|
3167 |
-
|
3168 |
-
|
3169 |
-
|
3170 |
-
|
3171 |
-
|
3172 |
-
|
3173 |
-
|
3174 |
-
|
3175 |
-
|
3176 |
-
|
3177 |
-
|
3178 |
-
|
3179 |
-
|
3180 |
-
|
3181 |
-
|
3182 |
-
|
3183 |
-
|
3184 |
-
|
3185 |
-
|
3186 |
-
|
3187 |
-
|
3188 |
-
|
3189 |
-
|
3190 |
-
|
3191 |
-
|
3192 |
-
|
3193 |
-
|
3194 |
-
|
3195 |
-
|
3196 |
-
|
3197 |
-
|
3198 |
-
|
3199 |
-
|
3200 |
-
|
3201 |
-
|
3202 |
-
|
3203 |
-
|
3204 |
-
|
3205 |
-
|
3206 |
-
|
3207 |
-
|
3208 |
-
|
3209 |
-
|
3210 |
-
|
3211 |
-
|
3212 |
-
|
3213 |
-
|
3214 |
-
|
3215 |
-
|
3216 |
-
|
3217 |
-
|
3218 |
-
|
3219 |
-
|
3220 |
-
|
3221 |
-
|
3222 |
-
|
3223 |
-
|
3224 |
-
|
3225 |
-
|
3226 |
-
|
3227 |
-
|
3228 |
-
|
3229 |
-
|
3230 |
-
|
3231 |
-
|
3232 |
-
|
3233 |
-
|
3234 |
-
|
3235 |
-
*
|
3236 |
-
*
|
3237 |
-
*
|
3238 |
-
|
3239 |
-
|
3240 |
-
|
3241 |
-
|
3242 |
-
|
3243 |
-
|
3244 |
-
|
3245 |
-
|
3246 |
-
|
3247 |
-
|
3248 |
-
|
3249 |
-
|
3250 |
-
|
3251 |
-
|
3252 |
-
|
3253 |
-
|
3254 |
-
|
3255 |
-
|
3256 |
-
|
3257 |
-
|
3258 |
-
|
3259 |
-
|
3260 |
-
|
3261 |
-
*
|
3262 |
-
* @
|
3263 |
-
*/
|
3264 |
-
function
|
3265 |
-
$
|
3266 |
-
|
3267 |
-
|
3268 |
-
|
3269 |
-
|
3270 |
-
|
3271 |
-
|
3272 |
-
|
3273 |
-
|
3274 |
-
|
3275 |
-
|
3276 |
-
|
3277 |
-
|
3278 |
-
|
3279 |
-
|
3280 |
-
|
3281 |
-
|
3282 |
-
|
3283 |
-
|
3284 |
-
|
3285 |
-
|
3286 |
-
|
3287 |
-
|
3288 |
-
|
3289 |
-
|
3290 |
-
|
3291 |
-
|
3292 |
-
|
3293 |
-
|
3294 |
-
|
3295 |
-
|
3296 |
-
|
3297 |
-
|
3298 |
-
|
3299 |
-
|
3300 |
-
|
3301 |
-
|
3302 |
-
|
3303 |
-
|
3304 |
-
|
3305 |
-
|
3306 |
-
|
3307 |
-
|
3308 |
-
|
3309 |
-
|
3310 |
-
|
3311 |
-
|
3312 |
-
|
3313 |
-
|
3314 |
-
|
3315 |
-
|
3316 |
-
|
3317 |
-
|
3318 |
-
|
3319 |
-
|
3320 |
-
|
3321 |
-
|
3322 |
-
|
3323 |
-
|
3324 |
-
|
3325 |
-
|
3326 |
-
|
3327 |
-
|
3328 |
-
|
3329 |
-
|
3330 |
-
|
3331 |
-
|
3332 |
-
|
3333 |
-
|
3334 |
-
|
3335 |
-
|
3336 |
-
|
3337 |
-
|
3338 |
-
|
3339 |
-
|
3340 |
-
|
3341 |
-
|
3342 |
-
|
3343 |
-
|
3344 |
-
|
3345 |
-
|
3346 |
-
|
3347 |
-
|
3348 |
-
|
3349 |
-
|
3350 |
-
|
3351 |
-
|
3352 |
-
|
3353 |
-
|
3354 |
-
|
3355 |
-
|
3356 |
-
|
3357 |
-
|
3358 |
-
|
3359 |
-
|
3360 |
-
|
3361 |
-
|
3362 |
-
|
3363 |
-
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
-
|
3368 |
-
|
3369 |
-
|
3370 |
-
|
3371 |
-
|
3372 |
-
|
3373 |
-
|
3374 |
-
|
3375 |
-
|
3376 |
-
|
3377 |
-
|
3378 |
-
|
3379 |
-
|
3380 |
-
|
3381 |
-
|
3382 |
-
|
3383 |
-
|
3384 |
-
|
3385 |
-
|
3386 |
-
|
3387 |
-
|
3388 |
-
|
3389 |
-
|
3390 |
-
|
3391 |
-
*
|
3392 |
-
*
|
3393 |
-
|
3394 |
-
|
3395 |
-
|
3396 |
-
|
3397 |
-
|
3398 |
-
|
3399 |
-
|
3400 |
-
|
3401 |
-
|
3402 |
-
|
3403 |
-
}
|
3404 |
-
|
3405 |
-
/**
|
3406 |
-
*
|
3407 |
-
*
|
3408 |
-
* @author Vova Feldman (@svovaf)
|
3409 |
-
* @since 1.
|
3410 |
-
*
|
3411 |
-
* @
|
3412 |
-
|
3413 |
-
|
3414 |
-
|
3415 |
-
|
3416 |
-
|
3417 |
-
|
3418 |
-
|
3419 |
-
|
3420 |
-
|
3421 |
-
|
3422 |
-
|
3423 |
-
|
3424 |
-
|
3425 |
-
|
3426 |
-
|
3427 |
-
|
3428 |
-
|
3429 |
-
|
3430 |
-
|
3431 |
-
|
3432 |
-
|
3433 |
-
|
3434 |
-
|
3435 |
-
|
3436 |
-
|
3437 |
-
|
3438 |
-
|
3439 |
-
|
3440 |
-
|
3441 |
-
|
3442 |
-
|
3443 |
-
|
3444 |
-
|
3445 |
-
|
3446 |
-
|
3447 |
-
|
3448 |
-
|
3449 |
-
|
3450 |
-
|
3451 |
-
|
3452 |
-
|
3453 |
-
|
3454 |
-
|
3455 |
-
|
3456 |
-
|
3457 |
-
|
3458 |
-
|
3459 |
-
|
3460 |
-
|
3461 |
-
|
3462 |
-
|
3463 |
-
|
3464 |
-
|
3465 |
-
|
3466 |
-
|
3467 |
-
|
3468 |
-
|
3469 |
-
|
3470 |
-
|
3471 |
-
|
3472 |
-
|
3473 |
-
|
3474 |
-
|
3475 |
-
|
3476 |
-
|
3477 |
-
|
3478 |
-
|
3479 |
-
|
3480 |
-
|
3481 |
-
|
3482 |
-
|
3483 |
-
|
3484 |
-
|
3485 |
-
|
3486 |
-
|
3487 |
-
|
3488 |
-
|
3489 |
-
|
3490 |
-
|
3491 |
-
|
3492 |
-
|
3493 |
-
|
3494 |
-
|
3495 |
-
|
3496 |
-
|
3497 |
-
|
3498 |
-
$this->
|
3499 |
-
|
3500 |
-
|
3501 |
-
|
3502 |
-
|
3503 |
-
|
3504 |
-
|
3505 |
-
|
3506 |
-
|
3507 |
-
|
3508 |
-
|
3509 |
-
|
3510 |
-
|
3511 |
-
|
3512 |
-
|
3513 |
-
|
3514 |
-
|
3515 |
-
|
3516 |
-
|
3517 |
-
|
3518 |
-
|
3519 |
-
|
3520 |
-
|
3521 |
-
|
3522 |
-
|
3523 |
-
|
3524 |
-
|
3525 |
-
|
3526 |
-
|
3527 |
-
|
3528 |
-
|
3529 |
-
|
3530 |
-
|
3531 |
-
|
3532 |
-
|
3533 |
-
|
3534 |
-
|
3535 |
-
|
3536 |
-
|
3537 |
-
|
3538 |
-
|
3539 |
-
|
3540 |
-
|
3541 |
-
|
3542 |
-
|
3543 |
-
|
3544 |
-
|
3545 |
-
|
3546 |
-
|
3547 |
-
|
3548 |
-
|
3549 |
-
|
3550 |
-
|
3551 |
-
|
3552 |
-
|
3553 |
-
|
3554 |
-
|
3555 |
-
|
3556 |
-
|
3557 |
-
|
3558 |
-
|
3559 |
-
|
3560 |
-
|
3561 |
-
|
3562 |
-
|
3563 |
-
|
3564 |
-
|
3565 |
-
|
3566 |
-
|
3567 |
-
|
3568 |
-
|
3569 |
-
|
3570 |
-
|
3571 |
-
|
3572 |
-
|
3573 |
-
|
3574 |
-
|
3575 |
-
|
3576 |
-
|
3577 |
-
|
3578 |
-
|
3579 |
-
|
3580 |
-
|
3581 |
-
|
3582 |
-
|
3583 |
-
|
3584 |
-
|
3585 |
-
|
3586 |
-
|
3587 |
-
|
3588 |
-
|
3589 |
-
|
3590 |
-
|
3591 |
-
|
3592 |
-
|
3593 |
-
|
3594 |
-
|
3595 |
-
|
3596 |
-
|
3597 |
-
|
3598 |
-
|
3599 |
-
|
3600 |
-
|
3601 |
-
|
3602 |
-
|
3603 |
-
|
3604 |
-
|
3605 |
-
|
3606 |
-
|
3607 |
-
|
3608 |
-
|
3609 |
-
|
3610 |
-
|
3611 |
-
|
3612 |
-
|
3613 |
-
|
3614 |
-
|
3615 |
-
|
3616 |
-
|
3617 |
-
|
3618 |
-
|
3619 |
-
|
3620 |
-
|
3621 |
-
|
3622 |
-
|
3623 |
-
|
3624 |
-
|
3625 |
-
|
3626 |
-
|
3627 |
-
|
3628 |
-
|
3629 |
-
|
3630 |
-
|
3631 |
-
|
3632 |
-
|
3633 |
-
|
3634 |
-
|
3635 |
-
|
3636 |
-
|
3637 |
-
|
3638 |
-
|
3639 |
-
|
3640 |
-
|
3641 |
-
|
3642 |
-
|
3643 |
-
|
3644 |
-
|
3645 |
-
if (
|
3646 |
-
|
3647 |
-
|
3648 |
-
|
3649 |
-
|
3650 |
-
|
3651 |
-
|
3652 |
-
|
3653 |
-
|
3654 |
-
|
3655 |
-
|
3656 |
-
|
3657 |
-
|
3658 |
-
|
3659 |
-
|
3660 |
-
|
3661 |
-
|
3662 |
-
|
3663 |
-
|
3664 |
-
|
3665 |
-
|
3666 |
-
|
3667 |
-
|
3668 |
-
|
3669 |
-
|
3670 |
-
|
3671 |
-
|
3672 |
-
|
3673 |
-
|
3674 |
-
|
3675 |
-
|
3676 |
-
|
3677 |
-
|
3678 |
-
|
3679 |
-
|
3680 |
-
|
3681 |
-
|
3682 |
-
|
3683 |
-
|
3684 |
-
|
3685 |
-
|
3686 |
-
|
3687 |
-
|
3688 |
-
|
3689 |
-
|
3690 |
-
|
3691 |
-
|
3692 |
-
|
3693 |
-
|
3694 |
-
|
3695 |
-
|
3696 |
-
|
3697 |
-
|
3698 |
-
|
3699 |
-
|
3700 |
-
|
3701 |
-
|
3702 |
-
|
3703 |
-
|
3704 |
-
|
3705 |
-
|
3706 |
-
|
3707 |
-
|
3708 |
-
|
3709 |
-
|
3710 |
-
|
3711 |
-
|
3712 |
-
|
3713 |
-
|
3714 |
-
|
3715 |
-
|
3716 |
-
|
3717 |
-
|
3718 |
-
|
3719 |
-
|
3720 |
-
|
3721 |
-
|
3722 |
-
|
3723 |
-
|
3724 |
-
$this->
|
3725 |
-
|
3726 |
-
|
3727 |
-
|
3728 |
-
|
3729 |
-
|
3730 |
-
|
3731 |
-
|
3732 |
-
|
3733 |
-
|
3734 |
-
|
3735 |
-
|
3736 |
-
|
3737 |
-
|
3738 |
-
|
3739 |
-
|
3740 |
-
|
3741 |
-
|
3742 |
-
|
3743 |
-
|
3744 |
-
|
3745 |
-
|
3746 |
-
|
3747 |
-
|
3748 |
-
|
3749 |
-
|
3750 |
-
|
3751 |
-
|
3752 |
-
|
3753 |
-
|
3754 |
-
|
3755 |
-
|
3756 |
-
|
3757 |
-
|
3758 |
-
|
3759 |
-
|
3760 |
-
|
3761 |
-
|
3762 |
-
|
3763 |
-
|
3764 |
-
|
3765 |
-
|
3766 |
-
|
3767 |
-
|
3768 |
-
|
3769 |
-
|
3770 |
-
|
3771 |
-
|
3772 |
-
|
3773 |
-
|
3774 |
-
* @
|
3775 |
-
*
|
3776 |
-
|
3777 |
-
|
3778 |
-
|
3779 |
-
|
3780 |
-
|
3781 |
-
$
|
3782 |
-
|
3783 |
-
$
|
3784 |
-
|
3785 |
-
|
3786 |
-
|
3787 |
-
|
3788 |
-
|
3789 |
-
|
3790 |
-
|
3791 |
-
|
3792 |
-
|
3793 |
-
|
3794 |
-
|
3795 |
-
|
3796 |
-
|
3797 |
-
|
3798 |
-
|
3799 |
-
|
3800 |
-
|
3801 |
-
|
3802 |
-
|
3803 |
-
|
3804 |
-
|
3805 |
-
|
3806 |
-
|
3807 |
-
|
3808 |
-
|
3809 |
-
|
3810 |
-
|
3811 |
-
|
3812 |
-
|
3813 |
-
|
3814 |
-
|
3815 |
-
|
3816 |
-
*
|
3817 |
-
|
3818 |
-
|
3819 |
-
|
3820 |
-
|
3821 |
-
|
3822 |
-
|
3823 |
-
|
3824 |
-
|
3825 |
-
|
3826 |
-
|
3827 |
-
|
3828 |
-
*
|
3829 |
-
*
|
3830 |
-
*
|
3831 |
-
*
|
3832 |
-
* @
|
3833 |
-
|
3834 |
-
|
3835 |
-
|
3836 |
-
|
3837 |
-
|
3838 |
-
|
3839 |
-
|
3840 |
-
|
3841 |
-
|
3842 |
-
|
3843 |
-
|
3844 |
-
|
3845 |
-
|
3846 |
-
|
3847 |
-
|
3848 |
-
}
|
3849 |
-
|
3850 |
-
|
3851 |
-
|
3852 |
-
|
3853 |
-
$
|
3854 |
-
|
3855 |
-
|
3856 |
-
|
3857 |
-
|
3858 |
-
|
3859 |
-
|
3860 |
-
|
3861 |
-
|
3862 |
-
|
3863 |
-
|
3864 |
-
|
3865 |
-
|
3866 |
-
|
3867 |
-
|
3868 |
-
|
3869 |
-
|
3870 |
-
|
3871 |
-
|
3872 |
-
|
3873 |
-
|
3874 |
-
|
3875 |
-
|
3876 |
-
|
3877 |
-
|
3878 |
-
|
3879 |
-
|
3880 |
-
|
3881 |
-
|
3882 |
-
|
3883 |
-
|
3884 |
-
|
3885 |
-
|
3886 |
-
|
3887 |
-
|
3888 |
-
|
3889 |
-
|
3890 |
-
|
3891 |
-
|
3892 |
-
|
3893 |
-
|
3894 |
-
|
3895 |
-
|
3896 |
-
|
3897 |
-
|
3898 |
-
|
3899 |
-
|
3900 |
-
|
3901 |
-
|
3902 |
-
|
3903 |
-
|
3904 |
-
|
3905 |
-
|
3906 |
-
|
3907 |
-
|
3908 |
-
|
3909 |
-
|
3910 |
-
|
3911 |
-
|
3912 |
-
|
3913 |
-
|
3914 |
-
|
3915 |
-
*
|
3916 |
-
*
|
3917 |
-
|
3918 |
-
|
3919 |
-
|
3920 |
-
|
3921 |
-
|
3922 |
-
|
3923 |
-
|
3924 |
-
|
3925 |
-
|
3926 |
-
|
3927 |
-
|
3928 |
-
|
3929 |
-
|
3930 |
-
|
3931 |
-
|
3932 |
-
|
3933 |
-
*
|
3934 |
-
*
|
3935 |
-
|
3936 |
-
|
3937 |
-
|
3938 |
-
|
3939 |
-
|
3940 |
-
|
3941 |
-
|
3942 |
-
|
3943 |
-
|
3944 |
-
|
3945 |
-
|
3946 |
-
|
3947 |
-
|
3948 |
-
|
3949 |
-
|
3950 |
-
|
3951 |
-
|
3952 |
-
|
3953 |
-
|
3954 |
-
|
3955 |
-
|
3956 |
-
|
3957 |
-
|
3958 |
-
|
3959 |
-
|
3960 |
-
|
3961 |
-
|
3962 |
-
|
3963 |
-
|
3964 |
-
|
3965 |
-
|
3966 |
-
|
3967 |
-
|
3968 |
-
|
3969 |
-
|
3970 |
-
|
3971 |
-
|
3972 |
-
|
3973 |
-
|
3974 |
-
|
3975 |
-
|
3976 |
-
|
3977 |
-
|
3978 |
-
|
3979 |
-
|
3980 |
-
|
3981 |
-
|
3982 |
-
|
3983 |
-
|
3984 |
-
|
3985 |
-
|
3986 |
-
|
3987 |
-
|
3988 |
-
|
3989 |
-
|
3990 |
-
|
3991 |
-
|
3992 |
-
|
3993 |
-
|
3994 |
-
|
3995 |
-
|
3996 |
-
|
3997 |
-
|
3998 |
-
|
3999 |
-
|
4000 |
-
|
4001 |
-
|
4002 |
-
|
4003 |
-
|
4004 |
-
|
4005 |
-
|
4006 |
-
|
4007 |
-
|
4008 |
-
*
|
4009 |
-
*
|
4010 |
-
* @
|
4011 |
-
|
4012 |
-
|
4013 |
-
|
4014 |
-
|
4015 |
-
|
4016 |
-
|
4017 |
-
|
4018 |
-
|
4019 |
-
|
4020 |
-
|
4021 |
-
|
4022 |
-
|
4023 |
-
*
|
4024 |
-
*
|
4025 |
-
* @
|
4026 |
-
|
4027 |
-
|
4028 |
-
|
4029 |
-
|
4030 |
-
|
4031 |
-
|
4032 |
-
|
4033 |
-
|
4034 |
-
|
4035 |
-
|
4036 |
-
|
4037 |
-
|
4038 |
-
*
|
4039 |
-
*
|
4040 |
-
* @
|
4041 |
-
*
|
4042 |
-
* @
|
4043 |
-
|
4044 |
-
|
4045 |
-
|
4046 |
-
|
4047 |
-
|
4048 |
-
|
4049 |
-
|
4050 |
-
|
4051 |
-
|
4052 |
-
|
4053 |
-
|
4054 |
-
|
4055 |
-
|
4056 |
-
|
4057 |
-
|
4058 |
-
|
4059 |
-
|
4060 |
-
|
4061 |
-
|
4062 |
-
|
4063 |
-
|
4064 |
-
|
4065 |
-
|
4066 |
-
|
4067 |
-
|
4068 |
-
|
4069 |
-
|
4070 |
-
|
4071 |
-
}
|
4072 |
-
|
4073 |
-
|
4074 |
-
|
4075 |
-
|
4076 |
-
|
4077 |
-
|
4078 |
-
|
4079 |
-
*
|
4080 |
-
*
|
4081 |
-
*
|
4082 |
-
* @
|
4083 |
-
|
4084 |
-
|
4085 |
-
|
4086 |
-
|
4087 |
-
|
4088 |
-
|
4089 |
-
|
4090 |
-
|
4091 |
-
|
4092 |
-
*
|
4093 |
-
*
|
4094 |
-
|
4095 |
-
|
4096 |
-
|
4097 |
-
|
4098 |
-
|
4099 |
-
|
4100 |
-
|
4101 |
-
|
4102 |
-
|
4103 |
-
/**
|
4104 |
-
*
|
4105 |
-
*
|
4106 |
-
|
4107 |
-
|
4108 |
-
|
4109 |
-
|
4110 |
-
|
4111 |
-
|
4112 |
-
|
4113 |
-
|
4114 |
-
|
4115 |
-
|
4116 |
-
|
4117 |
-
|
4118 |
-
$this->
|
4119 |
-
|
4120 |
-
|
4121 |
-
|
4122 |
-
|
4123 |
-
|
4124 |
-
|
4125 |
-
|
4126 |
-
|
4127 |
-
|
4128 |
-
|
4129 |
-
|
4130 |
-
|
4131 |
-
|
4132 |
-
|
4133 |
-
//
|
4134 |
-
|
4135 |
-
|
4136 |
-
|
4137 |
-
|
4138 |
-
|
4139 |
-
|
4140 |
-
|
4141 |
-
|
4142 |
-
|
4143 |
-
|
4144 |
-
|
4145 |
-
|
4146 |
-
|
4147 |
-
|
4148 |
-
|
4149 |
-
|
4150 |
-
|
4151 |
-
|
4152 |
-
|
4153 |
-
|
4154 |
-
$this->
|
4155 |
-
|
4156 |
-
|
4157 |
-
|
4158 |
-
|
4159 |
-
|
4160 |
-
|
4161 |
-
|
4162 |
-
|
4163 |
-
|
4164 |
-
|
4165 |
-
|
4166 |
-
|
4167 |
-
|
4168 |
-
|
4169 |
-
|
4170 |
-
|
4171 |
-
|
4172 |
-
|
4173 |
-
|
4174 |
-
|
4175 |
-
|
4176 |
-
|
4177 |
-
|
4178 |
-
|
4179 |
-
|
4180 |
-
|
4181 |
-
|
4182 |
-
|
4183 |
-
|
4184 |
-
|
4185 |
-
|
4186 |
-
|
4187 |
-
|
4188 |
-
|
4189 |
-
|
4190 |
-
|
4191 |
-
|
4192 |
-
|
4193 |
-
|
4194 |
-
|
4195 |
-
|
4196 |
-
|
4197 |
-
|
4198 |
-
|
4199 |
-
|
4200 |
-
|
4201 |
-
|
4202 |
-
|
4203 |
-
|
4204 |
-
|
4205 |
-
|
4206 |
-
|
4207 |
-
|
4208 |
-
|
4209 |
-
|
4210 |
-
|
4211 |
-
|
4212 |
-
|
4213 |
-
|
4214 |
-
|
4215 |
-
|
4216 |
-
|
4217 |
-
|
4218 |
-
|
4219 |
-
|
4220 |
-
|
4221 |
-
|
4222 |
-
|
4223 |
-
|
4224 |
-
|
4225 |
-
|
4226 |
-
|
4227 |
-
|
4228 |
-
|
4229 |
-
|
4230 |
-
|
4231 |
-
|
4232 |
-
|
4233 |
-
|
4234 |
-
|
4235 |
-
|
4236 |
-
|
4237 |
-
|
4238 |
-
|
4239 |
-
|
4240 |
-
|
4241 |
-
|
4242 |
-
|
4243 |
-
|
4244 |
-
|
4245 |
-
|
4246 |
-
|
4247 |
-
|
4248 |
-
$this->
|
4249 |
-
|
4250 |
-
|
4251 |
-
|
4252 |
-
|
4253 |
-
|
4254 |
-
|
4255 |
-
|
4256 |
-
|
4257 |
-
|
4258 |
-
|
4259 |
-
|
4260 |
-
|
4261 |
-
|
4262 |
-
|
4263 |
-
|
4264 |
-
|
4265 |
-
|
4266 |
-
|
4267 |
-
|
4268 |
-
|
4269 |
-
|
4270 |
-
|
4271 |
-
|
4272 |
-
|
4273 |
-
|
4274 |
-
|
4275 |
-
|
4276 |
-
|
4277 |
-
|
4278 |
-
|
4279 |
-
|
4280 |
-
|
4281 |
-
|
4282 |
-
|
4283 |
-
|
4284 |
-
|
4285 |
-
|
4286 |
-
|
4287 |
-
|
4288 |
-
|
4289 |
-
|
4290 |
-
|
4291 |
-
|
4292 |
-
|
4293 |
-
|
4294 |
-
|
4295 |
-
|
4296 |
-
|
4297 |
-
|
4298 |
-
|
4299 |
-
|
4300 |
-
|
4301 |
-
|
4302 |
-
|
4303 |
-
|
4304 |
-
|
4305 |
-
|
4306 |
-
|
4307 |
-
|
4308 |
-
|
4309 |
-
|
4310 |
-
|
4311 |
-
|
4312 |
-
|
4313 |
-
|
4314 |
-
|
4315 |
-
|
4316 |
-
|
4317 |
-
|
4318 |
-
|
4319 |
-
|
4320 |
-
|
4321 |
-
|
4322 |
-
|
4323 |
-
|
4324 |
-
|
4325 |
-
|
4326 |
-
|
4327 |
-
|
4328 |
-
|
4329 |
-
|
4330 |
-
*
|
4331 |
-
*
|
4332 |
-
|
4333 |
-
|
4334 |
-
|
4335 |
-
|
4336 |
-
|
4337 |
-
|
4338 |
-
|
4339 |
-
|
4340 |
-
|
4341 |
-
|
4342 |
-
|
4343 |
-
$this->
|
4344 |
-
}
|
4345 |
-
|
4346 |
-
/**
|
4347 |
-
*
|
4348 |
-
*
|
4349 |
-
|
4350 |
-
|
4351 |
-
|
4352 |
-
|
4353 |
-
|
4354 |
-
|
4355 |
-
|
4356 |
-
|
4357 |
-
|
4358 |
-
|
4359 |
-
|
4360 |
-
|
4361 |
-
|
4362 |
-
|
4363 |
-
|
4364 |
-
|
4365 |
-
|
4366 |
-
|
4367 |
-
|
4368 |
-
|
4369 |
-
|
4370 |
-
|
4371 |
-
|
4372 |
-
|
4373 |
-
|
4374 |
-
|
4375 |
-
|
4376 |
-
|
4377 |
-
|
4378 |
-
|
4379 |
-
$this->
|
4380 |
-
|
4381 |
-
$this->
|
4382 |
-
|
4383 |
-
|
4384 |
-
|
4385 |
-
$this->
|
4386 |
-
|
4387 |
-
) );
|
4388 |
-
}
|
4389 |
-
|
4390 |
-
/**
|
4391 |
-
*
|
4392 |
-
*
|
4393 |
-
|
4394 |
-
|
4395 |
-
|
4396 |
-
|
4397 |
-
|
4398 |
-
|
4399 |
-
|
4400 |
-
|
4401 |
-
|
4402 |
-
|
4403 |
-
|
4404 |
-
|
4405 |
-
|
4406 |
-
|
4407 |
-
|
4408 |
-
*
|
4409 |
-
*
|
4410 |
-
*
|
4411 |
-
*
|
4412 |
-
*
|
4413 |
-
|
4414 |
-
|
4415 |
-
|
4416 |
-
|
4417 |
-
|
4418 |
-
|
4419 |
-
|
4420 |
-
|
4421 |
-
|
4422 |
-
|
4423 |
-
|
4424 |
-
|
4425 |
-
|
4426 |
-
|
4427 |
-
|
4428 |
-
|
4429 |
-
|
4430 |
-
|
4431 |
-
|
4432 |
-
|
4433 |
-
|
4434 |
-
|
4435 |
-
|
4436 |
-
|
4437 |
-
|
4438 |
-
|
4439 |
-
|
4440 |
-
|
4441 |
-
|
4442 |
-
|
4443 |
-
|
4444 |
-
|
4445 |
-
|
4446 |
-
|
4447 |
-
|
4448 |
-
|
4449 |
-
|
4450 |
-
|
4451 |
-
|
4452 |
-
|
4453 |
-
|
4454 |
-
|
4455 |
-
|
4456 |
-
|
4457 |
-
|
4458 |
-
|
4459 |
-
|
4460 |
-
|
4461 |
-
|
4462 |
-
|
4463 |
-
|
4464 |
-
|
4465 |
-
|
4466 |
-
|
4467 |
-
|
4468 |
-
|
4469 |
-
|
4470 |
-
|
4471 |
-
|
4472 |
-
|
4473 |
-
|
4474 |
-
|
4475 |
-
|
4476 |
-
|
4477 |
-
|
4478 |
-
|
4479 |
-
|
4480 |
-
|
4481 |
-
|
4482 |
-
|
4483 |
-
|
4484 |
-
|
4485 |
-
|
4486 |
-
|
4487 |
-
|
4488 |
-
|
4489 |
-
|
4490 |
-
|
4491 |
-
|
4492 |
-
|
4493 |
-
|
4494 |
-
|
4495 |
-
|
4496 |
-
|
4497 |
-
|
4498 |
-
|
4499 |
-
|
4500 |
-
|
4501 |
-
|
4502 |
-
|
4503 |
-
|
4504 |
-
|
4505 |
-
|
4506 |
-
|
4507 |
-
|
4508 |
-
|
4509 |
-
|
4510 |
-
|
4511 |
-
|
4512 |
-
|
4513 |
-
|
4514 |
-
|
4515 |
-
|
4516 |
-
|
4517 |
-
|
4518 |
-
|
4519 |
-
|
4520 |
-
|
4521 |
-
|
4522 |
-
|
4523 |
-
|
4524 |
-
|
4525 |
-
|
4526 |
-
|
4527 |
-
|
4528 |
-
|
4529 |
-
|
4530 |
-
|
4531 |
-
|
4532 |
-
|
4533 |
-
|
4534 |
-
|
4535 |
-
|
4536 |
-
|
4537 |
-
|
4538 |
-
|
4539 |
-
|
4540 |
-
|
4541 |
-
|
4542 |
-
|
4543 |
-
|
4544 |
-
|
4545 |
-
|
4546 |
-
|
4547 |
-
|
4548 |
-
|
4549 |
-
|
4550 |
-
|
4551 |
-
|
4552 |
-
|
4553 |
-
|
4554 |
-
|
4555 |
-
|
4556 |
-
|
4557 |
-
|
4558 |
-
|
4559 |
-
|
4560 |
-
|
4561 |
-
|
4562 |
-
|
4563 |
-
|
4564 |
-
|
4565 |
-
|
4566 |
-
|
4567 |
-
|
4568 |
-
|
4569 |
-
|
4570 |
-
|
4571 |
-
|
4572 |
-
|
4573 |
-
|
4574 |
-
|
4575 |
-
|
4576 |
-
|
4577 |
-
|
4578 |
-
|
4579 |
-
|
4580 |
-
|
4581 |
-
|
4582 |
-
|
4583 |
-
|
4584 |
-
|
4585 |
-
|
4586 |
-
|
4587 |
-
|
4588 |
-
|
4589 |
-
|
4590 |
-
|
4591 |
-
|
4592 |
-
|
4593 |
-
|
4594 |
-
|
4595 |
-
|
4596 |
-
|
4597 |
-
|
4598 |
-
|
4599 |
-
|
4600 |
-
|
4601 |
-
|
4602 |
-
|
4603 |
-
|
4604 |
-
|
4605 |
-
|
4606 |
-
|
4607 |
-
|
4608 |
-
|
4609 |
-
|
4610 |
-
|
4611 |
-
|
4612 |
-
|
4613 |
-
|
4614 |
-
|
4615 |
-
|
4616 |
-
|
4617 |
-
|
4618 |
-
|
4619 |
-
|
4620 |
-
|
4621 |
-
|
4622 |
-
|
4623 |
-
|
4624 |
-
|
4625 |
-
|
4626 |
-
|
4627 |
-
|
4628 |
-
|
4629 |
-
|
4630 |
-
|
4631 |
-
|
4632 |
-
|
4633 |
-
|
4634 |
-
|
4635 |
-
|
4636 |
-
|
4637 |
-
|
4638 |
-
|
4639 |
-
|
4640 |
-
|
4641 |
-
|
4642 |
-
|
4643 |
-
|
4644 |
-
$
|
4645 |
-
|
4646 |
-
|
4647 |
-
|
4648 |
-
|
4649 |
-
|
4650 |
-
|
4651 |
-
|
4652 |
-
|
4653 |
-
*
|
4654 |
-
*
|
4655 |
-
* @
|
4656 |
-
*
|
4657 |
-
*
|
4658 |
-
* @
|
4659 |
-
|
4660 |
-
|
4661 |
-
|
4662 |
-
|
4663 |
-
|
4664 |
-
|
4665 |
-
|
4666 |
-
|
4667 |
-
|
4668 |
-
|
4669 |
-
|
4670 |
-
|
4671 |
-
|
4672 |
-
|
4673 |
-
|
4674 |
-
|
4675 |
-
|
4676 |
-
|
4677 |
-
|
4678 |
-
|
4679 |
-
|
4680 |
-
|
4681 |
-
|
4682 |
-
|
4683 |
-
|
4684 |
-
|
4685 |
-
|
4686 |
-
|
4687 |
-
|
4688 |
-
|
4689 |
-
|
4690 |
-
|
4691 |
-
|
4692 |
-
|
4693 |
-
|
4694 |
-
|
4695 |
-
|
4696 |
-
|
4697 |
-
|
4698 |
-
|
4699 |
-
|
4700 |
-
|
4701 |
-
|
4702 |
-
|
4703 |
-
|
4704 |
-
|
4705 |
-
*
|
4706 |
-
|
4707 |
-
|
4708 |
-
|
4709 |
-
|
4710 |
-
|
4711 |
-
|
4712 |
-
|
4713 |
-
|
4714 |
-
|
4715 |
-
|
4716 |
-
|
4717 |
-
|
4718 |
-
|
4719 |
-
|
4720 |
-
|
4721 |
-
|
4722 |
-
|
4723 |
-
|
4724 |
-
|
4725 |
-
|
4726 |
-
|
4727 |
-
|
4728 |
-
|
4729 |
-
|
4730 |
-
|
4731 |
-
|
4732 |
-
|
4733 |
-
|
4734 |
-
|
4735 |
-
|
4736 |
-
|
4737 |
-
|
4738 |
-
|
4739 |
-
|
4740 |
-
|
4741 |
-
|
4742 |
-
|
4743 |
-
|
4744 |
-
|
4745 |
-
|
4746 |
-
|
4747 |
-
|
4748 |
-
|
4749 |
-
|
4750 |
-
|
4751 |
-
|
4752 |
-
|
4753 |
-
|
4754 |
-
|
4755 |
-
|
4756 |
-
|
4757 |
-
|
4758 |
-
|
4759 |
-
|
4760 |
-
|
4761 |
-
|
4762 |
-
|
4763 |
-
|
4764 |
-
|
4765 |
-
|
4766 |
-
|
4767 |
-
|
4768 |
-
|
4769 |
-
|
4770 |
-
|
4771 |
-
|
4772 |
-
|
4773 |
-
|
4774 |
-
|
4775 |
-
|
4776 |
-
|
4777 |
-
|
4778 |
-
*
|
4779 |
-
* @
|
4780 |
-
*
|
4781 |
-
*
|
4782 |
-
|
4783 |
-
|
4784 |
-
|
4785 |
-
|
4786 |
-
|
4787 |
-
|
4788 |
-
|
4789 |
-
|
4790 |
-
|
4791 |
-
|
4792 |
-
|
4793 |
-
|
4794 |
-
|
4795 |
-
|
4796 |
-
|
4797 |
-
|
4798 |
-
|
4799 |
-
|
4800 |
-
|
4801 |
-
$this->
|
4802 |
-
$this->
|
4803 |
-
|
4804 |
-
$
|
4805 |
-
|
4806 |
-
|
4807 |
-
|
4808 |
-
|
4809 |
-
|
4810 |
-
|
4811 |
-
|
4812 |
-
|
4813 |
-
|
4814 |
-
|
4815 |
-
|
4816 |
-
|
4817 |
-
*
|
4818 |
-
*
|
4819 |
-
*
|
4820 |
-
* @
|
4821 |
-
|
4822 |
-
|
4823 |
-
|
4824 |
-
|
4825 |
-
|
4826 |
-
|
4827 |
-
|
4828 |
-
|
4829 |
-
|
4830 |
-
|
4831 |
-
|
4832 |
-
|
4833 |
-
|
4834 |
-
|
4835 |
-
|
4836 |
-
|
4837 |
-
|
4838 |
-
|
4839 |
-
|
4840 |
-
|
4841 |
-
|
4842 |
-
|
4843 |
-
|
4844 |
-
|
4845 |
-
|
4846 |
-
|
4847 |
-
|
4848 |
-
|
4849 |
-
|
4850 |
-
|
4851 |
-
|
4852 |
-
|
4853 |
-
|
4854 |
-
|
4855 |
-
|
4856 |
-
|
4857 |
-
|
4858 |
-
|
4859 |
-
|
4860 |
-
|
4861 |
-
|
4862 |
-
|
4863 |
-
|
4864 |
-
|
4865 |
-
|
4866 |
-
|
4867 |
-
|
4868 |
-
|
4869 |
-
|
4870 |
-
|
4871 |
-
|
4872 |
-
|
4873 |
-
|
4874 |
-
|
4875 |
-
|
4876 |
-
|
4877 |
-
|
4878 |
-
|
4879 |
-
|
4880 |
-
|
4881 |
-
|
4882 |
-
|
4883 |
-
|
4884 |
-
|
4885 |
-
|
4886 |
-
|
4887 |
-
|
4888 |
-
|
4889 |
-
|
4890 |
-
|
4891 |
-
|
4892 |
-
|
4893 |
-
|
4894 |
-
|
4895 |
-
|
4896 |
-
|
4897 |
-
|
4898 |
-
|
4899 |
-
|
4900 |
-
|
4901 |
-
|
4902 |
-
|
4903 |
-
|
4904 |
-
|
4905 |
-
|
4906 |
-
|
4907 |
-
|
4908 |
-
|
4909 |
-
|
4910 |
-
|
4911 |
-
|
4912 |
-
|
4913 |
-
|
4914 |
-
|
4915 |
-
|
4916 |
-
|
4917 |
-
|
4918 |
-
|
4919 |
-
|
4920 |
-
|
4921 |
-
|
4922 |
-
|
4923 |
-
|
4924 |
-
|
4925 |
-
|
4926 |
-
|
4927 |
-
|
4928 |
-
|
4929 |
-
|
4930 |
-
|
4931 |
-
|
4932 |
-
|
4933 |
-
)
|
4934 |
-
|
4935 |
-
|
4936 |
-
|
4937 |
-
|
4938 |
-
|
4939 |
-
|
4940 |
-
|
4941 |
-
|
4942 |
-
|
4943 |
-
|
4944 |
-
|
4945 |
-
|
4946 |
-
|
4947 |
-
|
4948 |
-
|
4949 |
-
|
4950 |
-
|
4951 |
-
|
4952 |
-
|
4953 |
-
|
4954 |
-
|
4955 |
-
|
4956 |
-
|
4957 |
-
|
4958 |
-
|
4959 |
-
|
4960 |
-
|
4961 |
-
|
4962 |
-
}
|
4963 |
-
|
4964 |
-
|
4965 |
-
|
4966 |
-
|
4967 |
-
|
4968 |
-
|
4969 |
-
|
4970 |
-
|
4971 |
-
|
4972 |
-
|
4973 |
-
|
4974 |
-
|
4975 |
-
|
4976 |
-
|
4977 |
-
|
4978 |
-
|
4979 |
-
|
4980 |
-
|
4981 |
-
|
4982 |
-
|
4983 |
-
|
4984 |
-
|
4985 |
-
|
4986 |
-
|
4987 |
-
|
4988 |
-
|
4989 |
-
|
4990 |
-
|
4991 |
-
|
4992 |
-
|
4993 |
-
|
4994 |
-
|
4995 |
-
|
4996 |
-
|
4997 |
-
|
4998 |
-
|
4999 |
-
|
5000 |
-
|
5001 |
-
|
5002 |
-
|
5003 |
-
|
5004 |
-
|
5005 |
-
|
5006 |
-
|
5007 |
-
|
5008 |
-
|
5009 |
-
|
5010 |
-
|
5011 |
-
|
5012 |
-
|
5013 |
-
|
5014 |
-
|
5015 |
-
|
5016 |
-
|
5017 |
-
|
5018 |
-
|
5019 |
-
|
5020 |
-
|
5021 |
-
|
5022 |
-
|
5023 |
-
|
5024 |
-
|
5025 |
-
|
5026 |
-
|
5027 |
-
|
5028 |
-
|
5029 |
-
|
5030 |
-
|
5031 |
-
|
5032 |
-
|
5033 |
-
|
5034 |
-
|
5035 |
-
|
5036 |
-
|
5037 |
-
|
5038 |
-
|
5039 |
-
|
5040 |
-
|
5041 |
-
|
5042 |
-
|
5043 |
-
|
5044 |
-
|
5045 |
-
|
5046 |
-
|
5047 |
-
|
5048 |
-
|
5049 |
-
|
5050 |
-
|
5051 |
-
|
5052 |
-
|
5053 |
-
|
5054 |
-
|
5055 |
-
|
5056 |
-
|
5057 |
-
|
5058 |
-
|
5059 |
-
|
5060 |
-
|
5061 |
-
|
5062 |
-
|
5063 |
-
|
5064 |
-
|
5065 |
-
|
5066 |
-
|
5067 |
-
|
5068 |
-
|
5069 |
-
|
5070 |
-
|
5071 |
-
|
5072 |
-
|
5073 |
-
|
5074 |
-
}
|
5075 |
-
|
5076 |
-
/**
|
5077 |
-
* @author Vova Feldman (@svovaf)
|
5078 |
-
* @since 1.
|
5079 |
-
|
5080 |
-
|
5081 |
-
|
5082 |
-
|
5083 |
-
|
5084 |
-
|
5085 |
-
|
5086 |
-
|
5087 |
-
|
5088 |
-
|
5089 |
-
|
5090 |
-
|
5091 |
-
|
5092 |
-
|
5093 |
-
|
5094 |
-
|
5095 |
-
|
5096 |
-
|
5097 |
-
|
5098 |
-
|
5099 |
-
|
5100 |
-
|
5101 |
-
|
5102 |
-
|
5103 |
-
|
5104 |
-
|
5105 |
-
|
5106 |
-
|
5107 |
-
|
5108 |
-
|
5109 |
-
|
5110 |
-
|
5111 |
-
|
5112 |
-
|
5113 |
-
*
|
5114 |
-
* @
|
5115 |
-
*/
|
5116 |
-
function
|
5117 |
-
|
5118 |
-
|
5119 |
-
|
5120 |
-
|
5121 |
-
|
5122 |
-
|
5123 |
-
|
5124 |
-
|
5125 |
-
|
5126 |
-
|
5127 |
-
|
5128 |
-
}
|
5129 |
-
|
5130 |
-
/**
|
5131 |
-
*
|
5132 |
-
*
|
5133 |
-
*
|
5134 |
-
* @
|
5135 |
-
*/
|
5136 |
-
function
|
5137 |
-
$this->
|
5138 |
-
|
5139 |
-
|
5140 |
-
|
5141 |
-
|
5142 |
-
|
5143 |
-
|
5144 |
-
|
5145 |
-
|
5146 |
-
|
5147 |
-
|
5148 |
-
|
5149 |
-
|
5150 |
-
|
5151 |
-
|
5152 |
-
|
5153 |
-
|
5154 |
-
|
5155 |
-
|
5156 |
-
|
5157 |
-
|
5158 |
-
|
5159 |
-
|
5160 |
-
|
5161 |
-
|
5162 |
-
|
5163 |
-
|
5164 |
-
|
5165 |
-
|
5166 |
-
|
5167 |
-
|
5168 |
-
|
5169 |
-
|
5170 |
-
|
5171 |
-
|
5172 |
-
|
5173 |
-
|
5174 |
-
|
5175 |
-
|
5176 |
-
|
5177 |
-
|
5178 |
-
|
5179 |
-
|
5180 |
-
|
5181 |
-
|
5182 |
-
|
5183 |
-
|
5184 |
-
|
5185 |
-
|
5186 |
-
|
5187 |
-
|
5188 |
-
|
5189 |
-
|
5190 |
-
|
5191 |
-
|
5192 |
-
* @
|
5193 |
-
*
|
5194 |
-
*
|
5195 |
-
|
5196 |
-
|
5197 |
-
|
5198 |
-
|
5199 |
-
|
5200 |
-
|
5201 |
-
|
5202 |
-
$
|
5203 |
-
|
5204 |
-
|
5205 |
-
|
5206 |
-
|
5207 |
-
|
5208 |
-
}
|
5209 |
-
|
5210 |
-
$
|
5211 |
-
|
5212 |
-
|
5213 |
-
|
5214 |
-
|
5215 |
-
|
5216 |
-
|
5217 |
-
|
5218 |
-
|
5219 |
-
|
5220 |
-
|
5221 |
-
|
5222 |
-
|
5223 |
-
|
5224 |
-
|
5225 |
-
|
5226 |
-
|
5227 |
-
|
5228 |
-
|
5229 |
-
|
5230 |
-
|
5231 |
-
|
5232 |
-
|
5233 |
-
|
5234 |
-
|
5235 |
-
|
5236 |
-
|
5237 |
-
|
5238 |
-
|
5239 |
-
|
5240 |
-
|
5241 |
-
|
5242 |
-
|
5243 |
-
|
5244 |
-
|
5245 |
-
|
5246 |
-
|
5247 |
-
|
5248 |
-
|
5249 |
-
|
5250 |
-
|
5251 |
-
|
5252 |
-
|
5253 |
-
|
5254 |
-
|
5255 |
-
|
5256 |
-
|
5257 |
-
|
5258 |
-
|
5259 |
-
|
5260 |
-
|
5261 |
-
|
5262 |
-
|
5263 |
-
|
5264 |
-
|
5265 |
-
|
5266 |
-
|
5267 |
-
|
5268 |
-
|
5269 |
-
|
5270 |
-
|
5271 |
-
|
5272 |
-
|
5273 |
-
|
5274 |
-
|
5275 |
-
|
5276 |
-
|
5277 |
-
|
5278 |
-
|
5279 |
-
|
5280 |
-
|
5281 |
-
|
5282 |
-
|
5283 |
-
|
5284 |
-
|
5285 |
-
|
5286 |
-
|
5287 |
-
|
5288 |
-
|
5289 |
-
|
5290 |
-
|
5291 |
-
|
5292 |
-
|
5293 |
-
|
5294 |
-
|
5295 |
-
|
5296 |
-
|
5297 |
-
|
5298 |
-
|
5299 |
-
|
5300 |
-
|
5301 |
-
|
5302 |
-
|
5303 |
-
|
5304 |
-
*
|
5305 |
-
|
5306 |
-
|
5307 |
-
|
5308 |
-
|
5309 |
-
|
5310 |
-
|
5311 |
-
|
5312 |
-
|
5313 |
-
|
5314 |
-
|
5315 |
-
|
5316 |
-
|
5317 |
-
|
5318 |
-
|
5319 |
-
|
5320 |
-
|
5321 |
-
|
5322 |
-
|
5323 |
-
|
5324 |
-
|
5325 |
-
|
5326 |
-
|
5327 |
-
|
5328 |
-
|
5329 |
-
|
5330 |
-
|
5331 |
-
|
5332 |
-
|
5333 |
-
|
5334 |
-
|
5335 |
-
|
5336 |
-
|
5337 |
-
|
5338 |
-
|
5339 |
-
|
5340 |
-
|
5341 |
-
|
5342 |
-
|
5343 |
-
|
5344 |
-
|
5345 |
-
|
5346 |
-
|
5347 |
-
|
5348 |
-
|
5349 |
-
|
5350 |
-
|
5351 |
-
|
5352 |
-
|
5353 |
-
|
5354 |
-
|
5355 |
-
|
5356 |
-
|
5357 |
-
|
5358 |
-
|
5359 |
-
|
5360 |
-
|
5361 |
-
|
5362 |
-
|
5363 |
-
|
5364 |
-
|
5365 |
-
|
5366 |
-
|
5367 |
-
|
5368 |
-
|
5369 |
-
|
5370 |
-
|
5371 |
-
|
5372 |
-
|
5373 |
-
|
5374 |
-
|
5375 |
-
|
5376 |
-
|
5377 |
-
|
5378 |
-
|
5379 |
-
|
5380 |
-
|
5381 |
-
|
5382 |
-
|
5383 |
-
|
5384 |
-
|
5385 |
-
|
5386 |
-
|
5387 |
-
|
5388 |
-
|
5389 |
-
|
5390 |
-
|
5391 |
-
|
5392 |
-
|
5393 |
-
|
5394 |
-
|
5395 |
-
|
5396 |
-
|
5397 |
-
|
5398 |
-
|
5399 |
-
|
5400 |
-
|
5401 |
-
|
5402 |
-
|
5403 |
-
|
5404 |
-
|
5405 |
-
|
5406 |
-
|
5407 |
-
|
5408 |
-
|
5409 |
-
|
5410 |
-
|
5411 |
-
|
5412 |
-
|
5413 |
-
|
5414 |
-
|
5415 |
-
|
5416 |
-
|
5417 |
-
|
5418 |
-
|
5419 |
-
|
5420 |
-
|
5421 |
-
|
5422 |
-
|
5423 |
-
|
5424 |
-
|
5425 |
-
|
5426 |
-
|
5427 |
-
|
5428 |
-
*
|
5429 |
-
*
|
5430 |
-
*
|
5431 |
-
* @
|
5432 |
-
*
|
5433 |
-
* @
|
5434 |
-
|
5435 |
-
|
5436 |
-
|
5437 |
-
|
5438 |
-
|
5439 |
-
|
5440 |
-
|
5441 |
-
|
5442 |
-
$
|
5443 |
-
|
5444 |
-
|
5445 |
-
|
5446 |
-
|
5447 |
-
|
5448 |
-
|
5449 |
-
|
5450 |
-
|
5451 |
-
|
5452 |
-
|
5453 |
-
|
5454 |
-
|
5455 |
-
|
5456 |
-
$
|
5457 |
-
|
5458 |
-
|
5459 |
-
|
5460 |
-
|
5461 |
-
|
5462 |
-
|
5463 |
-
|
5464 |
-
|
5465 |
-
|
5466 |
-
|
5467 |
-
|
5468 |
-
|
5469 |
-
|
5470 |
-
|
5471 |
-
|
5472 |
-
|
5473 |
-
|
5474 |
-
|
5475 |
-
|
5476 |
-
|
5477 |
-
|
5478 |
-
|
5479 |
-
|
5480 |
-
|
5481 |
-
|
5482 |
-
|
5483 |
-
|
5484 |
-
|
5485 |
-
|
5486 |
-
|
5487 |
-
*
|
5488 |
-
*
|
5489 |
-
* @
|
5490 |
-
|
5491 |
-
|
5492 |
-
|
5493 |
-
|
5494 |
-
|
5495 |
-
|
5496 |
-
|
5497 |
-
|
5498 |
-
|
5499 |
-
|
5500 |
-
|
5501 |
-
|
5502 |
-
|
5503 |
-
|
5504 |
-
|
5505 |
-
|
5506 |
-
|
5507 |
-
|
5508 |
-
|
5509 |
-
|
5510 |
-
|
5511 |
-
|
5512 |
-
|
5513 |
-
|
5514 |
-
|
5515 |
-
|
5516 |
-
|
5517 |
-
|
5518 |
-
|
5519 |
-
|
5520 |
-
|
5521 |
-
|
5522 |
-
|
5523 |
-
|
5524 |
-
|
5525 |
-
|
5526 |
-
|
5527 |
-
|
5528 |
-
|
5529 |
-
|
5530 |
-
|
5531 |
-
|
5532 |
-
|
5533 |
-
|
5534 |
-
|
5535 |
-
|
5536 |
-
|
5537 |
-
|
5538 |
-
|
5539 |
-
|
5540 |
-
|
5541 |
-
|
5542 |
-
|
5543 |
-
|
5544 |
-
|
5545 |
-
|
5546 |
-
|
5547 |
-
|
5548 |
-
|
5549 |
-
|
5550 |
-
|
5551 |
-
|
5552 |
-
|
5553 |
-
|
5554 |
-
|
5555 |
-
|
5556 |
-
|
5557 |
-
*
|
5558 |
-
*
|
5559 |
-
* @
|
5560 |
-
|
5561 |
-
|
5562 |
-
|
5563 |
-
|
5564 |
-
|
5565 |
-
|
5566 |
-
|
5567 |
-
|
5568 |
-
|
5569 |
-
|
5570 |
-
|
5571 |
-
|
5572 |
-
|
5573 |
-
|
5574 |
-
|
5575 |
-
|
5576 |
-
|
5577 |
-
|
5578 |
-
|
5579 |
-
|
5580 |
-
|
5581 |
-
|
5582 |
-
|
5583 |
-
|
5584 |
-
*
|
5585 |
-
|
5586 |
-
|
5587 |
-
|
5588 |
-
|
5589 |
-
|
5590 |
-
|
5591 |
-
|
5592 |
-
|
5593 |
-
*
|
5594 |
-
*
|
5595 |
-
*
|
5596 |
-
* @
|
5597 |
-
|
5598 |
-
|
5599 |
-
|
5600 |
-
|
5601 |
-
|
5602 |
-
|
5603 |
-
|
5604 |
-
|
5605 |
-
|
5606 |
-
|
5607 |
-
|
5608 |
-
|
5609 |
-
|
5610 |
-
|
5611 |
-
|
5612 |
-
|
5613 |
-
|
5614 |
-
|
5615 |
-
|
5616 |
-
|
5617 |
-
|
5618 |
-
|
5619 |
-
|
5620 |
-
|
5621 |
-
|
5622 |
-
|
5623 |
-
|
5624 |
-
|
5625 |
-
|
5626 |
-
|
5627 |
-
|
5628 |
-
|
5629 |
-
|
5630 |
-
|
5631 |
-
|
5632 |
-
|
5633 |
-
|
5634 |
-
|
5635 |
-
|
5636 |
-
|
5637 |
-
|
5638 |
-
|
5639 |
-
|
5640 |
-
|
5641 |
-
|
5642 |
-
|
5643 |
-
|
5644 |
-
*
|
5645 |
-
*
|
5646 |
-
*
|
5647 |
-
*
|
5648 |
-
*
|
5649 |
-
*
|
5650 |
-
|
5651 |
-
|
5652 |
-
|
5653 |
-
|
5654 |
-
|
5655 |
-
|
5656 |
-
|
5657 |
-
|
5658 |
-
|
5659 |
-
|
5660 |
-
|
5661 |
-
|
5662 |
-
*
|
5663 |
-
*
|
5664 |
-
*
|
5665 |
-
*
|
5666 |
-
|
5667 |
-
|
5668 |
-
|
5669 |
-
|
5670 |
-
|
5671 |
-
|
5672 |
-
|
5673 |
-
|
5674 |
-
|
5675 |
-
|
5676 |
-
|
5677 |
-
|
5678 |
-
|
5679 |
-
|
5680 |
-
|
5681 |
-
|
5682 |
-
|
5683 |
-
|
5684 |
-
|
5685 |
-
|
5686 |
-
|
5687 |
-
|
5688 |
-
|
5689 |
-
|
5690 |
-
|
5691 |
-
|
5692 |
-
|
5693 |
-
|
5694 |
-
|
5695 |
-
|
5696 |
-
|
5697 |
-
|
5698 |
-
|
5699 |
-
|
5700 |
-
|
5701 |
-
|
5702 |
-
|
5703 |
-
|
5704 |
-
|
5705 |
-
|
5706 |
-
|
5707 |
-
|
5708 |
-
|
5709 |
-
|
5710 |
-
|
5711 |
-
|
5712 |
-
|
5713 |
-
|
5714 |
-
|
5715 |
-
|
5716 |
-
|
5717 |
-
|
5718 |
-
|
5719 |
-
|
5720 |
-
|
5721 |
-
|
5722 |
-
|
5723 |
-
|
5724 |
-
|
5725 |
-
|
5726 |
-
*
|
5727 |
-
*
|
5728 |
-
|
5729 |
-
|
5730 |
-
|
5731 |
-
|
5732 |
-
|
5733 |
-
|
5734 |
-
|
5735 |
-
|
5736 |
-
|
5737 |
-
|
5738 |
-
|
5739 |
-
|
5740 |
-
$
|
5741 |
-
|
5742 |
-
|
5743 |
-
|
5744 |
-
|
5745 |
-
|
5746 |
-
|
5747 |
-
|
5748 |
-
|
5749 |
-
|
5750 |
-
|
5751 |
-
|
5752 |
-
|
5753 |
-
|
5754 |
-
|
5755 |
-
|
5756 |
-
|
5757 |
-
|
5758 |
-
|
5759 |
-
|
5760 |
-
|
5761 |
-
|
5762 |
-
|
5763 |
-
|
5764 |
-
|
5765 |
-
|
5766 |
-
|
5767 |
-
|
5768 |
-
|
5769 |
-
|
5770 |
-
|
5771 |
-
|
5772 |
-
|
5773 |
-
|
5774 |
-
|
5775 |
-
|
5776 |
-
|
5777 |
-
|
5778 |
-
|
5779 |
-
|
5780 |
-
|
5781 |
-
|
5782 |
-
|
5783 |
-
*
|
5784 |
-
*
|
5785 |
-
|
5786 |
-
|
5787 |
-
|
5788 |
-
|
5789 |
-
if ( !
|
5790 |
-
|
5791 |
-
}
|
5792 |
-
|
5793 |
-
|
5794 |
-
|
5795 |
-
|
5796 |
-
|
5797 |
-
|
5798 |
-
|
5799 |
-
|
5800 |
-
|
5801 |
-
|
5802 |
-
|
5803 |
-
|
5804 |
-
|
5805 |
-
|
5806 |
-
|
5807 |
-
|
5808 |
-
|
5809 |
-
|
5810 |
-
|
5811 |
-
|
5812 |
-
|
5813 |
-
|
5814 |
-
|
5815 |
-
|
5816 |
-
|
5817 |
-
|
5818 |
-
|
5819 |
-
|
5820 |
-
|
5821 |
-
|
5822 |
-
|
5823 |
-
|
5824 |
-
|
5825 |
-
|
5826 |
-
|
5827 |
-
|
5828 |
-
|
5829 |
-
|
5830 |
-
|
5831 |
-
|
5832 |
-
|
5833 |
-
|
5834 |
-
|
5835 |
-
|
5836 |
-
|
5837 |
-
|
5838 |
-
|
5839 |
-
|
5840 |
-
|
5841 |
-
|
5842 |
-
|
5843 |
-
|
5844 |
-
|
5845 |
-
|
5846 |
-
$this->
|
5847 |
-
}
|
5848 |
-
|
5849 |
-
return $this->
|
5850 |
-
}
|
5851 |
-
|
5852 |
-
/**
|
5853 |
-
* @author Vova Feldman (@svovaf)
|
5854 |
-
* @since 1.
|
5855 |
-
*
|
5856 |
-
* @
|
5857 |
-
|
5858 |
-
|
5859 |
-
|
5860 |
-
|
5861 |
-
|
5862 |
-
|
5863 |
-
|
5864 |
-
|
5865 |
-
|
5866 |
-
|
5867 |
-
|
5868 |
-
|
5869 |
-
|
5870 |
-
|
5871 |
-
|
5872 |
-
|
5873 |
-
|
5874 |
-
|
5875 |
-
|
5876 |
-
|
5877 |
-
|
5878 |
-
|
5879 |
-
|
5880 |
-
|
5881 |
-
|
5882 |
-
|
5883 |
-
* @author Vova Feldman (@svovaf)
|
5884 |
-
* @since 1.
|
5885 |
-
*
|
5886 |
-
* @
|
5887 |
-
*/
|
5888 |
-
function
|
5889 |
-
$this->
|
5890 |
-
|
5891 |
-
|
5892 |
-
|
5893 |
-
|
5894 |
-
|
5895 |
-
|
5896 |
-
|
5897 |
-
|
5898 |
-
|
5899 |
-
|
5900 |
-
|
5901 |
-
|
5902 |
-
|
5903 |
-
|
5904 |
-
|
5905 |
-
|
5906 |
-
|
5907 |
-
|
5908 |
-
|
5909 |
-
|
5910 |
-
|
5911 |
-
|
5912 |
-
|
5913 |
-
|
5914 |
-
|
5915 |
-
|
5916 |
-
|
5917 |
-
|
5918 |
-
|
5919 |
-
|
5920 |
-
|
5921 |
-
|
5922 |
-
|
5923 |
-
|
5924 |
-
|
5925 |
-
|
5926 |
-
|
5927 |
-
* @author Vova Feldman (@svovaf)
|
5928 |
-
* @since 1.0.9
|
5929 |
-
*
|
5930 |
-
* @
|
5931 |
-
|
5932 |
-
|
5933 |
-
|
5934 |
-
|
5935 |
-
if ( !
|
5936 |
-
|
5937 |
-
|
5938 |
-
|
5939 |
-
|
5940 |
-
|
5941 |
-
|
5942 |
-
|
5943 |
-
|
5944 |
-
|
5945 |
-
|
5946 |
-
|
5947 |
-
|
5948 |
-
|
5949 |
-
|
5950 |
-
|
5951 |
-
|
5952 |
-
|
5953 |
-
|
5954 |
-
|
5955 |
-
|
5956 |
-
|
5957 |
-
|
5958 |
-
*
|
5959 |
-
* @
|
5960 |
-
|
5961 |
-
|
5962 |
-
|
5963 |
-
|
5964 |
-
|
5965 |
-
|
5966 |
-
|
5967 |
-
|
5968 |
-
|
5969 |
-
|
5970 |
-
|
5971 |
-
|
5972 |
-
|
5973 |
-
|
5974 |
-
|
5975 |
-
* @
|
5976 |
-
*
|
5977 |
-
*
|
5978 |
-
|
5979 |
-
|
5980 |
-
|
5981 |
-
|
5982 |
-
|
5983 |
-
|
5984 |
-
$this->
|
5985 |
-
|
5986 |
-
|
5987 |
-
|
5988 |
-
|
5989 |
-
|
5990 |
-
|
5991 |
-
|
5992 |
-
|
5993 |
-
|
5994 |
-
|
5995 |
-
|
5996 |
-
|
5997 |
-
|
5998 |
-
|
5999 |
-
|
6000 |
-
|
6001 |
-
|
6002 |
-
|
6003 |
-
|
6004 |
-
|
6005 |
-
|
6006 |
-
|
6007 |
-
|
6008 |
-
|
6009 |
-
|
6010 |
-
|
6011 |
-
|
6012 |
-
|
6013 |
-
|
6014 |
-
|
6015 |
-
|
6016 |
-
|
6017 |
-
|
6018 |
-
|
6019 |
-
|
6020 |
-
|
6021 |
-
|
6022 |
-
|
6023 |
-
|
6024 |
-
|
6025 |
-
|
6026 |
-
|
6027 |
-
|
6028 |
-
|
6029 |
-
|
6030 |
-
|
6031 |
-
|
6032 |
-
|
6033 |
-
|
6034 |
-
|
6035 |
-
|
6036 |
-
|
6037 |
-
|
6038 |
-
|
6039 |
-
|
6040 |
-
|
6041 |
-
|
6042 |
-
|
6043 |
-
|
6044 |
-
|
6045 |
-
|
6046 |
-
|
6047 |
-
|
6048 |
-
|
6049 |
-
|
6050 |
-
|
6051 |
-
|
6052 |
-
|
6053 |
-
|
6054 |
-
|
6055 |
-
|
6056 |
-
|
6057 |
-
|
6058 |
-
|
6059 |
-
|
6060 |
-
|
6061 |
-
|
6062 |
-
|
6063 |
-
|
6064 |
-
|
6065 |
-
|
6066 |
-
|
6067 |
-
|
6068 |
-
|
6069 |
-
|
6070 |
-
|
6071 |
-
|
6072 |
-
|
6073 |
-
|
6074 |
-
|
6075 |
-
|
6076 |
-
|
6077 |
-
|
6078 |
-
|
6079 |
-
|
6080 |
-
|
6081 |
-
|
6082 |
-
|
6083 |
-
|
6084 |
-
|
6085 |
-
|
6086 |
-
|
6087 |
-
|
6088 |
-
|
6089 |
-
|
6090 |
-
|
6091 |
-
|
6092 |
-
|
6093 |
-
|
6094 |
-
|
6095 |
-
|
6096 |
-
|
6097 |
-
|
6098 |
-
|
6099 |
-
|
6100 |
-
|
6101 |
-
|
6102 |
-
|
6103 |
-
|
6104 |
-
|
6105 |
-
|
6106 |
-
|
6107 |
-
|
6108 |
-
|
6109 |
-
|
6110 |
-
|
6111 |
-
|
6112 |
-
|
6113 |
-
|
6114 |
-
|
6115 |
-
|
6116 |
-
|
6117 |
-
|
6118 |
-
|
6119 |
-
|
6120 |
-
|
6121 |
-
|
6122 |
-
*
|
6123 |
-
*
|
6124 |
-
|
6125 |
-
|
6126 |
-
|
6127 |
-
|
6128 |
-
|
6129 |
-
|
6130 |
-
|
6131 |
-
|
6132 |
-
|
6133 |
-
|
6134 |
-
|
6135 |
-
|
6136 |
-
*
|
6137 |
-
*
|
6138 |
-
*
|
6139 |
-
*
|
6140 |
-
* @
|
6141 |
-
|
6142 |
-
|
6143 |
-
|
6144 |
-
|
6145 |
-
|
6146 |
-
|
6147 |
-
|
6148 |
-
|
6149 |
-
|
6150 |
-
|
6151 |
-
|
6152 |
-
|
6153 |
-
*
|
6154 |
-
*
|
6155 |
-
*
|
6156 |
-
* @
|
6157 |
-
* @
|
6158 |
-
|
6159 |
-
|
6160 |
-
|
6161 |
-
|
6162 |
-
)
|
6163 |
-
|
6164 |
-
|
6165 |
-
|
6166 |
-
|
6167 |
-
|
6168 |
-
|
6169 |
-
|
6170 |
-
* @author Vova Feldman (@svovaf)
|
6171 |
-
* @since 1.
|
6172 |
-
|
6173 |
-
|
6174 |
-
|
6175 |
-
|
6176 |
-
|
6177 |
-
|
6178 |
-
|
6179 |
-
|
6180 |
-
|
6181 |
-
|
6182 |
-
}
|
6183 |
-
|
6184 |
-
|
6185 |
-
|
6186 |
-
|
6187 |
-
|
6188 |
-
|
6189 |
-
|
6190 |
-
|
6191 |
-
|
6192 |
-
|
6193 |
-
|
6194 |
-
|
6195 |
-
|
6196 |
-
|
6197 |
-
|
6198 |
-
|
6199 |
-
|
6200 |
-
|
6201 |
-
|
6202 |
-
|
6203 |
-
|
6204 |
-
|
6205 |
-
*
|
6206 |
-
* @
|
6207 |
-
*/
|
6208 |
-
function
|
6209 |
-
$
|
6210 |
-
|
6211 |
-
|
6212 |
-
|
6213 |
-
|
6214 |
-
|
6215 |
-
|
6216 |
-
|
6217 |
-
|
6218 |
-
|
6219 |
-
|
6220 |
-
|
6221 |
-
|
6222 |
-
|
6223 |
-
|
6224 |
-
|
6225 |
-
$
|
6226 |
-
|
6227 |
-
if ( $
|
6228 |
-
$
|
6229 |
-
|
6230 |
-
|
6231 |
-
|
6232 |
-
|
6233 |
-
|
6234 |
-
|
6235 |
-
|
6236 |
-
|
6237 |
-
|
6238 |
-
|
6239 |
-
|
6240 |
-
|
6241 |
-
|
6242 |
-
|
6243 |
-
|
6244 |
-
|
6245 |
-
|
6246 |
-
|
6247 |
-
|
6248 |
-
|
6249 |
-
|
6250 |
-
|
6251 |
-
|
6252 |
-
|
6253 |
-
|
6254 |
-
|
6255 |
-
|
6256 |
-
|
6257 |
-
|
6258 |
-
|
6259 |
-
|
6260 |
-
|
6261 |
-
|
6262 |
-
|
6263 |
-
|
6264 |
-
|
6265 |
-
}
|
6266 |
-
|
6267 |
-
/**
|
6268 |
-
*
|
6269 |
-
*
|
6270 |
-
* @author
|
6271 |
-
* @since 1.2.1.5
|
6272 |
-
|
6273 |
-
|
6274 |
-
|
6275 |
-
|
6276 |
-
$this->
|
6277 |
-
|
6278 |
-
|
6279 |
-
|
6280 |
-
|
6281 |
-
|
6282 |
-
|
6283 |
-
|
6284 |
-
|
6285 |
-
|
6286 |
-
|
6287 |
-
|
6288 |
-
|
6289 |
-
|
6290 |
-
|
6291 |
-
|
6292 |
-
|
6293 |
-
|
6294 |
-
|
6295 |
-
|
6296 |
-
|
6297 |
-
|
6298 |
-
|
6299 |
-
|
6300 |
-
|
6301 |
-
*
|
6302 |
-
*
|
6303 |
-
* @
|
6304 |
-
|
6305 |
-
|
6306 |
-
|
6307 |
-
|
6308 |
-
|
6309 |
-
|
6310 |
-
|
6311 |
-
|
6312 |
-
|
6313 |
-
|
6314 |
-
|
6315 |
-
|
6316 |
-
|
6317 |
-
|
6318 |
-
|
6319 |
-
|
6320 |
-
|
6321 |
-
|
6322 |
-
|
6323 |
-
|
6324 |
-
|
6325 |
-
|
6326 |
-
|
6327 |
-
|
6328 |
-
|
6329 |
-
|
6330 |
-
|
6331 |
-
|
6332 |
-
|
6333 |
-
|
6334 |
-
|
6335 |
-
|
6336 |
-
|
6337 |
-
|
6338 |
-
|
6339 |
-
|
6340 |
-
|
6341 |
-
|
6342 |
-
|
6343 |
-
|
6344 |
-
|
6345 |
-
|
6346 |
-
|
6347 |
-
|
6348 |
-
|
6349 |
-
|
6350 |
-
|
6351 |
-
|
6352 |
-
|
6353 |
-
|
6354 |
-
|
6355 |
-
|
6356 |
-
|
6357 |
-
|
6358 |
-
|
6359 |
-
|
6360 |
-
|
6361 |
-
|
6362 |
-
|
6363 |
-
|
6364 |
-
|
6365 |
-
|
6366 |
-
|
6367 |
-
|
6368 |
-
|
6369 |
-
|
6370 |
-
|
6371 |
-
|
6372 |
-
|
6373 |
-
|
6374 |
-
|
6375 |
-
|
6376 |
-
|
6377 |
-
|
6378 |
-
|
6379 |
-
|
6380 |
-
|
6381 |
-
|
6382 |
-
|
6383 |
-
|
6384 |
-
|
6385 |
-
|
6386 |
-
|
6387 |
-
|
6388 |
-
|
6389 |
-
|
6390 |
-
|
6391 |
-
|
6392 |
-
|
6393 |
-
|
6394 |
-
|
6395 |
-
|
6396 |
-
|
6397 |
-
|
6398 |
-
|
6399 |
-
|
6400 |
-
|
6401 |
-
|
6402 |
-
|
6403 |
-
|
6404 |
-
|
6405 |
-
*
|
6406 |
-
*
|
6407 |
-
*
|
6408 |
-
* @
|
6409 |
-
|
6410 |
-
|
6411 |
-
|
6412 |
-
|
6413 |
-
|
6414 |
-
|
6415 |
-
|
6416 |
-
|
6417 |
-
|
6418 |
-
|
6419 |
-
|
6420 |
-
|
6421 |
-
|
6422 |
-
|
6423 |
-
|
6424 |
-
|
6425 |
-
|
6426 |
-
|
6427 |
-
|
6428 |
-
|
6429 |
-
|
6430 |
-
|
6431 |
-
*
|
6432 |
-
*
|
6433 |
-
* @
|
6434 |
-
|
6435 |
-
|
6436 |
-
|
6437 |
-
|
6438 |
-
|
6439 |
-
|
6440 |
-
|
6441 |
-
|
6442 |
-
|
6443 |
-
*
|
6444 |
-
*
|
6445 |
-
* @
|
6446 |
-
|
6447 |
-
|
6448 |
-
|
6449 |
-
|
6450 |
-
|
6451 |
-
|
6452 |
-
|
6453 |
-
|
6454 |
-
|
6455 |
-
*
|
6456 |
-
*
|
6457 |
-
* @
|
6458 |
-
*
|
6459 |
-
*
|
6460 |
-
*
|
6461 |
-
|
6462 |
-
|
6463 |
-
|
6464 |
-
|
6465 |
-
|
6466 |
-
|
6467 |
-
|
6468 |
-
|
6469 |
-
|
6470 |
-
|
6471 |
-
|
6472 |
-
|
6473 |
-
|
6474 |
-
|
6475 |
-
|
6476 |
-
|
6477 |
-
|
6478 |
-
|
6479 |
-
*
|
6480 |
-
* @
|
6481 |
-
*
|
6482 |
-
*
|
6483 |
-
|
6484 |
-
|
6485 |
-
|
6486 |
-
|
6487 |
-
|
6488 |
-
|
6489 |
-
|
6490 |
-
|
6491 |
-
$is_trial
|
6492 |
-
|
6493 |
-
|
6494 |
-
|
6495 |
-
|
6496 |
-
|
6497 |
-
|
6498 |
-
|
6499 |
-
|
6500 |
-
|
6501 |
-
|
6502 |
-
|
6503 |
-
|
6504 |
-
|
6505 |
-
|
6506 |
-
|
6507 |
-
|
6508 |
-
|
6509 |
-
|
6510 |
-
|
6511 |
-
|
6512 |
-
|
6513 |
-
|
6514 |
-
*
|
6515 |
-
*
|
6516 |
-
*
|
6517 |
-
* @
|
6518 |
-
|
6519 |
-
|
6520 |
-
|
6521 |
-
|
6522 |
-
|
6523 |
-
|
6524 |
-
|
6525 |
-
|
6526 |
-
|
6527 |
-
|
6528 |
-
|
6529 |
-
|
6530 |
-
|
6531 |
-
|
6532 |
-
|
6533 |
-
|
6534 |
-
|
6535 |
-
|
6536 |
-
|
6537 |
-
|
6538 |
-
|
6539 |
-
|
6540 |
-
|
6541 |
-
|
6542 |
-
|
6543 |
-
|
6544 |
-
|
6545 |
-
|
6546 |
-
|
6547 |
-
|
6548 |
-
*
|
6549 |
-
*
|
6550 |
-
* @
|
6551 |
-
|
6552 |
-
|
6553 |
-
|
6554 |
-
|
6555 |
-
|
6556 |
-
|
6557 |
-
|
6558 |
-
|
6559 |
-
|
6560 |
-
|
6561 |
-
|
6562 |
-
|
6563 |
-
|
6564 |
-
|
6565 |
-
|
6566 |
-
|
6567 |
-
|
6568 |
-
|
6569 |
-
|
6570 |
-
}
|
6571 |
-
|
6572 |
-
/**
|
6573 |
-
*
|
6574 |
-
*
|
6575 |
-
*
|
6576 |
-
* @
|
6577 |
-
|
6578 |
-
|
6579 |
-
|
6580 |
-
|
6581 |
-
|
6582 |
-
|
6583 |
-
|
6584 |
-
|
6585 |
-
|
6586 |
-
|
6587 |
-
|
6588 |
-
|
6589 |
-
|
6590 |
-
|
6591 |
-
|
6592 |
-
|
6593 |
-
|
6594 |
-
|
6595 |
-
|
6596 |
-
|
6597 |
-
*
|
6598 |
-
|
6599 |
-
|
6600 |
-
|
6601 |
-
|
6602 |
-
|
6603 |
-
|
6604 |
-
|
6605 |
-
|
6606 |
-
|
6607 |
-
|
6608 |
-
|
6609 |
-
*
|
6610 |
-
*
|
6611 |
-
*
|
6612 |
-
*
|
6613 |
-
*
|
6614 |
-
|
6615 |
-
|
6616 |
-
|
6617 |
-
|
6618 |
-
|
6619 |
-
|
6620 |
-
|
6621 |
-
|
6622 |
-
|
6623 |
-
|
6624 |
-
|
6625 |
-
|
6626 |
-
|
6627 |
-
|
6628 |
-
|
6629 |
-
|
6630 |
-
|
6631 |
-
|
6632 |
-
|
6633 |
-
|
6634 |
-
|
6635 |
-
|
6636 |
-
|
6637 |
-
|
6638 |
-
|
6639 |
-
|
6640 |
-
|
6641 |
-
|
6642 |
-
|
6643 |
-
|
6644 |
-
*
|
6645 |
-
|
6646 |
-
|
6647 |
-
|
6648 |
-
|
6649 |
-
|
6650 |
-
|
6651 |
-
|
6652 |
-
|
6653 |
-
|
6654 |
-
|
6655 |
-
|
6656 |
-
|
6657 |
-
|
6658 |
-
|
6659 |
-
|
6660 |
-
|
6661 |
-
|
6662 |
-
|
6663 |
-
|
6664 |
-
|
6665 |
-
* @author Vova Feldman (@svovaf)
|
6666 |
-
* @since 1.
|
6667 |
-
*
|
6668 |
-
* @param
|
6669 |
-
*
|
6670 |
-
* @return
|
6671 |
-
*/
|
6672 |
-
function
|
6673 |
-
|
6674 |
-
|
6675 |
-
|
6676 |
-
|
6677 |
-
|
6678 |
-
|
6679 |
-
|
6680 |
-
|
6681 |
-
|
6682 |
-
|
6683 |
-
|
6684 |
-
|
6685 |
-
|
6686 |
-
|
6687 |
-
|
6688 |
-
|
6689 |
-
|
6690 |
-
|
6691 |
-
|
6692 |
-
|
6693 |
-
|
6694 |
-
|
6695 |
-
|
6696 |
-
|
6697 |
-
|
6698 |
-
|
6699 |
-
|
6700 |
-
|
6701 |
-
|
6702 |
-
|
6703 |
-
|
6704 |
-
|
6705 |
-
|
6706 |
-
|
6707 |
-
|
6708 |
-
|
6709 |
-
|
6710 |
-
|
6711 |
-
|
6712 |
-
|
6713 |
-
|
6714 |
-
|
6715 |
-
|
6716 |
-
|
6717 |
-
|
6718 |
-
|
6719 |
-
|
6720 |
-
|
6721 |
-
|
6722 |
-
|
6723 |
-
|
6724 |
-
|
6725 |
-
|
6726 |
-
|
6727 |
-
$
|
6728 |
-
}
|
6729 |
-
|
6730 |
-
|
6731 |
-
|
6732 |
-
|
6733 |
-
|
6734 |
-
|
6735 |
-
|
6736 |
-
|
6737 |
-
|
6738 |
-
|
6739 |
-
|
6740 |
-
|
6741 |
-
|
6742 |
-
|
6743 |
-
|
6744 |
-
* @
|
6745 |
-
|
6746 |
-
|
6747 |
-
|
6748 |
-
|
6749 |
-
|
6750 |
-
|
6751 |
-
|
6752 |
-
|
6753 |
-
|
6754 |
-
|
6755 |
-
|
6756 |
-
|
6757 |
-
|
6758 |
-
|
6759 |
-
|
6760 |
-
|
6761 |
-
|
6762 |
-
|
6763 |
-
|
6764 |
-
|
6765 |
-
|
6766 |
-
|
6767 |
-
*
|
6768 |
-
*
|
6769 |
-
* @
|
6770 |
-
*
|
6771 |
-
*
|
6772 |
-
|
6773 |
-
|
6774 |
-
|
6775 |
-
|
6776 |
-
|
6777 |
-
|
6778 |
-
|
6779 |
-
|
6780 |
-
|
6781 |
-
|
6782 |
-
|
6783 |
-
|
6784 |
-
|
6785 |
-
|
6786 |
-
|
6787 |
-
|
6788 |
-
|
6789 |
-
|
6790 |
-
|
6791 |
-
|
6792 |
-
|
6793 |
-
|
6794 |
-
|
6795 |
-
|
6796 |
-
|
6797 |
-
|
6798 |
-
|
6799 |
-
|
6800 |
-
|
6801 |
-
|
6802 |
-
|
6803 |
-
|
6804 |
-
|
6805 |
-
|
6806 |
-
|
6807 |
-
|
6808 |
-
|
6809 |
-
|
6810 |
-
|
6811 |
-
|
6812 |
-
|
6813 |
-
|
6814 |
-
|
6815 |
-
|
6816 |
-
|
6817 |
-
|
6818 |
-
|
6819 |
-
|
6820 |
-
|
6821 |
-
|
6822 |
-
|
6823 |
-
|
6824 |
-
|
6825 |
-
|
6826 |
-
|
6827 |
-
|
6828 |
-
|
6829 |
-
|
6830 |
-
|
6831 |
-
|
6832 |
-
|
6833 |
-
|
6834 |
-
|
6835 |
-
|
6836 |
-
|
6837 |
-
|
6838 |
-
|
6839 |
-
|
6840 |
-
|
6841 |
-
|
6842 |
-
|
6843 |
-
|
6844 |
-
|
6845 |
-
|
6846 |
-
|
6847 |
-
|
6848 |
-
|
6849 |
-
|
6850 |
-
|
6851 |
-
|
6852 |
-
|
6853 |
-
|
6854 |
-
|
6855 |
-
|
6856 |
-
|
6857 |
-
|
6858 |
-
|
6859 |
-
|
6860 |
-
|
6861 |
-
* @author Vova Feldman (@svovaf)
|
6862 |
-
* @since 1.
|
6863 |
-
*
|
6864 |
-
* @param
|
6865 |
-
* @param bool
|
6866 |
-
*
|
6867 |
-
*
|
6868 |
-
|
6869 |
-
|
6870 |
-
|
6871 |
-
|
6872 |
-
|
6873 |
-
|
6874 |
-
|
6875 |
-
|
6876 |
-
|
6877 |
-
|
6878 |
-
|
6879 |
-
|
6880 |
-
|
6881 |
-
|
6882 |
-
|
6883 |
-
|
6884 |
-
|
6885 |
-
|
6886 |
-
|
6887 |
-
|
6888 |
-
|
6889 |
-
|
6890 |
-
|
6891 |
-
|
6892 |
-
|
6893 |
-
|
6894 |
-
|
6895 |
-
|
6896 |
-
|
6897 |
-
|
6898 |
-
|
6899 |
-
|
6900 |
-
|
6901 |
-
|
6902 |
-
|
6903 |
-
|
6904 |
-
|
6905 |
-
|
6906 |
-
|
6907 |
-
|
6908 |
-
|
6909 |
-
|
6910 |
-
|
6911 |
-
|
6912 |
-
|
6913 |
-
|
6914 |
-
|
6915 |
-
|
6916 |
-
|
6917 |
-
|
6918 |
-
|
6919 |
-
|
6920 |
-
|
6921 |
-
|
6922 |
-
|
6923 |
-
|
6924 |
-
|
6925 |
-
|
6926 |
-
|
6927 |
-
*
|
6928 |
-
*
|
6929 |
-
|
6930 |
-
|
6931 |
-
|
6932 |
-
|
6933 |
-
|
6934 |
-
|
6935 |
-
|
6936 |
-
|
6937 |
-
|
6938 |
-
|
6939 |
-
|
6940 |
-
|
6941 |
-
|
6942 |
-
|
6943 |
-
$
|
6944 |
-
}
|
6945 |
-
|
6946 |
-
if ( $this->
|
6947 |
-
|
6948 |
-
|
6949 |
-
|
6950 |
-
|
6951 |
-
return
|
6952 |
-
}
|
6953 |
-
|
6954 |
-
|
6955 |
-
|
6956 |
-
|
6957 |
-
|
6958 |
-
|
6959 |
-
|
6960 |
-
|
6961 |
-
|
6962 |
-
|
6963 |
-
|
6964 |
-
|
6965 |
-
|
6966 |
-
|
6967 |
-
|
6968 |
-
|
6969 |
-
|
6970 |
-
|
6971 |
-
|
6972 |
-
|
6973 |
-
|
6974 |
-
|
6975 |
-
|
6976 |
-
|
6977 |
-
|
6978 |
-
|
6979 |
-
|
6980 |
-
|
6981 |
-
|
6982 |
-
|
6983 |
-
|
6984 |
-
* @
|
6985 |
-
*
|
6986 |
-
* @
|
6987 |
-
|
6988 |
-
|
6989 |
-
|
6990 |
-
|
6991 |
-
|
6992 |
-
|
6993 |
-
|
6994 |
-
|
6995 |
-
|
6996 |
-
|
6997 |
-
|
6998 |
-
|
6999 |
-
|
7000 |
-
|
7001 |
-
|
7002 |
-
|
7003 |
-
|
7004 |
-
|
7005 |
-
|
7006 |
-
|
7007 |
-
|
7008 |
-
|
7009 |
-
|
7010 |
-
|
7011 |
-
|
7012 |
-
|
7013 |
-
|
7014 |
-
|
7015 |
-
|
7016 |
-
|
7017 |
-
|
7018 |
-
|
7019 |
-
|
7020 |
-
|
7021 |
-
|
7022 |
-
|
7023 |
-
|
7024 |
-
|
7025 |
-
|
7026 |
-
|
7027 |
-
|
7028 |
-
|
7029 |
-
|
7030 |
-
|
7031 |
-
|
7032 |
-
|
7033 |
-
|
7034 |
-
|
7035 |
-
|
7036 |
-
|
7037 |
-
|
7038 |
-
|
7039 |
-
|
7040 |
-
|
7041 |
-
|
7042 |
-
|
7043 |
-
|
7044 |
-
|
7045 |
-
|
7046 |
-
|
7047 |
-
|
7048 |
-
|
7049 |
-
|
7050 |
-
|
7051 |
-
|
7052 |
-
|
7053 |
-
|
7054 |
-
|
7055 |
-
|
7056 |
-
|
7057 |
-
|
7058 |
-
|
7059 |
-
|
7060 |
-
|
7061 |
-
|
7062 |
-
|
7063 |
-
|
7064 |
-
|
7065 |
-
|
7066 |
-
|
7067 |
-
|
7068 |
-
|
7069 |
-
|
7070 |
-
|
7071 |
-
|
7072 |
-
|
7073 |
-
|
7074 |
-
|
7075 |
-
|
7076 |
-
|
7077 |
-
|
7078 |
-
|
7079 |
-
|
7080 |
-
|
7081 |
-
|
7082 |
-
|
7083 |
-
|
7084 |
-
|
7085 |
-
|
7086 |
-
|
7087 |
-
|
7088 |
-
|
7089 |
-
|
7090 |
-
|
7091 |
-
|
7092 |
-
|
7093 |
-
|
7094 |
-
|
7095 |
-
|
7096 |
-
|
7097 |
-
|
7098 |
-
|
7099 |
-
|
7100 |
-
|
7101 |
-
|
7102 |
-
|
7103 |
-
|
7104 |
-
|
7105 |
-
|
7106 |
-
|
7107 |
-
|
7108 |
-
|
7109 |
-
$
|
7110 |
-
$
|
7111 |
-
|
7112 |
-
|
7113 |
-
|
7114 |
-
|
7115 |
-
|
7116 |
-
$
|
7117 |
-
$
|
7118 |
-
|
7119 |
-
|
7120 |
-
|
7121 |
-
$
|
7122 |
-
|
7123 |
-
|
7124 |
-
|
7125 |
-
|
7126 |
-
|
7127 |
-
|
7128 |
-
|
7129 |
-
|
7130 |
-
|
7131 |
-
|
7132 |
-
|
7133 |
-
|
7134 |
-
|
7135 |
-
|
7136 |
-
|
7137 |
-
|
7138 |
-
|
7139 |
-
|
7140 |
-
|
7141 |
-
|
7142 |
-
|
7143 |
-
|
7144 |
-
|
7145 |
-
|
7146 |
-
|
7147 |
-
|
7148 |
-
|
7149 |
-
|
7150 |
-
|
7151 |
-
|
7152 |
-
|
7153 |
-
|
7154 |
-
|
7155 |
-
|
7156 |
-
|
7157 |
-
|
7158 |
-
|
7159 |
-
|
7160 |
-
|
7161 |
-
|
7162 |
-
|
7163 |
-
|
7164 |
-
|
7165 |
-
|
7166 |
-
|
7167 |
-
|
7168 |
-
|
7169 |
-
|
7170 |
-
|
7171 |
-
$
|
7172 |
-
|
7173 |
-
$
|
7174 |
-
$
|
7175 |
-
|
7176 |
-
|
7177 |
-
|
7178 |
-
if ( $this->
|
7179 |
-
|
7180 |
-
|
7181 |
-
|
7182 |
-
|
7183 |
-
|
7184 |
-
|
7185 |
-
|
7186 |
-
|
7187 |
-
|
7188 |
-
|
7189 |
-
|
7190 |
-
|
7191 |
-
|
7192 |
-
|
7193 |
-
|
7194 |
-
|
7195 |
-
|
7196 |
-
|
7197 |
-
|
7198 |
-
|
7199 |
-
|
7200 |
-
|
7201 |
-
|
7202 |
-
|
7203 |
-
|
7204 |
-
|
7205 |
-
|
7206 |
-
|
7207 |
-
|
7208 |
-
|
7209 |
-
|
7210 |
-
|
7211 |
-
|
7212 |
-
|
7213 |
-
|
7214 |
-
|
7215 |
-
|
7216 |
-
|
7217 |
-
|
7218 |
-
|
7219 |
-
|
7220 |
-
|
7221 |
-
|
7222 |
-
|
7223 |
-
|
7224 |
-
|
7225 |
-
|
7226 |
-
|
7227 |
-
|
7228 |
-
|
7229 |
-
|
7230 |
-
|
7231 |
-
|
7232 |
-
|
7233 |
-
|
7234 |
-
|
7235 |
-
|
7236 |
-
|
7237 |
-
|
7238 |
-
|
7239 |
-
|
7240 |
-
|
7241 |
-
|
7242 |
-
|
7243 |
-
$
|
7244 |
-
|
7245 |
-
|
7246 |
-
$
|
7247 |
-
|
7248 |
-
|
7249 |
-
|
7250 |
-
|
7251 |
-
|
7252 |
-
|
7253 |
-
|
7254 |
-
|
7255 |
-
|
7256 |
-
|
7257 |
-
|
7258 |
-
|
7259 |
-
|
7260 |
-
|
7261 |
-
|
7262 |
-
|
7263 |
-
|
7264 |
-
|
7265 |
-
|
7266 |
-
|
7267 |
-
|
7268 |
-
|
7269 |
-
$
|
7270 |
-
|
7271 |
-
|
7272 |
-
|
7273 |
-
|
7274 |
-
|
7275 |
-
|
7276 |
-
|
7277 |
-
|
7278 |
-
|
7279 |
-
|
7280 |
-
|
7281 |
-
|
7282 |
-
|
7283 |
-
|
7284 |
-
|
7285 |
-
|
7286 |
-
|
7287 |
-
|
7288 |
-
|
7289 |
-
|
7290 |
-
|
7291 |
-
|
7292 |
-
|
7293 |
-
|
7294 |
-
|
7295 |
-
|
7296 |
-
|
7297 |
-
|
7298 |
-
|
7299 |
-
|
7300 |
-
|
7301 |
-
|
7302 |
-
|
7303 |
-
|
7304 |
-
|
7305 |
-
|
7306 |
-
|
7307 |
-
|
7308 |
-
|
7309 |
-
|
7310 |
-
|
7311 |
-
|
7312 |
-
|
7313 |
-
|
7314 |
-
|
7315 |
-
|
7316 |
-
|
7317 |
-
|
7318 |
-
|
7319 |
-
|
7320 |
-
|
7321 |
-
|
7322 |
-
|
7323 |
-
|
7324 |
-
|
7325 |
-
|
7326 |
-
|
7327 |
-
|
7328 |
-
|
7329 |
-
|
7330 |
-
|
7331 |
-
|
7332 |
-
|
7333 |
-
|
7334 |
-
*
|
7335 |
-
|
7336 |
-
|
7337 |
-
|
7338 |
-
|
7339 |
-
|
7340 |
-
|
7341 |
-
|
7342 |
-
|
7343 |
-
|
7344 |
-
|
7345 |
-
|
7346 |
-
|
7347 |
-
|
7348 |
-
|
7349 |
-
|
7350 |
-
|
7351 |
-
|
7352 |
-
|
7353 |
-
|
7354 |
-
|
7355 |
-
|
7356 |
-
|
7357 |
-
|
7358 |
-
|
7359 |
-
|
7360 |
-
|
7361 |
-
|
7362 |
-
|
7363 |
-
|
7364 |
-
|
7365 |
-
|
7366 |
-
|
7367 |
-
|
7368 |
-
|
7369 |
-
|
7370 |
-
|
7371 |
-
|
7372 |
-
|
7373 |
-
|
7374 |
-
|
7375 |
-
|
7376 |
-
|
7377 |
-
|
7378 |
-
|
7379 |
-
|
7380 |
-
|
7381 |
-
|
7382 |
-
|
7383 |
-
|
7384 |
-
|
7385 |
-
|
7386 |
-
|
7387 |
-
|
7388 |
-
|
7389 |
-
|
7390 |
-
|
7391 |
-
|
7392 |
-
|
7393 |
-
|
7394 |
-
|
7395 |
-
|
7396 |
-
|
7397 |
-
|
7398 |
-
|
7399 |
-
|
7400 |
-
|
7401 |
-
|
7402 |
-
|
7403 |
-
|
7404 |
-
|
7405 |
-
|
7406 |
-
|
7407 |
-
|
7408 |
-
|
7409 |
-
|
7410 |
-
|
7411 |
-
|
7412 |
-
|
7413 |
-
|
7414 |
-
|
7415 |
-
|
7416 |
-
|
7417 |
-
|
7418 |
-
|
7419 |
-
|
7420 |
-
|
7421 |
-
|
7422 |
-
|
7423 |
-
|
7424 |
-
|
7425 |
-
|
7426 |
-
|
7427 |
-
|
7428 |
-
|
7429 |
-
|
7430 |
-
|
7431 |
-
|
7432 |
-
|
7433 |
-
|
7434 |
-
|
7435 |
-
|
7436 |
-
|
7437 |
-
|
7438 |
-
|
7439 |
-
|
7440 |
-
|
7441 |
-
|
7442 |
-
|
7443 |
-
|
7444 |
-
|
7445 |
-
|
7446 |
-
|
7447 |
-
|
7448 |
-
|
7449 |
-
|
7450 |
-
|
7451 |
-
|
7452 |
-
|
7453 |
-
|
7454 |
-
|
7455 |
-
|
7456 |
-
|
7457 |
-
|
7458 |
-
|
7459 |
-
|
7460 |
-
|
7461 |
-
|
7462 |
-
|
7463 |
-
|
7464 |
-
|
7465 |
-
|
7466 |
-
|
7467 |
-
|
7468 |
-
|
7469 |
-
|
7470 |
-
|
7471 |
-
|
7472 |
-
|
7473 |
-
|
7474 |
-
|
7475 |
-
|
7476 |
-
|
7477 |
-
|
7478 |
-
|
7479 |
-
|
7480 |
-
|
7481 |
-
|
7482 |
-
|
7483 |
-
|
7484 |
-
|
7485 |
-
|
7486 |
-
|
7487 |
-
|
7488 |
-
|
7489 |
-
|
7490 |
-
|
7491 |
-
|
7492 |
-
|
7493 |
-
|
7494 |
-
|
7495 |
-
|
7496 |
-
|
7497 |
-
|
7498 |
-
|
7499 |
-
|
7500 |
-
|
7501 |
-
|
7502 |
-
|
7503 |
-
|
7504 |
-
|
7505 |
-
|
7506 |
-
|
7507 |
-
|
7508 |
-
|
7509 |
-
|
7510 |
-
|
7511 |
-
|
7512 |
-
|
7513 |
-
|
7514 |
-
|
7515 |
-
|
7516 |
-
|
7517 |
-
|
7518 |
-
|
7519 |
-
|
7520 |
-
|
7521 |
-
|
7522 |
-
|
7523 |
-
|
7524 |
-
|
7525 |
-
|
7526 |
-
|
7527 |
-
|
7528 |
-
|
7529 |
-
|
7530 |
-
|
7531 |
-
|
7532 |
-
|
7533 |
-
|
7534 |
-
|
7535 |
-
|
7536 |
-
|
7537 |
-
|
7538 |
-
|
7539 |
-
|
7540 |
-
|
7541 |
-
|
7542 |
-
|
7543 |
-
|
7544 |
-
|
7545 |
-
|
7546 |
-
|
7547 |
-
|
7548 |
-
|
7549 |
-
|
7550 |
-
|
7551 |
-
|
7552 |
-
|
7553 |
-
|
7554 |
-
|
7555 |
-
|
7556 |
-
|
7557 |
-
|
7558 |
-
|
7559 |
-
|
7560 |
-
|
7561 |
-
|
7562 |
-
|
7563 |
-
|
7564 |
-
|
7565 |
-
|
7566 |
-
|
7567 |
-
|
7568 |
-
|
7569 |
-
|
7570 |
-
|
7571 |
-
|
7572 |
-
|
7573 |
-
|
7574 |
-
|
7575 |
-
|
7576 |
-
|
7577 |
-
|
7578 |
-
|
7579 |
-
|
7580 |
-
|
7581 |
-
|
7582 |
-
|
7583 |
-
|
7584 |
-
|
7585 |
-
|
7586 |
-
|
7587 |
-
|
7588 |
-
|
7589 |
-
|
7590 |
-
|
7591 |
-
|
7592 |
-
|
7593 |
-
|
7594 |
-
|
7595 |
-
|
7596 |
-
|
7597 |
-
|
7598 |
-
|
7599 |
-
|
7600 |
-
|
7601 |
-
|
7602 |
-
|
7603 |
-
|
7604 |
-
|
7605 |
-
|
7606 |
-
|
7607 |
-
|
7608 |
-
|
7609 |
-
|
7610 |
-
|
7611 |
-
|
7612 |
-
|
7613 |
-
|
7614 |
-
|
7615 |
-
|
7616 |
-
|
7617 |
-
|
7618 |
-
|
7619 |
-
|
7620 |
-
|
7621 |
-
|
7622 |
-
|
7623 |
-
|
7624 |
-
|
7625 |
-
|
7626 |
-
|
7627 |
-
|
7628 |
-
|
7629 |
-
|
7630 |
-
|
7631 |
-
|
7632 |
-
|
7633 |
-
|
7634 |
-
|
7635 |
-
|
7636 |
-
|
7637 |
-
|
7638 |
-
|
7639 |
-
|
7640 |
-
|
7641 |
-
|
7642 |
-
|
7643 |
-
|
7644 |
-
|
7645 |
-
|
7646 |
-
|
7647 |
-
|
7648 |
-
|
7649 |
-
|
7650 |
-
|
7651 |
-
|
7652 |
-
|
7653 |
-
|
7654 |
-
|
7655 |
-
|
7656 |
-
|
7657 |
-
|
7658 |
-
|
7659 |
-
|
7660 |
-
|
7661 |
-
|
7662 |
-
|
7663 |
-
|
7664 |
-
|
7665 |
-
|
7666 |
-
|
7667 |
-
|
7668 |
-
|
7669 |
-
|
7670 |
-
|
7671 |
-
|
7672 |
-
|
7673 |
-
|
7674 |
-
|
7675 |
-
|
7676 |
-
|
7677 |
-
*
|
7678 |
-
*
|
7679 |
-
*
|
7680 |
-
* @
|
7681 |
-
*
|
7682 |
-
* @
|
7683 |
-
|
7684 |
-
|
7685 |
-
|
7686 |
-
|
7687 |
-
|
7688 |
-
|
7689 |
-
*
|
7690 |
-
*
|
7691 |
-
*
|
7692 |
-
*
|
7693 |
-
*
|
7694 |
-
|
7695 |
-
|
7696 |
-
|
7697 |
-
$
|
7698 |
-
|
7699 |
-
|
7700 |
-
|
7701 |
-
|
7702 |
-
|
7703 |
-
|
7704 |
-
|
7705 |
-
|
7706 |
-
|
7707 |
-
|
7708 |
-
|
7709 |
-
|
7710 |
-
|
7711 |
-
|
7712 |
-
|
7713 |
-
|
7714 |
-
|
7715 |
-
|
7716 |
-
|
7717 |
-
|
7718 |
-
|
7719 |
-
|
7720 |
-
|
7721 |
-
|
7722 |
-
|
7723 |
-
|
7724 |
-
|
7725 |
-
|
7726 |
-
|
7727 |
-
|
7728 |
-
|
7729 |
-
|
7730 |
-
|
7731 |
-
|
7732 |
-
|
7733 |
-
|
7734 |
-
|
7735 |
-
|
7736 |
-
|
7737 |
-
|
7738 |
-
|
7739 |
-
|
7740 |
-
* @
|
7741 |
-
*
|
7742 |
-
*
|
7743 |
-
|
7744 |
-
|
7745 |
-
|
7746 |
-
$
|
7747 |
-
|
7748 |
-
|
7749 |
-
|
7750 |
-
|
7751 |
-
|
7752 |
-
|
7753 |
-
|
7754 |
-
|
7755 |
-
|
7756 |
-
|
7757 |
-
|
7758 |
-
|
7759 |
-
|
7760 |
-
|
7761 |
-
|
7762 |
-
|
7763 |
-
|
7764 |
-
|
7765 |
-
|
7766 |
-
|
7767 |
-
|
7768 |
-
|
7769 |
-
|
7770 |
-
|
7771 |
-
|
7772 |
-
|
7773 |
-
|
7774 |
-
|
7775 |
-
|
7776 |
-
|
7777 |
-
|
7778 |
-
|
7779 |
-
|
7780 |
-
|
7781 |
-
|
7782 |
-
|
7783 |
-
|
7784 |
-
|
7785 |
-
|
7786 |
-
|
7787 |
-
|
7788 |
-
|
7789 |
-
|
7790 |
-
|
7791 |
-
|
7792 |
-
|
7793 |
-
|
7794 |
-
|
7795 |
-
|
7796 |
-
|
7797 |
-
|
7798 |
-
|
7799 |
-
|
7800 |
-
|
7801 |
-
|
7802 |
-
|
7803 |
-
|
7804 |
-
|
7805 |
-
|
7806 |
-
|
7807 |
-
|
7808 |
-
|
7809 |
-
|
7810 |
-
|
7811 |
-
|
7812 |
-
|
7813 |
-
|
7814 |
-
|
7815 |
-
|
7816 |
-
|
7817 |
-
|
7818 |
-
|
7819 |
-
|
7820 |
-
|
7821 |
-
|
7822 |
-
|
7823 |
-
|
7824 |
-
|
7825 |
-
$
|
7826 |
-
|
7827 |
-
|
7828 |
-
|
7829 |
-
|
7830 |
-
|
7831 |
-
|
7832 |
-
|
7833 |
-
|
7834 |
-
|
7835 |
-
|
7836 |
-
|
7837 |
-
|
7838 |
-
|
7839 |
-
|
7840 |
-
|
7841 |
-
|
7842 |
-
|
7843 |
-
|
7844 |
-
|
7845 |
-
|
7846 |
-
|
7847 |
-
|
7848 |
-
|
7849 |
-
|
7850 |
-
|
7851 |
-
|
7852 |
-
|
7853 |
-
|
7854 |
-
|
7855 |
-
|
7856 |
-
|
7857 |
-
|
7858 |
-
|
7859 |
-
|
7860 |
-
|
7861 |
-
|
7862 |
-
|
7863 |
-
|
7864 |
-
|
7865 |
-
|
7866 |
-
|
7867 |
-
|
7868 |
-
|
7869 |
-
|
7870 |
-
|
7871 |
-
|
7872 |
-
|
7873 |
-
|
7874 |
-
|
7875 |
-
|
7876 |
-
|
7877 |
-
|
7878 |
-
|
7879 |
-
|
7880 |
-
|
7881 |
-
|
7882 |
-
|
7883 |
-
|
7884 |
-
|
7885 |
-
|
7886 |
-
|
7887 |
-
*
|
7888 |
-
*
|
7889 |
-
* @
|
7890 |
-
|
7891 |
-
|
7892 |
-
|
7893 |
-
|
7894 |
-
|
7895 |
-
|
7896 |
-
|
7897 |
-
|
7898 |
-
|
7899 |
-
|
7900 |
-
|
7901 |
-
|
7902 |
-
|
7903 |
-
|
7904 |
-
|
7905 |
-
|
7906 |
-
|
7907 |
-
|
7908 |
-
|
7909 |
-
|
7910 |
-
|
7911 |
-
|
7912 |
-
|
7913 |
-
|
7914 |
-
|
7915 |
-
|
7916 |
-
|
7917 |
-
|
7918 |
-
|
7919 |
-
|
7920 |
-
|
7921 |
-
|
7922 |
-
|
7923 |
-
|
7924 |
-
|
7925 |
-
|
7926 |
-
|
7927 |
-
|
7928 |
-
$this->
|
7929 |
-
|
7930 |
-
|
7931 |
-
|
7932 |
-
|
7933 |
-
|
7934 |
-
|
7935 |
-
|
7936 |
-
|
7937 |
-
|
7938 |
-
|
7939 |
-
|
7940 |
-
|
7941 |
-
|
7942 |
-
|
7943 |
-
|
7944 |
-
|
7945 |
-
|
7946 |
-
|
7947 |
-
|
7948 |
-
|
7949 |
-
|
7950 |
-
|
7951 |
-
|
7952 |
-
|
7953 |
-
|
7954 |
-
|
7955 |
-
|
7956 |
-
|
7957 |
-
|
7958 |
-
|
7959 |
-
|
7960 |
-
|
7961 |
-
|
7962 |
-
|
7963 |
-
|
7964 |
-
|
7965 |
-
//
|
7966 |
-
//
|
7967 |
-
|
7968 |
-
|
7969 |
-
|
7970 |
-
|
7971 |
-
|
7972 |
-
|
7973 |
-
|
7974 |
-
|
7975 |
-
|
7976 |
-
|
7977 |
-
|
7978 |
-
|
7979 |
-
|
7980 |
-
|
7981 |
-
|
7982 |
-
|
7983 |
-
|
7984 |
-
|
7985 |
-
|
7986 |
-
|
7987 |
-
|
7988 |
-
|
7989 |
-
|
7990 |
-
|
7991 |
-
|
7992 |
-
|
7993 |
-
|
7994 |
-
|
7995 |
-
|
7996 |
-
|
7997 |
-
|
7998 |
-
|
7999 |
-
|
8000 |
-
|
8001 |
-
|
8002 |
-
|
8003 |
-
|
8004 |
-
|
8005 |
-
|
8006 |
-
|
8007 |
-
|
8008 |
-
|
8009 |
-
|
8010 |
-
|
8011 |
-
|
8012 |
-
|
8013 |
-
|
8014 |
-
|
8015 |
-
|
8016 |
-
|
8017 |
-
|
8018 |
-
|
8019 |
-
|
8020 |
-
|
8021 |
-
|
8022 |
-
|
8023 |
-
|
8024 |
-
|
8025 |
-
}
|
8026 |
-
|
8027 |
-
/**
|
8028 |
-
*
|
8029 |
-
*
|
8030 |
-
* @author Vova Feldman (@svovaf)
|
8031 |
-
* @since 1.
|
8032 |
-
|
8033 |
-
|
8034 |
-
|
8035 |
-
|
8036 |
-
|
8037 |
-
|
8038 |
-
|
8039 |
-
|
8040 |
-
|
8041 |
-
|
8042 |
-
|
8043 |
-
|
8044 |
-
|
8045 |
-
|
8046 |
-
|
8047 |
-
|
8048 |
-
|
8049 |
-
|
8050 |
-
|
8051 |
-
|
8052 |
-
|
8053 |
-
|
8054 |
-
|
8055 |
-
|
8056 |
-
|
8057 |
-
|
8058 |
-
|
8059 |
-
|
8060 |
-
|
8061 |
-
|
8062 |
-
|
8063 |
-
|
8064 |
-
|
8065 |
-
|
8066 |
-
|
8067 |
-
|
8068 |
-
|
8069 |
-
|
8070 |
-
|
8071 |
-
|
8072 |
-
|
8073 |
-
|
8074 |
-
|
8075 |
-
|
8076 |
-
|
8077 |
-
|
8078 |
-
|
8079 |
-
|
8080 |
-
|
8081 |
-
|
8082 |
-
|
8083 |
-
|
8084 |
-
|
8085 |
-
|
8086 |
-
|
8087 |
-
|
8088 |
-
|
8089 |
-
|
8090 |
-
|
8091 |
-
|
8092 |
-
|
8093 |
-
|
8094 |
-
|
8095 |
-
|
8096 |
-
|
8097 |
-
|
8098 |
-
|
8099 |
-
* @
|
8100 |
-
* @
|
8101 |
-
*
|
8102 |
-
*
|
8103 |
-
|
8104 |
-
|
8105 |
-
|
8106 |
-
|
8107 |
-
|
8108 |
-
|
8109 |
-
|
8110 |
-
|
8111 |
-
|
8112 |
-
|
8113 |
-
|
8114 |
-
|
8115 |
-
|
8116 |
-
|
8117 |
-
|
8118 |
-
|
8119 |
-
|
8120 |
-
|
8121 |
-
|
8122 |
-
|
8123 |
-
* @
|
8124 |
-
* @
|
8125 |
-
*
|
8126 |
-
*
|
8127 |
-
|
8128 |
-
|
8129 |
-
|
8130 |
-
|
8131 |
-
|
8132 |
-
|
8133 |
-
|
8134 |
-
|
8135 |
-
|
8136 |
-
|
8137 |
-
|
8138 |
-
*
|
8139 |
-
|
8140 |
-
|
8141 |
-
|
8142 |
-
|
8143 |
-
|
8144 |
-
|
8145 |
-
|
8146 |
-
|
8147 |
-
|
8148 |
-
|
8149 |
-
|
8150 |
-
|
8151 |
-
|
8152 |
-
|
8153 |
-
|
8154 |
-
|
8155 |
-
|
8156 |
-
|
8157 |
-
|
8158 |
-
|
8159 |
-
|
8160 |
-
|
8161 |
-
|
8162 |
-
|
8163 |
-
|
8164 |
-
|
8165 |
-
|
8166 |
-
|
8167 |
-
|
8168 |
-
|
8169 |
-
|
8170 |
-
|
8171 |
-
|
8172 |
-
|
8173 |
-
|
8174 |
-
|
8175 |
-
|
8176 |
-
|
8177 |
-
|
8178 |
-
|
8179 |
-
|
8180 |
-
|
8181 |
-
|
8182 |
-
|
8183 |
-
|
8184 |
-
|
8185 |
-
|
8186 |
-
|
8187 |
-
|
8188 |
-
|
8189 |
-
|
8190 |
-
|
8191 |
-
|
8192 |
-
|
8193 |
-
|
8194 |
-
|
8195 |
-
|
8196 |
-
|
8197 |
-
|
8198 |
-
|
8199 |
-
|
8200 |
-
|
8201 |
-
|
8202 |
-
|
8203 |
-
|
8204 |
-
|
8205 |
-
|
8206 |
-
|
8207 |
-
|
8208 |
-
|
8209 |
-
|
8210 |
-
|
8211 |
-
|
8212 |
-
|
8213 |
-
|
8214 |
-
|
8215 |
-
|
8216 |
-
|
8217 |
-
|
8218 |
-
|
8219 |
-
|
8220 |
-
|
8221 |
-
|
8222 |
-
|
8223 |
-
|
8224 |
-
|
8225 |
-
|
8226 |
-
|
8227 |
-
|
8228 |
-
|
8229 |
-
|
8230 |
-
|
8231 |
-
|
8232 |
-
|
8233 |
-
|
8234 |
-
|
8235 |
-
|
8236 |
-
|
8237 |
-
|
8238 |
-
|
8239 |
-
|
8240 |
-
|
8241 |
-
|
8242 |
-
|
8243 |
-
|
8244 |
-
|
8245 |
-
|
8246 |
-
|
8247 |
-
|
8248 |
-
|
8249 |
-
|
8250 |
-
|
8251 |
-
|
8252 |
-
|
8253 |
-
|
8254 |
-
|
8255 |
-
|
8256 |
-
|
8257 |
-
|
8258 |
-
|
8259 |
-
|
8260 |
-
|
8261 |
-
|
8262 |
-
|
8263 |
-
|
8264 |
-
|
8265 |
-
|
8266 |
-
|
8267 |
-
|
8268 |
-
|
8269 |
-
|
8270 |
-
|
8271 |
-
|
8272 |
-
|
8273 |
-
|
8274 |
-
|
8275 |
-
|
8276 |
-
|
8277 |
-
|
8278 |
-
|
8279 |
-
|
8280 |
-
|
8281 |
-
|
8282 |
-
|
8283 |
-
|
8284 |
-
|
8285 |
-
|
8286 |
-
|
8287 |
-
|
8288 |
-
|
8289 |
-
|
8290 |
-
|
8291 |
-
|
8292 |
-
|
8293 |
-
|
8294 |
-
|
8295 |
-
|
8296 |
-
|
8297 |
-
|
8298 |
-
|
8299 |
-
|
8300 |
-
|
8301 |
-
|
8302 |
-
|
8303 |
-
|
8304 |
-
|
8305 |
-
|
8306 |
-
|
8307 |
-
|
8308 |
-
|
8309 |
-
|
8310 |
-
|
8311 |
-
|
8312 |
-
|
8313 |
-
|
8314 |
-
|
8315 |
-
|
8316 |
-
|
8317 |
-
|
8318 |
-
|
8319 |
-
|
8320 |
-
|
8321 |
-
|
8322 |
-
|
8323 |
-
|
8324 |
-
|
8325 |
-
|
8326 |
-
|
8327 |
-
|
8328 |
-
|
8329 |
-
|
8330 |
-
|
8331 |
-
|
8332 |
-
|
8333 |
-
|
8334 |
-
|
8335 |
-
$
|
8336 |
-
|
8337 |
-
|
8338 |
-
|
8339 |
-
|
8340 |
-
|
8341 |
-
|
8342 |
-
|
8343 |
-
|
8344 |
-
|
8345 |
-
|
8346 |
-
|
8347 |
-
|
8348 |
-
|
8349 |
-
|
8350 |
-
|
8351 |
-
|
8352 |
-
|
8353 |
-
|
8354 |
-
|
8355 |
-
|
8356 |
-
|
8357 |
-
|
8358 |
-
|
8359 |
-
|
8360 |
-
|
8361 |
-
|
8362 |
-
|
8363 |
-
|
8364 |
-
|
8365 |
-
|
8366 |
-
|
8367 |
-
|
8368 |
-
|
8369 |
-
|
8370 |
-
|
8371 |
-
|
8372 |
-
|
8373 |
-
|
8374 |
-
|
8375 |
-
|
8376 |
-
|
8377 |
-
|
8378 |
-
|
8379 |
-
|
8380 |
-
|
8381 |
-
|
8382 |
-
|
8383 |
-
|
8384 |
-
|
8385 |
-
|
8386 |
-
|
8387 |
-
|
8388 |
-
|
8389 |
-
|
8390 |
-
|
8391 |
-
|
8392 |
-
|
8393 |
-
|
8394 |
-
|
8395 |
-
|
8396 |
-
|
8397 |
-
|
8398 |
-
|
8399 |
-
|
8400 |
-
|
8401 |
-
|
8402 |
-
|
8403 |
-
|
8404 |
-
|
8405 |
-
|
8406 |
-
|
8407 |
-
|
8408 |
-
|
8409 |
-
|
8410 |
-
|
8411 |
-
|
8412 |
-
|
8413 |
-
|
8414 |
-
|
8415 |
-
|
8416 |
-
|
8417 |
-
|
8418 |
-
|
8419 |
-
|
8420 |
-
|
8421 |
-
|
8422 |
-
|
8423 |
-
|
8424 |
-
|
8425 |
-
|
8426 |
-
|
8427 |
-
$
|
8428 |
-
|
8429 |
-
|
8430 |
-
|
8431 |
-
|
8432 |
-
|
8433 |
-
|
8434 |
-
|
8435 |
-
|
8436 |
-
|
8437 |
-
|
8438 |
-
|
8439 |
-
|
8440 |
-
|
8441 |
-
|
8442 |
-
|
8443 |
-
|
8444 |
-
|
8445 |
-
|
8446 |
-
|
8447 |
-
|
8448 |
-
|
8449 |
-
|
8450 |
-
|
8451 |
-
|
8452 |
-
|
8453 |
-
|
8454 |
-
|
8455 |
-
|
8456 |
-
|
8457 |
-
* @
|
8458 |
-
*
|
8459 |
-
*
|
8460 |
-
* @param
|
8461 |
-
* @param
|
8462 |
-
* @param
|
8463 |
-
|
8464 |
-
|
8465 |
-
|
8466 |
-
|
8467 |
-
|
8468 |
-
$
|
8469 |
-
$
|
8470 |
-
$
|
8471 |
-
|
8472 |
-
|
8473 |
-
|
8474 |
-
|
8475 |
-
|
8476 |
-
|
8477 |
-
|
8478 |
-
|
8479 |
-
|
8480 |
-
|
8481 |
-
|
8482 |
-
|
8483 |
-
|
8484 |
-
|
8485 |
-
|
8486 |
-
|
8487 |
-
|
8488 |
-
|
8489 |
-
|
8490 |
-
|
8491 |
-
|
8492 |
-
|
8493 |
-
|
8494 |
-
|
8495 |
-
|
8496 |
-
|
8497 |
-
'
|
8498 |
-
'
|
8499 |
-
|
8500 |
-
|
8501 |
-
'
|
8502 |
-
'
|
8503 |
-
|
8504 |
-
|
8505 |
-
|
8506 |
-
|
8507 |
-
|
8508 |
-
|
8509 |
-
|
8510 |
-
|
8511 |
-
|
8512 |
-
|
8513 |
-
|
8514 |
-
|
8515 |
-
|
8516 |
-
|
8517 |
-
|
8518 |
-
|
8519 |
-
|
8520 |
-
|
8521 |
-
|
8522 |
-
|
8523 |
-
|
8524 |
-
|
8525 |
-
|
8526 |
-
|
8527 |
-
|
8528 |
-
|
8529 |
-
|
8530 |
-
|
8531 |
-
|
8532 |
-
|
8533 |
-
|
8534 |
-
|
8535 |
-
|
8536 |
-
|
8537 |
-
|
8538 |
-
|
8539 |
-
|
8540 |
-
|
8541 |
-
|
8542 |
-
|
8543 |
-
|
8544 |
-
|
8545 |
-
|
8546 |
-
|
8547 |
-
|
8548 |
-
|
8549 |
-
|
8550 |
-
|
8551 |
-
|
8552 |
-
|
8553 |
-
*
|
8554 |
-
*
|
8555 |
-
*
|
8556 |
-
|
8557 |
-
|
8558 |
-
|
8559 |
-
|
8560 |
-
|
8561 |
-
|
8562 |
-
* @
|
8563 |
-
* @
|
8564 |
-
*
|
8565 |
-
*
|
8566 |
-
|
8567 |
-
|
8568 |
-
|
8569 |
-
|
8570 |
-
|
8571 |
-
|
8572 |
-
|
8573 |
-
|
8574 |
-
|
8575 |
-
|
8576 |
-
|
8577 |
-
|
8578 |
-
|
8579 |
-
|
8580 |
-
|
8581 |
-
$
|
8582 |
-
|
8583 |
-
if (
|
8584 |
-
$
|
8585 |
-
|
8586 |
-
|
8587 |
-
|
8588 |
-
|
8589 |
-
|
8590 |
-
|
8591 |
-
|
8592 |
-
|
8593 |
-
|
8594 |
-
|
8595 |
-
|
8596 |
-
|
8597 |
-
|
8598 |
-
|
8599 |
-
|
8600 |
-
|
8601 |
-
|
8602 |
-
|
8603 |
-
|
8604 |
-
|
8605 |
-
|
8606 |
-
|
8607 |
-
|
8608 |
-
|
8609 |
-
|
8610 |
-
|
8611 |
-
|
8612 |
-
|
8613 |
-
|
8614 |
-
|
8615 |
-
|
8616 |
-
|
8617 |
-
|
8618 |
-
|
8619 |
-
|
8620 |
-
|
8621 |
-
|
8622 |
-
|
8623 |
-
|
8624 |
-
|
8625 |
-
|
8626 |
-
|
8627 |
-
|
8628 |
-
|
8629 |
-
|
8630 |
-
|
8631 |
-
|
8632 |
-
|
8633 |
-
|
8634 |
-
|
8635 |
-
|
8636 |
-
|
8637 |
-
|
8638 |
-
|
8639 |
-
|
8640 |
-
|
8641 |
-
|
8642 |
-
|
8643 |
-
|
8644 |
-
|
8645 |
-
|
8646 |
-
|
8647 |
-
|
8648 |
-
|
8649 |
-
|
8650 |
-
|
8651 |
-
|
8652 |
-
|
8653 |
-
$
|
8654 |
-
|
8655 |
-
|
8656 |
-
|
8657 |
-
|
8658 |
-
|
8659 |
-
|
8660 |
-
|
8661 |
-
|
8662 |
-
$
|
8663 |
-
|
8664 |
-
|
8665 |
-
|
8666 |
-
|
8667 |
-
|
8668 |
-
|
8669 |
-
|
8670 |
-
|
8671 |
-
|
8672 |
-
|
8673 |
-
|
8674 |
-
|
8675 |
-
|
8676 |
-
|
8677 |
-
|
8678 |
-
|
8679 |
-
|
8680 |
-
|
8681 |
-
|
8682 |
-
|
8683 |
-
|
8684 |
-
|
8685 |
-
|
8686 |
-
|
8687 |
-
|
8688 |
-
|
8689 |
-
|
8690 |
-
|
8691 |
-
|
8692 |
-
|
8693 |
-
|
8694 |
-
|
8695 |
-
$
|
8696 |
-
|
8697 |
-
|
8698 |
-
|
8699 |
-
|
8700 |
-
|
8701 |
-
|
8702 |
-
|
8703 |
-
|
8704 |
-
|
8705 |
-
|
8706 |
-
|
8707 |
-
|
8708 |
-
|
8709 |
-
|
8710 |
-
|
8711 |
-
|
8712 |
-
|
8713 |
-
|
8714 |
-
|
8715 |
-
|
8716 |
-
|
8717 |
-
|
8718 |
-
|
8719 |
-
|
8720 |
-
|
8721 |
-
|
8722 |
-
|
8723 |
-
|
8724 |
-
|
8725 |
-
|
8726 |
-
|
8727 |
-
|
8728 |
-
|
8729 |
-
|
8730 |
-
|
8731 |
-
|
8732 |
-
|
8733 |
-
|
8734 |
-
|
8735 |
-
|
8736 |
-
|
8737 |
-
|
8738 |
-
|
8739 |
-
|
8740 |
-
|
8741 |
-
|
8742 |
-
|
8743 |
-
|
8744 |
-
|
8745 |
-
|
8746 |
-
|
8747 |
-
|
8748 |
-
|
8749 |
-
|
8750 |
-
|
8751 |
-
|
8752 |
-
|
8753 |
-
|
8754 |
-
|
8755 |
-
|
8756 |
-
|
8757 |
-
|
8758 |
-
|
8759 |
-
|
8760 |
-
|
8761 |
-
|
8762 |
-
|
8763 |
-
|
8764 |
-
|
8765 |
-
|
8766 |
-
|
8767 |
-
|
8768 |
-
|
8769 |
-
*
|
8770 |
-
*
|
8771 |
-
* @
|
8772 |
-
*
|
8773 |
-
*
|
8774 |
-
*
|
8775 |
-
* @
|
8776 |
-
|
8777 |
-
|
8778 |
-
|
8779 |
-
|
8780 |
-
|
8781 |
-
|
8782 |
-
|
8783 |
-
|
8784 |
-
|
8785 |
-
|
8786 |
-
|
8787 |
-
|
8788 |
-
|
8789 |
-
|
8790 |
-
|
8791 |
-
|
8792 |
-
|
8793 |
-
|
8794 |
-
|
8795 |
-
|
8796 |
-
|
8797 |
-
|
8798 |
-
|
8799 |
-
|
8800 |
-
|
8801 |
-
|
8802 |
-
|
8803 |
-
|
8804 |
-
|
8805 |
-
|
8806 |
-
|
8807 |
-
|
8808 |
-
|
8809 |
-
|
8810 |
-
|
8811 |
-
|
8812 |
-
|
8813 |
-
|
8814 |
-
|
8815 |
-
|
8816 |
-
|
8817 |
-
|
8818 |
-
|
8819 |
-
|
8820 |
-
|
8821 |
-
|
8822 |
-
|
8823 |
-
|
8824 |
-
|
8825 |
-
|
8826 |
-
|
8827 |
-
|
8828 |
-
|
8829 |
-
|
8830 |
-
|
8831 |
-
|
8832 |
-
|
8833 |
-
|
8834 |
-
|
8835 |
-
|
8836 |
-
|
8837 |
-
|
8838 |
-
|
8839 |
-
|
8840 |
-
|
8841 |
-
|
8842 |
-
|
8843 |
-
|
8844 |
-
|
8845 |
-
|
8846 |
-
|
8847 |
-
|
8848 |
-
|
8849 |
-
|
8850 |
-
|
8851 |
-
|
8852 |
-
|
8853 |
-
|
8854 |
-
|
8855 |
-
|
8856 |
-
|
8857 |
-
|
8858 |
-
|
8859 |
-
|
8860 |
-
|
8861 |
-
|
8862 |
-
|
8863 |
-
|
8864 |
-
|
8865 |
-
|
8866 |
-
|
8867 |
-
|
8868 |
-
|
8869 |
-
|
8870 |
-
|
8871 |
-
|
8872 |
-
|
8873 |
-
|
8874 |
-
|
8875 |
-
|
8876 |
-
|
8877 |
-
|
8878 |
-
|
8879 |
-
|
8880 |
-
|
8881 |
-
|
8882 |
-
|
8883 |
-
|
8884 |
-
|
8885 |
-
|
8886 |
-
|
8887 |
-
|
8888 |
-
|
8889 |
-
|
8890 |
-
|
8891 |
-
|
8892 |
-
|
8893 |
-
|
8894 |
-
|
8895 |
-
|
8896 |
-
|
8897 |
-
|
8898 |
-
|
8899 |
-
|
8900 |
-
|
8901 |
-
|
8902 |
-
*
|
8903 |
-
*
|
8904 |
-
* @
|
8905 |
-
|
8906 |
-
|
8907 |
-
|
8908 |
-
|
8909 |
-
|
8910 |
-
|
8911 |
-
|
8912 |
-
|
8913 |
-
|
8914 |
-
|
8915 |
-
|
8916 |
-
|
8917 |
-
|
8918 |
-
|
8919 |
-
|
8920 |
-
|
8921 |
-
|
8922 |
-
|
8923 |
-
|
8924 |
-
|
8925 |
-
|
8926 |
-
|
8927 |
-
|
8928 |
-
|
8929 |
-
|
8930 |
-
|
8931 |
-
|
8932 |
-
|
8933 |
-
|
8934 |
-
|
8935 |
-
|
8936 |
-
|
8937 |
-
|
8938 |
-
|
8939 |
-
|
8940 |
-
|
8941 |
-
|
8942 |
-
|
8943 |
-
|
8944 |
-
|
8945 |
-
|
8946 |
-
|
8947 |
-
|
8948 |
-
|
8949 |
-
|
8950 |
-
*
|
8951 |
-
*
|
8952 |
-
*
|
8953 |
-
* @
|
8954 |
-
|
8955 |
-
|
8956 |
-
|
8957 |
-
|
8958 |
-
|
8959 |
-
$
|
8960 |
-
|
8961 |
-
$
|
8962 |
-
$
|
8963 |
-
|
8964 |
-
|
8965 |
-
|
8966 |
-
|
8967 |
-
|
8968 |
-
|
8969 |
-
|
8970 |
-
|
8971 |
-
|
8972 |
-
|
8973 |
-
|
8974 |
-
|
8975 |
-
|
8976 |
-
|
8977 |
-
$
|
8978 |
-
|
8979 |
-
|
8980 |
-
|
8981 |
-
|
8982 |
-
|
8983 |
-
|
8984 |
-
|
8985 |
-
|
8986 |
-
|
8987 |
-
|
8988 |
-
|
8989 |
-
|
8990 |
-
|
8991 |
-
|
8992 |
-
|
8993 |
-
|
8994 |
-
* @
|
8995 |
-
*
|
8996 |
-
*
|
8997 |
-
* @param bool
|
8998 |
-
|
8999 |
-
|
9000 |
-
|
9001 |
-
|
9002 |
-
|
9003 |
-
|
9004 |
-
|
9005 |
-
|
9006 |
-
|
9007 |
-
|
9008 |
-
|
9009 |
-
|
9010 |
-
|
9011 |
-
|
9012 |
-
|
9013 |
-
|
9014 |
-
|
9015 |
-
|
9016 |
-
|
9017 |
-
|
9018 |
-
|
9019 |
-
|
9020 |
-
|
9021 |
-
|
9022 |
-
|
9023 |
-
|
9024 |
-
|
9025 |
-
|
9026 |
-
|
9027 |
-
|
9028 |
-
|
9029 |
-
|
9030 |
-
|
9031 |
-
|
9032 |
-
|
9033 |
-
|
9034 |
-
|
9035 |
-
|
9036 |
-
|
9037 |
-
|
9038 |
-
|
9039 |
-
if (
|
9040 |
-
$
|
9041 |
-
|
9042 |
-
|
9043 |
-
|
9044 |
-
|
9045 |
-
|
9046 |
-
|
9047 |
-
|
9048 |
-
|
9049 |
-
|
9050 |
-
|
9051 |
-
|
9052 |
-
|
9053 |
-
|
9054 |
-
|
9055 |
-
|
9056 |
-
|
9057 |
-
|
9058 |
-
|
9059 |
-
|
9060 |
-
|
9061 |
-
|
9062 |
-
|
9063 |
-
|
9064 |
-
|
9065 |
-
|
9066 |
-
|
9067 |
-
|
9068 |
-
$this->
|
9069 |
-
|
9070 |
-
|
9071 |
-
|
9072 |
-
|
9073 |
-
|
9074 |
-
|
9075 |
-
|
9076 |
-
|
9077 |
-
|
9078 |
-
|
9079 |
-
|
9080 |
-
|
9081 |
-
|
9082 |
-
|
9083 |
-
|
9084 |
-
|
9085 |
-
|
9086 |
-
|
9087 |
-
|
9088 |
-
|
9089 |
-
|
9090 |
-
|
9091 |
-
|
9092 |
-
//
|
9093 |
-
$
|
9094 |
-
|
9095 |
-
|
9096 |
-
|
9097 |
-
|
9098 |
-
|
9099 |
-
|
9100 |
-
|
9101 |
-
|
9102 |
-
|
9103 |
-
|
9104 |
-
|
9105 |
-
|
9106 |
-
|
9107 |
-
|
9108 |
-
|
9109 |
-
|
9110 |
-
|
9111 |
-
|
9112 |
-
|
9113 |
-
|
9114 |
-
|
9115 |
-
|
9116 |
-
|
9117 |
-
|
9118 |
-
|
9119 |
-
|
9120 |
-
|
9121 |
-
|
9122 |
-
|
9123 |
-
|
9124 |
-
$this->
|
9125 |
-
|
9126 |
-
|
9127 |
-
|
9128 |
-
|
9129 |
-
|
9130 |
-
|
9131 |
-
|
9132 |
-
|
9133 |
-
|
9134 |
-
|
9135 |
-
|
9136 |
-
|
9137 |
-
|
9138 |
-
|
9139 |
-
|
9140 |
-
|
9141 |
-
|
9142 |
-
|
9143 |
-
|
9144 |
-
|
9145 |
-
|
9146 |
-
|
9147 |
-
|
9148 |
-
|
9149 |
-
|
9150 |
-
|
9151 |
-
|
9152 |
-
|
9153 |
-
|
9154 |
-
|
9155 |
-
|
9156 |
-
|
9157 |
-
|
9158 |
-
|
9159 |
-
*
|
9160 |
-
*
|
9161 |
-
*
|
9162 |
-
* @
|
9163 |
-
*
|
9164 |
-
* @
|
9165 |
-
*/
|
9166 |
-
private function
|
9167 |
-
$this->
|
9168 |
-
|
9169 |
-
|
9170 |
-
|
9171 |
-
|
9172 |
-
|
9173 |
-
|
9174 |
-
|
9175 |
-
|
9176 |
-
|
9177 |
-
|
9178 |
-
|
9179 |
-
|
9180 |
-
|
9181 |
-
|
9182 |
-
|
9183 |
-
|
9184 |
-
|
9185 |
-
|
9186 |
-
|
9187 |
-
|
9188 |
-
|
9189 |
-
|
9190 |
-
|
9191 |
-
|
9192 |
-
|
9193 |
-
|
9194 |
-
|
9195 |
-
|
9196 |
-
|
9197 |
-
|
9198 |
-
|
9199 |
-
|
9200 |
-
|
9201 |
-
|
9202 |
-
|
9203 |
-
|
9204 |
-
|
9205 |
-
|
9206 |
-
|
9207 |
-
|
9208 |
-
|
9209 |
-
|
9210 |
-
|
9211 |
-
|
9212 |
-
|
9213 |
-
|
9214 |
-
|
9215 |
-
|
9216 |
-
|
9217 |
-
|
9218 |
-
|
9219 |
-
|
9220 |
-
|
9221 |
-
|
9222 |
-
|
9223 |
-
|
9224 |
-
|
9225 |
-
|
9226 |
-
|
9227 |
-
|
9228 |
-
if ( $
|
9229 |
-
|
9230 |
-
|
9231 |
-
|
9232 |
-
|
9233 |
-
|
9234 |
-
|
9235 |
-
|
9236 |
-
|
9237 |
-
|
9238 |
-
|
9239 |
-
|
9240 |
-
|
9241 |
-
|
9242 |
-
|
9243 |
-
|
9244 |
-
|
9245 |
-
|
9246 |
-
|
9247 |
-
|
9248 |
-
|
9249 |
-
|
9250 |
-
|
9251 |
-
|
9252 |
-
|
9253 |
-
|
9254 |
-
|
9255 |
-
|
9256 |
-
|
9257 |
-
|
9258 |
-
|
9259 |
-
|
9260 |
-
|
9261 |
-
|
9262 |
-
|
9263 |
-
|
9264 |
-
|
9265 |
-
|
9266 |
-
|
9267 |
-
|
9268 |
-
|
9269 |
-
|
9270 |
-
|
9271 |
-
|
9272 |
-
|
9273 |
-
|
9274 |
-
|
9275 |
-
|
9276 |
-
|
9277 |
-
|
9278 |
-
|
9279 |
-
|
9280 |
-
|
9281 |
-
|
9282 |
-
|
9283 |
-
|
9284 |
-
|
9285 |
-
|
9286 |
-
|
9287 |
-
|
9288 |
-
|
9289 |
-
|
9290 |
-
|
9291 |
-
|
9292 |
-
|
9293 |
-
|
9294 |
-
|
9295 |
-
|
9296 |
-
*
|
9297 |
-
* @
|
9298 |
-
|
9299 |
-
|
9300 |
-
|
9301 |
-
|
9302 |
-
|
9303 |
-
|
9304 |
-
|
9305 |
-
|
9306 |
-
|
9307 |
-
|
9308 |
-
|
9309 |
-
|
9310 |
-
if ( !
|
9311 |
-
|
9312 |
-
|
9313 |
-
|
9314 |
-
|
9315 |
-
|
9316 |
-
|
9317 |
-
|
9318 |
-
|
9319 |
-
|
9320 |
-
|
9321 |
-
|
9322 |
-
|
9323 |
-
|
9324 |
-
|
9325 |
-
*
|
9326 |
-
|
9327 |
-
|
9328 |
-
|
9329 |
-
|
9330 |
-
|
9331 |
-
|
9332 |
-
|
9333 |
-
|
9334 |
-
|
9335 |
-
|
9336 |
-
|
9337 |
-
|
9338 |
-
|
9339 |
-
|
9340 |
-
|
9341 |
-
|
9342 |
-
|
9343 |
-
|
9344 |
-
|
9345 |
-
|
9346 |
-
|
9347 |
-
|
9348 |
-
|
9349 |
-
|
9350 |
-
|
9351 |
-
|
9352 |
-
|
9353 |
-
|
9354 |
-
|
9355 |
-
|
9356 |
-
|
9357 |
-
|
9358 |
-
|
9359 |
-
|
9360 |
-
|
9361 |
-
|
9362 |
-
|
9363 |
-
|
9364 |
-
|
9365 |
-
|
9366 |
-
|
9367 |
-
|
9368 |
-
|
9369 |
-
|
9370 |
-
|
9371 |
-
|
9372 |
-
|
9373 |
-
$this->
|
9374 |
-
|
9375 |
-
|
9376 |
-
|
9377 |
-
|
9378 |
-
|
9379 |
-
|
9380 |
-
|
9381 |
-
|
9382 |
-
|
9383 |
-
|
9384 |
-
|
9385 |
-
|
9386 |
-
|
9387 |
-
|
9388 |
-
|
9389 |
-
|
9390 |
-
|
9391 |
-
|
9392 |
-
|
9393 |
-
|
9394 |
-
|
9395 |
-
|
9396 |
-
|
9397 |
-
|
9398 |
-
|
9399 |
-
$this->
|
9400 |
-
|
9401 |
-
|
9402 |
-
|
9403 |
-
|
9404 |
-
|
9405 |
-
|
9406 |
-
|
9407 |
-
|
9408 |
-
|
9409 |
-
|
9410 |
-
|
9411 |
-
|
9412 |
-
|
9413 |
-
|
9414 |
-
|
9415 |
-
|
9416 |
-
|
9417 |
-
|
9418 |
-
|
9419 |
-
|
9420 |
-
|
9421 |
-
|
9422 |
-
|
9423 |
-
|
9424 |
-
|
9425 |
-
|
9426 |
-
|
9427 |
-
|
9428 |
-
|
9429 |
-
|
9430 |
-
|
9431 |
-
|
9432 |
-
|
9433 |
-
|
9434 |
-
|
9435 |
-
|
9436 |
-
|
9437 |
-
|
9438 |
-
|
9439 |
-
|
9440 |
-
|
9441 |
-
|
9442 |
-
|
9443 |
-
|
9444 |
-
|
9445 |
-
|
9446 |
-
|
9447 |
-
|
9448 |
-
|
9449 |
-
|
9450 |
-
|
9451 |
-
|
9452 |
-
$this->
|
9453 |
-
|
9454 |
-
|
9455 |
-
|
9456 |
-
|
9457 |
-
|
9458 |
-
|
9459 |
-
|
9460 |
-
|
9461 |
-
* @
|
9462 |
-
*
|
9463 |
-
*
|
9464 |
-
|
9465 |
-
|
9466 |
-
|
9467 |
-
|
9468 |
-
|
9469 |
-
|
9470 |
-
|
9471 |
-
|
9472 |
-
|
9473 |
-
|
9474 |
-
|
9475 |
-
|
9476 |
-
|
9477 |
-
|
9478 |
-
|
9479 |
-
|
9480 |
-
|
9481 |
-
|
9482 |
-
|
9483 |
-
|
9484 |
-
|
9485 |
-
|
9486 |
-
*
|
9487 |
-
*
|
9488 |
-
*
|
9489 |
-
|
9490 |
-
|
9491 |
-
|
9492 |
-
|
9493 |
-
|
9494 |
-
|
9495 |
-
|
9496 |
-
|
9497 |
-
|
9498 |
-
|
9499 |
-
|
9500 |
-
*
|
9501 |
-
|
9502 |
-
|
9503 |
-
|
9504 |
-
|
9505 |
-
|
9506 |
-
|
9507 |
-
|
9508 |
-
|
9509 |
-
|
9510 |
-
|
9511 |
-
|
9512 |
-
|
9513 |
-
|
9514 |
-
|
9515 |
-
|
9516 |
-
|
9517 |
-
|
9518 |
-
|
9519 |
-
|
9520 |
-
|
9521 |
-
|
9522 |
-
|
9523 |
-
|
9524 |
-
|
9525 |
-
|
9526 |
-
|
9527 |
-
|
9528 |
-
|
9529 |
-
|
9530 |
-
|
9531 |
-
|
9532 |
-
|
9533 |
-
|
9534 |
-
|
9535 |
-
|
9536 |
-
|
9537 |
-
|
9538 |
-
|
9539 |
-
|
9540 |
-
|
9541 |
-
|
9542 |
-
|
9543 |
-
|
9544 |
-
|
9545 |
-
|
9546 |
-
|
9547 |
-
|
9548 |
-
|
9549 |
-
|
9550 |
-
|
9551 |
-
|
9552 |
-
|
9553 |
-
|
9554 |
-
|
9555 |
-
|
9556 |
-
|
9557 |
-
|
9558 |
-
|
9559 |
-
|
9560 |
-
|
9561 |
-
|
9562 |
-
|
9563 |
-
|
9564 |
-
|
9565 |
-
|
9566 |
-
|
9567 |
-
|
9568 |
-
|
9569 |
-
|
9570 |
-
|
9571 |
-
|
9572 |
-
|
9573 |
-
|
9574 |
-
|
9575 |
-
|
9576 |
-
|
9577 |
-
|
9578 |
-
|
9579 |
-
|
9580 |
-
|
9581 |
-
|
9582 |
-
|
9583 |
-
|
9584 |
-
|
9585 |
-
|
9586 |
-
|
9587 |
-
|
9588 |
-
|
9589 |
-
|
9590 |
-
|
9591 |
-
|
9592 |
-
|
9593 |
-
|
9594 |
-
|
9595 |
-
|
9596 |
-
|
9597 |
-
|
9598 |
-
|
9599 |
-
|
9600 |
-
|
9601 |
-
|
9602 |
-
|
9603 |
-
|
9604 |
-
|
9605 |
-
|
9606 |
-
|
9607 |
-
|
9608 |
-
|
9609 |
-
|
9610 |
-
|
9611 |
-
|
9612 |
-
|
9613 |
-
|
9614 |
-
|
9615 |
-
|
9616 |
-
|
9617 |
-
|
9618 |
-
|
9619 |
-
|
9620 |
-
|
9621 |
-
|
9622 |
-
|
9623 |
-
|
9624 |
-
|
9625 |
-
|
9626 |
-
|
9627 |
-
|
9628 |
-
|
9629 |
-
|
9630 |
-
|
9631 |
-
|
9632 |
-
|
9633 |
-
|
9634 |
-
|
9635 |
-
|
9636 |
-
|
9637 |
-
$
|
9638 |
-
|
9639 |
-
|
9640 |
-
|
9641 |
-
|
9642 |
-
|
9643 |
-
|
9644 |
-
|
9645 |
-
|
9646 |
-
|
9647 |
-
|
9648 |
-
|
9649 |
-
|
9650 |
-
|
9651 |
-
|
9652 |
-
|
9653 |
-
|
9654 |
-
|
9655 |
-
|
9656 |
-
|
9657 |
-
|
9658 |
-
|
9659 |
-
|
9660 |
-
|
9661 |
-
|
9662 |
-
|
9663 |
-
|
9664 |
-
|
9665 |
-
|
9666 |
-
|
9667 |
-
|
9668 |
-
|
9669 |
-
|
9670 |
-
|
9671 |
-
|
9672 |
-
|
9673 |
-
$this->
|
9674 |
-
|
9675 |
-
|
9676 |
-
|
9677 |
-
|
9678 |
-
|
9679 |
-
|
9680 |
-
|
9681 |
-
|
9682 |
-
|
9683 |
-
|
9684 |
-
|
9685 |
-
|
9686 |
-
|
9687 |
-
|
9688 |
-
|
9689 |
-
|
9690 |
-
|
9691 |
-
|
9692 |
-
|
9693 |
-
|
9694 |
-
|
9695 |
-
|
9696 |
-
|
9697 |
-
|
9698 |
-
|
9699 |
-
|
9700 |
-
|
9701 |
-
|
9702 |
-
|
9703 |
-
|
9704 |
-
|
9705 |
-
|
9706 |
-
|
9707 |
-
$
|
9708 |
-
$
|
9709 |
-
$
|
9710 |
-
|
9711 |
-
|
9712 |
-
|
9713 |
-
}
|
9714 |
-
|
9715 |
-
|
9716 |
-
|
9717 |
-
|
9718 |
-
|
9719 |
-
|
9720 |
-
|
9721 |
-
|
9722 |
-
|
9723 |
-
|
9724 |
-
|
9725 |
-
|
9726 |
-
|
9727 |
-
|
9728 |
-
|
9729 |
-
|
9730 |
-
|
9731 |
-
|
9732 |
-
|
9733 |
-
|
9734 |
-
|
9735 |
-
|
9736 |
-
|
9737 |
-
|
9738 |
-
|
9739 |
-
|
9740 |
-
|
9741 |
-
|
9742 |
-
|
9743 |
-
|
9744 |
-
|
9745 |
-
|
9746 |
-
|
9747 |
-
|
9748 |
-
|
9749 |
-
|
9750 |
-
|
9751 |
-
|
9752 |
-
|
9753 |
-
|
9754 |
-
|
9755 |
-
|
9756 |
-
|
9757 |
-
|
9758 |
-
|
9759 |
-
|
9760 |
-
|
9761 |
-
|
9762 |
-
|
9763 |
-
|
9764 |
-
|
9765 |
-
|
9766 |
-
|
9767 |
-
|
9768 |
-
|
9769 |
-
|
9770 |
-
|
9771 |
-
|
9772 |
-
|
9773 |
-
|
9774 |
-
|
9775 |
-
|
9776 |
-
|
9777 |
-
|
9778 |
-
|
9779 |
-
|
9780 |
-
|
9781 |
-
|
9782 |
-
|
9783 |
-
|
9784 |
-
|
9785 |
-
|
9786 |
-
|
9787 |
-
|
9788 |
-
|
9789 |
-
|
9790 |
-
|
9791 |
-
|
9792 |
-
|
9793 |
-
|
9794 |
-
|
9795 |
-
|
9796 |
-
|
9797 |
-
|
9798 |
-
|
9799 |
-
|
9800 |
-
|
9801 |
-
|
9802 |
-
|
9803 |
-
|
9804 |
-
|
9805 |
-
|
9806 |
-
|
9807 |
-
|
9808 |
-
|
9809 |
-
|
9810 |
-
|
9811 |
-
|
9812 |
-
|
9813 |
-
|
9814 |
-
|
9815 |
-
|
9816 |
-
|
9817 |
-
|
9818 |
-
|
9819 |
-
|
9820 |
-
|
9821 |
-
|
9822 |
-
|
9823 |
-
|
9824 |
-
|
9825 |
-
|
9826 |
-
|
9827 |
-
|
9828 |
-
|
9829 |
-
|
9830 |
-
|
9831 |
-
|
9832 |
-
|
9833 |
-
|
9834 |
-
|
9835 |
-
|
9836 |
-
|
9837 |
-
|
9838 |
-
|
9839 |
-
|
9840 |
-
|
9841 |
-
|
9842 |
-
|
9843 |
-
|
9844 |
-
|
9845 |
-
|
9846 |
-
|
9847 |
-
|
9848 |
-
|
9849 |
-
|
9850 |
-
|
9851 |
-
|
9852 |
-
|
9853 |
-
$
|
9854 |
-
|
9855 |
-
|
9856 |
-
$
|
9857 |
-
|
9858 |
-
|
9859 |
-
|
9860 |
-
|
9861 |
-
$
|
9862 |
-
|
9863 |
-
|
9864 |
-
|
9865 |
-
|
9866 |
-
|
9867 |
-
|
9868 |
-
|
9869 |
-
|
9870 |
-
|
9871 |
-
|
9872 |
-
|
9873 |
-
|
9874 |
-
|
9875 |
-
|
9876 |
-
|
9877 |
-
|
9878 |
-
|
9879 |
-
|
9880 |
-
|
9881 |
-
|
9882 |
-
|
9883 |
-
|
9884 |
-
|
9885 |
-
|
9886 |
-
|
9887 |
-
|
9888 |
-
|
9889 |
-
|
9890 |
-
|
9891 |
-
|
9892 |
-
|
9893 |
-
|
9894 |
-
|
9895 |
-
|
9896 |
-
|
9897 |
-
|
9898 |
-
|
9899 |
-
|
9900 |
-
|
9901 |
-
|
9902 |
-
|
9903 |
-
|
9904 |
-
|
9905 |
-
|
9906 |
-
|
9907 |
-
|
9908 |
-
|
9909 |
-
|
9910 |
-
|
9911 |
-
|
9912 |
-
|
9913 |
-
|
9914 |
-
|
9915 |
-
|
9916 |
-
|
9917 |
-
|
9918 |
-
|
9919 |
-
|
9920 |
-
|
9921 |
-
|
9922 |
-
|
9923 |
-
|
9924 |
-
|
9925 |
-
|
9926 |
-
|
9927 |
-
|
9928 |
-
|
9929 |
-
$
|
9930 |
-
$
|
9931 |
-
$
|
9932 |
-
|
9933 |
-
|
9934 |
-
|
9935 |
-
|
9936 |
-
|
9937 |
-
|
9938 |
-
|
9939 |
-
|
9940 |
-
|
9941 |
-
|
9942 |
-
|
9943 |
-
|
9944 |
-
|
9945 |
-
|
9946 |
-
|
9947 |
-
|
9948 |
-
|
9949 |
-
|
9950 |
-
|
9951 |
-
|
9952 |
-
|
9953 |
-
|
9954 |
-
|
9955 |
-
|
9956 |
-
|
9957 |
-
|
9958 |
-
|
9959 |
-
|
9960 |
-
|
9961 |
-
|
9962 |
-
|
9963 |
-
|
9964 |
-
|
9965 |
-
|
9966 |
-
|
9967 |
-
|
9968 |
-
|
9969 |
-
|
9970 |
-
if (
|
9971 |
-
$
|
9972 |
-
}
|
9973 |
-
|
9974 |
-
$
|
9975 |
-
|
9976 |
-
|
9977 |
-
|
9978 |
-
|
9979 |
-
|
9980 |
-
|
9981 |
-
|
9982 |
-
|
9983 |
-
|
9984 |
-
|
9985 |
-
|
9986 |
-
|
9987 |
-
$this->
|
9988 |
-
|
9989 |
-
|
9990 |
-
|
9991 |
-
|
9992 |
-
|
9993 |
-
|
9994 |
-
* @author Vova Feldman (@svovaf)
|
9995 |
-
* @since 1.
|
9996 |
-
*
|
9997 |
-
* @param
|
9998 |
-
|
9999 |
-
|
10000 |
-
|
10001 |
-
|
10002 |
-
|
10003 |
-
|
10004 |
-
|
10005 |
-
|
10006 |
-
|
10007 |
-
|
10008 |
-
|
10009 |
-
|
10010 |
-
|
10011 |
-
|
10012 |
-
|
10013 |
-
|
10014 |
-
|
10015 |
-
|
10016 |
-
|
10017 |
-
|
10018 |
-
|
10019 |
-
|
10020 |
-
|
10021 |
-
|
10022 |
-
|
10023 |
-
|
10024 |
-
|
10025 |
-
|
10026 |
-
|
10027 |
-
|
10028 |
-
|
10029 |
-
|
10030 |
-
|
10031 |
-
|
10032 |
-
|
10033 |
-
|
10034 |
-
|
10035 |
-
|
10036 |
-
|
10037 |
-
|
10038 |
-
|
10039 |
-
|
10040 |
-
|
10041 |
-
|
10042 |
-
|
10043 |
-
|
10044 |
-
|
10045 |
-
|
10046 |
-
|
10047 |
-
|
10048 |
-
|
10049 |
-
|
10050 |
-
|
10051 |
-
|
10052 |
-
|
10053 |
-
|
10054 |
-
|
10055 |
-
*
|
10056 |
-
*
|
10057 |
-
* @
|
10058 |
-
|
10059 |
-
|
10060 |
-
|
10061 |
-
|
10062 |
-
|
10063 |
-
|
10064 |
-
|
10065 |
-
|
10066 |
-
|
10067 |
-
|
10068 |
-
|
10069 |
-
|
10070 |
-
|
10071 |
-
|
10072 |
-
|
10073 |
-
|
10074 |
-
|
10075 |
-
|
10076 |
-
|
10077 |
-
|
10078 |
-
|
10079 |
-
|
10080 |
-
|
10081 |
-
|
10082 |
-
|
10083 |
-
|
10084 |
-
|
10085 |
-
|
10086 |
-
|
10087 |
-
|
10088 |
-
|
10089 |
-
|
10090 |
-
|
10091 |
-
|
10092 |
-
|
10093 |
-
|
10094 |
-
|
10095 |
-
|
10096 |
-
|
10097 |
-
|
10098 |
-
|
10099 |
-
|
10100 |
-
|
10101 |
-
|
10102 |
-
|
10103 |
-
|
10104 |
-
|
10105 |
-
|
10106 |
-
|
10107 |
-
|
10108 |
-
|
10109 |
-
|
10110 |
-
|
10111 |
-
|
10112 |
-
|
10113 |
-
|
10114 |
-
|
10115 |
-
|
10116 |
-
|
10117 |
-
|
10118 |
-
|
10119 |
-
|
10120 |
-
|
10121 |
-
|
10122 |
-
|
10123 |
-
|
10124 |
-
|
10125 |
-
|
10126 |
-
|
10127 |
-
|
10128 |
-
|
10129 |
-
|
10130 |
-
|
10131 |
-
|
10132 |
-
|
10133 |
-
|
10134 |
-
|
10135 |
-
|
10136 |
-
|
10137 |
-
|
10138 |
-
|
10139 |
-
|
10140 |
-
|
10141 |
-
|
10142 |
-
|
10143 |
-
|
10144 |
-
|
10145 |
-
|
10146 |
-
|
10147 |
-
|
10148 |
-
|
10149 |
-
|
10150 |
-
|
10151 |
-
|
10152 |
-
|
10153 |
-
|
10154 |
-
|
10155 |
-
|
10156 |
-
|
10157 |
-
|
10158 |
-
|
10159 |
-
|
10160 |
-
|
10161 |
-
|
10162 |
-
|
10163 |
-
|
10164 |
-
|
10165 |
-
|
10166 |
-
|
10167 |
-
|
10168 |
-
|
10169 |
-
|
10170 |
-
|
10171 |
-
|
10172 |
-
|
10173 |
-
|
10174 |
-
|
10175 |
-
|
10176 |
-
|
10177 |
-
|
10178 |
-
|
10179 |
-
|
10180 |
-
|
10181 |
-
|
10182 |
-
|
10183 |
-
|
10184 |
-
|
10185 |
-
|
10186 |
-
|
10187 |
-
|
10188 |
-
|
10189 |
-
|
10190 |
-
|
10191 |
-
|
10192 |
-
|
10193 |
-
|
10194 |
-
|
10195 |
-
|
10196 |
-
|
10197 |
-
|
10198 |
-
|
10199 |
-
|
10200 |
-
|
10201 |
-
|
10202 |
-
|
10203 |
-
|
10204 |
-
|
10205 |
-
|
10206 |
-
|
10207 |
-
|
10208 |
-
|
10209 |
-
*
|
10210 |
-
|
10211 |
-
|
10212 |
-
|
10213 |
-
|
10214 |
-
|
10215 |
-
|
10216 |
-
|
10217 |
-
|
10218 |
-
|
10219 |
-
|
10220 |
-
|
10221 |
-
|
10222 |
-
|
10223 |
-
|
10224 |
-
|
10225 |
-
|
10226 |
-
|
10227 |
-
|
10228 |
-
|
10229 |
-
|
10230 |
-
|
10231 |
-
|
10232 |
-
|
10233 |
-
|
10234 |
-
|
10235 |
-
|
10236 |
-
|
10237 |
-
|
10238 |
-
|
10239 |
-
|
10240 |
-
|
10241 |
-
|
10242 |
-
|
10243 |
-
|
10244 |
-
|
10245 |
-
|
10246 |
-
|
10247 |
-
|
10248 |
-
|
10249 |
-
|
10250 |
-
|
10251 |
-
|
10252 |
-
|
10253 |
-
|
10254 |
-
|
10255 |
-
|
10256 |
-
|
10257 |
-
|
10258 |
-
|
10259 |
-
|
10260 |
-
|
10261 |
-
|
10262 |
-
|
10263 |
-
|
10264 |
-
|
10265 |
-
|
10266 |
-
|
10267 |
-
|
10268 |
-
|
10269 |
-
|
10270 |
-
|
10271 |
-
|
10272 |
-
|
10273 |
-
|
10274 |
-
|
10275 |
-
|
10276 |
-
|
10277 |
-
|
10278 |
-
|
10279 |
-
|
10280 |
-
|
10281 |
-
|
10282 |
-
|
10283 |
-
|
10284 |
-
|
10285 |
-
|
10286 |
-
|
10287 |
-
|
10288 |
-
*
|
10289 |
-
|
10290 |
-
|
10291 |
-
|
10292 |
-
|
10293 |
-
|
10294 |
-
|
10295 |
-
*
|
10296 |
-
|
10297 |
-
|
10298 |
-
|
10299 |
-
|
10300 |
-
|
10301 |
-
|
10302 |
-
|
10303 |
-
|
10304 |
-
|
10305 |
-
|
10306 |
-
|
10307 |
-
|
10308 |
-
*
|
10309 |
-
* @
|
10310 |
-
|
10311 |
-
|
10312 |
-
|
10313 |
-
|
10314 |
-
|
10315 |
-
|
10316 |
-
|
10317 |
-
|
10318 |
-
|
10319 |
-
|
10320 |
-
|
10321 |
-
$
|
10322 |
-
|
10323 |
-
|
10324 |
-
|
10325 |
-
|
10326 |
-
|
10327 |
-
|
10328 |
-
|
10329 |
-
|
10330 |
-
|
10331 |
-
|
10332 |
-
|
10333 |
-
|
10334 |
-
|
10335 |
-
|
10336 |
-
|
10337 |
-
|
10338 |
-
|
10339 |
-
|
10340 |
-
|
10341 |
-
|
10342 |
-
|
10343 |
-
|
10344 |
-
|
10345 |
-
|
10346 |
-
*
|
10347 |
-
*
|
10348 |
-
* @
|
10349 |
-
* @
|
10350 |
-
*
|
10351 |
-
* @
|
10352 |
-
*/
|
10353 |
-
function
|
10354 |
-
$this->_logger->entrance();
|
10355 |
-
|
10356 |
-
|
10357 |
-
|
10358 |
-
|
10359 |
-
|
10360 |
-
|
10361 |
-
|
10362 |
-
|
10363 |
-
|
10364 |
-
|
10365 |
-
|
10366 |
-
$
|
10367 |
-
|
10368 |
-
|
10369 |
-
|
10370 |
-
|
10371 |
-
|
10372 |
-
|
10373 |
-
|
10374 |
-
|
10375 |
-
|
10376 |
-
|
10377 |
-
|
10378 |
-
|
10379 |
-
|
10380 |
-
|
10381 |
-
|
10382 |
-
|
10383 |
-
|
10384 |
-
|
10385 |
-
|
10386 |
-
|
10387 |
-
|
10388 |
-
|
10389 |
-
|
10390 |
-
|
10391 |
-
|
10392 |
-
|
10393 |
-
|
10394 |
-
|
10395 |
-
|
10396 |
-
|
10397 |
-
|
10398 |
-
|
10399 |
-
|
10400 |
-
|
10401 |
-
|
10402 |
-
|
10403 |
-
|
10404 |
-
*
|
10405 |
-
|
10406 |
-
|
10407 |
-
|
10408 |
-
|
10409 |
-
|
10410 |
-
|
10411 |
-
|
10412 |
-
|
10413 |
-
|
10414 |
-
|
10415 |
-
|
10416 |
-
|
10417 |
-
|
10418 |
-
|
10419 |
-
|
10420 |
-
|
10421 |
-
|
10422 |
-
*
|
10423 |
-
*
|
10424 |
-
* @
|
10425 |
-
*
|
10426 |
-
*
|
10427 |
-
* @param bool
|
10428 |
-
*
|
10429 |
-
|
10430 |
-
|
10431 |
-
|
10432 |
-
|
10433 |
-
|
10434 |
-
|
10435 |
-
|
10436 |
-
|
10437 |
-
|
10438 |
-
|
10439 |
-
|
10440 |
-
|
10441 |
-
|
10442 |
-
|
10443 |
-
|
10444 |
-
|
10445 |
-
|
10446 |
-
|
10447 |
-
*
|
10448 |
-
*
|
10449 |
-
|
10450 |
-
|
10451 |
-
|
10452 |
-
|
10453 |
-
|
10454 |
-
|
10455 |
-
|
10456 |
-
|
10457 |
-
|
10458 |
-
|
10459 |
-
|
10460 |
-
|
10461 |
-
|
10462 |
-
|
10463 |
-
|
10464 |
-
*
|
10465 |
-
*
|
10466 |
-
* @
|
10467 |
-
|
10468 |
-
|
10469 |
-
|
10470 |
-
|
10471 |
-
|
10472 |
-
|
10473 |
-
|
10474 |
-
|
10475 |
-
|
10476 |
-
|
10477 |
-
|
10478 |
-
|
10479 |
-
|
10480 |
-
|
10481 |
-
|
10482 |
-
|
10483 |
-
|
10484 |
-
|
10485 |
-
|
10486 |
-
|
10487 |
-
|
10488 |
-
*
|
10489 |
-
*
|
10490 |
-
* @
|
10491 |
-
|
10492 |
-
|
10493 |
-
|
10494 |
-
|
10495 |
-
|
10496 |
-
|
10497 |
-
|
10498 |
-
|
10499 |
-
|
10500 |
-
|
10501 |
-
|
10502 |
-
|
10503 |
-
|
10504 |
-
|
10505 |
-
|
10506 |
-
|
10507 |
-
|
10508 |
-
|
10509 |
-
|
10510 |
-
|
10511 |
-
|
10512 |
-
|
10513 |
-
|
10514 |
-
|
10515 |
-
|
10516 |
-
|
10517 |
-
|
10518 |
-
|
10519 |
-
|
10520 |
-
|
10521 |
-
|
10522 |
-
|
10523 |
-
|
10524 |
-
|
10525 |
-
|
10526 |
-
|
10527 |
-
|
10528 |
-
|
10529 |
-
|
10530 |
-
|
10531 |
-
|
10532 |
-
|
10533 |
-
|
10534 |
-
|
10535 |
-
|
10536 |
-
|
10537 |
-
|
10538 |
-
|
10539 |
-
|
10540 |
-
|
10541 |
-
|
10542 |
-
|
10543 |
-
|
10544 |
-
|
10545 |
-
|
10546 |
-
|
10547 |
-
|
10548 |
-
|
10549 |
-
|
10550 |
-
|
10551 |
-
|
10552 |
-
|
10553 |
-
|
10554 |
-
|
10555 |
-
|
10556 |
-
|
10557 |
-
|
10558 |
-
|
10559 |
-
|
10560 |
-
|
10561 |
-
|
10562 |
-
|
10563 |
-
|
10564 |
-
|
10565 |
-
|
10566 |
-
|
10567 |
-
|
10568 |
-
|
10569 |
-
|
10570 |
-
|
10571 |
-
|
10572 |
-
|
10573 |
-
|
10574 |
-
|
10575 |
-
|
10576 |
-
|
10577 |
-
|
10578 |
-
|
10579 |
-
|
10580 |
-
|
10581 |
-
|
10582 |
-
|
10583 |
-
|
10584 |
-
|
10585 |
-
|
10586 |
-
|
10587 |
-
|
10588 |
-
|
10589 |
-
|
10590 |
-
|
10591 |
-
|
10592 |
-
|
10593 |
-
|
10594 |
-
|
10595 |
-
|
10596 |
-
|
10597 |
-
|
10598 |
-
|
10599 |
-
|
10600 |
-
|
10601 |
-
|
10602 |
-
|
10603 |
-
|
10604 |
-
|
10605 |
-
|
10606 |
-
|
10607 |
-
|
10608 |
-
|
10609 |
-
|
10610 |
-
* @
|
10611 |
-
|
10612 |
-
|
10613 |
-
|
10614 |
-
|
10615 |
-
|
10616 |
-
|
10617 |
-
|
10618 |
-
|
10619 |
-
|
10620 |
-
|
10621 |
-
|
10622 |
-
|
10623 |
-
|
10624 |
-
|
10625 |
-
|
10626 |
-
|
10627 |
-
|
10628 |
-
* @
|
10629 |
-
*
|
10630 |
-
* @
|
10631 |
-
|
10632 |
-
|
10633 |
-
|
10634 |
-
|
10635 |
-
|
10636 |
-
|
10637 |
-
|
10638 |
-
|
10639 |
-
|
10640 |
-
|
10641 |
-
|
10642 |
-
|
10643 |
-
|
10644 |
-
|
10645 |
-
|
10646 |
-
|
10647 |
-
|
10648 |
-
|
10649 |
-
|
10650 |
-
|
10651 |
-
|
10652 |
-
|
10653 |
-
|
10654 |
-
|
10655 |
-
* @author Vova Feldman (@svovaf)
|
10656 |
-
* @since 1.
|
10657 |
-
*
|
10658 |
-
*
|
10659 |
-
* @param
|
10660 |
-
*
|
10661 |
-
* @return
|
10662 |
-
*/
|
10663 |
-
private function
|
10664 |
-
|
10665 |
-
|
10666 |
-
|
10667 |
-
|
10668 |
-
|
10669 |
-
|
10670 |
-
|
10671 |
-
|
10672 |
-
|
10673 |
-
|
10674 |
-
|
10675 |
-
|
10676 |
-
|
10677 |
-
|
10678 |
-
|
10679 |
-
|
10680 |
-
|
10681 |
-
|
10682 |
-
|
10683 |
-
|
10684 |
-
|
10685 |
-
|
10686 |
-
|
10687 |
-
|
10688 |
-
|
10689 |
-
|
10690 |
-
|
10691 |
-
|
10692 |
-
|
10693 |
-
|
10694 |
-
|
10695 |
-
|
10696 |
-
|
10697 |
-
|
10698 |
-
|
10699 |
-
|
10700 |
-
|
10701 |
-
|
10702 |
-
|
10703 |
-
|
10704 |
-
|
10705 |
-
|
10706 |
-
|
10707 |
-
|
10708 |
-
|
10709 |
-
|
10710 |
-
|
10711 |
-
|
10712 |
-
|
10713 |
-
|
10714 |
-
|
10715 |
-
|
10716 |
-
|
10717 |
-
|
10718 |
-
|
10719 |
-
|
10720 |
-
|
10721 |
-
|
10722 |
-
$
|
10723 |
-
|
10724 |
-
$
|
10725 |
-
|
10726 |
-
$
|
10727 |
-
|
10728 |
-
|
10729 |
-
|
10730 |
-
|
10731 |
-
|
10732 |
-
|
10733 |
-
|
10734 |
-
|
10735 |
-
|
10736 |
-
|
10737 |
-
|
10738 |
-
|
10739 |
-
|
10740 |
-
|
10741 |
-
|
10742 |
-
|
10743 |
-
|
10744 |
-
|
10745 |
-
|
10746 |
-
|
10747 |
-
|
10748 |
-
|
10749 |
-
|
10750 |
-
|
10751 |
-
|
10752 |
-
|
10753 |
-
|
10754 |
-
|
10755 |
-
|
10756 |
-
|
10757 |
-
|
10758 |
-
|
10759 |
-
|
10760 |
-
|
10761 |
-
|
10762 |
-
|
10763 |
-
|
10764 |
-
|
10765 |
-
|
10766 |
-
|
10767 |
-
|
10768 |
-
|
10769 |
-
|
10770 |
-
|
10771 |
-
|
10772 |
-
|
10773 |
-
|
10774 |
-
|
10775 |
-
|
10776 |
-
$result
|
10777 |
-
|
10778 |
-
|
10779 |
-
|
10780 |
-
|
10781 |
-
) )
|
10782 |
-
|
10783 |
-
|
10784 |
-
|
10785 |
-
|
10786 |
-
|
10787 |
-
|
10788 |
-
|
10789 |
-
|
10790 |
-
|
10791 |
-
|
10792 |
-
|
10793 |
-
|
10794 |
-
|
10795 |
-
* @
|
10796 |
-
* @
|
10797 |
-
*
|
10798 |
-
* @
|
10799 |
-
|
10800 |
-
|
10801 |
-
|
10802 |
-
|
10803 |
-
|
10804 |
-
|
10805 |
-
|
10806 |
-
|
10807 |
-
|
10808 |
-
|
10809 |
-
}
|
10810 |
-
|
10811 |
-
|
10812 |
-
|
10813 |
-
|
10814 |
-
|
10815 |
-
|
10816 |
-
|
10817 |
-
|
10818 |
-
|
10819 |
-
|
10820 |
-
|
10821 |
-
|
10822 |
-
|
10823 |
-
|
10824 |
-
|
10825 |
-
|
10826 |
-
|
10827 |
-
|
10828 |
-
|
10829 |
-
|
10830 |
-
|
10831 |
-
|
10832 |
-
|
10833 |
-
|
10834 |
-
|
10835 |
-
|
10836 |
-
|
10837 |
-
|
10838 |
-
|
10839 |
-
|
10840 |
-
|
10841 |
-
|
10842 |
-
|
10843 |
-
|
10844 |
-
|
10845 |
-
|
10846 |
-
|
10847 |
-
|
10848 |
-
|
10849 |
-
|
10850 |
-
|
10851 |
-
|
10852 |
-
|
10853 |
-
|
10854 |
-
|
10855 |
-
|
10856 |
-
|
10857 |
-
|
10858 |
-
|
10859 |
-
|
10860 |
-
|
10861 |
-
|
10862 |
-
|
10863 |
-
|
10864 |
-
|
10865 |
-
|
10866 |
-
|
10867 |
-
|
10868 |
-
|
10869 |
-
|
10870 |
-
|
10871 |
-
|
10872 |
-
|
10873 |
-
|
10874 |
-
|
10875 |
-
|
10876 |
-
|
10877 |
-
|
10878 |
-
|
10879 |
-
|
10880 |
-
|
10881 |
-
|
10882 |
-
|
10883 |
-
|
10884 |
-
|
10885 |
-
|
10886 |
-
|
10887 |
-
|
10888 |
-
|
10889 |
-
|
10890 |
-
|
10891 |
-
|
10892 |
-
|
10893 |
-
|
10894 |
-
|
10895 |
-
|
10896 |
-
|
10897 |
-
|
10898 |
-
|
10899 |
-
|
10900 |
-
|
10901 |
-
|
10902 |
-
|
10903 |
-
|
10904 |
-
|
10905 |
-
|
10906 |
-
|
10907 |
-
|
10908 |
-
|
10909 |
-
|
10910 |
-
|
10911 |
-
|
10912 |
-
|
10913 |
-
|
10914 |
-
|
10915 |
-
|
10916 |
-
|
10917 |
-
|
10918 |
-
|
10919 |
-
|
10920 |
-
|
10921 |
-
|
10922 |
-
|
10923 |
-
|
10924 |
-
|
10925 |
-
|
10926 |
-
|
10927 |
-
|
10928 |
-
|
10929 |
-
|
10930 |
-
|
10931 |
-
|
10932 |
-
|
10933 |
-
|
10934 |
-
|
10935 |
-
|
10936 |
-
|
10937 |
-
|
10938 |
-
|
10939 |
-
|
10940 |
-
|
10941 |
-
|
10942 |
-
|
10943 |
-
|
10944 |
-
|
10945 |
-
|
10946 |
-
|
10947 |
-
|
10948 |
-
|
10949 |
-
|
10950 |
-
|
10951 |
-
|
10952 |
-
|
10953 |
-
|
10954 |
-
|
10955 |
-
|
10956 |
-
|
10957 |
-
|
10958 |
-
|
10959 |
-
|
10960 |
-
|
10961 |
-
|
10962 |
-
|
10963 |
-
|
10964 |
-
|
10965 |
-
|
10966 |
-
|
10967 |
-
|
10968 |
-
|
10969 |
-
|
10970 |
-
|
10971 |
-
|
10972 |
-
|
10973 |
-
|
10974 |
-
|
10975 |
-
|
10976 |
-
|
10977 |
-
|
10978 |
-
|
10979 |
-
|
10980 |
-
|
10981 |
-
|
10982 |
-
|
10983 |
-
|
10984 |
-
|
10985 |
-
|
10986 |
-
|
10987 |
-
|
10988 |
-
|
10989 |
-
|
10990 |
-
|
10991 |
-
|
10992 |
-
|
10993 |
-
|
10994 |
-
|
10995 |
-
|
10996 |
-
|
10997 |
-
|
10998 |
-
|
10999 |
-
|
11000 |
-
|
11001 |
-
|
11002 |
-
|
11003 |
-
|
11004 |
-
|
11005 |
-
|
11006 |
-
|
11007 |
-
|
11008 |
-
|
11009 |
-
|
11010 |
-
|
11011 |
-
|
11012 |
-
|
11013 |
-
|
11014 |
-
|
11015 |
-
|
11016 |
-
|
11017 |
-
|
11018 |
-
|
11019 |
-
|
11020 |
-
|
11021 |
-
|
11022 |
-
|
11023 |
-
|
11024 |
-
|
11025 |
-
|
11026 |
-
|
11027 |
-
|
11028 |
-
|
11029 |
-
|
11030 |
-
|
11031 |
-
|
11032 |
-
|
11033 |
-
|
11034 |
-
|
11035 |
-
|
11036 |
-
|
11037 |
-
|
11038 |
-
|
11039 |
-
|
11040 |
-
|
11041 |
-
|
11042 |
-
|
11043 |
-
|
11044 |
-
|
11045 |
-
|
11046 |
-
|
11047 |
-
|
11048 |
-
|
11049 |
-
|
11050 |
-
|
11051 |
-
|
11052 |
-
|
11053 |
-
|
11054 |
-
|
11055 |
-
|
11056 |
-
|
11057 |
-
|
11058 |
-
|
11059 |
-
|
11060 |
-
|
11061 |
-
|
11062 |
-
|
11063 |
-
|
11064 |
-
|
11065 |
-
|
11066 |
-
|
11067 |
-
|
11068 |
-
|
11069 |
-
|
11070 |
-
|
11071 |
-
|
11072 |
-
|
11073 |
-
|
11074 |
-
|
11075 |
-
|
11076 |
-
|
11077 |
-
|
11078 |
-
|
11079 |
-
|
11080 |
-
|
11081 |
-
|
11082 |
-
|
11083 |
-
|
11084 |
-
|
11085 |
-
|
11086 |
-
|
11087 |
-
|
11088 |
-
|
11089 |
-
|
11090 |
-
|
11091 |
-
|
11092 |
-
|
11093 |
-
|
11094 |
-
|
11095 |
-
|
11096 |
-
|
11097 |
-
|
11098 |
-
|
11099 |
-
|
11100 |
-
|
11101 |
-
|
11102 |
-
|
11103 |
-
|
11104 |
-
|
11105 |
-
|
11106 |
-
|
11107 |
-
|
11108 |
-
|
11109 |
-
|
11110 |
-
|
11111 |
-
|
11112 |
-
|
11113 |
-
|
11114 |
-
|
11115 |
-
|
11116 |
-
|
11117 |
-
|
11118 |
-
|
11119 |
-
|
11120 |
-
|
11121 |
-
|
11122 |
-
|
11123 |
-
|
11124 |
-
|
11125 |
-
|
11126 |
-
|
11127 |
-
|
11128 |
-
|
11129 |
-
|
11130 |
-
|
11131 |
-
|
11132 |
-
|
11133 |
-
|
11134 |
-
|
11135 |
-
|
11136 |
-
|
11137 |
-
|
11138 |
-
|
11139 |
-
|
11140 |
-
|
11141 |
-
|
11142 |
-
|
11143 |
-
|
11144 |
-
|
11145 |
-
|
11146 |
-
|
11147 |
-
|
11148 |
-
|
11149 |
-
|
11150 |
-
|
11151 |
-
|
11152 |
-
|
11153 |
-
|
11154 |
-
|
11155 |
-
|
11156 |
-
|
11157 |
-
|
11158 |
-
|
11159 |
-
|
11160 |
-
|
11161 |
-
|
11162 |
-
|
11163 |
-
|
11164 |
-
|
11165 |
-
|
11166 |
-
|
11167 |
-
|
11168 |
-
|
11169 |
-
|
11170 |
-
|
11171 |
-
|
11172 |
-
|
11173 |
-
|
11174 |
-
|
11175 |
-
$this->
|
11176 |
-
|
11177 |
-
|
11178 |
-
|
11179 |
-
|
11180 |
-
|
11181 |
-
|
11182 |
-
|
11183 |
-
|
11184 |
-
|
11185 |
-
|
11186 |
-
|
11187 |
-
|
11188 |
-
|
11189 |
-
|
11190 |
-
|
11191 |
-
|
11192 |
-
|
11193 |
-
|
11194 |
-
|
11195 |
-
|
11196 |
-
|
11197 |
-
|
11198 |
-
|
11199 |
-
|
11200 |
-
|
11201 |
-
|
11202 |
-
|
11203 |
-
|
11204 |
-
|
11205 |
-
|
11206 |
-
|
11207 |
-
|
11208 |
-
|
11209 |
-
|
11210 |
-
|
11211 |
-
|
11212 |
-
|
11213 |
-
|
11214 |
-
|
11215 |
-
|
11216 |
-
|
11217 |
-
|
11218 |
-
|
11219 |
-
|
11220 |
-
|
11221 |
-
|
11222 |
-
|
11223 |
-
|
11224 |
-
|
11225 |
-
|
11226 |
-
|
11227 |
-
|
11228 |
-
|
11229 |
-
|
11230 |
-
|
11231 |
-
|
11232 |
-
|
11233 |
-
|
11234 |
-
|
11235 |
-
|
11236 |
-
|
11237 |
-
|
11238 |
-
|
11239 |
-
|
11240 |
-
|
11241 |
-
|
11242 |
-
|
11243 |
-
|
11244 |
-
|
11245 |
-
|
11246 |
-
|
11247 |
-
|
11248 |
-
|
11249 |
-
|
11250 |
-
|
11251 |
-
|
11252 |
-
|
11253 |
-
|
11254 |
-
|
11255 |
-
|
11256 |
-
|
11257 |
-
|
11258 |
-
|
11259 |
-
|
11260 |
-
|
11261 |
-
|
11262 |
-
|
11263 |
-
|
11264 |
-
|
11265 |
-
|
11266 |
-
|
11267 |
-
|
11268 |
-
|
11269 |
-
|
11270 |
-
|
11271 |
-
|
11272 |
-
|
11273 |
-
|
11274 |
-
|
11275 |
-
|
11276 |
-
|
11277 |
-
|
11278 |
-
|
11279 |
-
|
11280 |
-
|
11281 |
-
|
11282 |
-
|
11283 |
-
|
11284 |
-
|
11285 |
-
|
11286 |
-
|
11287 |
-
|
11288 |
-
|
11289 |
-
|
11290 |
-
|
11291 |
-
|
11292 |
-
|
11293 |
-
|
11294 |
-
|
11295 |
-
|
11296 |
-
|
11297 |
-
|
11298 |
-
|
11299 |
-
|
11300 |
-
|
11301 |
-
|
11302 |
-
|
11303 |
-
|
11304 |
-
|
11305 |
-
|
11306 |
-
|
11307 |
-
|
11308 |
-
|
11309 |
-
|
11310 |
-
|
11311 |
-
|
11312 |
-
|
11313 |
-
|
11314 |
-
|
11315 |
-
|
11316 |
-
|
11317 |
-
|
11318 |
-
|
11319 |
-
|
11320 |
-
|
11321 |
-
|
11322 |
-
|
11323 |
-
|
11324 |
-
|
11325 |
-
|
11326 |
-
|
11327 |
-
|
11328 |
-
|
11329 |
-
|
11330 |
-
|
11331 |
-
|
11332 |
-
|
11333 |
-
|
11334 |
-
|
11335 |
-
|
11336 |
-
|
11337 |
-
|
11338 |
-
|
11339 |
-
|
11340 |
-
|
11341 |
-
|
11342 |
-
|
11343 |
-
|
11344 |
-
'
|
11345 |
-
|
11346 |
-
|
11347 |
-
|
11348 |
-
|
11349 |
-
|
11350 |
-
|
11351 |
-
|
11352 |
-
|
11353 |
-
|
11354 |
-
|
11355 |
-
|
11356 |
-
|
11357 |
-
|
11358 |
-
|
11359 |
-
|
11360 |
-
|
11361 |
-
|
11362 |
-
|
11363 |
-
|
11364 |
-
|
11365 |
-
|
11366 |
-
|
11367 |
-
|
11368 |
-
|
11369 |
-
|
11370 |
-
|
11371 |
-
|
11372 |
-
|
11373 |
-
|
11374 |
-
|
11375 |
-
|
11376 |
-
|
11377 |
-
|
11378 |
-
|
11379 |
-
|
11380 |
-
|
11381 |
-
|
11382 |
-
|
11383 |
-
|
11384 |
-
|
11385 |
-
|
11386 |
-
|
11387 |
-
|
11388 |
-
|
11389 |
-
|
11390 |
-
|
11391 |
-
|
11392 |
-
|
11393 |
-
|
11394 |
-
|
11395 |
-
|
11396 |
-
|
11397 |
-
|
11398 |
-
|
11399 |
-
|
11400 |
-
|
11401 |
-
|
11402 |
-
|
11403 |
-
|
11404 |
-
|
11405 |
-
|
11406 |
-
|
11407 |
-
|
11408 |
-
|
11409 |
-
|
11410 |
-
|
11411 |
-
|
11412 |
-
|
11413 |
-
|
11414 |
-
|
11415 |
-
|
11416 |
-
|
11417 |
-
|
11418 |
-
|
11419 |
-
|
11420 |
-
|
11421 |
-
|
11422 |
-
|
11423 |
-
|
11424 |
-
|
11425 |
-
|
11426 |
-
|
11427 |
-
|
11428 |
-
|
11429 |
-
|
11430 |
-
|
11431 |
-
|
11432 |
-
|
11433 |
-
|
11434 |
-
|
11435 |
-
return
|
11436 |
-
}
|
11437 |
-
|
11438 |
-
|
11439 |
-
|
11440 |
-
|
11441 |
-
|
11442 |
-
|
11443 |
-
|
11444 |
-
|
11445 |
-
}
|
11446 |
-
|
11447 |
-
if ( $this->
|
11448 |
-
|
11449 |
-
|
11450 |
-
|
11451 |
-
|
11452 |
-
|
11453 |
-
|
11454 |
-
|
11455 |
-
|
11456 |
-
|
11457 |
-
|
11458 |
-
|
11459 |
-
|
11460 |
-
|
11461 |
-
|
11462 |
-
|
11463 |
-
|
11464 |
-
|
11465 |
-
|
11466 |
-
|
11467 |
-
|
11468 |
-
|
11469 |
-
|
11470 |
-
|
11471 |
-
|
11472 |
-
|
11473 |
-
|
11474 |
-
|
11475 |
-
|
11476 |
-
|
11477 |
-
|
11478 |
-
|
11479 |
-
|
11480 |
-
|
11481 |
-
|
11482 |
-
|
11483 |
-
|
11484 |
-
|
11485 |
-
|
11486 |
-
|
11487 |
-
|
11488 |
-
|
11489 |
-
|
11490 |
-
|
11491 |
-
|
11492 |
-
|
11493 |
-
|
11494 |
-
|
11495 |
-
|
11496 |
-
|
11497 |
-
|
11498 |
-
|
11499 |
-
|
11500 |
-
|
11501 |
-
|
11502 |
-
|
11503 |
-
|
11504 |
-
|
11505 |
-
|
11506 |
-
|
11507 |
-
|
11508 |
-
|
11509 |
-
|
11510 |
-
|
11511 |
-
|
11512 |
-
|
11513 |
-
|
11514 |
-
|
11515 |
-
|
11516 |
-
|
11517 |
-
|
11518 |
-
$
|
11519 |
-
|
11520 |
-
|
11521 |
-
|
11522 |
-
|
11523 |
-
|
11524 |
-
|
11525 |
-
|
11526 |
-
|
11527 |
-
|
11528 |
-
|
11529 |
-
|
11530 |
-
|
11531 |
-
|
11532 |
-
|
11533 |
-
|
11534 |
-
|
11535 |
-
|
11536 |
-
|
11537 |
-
|
11538 |
-
|
11539 |
-
|
11540 |
-
|
11541 |
-
|
11542 |
-
|
11543 |
-
|
11544 |
-
|
11545 |
-
|
11546 |
-
|
11547 |
-
|
11548 |
-
|
11549 |
-
|
11550 |
-
|
11551 |
-
|
11552 |
-
|
11553 |
-
|
11554 |
-
|
11555 |
-
|
11556 |
-
|
11557 |
-
|
11558 |
-
|
11559 |
-
|
11560 |
-
|
11561 |
-
|
11562 |
-
|
11563 |
-
|
11564 |
-
|
11565 |
-
|
11566 |
-
|
11567 |
-
|
11568 |
-
|
11569 |
-
|
11570 |
-
|
11571 |
-
|
11572 |
-
|
11573 |
-
|
11574 |
-
|
11575 |
-
|
11576 |
-
//
|
11577 |
-
|
11578 |
-
|
11579 |
-
|
11580 |
-
|
11581 |
-
|
11582 |
-
|
11583 |
-
|
11584 |
-
|
11585 |
-
|
11586 |
-
|
11587 |
-
|
11588 |
-
|
11589 |
-
|
11590 |
-
|
11591 |
-
|
11592 |
-
|
11593 |
-
|
11594 |
-
|
11595 |
-
|
11596 |
-
|
11597 |
-
|
11598 |
-
|
11599 |
-
|
11600 |
-
|
11601 |
-
|
11602 |
-
|
11603 |
-
|
11604 |
-
|
11605 |
-
|
11606 |
-
|
11607 |
-
|
11608 |
-
|
11609 |
-
|
11610 |
-
|
11611 |
-
|
11612 |
-
|
11613 |
-
* @author Vova Feldman (@svovaf)
|
11614 |
-
* @since 1.
|
11615 |
-
*
|
11616 |
-
* @param
|
11617 |
-
*
|
11618 |
-
* @
|
11619 |
-
|
11620 |
-
|
11621 |
-
|
11622 |
-
|
11623 |
-
|
11624 |
-
|
11625 |
-
|
11626 |
-
|
11627 |
-
|
11628 |
-
|
11629 |
-
|
11630 |
-
|
11631 |
-
|
11632 |
-
|
11633 |
-
|
11634 |
-
|
11635 |
-
|
11636 |
-
|
11637 |
-
|
11638 |
-
|
11639 |
-
|
11640 |
-
|
11641 |
-
|
11642 |
-
|
11643 |
-
|
11644 |
-
|
11645 |
-
|
11646 |
-
|
11647 |
-
|
11648 |
-
$
|
11649 |
-
|
11650 |
-
|
11651 |
-
if (
|
11652 |
-
|
11653 |
-
|
11654 |
-
$this->
|
11655 |
-
|
11656 |
-
|
11657 |
-
|
11658 |
-
|
11659 |
-
|
11660 |
-
|
11661 |
-
|
11662 |
-
|
11663 |
-
|
11664 |
-
|
11665 |
-
|
11666 |
-
|
11667 |
-
'
|
11668 |
-
);
|
11669 |
-
|
11670 |
-
|
11671 |
-
|
11672 |
-
|
11673 |
-
|
11674 |
-
|
11675 |
-
|
11676 |
-
|
11677 |
-
|
11678 |
-
|
11679 |
-
|
11680 |
-
|
11681 |
-
|
11682 |
-
|
11683 |
-
|
11684 |
-
|
11685 |
-
|
11686 |
-
|
11687 |
-
|
11688 |
-
|
11689 |
-
|
11690 |
-
|
11691 |
-
|
11692 |
-
|
11693 |
-
|
11694 |
-
|
11695 |
-
|
11696 |
-
|
11697 |
-
|
11698 |
-
|
11699 |
-
|
11700 |
-
|
11701 |
-
|
11702 |
-
|
11703 |
-
|
11704 |
-
|
11705 |
-
|
11706 |
-
|
11707 |
-
|
11708 |
-
|
11709 |
-
|
11710 |
-
|
11711 |
-
|
11712 |
-
|
11713 |
-
|
11714 |
-
|
11715 |
-
|
11716 |
-
|
11717 |
-
|
11718 |
-
|
11719 |
-
|
11720 |
-
|
11721 |
-
|
11722 |
-
|
11723 |
-
|
11724 |
-
if ( ! $this->
|
11725 |
-
|
11726 |
-
|
11727 |
-
|
11728 |
-
|
11729 |
-
|
11730 |
-
|
11731 |
-
return;
|
11732 |
-
}
|
11733 |
-
|
11734 |
-
|
11735 |
-
|
11736 |
-
|
11737 |
-
|
11738 |
-
|
11739 |
-
|
11740 |
-
|
11741 |
-
|
11742 |
-
|
11743 |
-
|
11744 |
-
$this->
|
11745 |
-
|
11746 |
-
|
11747 |
-
|
11748 |
-
|
11749 |
-
|
11750 |
-
|
11751 |
-
|
11752 |
-
|
11753 |
-
|
11754 |
-
|
11755 |
-
|
11756 |
-
|
11757 |
-
|
11758 |
-
|
11759 |
-
|
11760 |
-
}
|
11761 |
-
|
11762 |
-
|
11763 |
-
|
11764 |
-
|
11765 |
-
|
11766 |
-
|
11767 |
-
|
11768 |
-
|
11769 |
-
|
11770 |
-
|
11771 |
-
|
11772 |
-
|
11773 |
-
|
11774 |
-
|
11775 |
-
|
11776 |
-
|
11777 |
-
|
11778 |
-
|
11779 |
-
|
11780 |
-
|
11781 |
-
|
11782 |
-
|
11783 |
-
|
11784 |
-
|
11785 |
-
|
11786 |
-
|
11787 |
-
|
11788 |
-
|
11789 |
-
|
11790 |
-
|
11791 |
-
|
11792 |
-
|
11793 |
-
|
11794 |
-
|
11795 |
-
|
11796 |
-
|
11797 |
-
|
11798 |
-
|
11799 |
-
|
11800 |
-
|
11801 |
-
|
11802 |
-
|
11803 |
-
|
11804 |
-
|
11805 |
-
|
11806 |
-
|
11807 |
-
|
11808 |
-
|
11809 |
-
|
11810 |
-
|
11811 |
-
|
11812 |
-
|
11813 |
-
|
11814 |
-
|
11815 |
-
|
11816 |
-
|
11817 |
-
|
11818 |
-
|
11819 |
-
|
11820 |
-
|
11821 |
-
|
11822 |
-
*
|
11823 |
-
*
|
11824 |
-
*
|
11825 |
-
* @
|
11826 |
-
*/
|
11827 |
-
function
|
11828 |
-
|
11829 |
-
|
11830 |
-
|
11831 |
-
|
11832 |
-
|
11833 |
-
|
11834 |
-
|
11835 |
-
|
11836 |
-
|
11837 |
-
|
11838 |
-
|
11839 |
-
|
11840 |
-
|
11841 |
-
|
11842 |
-
|
11843 |
-
|
11844 |
-
|
11845 |
-
|
11846 |
-
|
11847 |
-
$this->
|
11848 |
-
|
11849 |
-
|
11850 |
-
|
11851 |
-
$
|
11852 |
-
|
11853 |
-
|
11854 |
-
|
11855 |
-
|
11856 |
-
|
11857 |
-
|
11858 |
-
|
11859 |
-
|
11860 |
-
|
11861 |
-
|
11862 |
-
|
11863 |
-
|
11864 |
-
|
11865 |
-
|
11866 |
-
|
11867 |
-
|
11868 |
-
|
11869 |
-
|
11870 |
-
|
11871 |
-
|
11872 |
-
|
11873 |
-
|
11874 |
-
|
11875 |
-
|
11876 |
-
|
11877 |
-
|
11878 |
-
|
11879 |
-
|
11880 |
-
|
11881 |
-
|
11882 |
-
|
11883 |
-
|
11884 |
-
|
11885 |
-
|
11886 |
-
|
11887 |
-
return
|
11888 |
-
}
|
11889 |
-
|
11890 |
-
|
11891 |
-
|
11892 |
-
|
11893 |
-
|
11894 |
-
|
11895 |
-
*
|
11896 |
-
*
|
11897 |
-
*
|
11898 |
-
*
|
11899 |
-
|
11900 |
-
|
11901 |
-
|
11902 |
-
|
11903 |
-
|
11904 |
-
|
11905 |
-
*
|
11906 |
-
*
|
11907 |
-
* @
|
11908 |
-
|
11909 |
-
|
11910 |
-
|
11911 |
-
|
11912 |
-
|
11913 |
-
|
11914 |
-
|
11915 |
-
|
11916 |
-
|
11917 |
-
|
11918 |
-
|
11919 |
-
|
11920 |
-
*
|
11921 |
-
*
|
11922 |
-
*
|
11923 |
-
*
|
11924 |
-
|
11925 |
-
|
11926 |
-
|
11927 |
-
|
11928 |
-
|
11929 |
-
|
11930 |
-
|
11931 |
-
|
11932 |
-
|
11933 |
-
|
11934 |
-
|
11935 |
-
|
11936 |
-
|
11937 |
-
|
11938 |
-
|
11939 |
-
|
11940 |
-
|
11941 |
-
|
11942 |
-
|
11943 |
-
|
11944 |
-
|
11945 |
-
|
11946 |
-
|
11947 |
-
$
|
11948 |
-
|
11949 |
-
|
11950 |
-
|
11951 |
-
|
11952 |
-
|
11953 |
-
|
11954 |
-
|
11955 |
-
|
11956 |
-
|
11957 |
-
|
11958 |
-
|
11959 |
-
|
11960 |
-
|
11961 |
-
|
11962 |
-
|
11963 |
-
|
11964 |
-
|
11965 |
-
|
11966 |
-
|
11967 |
-
|
11968 |
-
|
11969 |
-
|
11970 |
-
|
11971 |
-
*
|
11972 |
-
*
|
11973 |
-
* @author Vova Feldman (@svovaf)
|
11974 |
-
* @since 1.0.
|
11975 |
-
*
|
11976 |
-
* @param bool
|
11977 |
-
*
|
11978 |
-
*
|
11979 |
-
|
11980 |
-
|
11981 |
-
|
11982 |
-
|
11983 |
-
|
11984 |
-
|
11985 |
-
|
11986 |
-
|
11987 |
-
|
11988 |
-
|
11989 |
-
|
11990 |
-
|
11991 |
-
|
11992 |
-
|
11993 |
-
|
11994 |
-
|
11995 |
-
|
11996 |
-
|
11997 |
-
|
11998 |
-
|
11999 |
-
|
12000 |
-
|
12001 |
-
|
12002 |
-
|
12003 |
-
|
12004 |
-
|
12005 |
-
|
12006 |
-
|
12007 |
-
|
12008 |
-
|
12009 |
-
|
12010 |
-
|
12011 |
-
|
12012 |
-
|
12013 |
-
|
12014 |
-
|
12015 |
-
|
12016 |
-
|
12017 |
-
|
12018 |
-
|
12019 |
-
|
12020 |
-
|
12021 |
-
|
12022 |
-
|
12023 |
-
|
12024 |
-
|
12025 |
-
|
12026 |
-
|
12027 |
-
|
12028 |
-
|
12029 |
-
|
12030 |
-
|
12031 |
-
|
12032 |
-
|
12033 |
-
|
12034 |
-
|
12035 |
-
|
12036 |
-
|
12037 |
-
|
12038 |
-
|
12039 |
-
|
12040 |
-
|
12041 |
-
|
12042 |
-
|
12043 |
-
|
12044 |
-
|
12045 |
-
|
12046 |
-
|
12047 |
-
|
12048 |
-
|
12049 |
-
|
12050 |
-
|
12051 |
-
*
|
12052 |
-
*
|
12053 |
-
* @
|
12054 |
-
*
|
12055 |
-
*
|
12056 |
-
*
|
12057 |
-
|
12058 |
-
|
12059 |
-
|
12060 |
-
|
12061 |
-
|
12062 |
-
|
12063 |
-
|
12064 |
-
|
12065 |
-
|
12066 |
-
|
12067 |
-
|
12068 |
-
|
12069 |
-
|
12070 |
-
|
12071 |
-
|
12072 |
-
|
12073 |
-
|
12074 |
-
|
12075 |
-
|
12076 |
-
|
12077 |
-
|
12078 |
-
|
12079 |
-
|
12080 |
-
|
12081 |
-
|
12082 |
-
|
12083 |
-
|
12084 |
-
|
12085 |
-
|
12086 |
-
|
12087 |
-
|
12088 |
-
|
12089 |
-
|
12090 |
-
|
12091 |
-
|
12092 |
-
|
12093 |
-
|
12094 |
-
|
12095 |
-
|
12096 |
-
|
12097 |
-
|
12098 |
-
|
12099 |
-
|
12100 |
-
|
12101 |
-
*
|
12102 |
-
|
12103 |
-
|
12104 |
-
|
12105 |
-
|
12106 |
-
|
12107 |
-
|
12108 |
-
|
12109 |
-
|
12110 |
-
|
12111 |
-
|
12112 |
-
|
12113 |
-
|
12114 |
-
|
12115 |
-
|
12116 |
-
|
12117 |
-
|
12118 |
-
|
12119 |
-
|
12120 |
-
|
12121 |
-
|
12122 |
-
|
12123 |
-
|
12124 |
-
|
12125 |
-
|
12126 |
-
|
12127 |
-
|
12128 |
-
|
12129 |
-
|
12130 |
-
|
12131 |
-
|
12132 |
-
|
12133 |
-
|
12134 |
-
|
12135 |
-
|
12136 |
-
|
12137 |
-
|
12138 |
-
|
12139 |
-
|
12140 |
-
|
12141 |
-
|
12142 |
-
|
12143 |
-
|
12144 |
-
|
12145 |
-
|
12146 |
-
|
12147 |
-
|
12148 |
-
|
12149 |
-
|
12150 |
-
|
12151 |
-
|
12152 |
-
|
12153 |
-
|
12154 |
-
|
12155 |
-
|
12156 |
-
|
12157 |
-
|
12158 |
-
|
12159 |
-
|
12160 |
-
|
12161 |
-
|
12162 |
-
|
12163 |
-
|
12164 |
-
|
12165 |
-
|
12166 |
-
|
12167 |
-
|
12168 |
-
|
12169 |
-
|
12170 |
-
|
12171 |
-
|
12172 |
-
|
12173 |
-
|
12174 |
-
|
12175 |
-
|
12176 |
-
|
12177 |
-
|
12178 |
-
|
12179 |
-
|
12180 |
-
|
12181 |
-
|
12182 |
-
|
12183 |
-
|
12184 |
-
|
12185 |
-
|
12186 |
-
|
12187 |
-
|
12188 |
-
|
12189 |
-
|
12190 |
-
|
12191 |
-
|
12192 |
-
|
12193 |
-
|
12194 |
-
|
12195 |
-
|
12196 |
-
|
12197 |
-
|
12198 |
-
|
12199 |
-
*
|
12200 |
-
|
12201 |
-
|
12202 |
-
|
12203 |
-
|
12204 |
-
|
12205 |
-
|
12206 |
-
|
12207 |
-
|
12208 |
-
|
12209 |
-
|
12210 |
-
|
12211 |
-
|
12212 |
-
|
12213 |
-
|
12214 |
-
|
12215 |
-
|
12216 |
-
|
12217 |
-
|
12218 |
-
|
12219 |
-
|
12220 |
-
|
12221 |
-
|
12222 |
-
|
12223 |
-
|
12224 |
-
|
12225 |
-
|
12226 |
-
|
12227 |
-
|
12228 |
-
|
12229 |
-
|
12230 |
-
|
12231 |
-
|
12232 |
-
|
12233 |
-
|
12234 |
-
|
12235 |
-
|
12236 |
-
|
12237 |
-
|
12238 |
-
|
12239 |
-
|
12240 |
-
|
12241 |
-
|
12242 |
-
|
12243 |
-
|
12244 |
-
|
12245 |
-
|
12246 |
-
|
12247 |
-
|
12248 |
-
|
12249 |
-
|
12250 |
-
|
12251 |
-
|
12252 |
-
|
12253 |
-
|
12254 |
-
|
12255 |
-
|
12256 |
-
|
12257 |
-
|
12258 |
-
|
12259 |
-
|
12260 |
-
|
12261 |
-
|
12262 |
-
|
12263 |
-
|
12264 |
-
|
12265 |
-
|
12266 |
-
|
12267 |
-
|
12268 |
-
|
12269 |
-
|
12270 |
-
|
12271 |
-
|
12272 |
-
|
12273 |
-
|
12274 |
-
|
12275 |
-
|
12276 |
-
|
12277 |
-
|
12278 |
-
|
12279 |
-
|
12280 |
-
|
12281 |
-
|
12282 |
-
|
12283 |
-
|
12284 |
-
|
12285 |
-
|
12286 |
-
|
12287 |
-
|
12288 |
-
|
12289 |
-
*
|
12290 |
-
|
12291 |
-
|
12292 |
-
|
12293 |
-
|
12294 |
-
|
12295 |
-
|
12296 |
-
|
12297 |
-
|
12298 |
-
|
12299 |
-
|
12300 |
-
|
12301 |
-
|
12302 |
-
|
12303 |
-
|
12304 |
-
|
12305 |
-
|
12306 |
-
|
12307 |
-
|
12308 |
-
|
12309 |
-
|
12310 |
-
|
12311 |
-
|
12312 |
-
|
12313 |
-
|
12314 |
-
|
12315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.3
|
7 |
+
*/
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit;
|
10 |
+
}
|
11 |
+
|
12 |
+
// "final class"
|
13 |
+
class Freemius extends Freemius_Abstract {
|
14 |
+
/**
|
15 |
+
* SDK Version
|
16 |
+
*
|
17 |
+
* @var string
|
18 |
+
*/
|
19 |
+
public $version = WP_FS__SDK_VERSION;
|
20 |
+
|
21 |
+
#region Plugin Info
|
22 |
+
|
23 |
+
/**
|
24 |
+
* @since 1.0.1
|
25 |
+
*
|
26 |
+
* @var string
|
27 |
+
*/
|
28 |
+
private $_slug;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @since 1.0.0
|
32 |
+
*
|
33 |
+
* @var string
|
34 |
+
*/
|
35 |
+
private $_plugin_basename;
|
36 |
+
/**
|
37 |
+
* @since 1.0.0
|
38 |
+
*
|
39 |
+
* @var string
|
40 |
+
*/
|
41 |
+
private $_free_plugin_basename;
|
42 |
+
/**
|
43 |
+
* @since 1.0.0
|
44 |
+
*
|
45 |
+
* @var string
|
46 |
+
*/
|
47 |
+
private $_plugin_dir_path;
|
48 |
+
/**
|
49 |
+
* @since 1.0.0
|
50 |
+
*
|
51 |
+
* @var string
|
52 |
+
*/
|
53 |
+
private $_plugin_dir_name;
|
54 |
+
/**
|
55 |
+
* @since 1.0.0
|
56 |
+
*
|
57 |
+
* @var string
|
58 |
+
*/
|
59 |
+
private $_plugin_main_file_path;
|
60 |
+
/**
|
61 |
+
* @var string[]
|
62 |
+
*/
|
63 |
+
private $_plugin_data;
|
64 |
+
/**
|
65 |
+
* @since 1.0.9
|
66 |
+
*
|
67 |
+
* @var string
|
68 |
+
*/
|
69 |
+
private $_plugin_name;
|
70 |
+
/**
|
71 |
+
* @since 1.2.2
|
72 |
+
*
|
73 |
+
* @var string
|
74 |
+
*/
|
75 |
+
private $_module_type;
|
76 |
+
|
77 |
+
#endregion Plugin Info
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @since 1.0.9
|
81 |
+
*
|
82 |
+
* @var bool If false, don't turn Freemius on.
|
83 |
+
*/
|
84 |
+
private $_is_on;
|
85 |
+
|
86 |
+
/**
|
87 |
+
* @since 1.1.3
|
88 |
+
*
|
89 |
+
* @var bool If false, don't turn Freemius on.
|
90 |
+
*/
|
91 |
+
private $_is_anonymous;
|
92 |
+
|
93 |
+
/**
|
94 |
+
* @since 1.0.9
|
95 |
+
* @var bool If false, issues with connectivity to Freemius API.
|
96 |
+
*/
|
97 |
+
private $_has_api_connection;
|
98 |
+
|
99 |
+
/**
|
100 |
+
* @since 1.0.9
|
101 |
+
* @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
|
102 |
+
*/
|
103 |
+
private $_enable_anonymous;
|
104 |
+
|
105 |
+
/**
|
106 |
+
* @since 1.1.7.5
|
107 |
+
* @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
|
108 |
+
*/
|
109 |
+
private $_anonymous_mode;
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @since 1.1.9
|
113 |
+
* @var bool Hints the SDK if plugin have any free plans.
|
114 |
+
*/
|
115 |
+
private $_is_premium_only;
|
116 |
+
|
117 |
+
/**
|
118 |
+
* @since 1.2.1.6
|
119 |
+
* @var bool Hints the SDK if plugin have premium code version at all.
|
120 |
+
*/
|
121 |
+
private $_has_premium_version;
|
122 |
+
|
123 |
+
/**
|
124 |
+
* @since 1.2.1.6
|
125 |
+
* @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
|
126 |
+
*/
|
127 |
+
private $_ignore_pending_mode;
|
128 |
+
|
129 |
+
/**
|
130 |
+
* @since 1.0.8
|
131 |
+
* @var bool Hints the SDK if the plugin has any paid plans.
|
132 |
+
*/
|
133 |
+
private $_has_paid_plans;
|
134 |
+
|
135 |
+
/**
|
136 |
+
* @since 1.2.1.5
|
137 |
+
* @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
|
138 |
+
* without a specified period, if positive - the number of trial days.
|
139 |
+
*/
|
140 |
+
private $_trial_days = - 1;
|
141 |
+
|
142 |
+
/**
|
143 |
+
* @since 1.2.1.5
|
144 |
+
* @var bool Hints the SDK if the trial requires a payment method or not.
|
145 |
+
*/
|
146 |
+
private $_is_trial_require_payment = false;
|
147 |
+
|
148 |
+
/**
|
149 |
+
* @since 1.0.7
|
150 |
+
* @var bool Hints the SDK if the plugin is WordPress.org compliant.
|
151 |
+
*/
|
152 |
+
private $_is_org_compliant;
|
153 |
+
|
154 |
+
/**
|
155 |
+
* @since 1.0.7
|
156 |
+
* @var bool Hints the SDK if the plugin is has add-ons.
|
157 |
+
*/
|
158 |
+
private $_has_addons;
|
159 |
+
|
160 |
+
/**
|
161 |
+
* @since 1.1.6
|
162 |
+
* @var string[]bool.
|
163 |
+
*/
|
164 |
+
private $_permissions;
|
165 |
+
|
166 |
+
/**
|
167 |
+
* @var FS_Key_Value_Storage
|
168 |
+
*/
|
169 |
+
private $_storage;
|
170 |
+
|
171 |
+
/**
|
172 |
+
* @since 1.2.2.7
|
173 |
+
* @var FS_Cache_Manager
|
174 |
+
*/
|
175 |
+
private $_cache;
|
176 |
+
|
177 |
+
/**
|
178 |
+
* @since 1.0.0
|
179 |
+
*
|
180 |
+
* @var FS_Logger
|
181 |
+
*/
|
182 |
+
private $_logger;
|
183 |
+
/**
|
184 |
+
* @since 1.0.4
|
185 |
+
*
|
186 |
+
* @var FS_Plugin
|
187 |
+
*/
|
188 |
+
private $_plugin = false;
|
189 |
+
/**
|
190 |
+
* @since 1.0.4
|
191 |
+
*
|
192 |
+
* @var FS_Plugin|false
|
193 |
+
*/
|
194 |
+
private $_parent_plugin = false;
|
195 |
+
/**
|
196 |
+
* @since 1.1.1
|
197 |
+
*
|
198 |
+
* @var Freemius
|
199 |
+
*/
|
200 |
+
private $_parent = false;
|
201 |
+
/**
|
202 |
+
* @since 1.0.1
|
203 |
+
*
|
204 |
+
* @var FS_User
|
205 |
+
*/
|
206 |
+
private $_user = false;
|
207 |
+
/**
|
208 |
+
* @since 1.0.1
|
209 |
+
*
|
210 |
+
* @var FS_Site
|
211 |
+
*/
|
212 |
+
private $_site = false;
|
213 |
+
/**
|
214 |
+
* @since 1.0.1
|
215 |
+
*
|
216 |
+
* @var FS_Plugin_License
|
217 |
+
*/
|
218 |
+
private $_license;
|
219 |
+
/**
|
220 |
+
* @since 1.0.2
|
221 |
+
*
|
222 |
+
* @var FS_Plugin_Plan[]
|
223 |
+
*/
|
224 |
+
private $_plans = false;
|
225 |
+
/**
|
226 |
+
* @var FS_Plugin_License[]
|
227 |
+
* @since 1.0.5
|
228 |
+
*/
|
229 |
+
private $_licenses = false;
|
230 |
+
|
231 |
+
/**
|
232 |
+
* @since 1.0.1
|
233 |
+
*
|
234 |
+
* @var FS_Admin_Menu_Manager
|
235 |
+
*/
|
236 |
+
private $_menu;
|
237 |
+
|
238 |
+
/**
|
239 |
+
* @var FS_Admin_Notice_Manager
|
240 |
+
*/
|
241 |
+
private $_admin_notices;
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @since 1.1.6
|
245 |
+
*
|
246 |
+
* @var FS_Admin_Notice_Manager
|
247 |
+
*/
|
248 |
+
private static $_global_admin_notices;
|
249 |
+
|
250 |
+
/**
|
251 |
+
* @var FS_Logger
|
252 |
+
* @since 1.0.0
|
253 |
+
*/
|
254 |
+
private static $_static_logger;
|
255 |
+
|
256 |
+
/**
|
257 |
+
* @var FS_Option_Manager
|
258 |
+
* @since 1.0.2
|
259 |
+
*/
|
260 |
+
private static $_accounts;
|
261 |
+
|
262 |
+
/**
|
263 |
+
* @since 1.2.2
|
264 |
+
*
|
265 |
+
* @var number
|
266 |
+
*/
|
267 |
+
private $_module_id;
|
268 |
+
|
269 |
+
/**
|
270 |
+
* @var Freemius[]
|
271 |
+
*/
|
272 |
+
private static $_instances = array();
|
273 |
+
|
274 |
+
/**
|
275 |
+
* @author Leo Fajardo (@leorw)
|
276 |
+
*
|
277 |
+
* @since 1.2.3
|
278 |
+
*
|
279 |
+
* @var FS_Affiliate
|
280 |
+
*/
|
281 |
+
private $affiliate = null;
|
282 |
+
|
283 |
+
/**
|
284 |
+
* @author Leo Fajardo (@leorw)
|
285 |
+
*
|
286 |
+
* @since 1.2.3
|
287 |
+
*
|
288 |
+
* @var FS_AffiliateTerms
|
289 |
+
*/
|
290 |
+
private $plugin_affiliate_terms = null;
|
291 |
+
|
292 |
+
/**
|
293 |
+
* @author Leo Fajardo (@leorw)
|
294 |
+
*
|
295 |
+
* @since 1.2.3
|
296 |
+
*
|
297 |
+
* @var FS_AffiliateTerms
|
298 |
+
*/
|
299 |
+
private $custom_affiliate_terms = null;
|
300 |
+
|
301 |
+
#region Uninstall Reasons IDs
|
302 |
+
|
303 |
+
const REASON_NO_LONGER_NEEDED = 1;
|
304 |
+
const REASON_FOUND_A_BETTER_PLUGIN = 2;
|
305 |
+
const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
|
306 |
+
const REASON_BROKE_MY_SITE = 4;
|
307 |
+
const REASON_SUDDENLY_STOPPED_WORKING = 5;
|
308 |
+
const REASON_CANT_PAY_ANYMORE = 6;
|
309 |
+
const REASON_OTHER = 7;
|
310 |
+
const REASON_DIDNT_WORK = 8;
|
311 |
+
const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
|
312 |
+
const REASON_COULDNT_MAKE_IT_WORK = 10;
|
313 |
+
const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
|
314 |
+
const REASON_NOT_WORKING = 12;
|
315 |
+
const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
|
316 |
+
const REASON_DIDNT_WORK_AS_EXPECTED = 14;
|
317 |
+
const REASON_TEMPORARY_DEACTIVATION = 15;
|
318 |
+
|
319 |
+
#endregion
|
320 |
+
|
321 |
+
/* Ctor
|
322 |
+
------------------------------------------------------------------------------------------------------------------*/
|
323 |
+
|
324 |
+
/**
|
325 |
+
* Main singleton instance.
|
326 |
+
*
|
327 |
+
* @author Vova Feldman (@svovaf)
|
328 |
+
* @since 1.0.0
|
329 |
+
*
|
330 |
+
* @param number $module_id
|
331 |
+
* @param string|bool $slug
|
332 |
+
* @param bool $is_init Since 1.2.1 Is initiation sequence.
|
333 |
+
*/
|
334 |
+
private function __construct( $module_id, $slug = false, $is_init = false ) {
|
335 |
+
if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
|
336 |
+
$this->store_id_slug_type_path_map( $module_id, $slug );
|
337 |
+
}
|
338 |
+
|
339 |
+
$this->_module_id = $module_id;
|
340 |
+
$this->_slug = $this->get_slug();
|
341 |
+
$this->_module_type = $this->get_module_type();
|
342 |
+
|
343 |
+
$this->_storage = FS_Key_Value_Storage::instance( $this->_module_type . '_data', $this->_slug );
|
344 |
+
$this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
|
345 |
+
|
346 |
+
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
347 |
+
|
348 |
+
$this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
|
349 |
+
$this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
|
350 |
+
$this->_plugin_basename = $this->get_plugin_basename();
|
351 |
+
$this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
|
352 |
+
|
353 |
+
$base_name_split = explode( '/', $this->_plugin_basename );
|
354 |
+
$this->_plugin_dir_name = $base_name_split[0];
|
355 |
+
|
356 |
+
if ( $this->_logger->is_on() ) {
|
357 |
+
$this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
|
358 |
+
$this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
|
359 |
+
$this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
|
360 |
+
$this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
|
361 |
+
$this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
|
362 |
+
}
|
363 |
+
|
364 |
+
// Remember link between file to slug.
|
365 |
+
$this->store_file_slug_map();
|
366 |
+
|
367 |
+
// Store plugin's initial install timestamp.
|
368 |
+
if ( ! isset( $this->_storage->install_timestamp ) ) {
|
369 |
+
$this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
|
370 |
+
}
|
371 |
+
|
372 |
+
if ( ! is_object( $this->_plugin ) ) {
|
373 |
+
$this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
|
374 |
+
}
|
375 |
+
|
376 |
+
$this->_admin_notices = FS_Admin_Notice_Manager::instance(
|
377 |
+
$this->_slug . ( $this->is_theme() ? ':theme' : '' ),
|
378 |
+
/**
|
379 |
+
* Ensure that the admin notice will always have a title by using the stored plugin title if available and
|
380 |
+
* retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
|
381 |
+
*
|
382 |
+
* @author Leo Fajardo (@leorw)
|
383 |
+
* @since 1.2.2
|
384 |
+
*/
|
385 |
+
( is_object( $this->_plugin ) ? $this->_plugin->title : $this->get_plugin_name() ),
|
386 |
+
$this->get_unique_affix()
|
387 |
+
);
|
388 |
+
|
389 |
+
if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
|
390 |
+
'true' === fs_request_is_action( 'restart_freemius' )
|
391 |
+
) {
|
392 |
+
FS_Api::clear_cache();
|
393 |
+
$this->_cache->clear();
|
394 |
+
}
|
395 |
+
|
396 |
+
$this->_register_hooks();
|
397 |
+
|
398 |
+
$this->_load_account();
|
399 |
+
|
400 |
+
$this->_version_updates_handler();
|
401 |
+
}
|
402 |
+
|
403 |
+
/**
|
404 |
+
* Checks whether this module has a settings menu.
|
405 |
+
*
|
406 |
+
* @author Leo Fajardo (@leorw)
|
407 |
+
* @since 1.2.2
|
408 |
+
*
|
409 |
+
* @return bool
|
410 |
+
*/
|
411 |
+
function has_settings_menu() {
|
412 |
+
return $this->_menu->has_menu();
|
413 |
+
}
|
414 |
+
|
415 |
+
/**
|
416 |
+
* Check if the context module is free wp.org theme.
|
417 |
+
*
|
418 |
+
* This method is helpful because:
|
419 |
+
* 1. wp.org themes are limited to a single submenu item,
|
420 |
+
* and sub-submenu items are most likely not allowed (never verified).
|
421 |
+
* 2. wp.org themes are not allowed to redirect the user
|
422 |
+
* after the theme activation, therefore, the agreed UX
|
423 |
+
* is showing the opt-in as a modal dialog box after
|
424 |
+
* activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
|
425 |
+
*
|
426 |
+
* @author Vova Feldman (@svovaf)
|
427 |
+
* @since 1.2.2.7
|
428 |
+
*
|
429 |
+
* @return bool
|
430 |
+
*/
|
431 |
+
function is_free_wp_org_theme() {
|
432 |
+
return (
|
433 |
+
$this->is_theme() &&
|
434 |
+
$this->is_org_repo_compliant() &&
|
435 |
+
! $this->is_premium()
|
436 |
+
);
|
437 |
+
}
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Checks whether this a submenu item is visible.
|
441 |
+
*
|
442 |
+
* @author Vova Feldman (@svovaf)
|
443 |
+
* @since 1.2.2.6
|
444 |
+
* @since 1.2.2.7 Even if the menu item was specified to be hidden, when it is the context page, then show the submenu item so the user will have the right context page.
|
445 |
+
*
|
446 |
+
* @param string $slug
|
447 |
+
*
|
448 |
+
* @return bool
|
449 |
+
*/
|
450 |
+
function is_submenu_item_visible( $slug ) {
|
451 |
+
if ( $this->is_admin_page( $slug ) ) {
|
452 |
+
/**
|
453 |
+
* It is the current context page, so show the submenu item
|
454 |
+
* so the user will have the right context page, even if it
|
455 |
+
* was set to hidden.
|
456 |
+
*/
|
457 |
+
return true;
|
458 |
+
}
|
459 |
+
|
460 |
+
if ( ! $this->has_settings_menu() ) {
|
461 |
+
// No menu settings at all.
|
462 |
+
return false;
|
463 |
+
}
|
464 |
+
|
465 |
+
if ( $this->is_free_wp_org_theme() ) {
|
466 |
+
/**
|
467 |
+
* wp.org themes are limited to a single submenu item, and
|
468 |
+
* sub-submenu items are most likely not allowed (never verified).
|
469 |
+
*/
|
470 |
+
return false;
|
471 |
+
}
|
472 |
+
|
473 |
+
return $this->_menu->is_submenu_item_visible( $slug );
|
474 |
+
}
|
475 |
+
|
476 |
+
/**
|
477 |
+
* Check if a Freemius page should be accessible via the UI.
|
478 |
+
*
|
479 |
+
* @author Vova Feldman (@svovaf)
|
480 |
+
* @since 1.2.2.7
|
481 |
+
*
|
482 |
+
* @param string $slug
|
483 |
+
*
|
484 |
+
* @return bool
|
485 |
+
*/
|
486 |
+
function is_page_visible( $slug ) {
|
487 |
+
if ( $this->is_admin_page( $slug ) ) {
|
488 |
+
return true;
|
489 |
+
}
|
490 |
+
|
491 |
+
return $this->_menu->is_submenu_item_visible( $slug, true, true );
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* @author Vova Feldman (@svovaf)
|
496 |
+
* @since 1.0.9
|
497 |
+
*/
|
498 |
+
private function _version_updates_handler() {
|
499 |
+
if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
|
500 |
+
// Freemius version upgrade mode.
|
501 |
+
$this->_storage->sdk_last_version = $this->_storage->sdk_version;
|
502 |
+
$this->_storage->sdk_version = $this->version;
|
503 |
+
|
504 |
+
if ( empty( $this->_storage->sdk_last_version ) ||
|
505 |
+
version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
|
506 |
+
) {
|
507 |
+
$this->_storage->sdk_upgrade_mode = true;
|
508 |
+
$this->_storage->sdk_downgrade_mode = false;
|
509 |
+
} else {
|
510 |
+
$this->_storage->sdk_downgrade_mode = true;
|
511 |
+
$this->_storage->sdk_upgrade_mode = false;
|
512 |
+
|
513 |
+
}
|
514 |
+
|
515 |
+
$this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
|
516 |
+
}
|
517 |
+
|
518 |
+
$plugin_version = $this->get_plugin_version();
|
519 |
+
if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
|
520 |
+
// Plugin version upgrade mode.
|
521 |
+
$this->_storage->plugin_last_version = $this->_storage->plugin_version;
|
522 |
+
$this->_storage->plugin_version = $plugin_version;
|
523 |
+
|
524 |
+
if ( empty( $this->_storage->plugin_last_version ) ||
|
525 |
+
version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
|
526 |
+
) {
|
527 |
+
$this->_storage->plugin_upgrade_mode = true;
|
528 |
+
$this->_storage->plugin_downgrade_mode = false;
|
529 |
+
} else {
|
530 |
+
$this->_storage->plugin_downgrade_mode = true;
|
531 |
+
$this->_storage->plugin_upgrade_mode = false;
|
532 |
+
}
|
533 |
+
|
534 |
+
if ( ! empty( $this->_storage->plugin_last_version ) ) {
|
535 |
+
// Different version of the plugin was installed before, therefore it's an update.
|
536 |
+
$this->_storage->is_plugin_new_install = false;
|
537 |
+
}
|
538 |
+
|
539 |
+
$this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
|
540 |
+
}
|
541 |
+
}
|
542 |
+
|
543 |
+
/**
|
544 |
+
* @author Vova Feldman (@svovaf)
|
545 |
+
* @since 1.1.5
|
546 |
+
*
|
547 |
+
* @param string $sdk_prev_version
|
548 |
+
* @param string $sdk_version
|
549 |
+
*/
|
550 |
+
function _data_migration( $sdk_prev_version, $sdk_version ) {
|
551 |
+
/**
|
552 |
+
* @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
|
553 |
+
*/
|
554 |
+
if ( empty( $sdk_prev_version ) ) {
|
555 |
+
return;
|
556 |
+
}
|
557 |
+
|
558 |
+
if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
|
559 |
+
version_compare( $sdk_version, '1.2.3', '>=' )
|
560 |
+
) {
|
561 |
+
/**
|
562 |
+
* Starting from version 1.2.3, paths are stored as relative paths and not absolute paths; so when
|
563 |
+
* upgrading to 1.2.3, make paths relative.
|
564 |
+
*
|
565 |
+
* @author Leo Fajardo (@leorw)
|
566 |
+
*/
|
567 |
+
$this->make_paths_relative();
|
568 |
+
}
|
569 |
+
|
570 |
+
if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
|
571 |
+
version_compare( $sdk_version, '1.1.5', '>=' )
|
572 |
+
) {
|
573 |
+
// On version 1.1.5 merged connectivity and is_on data.
|
574 |
+
if ( isset( $this->_storage->connectivity_test ) ) {
|
575 |
+
if ( ! isset( $this->_storage->is_on ) ) {
|
576 |
+
unset( $this->_storage->connectivity_test );
|
577 |
+
} else {
|
578 |
+
$connectivity_data = $this->_storage->connectivity_test;
|
579 |
+
$connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
|
580 |
+
$connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
|
581 |
+
|
582 |
+
// Override.
|
583 |
+
$this->_storage->connectivity_test = $connectivity_data;
|
584 |
+
|
585 |
+
// Remove previous structure.
|
586 |
+
unset( $this->_storage->is_on );
|
587 |
+
}
|
588 |
+
|
589 |
+
}
|
590 |
+
}
|
591 |
+
}
|
592 |
+
|
593 |
+
/**
|
594 |
+
* Makes paths relative.
|
595 |
+
*
|
596 |
+
* @author Leo Fajardo
|
597 |
+
* @since 1.2.3
|
598 |
+
*/
|
599 |
+
private function make_paths_relative() {
|
600 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
601 |
+
|
602 |
+
if ( isset( $id_slug_type_path_map[ $this->_module_id ]['path'] ) ) {
|
603 |
+
$id_slug_type_path_map[ $this->_module_id ]['path'] = $this->get_relative_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
|
604 |
+
|
605 |
+
self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
|
606 |
+
}
|
607 |
+
|
608 |
+
if ( isset( $this->_storage->plugin_main_file ) ) {
|
609 |
+
$plugin_main_file = $this->_storage->plugin_main_file;
|
610 |
+
|
611 |
+
if ( isset( $plugin_main_file->path ) ) {
|
612 |
+
$this->_storage->plugin_main_file->path = $this->get_relative_path( $this->_storage->plugin_main_file->path );
|
613 |
+
} else if ( isset( $plugin_main_file->prev_path ) ) {
|
614 |
+
$this->_storage->plugin_main_file->prev_path = $this->get_relative_path( $this->_storage->plugin_main_file->prev_path );
|
615 |
+
}
|
616 |
+
}
|
617 |
+
|
618 |
+
// Remove invalid path that is still associated with the current slug if there's any.
|
619 |
+
$file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
|
620 |
+
foreach ( $file_slug_map as $plugin_basename => $slug ) {
|
621 |
+
if ( $slug === $this->_slug &&
|
622 |
+
$plugin_basename !== $this->_plugin_basename &&
|
623 |
+
! file_exists( $this->get_absolute_path( $plugin_basename ) )
|
624 |
+
) {
|
625 |
+
unset( $file_slug_map[ $plugin_basename ] );
|
626 |
+
self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
|
627 |
+
|
628 |
+
break;
|
629 |
+
}
|
630 |
+
}
|
631 |
+
}
|
632 |
+
|
633 |
+
/**
|
634 |
+
* @author Vova Feldman (@svovaf)
|
635 |
+
* @since 1.2.2.7
|
636 |
+
*
|
637 |
+
* @param string $plugin_prev_version
|
638 |
+
* @param string $plugin_version
|
639 |
+
*/
|
640 |
+
function _after_version_update( $plugin_prev_version, $plugin_version ) {
|
641 |
+
if ( $this->is_theme() ) {
|
642 |
+
// Expire the cache of the previous tabs since the theme may
|
643 |
+
// have setting updates.
|
644 |
+
$this->_cache->expire( 'tabs' );
|
645 |
+
$this->_cache->expire( 'tabs_stylesheets' );
|
646 |
+
}
|
647 |
+
}
|
648 |
+
|
649 |
+
/**
|
650 |
+
* This action is connected to the 'plugins_loaded' hook and helps to determine
|
651 |
+
* if this is a new plugin installation or a plugin update.
|
652 |
+
*
|
653 |
+
* There are 3 different use-cases:
|
654 |
+
* 1) New plugin installation right with Freemius:
|
655 |
+
* 1.1 _activate_plugin_event_hook() will be executed first
|
656 |
+
* 1.2 Since $this->_storage->is_plugin_new_install is not set,
|
657 |
+
* and $this->_storage->plugin_last_version is not set,
|
658 |
+
* $this->_storage->is_plugin_new_install will be set to TRUE.
|
659 |
+
* 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
|
660 |
+
* be already set to TRUE.
|
661 |
+
*
|
662 |
+
* 2) Plugin update, didn't have Freemius before, and now have the SDK:
|
663 |
+
* 2.1 _activate_plugin_event_hook() will not be executed, because
|
664 |
+
* the activation hook do NOT fires on updates since WP 3.1.
|
665 |
+
* 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
|
666 |
+
* be empty, therefore, it will be set to FALSE.
|
667 |
+
*
|
668 |
+
* 3) Plugin update, had Freemius in prev version as well:
|
669 |
+
* 3.1 _version_updates_handler() will be executed 1st, since FS was installed
|
670 |
+
* before, $this->_storage->plugin_last_version will NOT be empty,
|
671 |
+
* therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
|
672 |
+
* 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
|
673 |
+
* already set, therefore, it will not be modified.
|
674 |
+
*
|
675 |
+
* Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
|
676 |
+
*
|
677 |
+
* NOTE:
|
678 |
+
* The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
|
679 |
+
* and then, the next immediate PageView is the plugin's main settings page, it will not
|
680 |
+
* show the opt-in right away. The reason it will happen is because Freemius execution
|
681 |
+
* will be turned off till the plugin is fully loaded at least once
|
682 |
+
* (till $this->_storage->was_plugin_loaded is TRUE).
|
683 |
+
*
|
684 |
+
* @author Vova Feldman (@svovaf)
|
685 |
+
* @since 1.1.9
|
686 |
+
*
|
687 |
+
*/
|
688 |
+
function _plugins_loaded() {
|
689 |
+
// Update flag that plugin was loaded with Freemius at least once.
|
690 |
+
$this->_storage->was_plugin_loaded = true;
|
691 |
+
|
692 |
+
/**
|
693 |
+
* Bug fix - only set to false when it's a plugin, due to the
|
694 |
+
* execution sequence of the theme hooks and our methods, if
|
695 |
+
* this will be set for themes, Freemius will always assume
|
696 |
+
* it's a theme update.
|
697 |
+
*
|
698 |
+
* @author Vova Feldman (@svovaf)
|
699 |
+
* @since 1.2.2.2
|
700 |
+
*/
|
701 |
+
if ( $this->is_plugin() &&
|
702 |
+
! isset( $this->_storage->is_plugin_new_install )
|
703 |
+
) {
|
704 |
+
$this->_storage->is_plugin_new_install = false;
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
/**
|
709 |
+
* @author Vova Feldman (@svovaf)
|
710 |
+
* @since 1.0.9
|
711 |
+
*/
|
712 |
+
private function _register_hooks() {
|
713 |
+
$this->_logger->entrance();
|
714 |
+
|
715 |
+
if ( is_admin() ) {
|
716 |
+
if ( $this->is_plugin() ) {
|
717 |
+
$plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
|
718 |
+
|
719 |
+
/**
|
720 |
+
* @since 1.2.2
|
721 |
+
*
|
722 |
+
* Hook to both free and premium version activations to support
|
723 |
+
* auto deactivation on the other version activation.
|
724 |
+
*/
|
725 |
+
register_activation_hook(
|
726 |
+
$plugin_dir . $this->_free_plugin_basename,
|
727 |
+
array( &$this, '_activate_plugin_event_hook' )
|
728 |
+
);
|
729 |
+
|
730 |
+
register_activation_hook(
|
731 |
+
$plugin_dir . $this->premium_plugin_basename(),
|
732 |
+
array( &$this, '_activate_plugin_event_hook' )
|
733 |
+
);
|
734 |
+
} else {
|
735 |
+
add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
|
736 |
+
|
737 |
+
/**
|
738 |
+
* Include the required hooks to capture the theme settings' page tabs
|
739 |
+
* and cache them.
|
740 |
+
*
|
741 |
+
* @author Vova Feldman (@svovaf)
|
742 |
+
* @since 1.2.2.7
|
743 |
+
*/
|
744 |
+
if ( ! $this->_cache->has_valid( 'tabs' ) ) {
|
745 |
+
add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
|
746 |
+
// Add license activation AJAX callback.
|
747 |
+
$this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
|
748 |
+
|
749 |
+
add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
|
750 |
+
}
|
751 |
+
|
752 |
+
add_action(
|
753 |
+
'admin_footer',
|
754 |
+
array( &$this, '_add_freemius_tabs' ),
|
755 |
+
/**
|
756 |
+
* The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
|
757 |
+
* That's why the priority is 11 while the tabs capture logic is added
|
758 |
+
* with priority 10.
|
759 |
+
*
|
760 |
+
* @author Vova Feldman (@svovaf)
|
761 |
+
*/
|
762 |
+
11
|
763 |
+
);
|
764 |
+
|
765 |
+
add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
|
766 |
+
}
|
767 |
+
|
768 |
+
/**
|
769 |
+
* Part of the mechanism to identify new plugin install vs. plugin update.
|
770 |
+
*
|
771 |
+
* @author Vova Feldman (@svovaf)
|
772 |
+
* @since 1.1.9
|
773 |
+
*/
|
774 |
+
if ( empty( $this->_storage->was_plugin_loaded ) ) {
|
775 |
+
if ( $this->is_plugin() &&
|
776 |
+
$this->is_activation_mode( false ) &&
|
777 |
+
0 == did_action( 'plugins_loaded' )
|
778 |
+
) {
|
779 |
+
add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
|
780 |
+
} else {
|
781 |
+
// If was activated before, then it was already loaded before.
|
782 |
+
$this->_plugins_loaded();
|
783 |
+
}
|
784 |
+
}
|
785 |
+
|
786 |
+
if ( ! self::is_ajax() ) {
|
787 |
+
if ( ! $this->is_addon() ) {
|
788 |
+
add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
|
789 |
+
}
|
790 |
+
}
|
791 |
+
}
|
792 |
+
|
793 |
+
if ( $this->is_plugin() ) {
|
794 |
+
register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
|
795 |
+
}
|
796 |
+
|
797 |
+
if ( $this->is_theme() && self::is_customizer() ) {
|
798 |
+
// Register customizer upsell.
|
799 |
+
add_action( 'customize_register', array( &$this, '_customizer_register' ) );
|
800 |
+
}
|
801 |
+
|
802 |
+
add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
|
803 |
+
|
804 |
+
add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
|
805 |
+
add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
|
806 |
+
$this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
|
807 |
+
$this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
|
808 |
+
|
809 |
+
$this->add_ajax_action( 'install_premium_version', array(
|
810 |
+
&$this,
|
811 |
+
'_install_premium_version_ajax_action'
|
812 |
+
) );
|
813 |
+
|
814 |
+
$this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
|
815 |
+
|
816 |
+
$this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
|
817 |
+
|
818 |
+
$this->add_action( 'sdk_version_update', array( &$this, '_data_migration' ), WP_FS__DEFAULT_PRIORITY, 2 );
|
819 |
+
$this->add_action( 'plugin_version_update', array( &$this, '_after_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
|
820 |
+
$this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
|
821 |
+
|
822 |
+
add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
|
823 |
+
add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
|
824 |
+
add_action( 'admin_init', array( &$this, '_enqueue_common_css' ) );
|
825 |
+
|
826 |
+
/**
|
827 |
+
* Handle request to reset anonymous mode for `get_reconnect_url()`.
|
828 |
+
*
|
829 |
+
* @author Vova Feldman (@svovaf)
|
830 |
+
* @since 1.2.1.5
|
831 |
+
*/
|
832 |
+
if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
|
833 |
+
$this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
|
834 |
+
) {
|
835 |
+
add_action( 'admin_init', array( &$this, 'connect_again' ) );
|
836 |
+
}
|
837 |
+
}
|
838 |
+
|
839 |
+
/**
|
840 |
+
* Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
|
841 |
+
* could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
|
842 |
+
* plugin will trigger inclusion of the free or premium version and if one of them is active during the
|
843 |
+
* uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
|
844 |
+
*
|
845 |
+
* @author Leo Fajardo (leorw)
|
846 |
+
*
|
847 |
+
* @since 1.2.0
|
848 |
+
*/
|
849 |
+
private function unregister_uninstall_hook() {
|
850 |
+
$uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
|
851 |
+
unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
|
852 |
+
unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
|
853 |
+
|
854 |
+
update_option( 'uninstall_plugins', $uninstallable_plugins );
|
855 |
+
}
|
856 |
+
|
857 |
+
/**
|
858 |
+
* @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
|
859 |
+
*/
|
860 |
+
private function clear_module_main_file_cache() {
|
861 |
+
if ( ! isset( $this->_storage->plugin_main_file ) ||
|
862 |
+
empty( $this->_storage->plugin_main_file->path )
|
863 |
+
) {
|
864 |
+
return;
|
865 |
+
}
|
866 |
+
|
867 |
+
$plugin_main_file = clone $this->_storage->plugin_main_file;
|
868 |
+
|
869 |
+
// Store cached path (2nd layer cache).
|
870 |
+
$plugin_main_file->prev_path = $plugin_main_file->path;
|
871 |
+
|
872 |
+
// Clear cached path.
|
873 |
+
unset( $plugin_main_file->path );
|
874 |
+
|
875 |
+
$this->_storage->plugin_main_file = $plugin_main_file;
|
876 |
+
|
877 |
+
/**
|
878 |
+
* Clear global cached path.
|
879 |
+
*
|
880 |
+
* @author Leo Fajardo (@leorw)
|
881 |
+
* @since 1.2.2
|
882 |
+
*/
|
883 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
|
884 |
+
unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
|
885 |
+
self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* @author Vova Feldman (@svovaf)
|
890 |
+
* @since 1.0.9
|
891 |
+
*/
|
892 |
+
private function _register_account_hooks() {
|
893 |
+
if ( ! is_admin() ) {
|
894 |
+
return;
|
895 |
+
}
|
896 |
+
|
897 |
+
/**
|
898 |
+
* Always show the deactivation feedback form since we added
|
899 |
+
* automatic free version deactivation upon premium code activation.
|
900 |
+
*
|
901 |
+
* @since 1.2.1.6
|
902 |
+
*/
|
903 |
+
$this->add_ajax_action(
|
904 |
+
'submit_uninstall_reason',
|
905 |
+
array( &$this, '_submit_uninstall_reason_action' )
|
906 |
+
);
|
907 |
+
|
908 |
+
if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
|
909 |
+
( $this->is_theme() && self::is_themes_page() )
|
910 |
+
) {
|
911 |
+
add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
|
912 |
+
}
|
913 |
+
}
|
914 |
+
|
915 |
+
/**
|
916 |
+
* Leverage backtrace to find caller plugin file path.
|
917 |
+
*
|
918 |
+
* @author Vova Feldman (@svovaf)
|
919 |
+
* @since 1.0.6
|
920 |
+
*
|
921 |
+
* @param bool $is_init Is initiation sequence.
|
922 |
+
*
|
923 |
+
* @return string
|
924 |
+
*/
|
925 |
+
private function _find_caller_plugin_file( $is_init = false ) {
|
926 |
+
// Try to load the cached value of the file path.
|
927 |
+
if ( isset( $this->_storage->plugin_main_file ) ) {
|
928 |
+
$plugin_main_file = $this->_storage->plugin_main_file;
|
929 |
+
if ( isset( $plugin_main_file->path ) ) {
|
930 |
+
$absolute_path = $this->get_absolute_path( $plugin_main_file->path );
|
931 |
+
if ( file_exists( $absolute_path ) ) {
|
932 |
+
return $absolute_path;
|
933 |
+
}
|
934 |
+
}
|
935 |
+
}
|
936 |
+
|
937 |
+
/**
|
938 |
+
* @since 1.2.1
|
939 |
+
*
|
940 |
+
* `clear_module_main_file_cache()` is clearing the plugin's cached path on
|
941 |
+
* deactivation. Therefore, if any plugin/theme was initiating `Freemius`
|
942 |
+
* with that plugin's slug, it was overriding the empty plugin path with a wrong path.
|
943 |
+
*
|
944 |
+
* So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
|
945 |
+
* when the class instantiator isn't the module.
|
946 |
+
*/
|
947 |
+
if ( ! $is_init ) {
|
948 |
+
// Fetch prev path cache.
|
949 |
+
if ( isset( $this->_storage->plugin_main_file ) &&
|
950 |
+
isset( $this->_storage->plugin_main_file->prev_path )
|
951 |
+
) {
|
952 |
+
$absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
|
953 |
+
if ( file_exists( $absolute_path ) ) {
|
954 |
+
return $absolute_path;
|
955 |
+
}
|
956 |
+
}
|
957 |
+
|
958 |
+
wp_die(
|
959 |
+
$this->get_text_inline( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'failed-finding-main-path' ) .
|
960 |
+
" Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
|
961 |
+
$this->get_text_inline( 'Error', 'error' ),
|
962 |
+
array( 'back_link' => true )
|
963 |
+
);
|
964 |
+
}
|
965 |
+
|
966 |
+
/**
|
967 |
+
* @since 1.2.1
|
968 |
+
*
|
969 |
+
* Only the original instantiator that calls dynamic_init can modify the module's path.
|
970 |
+
*/
|
971 |
+
// Find caller module.
|
972 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
973 |
+
$this->_storage->plugin_main_file = (object) array(
|
974 |
+
'path' => $id_slug_type_path_map[ $this->_module_id ]['path'],
|
975 |
+
);
|
976 |
+
|
977 |
+
return $this->get_absolute_path( $id_slug_type_path_map[ $this->_module_id ]['path'] );
|
978 |
+
}
|
979 |
+
|
980 |
+
/**
|
981 |
+
* @author Leo Fajardo (@leorw)
|
982 |
+
* @since 1.2.3
|
983 |
+
*
|
984 |
+
* @param string $path
|
985 |
+
*
|
986 |
+
* @return string
|
987 |
+
*/
|
988 |
+
private function get_relative_path( $path ) {
|
989 |
+
$module_root_dir = $this->get_module_root_dir_path();
|
990 |
+
if ( 0 === strpos( $path, $module_root_dir ) ) {
|
991 |
+
$path = substr( $path, strlen( $module_root_dir ) );
|
992 |
+
}
|
993 |
+
|
994 |
+
return $path;
|
995 |
+
}
|
996 |
+
|
997 |
+
/**
|
998 |
+
* @author Leo Fajardo (@leorw)
|
999 |
+
* @since 1.2.3
|
1000 |
+
*
|
1001 |
+
* @param string $path
|
1002 |
+
* @param string|bool $module_type
|
1003 |
+
*
|
1004 |
+
* @return string
|
1005 |
+
*/
|
1006 |
+
private function get_absolute_path( $path, $module_type = false ) {
|
1007 |
+
$module_root_dir = $this->get_module_root_dir_path( $module_type );
|
1008 |
+
if ( 0 !== strpos( $path, $module_root_dir ) ) {
|
1009 |
+
$path = fs_normalize_path( $module_root_dir . $path );
|
1010 |
+
}
|
1011 |
+
|
1012 |
+
return $path;
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
/**
|
1016 |
+
* @author Leo Fajardo (@leorw)
|
1017 |
+
* @since 1.2.3
|
1018 |
+
*
|
1019 |
+
* @param string|bool $module_type
|
1020 |
+
*
|
1021 |
+
* @return string
|
1022 |
+
*/
|
1023 |
+
private function get_module_root_dir_path( $module_type = false ) {
|
1024 |
+
$is_plugin = empty( $module_type ) ?
|
1025 |
+
$this->is_plugin() :
|
1026 |
+
( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
|
1027 |
+
|
1028 |
+
return fs_normalize_path( trailingslashit( $is_plugin ?
|
1029 |
+
WP_PLUGIN_DIR :
|
1030 |
+
get_theme_root() ) );
|
1031 |
+
}
|
1032 |
+
|
1033 |
+
/**
|
1034 |
+
* @author Leo Fajardo (@leorw)
|
1035 |
+
*
|
1036 |
+
* @param number $module_id
|
1037 |
+
* @param string $slug
|
1038 |
+
*
|
1039 |
+
* @since 1.2.2
|
1040 |
+
*/
|
1041 |
+
private function store_id_slug_type_path_map( $module_id, $slug ) {
|
1042 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
1043 |
+
|
1044 |
+
$store_option = false;
|
1045 |
+
|
1046 |
+
if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
|
1047 |
+
$id_slug_type_path_map[ $module_id ] = array(
|
1048 |
+
'slug' => $slug
|
1049 |
+
);
|
1050 |
+
|
1051 |
+
$store_option = true;
|
1052 |
+
}
|
1053 |
+
|
1054 |
+
if ( ! isset( $id_slug_type_path_map[ $module_id ]['path'] ) ||
|
1055 |
+
/**
|
1056 |
+
* This verification is for cases when suddenly the same module
|
1057 |
+
* is installed but with a different folder name.
|
1058 |
+
*
|
1059 |
+
* @author Vova Feldman (@svovaf)
|
1060 |
+
* @since 1.2.3
|
1061 |
+
*/
|
1062 |
+
! file_exists( $this->get_absolute_path(
|
1063 |
+
$id_slug_type_path_map[ $module_id ]['path'],
|
1064 |
+
$id_slug_type_path_map[ $module_id ]['type']
|
1065 |
+
) )
|
1066 |
+
) {
|
1067 |
+
$caller_main_file_and_type = $this->get_caller_main_file_and_type();
|
1068 |
+
|
1069 |
+
$id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
|
1070 |
+
$id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
|
1071 |
+
|
1072 |
+
$store_option = true;
|
1073 |
+
}
|
1074 |
+
|
1075 |
+
if ( $store_option ) {
|
1076 |
+
self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
|
1077 |
+
}
|
1078 |
+
}
|
1079 |
+
|
1080 |
+
/**
|
1081 |
+
* Identifies the caller type: plugin or theme.
|
1082 |
+
*
|
1083 |
+
* @author Leo Fajardo (@leorw)
|
1084 |
+
* @since 1.2.2
|
1085 |
+
*
|
1086 |
+
* @author Vova Feldman (@svovaf)
|
1087 |
+
* @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
|
1088 |
+
* add-ons are relying on loading the SDK from the parent module, and also allows themes including the
|
1089 |
+
* SDK an internal file instead of directly from functions.php.
|
1090 |
+
* @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
|
1091 |
+
*/
|
1092 |
+
private function get_caller_main_file_and_type() {
|
1093 |
+
self::require_plugin_essentials();
|
1094 |
+
|
1095 |
+
$all_plugins = get_plugins();
|
1096 |
+
$all_plugins_paths = array();
|
1097 |
+
|
1098 |
+
// Get active plugin's main files real full names (might be symlinks).
|
1099 |
+
foreach ( $all_plugins as $relative_path => &$data ) {
|
1100 |
+
if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
|
1101 |
+
/**
|
1102 |
+
* Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
|
1103 |
+
* can't really include the SDK.
|
1104 |
+
*
|
1105 |
+
* @author Vova Feldman
|
1106 |
+
* @since 1.2.1.7
|
1107 |
+
*/
|
1108 |
+
continue;
|
1109 |
+
}
|
1110 |
+
|
1111 |
+
$all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
|
1112 |
+
}
|
1113 |
+
|
1114 |
+
$caller_file_candidate = false;
|
1115 |
+
$caller_map = array();
|
1116 |
+
$module_type = WP_FS__MODULE_TYPE_PLUGIN;
|
1117 |
+
$themes_dir = fs_normalize_path( get_theme_root() );
|
1118 |
+
|
1119 |
+
for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
|
1120 |
+
if ( empty( $bt[ $i ]['file'] ) ) {
|
1121 |
+
continue;
|
1122 |
+
}
|
1123 |
+
|
1124 |
+
if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
|
1125 |
+
// If file same as the prev file in the stack, skip it.
|
1126 |
+
continue;
|
1127 |
+
}
|
1128 |
+
|
1129 |
+
if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
|
1130 |
+
'do_action',
|
1131 |
+
'apply_filter',
|
1132 |
+
// The string split is stupid, but otherwise, theme check
|
1133 |
+
// throws info notices.
|
1134 |
+
'requir' . 'e_once',
|
1135 |
+
'requir' . 'e',
|
1136 |
+
'includ' . 'e_once',
|
1137 |
+
'includ' . 'e'
|
1138 |
+
) )
|
1139 |
+
) {
|
1140 |
+
// Ignore call stack hooks and files inclusion.
|
1141 |
+
continue;
|
1142 |
+
}
|
1143 |
+
|
1144 |
+
$caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
|
1145 |
+
|
1146 |
+
if ( 'functions.php' === basename( $caller_file_path ) ) {
|
1147 |
+
/**
|
1148 |
+
* 1. Assumes that theme's starting execution file is functions.php.
|
1149 |
+
* 2. This complex logic fixes symlink issues (e.g. with Vargant).
|
1150 |
+
*
|
1151 |
+
* @author Vova Feldman (@svovaf)
|
1152 |
+
* @since 1.2.2.5
|
1153 |
+
*/
|
1154 |
+
|
1155 |
+
if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
|
1156 |
+
$module_type = WP_FS__MODULE_TYPE_THEME;
|
1157 |
+
|
1158 |
+
/**
|
1159 |
+
* Relative path of the theme, e.g.:
|
1160 |
+
* `my-theme/functions.php`
|
1161 |
+
*
|
1162 |
+
* @author Leo Fajardo (@leorw)
|
1163 |
+
*/
|
1164 |
+
$caller_file_candidate = basename( dirname( $caller_file_path ) ) .
|
1165 |
+
'/' .
|
1166 |
+
basename( $caller_file_path );
|
1167 |
+
|
1168 |
+
continue;
|
1169 |
+
}
|
1170 |
+
}
|
1171 |
+
|
1172 |
+
$caller_file_hash = md5( $caller_file_path );
|
1173 |
+
|
1174 |
+
if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
|
1175 |
+
foreach ( $all_plugins_paths as $plugin_path ) {
|
1176 |
+
if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
|
1177 |
+
$caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
|
1178 |
+
break;
|
1179 |
+
}
|
1180 |
+
}
|
1181 |
+
}
|
1182 |
+
|
1183 |
+
if ( isset( $caller_map[ $caller_file_hash ] ) ) {
|
1184 |
+
$module_type = WP_FS__MODULE_TYPE_PLUGIN;
|
1185 |
+
$caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
|
1186 |
+
}
|
1187 |
+
}
|
1188 |
+
|
1189 |
+
return (object) array(
|
1190 |
+
'module_type' => $module_type,
|
1191 |
+
'path' => $caller_file_candidate
|
1192 |
+
);
|
1193 |
+
}
|
1194 |
+
|
1195 |
+
#----------------------------------------------------------------------------------
|
1196 |
+
#region Deactivation Feedback Form
|
1197 |
+
#----------------------------------------------------------------------------------
|
1198 |
+
|
1199 |
+
/**
|
1200 |
+
* Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
|
1201 |
+
* page.
|
1202 |
+
*
|
1203 |
+
* @author Vova Feldman (@svovaf)
|
1204 |
+
* @author Leo Fajardo (@leorw)
|
1205 |
+
* @since 1.1.2
|
1206 |
+
*/
|
1207 |
+
function _add_deactivation_feedback_dialog_box() {
|
1208 |
+
/* Check the type of user:
|
1209 |
+
* 1. Long-term (long-term)
|
1210 |
+
* 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
|
1211 |
+
* 3. Short-term (short-term)
|
1212 |
+
*/
|
1213 |
+
$is_long_term_user = true;
|
1214 |
+
|
1215 |
+
// Check if the site is at least 2 days old.
|
1216 |
+
$time_installed = $this->_storage->install_timestamp;
|
1217 |
+
|
1218 |
+
// Difference in seconds.
|
1219 |
+
$date_diff = time() - $time_installed;
|
1220 |
+
|
1221 |
+
// Convert seconds to days.
|
1222 |
+
$date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
|
1223 |
+
|
1224 |
+
if ( $date_diff_days < 2 ) {
|
1225 |
+
$is_long_term_user = false;
|
1226 |
+
}
|
1227 |
+
|
1228 |
+
$is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
|
1229 |
+
|
1230 |
+
if ( $is_long_term_user ) {
|
1231 |
+
$user_type = 'long-term';
|
1232 |
+
} else {
|
1233 |
+
if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
|
1234 |
+
$user_type = 'non-registered-and-non-anonymous-short-term';
|
1235 |
+
} else {
|
1236 |
+
$user_type = 'short-term';
|
1237 |
+
}
|
1238 |
+
}
|
1239 |
+
|
1240 |
+
$uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
|
1241 |
+
|
1242 |
+
// Load the HTML template for the deactivation feedback dialog box.
|
1243 |
+
$vars = array(
|
1244 |
+
'reasons' => $uninstall_reasons,
|
1245 |
+
'id' => $this->_module_id
|
1246 |
+
);
|
1247 |
+
|
1248 |
+
/**
|
1249 |
+
* @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
|
1250 |
+
*/
|
1251 |
+
fs_require_template( 'forms/deactivation/form.php', $vars );
|
1252 |
+
}
|
1253 |
+
|
1254 |
+
/**
|
1255 |
+
* @author Leo Fajardo (leorw)
|
1256 |
+
* @since 1.1.2
|
1257 |
+
*
|
1258 |
+
* @param string $user_type
|
1259 |
+
*
|
1260 |
+
* @return array The uninstall reasons for the specified user type.
|
1261 |
+
*/
|
1262 |
+
function _get_uninstall_reasons( $user_type = 'long-term' ) {
|
1263 |
+
$module_type = $this->_module_type;
|
1264 |
+
|
1265 |
+
$internal_message_template_var = array(
|
1266 |
+
'id' => $this->_module_id
|
1267 |
+
);
|
1268 |
+
|
1269 |
+
if ( $this->is_registered() && false !== $this->get_plan() && $this->get_plan()->has_technical_support() ) {
|
1270 |
+
$contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
|
1271 |
+
} else {
|
1272 |
+
$contact_support_template = '';
|
1273 |
+
}
|
1274 |
+
|
1275 |
+
$reason_found_better_plugin = array(
|
1276 |
+
'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
|
1277 |
+
'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
|
1278 |
+
'input_type' => 'textfield',
|
1279 |
+
'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
|
1280 |
+
);
|
1281 |
+
|
1282 |
+
$reason_temporary_deactivation = array(
|
1283 |
+
'id' => self::REASON_TEMPORARY_DEACTIVATION,
|
1284 |
+
'text' => sprintf(
|
1285 |
+
$this->get_text_inline( "It's a temporary %s. I'm just debugging an issue.", 'reason-temporary-x' ),
|
1286 |
+
strtolower( $this->is_plugin() ?
|
1287 |
+
$this->get_text_inline( 'Deactivation', 'deactivation' ) :
|
1288 |
+
$this->get_text_inline( 'Theme Switch', 'theme-switch' )
|
1289 |
+
)
|
1290 |
+
),
|
1291 |
+
'input_type' => '',
|
1292 |
+
'input_placeholder' => ''
|
1293 |
+
);
|
1294 |
+
|
1295 |
+
$reason_other = array(
|
1296 |
+
'id' => self::REASON_OTHER,
|
1297 |
+
'text' => $this->get_text_inline( 'Other', 'reason-other' ),
|
1298 |
+
'input_type' => 'textfield',
|
1299 |
+
'input_placeholder' => ''
|
1300 |
+
);
|
1301 |
+
|
1302 |
+
$long_term_user_reasons = array(
|
1303 |
+
array(
|
1304 |
+
'id' => self::REASON_NO_LONGER_NEEDED,
|
1305 |
+
'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
|
1306 |
+
'input_type' => '',
|
1307 |
+
'input_placeholder' => ''
|
1308 |
+
),
|
1309 |
+
$reason_found_better_plugin,
|
1310 |
+
array(
|
1311 |
+
'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
|
1312 |
+
'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
|
1313 |
+
'input_type' => '',
|
1314 |
+
'input_placeholder' => ''
|
1315 |
+
),
|
1316 |
+
array(
|
1317 |
+
'id' => self::REASON_BROKE_MY_SITE,
|
1318 |
+
'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
|
1319 |
+
'input_type' => '',
|
1320 |
+
'input_placeholder' => '',
|
1321 |
+
'internal_message' => $contact_support_template
|
1322 |
+
),
|
1323 |
+
array(
|
1324 |
+
'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
|
1325 |
+
'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
|
1326 |
+
'input_type' => '',
|
1327 |
+
'input_placeholder' => '',
|
1328 |
+
'internal_message' => $contact_support_template
|
1329 |
+
)
|
1330 |
+
);
|
1331 |
+
|
1332 |
+
if ( $this->is_paying() ) {
|
1333 |
+
$long_term_user_reasons[] = array(
|
1334 |
+
'id' => self::REASON_CANT_PAY_ANYMORE,
|
1335 |
+
'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
|
1336 |
+
'input_type' => 'textfield',
|
1337 |
+
'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
|
1338 |
+
);
|
1339 |
+
}
|
1340 |
+
|
1341 |
+
$reason_dont_share_info = array(
|
1342 |
+
'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
|
1343 |
+
'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
|
1344 |
+
'input_type' => '',
|
1345 |
+
'input_placeholder' => ''
|
1346 |
+
);
|
1347 |
+
|
1348 |
+
/**
|
1349 |
+
* If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
|
1350 |
+
* user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
|
1351 |
+
* (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
|
1352 |
+
* enabled and the user's account is currently not in pending activation state (similar to the way the Skip
|
1353 |
+
* button in the opt-in form is shown/hidden).
|
1354 |
+
*/
|
1355 |
+
if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
|
1356 |
+
$reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
|
1357 |
+
}
|
1358 |
+
|
1359 |
+
$uninstall_reasons = array(
|
1360 |
+
'long-term' => $long_term_user_reasons,
|
1361 |
+
'non-registered-and-non-anonymous-short-term' => array(
|
1362 |
+
array(
|
1363 |
+
'id' => self::REASON_DIDNT_WORK,
|
1364 |
+
'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
|
1365 |
+
'input_type' => '',
|
1366 |
+
'input_placeholder' => ''
|
1367 |
+
),
|
1368 |
+
$reason_dont_share_info,
|
1369 |
+
$reason_found_better_plugin
|
1370 |
+
),
|
1371 |
+
'short-term' => array(
|
1372 |
+
array(
|
1373 |
+
'id' => self::REASON_COULDNT_MAKE_IT_WORK,
|
1374 |
+
'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
|
1375 |
+
'input_type' => '',
|
1376 |
+
'input_placeholder' => '',
|
1377 |
+
'internal_message' => $contact_support_template
|
1378 |
+
),
|
1379 |
+
$reason_found_better_plugin,
|
1380 |
+
array(
|
1381 |
+
'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
|
1382 |
+
'text' => sprintf( $this->get_text_inline( "The %s is great, but I need specific feature that you don't support", 'reason-great-but-need-specific-feature' ), $module_type ),
|
1383 |
+
'input_type' => 'textarea',
|
1384 |
+
'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
|
1385 |
+
),
|
1386 |
+
array(
|
1387 |
+
'id' => self::REASON_NOT_WORKING,
|
1388 |
+
'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
|
1389 |
+
'input_type' => 'textarea',
|
1390 |
+
'input_placeholder' => $this->get_text_inline( "Kindly share what didn't work so we can fix it for future users...", 'placeholder-share-what-didnt-work' )
|
1391 |
+
),
|
1392 |
+
array(
|
1393 |
+
'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
|
1394 |
+
'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
|
1395 |
+
'input_type' => 'textarea',
|
1396 |
+
'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
|
1397 |
+
),
|
1398 |
+
array(
|
1399 |
+
'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
|
1400 |
+
'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
|
1401 |
+
'input_type' => 'textarea',
|
1402 |
+
'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
|
1403 |
+
)
|
1404 |
+
)
|
1405 |
+
);
|
1406 |
+
|
1407 |
+
// Randomize the reasons for the current user type.
|
1408 |
+
shuffle( $uninstall_reasons[ $user_type ] );
|
1409 |
+
|
1410 |
+
// Keep the following reasons as the last items in the list.
|
1411 |
+
$uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
|
1412 |
+
$uninstall_reasons[ $user_type ][] = $reason_other;
|
1413 |
+
|
1414 |
+
$uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
|
1415 |
+
|
1416 |
+
return $uninstall_reasons[ $user_type ];
|
1417 |
+
}
|
1418 |
+
|
1419 |
+
/**
|
1420 |
+
* Called after the user has submitted his reason for deactivating the plugin.
|
1421 |
+
*
|
1422 |
+
* @author Leo Fajardo (@leorw)
|
1423 |
+
* @since 1.1.2
|
1424 |
+
*/
|
1425 |
+
function _submit_uninstall_reason_action() {
|
1426 |
+
$this->_logger->entrance();
|
1427 |
+
|
1428 |
+
$this->check_ajax_referer( 'submit_uninstall_reason' );
|
1429 |
+
|
1430 |
+
$reason_id = fs_request_get( 'reason_id' );
|
1431 |
+
|
1432 |
+
// Check if the given reason ID is an unsigned integer.
|
1433 |
+
if ( ! ctype_digit( $reason_id ) ) {
|
1434 |
+
exit;
|
1435 |
+
}
|
1436 |
+
|
1437 |
+
$reason_info = trim( fs_request_get( 'reason_info', '' ) );
|
1438 |
+
if ( ! empty( $reason_info ) ) {
|
1439 |
+
$reason_info = substr( $reason_info, 0, 128 );
|
1440 |
+
}
|
1441 |
+
|
1442 |
+
$reason = (object) array(
|
1443 |
+
'id' => $reason_id,
|
1444 |
+
'info' => $reason_info,
|
1445 |
+
'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
|
1446 |
+
);
|
1447 |
+
|
1448 |
+
$this->_storage->store( 'uninstall_reason', $reason );
|
1449 |
+
|
1450 |
+
/**
|
1451 |
+
* If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
|
1452 |
+
* not support uninstall hook.
|
1453 |
+
*
|
1454 |
+
* @author Leo Fajardo (@leorw)
|
1455 |
+
* @since 1.2.2
|
1456 |
+
*/
|
1457 |
+
if ( $this->is_theme() ) {
|
1458 |
+
$this->_uninstall_plugin_event( false );
|
1459 |
+
$this->remove_sdk_reference();
|
1460 |
+
}
|
1461 |
+
|
1462 |
+
// Print '1' for successful operation.
|
1463 |
+
echo 1;
|
1464 |
+
exit;
|
1465 |
+
}
|
1466 |
+
|
1467 |
+
#endregion
|
1468 |
+
|
1469 |
+
#----------------------------------------------------------------------------------
|
1470 |
+
#region Instance
|
1471 |
+
#----------------------------------------------------------------------------------
|
1472 |
+
|
1473 |
+
/**
|
1474 |
+
* Main singleton instance.
|
1475 |
+
*
|
1476 |
+
* @author Vova Feldman (@svovaf)
|
1477 |
+
* @since 1.0.0
|
1478 |
+
*
|
1479 |
+
* @param number $module_id
|
1480 |
+
* @param string|bool $slug
|
1481 |
+
* @param bool $is_init Is initiation sequence.
|
1482 |
+
*
|
1483 |
+
* @return Freemius|false
|
1484 |
+
*/
|
1485 |
+
static function instance( $module_id, $slug = false, $is_init = false ) {
|
1486 |
+
if ( empty( $module_id ) ) {
|
1487 |
+
return false;
|
1488 |
+
}
|
1489 |
+
|
1490 |
+
if ( ! is_numeric( $module_id ) ) {
|
1491 |
+
if ( ! $is_init && true === $slug ) {
|
1492 |
+
$is_init = true;
|
1493 |
+
}
|
1494 |
+
|
1495 |
+
$slug = $module_id;
|
1496 |
+
|
1497 |
+
$module = FS_Plugin_Manager::instance( $slug )->get();
|
1498 |
+
|
1499 |
+
if ( is_object( $module ) ) {
|
1500 |
+
$module_id = $module->id;
|
1501 |
+
}
|
1502 |
+
}
|
1503 |
+
|
1504 |
+
$key = 'm_' . $module_id;
|
1505 |
+
|
1506 |
+
if ( ! isset( self::$_instances[ $key ] ) ) {
|
1507 |
+
if ( 0 === count( self::$_instances ) ) {
|
1508 |
+
self::_load_required_static();
|
1509 |
+
}
|
1510 |
+
|
1511 |
+
self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
|
1512 |
+
}
|
1513 |
+
|
1514 |
+
return self::$_instances[ $key ];
|
1515 |
+
}
|
1516 |
+
|
1517 |
+
/**
|
1518 |
+
* @author Vova Feldman (@svovaf)
|
1519 |
+
* @since 1.0.6
|
1520 |
+
*
|
1521 |
+
* @param number $addon_id
|
1522 |
+
*
|
1523 |
+
* @return bool
|
1524 |
+
*/
|
1525 |
+
private static function has_instance( $addon_id ) {
|
1526 |
+
return isset( self::$_instances[ 'm_' . $addon_id ] );
|
1527 |
+
}
|
1528 |
+
|
1529 |
+
/**
|
1530 |
+
* @author Leo Fajardo (@leorw)
|
1531 |
+
* @since 1.2.2
|
1532 |
+
*
|
1533 |
+
* @param string|number $id_or_slug
|
1534 |
+
*
|
1535 |
+
* @return number|false
|
1536 |
+
*/
|
1537 |
+
private static function get_module_id( $id_or_slug ) {
|
1538 |
+
if ( is_numeric( $id_or_slug ) ) {
|
1539 |
+
return $id_or_slug;
|
1540 |
+
}
|
1541 |
+
|
1542 |
+
foreach ( self::$_instances as $instance ) {
|
1543 |
+
if ( $instance->is_plugin() && ( $id_or_slug === $instance->get_slug() ) ) {
|
1544 |
+
return $instance->get_id();
|
1545 |
+
}
|
1546 |
+
}
|
1547 |
+
|
1548 |
+
return false;
|
1549 |
+
}
|
1550 |
+
|
1551 |
+
/**
|
1552 |
+
* @author Vova Feldman (@svovaf)
|
1553 |
+
* @since 1.0.6
|
1554 |
+
*
|
1555 |
+
* @param number $id
|
1556 |
+
*
|
1557 |
+
* @return false|Freemius
|
1558 |
+
*/
|
1559 |
+
static function get_instance_by_id( $id ) {
|
1560 |
+
return isset ( self::$_instances[ 'm_' . $id ] ) ?
|
1561 |
+
self::$_instances[ 'm_' . $id ] :
|
1562 |
+
false;
|
1563 |
+
}
|
1564 |
+
|
1565 |
+
/**
|
1566 |
+
*
|
1567 |
+
* @author Vova Feldman (@svovaf)
|
1568 |
+
* @since 1.0.1
|
1569 |
+
*
|
1570 |
+
* @param $plugin_file
|
1571 |
+
*
|
1572 |
+
* @return false|Freemius
|
1573 |
+
*/
|
1574 |
+
static function get_instance_by_file( $plugin_file ) {
|
1575 |
+
$slug = self::find_slug_by_basename( $plugin_file );
|
1576 |
+
|
1577 |
+
return ( false !== $slug ) ?
|
1578 |
+
self::instance( self::get_module_id( $slug ) ) :
|
1579 |
+
false;
|
1580 |
+
}
|
1581 |
+
|
1582 |
+
/**
|
1583 |
+
* @author Vova Feldman (@svovaf)
|
1584 |
+
* @since 1.0.6
|
1585 |
+
*
|
1586 |
+
* @return false|Freemius
|
1587 |
+
*/
|
1588 |
+
function get_parent_instance() {
|
1589 |
+
return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
|
1590 |
+
}
|
1591 |
+
|
1592 |
+
/**
|
1593 |
+
* @author Vova Feldman (@svovaf)
|
1594 |
+
* @since 1.0.6
|
1595 |
+
*
|
1596 |
+
* @param string|number $id_or_slug
|
1597 |
+
*
|
1598 |
+
* @return false|Freemius
|
1599 |
+
*/
|
1600 |
+
function get_addon_instance( $id_or_slug ) {
|
1601 |
+
$addon_id = self::get_module_id( $id_or_slug );
|
1602 |
+
|
1603 |
+
return self::instance( $addon_id );
|
1604 |
+
}
|
1605 |
+
|
1606 |
+
#endregion ------------------------------------------------------------------
|
1607 |
+
|
1608 |
+
/**
|
1609 |
+
* @author Vova Feldman (@svovaf)
|
1610 |
+
* @since 1.0.6
|
1611 |
+
*
|
1612 |
+
* @return bool
|
1613 |
+
*/
|
1614 |
+
function is_parent_plugin_installed() {
|
1615 |
+
$is_active = self::has_instance( $this->_plugin->parent_plugin_id );
|
1616 |
+
|
1617 |
+
if ( $is_active ) {
|
1618 |
+
return true;
|
1619 |
+
}
|
1620 |
+
|
1621 |
+
/**
|
1622 |
+
* Parent module might be a theme. If that's the case, the add-on's FS
|
1623 |
+
* instance will be loaded prior to the theme's FS instance, therefore,
|
1624 |
+
* we need to check if it's active with a "look ahead".
|
1625 |
+
*
|
1626 |
+
* @author Vova Feldman
|
1627 |
+
* @since 1.2.2.3
|
1628 |
+
*/
|
1629 |
+
global $fs_active_plugins;
|
1630 |
+
if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
|
1631 |
+
$active_theme = wp_get_theme();
|
1632 |
+
|
1633 |
+
foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
|
1634 |
+
if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
|
1635 |
+
if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
|
1636 |
+
// Parent module is a theme and it's currently active.
|
1637 |
+
return true;
|
1638 |
+
}
|
1639 |
+
}
|
1640 |
+
}
|
1641 |
+
}
|
1642 |
+
|
1643 |
+
return false;
|
1644 |
+
}
|
1645 |
+
|
1646 |
+
/**
|
1647 |
+
* Check if add-on parent plugin in activation mode.
|
1648 |
+
*
|
1649 |
+
* @author Vova Feldman (@svovaf)
|
1650 |
+
* @since 1.0.7
|
1651 |
+
*
|
1652 |
+
* @return bool
|
1653 |
+
*/
|
1654 |
+
function is_parent_in_activation() {
|
1655 |
+
$parent_fs = $this->get_parent_instance();
|
1656 |
+
if ( ! is_object( $parent_fs ) ) {
|
1657 |
+
return false;
|
1658 |
+
}
|
1659 |
+
|
1660 |
+
return ( $parent_fs->is_activation_mode() );
|
1661 |
+
}
|
1662 |
+
|
1663 |
+
/**
|
1664 |
+
* Is plugin in activation mode.
|
1665 |
+
*
|
1666 |
+
* @author Vova Feldman (@svovaf)
|
1667 |
+
* @since 1.0.7
|
1668 |
+
*
|
1669 |
+
* @param bool $and_on
|
1670 |
+
*
|
1671 |
+
* @return bool
|
1672 |
+
*/
|
1673 |
+
function is_activation_mode( $and_on = true ) {
|
1674 |
+
return (
|
1675 |
+
( $this->is_on() || ! $and_on ) &&
|
1676 |
+
( ! $this->is_registered() || ( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
|
1677 |
+
( ! $this->is_enable_anonymous() ||
|
1678 |
+
( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
|
1679 |
+
);
|
1680 |
+
}
|
1681 |
+
|
1682 |
+
/**
|
1683 |
+
* Check if current page is the opt-in/pending-activation page.
|
1684 |
+
*
|
1685 |
+
* @author Vova Feldman (@svovaf)
|
1686 |
+
* @since 1.2.1.7
|
1687 |
+
*
|
1688 |
+
* @return bool
|
1689 |
+
*/
|
1690 |
+
function is_activation_page() {
|
1691 |
+
if ( $this->_menu->is_main_settings_page() ) {
|
1692 |
+
return true;
|
1693 |
+
}
|
1694 |
+
|
1695 |
+
if ( ! $this->is_activation_mode() ) {
|
1696 |
+
return false;
|
1697 |
+
}
|
1698 |
+
|
1699 |
+
// Check if current page is matching the activation page.
|
1700 |
+
return $this->is_matching_url( $this->get_activation_url() );
|
1701 |
+
}
|
1702 |
+
|
1703 |
+
/**
|
1704 |
+
* Check if URL path's are matching and that all querystring
|
1705 |
+
* arguments of the $sub_url exist in the $url with the same values.
|
1706 |
+
*
|
1707 |
+
* WARNING:
|
1708 |
+
* 1. This method doesn't check if the sub/domain are matching.
|
1709 |
+
* 2. Ignore case sensitivity.
|
1710 |
+
*
|
1711 |
+
* @author Vova Feldman (@svovaf)
|
1712 |
+
* @since 1.2.1.7
|
1713 |
+
*
|
1714 |
+
* @param string $sub_url
|
1715 |
+
* @param string $url If argument is not set, check if the sub_url matching the current's page URL.
|
1716 |
+
*
|
1717 |
+
* @return bool
|
1718 |
+
*/
|
1719 |
+
private function is_matching_url( $sub_url, $url = '' ) {
|
1720 |
+
if ( empty( $url ) ) {
|
1721 |
+
$url = $_SERVER['REQUEST_URI'];
|
1722 |
+
}
|
1723 |
+
|
1724 |
+
$url = strtolower( $url );
|
1725 |
+
$sub_url = strtolower( $sub_url );
|
1726 |
+
|
1727 |
+
if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
|
1728 |
+
// Different path - DO NOT OVERRIDE PAGE.
|
1729 |
+
return false;
|
1730 |
+
}
|
1731 |
+
|
1732 |
+
$url_params = array();
|
1733 |
+
parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
|
1734 |
+
|
1735 |
+
$sub_url_params = array();
|
1736 |
+
parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
|
1737 |
+
|
1738 |
+
foreach ( $sub_url_params as $key => $val ) {
|
1739 |
+
if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
|
1740 |
+
// Not matching query string - DO NOT OVERRIDE PAGE.
|
1741 |
+
return false;
|
1742 |
+
}
|
1743 |
+
}
|
1744 |
+
|
1745 |
+
return true;
|
1746 |
+
}
|
1747 |
+
|
1748 |
+
/**
|
1749 |
+
* Get collection of all active plugins.
|
1750 |
+
*
|
1751 |
+
* @author Vova Feldman (@svovaf)
|
1752 |
+
* @since 1.0.9
|
1753 |
+
*
|
1754 |
+
* @return array[string]array
|
1755 |
+
*/
|
1756 |
+
private static function get_active_plugins() {
|
1757 |
+
self::require_plugin_essentials();
|
1758 |
+
|
1759 |
+
$active_plugin = array();
|
1760 |
+
$all_plugins = get_plugins();
|
1761 |
+
$active_plugins_basenames = get_option( 'active_plugins' );
|
1762 |
+
|
1763 |
+
foreach ( $active_plugins_basenames as $plugin_basename ) {
|
1764 |
+
$active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
|
1765 |
+
}
|
1766 |
+
|
1767 |
+
return $active_plugin;
|
1768 |
+
}
|
1769 |
+
|
1770 |
+
/**
|
1771 |
+
* Get collection of all plugins.
|
1772 |
+
*
|
1773 |
+
* @author Vova Feldman (@svovaf)
|
1774 |
+
* @since 1.1.8
|
1775 |
+
*
|
1776 |
+
* @return array Key is the plugin file path and the value is an array of the plugin data.
|
1777 |
+
*/
|
1778 |
+
private static function get_all_plugins() {
|
1779 |
+
self::require_plugin_essentials();
|
1780 |
+
|
1781 |
+
$all_plugins = get_plugins();
|
1782 |
+
$active_plugins_basenames = get_option( 'active_plugins' );
|
1783 |
+
|
1784 |
+
foreach ( $all_plugins as $basename => &$data ) {
|
1785 |
+
// By default set to inactive (next foreach update the active plugins).
|
1786 |
+
$data['is_active'] = false;
|
1787 |
+
// Enrich with plugin slug.
|
1788 |
+
$data['slug'] = self::get_plugin_slug( $basename );
|
1789 |
+
}
|
1790 |
+
|
1791 |
+
// Flag active plugins.
|
1792 |
+
foreach ( $active_plugins_basenames as $basename ) {
|
1793 |
+
if ( isset( $all_plugins[ $basename ] ) ) {
|
1794 |
+
$all_plugins[ $basename ]['is_active'] = true;
|
1795 |
+
}
|
1796 |
+
}
|
1797 |
+
|
1798 |
+
return $all_plugins;
|
1799 |
+
}
|
1800 |
+
|
1801 |
+
|
1802 |
+
/**
|
1803 |
+
* Cached result of get_site_transient( 'update_plugins' )
|
1804 |
+
*
|
1805 |
+
* @author Vova Feldman (@svovaf)
|
1806 |
+
* @since 1.1.8
|
1807 |
+
*
|
1808 |
+
* @var object
|
1809 |
+
*/
|
1810 |
+
private static $_plugins_info;
|
1811 |
+
|
1812 |
+
/**
|
1813 |
+
* Helper function to get specified plugin's slug.
|
1814 |
+
*
|
1815 |
+
* @author Vova Feldman (@svovaf)
|
1816 |
+
* @since 1.1.8
|
1817 |
+
*
|
1818 |
+
* @param $basename
|
1819 |
+
*
|
1820 |
+
* @return string
|
1821 |
+
*/
|
1822 |
+
private static function get_plugin_slug( $basename ) {
|
1823 |
+
if ( ! isset( self::$_plugins_info ) ) {
|
1824 |
+
self::$_plugins_info = get_site_transient( 'update_plugins' );
|
1825 |
+
}
|
1826 |
+
|
1827 |
+
$slug = '';
|
1828 |
+
|
1829 |
+
if ( is_object( self::$_plugins_info ) ) {
|
1830 |
+
if ( isset( self::$_plugins_info->no_update ) &&
|
1831 |
+
isset( self::$_plugins_info->no_update[ $basename ] ) &&
|
1832 |
+
! empty( self::$_plugins_info->no_update[ $basename ]->slug )
|
1833 |
+
) {
|
1834 |
+
$slug = self::$_plugins_info->no_update[ $basename ]->slug;
|
1835 |
+
} else if ( isset( self::$_plugins_info->response ) &&
|
1836 |
+
isset( self::$_plugins_info->response[ $basename ] ) &&
|
1837 |
+
! empty( self::$_plugins_info->response[ $basename ]->slug )
|
1838 |
+
) {
|
1839 |
+
$slug = self::$_plugins_info->response[ $basename ]->slug;
|
1840 |
+
}
|
1841 |
+
}
|
1842 |
+
|
1843 |
+
if ( empty( $slug ) ) {
|
1844 |
+
// Try to find slug from FS data.
|
1845 |
+
$slug = self::find_slug_by_basename( $basename );
|
1846 |
+
}
|
1847 |
+
|
1848 |
+
if ( empty( $slug ) ) {
|
1849 |
+
// Fallback to plugin's folder name.
|
1850 |
+
$slug = dirname( $basename );
|
1851 |
+
}
|
1852 |
+
|
1853 |
+
return $slug;
|
1854 |
+
}
|
1855 |
+
|
1856 |
+
private static $_statics_loaded = false;
|
1857 |
+
|
1858 |
+
/**
|
1859 |
+
* Load static resources.
|
1860 |
+
*
|
1861 |
+
* @author Vova Feldman (@svovaf)
|
1862 |
+
* @since 1.0.1
|
1863 |
+
*/
|
1864 |
+
private static function _load_required_static() {
|
1865 |
+
if ( self::$_statics_loaded ) {
|
1866 |
+
return;
|
1867 |
+
}
|
1868 |
+
|
1869 |
+
self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
1870 |
+
|
1871 |
+
self::$_static_logger->entrance();
|
1872 |
+
|
1873 |
+
self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
|
1874 |
+
|
1875 |
+
self::$_global_admin_notices = FS_Admin_Notice_Manager::instance( 'global' );
|
1876 |
+
|
1877 |
+
add_action( 'admin_menu', array( 'Freemius', '_add_debug_section' ) );
|
1878 |
+
|
1879 |
+
add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
|
1880 |
+
|
1881 |
+
self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
|
1882 |
+
|
1883 |
+
self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
|
1884 |
+
|
1885 |
+
self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
|
1886 |
+
|
1887 |
+
if ( 0 == did_action( 'plugins_loaded' ) ) {
|
1888 |
+
add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
|
1889 |
+
}
|
1890 |
+
|
1891 |
+
self::$_statics_loaded = true;
|
1892 |
+
}
|
1893 |
+
|
1894 |
+
#----------------------------------------------------------------------------------
|
1895 |
+
#region Localization
|
1896 |
+
#----------------------------------------------------------------------------------
|
1897 |
+
|
1898 |
+
/**
|
1899 |
+
* Load framework's text domain.
|
1900 |
+
*
|
1901 |
+
* @author Vova Feldman (@svovaf)
|
1902 |
+
* @since 1.2.1
|
1903 |
+
*/
|
1904 |
+
static function _load_textdomain() {
|
1905 |
+
if ( ! is_admin() ) {
|
1906 |
+
return;
|
1907 |
+
}
|
1908 |
+
|
1909 |
+
global $fs_active_plugins;
|
1910 |
+
|
1911 |
+
// Works both for plugins and themes.
|
1912 |
+
load_plugin_textdomain(
|
1913 |
+
'freemius',
|
1914 |
+
false,
|
1915 |
+
$fs_active_plugins->newest->sdk_path . '/languages/'
|
1916 |
+
);
|
1917 |
+
}
|
1918 |
+
|
1919 |
+
#endregion
|
1920 |
+
|
1921 |
+
#----------------------------------------------------------------------------------
|
1922 |
+
#region Debugging
|
1923 |
+
#----------------------------------------------------------------------------------
|
1924 |
+
|
1925 |
+
/**
|
1926 |
+
* @author Vova Feldman (@svovaf)
|
1927 |
+
* @since 1.0.8
|
1928 |
+
*/
|
1929 |
+
static function _add_debug_section() {
|
1930 |
+
if ( ! current_user_can( 'activate_plugins' )
|
1931 |
+
&& ! current_user_can( 'switch_themes' )
|
1932 |
+
) {
|
1933 |
+
return;
|
1934 |
+
}
|
1935 |
+
|
1936 |
+
self::$_static_logger->entrance();
|
1937 |
+
|
1938 |
+
$title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
|
1939 |
+
|
1940 |
+
if ( WP_FS__DEV_MODE ) {
|
1941 |
+
// Add top-level debug menu item.
|
1942 |
+
$hook = FS_Admin_Menu_Manager::add_page(
|
1943 |
+
$title,
|
1944 |
+
$title,
|
1945 |
+
'manage_options',
|
1946 |
+
'freemius',
|
1947 |
+
array( 'Freemius', '_debug_page_render' )
|
1948 |
+
);
|
1949 |
+
} else {
|
1950 |
+
// Add hidden debug page.
|
1951 |
+
$hook = FS_Admin_Menu_Manager::add_subpage(
|
1952 |
+
null,
|
1953 |
+
$title,
|
1954 |
+
$title,
|
1955 |
+
'manage_options',
|
1956 |
+
'freemius',
|
1957 |
+
array( 'Freemius', '_debug_page_render' )
|
1958 |
+
);
|
1959 |
+
}
|
1960 |
+
|
1961 |
+
if ( ! empty( $hook ) ) {
|
1962 |
+
add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
|
1963 |
+
}
|
1964 |
+
}
|
1965 |
+
|
1966 |
+
/**
|
1967 |
+
* @author Vova Feldman (@svovaf)
|
1968 |
+
* @since 1.1.7.3
|
1969 |
+
*/
|
1970 |
+
static function _toggle_debug_mode() {
|
1971 |
+
$is_on = fs_request_get( 'is_on', false, 'post' );
|
1972 |
+
|
1973 |
+
if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
|
1974 |
+
update_option( 'fs_debug_mode', $is_on );
|
1975 |
+
|
1976 |
+
// Turn on/off storage logging.
|
1977 |
+
FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
|
1978 |
+
}
|
1979 |
+
|
1980 |
+
exit;
|
1981 |
+
}
|
1982 |
+
|
1983 |
+
/**
|
1984 |
+
* @author Vova Feldman (@svovaf)
|
1985 |
+
* @since 1.2.1.6
|
1986 |
+
*/
|
1987 |
+
static function _get_debug_log() {
|
1988 |
+
$logs = FS_Logger::load_db_logs(
|
1989 |
+
fs_request_get( 'filters', false, 'post' ),
|
1990 |
+
! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
|
1991 |
+
! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
|
1992 |
+
);
|
1993 |
+
|
1994 |
+
self::shoot_ajax_success( $logs );
|
1995 |
+
}
|
1996 |
+
|
1997 |
+
/**
|
1998 |
+
* @author Vova Feldman (@svovaf)
|
1999 |
+
* @since 1.2.1.7
|
2000 |
+
*/
|
2001 |
+
static function _get_db_option() {
|
2002 |
+
$option_name = fs_request_get( 'option_name' );
|
2003 |
+
|
2004 |
+
$value = get_option( $option_name );
|
2005 |
+
|
2006 |
+
$result = array(
|
2007 |
+
'name' => $option_name,
|
2008 |
+
);
|
2009 |
+
|
2010 |
+
if ( false !== $value ) {
|
2011 |
+
if ( ! is_string( $value ) ) {
|
2012 |
+
$value = json_encode( $value );
|
2013 |
+
}
|
2014 |
+
|
2015 |
+
$result['value'] = $value;
|
2016 |
+
}
|
2017 |
+
|
2018 |
+
self::shoot_ajax_success( $result );
|
2019 |
+
}
|
2020 |
+
|
2021 |
+
/**
|
2022 |
+
* @author Vova Feldman (@svovaf)
|
2023 |
+
* @since 1.2.1.7
|
2024 |
+
*/
|
2025 |
+
static function _set_db_option() {
|
2026 |
+
$option_name = fs_request_get( 'option_name' );
|
2027 |
+
$option_value = fs_request_get( 'option_value' );
|
2028 |
+
|
2029 |
+
if ( ! empty( $option_value ) ) {
|
2030 |
+
update_option( $option_name, $option_value );
|
2031 |
+
}
|
2032 |
+
|
2033 |
+
self::shoot_ajax_success();
|
2034 |
+
}
|
2035 |
+
|
2036 |
+
/**
|
2037 |
+
* @author Vova Feldman (@svovaf)
|
2038 |
+
* @since 1.0.8
|
2039 |
+
*/
|
2040 |
+
static function _debug_page_actions() {
|
2041 |
+
self::_clean_admin_content_section();
|
2042 |
+
|
2043 |
+
if ( fs_request_is_action( 'restart_freemius' ) ) {
|
2044 |
+
check_admin_referer( 'restart_freemius' );
|
2045 |
+
|
2046 |
+
// Clear accounts data.
|
2047 |
+
self::$_accounts->clear( true );
|
2048 |
+
|
2049 |
+
// Clear SDK reference cache.
|
2050 |
+
delete_option( 'fs_active_plugins' );
|
2051 |
+
} else if ( fs_request_is_action( 'simulate_trial' ) ) {
|
2052 |
+
check_admin_referer( 'simulate_trial' );
|
2053 |
+
|
2054 |
+
$fs = freemius( fs_request_get( 'module_id' ) );
|
2055 |
+
|
2056 |
+
// Update SDK install to at least 24 hours before.
|
2057 |
+
$fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
|
2058 |
+
// Unset the trial shown timestamp.
|
2059 |
+
unset( $fs->_storage->trial_promotion_shown );
|
2060 |
+
} else if ( fs_request_is_action( 'delete_install' ) ) {
|
2061 |
+
check_admin_referer( 'delete_install' );
|
2062 |
+
|
2063 |
+
self::_delete_site_by_slug(
|
2064 |
+
fs_request_get( 'slug' ),
|
2065 |
+
fs_request_get( 'module_type' )
|
2066 |
+
);
|
2067 |
+
} else if ( fs_request_is_action( 'download_logs' ) ) {
|
2068 |
+
check_admin_referer( 'download_logs' );
|
2069 |
+
|
2070 |
+
$download_url = FS_Logger::download_db_logs(
|
2071 |
+
fs_request_get( 'filters', false, 'post' )
|
2072 |
+
);
|
2073 |
+
|
2074 |
+
if ( false === $download_url ) {
|
2075 |
+
wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
|
2076 |
+
}
|
2077 |
+
|
2078 |
+
fs_redirect( $download_url );
|
2079 |
+
}
|
2080 |
+
}
|
2081 |
+
|
2082 |
+
/**
|
2083 |
+
* @author Vova Feldman (@svovaf)
|
2084 |
+
* @since 1.0.8
|
2085 |
+
*/
|
2086 |
+
static function _debug_page_render() {
|
2087 |
+
self::$_static_logger->entrance();
|
2088 |
+
|
2089 |
+
$vars = array(
|
2090 |
+
'plugin_sites' => self::get_all_sites(),
|
2091 |
+
'theme_sites' => self::get_all_sites( WP_FS__MODULE_TYPE_THEME ),
|
2092 |
+
'users' => self::get_all_users(),
|
2093 |
+
'addons' => self::get_all_addons(),
|
2094 |
+
'account_addons' => self::get_all_account_addons(),
|
2095 |
+
'plugin_licenses' => self::get_all_licenses(),
|
2096 |
+
'theme_licenses' => self::get_all_licenses( WP_FS__MODULE_TYPE_THEME )
|
2097 |
+
);
|
2098 |
+
|
2099 |
+
fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
|
2100 |
+
fs_require_once_template( 'debug.php', $vars );
|
2101 |
+
}
|
2102 |
+
|
2103 |
+
#endregion
|
2104 |
+
|
2105 |
+
#----------------------------------------------------------------------------------
|
2106 |
+
#region Connectivity Issues
|
2107 |
+
#----------------------------------------------------------------------------------
|
2108 |
+
|
2109 |
+
/**
|
2110 |
+
* Check if Freemius should be turned on for the current plugin install.
|
2111 |
+
*
|
2112 |
+
* Note:
|
2113 |
+
* $this->_is_on is updated in has_api_connectivity()
|
2114 |
+
*
|
2115 |
+
* @author Vova Feldman (@svovaf)
|
2116 |
+
* @since 1.0.9
|
2117 |
+
*
|
2118 |
+
* @return bool
|
2119 |
+
*/
|
2120 |
+
function is_on() {
|
2121 |
+
self::$_static_logger->entrance();
|
2122 |
+
|
2123 |
+
if ( isset( $this->_is_on ) ) {
|
2124 |
+
return $this->_is_on;
|
2125 |
+
}
|
2126 |
+
|
2127 |
+
// If already installed or pending then sure it's on :)
|
2128 |
+
if ( $this->is_registered() || $this->is_pending_activation() ) {
|
2129 |
+
$this->_is_on = true;
|
2130 |
+
|
2131 |
+
return true;
|
2132 |
+
}
|
2133 |
+
|
2134 |
+
return false;
|
2135 |
+
}
|
2136 |
+
|
2137 |
+
/**
|
2138 |
+
* @author Vova Feldman (@svovaf)
|
2139 |
+
* @since 1.1.7.3
|
2140 |
+
*
|
2141 |
+
* @param bool $flush_if_no_connectivity
|
2142 |
+
*
|
2143 |
+
* @return bool
|
2144 |
+
*/
|
2145 |
+
private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
|
2146 |
+
if ( ! isset( $this->_storage->connectivity_test ) ) {
|
2147 |
+
// Connectivity test was never executed, or cache was cleared.
|
2148 |
+
return true;
|
2149 |
+
}
|
2150 |
+
|
2151 |
+
if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
|
2152 |
+
if ( WP_FS__IS_HTTP_REQUEST ) {
|
2153 |
+
if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
|
2154 |
+
// Domain changed.
|
2155 |
+
return true;
|
2156 |
+
}
|
2157 |
+
|
2158 |
+
if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
|
2159 |
+
// Server IP changed.
|
2160 |
+
return true;
|
2161 |
+
}
|
2162 |
+
}
|
2163 |
+
}
|
2164 |
+
|
2165 |
+
if ( $this->_storage->connectivity_test['is_connected'] &&
|
2166 |
+
$this->_storage->connectivity_test['is_active']
|
2167 |
+
) {
|
2168 |
+
// API connected and Freemius is active - no need to run connectivity check.
|
2169 |
+
return false;
|
2170 |
+
}
|
2171 |
+
|
2172 |
+
if ( $flush_if_no_connectivity ) {
|
2173 |
+
/**
|
2174 |
+
* If explicitly asked to flush when no connectivity - do it only
|
2175 |
+
* if at least 10 sec passed from the last API connectivity test.
|
2176 |
+
*/
|
2177 |
+
return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
|
2178 |
+
( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
|
2179 |
+
}
|
2180 |
+
|
2181 |
+
/**
|
2182 |
+
* @since 1.1.7 Don't check for connectivity on plugin downgrade.
|
2183 |
+
*/
|
2184 |
+
$version = $this->get_plugin_version();
|
2185 |
+
if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
|
2186 |
+
// If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
|
2187 |
+
return true;
|
2188 |
+
}
|
2189 |
+
|
2190 |
+
return false;
|
2191 |
+
}
|
2192 |
+
|
2193 |
+
/**
|
2194 |
+
* @author Vova Feldman (@svovaf)
|
2195 |
+
* @since 1.1.7.4
|
2196 |
+
*
|
2197 |
+
* @return object|false
|
2198 |
+
*/
|
2199 |
+
private function ping() {
|
2200 |
+
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
|
2201 |
+
return false;
|
2202 |
+
}
|
2203 |
+
|
2204 |
+
$version = $this->get_plugin_version();
|
2205 |
+
|
2206 |
+
$is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
|
2207 |
+
|
2208 |
+
return $this->get_api_plugin_scope()->ping(
|
2209 |
+
$this->get_anonymous_id(),
|
2210 |
+
array(
|
2211 |
+
'is_update' => json_encode( $is_update ),
|
2212 |
+
'version' => $version,
|
2213 |
+
'sdk' => $this->version,
|
2214 |
+
'is_admin' => json_encode( is_admin() ),
|
2215 |
+
'is_ajax' => json_encode( self::is_ajax() ),
|
2216 |
+
'is_cron' => json_encode( self::is_cron() ),
|
2217 |
+
'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
|
2218 |
+
)
|
2219 |
+
);
|
2220 |
+
}
|
2221 |
+
|
2222 |
+
/**
|
2223 |
+
* Check if there's any connectivity issue to Freemius API.
|
2224 |
+
*
|
2225 |
+
* @author Vova Feldman (@svovaf)
|
2226 |
+
* @since 1.0.9
|
2227 |
+
*
|
2228 |
+
* @param bool $flush_if_no_connectivity
|
2229 |
+
*
|
2230 |
+
* @return bool
|
2231 |
+
*/
|
2232 |
+
function has_api_connectivity( $flush_if_no_connectivity = false ) {
|
2233 |
+
$this->_logger->entrance();
|
2234 |
+
|
2235 |
+
if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
|
2236 |
+
return $this->_has_api_connection;
|
2237 |
+
}
|
2238 |
+
|
2239 |
+
if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
|
2240 |
+
isset( $this->_storage->connectivity_test ) &&
|
2241 |
+
true === $this->_storage->connectivity_test['is_connected']
|
2242 |
+
) {
|
2243 |
+
unset( $this->_storage->connectivity_test );
|
2244 |
+
}
|
2245 |
+
|
2246 |
+
if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
|
2247 |
+
$this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
|
2248 |
+
/**
|
2249 |
+
* @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
|
2250 |
+
*
|
2251 |
+
* @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
|
2252 |
+
*/
|
2253 |
+
$this->_is_on = $this->_storage->connectivity_test['is_active'] ||
|
2254 |
+
$this->is_premium() ||
|
2255 |
+
( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
|
2256 |
+
|
2257 |
+
return $this->_has_api_connection;
|
2258 |
+
}
|
2259 |
+
|
2260 |
+
$pong = $this->ping();
|
2261 |
+
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
2262 |
+
|
2263 |
+
if ( ! $is_connected ) {
|
2264 |
+
// API failure.
|
2265 |
+
$this->_add_connectivity_issue_message( $pong );
|
2266 |
+
}
|
2267 |
+
|
2268 |
+
$this->store_connectivity_info( $pong, $is_connected );
|
2269 |
+
|
2270 |
+
return $this->_has_api_connection;
|
2271 |
+
}
|
2272 |
+
|
2273 |
+
/**
|
2274 |
+
* @author Vova Feldman (@svovaf)
|
2275 |
+
* @since 1.1.7.4
|
2276 |
+
*
|
2277 |
+
* @param object $pong
|
2278 |
+
* @param bool $is_connected
|
2279 |
+
*/
|
2280 |
+
private function store_connectivity_info( $pong, $is_connected ) {
|
2281 |
+
$this->_logger->entrance();
|
2282 |
+
|
2283 |
+
$version = $this->get_plugin_version();
|
2284 |
+
|
2285 |
+
if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
|
2286 |
+
$is_active = false;
|
2287 |
+
} else {
|
2288 |
+
$is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
|
2289 |
+
}
|
2290 |
+
|
2291 |
+
$is_active = $this->apply_filters(
|
2292 |
+
'is_on',
|
2293 |
+
$is_active,
|
2294 |
+
$this->is_plugin_update(),
|
2295 |
+
$version
|
2296 |
+
);
|
2297 |
+
|
2298 |
+
$this->_storage->connectivity_test = array(
|
2299 |
+
'is_connected' => $is_connected,
|
2300 |
+
'host' => $_SERVER['HTTP_HOST'],
|
2301 |
+
'server_ip' => WP_FS__REMOTE_ADDR,
|
2302 |
+
'is_active' => $is_active,
|
2303 |
+
'timestamp' => WP_FS__SCRIPT_START_TIME,
|
2304 |
+
// Last version with connectivity attempt.
|
2305 |
+
'version' => $version,
|
2306 |
+
);
|
2307 |
+
|
2308 |
+
$this->_has_api_connection = $is_connected;
|
2309 |
+
$this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
|
2310 |
+
}
|
2311 |
+
|
2312 |
+
/**
|
2313 |
+
* Force turning Freemius on.
|
2314 |
+
*
|
2315 |
+
* @author Vova Feldman (@svovaf)
|
2316 |
+
* @since 1.1.8.1
|
2317 |
+
*
|
2318 |
+
* @return bool TRUE if successfully turned on.
|
2319 |
+
*/
|
2320 |
+
private function turn_on() {
|
2321 |
+
$this->_logger->entrance();
|
2322 |
+
|
2323 |
+
if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
|
2324 |
+
return false;
|
2325 |
+
}
|
2326 |
+
|
2327 |
+
$updated_connectivity = $this->_storage->connectivity_test;
|
2328 |
+
$updated_connectivity['is_active'] = true;
|
2329 |
+
$updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
|
2330 |
+
$this->_storage->connectivity_test = $updated_connectivity;
|
2331 |
+
|
2332 |
+
$this->_is_on = true;
|
2333 |
+
|
2334 |
+
return true;
|
2335 |
+
}
|
2336 |
+
|
2337 |
+
/**
|
2338 |
+
* Anonymous and unique site identifier (Hash).
|
2339 |
+
*
|
2340 |
+
* @author Vova Feldman (@svovaf)
|
2341 |
+
* @since 1.1.0
|
2342 |
+
*
|
2343 |
+
* @return string
|
2344 |
+
*/
|
2345 |
+
function get_anonymous_id() {
|
2346 |
+
$unique_id = self::$_accounts->get_option( 'unique_id' );
|
2347 |
+
|
2348 |
+
if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
|
2349 |
+
$key = get_site_url();
|
2350 |
+
|
2351 |
+
// If localhost, assign microtime instead of domain.
|
2352 |
+
if ( WP_FS__IS_LOCALHOST ||
|
2353 |
+
false !== strpos( $key, 'localhost' ) ||
|
2354 |
+
false === strpos( $key, '.' )
|
2355 |
+
) {
|
2356 |
+
$key = microtime();
|
2357 |
+
}
|
2358 |
+
|
2359 |
+
/**
|
2360 |
+
* Base the unique identifier on the WP secure authentication key. Which
|
2361 |
+
* turns the key into a secret anonymous identifier.
|
2362 |
+
*
|
2363 |
+
* @author Vova Feldman (@svovaf)
|
2364 |
+
* @since 1.2.3
|
2365 |
+
*/
|
2366 |
+
$unique_id = md5( $key . SECURE_AUTH_KEY );
|
2367 |
+
|
2368 |
+
self::$_accounts->set_option( 'unique_id', $unique_id, true );
|
2369 |
+
}
|
2370 |
+
|
2371 |
+
$this->_logger->departure( $unique_id );
|
2372 |
+
|
2373 |
+
return $unique_id;
|
2374 |
+
}
|
2375 |
+
|
2376 |
+
/**
|
2377 |
+
* @author Vova Feldman (@svovaf)
|
2378 |
+
* @since 1.1.7.4
|
2379 |
+
*
|
2380 |
+
* @return \WP_User
|
2381 |
+
*/
|
2382 |
+
static function _get_current_wp_user() {
|
2383 |
+
self::require_pluggable_essentials();
|
2384 |
+
|
2385 |
+
return wp_get_current_user();
|
2386 |
+
}
|
2387 |
+
|
2388 |
+
/**
|
2389 |
+
* @author Vova Feldman (@svovaf)
|
2390 |
+
* @since 1.2.1.7
|
2391 |
+
*
|
2392 |
+
* @param string $email
|
2393 |
+
*
|
2394 |
+
* @return bool
|
2395 |
+
*/
|
2396 |
+
static function is_valid_email( $email ) {
|
2397 |
+
if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
|
2398 |
+
return false;
|
2399 |
+
}
|
2400 |
+
|
2401 |
+
$parts = explode( '@', $email );
|
2402 |
+
|
2403 |
+
if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
|
2404 |
+
return false;
|
2405 |
+
}
|
2406 |
+
|
2407 |
+
$blacklist = array(
|
2408 |
+
'admin.',
|
2409 |
+
'webmaster.',
|
2410 |
+
'localhost.',
|
2411 |
+
'dev.',
|
2412 |
+
'development.',
|
2413 |
+
'test.',
|
2414 |
+
'stage.',
|
2415 |
+
'staging.',
|
2416 |
+
);
|
2417 |
+
|
2418 |
+
// Make sure domain is not one of the blacklisted.
|
2419 |
+
foreach ( $blacklist as $invalid ) {
|
2420 |
+
if ( 0 === strpos( $parts[1], $invalid ) ) {
|
2421 |
+
return false;
|
2422 |
+
}
|
2423 |
+
}
|
2424 |
+
|
2425 |
+
// Get the UTF encoded domain name.
|
2426 |
+
$domain = idn_to_ascii( $parts[1] ) . '.';
|
2427 |
+
|
2428 |
+
return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
|
2429 |
+
}
|
2430 |
+
|
2431 |
+
/**
|
2432 |
+
* Generate API connectivity issue message.
|
2433 |
+
*
|
2434 |
+
* @author Vova Feldman (@svovaf)
|
2435 |
+
* @since 1.0.9
|
2436 |
+
*
|
2437 |
+
* @param mixed $api_result
|
2438 |
+
* @param bool $is_first_failure
|
2439 |
+
*/
|
2440 |
+
function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
|
2441 |
+
if ( ! $this->is_premium() && $this->_enable_anonymous ) {
|
2442 |
+
// Don't add message if it's the free version and can run anonymously.
|
2443 |
+
return;
|
2444 |
+
}
|
2445 |
+
|
2446 |
+
if ( ! function_exists( 'wp_nonce_url' ) ) {
|
2447 |
+
require_once ABSPATH . 'wp-includes/functions.php';
|
2448 |
+
}
|
2449 |
+
|
2450 |
+
$current_user = self::_get_current_wp_user();
|
2451 |
+
// $admin_email = get_option( 'admin_email' );
|
2452 |
+
$admin_email = $current_user->user_email;
|
2453 |
+
|
2454 |
+
// Aliases.
|
2455 |
+
$deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
|
2456 |
+
$deactivate_plugin_desc = $this->esc_html_inline( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'deactivate-plugin-desc' );
|
2457 |
+
$install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
|
2458 |
+
$install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
|
2459 |
+
$fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
|
2460 |
+
$fix_issue_desc = $this->esc_html_inline( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'fix-issue-desc' );
|
2461 |
+
/* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
|
2462 |
+
$x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
|
2463 |
+
$sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
|
2464 |
+
$happy_to_resolve_issue_asap = $this->esc_html_inline( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'happy-to-resolve-issue-asap' );
|
2465 |
+
|
2466 |
+
$message = false;
|
2467 |
+
if ( is_object( $api_result ) &&
|
2468 |
+
isset( $api_result->error ) &&
|
2469 |
+
isset( $api_result->error->code )
|
2470 |
+
) {
|
2471 |
+
switch ( $api_result->error->code ) {
|
2472 |
+
case 'curl_missing':
|
2473 |
+
$missing_methods = '';
|
2474 |
+
if ( is_array( $api_result->missing_methods ) &&
|
2475 |
+
! empty( $api_result->missing_methods )
|
2476 |
+
) {
|
2477 |
+
foreach ( $api_result->missing_methods as $m ) {
|
2478 |
+
if ( 'curl_version' === $m ) {
|
2479 |
+
continue;
|
2480 |
+
}
|
2481 |
+
|
2482 |
+
if ( ! empty( $missing_methods ) ) {
|
2483 |
+
$missing_methods .= ', ';
|
2484 |
+
}
|
2485 |
+
|
2486 |
+
$missing_methods .= sprintf( '<code>%s</code>', $m );
|
2487 |
+
}
|
2488 |
+
|
2489 |
+
if ( ! empty( $missing_methods ) ) {
|
2490 |
+
$missing_methods = sprintf(
|
2491 |
+
'<br><br><b>%s</b> %s',
|
2492 |
+
$this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
|
2493 |
+
$missing_methods
|
2494 |
+
);
|
2495 |
+
}
|
2496 |
+
}
|
2497 |
+
|
2498 |
+
$message = sprintf(
|
2499 |
+
$x_requires_access_to_api . ' ' .
|
2500 |
+
$this->esc_html_inline( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.', 'curl-missing-message' ) . ' ' .
|
2501 |
+
$missing_methods .
|
2502 |
+
' %s',
|
2503 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
2504 |
+
sprintf(
|
2505 |
+
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
2506 |
+
sprintf(
|
2507 |
+
'<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
|
2508 |
+
$this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
|
2509 |
+
' - ' . sprintf(
|
2510 |
+
$this->get_text_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'curl-missing-no-clue-desc' ),
|
2511 |
+
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
2512 |
+
)
|
2513 |
+
),
|
2514 |
+
sprintf(
|
2515 |
+
'<b>%s</b> - %s',
|
2516 |
+
$sysadmin_title,
|
2517 |
+
esc_html( sprintf( $this->get_text_inline( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the %s and reactivate it back again.', 'curl-missing-sysadmin-desc' ), $this->get_module_label( true ) ) )
|
2518 |
+
),
|
2519 |
+
sprintf(
|
2520 |
+
'<a href="%s"><b>%s</b></a> - %s',
|
2521 |
+
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
2522 |
+
$deactivate_plugin_title,
|
2523 |
+
$deactivate_plugin_desc
|
2524 |
+
)
|
2525 |
+
)
|
2526 |
+
);
|
2527 |
+
break;
|
2528 |
+
case 'cloudflare_ddos_protection':
|
2529 |
+
$message = sprintf(
|
2530 |
+
$x_requires_access_to_api . ' ' .
|
2531 |
+
$this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
|
2532 |
+
$happy_to_resolve_issue_asap .
|
2533 |
+
' %s',
|
2534 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
2535 |
+
sprintf(
|
2536 |
+
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
2537 |
+
sprintf(
|
2538 |
+
'<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
|
2539 |
+
$fix_issue_title,
|
2540 |
+
' - ' . sprintf(
|
2541 |
+
$fix_issue_desc,
|
2542 |
+
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
2543 |
+
)
|
2544 |
+
),
|
2545 |
+
sprintf(
|
2546 |
+
'<a href="%s" target="_blank"><b>%s</b></a> - %s',
|
2547 |
+
sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
|
2548 |
+
$install_previous_title,
|
2549 |
+
$install_previous_desc
|
2550 |
+
),
|
2551 |
+
sprintf(
|
2552 |
+
'<a href="%s"><b>%s</b></a> - %s',
|
2553 |
+
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
|
2554 |
+
$deactivate_plugin_title,
|
2555 |
+
$deactivate_plugin_desc
|
2556 |
+
)
|
2557 |
+
)
|
2558 |
+
);
|
2559 |
+
break;
|
2560 |
+
case 'squid_cache_block':
|
2561 |
+
$message = sprintf(
|
2562 |
+
$x_requires_access_to_api . ' ' .
|
2563 |
+
$this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
|
2564 |
+
' %s',
|
2565 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
2566 |
+
sprintf(
|
2567 |
+
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
2568 |
+
sprintf(
|
2569 |
+
'<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
|
2570 |
+
$this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
|
2571 |
+
sprintf(
|
2572 |
+
$this->esc_html_inline( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'squid-no-clue-desc' ),
|
2573 |
+
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
2574 |
+
)
|
2575 |
+
),
|
2576 |
+
sprintf(
|
2577 |
+
'<b>%s</b> - %s',
|
2578 |
+
$sysadmin_title,
|
2579 |
+
sprintf(
|
2580 |
+
$this->esc_html_inline( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the %s and activate it again.', 'squid-sysadmin-desc' ),
|
2581 |
+
// We use a filter since the plugin might require additional API connectivity.
|
2582 |
+
'<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com', 'wp.freemius.com' ) ) ) . '</b>',
|
2583 |
+
$this->_module_type
|
2584 |
+
)
|
2585 |
+
),
|
2586 |
+
sprintf(
|
2587 |
+
'<a href="%s"><b>%s</b></a> - %s',
|
2588 |
+
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
2589 |
+
$deactivate_plugin_title,
|
2590 |
+
$deactivate_plugin_desc
|
2591 |
+
)
|
2592 |
+
)
|
2593 |
+
);
|
2594 |
+
break;
|
2595 |
+
// default:
|
2596 |
+
// $message = $this->get_text_inline( 'connectivity-test-fails-message' );
|
2597 |
+
// break;
|
2598 |
+
}
|
2599 |
+
}
|
2600 |
+
|
2601 |
+
$message_id = 'failed_connect_api';
|
2602 |
+
$type = 'error';
|
2603 |
+
|
2604 |
+
$connectivity_test_fails_message = $this->esc_html_inline( 'From unknown reason, the API connectivity test failed.', 'connectivity-test-fails-message' );
|
2605 |
+
|
2606 |
+
if ( false === $message ) {
|
2607 |
+
if ( $is_first_failure ) {
|
2608 |
+
// First attempt failed.
|
2609 |
+
$message = sprintf(
|
2610 |
+
$x_requires_access_to_api . ' ' .
|
2611 |
+
$connectivity_test_fails_message . ' ' .
|
2612 |
+
$this->esc_html_inline( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?', 'connectivity-test-maybe-temporary' ) . '<br><br>' .
|
2613 |
+
'%s',
|
2614 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
2615 |
+
sprintf(
|
2616 |
+
'<div id="fs_firewall_issue_options">%s %s</div>',
|
2617 |
+
sprintf(
|
2618 |
+
'<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
|
2619 |
+
$this->get_text_inline( 'Yes - do your thing', 'yes-do-your-thing' )
|
2620 |
+
),
|
2621 |
+
sprintf(
|
2622 |
+
'<a href="%s" class="button">%s</a>',
|
2623 |
+
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
2624 |
+
$this->get_text_inline( 'No - just deactivate', 'no-deactivate' )
|
2625 |
+
)
|
2626 |
+
)
|
2627 |
+
);
|
2628 |
+
|
2629 |
+
$message_id = 'failed_connect_api_first';
|
2630 |
+
$type = 'promotion';
|
2631 |
+
} else {
|
2632 |
+
// Second connectivity attempt failed.
|
2633 |
+
$message = sprintf(
|
2634 |
+
$x_requires_access_to_api . ' ' .
|
2635 |
+
$connectivity_test_fails_message . ' ' .
|
2636 |
+
$happy_to_resolve_issue_asap .
|
2637 |
+
' %s',
|
2638 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
2639 |
+
sprintf(
|
2640 |
+
'<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
|
2641 |
+
sprintf(
|
2642 |
+
'<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
|
2643 |
+
$fix_issue_title,
|
2644 |
+
' - ' . sprintf(
|
2645 |
+
$fix_issue_desc,
|
2646 |
+
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
2647 |
+
)
|
2648 |
+
),
|
2649 |
+
sprintf(
|
2650 |
+
'<a href="%s" target="_blank"><b>%s</b></a> - %s',
|
2651 |
+
sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
|
2652 |
+
$install_previous_title,
|
2653 |
+
$install_previous_desc
|
2654 |
+
),
|
2655 |
+
sprintf(
|
2656 |
+
'<a href="%s"><b>%s</b></a> - %s',
|
2657 |
+
wp_nonce_url( 'plugins.php?action=deactivate&plugin=' . $this->_plugin_basename . '&plugin_status=all&paged=1&s=', 'deactivate-plugin_' . $this->_plugin_basename ),
|
2658 |
+
$deactivate_plugin_title,
|
2659 |
+
$deactivate_plugin_desc
|
2660 |
+
)
|
2661 |
+
)
|
2662 |
+
);
|
2663 |
+
}
|
2664 |
+
}
|
2665 |
+
|
2666 |
+
$this->_admin_notices->add_sticky(
|
2667 |
+
$message,
|
2668 |
+
$message_id,
|
2669 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
2670 |
+
$type
|
2671 |
+
);
|
2672 |
+
}
|
2673 |
+
|
2674 |
+
/**
|
2675 |
+
* Handle user request to resolve connectivity issue.
|
2676 |
+
* This method will send an email to Freemius API technical staff for resolution.
|
2677 |
+
* The email will contain server's info and installed plugins (might be caching issue).
|
2678 |
+
*
|
2679 |
+
* @author Vova Feldman (@svovaf)
|
2680 |
+
* @since 1.0.9
|
2681 |
+
*/
|
2682 |
+
function _email_about_firewall_issue() {
|
2683 |
+
$this->_admin_notices->remove_sticky( 'failed_connect_api' );
|
2684 |
+
|
2685 |
+
$pong = $this->ping();
|
2686 |
+
|
2687 |
+
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
2688 |
+
|
2689 |
+
if ( $is_connected ) {
|
2690 |
+
$this->store_connectivity_info( $pong, $is_connected );
|
2691 |
+
|
2692 |
+
echo $this->get_after_plugin_activation_redirect_url();
|
2693 |
+
exit;
|
2694 |
+
}
|
2695 |
+
|
2696 |
+
$current_user = self::_get_current_wp_user();
|
2697 |
+
$admin_email = $current_user->user_email;
|
2698 |
+
|
2699 |
+
$error_type = fs_request_get( 'error_type', 'general' );
|
2700 |
+
|
2701 |
+
switch ( $error_type ) {
|
2702 |
+
case 'squid':
|
2703 |
+
$title = 'Squid ACL Blocking Issue';
|
2704 |
+
break;
|
2705 |
+
case 'cloudflare':
|
2706 |
+
$title = 'CloudFlare Blocking Issue';
|
2707 |
+
break;
|
2708 |
+
default:
|
2709 |
+
$title = 'API Connectivity Issue';
|
2710 |
+
break;
|
2711 |
+
}
|
2712 |
+
|
2713 |
+
$custom_email_sections = array();
|
2714 |
+
|
2715 |
+
// Add 'API Error' custom email section.
|
2716 |
+
$custom_email_sections['api_error'] = array(
|
2717 |
+
'title' => 'API Error',
|
2718 |
+
'rows' => array(
|
2719 |
+
'ping' => array(
|
2720 |
+
'API Error',
|
2721 |
+
is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
|
2722 |
+
),
|
2723 |
+
)
|
2724 |
+
);
|
2725 |
+
|
2726 |
+
// Send email with technical details to resolve API connectivity issues.
|
2727 |
+
$this->send_email(
|
2728 |
+
'api@freemius.com', // recipient
|
2729 |
+
$title . ' [' . $this->get_plugin_name() . ']', // subject
|
2730 |
+
$custom_email_sections,
|
2731 |
+
array( "Reply-To: $admin_email <$admin_email>" ) // headers
|
2732 |
+
);
|
2733 |
+
|
2734 |
+
$this->_admin_notices->add_sticky(
|
2735 |
+
sprintf(
|
2736 |
+
$this->get_text_inline( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'fix-request-sent-message' ),
|
2737 |
+
'<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
|
2738 |
+
),
|
2739 |
+
'server_details_sent'
|
2740 |
+
);
|
2741 |
+
|
2742 |
+
// Action was taken, tell that API connectivity troubleshooting should be off now.
|
2743 |
+
|
2744 |
+
echo "1";
|
2745 |
+
exit;
|
2746 |
+
}
|
2747 |
+
|
2748 |
+
/**
|
2749 |
+
* Handle connectivity test retry approved by the user.
|
2750 |
+
*
|
2751 |
+
* @author Vova Feldman (@svovaf)
|
2752 |
+
* @since 1.1.7.4
|
2753 |
+
*/
|
2754 |
+
function _retry_connectivity_test() {
|
2755 |
+
$this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
|
2756 |
+
|
2757 |
+
$pong = $this->ping();
|
2758 |
+
|
2759 |
+
$is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
|
2760 |
+
|
2761 |
+
if ( $is_connected ) {
|
2762 |
+
$this->store_connectivity_info( $pong, $is_connected );
|
2763 |
+
|
2764 |
+
echo $this->get_after_plugin_activation_redirect_url();
|
2765 |
+
} else {
|
2766 |
+
// Add connectivity issue message after 2nd failed attempt.
|
2767 |
+
$this->_add_connectivity_issue_message( $pong, false );
|
2768 |
+
|
2769 |
+
echo "1";
|
2770 |
+
}
|
2771 |
+
|
2772 |
+
exit;
|
2773 |
+
}
|
2774 |
+
|
2775 |
+
static function _add_firewall_issues_javascript() {
|
2776 |
+
$params = array();
|
2777 |
+
fs_require_once_template( 'firewall-issues-js.php', $params );
|
2778 |
+
}
|
2779 |
+
|
2780 |
+
#endregion
|
2781 |
+
|
2782 |
+
#----------------------------------------------------------------------------------
|
2783 |
+
#region Email
|
2784 |
+
#----------------------------------------------------------------------------------
|
2785 |
+
|
2786 |
+
/**
|
2787 |
+
* Generates and sends an HTML email with customizable sections.
|
2788 |
+
*
|
2789 |
+
* @author Leo Fajardo (@leorw)
|
2790 |
+
* @since 1.1.2
|
2791 |
+
*
|
2792 |
+
* @param string $to_address
|
2793 |
+
* @param string $subject
|
2794 |
+
* @param array $sections
|
2795 |
+
* @param array $headers
|
2796 |
+
*
|
2797 |
+
* @return bool Whether the email contents were sent successfully.
|
2798 |
+
*/
|
2799 |
+
private function send_email(
|
2800 |
+
$to_address,
|
2801 |
+
$subject,
|
2802 |
+
$sections = array(),
|
2803 |
+
$headers = array()
|
2804 |
+
) {
|
2805 |
+
$default_sections = $this->get_email_sections();
|
2806 |
+
|
2807 |
+
// Insert new sections or replace the default email sections.
|
2808 |
+
if ( is_array( $sections ) && ! empty( $sections ) ) {
|
2809 |
+
foreach ( $sections as $section_id => $custom_section ) {
|
2810 |
+
if ( ! isset( $default_sections[ $section_id ] ) ) {
|
2811 |
+
// If the section does not exist, add it.
|
2812 |
+
$default_sections[ $section_id ] = $custom_section;
|
2813 |
+
} else {
|
2814 |
+
// If the section already exists, override it.
|
2815 |
+
$current_section = $default_sections[ $section_id ];
|
2816 |
+
|
2817 |
+
// Replace the current section's title if a custom section title exists.
|
2818 |
+
if ( isset( $custom_section['title'] ) ) {
|
2819 |
+
$current_section['title'] = $custom_section['title'];
|
2820 |
+
}
|
2821 |
+
|
2822 |
+
// Insert new rows under the current section or replace the default rows.
|
2823 |
+
if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
|
2824 |
+
foreach ( $custom_section['rows'] as $row_id => $row ) {
|
2825 |
+
$current_section['rows'][ $row_id ] = $row;
|
2826 |
+
}
|
2827 |
+
}
|
2828 |
+
|
2829 |
+
$default_sections[ $section_id ] = $current_section;
|
2830 |
+
}
|
2831 |
+
}
|
2832 |
+
}
|
2833 |
+
|
2834 |
+
$vars = array( 'sections' => $default_sections );
|
2835 |
+
$message = fs_get_template( 'email.php', $vars );
|
2836 |
+
|
2837 |
+
// Set the type of email to HTML.
|
2838 |
+
$headers[] = 'Content-type: text/html; charset=UTF-8';
|
2839 |
+
|
2840 |
+
$header_string = implode( "\r\n", $headers );
|
2841 |
+
|
2842 |
+
return wp_mail(
|
2843 |
+
$to_address,
|
2844 |
+
$subject,
|
2845 |
+
$message,
|
2846 |
+
$header_string
|
2847 |
+
);
|
2848 |
+
}
|
2849 |
+
|
2850 |
+
/**
|
2851 |
+
* Generates the data for the sections of the email content.
|
2852 |
+
*
|
2853 |
+
* @author Leo Fajardo (@leorw)
|
2854 |
+
* @since 1.1.2
|
2855 |
+
*
|
2856 |
+
* @return array
|
2857 |
+
*/
|
2858 |
+
private function get_email_sections() {
|
2859 |
+
// Retrieve the current user's information so that we can get the user's email, first name, and last name below.
|
2860 |
+
$current_user = self::_get_current_wp_user();
|
2861 |
+
|
2862 |
+
// Retrieve the cURL version information so that we can get the version number below.
|
2863 |
+
$curl_version_information = curl_version();
|
2864 |
+
|
2865 |
+
$active_plugin = self::get_active_plugins();
|
2866 |
+
|
2867 |
+
// Generate the list of active plugins separated by new line.
|
2868 |
+
$active_plugin_string = '';
|
2869 |
+
foreach ( $active_plugin as $plugin ) {
|
2870 |
+
$active_plugin_string .= sprintf(
|
2871 |
+
'<a href="%s">%s</a> [v%s]<br>',
|
2872 |
+
$plugin['PluginURI'],
|
2873 |
+
$plugin['Name'],
|
2874 |
+
$plugin['Version']
|
2875 |
+
);
|
2876 |
+
}
|
2877 |
+
|
2878 |
+
$server_ip = WP_FS__REMOTE_ADDR;
|
2879 |
+
|
2880 |
+
// Add PHP info for deeper investigation.
|
2881 |
+
ob_start();
|
2882 |
+
phpinfo();
|
2883 |
+
$php_info = ob_get_clean();
|
2884 |
+
|
2885 |
+
$api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
|
2886 |
+
|
2887 |
+
// Generate the default email sections.
|
2888 |
+
$sections = array(
|
2889 |
+
'sdk' => array(
|
2890 |
+
'title' => 'SDK',
|
2891 |
+
'rows' => array(
|
2892 |
+
'fs_version' => array( 'FS Version', $this->version ),
|
2893 |
+
'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
|
2894 |
+
)
|
2895 |
+
),
|
2896 |
+
'plugin' => array(
|
2897 |
+
'title' => ucfirst( $this->get_module_type() ),
|
2898 |
+
'rows' => array(
|
2899 |
+
'name' => array( 'Name', $this->get_plugin_name() ),
|
2900 |
+
'version' => array( 'Version', $this->get_plugin_version() )
|
2901 |
+
)
|
2902 |
+
),
|
2903 |
+
'api' => array(
|
2904 |
+
'title' => 'API Subdomain',
|
2905 |
+
'rows' => array(
|
2906 |
+
'dns' => array(
|
2907 |
+
'DNS_CNAME',
|
2908 |
+
function_exists( 'dns_get_record' ) ?
|
2909 |
+
var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) :
|
2910 |
+
'dns_get_record() disabled/blocked'
|
2911 |
+
),
|
2912 |
+
'ip' => array(
|
2913 |
+
'IP',
|
2914 |
+
function_exists( 'gethostbyname' ) ?
|
2915 |
+
gethostbyname( $api_domain ) :
|
2916 |
+
'gethostbyname() disabled/blocked'
|
2917 |
+
),
|
2918 |
+
),
|
2919 |
+
),
|
2920 |
+
'site' => array(
|
2921 |
+
'title' => 'Site',
|
2922 |
+
'rows' => array(
|
2923 |
+
'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
|
2924 |
+
'address' => array( 'Address', site_url() ),
|
2925 |
+
'host' => array(
|
2926 |
+
'HTTP_HOST',
|
2927 |
+
( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
|
2928 |
+
),
|
2929 |
+
'hosting' => array(
|
2930 |
+
'Hosting Company' => fs_request_has( 'hosting_company' ) ?
|
2931 |
+
fs_request_get( 'hosting_company' ) :
|
2932 |
+
'Unknown',
|
2933 |
+
),
|
2934 |
+
'server_addr' => array(
|
2935 |
+
'SERVER_ADDR',
|
2936 |
+
'<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
|
2937 |
+
)
|
2938 |
+
)
|
2939 |
+
),
|
2940 |
+
'user' => array(
|
2941 |
+
'title' => 'User',
|
2942 |
+
'rows' => array(
|
2943 |
+
'email' => array( 'Email', $current_user->user_email ),
|
2944 |
+
'first' => array( 'First', $current_user->user_firstname ),
|
2945 |
+
'last' => array( 'Last', $current_user->user_lastname )
|
2946 |
+
)
|
2947 |
+
),
|
2948 |
+
'plugins' => array(
|
2949 |
+
'title' => 'Plugins',
|
2950 |
+
'rows' => array(
|
2951 |
+
'active_plugins' => array( 'Active Plugins', $active_plugin_string )
|
2952 |
+
)
|
2953 |
+
),
|
2954 |
+
'php_info' => array(
|
2955 |
+
'title' => 'PHP Info',
|
2956 |
+
'rows' => array(
|
2957 |
+
'info' => array( $php_info )
|
2958 |
+
),
|
2959 |
+
)
|
2960 |
+
);
|
2961 |
+
|
2962 |
+
// Allow the sections to be modified by other code.
|
2963 |
+
$sections = $this->apply_filters( 'email_template_sections', $sections );
|
2964 |
+
|
2965 |
+
return $sections;
|
2966 |
+
}
|
2967 |
+
|
2968 |
+
#endregion
|
2969 |
+
|
2970 |
+
#----------------------------------------------------------------------------------
|
2971 |
+
#region Initialization
|
2972 |
+
#----------------------------------------------------------------------------------
|
2973 |
+
|
2974 |
+
/**
|
2975 |
+
* Init plugin's Freemius instance.
|
2976 |
+
*
|
2977 |
+
* @author Vova Feldman (@svovaf)
|
2978 |
+
* @since 1.0.1
|
2979 |
+
*
|
2980 |
+
* @param number $id
|
2981 |
+
* @param string $public_key
|
2982 |
+
* @param bool $is_live
|
2983 |
+
* @param bool $is_premium
|
2984 |
+
*/
|
2985 |
+
function init( $id, $public_key, $is_live = true, $is_premium = true ) {
|
2986 |
+
$this->_logger->entrance();
|
2987 |
+
|
2988 |
+
$this->dynamic_init( array(
|
2989 |
+
'id' => $id,
|
2990 |
+
'public_key' => $public_key,
|
2991 |
+
'is_live' => $is_live,
|
2992 |
+
'is_premium' => $is_premium,
|
2993 |
+
) );
|
2994 |
+
}
|
2995 |
+
|
2996 |
+
/**
|
2997 |
+
* Dynamic initiator, originally created to support initiation
|
2998 |
+
* with parent_id for add-ons.
|
2999 |
+
*
|
3000 |
+
* @author Vova Feldman (@svovaf)
|
3001 |
+
* @since 1.0.6
|
3002 |
+
*
|
3003 |
+
* @param array $plugin_info
|
3004 |
+
*
|
3005 |
+
* @throws Freemius_Exception
|
3006 |
+
*/
|
3007 |
+
function dynamic_init( array $plugin_info ) {
|
3008 |
+
$this->_logger->entrance();
|
3009 |
+
|
3010 |
+
$this->parse_settings( $plugin_info );
|
3011 |
+
|
3012 |
+
if ( $this->has_affiliate_program() ) {
|
3013 |
+
$this->fetch_affiliate_and_terms();
|
3014 |
+
}
|
3015 |
+
|
3016 |
+
if ( ! self::is_ajax() ) {
|
3017 |
+
if ( ! $this->is_addon() || $this->is_only_premium() ) {
|
3018 |
+
add_action( 'admin_menu', array( &$this, '_prepare_admin_menu' ), WP_FS__LOWEST_PRIORITY );
|
3019 |
+
}
|
3020 |
+
}
|
3021 |
+
|
3022 |
+
if ( $this->should_stop_execution() ) {
|
3023 |
+
return;
|
3024 |
+
}
|
3025 |
+
|
3026 |
+
if ( ! $this->is_registered() ) {
|
3027 |
+
if ( $this->is_anonymous() ) {
|
3028 |
+
// If user skipped, no need to test connectivity.
|
3029 |
+
$this->_has_api_connection = true;
|
3030 |
+
$this->_is_on = true;
|
3031 |
+
} else {
|
3032 |
+
if ( ! $this->has_api_connectivity() ) {
|
3033 |
+
if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
|
3034 |
+
$this->_admin_notices->has_sticky( 'failed_connect_api' )
|
3035 |
+
) {
|
3036 |
+
if ( ! $this->_enable_anonymous || $this->is_premium() ) {
|
3037 |
+
// If anonymous mode is disabled, add firewall admin-notice message.
|
3038 |
+
add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
|
3039 |
+
|
3040 |
+
$this->add_ajax_action( 'resolve_firewall_issues', array(
|
3041 |
+
&$this,
|
3042 |
+
'_email_about_firewall_issue'
|
3043 |
+
) );
|
3044 |
+
|
3045 |
+
$this->add_ajax_action( 'retry_connectivity_test', array(
|
3046 |
+
&$this,
|
3047 |
+
'_retry_connectivity_test'
|
3048 |
+
) );
|
3049 |
+
}
|
3050 |
+
}
|
3051 |
+
|
3052 |
+
return;
|
3053 |
+
} else {
|
3054 |
+
$this->_admin_notices->remove_sticky( array(
|
3055 |
+
'failed_connect_api_first',
|
3056 |
+
'failed_connect_api',
|
3057 |
+
) );
|
3058 |
+
|
3059 |
+
if ( $this->_anonymous_mode ) {
|
3060 |
+
// Simulate anonymous mode.
|
3061 |
+
$this->_is_anonymous = true;
|
3062 |
+
}
|
3063 |
+
}
|
3064 |
+
}
|
3065 |
+
|
3066 |
+
// Check if Freemius is on for the current plugin.
|
3067 |
+
// This MUST be executed after all the plugin variables has been loaded.
|
3068 |
+
if ( ! $this->is_on() ) {
|
3069 |
+
return;
|
3070 |
+
}
|
3071 |
+
}
|
3072 |
+
|
3073 |
+
if ( $this->has_api_connectivity() ) {
|
3074 |
+
if ( self::is_cron() ) {
|
3075 |
+
$this->hook_callback_to_sync_cron();
|
3076 |
+
} else if ( $this->is_user_in_admin() ) {
|
3077 |
+
/**
|
3078 |
+
* Schedule daily data sync cron if:
|
3079 |
+
*
|
3080 |
+
* 1. User opted-in (for tracking).
|
3081 |
+
* 2. If skipped, but later upgraded (opted-in via upgrade).
|
3082 |
+
*
|
3083 |
+
* @author Vova Feldman (@svovaf)
|
3084 |
+
* @since 1.1.7.3
|
3085 |
+
*
|
3086 |
+
*/
|
3087 |
+
if ( $this->is_registered() ) {
|
3088 |
+
if ( ! $this->is_sync_cron_on() && $this->is_tracking_allowed() ) {
|
3089 |
+
$this->schedule_sync_cron();
|
3090 |
+
}
|
3091 |
+
}
|
3092 |
+
|
3093 |
+
/**
|
3094 |
+
* Check if requested for manual blocking background sync.
|
3095 |
+
*/
|
3096 |
+
if ( fs_request_has( 'background_sync' ) ) {
|
3097 |
+
$this->run_manual_sync();
|
3098 |
+
}
|
3099 |
+
}
|
3100 |
+
}
|
3101 |
+
|
3102 |
+
if ( $this->is_registered() ) {
|
3103 |
+
$this->hook_callback_to_install_sync();
|
3104 |
+
}
|
3105 |
+
|
3106 |
+
if ( $this->is_addon() ) {
|
3107 |
+
if ( $this->is_parent_plugin_installed() ) {
|
3108 |
+
// Link to parent FS.
|
3109 |
+
$this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
|
3110 |
+
|
3111 |
+
// Get parent plugin reference.
|
3112 |
+
$this->_parent_plugin = $this->_parent->get_plugin();
|
3113 |
+
}
|
3114 |
+
}
|
3115 |
+
|
3116 |
+
if ( $this->is_user_in_admin() ) {
|
3117 |
+
if ( self::is_plugins_page() && $this->is_plugin() ) {
|
3118 |
+
$this->hook_plugin_action_links();
|
3119 |
+
}
|
3120 |
+
|
3121 |
+
if ( $this->is_addon() ) {
|
3122 |
+
if ( ! $this->is_parent_plugin_installed() ) {
|
3123 |
+
$parent_name = $this->get_option( $plugin_info, 'parent_name', null );
|
3124 |
+
|
3125 |
+
if ( isset( $plugin_info['parent'] ) ) {
|
3126 |
+
$parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
|
3127 |
+
}
|
3128 |
+
|
3129 |
+
$this->_admin_notices->add(
|
3130 |
+
( ! empty( $parent_name ) ?
|
3131 |
+
sprintf( $this->get_text_x_inline( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'addon-x-cannot-run-without-y' ), $this->get_plugin_name(), $parent_name ) :
|
3132 |
+
sprintf( $this->get_text_x_inline( '%s cannot run without the plugin.', 'addonX cannot run...', 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
|
3133 |
+
),
|
3134 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
3135 |
+
'error'
|
3136 |
+
);
|
3137 |
+
|
3138 |
+
return;
|
3139 |
+
} else {
|
3140 |
+
if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
|
3141 |
+
// If parent plugin activated, automatically install add-on for the user.
|
3142 |
+
$this->_activate_addon_account( $this->_parent );
|
3143 |
+
} else if ( ! $this->_parent->is_registered() && $this->is_registered() ) {
|
3144 |
+
// If add-on activated and parent not, automatically install parent for the user.
|
3145 |
+
$this->activate_parent_account( $this->_parent );
|
3146 |
+
}
|
3147 |
+
|
3148 |
+
// @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
|
3149 |
+
if ( $this->is_premium() ) {
|
3150 |
+
// Remove add-on download admin-notice.
|
3151 |
+
$this->_parent->_admin_notices->remove_sticky( array(
|
3152 |
+
'addon_plan_upgraded_' . $this->_slug,
|
3153 |
+
'no_addon_license_' . $this->_slug,
|
3154 |
+
) );
|
3155 |
+
}
|
3156 |
+
|
3157 |
+
// $this->deactivate_premium_only_addon_without_license();
|
3158 |
+
}
|
3159 |
+
} else {
|
3160 |
+
if ( $this->has_addons() &&
|
3161 |
+
'plugin-information' === fs_request_get( 'tab', false ) &&
|
3162 |
+
$this->get_id() == fs_request_get( 'parent_plugin_id', false )
|
3163 |
+
) {
|
3164 |
+
require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
|
3165 |
+
|
3166 |
+
new FS_Plugin_Info_Dialog( $this );
|
3167 |
+
}
|
3168 |
+
}
|
3169 |
+
|
3170 |
+
add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
|
3171 |
+
|
3172 |
+
// if ( $this->is_registered() ||
|
3173 |
+
// $this->is_anonymous() ||
|
3174 |
+
// $this->is_pending_activation()
|
3175 |
+
// ) {
|
3176 |
+
// $this->_init_admin();
|
3177 |
+
// }
|
3178 |
+
}
|
3179 |
+
|
3180 |
+
/**
|
3181 |
+
* Should be called outside `$this->is_user_in_admin()` scope
|
3182 |
+
* because the updater has some logic that needs to be executed
|
3183 |
+
* during AJAX calls.
|
3184 |
+
*
|
3185 |
+
* Currently we need to hook to the `http_request_host_is_external` filter.
|
3186 |
+
* In the future, there might be additional logic added.
|
3187 |
+
*
|
3188 |
+
* @author Vova Feldman
|
3189 |
+
* @since 1.2.1.6
|
3190 |
+
*/
|
3191 |
+
if ( $this->is_premium() && $this->has_release_on_freemius() ) {
|
3192 |
+
new FS_Plugin_Updater( $this );
|
3193 |
+
}
|
3194 |
+
|
3195 |
+
$this->do_action( 'initiated' );
|
3196 |
+
|
3197 |
+
if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
|
3198 |
+
if ( isset( $this->_storage->prev_is_premium ) ) {
|
3199 |
+
$this->apply_filters(
|
3200 |
+
'after_code_type_change',
|
3201 |
+
// New code type.
|
3202 |
+
$this->_plugin->is_premium
|
3203 |
+
);
|
3204 |
+
} else {
|
3205 |
+
// Set for code type for the first time.
|
3206 |
+
$this->_storage->prev_is_premium = $this->_plugin->is_premium;
|
3207 |
+
}
|
3208 |
+
}
|
3209 |
+
|
3210 |
+
if ( ! $this->is_addon() ) {
|
3211 |
+
if ( $this->is_registered() ) {
|
3212 |
+
// Fix for upgrade from versions < 1.0.9.
|
3213 |
+
if ( ! isset( $this->_storage->activation_timestamp ) ) {
|
3214 |
+
$this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
|
3215 |
+
}
|
3216 |
+
|
3217 |
+
$this->do_action( 'after_init_plugin_registered' );
|
3218 |
+
} else if ( $this->is_anonymous() ) {
|
3219 |
+
$this->do_action( 'after_init_plugin_anonymous' );
|
3220 |
+
} else if ( $this->is_pending_activation() ) {
|
3221 |
+
$this->do_action( 'after_init_plugin_pending_activations' );
|
3222 |
+
}
|
3223 |
+
} else {
|
3224 |
+
if ( $this->is_registered() ) {
|
3225 |
+
$this->do_action( 'after_init_addon_registered' );
|
3226 |
+
} else if ( $this->is_anonymous() ) {
|
3227 |
+
$this->do_action( 'after_init_addon_anonymous' );
|
3228 |
+
} else if ( $this->is_pending_activation() ) {
|
3229 |
+
$this->do_action( 'after_init_addon_pending_activations' );
|
3230 |
+
}
|
3231 |
+
}
|
3232 |
+
}
|
3233 |
+
|
3234 |
+
/**
|
3235 |
+
* @author Leo Fajardo (@leorw)
|
3236 |
+
*
|
3237 |
+
* @since 1.2.1.5
|
3238 |
+
*/
|
3239 |
+
function _stop_tracking_callback() {
|
3240 |
+
$this->_logger->entrance();
|
3241 |
+
|
3242 |
+
$this->check_ajax_referer( 'stop_tracking' );
|
3243 |
+
|
3244 |
+
$result = $this->stop_tracking();
|
3245 |
+
|
3246 |
+
if ( true === $result ) {
|
3247 |
+
self::shoot_ajax_success();
|
3248 |
+
}
|
3249 |
+
|
3250 |
+
$this->_logger->api_error( $result );
|
3251 |
+
|
3252 |
+
self::shoot_ajax_failure(
|
3253 |
+
sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
|
3254 |
+
( $this->is_api_error( $result ) && isset( $result->error ) ?
|
3255 |
+
$result->error->message :
|
3256 |
+
var_export( $result, true ) )
|
3257 |
+
);
|
3258 |
+
}
|
3259 |
+
|
3260 |
+
/**
|
3261 |
+
* @author Leo Fajardo (@leorw)
|
3262 |
+
* @since 1.2.1.5
|
3263 |
+
*/
|
3264 |
+
function _allow_tracking_callback() {
|
3265 |
+
$this->_logger->entrance();
|
3266 |
+
|
3267 |
+
$this->check_ajax_referer( 'allow_tracking' );
|
3268 |
+
|
3269 |
+
$result = $this->allow_tracking();
|
3270 |
+
|
3271 |
+
if ( true === $result ) {
|
3272 |
+
self::shoot_ajax_success();
|
3273 |
+
}
|
3274 |
+
|
3275 |
+
$this->_logger->api_error( $result );
|
3276 |
+
|
3277 |
+
self::shoot_ajax_failure(
|
3278 |
+
sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
|
3279 |
+
( $this->is_api_error( $result ) && isset( $result->error ) ?
|
3280 |
+
$result->error->message :
|
3281 |
+
var_export( $result, true ) )
|
3282 |
+
);
|
3283 |
+
}
|
3284 |
+
|
3285 |
+
/**
|
3286 |
+
* Opt-out from usage tracking.
|
3287 |
+
*
|
3288 |
+
* Note: This will not delete the account information but will stop all tracking.
|
3289 |
+
*
|
3290 |
+
* Returns:
|
3291 |
+
* 1. FALSE - If the user never opted-in.
|
3292 |
+
* 2. TRUE - If successfully opted-out.
|
3293 |
+
* 3. object - API result on failure.
|
3294 |
+
*
|
3295 |
+
* @author Leo Fajardo (@leorw)
|
3296 |
+
* @since 1.2.1.5
|
3297 |
+
*
|
3298 |
+
* @return bool|object
|
3299 |
+
*/
|
3300 |
+
function stop_tracking() {
|
3301 |
+
$this->_logger->entrance();
|
3302 |
+
|
3303 |
+
if ( ! $this->is_registered() ) {
|
3304 |
+
// User never opted-in.
|
3305 |
+
return false;
|
3306 |
+
}
|
3307 |
+
|
3308 |
+
if ( $this->is_tracking_prohibited() ) {
|
3309 |
+
// Already disconnected.
|
3310 |
+
return true;
|
3311 |
+
}
|
3312 |
+
|
3313 |
+
// Send update to FS.
|
3314 |
+
$result = $this->get_api_site_scope()->call( '/?fields=is_disconnected', 'put', array(
|
3315 |
+
'is_disconnected' => true
|
3316 |
+
) );
|
3317 |
+
|
3318 |
+
if ( ! $this->is_api_result_entity( $result ) ||
|
3319 |
+
! isset( $result->is_disconnected ) ||
|
3320 |
+
! $result->is_disconnected
|
3321 |
+
) {
|
3322 |
+
$this->_logger->api_error( $result );
|
3323 |
+
|
3324 |
+
return $result;
|
3325 |
+
}
|
3326 |
+
|
3327 |
+
$this->_site->is_disconnected = $result->is_disconnected;
|
3328 |
+
$this->_store_site();
|
3329 |
+
|
3330 |
+
$this->clear_sync_cron();
|
3331 |
+
|
3332 |
+
// Successfully disconnected.
|
3333 |
+
return true;
|
3334 |
+
}
|
3335 |
+
|
3336 |
+
/**
|
3337 |
+
* Opt-in back into usage tracking.
|
3338 |
+
*
|
3339 |
+
* Note: This will only work if the user opted-in previously.
|
3340 |
+
*
|
3341 |
+
* Returns:
|
3342 |
+
* 1. FALSE - If the user never opted-in.
|
3343 |
+
* 2. TRUE - If successfully opted-in back to usage tracking.
|
3344 |
+
* 3. object - API result on failure.
|
3345 |
+
*
|
3346 |
+
* @author Leo Fajardo (@leorw)
|
3347 |
+
* @since 1.2.1.5
|
3348 |
+
*
|
3349 |
+
* @return bool|object
|
3350 |
+
*/
|
3351 |
+
function allow_tracking() {
|
3352 |
+
$this->_logger->entrance();
|
3353 |
+
|
3354 |
+
if ( ! $this->is_registered() ) {
|
3355 |
+
// User never opted-in.
|
3356 |
+
return false;
|
3357 |
+
}
|
3358 |
+
|
3359 |
+
if ( $this->is_tracking_allowed() ) {
|
3360 |
+
// Tracking already allowed.
|
3361 |
+
return true;
|
3362 |
+
}
|
3363 |
+
|
3364 |
+
$result = $this->get_api_site_scope()->call( '/?is_disconnected', 'put', array(
|
3365 |
+
'is_disconnected' => false
|
3366 |
+
) );
|
3367 |
+
|
3368 |
+
if ( ! $this->is_api_result_entity( $result ) ||
|
3369 |
+
! isset( $result->is_disconnected ) ||
|
3370 |
+
$result->is_disconnected
|
3371 |
+
) {
|
3372 |
+
$this->_logger->api_error( $result );
|
3373 |
+
|
3374 |
+
return $result;
|
3375 |
+
}
|
3376 |
+
|
3377 |
+
$this->_site->is_disconnected = $result->is_disconnected;
|
3378 |
+
$this->_store_site();
|
3379 |
+
|
3380 |
+
$this->schedule_sync_cron();
|
3381 |
+
|
3382 |
+
// Successfully reconnected.
|
3383 |
+
return true;
|
3384 |
+
}
|
3385 |
+
|
3386 |
+
/**
|
3387 |
+
* If user opted-in and later disabled usage-tracking,
|
3388 |
+
* re-allow tracking for licensing and updates.
|
3389 |
+
*
|
3390 |
+
* @author Leo Fajardo (@leorw)
|
3391 |
+
*
|
3392 |
+
* @since 1.2.1.5
|
3393 |
+
*/
|
3394 |
+
private function reconnect_locally() {
|
3395 |
+
$this->_logger->entrance();
|
3396 |
+
|
3397 |
+
if ( $this->is_tracking_prohibited() &&
|
3398 |
+
$this->is_registered()
|
3399 |
+
) {
|
3400 |
+
$this->_site->is_disconnected = false;
|
3401 |
+
$this->_store_site();
|
3402 |
+
}
|
3403 |
+
}
|
3404 |
+
|
3405 |
+
/**
|
3406 |
+
* Parse plugin's settings (as defined by the plugin dev).
|
3407 |
+
*
|
3408 |
+
* @author Vova Feldman (@svovaf)
|
3409 |
+
* @since 1.1.7.3
|
3410 |
+
*
|
3411 |
+
* @param array $plugin_info
|
3412 |
+
*
|
3413 |
+
* @throws \Freemius_Exception
|
3414 |
+
*/
|
3415 |
+
private function parse_settings( &$plugin_info ) {
|
3416 |
+
$this->_logger->entrance();
|
3417 |
+
|
3418 |
+
$id = $this->get_numeric_option( $plugin_info, 'id', false );
|
3419 |
+
$public_key = $this->get_option( $plugin_info, 'public_key', false );
|
3420 |
+
$secret_key = $this->get_option( $plugin_info, 'secret_key', null );
|
3421 |
+
$parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
|
3422 |
+
$parent_name = $this->get_option( $plugin_info, 'parent_name', null );
|
3423 |
+
|
3424 |
+
/**
|
3425 |
+
* @author Vova Feldman (@svovaf)
|
3426 |
+
* @since 1.1.9 Try to pull secret key from external config.
|
3427 |
+
*/
|
3428 |
+
if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
|
3429 |
+
$secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
|
3430 |
+
}
|
3431 |
+
|
3432 |
+
if ( isset( $plugin_info['parent'] ) ) {
|
3433 |
+
$parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
|
3434 |
+
// $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
|
3435 |
+
// $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
|
3436 |
+
// $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
|
3437 |
+
}
|
3438 |
+
|
3439 |
+
if ( false === $id ) {
|
3440 |
+
throw new Freemius_Exception( array(
|
3441 |
+
'error' => array(
|
3442 |
+
'type' => 'ParameterNotSet',
|
3443 |
+
'message' => 'Plugin id parameter is not set.',
|
3444 |
+
'code' => 'plugin_id_not_set',
|
3445 |
+
'http' => 500,
|
3446 |
+
)
|
3447 |
+
) );
|
3448 |
+
}
|
3449 |
+
if ( false === $public_key ) {
|
3450 |
+
throw new Freemius_Exception( array(
|
3451 |
+
'error' => array(
|
3452 |
+
'type' => 'ParameterNotSet',
|
3453 |
+
'message' => 'Plugin public_key parameter is not set.',
|
3454 |
+
'code' => 'plugin_public_key_not_set',
|
3455 |
+
'http' => 500,
|
3456 |
+
)
|
3457 |
+
) );
|
3458 |
+
}
|
3459 |
+
|
3460 |
+
$plugin = ( $this->_plugin instanceof FS_Plugin ) ?
|
3461 |
+
$this->_plugin :
|
3462 |
+
new FS_Plugin();
|
3463 |
+
|
3464 |
+
$plugin->update( array(
|
3465 |
+
'id' => $id,
|
3466 |
+
'type' => $this->get_option( $plugin_info, 'type', $this->_module_type),
|
3467 |
+
'public_key' => $public_key,
|
3468 |
+
'slug' => $this->_slug,
|
3469 |
+
'parent_plugin_id' => $parent_id,
|
3470 |
+
'version' => $this->get_plugin_version(),
|
3471 |
+
'title' => $this->get_plugin_name(),
|
3472 |
+
'file' => $this->_plugin_basename,
|
3473 |
+
'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
|
3474 |
+
'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
|
3475 |
+
'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
|
3476 |
+
) );
|
3477 |
+
|
3478 |
+
if ( $plugin->is_updated() ) {
|
3479 |
+
// Update plugin details.
|
3480 |
+
$this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
|
3481 |
+
}
|
3482 |
+
// Set the secret key after storing the plugin, we don't want to store the key in the storage.
|
3483 |
+
$this->_plugin->secret_key = $secret_key;
|
3484 |
+
|
3485 |
+
if ( ! isset( $plugin_info['menu'] ) ) {
|
3486 |
+
$plugin_info['menu'] = array();
|
3487 |
+
|
3488 |
+
if ( ! empty( $this->_storage->sdk_last_version ) &&
|
3489 |
+
version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
|
3490 |
+
) {
|
3491 |
+
// Backward compatibility to 1.1.2
|
3492 |
+
$plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
|
3493 |
+
$plugin_info['menu_slug'] :
|
3494 |
+
$this->_slug;
|
3495 |
+
}
|
3496 |
+
}
|
3497 |
+
|
3498 |
+
$this->_menu = FS_Admin_Menu_Manager::instance(
|
3499 |
+
$this->_module_id,
|
3500 |
+
$this->_module_type,
|
3501 |
+
$this->get_unique_affix()
|
3502 |
+
);
|
3503 |
+
|
3504 |
+
$this->_menu->init( $plugin_info['menu'], $this->is_addon() );
|
3505 |
+
|
3506 |
+
$this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
|
3507 |
+
$this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
|
3508 |
+
$this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
|
3509 |
+
$this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
|
3510 |
+
$this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
|
3511 |
+
$this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
|
3512 |
+
if ( $this->_is_premium_only ) {
|
3513 |
+
// If premium only plugin, disable anonymous mode.
|
3514 |
+
$this->_enable_anonymous = false;
|
3515 |
+
$this->_anonymous_mode = false;
|
3516 |
+
} else {
|
3517 |
+
$this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
|
3518 |
+
$this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
|
3519 |
+
}
|
3520 |
+
$this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
|
3521 |
+
|
3522 |
+
if ( ! empty( $plugin_info['trial'] ) ) {
|
3523 |
+
$this->_trial_days = $this->get_numeric_option(
|
3524 |
+
$plugin_info['trial'],
|
3525 |
+
'days',
|
3526 |
+
// Default to 0 - trial without days specification.
|
3527 |
+
0
|
3528 |
+
);
|
3529 |
+
|
3530 |
+
$this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
|
3531 |
+
}
|
3532 |
+
}
|
3533 |
+
|
3534 |
+
/**
|
3535 |
+
* @param string[] $options
|
3536 |
+
* @param string $key
|
3537 |
+
* @param mixed $default
|
3538 |
+
*
|
3539 |
+
* @return bool
|
3540 |
+
*/
|
3541 |
+
private function get_option( &$options, $key, $default = false ) {
|
3542 |
+
return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
|
3543 |
+
}
|
3544 |
+
|
3545 |
+
private function get_bool_option( &$options, $key, $default = false ) {
|
3546 |
+
return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
|
3547 |
+
}
|
3548 |
+
|
3549 |
+
private function get_numeric_option( &$options, $key, $default = false ) {
|
3550 |
+
return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
|
3551 |
+
}
|
3552 |
+
|
3553 |
+
/**
|
3554 |
+
* Gate keeper.
|
3555 |
+
*
|
3556 |
+
* @author Vova Feldman (@svovaf)
|
3557 |
+
* @since 1.1.7.3
|
3558 |
+
*
|
3559 |
+
* @return bool
|
3560 |
+
*/
|
3561 |
+
private function should_stop_execution() {
|
3562 |
+
if ( empty( $this->_storage->was_plugin_loaded ) ) {
|
3563 |
+
/**
|
3564 |
+
* Don't execute Freemius until plugin was fully loaded at least once,
|
3565 |
+
* to give the opportunity for the activation hook to run before pinging
|
3566 |
+
* the API for connectivity test. This logic is relevant for the
|
3567 |
+
* identification of new plugin install vs. plugin update.
|
3568 |
+
*
|
3569 |
+
* @author Vova Feldman (@svovaf)
|
3570 |
+
* @since 1.1.9
|
3571 |
+
*/
|
3572 |
+
return true;
|
3573 |
+
}
|
3574 |
+
|
3575 |
+
if ( $this->is_activation_mode() ) {
|
3576 |
+
if ( ! is_admin() ) {
|
3577 |
+
/**
|
3578 |
+
* If in activation mode, don't execute Freemius outside of the
|
3579 |
+
* admin dashboard.
|
3580 |
+
*
|
3581 |
+
* @author Vova Feldman (@svovaf)
|
3582 |
+
* @since 1.1.7.3
|
3583 |
+
*/
|
3584 |
+
return true;
|
3585 |
+
}
|
3586 |
+
|
3587 |
+
if ( ! WP_FS__IS_HTTP_REQUEST ) {
|
3588 |
+
/**
|
3589 |
+
* If in activation and executed without HTTP context (e.g. CLI, Cronjob),
|
3590 |
+
* then don't start Freemius.
|
3591 |
+
*
|
3592 |
+
* @author Vova Feldman (@svovaf)
|
3593 |
+
* @since 1.1.6.3
|
3594 |
+
*
|
3595 |
+
* @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
|
3596 |
+
*/
|
3597 |
+
return true;
|
3598 |
+
}
|
3599 |
+
|
3600 |
+
if ( self::is_cron() ) {
|
3601 |
+
/**
|
3602 |
+
* If in activation mode, don't execute Freemius during wp crons
|
3603 |
+
* (wp crons have HTTP context - called as HTTP request).
|
3604 |
+
*
|
3605 |
+
* @author Vova Feldman (@svovaf)
|
3606 |
+
* @since 1.1.7.3
|
3607 |
+
*/
|
3608 |
+
return true;
|
3609 |
+
}
|
3610 |
+
|
3611 |
+
if ( self::is_ajax() &&
|
3612 |
+
! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
|
3613 |
+
! $this->_admin_notices->has_sticky( 'failed_connect_api' )
|
3614 |
+
) {
|
3615 |
+
/**
|
3616 |
+
* During activation, if running in AJAX mode, unless there's a sticky
|
3617 |
+
* connectivity issue notice, don't run Freemius.
|
3618 |
+
*
|
3619 |
+
* @author Vova Feldman (@svovaf)
|
3620 |
+
* @since 1.1.7.3
|
3621 |
+
*/
|
3622 |
+
return true;
|
3623 |
+
}
|
3624 |
+
}
|
3625 |
+
|
3626 |
+
return false;
|
3627 |
+
}
|
3628 |
+
|
3629 |
+
/**
|
3630 |
+
* Triggered after code type has changed.
|
3631 |
+
*
|
3632 |
+
* @author Vova Feldman (@svovaf)
|
3633 |
+
* @since 1.1.9.1
|
3634 |
+
*/
|
3635 |
+
function _after_code_type_change() {
|
3636 |
+
$this->_logger->entrance();
|
3637 |
+
|
3638 |
+
if ( $this->is_theme() ) {
|
3639 |
+
// Expire the cache of the previous tabs since the theme may
|
3640 |
+
// have setting updates after code type has changed.
|
3641 |
+
$this->_cache->expire( 'tabs' );
|
3642 |
+
$this->_cache->expire( 'tabs_stylesheets' );
|
3643 |
+
}
|
3644 |
+
|
3645 |
+
if ( $this->is_registered() ) {
|
3646 |
+
if ( ! $this->is_addon() ) {
|
3647 |
+
add_action(
|
3648 |
+
is_admin() ? 'admin_init' : 'init',
|
3649 |
+
array( &$this, '_plugin_code_type_changed' )
|
3650 |
+
);
|
3651 |
+
}
|
3652 |
+
|
3653 |
+
if ( $this->is_premium() ) {
|
3654 |
+
// Purge cached payments after switching to the premium version.
|
3655 |
+
// @todo This logic doesn't handle purging the cache for serviceware module upgrade.
|
3656 |
+
$this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" );
|
3657 |
+
}
|
3658 |
+
}
|
3659 |
+
}
|
3660 |
+
|
3661 |
+
/**
|
3662 |
+
* Handles plugin's code type change (free <--> premium).
|
3663 |
+
*
|
3664 |
+
* @author Vova Feldman (@svovaf)
|
3665 |
+
* @since 1.0.9
|
3666 |
+
*/
|
3667 |
+
function _plugin_code_type_changed() {
|
3668 |
+
$this->_logger->entrance();
|
3669 |
+
|
3670 |
+
if ( $this->is_premium() ) {
|
3671 |
+
$this->reconnect_locally();
|
3672 |
+
|
3673 |
+
// Activated premium code.
|
3674 |
+
$this->do_action( 'after_premium_version_activation' );
|
3675 |
+
|
3676 |
+
// Remove all sticky messages related to download of the premium version.
|
3677 |
+
$this->_admin_notices->remove_sticky( array(
|
3678 |
+
'trial_started',
|
3679 |
+
'plan_upgraded',
|
3680 |
+
'plan_changed',
|
3681 |
+
'license_activated',
|
3682 |
+
) );
|
3683 |
+
|
3684 |
+
if ( ! $this->is_only_premium() ) {
|
3685 |
+
$this->_admin_notices->add_sticky(
|
3686 |
+
sprintf( $this->get_text_inline( 'Premium %s version was successfully activated.', 'premium-activated-message' ), $this->_module_type ),
|
3687 |
+
'premium_activated',
|
3688 |
+
$this->get_text_x_inline( 'W00t',
|
3689 |
+
'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
|
3690 |
+
);
|
3691 |
+
}
|
3692 |
+
} else {
|
3693 |
+
// Remove sticky message related to premium code activation.
|
3694 |
+
$this->_admin_notices->remove_sticky( 'premium_activated' );
|
3695 |
+
|
3696 |
+
// Activated free code (after had the premium before).
|
3697 |
+
$this->do_action( 'after_free_version_reactivation' );
|
3698 |
+
|
3699 |
+
if ( $this->is_paying() && ! $this->is_premium() ) {
|
3700 |
+
$this->_admin_notices->add_sticky(
|
3701 |
+
sprintf(
|
3702 |
+
/* translators: %s: License type (e.g. you have a professional license) */
|
3703 |
+
$this->get_text_inline( 'You have a %s license.', 'you-have-x-license' ),
|
3704 |
+
$this->_site->plan->title
|
3705 |
+
) . $this->get_complete_upgrade_instructions(),
|
3706 |
+
'plan_upgraded',
|
3707 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
3708 |
+
);
|
3709 |
+
}
|
3710 |
+
}
|
3711 |
+
|
3712 |
+
// Schedule code type changes event.
|
3713 |
+
$this->schedule_install_sync();
|
3714 |
+
|
3715 |
+
/**
|
3716 |
+
* Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
|
3717 |
+
* triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
|
3718 |
+
* of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
|
3719 |
+
* activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
|
3720 |
+
* the main file of the "free" version will be loaded first before calling the hooked callback. Since the
|
3721 |
+
* free and premium versions are almost identical (same class or have same functions), a fatal error like
|
3722 |
+
* "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
|
3723 |
+
*/
|
3724 |
+
$this->unregister_uninstall_hook();
|
3725 |
+
|
3726 |
+
$this->clear_module_main_file_cache();
|
3727 |
+
|
3728 |
+
// Update is_premium of latest version.
|
3729 |
+
$this->_storage->prev_is_premium = $this->_plugin->is_premium;
|
3730 |
+
}
|
3731 |
+
|
3732 |
+
#endregion
|
3733 |
+
|
3734 |
+
#----------------------------------------------------------------------------------
|
3735 |
+
#region Add-ons
|
3736 |
+
#----------------------------------------------------------------------------------
|
3737 |
+
|
3738 |
+
/**
|
3739 |
+
* Check if add-on installed and activated on site.
|
3740 |
+
*
|
3741 |
+
* @author Vova Feldman (@svovaf)
|
3742 |
+
* @since 1.0.6
|
3743 |
+
*
|
3744 |
+
* @param string|number $id_or_slug
|
3745 |
+
* @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
|
3746 |
+
*
|
3747 |
+
* @return bool
|
3748 |
+
*/
|
3749 |
+
function is_addon_activated( $id_or_slug, $is_premium = null ) {
|
3750 |
+
$this->_logger->entrance();
|
3751 |
+
|
3752 |
+
$addon_id = self::get_module_id( $id_or_slug );
|
3753 |
+
$is_activated = self::has_instance( $addon_id );
|
3754 |
+
|
3755 |
+
if ( ! $is_activated ) {
|
3756 |
+
return false;
|
3757 |
+
}
|
3758 |
+
|
3759 |
+
if ( is_bool( $is_premium ) ) {
|
3760 |
+
// Check if the specified code version is activate.
|
3761 |
+
$addon = $this->get_addon_instance( $addon_id );
|
3762 |
+
$is_activated = ( $is_premium === $addon->is_premium() );
|
3763 |
+
}
|
3764 |
+
|
3765 |
+
return $is_activated;
|
3766 |
+
}
|
3767 |
+
|
3768 |
+
/**
|
3769 |
+
* Check if add-on was connected to install
|
3770 |
+
*
|
3771 |
+
* @author Vova Feldman (@svovaf)
|
3772 |
+
* @since 1.1.7
|
3773 |
+
*
|
3774 |
+
* @param string|number $id_or_slug
|
3775 |
+
*
|
3776 |
+
* @return bool
|
3777 |
+
*/
|
3778 |
+
function is_addon_connected( $id_or_slug ) {
|
3779 |
+
$this->_logger->entrance();
|
3780 |
+
|
3781 |
+
$sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
|
3782 |
+
|
3783 |
+
$addon_id = self::get_module_id( $id_or_slug );
|
3784 |
+
$addon = $this->get_addon( $addon_id );
|
3785 |
+
$slug = $addon->slug;
|
3786 |
+
if ( ! isset( $sites[ $slug ] ) ) {
|
3787 |
+
return false;
|
3788 |
+
}
|
3789 |
+
|
3790 |
+
$site = $sites[ $slug ];
|
3791 |
+
|
3792 |
+
$plugin = FS_Plugin_Manager::instance( $addon_id )->get();
|
3793 |
+
|
3794 |
+
if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
|
3795 |
+
// The given slug do NOT belong to any of the plugin's add-ons.
|
3796 |
+
return false;
|
3797 |
+
}
|
3798 |
+
|
3799 |
+
return ( is_object( $site ) &&
|
3800 |
+
is_numeric( $site->id ) &&
|
3801 |
+
is_numeric( $site->user_id ) &&
|
3802 |
+
is_object( $site->plan )
|
3803 |
+
);
|
3804 |
+
}
|
3805 |
+
|
3806 |
+
/**
|
3807 |
+
* Determines if add-on installed.
|
3808 |
+
*
|
3809 |
+
* NOTE: This is a heuristic and only works if the folder/file named as the slug.
|
3810 |
+
*
|
3811 |
+
* @author Vova Feldman (@svovaf)
|
3812 |
+
* @since 1.0.6
|
3813 |
+
*
|
3814 |
+
* @param string|number $id_or_slug
|
3815 |
+
*
|
3816 |
+
* @return bool
|
3817 |
+
*/
|
3818 |
+
function is_addon_installed( $id_or_slug ) {
|
3819 |
+
$this->_logger->entrance();
|
3820 |
+
|
3821 |
+
$addon_id = self::get_module_id( $id_or_slug );
|
3822 |
+
|
3823 |
+
return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) );
|
3824 |
+
}
|
3825 |
+
|
3826 |
+
/**
|
3827 |
+
* Get add-on basename.
|
3828 |
+
*
|
3829 |
+
* @author Vova Feldman (@svovaf)
|
3830 |
+
* @since 1.0.6
|
3831 |
+
*
|
3832 |
+
* @param string|number $id_or_slug
|
3833 |
+
*
|
3834 |
+
* @return string
|
3835 |
+
*/
|
3836 |
+
function get_addon_basename( $id_or_slug ) {
|
3837 |
+
$addon_id = self::get_module_id( $id_or_slug );
|
3838 |
+
|
3839 |
+
if ( $this->is_addon_activated( $addon_id ) ) {
|
3840 |
+
return self::instance( $addon_id )->get_plugin_basename();
|
3841 |
+
}
|
3842 |
+
|
3843 |
+
$addon = $this->get_addon( $addon_id );
|
3844 |
+
$premium_basename = "{$addon->slug}-premium/{$addon->slug}.php";
|
3845 |
+
|
3846 |
+
if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
|
3847 |
+
return $premium_basename;
|
3848 |
+
}
|
3849 |
+
|
3850 |
+
$all_plugins = $this->get_all_plugins();
|
3851 |
+
|
3852 |
+
foreach ( $all_plugins as $basename => &$data ) {
|
3853 |
+
if ( $addon->slug === $data['slug'] ||
|
3854 |
+
$addon->slug . '-premium' === $data['slug']
|
3855 |
+
) {
|
3856 |
+
return $basename;
|
3857 |
+
}
|
3858 |
+
}
|
3859 |
+
|
3860 |
+
$free_basename = "{$addon->slug}/{$addon->slug}.php";
|
3861 |
+
|
3862 |
+
return $free_basename;
|
3863 |
+
}
|
3864 |
+
|
3865 |
+
/**
|
3866 |
+
* Get installed add-ons instances.
|
3867 |
+
*
|
3868 |
+
* @author Vova Feldman (@svovaf)
|
3869 |
+
* @since 1.0.6
|
3870 |
+
*
|
3871 |
+
* @return Freemius[]
|
3872 |
+
*/
|
3873 |
+
function get_installed_addons() {
|
3874 |
+
$installed_addons = array();
|
3875 |
+
foreach ( self::$_instances as $instance ) {
|
3876 |
+
if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
|
3877 |
+
if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
|
3878 |
+
$installed_addons[] = $instance;
|
3879 |
+
}
|
3880 |
+
}
|
3881 |
+
}
|
3882 |
+
|
3883 |
+
return $installed_addons;
|
3884 |
+
}
|
3885 |
+
|
3886 |
+
/**
|
3887 |
+
* Check if any add-ons of the plugin are installed.
|
3888 |
+
*
|
3889 |
+
* @author Leo Fajardo (@leorw)
|
3890 |
+
* @since 1.1.1
|
3891 |
+
*
|
3892 |
+
* @return bool
|
3893 |
+
*/
|
3894 |
+
function has_installed_addons() {
|
3895 |
+
if ( ! $this->has_addons() ) {
|
3896 |
+
return false;
|
3897 |
+
}
|
3898 |
+
|
3899 |
+
foreach ( self::$_instances as $instance ) {
|
3900 |
+
if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
|
3901 |
+
if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
|
3902 |
+
return true;
|
3903 |
+
}
|
3904 |
+
}
|
3905 |
+
}
|
3906 |
+
|
3907 |
+
return false;
|
3908 |
+
}
|
3909 |
+
|
3910 |
+
/**
|
3911 |
+
* Tell Freemius that the current plugin is an add-on.
|
3912 |
+
*
|
3913 |
+
* @author Vova Feldman (@svovaf)
|
3914 |
+
* @since 1.0.6
|
3915 |
+
*
|
3916 |
+
* @param number $parent_plugin_id The parent plugin ID
|
3917 |
+
*/
|
3918 |
+
function init_addon( $parent_plugin_id ) {
|
3919 |
+
$this->_plugin->parent_plugin_id = $parent_plugin_id;
|
3920 |
+
}
|
3921 |
+
|
3922 |
+
/**
|
3923 |
+
* @author Vova Feldman (@svovaf)
|
3924 |
+
* @since 1.0.6
|
3925 |
+
*
|
3926 |
+
* @return bool
|
3927 |
+
*/
|
3928 |
+
function is_addon() {
|
3929 |
+
return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
|
3930 |
+
}
|
3931 |
+
|
3932 |
+
/**
|
3933 |
+
* Deactivate add-on if it's premium only and the user does't have a valid license.
|
3934 |
+
*
|
3935 |
+
* @param bool $is_after_trial_cancel
|
3936 |
+
*
|
3937 |
+
* @return bool If add-on was deactivated.
|
3938 |
+
*/
|
3939 |
+
private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
|
3940 |
+
if ( ! $this->has_free_plan() &&
|
3941 |
+
! $this->has_features_enabled_license() &&
|
3942 |
+
! $this->_has_premium_license()
|
3943 |
+
) {
|
3944 |
+
if ( $this->is_registered() ) {
|
3945 |
+
// IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
|
3946 |
+
// if (empty($this->_storage->activation_timestamp) ||
|
3947 |
+
// (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
|
3948 |
+
// ) {
|
3949 |
+
/**
|
3950 |
+
* @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
|
3951 |
+
*
|
3952 |
+
* Retry syncing the user add-on licenses.
|
3953 |
+
*/
|
3954 |
+
// Sync licenses.
|
3955 |
+
$this->_sync_licenses();
|
3956 |
+
// }
|
3957 |
+
|
3958 |
+
// Try to activate premium license.
|
3959 |
+
$this->_activate_license( true );
|
3960 |
+
}
|
3961 |
+
|
3962 |
+
if ( ! $this->has_free_plan() &&
|
3963 |
+
! $this->has_features_enabled_license() &&
|
3964 |
+
! $this->_has_premium_license()
|
3965 |
+
) {
|
3966 |
+
// @todo Check if deactivate plugins also call the deactivation hook.
|
3967 |
+
|
3968 |
+
$this->_parent->_admin_notices->add_sticky(
|
3969 |
+
sprintf(
|
3970 |
+
($is_after_trial_cancel ?
|
3971 |
+
$this->_parent->get_text_inline(
|
3972 |
+
'%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.',
|
3973 |
+
'addon-trial-cancelled-message'
|
3974 |
+
) :
|
3975 |
+
$this->_parent->get_text_inline(
|
3976 |
+
'%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
|
3977 |
+
'addon-no-license-message'
|
3978 |
+
)
|
3979 |
+
),
|
3980 |
+
'<b>' . $this->_plugin->title . '</b>'
|
3981 |
+
) . ' ' . sprintf(
|
3982 |
+
'<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s ➜</a>',
|
3983 |
+
$this->_parent->addon_url( $this->_slug ),
|
3984 |
+
esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
|
3985 |
+
$this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
|
3986 |
+
),
|
3987 |
+
'no_addon_license_' . $this->_slug,
|
3988 |
+
( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
|
3989 |
+
( $is_after_trial_cancel ? 'success' : 'error' )
|
3990 |
+
);
|
3991 |
+
|
3992 |
+
deactivate_plugins( array( $this->_plugin_basename ), true );
|
3993 |
+
|
3994 |
+
return true;
|
3995 |
+
}
|
3996 |
+
}
|
3997 |
+
|
3998 |
+
return false;
|
3999 |
+
}
|
4000 |
+
|
4001 |
+
#endregion
|
4002 |
+
|
4003 |
+
#----------------------------------------------------------------------------------
|
4004 |
+
#region Sandbox
|
4005 |
+
#----------------------------------------------------------------------------------
|
4006 |
+
|
4007 |
+
/**
|
4008 |
+
* Set Freemius into sandbox mode for debugging.
|
4009 |
+
*
|
4010 |
+
* @author Vova Feldman (@svovaf)
|
4011 |
+
* @since 1.0.4
|
4012 |
+
*
|
4013 |
+
* @param string $secret_key
|
4014 |
+
*/
|
4015 |
+
function init_sandbox( $secret_key ) {
|
4016 |
+
$this->_plugin->secret_key = $secret_key;
|
4017 |
+
|
4018 |
+
// Update plugin details.
|
4019 |
+
FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true );
|
4020 |
+
}
|
4021 |
+
|
4022 |
+
/**
|
4023 |
+
* Check if running payments in sandbox mode.
|
4024 |
+
*
|
4025 |
+
* @author Vova Feldman (@svovaf)
|
4026 |
+
* @since 1.0.4
|
4027 |
+
*
|
4028 |
+
* @return bool
|
4029 |
+
*/
|
4030 |
+
function is_payments_sandbox() {
|
4031 |
+
return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
|
4032 |
+
}
|
4033 |
+
|
4034 |
+
#endregion
|
4035 |
+
|
4036 |
+
/**
|
4037 |
+
* Check if running test vs. live plugin.
|
4038 |
+
*
|
4039 |
+
* @author Vova Feldman (@svovaf)
|
4040 |
+
* @since 1.0.5
|
4041 |
+
*
|
4042 |
+
* @return bool
|
4043 |
+
*/
|
4044 |
+
function is_live() {
|
4045 |
+
return $this->_plugin->is_live;
|
4046 |
+
}
|
4047 |
+
|
4048 |
+
/**
|
4049 |
+
* Check if the user skipped connecting the account with Freemius.
|
4050 |
+
*
|
4051 |
+
* @author Vova Feldman (@svovaf)
|
4052 |
+
* @since 1.0.7
|
4053 |
+
*
|
4054 |
+
* @return bool
|
4055 |
+
*/
|
4056 |
+
function is_anonymous() {
|
4057 |
+
if ( ! isset( $this->_is_anonymous ) ) {
|
4058 |
+
if ( ! isset( $this->_storage->is_anonymous ) ) {
|
4059 |
+
// Not skipped.
|
4060 |
+
$this->_is_anonymous = false;
|
4061 |
+
} else if ( is_bool( $this->_storage->is_anonymous ) ) {
|
4062 |
+
// For back compatibility, since the variable was boolean before.
|
4063 |
+
$this->_is_anonymous = $this->_storage->is_anonymous;
|
4064 |
+
|
4065 |
+
// Upgrade stored data format to 1.1.3 format.
|
4066 |
+
$this->set_anonymous_mode( $this->_storage->is_anonymous );
|
4067 |
+
} else {
|
4068 |
+
// Version 1.1.3 and later.
|
4069 |
+
$this->_is_anonymous = $this->_storage->is_anonymous['is'];
|
4070 |
+
}
|
4071 |
+
}
|
4072 |
+
|
4073 |
+
return $this->_is_anonymous;
|
4074 |
+
}
|
4075 |
+
|
4076 |
+
/**
|
4077 |
+
* Check if user connected his account and install pending email activation.
|
4078 |
+
*
|
4079 |
+
* @author Vova Feldman (@svovaf)
|
4080 |
+
* @since 1.0.7
|
4081 |
+
*
|
4082 |
+
* @return bool
|
4083 |
+
*/
|
4084 |
+
function is_pending_activation() {
|
4085 |
+
return $this->_storage->get( 'is_pending_activation', false );
|
4086 |
+
}
|
4087 |
+
|
4088 |
+
/**
|
4089 |
+
* Check if plugin must be WordPress.org compliant.
|
4090 |
+
*
|
4091 |
+
* @since 1.0.7
|
4092 |
+
*
|
4093 |
+
* @return bool
|
4094 |
+
*/
|
4095 |
+
function is_org_repo_compliant() {
|
4096 |
+
return $this->_is_org_compliant;
|
4097 |
+
}
|
4098 |
+
|
4099 |
+
#----------------------------------------------------------------------------------
|
4100 |
+
#region Daily Sync Cron
|
4101 |
+
#----------------------------------------------------------------------------------
|
4102 |
+
|
4103 |
+
/**
|
4104 |
+
* @author Vova Feldman (@svovaf)
|
4105 |
+
* @since 1.1.7.3
|
4106 |
+
*/
|
4107 |
+
private function run_manual_sync() {
|
4108 |
+
self::require_pluggable_essentials();
|
4109 |
+
|
4110 |
+
if ( ! $this->is_user_admin() ) {
|
4111 |
+
return;
|
4112 |
+
}
|
4113 |
+
|
4114 |
+
// Run manual sync.
|
4115 |
+
$this->_sync_cron();
|
4116 |
+
|
4117 |
+
// Reschedule next cron to run 24 hours from now (performance optimization).
|
4118 |
+
$this->clear_sync_cron();
|
4119 |
+
|
4120 |
+
$this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
|
4121 |
+
}
|
4122 |
+
|
4123 |
+
/**
|
4124 |
+
* Data sync cron job. Replaces the background sync non blocking HTTP request
|
4125 |
+
* that doesn't halt page loading.
|
4126 |
+
*
|
4127 |
+
* @author Vova Feldman (@svovaf)
|
4128 |
+
* @since 1.1.7.3
|
4129 |
+
*/
|
4130 |
+
function _sync_cron() {
|
4131 |
+
$this->_logger->entrance();
|
4132 |
+
|
4133 |
+
// Store the last time data sync was executed.
|
4134 |
+
$this->_storage->sync_timestamp = time();
|
4135 |
+
|
4136 |
+
// Check if API is temporary down.
|
4137 |
+
if ( FS_Api::is_temporary_down() ) {
|
4138 |
+
return;
|
4139 |
+
}
|
4140 |
+
|
4141 |
+
// @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
|
4142 |
+
|
4143 |
+
if ( $this->is_registered() ) {
|
4144 |
+
if ( $this->has_paid_plan() ) {
|
4145 |
+
// Initiate background plan sync.
|
4146 |
+
$this->_sync_license( true );
|
4147 |
+
|
4148 |
+
if ( $this->is_paying() ) {
|
4149 |
+
// Check for premium plugin updates.
|
4150 |
+
$this->check_updates( true );
|
4151 |
+
}
|
4152 |
+
} else {
|
4153 |
+
// Sync install (only if something changed locally).
|
4154 |
+
$this->sync_install();
|
4155 |
+
}
|
4156 |
+
}
|
4157 |
+
|
4158 |
+
$this->do_action( 'after_sync_cron' );
|
4159 |
+
}
|
4160 |
+
|
4161 |
+
/**
|
4162 |
+
* Check if sync was executed in the last $period of seconds.
|
4163 |
+
*
|
4164 |
+
* @author Vova Feldman (@svovaf)
|
4165 |
+
* @since 1.1.7.3
|
4166 |
+
*
|
4167 |
+
* @param int $period In seconds
|
4168 |
+
*
|
4169 |
+
* @return bool
|
4170 |
+
*/
|
4171 |
+
private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
4172 |
+
if ( ! isset( $this->_storage->sync_timestamp ) ) {
|
4173 |
+
return false;
|
4174 |
+
}
|
4175 |
+
|
4176 |
+
return ( $this->_storage->sync_timestamp > ( WP_FS__SCRIPT_START_TIME - $period ) );
|
4177 |
+
}
|
4178 |
+
|
4179 |
+
/**
|
4180 |
+
* @author Vova Feldman (@svovaf)
|
4181 |
+
* @since 1.1.7.3
|
4182 |
+
*
|
4183 |
+
* @return bool
|
4184 |
+
*/
|
4185 |
+
private function is_sync_cron_on() {
|
4186 |
+
/**
|
4187 |
+
* @var object $sync_cron_data
|
4188 |
+
*/
|
4189 |
+
$sync_cron_data = $this->_storage->get( 'sync_cron', null );
|
4190 |
+
|
4191 |
+
return ( ! is_null( $sync_cron_data ) && true === $sync_cron_data->on );
|
4192 |
+
}
|
4193 |
+
|
4194 |
+
/**
|
4195 |
+
* @author Vova Feldman (@svovaf)
|
4196 |
+
* @since 1.1.7.3
|
4197 |
+
*
|
4198 |
+
* @param int $start_at Defaults to now.
|
4199 |
+
* @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise,
|
4200 |
+
* schedule job to start right away.
|
4201 |
+
*/
|
4202 |
+
private function schedule_sync_cron( $start_at = WP_FS__SCRIPT_START_TIME, $randomize_start = true ) {
|
4203 |
+
$this->_logger->entrance();
|
4204 |
+
|
4205 |
+
if ( $randomize_start ) {
|
4206 |
+
// Schedule first sync with a random 12 hour time range from now.
|
4207 |
+
$start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
|
4208 |
+
}
|
4209 |
+
|
4210 |
+
// Schedule daily WP cron.
|
4211 |
+
wp_schedule_event(
|
4212 |
+
$start_at,
|
4213 |
+
'daily',
|
4214 |
+
$this->get_action_tag( 'data_sync' )
|
4215 |
+
);
|
4216 |
+
|
4217 |
+
$this->_storage->store( 'sync_cron', (object) array(
|
4218 |
+
'version' => $this->get_plugin_version(),
|
4219 |
+
'sdk_version' => $this->version,
|
4220 |
+
'timestamp' => WP_FS__SCRIPT_START_TIME,
|
4221 |
+
'on' => true,
|
4222 |
+
) );
|
4223 |
+
}
|
4224 |
+
|
4225 |
+
/**
|
4226 |
+
* Add the actual sync function to the cron job hook.
|
4227 |
+
*
|
4228 |
+
* @author Vova Feldman (@svovaf)
|
4229 |
+
* @since 1.1.7.3
|
4230 |
+
*/
|
4231 |
+
private function hook_callback_to_sync_cron() {
|
4232 |
+
$this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
|
4233 |
+
}
|
4234 |
+
|
4235 |
+
/**
|
4236 |
+
* @author Vova Feldman (@svovaf)
|
4237 |
+
* @since 1.1.7.3
|
4238 |
+
*/
|
4239 |
+
private function clear_sync_cron() {
|
4240 |
+
$this->_logger->entrance();
|
4241 |
+
|
4242 |
+
if ( ! $this->is_sync_cron_on() ) {
|
4243 |
+
return;
|
4244 |
+
}
|
4245 |
+
|
4246 |
+
$this->_storage->remove( 'sync_cron' );
|
4247 |
+
|
4248 |
+
wp_clear_scheduled_hook( $this->get_action_tag( 'data_sync' ) );
|
4249 |
+
}
|
4250 |
+
|
4251 |
+
/**
|
4252 |
+
* Unix timestamp for next sync cron execution or false if not scheduled.
|
4253 |
+
*
|
4254 |
+
* @author Vova Feldman (@svovaf)
|
4255 |
+
* @since 1.1.7.3
|
4256 |
+
*
|
4257 |
+
* @return int|false
|
4258 |
+
*/
|
4259 |
+
function next_sync_cron() {
|
4260 |
+
$this->_logger->entrance();
|
4261 |
+
|
4262 |
+
if ( ! $this->is_sync_cron_on() ) {
|
4263 |
+
return false;
|
4264 |
+
}
|
4265 |
+
|
4266 |
+
return wp_next_scheduled( $this->get_action_tag( 'data_sync' ) );
|
4267 |
+
}
|
4268 |
+
|
4269 |
+
/**
|
4270 |
+
* Unix timestamp for previous sync cron execution or false if never executed.
|
4271 |
+
*
|
4272 |
+
* @author Vova Feldman (@svovaf)
|
4273 |
+
* @since 1.1.7.3
|
4274 |
+
*
|
4275 |
+
* @return int|false
|
4276 |
+
*/
|
4277 |
+
function last_sync_cron() {
|
4278 |
+
$this->_logger->entrance();
|
4279 |
+
|
4280 |
+
return $this->_storage->get( 'sync_timestamp' );
|
4281 |
+
}
|
4282 |
+
|
4283 |
+
#endregion Daily Sync Cron ------------------------------------------------------------------
|
4284 |
+
|
4285 |
+
#----------------------------------------------------------------------------------
|
4286 |
+
#region Async Install Sync
|
4287 |
+
#----------------------------------------------------------------------------------
|
4288 |
+
|
4289 |
+
/**
|
4290 |
+
* @author Vova Feldman (@svovaf)
|
4291 |
+
* @since 1.1.7.3
|
4292 |
+
*
|
4293 |
+
* @return bool
|
4294 |
+
*/
|
4295 |
+
private function is_install_sync_scheduled() {
|
4296 |
+
/**
|
4297 |
+
* @var object $cron_data
|
4298 |
+
*/
|
4299 |
+
$cron_data = $this->_storage->get( 'install_sync_cron', null );
|
4300 |
+
|
4301 |
+
return ( ! is_null( $cron_data ) && true === $cron_data->on );
|
4302 |
+
}
|
4303 |
+
|
4304 |
+
/**
|
4305 |
+
* Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
|
4306 |
+
*
|
4307 |
+
* @author Vova Feldman (@svovaf)
|
4308 |
+
* @since 1.1.7.3
|
4309 |
+
*/
|
4310 |
+
private function schedule_install_sync() {
|
4311 |
+
$this->_logger->entrance();
|
4312 |
+
|
4313 |
+
$this->clear_install_sync_cron();
|
4314 |
+
|
4315 |
+
// Schedule immediate install sync.
|
4316 |
+
wp_schedule_single_event(
|
4317 |
+
WP_FS__SCRIPT_START_TIME,
|
4318 |
+
$this->get_action_tag( 'install_sync' )
|
4319 |
+
);
|
4320 |
+
|
4321 |
+
$this->_storage->store( 'install_sync_cron', (object) array(
|
4322 |
+
'version' => $this->get_plugin_version(),
|
4323 |
+
'sdk_version' => $this->version,
|
4324 |
+
'timestamp' => WP_FS__SCRIPT_START_TIME,
|
4325 |
+
'on' => true,
|
4326 |
+
) );
|
4327 |
+
}
|
4328 |
+
|
4329 |
+
/**
|
4330 |
+
* Unix timestamp for previous install sync cron execution or false if never executed.
|
4331 |
+
*
|
4332 |
+
* @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being
|
4333 |
+
* updated. But for sure the sync event is working.
|
4334 |
+
*
|
4335 |
+
* @author Vova Feldman (@svovaf)
|
4336 |
+
* @since 1.1.7.3
|
4337 |
+
*
|
4338 |
+
* @return int|false
|
4339 |
+
*/
|
4340 |
+
function last_install_sync() {
|
4341 |
+
$this->_logger->entrance();
|
4342 |
+
|
4343 |
+
return $this->_storage->get( 'install_sync_timestamp' );
|
4344 |
+
}
|
4345 |
+
|
4346 |
+
/**
|
4347 |
+
* Unix timestamp for next install sync cron execution or false if not scheduled.
|
4348 |
+
*
|
4349 |
+
* @author Vova Feldman (@svovaf)
|
4350 |
+
* @since 1.1.7.3
|
4351 |
+
*
|
4352 |
+
* @return int|false
|
4353 |
+
*/
|
4354 |
+
function next_install_sync() {
|
4355 |
+
$this->_logger->entrance();
|
4356 |
+
|
4357 |
+
if ( ! $this->is_install_sync_scheduled() ) {
|
4358 |
+
return false;
|
4359 |
+
}
|
4360 |
+
|
4361 |
+
return wp_next_scheduled( $this->get_action_tag( 'install_sync' ) );
|
4362 |
+
}
|
4363 |
+
|
4364 |
+
/**
|
4365 |
+
* Add the actual install sync function to the cron job hook.
|
4366 |
+
*
|
4367 |
+
* @author Vova Feldman (@svovaf)
|
4368 |
+
* @since 1.1.7.3
|
4369 |
+
*/
|
4370 |
+
private function hook_callback_to_install_sync() {
|
4371 |
+
$this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
|
4372 |
+
}
|
4373 |
+
|
4374 |
+
/**
|
4375 |
+
* @author Vova Feldman (@svovaf)
|
4376 |
+
* @since 1.1.7.3
|
4377 |
+
*/
|
4378 |
+
private function clear_install_sync_cron() {
|
4379 |
+
$this->_logger->entrance();
|
4380 |
+
|
4381 |
+
if ( ! $this->is_install_sync_scheduled() ) {
|
4382 |
+
return;
|
4383 |
+
}
|
4384 |
+
|
4385 |
+
$this->_storage->remove( 'install_sync_cron' );
|
4386 |
+
|
4387 |
+
wp_clear_scheduled_hook( $this->get_action_tag( 'install_sync' ) );
|
4388 |
+
}
|
4389 |
+
|
4390 |
+
/**
|
4391 |
+
* @author Vova Feldman (@svovaf)
|
4392 |
+
* @since 1.1.7.3
|
4393 |
+
*/
|
4394 |
+
public function _run_sync_install() {
|
4395 |
+
$this->_logger->entrance();
|
4396 |
+
|
4397 |
+
// Update last install sync timestamp.
|
4398 |
+
$this->_storage->install_sync_timestamp = time();
|
4399 |
+
|
4400 |
+
$this->sync_install( array(), true );
|
4401 |
+
}
|
4402 |
+
|
4403 |
+
#endregion Async Install Sync ------------------------------------------------------------------
|
4404 |
+
|
4405 |
+
/**
|
4406 |
+
* Show a notice that activation is currently pending.
|
4407 |
+
*
|
4408 |
+
* @author Vova Feldman (@svovaf)
|
4409 |
+
* @since 1.0.7
|
4410 |
+
*
|
4411 |
+
* @param bool|string $email
|
4412 |
+
* @param bool $is_pending_trial Since 1.2.1.5
|
4413 |
+
*/
|
4414 |
+
function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) {
|
4415 |
+
if ( ! is_string( $email ) ) {
|
4416 |
+
$current_user = self::_get_current_wp_user();
|
4417 |
+
$email = $current_user->user_email;
|
4418 |
+
}
|
4419 |
+
|
4420 |
+
$this->_admin_notices->add_sticky(
|
4421 |
+
sprintf(
|
4422 |
+
$this->get_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message' ),
|
4423 |
+
'<b>' . $this->get_plugin_name() . '</b>',
|
4424 |
+
'<b>' . $email . '</b>',
|
4425 |
+
( $is_pending_trial ?
|
4426 |
+
$this->get_text_inline( 'start the trial', 'start-the-trial' ) :
|
4427 |
+
$this->get_text_inline( 'complete the install', 'complete-the-install' ) )
|
4428 |
+
),
|
4429 |
+
'activation_pending',
|
4430 |
+
'Thanks!'
|
4431 |
+
);
|
4432 |
+
}
|
4433 |
+
|
4434 |
+
/**
|
4435 |
+
* Check if currently in plugin activation.
|
4436 |
+
*
|
4437 |
+
* @author Vova Feldman (@svovaf)
|
4438 |
+
* @since 1.1.4
|
4439 |
+
*
|
4440 |
+
* @return bool
|
4441 |
+
*/
|
4442 |
+
function is_plugin_activation() {
|
4443 |
+
return get_option( 'fs_'
|
4444 |
+
. ( $this->is_plugin() ? '' : $this->_module_type . '_' )
|
4445 |
+
. "{$this->_slug}_activated", false );
|
4446 |
+
}
|
4447 |
+
|
4448 |
+
/**
|
4449 |
+
*
|
4450 |
+
* NOTE: admin_menu action executed before admin_init.
|
4451 |
+
*
|
4452 |
+
* @author Vova Feldman (@svovaf)
|
4453 |
+
* @since 1.0.7
|
4454 |
+
*/
|
4455 |
+
function _admin_init_action() {
|
4456 |
+
/**
|
4457 |
+
* Automatically redirect to connect/activation page after plugin activation.
|
4458 |
+
*
|
4459 |
+
* @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
|
4460 |
+
*/
|
4461 |
+
if ( $this->is_plugin_activation() ) {
|
4462 |
+
delete_option( 'fs_'
|
4463 |
+
. ( $this->is_plugin() ? '' : $this->_module_type . '_' )
|
4464 |
+
. "{$this->_slug}_activated" );
|
4465 |
+
|
4466 |
+
if ( ! function_exists( 'is_network_admin' ) || ! is_network_admin() ) {
|
4467 |
+
$this->_redirect_on_activation_hook();
|
4468 |
+
|
4469 |
+
return;
|
4470 |
+
}
|
4471 |
+
}
|
4472 |
+
|
4473 |
+
if ( fs_request_is_action( $this->get_unique_affix() . '_skip_activation' ) ) {
|
4474 |
+
check_admin_referer( $this->get_unique_affix() . '_skip_activation' );
|
4475 |
+
|
4476 |
+
$this->skip_connection();
|
4477 |
+
|
4478 |
+
fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) );
|
4479 |
+
}
|
4480 |
+
|
4481 |
+
if ( ! $this->is_addon() && ! $this->is_registered() && ! $this->is_anonymous() ) {
|
4482 |
+
if ( ! $this->is_pending_activation() ) {
|
4483 |
+
if ( ! $this->_menu->is_main_settings_page() ) {
|
4484 |
+
/**
|
4485 |
+
* If a user visits any other admin page before activating the premium-only theme with a valid
|
4486 |
+
* license, reactivate the previous theme.
|
4487 |
+
*
|
4488 |
+
* @author Leo Fajardo (@leorw)
|
4489 |
+
* @since 1.2.2
|
4490 |
+
*/
|
4491 |
+
if ( $this->is_theme()
|
4492 |
+
&& $this->is_only_premium()
|
4493 |
+
&& ! $this->has_settings_menu()
|
4494 |
+
&& ! isset( $_REQUEST['fs_action'] )
|
4495 |
+
&& $this->can_activate_previous_theme()
|
4496 |
+
) {
|
4497 |
+
$this->activate_previous_theme();
|
4498 |
+
|
4499 |
+
return;
|
4500 |
+
}
|
4501 |
+
|
4502 |
+
if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
|
4503 |
+
// Show notice for new plugin installations.
|
4504 |
+
$this->_admin_notices->add(
|
4505 |
+
sprintf(
|
4506 |
+
$this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
|
4507 |
+
sprintf( '<b><a href="%s">%s</a></b>',
|
4508 |
+
$this->get_activation_url(),
|
4509 |
+
sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
|
4510 |
+
'%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
|
4511 |
+
)
|
4512 |
+
),
|
4513 |
+
'',
|
4514 |
+
'update-nag'
|
4515 |
+
);
|
4516 |
+
} else {
|
4517 |
+
if ( ! isset( $this->_storage->sticky_optin_added ) ) {
|
4518 |
+
$this->_storage->sticky_optin_added = true;
|
4519 |
+
|
4520 |
+
// Show notice for new plugin installations.
|
4521 |
+
$this->_admin_notices->add_sticky(
|
4522 |
+
sprintf(
|
4523 |
+
$this->get_text_inline( 'We made a few tweaks to the %s, %s', 'few-plugin-tweaks' ),
|
4524 |
+
$this->_module_type,
|
4525 |
+
sprintf( '<b><a href="%s">%s</a></b>',
|
4526 |
+
$this->get_activation_url(),
|
4527 |
+
sprintf( $this->get_text_inline( 'Opt in to make "%s" Better!', 'optin-x-now' ), $this->get_plugin_name() )
|
4528 |
+
)
|
4529 |
+
),
|
4530 |
+
'connect_account',
|
4531 |
+
'',
|
4532 |
+
'update-nag'
|
4533 |
+
);
|
4534 |
+
}
|
4535 |
+
|
4536 |
+
if ( $this->has_filter( 'optin_pointer_element' ) ) {
|
4537 |
+
// Don't show admin nag if plugin update.
|
4538 |
+
wp_enqueue_script( 'wp-pointer' );
|
4539 |
+
wp_enqueue_style( 'wp-pointer' );
|
4540 |
+
|
4541 |
+
$this->_enqueue_connect_essentials();
|
4542 |
+
|
4543 |
+
add_action( 'admin_print_footer_scripts', array(
|
4544 |
+
$this,
|
4545 |
+
'_add_connect_pointer_script'
|
4546 |
+
) );
|
4547 |
+
}
|
4548 |
+
}
|
4549 |
+
}
|
4550 |
+
}
|
4551 |
+
|
4552 |
+
if ( $this->is_theme() &&
|
4553 |
+
$this->_menu->is_main_settings_page()
|
4554 |
+
) {
|
4555 |
+
$this->_show_theme_activation_optin_dialog();
|
4556 |
+
}
|
4557 |
+
}
|
4558 |
+
|
4559 |
+
$this->_add_upgrade_action_link();
|
4560 |
+
}
|
4561 |
+
|
4562 |
+
/**
|
4563 |
+
* Enqueue connect requires scripts and styles.
|
4564 |
+
*
|
4565 |
+
* @author Vova Feldman (@svovaf)
|
4566 |
+
* @since 1.1.4
|
4567 |
+
*/
|
4568 |
+
function _enqueue_connect_essentials() {
|
4569 |
+
wp_enqueue_script( 'jquery' );
|
4570 |
+
wp_enqueue_script( 'json2' );
|
4571 |
+
|
4572 |
+
fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
|
4573 |
+
fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
|
4574 |
+
|
4575 |
+
fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
|
4576 |
+
}
|
4577 |
+
|
4578 |
+
/**
|
4579 |
+
* Add connect / opt-in pointer.
|
4580 |
+
*
|
4581 |
+
* @author Vova Feldman (@svovaf)
|
4582 |
+
* @since 1.1.4
|
4583 |
+
*/
|
4584 |
+
function _add_connect_pointer_script() {
|
4585 |
+
$vars = array( 'id' => $this->_module_id );
|
4586 |
+
$pointer_content = fs_get_template( 'connect.php', $vars );
|
4587 |
+
?>
|
4588 |
+
<script type="text/javascript">// <![CDATA[
|
4589 |
+
jQuery(document).ready(function ($) {
|
4590 |
+
if ('undefined' !== typeof(jQuery().pointer)) {
|
4591 |
+
|
4592 |
+
var element = <?php echo $this->apply_filters( 'optin_pointer_element', '$("#non_existing_element");' ) ?>;
|
4593 |
+
|
4594 |
+
if (element.length > 0) {
|
4595 |
+
var optin = $(element).pointer($.extend(true, {}, {
|
4596 |
+
content : <?php echo json_encode( $pointer_content ) ?>,
|
4597 |
+
position : {
|
4598 |
+
edge : 'left',
|
4599 |
+
align: 'center'
|
4600 |
+
},
|
4601 |
+
buttons : function () {
|
4602 |
+
// Don't show pointer buttons.
|
4603 |
+
return '';
|
4604 |
+
},
|
4605 |
+
pointerWidth: 482
|
4606 |
+
}, <?php echo $this->apply_filters( 'optin_pointer_options_json', '{}' ) ?>));
|
4607 |
+
|
4608 |
+
<?php
|
4609 |
+
echo $this->apply_filters( 'optin_pointer_execute', "
|
4610 |
+
|
4611 |
+
optin.pointer('open');
|
4612 |
+
|
4613 |
+
// Tag the opt-in pointer with custom class.
|
4614 |
+
$('.wp-pointer #fs_connect')
|
4615 |
+
.parents('.wp-pointer.wp-pointer-top')
|
4616 |
+
.addClass('fs-opt-in-pointer');
|
4617 |
+
|
4618 |
+
", 'element', 'optin' ) ?>
|
4619 |
+
}
|
4620 |
+
}
|
4621 |
+
});
|
4622 |
+
// ]]></script>
|
4623 |
+
<?php
|
4624 |
+
}
|
4625 |
+
|
4626 |
+
/**
|
4627 |
+
* Return current page's URL.
|
4628 |
+
*
|
4629 |
+
* @author Vova Feldman (@svovaf)
|
4630 |
+
* @since 1.0.7
|
4631 |
+
*
|
4632 |
+
* @return string
|
4633 |
+
*/
|
4634 |
+
function current_page_url() {
|
4635 |
+
$url = 'http';
|
4636 |
+
|
4637 |
+
if ( isset( $_SERVER["HTTPS"] ) ) {
|
4638 |
+
if ( $_SERVER["HTTPS"] == "on" ) {
|
4639 |
+
$url .= "s";
|
4640 |
+
}
|
4641 |
+
}
|
4642 |
+
$url .= "://";
|
4643 |
+
if ( $_SERVER["SERVER_PORT"] != "80" ) {
|
4644 |
+
$url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
|
4645 |
+
} else {
|
4646 |
+
$url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
|
4647 |
+
}
|
4648 |
+
|
4649 |
+
return esc_url( $url );
|
4650 |
+
}
|
4651 |
+
|
4652 |
+
/**
|
4653 |
+
* Check if the current page is the plugin's main admin settings page.
|
4654 |
+
*
|
4655 |
+
* @author Vova Feldman (@svovaf)
|
4656 |
+
* @since 1.0.7
|
4657 |
+
*
|
4658 |
+
* @return bool
|
4659 |
+
*/
|
4660 |
+
function _is_plugin_page() {
|
4661 |
+
return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
|
4662 |
+
fs_is_plugin_page( $this->_slug );
|
4663 |
+
}
|
4664 |
+
|
4665 |
+
/* Events
|
4666 |
+
------------------------------------------------------------------------------------------------------------------*/
|
4667 |
+
/**
|
4668 |
+
* Delete site install from Database.
|
4669 |
+
*
|
4670 |
+
* @author Vova Feldman (@svovaf)
|
4671 |
+
* @since 1.0.1
|
4672 |
+
*
|
4673 |
+
* @param bool $store
|
4674 |
+
*/
|
4675 |
+
function _delete_site( $store = true ) {
|
4676 |
+
self::_delete_site_by_slug( $this->_slug, $this->_module_type, $store );
|
4677 |
+
}
|
4678 |
+
|
4679 |
+
/**
|
4680 |
+
* Delete site install from Database.
|
4681 |
+
*
|
4682 |
+
* @author Vova Feldman (@svovaf)
|
4683 |
+
* @since 1.2.2.7
|
4684 |
+
*
|
4685 |
+
* @param string $slug
|
4686 |
+
* @param string $module_type
|
4687 |
+
* @param bool $store
|
4688 |
+
*/
|
4689 |
+
static function _delete_site_by_slug($slug, $module_type, $store = true ) {
|
4690 |
+
$sites = self::get_all_sites( $module_type );
|
4691 |
+
|
4692 |
+
if ( isset( $sites[ $slug ] ) ) {
|
4693 |
+
unset( $sites[ $slug ] );
|
4694 |
+
}
|
4695 |
+
|
4696 |
+
self::set_account_option_by_module( $module_type, 'sites', $sites, $store );
|
4697 |
+
}
|
4698 |
+
|
4699 |
+
/**
|
4700 |
+
* Delete plugin's plans information.
|
4701 |
+
*
|
4702 |
+
* @param bool $store Flush to Database if true.
|
4703 |
+
*
|
4704 |
+
* @author Vova Feldman (@svovaf)
|
4705 |
+
* @since 1.0.9
|
4706 |
+
*/
|
4707 |
+
private function _delete_plans( $store = true ) {
|
4708 |
+
$this->_logger->entrance();
|
4709 |
+
|
4710 |
+
$plans = self::get_all_plans( $this->_module_type );
|
4711 |
+
|
4712 |
+
unset( $plans[ $this->_slug ] );
|
4713 |
+
|
4714 |
+
$this->set_account_option( 'plans', $plans, $store );
|
4715 |
+
}
|
4716 |
+
|
4717 |
+
/**
|
4718 |
+
* Delete all plugin licenses.
|
4719 |
+
*
|
4720 |
+
* @author Vova Feldman (@svovaf)
|
4721 |
+
* @since 1.0.9
|
4722 |
+
*
|
4723 |
+
* @param bool $store
|
4724 |
+
* @param string|bool $plugin_slug
|
4725 |
+
*/
|
4726 |
+
private function _delete_licenses( $store = true, $plugin_slug = false ) {
|
4727 |
+
$this->_logger->entrance();
|
4728 |
+
|
4729 |
+
$all_licenses = self::get_all_licenses( $this->_module_type );
|
4730 |
+
|
4731 |
+
if ( ! is_string( $plugin_slug ) ) {
|
4732 |
+
$plugin_slug = $this->_slug;
|
4733 |
+
}
|
4734 |
+
|
4735 |
+
unset( $all_licenses[ $plugin_slug ] );
|
4736 |
+
|
4737 |
+
$this->set_account_option( 'licenses', $all_licenses, $store );
|
4738 |
+
}
|
4739 |
+
|
4740 |
+
/**
|
4741 |
+
* Check if Freemius was added on new plugin installation.
|
4742 |
+
*
|
4743 |
+
* @author Vova Feldman (@svovaf)
|
4744 |
+
* @since 1.1.5
|
4745 |
+
*
|
4746 |
+
* @return bool
|
4747 |
+
*/
|
4748 |
+
function is_plugin_new_install() {
|
4749 |
+
return isset( $this->_storage->is_plugin_new_install ) &&
|
4750 |
+
$this->_storage->is_plugin_new_install;
|
4751 |
+
}
|
4752 |
+
|
4753 |
+
/**
|
4754 |
+
* Check if it's the first plugin release that is running Freemius.
|
4755 |
+
*
|
4756 |
+
* @author Vova Feldman (@svovaf)
|
4757 |
+
* @since 1.2.1.5
|
4758 |
+
*
|
4759 |
+
* @return bool
|
4760 |
+
*/
|
4761 |
+
function is_first_freemius_powered_version() {
|
4762 |
+
return empty( $this->_storage->plugin_last_version );
|
4763 |
+
}
|
4764 |
+
|
4765 |
+
/**
|
4766 |
+
* @author Leo Fajardo (@leorw)
|
4767 |
+
* @since 1.2.2
|
4768 |
+
*
|
4769 |
+
* @return bool|string
|
4770 |
+
*/
|
4771 |
+
private function get_previous_theme_slug() {
|
4772 |
+
return isset( $this->_storage->previous_theme ) ?
|
4773 |
+
$this->_storage->previous_theme :
|
4774 |
+
false;
|
4775 |
+
}
|
4776 |
+
|
4777 |
+
/**
|
4778 |
+
* @author Leo Fajardo (@leorw)
|
4779 |
+
* @since 1.2.2
|
4780 |
+
*
|
4781 |
+
* @return string
|
4782 |
+
*/
|
4783 |
+
private function can_activate_previous_theme() {
|
4784 |
+
$slug = $this->get_previous_theme_slug();
|
4785 |
+
if ( false !== $slug && current_user_can( 'switch_themes' ) ) {
|
4786 |
+
$theme_instance = wp_get_theme( $slug );
|
4787 |
+
|
4788 |
+
return $theme_instance->exists();
|
4789 |
+
}
|
4790 |
+
|
4791 |
+
return false;
|
4792 |
+
}
|
4793 |
+
|
4794 |
+
/**
|
4795 |
+
* @author Leo Fajardo (@leorw)
|
4796 |
+
* @since 1.2.2
|
4797 |
+
*
|
4798 |
+
* @return string
|
4799 |
+
*/
|
4800 |
+
private function activate_previous_theme() {
|
4801 |
+
switch_theme( $this->get_previous_theme_slug() );
|
4802 |
+
unset( $this->_storage->previous_theme );
|
4803 |
+
|
4804 |
+
global $pagenow;
|
4805 |
+
if ( 'themes.php' === $pagenow ) {
|
4806 |
+
/**
|
4807 |
+
* Refresh the active theme information.
|
4808 |
+
*
|
4809 |
+
* @author Leo Fajardo (@leorw)
|
4810 |
+
* @since 1.2.2
|
4811 |
+
*/
|
4812 |
+
fs_redirect( admin_url( $pagenow ) );
|
4813 |
+
}
|
4814 |
+
}
|
4815 |
+
|
4816 |
+
/**
|
4817 |
+
* @author Leo Fajardo (@leorw)
|
4818 |
+
* @since 1.2.2
|
4819 |
+
*
|
4820 |
+
* @return string
|
4821 |
+
*/
|
4822 |
+
function get_previous_theme_activation_url() {
|
4823 |
+
if ( ! $this->can_activate_previous_theme() ) {
|
4824 |
+
return '';
|
4825 |
+
}
|
4826 |
+
|
4827 |
+
/**
|
4828 |
+
* Activation URL
|
4829 |
+
*
|
4830 |
+
* @author Leo Fajardo (@leorw)
|
4831 |
+
* @since 1.2.2
|
4832 |
+
*/
|
4833 |
+
return wp_nonce_url(
|
4834 |
+
admin_url( 'themes.php?action=activate&stylesheet=' . urlencode( $this->get_previous_theme_slug() ) ),
|
4835 |
+
'switch-theme_' . $this->get_previous_theme_slug()
|
4836 |
+
);
|
4837 |
+
}
|
4838 |
+
|
4839 |
+
/**
|
4840 |
+
* Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in
|
4841 |
+
* form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is
|
4842 |
+
* activated, the close button will appear and will reactivate the previous theme if clicked. If the previous
|
4843 |
+
* theme doesn't exist, then there will be no close button.
|
4844 |
+
*
|
4845 |
+
* @author Leo Fajardo (@leorw)
|
4846 |
+
* @since 1.2.2
|
4847 |
+
*
|
4848 |
+
* @param string $slug_or_name Old theme's slug or name.
|
4849 |
+
* @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
|
4850 |
+
*/
|
4851 |
+
function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) {
|
4852 |
+
$this->_storage->previous_theme = ( false !== $old_theme ) ?
|
4853 |
+
$old_theme->get_stylesheet() :
|
4854 |
+
$slug_or_name;
|
4855 |
+
|
4856 |
+
$this->_activate_plugin_event_hook();
|
4857 |
+
}
|
4858 |
+
|
4859 |
+
/**
|
4860 |
+
* Plugin activated hook.
|
4861 |
+
*
|
4862 |
+
* @author Vova Feldman (@svovaf)
|
4863 |
+
* @since 1.0.1
|
4864 |
+
*
|
4865 |
+
* @uses FS_Api
|
4866 |
+
*/
|
4867 |
+
function _activate_plugin_event_hook() {
|
4868 |
+
$this->_logger->entrance( 'slug = ' . $this->_slug );
|
4869 |
+
|
4870 |
+
if ( ! $this->is_user_admin() ) {
|
4871 |
+
return;
|
4872 |
+
}
|
4873 |
+
|
4874 |
+
$this->unregister_uninstall_hook();
|
4875 |
+
|
4876 |
+
// Clear API cache on activation.
|
4877 |
+
FS_Api::clear_cache();
|
4878 |
+
|
4879 |
+
$is_premium_version_activation = ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) );
|
4880 |
+
|
4881 |
+
$this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
|
4882 |
+
|
4883 |
+
// 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
|
4884 |
+
// 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
|
4885 |
+
$other_version_basename = $is_premium_version_activation ?
|
4886 |
+
$this->_free_plugin_basename :
|
4887 |
+
$this->premium_plugin_basename();
|
4888 |
+
|
4889 |
+
/**
|
4890 |
+
* If the other module version is activate, deactivate it.
|
4891 |
+
*
|
4892 |
+
* @author Leo Fajardo (@leorw)
|
4893 |
+
* @since 1.2.2
|
4894 |
+
*/
|
4895 |
+
if ( is_plugin_active( $other_version_basename ) ) {
|
4896 |
+
deactivate_plugins( $other_version_basename );
|
4897 |
+
}
|
4898 |
+
|
4899 |
+
if ( $this->is_registered() ) {
|
4900 |
+
if ( $is_premium_version_activation ) {
|
4901 |
+
$this->reconnect_locally();
|
4902 |
+
}
|
4903 |
+
|
4904 |
+
|
4905 |
+
// Schedule re-activation event and sync.
|
4906 |
+
// $this->sync_install( array(), true );
|
4907 |
+
$this->schedule_install_sync();
|
4908 |
+
|
4909 |
+
// If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
|
4910 |
+
if ( $is_premium_version_activation ) {
|
4911 |
+
$this->_admin_notices->add(
|
4912 |
+
sprintf( $this->get_text_inline( 'The upgrade of %s was successfully completed.', 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
|
4913 |
+
$this->get_text_x_inline( 'W00t',
|
4914 |
+
'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
|
4915 |
+
);
|
4916 |
+
}
|
4917 |
+
} else if ( $this->is_anonymous() ) {
|
4918 |
+
/**
|
4919 |
+
* Reset "skipped" click cache on the following:
|
4920 |
+
* 1. Freemius DEV mode.
|
4921 |
+
* 2. WordPress DEBUG mode.
|
4922 |
+
* 3. If a plugin and the user skipped the exact same version before.
|
4923 |
+
*
|
4924 |
+
* @since 1.2.2.7 Ulrich Pogson (@grapplerulrich) asked to not reset the SKIPPED flag if the exact same THEME version was activated before unless the developer is running with WP_DEBUG on, or Freemius debug mode on (WP_FS__DEV_MODE).
|
4925 |
+
*
|
4926 |
+
* @todo 4. If explicitly asked to retry after every activation.
|
4927 |
+
*/
|
4928 |
+
if ( WP_FS__DEV_MODE ||
|
4929 |
+
(
|
4930 |
+
( $this->is_plugin() || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) &&
|
4931 |
+
$this->get_plugin_version() == $this->_storage->is_anonymous['version']
|
4932 |
+
)
|
4933 |
+
) {
|
4934 |
+
$this->reset_anonymous_mode();
|
4935 |
+
}
|
4936 |
+
}
|
4937 |
+
|
4938 |
+
if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
|
4939 |
+
/**
|
4940 |
+
* If no previous version of plugin's version exist, it means that it's either
|
4941 |
+
* the first time that the plugin installed on the site, or the plugin was installed
|
4942 |
+
* before but didn't have Freemius integrated.
|
4943 |
+
*
|
4944 |
+
* Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
|
4945 |
+
* on manual activation via the dashboard, is_plugin_activation() is TRUE
|
4946 |
+
* only after immediate activation.
|
4947 |
+
*
|
4948 |
+
* @since 1.1.4
|
4949 |
+
* @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
|
4950 |
+
*/
|
4951 |
+
$this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
|
4952 |
+
}
|
4953 |
+
|
4954 |
+
if ( ! $this->_anonymous_mode &&
|
4955 |
+
$this->has_api_connectivity( WP_FS__DEV_MODE ) &&
|
4956 |
+
! $this->_isAutoInstall
|
4957 |
+
) {
|
4958 |
+
// Store hint that the plugin was just activated to enable auto-redirection to settings.
|
4959 |
+
add_option( 'fs_'
|
4960 |
+
. ( $this->is_plugin() ? '' : $this->_module_type . '_' )
|
4961 |
+
. "{$this->_slug}_activated", true );
|
4962 |
+
}
|
4963 |
+
|
4964 |
+
/**
|
4965 |
+
* Activation hook is executed after the plugin's main file is loaded, therefore,
|
4966 |
+
* after the plugin was loaded. The logic is located at activate_plugin()
|
4967 |
+
* ./wp-admin/includes/plugin.php.
|
4968 |
+
*
|
4969 |
+
* @author Vova Feldman (@svovaf)
|
4970 |
+
* @since 1.1.9
|
4971 |
+
*/
|
4972 |
+
$this->_storage->was_plugin_loaded = true;
|
4973 |
+
}
|
4974 |
+
|
4975 |
+
/**
|
4976 |
+
* Delete account.
|
4977 |
+
*
|
4978 |
+
* @author Vova Feldman (@svovaf)
|
4979 |
+
* @since 1.0.3
|
4980 |
+
*
|
4981 |
+
* @param bool $check_user Enforce checking if user have plugins activation privileges.
|
4982 |
+
*/
|
4983 |
+
function delete_account_event( $check_user = true ) {
|
4984 |
+
$this->_logger->entrance( 'slug = ' . $this->_slug );
|
4985 |
+
|
4986 |
+
if ( $check_user && ! $this->is_user_admin() ) {
|
4987 |
+
return;
|
4988 |
+
}
|
4989 |
+
|
4990 |
+
$this->do_action( 'before_account_delete' );
|
4991 |
+
|
4992 |
+
// Clear all admin notices.
|
4993 |
+
$this->_admin_notices->clear_all_sticky();
|
4994 |
+
|
4995 |
+
$this->_delete_site( false );
|
4996 |
+
|
4997 |
+
$this->_delete_plans( false );
|
4998 |
+
|
4999 |
+
$this->_delete_licenses( false );
|
5000 |
+
|
5001 |
+
// Delete add-ons related to plugin's account.
|
5002 |
+
$this->_delete_account_addons( false );
|
5003 |
+
|
5004 |
+
// @todo Delete plans and licenses of add-ons.
|
5005 |
+
|
5006 |
+
self::$_accounts->store();
|
5007 |
+
|
5008 |
+
/**
|
5009 |
+
* IMPORTANT:
|
5010 |
+
* Clear crons must be executed before clearing all storage.
|
5011 |
+
* Otherwise, the cron will not be cleared.
|
5012 |
+
*/
|
5013 |
+
$this->clear_sync_cron();
|
5014 |
+
$this->clear_install_sync_cron();
|
5015 |
+
|
5016 |
+
// Clear all storage data.
|
5017 |
+
$this->_storage->clear_all( true, array(
|
5018 |
+
'connectivity_test',
|
5019 |
+
'is_on',
|
5020 |
+
) );
|
5021 |
+
|
5022 |
+
// Send delete event.
|
5023 |
+
$this->get_api_site_scope()->call( '/', 'delete' );
|
5024 |
+
|
5025 |
+
$this->do_action( 'after_account_delete' );
|
5026 |
+
}
|
5027 |
+
|
5028 |
+
/**
|
5029 |
+
* Plugin deactivation hook.
|
5030 |
+
*
|
5031 |
+
* @author Vova Feldman (@svovaf)
|
5032 |
+
* @since 1.0.1
|
5033 |
+
*/
|
5034 |
+
function _deactivate_plugin_hook() {
|
5035 |
+
$this->_logger->entrance( 'slug = ' . $this->_slug );
|
5036 |
+
|
5037 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
5038 |
+
return;
|
5039 |
+
}
|
5040 |
+
|
5041 |
+
$this->_admin_notices->clear_all_sticky();
|
5042 |
+
if ( isset( $this->_storage->sticky_optin_added ) ) {
|
5043 |
+
unset( $this->_storage->sticky_optin_added );
|
5044 |
+
}
|
5045 |
+
|
5046 |
+
if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
|
5047 |
+
// Remember that plugin was already installed.
|
5048 |
+
$this->_storage->is_plugin_new_install = false;
|
5049 |
+
}
|
5050 |
+
|
5051 |
+
// Hook to plugin uninstall.
|
5052 |
+
register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
|
5053 |
+
|
5054 |
+
$this->clear_module_main_file_cache();
|
5055 |
+
$this->clear_sync_cron();
|
5056 |
+
$this->clear_install_sync_cron();
|
5057 |
+
|
5058 |
+
if ( $this->is_registered() ) {
|
5059 |
+
// Send deactivation event.
|
5060 |
+
$this->sync_install( array(
|
5061 |
+
'is_active' => false,
|
5062 |
+
) );
|
5063 |
+
} else {
|
5064 |
+
if ( ! $this->has_api_connectivity() ) {
|
5065 |
+
// Reset connectivity test cache.
|
5066 |
+
unset( $this->_storage->connectivity_test );
|
5067 |
+
}
|
5068 |
+
}
|
5069 |
+
|
5070 |
+
// Clear API cache on deactivation.
|
5071 |
+
FS_Api::clear_cache();
|
5072 |
+
|
5073 |
+
$this->remove_sdk_reference();
|
5074 |
+
}
|
5075 |
+
|
5076 |
+
/**
|
5077 |
+
* @author Vova Feldman (@svovaf)
|
5078 |
+
* @since 1.1.6
|
5079 |
+
*/
|
5080 |
+
private function remove_sdk_reference() {
|
5081 |
+
global $fs_active_plugins;
|
5082 |
+
|
5083 |
+
foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) {
|
5084 |
+
if ( $this->_plugin_basename == $data->plugin_path ) {
|
5085 |
+
unset( $fs_active_plugins->plugins[ $sdk_path ] );
|
5086 |
+
break;
|
5087 |
+
}
|
5088 |
+
}
|
5089 |
+
|
5090 |
+
fs_fallback_to_newest_active_sdk();
|
5091 |
+
}
|
5092 |
+
|
5093 |
+
/**
|
5094 |
+
* @author Vova Feldman (@svovaf)
|
5095 |
+
* @since 1.1.3
|
5096 |
+
*
|
5097 |
+
* @param bool $is_anonymous
|
5098 |
+
*/
|
5099 |
+
private function set_anonymous_mode( $is_anonymous = true ) {
|
5100 |
+
// Store information regarding skip to try and opt-in the user
|
5101 |
+
// again in the future.
|
5102 |
+
$this->_storage->is_anonymous = array(
|
5103 |
+
'is' => $is_anonymous,
|
5104 |
+
'timestamp' => WP_FS__SCRIPT_START_TIME,
|
5105 |
+
'version' => $this->get_plugin_version(),
|
5106 |
+
);
|
5107 |
+
|
5108 |
+
// Update anonymous mode cache.
|
5109 |
+
$this->_is_anonymous = $is_anonymous;
|
5110 |
+
}
|
5111 |
+
|
5112 |
+
/**
|
5113 |
+
* @author Vova Feldman (@svovaf)
|
5114 |
+
* @since 1.1.3
|
5115 |
+
*/
|
5116 |
+
private function reset_anonymous_mode() {
|
5117 |
+
unset( $this->_storage->is_anonymous );
|
5118 |
+
|
5119 |
+
/**
|
5120 |
+
* Ensure that this field is also "false", otherwise, if the current module's type is "theme" and the module
|
5121 |
+
* has no menus, the opt-in popup will not be shown immediately (in this case, the user will have to click
|
5122 |
+
* on the admin notice that contains the opt-in link in order to trigger the opt-in popup).
|
5123 |
+
*
|
5124 |
+
* @author Leo Fajardo (@leorw)
|
5125 |
+
* @since 1.2.2
|
5126 |
+
*/
|
5127 |
+
unset( $this->_is_anonymous );
|
5128 |
+
}
|
5129 |
+
|
5130 |
+
/**
|
5131 |
+
* Clears the anonymous mode and redirects to the opt-in screen.
|
5132 |
+
*
|
5133 |
+
* @author Vova Feldman (@svovaf)
|
5134 |
+
* @since 1.1.7
|
5135 |
+
*/
|
5136 |
+
function connect_again() {
|
5137 |
+
if ( ! $this->is_anonymous() ) {
|
5138 |
+
return;
|
5139 |
+
}
|
5140 |
+
|
5141 |
+
$this->reset_anonymous_mode();
|
5142 |
+
|
5143 |
+
fs_redirect( $this->get_activation_url() );
|
5144 |
+
}
|
5145 |
+
|
5146 |
+
/**
|
5147 |
+
* Skip account connect, and set anonymous mode.
|
5148 |
+
*
|
5149 |
+
* @author Vova Feldman (@svovaf)
|
5150 |
+
* @since 1.1.1
|
5151 |
+
*/
|
5152 |
+
private function skip_connection() {
|
5153 |
+
$this->_logger->entrance();
|
5154 |
+
|
5155 |
+
$this->_admin_notices->remove_sticky( 'connect_account' );
|
5156 |
+
|
5157 |
+
$this->set_anonymous_mode();
|
5158 |
+
|
5159 |
+
// Send anonymous skip event.
|
5160 |
+
// No user identified info nor any tracking will be sent after the user skips the opt-in.
|
5161 |
+
$this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
|
5162 |
+
'uid' => $this->get_anonymous_id(),
|
5163 |
+
) );
|
5164 |
+
}
|
5165 |
+
|
5166 |
+
/**
|
5167 |
+
* Plugin version update hook.
|
5168 |
+
*
|
5169 |
+
* @author Vova Feldman (@svovaf)
|
5170 |
+
* @since 1.0.4
|
5171 |
+
*/
|
5172 |
+
private function update_plugin_version_event() {
|
5173 |
+
$this->_logger->entrance();
|
5174 |
+
|
5175 |
+
if ( ! $this->is_registered() ) {
|
5176 |
+
return;
|
5177 |
+
}
|
5178 |
+
|
5179 |
+
$this->schedule_install_sync();
|
5180 |
+
// $this->sync_install( array(), true );
|
5181 |
+
}
|
5182 |
+
|
5183 |
+
/**
|
5184 |
+
* Return a list of modified plugins since the last sync.
|
5185 |
+
*
|
5186 |
+
* Note:
|
5187 |
+
* There's no point to store a plugins counter since even if the number of
|
5188 |
+
* plugins didn't change, we still need to check if the versions are all the
|
5189 |
+
* same and the activity state is similar.
|
5190 |
+
*
|
5191 |
+
* @author Vova Feldman (@svovaf)
|
5192 |
+
* @since 1.1.8
|
5193 |
+
*
|
5194 |
+
* @return array|false
|
5195 |
+
*/
|
5196 |
+
private function get_plugins_data_for_api() {
|
5197 |
+
// Alias.
|
5198 |
+
$option_name = 'all_plugins';
|
5199 |
+
|
5200 |
+
$all_cached_plugins = self::$_accounts->get_option( $option_name );
|
5201 |
+
|
5202 |
+
if ( ! is_object( $all_cached_plugins ) ) {
|
5203 |
+
$all_cached_plugins = (object) array(
|
5204 |
+
'timestamp' => '',
|
5205 |
+
'md5' => '',
|
5206 |
+
'plugins' => array(),
|
5207 |
+
);
|
5208 |
+
}
|
5209 |
+
|
5210 |
+
$time = time();
|
5211 |
+
|
5212 |
+
if ( ! empty( $all_cached_plugins->timestamp ) &&
|
5213 |
+
( $time - $all_cached_plugins->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
|
5214 |
+
) {
|
5215 |
+
// Don't send plugin updates if last update was in the past 5 min.
|
5216 |
+
return false;
|
5217 |
+
}
|
5218 |
+
|
5219 |
+
// Write timestamp to lock the logic.
|
5220 |
+
$all_cached_plugins->timestamp = $time;
|
5221 |
+
self::$_accounts->set_option( $option_name, $all_cached_plugins, true );
|
5222 |
+
|
5223 |
+
// Reload options from DB.
|
5224 |
+
self::$_accounts->load( true );
|
5225 |
+
$all_cached_plugins = self::$_accounts->get_option( $option_name );
|
5226 |
+
|
5227 |
+
if ( $time != $all_cached_plugins->timestamp ) {
|
5228 |
+
// If timestamp is different, then another thread captured the lock.
|
5229 |
+
return false;
|
5230 |
+
}
|
5231 |
+
|
5232 |
+
// Check if there's a change in plugins.
|
5233 |
+
$all_plugins = self::get_all_plugins();
|
5234 |
+
|
5235 |
+
// Check if plugins changed.
|
5236 |
+
ksort( $all_plugins );
|
5237 |
+
|
5238 |
+
$plugins_signature = '';
|
5239 |
+
foreach ( $all_plugins as $basename => $data ) {
|
5240 |
+
$plugins_signature .= $data['slug'] . ',' .
|
5241 |
+
$data['Version'] . ',' .
|
5242 |
+
( $data['is_active'] ? '1' : '0' ) . ';';
|
5243 |
+
}
|
5244 |
+
|
5245 |
+
// Check if plugins status changed (version or active/inactive).
|
5246 |
+
$plugins_changed = ( $all_cached_plugins->md5 !== md5( $plugins_signature ) );
|
5247 |
+
|
5248 |
+
$plugins_update_data = array();
|
5249 |
+
|
5250 |
+
if ( $plugins_changed ) {
|
5251 |
+
// Change in plugins, report changes.
|
5252 |
+
|
5253 |
+
// Update existing plugins info.
|
5254 |
+
foreach ( $all_cached_plugins->plugins as $basename => $data ) {
|
5255 |
+
if ( ! isset( $all_plugins[ $basename ] ) ) {
|
5256 |
+
// Plugin uninstalled.
|
5257 |
+
$uninstalled_plugin_data = $data;
|
5258 |
+
$uninstalled_plugin_data['is_active'] = false;
|
5259 |
+
$uninstalled_plugin_data['is_uninstalled'] = true;
|
5260 |
+
$plugins_update_data[] = $uninstalled_plugin_data;
|
5261 |
+
|
5262 |
+
unset( $all_plugins[ $basename ] );
|
5263 |
+
unset( $all_cached_plugins->plugins[ $basename ] );
|
5264 |
+
} else if ( $data['is_active'] !== $all_plugins[ $basename ]['is_active'] ||
|
5265 |
+
$data['version'] !== $all_plugins[ $basename ]['Version']
|
5266 |
+
) {
|
5267 |
+
// Plugin activated or deactivated, or version changed.
|
5268 |
+
$all_cached_plugins->plugins[ $basename ]['is_active'] = $all_plugins[ $basename ]['is_active'];
|
5269 |
+
$all_cached_plugins->plugins[ $basename ]['version'] = $all_plugins[ $basename ]['Version'];
|
5270 |
+
|
5271 |
+
$plugins_update_data[] = $all_cached_plugins->plugins[ $basename ];
|
5272 |
+
}
|
5273 |
+
}
|
5274 |
+
|
5275 |
+
// Find new plugins that weren't yet seen before.
|
5276 |
+
foreach ( $all_plugins as $basename => $data ) {
|
5277 |
+
if ( ! isset( $all_cached_plugins->plugins[ $basename ] ) ) {
|
5278 |
+
// New plugin.
|
5279 |
+
$new_plugin = array(
|
5280 |
+
'slug' => $data['slug'],
|
5281 |
+
'version' => $data['Version'],
|
5282 |
+
'title' => $data['Name'],
|
5283 |
+
'is_active' => $data['is_active'],
|
5284 |
+
'is_uninstalled' => false,
|
5285 |
+
);
|
5286 |
+
|
5287 |
+
$plugins_update_data[] = $new_plugin;
|
5288 |
+
$all_cached_plugins->plugins[ $basename ] = $new_plugin;
|
5289 |
+
}
|
5290 |
+
}
|
5291 |
+
|
5292 |
+
$all_cached_plugins->md5 = md5( $plugins_signature );
|
5293 |
+
$all_cached_plugins->timestamp = $time;
|
5294 |
+
self::$_accounts->set_option( $option_name, $all_cached_plugins, true );
|
5295 |
+
}
|
5296 |
+
|
5297 |
+
return $plugins_update_data;
|
5298 |
+
}
|
5299 |
+
|
5300 |
+
/**
|
5301 |
+
* Return a list of modified themes since the last sync.
|
5302 |
+
*
|
5303 |
+
* Note:
|
5304 |
+
* There's no point to store a themes counter since even if the number of
|
5305 |
+
* themes didn't change, we still need to check if the versions are all the
|
5306 |
+
* same and the activity state is similar.
|
5307 |
+
*
|
5308 |
+
* @author Vova Feldman (@svovaf)
|
5309 |
+
* @since 1.1.8
|
5310 |
+
*
|
5311 |
+
* @return array|false
|
5312 |
+
*/
|
5313 |
+
private function get_themes_data_for_api() {
|
5314 |
+
// Alias.
|
5315 |
+
$option_name = 'all_themes';
|
5316 |
+
|
5317 |
+
$all_cached_themes = self::$_accounts->get_option( $option_name );
|
5318 |
+
|
5319 |
+
if ( ! is_object( $all_cached_themes ) ) {
|
5320 |
+
$all_cached_themes = (object) array(
|
5321 |
+
'timestamp' => '',
|
5322 |
+
'md5' => '',
|
5323 |
+
'themes' => array(),
|
5324 |
+
);
|
5325 |
+
}
|
5326 |
+
|
5327 |
+
$time = time();
|
5328 |
+
|
5329 |
+
if ( ! empty( $all_cached_themes->timestamp ) &&
|
5330 |
+
( $time - $all_cached_themes->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
|
5331 |
+
) {
|
5332 |
+
// Don't send theme updates if last update was in the past 5 min.
|
5333 |
+
return false;
|
5334 |
+
}
|
5335 |
+
|
5336 |
+
// Write timestamp to lock the logic.
|
5337 |
+
$all_cached_themes->timestamp = $time;
|
5338 |
+
self::$_accounts->set_option( $option_name, $all_cached_themes, true );
|
5339 |
+
|
5340 |
+
// Reload options from DB.
|
5341 |
+
self::$_accounts->load( true );
|
5342 |
+
$all_cached_themes = self::$_accounts->get_option( $option_name );
|
5343 |
+
|
5344 |
+
if ( $time != $all_cached_themes->timestamp ) {
|
5345 |
+
// If timestamp is different, then another thread captured the lock.
|
5346 |
+
return false;
|
5347 |
+
}
|
5348 |
+
|
5349 |
+
// Get active theme.
|
5350 |
+
$active_theme = wp_get_theme();
|
5351 |
+
$active_theme_stylesheet = $active_theme->get_stylesheet();
|
5352 |
+
|
5353 |
+
// Check if there's a change in themes.
|
5354 |
+
$all_themes = wp_get_themes();
|
5355 |
+
|
5356 |
+
// Check if themes changed.
|
5357 |
+
ksort( $all_themes );
|
5358 |
+
|
5359 |
+
$themes_signature = '';
|
5360 |
+
foreach ( $all_themes as $slug => $data ) {
|
5361 |
+
$is_active = ( $slug === $active_theme_stylesheet );
|
5362 |
+
$themes_signature .= $slug . ',' .
|
5363 |
+
$data->version . ',' .
|
5364 |
+
( $is_active ? '1' : '0' ) . ';';
|
5365 |
+
}
|
5366 |
+
|
5367 |
+
// Check if themes status changed (version or active/inactive).
|
5368 |
+
$themes_changed = ( $all_cached_themes->md5 !== md5( $themes_signature ) );
|
5369 |
+
|
5370 |
+
$themes_update_data = array();
|
5371 |
+
|
5372 |
+
if ( $themes_changed ) {
|
5373 |
+
// Change in themes, report changes.
|
5374 |
+
|
5375 |
+
// Update existing themes info.
|
5376 |
+
foreach ( $all_cached_themes->themes as $slug => $data ) {
|
5377 |
+
$is_active = ( $slug === $active_theme_stylesheet );
|
5378 |
+
|
5379 |
+
if ( ! isset( $all_themes[ $slug ] ) ) {
|
5380 |
+
// Plugin uninstalled.
|
5381 |
+
$uninstalled_theme_data = $data;
|
5382 |
+
$uninstalled_theme_data['is_active'] = false;
|
5383 |
+
$uninstalled_theme_data['is_uninstalled'] = true;
|
5384 |
+
$themes_update_data[] = $uninstalled_theme_data;
|
5385 |
+
|
5386 |
+
unset( $all_themes[ $slug ] );
|
5387 |
+
unset( $all_cached_themes->themes[ $slug ] );
|
5388 |
+
} else if ( $data['is_active'] !== $is_active ||
|
5389 |
+
$data['version'] !== $all_themes[ $slug ]->version
|
5390 |
+
) {
|
5391 |
+
// Plugin activated or deactivated, or version changed.
|
5392 |
+
|
5393 |
+
$all_cached_themes->themes[ $slug ]['is_active'] = $is_active;
|
5394 |
+
$all_cached_themes->themes[ $slug ]['version'] = $all_themes[ $slug ]->version;
|
5395 |
+
|
5396 |
+
$themes_update_data[] = $all_cached_themes->themes[ $slug ];
|
5397 |
+
}
|
5398 |
+
}
|
5399 |
+
|
5400 |
+
// Find new themes that weren't yet seen before.
|
5401 |
+
foreach ( $all_themes as $slug => $data ) {
|
5402 |
+
if ( ! isset( $all_cached_themes->themes[ $slug ] ) ) {
|
5403 |
+
$is_active = ( $slug === $active_theme_stylesheet );
|
5404 |
+
|
5405 |
+
// New plugin.
|
5406 |
+
$new_plugin = array(
|
5407 |
+
'slug' => $slug,
|
5408 |
+
'version' => $data->version,
|
5409 |
+
'title' => $data->name,
|
5410 |
+
'is_active' => $is_active,
|
5411 |
+
'is_uninstalled' => false,
|
5412 |
+
);
|
5413 |
+
|
5414 |
+
$themes_update_data[] = $new_plugin;
|
5415 |
+
$all_cached_themes->themes[ $slug ] = $new_plugin;
|
5416 |
+
}
|
5417 |
+
}
|
5418 |
+
|
5419 |
+
$all_cached_themes->md5 = md5( $themes_signature );
|
5420 |
+
$all_cached_themes->timestamp = time();
|
5421 |
+
self::$_accounts->set_option( $option_name, $all_cached_themes, true );
|
5422 |
+
}
|
5423 |
+
|
5424 |
+
return $themes_update_data;
|
5425 |
+
}
|
5426 |
+
|
5427 |
+
/**
|
5428 |
+
* Update install details.
|
5429 |
+
*
|
5430 |
+
* @author Vova Feldman (@svovaf)
|
5431 |
+
* @since 1.1.2
|
5432 |
+
*
|
5433 |
+
* @param string[] string $override
|
5434 |
+
* @param bool $include_plugins Since 1.1.8 by default include plugin changes.
|
5435 |
+
* @param bool $include_themes Since 1.1.8 by default include plugin changes.
|
5436 |
+
*
|
5437 |
+
* @return array
|
5438 |
+
*/
|
5439 |
+
private function get_install_data_for_api(
|
5440 |
+
array $override,
|
5441 |
+
$include_plugins = true,
|
5442 |
+
$include_themes = true
|
5443 |
+
) {
|
5444 |
+
/**
|
5445 |
+
* @since 1.1.8 Also send plugin updates.
|
5446 |
+
*/
|
5447 |
+
if ( $include_plugins && ! isset( $override['plugins'] ) ) {
|
5448 |
+
$plugins = $this->get_plugins_data_for_api();
|
5449 |
+
if ( ! empty( $plugins ) ) {
|
5450 |
+
$override['plugins'] = $plugins;
|
5451 |
+
}
|
5452 |
+
}
|
5453 |
+
/**
|
5454 |
+
* @since 1.1.8 Also send themes updates.
|
5455 |
+
*/
|
5456 |
+
if ( $include_themes && ! isset( $override['themes'] ) ) {
|
5457 |
+
$themes = $this->get_themes_data_for_api();
|
5458 |
+
if ( ! empty( $themes ) ) {
|
5459 |
+
$override['themes'] = $themes;
|
5460 |
+
}
|
5461 |
+
}
|
5462 |
+
|
5463 |
+
return array_merge( array(
|
5464 |
+
'version' => $this->get_plugin_version(),
|
5465 |
+
'is_premium' => $this->is_premium(),
|
5466 |
+
'language' => get_bloginfo( 'language' ),
|
5467 |
+
'charset' => get_bloginfo( 'charset' ),
|
5468 |
+
'platform_version' => get_bloginfo( 'version' ),
|
5469 |
+
'sdk_version' => $this->version,
|
5470 |
+
'programming_language_version' => phpversion(),
|
5471 |
+
'title' => get_bloginfo( 'name' ),
|
5472 |
+
'url' => get_site_url(),
|
5473 |
+
// Special params.
|
5474 |
+
'is_active' => true,
|
5475 |
+
'is_disconnected' => $this->is_tracking_prohibited(),
|
5476 |
+
'is_uninstalled' => false,
|
5477 |
+
), $override );
|
5478 |
+
}
|
5479 |
+
|
5480 |
+
/**
|
5481 |
+
* Update install only if changed.
|
5482 |
+
*
|
5483 |
+
* @author Vova Feldman (@svovaf)
|
5484 |
+
* @since 1.0.9
|
5485 |
+
*
|
5486 |
+
* @param string[] string $override
|
5487 |
+
* @param bool $flush
|
5488 |
+
*
|
5489 |
+
* @return false|object|string
|
5490 |
+
*/
|
5491 |
+
private function send_install_update( $override = array(), $flush = false ) {
|
5492 |
+
$this->_logger->entrance();
|
5493 |
+
|
5494 |
+
$check_properties = $this->get_install_data_for_api( $override );
|
5495 |
+
|
5496 |
+
if ( $flush ) {
|
5497 |
+
$params = $check_properties;
|
5498 |
+
} else {
|
5499 |
+
$params = array();
|
5500 |
+
$special = array();
|
5501 |
+
$special_override = false;
|
5502 |
+
|
5503 |
+
foreach ( $check_properties as $p => $v ) {
|
5504 |
+
if ( property_exists( $this->_site, $p ) ) {
|
5505 |
+
if ( ( is_bool( $this->_site->{$p} ) || ! empty( $this->_site->{$p} ) ) &&
|
5506 |
+
$this->_site->{$p} != $v
|
5507 |
+
) {
|
5508 |
+
$this->_site->{$p} = $v;
|
5509 |
+
$params[ $p ] = $v;
|
5510 |
+
}
|
5511 |
+
} else {
|
5512 |
+
$special[ $p ] = $v;
|
5513 |
+
|
5514 |
+
if ( isset( $override[ $p ] ) ||
|
5515 |
+
'plugins' === $p ||
|
5516 |
+
'themes' === $p
|
5517 |
+
) {
|
5518 |
+
$special_override = true;
|
5519 |
+
}
|
5520 |
+
}
|
5521 |
+
}
|
5522 |
+
|
5523 |
+
if ( $special_override || 0 < count( $params ) ) {
|
5524 |
+
// Add special params only if has at least one
|
5525 |
+
// standard param, or if explicitly requested to
|
5526 |
+
// override a special param or a param which is not exist
|
5527 |
+
// in the install object.
|
5528 |
+
$params = array_merge( $params, $special );
|
5529 |
+
}
|
5530 |
+
}
|
5531 |
+
|
5532 |
+
if ( 0 < count( $params ) ) {
|
5533 |
+
// Update last install sync timestamp.
|
5534 |
+
$this->_storage->install_sync_timestamp = time();
|
5535 |
+
|
5536 |
+
$params['uid'] = $this->get_anonymous_id();
|
5537 |
+
|
5538 |
+
// Send updated values to FS.
|
5539 |
+
$site = $this->get_api_site_scope()->call( '/', 'put', $params );
|
5540 |
+
|
5541 |
+
if ( $this->is_api_result_entity( $site ) ) {
|
5542 |
+
// I successfully sent install update, clear scheduled sync if exist.
|
5543 |
+
$this->clear_install_sync_cron();
|
5544 |
+
}
|
5545 |
+
|
5546 |
+
return $site;
|
5547 |
+
}
|
5548 |
+
|
5549 |
+
return false;
|
5550 |
+
}
|
5551 |
+
|
5552 |
+
/**
|
5553 |
+
* Update install only if changed.
|
5554 |
+
*
|
5555 |
+
* @author Vova Feldman (@svovaf)
|
5556 |
+
* @since 1.0.9
|
5557 |
+
*
|
5558 |
+
* @param string[] string $override
|
5559 |
+
* @param bool $flush
|
5560 |
+
*/
|
5561 |
+
private function sync_install( $override = array(), $flush = false ) {
|
5562 |
+
$this->_logger->entrance();
|
5563 |
+
|
5564 |
+
$site = $this->send_install_update( $override, $flush );
|
5565 |
+
|
5566 |
+
if ( false === $site ) {
|
5567 |
+
// No sync required.
|
5568 |
+
return;
|
5569 |
+
}
|
5570 |
+
|
5571 |
+
if ( ! $this->is_api_result_entity( $site ) ) {
|
5572 |
+
// Failed to sync, don't update locally.
|
5573 |
+
return;
|
5574 |
+
}
|
5575 |
+
|
5576 |
+
$plan = $this->get_plan();
|
5577 |
+
$this->_site = new FS_Site( $site );
|
5578 |
+
$this->_site->plan = $plan;
|
5579 |
+
|
5580 |
+
$this->_store_site( true );
|
5581 |
+
}
|
5582 |
+
|
5583 |
+
/**
|
5584 |
+
* Track install's custom event.
|
5585 |
+
*
|
5586 |
+
* IMPORTANT:
|
5587 |
+
* Custom event tracking is currently only supported for specific clients.
|
5588 |
+
* If you are not one of them, please don't use this method. If you will,
|
5589 |
+
* the API will simply ignore your request based on the plugin ID.
|
5590 |
+
*
|
5591 |
+
* Need custom tracking for your plugin or theme?
|
5592 |
+
* If you are interested in custom event tracking please contact yo@freemius.com
|
5593 |
+
* for further details.
|
5594 |
+
*
|
5595 |
+
* @author Vova Feldman (@svovaf)
|
5596 |
+
* @since 1.2.1
|
5597 |
+
*
|
5598 |
+
* @param string $name Event name.
|
5599 |
+
* @param array $properties Associative key/value array with primitive values only
|
5600 |
+
* @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
|
5601 |
+
* @param bool $once If true, event will be tracked only once. IMPORTANT: Still trigger the API call.
|
5602 |
+
*
|
5603 |
+
* @return object|false Event data or FALSE on failure.
|
5604 |
+
*
|
5605 |
+
* @throws \Freemius_InvalidArgumentException
|
5606 |
+
*/
|
5607 |
+
public function track_event( $name, $properties = array(), $process_at = false, $once = false ) {
|
5608 |
+
$this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) );
|
5609 |
+
|
5610 |
+
if ( ! $this->is_registered() ) {
|
5611 |
+
return false;
|
5612 |
+
}
|
5613 |
+
|
5614 |
+
$event = array( 'type' => $name );
|
5615 |
+
|
5616 |
+
if ( is_numeric( $process_at ) && $process_at > time() ) {
|
5617 |
+
$event['process_at'] = $process_at;
|
5618 |
+
}
|
5619 |
+
|
5620 |
+
if ( $once ) {
|
5621 |
+
$event['once'] = true;
|
5622 |
+
}
|
5623 |
+
|
5624 |
+
if ( ! empty( $properties ) ) {
|
5625 |
+
// Verify associative array values are primitive.
|
5626 |
+
foreach ( $properties as $k => $v ) {
|
5627 |
+
if ( ! is_scalar( $v ) ) {
|
5628 |
+
throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' );
|
5629 |
+
}
|
5630 |
+
}
|
5631 |
+
|
5632 |
+
$event['properties'] = $properties;
|
5633 |
+
}
|
5634 |
+
|
5635 |
+
$result = $this->get_api_site_scope()->call( 'events.json', 'post', $event );
|
5636 |
+
|
5637 |
+
return $this->is_api_error( $result ) ?
|
5638 |
+
false :
|
5639 |
+
$result;
|
5640 |
+
}
|
5641 |
+
|
5642 |
+
/**
|
5643 |
+
* Track install's custom event only once, but it still triggers the API call.
|
5644 |
+
*
|
5645 |
+
* IMPORTANT:
|
5646 |
+
* Custom event tracking is currently only supported for specific clients.
|
5647 |
+
* If you are not one of them, please don't use this method. If you will,
|
5648 |
+
* the API will simply ignore your request based on the plugin ID.
|
5649 |
+
*
|
5650 |
+
* Need custom tracking for your plugin or theme?
|
5651 |
+
* If you are interested in custom event tracking please contact yo@freemius.com
|
5652 |
+
* for further details.
|
5653 |
+
*
|
5654 |
+
* @author Vova Feldman (@svovaf)
|
5655 |
+
* @since 1.2.1
|
5656 |
+
*
|
5657 |
+
* @param string $name Event name.
|
5658 |
+
* @param array $properties Associative key/value array with primitive values only
|
5659 |
+
* @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
|
5660 |
+
*
|
5661 |
+
* @return object|false Event data or FALSE on failure.
|
5662 |
+
*
|
5663 |
+
* @throws \Freemius_InvalidArgumentException
|
5664 |
+
*
|
5665 |
+
* @user Freemius::track_event()
|
5666 |
+
*/
|
5667 |
+
public function track_event_once( $name, $properties = array(), $process_at = false ) {
|
5668 |
+
return $this->track_event( $name, $properties, $process_at, true );
|
5669 |
+
}
|
5670 |
+
|
5671 |
+
/**
|
5672 |
+
* Plugin uninstall hook.
|
5673 |
+
*
|
5674 |
+
* @author Vova Feldman (@svovaf)
|
5675 |
+
* @since 1.0.1
|
5676 |
+
*
|
5677 |
+
* @param bool $check_user Enforce checking if user have plugins activation privileges.
|
5678 |
+
*/
|
5679 |
+
function _uninstall_plugin_event( $check_user = true ) {
|
5680 |
+
$this->_logger->entrance( 'slug = ' . $this->_slug );
|
5681 |
+
|
5682 |
+
if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
|
5683 |
+
return;
|
5684 |
+
}
|
5685 |
+
|
5686 |
+
$params = array();
|
5687 |
+
$uninstall_reason = null;
|
5688 |
+
if ( isset( $this->_storage->uninstall_reason ) ) {
|
5689 |
+
$uninstall_reason = $this->_storage->uninstall_reason;
|
5690 |
+
$params['reason_id'] = $uninstall_reason->id;
|
5691 |
+
$params['reason_info'] = $uninstall_reason->info;
|
5692 |
+
}
|
5693 |
+
|
5694 |
+
if ( ! $this->is_registered() ) {
|
5695 |
+
// Send anonymous uninstall event only if user submitted a feedback.
|
5696 |
+
if ( isset( $uninstall_reason ) ) {
|
5697 |
+
if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) {
|
5698 |
+
$this->opt_in( false, false, false, false, true );
|
5699 |
+
} else {
|
5700 |
+
$params['uid'] = $this->get_anonymous_id();
|
5701 |
+
$this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
|
5702 |
+
}
|
5703 |
+
}
|
5704 |
+
} else {
|
5705 |
+
// Send uninstall event.
|
5706 |
+
$this->send_install_update( array_merge( $params, array(
|
5707 |
+
'is_active' => false,
|
5708 |
+
'is_uninstalled' => true,
|
5709 |
+
) ) );
|
5710 |
+
}
|
5711 |
+
|
5712 |
+
// @todo Decide if we want to delete plugin information from db.
|
5713 |
+
}
|
5714 |
+
|
5715 |
+
/**
|
5716 |
+
* @author Vova Feldman (@svovaf)
|
5717 |
+
* @since 1.1.1
|
5718 |
+
*
|
5719 |
+
* @return string
|
5720 |
+
*/
|
5721 |
+
function premium_plugin_basename() {
|
5722 |
+
return "{$this->_slug}-premium/" . basename( $this->_free_plugin_basename );
|
5723 |
+
}
|
5724 |
+
|
5725 |
+
/**
|
5726 |
+
* Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
|
5727 |
+
*
|
5728 |
+
* @author Vova Feldman (@svovaf)
|
5729 |
+
* @since 1.0.2
|
5730 |
+
*/
|
5731 |
+
public static function _uninstall_plugin_hook() {
|
5732 |
+
self::_load_required_static();
|
5733 |
+
|
5734 |
+
self::$_static_logger->entrance();
|
5735 |
+
|
5736 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
5737 |
+
return;
|
5738 |
+
}
|
5739 |
+
|
5740 |
+
$plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
|
5741 |
+
|
5742 |
+
self::$_static_logger->info( 'plugin = ' . $plugin_file );
|
5743 |
+
|
5744 |
+
define( 'WP_FS__UNINSTALL_MODE', true );
|
5745 |
+
|
5746 |
+
$fs = self::get_instance_by_file( $plugin_file );
|
5747 |
+
|
5748 |
+
if ( is_object( $fs ) ) {
|
5749 |
+
self::require_plugin_essentials();
|
5750 |
+
|
5751 |
+
if ( is_plugin_active( $fs->_free_plugin_basename ) ||
|
5752 |
+
is_plugin_active( $fs->premium_plugin_basename() )
|
5753 |
+
) {
|
5754 |
+
// Deleting Free or Premium plugin version while the other version still installed.
|
5755 |
+
return;
|
5756 |
+
}
|
5757 |
+
|
5758 |
+
$fs->_uninstall_plugin_event();
|
5759 |
+
|
5760 |
+
$fs->do_action( 'after_uninstall' );
|
5761 |
+
}
|
5762 |
+
}
|
5763 |
+
|
5764 |
+
#----------------------------------------------------------------------------------
|
5765 |
+
#region Plugin Information
|
5766 |
+
#----------------------------------------------------------------------------------
|
5767 |
+
|
5768 |
+
/**
|
5769 |
+
* Load WordPress core plugin.php essential module.
|
5770 |
+
*
|
5771 |
+
* @author Vova Feldman (@svovaf)
|
5772 |
+
* @since 1.1.1
|
5773 |
+
*/
|
5774 |
+
private static function require_plugin_essentials() {
|
5775 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
5776 |
+
self::$_static_logger->log( 'Including wp-admin/includes/plugin.php...' );
|
5777 |
+
|
5778 |
+
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
5779 |
+
}
|
5780 |
+
}
|
5781 |
+
|
5782 |
+
/**
|
5783 |
+
* Load WordPress core pluggable.php module.
|
5784 |
+
*
|
5785 |
+
* @author Vova Feldman (@svovaf)
|
5786 |
+
* @since 1.1.2
|
5787 |
+
*/
|
5788 |
+
private static function require_pluggable_essentials() {
|
5789 |
+
if ( ! function_exists( 'wp_get_current_user' ) ) {
|
5790 |
+
require_once ABSPATH . 'wp-includes/pluggable.php';
|
5791 |
+
}
|
5792 |
+
}
|
5793 |
+
|
5794 |
+
/**
|
5795 |
+
* Return plugin data.
|
5796 |
+
*
|
5797 |
+
* @author Vova Feldman (@svovaf)
|
5798 |
+
* @since 1.0.1
|
5799 |
+
*
|
5800 |
+
* @return array
|
5801 |
+
*/
|
5802 |
+
function get_plugin_data() {
|
5803 |
+
if ( ! isset( $this->_plugin_data ) ) {
|
5804 |
+
self::require_plugin_essentials();
|
5805 |
+
|
5806 |
+
if ( $this->is_plugin() ) {
|
5807 |
+
/**
|
5808 |
+
* @author Vova Feldman (@svovaf)
|
5809 |
+
* @since 1.2.0 When using get_plugin_data() do NOT translate plugin data.
|
5810 |
+
*
|
5811 |
+
* @link https://github.com/Freemius/wordpress-sdk/issues/77
|
5812 |
+
*/
|
5813 |
+
$plugin_data = get_plugin_data(
|
5814 |
+
$this->_plugin_main_file_path,
|
5815 |
+
false,
|
5816 |
+
false
|
5817 |
+
);
|
5818 |
+
} else {
|
5819 |
+
$theme_data = wp_get_theme();
|
5820 |
+
|
5821 |
+
$plugin_data = array(
|
5822 |
+
'Name' => $theme_data->get( 'Name' ),
|
5823 |
+
'Version' => $theme_data->get( 'Version' ),
|
5824 |
+
'Author' => $theme_data->get( 'Author' ),
|
5825 |
+
'Description' => $theme_data->get( 'Description' ),
|
5826 |
+
'PluginURI' => $theme_data->get( 'ThemeURI' ),
|
5827 |
+
);
|
5828 |
+
}
|
5829 |
+
|
5830 |
+
$this->_plugin_data = $plugin_data;
|
5831 |
+
}
|
5832 |
+
|
5833 |
+
return $this->_plugin_data;
|
5834 |
+
}
|
5835 |
+
|
5836 |
+
/**
|
5837 |
+
* @author Vova Feldman (@svovaf)
|
5838 |
+
* @since 1.0.1
|
5839 |
+
* @since 1.2.2.5 If slug not set load slug by module ID.
|
5840 |
+
*
|
5841 |
+
* @return string Plugin slug.
|
5842 |
+
*/
|
5843 |
+
function get_slug() {
|
5844 |
+
if ( ! isset( $this->_slug ) ) {
|
5845 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
5846 |
+
$this->_slug = $id_slug_type_path_map[ $this->_module_id ]['slug'];
|
5847 |
+
}
|
5848 |
+
|
5849 |
+
return $this->_slug;
|
5850 |
+
}
|
5851 |
+
|
5852 |
+
/**
|
5853 |
+
* @author Vova Feldman (@svovaf)
|
5854 |
+
* @since 1.2.1.7
|
5855 |
+
*
|
5856 |
+
* @return string Plugin slug.
|
5857 |
+
*/
|
5858 |
+
function get_target_folder_name() {
|
5859 |
+
return $this->_slug . ( $this->can_use_premium_code() ? '-premium' : '' );
|
5860 |
+
}
|
5861 |
+
|
5862 |
+
/**
|
5863 |
+
* @author Vova Feldman (@svovaf)
|
5864 |
+
* @since 1.0.1
|
5865 |
+
*
|
5866 |
+
* @return number Plugin ID.
|
5867 |
+
*/
|
5868 |
+
function get_id() {
|
5869 |
+
return $this->_plugin->id;
|
5870 |
+
}
|
5871 |
+
|
5872 |
+
/**
|
5873 |
+
* @author Vova Feldman (@svovaf)
|
5874 |
+
* @since 1.2.1.5
|
5875 |
+
*
|
5876 |
+
* @return string Freemius SDK version
|
5877 |
+
*/
|
5878 |
+
function get_sdk_version() {
|
5879 |
+
return $this->version;
|
5880 |
+
}
|
5881 |
+
|
5882 |
+
/**
|
5883 |
+
* @author Vova Feldman (@svovaf)
|
5884 |
+
* @since 1.2.1.5
|
5885 |
+
*
|
5886 |
+
* @return number Parent plugin ID (if parent exist).
|
5887 |
+
*/
|
5888 |
+
function get_parent_id() {
|
5889 |
+
return $this->is_addon() ?
|
5890 |
+
$this->get_parent_instance()->get_id() :
|
5891 |
+
$this->_plugin->id;
|
5892 |
+
}
|
5893 |
+
|
5894 |
+
/**
|
5895 |
+
* @author Vova Feldman (@svovaf)
|
5896 |
+
* @since 1.0.1
|
5897 |
+
*
|
5898 |
+
* @return string Plugin public key.
|
5899 |
+
*/
|
5900 |
+
function get_public_key() {
|
5901 |
+
return $this->_plugin->public_key;
|
5902 |
+
}
|
5903 |
+
|
5904 |
+
/**
|
5905 |
+
* Will be available only on sandbox mode.
|
5906 |
+
*
|
5907 |
+
* @author Vova Feldman (@svovaf)
|
5908 |
+
* @since 1.0.4
|
5909 |
+
*
|
5910 |
+
* @return mixed Plugin secret key.
|
5911 |
+
*/
|
5912 |
+
function get_secret_key() {
|
5913 |
+
return $this->_plugin->secret_key;
|
5914 |
+
}
|
5915 |
+
|
5916 |
+
/**
|
5917 |
+
* @author Vova Feldman (@svovaf)
|
5918 |
+
* @since 1.1.1
|
5919 |
+
*
|
5920 |
+
* @return bool
|
5921 |
+
*/
|
5922 |
+
function has_secret_key() {
|
5923 |
+
return ! empty( $this->_plugin->secret_key );
|
5924 |
+
}
|
5925 |
+
|
5926 |
+
/**
|
5927 |
+
* @author Vova Feldman (@svovaf)
|
5928 |
+
* @since 1.0.9
|
5929 |
+
*
|
5930 |
+
* @return string
|
5931 |
+
*/
|
5932 |
+
function get_plugin_name() {
|
5933 |
+
$this->_logger->entrance();
|
5934 |
+
|
5935 |
+
if ( ! isset( $this->_plugin_name ) ) {
|
5936 |
+
$plugin_data = $this->get_plugin_data();
|
5937 |
+
|
5938 |
+
// Get name.
|
5939 |
+
$this->_plugin_name = $plugin_data['Name'];
|
5940 |
+
|
5941 |
+
// Check if plugin name contains "(Premium)" suffix and remove it.
|
5942 |
+
$suffix = ' (premium)';
|
5943 |
+
$suffix_len = strlen( $suffix );
|
5944 |
+
|
5945 |
+
if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
|
5946 |
+
$suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
|
5947 |
+
) {
|
5948 |
+
$this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
|
5949 |
+
}
|
5950 |
+
|
5951 |
+
$this->_logger->departure( 'Name = ' . $this->_plugin_name );
|
5952 |
+
}
|
5953 |
+
|
5954 |
+
return $this->_plugin_name;
|
5955 |
+
}
|
5956 |
+
|
5957 |
+
/**
|
5958 |
+
* @author Vova Feldman (@svovaf)
|
5959 |
+
* @since 1.0.0
|
5960 |
+
*
|
5961 |
+
* @return string
|
5962 |
+
*/
|
5963 |
+
function get_plugin_version() {
|
5964 |
+
$this->_logger->entrance();
|
5965 |
+
|
5966 |
+
$plugin_data = $this->get_plugin_data();
|
5967 |
+
|
5968 |
+
$this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
|
5969 |
+
|
5970 |
+
return $this->apply_filters( 'plugin_version', $plugin_data['Version'] );
|
5971 |
+
}
|
5972 |
+
|
5973 |
+
/**
|
5974 |
+
* @author Vova Feldman (@svovaf)
|
5975 |
+
* @since 1.2.1.7
|
5976 |
+
*
|
5977 |
+
* @return string
|
5978 |
+
*/
|
5979 |
+
function get_plugin_title() {
|
5980 |
+
$this->_logger->entrance();
|
5981 |
+
|
5982 |
+
$title = $this->_plugin->title;
|
5983 |
+
|
5984 |
+
return $this->apply_filters( 'plugin_title', $title );
|
5985 |
+
}
|
5986 |
+
|
5987 |
+
/**
|
5988 |
+
* @author Vova Feldman (@svovaf)
|
5989 |
+
* @since 1.2.2.7
|
5990 |
+
*
|
5991 |
+
* @param bool $lowercase
|
5992 |
+
*
|
5993 |
+
* @return string
|
5994 |
+
*/
|
5995 |
+
function get_module_label( $lowercase = false ) {
|
5996 |
+
$label = $this->is_addon() ?
|
5997 |
+
$this->get_text_inline( 'Add-On', 'addon' ) :
|
5998 |
+
( $this->is_plugin() ?
|
5999 |
+
$this->get_text_inline( 'Plugin', 'plugin' ) :
|
6000 |
+
$this->get_text_inline( 'Theme', 'theme' ) );
|
6001 |
+
|
6002 |
+
if ( $lowercase ) {
|
6003 |
+
$label = strtolower( $label );
|
6004 |
+
}
|
6005 |
+
|
6006 |
+
return $label;
|
6007 |
+
}
|
6008 |
+
|
6009 |
+
/**
|
6010 |
+
* @author Vova Feldman (@svovaf)
|
6011 |
+
* @since 1.0.4
|
6012 |
+
*
|
6013 |
+
* @return string
|
6014 |
+
*/
|
6015 |
+
function get_plugin_basename() {
|
6016 |
+
if ( ! isset( $this->_plugin_basename ) ) {
|
6017 |
+
if ( $this->is_plugin() ) {
|
6018 |
+
$this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
|
6019 |
+
} else {
|
6020 |
+
$this->_plugin_basename = basename( dirname( $this->_plugin_main_file_path ) );
|
6021 |
+
}
|
6022 |
+
}
|
6023 |
+
|
6024 |
+
return $this->_plugin_basename;
|
6025 |
+
}
|
6026 |
+
|
6027 |
+
function get_plugin_folder_name() {
|
6028 |
+
$this->_logger->entrance();
|
6029 |
+
|
6030 |
+
$plugin_folder = $this->_plugin_basename;
|
6031 |
+
|
6032 |
+
while ( '.' !== dirname( $plugin_folder ) ) {
|
6033 |
+
$plugin_folder = dirname( $plugin_folder );
|
6034 |
+
}
|
6035 |
+
|
6036 |
+
$this->_logger->departure( 'Folder Name = ' . $plugin_folder );
|
6037 |
+
|
6038 |
+
return $plugin_folder;
|
6039 |
+
}
|
6040 |
+
|
6041 |
+
#endregion ------------------------------------------------------------------
|
6042 |
+
|
6043 |
+
/* Account
|
6044 |
+
------------------------------------------------------------------------------------------------------------------*/
|
6045 |
+
|
6046 |
+
/**
|
6047 |
+
* Find plugin's slug by plugin's basename.
|
6048 |
+
*
|
6049 |
+
* @author Vova Feldman (@svovaf)
|
6050 |
+
* @since 1.0.9
|
6051 |
+
*
|
6052 |
+
* @param string $plugin_base_name
|
6053 |
+
*
|
6054 |
+
* @return false|string
|
6055 |
+
*/
|
6056 |
+
private static function find_slug_by_basename( $plugin_base_name ) {
|
6057 |
+
$file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
|
6058 |
+
|
6059 |
+
if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
|
6060 |
+
return false;
|
6061 |
+
}
|
6062 |
+
|
6063 |
+
return $file_slug_map[ $plugin_base_name ];
|
6064 |
+
}
|
6065 |
+
|
6066 |
+
/**
|
6067 |
+
* Store the map between the plugin's basename to the slug.
|
6068 |
+
*
|
6069 |
+
* @author Vova Feldman (@svovaf)
|
6070 |
+
* @since 1.0.9
|
6071 |
+
*/
|
6072 |
+
private function store_file_slug_map() {
|
6073 |
+
$file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
|
6074 |
+
|
6075 |
+
if ( ! array( $file_slug_map ) ) {
|
6076 |
+
$file_slug_map = array();
|
6077 |
+
}
|
6078 |
+
|
6079 |
+
if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
|
6080 |
+
$file_slug_map[ $this->_plugin_basename ] !== $this->_slug
|
6081 |
+
) {
|
6082 |
+
$file_slug_map[ $this->_plugin_basename ] = $this->_slug;
|
6083 |
+
self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
|
6084 |
+
}
|
6085 |
+
}
|
6086 |
+
|
6087 |
+
/**
|
6088 |
+
* @return FS_User[]
|
6089 |
+
*/
|
6090 |
+
static function get_all_users() {
|
6091 |
+
$users = self::$_accounts->get_option( 'users', array() );
|
6092 |
+
|
6093 |
+
if ( ! is_array( $users ) ) {
|
6094 |
+
$users = array();
|
6095 |
+
}
|
6096 |
+
|
6097 |
+
return $users;
|
6098 |
+
}
|
6099 |
+
|
6100 |
+
/**
|
6101 |
+
* @param string $module_type
|
6102 |
+
*
|
6103 |
+
* @return FS_Site[]
|
6104 |
+
*/
|
6105 |
+
private static function get_all_sites( $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
|
6106 |
+
$sites = self::get_account_option( 'sites', $module_type );
|
6107 |
+
|
6108 |
+
if ( ! is_array( $sites ) ) {
|
6109 |
+
$sites = array();
|
6110 |
+
}
|
6111 |
+
|
6112 |
+
return $sites;
|
6113 |
+
}
|
6114 |
+
|
6115 |
+
/**
|
6116 |
+
* @author Leo Fajardo (@leorw)
|
6117 |
+
*
|
6118 |
+
* @since 1.2.2
|
6119 |
+
*
|
6120 |
+
* @param string $option_name
|
6121 |
+
* @param string $module_type
|
6122 |
+
*
|
6123 |
+
* @return mixed
|
6124 |
+
*/
|
6125 |
+
private static function get_account_option( $option_name, $module_type ) {
|
6126 |
+
if ( WP_FS__MODULE_TYPE_PLUGIN !== $module_type ) {
|
6127 |
+
$option_name = $module_type . '_' . $option_name;
|
6128 |
+
}
|
6129 |
+
|
6130 |
+
return self::$_accounts->get_option( $option_name, array() );
|
6131 |
+
}
|
6132 |
+
|
6133 |
+
/**
|
6134 |
+
* @author Leo Fajardo (@leorw)
|
6135 |
+
*
|
6136 |
+
* @since 1.2.2
|
6137 |
+
*
|
6138 |
+
* @param string $option_name
|
6139 |
+
* @param mixed $option_value
|
6140 |
+
* @param bool $store
|
6141 |
+
*/
|
6142 |
+
private function set_account_option( $option_name, $option_value, $store ) {
|
6143 |
+
self::set_account_option_by_module(
|
6144 |
+
$this->_module_type,
|
6145 |
+
$option_name,
|
6146 |
+
$option_value,
|
6147 |
+
$store
|
6148 |
+
);
|
6149 |
+
}
|
6150 |
+
|
6151 |
+
/**
|
6152 |
+
* @author Vova Feldman (@svovaf)
|
6153 |
+
*
|
6154 |
+
* @since 1.2.2.7
|
6155 |
+
*
|
6156 |
+
* @param string $module_type
|
6157 |
+
* @param string $option_name
|
6158 |
+
* @param mixed $option_value
|
6159 |
+
* @param bool $store
|
6160 |
+
*/
|
6161 |
+
private static function set_account_option_by_module( $module_type, $option_name, $option_value, $store ) {
|
6162 |
+
if ( WP_FS__MODULE_TYPE_PLUGIN != $module_type ) {
|
6163 |
+
$option_name = $module_type . '_' . $option_name;
|
6164 |
+
}
|
6165 |
+
|
6166 |
+
self::$_accounts->set_option( $option_name, $option_value, $store );
|
6167 |
+
}
|
6168 |
+
|
6169 |
+
/**
|
6170 |
+
* @author Vova Feldman (@svovaf)
|
6171 |
+
* @since 1.0.6
|
6172 |
+
*
|
6173 |
+
* @param string $module_type
|
6174 |
+
*
|
6175 |
+
* @return FS_Plugin_License[]
|
6176 |
+
*/
|
6177 |
+
private static function get_all_licenses( $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
|
6178 |
+
$licenses = self::get_account_option( 'licenses', $module_type );
|
6179 |
+
|
6180 |
+
if ( ! is_array( $licenses ) ) {
|
6181 |
+
$licenses = array();
|
6182 |
+
}
|
6183 |
+
|
6184 |
+
return $licenses;
|
6185 |
+
}
|
6186 |
+
|
6187 |
+
/**
|
6188 |
+
* @param string|bool $module_type
|
6189 |
+
*
|
6190 |
+
* @return FS_Plugin_Plan[]
|
6191 |
+
*/
|
6192 |
+
private static function get_all_plans( $module_type = false ) {
|
6193 |
+
$plans = self::get_account_option( 'plans', $module_type );
|
6194 |
+
|
6195 |
+
if ( ! is_array( $plans ) ) {
|
6196 |
+
$plans = array();
|
6197 |
+
}
|
6198 |
+
|
6199 |
+
return $plans;
|
6200 |
+
}
|
6201 |
+
|
6202 |
+
/**
|
6203 |
+
* @author Vova Feldman (@svovaf)
|
6204 |
+
* @since 1.0.4
|
6205 |
+
*
|
6206 |
+
* @return FS_Plugin_Tag[]
|
6207 |
+
*/
|
6208 |
+
private static function get_all_updates() {
|
6209 |
+
$updates = self::$_accounts->get_option( 'updates', array() );
|
6210 |
+
|
6211 |
+
if ( ! is_array( $updates ) ) {
|
6212 |
+
$updates = array();
|
6213 |
+
}
|
6214 |
+
|
6215 |
+
return $updates;
|
6216 |
+
}
|
6217 |
+
|
6218 |
+
/**
|
6219 |
+
* @author Vova Feldman (@svovaf)
|
6220 |
+
* @since 1.0.6
|
6221 |
+
*
|
6222 |
+
* @return array<number,FS_Plugin[]>|false
|
6223 |
+
*/
|
6224 |
+
private static function get_all_addons() {
|
6225 |
+
$addons = self::$_accounts->get_option( 'addons', array() );
|
6226 |
+
|
6227 |
+
if ( ! is_array( $addons ) ) {
|
6228 |
+
$addons = array();
|
6229 |
+
}
|
6230 |
+
|
6231 |
+
return $addons;
|
6232 |
+
}
|
6233 |
+
|
6234 |
+
/**
|
6235 |
+
* @author Vova Feldman (@svovaf)
|
6236 |
+
* @since 1.0.6
|
6237 |
+
*
|
6238 |
+
* @return FS_Plugin[]|false
|
6239 |
+
*/
|
6240 |
+
private static function get_all_account_addons() {
|
6241 |
+
$addons = self::$_accounts->get_option( 'account_addons', array() );
|
6242 |
+
|
6243 |
+
if ( ! is_array( $addons ) ) {
|
6244 |
+
$addons = array();
|
6245 |
+
}
|
6246 |
+
|
6247 |
+
return $addons;
|
6248 |
+
}
|
6249 |
+
|
6250 |
+
/**
|
6251 |
+
* Check if user has connected his account (opted-in).
|
6252 |
+
*
|
6253 |
+
* Note:
|
6254 |
+
* If the user opted-in and opted-out on a later stage,
|
6255 |
+
* this will still return true. If you want to check if the
|
6256 |
+
* user is currently opted-in, use:
|
6257 |
+
* `$fs->is_registered() && $fs->is_tracking_allowed()`
|
6258 |
+
*
|
6259 |
+
* @author Vova Feldman (@svovaf)
|
6260 |
+
* @since 1.0.1
|
6261 |
+
* @return bool
|
6262 |
+
*/
|
6263 |
+
function is_registered() {
|
6264 |
+
return is_object( $this->_user );
|
6265 |
+
}
|
6266 |
+
|
6267 |
+
/**
|
6268 |
+
* Returns TRUE if the user opted-in and didn't disconnect (opt-out).
|
6269 |
+
*
|
6270 |
+
* @author Leo Fajardo (@leorw)
|
6271 |
+
* @since 1.2.1.5
|
6272 |
+
*
|
6273 |
+
* @return bool
|
6274 |
+
*/
|
6275 |
+
function is_tracking_allowed() {
|
6276 |
+
return ( is_object( $this->_site ) && true !== $this->_site->is_disconnected );
|
6277 |
+
}
|
6278 |
+
|
6279 |
+
/**
|
6280 |
+
* @author Vova Feldman (@svovaf)
|
6281 |
+
* @since 1.0.4
|
6282 |
+
*
|
6283 |
+
* @return FS_Plugin
|
6284 |
+
*/
|
6285 |
+
function get_plugin() {
|
6286 |
+
return $this->_plugin;
|
6287 |
+
}
|
6288 |
+
|
6289 |
+
/**
|
6290 |
+
* @author Vova Feldman (@svovaf)
|
6291 |
+
* @since 1.0.3
|
6292 |
+
*
|
6293 |
+
* @return FS_User
|
6294 |
+
*/
|
6295 |
+
function get_user() {
|
6296 |
+
return $this->_user;
|
6297 |
+
}
|
6298 |
+
|
6299 |
+
/**
|
6300 |
+
* @author Vova Feldman (@svovaf)
|
6301 |
+
* @since 1.0.3
|
6302 |
+
*
|
6303 |
+
* @return FS_Site
|
6304 |
+
*/
|
6305 |
+
function get_site() {
|
6306 |
+
return $this->_site;
|
6307 |
+
}
|
6308 |
+
|
6309 |
+
/**
|
6310 |
+
* Get plugin add-ons.
|
6311 |
+
*
|
6312 |
+
* @author Vova Feldman (@svovaf)
|
6313 |
+
* @since 1.0.6
|
6314 |
+
*
|
6315 |
+
* @since 1.1.7.3 If not yet loaded, fetch data from the API.
|
6316 |
+
*
|
6317 |
+
* @param bool $flush
|
6318 |
+
*
|
6319 |
+
* @return FS_Plugin[]|false
|
6320 |
+
*/
|
6321 |
+
function get_addons( $flush = false ) {
|
6322 |
+
$this->_logger->entrance();
|
6323 |
+
|
6324 |
+
if ( ! $this->_has_addons ) {
|
6325 |
+
return false;
|
6326 |
+
}
|
6327 |
+
|
6328 |
+
$addons = $this->sync_addons( $flush );
|
6329 |
+
|
6330 |
+
return ( ! is_array( $addons ) || empty( $addons ) ) ?
|
6331 |
+
false :
|
6332 |
+
$addons;
|
6333 |
+
}
|
6334 |
+
|
6335 |
+
/**
|
6336 |
+
* @author Vova Feldman (@svovaf)
|
6337 |
+
* @since 1.0.6
|
6338 |
+
*
|
6339 |
+
* @return FS_Plugin[]|false
|
6340 |
+
*/
|
6341 |
+
function get_account_addons() {
|
6342 |
+
$this->_logger->entrance();
|
6343 |
+
|
6344 |
+
$addons = self::get_all_account_addons();
|
6345 |
+
|
6346 |
+
if ( ! is_array( $addons ) ||
|
6347 |
+
! isset( $addons[ $this->_plugin->id ] ) ||
|
6348 |
+
! is_array( $addons[ $this->_plugin->id ] ) ||
|
6349 |
+
0 === count( $addons[ $this->_plugin->id ] )
|
6350 |
+
) {
|
6351 |
+
return false;
|
6352 |
+
}
|
6353 |
+
|
6354 |
+
return $addons[ $this->_plugin->id ];
|
6355 |
+
}
|
6356 |
+
|
6357 |
+
/**
|
6358 |
+
* Check if user has any
|
6359 |
+
*
|
6360 |
+
* @author Vova Feldman (@svovaf)
|
6361 |
+
* @since 1.1.6
|
6362 |
+
*
|
6363 |
+
* @return bool
|
6364 |
+
*/
|
6365 |
+
function has_account_addons() {
|
6366 |
+
$addons = $this->get_account_addons();
|
6367 |
+
|
6368 |
+
return is_array( $addons ) && ( 0 < count( $addons ) );
|
6369 |
+
}
|
6370 |
+
|
6371 |
+
|
6372 |
+
/**
|
6373 |
+
* Get add-on by ID (from local data).
|
6374 |
+
*
|
6375 |
+
* @author Vova Feldman (@svovaf)
|
6376 |
+
* @since 1.0.6
|
6377 |
+
*
|
6378 |
+
* @param number $id
|
6379 |
+
*
|
6380 |
+
* @return FS_Plugin|false
|
6381 |
+
*/
|
6382 |
+
function get_addon( $id ) {
|
6383 |
+
$this->_logger->entrance();
|
6384 |
+
|
6385 |
+
$addons = $this->get_addons();
|
6386 |
+
|
6387 |
+
if ( is_array( $addons ) ) {
|
6388 |
+
foreach ( $addons as $addon ) {
|
6389 |
+
if ( $id == $addon->id ) {
|
6390 |
+
return $addon;
|
6391 |
+
}
|
6392 |
+
}
|
6393 |
+
}
|
6394 |
+
|
6395 |
+
return false;
|
6396 |
+
}
|
6397 |
+
|
6398 |
+
/**
|
6399 |
+
* Get add-on by slug (from local data).
|
6400 |
+
*
|
6401 |
+
* @author Vova Feldman (@svovaf)
|
6402 |
+
* @since 1.0.6
|
6403 |
+
*
|
6404 |
+
* @param string $slug
|
6405 |
+
*
|
6406 |
+
* @param bool $flush
|
6407 |
+
*
|
6408 |
+
* @return FS_Plugin|false
|
6409 |
+
*/
|
6410 |
+
function get_addon_by_slug( $slug, $flush = false ) {
|
6411 |
+
$this->_logger->entrance();
|
6412 |
+
|
6413 |
+
$addons = $this->get_addons( $flush );
|
6414 |
+
|
6415 |
+
if ( is_array( $addons ) ) {
|
6416 |
+
foreach ( $addons as $addon ) {
|
6417 |
+
if ( $slug === $addon->slug ) {
|
6418 |
+
return $addon;
|
6419 |
+
}
|
6420 |
+
}
|
6421 |
+
}
|
6422 |
+
|
6423 |
+
return false;
|
6424 |
+
}
|
6425 |
+
|
6426 |
+
#----------------------------------------------------------------------------------
|
6427 |
+
#region Plans & Licensing
|
6428 |
+
#----------------------------------------------------------------------------------
|
6429 |
+
|
6430 |
+
/**
|
6431 |
+
* Check if running premium plugin code.
|
6432 |
+
*
|
6433 |
+
* @author Vova Feldman (@svovaf)
|
6434 |
+
* @since 1.0.5
|
6435 |
+
*
|
6436 |
+
* @return bool
|
6437 |
+
*/
|
6438 |
+
function is_premium() {
|
6439 |
+
return $this->_plugin->is_premium;
|
6440 |
+
}
|
6441 |
+
|
6442 |
+
/**
|
6443 |
+
* Get site's plan ID.
|
6444 |
+
*
|
6445 |
+
* @author Vova Feldman (@svovaf)
|
6446 |
+
* @since 1.0.2
|
6447 |
+
*
|
6448 |
+
* @return number
|
6449 |
+
*/
|
6450 |
+
function get_plan_id() {
|
6451 |
+
return $this->_site->plan->id;
|
6452 |
+
}
|
6453 |
+
|
6454 |
+
/**
|
6455 |
+
* Get site's plan title.
|
6456 |
+
*
|
6457 |
+
* @author Vova Feldman (@svovaf)
|
6458 |
+
* @since 1.0.2
|
6459 |
+
*
|
6460 |
+
* @return string
|
6461 |
+
*/
|
6462 |
+
function get_plan_title() {
|
6463 |
+
return $this->_site->plan->title;
|
6464 |
+
}
|
6465 |
+
|
6466 |
+
/**
|
6467 |
+
* @author Vova Feldman (@svovaf)
|
6468 |
+
* @since 1.0.9
|
6469 |
+
*
|
6470 |
+
* @return FS_Plugin_Plan|false
|
6471 |
+
*/
|
6472 |
+
function get_plan() {
|
6473 |
+
return is_object( $this->_site->plan ) ?
|
6474 |
+
$this->_site->plan :
|
6475 |
+
false;
|
6476 |
+
}
|
6477 |
+
|
6478 |
+
/**
|
6479 |
+
* @author Vova Feldman (@svovaf)
|
6480 |
+
* @since 1.0.3
|
6481 |
+
*
|
6482 |
+
* @return bool
|
6483 |
+
*/
|
6484 |
+
function is_trial() {
|
6485 |
+
$this->_logger->entrance();
|
6486 |
+
|
6487 |
+
if ( ! $this->is_registered() ) {
|
6488 |
+
return false;
|
6489 |
+
}
|
6490 |
+
|
6491 |
+
return $this->_site->is_trial();
|
6492 |
+
}
|
6493 |
+
|
6494 |
+
/**
|
6495 |
+
* Check if currently in a trial with payment method (credit card or paypal).
|
6496 |
+
*
|
6497 |
+
* @author Vova Feldman (@svovaf)
|
6498 |
+
* @since 1.1.7
|
6499 |
+
*
|
6500 |
+
* @return bool
|
6501 |
+
*/
|
6502 |
+
function is_paid_trial() {
|
6503 |
+
$this->_logger->entrance();
|
6504 |
+
|
6505 |
+
if ( ! $this->is_trial() ) {
|
6506 |
+
return false;
|
6507 |
+
}
|
6508 |
+
|
6509 |
+
return $this->has_active_valid_license() && ( $this->_site->trial_plan_id == $this->_license->plan_id );
|
6510 |
+
}
|
6511 |
+
|
6512 |
+
/**
|
6513 |
+
* Check if trial already utilized.
|
6514 |
+
*
|
6515 |
+
* @since 1.0.9
|
6516 |
+
*
|
6517 |
+
* @return bool
|
6518 |
+
*/
|
6519 |
+
function is_trial_utilized() {
|
6520 |
+
$this->_logger->entrance();
|
6521 |
+
|
6522 |
+
if ( ! $this->is_registered() ) {
|
6523 |
+
return false;
|
6524 |
+
}
|
6525 |
+
|
6526 |
+
return $this->_site->is_trial_utilized();
|
6527 |
+
}
|
6528 |
+
|
6529 |
+
/**
|
6530 |
+
* Get trial plan information (if in trial).
|
6531 |
+
*
|
6532 |
+
* @author Vova Feldman (@svovaf)
|
6533 |
+
* @since 1.0.9
|
6534 |
+
*
|
6535 |
+
* @return bool|FS_Plugin_Plan
|
6536 |
+
*/
|
6537 |
+
function get_trial_plan() {
|
6538 |
+
$this->_logger->entrance();
|
6539 |
+
|
6540 |
+
if ( ! $this->is_trial() ) {
|
6541 |
+
return false;
|
6542 |
+
}
|
6543 |
+
|
6544 |
+
return $this->_storage->trial_plan;
|
6545 |
+
}
|
6546 |
+
|
6547 |
+
/**
|
6548 |
+
* Check if the user has an activate, non-expired license on current plugin's install.
|
6549 |
+
*
|
6550 |
+
* @since 1.0.9
|
6551 |
+
*
|
6552 |
+
* @return bool
|
6553 |
+
*/
|
6554 |
+
function is_paying() {
|
6555 |
+
$this->_logger->entrance();
|
6556 |
+
|
6557 |
+
if ( ! $this->is_registered() ) {
|
6558 |
+
return false;
|
6559 |
+
}
|
6560 |
+
|
6561 |
+
if ( ! $this->has_paid_plan() ) {
|
6562 |
+
return false;
|
6563 |
+
}
|
6564 |
+
|
6565 |
+
return (
|
6566 |
+
! $this->is_trial() &&
|
6567 |
+
'free' !== $this->_site->plan->name &&
|
6568 |
+
$this->has_active_valid_license()
|
6569 |
+
);
|
6570 |
+
}
|
6571 |
+
|
6572 |
+
/**
|
6573 |
+
* @author Vova Feldman (@svovaf)
|
6574 |
+
* @since 1.0.4
|
6575 |
+
*
|
6576 |
+
* @return bool
|
6577 |
+
*/
|
6578 |
+
function is_free_plan() {
|
6579 |
+
if ( ! $this->is_registered() ) {
|
6580 |
+
return true;
|
6581 |
+
}
|
6582 |
+
|
6583 |
+
if ( ! $this->has_paid_plan() ) {
|
6584 |
+
return true;
|
6585 |
+
}
|
6586 |
+
|
6587 |
+
return (
|
6588 |
+
'free' === $this->_site->plan->name ||
|
6589 |
+
! $this->has_features_enabled_license()
|
6590 |
+
);
|
6591 |
+
}
|
6592 |
+
|
6593 |
+
/**
|
6594 |
+
* @author Vova Feldman (@svovaf)
|
6595 |
+
* @since 1.0.5
|
6596 |
+
*
|
6597 |
+
* @return bool
|
6598 |
+
*/
|
6599 |
+
function _has_premium_license() {
|
6600 |
+
$this->_logger->entrance();
|
6601 |
+
|
6602 |
+
$premium_license = $this->_get_available_premium_license();
|
6603 |
+
|
6604 |
+
return ( false !== $premium_license );
|
6605 |
+
}
|
6606 |
+
|
6607 |
+
/**
|
6608 |
+
* Check if user has any licenses associated with the plugin (including expired or blocking).
|
6609 |
+
*
|
6610 |
+
* @author Vova Feldman (@svovaf)
|
6611 |
+
* @since 1.1.7.3
|
6612 |
+
*
|
6613 |
+
* @return bool
|
6614 |
+
*/
|
6615 |
+
private function has_any_license() {
|
6616 |
+
return is_array( $this->_licenses ) && ( 0 < count( $this->_licenses ) );
|
6617 |
+
}
|
6618 |
+
|
6619 |
+
/**
|
6620 |
+
* @author Vova Feldman (@svovaf)
|
6621 |
+
* @since 1.0.5
|
6622 |
+
*
|
6623 |
+
* @return FS_Plugin_License|false
|
6624 |
+
*/
|
6625 |
+
function _get_available_premium_license() {
|
6626 |
+
$this->_logger->entrance();
|
6627 |
+
|
6628 |
+
if ( ! $this->has_paid_plan() ) {
|
6629 |
+
return false;
|
6630 |
+
}
|
6631 |
+
|
6632 |
+
if ( is_array( $this->_licenses ) ) {
|
6633 |
+
foreach ( $this->_licenses as $license ) {
|
6634 |
+
if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
|
6635 |
+
return $license;
|
6636 |
+
}
|
6637 |
+
}
|
6638 |
+
}
|
6639 |
+
|
6640 |
+
return false;
|
6641 |
+
}
|
6642 |
+
|
6643 |
+
/**
|
6644 |
+
* Sync local plugin plans with remote server.
|
6645 |
+
*
|
6646 |
+
* @author Vova Feldman (@svovaf)
|
6647 |
+
* @since 1.0.5
|
6648 |
+
*
|
6649 |
+
* @return FS_Plugin_Plan[]|object
|
6650 |
+
*/
|
6651 |
+
function _sync_plans() {
|
6652 |
+
$plans = $this->_fetch_plugin_plans();
|
6653 |
+
|
6654 |
+
if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) {
|
6655 |
+
$this->_plans = $plans;
|
6656 |
+
$this->_store_plans();
|
6657 |
+
}
|
6658 |
+
|
6659 |
+
$this->do_action( 'after_plans_sync', $plans );
|
6660 |
+
|
6661 |
+
return $this->_plans;
|
6662 |
+
}
|
6663 |
+
|
6664 |
+
/**
|
6665 |
+
* @author Vova Feldman (@svovaf)
|
6666 |
+
* @since 1.0.5
|
6667 |
+
*
|
6668 |
+
* @param number $id
|
6669 |
+
*
|
6670 |
+
* @return FS_Plugin_Plan|false
|
6671 |
+
*/
|
6672 |
+
function _get_plan_by_id( $id ) {
|
6673 |
+
$this->_logger->entrance();
|
6674 |
+
|
6675 |
+
if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
|
6676 |
+
$this->_sync_plans();
|
6677 |
+
}
|
6678 |
+
|
6679 |
+
foreach ( $this->_plans as $plan ) {
|
6680 |
+
if ( $id == $plan->id ) {
|
6681 |
+
return $plan;
|
6682 |
+
}
|
6683 |
+
}
|
6684 |
+
|
6685 |
+
return false;
|
6686 |
+
}
|
6687 |
+
|
6688 |
+
/**
|
6689 |
+
* @author Vova Feldman (@svovaf)
|
6690 |
+
* @since 1.1.8.1
|
6691 |
+
*
|
6692 |
+
* @param string $name
|
6693 |
+
*
|
6694 |
+
* @return FS_Plugin_Plan|false
|
6695 |
+
*/
|
6696 |
+
private function get_plan_by_name( $name ) {
|
6697 |
+
$this->_logger->entrance();
|
6698 |
+
|
6699 |
+
if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
|
6700 |
+
$this->_sync_plans();
|
6701 |
+
}
|
6702 |
+
|
6703 |
+
foreach ( $this->_plans as $plan ) {
|
6704 |
+
if ( $name == $plan->name ) {
|
6705 |
+
return $plan;
|
6706 |
+
}
|
6707 |
+
}
|
6708 |
+
|
6709 |
+
return false;
|
6710 |
+
}
|
6711 |
+
|
6712 |
+
/**
|
6713 |
+
* Sync local plugin plans with remote server.
|
6714 |
+
*
|
6715 |
+
* @author Vova Feldman (@svovaf)
|
6716 |
+
* @since 1.0.6
|
6717 |
+
*
|
6718 |
+
* @param number|bool $site_license_id
|
6719 |
+
*
|
6720 |
+
* @return FS_Plugin_License[]|object
|
6721 |
+
*/
|
6722 |
+
function _sync_licenses( $site_license_id = false ) {
|
6723 |
+
$licenses = $this->_fetch_licenses( false, $site_license_id );
|
6724 |
+
|
6725 |
+
if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
|
6726 |
+
$this->_licenses = $licenses;
|
6727 |
+
$this->_store_licenses();
|
6728 |
+
}
|
6729 |
+
|
6730 |
+
// Update current license.
|
6731 |
+
if ( is_object( $this->_license ) ) {
|
6732 |
+
$this->_license = $this->_get_license_by_id( $this->_license->id );
|
6733 |
+
}
|
6734 |
+
|
6735 |
+
return $this->_licenses;
|
6736 |
+
}
|
6737 |
+
|
6738 |
+
/**
|
6739 |
+
* @author Vova Feldman (@svovaf)
|
6740 |
+
* @since 1.0.5
|
6741 |
+
*
|
6742 |
+
* @param number $id
|
6743 |
+
*
|
6744 |
+
* @return FS_Plugin_License|false
|
6745 |
+
*/
|
6746 |
+
function _get_license_by_id( $id ) {
|
6747 |
+
$this->_logger->entrance();
|
6748 |
+
|
6749 |
+
if ( ! is_numeric( $id ) ) {
|
6750 |
+
return false;
|
6751 |
+
}
|
6752 |
+
|
6753 |
+
if ( ! $this->has_any_license() ) {
|
6754 |
+
$this->_sync_licenses();
|
6755 |
+
}
|
6756 |
+
|
6757 |
+
foreach ( $this->_licenses as $license ) {
|
6758 |
+
if ( $id == $license->id ) {
|
6759 |
+
return $license;
|
6760 |
+
}
|
6761 |
+
}
|
6762 |
+
|
6763 |
+
return false;
|
6764 |
+
}
|
6765 |
+
|
6766 |
+
/**
|
6767 |
+
* Sync site's license with user licenses.
|
6768 |
+
*
|
6769 |
+
* @author Vova Feldman (@svovaf)
|
6770 |
+
* @since 1.0.6
|
6771 |
+
*
|
6772 |
+
* @param FS_Plugin_License|null $new_license
|
6773 |
+
*/
|
6774 |
+
function _update_site_license( $new_license ) {
|
6775 |
+
$this->_logger->entrance();
|
6776 |
+
|
6777 |
+
$this->_license = $new_license;
|
6778 |
+
|
6779 |
+
if ( ! is_object( $new_license ) ) {
|
6780 |
+
$this->_site->license_id = null;
|
6781 |
+
$this->_sync_site_subscription( null );
|
6782 |
+
|
6783 |
+
return;
|
6784 |
+
}
|
6785 |
+
|
6786 |
+
$this->_site->license_id = $this->_license->id;
|
6787 |
+
|
6788 |
+
if ( ! is_array( $this->_licenses ) ) {
|
6789 |
+
$this->_licenses = array();
|
6790 |
+
}
|
6791 |
+
|
6792 |
+
$is_license_found = false;
|
6793 |
+
for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
|
6794 |
+
if ( $new_license->id == $this->_licenses[ $i ]->id ) {
|
6795 |
+
$this->_licenses[ $i ] = $new_license;
|
6796 |
+
|
6797 |
+
$is_license_found = true;
|
6798 |
+
break;
|
6799 |
+
}
|
6800 |
+
}
|
6801 |
+
|
6802 |
+
// If new license just append.
|
6803 |
+
if ( ! $is_license_found ) {
|
6804 |
+
$this->_licenses[] = $new_license;
|
6805 |
+
}
|
6806 |
+
|
6807 |
+
$this->_sync_site_subscription( $new_license );
|
6808 |
+
}
|
6809 |
+
|
6810 |
+
/**
|
6811 |
+
* Sync site's subscription.
|
6812 |
+
*
|
6813 |
+
* @author Vova Feldman (@svovaf)
|
6814 |
+
* @since 1.0.9
|
6815 |
+
*
|
6816 |
+
* @param FS_Plugin_License|null $license
|
6817 |
+
*
|
6818 |
+
* @return bool|\FS_Subscription
|
6819 |
+
*/
|
6820 |
+
private function _sync_site_subscription( $license ) {
|
6821 |
+
if ( ! is_object( $license ) ) {
|
6822 |
+
unset( $this->_storage->subscription );
|
6823 |
+
|
6824 |
+
return false;
|
6825 |
+
}
|
6826 |
+
|
6827 |
+
// Load subscription details if not lifetime.
|
6828 |
+
$subscription = $license->is_lifetime() ?
|
6829 |
+
false :
|
6830 |
+
$this->_fetch_site_license_subscription();
|
6831 |
+
|
6832 |
+
if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
|
6833 |
+
$this->_storage->subscription = $subscription;
|
6834 |
+
} else {
|
6835 |
+
unset( $this->_storage->subscription );
|
6836 |
+
}
|
6837 |
+
|
6838 |
+
return $subscription;
|
6839 |
+
}
|
6840 |
+
|
6841 |
+
/**
|
6842 |
+
* @author Vova Feldman (@svovaf)
|
6843 |
+
* @since 1.0.6
|
6844 |
+
*
|
6845 |
+
* @return bool|\FS_Plugin_License
|
6846 |
+
*/
|
6847 |
+
function _get_license() {
|
6848 |
+
return $this->_license;
|
6849 |
+
}
|
6850 |
+
|
6851 |
+
/**
|
6852 |
+
* @return bool|\FS_Subscription
|
6853 |
+
*/
|
6854 |
+
function _get_subscription() {
|
6855 |
+
return isset( $this->_storage->subscription ) ?
|
6856 |
+
$this->_storage->subscription :
|
6857 |
+
false;
|
6858 |
+
}
|
6859 |
+
|
6860 |
+
/**
|
6861 |
+
* @author Vova Feldman (@svovaf)
|
6862 |
+
* @since 1.0.2
|
6863 |
+
*
|
6864 |
+
* @param string $plan Plan name
|
6865 |
+
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
|
6866 |
+
*
|
6867 |
+
* @return bool
|
6868 |
+
*/
|
6869 |
+
function is_plan( $plan, $exact = false ) {
|
6870 |
+
$this->_logger->entrance();
|
6871 |
+
|
6872 |
+
if ( ! $this->is_registered() ) {
|
6873 |
+
return false;
|
6874 |
+
}
|
6875 |
+
|
6876 |
+
$plan = strtolower( $plan );
|
6877 |
+
|
6878 |
+
if ( $this->_site->plan->name === $plan ) // Exact plan.
|
6879 |
+
{
|
6880 |
+
return true;
|
6881 |
+
} else if ( $exact ) // Required exact, but plans are different.
|
6882 |
+
{
|
6883 |
+
return false;
|
6884 |
+
}
|
6885 |
+
|
6886 |
+
$current_plan_order = - 1;
|
6887 |
+
$required_plan_order = - 1;
|
6888 |
+
for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
|
6889 |
+
if ( $plan === $this->_plans[ $i ]->name ) {
|
6890 |
+
$required_plan_order = $i;
|
6891 |
+
} else if ( $this->_site->plan->name === $this->_plans[ $i ]->name ) {
|
6892 |
+
$current_plan_order = $i;
|
6893 |
+
}
|
6894 |
+
}
|
6895 |
+
|
6896 |
+
return ( $current_plan_order > $required_plan_order );
|
6897 |
+
}
|
6898 |
+
|
6899 |
+
/**
|
6900 |
+
* Check if module has only one plan.
|
6901 |
+
*
|
6902 |
+
* @author Vova Feldman (@svovaf)
|
6903 |
+
* @since 1.2.1.7
|
6904 |
+
*
|
6905 |
+
* @return bool
|
6906 |
+
*/
|
6907 |
+
function is_single_plan() {
|
6908 |
+
$this->_logger->entrance();
|
6909 |
+
|
6910 |
+
if ( ! $this->is_registered() ||
|
6911 |
+
! is_array( $this->_plans ) ||
|
6912 |
+
0 === count( $this->_plans )
|
6913 |
+
) {
|
6914 |
+
return true;
|
6915 |
+
}
|
6916 |
+
|
6917 |
+
return ( 1 === count( $this->_plans ) );
|
6918 |
+
}
|
6919 |
+
|
6920 |
+
/**
|
6921 |
+
* Check if plan based on trial. If not in trial mode, should return false.
|
6922 |
+
*
|
6923 |
+
* @since 1.0.9
|
6924 |
+
*
|
6925 |
+
* @param string $plan Plan name
|
6926 |
+
* @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
|
6927 |
+
*
|
6928 |
+
* @return bool
|
6929 |
+
*/
|
6930 |
+
function is_trial_plan( $plan, $exact = false ) {
|
6931 |
+
$this->_logger->entrance();
|
6932 |
+
|
6933 |
+
if ( ! $this->is_registered() ) {
|
6934 |
+
return false;
|
6935 |
+
}
|
6936 |
+
|
6937 |
+
if ( ! $this->is_trial() ) {
|
6938 |
+
return false;
|
6939 |
+
}
|
6940 |
+
|
6941 |
+
if ( ! isset( $this->_storage->trial_plan ) ) {
|
6942 |
+
// Store trial plan information.
|
6943 |
+
$this->_enrich_site_trial_plan( true );
|
6944 |
+
}
|
6945 |
+
|
6946 |
+
if ( $this->_storage->trial_plan->name === $plan ) // Exact plan.
|
6947 |
+
{
|
6948 |
+
return true;
|
6949 |
+
} else if ( $exact ) // Required exact, but plans are different.
|
6950 |
+
{
|
6951 |
+
return false;
|
6952 |
+
}
|
6953 |
+
|
6954 |
+
$current_plan_order = - 1;
|
6955 |
+
$required_plan_order = - 1;
|
6956 |
+
for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
|
6957 |
+
if ( $plan === $this->_plans[ $i ]->name ) {
|
6958 |
+
$required_plan_order = $i;
|
6959 |
+
} else if ( $this->_storage->trial_plan->name === $this->_plans[ $i ]->name ) {
|
6960 |
+
$current_plan_order = $i;
|
6961 |
+
}
|
6962 |
+
}
|
6963 |
+
|
6964 |
+
return ( $current_plan_order > $required_plan_order );
|
6965 |
+
}
|
6966 |
+
|
6967 |
+
/**
|
6968 |
+
* Check if plugin has any paid plans.
|
6969 |
+
*
|
6970 |
+
* @author Vova Feldman (@svovaf)
|
6971 |
+
* @since 1.0.7
|
6972 |
+
*
|
6973 |
+
* @return bool
|
6974 |
+
*/
|
6975 |
+
function has_paid_plan() {
|
6976 |
+
return $this->_has_paid_plans ||
|
6977 |
+
FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
|
6978 |
+
}
|
6979 |
+
|
6980 |
+
/**
|
6981 |
+
* Check if plugin has any plan with a trail.
|
6982 |
+
*
|
6983 |
+
* @author Vova Feldman (@svovaf)
|
6984 |
+
* @since 1.0.9
|
6985 |
+
*
|
6986 |
+
* @return bool
|
6987 |
+
*/
|
6988 |
+
function has_trial_plan() {
|
6989 |
+
if ( ! $this->is_registered() ) {
|
6990 |
+
/**
|
6991 |
+
* @author Vova Feldman(@svovaf)
|
6992 |
+
* @since 1.2.1.5
|
6993 |
+
*
|
6994 |
+
* Allow setting a trial from the SDK without calling the API.
|
6995 |
+
* But, if the user did opt-in, continue using the real data from the API.
|
6996 |
+
*/
|
6997 |
+
if ( $this->_trial_days >= 0 ) {
|
6998 |
+
return true;
|
6999 |
+
}
|
7000 |
+
|
7001 |
+
return false;
|
7002 |
+
}
|
7003 |
+
|
7004 |
+
return $this->_storage->get( 'has_trial_plan', false );
|
7005 |
+
}
|
7006 |
+
|
7007 |
+
/**
|
7008 |
+
* Check if plugin has any free plan, or is it premium only.
|
7009 |
+
*
|
7010 |
+
* Note: If no plans configured, assume plugin is free.
|
7011 |
+
*
|
7012 |
+
* @author Vova Feldman (@svovaf)
|
7013 |
+
* @since 1.0.7
|
7014 |
+
*
|
7015 |
+
* @return bool
|
7016 |
+
*/
|
7017 |
+
function has_free_plan() {
|
7018 |
+
return ! $this->is_only_premium();
|
7019 |
+
}
|
7020 |
+
|
7021 |
+
/**
|
7022 |
+
* Displays a license activation dialog box when the user clicks on the "Activate License"
|
7023 |
+
* or "Change License" link on the plugins
|
7024 |
+
* page.
|
7025 |
+
*
|
7026 |
+
* @author Leo Fajardo (@leorw)
|
7027 |
+
* @since 1.1.9
|
7028 |
+
*/
|
7029 |
+
function _add_license_activation_dialog_box() {
|
7030 |
+
$vars = array(
|
7031 |
+
'id' => $this->_module_id,
|
7032 |
+
);
|
7033 |
+
|
7034 |
+
fs_require_template( 'forms/license-activation.php', $vars );
|
7035 |
+
fs_require_template( 'forms/resend-key.php', $vars );
|
7036 |
+
}
|
7037 |
+
|
7038 |
+
/**
|
7039 |
+
* Displays the opt-out dialog box when the user clicks on the "Opt Out" link on the "Plugins"
|
7040 |
+
* page.
|
7041 |
+
*
|
7042 |
+
* @author Leo Fajardo (@leorw)
|
7043 |
+
* @since 1.2.1.5
|
7044 |
+
*/
|
7045 |
+
function _add_optout_dialog() {
|
7046 |
+
if ( $this->is_theme() ) {
|
7047 |
+
$vars = null;
|
7048 |
+
fs_require_once_template( '/js/jquery.content-change.php', $vars );
|
7049 |
+
}
|
7050 |
+
|
7051 |
+
$vars = array( 'id' => $this->_module_id );
|
7052 |
+
fs_require_template( 'forms/optout.php', $vars );
|
7053 |
+
}
|
7054 |
+
|
7055 |
+
/**
|
7056 |
+
* Prepare page to include all required UI and logic for the license activation dialog.
|
7057 |
+
*
|
7058 |
+
* @author Vova Feldman (@svovaf)
|
7059 |
+
* @since 1.2.0
|
7060 |
+
*/
|
7061 |
+
function _add_license_activation() {
|
7062 |
+
if ( ! $this->is_user_admin() ) {
|
7063 |
+
// Only admins can activate a license.
|
7064 |
+
return;
|
7065 |
+
}
|
7066 |
+
|
7067 |
+
if ( ! $this->has_paid_plan() ) {
|
7068 |
+
// Module doesn't have any paid plans.
|
7069 |
+
return;
|
7070 |
+
}
|
7071 |
+
|
7072 |
+
if ( ! $this->is_premium() ) {
|
7073 |
+
// Only add license activation logic to the premium version.
|
7074 |
+
return;
|
7075 |
+
}
|
7076 |
+
|
7077 |
+
// Add license activation link and AJAX request handler.
|
7078 |
+
if ( self::is_plugins_page() ) {
|
7079 |
+
/**
|
7080 |
+
* @since 1.2.0 Add license action link only on plugins page.
|
7081 |
+
*/
|
7082 |
+
$this->_add_license_action_link();
|
7083 |
+
}
|
7084 |
+
|
7085 |
+
// Add license activation AJAX callback.
|
7086 |
+
$this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) );
|
7087 |
+
|
7088 |
+
// Add resend license AJAX callback.
|
7089 |
+
$this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) );
|
7090 |
+
}
|
7091 |
+
|
7092 |
+
/**
|
7093 |
+
* @author Leo Fajardo (@leorw)
|
7094 |
+
* @since 1.1.9
|
7095 |
+
*/
|
7096 |
+
function _activate_license_ajax_action() {
|
7097 |
+
$this->_logger->entrance();
|
7098 |
+
|
7099 |
+
$this->check_ajax_referer( 'activate_license' );
|
7100 |
+
|
7101 |
+
$license_key = trim( fs_request_get( 'license_key' ) );
|
7102 |
+
|
7103 |
+
if ( empty( $license_key ) ) {
|
7104 |
+
exit;
|
7105 |
+
}
|
7106 |
+
|
7107 |
+
$plugin_id = fs_request_get( 'module_id', '', 'post' );
|
7108 |
+
$fs = ( $plugin_id == $this->_module_id ) ?
|
7109 |
+
$this :
|
7110 |
+
$this->get_addon_instance( $plugin_id );
|
7111 |
+
|
7112 |
+
$error = false;
|
7113 |
+
$next_page = false;
|
7114 |
+
|
7115 |
+
if ( $fs->is_registered() ) {
|
7116 |
+
$api = $fs->get_api_site_scope();
|
7117 |
+
$install = $api->call( '/', 'put', array(
|
7118 |
+
'license_key' => $fs->apply_filters( 'license_key', $license_key )
|
7119 |
+
) );
|
7120 |
+
|
7121 |
+
if ( isset( $install->error ) ) {
|
7122 |
+
$error = $install->error->message;
|
7123 |
+
} else {
|
7124 |
+
$fs->_sync_license( true );
|
7125 |
+
|
7126 |
+
$next_page = $fs->is_addon() ?
|
7127 |
+
$fs->get_parent_instance()->get_account_url() :
|
7128 |
+
$fs->get_account_url();
|
7129 |
+
|
7130 |
+
$fs->reconnect_locally();
|
7131 |
+
}
|
7132 |
+
} else {
|
7133 |
+
$next_page = $fs->opt_in( false, false, false, $license_key );
|
7134 |
+
|
7135 |
+
if ( isset( $next_page->error ) ) {
|
7136 |
+
$error = $next_page->error;
|
7137 |
+
}
|
7138 |
+
}
|
7139 |
+
|
7140 |
+
$result = array(
|
7141 |
+
'success' => ( false === $error )
|
7142 |
+
);
|
7143 |
+
|
7144 |
+
if ( false !== $error ) {
|
7145 |
+
$result['error'] = $error;
|
7146 |
+
} else {
|
7147 |
+
$result['next_page'] = $next_page;
|
7148 |
+
}
|
7149 |
+
|
7150 |
+
echo json_encode( $result );
|
7151 |
+
|
7152 |
+
exit;
|
7153 |
+
}
|
7154 |
+
|
7155 |
+
/**
|
7156 |
+
* Billing update AJAX callback.
|
7157 |
+
*
|
7158 |
+
* @author Vova Feldman (@svovaf)
|
7159 |
+
* @since 1.2.1.5
|
7160 |
+
*/
|
7161 |
+
function _update_billing_ajax_action() {
|
7162 |
+
$this->_logger->entrance();
|
7163 |
+
|
7164 |
+
$this->check_ajax_referer( 'update_billing' );
|
7165 |
+
|
7166 |
+
if ( ! $this->is_user_admin() ) {
|
7167 |
+
// Only for admins.
|
7168 |
+
self::shoot_ajax_failure();
|
7169 |
+
}
|
7170 |
+
|
7171 |
+
$billing = fs_request_get( 'billing' );
|
7172 |
+
|
7173 |
+
$api = $this->get_api_user_scope();
|
7174 |
+
$result = $api->call( '/billing.json', 'put', array_merge( $billing, array(
|
7175 |
+
'plugin_id' => $this->get_parent_id(),
|
7176 |
+
) ) );
|
7177 |
+
|
7178 |
+
if ( ! $this->is_api_result_entity( $result ) ) {
|
7179 |
+
self::shoot_ajax_failure();
|
7180 |
+
}
|
7181 |
+
|
7182 |
+
// Purge cached billing.
|
7183 |
+
$this->get_api_user_scope()->purge_cache( 'billing.json' );
|
7184 |
+
|
7185 |
+
self::shoot_ajax_success();
|
7186 |
+
}
|
7187 |
+
|
7188 |
+
/**
|
7189 |
+
* Trial start for anonymous users (AJAX callback).
|
7190 |
+
*
|
7191 |
+
* @author Vova Feldman (@svovaf)
|
7192 |
+
* @since 1.2.1.5
|
7193 |
+
*/
|
7194 |
+
function _start_trial_ajax_action() {
|
7195 |
+
$this->_logger->entrance();
|
7196 |
+
|
7197 |
+
$this->check_ajax_referer( 'start_trial' );
|
7198 |
+
|
7199 |
+
if ( ! $this->is_user_admin() ) {
|
7200 |
+
// Only for admins.
|
7201 |
+
self::shoot_ajax_failure();
|
7202 |
+
}
|
7203 |
+
|
7204 |
+
$trial_data = fs_request_get( 'trial' );
|
7205 |
+
|
7206 |
+
$next_page = $this->opt_in(
|
7207 |
+
false,
|
7208 |
+
false,
|
7209 |
+
false,
|
7210 |
+
false,
|
7211 |
+
false,
|
7212 |
+
$trial_data['plan_id']
|
7213 |
+
);
|
7214 |
+
|
7215 |
+
if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
|
7216 |
+
self::shoot_ajax_failure(
|
7217 |
+
isset( $next_page->error ) ?
|
7218 |
+
$next_page->error->message :
|
7219 |
+
var_export( $next_page, true )
|
7220 |
+
);
|
7221 |
+
}
|
7222 |
+
|
7223 |
+
$this->shoot_ajax_success( array(
|
7224 |
+
'next_page' => $next_page,
|
7225 |
+
) );
|
7226 |
+
}
|
7227 |
+
|
7228 |
+
/**
|
7229 |
+
* @author Leo Fajardo (@leorw)
|
7230 |
+
* @since 1.2.0
|
7231 |
+
*/
|
7232 |
+
function _resend_license_key_ajax_action() {
|
7233 |
+
$this->_logger->entrance();
|
7234 |
+
|
7235 |
+
$this->check_ajax_referer( 'resend_license_key' );
|
7236 |
+
|
7237 |
+
$email_address = sanitize_email( trim( fs_request_get( 'email', '', 'post' ) ) );
|
7238 |
+
|
7239 |
+
if ( empty( $email_address ) ) {
|
7240 |
+
exit;
|
7241 |
+
}
|
7242 |
+
|
7243 |
+
$error = false;
|
7244 |
+
|
7245 |
+
$api = $this->get_api_plugin_scope();
|
7246 |
+
$result = $api->call( '/licenses/resend.json', 'post',
|
7247 |
+
array(
|
7248 |
+
'email' => $email_address,
|
7249 |
+
'url' => home_url(),
|
7250 |
+
)
|
7251 |
+
);
|
7252 |
+
|
7253 |
+
if ( is_object( $result ) && isset( $result->error ) ) {
|
7254 |
+
$error = $result->error;
|
7255 |
+
|
7256 |
+
if ( in_array( $error->code, array( 'invalid_email', 'no_user' ) ) ) {
|
7257 |
+
$error = $this->get_text_inline( "We couldn't find your email address in the system, are you sure it's the right address?", 'email-not-found' );
|
7258 |
+
} else if ( 'no_license' === $error->code ) {
|
7259 |
+
$error = $this->get_text_inline( "We can't see any active licenses associated with that email address, are you sure it's the right address?", 'no-active-licenses' );
|
7260 |
+
} else {
|
7261 |
+
$error = $error->message;
|
7262 |
+
}
|
7263 |
+
}
|
7264 |
+
|
7265 |
+
$licenses = array(
|
7266 |
+
'success' => ( false === $error )
|
7267 |
+
);
|
7268 |
+
|
7269 |
+
if ( false !== $error ) {
|
7270 |
+
$licenses['error'] = sprintf( '%s... %s', $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ), strtolower( $error ) );
|
7271 |
+
}
|
7272 |
+
|
7273 |
+
echo json_encode( $licenses );
|
7274 |
+
|
7275 |
+
exit;
|
7276 |
+
}
|
7277 |
+
|
7278 |
+
/**
|
7279 |
+
* @author Vova Feldman (@svovaf)
|
7280 |
+
* @since 1.2.1.8
|
7281 |
+
*
|
7282 |
+
* @var string
|
7283 |
+
*/
|
7284 |
+
private static $_pagenow;
|
7285 |
+
|
7286 |
+
/**
|
7287 |
+
* Get current page or the referer if executing a WP AJAX request.
|
7288 |
+
*
|
7289 |
+
* @author Vova Feldman (@svovaf)
|
7290 |
+
* @since 1.2.1.8
|
7291 |
+
*
|
7292 |
+
* @return string
|
7293 |
+
*/
|
7294 |
+
static function get_current_page() {
|
7295 |
+
if ( ! isset( self::$_pagenow ) ) {
|
7296 |
+
global $pagenow;
|
7297 |
+
|
7298 |
+
self::$_pagenow = $pagenow;
|
7299 |
+
|
7300 |
+
if ( self::is_ajax() &&
|
7301 |
+
'admin-ajax.php' === $pagenow
|
7302 |
+
) {
|
7303 |
+
$referer = fs_get_raw_referer();
|
7304 |
+
|
7305 |
+
if ( is_string( $referer ) ) {
|
7306 |
+
$parts = explode( '?', $referer );
|
7307 |
+
|
7308 |
+
self::$_pagenow = basename( $parts[0] );
|
7309 |
+
}
|
7310 |
+
}
|
7311 |
+
}
|
7312 |
+
|
7313 |
+
return self::$_pagenow;
|
7314 |
+
}
|
7315 |
+
|
7316 |
+
/**
|
7317 |
+
* Helper method to check if user in the plugins page.
|
7318 |
+
*
|
7319 |
+
* @author Vova Feldman (@svovaf)
|
7320 |
+
* @since 1.2.1.5
|
7321 |
+
*
|
7322 |
+
* @return bool
|
7323 |
+
*/
|
7324 |
+
static function is_plugins_page() {
|
7325 |
+
return ( 'plugins.php' === self::get_current_page() );
|
7326 |
+
}
|
7327 |
+
|
7328 |
+
/**
|
7329 |
+
* Helper method to check if user in the themes page.
|
7330 |
+
*
|
7331 |
+
* @author Vova Feldman (@svovaf)
|
7332 |
+
* @since 1.2.2.6
|
7333 |
+
*
|
7334 |
+
* @return bool
|
7335 |
+
*/
|
7336 |
+
static function is_themes_page() {
|
7337 |
+
return ( 'themes.php' === self::get_current_page() );
|
7338 |
+
}
|
7339 |
+
|
7340 |
+
#----------------------------------------------------------------------------------
|
7341 |
+
#region Affiliation
|
7342 |
+
#----------------------------------------------------------------------------------
|
7343 |
+
|
7344 |
+
/**
|
7345 |
+
* @author Leo Fajardo
|
7346 |
+
* @since 1.2.3
|
7347 |
+
*
|
7348 |
+
* @return bool
|
7349 |
+
*/
|
7350 |
+
function has_affiliate_program() {
|
7351 |
+
if ( ! is_object( $this->_plugin ) ) {
|
7352 |
+
return false;
|
7353 |
+
}
|
7354 |
+
|
7355 |
+
return $this->_plugin->has_affiliate_program();
|
7356 |
+
}
|
7357 |
+
|
7358 |
+
/**
|
7359 |
+
* @author Leo Fajardo (@leorw)
|
7360 |
+
* @since 1.2.3
|
7361 |
+
*/
|
7362 |
+
private function fetch_affiliate_and_terms() {
|
7363 |
+
$this->_logger->entrance();
|
7364 |
+
|
7365 |
+
if ( ! is_object( $this->plugin_affiliate_terms ) ) {
|
7366 |
+
$plugins_api = $this->get_api_plugin_scope();
|
7367 |
+
$affiliate_terms = $plugins_api->get( '/aff.json?type=affiliation', true );
|
7368 |
+
|
7369 |
+
if ( ! $this->is_api_result_entity( $affiliate_terms ) ) {
|
7370 |
+
return;
|
7371 |
+
}
|
7372 |
+
|
7373 |
+
$this->plugin_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
|
7374 |
+
}
|
7375 |
+
|
7376 |
+
if ( $this->is_registered() ) {
|
7377 |
+
$users_api = $this->get_api_user_scope();
|
7378 |
+
$result = $users_api->get( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json", true );
|
7379 |
+
if ( $this->is_api_result_object( $result, 'affiliates' ) ) {
|
7380 |
+
if ( ! empty( $result->affiliates ) ) {
|
7381 |
+
$affiliate = new FS_Affiliate( $result->affiliates[0] );
|
7382 |
+
|
7383 |
+
if ( ! $affiliate->is_pending() && ! empty( $this->_storage->affiliate_application_data ) ) {
|
7384 |
+
unset( $this->_storage->affiliate_application_data );
|
7385 |
+
}
|
7386 |
+
|
7387 |
+
if ( $affiliate->is_using_custom_terms ) {
|
7388 |
+
$affiliate_terms = $users_api->get( "/plugins/{$this->_plugin->id}/affiliates/{$affiliate->id}/aff/{$affiliate->custom_affiliate_terms_id}.json", true );
|
7389 |
+
if ( $this->is_api_result_entity( $affiliate_terms ) ) {
|
7390 |
+
$this->custom_affiliate_terms = new FS_AffiliateTerms( $affiliate_terms );
|
7391 |
+
}
|
7392 |
+
}
|
7393 |
+
|
7394 |
+
$this->affiliate = $affiliate;
|
7395 |
+
}
|
7396 |
+
}
|
7397 |
+
}
|
7398 |
+
}
|
7399 |
+
|
7400 |
+
/**
|
7401 |
+
* @author Leo Fajardo
|
7402 |
+
* @since 1.2.3
|
7403 |
+
*
|
7404 |
+
* @return FS_Affiliate
|
7405 |
+
*/
|
7406 |
+
function get_affiliate() {
|
7407 |
+
return $this->affiliate;
|
7408 |
+
}
|
7409 |
+
|
7410 |
+
|
7411 |
+
/**
|
7412 |
+
* @author Leo Fajardo
|
7413 |
+
* @since 1.2.3
|
7414 |
+
*
|
7415 |
+
* @return FS_AffiliateTerms
|
7416 |
+
*/
|
7417 |
+
function get_affiliate_terms() {
|
7418 |
+
return is_object( $this->custom_affiliate_terms ) ?
|
7419 |
+
$this->custom_affiliate_terms :
|
7420 |
+
$this->plugin_affiliate_terms;
|
7421 |
+
}
|
7422 |
+
|
7423 |
+
/**
|
7424 |
+
* @author Leo Fajardo
|
7425 |
+
* @since 1.2.3
|
7426 |
+
*
|
7427 |
+
* @return FS_Affiliate|null
|
7428 |
+
*/
|
7429 |
+
function _submit_affiliate_application() {
|
7430 |
+
$this->_logger->entrance();
|
7431 |
+
|
7432 |
+
$this->check_ajax_referer( 'submit_affiliate_application' );
|
7433 |
+
|
7434 |
+
if ( ! $this->is_user_admin() ) {
|
7435 |
+
// Only for admins.
|
7436 |
+
self::shoot_ajax_failure();
|
7437 |
+
}
|
7438 |
+
|
7439 |
+
$affiliate = fs_request_get( 'affiliate' );
|
7440 |
+
|
7441 |
+
if ( empty( $affiliate['promotion_methods'] ) ) {
|
7442 |
+
unset( $affiliate['promotion_methods'] );
|
7443 |
+
}
|
7444 |
+
|
7445 |
+
if ( ! empty( $affiliate['additional_domains'] ) ) {
|
7446 |
+
$affiliate['additional_domains'] = array_unique( $affiliate['additional_domains'] );
|
7447 |
+
}
|
7448 |
+
|
7449 |
+
if ( ! $this->is_registered() ) {
|
7450 |
+
// Opt in but don't track usage.
|
7451 |
+
$next_page = $this->opt_in(
|
7452 |
+
false,
|
7453 |
+
false,
|
7454 |
+
false,
|
7455 |
+
false,
|
7456 |
+
false,
|
7457 |
+
false,
|
7458 |
+
true
|
7459 |
+
);
|
7460 |
+
|
7461 |
+
if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
|
7462 |
+
self::shoot_ajax_failure(
|
7463 |
+
isset( $next_page->error ) ?
|
7464 |
+
$next_page->error->message :
|
7465 |
+
var_export( $next_page, true )
|
7466 |
+
);
|
7467 |
+
} else if ( $this->is_pending_activation() ) {
|
7468 |
+
self::shoot_ajax_failure( $this->get_text_inline( 'Account is pending activation.', 'account-is-pending-activation' ) );
|
7469 |
+
}
|
7470 |
+
}
|
7471 |
+
|
7472 |
+
$api = $this->get_api_user_scope();
|
7473 |
+
$result = $api->call(
|
7474 |
+
( "/plugins/{$this->_plugin->id}/aff/{$this->plugin_affiliate_terms->id}/affiliates.json" ),
|
7475 |
+
'post',
|
7476 |
+
$affiliate
|
7477 |
+
);
|
7478 |
+
|
7479 |
+
if ( $this->is_api_error( $result ) ) {
|
7480 |
+
self::shoot_ajax_failure(
|
7481 |
+
isset( $result->error ) ?
|
7482 |
+
$result->error->message :
|
7483 |
+
var_export( $result, true )
|
7484 |
+
);
|
7485 |
+
}
|
7486 |
+
else
|
7487 |
+
{
|
7488 |
+
if ( $this->_admin_notices->has_sticky( 'affiliate_program' ) ) {
|
7489 |
+
$this->_admin_notices->remove_sticky( 'affiliate_program' );
|
7490 |
+
}
|
7491 |
+
|
7492 |
+
$affiliate_application_data = array(
|
7493 |
+
'stats_description' => $affiliate['stats_description'],
|
7494 |
+
'promotion_method_description' => $affiliate['promotion_method_description'],
|
7495 |
+
);
|
7496 |
+
|
7497 |
+
if ( ! empty( $affiliate['promotion_methods'] ) ) {
|
7498 |
+
$affiliate_application_data['promotion_methods'] = $affiliate['promotion_methods'];
|
7499 |
+
}
|
7500 |
+
|
7501 |
+
if ( ! empty( $affiliate['domain'] ) ) {
|
7502 |
+
$affiliate_application_data['domain'] = $affiliate['domain'];
|
7503 |
+
}
|
7504 |
+
|
7505 |
+
if ( ! empty( $affiliate['additional_domains'] ) ) {
|
7506 |
+
$affiliate_application_data['additional_domains'] = $affiliate['additional_domains'];
|
7507 |
+
}
|
7508 |
+
|
7509 |
+
$this->_storage->affiliate_application_data = $affiliate_application_data;
|
7510 |
+
}
|
7511 |
+
|
7512 |
+
// Purge cached affiliate.
|
7513 |
+
$api->purge_cache( 'affiliate.json' );
|
7514 |
+
|
7515 |
+
self::shoot_ajax_success( $result );
|
7516 |
+
}
|
7517 |
+
|
7518 |
+
/**
|
7519 |
+
* @author Leo Fajardo
|
7520 |
+
* @since 1.2.3
|
7521 |
+
*
|
7522 |
+
* @return array|null
|
7523 |
+
*/
|
7524 |
+
function get_affiliate_application_data() {
|
7525 |
+
if ( empty( $this->_storage->affiliate_application_data ) ) {
|
7526 |
+
return null;
|
7527 |
+
}
|
7528 |
+
|
7529 |
+
return $this->_storage->affiliate_application_data;
|
7530 |
+
}
|
7531 |
+
|
7532 |
+
#endregion Affiliation ------------------------------------------------------------
|
7533 |
+
|
7534 |
+
#----------------------------------------------------------------------------------
|
7535 |
+
#region URL Generators
|
7536 |
+
#----------------------------------------------------------------------------------
|
7537 |
+
|
7538 |
+
/**
|
7539 |
+
* Alias to pricing_url().
|
7540 |
+
*
|
7541 |
+
* @author Vova Feldman (@svovaf)
|
7542 |
+
* @since 1.0.2
|
7543 |
+
*
|
7544 |
+
* @uses pricing_url()
|
7545 |
+
*
|
7546 |
+
* @param string $period Billing cycle
|
7547 |
+
* @param bool $is_trial
|
7548 |
+
*
|
7549 |
+
* @return string
|
7550 |
+
*/
|
7551 |
+
function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
|
7552 |
+
return $this->pricing_url( $period, $is_trial );
|
7553 |
+
}
|
7554 |
+
|
7555 |
+
/**
|
7556 |
+
* @author Vova Feldman (@svovaf)
|
7557 |
+
* @since 1.0.9
|
7558 |
+
*
|
7559 |
+
* @uses get_upgrade_url()
|
7560 |
+
*
|
7561 |
+
* @return string
|
7562 |
+
*/
|
7563 |
+
function get_trial_url() {
|
7564 |
+
return $this->get_upgrade_url( WP_FS__PERIOD_ANNUALLY, true );
|
7565 |
+
}
|
7566 |
+
|
7567 |
+
/**
|
7568 |
+
* Plugin's pricing URL.
|
7569 |
+
*
|
7570 |
+
* @author Vova Feldman (@svovaf)
|
7571 |
+
* @since 1.0.4
|
7572 |
+
*
|
7573 |
+
* @param string $billing_cycle Billing cycle
|
7574 |
+
*
|
7575 |
+
* @param bool $is_trial
|
7576 |
+
*
|
7577 |
+
* @return string
|
7578 |
+
*/
|
7579 |
+
function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
|
7580 |
+
$this->_logger->entrance();
|
7581 |
+
|
7582 |
+
$params = array(
|
7583 |
+
'billing_cycle' => $billing_cycle
|
7584 |
+
);
|
7585 |
+
|
7586 |
+
if ( $is_trial ) {
|
7587 |
+
$params['trial'] = 'true';
|
7588 |
+
}
|
7589 |
+
|
7590 |
+
return $this->_get_admin_page_url( 'pricing', $params );
|
7591 |
+
}
|
7592 |
+
|
7593 |
+
/**
|
7594 |
+
* Checkout page URL.
|
7595 |
+
*
|
7596 |
+
* @author Vova Feldman (@svovaf)
|
7597 |
+
* @since 1.0.6
|
7598 |
+
*
|
7599 |
+
* @param string $billing_cycle Billing cycle
|
7600 |
+
* @param bool $is_trial
|
7601 |
+
* @param array $extra (optional) Extra parameters, override other query params.
|
7602 |
+
*
|
7603 |
+
* @return string
|
7604 |
+
*/
|
7605 |
+
function checkout_url(
|
7606 |
+
$billing_cycle = WP_FS__PERIOD_ANNUALLY,
|
7607 |
+
$is_trial = false,
|
7608 |
+
$extra = array()
|
7609 |
+
) {
|
7610 |
+
$this->_logger->entrance();
|
7611 |
+
|
7612 |
+
$params = array(
|
7613 |
+
'checkout' => 'true',
|
7614 |
+
'billing_cycle' => $billing_cycle,
|
7615 |
+
);
|
7616 |
+
|
7617 |
+
if ( $is_trial ) {
|
7618 |
+
$params['trial'] = 'true';
|
7619 |
+
}
|
7620 |
+
|
7621 |
+
/**
|
7622 |
+
* Params in extra override other params.
|
7623 |
+
*/
|
7624 |
+
$params = array_merge( $params, $extra );
|
7625 |
+
|
7626 |
+
return $this->_get_admin_page_url( 'pricing', $params );
|
7627 |
+
}
|
7628 |
+
|
7629 |
+
/**
|
7630 |
+
* Add-on checkout URL.
|
7631 |
+
*
|
7632 |
+
* @author Vova Feldman (@svovaf)
|
7633 |
+
* @since 1.1.7
|
7634 |
+
*
|
7635 |
+
* @param number $addon_id
|
7636 |
+
* @param number $pricing_id
|
7637 |
+
* @param string $billing_cycle
|
7638 |
+
* @param bool $is_trial
|
7639 |
+
*
|
7640 |
+
* @return string
|
7641 |
+
*/
|
7642 |
+
function addon_checkout_url(
|
7643 |
+
$addon_id,
|
7644 |
+
$pricing_id,
|
7645 |
+
$billing_cycle = WP_FS__PERIOD_ANNUALLY,
|
7646 |
+
$is_trial = false
|
7647 |
+
) {
|
7648 |
+
return $this->checkout_url( $billing_cycle, $is_trial, array(
|
7649 |
+
'plugin_id' => $addon_id,
|
7650 |
+
'pricing_id' => $pricing_id,
|
7651 |
+
) );
|
7652 |
+
}
|
7653 |
+
|
7654 |
+
#endregion
|
7655 |
+
|
7656 |
+
#endregion ------------------------------------------------------------------
|
7657 |
+
|
7658 |
+
/**
|
7659 |
+
* Check if plugin has any add-ons.
|
7660 |
+
*
|
7661 |
+
* @author Vova Feldman (@svovaf)
|
7662 |
+
* @since 1.0.5
|
7663 |
+
*
|
7664 |
+
* @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
|
7665 |
+
*
|
7666 |
+
* @return bool
|
7667 |
+
*/
|
7668 |
+
function has_addons() {
|
7669 |
+
$this->_logger->entrance();
|
7670 |
+
|
7671 |
+
return $this->_has_addons;
|
7672 |
+
}
|
7673 |
+
|
7674 |
+
/**
|
7675 |
+
* Check if plugin can work in anonymous mode.
|
7676 |
+
*
|
7677 |
+
* @author Vova Feldman (@svovaf)
|
7678 |
+
* @since 1.0.9
|
7679 |
+
*
|
7680 |
+
* @return bool
|
7681 |
+
*
|
7682 |
+
* @deprecated Please use is_enable_anonymous() instead
|
7683 |
+
*/
|
7684 |
+
function enable_anonymous() {
|
7685 |
+
return $this->_enable_anonymous;
|
7686 |
+
}
|
7687 |
+
|
7688 |
+
/**
|
7689 |
+
* Check if plugin can work in anonymous mode.
|
7690 |
+
*
|
7691 |
+
* @author Vova Feldman (@svovaf)
|
7692 |
+
* @since 1.1.9
|
7693 |
+
*
|
7694 |
+
* @return bool
|
7695 |
+
*/
|
7696 |
+
function is_enable_anonymous() {
|
7697 |
+
return $this->_enable_anonymous;
|
7698 |
+
}
|
7699 |
+
|
7700 |
+
/**
|
7701 |
+
* Check if plugin is premium only (no free plans).
|
7702 |
+
*
|
7703 |
+
* @author Vova Feldman (@svovaf)
|
7704 |
+
* @since 1.1.9
|
7705 |
+
*
|
7706 |
+
* @return bool
|
7707 |
+
*/
|
7708 |
+
function is_only_premium() {
|
7709 |
+
return $this->_is_premium_only;
|
7710 |
+
}
|
7711 |
+
|
7712 |
+
/**
|
7713 |
+
* Checks if the plugin's type is "plugin". The other type is "theme".
|
7714 |
+
*
|
7715 |
+
* @author Leo Fajardo (@leorw)
|
7716 |
+
* @since 1.2.2
|
7717 |
+
*
|
7718 |
+
* @return bool
|
7719 |
+
*/
|
7720 |
+
function is_plugin() {
|
7721 |
+
return ( WP_FS__MODULE_TYPE_PLUGIN === $this->_module_type );
|
7722 |
+
}
|
7723 |
+
|
7724 |
+
/**
|
7725 |
+
* @author Leo Fajardo (@leorw)
|
7726 |
+
* @since 1.2.2
|
7727 |
+
*
|
7728 |
+
* @return string
|
7729 |
+
*/
|
7730 |
+
function get_module_type() {
|
7731 |
+
if ( ! isset( $this->_module_type ) ) {
|
7732 |
+
$id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
|
7733 |
+
$this->_module_type = $id_slug_type_path_map[ $this->_module_id ]['type'];
|
7734 |
+
}
|
7735 |
+
|
7736 |
+
return $this->_module_type;
|
7737 |
+
}
|
7738 |
+
|
7739 |
+
/**
|
7740 |
+
* @author Leo Fajardo (@leorw)
|
7741 |
+
* @since 1.2.2
|
7742 |
+
*
|
7743 |
+
* @return string
|
7744 |
+
*/
|
7745 |
+
function get_plugin_main_file_path() {
|
7746 |
+
return $this->_plugin_main_file_path;
|
7747 |
+
}
|
7748 |
+
|
7749 |
+
/**
|
7750 |
+
* Check if module has a premium code version.
|
7751 |
+
*
|
7752 |
+
* Serviceware module might be freemium without any
|
7753 |
+
* premium code version, where the paid features
|
7754 |
+
* are all part of the service.
|
7755 |
+
*
|
7756 |
+
* @author Vova Feldman (@svovaf)
|
7757 |
+
* @since 1.2.1.6
|
7758 |
+
*
|
7759 |
+
* @return bool
|
7760 |
+
*/
|
7761 |
+
function has_premium_version() {
|
7762 |
+
return $this->_has_premium_version;
|
7763 |
+
}
|
7764 |
+
|
7765 |
+
/**
|
7766 |
+
* Check if feature supported with current site's plan.
|
7767 |
+
*
|
7768 |
+
* @author Vova Feldman (@svovaf)
|
7769 |
+
* @since 1.0.1
|
7770 |
+
*
|
7771 |
+
* @todo IMPLEMENT
|
7772 |
+
*
|
7773 |
+
* @param number $feature_id
|
7774 |
+
*
|
7775 |
+
* @throws Exception
|
7776 |
+
*/
|
7777 |
+
function is_feature_supported( $feature_id ) {
|
7778 |
+
throw new Exception( 'not implemented' );
|
7779 |
+
}
|
7780 |
+
|
7781 |
+
/**
|
7782 |
+
* @author Vova Feldman (@svovaf)
|
7783 |
+
* @since 1.0.1
|
7784 |
+
*
|
7785 |
+
* @return bool Is running in SSL/HTTPS
|
7786 |
+
*/
|
7787 |
+
function is_ssl() {
|
7788 |
+
return WP_FS__IS_HTTPS;
|
7789 |
+
}
|
7790 |
+
|
7791 |
+
/**
|
7792 |
+
* @author Vova Feldman (@svovaf)
|
7793 |
+
* @since 1.0.9
|
7794 |
+
*
|
7795 |
+
* @return bool Is running in AJAX call.
|
7796 |
+
*
|
7797 |
+
* @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
|
7798 |
+
*/
|
7799 |
+
static function is_ajax() {
|
7800 |
+
return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
|
7801 |
+
}
|
7802 |
+
|
7803 |
+
/**
|
7804 |
+
* Check if it's an AJAX call targeted for the current module.
|
7805 |
+
*
|
7806 |
+
* @author Vova Feldman (@svovaf)
|
7807 |
+
* @since 1.2.0
|
7808 |
+
*
|
7809 |
+
* @param array|string $actions Collection of AJAX actions.
|
7810 |
+
*
|
7811 |
+
* @return bool
|
7812 |
+
*/
|
7813 |
+
function is_ajax_action( $actions ) {
|
7814 |
+
// Verify it's an ajax call.
|
7815 |
+
if ( ! self::is_ajax() ) {
|
7816 |
+
return false;
|
7817 |
+
}
|
7818 |
+
|
7819 |
+
// Verify the call is relevant for the plugin.
|
7820 |
+
if ( $this->_module_id != fs_request_get( 'module_id' ) ) {
|
7821 |
+
return false;
|
7822 |
+
}
|
7823 |
+
|
7824 |
+
// Verify it's one of the specified actions.
|
7825 |
+
if ( is_string( $actions ) ) {
|
7826 |
+
$actions = explode( ',', $actions );
|
7827 |
+
}
|
7828 |
+
|
7829 |
+
if ( is_array( $actions ) && 0 < count( $actions ) ) {
|
7830 |
+
$ajax_action = fs_request_get( 'action' );
|
7831 |
+
|
7832 |
+
foreach ( $actions as $action ) {
|
7833 |
+
if ( $ajax_action === $this->get_action_tag( $action ) ) {
|
7834 |
+
return true;
|
7835 |
+
}
|
7836 |
+
}
|
7837 |
+
}
|
7838 |
+
|
7839 |
+
return false;
|
7840 |
+
}
|
7841 |
+
|
7842 |
+
/**
|
7843 |
+
* Check if it's an AJAX call targeted for current request.
|
7844 |
+
*
|
7845 |
+
* @author Vova Feldman (@svovaf)
|
7846 |
+
* @since 1.2.0
|
7847 |
+
*
|
7848 |
+
* @param array|string $actions Collection of AJAX actions.
|
7849 |
+
* @param number|null $module_id
|
7850 |
+
*
|
7851 |
+
* @return bool
|
7852 |
+
*/
|
7853 |
+
static function is_ajax_action_static( $actions, $module_id = null ) {
|
7854 |
+
// Verify it's an ajax call.
|
7855 |
+
if ( ! self::is_ajax() ) {
|
7856 |
+
return false;
|
7857 |
+
}
|
7858 |
+
|
7859 |
+
|
7860 |
+
if ( ! empty( $module_id ) ) {
|
7861 |
+
// Verify the call is relevant for the plugin.
|
7862 |
+
if ( $module_id != fs_request_get( 'module_id' ) ) {
|
7863 |
+
return false;
|
7864 |
+
}
|
7865 |
+
}
|
7866 |
+
|
7867 |
+
// Verify it's one of the specified actions.
|
7868 |
+
if ( is_string( $actions ) ) {
|
7869 |
+
$actions = explode( ',', $actions );
|
7870 |
+
}
|
7871 |
+
|
7872 |
+
if ( is_array( $actions ) && 0 < count( $actions ) ) {
|
7873 |
+
$ajax_action = fs_request_get( 'action' );
|
7874 |
+
|
7875 |
+
foreach ( $actions as $action ) {
|
7876 |
+
if ( $ajax_action === self::get_ajax_action_static( $action, $module_id ) ) {
|
7877 |
+
return true;
|
7878 |
+
}
|
7879 |
+
}
|
7880 |
+
}
|
7881 |
+
|
7882 |
+
return false;
|
7883 |
+
}
|
7884 |
+
|
7885 |
+
/**
|
7886 |
+
* @author Vova Feldman (@svovaf)
|
7887 |
+
* @since 1.1.7
|
7888 |
+
*
|
7889 |
+
* @return bool
|
7890 |
+
*/
|
7891 |
+
static function is_cron() {
|
7892 |
+
return ( defined( 'DOING_CRON' ) && DOING_CRON );
|
7893 |
+
}
|
7894 |
+
|
7895 |
+
/**
|
7896 |
+
* Check if a real user is visiting the admin dashboard.
|
7897 |
+
*
|
7898 |
+
* @author Vova Feldman (@svovaf)
|
7899 |
+
* @since 1.1.7
|
7900 |
+
*
|
7901 |
+
* @return bool
|
7902 |
+
*/
|
7903 |
+
function is_user_in_admin() {
|
7904 |
+
return is_admin() && ! self::is_ajax() && ! self::is_cron();
|
7905 |
+
}
|
7906 |
+
|
7907 |
+
/**
|
7908 |
+
* Check if a real user is in the customizer view.
|
7909 |
+
*
|
7910 |
+
* @author Vova Feldman (@svovaf)
|
7911 |
+
* @since 1.2.2.7
|
7912 |
+
*
|
7913 |
+
* @return bool
|
7914 |
+
*/
|
7915 |
+
static function is_customizer() {
|
7916 |
+
return is_customize_preview();
|
7917 |
+
}
|
7918 |
+
|
7919 |
+
/**
|
7920 |
+
* Check if running in HTTPS and if site's plan matching the specified plan.
|
7921 |
+
*
|
7922 |
+
* @param string $plan
|
7923 |
+
* @param bool $exact
|
7924 |
+
*
|
7925 |
+
* @return bool
|
7926 |
+
*/
|
7927 |
+
function is_ssl_and_plan( $plan, $exact = false ) {
|
7928 |
+
return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
|
7929 |
+
}
|
7930 |
+
|
7931 |
+
/**
|
7932 |
+
* Construct plugin's settings page URL.
|
7933 |
+
*
|
7934 |
+
* @author Vova Feldman (@svovaf)
|
7935 |
+
* @since 1.0.4
|
7936 |
+
*
|
7937 |
+
* @param string $page
|
7938 |
+
* @param array $params
|
7939 |
+
*
|
7940 |
+
* @return string
|
7941 |
+
*/
|
7942 |
+
function _get_admin_page_url( $page = '', $params = array() ) {
|
7943 |
+
if ( 0 < count( $params ) ) {
|
7944 |
+
foreach ( $params as $k => $v ) {
|
7945 |
+
$params[ $k ] = urlencode( $v );
|
7946 |
+
}
|
7947 |
+
}
|
7948 |
+
|
7949 |
+
$page_param = $this->_menu->get_slug( $page );
|
7950 |
+
|
7951 |
+
if ( empty( $page ) &&
|
7952 |
+
$this->is_theme() &&
|
7953 |
+
// Show the opt-in as an overlay for free wp.org themes or themes without any settings page.
|
7954 |
+
( $this->is_free_wp_org_theme() || ! $this->has_settings_menu() ) ) {
|
7955 |
+
$params[ $this->get_unique_affix() . '_show_optin' ] = 'true';
|
7956 |
+
|
7957 |
+
return add_query_arg(
|
7958 |
+
$params,
|
7959 |
+
admin_url( 'themes.php' )
|
7960 |
+
);
|
7961 |
+
}
|
7962 |
+
|
7963 |
+
if ( ! $this->has_settings_menu() ) {
|
7964 |
+
if ( ! empty( $page ) ) {
|
7965 |
+
// Module doesn't have a setting page, but since the request is for
|
7966 |
+
// a specific Freemius page, use the admin.php path.
|
7967 |
+
return add_query_arg( array_merge( $params, array(
|
7968 |
+
'page' => $page_param,
|
7969 |
+
) ), admin_url( 'admin.php' ) );
|
7970 |
+
} else {
|
7971 |
+
if ( $this->is_activation_mode() ) {
|
7972 |
+
/**
|
7973 |
+
* @author Vova Feldman
|
7974 |
+
* @since 1.2.1.6
|
7975 |
+
*
|
7976 |
+
* If plugin doesn't have a settings page, create one for the opt-in screen.
|
7977 |
+
*/
|
7978 |
+
return add_query_arg( array_merge( $params, array(
|
7979 |
+
'page' => $this->_slug,
|
7980 |
+
) ), admin_url( 'admin.php', 'admin' ) );
|
7981 |
+
} else {
|
7982 |
+
// Plugin without a settings page.
|
7983 |
+
return add_query_arg(
|
7984 |
+
$params,
|
7985 |
+
admin_url( 'plugins.php' )
|
7986 |
+
);
|
7987 |
+
}
|
7988 |
+
}
|
7989 |
+
}
|
7990 |
+
|
7991 |
+
// Module has a submenu settings page.
|
7992 |
+
if ( ! $this->_menu->is_top_level() ) {
|
7993 |
+
$parent_slug = $this->_menu->get_parent_slug();
|
7994 |
+
$menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
|
7995 |
+
$parent_slug :
|
7996 |
+
'admin.php';
|
7997 |
+
|
7998 |
+
return add_query_arg( array_merge( $params, array(
|
7999 |
+
'page' => $page_param,
|
8000 |
+
) ), admin_url( $menu_file, 'admin' ) );
|
8001 |
+
}
|
8002 |
+
|
8003 |
+
// Module has a top level CPT settings page.
|
8004 |
+
if ( $this->_menu->is_cpt() ) {
|
8005 |
+
if ( empty( $page ) && $this->is_activation_mode() ) {
|
8006 |
+
return add_query_arg( array_merge( $params, array(
|
8007 |
+
'page' => $page_param
|
8008 |
+
) ), admin_url( 'admin.php', 'admin' ) );
|
8009 |
+
} else {
|
8010 |
+
if ( ! empty( $page ) ) {
|
8011 |
+
$params['page'] = $page_param;
|
8012 |
+
}
|
8013 |
+
|
8014 |
+
return add_query_arg(
|
8015 |
+
$params,
|
8016 |
+
admin_url( $this->_menu->get_raw_slug(), 'admin' )
|
8017 |
+
);
|
8018 |
+
}
|
8019 |
+
}
|
8020 |
+
|
8021 |
+
// Module has a custom top level settings page.
|
8022 |
+
return add_query_arg( array_merge( $params, array(
|
8023 |
+
'page' => $page_param,
|
8024 |
+
) ), admin_url( 'admin.php', 'admin' ) );
|
8025 |
+
}
|
8026 |
+
|
8027 |
+
/**
|
8028 |
+
* Check if currently in a specified admin page.
|
8029 |
+
*
|
8030 |
+
* @author Vova Feldman (@svovaf)
|
8031 |
+
* @since 1.2.2.7
|
8032 |
+
*
|
8033 |
+
* @param string $page
|
8034 |
+
*
|
8035 |
+
* @return bool
|
8036 |
+
*/
|
8037 |
+
function is_admin_page( $page ) {
|
8038 |
+
return ( $this->_menu->get_slug( $page ) === fs_request_get( 'page', '', 'get' ) );
|
8039 |
+
}
|
8040 |
+
|
8041 |
+
/**
|
8042 |
+
* Get module's main admin setting page URL.
|
8043 |
+
*
|
8044 |
+
* @author Vova Feldman (@svovaf)
|
8045 |
+
* @since 1.2.2.7
|
8046 |
+
*
|
8047 |
+
* @return string
|
8048 |
+
*/
|
8049 |
+
function main_menu_url() {
|
8050 |
+
return $this->_menu->main_menu_url();
|
8051 |
+
}
|
8052 |
+
|
8053 |
+
/**
|
8054 |
+
* Check if currently on the theme's setting page or
|
8055 |
+
* on any of the Freemius added pages (via tabs).
|
8056 |
+
*
|
8057 |
+
* @author Vova Feldman (@svovaf)
|
8058 |
+
* @since 1.2.2.7
|
8059 |
+
*
|
8060 |
+
* @return bool
|
8061 |
+
*/
|
8062 |
+
function is_theme_settings_page() {
|
8063 |
+
return fs_starts_with(
|
8064 |
+
fs_request_get( 'page', '', 'get' ),
|
8065 |
+
$this->_menu->get_slug()
|
8066 |
+
);
|
8067 |
+
}
|
8068 |
+
|
8069 |
+
/**
|
8070 |
+
* Plugin's account page + sync license URL.
|
8071 |
+
*
|
8072 |
+
* @author Vova Feldman (@svovaf)
|
8073 |
+
* @since 1.1.9.1
|
8074 |
+
*
|
8075 |
+
* @param bool|number $plugin_id
|
8076 |
+
* @param bool $add_action_nonce
|
8077 |
+
* @param array $params
|
8078 |
+
*
|
8079 |
+
* @return string
|
8080 |
+
*/
|
8081 |
+
function _get_sync_license_url( $plugin_id = false, $add_action_nonce = true, $params = array() ) {
|
8082 |
+
if ( is_numeric( $plugin_id ) ) {
|
8083 |
+
$params['plugin_id'] = $plugin_id;
|
8084 |
+
}
|
8085 |
+
|
8086 |
+
return $this->get_account_url(
|
8087 |
+
$this->get_unique_affix() . '_sync_license',
|
8088 |
+
$params,
|
8089 |
+
$add_action_nonce
|
8090 |
+
);
|
8091 |
+
}
|
8092 |
+
|
8093 |
+
/**
|
8094 |
+
* Plugin's account URL.
|
8095 |
+
*
|
8096 |
+
* @author Vova Feldman (@svovaf)
|
8097 |
+
* @since 1.0.4
|
8098 |
+
*
|
8099 |
+
* @param bool|string $action
|
8100 |
+
* @param array $params
|
8101 |
+
*
|
8102 |
+
* @param bool $add_action_nonce
|
8103 |
+
*
|
8104 |
+
* @return string
|
8105 |
+
*/
|
8106 |
+
function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
|
8107 |
+
if ( is_string( $action ) ) {
|
8108 |
+
$params['fs_action'] = $action;
|
8109 |
+
}
|
8110 |
+
|
8111 |
+
self::require_pluggable_essentials();
|
8112 |
+
|
8113 |
+
return ( $add_action_nonce && is_string( $action ) ) ?
|
8114 |
+
fs_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
|
8115 |
+
$this->_get_admin_page_url( 'account', $params );
|
8116 |
+
}
|
8117 |
+
|
8118 |
+
/**
|
8119 |
+
* @author Vova Feldman (@svovaf)
|
8120 |
+
* @since 1.2.0
|
8121 |
+
*
|
8122 |
+
* @param string $tab
|
8123 |
+
* @param bool $action
|
8124 |
+
* @param array $params
|
8125 |
+
* @param bool $add_action_nonce
|
8126 |
+
*
|
8127 |
+
* @return string
|
8128 |
+
*
|
8129 |
+
* @uses get_account_url()
|
8130 |
+
*/
|
8131 |
+
function get_account_tab_url( $tab, $action = false, $params = array(), $add_action_nonce = true ) {
|
8132 |
+
$params['tab'] = $tab;
|
8133 |
+
|
8134 |
+
return $this->get_account_url( $action, $params, $add_action_nonce );
|
8135 |
+
}
|
8136 |
+
|
8137 |
+
/**
|
8138 |
+
* Plugin's account URL.
|
8139 |
+
*
|
8140 |
+
* @author Vova Feldman (@svovaf)
|
8141 |
+
* @since 1.0.4
|
8142 |
+
*
|
8143 |
+
* @param bool|string $topic
|
8144 |
+
* @param bool|string $message
|
8145 |
+
*
|
8146 |
+
* @return string
|
8147 |
+
*/
|
8148 |
+
function contact_url( $topic = false, $message = false ) {
|
8149 |
+
$params = array();
|
8150 |
+
if ( is_string( $topic ) ) {
|
8151 |
+
$params['topic'] = $topic;
|
8152 |
+
}
|
8153 |
+
if ( is_string( $message ) ) {
|
8154 |
+
$params['message'] = $message;
|
8155 |
+
}
|
8156 |
+
|
8157 |
+
if ( $this->is_addon() ) {
|
8158 |
+
$params['addon_id'] = $this->get_id();
|
8159 |
+
|
8160 |
+
return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
|
8161 |
+
} else {
|
8162 |
+
return $this->_get_admin_page_url( 'contact', $params );
|
8163 |
+
}
|
8164 |
+
}
|
8165 |
+
|
8166 |
+
/**
|
8167 |
+
* Add-on direct info URL.
|
8168 |
+
*
|
8169 |
+
* @author Vova Feldman (@svovaf)
|
8170 |
+
* @since 1.1.0
|
8171 |
+
*
|
8172 |
+
* @param string $slug
|
8173 |
+
*
|
8174 |
+
* @return string
|
8175 |
+
*/
|
8176 |
+
function addon_url( $slug ) {
|
8177 |
+
return $this->_get_admin_page_url( 'addons', array(
|
8178 |
+
'slug' => $slug
|
8179 |
+
) );
|
8180 |
+
}
|
8181 |
+
|
8182 |
+
/* Logger
|
8183 |
+
------------------------------------------------------------------------------------------------------------------*/
|
8184 |
+
/**
|
8185 |
+
* @param string $id
|
8186 |
+
* @param bool $prefix_slug
|
8187 |
+
*
|
8188 |
+
* @return FS_Logger
|
8189 |
+
*/
|
8190 |
+
function get_logger( $id = '', $prefix_slug = true ) {
|
8191 |
+
return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
|
8192 |
+
}
|
8193 |
+
|
8194 |
+
/**
|
8195 |
+
* @param $id
|
8196 |
+
* @param bool $load_options
|
8197 |
+
* @param bool $prefix_slug
|
8198 |
+
*
|
8199 |
+
* @return FS_Option_Manager
|
8200 |
+
*/
|
8201 |
+
function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
|
8202 |
+
return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
|
8203 |
+
}
|
8204 |
+
|
8205 |
+
/* Security
|
8206 |
+
------------------------------------------------------------------------------------------------------------------*/
|
8207 |
+
private static function _encrypt( $str ) {
|
8208 |
+
if ( is_null( $str ) ) {
|
8209 |
+
return null;
|
8210 |
+
}
|
8211 |
+
|
8212 |
+
/**
|
8213 |
+
* The encrypt/decrypt functions are used to protect
|
8214 |
+
* the user from messing up with some of the sensitive
|
8215 |
+
* data stored for the module as a JSON in the database.
|
8216 |
+
*
|
8217 |
+
* I used the same suggested hack by the theme review team.
|
8218 |
+
* For more details, look at the function `Base64UrlDecode()`
|
8219 |
+
* in `./sdk/FreemiusBase.php`.
|
8220 |
+
*
|
8221 |
+
* @todo Remove this hack once the base64 error is removed from the Theme Check.
|
8222 |
+
*
|
8223 |
+
* @author Vova Feldman (@svovaf)
|
8224 |
+
* @since 1.2.2
|
8225 |
+
*/
|
8226 |
+
$fn = 'base64' . '_encode';
|
8227 |
+
|
8228 |
+
return $fn( $str );
|
8229 |
+
}
|
8230 |
+
|
8231 |
+
static function _decrypt( $str ) {
|
8232 |
+
if ( is_null( $str ) ) {
|
8233 |
+
return null;
|
8234 |
+
}
|
8235 |
+
|
8236 |
+
/**
|
8237 |
+
* The encrypt/decrypt functions are used to protect
|
8238 |
+
* the user from messing up with some of the sensitive
|
8239 |
+
* data stored for the module as a JSON in the database.
|
8240 |
+
*
|
8241 |
+
* I used the same suggested hack by the theme review team.
|
8242 |
+
* For more details, look at the function `Base64UrlDecode()`
|
8243 |
+
* in `./sdk/FreemiusBase.php`.
|
8244 |
+
*
|
8245 |
+
* @todo Remove this hack once the base64 error is removed from the Theme Check.
|
8246 |
+
*
|
8247 |
+
* @author Vova Feldman (@svovaf)
|
8248 |
+
* @since 1.2.2
|
8249 |
+
*/
|
8250 |
+
$fn = 'base64' . '_decode';
|
8251 |
+
|
8252 |
+
return $fn( $str );
|
8253 |
+
}
|
8254 |
+
|
8255 |
+
/**
|
8256 |
+
* @author Vova Feldman (@svovaf)
|
8257 |
+
* @since 1.0.5
|
8258 |
+
*
|
8259 |
+
* @param FS_Entity $entity
|
8260 |
+
*
|
8261 |
+
* @return FS_Entity Return an encrypted clone entity.
|
8262 |
+
*/
|
8263 |
+
private static function _encrypt_entity( FS_Entity $entity ) {
|
8264 |
+
$clone = clone $entity;
|
8265 |
+
$props = get_object_vars( $entity );
|
8266 |
+
|
8267 |
+
foreach ( $props as $key => $val ) {
|
8268 |
+
$clone->{$key} = self::_encrypt( $val );
|
8269 |
+
}
|
8270 |
+
|
8271 |
+
return $clone;
|
8272 |
+
}
|
8273 |
+
|
8274 |
+
/**
|
8275 |
+
* @author Vova Feldman (@svovaf)
|
8276 |
+
* @since 1.0.5
|
8277 |
+
*
|
8278 |
+
* @param FS_Entity $entity
|
8279 |
+
*
|
8280 |
+
* @return FS_Entity Return an decrypted clone entity.
|
8281 |
+
*/
|
8282 |
+
private static function decrypt_entity( FS_Entity $entity ) {
|
8283 |
+
$clone = clone $entity;
|
8284 |
+
$props = get_object_vars( $entity );
|
8285 |
+
|
8286 |
+
foreach ( $props as $key => $val ) {
|
8287 |
+
$clone->{$key} = self::_decrypt( $val );
|
8288 |
+
}
|
8289 |
+
|
8290 |
+
return $clone;
|
8291 |
+
}
|
8292 |
+
|
8293 |
+
/**
|
8294 |
+
* Tries to activate account based on POST params.
|
8295 |
+
*
|
8296 |
+
* @author Vova Feldman (@svovaf)
|
8297 |
+
* @since 1.0.2
|
8298 |
+
*/
|
8299 |
+
function _activate_account() {
|
8300 |
+
if ( $this->is_registered() ) {
|
8301 |
+
// Already activated.
|
8302 |
+
return;
|
8303 |
+
}
|
8304 |
+
|
8305 |
+
self::_clean_admin_content_section();
|
8306 |
+
|
8307 |
+
if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
|
8308 |
+
// check_admin_referer( 'activate_' . $this->_plugin->public_key );
|
8309 |
+
|
8310 |
+
// Verify matching plugin details.
|
8311 |
+
if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
|
8312 |
+
return;
|
8313 |
+
}
|
8314 |
+
|
8315 |
+
$user = new FS_User();
|
8316 |
+
$user->id = fs_request_get( 'user_id' );
|
8317 |
+
$user->public_key = fs_request_get( 'user_public_key' );
|
8318 |
+
$user->secret_key = fs_request_get( 'user_secret_key' );
|
8319 |
+
$user->email = fs_request_get( 'user_email' );
|
8320 |
+
$user->first = fs_request_get( 'user_first' );
|
8321 |
+
$user->last = fs_request_get( 'user_last' );
|
8322 |
+
$user->is_verified = fs_request_get_bool( 'user_is_verified' );
|
8323 |
+
|
8324 |
+
$site = new FS_Site();
|
8325 |
+
$site->id = fs_request_get( 'install_id' );
|
8326 |
+
$site->public_key = fs_request_get( 'install_public_key' );
|
8327 |
+
$site->secret_key = fs_request_get( 'install_secret_key' );
|
8328 |
+
$site->plan->id = fs_request_get( 'plan_id' );
|
8329 |
+
$site->plan->title = fs_request_get( 'plan_title' );
|
8330 |
+
$site->plan->name = fs_request_get( 'plan_name' );
|
8331 |
+
|
8332 |
+
$plans = array();
|
8333 |
+
$plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
|
8334 |
+
foreach ( $plans_data as $p ) {
|
8335 |
+
$plans[] = new FS_Plugin_Plan( $p );
|
8336 |
+
}
|
8337 |
+
|
8338 |
+
$this->_set_account( $user, $site, $plans );
|
8339 |
+
|
8340 |
+
// Reload the page with the keys.
|
8341 |
+
fs_redirect( $this->_get_admin_page_url() );
|
8342 |
+
}
|
8343 |
+
}
|
8344 |
+
|
8345 |
+
/**
|
8346 |
+
* @author Vova Feldman (@svovaf)
|
8347 |
+
* @since 1.0.7
|
8348 |
+
*
|
8349 |
+
* @param string $email
|
8350 |
+
*
|
8351 |
+
* @return FS_User|bool
|
8352 |
+
*/
|
8353 |
+
static function _get_user_by_email( $email ) {
|
8354 |
+
self::$_static_logger->entrance();
|
8355 |
+
|
8356 |
+
$email = trim( strtolower( $email ) );
|
8357 |
+
$users = self::get_all_users();
|
8358 |
+
if ( is_array( $users ) ) {
|
8359 |
+
foreach ( $users as $u ) {
|
8360 |
+
if ( $email === trim( strtolower( $u->email ) ) ) {
|
8361 |
+
return $u;
|
8362 |
+
}
|
8363 |
+
}
|
8364 |
+
}
|
8365 |
+
|
8366 |
+
return false;
|
8367 |
+
}
|
8368 |
+
|
8369 |
+
#----------------------------------------------------------------------------------
|
8370 |
+
#region Account (Loading, Updates & Activation)
|
8371 |
+
#----------------------------------------------------------------------------------
|
8372 |
+
|
8373 |
+
/***
|
8374 |
+
* Load account information (user + site).
|
8375 |
+
*
|
8376 |
+
* @author Vova Feldman (@svovaf)
|
8377 |
+
* @since 1.0.1
|
8378 |
+
*/
|
8379 |
+
private function _load_account() {
|
8380 |
+
$this->_logger->entrance();
|
8381 |
+
|
8382 |
+
$this->do_action( 'before_account_load' );
|
8383 |
+
|
8384 |
+
$sites = self::get_all_sites( $this->_module_type );
|
8385 |
+
$users = self::get_all_users();
|
8386 |
+
$plans = self::get_all_plans( $this->_module_type );
|
8387 |
+
$licenses = self::get_all_licenses( $this->_module_type );
|
8388 |
+
|
8389 |
+
if ( $this->_logger->is_on() && is_admin() ) {
|
8390 |
+
$this->_logger->log( 'sites = ' . var_export( $sites, true ) );
|
8391 |
+
$this->_logger->log( 'users = ' . var_export( $users, true ) );
|
8392 |
+
$this->_logger->log( 'plans = ' . var_export( $plans, true ) );
|
8393 |
+
$this->_logger->log( 'licenses = ' . var_export( $licenses, true ) );
|
8394 |
+
}
|
8395 |
+
|
8396 |
+
$site = isset( $sites[ $this->_slug ] ) ? $sites[ $this->_slug ] : false;
|
8397 |
+
|
8398 |
+
if ( is_object( $site ) &&
|
8399 |
+
is_numeric( $site->id ) &&
|
8400 |
+
is_numeric( $site->user_id ) &&
|
8401 |
+
is_object( $site->plan )
|
8402 |
+
) {
|
8403 |
+
// Load site.
|
8404 |
+
$this->_site = clone $site;
|
8405 |
+
$this->_site->plan = self::decrypt_entity( $this->_site->plan );
|
8406 |
+
|
8407 |
+
/**
|
8408 |
+
* If the install owner's details are not stored locally, use the previous user's details if available.
|
8409 |
+
*
|
8410 |
+
* @author Leo Fajardo (@leorw)
|
8411 |
+
*/
|
8412 |
+
if ( ! isset( $users[ $this->_site->user_id ] ) && FS_User::is_valid_id( $this->_storage->prev_user_id ) ) {
|
8413 |
+
$user_id = $this->_storage->prev_user_id;
|
8414 |
+
} else {
|
8415 |
+
$user_id = $this->_site->user_id;
|
8416 |
+
}
|
8417 |
+
|
8418 |
+
// Load relevant user.
|
8419 |
+
$this->_user = clone $users[ $user_id ];
|
8420 |
+
|
8421 |
+
// Load plans.
|
8422 |
+
$this->_plans = $plans[ $this->_slug ];
|
8423 |
+
if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
|
8424 |
+
$this->_sync_plans();
|
8425 |
+
} else {
|
8426 |
+
for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
|
8427 |
+
if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
|
8428 |
+
$this->_plans[ $i ] = self::decrypt_entity( $this->_plans[ $i ] );
|
8429 |
+
} else {
|
8430 |
+
unset( $this->_plans[ $i ] );
|
8431 |
+
}
|
8432 |
+
}
|
8433 |
+
}
|
8434 |
+
|
8435 |
+
// Load licenses.
|
8436 |
+
$this->_licenses = array();
|
8437 |
+
if ( is_array( $licenses ) &&
|
8438 |
+
isset( $licenses[ $this->_slug ] ) &&
|
8439 |
+
isset( $licenses[ $this->_slug ][ $this->_user->id ] )
|
8440 |
+
) {
|
8441 |
+
$this->_licenses = $licenses[ $this->_slug ][ $this->_user->id ];
|
8442 |
+
}
|
8443 |
+
|
8444 |
+
$this->_license = $this->_get_license_by_id( $this->_site->license_id );
|
8445 |
+
|
8446 |
+
if ( $this->_site->version != $this->get_plugin_version() ) {
|
8447 |
+
// If stored install version is different than current installed plugin version,
|
8448 |
+
// then update plugin version event.
|
8449 |
+
$this->update_plugin_version_event();
|
8450 |
+
}
|
8451 |
+
}
|
8452 |
+
|
8453 |
+
$this->_register_account_hooks();
|
8454 |
+
}
|
8455 |
+
|
8456 |
+
/**
|
8457 |
+
* @author Vova Feldman (@svovaf)
|
8458 |
+
* @since 1.0.1
|
8459 |
+
*
|
8460 |
+
* @param FS_User $user
|
8461 |
+
* @param FS_Site $site
|
8462 |
+
* @param bool|array $plans
|
8463 |
+
*/
|
8464 |
+
private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
|
8465 |
+
$site->slug = $this->_slug;
|
8466 |
+
$site->user_id = $user->id;
|
8467 |
+
|
8468 |
+
$this->_site = $site;
|
8469 |
+
$this->_user = $user;
|
8470 |
+
if ( false !== $plans ) {
|
8471 |
+
$this->_plans = $plans;
|
8472 |
+
}
|
8473 |
+
|
8474 |
+
$this->send_install_update();
|
8475 |
+
|
8476 |
+
$this->_store_account();
|
8477 |
+
|
8478 |
+
}
|
8479 |
+
|
8480 |
+
/**
|
8481 |
+
* @author Vova Feldman (@svovaf)
|
8482 |
+
* @since 1.1.7.4
|
8483 |
+
*
|
8484 |
+
* @param array $override_with
|
8485 |
+
*
|
8486 |
+
* @return array
|
8487 |
+
*/
|
8488 |
+
function get_opt_in_params( $override_with = array() ) {
|
8489 |
+
$this->_logger->entrance();
|
8490 |
+
|
8491 |
+
$current_user = self::_get_current_wp_user();
|
8492 |
+
|
8493 |
+
$activation_action = $this->get_unique_affix() . '_activate_new';
|
8494 |
+
$return_url = $this->is_anonymous() ?
|
8495 |
+
// If skipped already, then return to the account page.
|
8496 |
+
$this->get_account_url( $activation_action, array(), false ) :
|
8497 |
+
// Return to the module's main page.
|
8498 |
+
$this->get_after_activation_url( 'after_connect_url', array( 'fs_action' => $activation_action ) );
|
8499 |
+
|
8500 |
+
$params = array(
|
8501 |
+
'user_firstname' => $current_user->user_firstname,
|
8502 |
+
'user_lastname' => $current_user->user_lastname,
|
8503 |
+
'user_nickname' => $current_user->user_nicename,
|
8504 |
+
'user_email' => $current_user->user_email,
|
8505 |
+
'user_ip' => WP_FS__REMOTE_ADDR,
|
8506 |
+
'plugin_slug' => $this->_slug,
|
8507 |
+
'plugin_id' => $this->get_id(),
|
8508 |
+
'plugin_public_key' => $this->get_public_key(),
|
8509 |
+
'plugin_version' => $this->get_plugin_version(),
|
8510 |
+
'return_url' => fs_nonce_url( $return_url, $activation_action ),
|
8511 |
+
'account_url' => fs_nonce_url( $this->_get_admin_page_url(
|
8512 |
+
'account',
|
8513 |
+
array( 'fs_action' => 'sync_user' )
|
8514 |
+
), 'sync_user' ),
|
8515 |
+
'site_uid' => $this->get_anonymous_id(),
|
8516 |
+
'site_url' => get_site_url(),
|
8517 |
+
'site_name' => get_bloginfo( 'name' ),
|
8518 |
+
'platform_version' => get_bloginfo( 'version' ),
|
8519 |
+
'sdk_version' => $this->version,
|
8520 |
+
'programming_language_version' => phpversion(),
|
8521 |
+
'language' => get_bloginfo( 'language' ),
|
8522 |
+
'charset' => get_bloginfo( 'charset' ),
|
8523 |
+
'is_premium' => $this->is_premium(),
|
8524 |
+
'is_active' => true,
|
8525 |
+
'is_uninstalled' => false,
|
8526 |
+
);
|
8527 |
+
|
8528 |
+
if ( $this->is_pending_activation() &&
|
8529 |
+
! empty( $this->_storage->pending_license_key )
|
8530 |
+
) {
|
8531 |
+
$params['license_key'] = $this->_storage->pending_license_key;
|
8532 |
+
}
|
8533 |
+
|
8534 |
+
if ( WP_FS__SKIP_EMAIL_ACTIVATION && $this->has_secret_key() ) {
|
8535 |
+
// Even though rand() is known for its security issues,
|
8536 |
+
// the timestamp adds another layer of protection.
|
8537 |
+
// It would be very hard for an attacker to get the secret key form here.
|
8538 |
+
// Plus, this should never run in production since the secret should never
|
8539 |
+
// be included in the production version.
|
8540 |
+
$params['ts'] = WP_FS__SCRIPT_START_TIME;
|
8541 |
+
$params['salt'] = md5( uniqid( rand() ) );
|
8542 |
+
$params['secure'] = md5(
|
8543 |
+
$params['ts'] .
|
8544 |
+
$params['salt'] .
|
8545 |
+
$this->get_secret_key()
|
8546 |
+
);
|
8547 |
+
}
|
8548 |
+
|
8549 |
+
return array_merge( $params, $override_with );
|
8550 |
+
}
|
8551 |
+
|
8552 |
+
/**
|
8553 |
+
* 1. If successful opt-in or pending activation returns the next page that the user should be redirected to.
|
8554 |
+
* 2. If there was an API error, return the API result.
|
8555 |
+
*
|
8556 |
+
* @author Vova Feldman (@svovaf)
|
8557 |
+
* @since 1.1.7.4
|
8558 |
+
*
|
8559 |
+
* @param string|bool $email
|
8560 |
+
* @param string|bool $first
|
8561 |
+
* @param string|bool $last
|
8562 |
+
* @param string|bool $license_key
|
8563 |
+
* @param bool $is_uninstall If "true", this means that the module is currently being uninstalled.
|
8564 |
+
* In this case, the user and site info will be sent to the server but no
|
8565 |
+
* data will be saved to the WP installation's database.
|
8566 |
+
* @param number|bool $trial_plan_id
|
8567 |
+
* @param bool $is_disconnected Whether or not to opt in without tracking.
|
8568 |
+
*
|
8569 |
+
* @return string|object
|
8570 |
+
* @use WP_Error
|
8571 |
+
*/
|
8572 |
+
function opt_in(
|
8573 |
+
$email = false,
|
8574 |
+
$first = false,
|
8575 |
+
$last = false,
|
8576 |
+
$license_key = false,
|
8577 |
+
$is_uninstall = false,
|
8578 |
+
$trial_plan_id = false,
|
8579 |
+
$is_disconnected = false
|
8580 |
+
) {
|
8581 |
+
$this->_logger->entrance();
|
8582 |
+
|
8583 |
+
if ( false === $email ) {
|
8584 |
+
$current_user = self::_get_current_wp_user();
|
8585 |
+
$email = $current_user->user_email;
|
8586 |
+
}
|
8587 |
+
|
8588 |
+
/**
|
8589 |
+
* @since 1.2.1 If activating with license key, ignore the context-user
|
8590 |
+
* since the user will be automatically loaded from the license.
|
8591 |
+
*/
|
8592 |
+
if ( empty( $license_key ) ) {
|
8593 |
+
// Clean up pending license if opt-ing in again.
|
8594 |
+
$this->_storage->remove( 'pending_license_key' );
|
8595 |
+
|
8596 |
+
if ( ! $is_uninstall ) {
|
8597 |
+
$fs_user = Freemius::_get_user_by_email( $email );
|
8598 |
+
if ( is_object( $fs_user ) && ! $this->is_pending_activation() ) {
|
8599 |
+
return $this->install_with_current_user( false, $trial_plan_id );
|
8600 |
+
}
|
8601 |
+
}
|
8602 |
+
}
|
8603 |
+
|
8604 |
+
$user_info = array();
|
8605 |
+
if ( ! empty( $email ) ) {
|
8606 |
+
$user_info['user_email'] = $email;
|
8607 |
+
}
|
8608 |
+
if ( ! empty( $first ) ) {
|
8609 |
+
$user_info['user_firstname'] = $first;
|
8610 |
+
}
|
8611 |
+
if ( ! empty( $last ) ) {
|
8612 |
+
$user_info['user_lastname'] = $last;
|
8613 |
+
}
|
8614 |
+
|
8615 |
+
$params = $this->get_opt_in_params( $user_info );
|
8616 |
+
|
8617 |
+
$filtered_license_key = false;
|
8618 |
+
if ( is_string( $license_key ) ) {
|
8619 |
+
$filtered_license_key = $this->apply_filters( 'license_key', $license_key );
|
8620 |
+
$params['license_key'] = $filtered_license_key;
|
8621 |
+
} else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) {
|
8622 |
+
$params['trial_plan_id'] = $trial_plan_id;
|
8623 |
+
}
|
8624 |
+
|
8625 |
+
if ( $is_uninstall ) {
|
8626 |
+
$params['uninstall_params'] = array(
|
8627 |
+
'reason_id' => $this->_storage->uninstall_reason->id,
|
8628 |
+
'reason_info' => $this->_storage->uninstall_reason->info
|
8629 |
+
);
|
8630 |
+
}
|
8631 |
+
|
8632 |
+
if ( isset( $params['license_key'] ) ) {
|
8633 |
+
$fs_user = Freemius::_get_user_by_email( $email );
|
8634 |
+
|
8635 |
+
if ( is_object( $fs_user ) ) {
|
8636 |
+
/**
|
8637 |
+
* If opting in with a context license and the context WP Admin user already opted in
|
8638 |
+
* before from the current site, add the user context security params to avoid the
|
8639 |
+
* unnecessry email activation when the context license is owned by the same context user.
|
8640 |
+
*
|
8641 |
+
* @author Leo Fajardo (@leorw)
|
8642 |
+
* @since 1.2.3
|
8643 |
+
*/
|
8644 |
+
$params = array_merge( $params, FS_Security::instance()->get_context_params(
|
8645 |
+
$fs_user,
|
8646 |
+
false,
|
8647 |
+
'install_with_existing_user'
|
8648 |
+
) );
|
8649 |
+
}
|
8650 |
+
}
|
8651 |
+
|
8652 |
+
$params['is_disconnected'] = $is_disconnected;
|
8653 |
+
$params['format'] = 'json';
|
8654 |
+
|
8655 |
+
$url = WP_FS__ADDRESS . '/action/service/user/install/';
|
8656 |
+
if ( isset( $_COOKIE['XDEBUG_SESSION'] ) ) {
|
8657 |
+
$url = add_query_arg( 'XDEBUG_SESSION', 'PHPSTORM', $url );
|
8658 |
+
}
|
8659 |
+
|
8660 |
+
$response = wp_remote_post( $url, array(
|
8661 |
+
'method' => 'POST',
|
8662 |
+
'body' => $params,
|
8663 |
+
'timeout' => 15,
|
8664 |
+
) );
|
8665 |
+
|
8666 |
+
if ( $response instanceof WP_Error ) {
|
8667 |
+
if ( 'https://' === substr( $url, 0, 8 ) &&
|
8668 |
+
isset( $response->errors ) &&
|
8669 |
+
isset( $response->errors['http_request_failed'] )
|
8670 |
+
) {
|
8671 |
+
$http_error = strtolower( $response->errors['http_request_failed'][0] );
|
8672 |
+
|
8673 |
+
if ( false !== strpos( $http_error, 'ssl' ) ) {
|
8674 |
+
// Failed due to old version of cURL or Open SSL (SSLv3 is not supported by CloudFlare).
|
8675 |
+
$url = 'http://' . substr( $url, 8 );
|
8676 |
+
|
8677 |
+
$response = wp_remote_post( $url, array(
|
8678 |
+
'method' => 'POST',
|
8679 |
+
'body' => $params,
|
8680 |
+
'timeout' => 15,
|
8681 |
+
) );
|
8682 |
+
}
|
8683 |
+
}
|
8684 |
+
}
|
8685 |
+
|
8686 |
+
if ( is_wp_error( $response ) ) {
|
8687 |
+
/**
|
8688 |
+
* @var WP_Error $response
|
8689 |
+
*/
|
8690 |
+
$result = new stdClass();
|
8691 |
+
|
8692 |
+
$error_code = $response->get_error_code();
|
8693 |
+
$error_type = str_replace( ' ', '', ucwords( str_replace( '_', ' ', $error_code ) ) );
|
8694 |
+
|
8695 |
+
$result->error = (object) array(
|
8696 |
+
'type' => $error_type,
|
8697 |
+
'message' => $response->get_error_message(),
|
8698 |
+
'code' => $error_code,
|
8699 |
+
'http' => 402
|
8700 |
+
);
|
8701 |
+
|
8702 |
+
return $result;
|
8703 |
+
}
|
8704 |
+
|
8705 |
+
// Module is being uninstalled, don't handle the returned data.
|
8706 |
+
if ( $is_uninstall ) {
|
8707 |
+
return true;
|
8708 |
+
}
|
8709 |
+
|
8710 |
+
/**
|
8711 |
+
* When json_decode() executed on PHP 5.2 with an invalid JSON, it will throw a PHP warning. Unfortunately, the new Theme Check doesn't allow PHP silencing and the theme review team isn't open to change that, therefore, instead of using `@json_decode()` we had to use the method without the `@` directive.
|
8712 |
+
*
|
8713 |
+
* @author Vova Feldman (@svovaf)
|
8714 |
+
* @since 1.2.3
|
8715 |
+
* @link https://themes.trac.wordpress.org/ticket/46134#comment:5
|
8716 |
+
* @link https://themes.trac.wordpress.org/ticket/46134#comment:9
|
8717 |
+
* @link https://themes.trac.wordpress.org/ticket/46134#comment:12
|
8718 |
+
* @link https://themes.trac.wordpress.org/ticket/46134#comment:14
|
8719 |
+
*/
|
8720 |
+
$decoded = is_string( $response['body'] ) ?
|
8721 |
+
json_decode( $response['body'] ) :
|
8722 |
+
null;
|
8723 |
+
|
8724 |
+
if ( empty( $decoded ) ) {
|
8725 |
+
return false;
|
8726 |
+
}
|
8727 |
+
|
8728 |
+
if ( ! $this->is_api_result_object( $decoded ) ) {
|
8729 |
+
if ( ! empty( $params['license_key'] ) ) {
|
8730 |
+
// Pass the fully entered license key to the failure handler.
|
8731 |
+
$params['license_key'] = $license_key;
|
8732 |
+
}
|
8733 |
+
|
8734 |
+
return $is_uninstall ?
|
8735 |
+
$decoded :
|
8736 |
+
$this->apply_filters( 'after_install_failure', $decoded, $params );
|
8737 |
+
} else if ( isset( $decoded->pending_activation ) && $decoded->pending_activation ) {
|
8738 |
+
// Pending activation, add message.
|
8739 |
+
return $this->set_pending_confirmation(
|
8740 |
+
( isset( $decoded->email ) ?
|
8741 |
+
$decoded->email :
|
8742 |
+
true ),
|
8743 |
+
false,
|
8744 |
+
$filtered_license_key,
|
8745 |
+
! empty( $params['trial_plan_id'] )
|
8746 |
+
);
|
8747 |
+
} else if ( isset( $decoded->install_secret_key ) ) {
|
8748 |
+
return $this->install_with_new_user(
|
8749 |
+
$decoded->user_id,
|
8750 |
+
$decoded->user_public_key,
|
8751 |
+
$decoded->user_secret_key,
|
8752 |
+
$decoded->install_id,
|
8753 |
+
$decoded->install_public_key,
|
8754 |
+
$decoded->install_secret_key,
|
8755 |
+
false
|
8756 |
+
);
|
8757 |
+
}
|
8758 |
+
|
8759 |
+
return $decoded;
|
8760 |
+
}
|
8761 |
+
|
8762 |
+
/**
|
8763 |
+
* Set user and site identities.
|
8764 |
+
*
|
8765 |
+
* @author Vova Feldman (@svovaf)
|
8766 |
+
* @since 1.0.9
|
8767 |
+
*
|
8768 |
+
* @param FS_User $user
|
8769 |
+
* @param FS_Site $site
|
8770 |
+
* @param bool $redirect
|
8771 |
+
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
|
8772 |
+
* redirect (or return a URL) to the account page with a special parameter to
|
8773 |
+
* trigger the auto installation processes.
|
8774 |
+
*
|
8775 |
+
* @return string If redirect is `false`, returns the next page the user should be redirected to.
|
8776 |
+
*/
|
8777 |
+
function setup_account(
|
8778 |
+
FS_User $user,
|
8779 |
+
FS_Site $site,
|
8780 |
+
$redirect = true,
|
8781 |
+
$auto_install = false
|
8782 |
+
) {
|
8783 |
+
$this->_user = $user;
|
8784 |
+
$this->_site = $site;
|
8785 |
+
|
8786 |
+
$this->_sync_plans();
|
8787 |
+
|
8788 |
+
$this->_enrich_site_plan( false );
|
8789 |
+
|
8790 |
+
$this->_set_account( $user, $site );
|
8791 |
+
|
8792 |
+
if ( $this->is_trial() ) {
|
8793 |
+
// Store trial plan information.
|
8794 |
+
$this->_enrich_site_trial_plan( true );
|
8795 |
+
}
|
8796 |
+
|
8797 |
+
// If Freemius was OFF before, turn it on.
|
8798 |
+
$this->turn_on();
|
8799 |
+
|
8800 |
+
$this->do_action( 'after_account_connection', $user, $site );
|
8801 |
+
|
8802 |
+
if ( is_numeric( $site->license_id ) ) {
|
8803 |
+
$this->_license = $this->_get_license_by_id( $site->license_id );
|
8804 |
+
}
|
8805 |
+
|
8806 |
+
$this->_admin_notices->remove_sticky( 'connect_account' );
|
8807 |
+
|
8808 |
+
if ( $this->is_pending_activation() || ! $this->has_settings_menu() ) {
|
8809 |
+
// Remove pending activation sticky notice (if still exist).
|
8810 |
+
$this->_admin_notices->remove_sticky( 'activation_pending' );
|
8811 |
+
|
8812 |
+
// Remove plugin from pending activation mode.
|
8813 |
+
unset( $this->_storage->is_pending_activation );
|
8814 |
+
|
8815 |
+
if ( ! $this->is_paying_or_trial() ) {
|
8816 |
+
$this->_admin_notices->add_sticky(
|
8817 |
+
sprintf( $this->get_text_x_inline( '%s activation was successfully completed.',
|
8818 |
+
'pluginX activation was successfully...', 'plugin-x-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
|
8819 |
+
'activation_complete'
|
8820 |
+
);
|
8821 |
+
}
|
8822 |
+
}
|
8823 |
+
|
8824 |
+
if ( $this->is_paying_or_trial() ) {
|
8825 |
+
if ( ! $this->is_premium() || ! $this->has_premium_version() || ! $this->has_settings_menu() ) {
|
8826 |
+
if ( $this->is_paying() ) {
|
8827 |
+
$this->_admin_notices->add_sticky(
|
8828 |
+
sprintf(
|
8829 |
+
$this->get_text_inline( 'Your account was successfully activated with the %s plan.', 'activation-with-plan-x-message' ),
|
8830 |
+
$this->_site->plan->title
|
8831 |
+
) . $this->get_complete_upgrade_instructions(),
|
8832 |
+
'plan_upgraded',
|
8833 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
8834 |
+
);
|
8835 |
+
} else {
|
8836 |
+
$this->_admin_notices->add_sticky(
|
8837 |
+
sprintf(
|
8838 |
+
$this->get_text_inline( 'Your trial has been successfully started.', 'trial-started-message' ),
|
8839 |
+
'<i>' . $this->get_plugin_name() . '</i>'
|
8840 |
+
) . $this->get_complete_upgrade_instructions( $this->_storage->trial_plan->title ),
|
8841 |
+
'trial_started',
|
8842 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
8843 |
+
);
|
8844 |
+
}
|
8845 |
+
}
|
8846 |
+
|
8847 |
+
$this->_admin_notices->remove_sticky( array(
|
8848 |
+
'trial_promotion',
|
8849 |
+
) );
|
8850 |
+
}
|
8851 |
+
|
8852 |
+
$plugin_id = fs_request_get( 'plugin_id', false );
|
8853 |
+
|
8854 |
+
// Store activation time ONLY for plugins (not add-ons).
|
8855 |
+
if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
|
8856 |
+
$this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
|
8857 |
+
}
|
8858 |
+
|
8859 |
+
$next_page = '';
|
8860 |
+
|
8861 |
+
$extra = array();
|
8862 |
+
if ( $auto_install ) {
|
8863 |
+
$extra['auto_install'] = 'true';
|
8864 |
+
}
|
8865 |
+
|
8866 |
+
if ( is_numeric( $plugin_id ) ) {
|
8867 |
+
/**
|
8868 |
+
* @author Leo Fajardo
|
8869 |
+
* @since 1.2.1.6
|
8870 |
+
*
|
8871 |
+
* Also sync the license after an anonymous user subscribes.
|
8872 |
+
*/
|
8873 |
+
if ( $this->is_anonymous() || $plugin_id != $this->_plugin->id ) {
|
8874 |
+
// Add-on was installed - sync license right after install.
|
8875 |
+
$next_page = $this->_get_sync_license_url( $plugin_id, true, $extra );
|
8876 |
+
}
|
8877 |
+
} else {
|
8878 |
+
/**
|
8879 |
+
* @author Vova Feldman (@svovaf)
|
8880 |
+
* @since 1.1.9 If site installed with a valid license, sync license.
|
8881 |
+
*/
|
8882 |
+
if ( $this->is_paying() ) {
|
8883 |
+
$this->_sync_plugin_license( true );
|
8884 |
+
}
|
8885 |
+
|
8886 |
+
// Reload the page with the keys.
|
8887 |
+
$next_page = $this->is_anonymous() ?
|
8888 |
+
// If user previously skipped, redirect to account page.
|
8889 |
+
$this->get_account_url( false, $extra ) :
|
8890 |
+
$this->get_after_activation_url( 'after_connect_url' );
|
8891 |
+
}
|
8892 |
+
|
8893 |
+
if ( ! empty( $next_page ) && $redirect ) {
|
8894 |
+
fs_redirect( $next_page );
|
8895 |
+
}
|
8896 |
+
|
8897 |
+
return $next_page;
|
8898 |
+
}
|
8899 |
+
|
8900 |
+
/**
|
8901 |
+
* Install plugin with new user information after approval.
|
8902 |
+
*
|
8903 |
+
* @author Vova Feldman (@svovaf)
|
8904 |
+
* @since 1.0.7
|
8905 |
+
*/
|
8906 |
+
function _install_with_new_user() {
|
8907 |
+
$this->_logger->entrance();
|
8908 |
+
|
8909 |
+
if ( $this->is_registered() ) {
|
8910 |
+
return;
|
8911 |
+
}
|
8912 |
+
|
8913 |
+
if ( ( $this->is_plugin() && fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) ||
|
8914 |
+
// @todo This logic should be improved because it's executed on every load of a theme.
|
8915 |
+
$this->is_theme()
|
8916 |
+
) {
|
8917 |
+
// check_admin_referer( $this->_slug . '_activate_new' );
|
8918 |
+
|
8919 |
+
if ( fs_request_has( 'user_secret_key' ) ) {
|
8920 |
+
$this->install_with_new_user(
|
8921 |
+
fs_request_get( 'user_id' ),
|
8922 |
+
fs_request_get( 'user_public_key' ),
|
8923 |
+
fs_request_get( 'user_secret_key' ),
|
8924 |
+
fs_request_get( 'install_id' ),
|
8925 |
+
fs_request_get( 'install_public_key' ),
|
8926 |
+
fs_request_get( 'install_secret_key' ),
|
8927 |
+
true,
|
8928 |
+
fs_request_get_bool( 'auto_install' )
|
8929 |
+
);
|
8930 |
+
} else if ( fs_request_has( 'pending_activation' ) ) {
|
8931 |
+
$this->set_pending_confirmation( fs_request_get( 'user_email' ), true );
|
8932 |
+
}
|
8933 |
+
}
|
8934 |
+
}
|
8935 |
+
|
8936 |
+
/**
|
8937 |
+
* Install plugin with new user.
|
8938 |
+
*
|
8939 |
+
* @author Vova Feldman (@svovaf)
|
8940 |
+
* @since 1.1.7.4
|
8941 |
+
*
|
8942 |
+
* @param number $user_id
|
8943 |
+
* @param string $user_public_key
|
8944 |
+
* @param string $user_secret_key
|
8945 |
+
* @param number $install_id
|
8946 |
+
* @param string $install_public_key
|
8947 |
+
* @param string $install_secret_key
|
8948 |
+
* @param bool $redirect
|
8949 |
+
* @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
|
8950 |
+
* redirect (or return a URL) to the account page with a special parameter to
|
8951 |
+
* trigger the auto installation processes.
|
8952 |
+
*
|
8953 |
+
* @return string If redirect is `false`, returns the next page the user should be redirected to.
|
8954 |
+
*/
|
8955 |
+
private function install_with_new_user(
|
8956 |
+
$user_id,
|
8957 |
+
$user_public_key,
|
8958 |
+
$user_secret_key,
|
8959 |
+
$install_id,
|
8960 |
+
$install_public_key,
|
8961 |
+
$install_secret_key,
|
8962 |
+
$redirect = true,
|
8963 |
+
$auto_install = false
|
8964 |
+
) {
|
8965 |
+
$user = new FS_User();
|
8966 |
+
$user->id = $user_id;
|
8967 |
+
$user->public_key = $user_public_key;
|
8968 |
+
$user->secret_key = $user_secret_key;
|
8969 |
+
|
8970 |
+
$this->_user = $user;
|
8971 |
+
$user_result = $this->get_api_user_scope()->get();
|
8972 |
+
$user = new FS_User( $user_result );
|
8973 |
+
$this->_user = $user;
|
8974 |
+
|
8975 |
+
$site = new FS_Site();
|
8976 |
+
$site->id = $install_id;
|
8977 |
+
$site->public_key = $install_public_key;
|
8978 |
+
$site->secret_key = $install_secret_key;
|
8979 |
+
|
8980 |
+
$this->_site = $site;
|
8981 |
+
$site_result = $this->get_api_site_scope()->get();
|
8982 |
+
$site = new FS_Site( $site_result );
|
8983 |
+
$this->_site = $site;
|
8984 |
+
|
8985 |
+
return $this->setup_account(
|
8986 |
+
$this->_user,
|
8987 |
+
$this->_site,
|
8988 |
+
$redirect,
|
8989 |
+
$auto_install
|
8990 |
+
);
|
8991 |
+
}
|
8992 |
+
|
8993 |
+
/**
|
8994 |
+
* @author Vova Feldman (@svovaf)
|
8995 |
+
* @since 1.1.7.4
|
8996 |
+
*
|
8997 |
+
* @param string|bool $email
|
8998 |
+
* @param bool $redirect
|
8999 |
+
* @param string|bool $license_key Since 1.2.1.5
|
9000 |
+
* @param bool $is_pending_trial Since 1.2.1.5
|
9001 |
+
*
|
9002 |
+
* @return string Since 1.2.1.5 if $redirect is `false`, return the pending activation page.
|
9003 |
+
*/
|
9004 |
+
private function set_pending_confirmation(
|
9005 |
+
$email = false,
|
9006 |
+
$redirect = true,
|
9007 |
+
$license_key = false,
|
9008 |
+
$is_pending_trial = false
|
9009 |
+
) {
|
9010 |
+
if ( $this->_ignore_pending_mode ) {
|
9011 |
+
/**
|
9012 |
+
* If explicitly asked to ignore pending mode, set to anonymous mode
|
9013 |
+
* if require confirmation before finalizing the opt-in.
|
9014 |
+
*
|
9015 |
+
* @author Vova Feldman
|
9016 |
+
* @since 1.2.1.6
|
9017 |
+
*/
|
9018 |
+
$this->skip_connection();
|
9019 |
+
} else {
|
9020 |
+
// Install must be activated via email since
|
9021 |
+
// user with the same email already exist.
|
9022 |
+
$this->_storage->is_pending_activation = true;
|
9023 |
+
$this->_add_pending_activation_notice( $email, $is_pending_trial );
|
9024 |
+
}
|
9025 |
+
|
9026 |
+
if ( ! empty( $license_key ) ) {
|
9027 |
+
$this->_storage->pending_license_key = $license_key;
|
9028 |
+
}
|
9029 |
+
|
9030 |
+
// Remove the opt-in sticky notice.
|
9031 |
+
$this->_admin_notices->remove_sticky( array(
|
9032 |
+
'connect_account',
|
9033 |
+
'trial_promotion',
|
9034 |
+
) );
|
9035 |
+
|
9036 |
+
$next_page = $this->get_after_activation_url( 'after_pending_connect_url' );
|
9037 |
+
|
9038 |
+
// Reload the page with with pending activation message.
|
9039 |
+
if ( $redirect ) {
|
9040 |
+
fs_redirect( $next_page );
|
9041 |
+
}
|
9042 |
+
|
9043 |
+
return $next_page;
|
9044 |
+
}
|
9045 |
+
|
9046 |
+
/**
|
9047 |
+
* Install plugin with current logged WP user info.
|
9048 |
+
*
|
9049 |
+
* @author Vova Feldman (@svovaf)
|
9050 |
+
* @since 1.0.7
|
9051 |
+
*/
|
9052 |
+
function _install_with_current_user() {
|
9053 |
+
$this->_logger->entrance();
|
9054 |
+
|
9055 |
+
if ( $this->is_registered() ) {
|
9056 |
+
return;
|
9057 |
+
}
|
9058 |
+
|
9059 |
+
if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) && fs_request_is_post() ) {
|
9060 |
+
// check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
|
9061 |
+
|
9062 |
+
/**
|
9063 |
+
* @author Vova Feldman (@svovaf)
|
9064 |
+
* @since 1.1.9 Add license key if given.
|
9065 |
+
*/
|
9066 |
+
$license_key = fs_request_get( 'license_secret_key' );
|
9067 |
+
|
9068 |
+
$this->install_with_current_user( $license_key );
|
9069 |
+
}
|
9070 |
+
}
|
9071 |
+
|
9072 |
+
|
9073 |
+
/**
|
9074 |
+
* @author Vova Feldman (@svovaf)
|
9075 |
+
* @since 1.1.7.4
|
9076 |
+
*
|
9077 |
+
* @param string|bool $license_key
|
9078 |
+
* @param number|bool $trial_plan_id
|
9079 |
+
* @param bool $redirect
|
9080 |
+
*
|
9081 |
+
* @return string|object If redirect is `false`, returns the next page the user should be redirected to, or the
|
9082 |
+
* API error object if failed to install.
|
9083 |
+
*/
|
9084 |
+
private function install_with_current_user(
|
9085 |
+
$license_key = false,
|
9086 |
+
$trial_plan_id = false,
|
9087 |
+
$redirect = true
|
9088 |
+
) {
|
9089 |
+
// Get current logged WP user.
|
9090 |
+
$current_user = self::_get_current_wp_user();
|
9091 |
+
|
9092 |
+
// Find the relevant FS user by the email.
|
9093 |
+
$user = self::_get_user_by_email( $current_user->user_email );
|
9094 |
+
|
9095 |
+
// We have to set the user before getting user scope API handler.
|
9096 |
+
$this->_user = $user;
|
9097 |
+
|
9098 |
+
$extra_install_params = array(
|
9099 |
+
'uid' => $this->get_anonymous_id(),
|
9100 |
+
);
|
9101 |
+
|
9102 |
+
if ( ! empty( $license_key ) ) {
|
9103 |
+
$filtered_license_key = $this->apply_filters( 'license_key', $license_key );
|
9104 |
+
$extra_install_params['license_key'] = $filtered_license_key;
|
9105 |
+
} else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) {
|
9106 |
+
$extra_install_params['trial_plan_id'] = $trial_plan_id;
|
9107 |
+
}
|
9108 |
+
|
9109 |
+
$args = $this->get_install_data_for_api( $extra_install_params, false, false );
|
9110 |
+
|
9111 |
+
// Install the plugin.
|
9112 |
+
$install = $this->get_api_user_scope()->call(
|
9113 |
+
"/plugins/{$this->get_id()}/installs.json",
|
9114 |
+
'post',
|
9115 |
+
$args
|
9116 |
+
);
|
9117 |
+
|
9118 |
+
if ( ! $this->is_api_result_entity( $install ) ) {
|
9119 |
+
if ( ! empty( $args['license_key'] ) ) {
|
9120 |
+
// Pass full the fully entered license key to the failure handler.
|
9121 |
+
$args['license_key'] = $license_key;
|
9122 |
+
}
|
9123 |
+
|
9124 |
+
$install = $this->apply_filters( 'after_install_failure', $install, $args );
|
9125 |
+
|
9126 |
+
$this->_admin_notices->add(
|
9127 |
+
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
|
9128 |
+
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $install->error->message . '</b>',
|
9129 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
9130 |
+
'error'
|
9131 |
+
);
|
9132 |
+
|
9133 |
+
if ( $redirect ) {
|
9134 |
+
/**
|
9135 |
+
* We set the user before getting the user scope API handler, so the user became temporarily
|
9136 |
+
* registered (`is_registered() = true`). Since the API returned an error and we will redirect,
|
9137 |
+
* we have to set the user to `null`, otherwise, the user will be redirected to the wrong
|
9138 |
+
* activation page based on the return value of `is_registered()`. In addition, in case the
|
9139 |
+
* context plugin doesn't have a settings menu and the default page is the `Plugins` page,
|
9140 |
+
* misleading plugin activation errors will be shown on the `Plugins` page.
|
9141 |
+
*
|
9142 |
+
* @author Leo Fajardo (@leorw)
|
9143 |
+
*/
|
9144 |
+
$this->_user = null;
|
9145 |
+
|
9146 |
+
fs_redirect( $this->get_activation_url( array( 'error' => $install->error->message ) ) );
|
9147 |
+
}
|
9148 |
+
|
9149 |
+
return $install;
|
9150 |
+
}
|
9151 |
+
|
9152 |
+
$site = new FS_Site( $install );
|
9153 |
+
$this->_site = $site;
|
9154 |
+
|
9155 |
+
return $this->setup_account( $this->_user, $this->_site, $redirect );
|
9156 |
+
}
|
9157 |
+
|
9158 |
+
/**
|
9159 |
+
* Tries to activate add-on account based on parent plugin info.
|
9160 |
+
*
|
9161 |
+
* @author Vova Feldman (@svovaf)
|
9162 |
+
* @since 1.0.6
|
9163 |
+
*
|
9164 |
+
* @param Freemius $parent_fs
|
9165 |
+
*/
|
9166 |
+
private function _activate_addon_account( Freemius $parent_fs ) {
|
9167 |
+
if ( $this->is_registered() ) {
|
9168 |
+
// Already activated.
|
9169 |
+
return;
|
9170 |
+
}
|
9171 |
+
|
9172 |
+
// Activate add-on with parent plugin credentials.
|
9173 |
+
$addon_install = $parent_fs->get_api_site_scope()->call(
|
9174 |
+
"/addons/{$this->_plugin->id}/installs.json",
|
9175 |
+
'post',
|
9176 |
+
$this->get_install_data_for_api( array(
|
9177 |
+
'uid' => $this->get_anonymous_id(),
|
9178 |
+
), false, false )
|
9179 |
+
);
|
9180 |
+
|
9181 |
+
if ( isset( $addon_install->error ) ) {
|
9182 |
+
$this->_admin_notices->add(
|
9183 |
+
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
|
9184 |
+
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
|
9185 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
9186 |
+
'error'
|
9187 |
+
);
|
9188 |
+
|
9189 |
+
return;
|
9190 |
+
}
|
9191 |
+
|
9192 |
+
// First of all, set site info - otherwise we won't
|
9193 |
+
// be able to invoke API calls.
|
9194 |
+
$this->_site = new FS_Site( $addon_install );
|
9195 |
+
|
9196 |
+
// Sync add-on plans.
|
9197 |
+
$this->_sync_plans();
|
9198 |
+
|
9199 |
+
// Get site's current plan.
|
9200 |
+
$this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
|
9201 |
+
|
9202 |
+
// Get user information based on parent's plugin.
|
9203 |
+
$user = $parent_fs->get_user();
|
9204 |
+
|
9205 |
+
$this->_set_account( $user, $this->_site );
|
9206 |
+
|
9207 |
+
// Sync licenses.
|
9208 |
+
$this->_sync_licenses();
|
9209 |
+
|
9210 |
+
// Try to activate premium license.
|
9211 |
+
$this->_activate_license( true );
|
9212 |
+
}
|
9213 |
+
|
9214 |
+
/**
|
9215 |
+
* Tries to activate parent account based on add-on's info.
|
9216 |
+
*
|
9217 |
+
* @author Vova Feldman (@svovaf)
|
9218 |
+
* @since 1.2.2.7
|
9219 |
+
*
|
9220 |
+
* @param Freemius $parent_fs
|
9221 |
+
*/
|
9222 |
+
private function activate_parent_account( Freemius $parent_fs ) {
|
9223 |
+
if ( ! $this->is_addon() ) {
|
9224 |
+
// This is not an add-on.
|
9225 |
+
return;
|
9226 |
+
}
|
9227 |
+
|
9228 |
+
if ( $parent_fs->is_registered() ) {
|
9229 |
+
// Already activated.
|
9230 |
+
return;
|
9231 |
+
}
|
9232 |
+
|
9233 |
+
// Activate parent with add-on's user credentials.
|
9234 |
+
$parent_install = $this->get_api_user_scope()->call(
|
9235 |
+
"/plugins/{$parent_fs->_plugin->id}/installs.json",
|
9236 |
+
'post',
|
9237 |
+
$parent_fs->get_install_data_for_api( array(
|
9238 |
+
'uid' => $parent_fs->get_anonymous_id(),
|
9239 |
+
), false, false )
|
9240 |
+
);
|
9241 |
+
|
9242 |
+
if ( isset( $parent_install->error ) ) {
|
9243 |
+
$this->_admin_notices->add(
|
9244 |
+
sprintf( $this->get_text_inline( 'Couldn\'t activate %s.', 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
|
9245 |
+
$this->get_text_inline( 'Please contact us with the following message:', 'contact-us-with-error-message' ) . ' ' . '<b>' . $parent_install->error->message . '</b>',
|
9246 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
9247 |
+
'error'
|
9248 |
+
);
|
9249 |
+
|
9250 |
+
return;
|
9251 |
+
}
|
9252 |
+
|
9253 |
+
$parent_fs->_admin_notices->remove_sticky( 'connect_account' );
|
9254 |
+
|
9255 |
+
if ( $parent_fs->is_pending_activation() ) {
|
9256 |
+
$parent_fs->_admin_notices->remove_sticky( 'activation_pending' );
|
9257 |
+
|
9258 |
+
unset( $parent_fs->_storage->is_pending_activation );
|
9259 |
+
}
|
9260 |
+
|
9261 |
+
// First of all, set site info - otherwise we won't
|
9262 |
+
// be able to invoke API calls.
|
9263 |
+
$parent_fs->_site = new FS_Site( $parent_install );
|
9264 |
+
|
9265 |
+
// Sync add-on plans.
|
9266 |
+
$parent_fs->_sync_plans();
|
9267 |
+
|
9268 |
+
// Get site's current plan.
|
9269 |
+
$parent_fs->_site->plan = $parent_fs->_get_plan_by_id( $parent_fs->_site->plan->id );
|
9270 |
+
|
9271 |
+
// Get user information based on parent's plugin.
|
9272 |
+
$user = $this->get_user();
|
9273 |
+
|
9274 |
+
$parent_fs->_set_account( $user, $parent_fs->_site );
|
9275 |
+
}
|
9276 |
+
|
9277 |
+
#endregion
|
9278 |
+
|
9279 |
+
#----------------------------------------------------------------------------------
|
9280 |
+
#region Admin Menu Items
|
9281 |
+
#----------------------------------------------------------------------------------
|
9282 |
+
|
9283 |
+
private $_menu_items = array();
|
9284 |
+
|
9285 |
+
/**
|
9286 |
+
* @author Vova Feldman (@svovaf)
|
9287 |
+
* @since 1.2.1.8
|
9288 |
+
*
|
9289 |
+
* @return array
|
9290 |
+
*/
|
9291 |
+
function get_menu_items() {
|
9292 |
+
return $this->_menu_items;
|
9293 |
+
}
|
9294 |
+
|
9295 |
+
/**
|
9296 |
+
* @author Vova Feldman (@svovaf)
|
9297 |
+
* @since 1.0.7
|
9298 |
+
*
|
9299 |
+
* @return string
|
9300 |
+
*/
|
9301 |
+
function get_menu_slug() {
|
9302 |
+
return $this->_menu->get_slug();
|
9303 |
+
}
|
9304 |
+
|
9305 |
+
/**
|
9306 |
+
* @author Vova Feldman (@svovaf)
|
9307 |
+
* @since 1.0.9
|
9308 |
+
*/
|
9309 |
+
function _prepare_admin_menu() {
|
9310 |
+
// if ( ! $this->is_on() ) {
|
9311 |
+
// return;
|
9312 |
+
// }
|
9313 |
+
|
9314 |
+
if ( ! $this->has_api_connectivity() && ! $this->is_enable_anonymous() ) {
|
9315 |
+
$this->_menu->remove_menu_item();
|
9316 |
+
} else {
|
9317 |
+
$this->do_action( 'before_admin_menu_init' );
|
9318 |
+
|
9319 |
+
$this->add_menu_action();
|
9320 |
+
$this->add_submenu_items();
|
9321 |
+
}
|
9322 |
+
}
|
9323 |
+
|
9324 |
+
/**
|
9325 |
+
* Admin dashboard menu items modifications.
|
9326 |
+
*
|
9327 |
+
* NOTE: admin_menu action executed before admin_init.
|
9328 |
+
*
|
9329 |
+
* @author Vova Feldman (@svovaf)
|
9330 |
+
* @since 1.0.7
|
9331 |
+
*
|
9332 |
+
*/
|
9333 |
+
private function add_menu_action() {
|
9334 |
+
if ( $this->is_activation_mode() ) {
|
9335 |
+
if ( $this->is_plugin() || ( $this->has_settings_menu() && ! $this->is_free_wp_org_theme() ) ) {
|
9336 |
+
$this->override_plugin_menu_with_activation();
|
9337 |
+
} else {
|
9338 |
+
/**
|
9339 |
+
* Handle theme opt-in when the opt-in form shows as a dialog box in the themes page.
|
9340 |
+
*/
|
9341 |
+
if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) {
|
9342 |
+
add_action( 'load-themes.php', array( &$this, '_install_with_current_user' ) );
|
9343 |
+
} else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ||
|
9344 |
+
fs_request_get_bool( 'pending_activation' )
|
9345 |
+
) {
|
9346 |
+
add_action( 'load-themes.php', array( &$this, '_install_with_new_user' ) );
|
9347 |
+
}
|
9348 |
+
}
|
9349 |
+
} else {
|
9350 |
+
if ( ! $this->is_registered() ) {
|
9351 |
+
// If not registered try to install user.
|
9352 |
+
if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) {
|
9353 |
+
$this->_install_with_new_user();
|
9354 |
+
}
|
9355 |
+
} else if (
|
9356 |
+
fs_request_is_action( 'sync_user' ) &&
|
9357 |
+
( ! $this->has_settings_menu() || $this->is_free_wp_org_theme() )
|
9358 |
+
) {
|
9359 |
+
$this->_handle_account_user_sync();
|
9360 |
+
}
|
9361 |
+
}
|
9362 |
+
}
|
9363 |
+
|
9364 |
+
/**
|
9365 |
+
* @author Vova Feldman (@svovaf)
|
9366 |
+
* @since 1.0.1
|
9367 |
+
*/
|
9368 |
+
function _redirect_on_clicked_menu_link() {
|
9369 |
+
$this->_logger->entrance();
|
9370 |
+
|
9371 |
+
$page = strtolower( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
|
9372 |
+
|
9373 |
+
$this->_logger->log( 'page = ' . $page );
|
9374 |
+
|
9375 |
+
foreach ( $this->_menu_items as $priority => $items ) {
|
9376 |
+
foreach ( $items as $item ) {
|
9377 |
+
if ( isset( $item['url'] ) ) {
|
9378 |
+
if ( $page === $this->_menu->get_slug( strtolower( $item['menu_slug'] ) ) ) {
|
9379 |
+
$this->_logger->log( 'Redirecting to ' . $item['url'] );
|
9380 |
+
|
9381 |
+
fs_redirect( $item['url'] );
|
9382 |
+
}
|
9383 |
+
}
|
9384 |
+
}
|
9385 |
+
}
|
9386 |
+
}
|
9387 |
+
|
9388 |
+
/**
|
9389 |
+
* Remove plugin's all admin menu items & pages, and replace with activation page.
|
9390 |
+
*
|
9391 |
+
* @author Vova Feldman (@svovaf)
|
9392 |
+
* @since 1.0.1
|
9393 |
+
*/
|
9394 |
+
private function override_plugin_menu_with_activation() {
|
9395 |
+
$this->_logger->entrance();
|
9396 |
+
|
9397 |
+
$hook = false;
|
9398 |
+
|
9399 |
+
if ( ! $this->_menu->has_menu() ) {
|
9400 |
+
// Add the opt-in page without a menu item.
|
9401 |
+
$hook = FS_Admin_Menu_Manager::add_subpage(
|
9402 |
+
null,
|
9403 |
+
$this->get_plugin_name(),
|
9404 |
+
$this->get_plugin_name(),
|
9405 |
+
'manage_options',
|
9406 |
+
$this->_slug,
|
9407 |
+
array( &$this, '_connect_page_render' )
|
9408 |
+
);
|
9409 |
+
} else if ( $this->_menu->is_top_level() ) {
|
9410 |
+
$hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) );
|
9411 |
+
|
9412 |
+
if ( false === $hook ) {
|
9413 |
+
// Create new menu item just for the opt-in.
|
9414 |
+
$hook = FS_Admin_Menu_Manager::add_page(
|
9415 |
+
$this->get_plugin_name(),
|
9416 |
+
$this->get_plugin_name(),
|
9417 |
+
'manage_options',
|
9418 |
+
$this->_menu->get_slug(),
|
9419 |
+
array( &$this, '_connect_page_render' )
|
9420 |
+
);
|
9421 |
+
}
|
9422 |
+
} else {
|
9423 |
+
$menus = array( $this->_menu->get_parent_slug() );
|
9424 |
+
|
9425 |
+
if ( $this->_menu->is_override_exact() ) {
|
9426 |
+
// Make sure the current page is matching the activation page.
|
9427 |
+
if ( ! $this->is_matching_url( $this->get_activation_url() ) ) {
|
9428 |
+
return;
|
9429 |
+
}
|
9430 |
+
}
|
9431 |
+
|
9432 |
+
foreach ( $menus as $parent_slug ) {
|
9433 |
+
$hook = $this->_menu->override_submenu_action(
|
9434 |
+
$parent_slug,
|
9435 |
+
$this->_menu->get_raw_slug(),
|
9436 |
+
array( &$this, '_connect_page_render' )
|
9437 |
+
);
|
9438 |
+
|
9439 |
+
if ( false !== $hook ) {
|
9440 |
+
// Found plugin's submenu item.
|
9441 |
+
break;
|
9442 |
+
}
|
9443 |
+
}
|
9444 |
+
}
|
9445 |
+
|
9446 |
+
if ( $this->is_activation_page() ) {
|
9447 |
+
// Clean admin page from distracting content.
|
9448 |
+
self::_clean_admin_content_section();
|
9449 |
+
}
|
9450 |
+
|
9451 |
+
if ( false !== $hook ) {
|
9452 |
+
if ( fs_request_is_action( $this->get_unique_affix() . '_activate_existing' ) ) {
|
9453 |
+
$this->_install_with_current_user();
|
9454 |
+
} else if ( fs_request_is_action( $this->get_unique_affix() . '_activate_new' ) ) {
|
9455 |
+
$this->_install_with_new_user();
|
9456 |
+
}
|
9457 |
+
}
|
9458 |
+
}
|
9459 |
+
|
9460 |
+
/**
|
9461 |
+
* @author Leo Fajardo (leorw)
|
9462 |
+
* @since 1.2.1
|
9463 |
+
*
|
9464 |
+
* return string
|
9465 |
+
*/
|
9466 |
+
function get_top_level_menu_capability() {
|
9467 |
+
global $menu;
|
9468 |
+
|
9469 |
+
$top_level_menu_slug = $this->get_top_level_menu_slug();
|
9470 |
+
|
9471 |
+
foreach ( $menu as $menu_info ) {
|
9472 |
+
/**
|
9473 |
+
* The second element in the menu info array is the capability/role that has access to the menu and the
|
9474 |
+
* third element is the menu slug.
|
9475 |
+
*/
|
9476 |
+
if ( $menu_info[2] === $top_level_menu_slug ) {
|
9477 |
+
return $menu_info[1];
|
9478 |
+
}
|
9479 |
+
}
|
9480 |
+
|
9481 |
+
return 'read';
|
9482 |
+
}
|
9483 |
+
|
9484 |
+
/**
|
9485 |
+
* @author Vova Feldman (@svovaf)
|
9486 |
+
* @since 1.0.0
|
9487 |
+
*
|
9488 |
+
* @return string
|
9489 |
+
*/
|
9490 |
+
private function get_top_level_menu_slug() {
|
9491 |
+
return ( $this->is_addon() ?
|
9492 |
+
$this->get_parent_instance()->_menu->get_top_level_menu_slug() :
|
9493 |
+
$this->_menu->get_top_level_menu_slug() );
|
9494 |
+
}
|
9495 |
+
|
9496 |
+
/**
|
9497 |
+
* @author Vova Feldman (@svovaf)
|
9498 |
+
* @since 1.2.2.7
|
9499 |
+
*
|
9500 |
+
* @return string
|
9501 |
+
*/
|
9502 |
+
function get_pricing_cta_label() {
|
9503 |
+
$label = $this->get_text_inline( 'Upgrade', 'upgrade' );
|
9504 |
+
|
9505 |
+
if ( $this->is_in_trial_promotion() &&
|
9506 |
+
! $this->is_paying_or_trial()
|
9507 |
+
) {
|
9508 |
+
// If running a trial promotion, modify the pricing to load the trial.
|
9509 |
+
$label = $this->get_text_inline( 'Start Trial', 'start-trial' );
|
9510 |
+
} else if ( $this->is_paying() ) {
|
9511 |
+
$label = $this->get_text_inline( 'Pricing', 'pricing' );
|
9512 |
+
}
|
9513 |
+
|
9514 |
+
return $label;
|
9515 |
+
}
|
9516 |
+
|
9517 |
+
/**
|
9518 |
+
* @author Vova Feldman (@svovaf)
|
9519 |
+
* @since 1.2.2.7
|
9520 |
+
*
|
9521 |
+
* @return bool
|
9522 |
+
*/
|
9523 |
+
function is_pricing_page_visible() {
|
9524 |
+
return (
|
9525 |
+
// Has at least one paid plan.
|
9526 |
+
$this->has_paid_plan() &&
|
9527 |
+
// Didn't ask to hide the pricing page.
|
9528 |
+
$this->is_page_visible( 'pricing' ) &&
|
9529 |
+
// Don't have a valid active license or has more than one plan.
|
9530 |
+
( ! $this->is_paying() || ! $this->is_single_plan() )
|
9531 |
+
);
|
9532 |
+
}
|
9533 |
+
|
9534 |
+
/**
|
9535 |
+
* Add default Freemius menu items.
|
9536 |
+
*
|
9537 |
+
* @author Vova Feldman (@svovaf)
|
9538 |
+
* @since 1.0.0
|
9539 |
+
*/
|
9540 |
+
private function add_submenu_items() {
|
9541 |
+
$this->_logger->entrance();
|
9542 |
+
|
9543 |
+
if ( ! $this->is_addon() ) {
|
9544 |
+
/**
|
9545 |
+
* @since 1.2.2.7 Also add submenu items when running in a free .org theme so the tabs will be visible.
|
9546 |
+
*/
|
9547 |
+
if ( ! $this->is_activation_mode() || $this->is_free_wp_org_theme() ) {
|
9548 |
+
if ( $this->has_affiliate_program() ) {
|
9549 |
+
// Add affiliation page.
|
9550 |
+
$this->add_submenu_item(
|
9551 |
+
$this->get_text_inline( 'Affiliation', 'affiliation' ),
|
9552 |
+
array( &$this, '_affiliation_page_render' ),
|
9553 |
+
$this->get_plugin_name() . ' – ' . $this->get_text_inline( 'Affiliation', 'affiliation' ),
|
9554 |
+
'manage_options',
|
9555 |
+
'affiliation',
|
9556 |
+
'Freemius::_clean_admin_content_section',
|
9557 |
+
WP_FS__DEFAULT_PRIORITY,
|
9558 |
+
$this->is_submenu_item_visible( 'affiliation' )
|
9559 |
+
);
|
9560 |
+
}
|
9561 |
+
|
9562 |
+
if ( $this->is_registered() ) {
|
9563 |
+
$show_account = (
|
9564 |
+
$this->is_submenu_item_visible( 'account' ) &&
|
9565 |
+
/**
|
9566 |
+
* @since 1.2.2.7 Don't show the Account for free WP.org themes without any paid plans.
|
9567 |
+
*/
|
9568 |
+
( ! $this->is_free_wp_org_theme() || $this->has_paid_plan() )
|
9569 |
+
);
|
9570 |
+
|
9571 |
+
// Add user account page.
|
9572 |
+
$this->add_submenu_item(
|
9573 |
+
$this->get_text_inline( 'Account', 'account' ),
|
9574 |
+
array( &$this, '_account_page_render' ),
|
9575 |
+
$this->get_plugin_name() . ' – ' . $this->get_text_inline( 'Account', 'account' ),
|
9576 |
+
'manage_options',
|
9577 |
+
'account',
|
9578 |
+
array( &$this, '_account_page_load' ),
|
9579 |
+
WP_FS__DEFAULT_PRIORITY,
|
9580 |
+
$show_account
|
9581 |
+
);
|
9582 |
+
}
|
9583 |
+
|
9584 |
+
// Add contact page.
|
9585 |
+
$this->add_submenu_item(
|
9586 |
+
$this->get_text_inline( 'Contact Us', 'contact-us' ),
|
9587 |
+
array( &$this, '_contact_page_render' ),
|
9588 |
+
$this->get_plugin_name() . ' – ' . $this->get_text_inline( 'Contact Us', 'contact-us' ),
|
9589 |
+
'manage_options',
|
9590 |
+
'contact',
|
9591 |
+
'Freemius::_clean_admin_content_section',
|
9592 |
+
WP_FS__DEFAULT_PRIORITY,
|
9593 |
+
$this->is_submenu_item_visible( 'contact' )
|
9594 |
+
);
|
9595 |
+
|
9596 |
+
if ( $this->has_addons() ) {
|
9597 |
+
$this->add_submenu_item(
|
9598 |
+
$this->get_text_inline( 'Add-Ons', 'add-ons' ),
|
9599 |
+
array( &$this, '_addons_page_render' ),
|
9600 |
+
$this->get_plugin_name() . ' – ' . $this->get_text_inline( 'Add-Ons', 'add-ons' ),
|
9601 |
+
'manage_options',
|
9602 |
+
'addons',
|
9603 |
+
array( &$this, '_addons_page_load' ),
|
9604 |
+
WP_FS__LOWEST_PRIORITY - 1,
|
9605 |
+
$this->is_submenu_item_visible( 'addons' )
|
9606 |
+
);
|
9607 |
+
}
|
9608 |
+
|
9609 |
+
$show_pricing = (
|
9610 |
+
$this->is_submenu_item_visible( 'pricing' ) &&
|
9611 |
+
$this->is_pricing_page_visible()
|
9612 |
+
);
|
9613 |
+
|
9614 |
+
$pricing_cta_text = $this->get_pricing_cta_label();
|
9615 |
+
$pricing_class = 'upgrade-mode';
|
9616 |
+
if ( $show_pricing ) {
|
9617 |
+
if ( $this->is_in_trial_promotion() &&
|
9618 |
+
! $this->is_paying_or_trial()
|
9619 |
+
) {
|
9620 |
+
// If running a trial promotion, modify the pricing to load the trial.
|
9621 |
+
$pricing_class = 'trial-mode';
|
9622 |
+
} else if ( $this->is_paying() ) {
|
9623 |
+
$pricing_class = '';
|
9624 |
+
}
|
9625 |
+
}
|
9626 |
+
|
9627 |
+
// Add upgrade/pricing page.
|
9628 |
+
$this->add_submenu_item(
|
9629 |
+
$pricing_cta_text . ' ' . ( is_rtl() ? '←' : '➤' ),
|
9630 |
+
array( &$this, '_pricing_page_render' ),
|
9631 |
+
$this->get_plugin_name() . ' – ' . $this->get_text_x_inline( 'Pricing', 'noun', 'pricing' ),
|
9632 |
+
'manage_options',
|
9633 |
+
'pricing',
|
9634 |
+
'Freemius::_clean_admin_content_section',
|
9635 |
+
WP_FS__LOWEST_PRIORITY,
|
9636 |
+
$show_pricing,
|
9637 |
+
$pricing_class
|
9638 |
+
);
|
9639 |
+
}
|
9640 |
+
}
|
9641 |
+
|
9642 |
+
|
9643 |
+
if ( 0 < count( $this->_menu_items ) ) {
|
9644 |
+
if ( ! $this->_menu->is_top_level() ) {
|
9645 |
+
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
|
9646 |
+
|
9647 |
+
// Append submenu items right after the plugin's submenu item.
|
9648 |
+
$this->order_sub_submenu_items();
|
9649 |
+
} else {
|
9650 |
+
// Append submenu items.
|
9651 |
+
$this->embed_submenu_items();
|
9652 |
+
}
|
9653 |
+
}
|
9654 |
+
}
|
9655 |
+
|
9656 |
+
/**
|
9657 |
+
* Moved the actual submenu item additions to a separated function,
|
9658 |
+
* in order to support sub-submenu items when the plugin's settings
|
9659 |
+
* only have a submenu and not top-level menu item.
|
9660 |
+
*
|
9661 |
+
* @author Vova Feldman (@svovaf)
|
9662 |
+
* @since 1.1.4
|
9663 |
+
*/
|
9664 |
+
private function embed_submenu_items() {
|
9665 |
+
$item_template = $this->_menu->is_top_level() ?
|
9666 |
+
'<span class="fs-submenu-item %s %s %s">%s</span>' :
|
9667 |
+
'<span class="fs-submenu-item fs-sub %s %s %s">%s</span>';
|
9668 |
+
|
9669 |
+
$top_level_menu_capability = $this->get_top_level_menu_capability();
|
9670 |
+
|
9671 |
+
ksort( $this->_menu_items );
|
9672 |
+
|
9673 |
+
foreach ( $this->_menu_items as $priority => $items ) {
|
9674 |
+
foreach ( $items as $item ) {
|
9675 |
+
$capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability );
|
9676 |
+
|
9677 |
+
$menu_item = sprintf(
|
9678 |
+
$item_template,
|
9679 |
+
$this->get_unique_affix(),
|
9680 |
+
$item['menu_slug'],
|
9681 |
+
! empty( $item['class'] ) ? $item['class'] : '',
|
9682 |
+
$item['menu_title']
|
9683 |
+
);
|
9684 |
+
|
9685 |
+
$menu_slug = $this->_menu->get_slug( $item['menu_slug'] );
|
9686 |
+
|
9687 |
+
if ( ! isset( $item['url'] ) ) {
|
9688 |
+
$hook = FS_Admin_Menu_Manager::add_subpage(
|
9689 |
+
$item['show_submenu'] ?
|
9690 |
+
$this->get_top_level_menu_slug() :
|
9691 |
+
null,
|
9692 |
+
$item['page_title'],
|
9693 |
+
$menu_item,
|
9694 |
+
$capability,
|
9695 |
+
$menu_slug,
|
9696 |
+
$item['render_function']
|
9697 |
+
);
|
9698 |
+
|
9699 |
+
if ( false !== $item['before_render_function'] ) {
|
9700 |
+
add_action( "load-$hook", $item['before_render_function'] );
|
9701 |
+
}
|
9702 |
+
} else {
|
9703 |
+
FS_Admin_Menu_Manager::add_subpage(
|
9704 |
+
$item['show_submenu'] ?
|
9705 |
+
$this->get_top_level_menu_slug() :
|
9706 |
+
null,
|
9707 |
+
$item['page_title'],
|
9708 |
+
$menu_item,
|
9709 |
+
$capability,
|
9710 |
+
$menu_slug,
|
9711 |
+
array( $this, '' )
|
9712 |
+
);
|
9713 |
+
}
|
9714 |
+
}
|
9715 |
+
}
|
9716 |
+
}
|
9717 |
+
|
9718 |
+
/**
|
9719 |
+
* Re-order the submenu items so all Freemius added new submenu items
|
9720 |
+
* are added right after the plugin's settings submenu item.
|
9721 |
+
*
|
9722 |
+
* @author Vova Feldman (@svovaf)
|
9723 |
+
* @since 1.1.4
|
9724 |
+
*/
|
9725 |
+
private function order_sub_submenu_items() {
|
9726 |
+
global $submenu;
|
9727 |
+
|
9728 |
+
$menu_slug = $this->_menu->get_top_level_menu_slug();
|
9729 |
+
|
9730 |
+
/**
|
9731 |
+
* Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
|
9732 |
+
* does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
|
9733 |
+
* of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
|
9734 |
+
* Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
|
9735 |
+
*
|
9736 |
+
* In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
|
9737 |
+
* of another plugin, only users that have the right role can access its sub-submenus since we will use the
|
9738 |
+
* capability needed to access the parent menu as the capability for the submenus that we will add.
|
9739 |
+
*/
|
9740 |
+
if ( empty( $submenu[ $menu_slug ] ) ) {
|
9741 |
+
return;
|
9742 |
+
}
|
9743 |
+
|
9744 |
+
$top_level_menu = &$submenu[ $menu_slug ];
|
9745 |
+
|
9746 |
+
$all_submenu_items_after = array();
|
9747 |
+
|
9748 |
+
$found_submenu_item = false;
|
9749 |
+
|
9750 |
+
foreach ( $top_level_menu as $submenu_id => $meta ) {
|
9751 |
+
if ( $found_submenu_item ) {
|
9752 |
+
// Remove all submenu items after the plugin's submenu item.
|
9753 |
+
$all_submenu_items_after[] = $meta;
|
9754 |
+
unset( $top_level_menu[ $submenu_id ] );
|
9755 |
+
}
|
9756 |
+
|
9757 |
+
if ( $this->_menu->get_raw_slug() === $meta[2] ) {
|
9758 |
+
// Found the submenu item, put all below.
|
9759 |
+
$found_submenu_item = true;
|
9760 |
+
continue;
|
9761 |
+
}
|
9762 |
+
}
|
9763 |
+
|
9764 |
+
// Embed all plugin's new submenu items.
|
9765 |
+
$this->embed_submenu_items();
|
9766 |
+
|
9767 |
+
// Start with specially high number to make sure it's appended.
|
9768 |
+
$i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
|
9769 |
+
foreach ( $all_submenu_items_after as $meta ) {
|
9770 |
+
$top_level_menu[ $i ] = $meta;
|
9771 |
+
$i ++;
|
9772 |
+
}
|
9773 |
+
|
9774 |
+
// Sort submenu items.
|
9775 |
+
ksort( $top_level_menu );
|
9776 |
+
}
|
9777 |
+
|
9778 |
+
/**
|
9779 |
+
* Helper method to return the module's support forum URL.
|
9780 |
+
*
|
9781 |
+
* @author Vova Feldman (@svovaf)
|
9782 |
+
* @since 1.2.2.7
|
9783 |
+
*
|
9784 |
+
* @return string
|
9785 |
+
*/
|
9786 |
+
function get_support_forum_url() {
|
9787 |
+
return $this->apply_filters( 'support_forum_url', "https://wordpress.org/support/{$this->_module_type}/{$this->_slug}" );
|
9788 |
+
}
|
9789 |
+
|
9790 |
+
/**
|
9791 |
+
* Displays the Support Forum link when enabled.
|
9792 |
+
*
|
9793 |
+
* Can be filtered like so:
|
9794 |
+
*
|
9795 |
+
* function _fs_show_support_menu( $is_visible, $menu_id ) {
|
9796 |
+
* if ( 'support' === $menu_id ) {
|
9797 |
+
* return _fs->is_registered();
|
9798 |
+
* }
|
9799 |
+
* return $is_visible;
|
9800 |
+
* }
|
9801 |
+
* _fs()->add_filter('is_submenu_visible', '_fs_show_support_menu', 10, 2);
|
9802 |
+
*
|
9803 |
+
*/
|
9804 |
+
function _add_default_submenu_items() {
|
9805 |
+
if ( ! $this->is_on() ) {
|
9806 |
+
return;
|
9807 |
+
}
|
9808 |
+
|
9809 |
+
if ( ! $this->is_activation_mode() ) {
|
9810 |
+
$this->add_submenu_link_item(
|
9811 |
+
$this->apply_filters( 'support_forum_submenu', $this->get_text_inline( 'Support Forum', 'support-forum' ) ),
|
9812 |
+
$this->get_support_forum_url(),
|
9813 |
+
'wp-support-forum',
|
9814 |
+
null,
|
9815 |
+
50,
|
9816 |
+
$this->is_submenu_item_visible( 'support' )
|
9817 |
+
);
|
9818 |
+
}
|
9819 |
+
}
|
9820 |
+
|
9821 |
+
/**
|
9822 |
+
* @author Vova Feldman (@svovaf)
|
9823 |
+
* @since 1.0.1
|
9824 |
+
*
|
9825 |
+
* @param string $menu_title
|
9826 |
+
* @param callable $render_function
|
9827 |
+
* @param bool|string $page_title
|
9828 |
+
* @param string $capability
|
9829 |
+
* @param bool|string $menu_slug
|
9830 |
+
* @param bool|callable $before_render_function
|
9831 |
+
* @param int $priority
|
9832 |
+
* @param bool $show_submenu
|
9833 |
+
* @param string $class Since 1.2.1.5 can add custom classes to menu items.
|
9834 |
+
*/
|
9835 |
+
function add_submenu_item(
|
9836 |
+
$menu_title,
|
9837 |
+
$render_function,
|
9838 |
+
$page_title = false,
|
9839 |
+
$capability = 'manage_options',
|
9840 |
+
$menu_slug = false,
|
9841 |
+
$before_render_function = false,
|
9842 |
+
$priority = WP_FS__DEFAULT_PRIORITY,
|
9843 |
+
$show_submenu = true,
|
9844 |
+
$class = ''
|
9845 |
+
) {
|
9846 |
+
$this->_logger->entrance( 'Title = ' . $menu_title );
|
9847 |
+
|
9848 |
+
if ( $this->is_addon() ) {
|
9849 |
+
$parent_fs = $this->get_parent_instance();
|
9850 |
+
|
9851 |
+
if ( is_object( $parent_fs ) ) {
|
9852 |
+
$parent_fs->add_submenu_item(
|
9853 |
+
$menu_title,
|
9854 |
+
$render_function,
|
9855 |
+
$page_title,
|
9856 |
+
$capability,
|
9857 |
+
$menu_slug,
|
9858 |
+
$before_render_function,
|
9859 |
+
$priority,
|
9860 |
+
$show_submenu,
|
9861 |
+
$class
|
9862 |
+
);
|
9863 |
+
|
9864 |
+
return;
|
9865 |
+
}
|
9866 |
+
}
|
9867 |
+
|
9868 |
+
if ( ! isset( $this->_menu_items[ $priority ] ) ) {
|
9869 |
+
$this->_menu_items[ $priority ] = array();
|
9870 |
+
}
|
9871 |
+
|
9872 |
+
$this->_menu_items[ $priority ][] = array(
|
9873 |
+
'page_title' => is_string( $page_title ) ? $page_title : $menu_title,
|
9874 |
+
'menu_title' => $menu_title,
|
9875 |
+
'capability' => $capability,
|
9876 |
+
'menu_slug' => is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ),
|
9877 |
+
'render_function' => $render_function,
|
9878 |
+
'before_render_function' => $before_render_function,
|
9879 |
+
'show_submenu' => $show_submenu,
|
9880 |
+
'class' => $class,
|
9881 |
+
);
|
9882 |
+
}
|
9883 |
+
|
9884 |
+
/**
|
9885 |
+
* @author Vova Feldman (@svovaf)
|
9886 |
+
* @since 1.0.1
|
9887 |
+
*
|
9888 |
+
* @param string $menu_title
|
9889 |
+
* @param string $url
|
9890 |
+
* @param bool $menu_slug
|
9891 |
+
* @param string $capability
|
9892 |
+
* @param int $priority
|
9893 |
+
* @param bool $show_submenu
|
9894 |
+
*/
|
9895 |
+
function add_submenu_link_item(
|
9896 |
+
$menu_title,
|
9897 |
+
$url,
|
9898 |
+
$menu_slug = false,
|
9899 |
+
$capability = 'read',
|
9900 |
+
$priority = WP_FS__DEFAULT_PRIORITY,
|
9901 |
+
$show_submenu = true
|
9902 |
+
) {
|
9903 |
+
$this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
|
9904 |
+
|
9905 |
+
if ( $this->is_addon() ) {
|
9906 |
+
$parent_fs = $this->get_parent_instance();
|
9907 |
+
|
9908 |
+
if ( is_object( $parent_fs ) ) {
|
9909 |
+
$parent_fs->add_submenu_link_item(
|
9910 |
+
$menu_title,
|
9911 |
+
$url,
|
9912 |
+
$menu_slug,
|
9913 |
+
$capability,
|
9914 |
+
$priority,
|
9915 |
+
$show_submenu
|
9916 |
+
);
|
9917 |
+
|
9918 |
+
return;
|
9919 |
+
}
|
9920 |
+
}
|
9921 |
+
|
9922 |
+
if ( ! isset( $this->_menu_items[ $priority ] ) ) {
|
9923 |
+
$this->_menu_items[ $priority ] = array();
|
9924 |
+
}
|
9925 |
+
|
9926 |
+
$this->_menu_items[ $priority ][] = array(
|
9927 |
+
'menu_title' => $menu_title,
|
9928 |
+
'capability' => $capability,
|
9929 |
+
'menu_slug' => is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ),
|
9930 |
+
'url' => $url,
|
9931 |
+
'page_title' => $menu_title,
|
9932 |
+
'render_function' => 'fs_dummy',
|
9933 |
+
'before_render_function' => '',
|
9934 |
+
'show_submenu' => $show_submenu,
|
9935 |
+
);
|
9936 |
+
}
|
9937 |
+
|
9938 |
+
#endregion ------------------------------------------------------------------
|
9939 |
+
|
9940 |
+
|
9941 |
+
#--------------------------------------------------------------------------------
|
9942 |
+
#region Actions / Hooks / Filters
|
9943 |
+
#--------------------------------------------------------------------------------
|
9944 |
+
|
9945 |
+
/**
|
9946 |
+
* @author Vova Feldman (@svovaf)
|
9947 |
+
* @since 1.1.7
|
9948 |
+
*
|
9949 |
+
* @param string $tag
|
9950 |
+
*
|
9951 |
+
* @return string
|
9952 |
+
*/
|
9953 |
+
public function get_action_tag( $tag ) {
|
9954 |
+
return self::get_action_tag_static( $tag, $this->_slug, $this->is_plugin() );
|
9955 |
+
}
|
9956 |
+
|
9957 |
+
/**
|
9958 |
+
* @author Vova Feldman (@svovaf)
|
9959 |
+
* @since 1.2.1.6
|
9960 |
+
*
|
9961 |
+
* @param string $tag
|
9962 |
+
* @param string $slug
|
9963 |
+
* @param bool $is_plugin
|
9964 |
+
*
|
9965 |
+
* @return string
|
9966 |
+
*/
|
9967 |
+
static function get_action_tag_static( $tag, $slug = '', $is_plugin = true ) {
|
9968 |
+
$action = "fs_{$tag}";
|
9969 |
+
|
9970 |
+
if ( ! empty( $slug ) ) {
|
9971 |
+
$action .= '_' . self::get_module_unique_affix( $slug, $is_plugin );
|
9972 |
+
}
|
9973 |
+
|
9974 |
+
return $action;
|
9975 |
+
}
|
9976 |
+
|
9977 |
+
/**
|
9978 |
+
* Returns a string that can be used to generate a unique action name,
|
9979 |
+
* option name, HTML element ID, or HTML element class.
|
9980 |
+
*
|
9981 |
+
* @author Leo Fajardo (@leorw)
|
9982 |
+
* @since 1.2.2
|
9983 |
+
*
|
9984 |
+
* @return string
|
9985 |
+
*/
|
9986 |
+
public function get_unique_affix() {
|
9987 |
+
return self::get_module_unique_affix( $this->_slug, $this->is_plugin() );
|
9988 |
+
}
|
9989 |
+
|
9990 |
+
/**
|
9991 |
+
* Returns a string that can be used to generate a unique action name,
|
9992 |
+
* option name, HTML element ID, or HTML element class.
|
9993 |
+
*
|
9994 |
+
* @author Vova Feldman (@svovaf)
|
9995 |
+
* @since 1.2.2.5
|
9996 |
+
*
|
9997 |
+
* @param string $slug
|
9998 |
+
* @param bool $is_plugin
|
9999 |
+
*
|
10000 |
+
* @return string
|
10001 |
+
*/
|
10002 |
+
static function get_module_unique_affix( $slug, $is_plugin = true ) {
|
10003 |
+
$affix = $slug;
|
10004 |
+
|
10005 |
+
if ( ! $is_plugin ) {
|
10006 |
+
$affix .= '-' . WP_FS__MODULE_TYPE_THEME;
|
10007 |
+
}
|
10008 |
+
|
10009 |
+
return $affix;
|
10010 |
+
}
|
10011 |
+
|
10012 |
+
/**
|
10013 |
+
* @author Vova Feldman (@svovaf)
|
10014 |
+
* @since 1.2.1
|
10015 |
+
* @since 1.2.2.5 The AJAX action names are based on the module ID, not like the non-AJAX actions that are
|
10016 |
+
* based on the slug for backward compatibility.
|
10017 |
+
*
|
10018 |
+
* @param string $tag
|
10019 |
+
*
|
10020 |
+
* @return string
|
10021 |
+
*/
|
10022 |
+
function get_ajax_action( $tag ) {
|
10023 |
+
return self::get_ajax_action_static( $tag, $this->_module_id );
|
10024 |
+
}
|
10025 |
+
|
10026 |
+
/**
|
10027 |
+
* @author Vova Feldman (@svovaf)
|
10028 |
+
* @since 1.2.1.7
|
10029 |
+
*
|
10030 |
+
* @param string $tag
|
10031 |
+
*
|
10032 |
+
* @return string
|
10033 |
+
*/
|
10034 |
+
function get_ajax_security( $tag ) {
|
10035 |
+
return wp_create_nonce( $this->get_ajax_action( $tag ) );
|
10036 |
+
}
|
10037 |
+
|
10038 |
+
/**
|
10039 |
+
* @author Vova Feldman (@svovaf)
|
10040 |
+
* @since 1.2.1.7
|
10041 |
+
*
|
10042 |
+
* @param string $tag
|
10043 |
+
*/
|
10044 |
+
function check_ajax_referer( $tag ) {
|
10045 |
+
check_ajax_referer( $this->get_ajax_action( $tag ), 'security' );
|
10046 |
+
}
|
10047 |
+
|
10048 |
+
/**
|
10049 |
+
* @author Vova Feldman (@svovaf)
|
10050 |
+
* @since 1.2.1.6
|
10051 |
+
* @since 1.2.2.5 The AJAX action names are based on the module ID, not like the non-AJAX actions that are
|
10052 |
+
* based on the slug for backward compatibility.
|
10053 |
+
*
|
10054 |
+
* @param string $tag
|
10055 |
+
* @param number|null $module_id
|
10056 |
+
*
|
10057 |
+
* @return string
|
10058 |
+
*/
|
10059 |
+
private static function get_ajax_action_static( $tag, $module_id = null ) {
|
10060 |
+
$action = "fs_{$tag}";
|
10061 |
+
|
10062 |
+
if ( ! empty( $module_id ) ) {
|
10063 |
+
$action .= "_{$module_id}";
|
10064 |
+
}
|
10065 |
+
|
10066 |
+
return $action;
|
10067 |
+
}
|
10068 |
+
|
10069 |
+
/**
|
10070 |
+
* Do action, specific for the current context plugin.
|
10071 |
+
*
|
10072 |
+
* @author Vova Feldman (@svovaf)
|
10073 |
+
* @since 1.0.1
|
10074 |
+
*
|
10075 |
+
* @param string $tag The name of the action to be executed.
|
10076 |
+
* @param mixed $arg,... Optional. Additional arguments which are passed on to the
|
10077 |
+
* functions hooked to the action. Default empty.
|
10078 |
+
*
|
10079 |
+
* @uses do_action()
|
10080 |
+
*/
|
10081 |
+
function do_action( $tag, $arg = '' ) {
|
10082 |
+
$this->_logger->entrance( $tag );
|
10083 |
+
|
10084 |
+
$args = func_get_args();
|
10085 |
+
|
10086 |
+
call_user_func_array( 'do_action', array_merge(
|
10087 |
+
array( $this->get_action_tag( $tag ) ),
|
10088 |
+
array_slice( $args, 1 ) )
|
10089 |
+
);
|
10090 |
+
}
|
10091 |
+
|
10092 |
+
/**
|
10093 |
+
* Add action, specific for the current context plugin.
|
10094 |
+
*
|
10095 |
+
* @author Vova Feldman (@svovaf)
|
10096 |
+
* @since 1.0.1
|
10097 |
+
*
|
10098 |
+
* @param string $tag
|
10099 |
+
* @param callable $function_to_add
|
10100 |
+
* @param int $priority
|
10101 |
+
* @param int $accepted_args
|
10102 |
+
*
|
10103 |
+
* @uses add_action()
|
10104 |
+
*/
|
10105 |
+
function add_action(
|
10106 |
+
$tag,
|
10107 |
+
$function_to_add,
|
10108 |
+
$priority = WP_FS__DEFAULT_PRIORITY,
|
10109 |
+
$accepted_args = 1
|
10110 |
+
) {
|
10111 |
+
$this->_logger->entrance( $tag );
|
10112 |
+
|
10113 |
+
add_action( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
|
10114 |
+
}
|
10115 |
+
|
10116 |
+
/**
|
10117 |
+
* Add AJAX action, specific for the current context plugin.
|
10118 |
+
*
|
10119 |
+
* @author Vova Feldman (@svovaf)
|
10120 |
+
* @since 1.2.1
|
10121 |
+
*
|
10122 |
+
* @param string $tag
|
10123 |
+
* @param callable $function_to_add
|
10124 |
+
* @param int $priority
|
10125 |
+
*
|
10126 |
+
* @uses add_action()
|
10127 |
+
*
|
10128 |
+
* @return bool True if action added, false if no need to add the action since the AJAX call isn't matching.
|
10129 |
+
*/
|
10130 |
+
function add_ajax_action(
|
10131 |
+
$tag,
|
10132 |
+
$function_to_add,
|
10133 |
+
$priority = WP_FS__DEFAULT_PRIORITY
|
10134 |
+
) {
|
10135 |
+
$this->_logger->entrance( $tag );
|
10136 |
+
|
10137 |
+
return self::add_ajax_action_static(
|
10138 |
+
$tag,
|
10139 |
+
$function_to_add,
|
10140 |
+
$priority,
|
10141 |
+
$this->_module_id
|
10142 |
+
);
|
10143 |
+
}
|
10144 |
+
|
10145 |
+
/**
|
10146 |
+
* Add AJAX action.
|
10147 |
+
*
|
10148 |
+
* @author Vova Feldman (@svovaf)
|
10149 |
+
* @since 1.2.1.6
|
10150 |
+
*
|
10151 |
+
* @param string $tag
|
10152 |
+
* @param callable $function_to_add
|
10153 |
+
* @param int $priority
|
10154 |
+
* @param number|null $module_id
|
10155 |
+
*
|
10156 |
+
* @return bool True if action added, false if no need to add the action since the AJAX call isn't matching.
|
10157 |
+
* @uses add_action()
|
10158 |
+
*
|
10159 |
+
*/
|
10160 |
+
static function add_ajax_action_static(
|
10161 |
+
$tag,
|
10162 |
+
$function_to_add,
|
10163 |
+
$priority = WP_FS__DEFAULT_PRIORITY,
|
10164 |
+
$module_id = null
|
10165 |
+
) {
|
10166 |
+
self::$_static_logger->entrance( $tag );
|
10167 |
+
|
10168 |
+
if ( ! self::is_ajax_action_static( $tag, $module_id ) ) {
|
10169 |
+
return false;
|
10170 |
+
}
|
10171 |
+
|
10172 |
+
add_action(
|
10173 |
+
'wp_ajax_' . self::get_ajax_action_static( $tag, $module_id ),
|
10174 |
+
$function_to_add,
|
10175 |
+
$priority,
|
10176 |
+
0
|
10177 |
+
);
|
10178 |
+
|
10179 |
+
self::$_static_logger->info( "$tag AJAX callback action added." );
|
10180 |
+
|
10181 |
+
return true;
|
10182 |
+
}
|
10183 |
+
|
10184 |
+
/**
|
10185 |
+
* Send a JSON response back to an Ajax request.
|
10186 |
+
*
|
10187 |
+
* @author Vova Feldman (@svovaf)
|
10188 |
+
* @since 1.2.1.5
|
10189 |
+
*
|
10190 |
+
* @param mixed $response
|
10191 |
+
*/
|
10192 |
+
static function shoot_ajax_response( $response ) {
|
10193 |
+
wp_send_json( $response );
|
10194 |
+
}
|
10195 |
+
|
10196 |
+
/**
|
10197 |
+
* Send a JSON response back to an Ajax request, indicating success.
|
10198 |
+
*
|
10199 |
+
* @author Vova Feldman (@svovaf)
|
10200 |
+
* @since 1.2.1.5
|
10201 |
+
*
|
10202 |
+
* @param mixed $data Data to encode as JSON, then print and exit.
|
10203 |
+
*/
|
10204 |
+
static function shoot_ajax_success( $data = null ) {
|
10205 |
+
wp_send_json_success( $data );
|
10206 |
+
}
|
10207 |
+
|
10208 |
+
/**
|
10209 |
+
* Send a JSON response back to an Ajax request, indicating failure.
|
10210 |
+
*
|
10211 |
+
* @author Vova Feldman (@svovaf)
|
10212 |
+
* @since 1.2.1.5
|
10213 |
+
*
|
10214 |
+
* @param mixed $error Optional error message.
|
10215 |
+
*/
|
10216 |
+
static function shoot_ajax_failure( $error = '' ) {
|
10217 |
+
$result = array( 'success' => false );
|
10218 |
+
if ( ! empty( $error ) ) {
|
10219 |
+
$result['error'] = $error;
|
10220 |
+
}
|
10221 |
+
|
10222 |
+
wp_send_json( $result );
|
10223 |
+
}
|
10224 |
+
|
10225 |
+
/**
|
10226 |
+
* Apply filter, specific for the current context plugin.
|
10227 |
+
*
|
10228 |
+
* @author Vova Feldman (@svovaf)
|
10229 |
+
* @since 1.0.9
|
10230 |
+
*
|
10231 |
+
* @param string $tag The name of the filter hook.
|
10232 |
+
* @param mixed $value The value on which the filters hooked to `$tag` are applied on.
|
10233 |
+
*
|
10234 |
+
* @return mixed The filtered value after all hooked functions are applied to it.
|
10235 |
+
*
|
10236 |
+
* @uses apply_filters()
|
10237 |
+
*/
|
10238 |
+
function apply_filters( $tag, $value ) {
|
10239 |
+
$this->_logger->entrance( $tag );
|
10240 |
+
|
10241 |
+
$args = func_get_args();
|
10242 |
+
array_unshift( $args, $this->get_unique_affix() );
|
10243 |
+
|
10244 |
+
return call_user_func_array( 'fs_apply_filter', $args );
|
10245 |
+
}
|
10246 |
+
|
10247 |
+
/**
|
10248 |
+
* Add filter, specific for the current context plugin.
|
10249 |
+
*
|
10250 |
+
* @author Vova Feldman (@svovaf)
|
10251 |
+
* @since 1.0.9
|
10252 |
+
*
|
10253 |
+
* @param string $tag
|
10254 |
+
* @param callable $function_to_add
|
10255 |
+
* @param int $priority
|
10256 |
+
* @param int $accepted_args
|
10257 |
+
*
|
10258 |
+
* @uses add_filter()
|
10259 |
+
*/
|
10260 |
+
function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
|
10261 |
+
$this->_logger->entrance( $tag );
|
10262 |
+
|
10263 |
+
add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
|
10264 |
+
}
|
10265 |
+
|
10266 |
+
/**
|
10267 |
+
* Check if has filter.
|
10268 |
+
*
|
10269 |
+
* @author Vova Feldman (@svovaf)
|
10270 |
+
* @since 1.1.4
|
10271 |
+
*
|
10272 |
+
* @param string $tag
|
10273 |
+
* @param callable|bool $function_to_check Optional. The callback to check for. Default false.
|
10274 |
+
*
|
10275 |
+
* @return false|int
|
10276 |
+
*
|
10277 |
+
* @uses has_filter()
|
10278 |
+
*/
|
10279 |
+
function has_filter( $tag, $function_to_check = false ) {
|
10280 |
+
$this->_logger->entrance( $tag );
|
10281 |
+
|
10282 |
+
return has_filter( $this->get_action_tag( $tag ), $function_to_check );
|
10283 |
+
}
|
10284 |
+
|
10285 |
+
#endregion
|
10286 |
+
|
10287 |
+
/**
|
10288 |
+
* Override default i18n text phrases.
|
10289 |
+
*
|
10290 |
+
* @author Vova Feldman (@svovaf)
|
10291 |
+
* @since 1.1.6
|
10292 |
+
*
|
10293 |
+
* @param string[] string $key_value
|
10294 |
+
*
|
10295 |
+
* @uses fs_override_i18n()
|
10296 |
+
*/
|
10297 |
+
function override_i18n( $key_value ) {
|
10298 |
+
fs_override_i18n( $key_value, $this->_slug );
|
10299 |
+
}
|
10300 |
+
|
10301 |
+
/* Account Page
|
10302 |
+
------------------------------------------------------------------------------------------------------------------*/
|
10303 |
+
/**
|
10304 |
+
* Update site information.
|
10305 |
+
*
|
10306 |
+
* @author Vova Feldman (@svovaf)
|
10307 |
+
* @since 1.0.1
|
10308 |
+
*
|
10309 |
+
* @param bool $store Flush to Database if true.
|
10310 |
+
*/
|
10311 |
+
private function _store_site( $store = true ) {
|
10312 |
+
$this->_logger->entrance();
|
10313 |
+
|
10314 |
+
if ( empty( $this->_site->id ) ) {
|
10315 |
+
$this->_logger->error( "Empty install ID, can't store site." );
|
10316 |
+
|
10317 |
+
return;
|
10318 |
+
}
|
10319 |
+
|
10320 |
+
$encrypted_site = clone $this->_site;
|
10321 |
+
$encrypted_site->plan = self::_encrypt_entity( $this->_site->plan );
|
10322 |
+
|
10323 |
+
$sites = self::get_all_sites( $this->_module_type );
|
10324 |
+
|
10325 |
+
if ( empty( $this->_storage->prev_user_id ) && $this->_user->id != $this->_site->user_id ) {
|
10326 |
+
/**
|
10327 |
+
* Store the current user ID as the previous user ID so that the previous user can be used
|
10328 |
+
* as the install's owner while the new owner's details are not yet available.
|
10329 |
+
*
|
10330 |
+
* This will be executed only in the `replica` site. For example, there are 2 sites, namely `original`
|
10331 |
+
* and `replica`, then an ownership change was initiated and completed in the `original`, the `replica`
|
10332 |
+
* will be using the previous user until it is updated again (e.g.: until the next clone of `original`
|
10333 |
+
* into `replica`.
|
10334 |
+
*
|
10335 |
+
* @author Leo Fajardo (@leorw)
|
10336 |
+
*/
|
10337 |
+
$this->_storage->prev_user_id = $sites[ $this->_slug ]->user_id;
|
10338 |
+
}
|
10339 |
+
|
10340 |
+
$sites[ $this->_slug ] = $encrypted_site;
|
10341 |
+
|
10342 |
+
$this->set_account_option( 'sites', $sites, $store );
|
10343 |
+
}
|
10344 |
+
|
10345 |
+
/**
|
10346 |
+
* Update plugin's plans information.
|
10347 |
+
*
|
10348 |
+
* @author Vova Feldman (@svovaf)
|
10349 |
+
* @since 1.0.2
|
10350 |
+
*
|
10351 |
+
* @param bool $store Flush to Database if true.
|
10352 |
+
*/
|
10353 |
+
private function _store_plans( $store = true ) {
|
10354 |
+
$this->_logger->entrance();
|
10355 |
+
|
10356 |
+
$plans = self::get_all_plans( $this->_module_type );
|
10357 |
+
|
10358 |
+
// Copy plans.
|
10359 |
+
$encrypted_plans = array();
|
10360 |
+
for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
|
10361 |
+
$encrypted_plans[] = self::_encrypt_entity( $this->_plans[ $i ] );
|
10362 |
+
}
|
10363 |
+
|
10364 |
+
$plans[ $this->_slug ] = $encrypted_plans;
|
10365 |
+
|
10366 |
+
$this->set_account_option( 'plans', $plans, $store );
|
10367 |
+
}
|
10368 |
+
|
10369 |
+
/**
|
10370 |
+
* Update user's plugin licenses.
|
10371 |
+
*
|
10372 |
+
* @author Vova Feldman (@svovaf)
|
10373 |
+
* @since 1.0.5
|
10374 |
+
*
|
10375 |
+
* @param bool $store
|
10376 |
+
* @param string|bool $plugin_slug
|
10377 |
+
* @param FS_Plugin_License[] $licenses
|
10378 |
+
*/
|
10379 |
+
private function _store_licenses( $store = true, $plugin_slug = false, $licenses = array() ) {
|
10380 |
+
$this->_logger->entrance();
|
10381 |
+
|
10382 |
+
$all_licenses = self::get_all_licenses( $this->_module_type );
|
10383 |
+
|
10384 |
+
if ( ! is_string( $plugin_slug ) ) {
|
10385 |
+
$plugin_slug = $this->_slug;
|
10386 |
+
$licenses = $this->_licenses;
|
10387 |
+
}
|
10388 |
+
|
10389 |
+
if ( ! isset( $all_licenses[ $plugin_slug ] ) ) {
|
10390 |
+
$all_licenses[ $plugin_slug ] = array();
|
10391 |
+
}
|
10392 |
+
|
10393 |
+
$all_licenses[ $plugin_slug ][ $this->_user->id ] = $licenses;
|
10394 |
+
|
10395 |
+
$this->set_account_option( 'licenses', $all_licenses, $store );
|
10396 |
+
}
|
10397 |
+
|
10398 |
+
/**
|
10399 |
+
* Update user information.
|
10400 |
+
*
|
10401 |
+
* @author Vova Feldman (@svovaf)
|
10402 |
+
* @since 1.0.1
|
10403 |
+
*
|
10404 |
+
* @param bool $store Flush to Database if true.
|
10405 |
+
*/
|
10406 |
+
private function _store_user( $store = true ) {
|
10407 |
+
$this->_logger->entrance();
|
10408 |
+
|
10409 |
+
if ( empty( $this->_user->id ) ) {
|
10410 |
+
$this->_logger->error( "Empty user ID, can't store user." );
|
10411 |
+
|
10412 |
+
return;
|
10413 |
+
}
|
10414 |
+
|
10415 |
+
$users = self::get_all_users();
|
10416 |
+
$users[ $this->_user->id ] = $this->_user;
|
10417 |
+
self::$_accounts->set_option( 'users', $users, $store );
|
10418 |
+
}
|
10419 |
+
|
10420 |
+
/**
|
10421 |
+
* Update new updates information.
|
10422 |
+
*
|
10423 |
+
* @author Vova Feldman (@svovaf)
|
10424 |
+
* @since 1.0.4
|
10425 |
+
*
|
10426 |
+
* @param FS_Plugin_Tag|null $update
|
10427 |
+
* @param bool $store Flush to Database if true.
|
10428 |
+
* @param bool|number $plugin_id
|
10429 |
+
*/
|
10430 |
+
private function _store_update( $update, $store = true, $plugin_id = false ) {
|
10431 |
+
$this->_logger->entrance();
|
10432 |
+
|
10433 |
+
if ( $update instanceof FS_Plugin_Tag ) {
|
10434 |
+
$update->updated = time();
|
10435 |
+
}
|
10436 |
+
|
10437 |
+
if ( ! is_numeric( $plugin_id ) ) {
|
10438 |
+
$plugin_id = $this->_plugin->id;
|
10439 |
+
}
|
10440 |
+
|
10441 |
+
$updates = self::get_all_updates();
|
10442 |
+
$updates[ $plugin_id ] = $update;
|
10443 |
+
self::$_accounts->set_option( 'updates', $updates, $store );
|
10444 |
+
}
|
10445 |
+
|
10446 |
+
/**
|
10447 |
+
* Update new updates information.
|
10448 |
+
*
|
10449 |
+
* @author Vova Feldman (@svovaf)
|
10450 |
+
* @since 1.0.6
|
10451 |
+
*
|
10452 |
+
* @param FS_Plugin[] $plugin_addons
|
10453 |
+
* @param bool $store Flush to Database if true.
|
10454 |
+
*/
|
10455 |
+
private function _store_addons( $plugin_addons, $store = true ) {
|
10456 |
+
$this->_logger->entrance();
|
10457 |
+
|
10458 |
+
$addons = self::get_all_addons();
|
10459 |
+
$addons[ $this->_plugin->id ] = $plugin_addons;
|
10460 |
+
self::$_accounts->set_option( 'addons', $addons, $store );
|
10461 |
+
}
|
10462 |
+
|
10463 |
+
/**
|
10464 |
+
* Delete plugin's associated add-ons.
|
10465 |
+
*
|
10466 |
+
* @author Vova Feldman (@svovaf)
|
10467 |
+
* @since 1.0.8
|
10468 |
+
*
|
10469 |
+
* @param bool $store
|
10470 |
+
*
|
10471 |
+
* @return bool
|
10472 |
+
*/
|
10473 |
+
private function _delete_account_addons( $store = true ) {
|
10474 |
+
$all_addons = self::get_all_account_addons();
|
10475 |
+
|
10476 |
+
if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) {
|
10477 |
+
return false;
|
10478 |
+
}
|
10479 |
+
|
10480 |
+
unset( $all_addons[ $this->_plugin->id ] );
|
10481 |
+
|
10482 |
+
self::$_accounts->set_option( 'account_addons', $all_addons, $store );
|
10483 |
+
|
10484 |
+
return true;
|
10485 |
+
}
|
10486 |
+
|
10487 |
+
/**
|
10488 |
+
* Update account add-ons list.
|
10489 |
+
*
|
10490 |
+
* @author Vova Feldman (@svovaf)
|
10491 |
+
* @since 1.0.6
|
10492 |
+
*
|
10493 |
+
* @param FS_Plugin[] $addons
|
10494 |
+
* @param bool $store Flush to Database if true.
|
10495 |
+
*/
|
10496 |
+
private function _store_account_addons( $addons, $store = true ) {
|
10497 |
+
$this->_logger->entrance();
|
10498 |
+
|
10499 |
+
$all_addons = self::get_all_account_addons();
|
10500 |
+
$all_addons[ $this->_plugin->id ] = $addons;
|
10501 |
+
self::$_accounts->set_option( 'account_addons', $all_addons, $store );
|
10502 |
+
}
|
10503 |
+
|
10504 |
+
/**
|
10505 |
+
* Store account params in the Database.
|
10506 |
+
*
|
10507 |
+
* @author Vova Feldman (@svovaf)
|
10508 |
+
* @since 1.0.1
|
10509 |
+
*/
|
10510 |
+
private function _store_account() {
|
10511 |
+
$this->_logger->entrance();
|
10512 |
+
|
10513 |
+
$this->_store_site( false );
|
10514 |
+
$this->_store_user( false );
|
10515 |
+
$this->_store_plans( false );
|
10516 |
+
$this->_store_licenses( false );
|
10517 |
+
|
10518 |
+
self::$_accounts->store();
|
10519 |
+
}
|
10520 |
+
|
10521 |
+
/**
|
10522 |
+
* Sync user's information.
|
10523 |
+
*
|
10524 |
+
* @author Vova Feldman (@svovaf)
|
10525 |
+
* @since 1.0.3
|
10526 |
+
* @uses FS_Api
|
10527 |
+
*/
|
10528 |
+
private function _handle_account_user_sync() {
|
10529 |
+
$this->_logger->entrance();
|
10530 |
+
|
10531 |
+
$api = $this->get_api_user_scope();
|
10532 |
+
|
10533 |
+
// Get user's information.
|
10534 |
+
$user = $api->get( '/', true );
|
10535 |
+
|
10536 |
+
if ( isset( $user->id ) ) {
|
10537 |
+
$this->_user->first = $user->first;
|
10538 |
+
$this->_user->last = $user->last;
|
10539 |
+
$this->_user->email = $user->email;
|
10540 |
+
|
10541 |
+
$is_menu_item_account_visible = $this->is_submenu_item_visible( 'account' );
|
10542 |
+
|
10543 |
+
if ( $user->is_verified &&
|
10544 |
+
( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified )
|
10545 |
+
) {
|
10546 |
+
$this->_user->is_verified = true;
|
10547 |
+
|
10548 |
+
$this->do_action( 'account_email_verified', $user->email );
|
10549 |
+
|
10550 |
+
$this->_admin_notices->add(
|
10551 |
+
$this->get_text_inline( 'Your email has been successfully verified - you are AWESOME!', 'email-verified-message' ),
|
10552 |
+
$this->get_text_x_inline( 'Right on', 'a positive response', 'right-on' ) . '!',
|
10553 |
+
'success',
|
10554 |
+
// Make admin sticky if account menu item is invisible,
|
10555 |
+
// since the page will be auto redirected to the plugin's
|
10556 |
+
// main settings page, and the non-sticky message
|
10557 |
+
// will disappear.
|
10558 |
+
! $is_menu_item_account_visible,
|
10559 |
+
false,
|
10560 |
+
'email_verified'
|
10561 |
+
);
|
10562 |
+
}
|
10563 |
+
|
10564 |
+
// Flush user details to DB.
|
10565 |
+
$this->_store_user();
|
10566 |
+
|
10567 |
+
$this->do_action( 'after_account_user_sync', $user );
|
10568 |
+
|
10569 |
+
/**
|
10570 |
+
* If account menu item is hidden, redirect to plugin's main settings page.
|
10571 |
+
*
|
10572 |
+
* @author Vova Feldman (@svovaf)
|
10573 |
+
* @since 1.1.6
|
10574 |
+
*
|
10575 |
+
* @link https://github.com/Freemius/wordpress-sdk/issues/6
|
10576 |
+
*/
|
10577 |
+
if ( ! $is_menu_item_account_visible ) {
|
10578 |
+
fs_redirect( $this->_get_admin_page_url() );
|
10579 |
+
}
|
10580 |
+
}
|
10581 |
+
}
|
10582 |
+
|
10583 |
+
/**
|
10584 |
+
* @param bool $store
|
10585 |
+
*
|
10586 |
+
* @return FS_Plugin_Plan|object|false
|
10587 |
+
*/
|
10588 |
+
private function _enrich_site_plan( $store = true ) {
|
10589 |
+
// Try to load plan from local cache.
|
10590 |
+
$plan = $this->_get_plan_by_id( $this->_site->plan->id );
|
10591 |
+
|
10592 |
+
if ( false === $plan ) {
|
10593 |
+
$plan = $this->_fetch_site_plan();
|
10594 |
+
}
|
10595 |
+
|
10596 |
+
if ( $plan instanceof FS_Plugin_Plan ) {
|
10597 |
+
$this->_update_plan( $plan, $store );
|
10598 |
+
}
|
10599 |
+
|
10600 |
+
return $plan;
|
10601 |
+
}
|
10602 |
+
|
10603 |
+
/**
|
10604 |
+
* @author Vova Feldman (@svovaf)
|
10605 |
+
* @since 1.0.9
|
10606 |
+
* @uses FS_Api
|
10607 |
+
*
|
10608 |
+
* @param bool $store
|
10609 |
+
*
|
10610 |
+
* @return FS_Plugin_Plan|object|false
|
10611 |
+
*/
|
10612 |
+
private function _enrich_site_trial_plan( $store = true ) {
|
10613 |
+
// Try to load plan from local cache.
|
10614 |
+
$trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
|
10615 |
+
|
10616 |
+
if ( false === $trial_plan ) {
|
10617 |
+
$trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
|
10618 |
+
}
|
10619 |
+
|
10620 |
+
if ( $trial_plan instanceof FS_Plugin_Plan ) {
|
10621 |
+
$this->_storage->store( 'trial_plan', $trial_plan, $store );
|
10622 |
+
}
|
10623 |
+
|
10624 |
+
return $trial_plan;
|
10625 |
+
}
|
10626 |
+
|
10627 |
+
/**
|
10628 |
+
* @author Vova Feldman (@svovaf)
|
10629 |
+
* @since 1.0.9
|
10630 |
+
* @uses FS_Api
|
10631 |
+
*
|
10632 |
+
* @param number|bool $license_id
|
10633 |
+
*
|
10634 |
+
* @return FS_Subscription|object|bool
|
10635 |
+
*/
|
10636 |
+
private function _fetch_site_license_subscription( $license_id = false ) {
|
10637 |
+
$this->_logger->entrance();
|
10638 |
+
$api = $this->get_api_site_scope();
|
10639 |
+
|
10640 |
+
if ( ! is_numeric( $license_id ) ) {
|
10641 |
+
$license_id = $this->_license->id;
|
10642 |
+
}
|
10643 |
+
|
10644 |
+
$result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );
|
10645 |
+
|
10646 |
+
return ! isset( $result->error ) ?
|
10647 |
+
( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
|
10648 |
+
new FS_Subscription( $result->subscriptions[0] ) :
|
10649 |
+
false
|
10650 |
+
) :
|
10651 |
+
$result;
|
10652 |
+
}
|
10653 |
+
|
10654 |
+
/**
|
10655 |
+
* @author Vova Feldman (@svovaf)
|
10656 |
+
* @since 1.0.4
|
10657 |
+
* @uses FS_Api
|
10658 |
+
*
|
10659 |
+
* @param number|bool $plan_id
|
10660 |
+
*
|
10661 |
+
* @return FS_Plugin_Plan|object
|
10662 |
+
*/
|
10663 |
+
private function _fetch_site_plan( $plan_id = false ) {
|
10664 |
+
$this->_logger->entrance();
|
10665 |
+
$api = $this->get_api_site_scope();
|
10666 |
+
|
10667 |
+
if ( ! is_numeric( $plan_id ) ) {
|
10668 |
+
$plan_id = $this->_site->plan->id;
|
10669 |
+
}
|
10670 |
+
|
10671 |
+
$plan = $api->get( "/plans/{$plan_id}.json", true );
|
10672 |
+
|
10673 |
+
return ! isset( $plan->error ) ? new FS_Plugin_Plan( $plan ) : $plan;
|
10674 |
+
}
|
10675 |
+
|
10676 |
+
/**
|
10677 |
+
* @author Vova Feldman (@svovaf)
|
10678 |
+
* @since 1.0.5
|
10679 |
+
* @uses FS_Api
|
10680 |
+
*
|
10681 |
+
* @return FS_Plugin_Plan[]|object
|
10682 |
+
*/
|
10683 |
+
private function _fetch_plugin_plans() {
|
10684 |
+
$this->_logger->entrance();
|
10685 |
+
$api = $this->get_api_site_scope();
|
10686 |
+
|
10687 |
+
/**
|
10688 |
+
* @since 1.2.3 When running in DEV mode, retrieve pending plans as well.
|
10689 |
+
*/
|
10690 |
+
$result = $api->get( '/plans.json?show_pending=' . ( $this->has_secret_key() ? 'true' : 'false' ), true );
|
10691 |
+
|
10692 |
+
if ( $this->is_api_result_object( $result, 'plans' ) && is_array( $result->plans ) ) {
|
10693 |
+
for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
|
10694 |
+
$result->plans[ $i ] = new FS_Plugin_Plan( $result->plans[ $i ] );
|
10695 |
+
}
|
10696 |
+
|
10697 |
+
$result = $result->plans;
|
10698 |
+
}
|
10699 |
+
|
10700 |
+
return $result;
|
10701 |
+
}
|
10702 |
+
|
10703 |
+
/**
|
10704 |
+
* @author Vova Feldman (@svovaf)
|
10705 |
+
* @since 1.0.5
|
10706 |
+
* @uses FS_Api
|
10707 |
+
*
|
10708 |
+
* @param number|bool $plugin_id
|
10709 |
+
* @param number|bool $site_license_id
|
10710 |
+
*
|
10711 |
+
* @return FS_Plugin_License[]|object
|
10712 |
+
*/
|
10713 |
+
private function _fetch_licenses( $plugin_id = false, $site_license_id = false ) {
|
10714 |
+
$this->_logger->entrance();
|
10715 |
+
|
10716 |
+
$api = $this->get_api_user_scope();
|
10717 |
+
|
10718 |
+
if ( ! is_numeric( $plugin_id ) ) {
|
10719 |
+
$plugin_id = $this->_plugin->id;
|
10720 |
+
}
|
10721 |
+
|
10722 |
+
$result = $api->get( "/plugins/{$plugin_id}/licenses.json", true );
|
10723 |
+
|
10724 |
+
$is_site_license_synced = false;
|
10725 |
+
|
10726 |
+
$api_errors = array();
|
10727 |
+
|
10728 |
+
if ( $this->is_api_result_object( $result, 'licenses' ) &&
|
10729 |
+
is_array( $result->licenses )
|
10730 |
+
) {
|
10731 |
+
for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
|
10732 |
+
$result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
|
10733 |
+
|
10734 |
+
if ( ( ! $is_site_license_synced ) && is_numeric( $site_license_id ) ) {
|
10735 |
+
$is_site_license_synced = ( $site_license_id == $result->licenses[ $i ]->id );
|
10736 |
+
}
|
10737 |
+
}
|
10738 |
+
|
10739 |
+
$result = $result->licenses;
|
10740 |
+
} else {
|
10741 |
+
$api_errors[] = $result;
|
10742 |
+
$result = array();
|
10743 |
+
}
|
10744 |
+
|
10745 |
+
if ( ! $is_site_license_synced ) {
|
10746 |
+
$api = $this->get_api_site_scope();
|
10747 |
+
|
10748 |
+
if ( is_numeric( $site_license_id ) ) {
|
10749 |
+
// Try to retrieve a foreign license that is linked to the install.
|
10750 |
+
$api_result = $api->call( '/licenses.json' );
|
10751 |
+
|
10752 |
+
if ( $this->is_api_result_object( $api_result, 'licenses' ) &&
|
10753 |
+
is_array( $api_result->licenses )
|
10754 |
+
) {
|
10755 |
+
$licenses = $api_result->licenses;
|
10756 |
+
|
10757 |
+
if ( ! empty( $licenses ) ) {
|
10758 |
+
$result[] = new FS_Plugin_License( $licenses[0] );
|
10759 |
+
}
|
10760 |
+
} else {
|
10761 |
+
$api_errors[] = $api_result;
|
10762 |
+
}
|
10763 |
+
} else if ( is_object( $this->_license ) ) {
|
10764 |
+
// Fetch foreign license by ID and license key.
|
10765 |
+
$license = $api->get( "/licenses/{$this->_license->id}.json?license_key=" .
|
10766 |
+
urlencode( $this->_license->secret_key ) );
|
10767 |
+
|
10768 |
+
if ( $this->is_api_result_entity( $license ) ) {
|
10769 |
+
$result[] = new FS_Plugin_License( $license );
|
10770 |
+
} else {
|
10771 |
+
$api_errors[] = $license;
|
10772 |
+
}
|
10773 |
+
}
|
10774 |
+
}
|
10775 |
+
|
10776 |
+
if ( is_array( $result ) && 0 < count( $result ) ) {
|
10777 |
+
// If found at least one license, return license collection even if there are errors.
|
10778 |
+
return $result;
|
10779 |
+
}
|
10780 |
+
|
10781 |
+
if ( ! empty( $api_errors ) ) {
|
10782 |
+
// If found any errors and no licenses, return first error.
|
10783 |
+
return $api_errors[0];
|
10784 |
+
}
|
10785 |
+
|
10786 |
+
// Fallback to empty licenses list.
|
10787 |
+
return $result;
|
10788 |
+
}
|
10789 |
+
|
10790 |
+
/**
|
10791 |
+
* @author Vova Feldman (@svovaf)
|
10792 |
+
* @since 1.2.0
|
10793 |
+
* @uses FS_Api
|
10794 |
+
*
|
10795 |
+
* @param number|bool $plugin_id
|
10796 |
+
* @param bool $flush
|
10797 |
+
*
|
10798 |
+
* @return FS_Payment[]|object
|
10799 |
+
*/
|
10800 |
+
function _fetch_payments( $plugin_id = false, $flush = false ) {
|
10801 |
+
$this->_logger->entrance();
|
10802 |
+
|
10803 |
+
$api = $this->get_api_user_scope();
|
10804 |
+
|
10805 |
+
if ( ! is_numeric( $plugin_id ) ) {
|
10806 |
+
$plugin_id = $this->_plugin->id;
|
10807 |
+
}
|
10808 |
+
|
10809 |
+
$result = $api->get( "/plugins/{$plugin_id}/payments.json?include_addons=true", $flush );
|
10810 |
+
|
10811 |
+
if ( ! isset( $result->error ) ) {
|
10812 |
+
for ( $i = 0, $len = count( $result->payments ); $i < $len; $i ++ ) {
|
10813 |
+
$result->payments[ $i ] = new FS_Payment( $result->payments[ $i ] );
|
10814 |
+
}
|
10815 |
+
$result = $result->payments;
|
10816 |
+
}
|
10817 |
+
|
10818 |
+
return $result;
|
10819 |
+
}
|
10820 |
+
|
10821 |
+
/**
|
10822 |
+
* @author Vova Feldman (@svovaf)
|
10823 |
+
* @since 1.2.1.5
|
10824 |
+
* @uses FS_Api
|
10825 |
+
*
|
10826 |
+
* @param bool $flush
|
10827 |
+
*
|
10828 |
+
* @return \FS_Billing|mixed
|
10829 |
+
*/
|
10830 |
+
function _fetch_billing( $flush = false ) {
|
10831 |
+
require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-billing.php';
|
10832 |
+
|
10833 |
+
$billing = $this->get_api_user_scope()->get( 'billing.json', $flush );
|
10834 |
+
|
10835 |
+
if ( $this->is_api_result_entity( $billing ) ) {
|
10836 |
+
$billing = new FS_Billing( $billing );
|
10837 |
+
}
|
10838 |
+
|
10839 |
+
return $billing;
|
10840 |
+
}
|
10841 |
+
|
10842 |
+
/**
|
10843 |
+
* @author Vova Feldman (@svovaf)
|
10844 |
+
* @since 1.0.4
|
10845 |
+
*
|
10846 |
+
* @param FS_Plugin_Plan $plan
|
10847 |
+
* @param bool $store
|
10848 |
+
*/
|
10849 |
+
private function _update_plan( $plan, $store = false ) {
|
10850 |
+
$this->_logger->entrance();
|
10851 |
+
|
10852 |
+
$this->_site->plan = $plan;
|
10853 |
+
$this->_store_site( $store );
|
10854 |
+
}
|
10855 |
+
|
10856 |
+
/**
|
10857 |
+
* @author Vova Feldman (@svovaf)
|
10858 |
+
* @since 1.0.5
|
10859 |
+
*
|
10860 |
+
* @param FS_Plugin_License[] $licenses
|
10861 |
+
* @param string|bool $plugin_slug
|
10862 |
+
*/
|
10863 |
+
private function _update_licenses( $licenses, $plugin_slug = false ) {
|
10864 |
+
$this->_logger->entrance();
|
10865 |
+
|
10866 |
+
if ( is_array( $licenses ) ) {
|
10867 |
+
for ( $i = 0, $len = count( $licenses ); $i < $len; $i ++ ) {
|
10868 |
+
$licenses[ $i ]->updated = time();
|
10869 |
+
}
|
10870 |
+
}
|
10871 |
+
|
10872 |
+
if ( ! is_string( $plugin_slug ) ) {
|
10873 |
+
$this->_licenses = $licenses;
|
10874 |
+
}
|
10875 |
+
|
10876 |
+
$this->_store_licenses( true, $plugin_slug, $licenses );
|
10877 |
+
}
|
10878 |
+
|
10879 |
+
/**
|
10880 |
+
* @author Vova Feldman (@svovaf)
|
10881 |
+
* @since 1.0.4
|
10882 |
+
*
|
10883 |
+
* @param bool|number $plugin_id
|
10884 |
+
* @param bool $flush Since 1.1.7.3
|
10885 |
+
* @param int $expiration Since 1.2.2.7
|
10886 |
+
*
|
10887 |
+
* @return object|false New plugin tag info if exist.
|
10888 |
+
*/
|
10889 |
+
private function _fetch_newer_version( $plugin_id = false, $flush = true, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
10890 |
+
$latest_tag = $this->_fetch_latest_version( $plugin_id, $flush, $expiration );
|
10891 |
+
|
10892 |
+
if ( ! is_object( $latest_tag ) ) {
|
10893 |
+
return false;
|
10894 |
+
}
|
10895 |
+
|
10896 |
+
// Check if version is actually newer.
|
10897 |
+
$has_new_version =
|
10898 |
+
// If it's an non-installed add-on then always return latest.
|
10899 |
+
( $this->_is_addon_id( $plugin_id ) && ! $this->is_addon_activated( $plugin_id ) ) ||
|
10900 |
+
// Compare versions.
|
10901 |
+
version_compare( $this->get_plugin_version(), $latest_tag->version, '<' );
|
10902 |
+
|
10903 |
+
$this->_logger->departure( $has_new_version ? 'Found newer plugin version ' . $latest_tag->version : 'No new version' );
|
10904 |
+
|
10905 |
+
return $has_new_version ? $latest_tag : false;
|
10906 |
+
}
|
10907 |
+
|
10908 |
+
/**
|
10909 |
+
* @author Vova Feldman (@svovaf)
|
10910 |
+
* @since 1.0.5
|
10911 |
+
*
|
10912 |
+
* @param bool|number $plugin_id
|
10913 |
+
* @param bool $flush Since 1.1.7.3
|
10914 |
+
* @param int $expiration Since 1.2.2.7
|
10915 |
+
*
|
10916 |
+
* @return bool|FS_Plugin_Tag
|
10917 |
+
*/
|
10918 |
+
function get_update( $plugin_id = false, $flush = true, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
10919 |
+
$this->_logger->entrance();
|
10920 |
+
|
10921 |
+
if ( ! is_numeric( $plugin_id ) ) {
|
10922 |
+
$plugin_id = $this->_plugin->id;
|
10923 |
+
}
|
10924 |
+
|
10925 |
+
$this->check_updates( true, $plugin_id, $flush, $expiration );
|
10926 |
+
$updates = $this->get_all_updates();
|
10927 |
+
|
10928 |
+
return isset( $updates[ $plugin_id ] ) && is_object( $updates[ $plugin_id ] ) ? $updates[ $plugin_id ] : false;
|
10929 |
+
}
|
10930 |
+
|
10931 |
+
/**
|
10932 |
+
* Check if site assigned with active license.
|
10933 |
+
*
|
10934 |
+
* @author Vova Feldman (@svovaf)
|
10935 |
+
* @since 1.0.6
|
10936 |
+
*
|
10937 |
+
* @deprecated Please use has_active_valid_license() instead because license can be cancelled.
|
10938 |
+
*/
|
10939 |
+
function has_active_license() {
|
10940 |
+
return (
|
10941 |
+
is_object( $this->_license ) &&
|
10942 |
+
is_numeric( $this->_license->id ) &&
|
10943 |
+
! $this->_license->is_expired()
|
10944 |
+
);
|
10945 |
+
}
|
10946 |
+
|
10947 |
+
/**
|
10948 |
+
* Check if site assigned with active & valid (not expired) license.
|
10949 |
+
*
|
10950 |
+
* @author Vova Feldman (@svovaf)
|
10951 |
+
* @since 1.2.1
|
10952 |
+
*/
|
10953 |
+
function has_active_valid_license() {
|
10954 |
+
return (
|
10955 |
+
is_object( $this->_license ) &&
|
10956 |
+
is_numeric( $this->_license->id ) &&
|
10957 |
+
$this->_license->is_active() &&
|
10958 |
+
$this->_license->is_valid()
|
10959 |
+
);
|
10960 |
+
}
|
10961 |
+
|
10962 |
+
/**
|
10963 |
+
* Check if site assigned with license with enabled features.
|
10964 |
+
*
|
10965 |
+
* @author Vova Feldman (@svovaf)
|
10966 |
+
* @since 1.0.6
|
10967 |
+
*
|
10968 |
+
* @return bool
|
10969 |
+
*/
|
10970 |
+
function has_features_enabled_license() {
|
10971 |
+
return (
|
10972 |
+
is_object( $this->_license ) &&
|
10973 |
+
is_numeric( $this->_license->id ) &&
|
10974 |
+
$this->_license->is_features_enabled()
|
10975 |
+
);
|
10976 |
+
}
|
10977 |
+
|
10978 |
+
/**
|
10979 |
+
* Check if user is a trial or have feature enabled license.
|
10980 |
+
*
|
10981 |
+
* @author Vova Feldman (@svovaf)
|
10982 |
+
* @since 1.1.7
|
10983 |
+
*
|
10984 |
+
* @return bool
|
10985 |
+
*/
|
10986 |
+
function can_use_premium_code() {
|
10987 |
+
return $this->is_trial() || $this->has_features_enabled_license();
|
10988 |
+
}
|
10989 |
+
|
10990 |
+
/**
|
10991 |
+
* Checks if the current user can activate plugins or switch themes. Note that this method should only be used
|
10992 |
+
* after the `init` action is triggered because it is using `current_user_can()` which is only functional after
|
10993 |
+
* the context user is authenticated.
|
10994 |
+
*
|
10995 |
+
* @author Leo Fajardo (@leorw)
|
10996 |
+
* @since 1.2.2
|
10997 |
+
*
|
10998 |
+
* @return bool
|
10999 |
+
*/
|
11000 |
+
function is_user_admin() {
|
11001 |
+
return ( $this->is_plugin() && current_user_can( 'activate_plugins' ) )
|
11002 |
+
|| ( $this->is_theme() && current_user_can( 'switch_themes' ) );
|
11003 |
+
}
|
11004 |
+
|
11005 |
+
/**
|
11006 |
+
* Sync site's plan.
|
11007 |
+
*
|
11008 |
+
* @author Vova Feldman (@svovaf)
|
11009 |
+
* @since 1.0.3
|
11010 |
+
*
|
11011 |
+
* @uses FS_Api
|
11012 |
+
*
|
11013 |
+
* @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
|
11014 |
+
* the admin.
|
11015 |
+
*/
|
11016 |
+
private function _sync_license( $background = false ) {
|
11017 |
+
$this->_logger->entrance();
|
11018 |
+
|
11019 |
+
$plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
|
11020 |
+
|
11021 |
+
$is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() );
|
11022 |
+
|
11023 |
+
if ( $is_addon_sync ) {
|
11024 |
+
$this->_sync_addon_license( $plugin_id, $background );
|
11025 |
+
} else {
|
11026 |
+
$this->_sync_plugin_license( $background );
|
11027 |
+
}
|
11028 |
+
|
11029 |
+
$this->do_action( 'after_account_plan_sync', $this->_site->plan->name );
|
11030 |
+
}
|
11031 |
+
|
11032 |
+
/**
|
11033 |
+
* Sync plugin's add-on license.
|
11034 |
+
*
|
11035 |
+
* @author Vova Feldman (@svovaf)
|
11036 |
+
* @since 1.0.6
|
11037 |
+
* @uses FS_Api
|
11038 |
+
*
|
11039 |
+
* @param number $addon_id
|
11040 |
+
* @param bool $background
|
11041 |
+
*/
|
11042 |
+
private function _sync_addon_license( $addon_id, $background ) {
|
11043 |
+
$this->_logger->entrance();
|
11044 |
+
|
11045 |
+
if ( $this->is_addon_activated( $addon_id ) ) {
|
11046 |
+
// If already installed, use add-on sync.
|
11047 |
+
$fs_addon = self::get_instance_by_id( $addon_id );
|
11048 |
+
$fs_addon->_sync_license( $background );
|
11049 |
+
|
11050 |
+
return;
|
11051 |
+
}
|
11052 |
+
|
11053 |
+
// Validate add-on exists.
|
11054 |
+
$addon = $this->get_addon( $addon_id );
|
11055 |
+
|
11056 |
+
if ( ! is_object( $addon ) ) {
|
11057 |
+
return;
|
11058 |
+
}
|
11059 |
+
|
11060 |
+
// Add add-on into account add-ons.
|
11061 |
+
$account_addons = $this->get_account_addons();
|
11062 |
+
if ( ! is_array( $account_addons ) ) {
|
11063 |
+
$account_addons = array();
|
11064 |
+
}
|
11065 |
+
$account_addons[] = $addon->id;
|
11066 |
+
$account_addons = array_unique( $account_addons );
|
11067 |
+
$this->_store_account_addons( $account_addons );
|
11068 |
+
|
11069 |
+
// Load add-on licenses.
|
11070 |
+
$licenses = $this->_fetch_licenses( $addon->id );
|
11071 |
+
|
11072 |
+
// Sync add-on licenses.
|
11073 |
+
if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
|
11074 |
+
$this->_update_licenses( $licenses, $addon->slug );
|
11075 |
+
|
11076 |
+
if ( ! $this->is_addon_installed( $addon->id ) && FS_License_Manager::has_premium_license( $licenses ) ) {
|
11077 |
+
$plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
|
11078 |
+
|
11079 |
+
if ( ! isset( $plans_result->error ) ) {
|
11080 |
+
$plans = array();
|
11081 |
+
foreach ( $plans_result->plans as $plan ) {
|
11082 |
+
$plans[] = new FS_Plugin_Plan( $plan );
|
11083 |
+
}
|
11084 |
+
|
11085 |
+
$this->_admin_notices->add_sticky(
|
11086 |
+
sprintf(
|
11087 |
+
( FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
|
11088 |
+
$this->get_text_inline( 'Your %s Add-on plan was successfully upgraded.', 'addon-successfully-upgraded-message' ) :
|
11089 |
+
/* translators: %s:product name, e.g. Facebook add-on was successfully... */
|
11090 |
+
$this->get_text_inline( '%s Add-on was successfully purchased.', 'addon-successfully-purchased-message' ) ),
|
11091 |
+
$addon->title
|
11092 |
+
) . ' ' . $this->get_latest_download_link(
|
11093 |
+
$this->get_text_inline( 'Download the latest version', 'download-latest-version' ),
|
11094 |
+
$addon_id
|
11095 |
+
),
|
11096 |
+
'addon_plan_upgraded_' . $addon->slug,
|
11097 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
11098 |
+
);
|
11099 |
+
}
|
11100 |
+
}
|
11101 |
+
}
|
11102 |
+
}
|
11103 |
+
|
11104 |
+
/**
|
11105 |
+
* Sync site's plugin plan.
|
11106 |
+
*
|
11107 |
+
* @author Vova Feldman (@svovaf)
|
11108 |
+
* @since 1.0.6
|
11109 |
+
* @uses FS_Api
|
11110 |
+
*
|
11111 |
+
* @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
|
11112 |
+
* the admin.
|
11113 |
+
*/
|
11114 |
+
private function _sync_plugin_license( $background = false ) {
|
11115 |
+
$this->_logger->entrance();
|
11116 |
+
|
11117 |
+
/**
|
11118 |
+
* Sync site info.
|
11119 |
+
*
|
11120 |
+
* @todo This line will execute install sync on a daily basis, even if running the free version (for opted-in users). The reason we want to keep it that way is for cases when the user was a paying customer, then there was a failure in subscription payment, and then after some time the payment was successful. This could be heavily optimized. For example, we can skip the $flush if the current install was never associated with a paid version.
|
11121 |
+
*/
|
11122 |
+
$site = $this->send_install_update( array(), true );
|
11123 |
+
|
11124 |
+
$plan_change = 'none';
|
11125 |
+
|
11126 |
+
if ( ! $this->is_api_result_entity( $site ) ) {
|
11127 |
+
// Show API messages only if not background sync or if paying customer.
|
11128 |
+
if ( ! $background || $this->is_paying() ) {
|
11129 |
+
// Try to ping API to see if not blocked.
|
11130 |
+
if ( ! FS_Api::test() ) {
|
11131 |
+
/**
|
11132 |
+
* Failed to ping API - blocked!
|
11133 |
+
*
|
11134 |
+
* @author Vova Feldman (@svovaf)
|
11135 |
+
* @since 1.1.6 Only show message related to one of the Freemius powered plugins. Once it will be resolved it will fix the issue for all plugins anyways. There's no point to scare users with multiple error messages.
|
11136 |
+
*/
|
11137 |
+
$api = $this->get_api_site_scope();
|
11138 |
+
|
11139 |
+
if ( ! self::$_global_admin_notices->has_sticky( 'api_blocked' ) ) {
|
11140 |
+
self::$_global_admin_notices->add(
|
11141 |
+
sprintf(
|
11142 |
+
$this->get_text_x_inline( 'Your server is blocking the access to Freemius\' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s', '%1s - plugin title, %2s - API domain', 'server-blocking-access' ),
|
11143 |
+
$this->get_plugin_name(),
|
11144 |
+
'<a href="' . $api->get_url() . '" target="_blank">' . $api->get_url() . '</a>'
|
11145 |
+
) . '<br> ' . $this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . var_export( $site->error, true ),
|
11146 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
11147 |
+
'error',
|
11148 |
+
$background,
|
11149 |
+
false,
|
11150 |
+
'api_blocked'
|
11151 |
+
);
|
11152 |
+
}
|
11153 |
+
} else {
|
11154 |
+
// Authentication params are broken.
|
11155 |
+
$this->_admin_notices->add(
|
11156 |
+
$this->get_text_inline( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'wrong-authentication-param-message' ),
|
11157 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
11158 |
+
'error'
|
11159 |
+
);
|
11160 |
+
}
|
11161 |
+
}
|
11162 |
+
|
11163 |
+
// No reason to continue with license sync while there are API issues.
|
11164 |
+
return;
|
11165 |
+
}
|
11166 |
+
|
11167 |
+
// Remove sticky API connectivity message.
|
11168 |
+
self::$_global_admin_notices->remove_sticky( 'api_blocked' );
|
11169 |
+
|
11170 |
+
$site = new FS_Site( $site );
|
11171 |
+
|
11172 |
+
// Sync plans.
|
11173 |
+
$this->_sync_plans();
|
11174 |
+
|
11175 |
+
if ( ! $this->has_paid_plan() ) {
|
11176 |
+
$this->_site = $site;
|
11177 |
+
$this->_enrich_site_plan( true );
|
11178 |
+
$this->_store_site();
|
11179 |
+
} else {
|
11180 |
+
/**
|
11181 |
+
* Sync licenses. Pass the site's license ID so that the foreign licenses will be fetched if the license
|
11182 |
+
* associated with that ID is not included in the user's licenses collection.
|
11183 |
+
*/
|
11184 |
+
$this->_sync_licenses( $site->license_id );
|
11185 |
+
|
11186 |
+
// Check if plan / license changed.
|
11187 |
+
if ( ! FS_Entity::equals( $site->plan, $this->_site->plan ) ||
|
11188 |
+
// Check if trial started.
|
11189 |
+
$site->trial_plan_id != $this->_site->trial_plan_id ||
|
11190 |
+
$site->trial_ends != $this->_site->trial_ends ||
|
11191 |
+
// Check if license changed.
|
11192 |
+
$site->license_id != $this->_site->license_id
|
11193 |
+
) {
|
11194 |
+
if ( $site->is_trial() && ( ! $this->_site->is_trial() || $site->trial_ends != $this->_site->trial_ends ) ) {
|
11195 |
+
// New trial started.
|
11196 |
+
$this->_site = $site;
|
11197 |
+
$plan_change = 'trial_started';
|
11198 |
+
|
11199 |
+
// Store trial plan information.
|
11200 |
+
$this->_enrich_site_trial_plan( true );
|
11201 |
+
|
11202 |
+
// For trial with subscription use-case.
|
11203 |
+
$new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
|
11204 |
+
|
11205 |
+
if ( is_object( $new_license ) && $new_license->is_valid() ) {
|
11206 |
+
$this->_site = $site;
|
11207 |
+
$this->_update_site_license( $new_license );
|
11208 |
+
$this->_store_licenses();
|
11209 |
+
$this->_enrich_site_plan( true );
|
11210 |
+
|
11211 |
+
$this->_sync_site_subscription( $this->_license );
|
11212 |
+
}
|
11213 |
+
} else if ( $this->_site->is_trial() && ! $site->is_trial() && ! is_numeric( $site->license_id ) ) {
|
11214 |
+
// Was in trial, but now trial expired and no license ID.
|
11215 |
+
// New trial started.
|
11216 |
+
$this->_site = $site;
|
11217 |
+
$plan_change = 'trial_expired';
|
11218 |
+
|
11219 |
+
// Clear trial plan information.
|
11220 |
+
$this->_storage->trial_plan = null;
|
11221 |
+
|
11222 |
+
} else {
|
11223 |
+
$is_free = $this->is_free_plan();
|
11224 |
+
|
11225 |
+
// Make sure license exist and not expired.
|
11226 |
+
$new_license = is_null( $site->license_id ) ?
|
11227 |
+
null :
|
11228 |
+
$this->_get_license_by_id( $site->license_id );
|
11229 |
+
|
11230 |
+
if ( $is_free && is_null( $new_license ) && $this->has_any_license() && $this->_license->is_cancelled ) {
|
11231 |
+
// License cancelled.
|
11232 |
+
$this->_site = $site;
|
11233 |
+
$this->_update_site_license( $new_license );
|
11234 |
+
$this->_store_licenses();
|
11235 |
+
$this->_enrich_site_plan( true );
|
11236 |
+
|
11237 |
+
$plan_change = 'cancelled';
|
11238 |
+
} else if ( $is_free && ( ( ! is_object( $new_license ) || $new_license->is_expired() ) ) ) {
|
11239 |
+
// The license is expired, so ignore upgrade method.
|
11240 |
+
} else {
|
11241 |
+
// License changed.
|
11242 |
+
$this->_site = $site;
|
11243 |
+
$this->_update_site_license( $new_license );
|
11244 |
+
$this->_store_licenses();
|
11245 |
+
$this->_enrich_site_plan( true );
|
11246 |
+
|
11247 |
+
$plan_change = $is_free ?
|
11248 |
+
'upgraded' :
|
11249 |
+
( is_object( $new_license ) ?
|
11250 |
+
'changed' :
|
11251 |
+
'downgraded' );
|
11252 |
+
}
|
11253 |
+
}
|
11254 |
+
|
11255 |
+
// Store updated site info.
|
11256 |
+
$this->_store_site();
|
11257 |
+
} else {
|
11258 |
+
if ( is_object( $this->_license ) && $this->_license->is_expired() ) {
|
11259 |
+
if ( ! $this->has_features_enabled_license() ) {
|
11260 |
+
$this->_deactivate_license();
|
11261 |
+
$plan_change = 'downgraded';
|
11262 |
+
} else {
|
11263 |
+
$plan_change = 'expired';
|
11264 |
+
}
|
11265 |
+
}
|
11266 |
+
|
11267 |
+
if ( is_numeric( $site->license_id ) && is_object( $this->_license ) ) {
|
11268 |
+
$this->_sync_site_subscription( $this->_license );
|
11269 |
+
}
|
11270 |
+
}
|
11271 |
+
}
|
11272 |
+
|
11273 |
+
$hmm_text = $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...';
|
11274 |
+
|
11275 |
+
if ( $this->has_paid_plan() ) {
|
11276 |
+
switch ( $plan_change ) {
|
11277 |
+
case 'none':
|
11278 |
+
if ( ! $background && is_admin() ) {
|
11279 |
+
$plan = $this->is_trial() ?
|
11280 |
+
$this->_storage->trial_plan :
|
11281 |
+
$this->_site->plan;
|
11282 |
+
|
11283 |
+
if ( $plan->is_free() ) {
|
11284 |
+
$this->_admin_notices->add(
|
11285 |
+
sprintf(
|
11286 |
+
$this->get_text_inline( 'It looks like you are still on the %s plan. If you did upgrade or change your plan, it\'s probably an issue on our side - sorry.', 'plan-did-not-change-message' ),
|
11287 |
+
'<i><b>' . $plan->title . ( $this->is_trial() ? ' ' . $this->get_text_x_inline( 'Trial', 'trial period', 'trial' ) : '' ) . '</b></i>'
|
11288 |
+
) . ' ' . sprintf(
|
11289 |
+
'<a href="%s">%s</a>',
|
11290 |
+
$this->contact_url(
|
11291 |
+
'bug',
|
11292 |
+
sprintf( $this->get_text_inline( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.', 'plan-did-not-change-email-message' ),
|
11293 |
+
strtoupper( $plan->name )
|
11294 |
+
)
|
11295 |
+
),
|
11296 |
+
$this->get_text_inline( 'Please contact us here', 'contact-us-here' )
|
11297 |
+
),
|
11298 |
+
$hmm_text
|
11299 |
+
);
|
11300 |
+
}
|
11301 |
+
}
|
11302 |
+
break;
|
11303 |
+
case 'upgraded':
|
11304 |
+
$this->_admin_notices->add_sticky(
|
11305 |
+
sprintf(
|
11306 |
+
$this->get_text_inline( 'Your plan was successfully upgraded.', 'plan-upgraded-message' ),
|
11307 |
+
'<i>' . $this->get_plugin_name() . '</i>'
|
11308 |
+
) . $this->get_complete_upgrade_instructions(),
|
11309 |
+
'plan_upgraded',
|
11310 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
11311 |
+
);
|
11312 |
+
|
11313 |
+
$this->_admin_notices->remove_sticky( array(
|
11314 |
+
'trial_started',
|
11315 |
+
'trial_promotion',
|
11316 |
+
'trial_expired',
|
11317 |
+
'activation_complete',
|
11318 |
+
) );
|
11319 |
+
break;
|
11320 |
+
case 'changed':
|
11321 |
+
$this->_admin_notices->add_sticky(
|
11322 |
+
sprintf(
|
11323 |
+
$this->get_text_inline( 'Your plan was successfully changed to %s.', 'plan-changed-to-x-message' ),
|
11324 |
+
$this->_site->plan->title
|
11325 |
+
),
|
11326 |
+
'plan_changed'
|
11327 |
+
);
|
11328 |
+
|
11329 |
+
$this->_admin_notices->remove_sticky( array(
|
11330 |
+
'trial_started',
|
11331 |
+
'trial_promotion',
|
11332 |
+
'trial_expired',
|
11333 |
+
'activation_complete',
|
11334 |
+
) );
|
11335 |
+
break;
|
11336 |
+
case 'downgraded':
|
11337 |
+
$this->_admin_notices->add_sticky(
|
11338 |
+
sprintf( $this->get_text_inline( 'Your license has expired. You can still continue using the free %s forever.', 'license-expired-blocking-message' ), $this->_module_type ),
|
11339 |
+
'license_expired',
|
11340 |
+
$hmm_text
|
11341 |
+
);
|
11342 |
+
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
|
11343 |
+
break;
|
11344 |
+
case 'cancelled':
|
11345 |
+
$this->_admin_notices->add(
|
11346 |
+
$this->get_text_inline( 'Your license has been cancelled. If you think it\'s a mistake, please contact support.', 'license-cancelled' ) . ' ' .
|
11347 |
+
sprintf(
|
11348 |
+
'<a href="%s">%s</a>',
|
11349 |
+
$this->contact_url( 'bug' ),
|
11350 |
+
$this->get_text_inline( 'Please contact us here', 'contact-us-here' )
|
11351 |
+
),
|
11352 |
+
$hmm_text,
|
11353 |
+
'error'
|
11354 |
+
);
|
11355 |
+
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
|
11356 |
+
break;
|
11357 |
+
case 'expired':
|
11358 |
+
$this->_admin_notices->add_sticky(
|
11359 |
+
sprintf( $this->get_text_inline( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.', 'license-expired-non-blocking-message' ), $this->_site->plan->title ),
|
11360 |
+
'license_expired',
|
11361 |
+
$hmm_text
|
11362 |
+
);
|
11363 |
+
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
|
11364 |
+
break;
|
11365 |
+
case 'trial_started':
|
11366 |
+
$this->_admin_notices->add_sticky(
|
11367 |
+
sprintf(
|
11368 |
+
$this->get_text_inline( 'Your trial has been successfully started.', 'trial-started-message' ),
|
11369 |
+
'<i>' . $this->get_plugin_name() . '</i>'
|
11370 |
+
) . $this->get_complete_upgrade_instructions( $this->_storage->trial_plan->title ),
|
11371 |
+
'trial_started',
|
11372 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
11373 |
+
);
|
11374 |
+
|
11375 |
+
$this->_admin_notices->remove_sticky( array(
|
11376 |
+
'trial_promotion',
|
11377 |
+
) );
|
11378 |
+
break;
|
11379 |
+
case 'trial_expired':
|
11380 |
+
$this->_admin_notices->add_sticky(
|
11381 |
+
$this->get_text_inline( 'Your trial has expired. You can still continue using all our free features.', 'trial-expired-message' ),
|
11382 |
+
'trial_expired',
|
11383 |
+
$hmm_text
|
11384 |
+
);
|
11385 |
+
$this->_admin_notices->remove_sticky( array(
|
11386 |
+
'trial_started',
|
11387 |
+
'trial_promotion',
|
11388 |
+
'plan_upgraded',
|
11389 |
+
) );
|
11390 |
+
break;
|
11391 |
+
}
|
11392 |
+
}
|
11393 |
+
|
11394 |
+
if ( 'none' !== $plan_change ) {
|
11395 |
+
$this->do_action( 'after_license_change', $plan_change, $this->_site->plan );
|
11396 |
+
}
|
11397 |
+
}
|
11398 |
+
|
11399 |
+
/**
|
11400 |
+
* @author Vova Feldman (@svovaf)
|
11401 |
+
* @since 1.0.5
|
11402 |
+
*
|
11403 |
+
* @param bool $background
|
11404 |
+
*/
|
11405 |
+
protected function _activate_license( $background = false ) {
|
11406 |
+
$this->_logger->entrance();
|
11407 |
+
|
11408 |
+
$license_id = fs_request_get( 'license_id' );
|
11409 |
+
|
11410 |
+
if ( FS_Plugin_License::is_valid_id( $license_id ) && $license_id == $this->_site->license_id ) {
|
11411 |
+
// License is already activated.
|
11412 |
+
return;
|
11413 |
+
}
|
11414 |
+
|
11415 |
+
$premium_license = FS_Plugin_License::is_valid_id( $license_id ) ?
|
11416 |
+
$this->_get_license_by_id( $license_id ) :
|
11417 |
+
$this->_get_available_premium_license();
|
11418 |
+
|
11419 |
+
if ( ! is_object( $premium_license ) ) {
|
11420 |
+
return;
|
11421 |
+
}
|
11422 |
+
|
11423 |
+
/**
|
11424 |
+
* If the premium license is already associated with the install, just
|
11425 |
+
* update the license reference (activation is not required).
|
11426 |
+
*
|
11427 |
+
* @since 1.1.9
|
11428 |
+
*/
|
11429 |
+
if ( $premium_license->id == $this->_site->license_id ) {
|
11430 |
+
// License is already activated.
|
11431 |
+
$this->_update_site_license( $premium_license );
|
11432 |
+
$this->_enrich_site_plan( false );
|
11433 |
+
$this->_store_account();
|
11434 |
+
|
11435 |
+
return;
|
11436 |
+
}
|
11437 |
+
|
11438 |
+
if ( $this->_site->user_id != $premium_license->user_id ) {
|
11439 |
+
$api_request_params = array( 'license_key' => $premium_license->secret_key );
|
11440 |
+
} else {
|
11441 |
+
$api_request_params = array();
|
11442 |
+
}
|
11443 |
+
|
11444 |
+
$api = $this->get_api_site_scope();
|
11445 |
+
$license = $api->call( "/licenses/{$premium_license->id}.json", 'put', $api_request_params );
|
11446 |
+
|
11447 |
+
if ( ! $this->is_api_result_entity( $license ) ) {
|
11448 |
+
if ( ! $background ) {
|
11449 |
+
$this->_admin_notices->add( sprintf(
|
11450 |
+
'%s %s',
|
11451 |
+
$this->get_text_inline( 'It looks like the license could not be activated.', 'license-activation-failed-message' ),
|
11452 |
+
( is_object( $license ) && isset( $license->error ) ?
|
11453 |
+
$license->error->message :
|
11454 |
+
sprintf( '%s<br><code>%s</code>',
|
11455 |
+
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ),
|
11456 |
+
var_export( $license, true )
|
11457 |
+
)
|
11458 |
+
)
|
11459 |
+
),
|
11460 |
+
$this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...',
|
11461 |
+
'error'
|
11462 |
+
);
|
11463 |
+
}
|
11464 |
+
|
11465 |
+
return;
|
11466 |
+
}
|
11467 |
+
$premium_license = new FS_Plugin_License( $license );
|
11468 |
+
|
11469 |
+
// Updated site plan.
|
11470 |
+
$site = $this->get_api_site_scope()->get( '/', true );
|
11471 |
+
if ( $this->is_api_result_entity( $site ) ) {
|
11472 |
+
$this->_site = new FS_Site( $site );
|
11473 |
+
}
|
11474 |
+
$this->_update_site_license( $premium_license );
|
11475 |
+
$this->_enrich_site_plan( false );
|
11476 |
+
|
11477 |
+
$this->_store_account();
|
11478 |
+
|
11479 |
+
if ( ! $background ) {
|
11480 |
+
$this->_admin_notices->add_sticky(
|
11481 |
+
$this->get_text_inline( 'Your license was successfully activated.', 'license-activated-message' ) .
|
11482 |
+
$this->get_complete_upgrade_instructions(),
|
11483 |
+
'license_activated',
|
11484 |
+
$this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
|
11485 |
+
);
|
11486 |
+
}
|
11487 |
+
|
11488 |
+
$this->_admin_notices->remove_sticky( array(
|
11489 |
+
'trial_promotion',
|
11490 |
+
'license_expired',
|
11491 |
+
) );
|
11492 |
+
}
|
11493 |
+
|
11494 |
+
/**
|
11495 |
+
* @author Vova Feldman (@svovaf)
|
11496 |
+
* @since 1.0.5
|
11497 |
+
*
|
11498 |
+
* @param bool $show_notice
|
11499 |
+
*/
|
11500 |
+
protected function _deactivate_license( $show_notice = true ) {
|
11501 |
+
$this->_logger->entrance();
|
11502 |
+
|
11503 |
+
$hmm_text = $this->get_text_x_inline( 'Hmm', 'something somebody says when they are thinking about what you have just said.', 'hmm' ) . '...';
|
11504 |
+
|
11505 |
+
if ( ! is_object( $this->_license ) ) {
|
11506 |
+
$this->_admin_notices->add(
|
11507 |
+
sprintf( $this->get_text_inline( 'It looks like your site currently doesn\'t have an active license.', 'no-active-license-message' ), $this->_site->plan->title ),
|
11508 |
+
$hmm_text
|
11509 |
+
);
|
11510 |
+
|
11511 |
+
return;
|
11512 |
+
}
|
11513 |
+
|
11514 |
+
$api = $this->get_api_site_scope();
|
11515 |
+
$license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
|
11516 |
+
|
11517 |
+
if ( isset( $license->error ) ) {
|
11518 |
+
$this->_admin_notices->add(
|
11519 |
+
$this->get_text_inline( 'It looks like the license deactivation failed.', 'license-deactivation-failed-message' ) . '<br> ' .
|
11520 |
+
$this->get_text_inline( 'Error received from the server:', 'server-error-message' ) . ' ' . var_export( $license->error, true ),
|
11521 |
+
$hmm_text,
|
11522 |
+
'error'
|
11523 |
+
);
|
11524 |
+
|
11525 |
+
return;
|
11526 |
+
}
|
11527 |
+
|
11528 |
+
// Update license cache.
|
11529 |
+
for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
|
11530 |
+
if ( $license->id == $this->_licenses[ $i ]->id ) {
|
11531 |
+
$this->_licenses[ $i ] = new FS_Plugin_License( $license );
|
11532 |
+
}
|
11533 |
+
}
|
11534 |
+
|
11535 |
+
// Updated site plan to default.
|
11536 |
+
$this->_sync_plans();
|
11537 |
+
$this->_site->plan->id = $this->_plans[0]->id;
|
11538 |
+
// Unlink license from site.
|
11539 |
+
$this->_update_site_license( null );
|
11540 |
+
$this->_enrich_site_plan( false );
|
11541 |
+
|
11542 |
+
$this->_store_account();
|
11543 |
+
|
11544 |
+
if ( $show_notice ) {
|
11545 |
+
$this->_admin_notices->add(
|
11546 |
+
sprintf( $this->get_text_inline( 'Your license was successfully deactivated, you are back to the %s plan.', 'license-deactivation-message' ), $this->_site->plan->title ),
|
11547 |
+
$this->get_text_inline( 'O.K', 'ok' )
|
11548 |
+
);
|
11549 |
+
}
|
11550 |
+
|
11551 |
+
$this->_admin_notices->remove_sticky( array(
|
11552 |
+
'plan_upgraded',
|
11553 |
+
'license_activated',
|
11554 |
+
) );
|
11555 |
+
}
|
11556 |
+
|
11557 |
+
/**
|
11558 |
+
* Site plan downgrade.
|
11559 |
+
*
|
11560 |
+
* @author Vova Feldman (@svovaf)
|
11561 |
+
* @since 1.0.4
|
11562 |
+
*
|
11563 |
+
* @uses FS_Api
|
11564 |
+
*/
|
11565 |
+
private function _downgrade_site() {
|
11566 |
+
$this->_logger->entrance();
|
11567 |
+
|
11568 |
+
$api = $this->get_api_site_scope();
|
11569 |
+
$site = $api->call( 'downgrade.json', 'put' );
|
11570 |
+
|
11571 |
+
$plan_downgraded = false;
|
11572 |
+
$plan = false;
|
11573 |
+
if ( $this->is_api_result_entity( $site ) ) {
|
11574 |
+
$prev_plan_id = $this->_site->plan->id;
|
11575 |
+
|
11576 |
+
// Update new site plan id.
|
11577 |
+
$this->_site->plan->id = $site->plan_id;
|
11578 |
+
|
11579 |
+
$plan = $this->_enrich_site_plan();
|
11580 |
+
$subscription = $this->_sync_site_subscription( $this->_license );
|
11581 |
+
|
11582 |
+
// Plan downgraded if plan was changed or subscription was cancelled.
|
11583 |
+
$plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
|
11584 |
+
( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
|
11585 |
+
} else {
|
11586 |
+
// handle different error cases.
|
11587 |
+
|
11588 |
+
}
|
11589 |
+
|
11590 |
+
if ( $plan_downgraded ) {
|
11591 |
+
// Remove previous sticky message about upgrade (if exist).
|
11592 |
+
$this->_admin_notices->remove_sticky( 'plan_upgraded' );
|
11593 |
+
|
11594 |
+
$this->_admin_notices->add(
|
11595 |
+
sprintf( $this->get_text_inline( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.', 'plan-x-downgraded-message' ),
|
11596 |
+
$plan->title,
|
11597 |
+
human_time_diff( time(), strtotime( $this->_license->expiration ) )
|
11598 |
+
)
|
11599 |
+
);
|
11600 |
+
|
11601 |
+
// Store site updates.
|
11602 |
+
$this->_store_site();
|
11603 |
+
} else {
|
11604 |
+
$this->_admin_notices->add(
|
11605 |
+
$this->get_text_inline( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.', 'plan-downgraded-failure-message' ),
|
11606 |
+
$this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
|
11607 |
+
'error'
|
11608 |
+
);
|
11609 |
+
}
|
11610 |
+
}
|
11611 |
+
|
11612 |
+
/**
|
11613 |
+
* @author Vova Feldman (@svovaf)
|
11614 |
+
* @since 1.1.8.1
|
11615 |
+
*
|
11616 |
+
* @param bool|string $plan_name
|
11617 |
+
*
|
11618 |
+
* @return bool If trial was successfully started.
|
11619 |
+
*/
|
11620 |
+
function start_trial( $plan_name = false ) {
|
11621 |
+
$this->_logger->entrance();
|
11622 |
+
|
11623 |
+
// Alias.
|
11624 |
+
$oops_text = $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...';
|
11625 |
+
|
11626 |
+
if ( $this->is_trial() ) {
|
11627 |
+
// Already in trial mode.
|
11628 |
+
$this->_admin_notices->add(
|
11629 |
+
sprintf( $this->get_text_inline( 'You are already running the %s in a trial mode.', 'in-trial-mode' ), $this->_module_type ),
|
11630 |
+
$oops_text,
|
11631 |
+
'error'
|
11632 |
+
);
|
11633 |
+
|
11634 |
+
return false;
|
11635 |
+
}
|
11636 |
+
|
11637 |
+
if ( $this->_site->is_trial_utilized() ) {
|
11638 |
+
// Trial was already utilized.
|
11639 |
+
$this->_admin_notices->add(
|
11640 |
+
$this->get_text_inline( 'You already utilized a trial before.', 'trial-utilized' ),
|
11641 |
+
$oops_text,
|
11642 |
+
'error'
|
11643 |
+
);
|
11644 |
+
|
11645 |
+
return false;
|
11646 |
+
}
|
11647 |
+
|
11648 |
+
if ( false !== $plan_name ) {
|
11649 |
+
$plan = $this->get_plan_by_name( $plan_name );
|
11650 |
+
|
11651 |
+
if ( false === $plan ) {
|
11652 |
+
// Plan doesn't exist.
|
11653 |
+
$this->_admin_notices->add(
|
11654 |
+
sprintf( $this->get_text_inline( 'Plan %s do not exist, therefore, can\'t start a trial.', 'trial-plan-x-not-exist' ), $plan_name ),
|
11655 |
+
$oops_text,
|
11656 |
+
'error'
|
11657 |
+
);
|
11658 |
+
|
11659 |
+
return false;
|
11660 |
+
}
|
11661 |
+
|
11662 |
+
if ( ! $plan->has_trial() ) {
|
11663 |
+
// Plan doesn't exist.
|
11664 |
+
$this->_admin_notices->add(
|
11665 |
+
sprintf( $this->get_text_inline( 'Plan %s does not support a trial period.', 'plan-x-no-trial' ), $plan_name ),
|
11666 |
+
$oops_text,
|
11667 |
+
'error'
|
11668 |
+
);
|
11669 |
+
|
11670 |
+
return false;
|
11671 |
+
}
|
11672 |
+
} else {
|
11673 |
+
if ( ! $this->has_trial_plan() ) {
|
11674 |
+
// None of the plans have a trial.
|
11675 |
+
$this->_admin_notices->add(
|
11676 |
+
sprintf( $this->get_text_inline( 'None of the %s\'s plans supports a trial period.', 'no-trials' ), $this->_module_type ),
|
11677 |
+
$oops_text,
|
11678 |
+
'error'
|
11679 |
+
);
|
11680 |
+
|
11681 |
+
return false;
|
11682 |
+
}
|
11683 |
+
|
11684 |
+
$plans_with_trial = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
|
11685 |
+
|
11686 |
+
$plan = $plans_with_trial[0];
|
11687 |
+
}
|
11688 |
+
|
11689 |
+
$api = $this->get_api_site_scope();
|
11690 |
+
$plan = $api->call( "plans/{$plan->id}/trials.json", 'post' );
|
11691 |
+
|
11692 |
+
if ( ! $this->is_api_result_entity( $plan ) ) {
|
11693 |
+
// Some API error while trying to start the trial.
|
11694 |
+
$this->_admin_notices->add(
|
11695 |
+
sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type )
|
11696 |
+
. ' ' . var_export( $plan, true ),
|
11697 |
+
$oops_text,
|
11698 |
+
'error'
|
11699 |
+
);
|
11700 |
+
|
11701 |
+
return false;
|
11702 |
+
}
|
11703 |
+
|
11704 |
+
// Sync license.
|
11705 |
+
$this->_sync_license();
|
11706 |
+
|
11707 |
+
return $this->is_trial();
|
11708 |
+
}
|
11709 |
+
|
11710 |
+
/**
|
11711 |
+
* Cancel site trial.
|
11712 |
+
*
|
11713 |
+
* @author Vova Feldman (@svovaf)
|
11714 |
+
* @since 1.0.9
|
11715 |
+
*
|
11716 |
+
* @uses FS_Api
|
11717 |
+
*/
|
11718 |
+
private function _cancel_trial() {
|
11719 |
+
$this->_logger->entrance();
|
11720 |
+
|
11721 |
+
// Alias.
|
11722 |
+
$oops_text = $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...';
|
11723 |
+
|
11724 |
+
if ( ! $this->is_trial() ) {
|
11725 |
+
$this->_admin_notices->add(
|
11726 |
+
$this->get_text_inline( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'trial-cancel-no-trial-message' ),
|
11727 |
+
$oops_text,
|
11728 |
+
'error'
|
11729 |
+
);
|
11730 |
+
|
11731 |
+
return;
|
11732 |
+
}
|
11733 |
+
|
11734 |
+
$api = $this->get_api_site_scope();
|
11735 |
+
$site = $api->call( 'trials.json', 'delete' );
|
11736 |
+
|
11737 |
+
$trial_cancelled = false;
|
11738 |
+
|
11739 |
+
if ( $this->is_api_result_entity( $site ) ) {
|
11740 |
+
$prev_trial_ends = $this->_site->trial_ends;
|
11741 |
+
|
11742 |
+
if ( $this->is_paid_trial() ) {
|
11743 |
+
$this->_license->expiration = $site->trial_ends;
|
11744 |
+
$this->_license->is_cancelled = true;
|
11745 |
+
$this->_update_site_license( $this->_license );
|
11746 |
+
$this->_store_licenses();
|
11747 |
+
|
11748 |
+
// Clear subscription reference.
|
11749 |
+
$this->_sync_site_subscription( null );
|
11750 |
+
}
|
11751 |
+
|
11752 |
+
// Update site info.
|
11753 |
+
$this->_site = new FS_Site( $site );
|
11754 |
+
$this->_enrich_site_plan();
|
11755 |
+
|
11756 |
+
$trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
|
11757 |
+
} else {
|
11758 |
+
// handle different error cases.
|
11759 |
+
|
11760 |
+
}
|
11761 |
+
|
11762 |
+
if ( $trial_cancelled ) {
|
11763 |
+
// Remove previous sticky messages about upgrade or trial (if exist).
|
11764 |
+
$this->_admin_notices->remove_sticky( array(
|
11765 |
+
'trial_started',
|
11766 |
+
'trial_promotion',
|
11767 |
+
'plan_upgraded',
|
11768 |
+
) );
|
11769 |
+
|
11770 |
+
// Store site updates.
|
11771 |
+
$this->_store_site();
|
11772 |
+
|
11773 |
+
if ( ! $this->is_addon() ||
|
11774 |
+
! $this->deactivate_premium_only_addon_without_license( true )
|
11775 |
+
) {
|
11776 |
+
$this->_admin_notices->add(
|
11777 |
+
sprintf( $this->get_text_inline( 'Your %s free trial was successfully cancelled.', 'trial-cancel-message' ), $this->_storage->trial_plan->title )
|
11778 |
+
);
|
11779 |
+
}
|
11780 |
+
|
11781 |
+
// Clear trial plan information.
|
11782 |
+
unset( $this->_storage->trial_plan );
|
11783 |
+
} else {
|
11784 |
+
$this->_admin_notices->add(
|
11785 |
+
$this->get_text_inline( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'trial-cancel-failure-message' ),
|
11786 |
+
$oops_text,
|
11787 |
+
'error'
|
11788 |
+
);
|
11789 |
+
}
|
11790 |
+
}
|
11791 |
+
|
11792 |
+
/**
|
11793 |
+
* @author Vova Feldman (@svovaf)
|
11794 |
+
* @since 1.0.6
|
11795 |
+
*
|
11796 |
+
* @param bool|number $plugin_id
|
11797 |
+
*
|
11798 |
+
* @return bool
|
11799 |
+
*/
|
11800 |
+
private function _is_addon_id( $plugin_id ) {
|
11801 |
+
return is_numeric( $plugin_id ) && ( $this->get_id() != $plugin_id );
|
11802 |
+
}
|
11803 |
+
|
11804 |
+
/**
|
11805 |
+
* Check if user eligible to download premium version updates.
|
11806 |
+
*
|
11807 |
+
* @author Vova Feldman (@svovaf)
|
11808 |
+
* @since 1.0.6
|
11809 |
+
*
|
11810 |
+
* @return bool
|
11811 |
+
*/
|
11812 |
+
private function _can_download_premium() {
|
11813 |
+
return $this->has_active_valid_license() ||
|
11814 |
+
( $this->is_trial() && ! $this->get_trial_plan()->is_free() );
|
11815 |
+
}
|
11816 |
+
|
11817 |
+
/**
|
11818 |
+
*
|
11819 |
+
* @author Vova Feldman (@svovaf)
|
11820 |
+
* @since 1.0.6
|
11821 |
+
*
|
11822 |
+
* @param bool|number $addon_id
|
11823 |
+
* @param string $type "json" or "zip"
|
11824 |
+
*
|
11825 |
+
* @return string
|
11826 |
+
*/
|
11827 |
+
private function _get_latest_version_endpoint( $addon_id = false, $type = 'json' ) {
|
11828 |
+
|
11829 |
+
$is_addon = $this->_is_addon_id( $addon_id );
|
11830 |
+
|
11831 |
+
$is_premium = null;
|
11832 |
+
if ( ! $is_addon ) {
|
11833 |
+
$is_premium = $this->_can_download_premium();
|
11834 |
+
} else if ( $this->is_addon_activated( $addon_id ) ) {
|
11835 |
+
$is_premium = self::get_instance_by_id( $addon_id )->_can_download_premium();
|
11836 |
+
}
|
11837 |
+
|
11838 |
+
// If add-on, then append add-on ID.
|
11839 |
+
$endpoint = ( $is_addon ? "/addons/$addon_id" : '' ) .
|
11840 |
+
'/updates/latest.' . $type;
|
11841 |
+
|
11842 |
+
// If add-on and not yet activated, try to fetch based on server licensing.
|
11843 |
+
if ( is_bool( $is_premium ) ) {
|
11844 |
+
$endpoint = add_query_arg( 'is_premium', json_encode( $is_premium ), $endpoint );
|
11845 |
+
}
|
11846 |
+
|
11847 |
+
if ( $this->has_secret_key() ) {
|
11848 |
+
$endpoint = add_query_arg( 'type', 'all', $endpoint );
|
11849 |
+
}
|
11850 |
+
|
11851 |
+
return $endpoint;
|
11852 |
+
}
|
11853 |
+
|
11854 |
+
/**
|
11855 |
+
* @author Vova Feldman (@svovaf)
|
11856 |
+
* @since 1.0.4
|
11857 |
+
*
|
11858 |
+
* @param bool|number $addon_id
|
11859 |
+
* @param bool $flush Since 1.1.7.3
|
11860 |
+
* @param int $expiration Since 1.2.2.7
|
11861 |
+
*
|
11862 |
+
* @return object|false Plugin latest tag info.
|
11863 |
+
*/
|
11864 |
+
function _fetch_latest_version( $addon_id = false, $flush = true, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
11865 |
+
$this->_logger->entrance();
|
11866 |
+
|
11867 |
+
/**
|
11868 |
+
* @since 1.1.7.3 Check for plugin updates from Freemius only if opted-in.
|
11869 |
+
* @since 1.1.7.4 Also check updates for add-ons.
|
11870 |
+
*/
|
11871 |
+
if ( ! $this->is_registered() &&
|
11872 |
+
! $this->_is_addon_id( $addon_id )
|
11873 |
+
) {
|
11874 |
+
return false;
|
11875 |
+
}
|
11876 |
+
|
11877 |
+
$tag = $this->get_api_site_or_plugin_scope()->get(
|
11878 |
+
$this->_get_latest_version_endpoint( $addon_id, 'json' ),
|
11879 |
+
$flush,
|
11880 |
+
$expiration
|
11881 |
+
);
|
11882 |
+
|
11883 |
+
$latest_version = ( is_object( $tag ) && isset( $tag->version ) ) ? $tag->version : 'couldn\'t get';
|
11884 |
+
|
11885 |
+
$this->_logger->departure( 'Latest version ' . $latest_version );
|
11886 |
+
|
11887 |
+
return ( is_object( $tag ) && isset( $tag->version ) ) ? $tag : false;
|
11888 |
+
}
|
11889 |
+
|
11890 |
+
#----------------------------------------------------------------------------------
|
11891 |
+
#region Download Plugin
|
11892 |
+
#----------------------------------------------------------------------------------
|
11893 |
+
|
11894 |
+
/**
|
11895 |
+
* Download latest plugin version, based on plan.
|
11896 |
+
*
|
11897 |
+
* Not like _download_latest(), this will redirect the page
|
11898 |
+
* to secure download url to prevent dual download (from FS to WP server,
|
11899 |
+
* and then from WP server to the client / browser).
|
11900 |
+
*
|
11901 |
+
* @author Vova Feldman (@svovaf)
|
11902 |
+
* @since 1.0.9
|
11903 |
+
*
|
11904 |
+
* @param bool|number $plugin_id
|
11905 |
+
*
|
11906 |
+
* @uses FS_Api
|
11907 |
+
* @uses wp_redirect()
|
11908 |
+
*/
|
11909 |
+
private function download_latest_directly( $plugin_id = false ) {
|
11910 |
+
$this->_logger->entrance();
|
11911 |
+
|
11912 |
+
wp_redirect( $this->get_latest_download_api_url( $plugin_id ) );
|
11913 |
+
}
|
11914 |
+
|
11915 |
+
/**
|
11916 |
+
* Get latest plugin FS API download URL.
|
11917 |
+
*
|
11918 |
+
* @author Vova Feldman (@svovaf)
|
11919 |
+
* @since 1.0.9
|
11920 |
+
*
|
11921 |
+
* @param bool|number $plugin_id
|
11922 |
+
*
|
11923 |
+
* @return string
|
11924 |
+
*/
|
11925 |
+
private function get_latest_download_api_url( $plugin_id = false ) {
|
11926 |
+
$this->_logger->entrance();
|
11927 |
+
|
11928 |
+
return $this->get_api_site_scope()->get_signed_url(
|
11929 |
+
$this->_get_latest_version_endpoint( $plugin_id, 'zip' )
|
11930 |
+
);
|
11931 |
+
}
|
11932 |
+
|
11933 |
+
/**
|
11934 |
+
* Get payment invoice URL.
|
11935 |
+
*
|
11936 |
+
* @author Vova Feldman (@svovaf)
|
11937 |
+
* @since 1.2.0
|
11938 |
+
*
|
11939 |
+
* @param bool|number $payment_id
|
11940 |
+
*
|
11941 |
+
* @return string
|
11942 |
+
*/
|
11943 |
+
function _get_invoice_api_url( $payment_id = false ) {
|
11944 |
+
$this->_logger->entrance();
|
11945 |
+
|
11946 |
+
return $this->get_api_user_scope()->get_signed_url(
|
11947 |
+
"/payments/{$payment_id}/invoice.pdf"
|
11948 |
+
);
|
11949 |
+
}
|
11950 |
+
|
11951 |
+
/**
|
11952 |
+
* Get latest plugin download link.
|
11953 |
+
*
|
11954 |
+
* @author Vova Feldman (@svovaf)
|
11955 |
+
* @since 1.0.9
|
11956 |
+
*
|
11957 |
+
* @param string $label
|
11958 |
+
* @param bool|number $plugin_id
|
11959 |
+
*
|
11960 |
+
* @return string
|
11961 |
+
*/
|
11962 |
+
private function get_latest_download_link( $label, $plugin_id = false ) {
|
11963 |
+
return sprintf(
|
11964 |
+
'<a target="_blank" href="%s">%s</a>',
|
11965 |
+
$this->_get_latest_download_local_url( $plugin_id ),
|
11966 |
+
$label
|
11967 |
+
);
|
11968 |
+
}
|
11969 |
+
|
11970 |
+
/**
|
11971 |
+
* Get latest plugin download local URL.
|
11972 |
+
*
|
11973 |
+
* @author Vova Feldman (@svovaf)
|
11974 |
+
* @since 1.0.9
|
11975 |
+
*
|
11976 |
+
* @param bool|number $plugin_id
|
11977 |
+
*
|
11978 |
+
* @return string
|
11979 |
+
*/
|
11980 |
+
function _get_latest_download_local_url( $plugin_id = false ) {
|
11981 |
+
// Add timestamp to protect from caching.
|
11982 |
+
$params = array( 'ts' => WP_FS__SCRIPT_START_TIME );
|
11983 |
+
|
11984 |
+
if ( ! empty( $plugin_id ) ) {
|
11985 |
+
$params['plugin_id'] = $plugin_id;
|
11986 |
+
}
|
11987 |
+
|
11988 |
+
return $this->get_account_url( 'download_latest', $params );
|
11989 |
+
}
|
11990 |
+
|
11991 |
+
#endregion Download Plugin ------------------------------------------------------------------
|
11992 |
+
|
11993 |
+
/**
|
11994 |
+
* @author Vova Feldman (@svovaf)
|
11995 |
+
* @since 1.0.4
|
11996 |
+
*
|
11997 |
+
* @uses FS_Api
|
11998 |
+
*
|
11999 |
+
* @param bool $background Hints the method if it's a background updates check. If false, it means that
|
12000 |
+
* was initiated by the admin.
|
12001 |
+
* @param bool|number $plugin_id
|
12002 |
+
* @param bool $flush Since 1.1.7.3
|
12003 |
+
* @param int $expiration Since 1.2.2.7
|
12004 |
+
*/
|
12005 |
+
private function check_updates(
|
12006 |
+
$background = false,
|
12007 |
+
$plugin_id = false,
|
12008 |
+
$flush = true,
|
12009 |
+
$expiration = WP_FS__TIME_24_HOURS_IN_SEC
|
12010 |
+
) {
|
12011 |
+
$this->_logger->entrance();
|
12012 |
+
|
12013 |
+
// Check if there's a newer version for download.
|
12014 |
+
$new_version = $this->_fetch_newer_version( $plugin_id, $flush, $expiration );
|
12015 |
+
|
12016 |
+
$update = null;
|
12017 |
+
if ( is_object( $new_version ) ) {
|
12018 |
+
$update = new FS_Plugin_Tag( $new_version );
|
12019 |
+
|
12020 |
+
if ( ! $background ) {
|
12021 |
+
$this->_admin_notices->add(
|
12022 |
+
sprintf(
|
12023 |
+
/* translators: %s: Numeric version number (e.g. '2.1.9' */
|
12024 |
+
$this->get_text_inline( 'Version %s was released.', 'version-x-released' ) . ' ' . $this->get_text_inline( 'Please download %s.', 'please-download-x' ),
|
12025 |
+
$update->version,
|
12026 |
+
sprintf(
|
12027 |
+
'<a href="%s" target="_blank">%s</a>',
|
12028 |
+
$this->get_account_url( 'download_latest' ),
|
12029 |
+
sprintf(
|
12030 |
+
/* translators: %s: plan name (e.g. latest "Professional" version) */
|
12031 |
+
$this->get_text_inline( 'the latest %s version here', 'latest-x-version' ),
|
12032 |
+
$this->_site->plan->title
|
12033 |
+
)
|
12034 |
+
)
|
12035 |
+
),
|
12036 |
+
$this->get_text_inline( 'New', 'new' ) . '!'
|
12037 |
+
);
|
12038 |
+
}
|
12039 |
+
} else if ( false === $new_version && ! $background ) {
|
12040 |
+
$this->_admin_notices->add(
|
12041 |
+
$this->get_text_inline( 'Seems like you got the latest release.', 'you-have-latest' ),
|
12042 |
+
$this->get_text_inline( 'You are all good!', 'you-are-good' )
|
12043 |
+
);
|
12044 |
+
}
|
12045 |
+
|
12046 |
+
$this->_store_update( $update, true, $plugin_id );
|
12047 |
+
}
|
12048 |
+
|
12049 |
+
/**
|
12050 |
+
* @author Vova Feldman (@svovaf)
|
12051 |
+
* @since 1.0.4
|
12052 |
+
*
|
12053 |
+
* @param bool $flush Since 1.1.7.3 add 24 hour cache by default.
|
12054 |
+
*
|
12055 |
+
* @return FS_Plugin[]
|
12056 |
+
*
|
12057 |
+
* @uses FS_Api
|
12058 |
+
*/
|
12059 |
+
private function sync_addons( $flush = false ) {
|
12060 |
+
$this->_logger->entrance();
|
12061 |
+
|
12062 |
+
$api = $this->get_api_site_or_plugin_scope();
|
12063 |
+
|
12064 |
+
/**
|
12065 |
+
* @since 1.2.1
|
12066 |
+
*
|
12067 |
+
* If there's a cached version of the add-ons and not asking
|
12068 |
+
* for a flush, just use the currently stored add-ons.
|
12069 |
+
*/
|
12070 |
+
if ( ! $flush && $api->is_cached( '/addons.json?enriched=true' ) ) {
|
12071 |
+
$addons = self::get_all_addons();
|
12072 |
+
|
12073 |
+
return $addons[ $this->_plugin->id ];
|
12074 |
+
}
|
12075 |
+
|
12076 |
+
$result = $api->get( '/addons.json?enriched=true', $flush );
|
12077 |
+
|
12078 |
+
$addons = array();
|
12079 |
+
if ( $this->is_api_result_object( $result, 'plugins' ) &&
|
12080 |
+
is_array( $result->plugins )
|
12081 |
+
) {
|
12082 |
+
for ( $i = 0, $len = count( $result->plugins ); $i < $len; $i ++ ) {
|
12083 |
+
$addons[ $i ] = new FS_Plugin( $result->plugins[ $i ] );
|
12084 |
+
}
|
12085 |
+
|
12086 |
+
$this->_store_addons( $addons, true );
|
12087 |
+
}
|
12088 |
+
|
12089 |
+
return $addons;
|
12090 |
+
}
|
12091 |
+
|
12092 |
+
/**
|
12093 |
+
* Handle user email update.
|
12094 |
+
*
|
12095 |
+
* @author Vova Feldman (@svovaf)
|
12096 |
+
* @since 1.0.3
|
12097 |
+
* @uses FS_Api
|
12098 |
+
*
|
12099 |
+
* @param string $new_email
|
12100 |
+
*
|
12101 |
+
* @return object
|
12102 |
+
*/
|
12103 |
+
private function update_email( $new_email ) {
|
12104 |
+
$this->_logger->entrance();
|
12105 |
+
|
12106 |
+
|
12107 |
+
$api = $this->get_api_user_scope();
|
12108 |
+
$user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array(
|
12109 |
+
'email' => $new_email,
|
12110 |
+
'after_email_confirm_url' => $this->_get_admin_page_url(
|
12111 |
+
'account',
|
12112 |
+
array( 'fs_action' => 'sync_user' )
|
12113 |
+
),
|
12114 |
+
) );
|
12115 |
+
|
12116 |
+
if ( ! isset( $user->error ) ) {
|
12117 |
+
$this->_user->email = $user->email;
|
12118 |
+
$this->_user->is_verified = $user->is_verified;
|
12119 |
+
$this->_store_user();
|
12120 |
+
} else {
|
12121 |
+
// handle different error cases.
|
12122 |
+
|
12123 |
+
}
|
12124 |
+
|
12125 |
+
return $user;
|
12126 |
+
}
|
12127 |
+
|
12128 |
+
#----------------------------------------------------------------------------------
|
12129 |
+
#region API Error Handling
|
12130 |
+
#----------------------------------------------------------------------------------
|
12131 |
+
|
12132 |
+
/**
|
12133 |
+
* @author Vova Feldman (@svovaf)
|
12134 |
+
* @since 1.1.1
|
12135 |
+
*
|
12136 |
+
* @param mixed $result
|
12137 |
+
*
|
12138 |
+
* @return bool Is API result contains an error.
|
12139 |
+
*/
|
12140 |
+
private function is_api_error( $result ) {
|
12141 |
+
return FS_Api::is_api_error( $result );
|
12142 |
+
}
|
12143 |
+
|
12144 |
+
/**
|
12145 |
+
* Checks if given API result is a non-empty and not an error object.
|
12146 |
+
*
|
12147 |
+
* @author Vova Feldman (@svovaf)
|
12148 |
+
* @since 1.2.1.5
|
12149 |
+
*
|
12150 |
+
* @param mixed $result
|
12151 |
+
* @param string|null $required_property Optional property we want to verify that is set.
|
12152 |
+
*
|
12153 |
+
* @return bool
|
12154 |
+
*/
|
12155 |
+
function is_api_result_object( $result, $required_property = null ) {
|
12156 |
+
return FS_Api::is_api_result_object( $result, $required_property );
|
12157 |
+
}
|
12158 |
+
|
12159 |
+
/**
|
12160 |
+
* Checks if given API result is a non-empty entity object with non-empty ID.
|
12161 |
+
*
|
12162 |
+
* @author Vova Feldman (@svovaf)
|
12163 |
+
* @since 1.2.1.5
|
12164 |
+
*
|
12165 |
+
* @param mixed $result
|
12166 |
+
*
|
12167 |
+
* @return bool
|
12168 |
+
*/
|
12169 |
+
private function is_api_result_entity( $result ) {
|
12170 |
+
return FS_Api::is_api_result_entity( $result );
|
12171 |
+
}
|
12172 |
+
|
12173 |
+
#endregion
|
12174 |
+
|
12175 |
+
/**
|
12176 |
+
* Make sure a given argument is an array of a specific type.
|
12177 |
+
*
|
12178 |
+
* @author Vova Feldman (@svovaf)
|
12179 |
+
* @since 1.2.1.5
|
12180 |
+
*
|
12181 |
+
* @param mixed $array
|
12182 |
+
* @param string $class
|
12183 |
+
*
|
12184 |
+
* @return bool
|
12185 |
+
*/
|
12186 |
+
private function is_array_instanceof( $array, $class ) {
|
12187 |
+
return ( is_array( $array ) && ( empty( $array ) || $array[0] instanceof $class ) );
|
12188 |
+
}
|
12189 |
+
|
12190 |
+
/**
|
12191 |
+
* Start install ownership change.
|
12192 |
+
*
|
12193 |
+
* @author Vova Feldman (@svovaf)
|
12194 |
+
* @since 1.1.1
|
12195 |
+
* @uses FS_Api
|
12196 |
+
*
|
12197 |
+
* @param string $candidate_email
|
12198 |
+
*
|
12199 |
+
* @return bool Is ownership change successfully initiated.
|
12200 |
+
*/
|
12201 |
+
private function init_change_owner( $candidate_email ) {
|
12202 |
+
$this->_logger->entrance();
|
12203 |
+
|
12204 |
+
$api = $this->get_api_site_scope();
|
12205 |
+
$result = $api->call( "/users/{$this->_user->id}.json", 'put', array(
|
12206 |
+
'email' => $candidate_email,
|
12207 |
+
'after_confirm_url' => $this->_get_admin_page_url(
|
12208 |
+
'account',
|
12209 |
+
array( 'fs_action' => 'change_owner' )
|
12210 |
+
),
|
12211 |
+
) );
|
12212 |
+
|
12213 |
+
return ! $this->is_api_error( $result );
|
12214 |
+
}
|
12215 |
+
|
12216 |
+
/**
|
12217 |
+
* Handle install ownership change.
|
12218 |
+
*
|
12219 |
+
* @author Vova Feldman (@svovaf)
|
12220 |
+
* @since 1.1.1
|
12221 |
+
* @uses FS_Api
|
12222 |
+
*
|
12223 |
+
* @return bool Was ownership change successfully complete.
|
12224 |
+
*/
|
12225 |
+
private function complete_change_owner() {
|
12226 |
+
$this->_logger->entrance();
|
12227 |
+
|
12228 |
+
$site_result = $this->get_api_site_scope( true )->get();
|
12229 |
+
$site = new FS_Site( $site_result );
|
12230 |
+
$this->_site = $site;
|
12231 |
+
|
12232 |
+
$user = new FS_User();
|
12233 |
+
$user->id = fs_request_get( 'user_id' );
|
12234 |
+
|
12235 |
+
// Validate install's user and given user.
|
12236 |
+
if ( $user->id != $this->_site->user_id ) {
|
12237 |
+
return false;
|
12238 |
+
}
|
12239 |
+
|
12240 |
+
$user->public_key = fs_request_get( 'user_public_key' );
|
12241 |
+
$user->secret_key = fs_request_get( 'user_secret_key' );
|
12242 |
+
|
12243 |
+
// Fetch new user information.
|
12244 |
+
$this->_user = $user;
|
12245 |
+
$user_result = $this->get_api_user_scope( true )->get();
|
12246 |
+
$user = new FS_User( $user_result );
|
12247 |
+
$this->_user = $user;
|
12248 |
+
|
12249 |
+
$this->_set_account( $user, $site );
|
12250 |
+
|
12251 |
+
return true;
|
12252 |
+
}
|
12253 |
+
|
12254 |
+
/**
|
12255 |
+
* Handle user name update.
|
12256 |
+
*
|
12257 |
+
* @author Vova Feldman (@svovaf)
|
12258 |
+
* @since 1.0.9
|
12259 |
+
* @uses FS_Api
|
12260 |
+
*
|
12261 |
+
* @return object
|
12262 |
+
*/
|
12263 |
+
private function update_user_name() {
|
12264 |
+
$this->_logger->entrance();
|
12265 |
+
$name = fs_request_get( 'fs_user_name_' . $this->get_unique_affix(), '' );
|
12266 |
+
|
12267 |
+
$api = $this->get_api_user_scope();
|
12268 |
+
$user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
|
12269 |
+
'name' => $name,
|
12270 |
+
) );
|
12271 |
+
|
12272 |
+
if ( ! isset( $user->error ) ) {
|
12273 |
+
$this->_user->first = $user->first;
|
12274 |
+
$this->_user->last = $user->last;
|
12275 |
+
$this->_store_user();
|
12276 |
+
} else {
|
12277 |
+
// handle different error cases.
|
12278 |
+
|
12279 |
+
}
|
12280 |
+
|
12281 |
+
return $user;
|
12282 |
+
}
|
12283 |
+
|
12284 |
+
/**
|
12285 |
+
* Verify user email.
|
12286 |
+
*
|
12287 |
+
* @author Vova Feldman (@svovaf)
|
12288 |
+
* @since 1.0.3
|
12289 |
+
* @uses FS_Api
|
12290 |
+
*/
|
12291 |
+
private function verify_email() {
|
12292 |
+
$this->_handle_account_user_sync();
|
12293 |
+
|
12294 |
+
if ( $this->_user->is_verified() ) {
|
12295 |
+
return;
|
12296 |
+
}
|
12297 |
+
|
12298 |
+
$api = $this->get_api_site_scope();
|
12299 |
+
$result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
|
12300 |
+
'after_email_confirm_url' => $this->_get_admin_page_url(
|
12301 |
+
'account',
|
12302 |
+
array( 'fs_action' => 'sync_user' )
|
12303 |
+
)
|
12304 |
+
) );
|
12305 |
+
|
12306 |
+
if ( ! isset( $result->error ) ) {
|
12307 |
+
$this->_admin_notices->add( sprintf(
|
12308 |
+
$this->get_text_inline( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'verification-email-sent-message' ),
|
12309 |
+
sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
|
12310 |
+
) );
|
12311 |
+
} else {
|
12312 |
+
// handle different error cases.
|
12313 |
+
|
12314 |
+
}
|
12315 |
+
}
|
12316 |
+
|
12317 |
+
/**
|
12318 |
+
* @author Vova Feldman (@svovaf)
|
12319 |
+
* @since 1.1.2
|
12320 |
+
*
|
12321 |
+
* @param array $params
|
12322 |
+
*
|
12323 |
+
* @return string
|
12324 |
+
*/
|
12325 |
+
function get_activation_url( $params = array() ) {
|
12326 |
+
if ( $this->is_addon() && $this->has_free_plan() ) {
|
12327 |
+
/**
|
12328 |
+
* @author Vova Feldman (@svovaf)
|
12329 |
+
* @since 1.2.1.7 Add-on's activation is the parent's module activation.
|
12330 |
+
*/
|
12331 |
+
return $this->get_parent_instance()->get_activation_url( $params );
|
12332 |
+
}
|
12333 |
+
|
12334 |
+
return $this->apply_filters( 'connect_url', $this->_get_admin_page_url( '', $params ) );
|
12335 |
+
}
|
12336 |
+
|
12337 |
+
/**
|
12338 |
+
* @author Vova Feldman (@svovaf)
|
12339 |
+
* @since 1.2.1.5
|
12340 |
+
*
|
12341 |
+
* @param array $params
|
12342 |
+
*
|
12343 |
+
* @return string
|
12344 |
+
*/
|
12345 |
+
function get_reconnect_url( $params = array() ) {
|
12346 |
+
$params['fs_action'] = 'reset_anonymous_mode';
|
12347 |
+
$params['fs_unique_affix'] = $this->get_unique_affix();
|
12348 |
+
|
12349 |
+
return $this->get_activation_url( $params );
|
12350 |
+
}
|
12351 |
+
|
12352 |
+
/**
|
12353 |
+
* Get the URL of the page that should be loaded after the user connect
|
12354 |
+
* or skip in the opt-in screen.
|
12355 |
+
*
|
12356 |
+
* @author Vova Feldman (@svovaf)
|
12357 |
+
* @since 1.1.3
|
12358 |
+
*
|
12359 |
+
* @param string $filter Filter name.
|
12360 |
+
* @param array $params Since 1.2.2.7
|
12361 |
+
*
|
12362 |
+
* @return string
|
12363 |
+
*/
|
12364 |
+
function get_after_activation_url( $filter, $params = array() ) {
|
12365 |
+
if ( $this->is_free_wp_org_theme() &&
|
12366 |
+
fs_request_has( 'pending_activation' )
|
12367 |
+
) {
|
12368 |
+
$first_time_path = '';
|
12369 |
+
} else {
|
12370 |
+
$first_time_path = $this->_menu->get_first_time_path();
|
12371 |
+
}
|
12372 |
+
|
12373 |
+
return add_query_arg( $params, $this->apply_filters(
|
12374 |
+
$filter,
|
12375 |
+
empty( $first_time_path ) ?
|
12376 |
+
$this->_get_admin_page_url() :
|
12377 |
+
$first_time_path
|
12378 |
+
) );
|
12379 |
+
}
|
12380 |
+
|
12381 |
+
/**
|
12382 |
+
* Handle account page updates / edits / actions.
|
12383 |
+
*
|
12384 |
+
* @author Vova Feldman (@svovaf)
|
12385 |
+
* @since 1.0.2
|
12386 |
+
*
|
12387 |
+
*/
|
12388 |
+
private function _handle_account_edits() {
|
12389 |
+
if ( ! $this->is_user_admin() ) {
|
12390 |
+
return;
|
12391 |
+
}
|
12392 |
+
|
12393 |
+
$plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
|
12394 |
+
$action = fs_get_action();
|
12395 |
+
|
12396 |
+
// Alias.
|
12397 |
+
$oops_text = $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...';
|
12398 |
+
|
12399 |
+
switch ( $action ) {
|
12400 |
+
case 'delete_account':
|
12401 |
+
check_admin_referer( $action );
|
12402 |
+
|
12403 |
+
if ( $plugin_id == $this->get_id() ) {
|
12404 |
+
$this->delete_account_event();
|
12405 |
+
|
12406 |
+
// Clear user and site.
|
12407 |
+
$this->_site = null;
|
12408 |
+
$this->_user = null;
|
12409 |
+
|
12410 |
+
fs_redirect( $this->get_activation_url() );
|
12411 |
+
} else {
|
12412 |
+
if ( $this->is_addon_activated( $plugin_id ) ) {
|
12413 |
+
$fs_addon = self::get_instance_by_id( $plugin_id );
|
12414 |
+
$fs_addon->delete_account_event();
|
12415 |
+
|
12416 |
+
fs_redirect( $this->_get_admin_page_url( 'account' ) );
|
12417 |
+
}
|
12418 |
+
}
|
12419 |
+
|
12420 |
+
return;
|
12421 |
+
|
12422 |
+
case 'downgrade_account':
|
12423 |
+
check_admin_referer( $action );
|
12424 |
+
|
12425 |
+
if ( $plugin_id == $this->get_id() ) {
|
12426 |
+
$this->_downgrade_site();
|
12427 |
+
} else if ( $this->is_addon_activated( $plugin_id ) ) {
|
12428 |
+
$fs_addon = self::get_instance_by_id( $plugin_id );
|
12429 |
+
$fs_addon->_downgrade_site();
|
12430 |
+
}
|
12431 |
+
|
12432 |
+
return;
|
12433 |
+
|
12434 |
+
case 'activate_license':
|
12435 |
+
check_admin_referer( $action );
|
12436 |
+
|
12437 |
+
if ( $plugin_id == $this->get_id() ) {
|
12438 |
+
$this->_activate_license();
|
12439 |
+
} else {
|
12440 |
+
if ( $this->is_addon_activated( $plugin_id ) ) {
|
12441 |
+
$fs_addon = self::get_instance_by_id( $plugin_id );
|
12442 |
+
$fs_addon->_activate_license();
|
12443 |
+
}
|
12444 |
+
}
|
12445 |
+
|
12446 |
+
return;
|
12447 |
+
|
12448 |
+
case 'deactivate_license':
|
12449 |
+
check_admin_referer( $action );
|
12450 |
+
|
12451 |
+
if ( $plugin_id == $this->get_id() ) {
|
12452 |
+
$this->_deactivate_license();
|
12453 |
+
|
12454 |
+
if ( $this->is_only_premium() ) {
|
12455 |
+
// Clear user and site.
|
12456 |
+
$this->_site = null;
|
12457 |
+
$this->_user = null;
|
12458 |
+
|
12459 |
+
fs_redirect( $this->get_activation_url() );
|
12460 |
+
}
|
12461 |
+
} else {
|
12462 |
+
if ( $this->is_addon_activated( $plugin_id ) ) {
|
12463 |
+
$fs_addon = self::get_instance_by_id( $plugin_id );
|
12464 |
+
$fs_addon->_deactivate_license();
|
12465 |
+
}
|
12466 |
+
}
|
12467 |
+
|
12468 |
+
return;
|
12469 |
+
|
12470 |
+
case 'check_updates':
|
12471 |
+
check_admin_referer( $action );
|
12472 |
+
$this->check_updates();
|
12473 |
+
|
12474 |
+
return;
|
12475 |
+
|
12476 |
+
case 'change_owner':
|
12477 |
+
$state = fs_request_get( 'state', 'init' );
|
12478 |
+
switch ( $state ) {
|
12479 |
+
case 'init':
|
12480 |
+
$candidate_email = fs_request_get( 'candidate_email', '' );
|
12481 |
+
|
12482 |
+
if ( $this->init_change_owner( $candidate_email ) ) {
|
12483 |
+
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.', 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
|
12484 |
+
}
|
12485 |
+
break;
|
12486 |
+
case 'owner_confirmed':
|
12487 |
+
$candidate_email = fs_request_get( 'candidate_email', '' );
|
12488 |
+
|
12489 |
+
$this->_admin_notices->add( sprintf( $this->get_text_inline( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
|
12490 |
+
break;
|
12491 |
+
case 'candidate_confirmed':
|
12492 |
+
if ( $this->complete_change_owner() ) {
|
12493 |
+
$this->_admin_notices->add_sticky(
|
12494 |
+
sprintf( $this->get_text_inline( '%s is the new owner of the account.', 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
|
12495 |
+
'ownership_changed',
|
12496 |
+
$this->get_text_x_inline( 'Congrats', 'as congratulations', 'congrats' ) . '!'
|
12497 |
+
);
|
12498 |
+
} else {
|
12499 |
+
// @todo Handle failed ownership change message.
|
12500 |
+
}
|
12501 |
+
break;
|
12502 |
+
}
|
12503 |
+
|
12504 |
+
return;
|
12505 |
+
|
12506 |
+
case 'update_email':
|
12507 |
+
check_admin_referer( 'update_email' );
|
12508 |
+
|
12509 |
+
$new_email = fs_request_get( 'fs_email_' . $this->get_unique_affix(), '' );
|
12510 |
+
$result = $this->update_email( $new_email );
|
12511 |
+
|
12512 |
+
if ( isset( $result->error ) ) {
|
12513 |
+
switch ( $result->error->code ) {
|
12514 |
+
case 'user_exist':
|
12515 |
+
$this->_admin_notices->add(
|
12516 |
+
$this->get_text_inline( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'user-exist-message' ) . ' ' .
|
12517 |
+
sprintf( $this->get_text_inline( 'If you would like to give up the ownership of the %s\'s account to %s click the Change Ownership button.', 'user-exist-message_ownership' ), $this->_module_type, '<b>' . $new_email . '</b>' ) .
|
12518 |
+
sprintf(
|
12519 |
+
'<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s ➜</button></a>',
|
12520 |
+
$this->get_account_url( 'change_owner', array(
|
12521 |
+
'state' => 'init',
|
12522 |
+
'candidate_email' => $new_email
|
12523 |
+
) ),
|
12524 |
+
$this->get_text_inline( 'Change Ownership', 'change-ownership' )
|
12525 |
+
),
|
12526 |
+
$oops_text,
|
12527 |
+
'error'
|
12528 |
+
);
|
12529 |
+
break;
|
12530 |
+
}
|
12531 |
+
} else {
|
12532 |
+
$this->_admin_notices->add( $this->get_text_inline( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.', 'email-updated-message' ) );
|
12533 |
+
}
|
12534 |
+
|
12535 |
+
return;
|
12536 |
+
|
12537 |
+
case 'update_user_name':
|
12538 |
+
check_admin_referer( 'update_user_name' );
|
12539 |
+
|
12540 |
+
$result = $this->update_user_name();
|
12541 |
+
|
12542 |
+
if ( isset( $result->error ) ) {
|
12543 |
+
$this->_admin_notices->add(
|
12544 |
+
$this->get_text_inline( 'Please provide your full name.', 'name-update-failed-message' ),
|
12545 |
+
$oops_text,
|
12546 |
+
'error'
|
12547 |
+
);
|
12548 |
+
} else {
|
12549 |
+
$this->_admin_notices->add( $this->get_text_inline( 'Your name was successfully updated.', 'name-updated-message' ) );
|
12550 |
+
}
|
12551 |
+
|
12552 |
+
return;
|
12553 |
+
|
12554 |
+
#region Actions that might be called from external links (e.g. email)
|
12555 |
+
|
12556 |
+
case 'cancel_trial':
|
12557 |
+
if ( $plugin_id == $this->get_id() ) {
|
12558 |
+
$this->_cancel_trial();
|
12559 |
+
} else {
|
12560 |
+
if ( $this->is_addon_activated( $plugin_id ) ) {
|
12561 |
+
$fs_addon = self::get_instance_by_id( $plugin_id );
|
12562 |
+
$fs_addon->_cancel_trial();
|
12563 |
+
}
|
12564 |
+
}
|
12565 |
+
|
12566 |
+
return;
|
12567 |
+
|
12568 |
+
case 'verify_email':
|
12569 |
+
$this->verify_email();
|
12570 |
+
|
12571 |
+
return;
|
12572 |
+
|
12573 |
+
case 'sync_user':
|
12574 |
+
$this->_handle_account_user_sync();
|
12575 |
+
|
12576 |
+
return;
|
12577 |
+
|
12578 |
+
case $this->get_unique_affix() . '_sync_license':
|
12579 |
+
$this->_sync_license();
|
12580 |
+
|
12581 |
+
return;
|
12582 |
+
|
12583 |
+
case 'download_latest':
|
12584 |
+
$this->download_latest_directly( $plugin_id );
|
12585 |
+
|
12586 |
+
return;
|
12587 |
+
|
12588 |
+
#endregion
|
12589 |
+
}
|
12590 |
+
|
12591 |
+
if ( WP_FS__IS_POST_REQUEST ) {
|
12592 |
+
$properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
|
12593 |
+
foreach ( $properties as $p ) {
|
12594 |
+
if ( 'update_' . $p === $action ) {
|
12595 |
+
check_admin_referer( $action );
|
12596 |
+
|
12597 |
+
$this->_logger->log( $action );
|
12598 |
+
|
12599 |
+
$site_property = substr( $p, strlen( 'site_' ) );
|
12600 |
+
$site_property_value = fs_request_get( 'fs_' . $p . '_' . $this->get_unique_affix(), '' );
|
12601 |
+
$this->get_site()->{$site_property} = $site_property_value;
|
12602 |
+
|
12603 |
+
// Store account after modification.
|
12604 |
+
$this->_store_site();
|
12605 |
+
|
12606 |
+
$this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );
|
12607 |
+
|
12608 |
+
$this->_admin_notices->add( sprintf(
|
12609 |
+
/* translators: %s: User's account property (e.g. email address, name) */
|
12610 |
+
$this->get_text_inline( 'You have successfully updated your %s.', 'x-updated' ),
|
12611 |
+
'<b>' . str_replace( '_', ' ', $p ) . '</b>'
|
12612 |
+
) );
|
12613 |
+
|
12614 |
+
return;
|
12615 |
+
}
|
12616 |
+
}
|
12617 |
+
}
|
12618 |
+
}
|
12619 |
+
|
12620 |
+
/**
|
12621 |
+
* Account page resources load.
|
12622 |
+
*
|
12623 |
+
* @author Vova Feldman (@svovaf)
|
12624 |
+
* @since 1.0.6
|
12625 |
+
*/
|
12626 |
+
function _account_page_load() {
|
12627 |
+
$this->_logger->entrance();
|
12628 |
+
|
12629 |
+
$this->_logger->info( var_export( $_REQUEST, true ) );
|
12630 |
+
|
12631 |
+
fs_enqueue_local_style( 'fs_account', '/admin/account.css' );
|
12632 |
+
|
12633 |
+
if ( $this->has_addons() ) {
|
12634 |
+
wp_enqueue_script( 'plugin-install' );
|
12635 |
+
add_thickbox();
|
12636 |
+
|
12637 |
+
function fs_addons_body_class( $classes ) {
|
12638 |
+
$classes .= ' plugins-php';
|
12639 |
+
|
12640 |
+
return $classes;
|
12641 |
+
}
|
12642 |
+
|
12643 |
+
add_filter( 'admin_body_class', 'fs_addons_body_class' );
|
12644 |
+
}
|
12645 |
+
|
12646 |
+
if ( $this->has_paid_plan() &&
|
12647 |
+
! $this->has_any_license() &&
|
12648 |
+
! $this->is_sync_executed() &&
|
12649 |
+
$this->is_tracking_allowed()
|
12650 |
+
) {
|
12651 |
+
/**
|
12652 |
+
* If no licenses found and no sync job was executed during the last 24 hours,
|
12653 |
+
* just execute the sync job right away (blocking execution).
|
12654 |
+
*
|
12655 |
+
* @since 1.1.7.3
|
12656 |
+
*/
|
12657 |
+
$this->run_manual_sync();
|
12658 |
+
}
|
12659 |
+
|
12660 |
+
$this->_handle_account_edits();
|
12661 |
+
|
12662 |
+
$this->do_action( 'account_page_load_before_departure' );
|
12663 |
+
}
|
12664 |
+
|
12665 |
+
/**
|
12666 |
+
* Renders the "Affiliation" page.
|
12667 |
+
*
|
12668 |
+
* @author Leo Fajardo (@leorw)
|
12669 |
+
* @since 1.2.3
|
12670 |
+
*/
|
12671 |
+
function _affiliation_page_render() {
|
12672 |
+
$this->_logger->entrance();
|
12673 |
+
|
12674 |
+
fs_enqueue_local_style( 'fs_affiliation', '/admin/affiliation.css' );
|
12675 |
+
|
12676 |
+
$vars = array( 'id' => $this->_module_id );
|
12677 |
+
echo $this->apply_filters( "/forms/affiliation.php", fs_get_template( '/forms/affiliation.php', $vars ) );
|
12678 |
+
}
|
12679 |
+
|
12680 |
+
|
12681 |
+
/**
|
12682 |
+
* Render account page.
|
12683 |
+
*
|
12684 |
+
* @author Vova Feldman (@svovaf)
|
12685 |
+
* @since 1.0.0
|
12686 |
+
*/
|
12687 |
+
function _account_page_render() {
|
12688 |
+
$this->_logger->entrance();
|
12689 |
+
|
12690 |
+
$template = 'account.php';
|
12691 |
+
$vars = array( 'id' => $this->_module_id );
|
12692 |
+
|
12693 |
+
/**
|
12694 |
+
* Added filter to the template to allow developers wrapping the template
|
12695 |
+
* in custom HTML (e.g. within a wizard/tabs).
|
12696 |
+
*
|
12697 |
+
* @author Vova Feldman (@svovaf)
|
12698 |
+
* @since 1.2.1.6
|
12699 |
+
*/
|
12700 |
+
echo $this->apply_filters( "templates/{$template}", fs_get_template( $template, $vars ) );
|
12701 |
+
}
|
12702 |
+
|
12703 |
+
/**
|
12704 |
+
* Render account connect page.
|
12705 |
+
*
|
12706 |
+
* @author Vova Feldman (@svovaf)
|
12707 |
+
* @since 1.0.7
|
12708 |
+
*/
|
12709 |
+
function _connect_page_render() {
|
12710 |
+
$this->_logger->entrance();
|
12711 |
+
|
12712 |
+
$vars = array( 'id' => $this->_module_id );
|
12713 |
+
|
12714 |
+
/**
|
12715 |
+
* Added filter to the template to allow developers wrapping the template
|
12716 |
+
* in custom HTML (e.g. within a wizard/tabs).
|
12717 |
+
*
|
12718 |
+
* @author Vova Feldman (@svovaf)
|
12719 |
+
* @since 1.2.1.6
|
12720 |
+
*/
|
12721 |
+
echo $this->apply_filters( 'templates/connect.php', fs_get_template( 'connect.php', $vars ) );
|
12722 |
+
}
|
12723 |
+
|
12724 |
+
/**
|
12725 |
+
* Load required resources before add-ons page render.
|
12726 |
+
*
|
12727 |
+
* @author Vova Feldman (@svovaf)
|
12728 |
+
* @since 1.0.6
|
12729 |
+
*/
|
12730 |
+
function _addons_page_load() {
|
12731 |
+
$this->_logger->entrance();
|
12732 |
+
|
12733 |
+
fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
|
12734 |
+
|
12735 |
+
wp_enqueue_script( 'plugin-install' );
|
12736 |
+
add_thickbox();
|
12737 |
+
|
12738 |
+
function fs_addons_body_class( $classes ) {
|
12739 |
+
$classes .= ' plugins-php';
|
12740 |
+
|
12741 |
+
return $classes;
|
12742 |
+
}
|
12743 |
+
|
12744 |
+
add_filter( 'admin_body_class', 'fs_addons_body_class' );
|
12745 |
+
|
12746 |
+
if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) {
|
12747 |
+
$this->_admin_notices->add(
|
12748 |
+
sprintf( $this->get_text_inline( 'Just letting you know that the add-ons information of %s is being pulled from an external server.', 'addons-info-external-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
|
12749 |
+
$this->get_text_x_inline( 'Heads up', 'advance notice of something that will need attention.', 'heads-up' ),
|
12750 |
+
'update-nag'
|
12751 |
+
);
|
12752 |
+
}
|
12753 |
+
}
|
12754 |
+
|
12755 |
+
/**
|
12756 |
+
* Render add-ons page.
|
12757 |
+
*
|
12758 |
+
* @author Vova Feldman (@svovaf)
|
12759 |
+
* @since 1.0.6
|
12760 |
+
*/
|
12761 |
+
function _addons_page_render() {
|
12762 |
+
$this->_logger->entrance();
|
12763 |
+
|
12764 |
+
$vars = array( 'id' => $this->_module_id );
|
12765 |
+
|
12766 |
+
/**
|
12767 |
+
* Added filter to the template to allow developers wrapping the template
|
12768 |
+
* in custom HTML (e.g. within a wizard/tabs).
|
12769 |
+
*
|
12770 |
+
* @author Vova Feldman (@svovaf)
|
12771 |
+
* @since 1.2.1.6
|
12772 |
+
*/
|
12773 |
+
echo $this->apply_filters( 'templates/add-ons.php', fs_get_template( 'add-ons.php', $vars ) );
|
12774 |
+
}
|
12775 |
+
|
12776 |
+
/* Pricing & Upgrade
|
12777 |
+
------------------------------------------------------------------------------------------------------------------*/
|
12778 |
+
/**
|
12779 |
+
* Render pricing page.
|
12780 |
+
*
|
12781 |
+
* @author Vova Feldman (@svovaf)
|
12782 |
+
* @since 1.0.0
|
12783 |
+
*/
|
12784 |
+
function _pricing_page_render() {
|
12785 |
+
$this->_logger->entrance();
|
12786 |
+
|
12787 |
+
$vars = array( 'id' => $this->_module_id );
|
12788 |
+
|
12789 |
+
if ( 'true' === fs_request_get( 'checkout', false ) ) {
|
12790 |
+
fs_require_once_template( 'checkout.php', $vars );
|
12791 |
+
} else {
|
12792 |
+
fs_require_once_template( 'pricing.php', $vars );
|
12793 |
+
}
|
12794 |
+
}
|
12795 |
+
|
12796 |
+
#----------------------------------------------------------------------------------
|
12797 |
+
#region Contact Us
|
12798 |
+
#----------------------------------------------------------------------------------
|
12799 |
+
|
12800 |
+
/**
|
12801 |
+
* Render contact-us page.
|
12802 |
+
*
|
12803 |
+
* @author Vova Feldman (@svovaf)
|
12804 |
+
* @since 1.0.3
|
12805 |
+
*/
|
12806 |
+
function _contact_page_render() {
|
12807 |
+
$this->_logger->entrance();
|
12808 |
+
|
12809 |
+
$vars = array( 'id' => $this->_module_id );
|
12810 |
+
fs_require_once_template( 'contact.php', $vars );
|
12811 |
+
}
|
12812 |
+
|
12813 |
+
#endregion ------------------------------------------------------------------------
|
12814 |
+
|
12815 |
+
/**
|
12816 |
+
* Hide all admin notices to prevent distractions.
|
12817 |
+
*
|
12818 |
+
* @author Vova Feldman (@svovaf)
|
12819 |
+
* @since 1.0.3
|
12820 |
+
*
|
12821 |
+
* @uses remove_all_actions()
|
12822 |
+
*/
|
12823 |
+
private static function _hide_admin_notices() {
|
12824 |
+
remove_all_actions( 'admin_notices' );
|
12825 |
+
remove_all_actions( 'network_admin_notices' );
|
12826 |
+
remove_all_actions( 'all_admin_notices' );
|
12827 |
+
remove_all_actions( 'user_admin_notices' );
|
12828 |
+
}
|
12829 |
+
|
12830 |
+
static function _clean_admin_content_section_hook() {
|
12831 |
+
self::_hide_admin_notices();
|
12832 |
+
|
12833 |
+
// Hide footer.
|
12834 |
+
echo '<style>#wpfooter { display: none !important; }</style>';
|
12835 |
+
}
|
12836 |
+
|
12837 |
+
/**
|
12838 |
+
* Attach to admin_head hook to hide all admin notices.
|
12839 |
+
*
|
12840 |
+
* @author Vova Feldman (@svovaf)
|
12841 |
+
* @since 1.0.3
|
12842 |
+
*/
|
12843 |
+
static function _clean_admin_content_section() {
|
12844 |
+
add_action( 'admin_head', 'Freemius::_clean_admin_content_section_hook' );
|
12845 |
+
}
|
12846 |
+
|
12847 |
+
/* CSS & JavaScript
|
12848 |
+
------------------------------------------------------------------------------------------------------------------*/
|
12849 |
+
/* function _enqueue_script($handle, $src) {
|
12850 |
+
$url = plugins_url( substr( WP_FS__DIR_JS, strlen( $this->_plugin_dir_path ) ) . '/assets/js/' . $src );
|
12851 |
+
|
12852 |
+
$this->_logger->entrance( 'script = ' . $url );
|
12853 |
+
|
12854 |
+
wp_enqueue_script( $handle, $url );
|
12855 |
+
}*/
|
12856 |
+
|
12857 |
+
/* SDK
|
12858 |
+
------------------------------------------------------------------------------------------------------------------*/
|
12859 |
+
private $_user_api;
|
12860 |
+
|
12861 |
+
/**
|
12862 |
+
*
|
12863 |
+
* @author Vova Feldman (@svovaf)
|
12864 |
+
* @since 1.0.2
|
12865 |
+
*
|
12866 |
+
* @param bool $flush
|
12867 |
+
*
|
12868 |
+
* @return FS_Api
|
12869 |
+
*/
|
12870 |
+
function get_api_user_scope( $flush = false ) {
|
12871 |
+
if ( ! isset( $this->_user_api ) || $flush ) {
|
12872 |
+
$this->_user_api = FS_Api::instance(
|
12873 |
+
$this->_module_id,
|
12874 |
+
'user',
|
12875 |
+
$this->_user->id,
|
12876 |
+
$this->_user->public_key,
|
12877 |
+
! $this->is_live(),
|
12878 |
+
$this->_user->secret_key
|
12879 |
+
);
|
12880 |
+
}
|
12881 |
+
|
12882 |
+
return $this->_user_api;
|
12883 |
+
}
|
12884 |
+
|
12885 |
+
private $_site_api;
|
12886 |
+
|
12887 |
+
/**
|
12888 |
+
*
|
12889 |
+
* @author Vova Feldman (@svovaf)
|
12890 |
+
* @since 1.0.2
|
12891 |
+
*
|
12892 |
+
* @param bool $flush
|
12893 |
+
*
|
12894 |
+
* @return FS_Api
|
12895 |
+
*/
|
12896 |
+
function get_api_site_scope( $flush = false ) {
|
12897 |
+
if ( ! isset( $this->_site_api ) || $flush ) {
|
12898 |
+
$this->_site_api = FS_Api::instance(
|
12899 |
+
$this->_module_id,
|
12900 |
+
'install',
|
12901 |
+
$this->_site->id,
|
12902 |
+
$this->_site->public_key,
|
12903 |
+
! $this->is_live(),
|
12904 |
+
$this->_site->secret_key
|
12905 |
+
);
|
12906 |
+
}
|
12907 |
+
|
12908 |
+
return $this->_site_api;
|
12909 |
+
}
|
12910 |
+
|
12911 |
+
private $_plugin_api;
|
12912 |
+
|
12913 |
+
/**
|
12914 |
+
* Get plugin public API scope.
|
12915 |
+
*
|
12916 |
+
* @author Vova Feldman (@svovaf)
|
12917 |
+
* @since 1.0.7
|
12918 |
+
*
|
12919 |
+
* @return FS_Api
|
12920 |
+
*/
|
12921 |
+
function get_api_plugin_scope() {
|
12922 |
+
if ( ! isset( $this->_plugin_api ) ) {
|
12923 |
+
$this->_plugin_api = FS_Api::instance(
|
12924 |
+
$this->_module_id,
|
12925 |
+
'plugin',
|
12926 |
+
$this->_plugin->id,
|
12927 |
+
$this->_plugin->public_key,
|
12928 |
+
! $this->is_live()
|
12929 |
+
);
|
12930 |
+
}
|
12931 |
+
|
12932 |
+
return $this->_plugin_api;
|
12933 |
+
}
|
12934 |
+
|
12935 |
+
/**
|
12936 |
+
* Get site API scope object (fallback to public plugin scope when not registered).
|
12937 |
+
*
|
12938 |
+
* @author Vova Feldman (@svovaf)
|
12939 |
+
* @since 1.0.7
|
12940 |
+
*
|
12941 |
+
* @return FS_Api
|
12942 |
+
*/
|
12943 |
+
function get_api_site_or_plugin_scope() {
|
12944 |
+
return $this->is_registered() ?
|
12945 |
+
$this->get_api_site_scope() :
|
12946 |
+
$this->get_api_plugin_scope();
|
12947 |
+
}
|
12948 |
+
|
12949 |
+
/**
|
12950 |
+
* Show trial promotional notice (if any trial exist).
|
12951 |
+
*
|
12952 |
+
* @author Vova Feldman (@svovaf)
|
12953 |
+
* @since 1.0.9
|
12954 |
+
*
|
12955 |
+
* @param $plans
|
12956 |
+
*/
|
12957 |
+
function _check_for_trial_plans( $plans ) {
|
12958 |
+
$this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
|
12959 |
+
}
|
12960 |
+
|
12961 |
+
/**
|
12962 |
+
* During trial promotion the "upgrade" submenu item turns to
|
12963 |
+
* "start trial" to encourage the trial. Since we want to keep
|
12964 |
+
* the same menu item handler and there's no robust way to
|
12965 |
+
* add new arguments to the menu item link's querystring,
|
12966 |
+
* use JavaScript to find the menu item and update the href of
|
12967 |
+
* the link.
|
12968 |
+
*
|
12969 |
+
* @author Vova Feldman (@svovaf)
|
12970 |
+
* @since 1.2.1.5
|
12971 |
+
*/
|
12972 |
+
function _fix_start_trial_menu_item_url() {
|
12973 |
+
$template_args = array( 'id' => $this->_module_id );
|
12974 |
+
fs_require_template( 'add-trial-to-pricing.php', $template_args );
|
12975 |
+
}
|
12976 |
+
|
12977 |
+
/**
|
12978 |
+
* Check if module is currently in a trial promotion mode.
|
12979 |
+
*
|
12980 |
+
* @author Vova Feldman (@svovaf)
|
12981 |
+
* @since 1.2.2.7
|
12982 |
+
*
|
12983 |
+
* @return bool
|
12984 |
+
*/
|
12985 |
+
function is_in_trial_promotion() {
|
12986 |
+
return $this->_admin_notices->has_sticky( 'trial_promotion' );
|
12987 |
+
}
|
12988 |
+
|
12989 |
+
/**
|
12990 |
+
* Show trial promotional notice (if any trial exist).
|
12991 |
+
*
|
12992 |
+
* @author Vova Feldman (@svovaf)
|
12993 |
+
* @since 1.0.9
|
12994 |
+
*
|
12995 |
+
* @return bool If trial notice added.
|
12996 |
+
*/
|
12997 |
+
function _add_trial_notice() {
|
12998 |
+
if ( ! $this->is_user_admin() ) {
|
12999 |
+
return false;
|
13000 |
+
}
|
13001 |
+
|
13002 |
+
if ( ! $this->is_user_in_admin() ) {
|
13003 |
+
return false;
|
13004 |
+
}
|
13005 |
+
|
13006 |
+
// Check if trial message is already shown.
|
13007 |
+
if ( $this->is_in_trial_promotion() ) {
|
13008 |
+
add_action( 'admin_footer', array( &$this, '_fix_start_trial_menu_item_url' ) );
|
13009 |
+
|
13010 |
+
$this->_menu->add_counter_to_menu_item( 1, 'fs-trial' );
|
13011 |
+
|
13012 |
+
return false;
|
13013 |
+
}
|
13014 |
+
|
13015 |
+
if ( $this->is_premium() && ! WP_FS__DEV_MODE ) {
|
13016 |
+
// Don't show trial if running the premium code, unless running in DEV mode.
|
13017 |
+
return false;
|
13018 |
+
}
|
13019 |
+
|
13020 |
+
if ( ! $this->has_trial_plan() ) {
|
13021 |
+
// No plans with trial.
|
13022 |
+
return false;
|
13023 |
+
}
|
13024 |
+
|
13025 |
+
if ( ! $this->apply_filters( 'show_trial', true ) ) {
|
13026 |
+
// Developer explicitly asked not to show the trial promo.
|
13027 |
+
return false;
|
13028 |
+
}
|
13029 |
+
|
13030 |
+
if ( $this->is_registered() ) {
|
13031 |
+
// Check if trial already utilized.
|
13032 |
+
if ( $this->_site->is_trial_utilized() ) {
|
13033 |
+
return false;
|
13034 |
+
}
|
13035 |
+
|
13036 |
+
if ( $this->is_paying_or_trial() ) {
|
13037 |
+
// Don't show trial if paying or already in trial.
|
13038 |
+
return false;
|
13039 |
+
}
|
13040 |
+
}
|
13041 |
+
|
13042 |
+
if ( $this->is_activation_mode() || $this->is_pending_activation() ) {
|
13043 |
+
// If not yet opted-in/skipped, or pending activation, don't show trial.
|
13044 |
+
return false;
|
13045 |
+
}
|
13046 |
+
|
13047 |
+
$last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
|
13048 |
+
$was_promotion_shown_before = ( false !== $last_time_trial_promotion_shown );
|
13049 |
+
|
13050 |
+
// Show promotion if never shown before and 24 hours after initial activation with FS.
|
13051 |
+
if ( ! $was_promotion_shown_before &&
|
13052 |
+
$this->_storage->install_timestamp > ( time() - WP_FS__TIME_24_HOURS_IN_SEC )
|
13053 |
+
) {
|
13054 |
+
return false;
|
13055 |
+
}
|
13056 |
+
|
13057 |
+
// OR if promotion was shown before, try showing it every 30 days.
|
13058 |
+
if ( $was_promotion_shown_before &&
|
13059 |
+
30 * WP_FS__TIME_24_HOURS_IN_SEC > time() - $last_time_trial_promotion_shown
|
13060 |
+
) {
|
13061 |
+
return false;
|
13062 |
+
}
|
13063 |
+
|
13064 |
+
$trial_period = $this->_trial_days;
|
13065 |
+
$require_payment = $this->_is_trial_require_payment;
|
13066 |
+
$trial_url = $this->get_trial_url();
|
13067 |
+
$plans_string = strtolower( $this->get_text_inline( 'Awesome', 'awesome' ) );
|
13068 |
+
|
13069 |
+
if ( $this->is_registered() ) {
|
13070 |
+
// If opted-in, override trial with up to date data from API.
|
13071 |
+
$trial_plans = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
|
13072 |
+
$trial_plans_count = count( $trial_plans );
|
13073 |
+
|
13074 |
+
if ( 0 === $trial_plans_count ) {
|
13075 |
+
// If there's no plans with a trial just exit.
|
13076 |
+
return false;
|
13077 |
+
}
|
13078 |
+
|
13079 |
+
/**
|
13080 |
+
* @var FS_Plugin_Plan $paid_plan
|
13081 |
+
*/
|
13082 |
+
$paid_plan = $trial_plans[0];
|
13083 |
+
$require_payment = $paid_plan->is_require_subscription;
|
13084 |
+
$trial_period = $paid_plan->trial_period;
|
13085 |
+
|
13086 |
+
$total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );
|
13087 |
+
|
13088 |
+
if ( $total_paid_plans !== $trial_plans_count ) {
|
13089 |
+
// Not all paid plans have a trial - generate a string of those that have it.
|
13090 |
+
for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
|
13091 |
+
$plans_string .= sprintf(
|
13092 |
+
' <a href="%s">%s</a>',
|
13093 |
+
$trial_url,
|
13094 |
+
$trial_plans[ $i ]->title
|
13095 |
+
);
|
13096 |
+
|
13097 |
+
if ( $i < $trial_plans_count - 2 ) {
|
13098 |
+
$plans_string .= ', ';
|
13099 |
+
} else if ( $i == $trial_plans_count - 2 ) {
|
13100 |
+
$plans_string .= ' and ';
|
13101 |
+
}
|
13102 |
+
}
|
13103 |
+
}
|
13104 |
+
}
|
13105 |
+
|
13106 |
+
$message = sprintf(
|
13107 |
+
$this->get_text_x_inline( 'Hey', 'exclamation', 'hey' ) . '! ' . $this->get_text_inline( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.', 'trial-x-promotion-message' ),
|
13108 |
+
sprintf( '<b>%s</b>', $this->get_plugin_name() ),
|
13109 |
+
$plans_string,
|
13110 |
+
$trial_period
|
13111 |
+
);
|
13112 |
+
|
13113 |
+
// "No Credit-Card Required" or "No Commitment for N Days".
|
13114 |
+
$cc_string = $require_payment ?
|
13115 |
+
sprintf( $this->get_text_inline( 'No commitment for %s days - cancel anytime!', 'no-commitment-for-x-days' ), $trial_period ) :
|
13116 |
+
$this->get_text_inline( 'No credit card required', 'no-cc-required' ) . '!';
|
13117 |
+
|
13118 |
+
|
13119 |
+
// Start trial button.
|
13120 |
+
$button = ' ' . sprintf(
|
13121 |
+
'<a style="margin-left: 10px; vertical-align: super;" href="%s"><button class="button button-primary">%s ➜</button></a>',
|
13122 |
+
$trial_url,
|
13123 |
+
$this->get_text_x_inline( 'Start free trial', 'call to action', 'start-free-trial' )
|
13124 |
+
);
|
13125 |
+
|
13126 |
+
$this->_admin_notices->add_sticky(
|
13127 |
+
$this->apply_filters( 'trial_promotion_message', "{$message} {$cc_string} {$button}" ),
|
13128 |
+
'trial_promotion',
|
13129 |
+
'',
|
13130 |
+
'promotion'
|
13131 |
+
);
|
13132 |
+
|
13133 |
+
$this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;
|
13134 |
+
|
13135 |
+
return true;
|
13136 |
+
}
|
13137 |
+
|
13138 |
+
/**
|
13139 |
+
* Lets users/customers know that the product has an affiliate program.
|
13140 |
+
*
|
13141 |
+
* @author Leo Fajardo (@leorw)
|
13142 |
+
* @since 1.2.2.11
|
13143 |
+
*
|
13144 |
+
* @return bool Returns true if the notice has been added.
|
13145 |
+
*/
|
13146 |
+
function _add_affiliate_program_notice() {
|
13147 |
+
if ( ! $this->is_user_admin() ) {
|
13148 |
+
return false;
|
13149 |
+
}
|
13150 |
+
|
13151 |
+
if ( ! $this->is_user_in_admin() ) {
|
13152 |
+
return false;
|
13153 |
+
}
|
13154 |
+
|
13155 |
+
// Check if the notice is already shown.
|
13156 |
+
if ( $this->_admin_notices->has_sticky( 'affiliate_program' ) ) {
|
13157 |
+
return false;
|
13158 |
+
}
|
13159 |
+
|
13160 |
+
if (
|
13161 |
+
// Product has no affiliate program.
|
13162 |
+
! $this->has_affiliate_program() ||
|
13163 |
+
// User is already an affiliate.
|
13164 |
+
is_object( $this->affiliate ) ||
|
13165 |
+
// User has applied for an affiliate account.
|
13166 |
+
! empty( $this->_storage->affiliate_application_data ) ) {
|
13167 |
+
return false;
|
13168 |
+
}
|
13169 |
+
|
13170 |
+
if ( ! $this->apply_filters( 'show_affiliate_program_notice', true ) ) {
|
13171 |
+
// Developer explicitly asked not to show the notice about the affiliate program.
|
13172 |
+
return false;
|
13173 |
+
}
|
13174 |
+
|
13175 |
+
if ( $this->is_activation_mode() || $this->is_pending_activation() ) {
|
13176 |
+
// If not yet opted in/skipped, or pending activation, don't show the notice.
|
13177 |
+
return false;
|
13178 |
+
}
|
13179 |
+
|
13180 |
+
$last_time_notice_was_shown = $this->_storage->get( 'affiliate_program_notice_shown', false );
|
13181 |
+
$was_notice_shown_before = ( false !== $last_time_notice_was_shown );
|
13182 |
+
|
13183 |
+
/**
|
13184 |
+
* Do not show the notice if it was already shown before or less than 30 days have passed since the initial
|
13185 |
+
* activation with FS.
|
13186 |
+
*/
|
13187 |
+
if ( $was_notice_shown_before ||
|
13188 |
+
$this->_storage->install_timestamp > ( time() - ( WP_FS__TIME_24_HOURS_IN_SEC * 30 ) )
|
13189 |
+
) {
|
13190 |
+
return false;
|
13191 |
+
}
|
13192 |
+
|
13193 |
+
if ( ! $this->is_paying() &&
|
13194 |
+
FS_Plugin::AFFILIATE_MODERATION_CUSTOMERS == $this->_plugin->affiliate_moderation ) {
|
13195 |
+
// If the user is not a customer and the affiliate program is only for customers, don't show the notice.
|
13196 |
+
return false;
|
13197 |
+
}
|
13198 |
+
|
13199 |
+
$message = sprintf(
|
13200 |
+
$this->get_text_inline( 'Hey there, did you know that %s has an affiliate program? If you like the %s you can become our ambassador and earn some cash!', 'become-an-ambassador-admin-notice' ),
|
13201 |
+
sprintf( '<strong>%s</strong>', $this->get_plugin_name() ),
|
13202 |
+
$this->get_module_label( true )
|
13203 |
+
);
|
13204 |
+
|
13205 |
+
// HTML code for the "Learn more..." button.
|
13206 |
+
$button = ' ' . sprintf(
|
13207 |
+
'<a style="display: block; margin-top: 10px;" href="%s"><button class="button button-primary">%s ➜</button></a>',
|
13208 |
+
$this->_get_admin_page_url( 'affiliation' ),
|
13209 |
+
$this->get_text_inline( 'Learn more', 'learn-more' ) . '...'
|
13210 |
+
);
|
13211 |
+
|
13212 |
+
$this->_admin_notices->add_sticky(
|
13213 |
+
$this->apply_filters( 'affiliate_program_notice', "{$message} {$button}" ),
|
13214 |
+
'affiliate_program',
|
13215 |
+
'',
|
13216 |
+
'promotion'
|
13217 |
+
);
|
13218 |
+
|
13219 |
+
$this->_storage->affiliate_program_notice_shown = WP_FS__SCRIPT_START_TIME;
|
13220 |
+
|
13221 |
+
return true;
|
13222 |
+
}
|
13223 |
+
|
13224 |
+
/**
|
13225 |
+
* @author Vova Feldman (@svovaf)
|
13226 |
+
* @since 1.2.1.5
|
13227 |
+
*/
|
13228 |
+
function _enqueue_common_css() {
|
13229 |
+
if ( $this->has_paid_plan() && ! $this->is_paying() ) {
|
13230 |
+
// Add basic CSS for admin-notices and menu-item colors.
|
13231 |
+
fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
|
13232 |
+
}
|
13233 |
+
}
|
13234 |
+
|
13235 |
+
/**
|
13236 |
+
* @author Leo Fajardo (leorw)
|
13237 |
+
* @since 1.2.2
|
13238 |
+
*/
|
13239 |
+
function _show_theme_activation_optin_dialog() {
|
13240 |
+
fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
|
13241 |
+
|
13242 |
+
add_action( 'admin_footer-themes.php', array( &$this, '_add_fs_theme_activation_dialog' ) );
|
13243 |
+
}
|
13244 |
+
|
13245 |
+
/**
|
13246 |
+
* @author Leo Fajardo (leorw)
|
13247 |
+
* @since 1.2.2
|
13248 |
+
*/
|
13249 |
+
function _add_fs_theme_activation_dialog() {
|
13250 |
+
$vars = array( 'id' => $this->_module_id );
|
13251 |
+
fs_require_once_template( 'connect.php', $vars );
|
13252 |
+
}
|
13253 |
+
|
13254 |
+
/* Action Links
|
13255 |
+
------------------------------------------------------------------------------------------------------------------*/
|
13256 |
+
private $_action_links_hooked = false;
|
13257 |
+
private $_action_links = array();
|
13258 |
+
|
13259 |
+
/**
|
13260 |
+
* Hook to plugin action links filter.
|
13261 |
+
*
|
13262 |
+
* @author Vova Feldman (@svovaf)
|
13263 |
+
* @since 1.0.0
|
13264 |
+
*/
|
13265 |
+
private function hook_plugin_action_links() {
|
13266 |
+
$this->_logger->entrance();
|
13267 |
+
|
13268 |
+
$this->_action_links_hooked = true;
|
13269 |
+
|
13270 |
+
$this->_logger->log( 'Adding action links hooks.' );
|
13271 |
+
|
13272 |
+
// Add action link to settings page.
|
13273 |
+
add_filter( 'plugin_action_links_' . $this->_plugin_basename, array(
|
13274 |
+
&$this,
|
13275 |
+
'_modify_plugin_action_links_hook'
|
13276 |
+
), WP_FS__DEFAULT_PRIORITY, 2 );
|
13277 |
+
add_filter( 'network_admin_plugin_action_links_' . $this->_plugin_basename, array(
|
13278 |
+
&$this,
|
13279 |
+
'_modify_plugin_action_links_hook'
|
13280 |
+
), WP_FS__DEFAULT_PRIORITY, 2 );
|
13281 |
+
}
|
13282 |
+
|
13283 |
+
/**
|
13284 |
+
* Add plugin action link.
|
13285 |
+
*
|
13286 |
+
* @author Vova Feldman (@svovaf)
|
13287 |
+
* @since 1.0.0
|
13288 |
+
*
|
13289 |
+
* @param $label
|
13290 |
+
* @param $url
|
13291 |
+
* @param bool $external
|
13292 |
+
* @param int $priority
|
13293 |
+
* @param bool $key
|
13294 |
+
*/
|
13295 |
+
function add_plugin_action_link( $label, $url, $external = false, $priority = WP_FS__DEFAULT_PRIORITY, $key = false ) {
|
13296 |
+
$this->_logger->entrance();
|
13297 |
+
|
13298 |
+
if ( ! isset( $this->_action_links[ $priority ] ) ) {
|
13299 |
+
$this->_action_links[ $priority ] = array();
|
13300 |
+
}
|
13301 |
+
|
13302 |
+
if ( false === $key ) {
|
13303 |
+
$key = preg_replace( "/[^A-Za-z0-9 ]/", '', strtolower( $label ) );
|
13304 |
+
}
|
13305 |
+
|
13306 |
+
$this->_action_links[ $priority ][] = array(
|
13307 |
+
'label' => $label,
|
13308 |
+
'href' => $url,
|
13309 |
+
'key' => $key,
|
13310 |
+
'external' => $external
|
13311 |
+
);
|
13312 |
+
}
|
13313 |
+
|
13314 |
+
/**
|
13315 |
+
* Adds Upgrade and Add-Ons links to the main Plugins page link actions collection.
|
13316 |
+
*
|
13317 |
+
* @author Vova Feldman (@svovaf)
|
13318 |
+
* @since 1.0.0
|
13319 |
+
*/
|
13320 |
+
function _add_upgrade_action_link() {
|
13321 |
+
$this->_logger->entrance();
|
13322 |
+
|
13323 |
+
if ( $this->is_registered() ) {
|
13324 |
+
if ( ! $this->is_paying() && $this->has_paid_plan() ) {
|
13325 |
+
$this->add_plugin_action_link(
|
13326 |
+
$this->get_text_inline( 'Upgrade', 'upgrade' ),
|
13327 |
+
$this->get_upgrade_url(),
|
13328 |
+
false,
|
13329 |
+
7,
|
13330 |
+
'upgrade'
|
13331 |
+
);
|
13332 |
+
}
|
13333 |
+
|
13334 |
+
if ( $this->has_addons() ) {
|
13335 |
+
$this->add_plugin_action_link(
|
13336 |
+
$this->get_text_inline( 'Add-Ons', 'add-ons' ),
|
13337 |
+
$this->_get_admin_page_url( 'addons' ),
|
13338 |
+
false,
|
13339 |
+
9,
|
13340 |
+
'addons'
|
13341 |
+
);
|
13342 |
+
}
|
13343 |
+
}
|
13344 |
+
}
|
13345 |
+
|
13346 |
+
/**
|
13347 |
+
* Adds "Activate License" or "Change License" link to the main Plugins page link actions collection.
|
13348 |
+
*
|
13349 |
+
* @author Leo Fajardo (@leorw)
|
13350 |
+
* @since 1.1.9
|
13351 |
+
*/
|
13352 |
+
function _add_license_action_link() {
|
13353 |
+
$this->_logger->entrance();
|
13354 |
+
|
13355 |
+
if ( $this->is_free_plan() && $this->is_addon() ) {
|
13356 |
+
return;
|
13357 |
+
}
|
13358 |
+
|
13359 |
+
if ( ! self::is_ajax() ) {
|
13360 |
+
// Inject license activation dialog UI and client side code.
|
13361 |
+
add_action( 'admin_footer', array( &$this, '_add_license_activation_dialog_box' ) );
|
13362 |
+
}
|
13363 |
+
|
13364 |
+
$link_text = $this->is_free_plan() ?
|
13365 |
+
$this->get_text_inline( 'Activate License', 'activate-license' ) :
|
13366 |
+
$this->get_text_inline( 'Change License', 'change-license' );
|
13367 |
+
|
13368 |
+
$this->add_plugin_action_link(
|
13369 |
+
$link_text,
|
13370 |
+
'#',
|
13371 |
+
false,
|
13372 |
+
11,
|
13373 |
+
( 'activate-license ' . $this->get_unique_affix() )
|
13374 |
+
);
|
13375 |
+
}
|
13376 |
+
|
13377 |
+
/**
|
13378 |
+
* Adds "Opt in" or "Opt out" link to the main "Plugins" page link actions collection.
|
13379 |
+
*
|
13380 |
+
* @author Leo Fajardo (@leorw)
|
13381 |
+
* @since 1.2.1.5
|
13382 |
+
*/
|
13383 |
+
function _add_tracking_links() {
|
13384 |
+
if ( ! current_user_can( 'activate_plugins' ) ) {
|
13385 |
+
return;
|
13386 |
+
}
|
13387 |
+
|
13388 |
+
$this->_logger->entrance();
|
13389 |
+
|
13390 |
+
if ( fs_request_is_action_secure( $this->get_unique_affix() . '_reconnect' ) ) {
|
13391 |
+
if ( ! $this->is_registered() && $this->is_anonymous() ) {
|
13392 |
+
$this->connect_again();
|
13393 |
+
|
13394 |
+
return;
|
13395 |
+
}
|
13396 |
+
}
|
13397 |
+
|
13398 |
+
if ( ( $this->is_plugin() && ! self::is_plugins_page() ) ||
|
13399 |
+
( $this->is_theme() && ! self::is_themes_page() )
|
13400 |
+
) {
|
13401 |
+
// Only show tracking links on the plugins and themes pages.
|
13402 |
+
return;
|
13403 |
+
}
|
13404 |
+
|
13405 |
+
if ( ! $this->is_enable_anonymous() ) {
|
13406 |
+
// Don't allow to opt-out if anonymous mode is disabled.
|
13407 |
+
return;
|
13408 |
+
}
|
13409 |
+
|
13410 |
+
if ( ! $this->is_free_plan() ) {
|
13411 |
+
// Don't allow to opt-out if running in paid plan.
|
13412 |
+
return;
|
13413 |
+
}
|
13414 |
+
|
13415 |
+
if ( $this->add_ajax_action( 'stop_tracking', array( &$this, '_stop_tracking_callback' ) ) ) {
|
13416 |
+
return;
|
13417 |
+
}
|
13418 |
+
|
13419 |
+
if ( $this->add_ajax_action( 'allow_tracking', array( &$this, '_allow_tracking_callback' ) ) ) {
|
13420 |
+
return;
|
13421 |
+
}
|
13422 |
+
|
13423 |
+
$url = '#';
|
13424 |
+
|
13425 |
+
if ( $this->is_registered() ) {
|
13426 |
+
if ( $this->is_tracking_allowed() ) {
|
13427 |
+
$link_text_id = $this->get_text_inline( 'Opt Out', 'opt-out' );
|
13428 |
+
} else {
|
13429 |
+
$link_text_id = $this->get_text_inline( 'Opt In', 'opt-in' );
|
13430 |
+
}
|
13431 |
+
|
13432 |
+
add_action( 'admin_footer', array( &$this, '_add_optout_dialog' ) );
|
13433 |
+
} else {
|
13434 |
+
$link_text_id = $this->get_text_inline( 'Opt In', 'opt-in' );
|
13435 |
+
|
13436 |
+
$params = ! $this->is_anonymous() ?
|
13437 |
+
array() :
|
13438 |
+
array(
|
13439 |
+
'nonce' => wp_create_nonce( $this->get_unique_affix() . '_reconnect' ),
|
13440 |
+
'fs_action' => ( $this->get_unique_affix() . '_reconnect' ),
|
13441 |
+
);
|
13442 |
+
|
13443 |
+
$url = $this->get_activation_url( $params );
|
13444 |
+
}
|
13445 |
+
|
13446 |
+
if ( $this->is_plugin() && self::is_plugins_page() ) {
|
13447 |
+
$this->add_plugin_action_link(
|
13448 |
+
$link_text_id,
|
13449 |
+
$url,
|
13450 |
+
false,
|
13451 |
+
13,
|
13452 |
+
"opt-in-or-opt-out {$this->_slug}"
|
13453 |
+
);
|
13454 |
+
}
|
13455 |
+
}
|
13456 |
+
|
13457 |
+
/**
|
13458 |
+
* Get the URL of the page that should be loaded right after the plugin activation.
|
13459 |
+
*
|
13460 |
+
* @author Vova Feldman (@svovaf)
|
13461 |
+
* @since 1.1.7.4
|
13462 |
+
*
|
13463 |
+
* @return string
|
13464 |
+
*/
|
13465 |
+
function get_after_plugin_activation_redirect_url() {
|
13466 |
+
$url = false;
|
13467 |
+
|
13468 |
+
if ( ! $this->is_addon() || ! $this->has_free_plan() ) {
|
13469 |
+
$first_time_path = $this->_menu->get_first_time_path();
|
13470 |
+
$url = $this->is_activation_mode() ?
|
13471 |
+
$this->get_activation_url() :
|
13472 |
+
( empty( $first_time_path ) ?
|
13473 |
+
$this->_get_admin_page_url() :
|
13474 |
+
$first_time_path );
|
13475 |
+
} else {
|
13476 |
+
$plugin_fs = false;
|
13477 |
+
|
13478 |
+
if ( $this->is_parent_plugin_installed() ) {
|
13479 |
+
$plugin_fs = self::get_parent_instance();
|
13480 |
+
}
|
13481 |
+
|
13482 |
+
if ( is_object( $plugin_fs ) ) {
|
13483 |
+
if ( ! $plugin_fs->is_registered() ) {
|
13484 |
+
// Forward to parent plugin connect when parent not registered.
|
13485 |
+
$url = $plugin_fs->get_activation_url();
|
13486 |
+
} else {
|
13487 |
+
// Forward to account page.
|
13488 |
+
$url = $plugin_fs->_get_admin_page_url( 'account' );
|
13489 |
+
}
|
13490 |
+
}
|
13491 |
+
}
|
13492 |
+
|
13493 |
+
return $url;
|
13494 |
+
}
|
13495 |
+
|
13496 |
+
/**
|
13497 |
+
* Forward page to activation page.
|
13498 |
+
*
|
13499 |
+
* @author Vova Feldman (@svovaf)
|
13500 |
+
* @since 1.0.3
|
13501 |
+
*/
|
13502 |
+
function _redirect_on_activation_hook() {
|
13503 |
+
$url = $this->get_after_plugin_activation_redirect_url();
|
13504 |
+
|
13505 |
+
if ( is_string( $url ) ) {
|
13506 |
+
fs_redirect( $url );
|
13507 |
+
}
|
13508 |
+
}
|
13509 |
+
|
13510 |
+
/**
|
13511 |
+
* Modify plugin's page action links collection.
|
13512 |
+
*
|
13513 |
+
* @author Vova Feldman (@svovaf)
|
13514 |
+
* @since 1.0.0
|
13515 |
+
*
|
13516 |
+
* @param array $links
|
13517 |
+
* @param $file
|
13518 |
+
*
|
13519 |
+
* @return array
|
13520 |
+
*/
|
13521 |
+
function _modify_plugin_action_links_hook( $links, $file ) {
|
13522 |
+
$this->_logger->entrance();
|
13523 |
+
|
13524 |
+
$passed_deactivate = false;
|
13525 |
+
$deactivate_link = '';
|
13526 |
+
$before_deactivate = array();
|
13527 |
+
$after_deactivate = array();
|
13528 |
+
foreach ( $links as $key => $link ) {
|
13529 |
+
if ( 'deactivate' === $key ) {
|
13530 |
+
$deactivate_link = $link;
|
13531 |
+
$passed_deactivate = true;
|
13532 |
+
continue;
|
13533 |
+
}
|
13534 |
+
|
13535 |
+
if ( ! $passed_deactivate ) {
|
13536 |
+
$before_deactivate[ $key ] = $link;
|
13537 |
+
} else {
|
13538 |
+
$after_deactivate[ $key ] = $link;
|
13539 |
+
}
|
13540 |
+
}
|
13541 |
+
|
13542 |
+
ksort( $this->_action_links );
|
13543 |
+
|
13544 |
+
foreach ( $this->_action_links as $new_links ) {
|
13545 |
+
foreach ( $new_links as $link ) {
|
13546 |
+
$before_deactivate[ $link['key'] ] = '<a href="' . $link['href'] . '"' . ( $link['external'] ? ' target="_blank"' : '' ) . '>' . $link['label'] . '</a>';
|
13547 |
+
}
|
13548 |
+
}
|
13549 |
+
|
13550 |
+
if ( ! empty( $deactivate_link ) ) {
|
13551 |
+
/**
|
13552 |
+
* This HTML element is used to identify the correct plugin when attaching an event to its Deactivate link.
|
13553 |
+
*
|
13554 |
+
* @since 1.2.1.6 Always show the deactivation feedback form since we added automatic free version deactivation upon premium code activation.
|
13555 |
+
*/
|
13556 |
+
$deactivate_link .= '<i class="fs-module-id" data-module-id="' . $this->_module_id . '"></i>';
|
13557 |
+
|
13558 |
+
// Append deactivation link.
|
13559 |
+
$before_deactivate['deactivate'] = $deactivate_link;
|
13560 |
+
}
|
13561 |
+
|
13562 |
+
return array_merge( $before_deactivate, $after_deactivate );
|
13563 |
+
}
|
13564 |
+
|
13565 |
+
/**
|
13566 |
+
* Adds admin message.
|
13567 |
+
*
|
13568 |
+
* @author Vova Feldman (@svovaf)
|
13569 |
+
* @since 1.0.4
|
13570 |
+
*
|
13571 |
+
* @param string $message
|
13572 |
+
* @param string $title
|
13573 |
+
* @param string $type
|
13574 |
+
*/
|
13575 |
+
function add_admin_message( $message, $title = '', $type = 'success' ) {
|
13576 |
+
$this->_admin_notices->add( $message, $title, $type );
|
13577 |
+
}
|
13578 |
+
|
13579 |
+
/**
|
13580 |
+
* Adds sticky admin message.
|
13581 |
+
*
|
13582 |
+
* @author Vova Feldman (@svovaf)
|
13583 |
+
* @since 1.1.0
|
13584 |
+
*
|
13585 |
+
* @param string $message
|
13586 |
+
* @param string $id
|
13587 |
+
* @param string $title
|
13588 |
+
* @param string $type
|
13589 |
+
*/
|
13590 |
+
function add_sticky_admin_message( $message, $id, $title = '', $type = 'success' ) {
|
13591 |
+
$this->_admin_notices->add_sticky( $message, $id, $title, $type );
|
13592 |
+
}
|
13593 |
+
|
13594 |
+
/**
|
13595 |
+
* Helper function that returns the final steps for the upgrade completion.
|
13596 |
+
*
|
13597 |
+
* If the module is already running the premium code, returns an empty string.
|
13598 |
+
*
|
13599 |
+
* @author Vova Feldman (@svovaf)
|
13600 |
+
* @since 1.2.1
|
13601 |
+
*
|
13602 |
+
* @param string $plan_title
|
13603 |
+
*
|
13604 |
+
* @return string
|
13605 |
+
*/
|
13606 |
+
private function get_complete_upgrade_instructions( $plan_title = '' ) {
|
13607 |
+
if ( ! $this->has_premium_version() || $this->is_premium() ) {
|
13608 |
+
return '';
|
13609 |
+
}
|
13610 |
+
|
13611 |
+
if ( empty( $plan_title ) ) {
|
13612 |
+
$plan_title = $this->_site->plan->title;
|
13613 |
+
}
|
13614 |
+
|
13615 |
+
// @since 1.2.1.5 The free version is auto deactivated.
|
13616 |
+
$deactivation_step = version_compare( $this->version, '1.2.1.5', '<' ) ?
|
13617 |
+
( '<li>' . $this->esc_html_inline( 'Deactivate the free version', 'deactivate-free-version' ) . '.</li>' ) :
|
13618 |
+
'';
|
13619 |
+
|
13620 |
+
return sprintf(
|
13621 |
+
' %s: <ol><li>%s.</li>%s<li>%s (<a href="%s" target="_blank">%s</a>).</li></ol>',
|
13622 |
+
$this->get_text_inline( 'Please follow these steps to complete the upgrade', 'follow-steps-to-complete-upgrade' ),
|
13623 |
+
$this->get_latest_download_link( sprintf(
|
13624 |
+
/* translators: %s: Plan title */
|
13625 |
+
$this->get_text_inline( 'Download the latest %s version', 'download-latest-x-version' ),
|
13626 |
+
$plan_title
|
13627 |
+
) ),
|
13628 |
+
$deactivation_step,
|
13629 |
+
$this->get_text_inline( 'Upload and activate the downloaded version', 'upload-and-activate' ),
|
13630 |
+
'//bit.ly/upload-wp-' . $this->_module_type . 's',
|
13631 |
+
$this->get_text_inline( 'How to upload and activate?', 'howto-upload-activate' )
|
13632 |
+
);
|
13633 |
+
}
|
13634 |
+
|
13635 |
+
/**
|
13636 |
+
* @author Vova Feldman (@svovaf)
|
13637 |
+
* @since 1.2.1.7
|
13638 |
+
*
|
13639 |
+
* @param string $key
|
13640 |
+
*
|
13641 |
+
* @return string
|
13642 |
+
*/
|
13643 |
+
function get_text( $key ) {
|
13644 |
+
return fs_text( $key, $this->_slug );
|
13645 |
+
}
|
13646 |
+
|
13647 |
+
/**
|
13648 |
+
* @author Vova Feldman (@svovaf)
|
13649 |
+
* @since 1.2.3
|
13650 |
+
*
|
13651 |
+
* @param string $text Translatable string.
|
13652 |
+
* @param string $key String key for overrides.
|
13653 |
+
*
|
13654 |
+
* @return string
|
13655 |
+
*/
|
13656 |
+
function get_text_inline( $text, $key = '' ) {
|
13657 |
+
return _fs_text_inline( $text, $key, $this->_slug );
|
13658 |
+
}
|
13659 |
+
|
13660 |
+
/**
|
13661 |
+
* @author Vova Feldman (@svovaf)
|
13662 |
+
* @since 1.2.3
|
13663 |
+
*
|
13664 |
+
* @param string $text Translatable string.
|
13665 |
+
* @param string $context Context information for the translators.
|
13666 |
+
* @param string $key String key for overrides.
|
13667 |
+
*
|
13668 |
+
* @return string
|
13669 |
+
*/
|
13670 |
+
function get_text_x_inline( $text, $context, $key ) {
|
13671 |
+
return _fs_text_x_inline( $text, $context, $key, $this->_slug );
|
13672 |
+
}
|
13673 |
+
|
13674 |
+
/**
|
13675 |
+
* @author Vova Feldman (@svovaf)
|
13676 |
+
* @since 1.2.3
|
13677 |
+
*
|
13678 |
+
* @param string $text Translatable string.
|
13679 |
+
* @param string $key String key for overrides.
|
13680 |
+
*
|
13681 |
+
* @return string
|
13682 |
+
*/
|
13683 |
+
function esc_html_inline( $text, $key ) {
|
13684 |
+
return esc_html( _fs_text_inline( $text, $key, $this->_slug ) );
|
13685 |
+
}
|
13686 |
+
|
13687 |
+
#----------------------------------------------------------------------------------
|
13688 |
+
#region Versioning
|
13689 |
+
#----------------------------------------------------------------------------------
|
13690 |
+
|
13691 |
+
/**
|
13692 |
+
* Check if Freemius in SDK upgrade mode.
|
13693 |
+
*
|
13694 |
+
* @author Vova Feldman (@svovaf)
|
13695 |
+
* @since 1.0.9
|
13696 |
+
*
|
13697 |
+
* @return bool
|
13698 |
+
*/
|
13699 |
+
function is_sdk_upgrade_mode() {
|
13700 |
+
return isset( $this->_storage->sdk_upgrade_mode ) ?
|
13701 |
+
$this->_storage->sdk_upgrade_mode :
|
13702 |
+
false;
|
13703 |
+
}
|
13704 |
+
|
13705 |
+
/**
|
13706 |
+
* Turn SDK upgrade mode off.
|
13707 |
+
*
|
13708 |
+
* @author Vova Feldman (@svovaf)
|
13709 |
+
* @since 1.0.9
|
13710 |
+
*/
|
13711 |
+
function set_sdk_upgrade_complete() {
|
13712 |
+
$this->_storage->sdk_upgrade_mode = false;
|
13713 |
+
}
|
13714 |
+
|
13715 |
+
/**
|
13716 |
+
* Check if plugin upgrade mode.
|
13717 |
+
*
|
13718 |
+
* @author Vova Feldman (@svovaf)
|
13719 |
+
* @since 1.0.9
|
13720 |
+
*
|
13721 |
+
* @return bool
|
13722 |
+
*/
|
13723 |
+
function is_plugin_upgrade_mode() {
|
13724 |
+
return isset( $this->_storage->plugin_upgrade_mode ) ?
|
13725 |
+
$this->_storage->plugin_upgrade_mode :
|
13726 |
+
false;
|
13727 |
+
}
|
13728 |
+
|
13729 |
+
/**
|
13730 |
+
* Turn plugin upgrade mode off.
|
13731 |
+
*
|
13732 |
+
* @author Vova Feldman (@svovaf)
|
13733 |
+
* @since 1.0.9
|
13734 |
+
*/
|
13735 |
+
function set_plugin_upgrade_complete() {
|
13736 |
+
$this->_storage->plugin_upgrade_mode = false;
|
13737 |
+
}
|
13738 |
+
|
13739 |
+
#endregion
|
13740 |
+
|
13741 |
+
#----------------------------------------------------------------------------------
|
13742 |
+
#region Permissions
|
13743 |
+
#----------------------------------------------------------------------------------
|
13744 |
+
|
13745 |
+
/**
|
13746 |
+
* Check if specific permission requested.
|
13747 |
+
*
|
13748 |
+
* @author Vova Feldman (@svovaf)
|
13749 |
+
* @since 1.1.6
|
13750 |
+
*
|
13751 |
+
* @param string $permission
|
13752 |
+
*
|
13753 |
+
* @return bool
|
13754 |
+
*/
|
13755 |
+
function is_permission_requested( $permission ) {
|
13756 |
+
return isset( $this->_permissions[ $permission ] ) && ( true === $this->_permissions[ $permission ] );
|
13757 |
+
}
|
13758 |
+
|
13759 |
+
#endregion
|
13760 |
+
|
13761 |
+
#----------------------------------------------------------------------------------
|
13762 |
+
#region Auto Activation
|
13763 |
+
#----------------------------------------------------------------------------------
|
13764 |
+
|
13765 |
+
/**
|
13766 |
+
* Hints the SDK if running an auto-installation.
|
13767 |
+
*
|
13768 |
+
* @var bool
|
13769 |
+
*/
|
13770 |
+
private $_isAutoInstall = false;
|
13771 |
+
|
13772 |
+
/**
|
13773 |
+
* After upgrade callback to install and auto activate a plugin.
|
13774 |
+
* This code will only be executed on explicit request from the user,
|
13775 |
+
* following the practice Jetpack are using with their theme installations.
|
13776 |
+
*
|
13777 |
+
* @link https://make.wordpress.org/plugins/2017/03/16/clarification-of-guideline-8-executable-code-and-installs/
|
13778 |
+
*
|
13779 |
+
* @author Vova Feldman (@svovaf)
|
13780 |
+
* @since 1.2.1.7
|
13781 |
+
*/
|
13782 |
+
function _install_premium_version_ajax_action() {
|
13783 |
+
$this->_logger->entrance();
|
13784 |
+
|
13785 |
+
$this->check_ajax_referer( 'install_premium_version' );
|
13786 |
+
|
13787 |
+
if ( ! $this->is_registered() ) {
|
13788 |
+
// Not registered.
|
13789 |
+
self::shoot_ajax_failure( array(
|
13790 |
+
'message' => $this->get_text_inline( 'Auto installation only works for opted-in users.', 'auto-install-error-not-opted-in' ),
|
13791 |
+
'code' => 'premium_installed',
|
13792 |
+
) );
|
13793 |
+
}
|
13794 |
+
|
13795 |
+
$plugin_id = fs_request_get( 'target_module_id', $this->get_id() );
|
13796 |
+
|
13797 |
+
if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
|
13798 |
+
// Invalid ID.
|
13799 |
+
self::shoot_ajax_failure( array(
|
13800 |
+
'message' => $this->get_text_inline( 'Invalid module ID.', 'auto-install-error-invalid-id' ),
|
13801 |
+
'code' => 'invalid_module_id',
|
13802 |
+
) );
|
13803 |
+
}
|
13804 |
+
|
13805 |
+
if ( $plugin_id == $this->get_id() ) {
|
13806 |
+
if ( $this->is_premium() ) {
|
13807 |
+
// Already using the premium code version.
|
13808 |
+
self::shoot_ajax_failure( array(
|
13809 |
+
'message' => $this->get_text_inline( 'Premium version already active.', 'auto-install-error-premium-activated' ),
|
13810 |
+
'code' => 'premium_installed',
|
13811 |
+
) );
|
13812 |
+
}
|
13813 |
+
if ( ! $this->can_use_premium_code() ) {
|
13814 |
+
// Don't have access to the premium code.
|
13815 |
+
self::shoot_ajax_failure( array(
|
13816 |
+
'message' => $this->get_text_inline( 'You do not have a valid license to access the premium version.', 'auto-install-error-invalid-license' ),
|
13817 |
+
'code' => 'invalid_license',
|
13818 |
+
) );
|
13819 |
+
}
|
13820 |
+
if ( ! $this->has_release_on_freemius() ) {
|
13821 |
+
// Plugin is a serviceware, no premium code version.
|
13822 |
+
self::shoot_ajax_failure( array(
|
13823 |
+
'message' => $this->get_text_inline( 'Plugin is a "Serviceware" which means it does not have a premium code version.', 'auto-install-error-serviceware' ),
|
13824 |
+
'code' => 'premium_version_missing',
|
13825 |
+
) );
|
13826 |
+
}
|
13827 |
+
} else {
|
13828 |
+
$addon = $this->get_addon( $plugin_id );
|
13829 |
+
|
13830 |
+
if ( ! is_object( $addon ) ) {
|
13831 |
+
// Invalid add-on ID.
|
13832 |
+
self::shoot_ajax_failure( array(
|
13833 |
+
'message' => $this->get_text_inline( 'Invalid module ID.', 'auto-install-error-invalid-id' ),
|
13834 |
+
'code' => 'invalid_module_id',
|
13835 |
+
) );
|
13836 |
+
}
|
13837 |
+
|
13838 |
+
if ( $this->is_addon_activated( $plugin_id, true ) ) {
|
13839 |
+
// Premium add-on version is already activated.
|
13840 |
+
self::shoot_ajax_failure( array(
|
13841 |
+
'message' => $this->get_text_inline( 'Premium add-on version already installed.', 'auto-install-error-premium-addon-activated' ),
|
13842 |
+
'code' => 'premium_installed',
|
13843 |
+
) );
|
13844 |
+
}
|
13845 |
+
}
|
13846 |
+
|
13847 |
+
$this->_isAutoInstall = true;
|
13848 |
+
|
13849 |
+
// Try to install and activate.
|
13850 |
+
$updater = new FS_Plugin_Updater( $this );
|
13851 |
+
$result = $updater->install_and_activate_plugin( $plugin_id );
|
13852 |
+
|
13853 |
+
if ( is_array( $result ) && ! empty( $result['message'] ) ) {
|
13854 |
+
self::shoot_ajax_failure( array(
|
13855 |
+
'message' => $result['message'],
|
13856 |
+
'code' => $result['code'],
|
13857 |
+
) );
|
13858 |
+
}
|
13859 |
+
|
13860 |
+
self::shoot_ajax_success( $result );
|
13861 |
+
}
|
13862 |
+
|
13863 |
+
/**
|
13864 |
+
* Displays module activation dialog box after a successful upgrade
|
13865 |
+
* where the user explicitly requested to auto download and install
|
13866 |
+
* the premium version.
|
13867 |
+
*
|
13868 |
+
* @author Vova Feldman (@svovaf)
|
13869 |
+
* @since 1.2.1.7
|
13870 |
+
*/
|
13871 |
+
function _add_auto_installation_dialog_box() {
|
13872 |
+
$this->_logger->entrance();
|
13873 |
+
|
13874 |
+
if ( ! $this->is_registered() ) {
|
13875 |
+
// Not registered.
|
13876 |
+
return;
|
13877 |
+
}
|
13878 |
+
|
13879 |
+
$plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
|
13880 |
+
|
13881 |
+
if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
|
13882 |
+
// Invalid module ID.
|
13883 |
+
return;
|
13884 |
+
}
|
13885 |
+
|
13886 |
+
if ( $plugin_id == $this->get_id() ) {
|
13887 |
+
if ( $this->is_premium() ) {
|
13888 |
+
// Already using the premium code version.
|
13889 |
+
return;
|
13890 |
+
}
|
13891 |
+
if ( ! $this->can_use_premium_code() ) {
|
13892 |
+
// Don't have access to the premium code.
|
13893 |
+
return;
|
13894 |
+
}
|
13895 |
+
if ( ! $this->has_release_on_freemius() ) {
|
13896 |
+
// Plugin is a serviceware, no premium code version.
|
13897 |
+
return;
|
13898 |
+
}
|
13899 |
+
} else {
|
13900 |
+
$addon = $this->get_addon( $plugin_id );
|
13901 |
+
|
13902 |
+
if ( ! is_object( $addon ) ) {
|
13903 |
+
// Invalid add-on ID.
|
13904 |
+
return;
|
13905 |
+
}
|
13906 |
+
|
13907 |
+
if ( $this->is_addon_activated( $plugin_id, true ) ) {
|
13908 |
+
// Premium add-on version is already activated.
|
13909 |
+
return;
|
13910 |
+
}
|
13911 |
+
}
|
13912 |
+
|
13913 |
+
$vars = array(
|
13914 |
+
'id' => $this->_module_id,
|
13915 |
+
'target_module_id' => $plugin_id,
|
13916 |
+
'slug' => $this->_slug,
|
13917 |
+
);
|
13918 |
+
|
13919 |
+
fs_require_template( 'auto-installation.php', $vars );
|
13920 |
+
}
|
13921 |
+
|
13922 |
+
#endregion
|
13923 |
+
|
13924 |
+
#--------------------------------------------------------------------------------
|
13925 |
+
#region Tabs Integration
|
13926 |
+
#--------------------------------------------------------------------------------
|
13927 |
+
|
13928 |
+
#region Module's Original Tabs
|
13929 |
+
|
13930 |
+
/**
|
13931 |
+
* Inject a JavaScript logic to capture the theme tabs HTML.
|
13932 |
+
*
|
13933 |
+
* @author Vova Feldman (@svovaf)
|
13934 |
+
* @since 1.2.2.7
|
13935 |
+
*/
|
13936 |
+
function _tabs_capture() {
|
13937 |
+
$this->_logger->entrance();
|
13938 |
+
|
13939 |
+
if ( ! $this->is_theme_settings_page() ||
|
13940 |
+
! $this->is_matching_url( $this->main_menu_url() )
|
13941 |
+
) {
|
13942 |
+
return;
|
13943 |
+
}
|
13944 |
+
|
13945 |
+
$params = array(
|
13946 |
+
'id' => $this->_module_id,
|
13947 |
+
);
|
13948 |
+
|
13949 |
+
fs_require_once_template( 'tabs-capture-js.php', $params );
|
13950 |
+
}
|
13951 |
+
|
13952 |
+
/**
|
13953 |
+
* Cache theme's tabs HTML for a week. The cache will also be set as expired
|
13954 |
+
* after version and type (free/premium) changes, in addition to the week period.
|
13955 |
+
*
|
13956 |
+
* @author Vova Feldman (@svovaf)
|
13957 |
+
* @since 1.2.2.7
|
13958 |
+
*/
|
13959 |
+
function _store_tabs_ajax_action() {
|
13960 |
+
$this->_logger->entrance();
|
13961 |
+
|
13962 |
+
$this->check_ajax_referer( 'store_tabs' );
|
13963 |
+
|
13964 |
+
// Init filesystem if not yet initiated.
|
13965 |
+
WP_Filesystem();
|
13966 |
+
|
13967 |
+
// Get POST body HTML data.
|
13968 |
+
global $wp_filesystem;
|
13969 |
+
$tabs_html = $wp_filesystem->get_contents( "php://input" );
|
13970 |
+
|
13971 |
+
if ( is_string( $tabs_html ) ) {
|
13972 |
+
$tabs_html = trim( $tabs_html );
|
13973 |
+
}
|
13974 |
+
|
13975 |
+
if ( ! is_string( $tabs_html ) || empty( $tabs_html ) ) {
|
13976 |
+
self::shoot_ajax_failure();
|
13977 |
+
}
|
13978 |
+
|
13979 |
+
$this->_cache->set( 'tabs', $tabs_html, 7 * WP_FS__TIME_24_HOURS_IN_SEC );
|
13980 |
+
|
13981 |
+
self::shoot_ajax_success();
|
13982 |
+
}
|
13983 |
+
|
13984 |
+
/**
|
13985 |
+
* Cache theme's settings page custom styles. The cache will also be set as expired
|
13986 |
+
* after version and type (free/premium) changes, in addition to the week period.
|
13987 |
+
*
|
13988 |
+
* @author Vova Feldman (@svovaf)
|
13989 |
+
* @since 1.2.2.7
|
13990 |
+
*/
|
13991 |
+
function _store_tabs_styles() {
|
13992 |
+
$this->_logger->entrance();
|
13993 |
+
|
13994 |
+
if ( ! $this->is_theme_settings_page() ||
|
13995 |
+
! $this->is_matching_url( $this->main_menu_url() )
|
13996 |
+
) {
|
13997 |
+
return;
|
13998 |
+
}
|
13999 |
+
|
14000 |
+
$wp_styles = wp_styles();
|
14001 |
+
|
14002 |
+
$theme_styles_url = get_template_directory_uri();
|
14003 |
+
|
14004 |
+
$stylesheets = array();
|
14005 |
+
foreach ( $wp_styles->queue as $handler ) {
|
14006 |
+
if ( fs_starts_with( $handler, 'fs_' ) ) {
|
14007 |
+
// Assume that stylesheets that their handler starts with "fs_" belong to the SDK.
|
14008 |
+
continue;
|
14009 |
+
}
|
14010 |
+
|
14011 |
+
/**
|
14012 |
+
* @var _WP_Dependency $stylesheet
|
14013 |
+
*/
|
14014 |
+
$stylesheet = $wp_styles->registered[ $handler ];
|
14015 |
+
|
14016 |
+
if ( fs_starts_with( $stylesheet->src, $theme_styles_url ) ) {
|
14017 |
+
$stylesheets[] = $stylesheet->src;
|
14018 |
+
}
|
14019 |
+
}
|
14020 |
+
|
14021 |
+
if ( ! empty( $stylesheets ) ) {
|
14022 |
+
$this->_cache->set( 'tabs_stylesheets', $stylesheets, 7 * WP_FS__TIME_24_HOURS_IN_SEC );
|
14023 |
+
}
|
14024 |
+
}
|
14025 |
+
|
14026 |
+
/**
|
14027 |
+
* Check if module's original settings page has any tabs.
|
14028 |
+
*
|
14029 |
+
* @author Vova Feldman (@svovaf)
|
14030 |
+
* @since 1.2.2.7
|
14031 |
+
*
|
14032 |
+
* @return bool
|
14033 |
+
*/
|
14034 |
+
private function has_tabs() {
|
14035 |
+
return $this->_cache->has( 'tabs' );
|
14036 |
+
}
|
14037 |
+
|
14038 |
+
/**
|
14039 |
+
* Get module's settings page HTML content, starting
|
14040 |
+
* from the beginning of the <div class="wrap"> element,
|
14041 |
+
* until the tabs HTML (including).
|
14042 |
+
*
|
14043 |
+
* @author Vova Feldman (@svovaf)
|
14044 |
+
* @since 1.2.2.7
|
14045 |
+
*
|
14046 |
+
* @return string
|
14047 |
+
*/
|
14048 |
+
private function get_tabs_html() {
|
14049 |
+
$this->_logger->entrance();
|
14050 |
+
|
14051 |
+
return $this->_cache->get( 'tabs' );
|
14052 |
+
}
|
14053 |
+
|
14054 |
+
/**
|
14055 |
+
* Check if page should include tabs.
|
14056 |
+
*
|
14057 |
+
* @author Vova Feldman (@svovaf)
|
14058 |
+
* @since 1.2.2.7
|
14059 |
+
*
|
14060 |
+
* @return bool
|
14061 |
+
*/
|
14062 |
+
private function should_page_include_tabs()
|
14063 |
+
{
|
14064 |
+
if ( ! $this->has_settings_menu() ) {
|
14065 |
+
// Don't add tabs if no settings at all.
|
14066 |
+
return false;
|
14067 |
+
}
|
14068 |
+
|
14069 |
+
if ( ! $this->is_theme() ) {
|
14070 |
+
// Only add tabs to themes for now.
|
14071 |
+
return false;
|
14072 |
+
}
|
14073 |
+
|
14074 |
+
if ( ! $this->has_paid_plan() && ! $this->has_addons() ) {
|
14075 |
+
// Only add tabs to monetizing themes.
|
14076 |
+
return false;
|
14077 |
+
}
|
14078 |
+
|
14079 |
+
if ( ! $this->is_theme_settings_page() ) {
|
14080 |
+
// Only add tabs if browsing one of the theme's setting pages.
|
14081 |
+
return false;
|
14082 |
+
}
|
14083 |
+
|
14084 |
+
if ( $this->is_admin_page( 'pricing' ) && fs_request_get_bool( 'checkout' ) ) {
|
14085 |
+
// Don't add tabs on checkout page, we want to reduce distractions
|
14086 |
+
// as much as possible.
|
14087 |
+
return false;
|
14088 |
+
}
|
14089 |
+
|
14090 |
+
return true;
|
14091 |
+
}
|
14092 |
+
|
14093 |
+
/**
|
14094 |
+
* Add the tabs HTML before the setting's page content and
|
14095 |
+
* enqueue any required stylesheets.
|
14096 |
+
*
|
14097 |
+
* @author Vova Feldman (@svovaf)
|
14098 |
+
* @since 1.2.2.7
|
14099 |
+
*
|
14100 |
+
* @return bool If tabs were included.
|
14101 |
+
*/
|
14102 |
+
function _add_tabs_before_content() {
|
14103 |
+
$this->_logger->entrance();
|
14104 |
+
|
14105 |
+
if ( ! $this->should_page_include_tabs() ) {
|
14106 |
+
return false;
|
14107 |
+
}
|
14108 |
+
|
14109 |
+
/**
|
14110 |
+
* Enqueue the original stylesheets that are included in the
|
14111 |
+
* theme settings page. That way, if the theme settings has
|
14112 |
+
* some custom _styled_ content above the tabs UI, this
|
14113 |
+
* will make sure that the styling is preserved.
|
14114 |
+
*/
|
14115 |
+
$stylesheets = $this->_cache->get( 'tabs_stylesheets', array() );
|
14116 |
+
if ( is_array( $stylesheets ) ) {
|
14117 |
+
for ( $i = 0, $len = count( $stylesheets ); $i < $len; $i ++ ) {
|
14118 |
+
wp_enqueue_style( "fs_{$this->_module_id}_tabs_{$i}", $stylesheets[ $i ] );
|
14119 |
+
}
|
14120 |
+
}
|
14121 |
+
|
14122 |
+
// Cut closing </div> tag.
|
14123 |
+
echo substr( trim( $this->get_tabs_html() ), 0, - 6 );
|
14124 |
+
|
14125 |
+
return true;
|
14126 |
+
}
|
14127 |
+
|
14128 |
+
/**
|
14129 |
+
* Add the tabs closing HTML after the setting's page content.
|
14130 |
+
*
|
14131 |
+
* @author Vova Feldman (@svovaf)
|
14132 |
+
* @since 1.2.2.7
|
14133 |
+
*
|
14134 |
+
* @return bool If tabs closing HTML was included.
|
14135 |
+
*/
|
14136 |
+
function _add_tabs_after_content() {
|
14137 |
+
$this->_logger->entrance();
|
14138 |
+
|
14139 |
+
if ( ! $this->should_page_include_tabs() ) {
|
14140 |
+
return false;
|
14141 |
+
}
|
14142 |
+
|
14143 |
+
echo '</div>';
|
14144 |
+
|
14145 |
+
return true;
|
14146 |
+
}
|
14147 |
+
|
14148 |
+
#endregion
|
14149 |
+
|
14150 |
+
/**
|
14151 |
+
* Add in-page JavaScript to inject the Freemius tabs into
|
14152 |
+
* the module's setting tabs section.
|
14153 |
+
*
|
14154 |
+
* @author Vova Feldman (@svovaf)
|
14155 |
+
* @since 1.2.2.7
|
14156 |
+
*/
|
14157 |
+
function _add_freemius_tabs() {
|
14158 |
+
$this->_logger->entrance();
|
14159 |
+
|
14160 |
+
if ( ! $this->should_page_include_tabs() ) {
|
14161 |
+
return;
|
14162 |
+
}
|
14163 |
+
|
14164 |
+
$params = array( 'id' => $this->_module_id );
|
14165 |
+
fs_require_once_template( 'tabs.php', $params );
|
14166 |
+
}
|
14167 |
+
|
14168 |
+
#endregion
|
14169 |
+
|
14170 |
+
#--------------------------------------------------------------------------------
|
14171 |
+
#region Customizer Integration for Themes
|
14172 |
+
#--------------------------------------------------------------------------------
|
14173 |
+
|
14174 |
+
/**
|
14175 |
+
* @author Vova Feldman (@svovaf)
|
14176 |
+
* @since 1.2.2.7
|
14177 |
+
*
|
14178 |
+
* @param WP_Customize_Manager $customizer
|
14179 |
+
*/
|
14180 |
+
function _customizer_register($customizer) {
|
14181 |
+
$this->_logger->entrance();
|
14182 |
+
|
14183 |
+
if ( $this->is_pricing_page_visible() ) {
|
14184 |
+
require_once WP_FS__DIR_INCLUDES . '/customizer/class-fs-customizer-upsell-control.php';
|
14185 |
+
|
14186 |
+
$customizer->add_section( 'freemius_upsell', array(
|
14187 |
+
'title' => '★ ' . $this->get_text_inline( 'View paid features', 'view-paid-features' ),
|
14188 |
+
'priority' => 1,
|
14189 |
+
) );
|
14190 |
+
$customizer->add_setting( 'freemius_upsell', array(
|
14191 |
+
'sanitize_callback' => 'esc_html',
|
14192 |
+
) );
|
14193 |
+
|
14194 |
+
$customizer->add_control( new FS_Customizer_Upsell_Control( $customizer, 'freemius_upsell', array(
|
14195 |
+
'fs' => $this,
|
14196 |
+
'section' => 'freemius_upsell',
|
14197 |
+
'priority' => 100,
|
14198 |
+
) ) );
|
14199 |
+
}
|
14200 |
+
|
14201 |
+
if ( $this->is_page_visible( 'contact' ) || $this->is_page_visible( 'support' ) ) {
|
14202 |
+
require_once WP_FS__DIR_INCLUDES . '/customizer/class-fs-customizer-support-section.php';
|
14203 |
+
|
14204 |
+
// Main Documentation Link In Customizer Root.
|
14205 |
+
$customizer->add_section( new FS_Customizer_Support_Section( $customizer, 'freemius_support', array(
|
14206 |
+
'fs' => $this,
|
14207 |
+
'priority' => 1000,
|
14208 |
+
) ) );
|
14209 |
+
}
|
14210 |
+
}
|
14211 |
+
|
14212 |
+
#endregion
|
14213 |
+
|
14214 |
+
/**
|
14215 |
+
* If the theme has a paid version, add some custom
|
14216 |
+
* styling to the theme's premium version (if exists)
|
14217 |
+
* to highlight that it's the premium version of the
|
14218 |
+
* same theme, making it easier for identification
|
14219 |
+
* after the user upgrades and upload it to the site.
|
14220 |
+
*
|
14221 |
+
* @author Vova Feldman (@svovaf)
|
14222 |
+
* @since 1.2.2.7
|
14223 |
+
*/
|
14224 |
+
function _style_premium_theme() {
|
14225 |
+
$this->_logger->entrance();
|
14226 |
+
|
14227 |
+
if ( ! self::is_themes_page() ) {
|
14228 |
+
// Only include in the themes page.
|
14229 |
+
return;
|
14230 |
+
}
|
14231 |
+
|
14232 |
+
if ( ! $this->has_paid_plan() ) {
|
14233 |
+
// Only include if has any paid plans.
|
14234 |
+
return;
|
14235 |
+
}
|
14236 |
+
|
14237 |
+
$params = null;
|
14238 |
+
fs_require_once_template( '/js/jquery.content-change.php', $params );
|
14239 |
+
|
14240 |
+
$params = array(
|
14241 |
+
'slug' => $this->_slug,
|
14242 |
+
'id' => $this->_module_id,
|
14243 |
+
);
|
14244 |
+
|
14245 |
+
fs_require_template( '/js/style-premium-theme.php', $params );
|
14246 |
+
}
|
14247 |
+
|
14248 |
+
#----------------------------------------------------------------------------------
|
14249 |
+
#region Marketing
|
14250 |
+
#----------------------------------------------------------------------------------
|
14251 |
+
|
14252 |
+
/**
|
14253 |
+
* Check if current user purchased any other plugins before.
|
14254 |
+
*
|
14255 |
+
* @author Vova Feldman (@svovaf)
|
14256 |
+
* @since 1.0.9
|
14257 |
+
*
|
14258 |
+
* @return bool
|
14259 |
+
*/
|
14260 |
+
function has_purchased_before() {
|
14261 |
+
// TODO: Implement has_purchased_before() method.
|
14262 |
+
throw new Exception( 'not implemented' );
|
14263 |
+
}
|
14264 |
+
|
14265 |
+
/**
|
14266 |
+
* Check if current user classified as an agency.
|
14267 |
+
*
|
14268 |
+
* @author Vova Feldman (@svovaf)
|
14269 |
+
* @since 1.0.9
|
14270 |
+
*
|
14271 |
+
* @return bool
|
14272 |
+
*/
|
14273 |
+
function is_agency() {
|
14274 |
+
// TODO: Implement is_agency() method.
|
14275 |
+
throw new Exception( 'not implemented' );
|
14276 |
+
}
|
14277 |
+
|
14278 |
+
/**
|
14279 |
+
* Check if current user classified as a developer.
|
14280 |
+
*
|
14281 |
+
* @author Vova Feldman (@svovaf)
|
14282 |
+
* @since 1.0.9
|
14283 |
+
*
|
14284 |
+
* @return bool
|
14285 |
+
*/
|
14286 |
+
function is_developer() {
|
14287 |
+
// TODO: Implement is_developer() method.
|
14288 |
+
throw new Exception( 'not implemented' );
|
14289 |
+
}
|
14290 |
+
|
14291 |
+
/**
|
14292 |
+
* Check if current user classified as a business.
|
14293 |
+
*
|
14294 |
+
* @author Vova Feldman (@svovaf)
|
14295 |
+
* @since 1.0.9
|
14296 |
+
*
|
14297 |
+
* @return bool
|
14298 |
+
*/
|
14299 |
+
function is_business() {
|
14300 |
+
// TODO: Implement is_business() method.
|
14301 |
+
throw new Exception( 'not implemented' );
|
14302 |
+
}
|
14303 |
+
|
14304 |
+
#endregion
|
14305 |
+
}
|
freemius/includes/class-fs-api.php
CHANGED
@@ -1,558 +1,558 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package Freemius
|
4 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
-
* @since 1.0.4
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit;
|
11 |
-
}
|
12 |
-
|
13 |
-
/**
|
14 |
-
* Class FS_Api
|
15 |
-
*
|
16 |
-
* Wraps Freemius API SDK to handle:
|
17 |
-
* 1. Clock sync.
|
18 |
-
* 2. Fallback to HTTP when HTTPS fails.
|
19 |
-
* 3. Adds caching layer to GET requests.
|
20 |
-
* 4. Adds consistency for failed requests by using last cached version.
|
21 |
-
*/
|
22 |
-
class FS_Api {
|
23 |
-
/**
|
24 |
-
* @var FS_Api[]
|
25 |
-
*/
|
26 |
-
private static $_instances = array();
|
27 |
-
|
28 |
-
/**
|
29 |
-
* @var FS_Option_Manager Freemius options, options-manager.
|
30 |
-
*/
|
31 |
-
private static $_options;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* @var FS_Cache_Manager API Caching layer
|
35 |
-
*/
|
36 |
-
private static $_cache;
|
37 |
-
|
38 |
-
/**
|
39 |
-
* @var int Clock diff in seconds between current server to API server.
|
40 |
-
*/
|
41 |
-
private static $_clock_diff;
|
42 |
-
|
43 |
-
/**
|
44 |
-
* @var
|
45 |
-
*/
|
46 |
-
private $_api;
|
47 |
-
|
48 |
-
/**
|
49 |
-
* @var string
|
50 |
-
*/
|
51 |
-
private $_slug;
|
52 |
-
|
53 |
-
/**
|
54 |
-
* @var FS_Logger
|
55 |
-
* @since 1.0.4
|
56 |
-
*/
|
57 |
-
private $_logger;
|
58 |
-
|
59 |
-
/**
|
60 |
-
* @param string $slug
|
61 |
-
* @param string $scope 'app', 'developer', 'user' or 'install'.
|
62 |
-
* @param number $id Element's id.
|
63 |
-
* @param string $public_key Public key.
|
64 |
-
* @param bool $is_sandbox
|
65 |
-
* @param bool|string $secret_key Element's secret key.
|
66 |
-
*
|
67 |
-
* @return FS_Api
|
68 |
-
*/
|
69 |
-
static function instance( $slug, $scope, $id, $public_key, $is_sandbox, $secret_key = false ) {
|
70 |
-
$identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
|
71 |
-
|
72 |
-
if ( ! isset( self::$_instances[ $identifier ] ) ) {
|
73 |
-
self::_init();
|
74 |
-
|
75 |
-
self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox );
|
76 |
-
}
|
77 |
-
|
78 |
-
return self::$_instances[ $identifier ];
|
79 |
-
}
|
80 |
-
|
81 |
-
private static function _init() {
|
82 |
-
if ( isset( self::$_options ) ) {
|
83 |
-
return;
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( ! class_exists( '
|
87 |
-
require_once WP_FS__DIR_SDK . '/
|
88 |
-
}
|
89 |
-
|
90 |
-
self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true );
|
91 |
-
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
|
92 |
-
|
93 |
-
self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
|
94 |
-
|
95 |
-
|
96 |
-
if ( self::$_options->get_option( 'api_force_http', false ) ) {
|
97 |
-
|
98 |
-
}
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* @param string $slug
|
103 |
-
* @param string $scope 'app', 'developer', 'user' or 'install'.
|
104 |
-
* @param number $id Element's id.
|
105 |
-
* @param string $public_key Public key.
|
106 |
-
* @param bool|string $secret_key Element's secret key.
|
107 |
-
* @param bool $is_sandbox
|
108 |
-
*/
|
109 |
-
private function __construct( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox ) {
|
110 |
-
$this->_api = new
|
111 |
-
|
112 |
-
$this->_slug = $slug;
|
113 |
-
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
114 |
-
}
|
115 |
-
|
116 |
-
/**
|
117 |
-
* Find clock diff between server and API server, and store the diff locally.
|
118 |
-
*
|
119 |
-
* @param bool|int $diff
|
120 |
-
*
|
121 |
-
* @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
|
122 |
-
*/
|
123 |
-
private function _sync_clock_diff( $diff = false ) {
|
124 |
-
$this->_logger->entrance();
|
125 |
-
|
126 |
-
// Sync clock and store.
|
127 |
-
$new_clock_diff = ( false === $diff ) ?
|
128 |
-
|
129 |
-
$diff;
|
130 |
-
|
131 |
-
if ( $new_clock_diff === self::$_clock_diff ) {
|
132 |
-
return false;
|
133 |
-
}
|
134 |
-
|
135 |
-
self::$_clock_diff = $new_clock_diff;
|
136 |
-
|
137 |
-
// Update API clock's diff.
|
138 |
-
|
139 |
-
|
140 |
-
// Store new clock diff in storage.
|
141 |
-
self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
|
142 |
-
|
143 |
-
return $new_clock_diff;
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* Override API call to enable retry with servers' clock auto sync method.
|
148 |
-
*
|
149 |
-
* @param string $path
|
150 |
-
* @param string $method
|
151 |
-
* @param array $params
|
152 |
-
* @param bool $retry Is in retry or first call attempt.
|
153 |
-
*
|
154 |
-
* @return array|mixed|string|void
|
155 |
-
*/
|
156 |
-
private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
|
157 |
-
$this->_logger->entrance( $method . ':' . $path );
|
158 |
-
|
159 |
-
if ( self::is_temporary_down() ) {
|
160 |
-
$result = $this->get_temporary_unavailable_error();
|
161 |
-
} else {
|
162 |
-
$result = $this->_api->Api( $path, $method, $params );
|
163 |
-
|
164 |
-
if ( null !== $result &&
|
165 |
-
isset( $result->error ) &&
|
166 |
-
isset( $result->error->code ) &&
|
167 |
-
'request_expired' === $result->error->code
|
168 |
-
) {
|
169 |
-
if ( ! $retry ) {
|
170 |
-
$diff = isset( $result->error->timestamp ) ?
|
171 |
-
( time() - strtotime( $result->error->timestamp ) ) :
|
172 |
-
false;
|
173 |
-
|
174 |
-
// Try to sync clock diff.
|
175 |
-
if ( false !== $this->_sync_clock_diff( $diff ) ) {
|
176 |
-
// Retry call with new synced clock.
|
177 |
-
return $this->_call( $path, $method, $params, true );
|
178 |
-
}
|
179 |
-
}
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
if ( $this->_logger->is_on() && self::is_api_error( $result ) ) {
|
184 |
-
// Log API errors.
|
185 |
-
$this->_logger->api_error( $result );
|
186 |
-
}
|
187 |
-
|
188 |
-
return $result;
|
189 |
-
}
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Override API call to wrap it in servers' clock sync method.
|
193 |
-
*
|
194 |
-
* @param string $path
|
195 |
-
* @param string $method
|
196 |
-
* @param array $params
|
197 |
-
*
|
198 |
-
* @return array|mixed|string|void
|
199 |
-
* @throws Freemius_Exception
|
200 |
-
*/
|
201 |
-
function call( $path, $method = 'GET', $params = array() ) {
|
202 |
-
return $this->_call( $path, $method, $params );
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Get API request URL signed via query string.
|
207 |
-
*
|
208 |
-
* @param string $path
|
209 |
-
*
|
210 |
-
* @return string
|
211 |
-
*/
|
212 |
-
function get_signed_url( $path ) {
|
213 |
-
return $this->_api->GetSignedUrl( $path );
|
214 |
-
}
|
215 |
-
|
216 |
-
/**
|
217 |
-
* @param string $path
|
218 |
-
* @param bool $flush
|
219 |
-
* @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
|
220 |
-
*
|
221 |
-
* @return stdClass|mixed
|
222 |
-
*/
|
223 |
-
function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
224 |
-
$this->_logger->entrance( $path );
|
225 |
-
|
226 |
-
$cache_key = $this->get_cache_key( $path );
|
227 |
-
|
228 |
-
// Always flush during development.
|
229 |
-
if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
|
230 |
-
$flush = true;
|
231 |
-
}
|
232 |
-
|
233 |
-
$cached_result = self::$_cache->get( $cache_key );
|
234 |
-
|
235 |
-
if ( $flush || ! self::$_cache->has_valid( $cache_key ) ) {
|
236 |
-
$result = $this->call( $path );
|
237 |
-
|
238 |
-
if ( ! is_object( $result ) || isset( $result->error ) ) {
|
239 |
-
// Api returned an error.
|
240 |
-
if ( is_object( $cached_result ) &&
|
241 |
-
! isset( $cached_result )
|
242 |
-
) {
|
243 |
-
// If there was an error during a newer data fetch,
|
244 |
-
// fallback to older data version.
|
245 |
-
$result = $cached_result;
|
246 |
-
|
247 |
-
if ( $this->_logger->is_on() ) {
|
248 |
-
$this->_logger->warn( 'Fallback to cached API result: ' . var_export( $cached_result, true ) );
|
249 |
-
}
|
250 |
-
} else {
|
251 |
-
// If no older data version, return result without
|
252 |
-
// caching the error.
|
253 |
-
return $result;
|
254 |
-
}
|
255 |
-
}
|
256 |
-
|
257 |
-
self::$_cache->set( $cache_key, $result, $expiration );
|
258 |
-
|
259 |
-
$cached_result = $result;
|
260 |
-
} else {
|
261 |
-
$this->_logger->log( 'Using cached API result.' );
|
262 |
-
}
|
263 |
-
|
264 |
-
return $cached_result;
|
265 |
-
}
|
266 |
-
|
267 |
-
/**
|
268 |
-
* Check if there's a cached version of the API request.
|
269 |
-
*
|
270 |
-
* @author Vova Feldman (@svovaf)
|
271 |
-
* @since 1.2.1
|
272 |
-
*
|
273 |
-
* @param string $path
|
274 |
-
* @param string $method
|
275 |
-
* @param array $params
|
276 |
-
*
|
277 |
-
* @return bool
|
278 |
-
*/
|
279 |
-
function is_cached( $path, $method = 'GET', $params = array() ) {
|
280 |
-
$cache_key = $this->get_cache_key( $path, $method, $params );
|
281 |
-
|
282 |
-
return self::$_cache->has_valid( $cache_key );
|
283 |
-
}
|
284 |
-
|
285 |
-
/**
|
286 |
-
* Invalidate a cached version of the API request.
|
287 |
-
*
|
288 |
-
* @author Vova Feldman (@svovaf)
|
289 |
-
* @since 1.2.1.5
|
290 |
-
*
|
291 |
-
* @param string $path
|
292 |
-
* @param string $method
|
293 |
-
* @param array $params
|
294 |
-
*/
|
295 |
-
function purge_cache( $path, $method = 'GET', $params = array() ) {
|
296 |
-
$this->_logger->entrance( "{$method}:{$path}" );
|
297 |
-
|
298 |
-
$cache_key = $this->get_cache_key( $path, $method, $params );
|
299 |
-
|
300 |
-
self::$_cache->purge( $cache_key );
|
301 |
-
}
|
302 |
-
|
303 |
-
/**
|
304 |
-
* @param string $path
|
305 |
-
* @param string $method
|
306 |
-
* @param array $params
|
307 |
-
*
|
308 |
-
* @return string
|
309 |
-
* @throws \Freemius_Exception
|
310 |
-
*/
|
311 |
-
private function get_cache_key( $path, $method = 'GET', $params = array() ) {
|
312 |
-
$canonized = $this->_api->CanonizePath( $path );
|
313 |
-
// $exploded = explode('/', $canonized);
|
314 |
-
// return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
|
315 |
-
return strtolower( $method . ':' . $canonized ) . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
|
316 |
-
}
|
317 |
-
|
318 |
-
/**
|
319 |
-
* Test API connectivity.
|
320 |
-
*
|
321 |
-
* @author Vova Feldman (@svovaf)
|
322 |
-
* @since 1.0.9 If fails, try to fallback to HTTP.
|
323 |
-
* @since 1.1.6 Added a 5-min caching mechanism, to prevent from overloading the server if the API if
|
324 |
-
* temporary down.
|
325 |
-
*
|
326 |
-
* @return bool True if successful connectivity to the API.
|
327 |
-
*/
|
328 |
-
static function test() {
|
329 |
-
self::_init();
|
330 |
-
|
331 |
-
$cache_key = 'ping_test';
|
332 |
-
|
333 |
-
$test = self::$_cache->get_valid( $cache_key, null );
|
334 |
-
|
335 |
-
if ( is_null( $test ) ) {
|
336 |
-
$test =
|
337 |
-
|
338 |
-
if ( false === $test &&
|
339 |
-
// Fallback to HTTP, since HTTPS fails.
|
340 |
-
|
341 |
-
|
342 |
-
self::$_options->set_option( 'api_force_http', true, true );
|
343 |
-
|
344 |
-
$test =
|
345 |
-
|
346 |
-
if ( false === $test ) {
|
347 |
-
/**
|
348 |
-
* API connectivity test fail also in HTTP request, therefore,
|
349 |
-
* fallback to HTTPS to keep connection secure.
|
350 |
-
*
|
351 |
-
* @since 1.1.6
|
352 |
-
*/
|
353 |
-
self::$_options->set_option( 'api_force_http', false, true );
|
354 |
-
}
|
355 |
-
}
|
356 |
-
|
357 |
-
self::$_cache->set( $cache_key, $test, WP_FS__TIME_5_MIN_IN_SEC );
|
358 |
-
}
|
359 |
-
|
360 |
-
return $test;
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Check if API is temporary down.
|
365 |
-
*
|
366 |
-
* @author Vova Feldman (@svovaf)
|
367 |
-
* @since 1.1.6
|
368 |
-
*
|
369 |
-
* @return bool
|
370 |
-
*/
|
371 |
-
static function is_temporary_down() {
|
372 |
-
self::_init();
|
373 |
-
|
374 |
-
$test = self::$_cache->get_valid( 'ping_test', null );
|
375 |
-
|
376 |
-
return ( false === $test );
|
377 |
-
}
|
378 |
-
|
379 |
-
/**
|
380 |
-
* @author Vova Feldman (@svovaf)
|
381 |
-
* @since 1.1.6
|
382 |
-
*
|
383 |
-
* @return object
|
384 |
-
*/
|
385 |
-
private function get_temporary_unavailable_error() {
|
386 |
-
return (object) array(
|
387 |
-
'error' => (object) array(
|
388 |
-
'type' => 'TemporaryUnavailable',
|
389 |
-
'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
|
390 |
-
'code' => 'temporary_unavailable',
|
391 |
-
'http' => 503
|
392 |
-
)
|
393 |
-
);
|
394 |
-
}
|
395 |
-
|
396 |
-
/**
|
397 |
-
* Ping API for connectivity test, and return result object.
|
398 |
-
*
|
399 |
-
* @author Vova Feldman (@svovaf)
|
400 |
-
* @since 1.0.9
|
401 |
-
*
|
402 |
-
* @param null|string $unique_anonymous_id
|
403 |
-
* @param array $params
|
404 |
-
*
|
405 |
-
* @return object
|
406 |
-
*/
|
407 |
-
function ping( $unique_anonymous_id = null, $params = array() ) {
|
408 |
-
$this->_logger->entrance();
|
409 |
-
|
410 |
-
if ( self::is_temporary_down() ) {
|
411 |
-
return $this->get_temporary_unavailable_error();
|
412 |
-
}
|
413 |
-
|
414 |
-
$pong = is_null( $unique_anonymous_id ) ?
|
415 |
-
|
416 |
-
$this->_call( 'ping.json?' . http_build_query( array_merge(
|
417 |
-
array( 'uid' => $unique_anonymous_id ),
|
418 |
-
$params
|
419 |
-
) ) );
|
420 |
-
|
421 |
-
if ( $this->is_valid_ping( $pong ) ) {
|
422 |
-
return $pong;
|
423 |
-
}
|
424 |
-
|
425 |
-
if ( self::should_try_with_http( $pong ) ) {
|
426 |
-
// Fallback to HTTP, since HTTPS fails.
|
427 |
-
|
428 |
-
|
429 |
-
self::$_options->set_option( 'api_force_http', true, true );
|
430 |
-
|
431 |
-
$pong = is_null( $unique_anonymous_id ) ?
|
432 |
-
|
433 |
-
$this->_call( 'ping.json?' . http_build_query( array_merge(
|
434 |
-
array( 'uid' => $unique_anonymous_id ),
|
435 |
-
$params
|
436 |
-
) ) );
|
437 |
-
|
438 |
-
if ( ! $this->is_valid_ping( $pong ) ) {
|
439 |
-
self::$_options->set_option( 'api_force_http', false, true );
|
440 |
-
}
|
441 |
-
}
|
442 |
-
|
443 |
-
return $pong;
|
444 |
-
}
|
445 |
-
|
446 |
-
/**
|
447 |
-
* Check if based on the API result we should try
|
448 |
-
* to re-run the same request with HTTP instead of HTTPS.
|
449 |
-
*
|
450 |
-
* @author Vova Feldman (@svovaf)
|
451 |
-
* @since 1.1.6
|
452 |
-
*
|
453 |
-
* @param $result
|
454 |
-
*
|
455 |
-
* @return bool
|
456 |
-
*/
|
457 |
-
private static function should_try_with_http( $result ) {
|
458 |
-
if ( !
|
459 |
-
return false;
|
460 |
-
}
|
461 |
-
|
462 |
-
return ( ! is_object( $result ) ||
|
463 |
-
! isset( $result->error ) ||
|
464 |
-
! isset( $result->error->code ) ||
|
465 |
-
! in_array( $result->error->code, array(
|
466 |
-
'curl_missing',
|
467 |
-
'cloudflare_ddos_protection',
|
468 |
-
'maintenance_mode',
|
469 |
-
'squid_cache_block',
|
470 |
-
'too_many_requests',
|
471 |
-
) ) );
|
472 |
-
|
473 |
-
}
|
474 |
-
|
475 |
-
/**
|
476 |
-
* Check if valid ping request result.
|
477 |
-
*
|
478 |
-
* @author Vova Feldman (@svovaf)
|
479 |
-
* @since 1.1.1
|
480 |
-
*
|
481 |
-
* @param mixed $pong
|
482 |
-
*
|
483 |
-
* @return bool
|
484 |
-
*/
|
485 |
-
function is_valid_ping( $pong ) {
|
486 |
-
return
|
487 |
-
}
|
488 |
-
|
489 |
-
function get_url( $path = '' ) {
|
490 |
-
return
|
491 |
-
}
|
492 |
-
|
493 |
-
/**
|
494 |
-
* Clear API cache.
|
495 |
-
*
|
496 |
-
* @author Vova Feldman (@svovaf)
|
497 |
-
* @since 1.0.9
|
498 |
-
*/
|
499 |
-
static function clear_cache() {
|
500 |
-
self::_init();
|
501 |
-
|
502 |
-
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
|
503 |
-
self::$_cache->clear();
|
504 |
-
}
|
505 |
-
|
506 |
-
#----------------------------------------------------------------------------------
|
507 |
-
#region Error Handling
|
508 |
-
#----------------------------------------------------------------------------------
|
509 |
-
|
510 |
-
/**
|
511 |
-
* @author Vova Feldman (@svovaf)
|
512 |
-
* @since 1.2.1.5
|
513 |
-
*
|
514 |
-
* @param mixed $result
|
515 |
-
*
|
516 |
-
* @return bool Is API result contains an error.
|
517 |
-
*/
|
518 |
-
static function is_api_error( $result ) {
|
519 |
-
return ( is_object( $result ) && isset( $result->error ) ) ||
|
520 |
-
is_string( $result );
|
521 |
-
}
|
522 |
-
|
523 |
-
/**
|
524 |
-
* Checks if given API result is a non-empty and not an error object.
|
525 |
-
*
|
526 |
-
* @author Vova Feldman (@svovaf)
|
527 |
-
* @since 1.2.1.5
|
528 |
-
*
|
529 |
-
* @param mixed $result
|
530 |
-
* @param string|null $required_property Optional property we want to verify that is set.
|
531 |
-
*
|
532 |
-
* @return bool
|
533 |
-
*/
|
534 |
-
static function is_api_result_object( $result, $required_property = null ) {
|
535 |
-
return (
|
536 |
-
is_object( $result ) &&
|
537 |
-
! isset( $result->error ) &&
|
538 |
-
( empty( $required_property ) || isset( $result->{$required_property} ) )
|
539 |
-
);
|
540 |
-
}
|
541 |
-
|
542 |
-
/**
|
543 |
-
* Checks if given API result is a non-empty entity object with non-empty ID.
|
544 |
-
*
|
545 |
-
* @author Vova Feldman (@svovaf)
|
546 |
-
* @since 1.2.1.5
|
547 |
-
*
|
548 |
-
* @param mixed $result
|
549 |
-
*
|
550 |
-
* @return bool
|
551 |
-
*/
|
552 |
-
static function is_api_result_entity( $result ) {
|
553 |
-
return self::is_api_result_object( $result, 'id' ) &&
|
554 |
-
FS_Entity::is_valid_id( $result->id );
|
555 |
-
}
|
556 |
-
|
557 |
-
#endregion
|
558 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.4
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class FS_Api
|
15 |
+
*
|
16 |
+
* Wraps Freemius API SDK to handle:
|
17 |
+
* 1. Clock sync.
|
18 |
+
* 2. Fallback to HTTP when HTTPS fails.
|
19 |
+
* 3. Adds caching layer to GET requests.
|
20 |
+
* 4. Adds consistency for failed requests by using last cached version.
|
21 |
+
*/
|
22 |
+
class FS_Api {
|
23 |
+
/**
|
24 |
+
* @var FS_Api[]
|
25 |
+
*/
|
26 |
+
private static $_instances = array();
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var FS_Option_Manager Freemius options, options-manager.
|
30 |
+
*/
|
31 |
+
private static $_options;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* @var FS_Cache_Manager API Caching layer
|
35 |
+
*/
|
36 |
+
private static $_cache;
|
37 |
+
|
38 |
+
/**
|
39 |
+
* @var int Clock diff in seconds between current server to API server.
|
40 |
+
*/
|
41 |
+
private static $_clock_diff;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @var Freemius_Api_WordPress
|
45 |
+
*/
|
46 |
+
private $_api;
|
47 |
+
|
48 |
+
/**
|
49 |
+
* @var string
|
50 |
+
*/
|
51 |
+
private $_slug;
|
52 |
+
|
53 |
+
/**
|
54 |
+
* @var FS_Logger
|
55 |
+
* @since 1.0.4
|
56 |
+
*/
|
57 |
+
private $_logger;
|
58 |
+
|
59 |
+
/**
|
60 |
+
* @param string $slug
|
61 |
+
* @param string $scope 'app', 'developer', 'user' or 'install'.
|
62 |
+
* @param number $id Element's id.
|
63 |
+
* @param string $public_key Public key.
|
64 |
+
* @param bool $is_sandbox
|
65 |
+
* @param bool|string $secret_key Element's secret key.
|
66 |
+
*
|
67 |
+
* @return FS_Api
|
68 |
+
*/
|
69 |
+
static function instance( $slug, $scope, $id, $public_key, $is_sandbox, $secret_key = false ) {
|
70 |
+
$identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
|
71 |
+
|
72 |
+
if ( ! isset( self::$_instances[ $identifier ] ) ) {
|
73 |
+
self::_init();
|
74 |
+
|
75 |
+
self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox );
|
76 |
+
}
|
77 |
+
|
78 |
+
return self::$_instances[ $identifier ];
|
79 |
+
}
|
80 |
+
|
81 |
+
private static function _init() {
|
82 |
+
if ( isset( self::$_options ) ) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( ! class_exists( 'Freemius_Api_WordPress' ) ) {
|
87 |
+
require_once WP_FS__DIR_SDK . '/FreemiusWordPress.php';
|
88 |
+
}
|
89 |
+
|
90 |
+
self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true );
|
91 |
+
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
|
92 |
+
|
93 |
+
self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
|
94 |
+
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
|
95 |
+
|
96 |
+
if ( self::$_options->get_option( 'api_force_http', false ) ) {
|
97 |
+
Freemius_Api_WordPress::SetHttp();
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @param string $slug
|
103 |
+
* @param string $scope 'app', 'developer', 'user' or 'install'.
|
104 |
+
* @param number $id Element's id.
|
105 |
+
* @param string $public_key Public key.
|
106 |
+
* @param bool|string $secret_key Element's secret key.
|
107 |
+
* @param bool $is_sandbox
|
108 |
+
*/
|
109 |
+
private function __construct( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox ) {
|
110 |
+
$this->_api = new Freemius_Api_WordPress( $scope, $id, $public_key, $secret_key, $is_sandbox );
|
111 |
+
|
112 |
+
$this->_slug = $slug;
|
113 |
+
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Find clock diff between server and API server, and store the diff locally.
|
118 |
+
*
|
119 |
+
* @param bool|int $diff
|
120 |
+
*
|
121 |
+
* @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
|
122 |
+
*/
|
123 |
+
private function _sync_clock_diff( $diff = false ) {
|
124 |
+
$this->_logger->entrance();
|
125 |
+
|
126 |
+
// Sync clock and store.
|
127 |
+
$new_clock_diff = ( false === $diff ) ?
|
128 |
+
Freemius_Api_WordPress::FindClockDiff() :
|
129 |
+
$diff;
|
130 |
+
|
131 |
+
if ( $new_clock_diff === self::$_clock_diff ) {
|
132 |
+
return false;
|
133 |
+
}
|
134 |
+
|
135 |
+
self::$_clock_diff = $new_clock_diff;
|
136 |
+
|
137 |
+
// Update API clock's diff.
|
138 |
+
Freemius_Api_WordPress::SetClockDiff( self::$_clock_diff );
|
139 |
+
|
140 |
+
// Store new clock diff in storage.
|
141 |
+
self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
|
142 |
+
|
143 |
+
return $new_clock_diff;
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Override API call to enable retry with servers' clock auto sync method.
|
148 |
+
*
|
149 |
+
* @param string $path
|
150 |
+
* @param string $method
|
151 |
+
* @param array $params
|
152 |
+
* @param bool $retry Is in retry or first call attempt.
|
153 |
+
*
|
154 |
+
* @return array|mixed|string|void
|
155 |
+
*/
|
156 |
+
private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
|
157 |
+
$this->_logger->entrance( $method . ':' . $path );
|
158 |
+
|
159 |
+
if ( self::is_temporary_down() ) {
|
160 |
+
$result = $this->get_temporary_unavailable_error();
|
161 |
+
} else {
|
162 |
+
$result = $this->_api->Api( $path, $method, $params );
|
163 |
+
|
164 |
+
if ( null !== $result &&
|
165 |
+
isset( $result->error ) &&
|
166 |
+
isset( $result->error->code ) &&
|
167 |
+
'request_expired' === $result->error->code
|
168 |
+
) {
|
169 |
+
if ( ! $retry ) {
|
170 |
+
$diff = isset( $result->error->timestamp ) ?
|
171 |
+
( time() - strtotime( $result->error->timestamp ) ) :
|
172 |
+
false;
|
173 |
+
|
174 |
+
// Try to sync clock diff.
|
175 |
+
if ( false !== $this->_sync_clock_diff( $diff ) ) {
|
176 |
+
// Retry call with new synced clock.
|
177 |
+
return $this->_call( $path, $method, $params, true );
|
178 |
+
}
|
179 |
+
}
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( $this->_logger->is_on() && self::is_api_error( $result ) ) {
|
184 |
+
// Log API errors.
|
185 |
+
$this->_logger->api_error( $result );
|
186 |
+
}
|
187 |
+
|
188 |
+
return $result;
|
189 |
+
}
|
190 |
+
|
191 |
+
/**
|
192 |
+
* Override API call to wrap it in servers' clock sync method.
|
193 |
+
*
|
194 |
+
* @param string $path
|
195 |
+
* @param string $method
|
196 |
+
* @param array $params
|
197 |
+
*
|
198 |
+
* @return array|mixed|string|void
|
199 |
+
* @throws Freemius_Exception
|
200 |
+
*/
|
201 |
+
function call( $path, $method = 'GET', $params = array() ) {
|
202 |
+
return $this->_call( $path, $method, $params );
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Get API request URL signed via query string.
|
207 |
+
*
|
208 |
+
* @param string $path
|
209 |
+
*
|
210 |
+
* @return string
|
211 |
+
*/
|
212 |
+
function get_signed_url( $path ) {
|
213 |
+
return $this->_api->GetSignedUrl( $path );
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* @param string $path
|
218 |
+
* @param bool $flush
|
219 |
+
* @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
|
220 |
+
*
|
221 |
+
* @return stdClass|mixed
|
222 |
+
*/
|
223 |
+
function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
|
224 |
+
$this->_logger->entrance( $path );
|
225 |
+
|
226 |
+
$cache_key = $this->get_cache_key( $path );
|
227 |
+
|
228 |
+
// Always flush during development.
|
229 |
+
if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
|
230 |
+
$flush = true;
|
231 |
+
}
|
232 |
+
|
233 |
+
$cached_result = self::$_cache->get( $cache_key );
|
234 |
+
|
235 |
+
if ( $flush || ! self::$_cache->has_valid( $cache_key, $expiration ) ) {
|
236 |
+
$result = $this->call( $path );
|
237 |
+
|
238 |
+
if ( ! is_object( $result ) || isset( $result->error ) ) {
|
239 |
+
// Api returned an error.
|
240 |
+
if ( is_object( $cached_result ) &&
|
241 |
+
! isset( $cached_result )
|
242 |
+
) {
|
243 |
+
// If there was an error during a newer data fetch,
|
244 |
+
// fallback to older data version.
|
245 |
+
$result = $cached_result;
|
246 |
+
|
247 |
+
if ( $this->_logger->is_on() ) {
|
248 |
+
$this->_logger->warn( 'Fallback to cached API result: ' . var_export( $cached_result, true ) );
|
249 |
+
}
|
250 |
+
} else {
|
251 |
+
// If no older data version, return result without
|
252 |
+
// caching the error.
|
253 |
+
return $result;
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
self::$_cache->set( $cache_key, $result, $expiration );
|
258 |
+
|
259 |
+
$cached_result = $result;
|
260 |
+
} else {
|
261 |
+
$this->_logger->log( 'Using cached API result.' );
|
262 |
+
}
|
263 |
+
|
264 |
+
return $cached_result;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Check if there's a cached version of the API request.
|
269 |
+
*
|
270 |
+
* @author Vova Feldman (@svovaf)
|
271 |
+
* @since 1.2.1
|
272 |
+
*
|
273 |
+
* @param string $path
|
274 |
+
* @param string $method
|
275 |
+
* @param array $params
|
276 |
+
*
|
277 |
+
* @return bool
|
278 |
+
*/
|
279 |
+
function is_cached( $path, $method = 'GET', $params = array() ) {
|
280 |
+
$cache_key = $this->get_cache_key( $path, $method, $params );
|
281 |
+
|
282 |
+
return self::$_cache->has_valid( $cache_key );
|
283 |
+
}
|
284 |
+
|
285 |
+
/**
|
286 |
+
* Invalidate a cached version of the API request.
|
287 |
+
*
|
288 |
+
* @author Vova Feldman (@svovaf)
|
289 |
+
* @since 1.2.1.5
|
290 |
+
*
|
291 |
+
* @param string $path
|
292 |
+
* @param string $method
|
293 |
+
* @param array $params
|
294 |
+
*/
|
295 |
+
function purge_cache( $path, $method = 'GET', $params = array() ) {
|
296 |
+
$this->_logger->entrance( "{$method}:{$path}" );
|
297 |
+
|
298 |
+
$cache_key = $this->get_cache_key( $path, $method, $params );
|
299 |
+
|
300 |
+
self::$_cache->purge( $cache_key );
|
301 |
+
}
|
302 |
+
|
303 |
+
/**
|
304 |
+
* @param string $path
|
305 |
+
* @param string $method
|
306 |
+
* @param array $params
|
307 |
+
*
|
308 |
+
* @return string
|
309 |
+
* @throws \Freemius_Exception
|
310 |
+
*/
|
311 |
+
private function get_cache_key( $path, $method = 'GET', $params = array() ) {
|
312 |
+
$canonized = $this->_api->CanonizePath( $path );
|
313 |
+
// $exploded = explode('/', $canonized);
|
314 |
+
// return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
|
315 |
+
return strtolower( $method . ':' . $canonized ) . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
|
316 |
+
}
|
317 |
+
|
318 |
+
/**
|
319 |
+
* Test API connectivity.
|
320 |
+
*
|
321 |
+
* @author Vova Feldman (@svovaf)
|
322 |
+
* @since 1.0.9 If fails, try to fallback to HTTP.
|
323 |
+
* @since 1.1.6 Added a 5-min caching mechanism, to prevent from overloading the server if the API if
|
324 |
+
* temporary down.
|
325 |
+
*
|
326 |
+
* @return bool True if successful connectivity to the API.
|
327 |
+
*/
|
328 |
+
static function test() {
|
329 |
+
self::_init();
|
330 |
+
|
331 |
+
$cache_key = 'ping_test';
|
332 |
+
|
333 |
+
$test = self::$_cache->get_valid( $cache_key, null );
|
334 |
+
|
335 |
+
if ( is_null( $test ) ) {
|
336 |
+
$test = Freemius_Api_WordPress::Test();
|
337 |
+
|
338 |
+
if ( false === $test && Freemius_Api_WordPress::IsHttps() ) {
|
339 |
+
// Fallback to HTTP, since HTTPS fails.
|
340 |
+
Freemius_Api_WordPress::SetHttp();
|
341 |
+
|
342 |
+
self::$_options->set_option( 'api_force_http', true, true );
|
343 |
+
|
344 |
+
$test = Freemius_Api_WordPress::Test();
|
345 |
+
|
346 |
+
if ( false === $test ) {
|
347 |
+
/**
|
348 |
+
* API connectivity test fail also in HTTP request, therefore,
|
349 |
+
* fallback to HTTPS to keep connection secure.
|
350 |
+
*
|
351 |
+
* @since 1.1.6
|
352 |
+
*/
|
353 |
+
self::$_options->set_option( 'api_force_http', false, true );
|
354 |
+
}
|
355 |
+
}
|
356 |
+
|
357 |
+
self::$_cache->set( $cache_key, $test, WP_FS__TIME_5_MIN_IN_SEC );
|
358 |
+
}
|
359 |
+
|
360 |
+
return $test;
|
361 |
+
}
|
362 |
+
|
363 |
+
/**
|
364 |
+
* Check if API is temporary down.
|
365 |
+
*
|
366 |
+
* @author Vova Feldman (@svovaf)
|
367 |
+
* @since 1.1.6
|
368 |
+
*
|
369 |
+
* @return bool
|
370 |
+
*/
|
371 |
+
static function is_temporary_down() {
|
372 |
+
self::_init();
|
373 |
+
|
374 |
+
$test = self::$_cache->get_valid( 'ping_test', null );
|
375 |
+
|
376 |
+
return ( false === $test );
|
377 |
+
}
|
378 |
+
|
379 |
+
/**
|
380 |
+
* @author Vova Feldman (@svovaf)
|
381 |
+
* @since 1.1.6
|
382 |
+
*
|
383 |
+
* @return object
|
384 |
+
*/
|
385 |
+
private function get_temporary_unavailable_error() {
|
386 |
+
return (object) array(
|
387 |
+
'error' => (object) array(
|
388 |
+
'type' => 'TemporaryUnavailable',
|
389 |
+
'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
|
390 |
+
'code' => 'temporary_unavailable',
|
391 |
+
'http' => 503
|
392 |
+
)
|
393 |
+
);
|
394 |
+
}
|
395 |
+
|
396 |
+
/**
|
397 |
+
* Ping API for connectivity test, and return result object.
|
398 |
+
*
|
399 |
+
* @author Vova Feldman (@svovaf)
|
400 |
+
* @since 1.0.9
|
401 |
+
*
|
402 |
+
* @param null|string $unique_anonymous_id
|
403 |
+
* @param array $params
|
404 |
+
*
|
405 |
+
* @return object
|
406 |
+
*/
|
407 |
+
function ping( $unique_anonymous_id = null, $params = array() ) {
|
408 |
+
$this->_logger->entrance();
|
409 |
+
|
410 |
+
if ( self::is_temporary_down() ) {
|
411 |
+
return $this->get_temporary_unavailable_error();
|
412 |
+
}
|
413 |
+
|
414 |
+
$pong = is_null( $unique_anonymous_id ) ?
|
415 |
+
Freemius_Api_WordPress::Ping() :
|
416 |
+
$this->_call( 'ping.json?' . http_build_query( array_merge(
|
417 |
+
array( 'uid' => $unique_anonymous_id ),
|
418 |
+
$params
|
419 |
+
) ) );
|
420 |
+
|
421 |
+
if ( $this->is_valid_ping( $pong ) ) {
|
422 |
+
return $pong;
|
423 |
+
}
|
424 |
+
|
425 |
+
if ( self::should_try_with_http( $pong ) ) {
|
426 |
+
// Fallback to HTTP, since HTTPS fails.
|
427 |
+
Freemius_Api_WordPress::SetHttp();
|
428 |
+
|
429 |
+
self::$_options->set_option( 'api_force_http', true, true );
|
430 |
+
|
431 |
+
$pong = is_null( $unique_anonymous_id ) ?
|
432 |
+
Freemius_Api_WordPress::Ping() :
|
433 |
+
$this->_call( 'ping.json?' . http_build_query( array_merge(
|
434 |
+
array( 'uid' => $unique_anonymous_id ),
|
435 |
+
$params
|
436 |
+
) ) );
|
437 |
+
|
438 |
+
if ( ! $this->is_valid_ping( $pong ) ) {
|
439 |
+
self::$_options->set_option( 'api_force_http', false, true );
|
440 |
+
}
|
441 |
+
}
|
442 |
+
|
443 |
+
return $pong;
|
444 |
+
}
|
445 |
+
|
446 |
+
/**
|
447 |
+
* Check if based on the API result we should try
|
448 |
+
* to re-run the same request with HTTP instead of HTTPS.
|
449 |
+
*
|
450 |
+
* @author Vova Feldman (@svovaf)
|
451 |
+
* @since 1.1.6
|
452 |
+
*
|
453 |
+
* @param $result
|
454 |
+
*
|
455 |
+
* @return bool
|
456 |
+
*/
|
457 |
+
private static function should_try_with_http( $result ) {
|
458 |
+
if ( ! Freemius_Api_WordPress::IsHttps() ) {
|
459 |
+
return false;
|
460 |
+
}
|
461 |
+
|
462 |
+
return ( ! is_object( $result ) ||
|
463 |
+
! isset( $result->error ) ||
|
464 |
+
! isset( $result->error->code ) ||
|
465 |
+
! in_array( $result->error->code, array(
|
466 |
+
'curl_missing',
|
467 |
+
'cloudflare_ddos_protection',
|
468 |
+
'maintenance_mode',
|
469 |
+
'squid_cache_block',
|
470 |
+
'too_many_requests',
|
471 |
+
) ) );
|
472 |
+
|
473 |
+
}
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Check if valid ping request result.
|
477 |
+
*
|
478 |
+
* @author Vova Feldman (@svovaf)
|
479 |
+
* @since 1.1.1
|
480 |
+
*
|
481 |
+
* @param mixed $pong
|
482 |
+
*
|
483 |
+
* @return bool
|
484 |
+
*/
|
485 |
+
function is_valid_ping( $pong ) {
|
486 |
+
return Freemius_Api_WordPress::Test( $pong );
|
487 |
+
}
|
488 |
+
|
489 |
+
function get_url( $path = '' ) {
|
490 |
+
return Freemius_Api_WordPress::GetUrl( $path, $this->_api->IsSandbox() );
|
491 |
+
}
|
492 |
+
|
493 |
+
/**
|
494 |
+
* Clear API cache.
|
495 |
+
*
|
496 |
+
* @author Vova Feldman (@svovaf)
|
497 |
+
* @since 1.0.9
|
498 |
+
*/
|
499 |
+
static function clear_cache() {
|
500 |
+
self::_init();
|
501 |
+
|
502 |
+
self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
|
503 |
+
self::$_cache->clear();
|
504 |
+
}
|
505 |
+
|
506 |
+
#----------------------------------------------------------------------------------
|
507 |
+
#region Error Handling
|
508 |
+
#----------------------------------------------------------------------------------
|
509 |
+
|
510 |
+
/**
|
511 |
+
* @author Vova Feldman (@svovaf)
|
512 |
+
* @since 1.2.1.5
|
513 |
+
*
|
514 |
+
* @param mixed $result
|
515 |
+
*
|
516 |
+
* @return bool Is API result contains an error.
|
517 |
+
*/
|
518 |
+
static function is_api_error( $result ) {
|
519 |
+
return ( is_object( $result ) && isset( $result->error ) ) ||
|
520 |
+
is_string( $result );
|
521 |
+
}
|
522 |
+
|
523 |
+
/**
|
524 |
+
* Checks if given API result is a non-empty and not an error object.
|
525 |
+
*
|
526 |
+
* @author Vova Feldman (@svovaf)
|
527 |
+
* @since 1.2.1.5
|
528 |
+
*
|
529 |
+
* @param mixed $result
|
530 |
+
* @param string|null $required_property Optional property we want to verify that is set.
|
531 |
+
*
|
532 |
+
* @return bool
|
533 |
+
*/
|
534 |
+
static function is_api_result_object( $result, $required_property = null ) {
|
535 |
+
return (
|
536 |
+
is_object( $result ) &&
|
537 |
+
! isset( $result->error ) &&
|
538 |
+
( empty( $required_property ) || isset( $result->{$required_property} ) )
|
539 |
+
);
|
540 |
+
}
|
541 |
+
|
542 |
+
/**
|
543 |
+
* Checks if given API result is a non-empty entity object with non-empty ID.
|
544 |
+
*
|
545 |
+
* @author Vova Feldman (@svovaf)
|
546 |
+
* @since 1.2.1.5
|
547 |
+
*
|
548 |
+
* @param mixed $result
|
549 |
+
*
|
550 |
+
* @return bool
|
551 |
+
*/
|
552 |
+
static function is_api_result_entity( $result ) {
|
553 |
+
return self::is_api_result_object( $result, 'id' ) &&
|
554 |
+
FS_Entity::is_valid_id( $result->id );
|
555 |
+
}
|
556 |
+
|
557 |
+
#endregion
|
558 |
}
|
freemius/includes/class-fs-logger.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
freemius/includes/class-fs-plugin-updater.php
CHANGED
@@ -1,683 +1,712 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* @package Freemius
|
4 |
-
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
-
* @since 1.0.4
|
7 |
-
*
|
8 |
-
* @link https://github.com/easydigitaldownloads/EDD-License-handler/blob/master/EDD_SL_Plugin_Updater.php
|
9 |
-
*/
|
10 |
-
|
11 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
-
exit;
|
13 |
-
}
|
14 |
-
|
15 |
-
// Uncomment this line for testing.
|
16 |
-
// set_site_transient( 'update_plugins', null );
|
17 |
-
|
18 |
-
class FS_Plugin_Updater {
|
19 |
-
|
20 |
-
/**
|
21 |
-
* @var Freemius
|
22 |
-
* @since 1.0.4
|
23 |
-
*/
|
24 |
-
private $_fs;
|
25 |
-
/**
|
26 |
-
* @var FS_Logger
|
27 |
-
* @since 1.0.4
|
28 |
-
*/
|
29 |
-
private $_logger;
|
30 |
-
/**
|
31 |
-
* @var object
|
32 |
-
* @since 1.1.8.1
|
33 |
-
*/
|
34 |
-
private $_update_details;
|
35 |
-
|
36 |
-
function __construct( Freemius $freemius ) {
|
37 |
-
$this->_fs = $freemius;
|
38 |
-
|
39 |
-
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $freemius->get_slug() . '_updater', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
40 |
-
|
41 |
-
$this->_filters();
|
42 |
-
}
|
43 |
-
|
44 |
-
/**
|
45 |
-
* Initiate required filters.
|
46 |
-
*
|
47 |
-
* @author Vova Feldman (@svovaf)
|
48 |
-
* @since 1.0.4
|
49 |
-
*/
|
50 |
-
private function _filters() {
|
51 |
-
// Override request for plugin information
|
52 |
-
add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
|
53 |
-
|
54 |
-
// WP 3.0+
|
55 |
-
add_filter( 'pre_set_site_transient_update_plugins', array(
|
56 |
-
&$this,
|
57 |
-
'pre_set_site_transient_update_plugins_filter'
|
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 |
-
$data
|
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 |
-
$data->
|
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 |
-
return
|
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 |
-
|
545 |
-
|
546 |
-
if (
|
547 |
-
|
548 |
-
|
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 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
*
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
*
|
647 |
-
*
|
648 |
-
* @
|
649 |
-
*
|
650 |
-
*
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
|
681 |
-
|
682 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
683 |
}
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.4
|
7 |
+
*
|
8 |
+
* @link https://github.com/easydigitaldownloads/EDD-License-handler/blob/master/EDD_SL_Plugin_Updater.php
|
9 |
+
*/
|
10 |
+
|
11 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
+
}
|
14 |
+
|
15 |
+
// Uncomment this line for testing.
|
16 |
+
// set_site_transient( 'update_plugins', null );
|
17 |
+
|
18 |
+
class FS_Plugin_Updater {
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @var Freemius
|
22 |
+
* @since 1.0.4
|
23 |
+
*/
|
24 |
+
private $_fs;
|
25 |
+
/**
|
26 |
+
* @var FS_Logger
|
27 |
+
* @since 1.0.4
|
28 |
+
*/
|
29 |
+
private $_logger;
|
30 |
+
/**
|
31 |
+
* @var object
|
32 |
+
* @since 1.1.8.1
|
33 |
+
*/
|
34 |
+
private $_update_details;
|
35 |
+
|
36 |
+
function __construct( Freemius $freemius ) {
|
37 |
+
$this->_fs = $freemius;
|
38 |
+
|
39 |
+
$this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $freemius->get_slug() . '_updater', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
|
40 |
+
|
41 |
+
$this->_filters();
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initiate required filters.
|
46 |
+
*
|
47 |
+
* @author Vova Feldman (@svovaf)
|
48 |
+
* @since 1.0.4
|
49 |
+
*/
|
50 |
+
private function _filters() {
|
51 |
+
// Override request for plugin information
|
52 |
+
add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
|
53 |
+
|
54 |
+
// WP 3.0+
|
55 |
+
add_filter( 'pre_set_site_transient_update_plugins', array(
|
56 |
+
&$this,
|
57 |
+
'pre_set_site_transient_update_plugins_filter'
|
58 |
+
) );
|
59 |
+
|
60 |
+
add_filter( 'pre_set_site_transient_update_themes', array(
|
61 |
+
&$this,
|
62 |
+
'pre_set_site_transient_update_plugins_filter'
|
63 |
+
) );
|
64 |
+
|
65 |
+
if ( ! $this->_fs->has_active_valid_license() ) {
|
66 |
+
/**
|
67 |
+
* If user has the premium plugin's code but do NOT have an active license,
|
68 |
+
* encourage him to upgrade by showing that there's a new release, but instead
|
69 |
+
* of showing an update link, show upgrade link to the pricing page.
|
70 |
+
*
|
71 |
+
* @since 1.1.6
|
72 |
+
*
|
73 |
+
*/
|
74 |
+
// WP 2.9+
|
75 |
+
add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array(
|
76 |
+
&$this,
|
77 |
+
'catch_plugin_update_row'
|
78 |
+
), 9 );
|
79 |
+
add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array(
|
80 |
+
&$this,
|
81 |
+
'edit_and_echo_plugin_update_row'
|
82 |
+
), 11, 2 );
|
83 |
+
}
|
84 |
+
|
85 |
+
if ( ! WP_FS__IS_PRODUCTION_MODE ) {
|
86 |
+
add_filter( 'http_request_host_is_external', array(
|
87 |
+
$this,
|
88 |
+
'http_request_host_is_external_filter'
|
89 |
+
), 10, 3 );
|
90 |
+
}
|
91 |
+
|
92 |
+
if ( $this->_fs->is_premium() && $this->is_correct_folder_name() ) {
|
93 |
+
add_filter( 'upgrader_post_install', array( &$this, '_maybe_update_folder_name' ), 10, 3 );
|
94 |
+
}
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Capture plugin update row by turning output buffering.
|
99 |
+
*
|
100 |
+
* @author Vova Feldman (@svovaf)
|
101 |
+
* @since 1.1.6
|
102 |
+
*/
|
103 |
+
function catch_plugin_update_row() {
|
104 |
+
ob_start();
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Overrides default update message format with "renew your license" message.
|
109 |
+
*
|
110 |
+
* @author Vova Feldman (@svovaf)
|
111 |
+
* @since 1.1.6
|
112 |
+
*
|
113 |
+
* @param string $file
|
114 |
+
* @param array $plugin_data
|
115 |
+
*/
|
116 |
+
function edit_and_echo_plugin_update_row( $file, $plugin_data ) {
|
117 |
+
$plugin_update_row = ob_get_clean();
|
118 |
+
|
119 |
+
$current = get_site_transient( 'update_plugins' );
|
120 |
+
if ( ! isset( $current->response[ $file ] ) ) {
|
121 |
+
echo $plugin_update_row;
|
122 |
+
|
123 |
+
return;
|
124 |
+
}
|
125 |
+
|
126 |
+
$r = $current->response[ $file ];
|
127 |
+
|
128 |
+
$plugin_update_row = preg_replace(
|
129 |
+
'/(\<div.+>)(.+)(\<a.+\<a.+)\<\/div\>/is',
|
130 |
+
'$1 $2 ' . sprintf(
|
131 |
+
$this->_fs->get_text_inline( '%sRenew your license now%s to access version %s features and support.', 'renew-license-now' ),
|
132 |
+
'<a href="' . $this->_fs->pricing_url() . '">', '</a>',
|
133 |
+
$r->new_version ) .
|
134 |
+
'$4',
|
135 |
+
$plugin_update_row
|
136 |
+
);
|
137 |
+
|
138 |
+
echo $plugin_update_row;
|
139 |
+
}
|
140 |
+
|
141 |
+
/**
|
142 |
+
* Since WP version 3.6, a new security feature was added that denies access to repository with a local ip.
|
143 |
+
* During development mode we want to be able updating plugin versions via our localhost repository. This
|
144 |
+
* filter white-list all domains including "api.freemius".
|
145 |
+
*
|
146 |
+
* @link http://www.emanueletessore.com/wordpress-download-failed-valid-url-provided/
|
147 |
+
*
|
148 |
+
* @author Vova Feldman (@svovaf)
|
149 |
+
* @since 1.0.4
|
150 |
+
*
|
151 |
+
* @param bool $allow
|
152 |
+
* @param string $host
|
153 |
+
* @param string $url
|
154 |
+
*
|
155 |
+
* @return bool
|
156 |
+
*/
|
157 |
+
function http_request_host_is_external_filter( $allow, $host, $url ) {
|
158 |
+
return ( false !== strpos( $host, 'freemius' ) ) ? true : $allow;
|
159 |
+
}
|
160 |
+
|
161 |
+
/**
|
162 |
+
* Check for Updates at the defined API endpoint and modify the update array.
|
163 |
+
*
|
164 |
+
* This function dives into the update api just when WordPress creates its update array,
|
165 |
+
* then adds a custom API call and injects the custom plugin data retrieved from the API.
|
166 |
+
* It is reassembled from parts of the native WordPress plugin update code.
|
167 |
+
* See wp-includes/update.php line 121 for the original wp_update_plugins() function.
|
168 |
+
*
|
169 |
+
* @author Vova Feldman (@svovaf)
|
170 |
+
* @since 1.0.4
|
171 |
+
*
|
172 |
+
* @uses FS_Api
|
173 |
+
*
|
174 |
+
* @param object $transient_data Update array build by WordPress.
|
175 |
+
*
|
176 |
+
* @return object Modified update array with custom plugin data.
|
177 |
+
*/
|
178 |
+
function pre_set_site_transient_update_plugins_filter( $transient_data ) {
|
179 |
+
$this->_logger->entrance();
|
180 |
+
|
181 |
+
/**
|
182 |
+
* "plugins" or "themes".
|
183 |
+
*
|
184 |
+
* @author Leo Fajardo (@leorw)
|
185 |
+
* @since 1.2.2
|
186 |
+
*/
|
187 |
+
$module_type = $this->_fs->get_module_type() . 's';
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Ensure that we don't mix plugins update info with themes update info.
|
191 |
+
*
|
192 |
+
* @author Leo Fajardo (@leorw)
|
193 |
+
* @since 1.2.2
|
194 |
+
*/
|
195 |
+
if ( "pre_set_site_transient_update_{$module_type}" !== current_filter() ) {
|
196 |
+
return $transient_data;
|
197 |
+
}
|
198 |
+
|
199 |
+
if ( empty( $transient_data ) ||
|
200 |
+
defined( 'WP_FS__UNINSTALL_MODE' )
|
201 |
+
) {
|
202 |
+
return $transient_data;
|
203 |
+
}
|
204 |
+
|
205 |
+
if ( ! isset( $this->_update_details ) ) {
|
206 |
+
// Get plugin's newest update.
|
207 |
+
$new_version = $this->_fs->get_update(
|
208 |
+
false,
|
209 |
+
fs_request_get_bool( 'force-check' ),
|
210 |
+
WP_FS__TIME_24_HOURS_IN_SEC / 24
|
211 |
+
);
|
212 |
+
|
213 |
+
$this->_update_details = false;
|
214 |
+
|
215 |
+
if ( is_object( $new_version ) ) {
|
216 |
+
$this->_logger->log( 'Found newer plugin version ' . $new_version->version );
|
217 |
+
|
218 |
+
$plugin_details = new stdClass();
|
219 |
+
$plugin_details->slug = $this->_fs->get_slug();
|
220 |
+
$plugin_details->new_version = $new_version->version;
|
221 |
+
$plugin_details->url = WP_FS__ADDRESS;
|
222 |
+
$plugin_details->package = $new_version->url;
|
223 |
+
$plugin_details->{ $this->_fs->get_module_type() } = $this->_fs->get_plugin_basename();
|
224 |
+
|
225 |
+
/**
|
226 |
+
* Cache plugin details locally since set_site_transient( 'update_plugins' )
|
227 |
+
* called multiple times and the non wp.org plugins are filtered after the
|
228 |
+
* call to .org.
|
229 |
+
*
|
230 |
+
* @since 1.1.8.1
|
231 |
+
*/
|
232 |
+
$this->_update_details = $plugin_details;
|
233 |
+
}
|
234 |
+
}
|
235 |
+
|
236 |
+
if ( is_object( $this->_update_details ) ) {
|
237 |
+
// Add plugin to transient data.
|
238 |
+
if ( $this->_fs->is_plugin() ) {
|
239 |
+
$transient_data->response[ $this->_fs->get_plugin_basename() ] = $this->_update_details;
|
240 |
+
} else {
|
241 |
+
$transient_data->response[ $this->_update_details->theme ] = (array) $this->_update_details;
|
242 |
+
}
|
243 |
+
}
|
244 |
+
|
245 |
+
return $transient_data;
|
246 |
+
}
|
247 |
+
|
248 |
+
/**
|
249 |
+
* Try to fetch plugin's info from .org repository.
|
250 |
+
*
|
251 |
+
* @author Vova Feldman (@svovaf)
|
252 |
+
* @since 1.0.5
|
253 |
+
*
|
254 |
+
* @param string $action
|
255 |
+
* @param object $args
|
256 |
+
*
|
257 |
+
* @return bool|mixed
|
258 |
+
*/
|
259 |
+
static function _fetch_plugin_info_from_repository( $action, $args ) {
|
260 |
+
$url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
|
261 |
+
if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
|
262 |
+
$url = set_url_scheme( $url, 'https' );
|
263 |
+
}
|
264 |
+
|
265 |
+
$args = array(
|
266 |
+
'timeout' => 15,
|
267 |
+
'body' => array(
|
268 |
+
'action' => $action,
|
269 |
+
'request' => serialize( $args )
|
270 |
+
)
|
271 |
+
);
|
272 |
+
|
273 |
+
$request = wp_remote_post( $url, $args );
|
274 |
+
|
275 |
+
if ( is_wp_error( $request ) ) {
|
276 |
+
return false;
|
277 |
+
}
|
278 |
+
|
279 |
+
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
|
280 |
+
|
281 |
+
if ( ! is_object( $res ) && ! is_array( $res ) ) {
|
282 |
+
return false;
|
283 |
+
}
|
284 |
+
|
285 |
+
return $res;
|
286 |
+
}
|
287 |
+
|
288 |
+
/**
|
289 |
+
* Updates information on the "View version x.x details" page with custom data.
|
290 |
+
*
|
291 |
+
* @author Vova Feldman (@svovaf)
|
292 |
+
* @since 1.0.4
|
293 |
+
*
|
294 |
+
* @uses FS_Api
|
295 |
+
*
|
296 |
+
* @param object $data
|
297 |
+
* @param string $action
|
298 |
+
* @param mixed $args
|
299 |
+
*
|
300 |
+
* @return object
|
301 |
+
*/
|
302 |
+
function plugins_api_filter( $data, $action = '', $args = null ) {
|
303 |
+
$this->_logger->entrance();
|
304 |
+
|
305 |
+
if ( ( 'plugin_information' !== $action ) ||
|
306 |
+
! isset( $args->slug )
|
307 |
+
) {
|
308 |
+
return $data;
|
309 |
+
}
|
310 |
+
|
311 |
+
$addon = false;
|
312 |
+
$is_addon = false;
|
313 |
+
|
314 |
+
if ( $this->_fs->get_slug() !== $args->slug ) {
|
315 |
+
$addon = $this->_fs->get_addon_by_slug( $args->slug );
|
316 |
+
|
317 |
+
if ( ! is_object( $addon ) ) {
|
318 |
+
return $data;
|
319 |
+
}
|
320 |
+
|
321 |
+
$is_addon = true;
|
322 |
+
}
|
323 |
+
|
324 |
+
$plugin_in_repo = false;
|
325 |
+
if ( ! $is_addon ) {
|
326 |
+
// Try to fetch info from .org repository.
|
327 |
+
$data = self::_fetch_plugin_info_from_repository( $action, $args );
|
328 |
+
|
329 |
+
$plugin_in_repo = ( false !== $data );
|
330 |
+
}
|
331 |
+
|
332 |
+
if ( ! $plugin_in_repo ) {
|
333 |
+
$data = $args;
|
334 |
+
|
335 |
+
// Fetch as much as possible info from local files.
|
336 |
+
$plugin_local_data = $this->_fs->get_plugin_data();
|
337 |
+
$data->name = $plugin_local_data['Name'];
|
338 |
+
$data->author = $plugin_local_data['Author'];
|
339 |
+
$data->sections = array(
|
340 |
+
'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
|
341 |
+
);
|
342 |
+
|
343 |
+
// @todo Store extra plugin info on Freemius or parse readme.txt markup.
|
344 |
+
/*$info = $this->_fs->get_api_site_scope()->call('/information.json');
|
345 |
+
|
346 |
+
if ( !isset($info->error) ) {
|
347 |
+
$data = $info;
|
348 |
+
}*/
|
349 |
+
}
|
350 |
+
|
351 |
+
// Get plugin's newest update.
|
352 |
+
$new_version = $this->get_latest_download_details( $is_addon ? $addon->id : false );
|
353 |
+
|
354 |
+
if ( ! is_object( $new_version ) || empty( $new_version->version ) ) {
|
355 |
+
$data->version = $this->_fs->get_plugin_version();
|
356 |
+
} else {
|
357 |
+
if ( $is_addon ) {
|
358 |
+
$data->name = $addon->title . ' ' . $this->_fs->get_text_inline( 'Add-On', 'addon' );
|
359 |
+
$data->slug = $addon->slug;
|
360 |
+
$data->url = WP_FS__ADDRESS;
|
361 |
+
$data->package = $new_version->url;
|
362 |
+
}
|
363 |
+
|
364 |
+
if ( ! $plugin_in_repo ) {
|
365 |
+
$data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
|
366 |
+
$data->requires = $new_version->requires_platform_version;
|
367 |
+
$data->tested = $new_version->tested_up_to_version;
|
368 |
+
}
|
369 |
+
|
370 |
+
$data->version = $new_version->version;
|
371 |
+
$data->download_link = $new_version->url;
|
372 |
+
}
|
373 |
+
|
374 |
+
return $data;
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* @author Vova Feldman (@svovaf)
|
379 |
+
* @since 1.2.1.7
|
380 |
+
*
|
381 |
+
* @param number|bool $addon_id
|
382 |
+
*
|
383 |
+
* @return object
|
384 |
+
*/
|
385 |
+
private function get_latest_download_details( $addon_id = false ) {
|
386 |
+
return $this->_fs->_fetch_latest_version( $addon_id );
|
387 |
+
}
|
388 |
+
|
389 |
+
/**
|
390 |
+
* Checks if a given basename has a matching folder name
|
391 |
+
* with the current context plugin.
|
392 |
+
*
|
393 |
+
* @author Vova Feldman (@svovaf)
|
394 |
+
* @since 1.2.1.6
|
395 |
+
*
|
396 |
+
* @param string $basename Current plugin's basename.
|
397 |
+
*
|
398 |
+
* @return bool
|
399 |
+
*/
|
400 |
+
private function is_correct_folder_name( $basename = '' ) {
|
401 |
+
if ( empty( $basename ) ) {
|
402 |
+
$basename = $this->_fs->get_plugin_basename();
|
403 |
+
}
|
404 |
+
|
405 |
+
return ( $this->_fs->get_target_folder_name() != trim( dirname( $basename ), '/\\' ) );
|
406 |
+
}
|
407 |
+
|
408 |
+
/**
|
409 |
+
* This is a special after upgrade handler for migrating modules
|
410 |
+
* that didn't use the '-premium' suffix folder structure before
|
411 |
+
* the migration.
|
412 |
+
*
|
413 |
+
* @author Vova Feldman (@svovaf)
|
414 |
+
* @since 1.2.1.6
|
415 |
+
*
|
416 |
+
* @param bool $response Install response.
|
417 |
+
* @param array $hook_extra Extra arguments passed to hooked filters.
|
418 |
+
* @param array $result Installation result data.
|
419 |
+
*
|
420 |
+
* @return bool
|
421 |
+
*/
|
422 |
+
function _maybe_update_folder_name( $response, $hook_extra, $result ) {
|
423 |
+
$basename = $this->_fs->get_plugin_basename();
|
424 |
+
|
425 |
+
if ( true !== $response ||
|
426 |
+
empty( $hook_extra ) ||
|
427 |
+
empty( $hook_extra['plugin'] ) ||
|
428 |
+
$basename !== $hook_extra['plugin']
|
429 |
+
) {
|
430 |
+
return $response;
|
431 |
+
}
|
432 |
+
|
433 |
+
$active_plugins_basenames = get_option( 'active_plugins' );
|
434 |
+
|
435 |
+
for ( $i = 0, $len = count( $active_plugins_basenames ); $i < $len; $i ++ ) {
|
436 |
+
if ( $basename === $active_plugins_basenames[ $i ] ) {
|
437 |
+
// Get filename including extension.
|
438 |
+
$filename = basename( $basename );
|
439 |
+
|
440 |
+
$new_basename = plugin_basename(
|
441 |
+
trailingslashit( $this->_fs->get_slug() . ( $this->_fs->is_premium() ? '-premium' : '' ) ) .
|
442 |
+
$filename
|
443 |
+
);
|
444 |
+
|
445 |
+
// Verify that the expected correct path exists.
|
446 |
+
if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $new_basename ) ) ) {
|
447 |
+
// Override active plugin name.
|
448 |
+
$active_plugins_basenames[ $i ] = $new_basename;
|
449 |
+
update_option( 'active_plugins', $active_plugins_basenames );
|
450 |
+
}
|
451 |
+
|
452 |
+
break;
|
453 |
+
}
|
454 |
+
}
|
455 |
+
|
456 |
+
return $response;
|
457 |
+
}
|
458 |
+
|
459 |
+
#----------------------------------------------------------------------------------
|
460 |
+
#region Auto Activation
|
461 |
+
#----------------------------------------------------------------------------------
|
462 |
+
|
463 |
+
/**
|
464 |
+
* Installs and active a plugin when explicitly requested that from a 3rd party service.
|
465 |
+
*
|
466 |
+
* This logic was inspired by the TGMPA GPL licensed library by Thomas Griffin.
|
467 |
+
*
|
468 |
+
* @link http://tgmpluginactivation.com/
|
469 |
+
*
|
470 |
+
* @author Vova Feldman
|
471 |
+
* @since 1.2.1.7
|
472 |
+
*
|
473 |
+
* @link https://make.wordpress.org/plugins/2017/03/16/clarification-of-guideline-8-executable-code-and-installs/
|
474 |
+
*
|
475 |
+
* @uses WP_Filesystem
|
476 |
+
* @uses WP_Error
|
477 |
+
* @uses WP_Upgrader
|
478 |
+
* @uses Plugin_Upgrader
|
479 |
+
* @uses Plugin_Installer_Skin
|
480 |
+
* @uses Plugin_Upgrader_Skin
|
481 |
+
*
|
482 |
+
* @param number|bool $plugin_id
|
483 |
+
*
|
484 |
+
* @return array
|
485 |
+
*/
|
486 |
+
function install_and_activate_plugin( $plugin_id = false ) {
|
487 |
+
if ( ! empty( $plugin_id ) && ! FS_Plugin::is_valid_id( $plugin_id ) ) {
|
488 |
+
// Invalid plugin ID.
|
489 |
+
return array(
|
490 |
+
'message' => $this->_fs->get_text_inline( 'Invalid module ID.', 'auto-install-error-invalid-id' ),
|
491 |
+
'code' => 'invalid_module_id',
|
492 |
+
);
|
493 |
+
}
|
494 |
+
|
495 |
+
$is_addon = false;
|
496 |
+
if ( FS_Plugin::is_valid_id( $plugin_id ) &&
|
497 |
+
$plugin_id != $this->_fs->get_id()
|
498 |
+
) {
|
499 |
+
$addon = $this->_fs->get_addon( $plugin_id );
|
500 |
+
|
501 |
+
if ( ! is_object( $addon ) ) {
|
502 |
+
// Invalid add-on ID.
|
503 |
+
return array(
|
504 |
+
'message' => $this->_fs->get_text_inline( 'Invalid module ID.', 'auto-install-error-invalid-id' ),
|
505 |
+
'code' => 'invalid_module_id',
|
506 |
+
);
|
507 |
+
}
|
508 |
+
|
509 |
+
$slug = $addon->slug;
|
510 |
+
$title = $addon->title . ' ' . $this->_fs->get_text_inline( 'Add-On', 'addon' );
|
511 |
+
|
512 |
+
$is_addon = true;
|
513 |
+
} else {
|
514 |
+
$slug = $this->_fs->get_slug();
|
515 |
+
$title = $this->_fs->get_plugin_title() .
|
516 |
+
( $this->_fs->is_addon() ? ' ' . $this->_fs->get_text_inline( 'Add-On', 'addon' ) : '' );
|
517 |
+
}
|
518 |
+
|
519 |
+
if ( $this->is_premium_plugin_active( $plugin_id ) ) {
|
520 |
+
// Premium version already activated.
|
521 |
+
return array(
|
522 |
+
'message' => $is_addon ?
|
523 |
+
$this->_fs->get_text_inline( 'Premium add-on version already installed.', 'auto-install-error-premium-addon-activated' ) :
|
524 |
+
$this->_fs->get_text_inline( 'Premium version already active.', 'auto-install-error-premium-activated' ),
|
525 |
+
'code' => 'premium_installed',
|
526 |
+
);
|
527 |
+
}
|
528 |
+
|
529 |
+
$latest_version = $this->get_latest_download_details( $plugin_id );
|
530 |
+
$target_folder = "{$slug}-premium";
|
531 |
+
|
532 |
+
// Prep variables for Plugin_Installer_Skin class.
|
533 |
+
$extra = array();
|
534 |
+
$extra['slug'] = $target_folder;
|
535 |
+
$source = $latest_version->url;
|
536 |
+
$api = null;
|
537 |
+
|
538 |
+
$install_url = add_query_arg(
|
539 |
+
array(
|
540 |
+
'action' => 'install-plugin',
|
541 |
+
'plugin' => urlencode( $slug ),
|
542 |
+
),
|
543 |
+
'update.php'
|
544 |
+
);
|
545 |
+
|
546 |
+
if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
|
547 |
+
// Include required resources for the installation.
|
548 |
+
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
|
549 |
+
}
|
550 |
+
|
551 |
+
$skin_args = array(
|
552 |
+
'type' => 'web',
|
553 |
+
'title' => sprintf( $this->_fs->get_text_inline( 'Installing plugin: %s', 'installing-plugin-x' ), $title ),
|
554 |
+
'url' => esc_url_raw( $install_url ),
|
555 |
+
'nonce' => 'install-plugin_' . $slug,
|
556 |
+
'plugin' => '',
|
557 |
+
'api' => $api,
|
558 |
+
'extra' => $extra,
|
559 |
+
);
|
560 |
+
|
561 |
+
// $skin = new Automatic_Upgrader_Skin( $skin_args );
|
562 |
+
// $skin = new Plugin_Installer_Skin( $skin_args );
|
563 |
+
$skin = new WP_Ajax_Upgrader_Skin( $skin_args );
|
564 |
+
|
565 |
+
// Create a new instance of Plugin_Upgrader.
|
566 |
+
$upgrader = new Plugin_Upgrader( $skin );
|
567 |
+
|
568 |
+
// Perform the action and install the plugin from the $source urldecode().
|
569 |
+
add_filter( 'upgrader_source_selection', array( &$this, '_maybe_adjust_source_dir' ), 1, 3 );
|
570 |
+
|
571 |
+
$install_result = $upgrader->install( $source );
|
572 |
+
|
573 |
+
remove_filter( 'upgrader_source_selection', array( &$this, '_maybe_adjust_source_dir' ), 1 );
|
574 |
+
|
575 |
+
if ( is_wp_error( $install_result ) ) {
|
576 |
+
return array(
|
577 |
+
'message' => $install_result->get_error_message(),
|
578 |
+
'code' => $install_result->get_error_code(),
|
579 |
+
);
|
580 |
+
} elseif ( is_wp_error( $skin->result ) ) {
|
581 |
+
return array(
|
582 |
+
'message' => $skin->result->get_error_message(),
|
583 |
+
'code' => $skin->result->get_error_code(),
|
584 |
+
);
|
585 |
+
} elseif ( $skin->get_errors()->get_error_code() ) {
|
586 |
+
return array(
|
587 |
+
'message' => $skin->get_error_messages(),
|
588 |
+
'code' => 'unknown',
|
589 |
+
);
|
590 |
+
} elseif ( is_null( $install_result ) ) {
|
591 |
+
global $wp_filesystem;
|
592 |
+
|
593 |
+
$error_code = 'unable_to_connect_to_filesystem';
|
594 |
+
$error_message = $this->_fs->get_text_inline( 'Unable to connect to the filesystem. Please confirm your credentials.' );
|
595 |
+
|
596 |
+
// Pass through the error from WP_Filesystem if one was raised.
|
597 |
+
if ( $wp_filesystem instanceof WP_Filesystem_Base &&
|
598 |
+
is_wp_error( $wp_filesystem->errors ) &&
|
599 |
+
$wp_filesystem->errors->get_error_code()
|
600 |
+
) {
|
601 |
+
$error_message = $wp_filesystem->errors->get_error_message();
|
602 |
+
}
|
603 |
+
|
604 |
+
return array(
|
605 |
+
'message' => $error_message,
|
606 |
+
'code' => $error_code,
|
607 |
+
);
|
608 |
+
}
|
609 |
+
|
610 |
+
// Grab the full path to the main plugin's file.
|
611 |
+
$plugin_activate = $upgrader->plugin_info();
|
612 |
+
|
613 |
+
// Try to activate the plugin.
|
614 |
+
$activation_result = $this->try_activate_plugin( $plugin_activate );
|
615 |
+
|
616 |
+
if ( is_wp_error( $activation_result ) ) {
|
617 |
+
return array(
|
618 |
+
'message' => $activation_result->get_error_message(),
|
619 |
+
'code' => $activation_result->get_error_code(),
|
620 |
+
);
|
621 |
+
}
|
622 |
+
|
623 |
+
return $skin->get_upgrade_messages();
|
624 |
+
}
|
625 |
+
|
626 |
+
/**
|
627 |
+
* Tries to activate a plugin. If fails, returns the error.
|
628 |
+
*
|
629 |
+
* @author Vova Feldman
|
630 |
+
* @since 1.2.1.7
|
631 |
+
*
|
632 |
+
* @param string $file_path Path within wp-plugins/ to main plugin file.
|
633 |
+
* This determines the styling of the output messages.
|
634 |
+
*
|
635 |
+
* @return bool|WP_Error
|
636 |
+
*/
|
637 |
+
protected function try_activate_plugin( $file_path ) {
|
638 |
+
$activate = activate_plugin( $file_path );
|
639 |
+
|
640 |
+
return is_wp_error( $activate ) ?
|
641 |
+
$activate :
|
642 |
+
true;
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Check if a premium module version is already active.
|
647 |
+
*
|
648 |
+
* @author Vova Feldman
|
649 |
+
* @since 1.2.1.7
|
650 |
+
*
|
651 |
+
* @param number|bool $plugin_id
|
652 |
+
*
|
653 |
+
* @return bool
|
654 |
+
*/
|
655 |
+
private function is_premium_plugin_active( $plugin_id = false ) {
|
656 |
+
if ( $plugin_id != $this->_fs->get_id() ) {
|
657 |
+
return $this->_fs->is_addon_activated( $plugin_id, true );
|
658 |
+
}
|
659 |
+
|
660 |
+
return is_plugin_active( $this->_fs->premium_plugin_basename() );
|
661 |
+
}
|
662 |
+
|
663 |
+
/**
|
664 |
+
* Adjust the plugin directory name if necessary.
|
665 |
+
* Assumes plugin has a folder (not a single file plugin).
|
666 |
+
*
|
667 |
+
* The final destination directory of a plugin is based on the subdirectory name found in the
|
668 |
+
* (un)zipped source. In some cases this subdirectory name is not the same as the expected
|
669 |
+
* slug and the plugin will not be recognized as installed. This is fixed by adjusting
|
670 |
+
* the temporary unzipped source subdirectory name to the expected plugin slug.
|
671 |
+
*
|
672 |
+
* @author Vova Feldman
|
673 |
+
* @since 1.2.1.7
|
674 |
+
*
|
675 |
+
* @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
|
676 |
+
* @param string $remote_source Path to upgrade/zip-file-name.tmp.
|
677 |
+
* @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
|
678 |
+
*
|
679 |
+
* @return string|WP_Error
|
680 |
+
*/
|
681 |
+
function _maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
|
682 |
+
if ( ! is_object( $GLOBALS['wp_filesystem'] ) ) {
|
683 |
+
return $source;
|
684 |
+
}
|
685 |
+
|
686 |
+
// Figure out what the slug is supposed to be.
|
687 |
+
$desired_slug = $upgrader->skin->options['extra']['slug'];
|
688 |
+
|
689 |
+
$subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
|
690 |
+
|
691 |
+
if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
|
692 |
+
$from_path = untrailingslashit( $source );
|
693 |
+
$to_path = trailingslashit( $remote_source ) . $desired_slug;
|
694 |
+
|
695 |
+
if ( true === $GLOBALS['wp_filesystem']->move( $from_path, $to_path ) ) {
|
696 |
+
return trailingslashit( $to_path );
|
697 |
+
} else {
|
698 |
+
return new WP_Error(
|
699 |
+
'rename_failed',
|
700 |
+
$this->_fs->get_text_inline( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.', 'module-package-rename-failure' ),
|
701 |
+
array(
|
702 |
+
'found' => $subdir_name,
|
703 |
+
'expected' => $desired_slug
|
704 |
+
) );
|
705 |
+
}
|
706 |
+
}
|
707 |
+
|
708 |
+
return $source;
|
709 |
+
}
|
710 |
+
|
711 |
+
#endregion
|
712 |
}
|
freemius/includes/class-fs-security.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
freemius/includes/customizer/class-fs-customizer-support-section.php
ADDED
@@ -0,0 +1,102 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.2.2.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class Zerif_Customizer_Theme_Info_Main
|
15 |
+
*
|
16 |
+
* @since 1.0.0
|
17 |
+
* @access public
|
18 |
+
*/
|
19 |
+
class FS_Customizer_Support_Section extends WP_Customize_Section {
|
20 |
+
|
21 |
+
function __construct( $manager, $id, $args = array() ) {
|
22 |
+
$manager->register_section_type( 'FS_Customizer_Support_Section' );
|
23 |
+
|
24 |
+
parent::__construct( $manager, $id, $args );
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* The type of customize section being rendered.
|
29 |
+
*
|
30 |
+
* @since 1.0.0
|
31 |
+
* @access public
|
32 |
+
* @var string
|
33 |
+
*/
|
34 |
+
public $type = 'freemius-support-section';
|
35 |
+
|
36 |
+
/**
|
37 |
+
* @var Freemius
|
38 |
+
*/
|
39 |
+
public $fs = null;
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Add custom parameters to pass to the JS via JSON.
|
43 |
+
*
|
44 |
+
* @since 1.0.0
|
45 |
+
*/
|
46 |
+
public function json() {
|
47 |
+
$json = parent::json();
|
48 |
+
|
49 |
+
$is_contact_visible = $this->fs->is_page_visible( 'contact' );
|
50 |
+
$is_support_visible = $this->fs->is_page_visible( 'support' );
|
51 |
+
|
52 |
+
$json['theme_title'] = $this->fs->get_plugin_name();
|
53 |
+
|
54 |
+
if ( $is_contact_visible && $is_support_visible ) {
|
55 |
+
$json['theme_title'] .= ' ' . $this->fs->get_text_inline( 'Support', 'support' );
|
56 |
+
}
|
57 |
+
|
58 |
+
if ( $is_contact_visible ) {
|
59 |
+
$json['contact'] = array(
|
60 |
+
'label' => $this->fs->get_text_inline( 'Contact Us', 'contact-us' ),
|
61 |
+
'url' => $this->fs->contact_url(),
|
62 |
+
);
|
63 |
+
}
|
64 |
+
|
65 |
+
if ( $is_support_visible ) {
|
66 |
+
$json['support'] = array(
|
67 |
+
'label' => $this->fs->get_text_inline( 'Support Forum', 'support-forum' ),
|
68 |
+
'url' => $this->fs->get_support_forum_url()
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
return $json;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Outputs the Underscore.js template.
|
77 |
+
*
|
78 |
+
* @since 1.0.0
|
79 |
+
*/
|
80 |
+
protected function render_template() {
|
81 |
+
?>
|
82 |
+
<li id="fs_customizer_support"
|
83 |
+
class="accordion-section control-section control-section-{{ data.type }} cannot-expand">
|
84 |
+
<h3 class="accordion-section-title">
|
85 |
+
<span>{{ data.theme_title }}</span>
|
86 |
+
<# if ( data.contact && data.support ) { #>
|
87 |
+
<div class="button-group">
|
88 |
+
<# } #>
|
89 |
+
<# if ( data.contact ) { #>
|
90 |
+
<a class="button" href="{{ data.contact.url }}" target="_blank">{{ data.contact.label }} </a>
|
91 |
+
<# } #>
|
92 |
+
<# if ( data.support ) { #>
|
93 |
+
<a class="button" href="{{ data.support.url }}" target="_blank">{{ data.support.label }} </a>
|
94 |
+
<# } #>
|
95 |
+
<# if ( data.contact && data.support ) { #>
|
96 |
+
</div>
|
97 |
+
<# } #>
|
98 |
+
</h3>
|
99 |
+
</li>
|
100 |
+
<?php
|
101 |
+
}
|
102 |
+
}
|
freemius/includes/customizer/class-fs-customizer-upsell-control.php
ADDED
@@ -0,0 +1,157 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.2.2.7
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Class FS_Customizer_Upsell_Control
|
15 |
+
*/
|
16 |
+
class FS_Customizer_Upsell_Control extends WP_Customize_Control {
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Control type
|
20 |
+
*
|
21 |
+
* @var string control type
|
22 |
+
*/
|
23 |
+
public $type = 'freemius-upsell-control';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @var Freemius
|
27 |
+
*/
|
28 |
+
public $fs = null;
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @param WP_Customize_Manager $manager the customize manager class.
|
32 |
+
* @param string $id id.
|
33 |
+
* @param array $args customizer manager parameters.
|
34 |
+
*/
|
35 |
+
public function __construct( WP_Customize_Manager $manager, $id, array $args ) {
|
36 |
+
$manager->register_control_type( 'FS_Customizer_Upsell_Control' );
|
37 |
+
|
38 |
+
parent::__construct( $manager, $id, $args );
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Enqueue resources for the control.
|
43 |
+
*/
|
44 |
+
public function enqueue() {
|
45 |
+
fs_enqueue_local_style( 'fs_customizer', 'customizer.css' );
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Json conversion
|
50 |
+
*/
|
51 |
+
public function to_json() {
|
52 |
+
$pricing_cta = esc_html( $this->fs->get_pricing_cta_label() ) . ' ' . ( is_rtl() ? '←' : '➤' );
|
53 |
+
|
54 |
+
parent::to_json();
|
55 |
+
|
56 |
+
$this->json['button_text'] = $pricing_cta;
|
57 |
+
$this->json['button_url'] = $this->fs->is_in_trial_promotion() ?
|
58 |
+
$this->fs->get_trial_url() :
|
59 |
+
$this->fs->get_upgrade_url();
|
60 |
+
|
61 |
+
// Load features.
|
62 |
+
$pricing = $this->fs->get_api_plugin_scope()->get( 'pricing.json' );
|
63 |
+
|
64 |
+
if ( $this->fs->is_api_result_object( $pricing, 'plans' ) ) {
|
65 |
+
// Add support features.
|
66 |
+
if ( is_array( $pricing->plans ) && 0 < count( $pricing->plans ) ) {
|
67 |
+
$support_features = array(
|
68 |
+
'kb' => 'Help Center',
|
69 |
+
'forum' => 'Support Forum',
|
70 |
+
'email' => 'Priority Email Support',
|
71 |
+
'phone' => 'Phone Support',
|
72 |
+
'skype' => 'Skype Support',
|
73 |
+
'is_success_manager' => 'Personal Success Manager',
|
74 |
+
);
|
75 |
+
|
76 |
+
for ( $i = 0, $len = count( $pricing->plans ); $i < $len; $i ++ ) {
|
77 |
+
if ( 'free' == $pricing->plans[$i]->name ) {
|
78 |
+
continue;
|
79 |
+
}
|
80 |
+
|
81 |
+
if ( ! isset( $pricing->plans[ $i ]->features ) ||
|
82 |
+
! is_array( $pricing->plans[ $i ]->features ) ) {
|
83 |
+
$pricing->plans[$i]->features = array();
|
84 |
+
}
|
85 |
+
|
86 |
+
foreach ( $support_features as $key => $label ) {
|
87 |
+
$key = ( 'is_success_manager' !== $key ) ?
|
88 |
+
"support_{$key}" :
|
89 |
+
$key;
|
90 |
+
|
91 |
+
if ( ! empty( $pricing->plans[ $i ]->{$key} ) ) {
|
92 |
+
|
93 |
+
$support_feature = new stdClass();
|
94 |
+
$support_feature->title = $label;
|
95 |
+
|
96 |
+
$pricing->plans[ $i ]->features[] = $support_feature;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
}
|
101 |
+
}
|
102 |
+
|
103 |
+
$this->json['plans'] = $pricing->plans;
|
104 |
+
|
105 |
+
$this->json['strings'] = array(
|
106 |
+
'plan' => $this->fs->get_text_x_inline( 'Plan', 'as product pricing plan', 'plan' ),
|
107 |
+
);
|
108 |
+
}
|
109 |
+
|
110 |
+
/**
|
111 |
+
* Control content
|
112 |
+
*/
|
113 |
+
public function content_template() {
|
114 |
+
?>
|
115 |
+
<div id="fs_customizer_upsell">
|
116 |
+
<# if ( data.plans ) { #>
|
117 |
+
<ul class="fs-customizer-plans">
|
118 |
+
<# for (i in data.plans) { #>
|
119 |
+
<# if ( 'free' != data.plans[i].name && (null != data.plans[i].features && 0 < data.plans[i].features.length) ) { #>
|
120 |
+
<li class="fs-customizer-plan">
|
121 |
+
<div class="fs-accordion-section-open">
|
122 |
+
<h2 class="fs-accordion-section-title menu-item">
|
123 |
+
<span>{{ data.plans[i].title }}</span>
|
124 |
+
<button type="button" class="button-link item-edit" aria-expanded="true">
|
125 |
+
<span class="screen-reader-text">Toggle section: {{ data.plans[i].title }} {{ data.strings.plan }}</span>
|
126 |
+
<span class="toggle-indicator" aria-hidden="true"></span>
|
127 |
+
</button>
|
128 |
+
</h2>
|
129 |
+
<div class="fs-accordion-section-content">
|
130 |
+
<# if ( data.plans[i].description ) { #>
|
131 |
+
<h3>{{ data.plans[i].description }}</h3>
|
132 |
+
<# } #>
|
133 |
+
<# if ( data.plans[i].features ) { #>
|
134 |
+
<ul>
|
135 |
+
<# for ( j in data.plans[i].features ) { #>
|
136 |
+
<li><div class="fs-feature">
|
137 |
+
<span class="dashicons dashicons-yes"></span><span><# if ( data.plans[i].features[j].value ) { #>{{ data.plans[i].features[j].value }} <# } #>{{ data.plans[i].features[j].title }}</span>
|
138 |
+
<# if ( data.plans[i].features[j].description ) { #>
|
139 |
+
<span class="dashicons dashicons-editor-help"><span class="fs-feature-desc">{{ data.plans[i].features[j].description }}</span></span>
|
140 |
+
<# } #>
|
141 |
+
</div></li>
|
142 |
+
<# } #>
|
143 |
+
</ul>
|
144 |
+
<# } #>
|
145 |
+
<# if ( 'free' != data.plans[i].name ) { #>
|
146 |
+
<a href="{{ data.button_url }}" class="button button-primary" target="_blank">{{{ data.button_text }}}</a>
|
147 |
+
<# } #>
|
148 |
+
</div>
|
149 |
+
</div>
|
150 |
+
</li>
|
151 |
+
<# } #>
|
152 |
+
<# } #>
|
153 |
+
</ul>
|
154 |
+
<# } #>
|
155 |
+
</div>
|
156 |
+
<?php }
|
157 |
+
}
|
freemius/includes/customizer/index.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Silence is golden.
|
3 |
+
// Hide file structure from users on unprotected servers.
|
freemius/includes/debug/class-fs-debug-bar-panel.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.1.7.3
|
7 |
*/
|
8 |
|
@@ -24,8 +24,8 @@
|
|
24 |
}
|
25 |
|
26 |
static function requests_count() {
|
27 |
-
if ( class_exists( '
|
28 |
-
$logger =
|
29 |
} else {
|
30 |
$logger = array();
|
31 |
}
|
@@ -34,8 +34,8 @@
|
|
34 |
}
|
35 |
|
36 |
static function total_time() {
|
37 |
-
if ( class_exists( '
|
38 |
-
$logger =
|
39 |
} else {
|
40 |
$logger = array();
|
41 |
}
|
@@ -45,7 +45,7 @@
|
|
45 |
$total_time += $l['total'];
|
46 |
}
|
47 |
|
48 |
-
return number_format( 100 * $total_time, 2 ) . ' ' .
|
49 |
}
|
50 |
|
51 |
function render() {
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.1.7.3
|
7 |
*/
|
8 |
|
24 |
}
|
25 |
|
26 |
static function requests_count() {
|
27 |
+
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
|
28 |
+
$logger = Freemius_Api_WordPress::GetLogger();
|
29 |
} else {
|
30 |
$logger = array();
|
31 |
}
|
34 |
}
|
35 |
|
36 |
static function total_time() {
|
37 |
+
if ( class_exists( 'Freemius_Api_WordPress' ) ) {
|
38 |
+
$logger = Freemius_Api_WordPress::GetLogger();
|
39 |
} else {
|
40 |
$logger = array();
|
41 |
}
|
45 |
$total_time += $l['total'];
|
46 |
}
|
47 |
|
48 |
+
return number_format( 100 * $total_time, 2 ) . ' ' . fs_text_x_inline( 'ms', 'milliseconds' );
|
49 |
}
|
50 |
|
51 |
function render() {
|
freemius/includes/debug/debug-bar-start.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.1.7.3
|
7 |
*/
|
8 |
|
@@ -38,8 +38,8 @@
|
|
38 |
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
|
39 |
$statuses[] = array(
|
40 |
'fs_api_requests',
|
41 |
-
|
42 |
-
Freemius_Debug_Bar_Panel::requests_count() . ' ' .
|
43 |
' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
|
44 |
);
|
45 |
}
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.1.7.3
|
7 |
*/
|
8 |
|
38 |
require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
|
39 |
$statuses[] = array(
|
40 |
'fs_api_requests',
|
41 |
+
fs_text_inline( 'Freemius API' ),
|
42 |
+
Freemius_Debug_Bar_Panel::requests_count() . ' ' . fs_text_inline( 'Requests' ) .
|
43 |
' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
|
44 |
);
|
45 |
}
|
freemius/includes/entities/class-fs-affiliate-terms.php
ADDED
@@ -0,0 +1,128 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.2.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
class FS_AffiliateTerms extends FS_Scope_Entity {
|
14 |
+
|
15 |
+
#region Properties
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var bool
|
19 |
+
*/
|
20 |
+
public $is_active;
|
21 |
+
/**
|
22 |
+
* @var string Enum: `affiliation` or `rewards`. Defaults to `affiliation`.
|
23 |
+
*/
|
24 |
+
public $type;
|
25 |
+
/**
|
26 |
+
* @var string Enum: `payout` or `credit`. Defaults to `payout`.
|
27 |
+
*/
|
28 |
+
public $reward_type;
|
29 |
+
/**
|
30 |
+
* If `first`, the referral will be attributed to the first visited source containing the affiliation link that
|
31 |
+
* was clicked.
|
32 |
+
*
|
33 |
+
* @var string Enum: `first` or `last`. Defaults to `first`.
|
34 |
+
*/
|
35 |
+
public $referral_attribution;
|
36 |
+
/**
|
37 |
+
* @var int Defaults to `30`, `0` for session cookie, and `null` for endless cookie (until cookies are cleaned).
|
38 |
+
*/
|
39 |
+
public $cookie_days;
|
40 |
+
/**
|
41 |
+
* @var int
|
42 |
+
*/
|
43 |
+
public $commission;
|
44 |
+
/**
|
45 |
+
* @var string Enum: `percentage` or `dollar`. Defaults to `percentage`.
|
46 |
+
*/
|
47 |
+
public $commission_type;
|
48 |
+
/**
|
49 |
+
* @var null|int Defaults to `0` (affiliate only on first payment). `null` for commission for all renewals. If
|
50 |
+
* greater than `0`, affiliate will get paid for all renewals for `commission_renewals_days` days after
|
51 |
+
* the initial upgrade/purchase.
|
52 |
+
*/
|
53 |
+
public $commission_renewals_days;
|
54 |
+
/**
|
55 |
+
* @var int Only cents and no percentage. In US cents, e.g.: 100 = $1.00. Defaults to `null`.
|
56 |
+
*/
|
57 |
+
public $install_commission;
|
58 |
+
/**
|
59 |
+
* @var string Required default target link, e.g.: pricing page.
|
60 |
+
*/
|
61 |
+
public $default_url;
|
62 |
+
/**
|
63 |
+
* @var string One of the following: 'all', 'new_customer', 'new_user'.
|
64 |
+
* If 'all' - reward for any user type.
|
65 |
+
* If 'new_customer' - reward only for new customers.
|
66 |
+
* If 'new_user' - reward only for new users.
|
67 |
+
*/
|
68 |
+
public $reward_customer_type;
|
69 |
+
/**
|
70 |
+
* @var int Defaults to `0` (affiliate only on directly affiliated links). `null` if an affiliate will get
|
71 |
+
* paid for all customers' lifetime payments. If greater than `0`, an affiliate will get paid for all
|
72 |
+
* customer payments for `future_payments_days` days after the initial payment.
|
73 |
+
*/
|
74 |
+
public $future_payments_days;
|
75 |
+
/**
|
76 |
+
* @var bool If `true`, allow referrals from social sites.
|
77 |
+
*/
|
78 |
+
public $is_social_allowed;
|
79 |
+
/**
|
80 |
+
* @var bool If `true`, allow conversions without HTTP referrer header at all.
|
81 |
+
*/
|
82 |
+
public $is_app_allowed;
|
83 |
+
/**
|
84 |
+
* @var bool If `true`, allow referrals from any site.
|
85 |
+
*/
|
86 |
+
public $is_any_site_allowed;
|
87 |
+
|
88 |
+
#endregion Properties
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @author Leo Fajardo (@leorw)
|
92 |
+
*
|
93 |
+
* @return string
|
94 |
+
*/
|
95 |
+
function get_formatted_commission()
|
96 |
+
{
|
97 |
+
return ( 'dollar' === $this->commission_type ) ?
|
98 |
+
( '$' . $this->commission ) :
|
99 |
+
( $this->commission . '%' );
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* @author Leo Fajardo (@leorw)
|
104 |
+
*
|
105 |
+
* @return bool
|
106 |
+
*/
|
107 |
+
function has_lifetime_commission() {
|
108 |
+
return ( 0 !== $this->future_payments_days );
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @author Leo Fajardo (@leorw)
|
113 |
+
*
|
114 |
+
* @return bool
|
115 |
+
*/
|
116 |
+
function is_session_cookie() {
|
117 |
+
return ( 0 == $this->cookie_days );
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @author Leo Fajardo (@leorw)
|
122 |
+
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
function has_renewals_commission() {
|
126 |
+
return ( is_null( $this->commission_renewals_days ) || $this->commission_renewals_days > 0 );
|
127 |
+
}
|
128 |
+
}
|
freemius/includes/entities/class-fs-affiliate.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.2.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
class FS_Affiliate extends FS_Scope_Entity {
|
14 |
+
|
15 |
+
#region Properties
|
16 |
+
|
17 |
+
/**
|
18 |
+
* @var string
|
19 |
+
*/
|
20 |
+
public $paypal_email;
|
21 |
+
/**
|
22 |
+
* @var number
|
23 |
+
*/
|
24 |
+
public $custom_affiliate_terms_id;
|
25 |
+
/**
|
26 |
+
* @var boolean
|
27 |
+
*/
|
28 |
+
public $is_using_custom_terms;
|
29 |
+
/**
|
30 |
+
* @var string status Enum: `pending`, `rejected`, `suspended`, or `active`. Defaults to `pending`.
|
31 |
+
*/
|
32 |
+
public $status;
|
33 |
+
/**
|
34 |
+
* @var string
|
35 |
+
*/
|
36 |
+
public $domain;
|
37 |
+
|
38 |
+
#endregion Properties
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @author Leo Fajardo
|
42 |
+
*
|
43 |
+
* @return bool
|
44 |
+
*/
|
45 |
+
function is_active() {
|
46 |
+
return ( 'active' === $this->status );
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* @author Leo Fajardo
|
51 |
+
*
|
52 |
+
* @return bool
|
53 |
+
*/
|
54 |
+
function is_pending() {
|
55 |
+
return ( 'pending' === $this->status );
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @author Leo Fajardo
|
60 |
+
*
|
61 |
+
* @return bool
|
62 |
+
*/
|
63 |
+
function is_suspended() {
|
64 |
+
return ( 'suspended' === $this->status );
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @author Leo Fajardo
|
69 |
+
*
|
70 |
+
* @return bool
|
71 |
+
*/
|
72 |
+
function is_rejected() {
|
73 |
+
return ( 'rejected' === $this->status );
|
74 |
+
}
|
75 |
+
|
76 |
+
/**
|
77 |
+
* @author Leo Fajardo
|
78 |
+
*
|
79 |
+
* @return bool
|
80 |
+
*/
|
81 |
+
function is_blocked() {
|
82 |
+
return ( 'blocked' === $this->status );
|
83 |
+
}
|
84 |
+
}
|
freemius/includes/entities/class-fs-billing.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius for EDD Add-On
|
4 |
* @copyright Copyright (c) 2016, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius for EDD Add-On
|
4 |
* @copyright Copyright (c) 2016, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-entity.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
@@ -42,9 +42,9 @@
|
|
42 |
* @param bool|object $entity
|
43 |
*/
|
44 |
function __construct( $entity = false ) {
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
|
49 |
$props = fs_get_object_public_vars( $this );
|
50 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
42 |
* @param bool|object $entity
|
43 |
*/
|
44 |
function __construct( $entity = false ) {
|
45 |
+
if ( ! ( $entity instanceof stdClass ) && ! ( $entity instanceof FS_Entity ) ) {
|
46 |
+
return;
|
47 |
+
}
|
48 |
|
49 |
$props = fs_get_object_public_vars( $this );
|
50 |
|
freemius/includes/entities/class-fs-payment.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2016, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2016, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-plugin-info.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-plugin-license.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.5
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.5
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-plugin-plan.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.5
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.5
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-plugin-tag.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-plugin.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
@@ -25,6 +25,8 @@
|
|
25 |
*/
|
26 |
public $slug;
|
27 |
/**
|
|
|
|
|
28 |
* @var string 'plugin' or 'theme'
|
29 |
*/
|
30 |
public $type;
|
@@ -59,6 +61,17 @@
|
|
59 |
* @var bool
|
60 |
*/
|
61 |
public $is_live;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
#endregion Install Specific Properties
|
64 |
|
@@ -88,6 +101,16 @@
|
|
88 |
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
|
89 |
}
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
static function get_type() {
|
92 |
return 'plugin';
|
93 |
}
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
25 |
*/
|
26 |
public $slug;
|
27 |
/**
|
28 |
+
* @since 1.2.2
|
29 |
+
*
|
30 |
* @var string 'plugin' or 'theme'
|
31 |
*/
|
32 |
public $type;
|
61 |
* @var bool
|
62 |
*/
|
63 |
public $is_live;
|
64 |
+
/**
|
65 |
+
* @author Leo Fajardo (@leorw)
|
66 |
+
*
|
67 |
+
* @since 1.2.3
|
68 |
+
*
|
69 |
+
* @var string|false false if the module doesn't have an affiliate program or one of the following:
|
70 |
+
* 'selected', 'customers', or 'all'.
|
71 |
+
*/
|
72 |
+
public $affiliate_moderation;
|
73 |
+
|
74 |
+
const AFFILIATE_MODERATION_CUSTOMERS = 'customers';
|
75 |
|
76 |
#endregion Install Specific Properties
|
77 |
|
101 |
return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
|
102 |
}
|
103 |
|
104 |
+
/**
|
105 |
+
* @author Leo Fajardo (@leorw)
|
106 |
+
* @since 1.2.3
|
107 |
+
*
|
108 |
+
* @return bool
|
109 |
+
*/
|
110 |
+
function has_affiliate_program() {
|
111 |
+
return ( ! empty( $this->affiliate_moderation ) );
|
112 |
+
}
|
113 |
+
|
114 |
static function get_type() {
|
115 |
return 'plugin';
|
116 |
}
|
freemius/includes/entities/class-fs-pricing.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius for EDD Add-On
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius for EDD Add-On
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.0
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-scope-entity.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.4
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-site.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-subscription.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.9
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.9
|
7 |
*/
|
8 |
|
freemius/includes/entities/class-fs-user.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
-
* @license
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
2 |
/**
|
3 |
* @package Freemius
|
4 |
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
* @since 1.0.3
|
7 |
*/
|
8 |
|
freemius/includes/fs-core-functions.php
CHANGED
@@ -1,629 +1,1118 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
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 |
-
// If both have priority return the winner.
|
507 |
-
return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
|
508 |
-
}
|
509 |
-
|
510 |
-
#--------------------------------------------------------------------------------
|
511 |
-
#region Localization
|
512 |
-
#--------------------------------------------------------------------------------
|
513 |
-
|
514 |
-
if ( ! function_exists( 'fs_text' ) ) {
|
515 |
-
/**
|
516 |
-
* Retrieve a translated text by key.
|
517 |
-
*
|
518 |
-
* @author Vova Feldman (@svovaf)
|
519 |
-
* @since 1.2.1.7
|
520 |
-
*
|
521 |
-
* @param string $key
|
522 |
-
* @param string $slug
|
523 |
-
*
|
524 |
-
* @return string
|
525 |
-
*
|
526 |
-
* @global $fs_text, $fs_text_overrides
|
527 |
-
*/
|
528 |
-
function fs_text( $key, $slug = 'freemius' ) {
|
529 |
-
return __fs( $key, $slug );
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* Output a translated text by key.
|
534 |
-
*
|
535 |
-
* @author Vova Feldman (@svovaf)
|
536 |
-
* @since 1.2.1.7
|
537 |
-
*
|
538 |
-
* @param string $key
|
539 |
-
* @param string $slug
|
540 |
-
*/
|
541 |
-
function fs_echo( $key, $slug = 'freemius' ) {
|
542 |
-
echo fs_text( $key, $slug );
|
543 |
-
}
|
544 |
-
}
|
545 |
-
|
546 |
-
/**
|
547 |
-
* @author Vova Feldman
|
548 |
-
* @since 1.2.1.6
|
549 |
-
*
|
550 |
-
* @param string $key
|
551 |
-
* @param string $slug
|
552 |
-
*
|
553 |
-
* @return string
|
554 |
-
*/
|
555 |
-
function fs_esc_attr( $key, $slug ) {
|
556 |
-
return esc_attr( fs_text( $key, $slug ) );
|
557 |
-
}
|
558 |
-
|
559 |
-
/**
|
560 |
-
* @author Vova Feldman
|
561 |
-
* @since 1.2.1.6
|
562 |
-
*
|
563 |
-
* @param string $key
|
564 |
-
* @param string $slug
|
565 |
-
*/
|
566 |
-
function fs_esc_attr_echo( $key, $slug ) {
|
567 |
-
echo esc_attr( fs_text( $key, $slug ) );
|
568 |
-
}
|
569 |
-
|
570 |
-
/**
|
571 |
-
* @author Vova Feldman
|
572 |
-
* @since 1.2.1.6
|
573 |
-
*
|
574 |
-
* @param string $key
|
575 |
-
* @param string $slug
|
576 |
-
*
|
577 |
-
* @return string
|
578 |
-
*/
|
579 |
-
function fs_esc_js( $key, $slug ) {
|
580 |
-
return esc_js( fs_text( $key, $slug ) );
|
581 |
-
}
|
582 |
-
|
583 |
-
/**
|
584 |
-
* @author Vova Feldman
|
585 |
-
* @since 1.2.1.6
|
586 |
-
*
|
587 |
-
* @param string $key
|
588 |
-
* @param string $slug
|
589 |
-
*/
|
590 |
-
function fs_esc_js_echo( $key, $slug ) {
|
591 |
-
echo esc_js( fs_text( $key, $slug ) );
|
592 |
-
}
|
593 |
-
|
594 |
-
/**
|
595 |
-
* @author Vova Feldman
|
596 |
-
* @since 1.2.1.6
|
597 |
-
*
|
598 |
-
* @param string $key
|
599 |
-
* @param string $slug
|
600 |
-
*/
|
601 |
-
function fs_json_encode_echo( $key, $slug ) {
|
602 |
-
echo json_encode( fs_text( $key, $slug ) );
|
603 |
-
}
|
604 |
-
|
605 |
-
/**
|
606 |
-
* @author Vova Feldman
|
607 |
-
* @since 1.2.1.6
|
608 |
-
*
|
609 |
-
* @param string $key
|
610 |
-
* @param string $slug
|
611 |
-
*
|
612 |
-
* @return string
|
613 |
-
*/
|
614 |
-
function fs_esc_html( $key, $slug ) {
|
615 |
-
return esc_html( fs_text( $key, $slug ) );
|
616 |
-
}
|
617 |
-
|
618 |
-
/**
|
619 |
-
* @author Vova Feldman
|
620 |
-
* @since 1.2.1.6
|
621 |
-
*
|
622 |
-
* @param string $key
|
623 |
-
* @param string $slug
|
624 |
-
*/
|
625 |
-
function fs_esc_html_echo( $key, $slug ) {
|
626 |
-
echo esc_html( fs_text( $key, $slug ) );
|
627 |
-
}
|
628 |
-
|
629 |
-
#endregion
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Freemius
|
4 |
+
* @copyright Copyright (c) 2015, Freemius, Inc.
|
5 |
+
* @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
|
6 |
+
* @since 1.0.3
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit;
|
11 |
+
}
|
12 |
+
|
13 |
+
if ( ! function_exists( 'fs_dummy' ) ) {
|
14 |
+
function fs_dummy() {
|
15 |
+
}
|
16 |
+
}
|
17 |
+
|
18 |
+
/* Url.
|
19 |
+
--------------------------------------------------------------------------------------------*/
|
20 |
+
if ( ! function_exists( 'fs_get_url_daily_cache_killer' ) ) {
|
21 |
+
function fs_get_url_daily_cache_killer() {
|
22 |
+
return date( '\YY\Mm\Dd' );
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
/* Templates / Views.
|
27 |
+
--------------------------------------------------------------------------------------------*/
|
28 |
+
if ( ! function_exists( 'fs_get_template_path' ) ) {
|
29 |
+
function fs_get_template_path( $path ) {
|
30 |
+
return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
|
31 |
+
}
|
32 |
+
|
33 |
+
function fs_include_template( $path, &$params = null ) {
|
34 |
+
$VARS = &$params;
|
35 |
+
include fs_get_template_path( $path );
|
36 |
+
}
|
37 |
+
|
38 |
+
function fs_include_once_template( $path, &$params = null ) {
|
39 |
+
$VARS = &$params;
|
40 |
+
include_once fs_get_template_path( $path );
|
41 |
+
}
|
42 |
+
|
43 |
+
function fs_require_template( $path, &$params = null ) {
|
44 |
+
$VARS = &$params;
|
45 |
+
require fs_get_template_path( $path );
|
46 |
+
}
|
47 |
+
|
48 |
+
function fs_require_once_template( $path, &$params = null ) {
|
49 |
+
$VARS = &$params;
|
50 |
+
require_once fs_get_template_path( $path );
|
51 |
+
}
|
52 |
+
|
53 |
+
function fs_get_template( $path, &$params = null ) {
|
54 |
+
ob_start();
|
55 |
+
|
56 |
+
$VARS = &$params;
|
57 |
+
require fs_get_template_path( $path );
|
58 |
+
|
59 |
+
return ob_get_clean();
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
/* Scripts and styles including.
|
64 |
+
--------------------------------------------------------------------------------------------*/
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Generates an absolute URL to the given path. This function ensures that the URL will be correct whether the asset
|
68 |
+
* is inside a plugin's folder or a theme's folder.
|
69 |
+
*
|
70 |
+
* Examples:
|
71 |
+
* 1. "themes" folder
|
72 |
+
* Path: C:/xampp/htdocs/fswp/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
|
73 |
+
* URL: http://fswp:8080/wp-content/themes/twentytwelve/freemius/assets/css/admin/common.css
|
74 |
+
*
|
75 |
+
* 2. "plugins" folder
|
76 |
+
* Path: C:/xampp/htdocs/fswp/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
|
77 |
+
* URL: http://fswp:8080/wp-content/plugins/rating-widget-premium/freemius/assets/css/admin/common.css
|
78 |
+
*
|
79 |
+
* @author Leo Fajardo (@leorw)
|
80 |
+
* @since 1.2.2
|
81 |
+
*
|
82 |
+
* @param string $asset_abs_path Asset's absolute path.
|
83 |
+
*
|
84 |
+
* @return string Asset's URL.
|
85 |
+
*/
|
86 |
+
function fs_asset_url( $asset_abs_path ) {
|
87 |
+
$wp_content_dir = fs_normalize_path( WP_CONTENT_DIR );
|
88 |
+
$asset_abs_path = fs_normalize_path( $asset_abs_path );
|
89 |
+
$asset_rel_path = str_replace( $wp_content_dir, '', $asset_abs_path );
|
90 |
+
|
91 |
+
$asset_url = content_url( fs_normalize_path( $asset_rel_path ) );
|
92 |
+
|
93 |
+
return $asset_url;
|
94 |
+
}
|
95 |
+
|
96 |
+
function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
|
97 |
+
wp_enqueue_style( $handle, fs_asset_url( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ), $deps, $ver, $media );
|
98 |
+
}
|
99 |
+
|
100 |
+
function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
|
101 |
+
wp_enqueue_script( $handle, fs_asset_url( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ), $deps, $ver, $in_footer );
|
102 |
+
}
|
103 |
+
|
104 |
+
function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) {
|
105 |
+
return ( fs_asset_url( $img_dir . '/' . trim( $path, '/' ) ) );
|
106 |
+
}
|
107 |
+
|
108 |
+
#--------------------------------------------------------------------------------
|
109 |
+
#region Request handlers.
|
110 |
+
#--------------------------------------------------------------------------------
|
111 |
+
|
112 |
+
if ( ! function_exists( 'fs_request_get' ) ) {
|
113 |
+
/**
|
114 |
+
* @param string $key
|
115 |
+
* @param mixed $def
|
116 |
+
* @param string|bool $type Since 1.2.1.7 - when set to 'get' will look for the value passed via querystring, when
|
117 |
+
* set to 'post' will look for the value passed via the POST request's body, otherwise,
|
118 |
+
* will check if the parameter was passed in any of the two.
|
119 |
+
*
|
120 |
+
* @return mixed
|
121 |
+
*/
|
122 |
+
function fs_request_get( $key, $def = false, $type = false ) {
|
123 |
+
if ( is_string( $type ) ) {
|
124 |
+
$type = strtolower( $type );
|
125 |
+
}
|
126 |
+
|
127 |
+
switch ( $type ) {
|
128 |
+
case 'post':
|
129 |
+
$value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def;
|
130 |
+
break;
|
131 |
+
case 'get':
|
132 |
+
$value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def;
|
133 |
+
break;
|
134 |
+
default:
|
135 |
+
$value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
|
136 |
+
break;
|
137 |
+
}
|
138 |
+
|
139 |
+
return $value;
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
if ( ! function_exists( 'fs_request_has' ) ) {
|
144 |
+
function fs_request_has( $key ) {
|
145 |
+
return isset( $_REQUEST[ $key ] );
|
146 |
+
}
|
147 |
+
}
|
148 |
+
|
149 |
+
if ( ! function_exists( 'fs_request_get_bool' ) ) {
|
150 |
+
function fs_request_get_bool( $key, $def = false ) {
|
151 |
+
if ( ! isset( $_REQUEST[ $key ] ) ) {
|
152 |
+
return $def;
|
153 |
+
}
|
154 |
+
|
155 |
+
if ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) {
|
156 |
+
return true;
|
157 |
+
}
|
158 |
+
|
159 |
+
if ( 0 == $_REQUEST[ $key ] || 'false' === strtolower( $_REQUEST[ $key ] ) ) {
|
160 |
+
return false;
|
161 |
+
}
|
162 |
+
|
163 |
+
return $def;
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
if ( ! function_exists( 'fs_request_is_post' ) ) {
|
168 |
+
function fs_request_is_post() {
|
169 |
+
return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
|
170 |
+
}
|
171 |
+
}
|
172 |
+
|
173 |
+
if ( ! function_exists( 'fs_request_is_get' ) ) {
|
174 |
+
function fs_request_is_get() {
|
175 |
+
return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
|
176 |
+
}
|
177 |
+
}
|
178 |
+
|
179 |
+
if ( ! function_exists( 'fs_get_action' ) ) {
|
180 |
+
function fs_get_action( $action_key = 'action' ) {
|
181 |
+
if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
|
182 |
+
return strtolower( $_REQUEST[ $action_key ] );
|
183 |
+
}
|
184 |
+
|
185 |
+
if ( 'action' == $action_key ) {
|
186 |
+
$action_key = 'fs_action';
|
187 |
+
|
188 |
+
if ( ! empty( $_REQUEST[ $action_key ] ) && is_string( $_REQUEST[ $action_key ] ) ) {
|
189 |
+
return strtolower( $_REQUEST[ $action_key ] );
|
190 |
+
}
|
191 |
+
}
|
192 |
+
|
193 |
+
return false;
|
194 |
+
}
|
195 |
+
}
|
196 |
+
|
197 |
+
if ( ! function_exists( 'fs_request_is_action' ) ) {
|
198 |
+
function fs_request_is_action( $action, $action_key = 'action' ) {
|
199 |
+
return ( strtolower( $action ) === fs_get_action( $action_key ) );
|
200 |
+
}
|
201 |
+
}
|
202 |
+
|
203 |
+
if ( ! function_exists( 'fs_request_is_action_secure' ) ) {
|
204 |
+
/**
|
205 |
+
* @author Vova Feldman (@svovaf)
|
206 |
+
* @since 1.0.0
|
207 |
+
*
|
208 |
+
* @since 1.2.1.5 Allow nonce verification.
|
209 |
+
*
|
210 |
+
* @param string $action
|
211 |
+
* @param string $action_key
|
212 |
+
* @param string $nonce_key
|
213 |
+
*
|
214 |
+
* @return bool
|
215 |
+
*/
|
216 |
+
function fs_request_is_action_secure(
|
217 |
+
$action,
|
218 |
+
$action_key = 'action',
|
219 |
+
$nonce_key = 'nonce'
|
220 |
+
) {
|
221 |
+
if ( strtolower( $action ) !== fs_get_action( $action_key ) ) {
|
222 |
+
return false;
|
223 |
+
}
|
224 |
+
|
225 |
+
$nonce = ! empty( $_REQUEST[ $nonce_key ] ) ?
|
226 |
+
$_REQUEST[ $nonce_key ] :
|
227 |
+
'';
|
228 |
+
|
229 |
+
if ( empty( $nonce ) ||
|
230 |
+
( false === wp_verify_nonce( $nonce, $action ) )
|
231 |
+
) {
|
232 |
+
return false;
|
233 |
+
}
|
234 |
+
|
235 |
+
return true;
|
236 |
+
}
|
237 |
+
}
|
238 |
+
|
239 |
+
#endregion
|
240 |
+
|
241 |
+
if ( ! function_exists( 'fs_is_plugin_page' ) ) {
|
242 |
+
function fs_is_plugin_page( $page_slug ) {
|
243 |
+
return ( is_admin() && $page_slug === fs_request_get( 'page' ) );
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
if ( ! function_exists( 'fs_get_raw_referer' ) ) {
|
248 |
+
/**
|
249 |
+
* Retrieves unvalidated referer from '_wp_http_referer' or HTTP referer.
|
250 |
+
*
|
251 |
+
* Do not use for redirects, use {@see wp_get_referer()} instead.
|
252 |
+
*
|
253 |
+
* @since 1.2.3
|
254 |
+
*
|
255 |
+
* @return string|false Referer URL on success, false on failure.
|
256 |
+
*/
|
257 |
+
function fs_get_raw_referer() {
|
258 |
+
if ( function_exists( 'wp_get_raw_referer' ) ) {
|
259 |
+
return wp_get_raw_referer();
|
260 |
+
}
|
261 |
+
if ( ! empty( $_REQUEST['_wp_http_referer'] ) ) {
|
262 |
+
return wp_unslash( $_REQUEST['_wp_http_referer'] );
|
263 |
+
} else if ( ! empty( $_SERVER['HTTP_REFERER'] ) ) {
|
264 |
+
return wp_unslash( $_SERVER['HTTP_REFERER'] );
|
265 |
+
}
|
266 |
+
|
267 |
+
return false;
|
268 |
+
}
|
269 |
+
}
|
270 |
+
|
271 |
+
/* Core UI.
|
272 |
+
--------------------------------------------------------------------------------------------*/
|
273 |
+
/**
|
274 |
+
* @param number $module_id
|
275 |
+
* @param string $page
|
276 |
+
* @param string $action
|
277 |
+
* @param string $title
|
278 |
+
* @param array $params
|
279 |
+
* @param bool $is_primary
|
280 |
+
* @param string|bool $icon_class Optional class for an icon (since 1.1.7).
|
281 |
+
* @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7).
|
282 |
+
* @param string $method Since 1.1.7
|
283 |
+
*
|
284 |
+
* @uses fs_ui_get_action_button()
|
285 |
+
*/
|
286 |
+
function fs_ui_action_button(
|
287 |
+
$module_id,
|
288 |
+
$page,
|
289 |
+
$action,
|
290 |
+
$title,
|
291 |
+
$params = array(),
|
292 |
+
$is_primary = true,
|
293 |
+
$icon_class = false,
|
294 |
+
$confirmation = false,
|
295 |
+
$method = 'GET'
|
296 |
+
) {
|
297 |
+
echo fs_ui_get_action_button(
|
298 |
+
$module_id,
|
299 |
+
$page,
|
300 |
+
$action,
|
301 |
+
$title,
|
302 |
+
$params,
|
303 |
+
$is_primary,
|
304 |
+
$icon_class,
|
305 |
+
$confirmation,
|
306 |
+
$method
|
307 |
+
);
|
308 |
+
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* @author Vova Feldman (@svovaf)
|
312 |
+
* @since 1.1.7
|
313 |
+
*
|
314 |
+
* @param number $module_id
|
315 |
+
* @param string $page
|
316 |
+
* @param string $action
|
317 |
+
* @param string $title
|
318 |
+
* @param array $params
|
319 |
+
* @param bool $is_primary
|
320 |
+
* @param string|bool $icon_class Optional class for an icon.
|
321 |
+
* @param string|bool $confirmation Optional confirmation message before submit.
|
322 |
+
* @param string $method
|
323 |
+
*
|
324 |
+
* @return string
|
325 |
+
*/
|
326 |
+
function fs_ui_get_action_button(
|
327 |
+
$module_id,
|
328 |
+
$page,
|
329 |
+
$action,
|
330 |
+
$title,
|
331 |
+
$params = array(),
|
332 |
+
$is_primary = true,
|
333 |
+
$icon_class = false,
|
334 |
+
$confirmation = false,
|
335 |
+
$method = 'GET'
|
336 |
+
) {
|
337 |
+
// Prepend icon (if set).
|
338 |
+
$title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title;
|
339 |
+
|
340 |
+
if ( is_string( $confirmation ) ) {
|
341 |
+
return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="if (confirm(\'%s\')) this.parentNode.submit(); return false;">%s</a></form>',
|
342 |
+
freemius( $module_id )->_get_admin_page_url( $page, $params ),
|
343 |
+
$method,
|
344 |
+
$action,
|
345 |
+
wp_nonce_field( $action, '_wpnonce', true, false ),
|
346 |
+
'button' . ( $is_primary ? ' button-primary' : '' ),
|
347 |
+
$confirmation,
|
348 |
+
$title
|
349 |
+
);
|
350 |
+
} else if ( 'GET' !== strtoupper( $method ) ) {
|
351 |
+
return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="this.parentNode.submit(); return false;">%s</a></form>',
|
352 |
+
freemius( $module_id )->_get_admin_page_url( $page, $params ),
|
353 |
+
$method,
|
354 |
+
$action,
|
355 |
+
wp_nonce_field( $action, '_wpnonce', true, false ),
|
356 |
+
'button' . ( $is_primary ? ' button-primary' : '' ),
|
357 |
+
$title
|
358 |
+
);
|
359 |
+
} else {
|
360 |
+
return sprintf( '<a href="%s" class="%s">%s</a></form>',
|
361 |
+
wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),
|
362 |
+
'button' . ( $is_primary ? ' button-primary' : '' ),
|
363 |
+
$title
|
364 |
+
);
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
function fs_ui_action_link( $module_id, $page, $action, $title, $params = array() ) {
|
369 |
+
?><a class=""
|
370 |
+
href="<?php echo wp_nonce_url( freemius( $module_id )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
|
371 |
+
}
|
372 |
+
|
373 |
+
/*function fs_error_handler($errno, $errstr, $errfile, $errline)
|
374 |
+
{
|
375 |
+
if (false === strpos($errfile, 'freemius/'))
|
376 |
+
{
|
377 |
+
// @todo Dump Freemius errors to local log.
|
378 |
+
}
|
379 |
+
|
380 |
+
// switch ($errno) {
|
381 |
+
// case E_USER_ERROR:
|
382 |
+
// break;
|
383 |
+
// case E_WARNING:
|
384 |
+
// case E_USER_WARNING:
|
385 |
+
// break;
|
386 |
+
// case E_NOTICE:
|
387 |
+
// case E_USER_NOTICE:
|
388 |
+
// break;
|
389 |
+
// default:
|
390 |
+
// break;
|
391 |
+
// }
|
392 |
+
}
|
393 |
+
|
394 |
+
set_error_handler('fs_error_handler');*/
|
395 |
+
|
396 |
+
if ( ! function_exists( 'fs_nonce_url' ) ) {
|
397 |
+
/**
|
398 |
+
* Retrieve URL with nonce added to URL query.
|
399 |
+
*
|
400 |
+
* Originally was using `wp_nonce_url()` but the new version
|
401 |
+
* changed the return value to escaped URL, that's not the expected
|
402 |
+
* behaviour.
|
403 |
+
*
|
404 |
+
* @author Vova Feldman (@svovaf)
|
405 |
+
* @since ~1.1.3
|
406 |
+
*
|
407 |
+
* @param string $actionurl URL to add nonce action.
|
408 |
+
* @param int|string $action Optional. Nonce action name. Default -1.
|
409 |
+
* @param string $name Optional. Nonce name. Default '_wpnonce'.
|
410 |
+
*
|
411 |
+
* @return string Escaped URL with nonce action added.
|
412 |
+
*/
|
413 |
+
function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
|
414 |
+
return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
if ( ! function_exists( 'fs_starts_with' ) ) {
|
419 |
+
/**
|
420 |
+
* Check if string starts with.
|
421 |
+
*
|
422 |
+
* @author Vova Feldman (@svovaf)
|
423 |
+
* @since 1.1.3
|
424 |
+
*
|
425 |
+
* @param string $haystack
|
426 |
+
* @param string $needle
|
427 |
+
*
|
428 |
+
* @return bool
|
429 |
+
*/
|
430 |
+
function fs_starts_with( $haystack, $needle ) {
|
431 |
+
$length = strlen( $needle );
|
432 |
+
|
433 |
+
return ( substr( $haystack, 0, $length ) === $needle );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
#region Url Canonization ------------------------------------------------------------------
|
438 |
+
|
439 |
+
if ( ! function_exists( 'fs_canonize_url' ) ) {
|
440 |
+
/**
|
441 |
+
* @author Vova Feldman (@svovaf)
|
442 |
+
* @since 1.1.3
|
443 |
+
*
|
444 |
+
* @param string $url
|
445 |
+
* @param bool $omit_host
|
446 |
+
* @param array $ignore_params
|
447 |
+
*
|
448 |
+
* @return string
|
449 |
+
*/
|
450 |
+
function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
|
451 |
+
$parsed_url = parse_url( strtolower( $url ) );
|
452 |
+
|
453 |
+
// if ( ! isset( $parsed_url['host'] ) ) {
|
454 |
+
// return $url;
|
455 |
+
// }
|
456 |
+
|
457 |
+
$canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
|
458 |
+
|
459 |
+
if ( isset( $parsed_url['query'] ) ) {
|
460 |
+
parse_str( $parsed_url['query'], $queryString );
|
461 |
+
$canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
|
462 |
+
}
|
463 |
+
|
464 |
+
return $canonical;
|
465 |
+
}
|
466 |
+
}
|
467 |
+
|
468 |
+
if ( ! function_exists( 'fs_canonize_query_string' ) ) {
|
469 |
+
/**
|
470 |
+
* @author Vova Feldman (@svovaf)
|
471 |
+
* @since 1.1.3
|
472 |
+
*
|
473 |
+
* @param array $params
|
474 |
+
* @param array $ignore_params
|
475 |
+
* @param bool $params_prefix
|
476 |
+
*
|
477 |
+
* @return string
|
478 |
+
*/
|
479 |
+
function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
|
480 |
+
if ( ! is_array( $params ) || 0 === count( $params ) ) {
|
481 |
+
return '';
|
482 |
+
}
|
483 |
+
|
484 |
+
// Url encode both keys and values
|
485 |
+
$keys = fs_urlencode_rfc3986( array_keys( $params ) );
|
486 |
+
$values = fs_urlencode_rfc3986( array_values( $params ) );
|
487 |
+
$params = array_combine( $keys, $values );
|
488 |
+
|
489 |
+
// Parameters are sorted by name, using lexicographical byte value ordering.
|
490 |
+
// Ref: Spec: 9.1.1 (1)
|
491 |
+
uksort( $params, 'strcmp' );
|
492 |
+
|
493 |
+
$pairs = array();
|
494 |
+
foreach ( $params as $parameter => $value ) {
|
495 |
+
$lower_param = strtolower( $parameter );
|
496 |
+
|
497 |
+
// Skip ignore params.
|
498 |
+
if ( in_array( $lower_param, $ignore_params ) ||
|
499 |
+
( false !== $params_prefix && fs_starts_with( $lower_param, $params_prefix ) )
|
500 |
+
) {
|
501 |
+
continue;
|
502 |
+
}
|
503 |
+
|
504 |
+
if ( is_array( $value ) ) {
|
505 |
+
// If two or more parameters share t
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|