Blocksy Companion - Version 1.8.47

Version Description

Download this release

Release Info

Developer creativethemeshq
Plugin Icon wp plugin Blocksy Companion
Version 1.8.47
Comparing to
See all releases

Code changes from version 1.8.46 to 1.8.47

Files changed (45) hide show
  1. blocksy-companion.php +20 -4
  2. framework/dashboard.php +114 -79
  3. framework/extensions-manager.php +1 -1
  4. framework/extensions/cookies-consent/static/bundle/main.min.css +1 -1
  5. framework/extensions/newsletter-subscribe/static/bundle/main.min.css +1 -1
  6. framework/extensions/product-reviews/static/bundle/main-admin.min.css +1 -1
  7. framework/extensions/product-reviews/static/bundle/main.min.css +1 -1
  8. framework/extensions/trending/customizer.php +1 -1
  9. framework/extensions/trending/extension.php +2 -2
  10. framework/extensions/trending/static/bundle/main.min.css +1 -1
  11. framework/extensions/widgets/static/bundle/main.min.css +1 -1
  12. framework/extensions/widgets/widgets/ct-contact-info/options.php +24 -24
  13. framework/features/header.php +6 -2
  14. framework/features/header/items/account/options.php +1 -1
  15. framework/features/header/modal/login.php +1 -1
  16. framework/features/header/modal/register.php +3 -2
  17. framework/features/opengraph-meta-data.php +2 -0
  18. framework/theme-integration.php +2 -0
  19. freemius/LICENSE.txt +0 -674
  20. freemius/assets/css/admin/account.css +0 -1
  21. freemius/assets/css/admin/add-ons.css +0 -1
  22. freemius/assets/css/admin/affiliation.css +0 -1
  23. freemius/assets/css/admin/checkout.css +0 -1
  24. freemius/assets/css/admin/clone-resolution.css +0 -1
  25. freemius/assets/css/admin/common.css +0 -1
  26. freemius/assets/css/admin/connect.css +0 -1
  27. freemius/assets/css/admin/debug.css +0 -1
  28. freemius/assets/css/admin/dialog-boxes.css +0 -1
  29. freemius/assets/css/admin/gdpr-optin-notice.css +0 -1
  30. freemius/assets/css/admin/index.php +0 -3
  31. freemius/assets/css/admin/plugins.css +0 -1
  32. freemius/assets/css/customizer.css +0 -1
  33. freemius/assets/css/index.php +0 -3
  34. freemius/assets/img/blocksy-companion.jpg +0 -0
  35. freemius/assets/img/index.php +0 -3
  36. freemius/assets/img/plugin-icon.png +0 -0
  37. freemius/assets/img/theme-icon.png +0 -0
  38. freemius/assets/index.php +0 -3
  39. freemius/assets/js/index.php +0 -3
  40. freemius/assets/js/nojquery.ba-postmessage.js +0 -140
  41. freemius/assets/js/nojquery.ba-postmessage.min.js +0 -12
  42. freemius/assets/js/postmessage.js +0 -135
  43. freemius/config.php +0 -391
  44. freemius/includes/class-freemius-abstract.php +0 -597
  45. freemius/includes/class-freemius.php +0 -23164
blocksy-companion.php CHANGED
@@ -3,7 +3,7 @@
3
  /*
4
  Plugin Name: Blocksy Companion
5
  Description: This plugin is the companion for the Blocksy theme, it runs and adds its enhacements only if the Blocksy theme is installed and active.
6
- Version: 1.8.46
7
  Author: CreativeThemes
8
  Author URI: https://creativethemes.com
9
  Text Domain: blocksy-companion
@@ -17,12 +17,28 @@ if ( !defined( 'ABSPATH' ) ) {
17
  // Exit if accessed directly.
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- if ( function_exists( 'blc_fs' ) ) {
22
- blc_fs()->set_basename( false, __FILE__ );
 
 
23
  } else {
24
 
25
- if ( !function_exists( 'blc_fs' ) ) {
26
  global $blc_fs ;
27
 
28
  if ( !isset( $blc_fs ) ) {
3
  /*
4
  Plugin Name: Blocksy Companion
5
  Description: This plugin is the companion for the Blocksy theme, it runs and adds its enhacements only if the Blocksy theme is installed and active.
6
+ Version: 1.8.47
7
  Author: CreativeThemes
8
  Author URI: https://creativethemes.com
9
  Text Domain: blocksy-companion
17
  // Exit if accessed directly.
18
  }
19
 
20
+ register_activation_hook( __FILE__, function () {
21
+
22
+ if ( class_exists( '\\Blocksy\\Plugin' ) && !function_exists( 'blc_fs' ) ) {
23
+ $to_deactivate = plugin_basename( str_replace( '-pro/', '/', __FILE__ ) );
24
+ if ( is_plugin_active( $to_deactivate ) ) {
25
+ deactivate_plugins( $to_deactivate );
26
+ }
27
+ }
28
+
29
+ if ( isset( $_REQUEST['action'] ) && 'activate-selected' === $_REQUEST['action'] && isset( $_POST['checked'] ) && count( $_POST['checked'] ) > 1 ) {
30
+ return;
31
+ }
32
+ add_option( 'blc_activation_redirect', wp_get_current_user()->ID );
33
+ } );
34
 
35
+ if ( function_exists( 'blc_fs' ) || class_exists( '\\Blocksy\\Plugin' ) ) {
36
+ if ( function_exists( 'blc_fs' ) ) {
37
+ blc_fs()->set_basename( false, __FILE__ );
38
+ }
39
  } else {
40
 
41
+ if ( !function_exists( 'blc_fs' ) && file_exists( dirname( __FILE__ ) . '/freemius/start.php' ) ) {
42
  global $blc_fs ;
43
 
44
  if ( !isset( $blc_fs ) ) {
framework/dashboard.php CHANGED
@@ -11,107 +11,131 @@ class Dashboard {
11
  );
12
 
13
  add_action('admin_body_class', function ($class) {
14
- if (blc_fs()->is_activation_mode()) {
15
  $class .= ' blocksy-fs-optin-dashboard';
16
  }
17
 
18
  return $class;
19
  });
20
 
21
- blc_fs()->add_filter(
22
- 'connect-message_on-premium',
23
- function ($text) {
24
- if (strpos($text, '<br>') !== false) {
25
- $exploded_message = explode('<br>', $text);
26
-
27
- $text = '<span>' . $exploded_message[0] . '</span>' . $exploded_message[1];
28
  }
 
29
 
30
- return $text;
31
- }
32
- );
33
-
34
- blc_fs()->add_filter(
35
- 'connect_message_on_update',
36
- function (
37
- $message,
38
- $user_first_name,
39
- $product_title,
40
- $user_login,
41
- $site_link,
42
- $freemius_link
43
- ) {
44
- $is_network_upgrade_mode = ( fs_is_network_admin() && blc_fs()->is_network_upgrade_mode() );
45
- $slug = blc_fs()->get_slug();
46
- $is_gdpr_required = \FS_GDPR_Manager::instance()->is_required();
47
- $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $user_first_name ) );
48
-
49
- $default_optin_message = $is_gdpr_required ?
50
- fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug ) :
51
- fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug );
52
-
53
- $default_optin_message = 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with.';
54
-
55
- return (($is_network_upgrade_mode ?
56
- '' :
57
- /* translators: %s: name (e.g. Hey John,) */
58
- '<span>' . $hey_x_text . '</span>'
59
- ) .
60
- sprintf(
61
- esc_html( $default_optin_message ),
62
- '<b>' . esc_html( blc_fs()->get_plugin_name() ) . '</b>',
63
- '<b>' . $user_login . '</b>',
64
- $site_link,
65
- $freemius_link
66
- ));
67
 
68
- }, 10, 6
69
- );
 
 
 
70
 
71
- blc_fs()->add_action('connect/before', function () {
72
- $path = dirname(__FILE__) . '/views/optin.php';
73
 
74
- echo blc_call_fn(
75
- ['fn' => 'blocksy_render_view'],
76
- $path,
77
- []
78
  );
79
- });
80
 
81
- blc_fs()->add_action('connect/after', function () {
82
- echo '</div>';
83
- });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
 
85
- add_action(
86
- 'wp_ajax_blocksy_fs_connect_again',
87
- function () {
88
- if (! current_user_can('edit_theme_options')) {
89
- wp_send_json_error();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
-
92
- blc_fs()->connect_again();
93
- wp_send_json_success();
94
- }
95
- );
96
 
97
  add_filter(
98
  'blocksy_dashboard_localizations',
99
  function ($d) {
100
- $is_anonymous = blc_fs()->is_anonymous();
101
- $connect_template = '';
102
-
103
- if ($is_anonymous) {
104
- ob_start();
105
- blc_fs()->_connect_page_render();
106
- $connect_template = ob_get_clean();
107
- }
108
-
109
  $result = [
110
- 'is_pro' => blc_fs()->can_use_premium_code(),
111
- 'is_anonymous' => $is_anonymous,
112
- 'connect_template' => $connect_template
113
  ];
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  if (
116
  Plugin::instance()->premium
117
  &&
@@ -126,6 +150,17 @@ class Dashboard {
126
  return array_merge($result, $d);
127
  }
128
  );
 
 
 
 
 
 
 
 
 
 
 
129
  }
130
 
131
  public function enqueue_static() {
11
  );
12
 
13
  add_action('admin_body_class', function ($class) {
14
+ if (function_exists('blc_fs') && blc_fs()->is_activation_mode()) {
15
  $class .= ' blocksy-fs-optin-dashboard';
16
  }
17
 
18
  return $class;
19
  });
20
 
21
+ if (function_exists('blc_fs')) {
22
+ blc_fs()->add_filter(
23
+ 'show_deactivation_feedback_form',
24
+ function ($res) {
25
+ return false;
 
 
26
  }
27
+ );
28
 
29
+ blc_fs()->add_filter(
30
+ 'hide_freemius_powered_by',
31
+ function ($res) {
32
+ return true;
33
+ }
34
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
 
36
+ blc_fs()->add_filter(
37
+ 'connect-message_on-premium',
38
+ function ($text) {
39
+ if (strpos($text, '<br>') !== false) {
40
+ $exploded_message = explode('<br>', $text);
41
 
42
+ $text = '<span>' . $exploded_message[0] . '</span>' . $exploded_message[1];
43
+ }
44
 
45
+ return $text;
46
+ }
 
 
47
  );
 
48
 
49
+ blc_fs()->add_filter(
50
+ 'connect_message_on_update',
51
+ function (
52
+ $message,
53
+ $user_first_name,
54
+ $product_title,
55
+ $user_login,
56
+ $site_link,
57
+ $freemius_link
58
+ ) {
59
+ $is_network_upgrade_mode = ( fs_is_network_admin() && blc_fs()->is_network_upgrade_mode() );
60
+ $slug = blc_fs()->get_slug();
61
+ $is_gdpr_required = \FS_GDPR_Manager::instance()->is_required();
62
+ $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $user_first_name ) );
63
+
64
+ $default_optin_message = $is_gdpr_required ?
65
+ fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug ) :
66
+ fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug );
67
+
68
+ $default_optin_message = 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with.';
69
+
70
+ return (($is_network_upgrade_mode ?
71
+ '' :
72
+ /* translators: %s: name (e.g. Hey John,) */
73
+ '<span>' . $hey_x_text . '</span>'
74
+ ) .
75
+ sprintf(
76
+ esc_html( $default_optin_message ),
77
+ '<b>' . esc_html( blc_fs()->get_plugin_name() ) . '</b>',
78
+ '<b>' . $user_login . '</b>',
79
+ $site_link,
80
+ $freemius_link
81
+ ));
82
+
83
+ }, 10, 6
84
+ );
85
 
86
+ blc_fs()->add_action('connect/before', function () {
87
+ $path = dirname(__FILE__) . '/views/optin.php';
88
+
89
+ echo blc_call_fn(
90
+ ['fn' => 'blocksy_render_view'],
91
+ $path,
92
+ []
93
+ );
94
+ });
95
+
96
+ blc_fs()->add_action('connect/after', function () {
97
+ echo '</div>';
98
+ });
99
+
100
+ add_action(
101
+ 'wp_ajax_blocksy_fs_connect_again',
102
+ function () {
103
+ if (! current_user_can('edit_theme_options')) {
104
+ wp_send_json_error();
105
+ }
106
+
107
+ blc_fs()->connect_again();
108
+ wp_send_json_success();
109
  }
110
+ );
111
+ }
 
 
 
112
 
113
  add_filter(
114
  'blocksy_dashboard_localizations',
115
  function ($d) {
 
 
 
 
 
 
 
 
 
116
  $result = [
117
+ 'is_pro' => false,
118
+ 'is_anonymous' => false,
119
+ 'connect_template' => ''
120
  ];
121
 
122
+ if (function_exists('blc_fs')) {
123
+ $is_anonymous = blc_fs()->is_anonymous();
124
+ $connect_template = '';
125
+
126
+ if ($is_anonymous) {
127
+ ob_start();
128
+ blc_fs()->_connect_page_render();
129
+ $connect_template = ob_get_clean();
130
+ }
131
+
132
+ $result = [
133
+ 'is_pro' => blc_fs()->can_use_premium_code(),
134
+ 'is_anonymous' => $is_anonymous,
135
+ 'connect_template' => $connect_template
136
+ ];
137
+ }
138
+
139
  if (
140
  Plugin::instance()->premium
141
  &&
150
  return array_merge($result, $d);
151
  }
152
  );
153
+
154
+ add_action('admin_init', function ($plugin) {
155
+ if (wp_doing_ajax()) {
156
+ return;
157
+ }
158
+
159
+ if (intval(get_option('blc_activation_redirect', false)) === wp_get_current_user()->ID) {
160
+ delete_option('blc_activation_redirect');
161
+ exit(wp_redirect(admin_url('admin.php?page=ct-dashboard')));
162
+ }
163
+ });
164
  }
165
 
166
  public function enqueue_static() {
framework/extensions-manager.php CHANGED
@@ -234,7 +234,7 @@ class ExtensionsManager {
234
  }
235
 
236
  private function register_fake_extensions() {
237
- if (blc_fs()->can_use_premium_code()) {
238
  return;
239
  }
240
 
234
  }
235
 
236
  private function register_fake_extensions() {
237
+ if (function_exists('blc_fs') && blc_fs()->can_use_premium_code()) {
238
  return;
239
  }
240
 
framework/extensions/cookies-consent/static/bundle/main.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/newsletter-subscribe/static/bundle/main.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/product-reviews/static/bundle/main-admin.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/product-reviews/static/bundle/main.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/trending/customizer.php CHANGED
@@ -283,7 +283,7 @@ $options = [
283
  ],
284
  ],
285
 
286
- blc_fs()->can_use_premium_code() ? [
287
  'trending_block_location' => [
288
  'label' => __('Display Location', 'blocksy-companion'),
289
  'type' => 'ct-select',
283
  ],
284
  ],
285
 
286
+ function_exists('blc_fs') && blc_fs()->can_use_premium_code() ? [
287
  'trending_block_location' => [
288
  'label' => __('Display Location', 'blocksy-companion'),
289
  'type' => 'ct-select',
framework/extensions/trending/extension.php CHANGED
@@ -59,7 +59,7 @@ class BlocksyExtensionTrending {
59
  add_action('wp', function () {
60
  $location = 'blocksy:template:after';
61
 
62
- if (blc_fs()->can_use_premium_code()) {
63
  $location = get_theme_mod(
64
  'trending_block_location',
65
  'blocksy:content:bottom'
@@ -69,7 +69,7 @@ class BlocksyExtensionTrending {
69
  add_action(
70
  $location,
71
  function () {
72
- if (blc_fs()->can_use_premium_code()) {
73
  $conditions = get_theme_mod(
74
  'trending_block_conditions',
75
  [
59
  add_action('wp', function () {
60
  $location = 'blocksy:template:after';
61
 
62
+ if (function_exists('blc_fs') && blc_fs()->can_use_premium_code()) {
63
  $location = get_theme_mod(
64
  'trending_block_location',
65
  'blocksy:content:bottom'
69
  add_action(
70
  $location,
71
  function () {
72
+ if (function_exists('blc_fs') && blc_fs()->can_use_premium_code()) {
73
  $conditions = get_theme_mod(
74
  'trending_block_conditions',
75
  [
framework/extensions/trending/static/bundle/main.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/widgets/static/bundle/main.min.css CHANGED
@@ -1,5 +1,5 @@
1
  /**
2
- * - v1.8.46
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
1
  /**
2
+ * - v1.8.47
3
  *
4
  * Copyright (c) 2022
5
  * Licensed GPLv2+
framework/extensions/widgets/widgets/ct-contact-info/options.php CHANGED
@@ -7,7 +7,7 @@
7
  * @package Blocksy
8
  */
9
 
10
- $is_pro = blc_fs()->can_use_premium_code();
11
 
12
  $options = [
13
 
@@ -74,21 +74,21 @@ $options = [
74
  'value' => __('Address:', 'blocksy-companion'),
75
  'design' => 'inline',
76
  ],
77
-
78
  'content' => [
79
  'type' => 'text',
80
  'label' => __('Content', 'blocksy-companion'),
81
  'value' => 'Street Name, NY 38954',
82
  'design' => 'inline',
83
  ],
84
-
85
  'link' => [
86
  'type' => 'text',
87
  'label' => __('Link (optional)', 'blocksy-companion'),
88
  'design' => 'inline',
89
  ],
90
  ],
91
-
92
  $is_pro ? [
93
  'icon_source' => [
94
  'label' => __( 'Icon Source', 'blocksy' ),
@@ -102,7 +102,7 @@ $options = [
102
  'custom' => __( 'Custom', 'blocksy' ),
103
  ],
104
  ],
105
-
106
  blocksy_rand_md5() => [
107
  'type' => 'ct-condition',
108
  'condition' => ['icon_source' => 'custom'],
@@ -135,14 +135,14 @@ $options = [
135
  'value' => __('Phone:', 'blocksy-companion'),
136
  'design' => 'inline',
137
  ],
138
-
139
  'content' => [
140
  'type' => 'text',
141
  'label' => __('Content', 'blocksy-companion'),
142
  'value' => '578-393-4937',
143
  'design' => 'inline',
144
  ],
145
-
146
  'link' => [
147
  'type' => 'text',
148
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -164,7 +164,7 @@ $options = [
164
  'custom' => __( 'Custom', 'blocksy' ),
165
  ],
166
  ],
167
-
168
  blocksy_rand_md5() => [
169
  'type' => 'ct-condition',
170
  'condition' => ['icon_source' => 'custom'],
@@ -195,14 +195,14 @@ $options = [
195
  'value' => __('Mobile:', 'blocksy-companion'),
196
  'design' => 'inline',
197
  ],
198
-
199
  'content' => [
200
  'type' => 'text',
201
  'label' => __('Content', 'blocksy-companion'),
202
  'value' => '578-393-4937',
203
  'design' => 'inline',
204
  ],
205
-
206
  'link' => [
207
  'type' => 'text',
208
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -224,7 +224,7 @@ $options = [
224
  'custom' => __( 'Custom', 'blocksy' ),
225
  ],
226
  ],
227
-
228
  blocksy_rand_md5() => [
229
  'type' => 'ct-condition',
230
  'condition' => ['icon_source' => 'custom'],
@@ -255,14 +255,14 @@ $options = [
255
  'value' => __('Opening hours', 'blocksy-companion'),
256
  'design' => 'inline',
257
  ],
258
-
259
  'content' => [
260
  'type' => 'text',
261
  'label' => __('Content', 'blocksy-companion'),
262
  'value' => '9AM - 5PM',
263
  'design' => 'inline',
264
  ],
265
-
266
  'link' => [
267
  'type' => 'text',
268
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -284,7 +284,7 @@ $options = [
284
  'custom' => __( 'Custom', 'blocksy' ),
285
  ],
286
  ],
287
-
288
  blocksy_rand_md5() => [
289
  'type' => 'ct-condition',
290
  'condition' => ['icon_source' => 'custom'],
@@ -315,14 +315,14 @@ $options = [
315
  'value' => __('Fax:', 'blocksy-companion'),
316
  'design' => 'inline',
317
  ],
318
-
319
  'content' => [
320
  'type' => 'text',
321
  'label' => __('Content', 'blocksy-companion'),
322
  'value' => '578-393-4937',
323
  'design' => 'inline',
324
  ],
325
-
326
  'link' => [
327
  'type' => 'text',
328
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -344,7 +344,7 @@ $options = [
344
  'custom' => __( 'Custom', 'blocksy' ),
345
  ],
346
  ],
347
-
348
  blocksy_rand_md5() => [
349
  'type' => 'ct-condition',
350
  'condition' => ['icon_source' => 'custom'],
@@ -375,14 +375,14 @@ $options = [
375
  'value' => __('Email:', 'blocksy-companion'),
376
  'design' => 'inline',
377
  ],
378
-
379
  'content' => [
380
  'type' => 'text',
381
  'label' => __('Content', 'blocksy-companion'),
382
  'value' => 'contact@yourwebsite.com',
383
  'design' => 'inline',
384
  ],
385
-
386
  'link' => [
387
  'type' => 'text',
388
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -404,7 +404,7 @@ $options = [
404
  'custom' => __( 'Custom', 'blocksy' ),
405
  ],
406
  ],
407
-
408
  blocksy_rand_md5() => [
409
  'type' => 'ct-condition',
410
  'condition' => ['icon_source' => 'custom'],
@@ -435,14 +435,14 @@ $options = [
435
  'value' => __('Website:', 'blocksy-companion'),
436
  'design' => 'inline',
437
  ],
438
-
439
  'content' => [
440
  'type' => 'text',
441
  'label' => __('Content', 'blocksy-companion'),
442
  'value' => 'creativethemes.com',
443
  'design' => 'inline',
444
  ],
445
-
446
  'link' => [
447
  'type' => 'text',
448
  'label' => __('Link (optional)', 'blocksy-companion'),
@@ -450,7 +450,7 @@ $options = [
450
  'design' => 'inline',
451
  ],
452
  ],
453
-
454
  $is_pro ? [
455
  'icon_source' => [
456
  'label' => __( 'Icon Source', 'blocksy' ),
@@ -464,7 +464,7 @@ $options = [
464
  'custom' => __( 'Custom', 'blocksy' ),
465
  ],
466
  ],
467
-
468
  blocksy_rand_md5() => [
469
  'type' => 'ct-condition',
470
  'condition' => ['icon_source' => 'custom'],
7
  * @package Blocksy
8
  */
9
 
10
+ $is_pro = function_exists('blc_fs') && blc_fs()->can_use_premium_code();
11
 
12
  $options = [
13
 
74
  'value' => __('Address:', 'blocksy-companion'),
75
  'design' => 'inline',
76
  ],
77
+
78
  'content' => [
79
  'type' => 'text',
80
  'label' => __('Content', 'blocksy-companion'),
81
  'value' => 'Street Name, NY 38954',
82
  'design' => 'inline',
83
  ],
84
+
85
  'link' => [
86
  'type' => 'text',
87
  'label' => __('Link (optional)', 'blocksy-companion'),
88
  'design' => 'inline',
89
  ],
90
  ],
91
+
92
  $is_pro ? [
93
  'icon_source' => [
94
  'label' => __( 'Icon Source', 'blocksy' ),
102
  'custom' => __( 'Custom', 'blocksy' ),
103
  ],
104
  ],
105
+
106
  blocksy_rand_md5() => [
107
  'type' => 'ct-condition',
108
  'condition' => ['icon_source' => 'custom'],
135
  'value' => __('Phone:', 'blocksy-companion'),
136
  'design' => 'inline',
137
  ],
138
+
139
  'content' => [
140
  'type' => 'text',
141
  'label' => __('Content', 'blocksy-companion'),
142
  'value' => '578-393-4937',
143
  'design' => 'inline',
144
  ],
145
+
146
  'link' => [
147
  'type' => 'text',
148
  'label' => __('Link (optional)', 'blocksy-companion'),
164
  'custom' => __( 'Custom', 'blocksy' ),
165
  ],
166
  ],
167
+
168
  blocksy_rand_md5() => [
169
  'type' => 'ct-condition',
170
  'condition' => ['icon_source' => 'custom'],
195
  'value' => __('Mobile:', 'blocksy-companion'),
196
  'design' => 'inline',
197
  ],
198
+
199
  'content' => [
200
  'type' => 'text',
201
  'label' => __('Content', 'blocksy-companion'),
202
  'value' => '578-393-4937',
203
  'design' => 'inline',
204
  ],
205
+
206
  'link' => [
207
  'type' => 'text',
208
  'label' => __('Link (optional)', 'blocksy-companion'),
224
  'custom' => __( 'Custom', 'blocksy' ),
225
  ],
226
  ],
227
+
228
  blocksy_rand_md5() => [
229
  'type' => 'ct-condition',
230
  'condition' => ['icon_source' => 'custom'],
255
  'value' => __('Opening hours', 'blocksy-companion'),
256
  'design' => 'inline',
257
  ],
258
+
259
  'content' => [
260
  'type' => 'text',
261
  'label' => __('Content', 'blocksy-companion'),
262
  'value' => '9AM - 5PM',
263
  'design' => 'inline',
264
  ],
265
+
266
  'link' => [
267
  'type' => 'text',
268
  'label' => __('Link (optional)', 'blocksy-companion'),
284
  'custom' => __( 'Custom', 'blocksy' ),
285
  ],
286
  ],
287
+
288
  blocksy_rand_md5() => [
289
  'type' => 'ct-condition',
290
  'condition' => ['icon_source' => 'custom'],
315
  'value' => __('Fax:', 'blocksy-companion'),
316
  'design' => 'inline',
317
  ],
318
+
319
  'content' => [
320
  'type' => 'text',
321
  'label' => __('Content', 'blocksy-companion'),
322
  'value' => '578-393-4937',
323
  'design' => 'inline',
324
  ],
325
+
326
  'link' => [
327
  'type' => 'text',
328
  'label' => __('Link (optional)', 'blocksy-companion'),
344
  'custom' => __( 'Custom', 'blocksy' ),
345
  ],
346
  ],
347
+
348
  blocksy_rand_md5() => [
349
  'type' => 'ct-condition',
350
  'condition' => ['icon_source' => 'custom'],
375
  'value' => __('Email:', 'blocksy-companion'),
376
  'design' => 'inline',
377
  ],
378
+
379
  'content' => [
380
  'type' => 'text',
381
  'label' => __('Content', 'blocksy-companion'),
382
  'value' => 'contact@yourwebsite.com',
383
  'design' => 'inline',
384
  ],
385
+
386
  'link' => [
387
  'type' => 'text',
388
  'label' => __('Link (optional)', 'blocksy-companion'),
404
  'custom' => __( 'Custom', 'blocksy' ),
405
  ],
406
  ],
407
+
408
  blocksy_rand_md5() => [
409
  'type' => 'ct-condition',
410
  'condition' => ['icon_source' => 'custom'],
435
  'value' => __('Website:', 'blocksy-companion'),
436
  'design' => 'inline',
437
  ],
438
+
439
  'content' => [
440
  'type' => 'text',
441
  'label' => __('Content', 'blocksy-companion'),
442
  'value' => 'creativethemes.com',
443
  'design' => 'inline',
444
  ],
445
+
446
  'link' => [
447
  'type' => 'text',
448
  'label' => __('Link (optional)', 'blocksy-companion'),
450
  'design' => 'inline',
451
  ],
452
  ],
453
+
454
  $is_pro ? [
455
  'icon_source' => [
456
  'label' => __( 'Icon Source', 'blocksy' ),
464
  'custom' => __( 'Custom', 'blocksy' ),
465
  ],
466
  ],
467
+
468
  blocksy_rand_md5() => [
469
  'type' => 'ct-condition',
470
  'condition' => ['icon_source' => 'custom'],
framework/features/header.php CHANGED
@@ -567,7 +567,9 @@ class HeaderAdditions {
567
  }
568
 
569
  public function retrieve_account_modal() {
570
- remove_filter('lostpassword_url', 'wc_lostpassword_url', 10, 1);
 
 
571
 
572
  $body = json_decode(file_get_contents('php://input'), true);
573
 
@@ -593,7 +595,9 @@ class HeaderAdditions {
593
  ]
594
  );
595
 
596
- add_filter('lostpassword_url', 'wc_lostpassword_url', 10, 1);
 
 
597
 
598
  return $html;
599
  }
567
  }
568
 
569
  public function retrieve_account_modal() {
570
+ if (function_exists('wc_lostpassword_url')) {
571
+ remove_filter('lostpassword_url', 'wc_lostpassword_url', 10, 1);
572
+ }
573
 
574
  $body = json_decode(file_get_contents('php://input'), true);
575
 
595
  ]
596
  );
597
 
598
+ if (function_exists('wc_lostpassword_url')) {
599
+ add_filter('lostpassword_url', 'wc_lostpassword_url', 10, 1);
600
+ }
601
 
602
  return $html;
603
  }
framework/features/header/items/account/options.php CHANGED
@@ -18,7 +18,7 @@ if (class_exists('WooCommerce')) {
18
  $logout_link_options['woocommerce_account'] = __('WooCommerce Account', 'blocksy-companion');
19
  }
20
 
21
- $is_pro = blc_fs()->can_use_premium_code();
22
 
23
  $options = [
24
  blocksy_rand_md5() => [
18
  $logout_link_options['woocommerce_account'] = __('WooCommerce Account', 'blocksy-companion');
19
  }
20
 
21
+ $is_pro = function_exists('blc_fs') && blc_fs()->can_use_premium_code();
22
 
23
  $options = [
24
  blocksy_rand_md5() => [
framework/features/header/modal/login.php CHANGED
@@ -46,7 +46,7 @@ if (! $forgot_password_inline) {
46
  </p>
47
 
48
  <?php
49
- if (blc_fs()->can_use_premium_code()) {
50
  if (class_exists('NextendSocialLogin')) {
51
  \NextendSocialLogin::addLoginFormButtons();
52
  }
46
  </p>
47
 
48
  <?php
49
+ if (function_exists('blc_fs') && blc_fs()->can_use_premium_code()) {
50
  if (class_exists('NextendSocialLogin')) {
51
  \NextendSocialLogin::addLoginFormButtons();
52
  }
framework/features/header/modal/register.php CHANGED
@@ -45,13 +45,14 @@ if (
45
  <?php } ?>
46
 
47
  <?php
48
- if (blc_fs()->can_use_premium_code()) {
49
  if (class_exists('NextendSocialLogin')) {
50
  \NextendSocialLogin::addRegisterFormButtons();
51
  }
52
  }
53
 
54
- do_action('register_form')
 
55
  ?>
56
 
57
  <p id="reg_passmail">
45
  <?php } ?>
46
 
47
  <?php
48
+ if (function_exists('blc_fs') && blc_fs()->can_use_premium_code()) {
49
  if (class_exists('NextendSocialLogin')) {
50
  \NextendSocialLogin::addRegisterFormButtons();
51
  }
52
  }
53
 
54
+ do_action('register_form');
55
+ do_action('woocommerce_register_form');
56
  ?>
57
 
58
  <p id="reg_passmail">
framework/features/opengraph-meta-data.php CHANGED
@@ -91,6 +91,8 @@ class OpenGraphMetaData {
91
  $title = get_the_archive_title();
92
  }
93
 
 
 
94
  // Description
95
  if (is_category() || is_tag() || is_tax()) {
96
  $description = wp_strip_all_tags(term_description());
91
  $title = get_the_archive_title();
92
  }
93
 
94
+ $title = wp_strip_all_tags($title);
95
+
96
  // Description
97
  if (is_category() || is_tag() || is_tax()) {
98
  $description = wp_strip_all_tags(term_description());
framework/theme-integration.php CHANGED
@@ -399,6 +399,8 @@ class ThemeIntegration {
399
  }
400
 
401
  if (
 
 
402
  blc_fs()->can_use_premium_code()
403
  &&
404
  BLOCKSY_PATH . '/framework/premium/changelog.txt'
399
  }
400
 
401
  if (
402
+ function_exists('blc_fs')
403
+ &&
404
  blc_fs()->can_use_premium_code()
405
  &&
406
  BLOCKSY_PATH . '/framework/premium/changelog.txt'
freemius/LICENSE.txt DELETED
@@ -1,674 +0,0 @@
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
-
623
- How to Apply These Terms to Your New Programs
624
-
625
- If you develop a new program, and you want it to be of the greatest
626
- possible use to the public, the best way to achieve this is to make it
627
- free software which everyone can redistribute and change under these terms.
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,
643
- but WITHOUT ANY WARRANTY; without even the implied warranty of
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/assets/css/admin/account.css DELETED
@@ -1 +0,0 @@
1
- label.fs-tag,span.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,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.fs-notice[data-id=license_not_whitelabeled].success,.fs-notice[data-id=license_whitelabeled].success{color:inherit;border-left-color:#00a0d2}.fs-notice[data-id=license_not_whitelabeled].success label.fs-plugin-title,.fs-notice[data-id=license_whitelabeled].success label.fs-plugin-title{display:none}#fs_account .postbox,#fs_account .widefat{max-width:800px}#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 .dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:.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}.fs-field-beta_program label{margin-left:7px}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_sites .fs-scrollable-table .fs-table-body{max-height:200px;overflow:auto;border:1px solid #e5e5e5}#fs_sites .fs-scrollable-table .fs-table-body>table.widefat{border:none !important}#fs_sites .fs-scrollable-table .fs-main-column{width:100%}#fs_sites .fs-scrollable-table .fs-site-details td:first-of-type{text-align:right;color:gray;width:1px}#fs_sites .fs-scrollable-table .fs-site-details td:last-of-type{text-align:right}#fs_sites .fs-scrollable-table .fs-install-details table tr td{width:1px;white-space:nowrap}#fs_sites .fs-scrollable-table .fs-install-details table tr td:last-of-type{width:auto}#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%}@media screen and (max-width: 639px){#fs_account .fs-header-actions{position:static;padding:0 15px 12px 15px;margin:0 0 12px 0}#fs_account .fs-header-actions li{float:none;display:inline-block}#fs_account #fs_account_details{display:block}#fs_account #fs_account_details tbody,#fs_account #fs_account_details tr,#fs_account #fs_account_details td,#fs_account #fs_account_details th{display:block}#fs_account #fs_account_details tr td:first-child{text-align:left}#fs_account #fs_account_details tr td:nth-child(2){padding:0 12px}#fs_account #fs_account_details tr td:nth-child(2) code{margin:0;padding:0}#fs_account #fs_account_details tr td:nth-child(2) label{margin-left:0}#fs_account #fs_account_details tr td:nth-child(3){text-align:left}#fs_account #fs_account_details tr.fs-field-plan td:nth-child(2) .button-group{float:none;margin:12px 0}}/*# sourceMappingURL=account.css.map */
 
freemius/assets/css/admin/add-ons.css DELETED
@@ -1 +0,0 @@
1
- .fs-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,.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,.3);box-shadow:0 2px 1px -1px rgba(0,0,0,.3)}#fs_addons .fs-cards-list{list-style:none}#fs_addons .fs-cards-list .fs-card{float:left;height:152px;width:310px;padding:0;margin:0 0 30px 30px;font-size:14px;list-style:none;border:1px solid #ddd;cursor:pointer;position:relative}#fs_addons .fs-cards-list .fs-card .fs-overlay{position:absolute;left:0;right:0;bottom:0;top:0;z-index:9}#fs_addons .fs-cards-list .fs-card .fs-inner{background-color:#fff;overflow:hidden;height:100%;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner>ul{-moz-transition:all,.15s;-o-transition:all,.15s;-ms-transition:all,.15s;-webkit-transition:all,.15s;transition:all,.15s;left:0;right:0;top:0;position:absolute}#fs_addons .fs-cards-list .fs-card .fs-inner>ul>li{list-style:none;line-height:18px;padding:0 15px;width:100%;display:block;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner{padding:0;margin:0;line-height:0;display:block;height:100px;background-repeat:repeat-x;background-size:100% 100%;-moz-transition:all,.15s;-o-transition:all,.15s;-ms-transition:all,.15s;-webkit-transition:all,.15s;transition:all,.15s}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner .fs-badge.fs-installed-addon-badge{font-size:1.02em;line-height:1.3em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-title{margin:10px 0 0 0;height:18px;overflow:hidden;color:#000;white-space:nowrap;text-overflow:ellipsis;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-offer{font-size:.9em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-description{background-color:#f9f9f9;padding:10px 15px 100px 15px;border-top:1px solid #eee;margin:0 0 10px 0;color:#777}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-tag{position:absolute;top:10px;right:0px;background:#adff2f;display:block;padding:2px 10px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,.3);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.3);box-shadow:1px 1px 1px rgba(0,0,0,.3);text-transform:uppercase;font-size:.9em;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button,#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button-group{position:absolute;top:112px;right:10px}@media screen and (min-width: 960px){#fs_addons .fs-cards-list .fs-card:hover .fs-overlay{border:2px solid #29abe1;margin-left:-1px;margin-top:-1px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner ul{top:-100px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-title,#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-offer{color:#29abe1}}#TB_window,#TB_window iframe{width:821px !important}#plugin-information .fyi{width:266px !important}#plugin-information #section-holder{margin-right:299px}#plugin-information #section-description h2,#plugin-information #section-description h3,#plugin-information #section-description p,#plugin-information #section-description b,#plugin-information #section-description i,#plugin-information #section-description blockquote,#plugin-information #section-description li,#plugin-information #section-description ul,#plugin-information #section-description ol{clear:none}#plugin-information #section-description iframe{max-width:100%}#plugin-information #section-description .fs-selling-points{padding-bottom:10px;border-bottom:1px solid #ddd}#plugin-information #section-description .fs-selling-points ul{margin:0}#plugin-information #section-description .fs-selling-points ul li{padding:0;list-style:none outside none}#plugin-information #section-description .fs-selling-points ul li i.dashicons{color:#71ae00;font-size:3em;vertical-align:middle;line-height:30px;float:left;margin:0 0 0 -15px}#plugin-information #section-description .fs-selling-points ul li h3{margin:1em 30px !important}#plugin-information #section-description .fs-screenshots:after{content:"";display:table;clear:both}#plugin-information #section-description .fs-screenshots ul{list-style:none;margin:0}#plugin-information #section-description .fs-screenshots ul li{width:225px;height:225px;float:left;margin-bottom:20px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#plugin-information #section-description .fs-screenshots ul li a{display:block;width:100%;height:100%;border:1px solid;-moz-box-shadow:1px 1px 1px rgba(0,0,0,.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.2);box-shadow:1px 1px 1px rgba(0,0,0,.2);background-size:cover}#plugin-information #section-description .fs-screenshots ul li.odd{margin-right:20px}#plugin-information .plugin-information-pricing{margin:-16px;border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan h3{margin-top:0;padding:20px;font-size:16px}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper{border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab{cursor:pointer;position:relative;padding:0 10px;font-size:.9em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab label{text-transform:uppercase;color:green;background:#adff2f;position:absolute;left:-1px;right:-1px;bottom:100%;border:1px solid #006400;padding:2px;text-align:center;font-size:.9em;line-height:1em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab.nav-tab-active{cursor:default;background:#fffeec;border-bottom-color:#fffeec}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle h3{background:#fffeec;margin:0;padding-bottom:0;color:#0073aa}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .nav-tab-wrapper,#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .fs-billing-frequency{display:none}#plugin-information .plugin-information-pricing .fs-plan .fs-pricing-body{background:#fffeec;padding:20px}#plugin-information .plugin-information-pricing .fs-plan .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing .fs-plan label{white-space:nowrap}#plugin-information .plugin-information-pricing .fs-plan var{font-style:normal}#plugin-information .plugin-information-pricing .fs-plan .fs-billing-frequency,#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-align:center;display:block;font-weight:bold;margin-bottom:10px;text-transform:uppercase;background:#f3f3f3;padding:2px;border:1px solid #ccc}#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-transform:none;color:green;background:#adff2f}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms{font-size:.9em}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms i{float:left;margin:0 0 0 -15px}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms li{margin:10px 0 0 0}#plugin-information #section-features .fs-features{margin:-20px -26px}#plugin-information #section-features table{width:100%;border-spacing:0;border-collapse:separate}#plugin-information #section-features table thead th{padding:10px 0}#plugin-information #section-features table thead .fs-price{color:#71ae00;font-weight:normal;display:block;text-align:center}#plugin-information #section-features table tbody td{border-top:1px solid #ccc;padding:10px 0;text-align:center;width:100px;color:#71ae00}#plugin-information #section-features table tbody td:first-child{text-align:left;width:auto;color:inherit;padding-left:26px}#plugin-information #section-features table tbody tr.fs-odd td{background:#fefefe}#plugin-information #section-features .dashicons-yes{width:30px;height:30px;font-size:30px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button,#plugin-information .fs-dropdown .button-group .button{position:relative;width:auto;top:0;right:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .button:focus,#plugin-information .fs-dropdown .button-group .button:focus{z-index:10}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .button-group .fs-dropdown-arrow,#plugin-information .fs-dropdown .button-group .fs-dropdown-arrow{border-top:6px solid #fff;border-right:4px solid transparent;border-left:4px solid transparent;top:12px;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active:not(.up) .button:not(.fs-dropdown-arrow-button){border-bottom-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active:not(.up) .fs-dropdown-arrow-button{border-bottom-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button),#plugin-information .fs-dropdown.active.up .button:not(.fs-dropdown-arrow-button){border-top-left-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.active.up .fs-dropdown-arrow-button,#plugin-information .fs-dropdown.active.up .fs-dropdown-arrow-button{border-top-right-radius:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list,#plugin-information .fs-dropdown .fs-dropdown-list{position:absolute;right:-1px;top:100%;margin-left:auto;padding:3px 0;border:1px solid #bfbfbf;background-color:#fff;z-index:1;width:230px;text-align:left;-moz-box-shadow:0px 2px 4px -1px rgba(0,0,0,.2),0px 4px 5px 0px rgba(0,0,0,.14),0px 1px 10px 0px rgba(0,0,0,.12);-webkit-box-shadow:0px 2px 4px -1px rgba(0,0,0,.2),0px 4px 5px 0px rgba(0,0,0,.14),0px 1px 10px 0px rgba(0,0,0,.12);box-shadow:0px 2px 4px -1px rgba(0,0,0,.2),0px 4px 5px 0px rgba(0,0,0,.14),0px 1px 10px 0px rgba(0,0,0,.12)}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li,#plugin-information .fs-dropdown .fs-dropdown-list li{margin:0}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li a,#plugin-information .fs-dropdown .fs-dropdown-list li a{display:block;padding:5px 10px;text-decoration:none;text-shadow:none}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover,#plugin-information .fs-dropdown .fs-dropdown-list li:hover{background-color:#0074a3;color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown .fs-dropdown-list li:hover a,#plugin-information .fs-dropdown .fs-dropdown-list li:hover a{color:#fff}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown:not(.up) .fs-dropdown-list,#plugin-information .fs-dropdown:not(.up) .fs-dropdown-list{-moz-border-radius:3px 0 3px 3px;-webkit-border-radius:3px 0 3px 3px;border-radius:3px 0 3px 3px}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-dropdown.up .fs-dropdown-list,#plugin-information .fs-dropdown.up .fs-dropdown-list{-moz-border-radius:3px 3px 0 3px;-webkit-border-radius:3px 3px 0 3px;border-radius:3px 3px 0 3px}#plugin-information .fs-dropdown .button-group{width:100%}#plugin-information .fs-dropdown .button-group .button{float:none;font-size:14px;font-weight:normal;text-transform:none}#plugin-information .fs-dropdown .fs-dropdown-list{margin-top:1px}#plugin-information .fs-dropdown.up .fs-dropdown-list{top:auto;bottom:100%;margin-bottom:2px}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group{text-align:center;display:table}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button{display:table-cell}#plugin-information.wp-core-ui .fs-pricing-body .fs-dropdown .button-group .button:not(.fs-dropdown-arrow-button){left:1px;width:100%}#plugin-information-footer>.button,#plugin-information-footer .fs-dropdown{position:relative;top:3px}#plugin-information-footer>.button.left,#plugin-information-footer .fs-dropdown.left{float:left}#plugin-information-footer>.right,#plugin-information-footer .fs-dropdown{float:right}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}/*# sourceMappingURL=add-ons.css.map */
 
freemius/assets/css/admin/affiliation.css DELETED
@@ -1 +0,0 @@
1
- #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{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;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}/*# sourceMappingURL=affiliation.css.map */
 
freemius/assets/css/admin/checkout.css DELETED
@@ -1 +0,0 @@
1
- @media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}/*# sourceMappingURL=checkout.css.map */
 
freemius/assets/css/admin/clone-resolution.css DELETED
@@ -1 +0,0 @@
1
- .fs-notice[data-id^=clone_resolution_options_notice]{padding:0;color:inherit !important}.fs-notice[data-id^=clone_resolution_options_notice] .fs-notice-body{padding:0;margin-bottom:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-notice-header{padding:5px 10px}.fs-notice[data-id^=clone_resolution_options_notice] ol{margin-top:0;margin-bottom:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-options-container{display:flex;flex-direction:row;padding:0 10px 10px}@media(max-width: 750px){.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-options-container{flex-direction:column}}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option{border:1px solid #ccc;padding:10px 10px 15px 10px;flex:auto;margin:5px}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option:first-child{margin-left:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option:last-child{margin-right:0}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-resolution-option strong{font-size:1.2em;padding:2px;line-height:1.5em}.fs-notice[data-id^=clone_resolution_options_notice] a{text-decoration:none}.fs-notice[data-id^=clone_resolution_options_notice] .button{margin-right:10px}.rtl .fs-notice[data-id^=clone_resolution_options_notice] .button{margin-right:0;margin-left:10px}.fs-notice[data-id^=clone_resolution_options_notice] .fs-clone-documentation-container{padding:0 10px 15px}.fs-notice[data-id=temporary_duplicate_notice] #fs_clone_resolution_error_message{border:1px solid #d3135a;background:#fee;color:#d3135a;padding:10px}.fs-notice[data-id=temporary_duplicate_notice] ol{margin-top:0}/*# sourceMappingURL=clone-resolution.css.map */
 
freemius/assets/css/admin/common.css DELETED
@@ -1 +0,0 @@
1
- .fs-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,.3);-webkit-box-shadow:0 2px 1px -1px rgba(0,0,0,.3);box-shadow:0 2px 1px -1px rgba(0,0,0,.3)}.theme-browser .theme .fs-premium-theme-badge-container{position:absolute;right:0;top:0}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge{position:relative;top:0;margin-top:10px;text-align:center}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-premium-theme-badge{font-size:1.1em}.theme-browser .theme .fs-premium-theme-badge-container .fs-badge.fs-beta-theme-badge{background:#00a0d2}.fs-switch{position:relative;display:inline-block;color:#ccc;text-shadow:0 1px 1px rgba(255,255,255,.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,.2);background:#ececec;box-shadow:0 0 4px rgba(0,0,0,.1),inset 0 1px 3px 0 rgba(0,0,0,.1);cursor:pointer}.fs-switch span{display:inline-block;width:35px;text-transform:uppercase}.fs-switch .fs-toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,.3);border-radius:4px;background:#fff;background-color:#fff;background-image:-webkit-gradient(linear, left top, left bottom, color-stop(0, #ececec), color-stop(1, #fff));background-image:-webkit-linear-gradient(top, #ececec, #fff);background-image:-moz-linear-gradient(top, #ececec, #fff);background-image:-ms-linear-gradient(top, #ececec, #fff);background-image:-o-linear-gradient(top, #ececec, #fff);background-image:linear-gradient(top, bottom, #ececec, #fff);box-shadow:inset 0 1px 0 0 rgba(255,255,255,.5);z-index:999;-moz-transition:.4s cubic-bezier(0.54, 1.6, 0.5, 1);-o-transition:.4s cubic-bezier(0.54, 1.6, 0.5, 1);-ms-transition:.4s cubic-bezier(0.54, 1.6, 0.5, 1);-webkit-transition:.4s cubic-bezier(0.54, 1.6, 0.5, 1);transition:.4s cubic-bezier(0.54, 1.6, 0.5, 1)}.fs-switch.fs-off .fs-toggle{left:2%}.fs-switch.fs-on .fs-toggle{left:54%}.fs-switch.fs-round{top:8px;padding:4px 25px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round .fs-toggle{top:0;width:24px;height:24px;-moz-border-radius:24px;-webkit-border-radius:24px;border-radius:24px}.fs-switch.fs-round.fs-off .fs-toggle{left:-1px}.fs-switch.fs-round.fs-on{background:#0085ba}.fs-switch.fs-round.fs-on .fs-toggle{left:25px}.fs-switch.fs-small.fs-round{padding:1px 19px}.fs-switch.fs-small.fs-round .fs-toggle{top:0;width:18px;height:18px;-moz-border-radius:18px;-webkit-border-radius:18px;border-radius:18px}.fs-switch.fs-small.fs-round.fs-on .fs-toggle{left:19px}.fs-switch-feedback{margin-left:10px}.fs-switch-feedback.success{color:#71ae00}.rtl .fs-switch-feedback{margin-left:0;margin-right:10px}#fs_frame{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}}.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,.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,.3);-webkit-box-shadow:0 2px 2px rgba(6,113,6,.3);box-shadow:0 2px 2px rgba(6,113,6,.3);opacity:.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: 1250px){#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:"↳";padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:"↲"}.fs-submenu-item.pricing.upgrade-mode{color:#adff2f}.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;margin-bottom:-2px}.wrap.fs-section h2{text-align:left}.plugins p.fs-upgrade-notice{border:0;background-color:#d54e21;padding:10px;color:#f9f9f9;margin-top:10px}/*# sourceMappingURL=common.css.map */
 
freemius/assets/css/admin/connect.css DELETED
@@ -1 +0,0 @@
1
- #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,.3);box-shadow:0px 1px 2px rgba(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,.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(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.require-license-key .fs-sites-list-container td{cursor:pointer}#fs_connect #delegate_to_site_admins{margin-right:15px;float:right;height:26px;vertical-align:middle;line-height:37px;font-weight:bold;border-bottom:1px dashed;text-decoration:none}#fs_connect #delegate_to_site_admins.rtl{margin-left:15px;margin-right:0}#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:" ➜"}#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 .5s ease;-o-transition:background .5s ease;-ms-transition:background .5s ease;-webkit-transition:background .5s ease;transition:background .5s ease}#fs_connect .fs-permissions .fs-license-sync-disclaimer{text-align:center;margin-top:0}#fs_connect .fs-permissions>.fs-trigger{font-size:.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 .fs-switch{float:right}#fs_connect .fs-permissions ul li .fs-permission-description{margin-left:55px}#fs_connect .fs-permissions ul li .fs-permission-description span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li .fs-permission-description p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{overflow:initial;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:.85em;padding:5px;background:rgba(0,0,0,.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-tooltip-trigger{position:relative}.fs-tooltip-trigger:not(a){cursor:help}.fs-tooltip-trigger .fs-tooltip{opacity:0;visibility:hidden;-moz-transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;transition:opacity .3s ease-in-out;position:absolute;background:rgba(0,0,0,.8);color:#fff !important;font-family:"arial",serif;font-size:12px;padding:10px;z-index:999999;bottom:100%;margin-bottom:5px;left:-17px;right:0;-moz-border-radius:5px;-webkit-border-radius:5px;border-radius:5px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.2);box-shadow:1px 1px 1px rgba(0,0,0,.2);line-height:1.3em;font-weight:bold;text-align:left;text-transform:none !important}.rtl .fs-tooltip-trigger .fs-tooltip{text-align:right;left:auto;right:-17px}.fs-tooltip-trigger .fs-tooltip::after{content:" ";display:block;width:0;height:0;border-style:solid;border-width:5px 5px 0 5px;border-color:rgba(0,0,0,.8) transparent transparent transparent;position:absolute;top:100%;left:21px}.rtl .fs-tooltip-trigger .fs-tooltip::after{right:21px;left:auto}.fs-tooltip-trigger:hover .fs-tooltip{visibility:visible;opacity:1}#fs_marketing_optin{display:none;margin-top:10px;border:1px solid #ccc;padding:10px;line-height:1.5em}#fs_marketing_optin .fs-message{display:block;margin-bottom:5px;font-size:1.05em;font-weight:600}#fs_marketing_optin.error{border:1px solid #d3135a;background:#fee}#fs_marketing_optin.error .fs-message{color:#d3135a}#fs_marketing_optin .fs-input-container{margin-top:5px}#fs_marketing_optin .fs-input-container label{margin-top:5px;display:block}#fs_marketing_optin .fs-input-container label input{float:left;margin:1px 0 0 0}#fs_marketing_optin .fs-input-container label:first-child{display:block;margin-bottom:2px}#fs_marketing_optin .fs-input-label{display:block;margin-left:20px}#fs_marketing_optin .fs-input-label .underlined{text-decoration:underline}.rtl #fs_marketing_optin .fs-input-container label input{float:right}.rtl #fs_marketing_optin .fs-input-label{margin-left:0;margin-right:20px}.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:" »"}.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 .fs-permission-description{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li .fs-switch{float:left}.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,.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:#fff;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,.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}#license_issues_link{display:block;text-align:center;font-size:.9em;margin-top:10px}/*# sourceMappingURL=connect.css.map */
 
freemius/assets/css/admin/debug.css DELETED
@@ -1 +0,0 @@
1
- .fs-switch-label{font-size:20px;line-height:31px;margin:0 5px}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}/*# sourceMappingURL=debug.css.map */
 
freemius/assets/css/admin/dialog-boxes.css DELETED
@@ -1 +0,0 @@
1
- .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,.6)}.fs-modal .dashicons{vertical-align:middle}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media(max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;-ms-transition:all .2s ease-in-out;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-header .fs-close .dashicons,.fs-modal .fs-modal-header .fs-close:hover .dashicons{text-decoration:none}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:last-of-type{margin:0}.fs-modal .fs-modal-panel>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}.rtl .fs-modal .fs-modal-footer{text-align:left}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media(max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label,.fs-modal.fs-modal-deactivation-feedback .feedback-from-snooze-label{float:left;line-height:30px}.rtl .fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label,.rtl .fs-modal.fs-modal-deactivation-feedback .feedback-from-snooze-label{float:right}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-subscription-cancellation .fs-price-increase-warning{color:red;font-weight:bold;padding:0 25px;margin-bottom:0}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:left;top:5px;position:relative}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label input{float:right}.fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{display:block;margin-left:24px}.rtl .fs-modal.fs-modal-subscription-cancellation ul.subscription-actions label span{margin-left:0;margin-right:24px}.fs-modal.fs-modal-license-activation .fs-modal-body input.fs-license-key{width:100%}.fs-license-options-container table,.fs-license-options-container table select,.fs-license-options-container table .fs-available-license-key{width:100%}.fs-license-options-container table td:first-child{width:1%}.fs-license-options-container table .fs-other-license-key-container label{position:relative;top:6px;float:left;margin-right:5px}.fs-license-options-container table .fs-other-license-key-container div{overflow:hidden;width:auto;height:30px;display:block;top:2px;position:relative}.fs-license-options-container table .fs-other-license-key-container div input{margin:0}.fs-sites-list-container td{cursor:pointer}.fs-modal.fs-modal-user-change .fs-modal-body input#fs_other_email_address{width:100%}.fs-user-change-options-container table{width:100%;border-collapse:collapse}.fs-user-change-options-container table tr{display:block;margin-bottom:2px}.fs-user-change-options-container table .fs-email-address-container td{display:inline-block}.fs-user-change-options-container table .fs-email-address-container input[type=radio]{margin-bottom:0;margin-top:0}.fs-user-change-options-container table .fs-other-email-address-container{width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div{display:table;width:100%}.fs-user-change-options-container table .fs-other-email-address-container>div label,.fs-user-change-options-container table .fs-other-email-address-container>div>div{display:table-cell}.fs-user-change-options-container table .fs-other-email-address-container>div label{width:1%;padding-left:3px;padding-right:3px}.fs-user-change-options-container table .fs-other-email-address-container>div>div{width:auto}.fs-user-change-options-container table .fs-other-email-address-container>div>div input{width:100%}.fs-modal.fs-modal-developer-license-debug-mode .fs-modal-body input.fs-license-or-user-key{width:100%}.fs-multisite-options-container{margin-top:10px;border:1px solid #ccc;padding:5px}.fs-multisite-options-container a{text-decoration:none}.fs-multisite-options-container a:focus{box-shadow:none}.fs-multisite-options-container a.selected{font-weight:bold}.fs-multisite-options-container.fs-apply-on-all-sites{border:0 none;padding:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options{border-spacing:0}.fs-multisite-options-container.fs-apply-on-all-sites .fs-all-sites-options td:not(:first-child){display:none}.fs-multisite-options-container .fs-sites-list-container{display:none;overflow:auto}.fs-multisite-options-container .fs-sites-list-container table td{border-top:1px solid #ccc;padding:4px 2px}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media(max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-modal.fs-modal-email-address-update .fs-modal-body input[type=text]{width:100%}.fs-modal.fs-modal-email-address-update p{margin-bottom:0}.fs-modal.fs-modal-email-address-update ul{margin:1em .5em}.fs-modal.fs-modal-email-address-update ul li label span{float:left;margin-top:0}.fs-modal.fs-modal-email-address-update ul li label span:last-child{display:block;float:none;margin-left:20px}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:.3;-o-transform:.3;-ms-transform:.3;-webkit-transform:.3;transform:.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}.button-primary.warn{box-shadow:0 1px 0 #d2593c;text-shadow:0 -1px 1px #d2593c,1px 0 1px #d2593c,0 1px 1px #d2593c,-1px 0 1px #d2593c;background:#f56a48;border-color:#ec6544 #d2593c #d2593c}.button-primary.warn:hover{background:#fd6d4a;border-color:#d2593c}.button-primary.warn:focus{box-shadow:0 1px 0 #dd6041,0 0 2px 1px #e4a796}.button-primary.warn:active{background:#dd6041;border-color:#d2593c;box-shadow:inset 0 2px 0 #d2593c}.button-primary.warn.disabled{color:#f5b3a1 !important;background:#e76444 !important;border-color:#d85e40 !important;text-shadow:0 -1px 0 rgba(0,0,0,.1) !important}/*# sourceMappingURL=dialog-boxes.css.map */
 
freemius/assets/css/admin/gdpr-optin-notice.css DELETED
@@ -1 +0,0 @@
1
- .fs-notice[data-id^=gdpr_optin_actions] .underlined{text-decoration:underline}.fs-notice[data-id^=gdpr_optin_actions] ul .button,.fs-notice[data-id^=gdpr_optin_actions] ul .action-description{vertical-align:middle}.fs-notice[data-id^=gdpr_optin_actions] ul .action-description{display:inline-block;margin-left:3px}/*# sourceMappingURL=gdpr-optin-notice.css.map */
 
freemius/assets/css/admin/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- // Hide file structure from users on unprotected servers.
 
 
 
freemius/assets/css/admin/plugins.css DELETED
@@ -1 +0,0 @@
1
- label.fs-tag,span.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,span.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-info,span.fs-tag.fs-info{background:#00a0d2}label.fs-tag.fs-success,span.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error,span.fs-tag.fs-error{background:#dc3232}.wp-list-table.plugins .plugin-title span.fs-tag{display:inline-block;margin-left:5px;line-height:10px}/*# sourceMappingURL=plugins.css.map */
 
freemius/assets/css/customizer.css DELETED
@@ -1 +0,0 @@
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 .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-ms-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out;transition:opacity .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,.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,.2);box-shadow:1px 1px 1px rgba(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}#customize-theme-controls #accordion-section-freemius_upsell{border-top:1px solid #0085ba !important;border-bottom:1px solid #0085ba !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title{color:#fff;background-color:#0085ba;border-left:4px solid #0085ba;transition:.15s background-color ease-in-out,.15s border-color ease-in-out;outline:none;border-bottom:none !important}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:hover{background-color:#008ec2;border-left-color:#0073aa}#customize-theme-controls #accordion-section-freemius_upsell h3.accordion-section-title:after{color:#fff}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title{border-left:none;border-right:4px solid #0085ba}#customize-theme-controls #accordion-section-freemius_upsell .rtl h3.accordion-section-title:hover{border-right-color:#0073aa}/*# sourceMappingURL=customizer.css.map */
 
freemius/assets/css/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- // Hide file structure from users on unprotected servers.
 
 
 
freemius/assets/img/blocksy-companion.jpg DELETED
Binary file
freemius/assets/img/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- // Hide file structure from users on unprotected servers.
 
 
 
freemius/assets/img/plugin-icon.png DELETED
Binary file
freemius/assets/img/theme-icon.png DELETED
Binary file
freemius/assets/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- // Hide file structure from users on unprotected servers.
 
 
 
freemius/assets/js/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- // Hide file structure from users on unprotected servers.
 
 
 
freemius/assets/js/nojquery.ba-postmessage.js DELETED
@@ -1,140 +0,0 @@
1
- /*!
2
- * jQuery postMessage - v0.5 - 9/11/2009
3
- * http://benalman.com/projects/jquery-postmessage-plugin/
4
- *
5
- * Copyright (c) 2009 "Cowboy" Ben Alman
6
- * Dual licensed under the MIT and GPL licenses.
7
- * http://benalman.com/about/license/
8
- *
9
- * Non-jQuery fork by Jeff Lee
10
- *
11
- * This fork consists of the following changes:
12
- * 1. Basic code cleanup and restructuring, for legibility.
13
- * 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
14
- * in terms of both function names and object scope. Scope is specified by
15
- * the the "this" context of NoJQueryPostMessageMixin();
16
- * 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
17
- * at least three different GitHub users requesting the removal of this
18
- * "Opera sniff" on the original project's Issues page, so I figured this
19
- * would be a relatively safe change.
20
- * 4. `postMessage` no longer uses `$.param` to serialize messages that are not
21
- * strings. I actually prefer this structure anyway. `receiveMessage` does
22
- * not implement a corresponding deserialization step, and as such it seems
23
- * cleaner and more symmetric to leave both data serialization and
24
- * deserialization to the client.
25
- * 5. The use of `$.isFunction` is replaced by a functionally-identical check.
26
- * 6. The `$:nomunge` YUI option is no longer necessary.
27
- */
28
-
29
- function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
30
-
31
- var setMessageCallback, unsetMessageCallback, currentMsgCallback,
32
- intervalId, lastHash, cacheBust = 1;
33
-
34
- if (window.postMessage) {
35
-
36
- if (window.addEventListener) {
37
- setMessageCallback = function(callback) {
38
- window.addEventListener('message', callback, false);
39
- }
40
-
41
- unsetMessageCallback = function(callback) {
42
- window.removeEventListener('message', callback, false);
43
- }
44
- } else {
45
- setMessageCallback = function(callback) {
46
- window.attachEvent('onmessage', callback);
47
- }
48
-
49
- unsetMessageCallback = function(callback) {
50
- window.detachEvent('onmessage', callback);
51
- }
52
- }
53
-
54
- this[postBinding] = function(message, targetUrl, target) {
55
- if (!targetUrl) {
56
- return;
57
- }
58
-
59
- // The browser supports window.postMessage, so call it with a targetOrigin
60
- // set appropriately, based on the targetUrl parameter.
61
- target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
62
- }
63
-
64
- // Since the browser supports window.postMessage, the callback will be
65
- // bound to the actual event associated with window.postMessage.
66
- this[receiveBinding] = function(callback, sourceOrigin, delay) {
67
- // Unbind an existing callback if it exists.
68
- if (currentMsgCallback) {
69
- unsetMessageCallback(currentMsgCallback);
70
- currentMsgCallback = null;
71
- }
72
-
73
- if (!callback) {
74
- return false;
75
- }
76
-
77
- // Bind the callback. A reference to the callback is stored for ease of
78
- // unbinding.
79
- currentMsgCallback = setMessageCallback(function(e) {
80
- switch(Object.prototype.toString.call(sourceOrigin)) {
81
- case '[object String]':
82
- if (sourceOrigin !== e.origin) {
83
- return false;
84
- }
85
- break;
86
- case '[object Function]':
87
- if (sourceOrigin(e.origin)) {
88
- return false;
89
- }
90
- break;
91
- }
92
-
93
- callback(e);
94
- });
95
- };
96
-
97
- } else {
98
-
99
- this[postBinding] = function(message, targetUrl, target) {
100
- if (!targetUrl) {
101
- return;
102
- }
103
-
104
- // The browser does not support window.postMessage, so set the location
105
- // of the target to targetUrl#message. A bit ugly, but it works! A cache
106
- // bust parameter is added to ensure that repeat messages trigger the
107
- // callback.
108
- target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
109
- }
110
-
111
- // Since the browser sucks, a polling loop will be started, and the
112
- // callback will be called whenever the location.hash changes.
113
- this[receiveBinding] = function(callback, sourceOrigin, delay) {
114
- if (intervalId) {
115
- clearInterval(intervalId);
116
- intervalId = null;
117
- }
118
-
119
- if (callback) {
120
- delay = typeof sourceOrigin === 'number'
121
- ? sourceOrigin
122
- : typeof delay === 'number'
123
- ? delay
124
- : 100;
125
-
126
- intervalId = setInterval(function(){
127
- var hash = document.location.hash,
128
- re = /^#?\d+&/;
129
- if ( hash !== lastHash && re.test( hash ) ) {
130
- lastHash = hash;
131
- callback({ data: hash.replace( re, '' ) });
132
- }
133
- }, delay );
134
- }
135
- };
136
-
137
- }
138
-
139
- return this;
140
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/js/nojquery.ba-postmessage.min.js DELETED
@@ -1,12 +0,0 @@
1
- /*
2
- * nojquery-postmessage by Jeff Lee
3
- * a non-jQuery fork of:
4
- *
5
- * jQuery postMessage - v0.5 - 9/11/2009
6
- * http://benalman.com/projects/jquery-postmessage-plugin/
7
- *
8
- * Copyright (c) 2009 "Cowboy" Ben Alman
9
- * Dual licensed under the MIT and GPL licenses.
10
- * http://benalman.com/about/license/
11
- */
12
- function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/js/postmessage.js DELETED
@@ -1,135 +0,0 @@
1
- (function ($, undef) {
2
- var global = this;
3
-
4
- // Namespace.
5
- global.FS = global.FS || {};
6
-
7
- global.FS.PostMessage = function ()
8
- {
9
- var
10
- _is_child = false,
11
- _postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
12
- _callbacks = {},
13
- _base_url,
14
- _parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
15
- _parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
16
- _init = function () {
17
- _postman.receiveMessage(function (e) {
18
- var data = JSON.parse(e.data);
19
-
20
- if (_callbacks[data.type]) {
21
- for (var i = 0; i < _callbacks[data.type].length; i++) {
22
- // Execute type callbacks.
23
- _callbacks[data.type][i](data.data);
24
- }
25
- }
26
- }, _base_url);
27
- },
28
- _hasParent = ('' !== _parent_url),
29
- $window = $(window),
30
- $html = $('html');
31
-
32
- return {
33
- init : function (url, iframes)
34
- {
35
- _base_url = url;
36
- _init();
37
-
38
- // Automatically receive forward messages.
39
- FS.PostMessage.receiveOnce('forward', function (data){
40
- window.location = data.url;
41
- });
42
-
43
- iframes = iframes || [];
44
-
45
- if (iframes.length > 0) {
46
- $window.on('scroll', function () {
47
- for (var i = 0; i < iframes.length; i++) {
48
- FS.PostMessage.postScroll(iframes[i]);
49
- }
50
- });
51
- }
52
- },
53
- init_child : function ()
54
- {
55
- this.init(_parent_subdomain);
56
-
57
- _is_child = true;
58
-
59
- // Post height of a child right after window is loaded.
60
- $(window).bind('load', function () {
61
- FS.PostMessage.postHeight();
62
-
63
- // Post message that window was loaded.
64
- FS.PostMessage.post('loaded');
65
- });
66
- },
67
- hasParent : function ()
68
- {
69
- return _hasParent;
70
- },
71
- postHeight : function (diff, wrapper) {
72
- diff = diff || 0;
73
- wrapper = wrapper || '#wrap_section';
74
- this.post('height', {
75
- height: diff + $(wrapper).outerHeight(true)
76
- });
77
- },
78
- postScroll : function (iframe) {
79
- this.post('scroll', {
80
- top: $window.scrollTop(),
81
- height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
82
- }, iframe);
83
- },
84
- post : function (type, data, iframe)
85
- {
86
- console.debug('PostMessage.post', type);
87
-
88
- if (iframe)
89
- {
90
- // Post to iframe.
91
- _postman.postMessage(JSON.stringify({
92
- type: type,
93
- data: data
94
- }), iframe.src, iframe.contentWindow);
95
- }
96
- else {
97
- // Post to parent.
98
- _postman.postMessage(JSON.stringify({
99
- type: type,
100
- data: data
101
- }), _parent_url, window.parent);
102
- }
103
- },
104
- receive: function (type, callback)
105
- {
106
- console.debug('PostMessage.receive', type);
107
-
108
- if (undef === _callbacks[type])
109
- _callbacks[type] = [];
110
-
111
- _callbacks[type].push(callback);
112
- },
113
- receiveOnce: function (type, callback)
114
- {
115
- if (this.is_set(type))
116
- return;
117
-
118
- this.receive(type, callback);
119
- },
120
- // Check if any callbacks assigned to a specified message type.
121
- is_set: function (type)
122
- {
123
- return (undef != _callbacks[type]);
124
- },
125
- parent_url: function ()
126
- {
127
- return _parent_url;
128
- },
129
- parent_subdomain: function ()
130
- {
131
- return _parent_subdomain;
132
- }
133
- };
134
- }();
135
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/config.php DELETED
@@ -1,391 +0,0 @@
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
- if ( ! defined( 'WP_FS__SLUG' ) ) {
14
- define( 'WP_FS__SLUG', 'freemius' );
15
- }
16
- if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
17
- define( 'WP_FS__DEV_MODE', false );
18
- }
19
-
20
- #--------------------------------------------------------------------------------
21
- #region API Connectivity Issues Simulation
22
- #--------------------------------------------------------------------------------
23
-
24
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
25
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
26
- }
27
- if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
28
- define( 'WP_FS__SIMULATE_NO_CURL', false );
29
- }
30
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
31
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
32
- }
33
- if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
34
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
35
- }
36
- if ( WP_FS__SIMULATE_NO_CURL ) {
37
- define( 'FS_SDK__SIMULATE_NO_CURL', true );
38
- }
39
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
40
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
41
- }
42
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
43
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
44
- }
45
-
46
- #endregion
47
-
48
- if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
49
- define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
50
- }
51
-
52
- if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
53
- /**
54
- * @since 1.1.7.3
55
- * @author Vova Feldman (@svovaf)
56
- *
57
- * I'm not sure if shared servers periodically change IP, or the subdomain of the
58
- * admin dashboard. Also, I've seen sites that have strange loop of switching
59
- * between domains on a daily basis. Therefore, to eliminate the risk of
60
- * multiple unwanted connectivity test pings, temporary ignore domain or
61
- * server IP changes.
62
- */
63
- define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
64
- }
65
-
66
- /**
67
- * If your dev environment supports custom public network IP setup
68
- * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
69
- * and uncomment it during dev.
70
- */
71
- if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
72
- // VVV default public network IP.
73
- define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
74
-
75
- // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
76
- }
77
-
78
- /**
79
- * If true and running with secret key, the opt-in process
80
- * will skip the email activation process which is invoked
81
- * when the email of the context user already exist in Freemius
82
- * database (as a security precaution, to prevent sharing user
83
- * secret with unauthorized entity).
84
- *
85
- * IMPORTANT:
86
- * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
87
- * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
88
- * CLOCK IS SYNCED.
89
- */
90
- if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
91
- define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
92
- }
93
-
94
-
95
- #--------------------------------------------------------------------------------
96
- #region Directories
97
- #--------------------------------------------------------------------------------
98
-
99
- if ( ! defined( 'WP_FS__DIR' ) ) {
100
- define( 'WP_FS__DIR', dirname( __FILE__ ) );
101
- }
102
- if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
103
- define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
104
- }
105
- if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
106
- define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
107
- }
108
- if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
109
- define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
110
- }
111
- if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
112
- define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
113
- }
114
- if ( ! defined( 'WP_FS__DIR_JS' ) ) {
115
- define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
116
- }
117
- if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
118
- define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
119
- }
120
- if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
121
- define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
122
- }
123
-
124
- #endregion
125
-
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
-
133
- if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
134
- define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
135
- }
136
- if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
137
- define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
138
- }
139
-
140
- if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
141
- define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
142
- }
143
-
144
- #--------------------------------------------------------------------------------
145
- #region HTTP
146
- #--------------------------------------------------------------------------------
147
-
148
- if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
149
- define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
150
- }
151
-
152
- if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
153
- define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
154
- // Checks if CloudFlare's HTTPS (Flexible SSL support).
155
- isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
156
- 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
157
- ) ||
158
- // Check if HTTPS request.
159
- ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
160
- ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
161
- );
162
- }
163
-
164
- if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
165
- define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
166
- strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
167
- }
168
-
169
- if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
170
- define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
171
- }
172
-
173
- if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
174
- if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
175
- define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
176
- } else {
177
- define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
178
- is_string( WP_FS__REMOTE_ADDR ) &&
179
- ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
180
- WP_FS__REMOTE_ADDR === '::1' )
181
- );
182
- }
183
- }
184
-
185
- if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
186
- define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
187
- false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
188
- }
189
-
190
- #endregion
191
-
192
- if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
193
- // By default, run with Freemius production servers.
194
- define( 'WP_FS__IS_PRODUCTION_MODE', true );
195
- }
196
-
197
- if ( ! defined( 'WP_FS__ADDRESS' ) ) {
198
- define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
199
- }
200
-
201
-
202
- #--------------------------------------------------------------------------------
203
- #region API
204
- #--------------------------------------------------------------------------------
205
-
206
- if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
207
- define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius-local.com:8080' );
208
- }
209
- if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
210
- define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
211
- }
212
-
213
- // Set API address for local testing.
214
- if ( ! WP_FS__IS_PRODUCTION_MODE ) {
215
- if ( ! defined( 'FS_API__ADDRESS' ) ) {
216
- define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
217
- }
218
- if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
219
- define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
220
- }
221
- }
222
-
223
- #endregion
224
-
225
- #--------------------------------------------------------------------------------
226
- #region Checkout
227
- #--------------------------------------------------------------------------------
228
-
229
- if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
230
- define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
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' ) ) {
238
- define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
239
- }
240
-
241
- #endregion
242
-
243
- define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
244
-
245
- if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
246
- define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
247
- }
248
- if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
249
- define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
250
- }
251
- if ( ! defined( 'WP_FS__GDPR_OPTION_NAME' ) ) {
252
- define( 'WP_FS__GDPR_OPTION_NAME', WP_FS___OPTION_PREFIX . 'gdpr' );
253
- }
254
- define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
255
-
256
- /**
257
- * Module types
258
- *
259
- * @since 1.2.2
260
- */
261
- define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
262
- define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
263
-
264
- /**
265
- * Billing Frequencies
266
- */
267
- define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
268
- define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
269
- define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
270
-
271
- /**
272
- * Plans
273
- */
274
- define( 'WP_FS__PLAN_DEFAULT_PAID', false );
275
- define( 'WP_FS__PLAN_FREE', 'free' );
276
- define( 'WP_FS__PLAN_TRIAL', 'trial' );
277
-
278
- /**
279
- * Times in seconds
280
- */
281
- if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
282
- define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
283
- }
284
- if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
285
- define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
286
- }
287
- // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
288
- if ( ! defined( 'WP_FS__TIME_12_HOURS_IN_SEC' ) ) {
289
- define( 'WP_FS__TIME_12_HOURS_IN_SEC', 43200 );
290
- }
291
- if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
292
- define( 'WP_FS__TIME_24_HOURS_IN_SEC', WP_FS__TIME_12_HOURS_IN_SEC * 2 );
293
- }
294
- if ( ! defined( 'WP_FS__TIME_WEEK_IN_SEC' ) ) {
295
- define( 'WP_FS__TIME_WEEK_IN_SEC', 7 * WP_FS__TIME_24_HOURS_IN_SEC );
296
- }
297
-
298
- #--------------------------------------------------------------------------------
299
- #region Debugging
300
- #--------------------------------------------------------------------------------
301
-
302
- if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
303
- $debug_mode = get_option( 'fs_debug_mode', null );
304
-
305
- if ( $debug_mode === null ) {
306
- $debug_mode = false;
307
- add_option( 'fs_debug_mode', $debug_mode );
308
- }
309
-
310
- define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
311
- }
312
-
313
- if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
314
- define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
315
- }
316
- if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
317
- define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
318
- }
319
- if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
320
- define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
321
- }
322
-
323
- if ( WP_FS__ECHO_DEBUG_SDK ) {
324
- error_reporting( E_ALL );
325
- }
326
-
327
- #endregion
328
-
329
- if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
330
- define( 'WP_FS__SCRIPT_START_TIME', time() );
331
- }
332
- if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
333
- define( 'WP_FS__DEFAULT_PRIORITY', 10 );
334
- }
335
- if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
336
- define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
337
- }
338
-
339
- #--------------------------------------------------------------------------------
340
- #region Multisite Network
341
- #--------------------------------------------------------------------------------
342
-
343
- /**
344
- * Do not use this define directly, it will have the wrong value
345
- * during plugin uninstall/deletion when the inclusion of the plugin
346
- * is triggered due to registration with register_uninstall_hook().
347
- *
348
- * Instead, use fs_is_network_admin().
349
- *
350
- * @author Vova Feldman (@svovaf)
351
- */
352
- if ( ! defined( 'WP_FS__IS_NETWORK_ADMIN' ) ) {
353
- define( 'WP_FS__IS_NETWORK_ADMIN',
354
- is_multisite() &&
355
- ( is_network_admin() ||
356
- ( ( defined( 'DOING_AJAX' ) && DOING_AJAX &&
357
- ( isset( $_REQUEST['_fs_network_admin'] ) && 'true' === $_REQUEST['_fs_network_admin'] /*||
358
- ( ! empty( $_REQUEST['action'] ) && 'delete-plugin' === $_REQUEST['action'] )*/ )
359
- ) ||
360
- // Plugin uninstall.
361
- defined( 'WP_UNINSTALL_PLUGIN' ) )
362
- )
363
- );
364
- }
365
-
366
- /**
367
- * Do not use this define directly, it will have the wrong value
368
- * during plugin uninstall/deletion when the inclusion of the plugin
369
- * is triggered due to registration with register_uninstall_hook().
370
- *
371
- * Instead, use fs_is_blog_admin().
372
- *
373
- * @author Vova Feldman (@svovaf)
374
- */
375
- if ( ! defined( 'WP_FS__IS_BLOG_ADMIN' ) ) {
376
- define( 'WP_FS__IS_BLOG_ADMIN', is_blog_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX && isset( $_REQUEST['_fs_blog_admin'] ) ) );
377
- }
378
-
379
- if ( ! defined( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED' ) ) {
380
- // Set to true to show network level settings even if delegated to site admins.
381
- define( 'WP_FS__SHOW_NETWORK_EVEN_WHEN_DELEGATED', false );
382
- }
383
-
384
- #endregion
385
-
386
- if ( ! defined( 'WP_FS__DEMO_MODE' ) ) {
387
- define( 'WP_FS__DEMO_MODE', false );
388
- }
389
- if ( ! defined( 'FS_SDK__SSLVERIFY' ) ) {
390
- define( 'FS_SDK__SSLVERIFY', false );
391
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-freemius-abstract.php DELETED
@@ -1,597 +0,0 @@
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.7
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
-
14
- /**
15
- * - Each instance of Freemius class represents a single plugin
16
- * install by a single user (the installer of the plugin).
17
- *
18
- * - Each website can only have one install of the same plugin.
19
- *
20
- * - Install entity is only created after a user connects his account with Freemius.
21
- *
22
- * Class Freemius_Abstract
23
- */
24
- abstract class Freemius_Abstract {
25
-
26
- #----------------------------------------------------------------------------------
27
- #region Identity
28
- #----------------------------------------------------------------------------------
29
-
30
- /**
31
- * Check if user has connected his account (opted-in).
32
- *
33
- * Note:
34
- * If the user opted-in and opted-out on a later stage,
35
- * this will still return true. If you want to check if the
36
- * user is currently opted-in, use:
37
- * `$fs->is_registered() && $fs->is_tracking_allowed()`
38
- *
39
- * @since 1.0.1
40
- * @return bool
41
- */
42
- abstract function is_registered();
43
-
44
- /**
45
- * Check if the user skipped connecting the account with Freemius.
46
- *
47
- * @since 1.0.7
48
- *
49
- * @return bool
50
- */
51
- abstract function is_anonymous();
52
-
53
- /**
54
- * Check if the user currently in activation mode.
55
- *
56
- * @since 1.0.7
57
- *
58
- * @return bool
59
- */
60
- abstract function is_activation_mode();
61
-
62
- #endregion
63
-
64
- #----------------------------------------------------------------------------------
65
- #region Usage Tracking
66
- #----------------------------------------------------------------------------------
67
-
68
- /**
69
- * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
70
- *
71
- * @author Leo Fajardo (@leorw)
72
- * @since 1.2.1.5
73
- *
74
- * @return bool
75
- */
76
- abstract function is_tracking_allowed();
77
-
78
- /**
79
- * Returns TRUE if the user never opted-in or manually opted-out.
80
- *
81
- * @author Vova Feldman (@svovaf)
82
- * @since 1.2.1.5
83
- *
84
- * @return bool
85
- */
86
- function is_tracking_prohibited() {
87
- return ! $this->is_registered() || ! $this->is_tracking_allowed();
88
- }
89
-
90
- /**
91
- * Opt-out from usage tracking.
92
- *
93
- * Note: This will not delete the account information but will stop all tracking.
94
- *
95
- * Returns:
96
- * 1. FALSE - If the user never opted-in.
97
- * 2. TRUE - If successfully opted-out.
98
- * 3. object - API Result on failure.
99
- *
100
- * @author Leo Fajardo (@leorw)
101
- * @since 1.2.1.5
102
- *
103
- * @return bool|object
104
- */
105
- abstract function stop_tracking();
106
-
107
- /**
108
- * Opt-in back into usage tracking.
109
- *
110
- * Note: This will only work if the user opted-in previously.
111
- *
112
- * Returns:
113
- * 1. FALSE - If the user never opted-in.
114
- * 2. TRUE - If successfully opted-in back to usage tracking.
115
- * 3. object - API result on failure.
116
- *
117
- * @author Leo Fajardo (@leorw)
118
- * @since 1.2.1.5
119
- *
120
- * @return bool|object
121
- */
122
- abstract function allow_tracking();
123
-
124
- #endregion
125
-
126
- #----------------------------------------------------------------------------------
127
- #region Module Type
128
- #----------------------------------------------------------------------------------
129
-
130
- /**
131
- * Checks if the plugin's type is "plugin". The other type is "theme".
132
- *
133
- * @author Leo Fajardo (@leorw)
134
- * @since 1.2.2
135
- *
136
- * @return bool
137
- */
138
- abstract function is_plugin();
139
-
140
- /**
141
- * Checks if the module type is "theme". The other type is "plugin".
142
- *
143
- * @author Leo Fajardo (@leorw)
144
- * @since 1.2.2
145
- *
146
- * @return bool
147
- */
148
- function is_theme() {
149
- return ( ! $this->is_plugin() );
150
- }
151
-
152
- #endregion
153
-
154
- #----------------------------------------------------------------------------------
155
- #region Permissions
156
- #----------------------------------------------------------------------------------
157
-
158
- /**
159
- * Check if plugin must be WordPress.org compliant.
160
- *
161
- * @since 1.0.7
162
- *
163
- * @return bool
164
- */
165
- abstract function is_org_repo_compliant();
166
-
167
- /**
168
- * Check if plugin is allowed to install executable files.
169
- *
170
- * @author Vova Feldman (@svovaf)
171
- * @since 1.0.5
172
- *
173
- * @return bool
174
- */
175
- function is_allowed_to_install() {
176
- return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
177
- }
178
-
179
- #endregion
180
-
181
- /**
182
- * Check if user in trial or in free plan (not paying).
183
- *
184
- * @author Vova Feldman (@svovaf)
185
- * @since 1.0.4
186
- *
187
- * @return bool
188
- */
189
- function is_not_paying() {
190
- return ( $this->is_trial() || $this->is_free_plan() );
191
- }
192
-
193
- /**
194
- * Check if the user has an activated and valid paid license on current plugin's install.
195
- *
196
- * @since 1.0.9
197
- *
198
- * @return bool
199
- */
200
- abstract function is_paying();
201
-
202
- /**
203
- * Check if the user is paying or in trial.
204
- *
205
- * @since 1.0.9
206
- *
207
- * @return bool
208
- */
209
- function is_paying_or_trial() {
210
- return ( $this->is_paying() || $this->is_trial() );
211
- }
212
-
213
- /**
214
- * Check if user in a trial or have feature enabled license.
215
- *
216
- * @author Vova Feldman (@svovaf)
217
- * @since 1.1.7
218
- *
219
- * @return bool
220
- */
221
- abstract function can_use_premium_code();
222
-
223
- #----------------------------------------------------------------------------------
224
- #region Premium Only
225
- #----------------------------------------------------------------------------------
226
-
227
- /**
228
- * All logic wrapped in methods with "__premium_only()" suffix will be only
229
- * included in the premium code.
230
- *
231
- * Example:
232
- * if ( freemius()->is__premium_only() ) {
233
- * ...
234
- * }
235
- */
236
-
237
- /**
238
- * Returns true when running premium plugin code.
239
- *
240
- * @since 1.0.9
241
- *
242
- * @return bool
243
- */
244
- function is__premium_only() {
245
- return $this->is_premium();
246
- }
247
-
248
- /**
249
- * Check if the user has an activated and valid paid license on current plugin's install.
250
- *
251
- * @since 1.0.9
252
- *
253
- * @return bool
254
- *
255
- */
256
- function is_paying__premium_only() {
257
- return ( $this->is__premium_only() && $this->is_paying() );
258
- }
259
-
260
- /**
261
- * All code wrapped in this statement will be only included in the premium code.
262
- *
263
- * @since 1.0.9
264
- *
265
- * @param string $plan Plan name.
266
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
267
- *
268
- * @return bool
269
- */
270
- function is_plan__premium_only( $plan, $exact = false ) {
271
- return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
272
- }
273
-
274
- /**
275
- * Check if plan matches active license' plan or active trial license' plan.
276
- *
277
- * All code wrapped in this statement will be only included in the premium code.
278
- *
279
- * @since 1.0.9
280
- *
281
- * @param string $plan Plan name.
282
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
283
- *
284
- * @return bool
285
- */
286
- function is_plan_or_trial__premium_only( $plan, $exact = false ) {
287
- return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
288
- }
289
-
290
- /**
291
- * Check if the user is paying or in trial.
292
- *
293
- * All code wrapped in this statement will be only included in the premium code.
294
- *
295
- * @since 1.0.9
296
- *
297
- * @return bool
298
- */
299
- function is_paying_or_trial__premium_only() {
300
- return $this->is_premium() && $this->is_paying_or_trial();
301
- }
302
-
303
- /**
304
- * Check if the user has an activated and valid paid license on current plugin's install.
305
- *
306
- * @since 1.0.4
307
- *
308
- * @return bool
309
- *
310
- * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
311
- * @using Alias to is_paying__premium_only()
312
- */
313
- function is_paying__fs__() {
314
- return $this->is_paying__premium_only();
315
- }
316
-
317
- /**
318
- * Check if user in a trial or have feature enabled license.
319
- *
320
- * All code wrapped in this statement will be only included in the premium code.
321
- *
322
- * @author Vova Feldman (@svovaf)
323
- * @since 1.1.9
324
- *
325
- * @return bool
326
- */
327
- function can_use_premium_code__premium_only() {
328
- return $this->is_premium() && $this->can_use_premium_code();
329
- }
330
-
331
- #endregion
332
-
333
- #----------------------------------------------------------------------------------
334
- #region Trial
335
- #----------------------------------------------------------------------------------
336
-
337
- /**
338
- * Check if the user in a trial.
339
- *
340
- * @since 1.0.3
341
- *
342
- * @return bool
343
- */
344
- abstract function is_trial();
345
-
346
- /**
347
- * Check if trial already utilized.
348
- *
349
- * @since 1.0.9
350
- *
351
- * @return bool
352
- */
353
- abstract function is_trial_utilized();
354
-
355
- #endregion
356
-
357
- #----------------------------------------------------------------------------------
358
- #region Plans
359
- #----------------------------------------------------------------------------------
360
-
361
- /**
362
- * Check if the user is on the free plan of the product.
363
- *
364
- * @since 1.0.4
365
- *
366
- * @return bool
367
- */
368
- abstract function is_free_plan();
369
-
370
- /**
371
- * @since 1.0.2
372
- *
373
- * @param string $plan Plan name.
374
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
375
- *
376
- * @return bool
377
- */
378
- abstract function is_plan( $plan, $exact = false );
379
-
380
- /**
381
- * Check if plan based on trial. If not in trial mode, should return false.
382
- *
383
- * @since 1.0.9
384
- *
385
- * @param string $plan Plan name.
386
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
387
- *
388
- * @return bool
389
- */
390
- abstract function is_trial_plan( $plan, $exact = false );
391
-
392
- /**
393
- * Check if plan matches active license' plan or active trial license' plan.
394
- *
395
- * @since 1.0.9
396
- *
397
- * @param string $plan Plan name.
398
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
399
- *
400
- * @return bool
401
- */
402
- function is_plan_or_trial( $plan, $exact = false ) {
403
- return $this->is_plan( $plan, $exact ) ||
404
- $this->is_trial_plan( $plan, $exact );
405
- }
406
-
407
- /**
408
- * Check if plugin has any paid plans.
409
- *
410
- * @author Vova Feldman (@svovaf)
411
- * @since 1.0.7
412
- *
413
- * @return bool
414
- */
415
- abstract function has_paid_plan();
416
-
417
- /**
418
- * Check if plugin has any free plan, or is it premium only.
419
- *
420
- * Note: If no plans configured, assume plugin is free.
421
- *
422
- * @author Vova Feldman (@svovaf)
423
- * @since 1.0.7
424
- *
425
- * @return bool
426
- */
427
- abstract function has_free_plan();
428
-
429
- /**
430
- * Check if plugin is premium only (no free plans).
431
- *
432
- * NOTE: is__premium_only() is very different method, don't get confused.
433
- *
434
- * @author Vova Feldman (@svovaf)
435
- * @since 1.1.9
436
- *
437
- * @return bool
438
- */
439
- abstract function is_only_premium();
440
-
441
- /**
442
- * Check if module has a premium code version.
443
- *
444
- * Serviceware module might be freemium without any
445
- * premium code version, where the paid features
446
- * are all part of the service.
447
- *
448
- * @author Vova Feldman (@svovaf)
449
- * @since 1.2.1.6
450
- *
451
- * @return bool
452
- */
453
- abstract function has_premium_version();
454
-
455
- /**
456
- * Check if module has any release on Freemius,
457
- * or all plugin's code is on WordPress.org (Serviceware).
458
- *
459
- * @return bool
460
- */
461
- function has_release_on_freemius() {
462
- return ! $this->is_org_repo_compliant() ||
463
- $this->has_premium_version();
464
- }
465
-
466
- /**
467
- * Checks if it's a freemium plugin.
468
- *
469
- * @author Vova Feldman (@svovaf)
470
- * @since 1.1.9
471
- *
472
- * @return bool
473
- */
474
- function is_freemium() {
475
- return $this->has_paid_plan() &&
476
- $this->has_free_plan();
477
- }
478
-
479
- /**
480
- * Check if module has only one plan.
481
- *
482
- * @author Vova Feldman (@svovaf)
483
- * @since 1.2.1.7
484
- *
485
- * @return bool
486
- */
487
- abstract function is_single_plan();
488
-
489
- #endregion
490
-
491
- /**
492
- * Check if running payments in sandbox mode.
493
- *
494
- * @since 1.0.4
495
- *
496
- * @return bool
497
- */
498
- abstract function is_payments_sandbox();
499
-
500
- /**
501
- * Check if running test vs. live plugin.
502
- *
503
- * @since 1.0.5
504
- *
505
- * @return bool
506
- */
507
- abstract function is_live();
508
-
509
- /**
510
- * Check if running premium plugin code.
511
- *
512
- * @since 1.0.5
513
- *
514
- * @return bool
515
- */
516
- abstract function is_premium();
517
-
518
- /**
519
- * Get upgrade URL.
520
- *
521
- * @author Vova Feldman (@svovaf)
522
- * @since 1.0.2
523
- *
524
- * @param string $period Billing cycle.
525
- *
526
- * @return string
527
- */
528
- abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
529
-
530
- /**
531
- * Check if Freemius was first added in a plugin update.
532
- *
533
- * @author Vova Feldman (@svovaf)
534
- * @since 1.1.5
535
- *
536
- * @return bool
537
- */
538
- function is_plugin_update() {
539
- return ! $this->is_plugin_new_install();
540
- }
541
-
542
- /**
543
- * Check if Freemius was part of the plugin when the user installed it first.
544
- *
545
- * @author Vova Feldman (@svovaf)
546
- * @since 1.1.5
547
- *
548
- * @return bool
549
- */
550
- abstract function is_plugin_new_install();
551
-
552
- #----------------------------------------------------------------------------------
553
- #region Marketing
554
- #----------------------------------------------------------------------------------
555
-
556
- /**
557
- * Check if current user purchased any other plugins before.
558
- *
559
- * @author Vova Feldman (@svovaf)
560
- * @since 1.0.9
561
- *
562
- * @return bool
563
- */
564
- abstract function has_purchased_before();
565
-
566
- /**
567
- * Check if current user classified as an agency.
568
- *
569
- * @author Vova Feldman (@svovaf)
570
- * @since 1.0.9
571
- *
572
- * @return bool
573
- */
574
- abstract function is_agency();
575
-
576
- /**
577
- * Check if current user classified as a developer.
578
- *
579
- * @author Vova Feldman (@svovaf)
580
- * @since 1.0.9
581
- *
582
- * @return bool
583
- */
584
- abstract function is_developer();
585
-
586
- /**
587
- * Check if current user classified as a business.
588
- *
589
- * @author Vova Feldman (@svovaf)
590
- * @since 1.0.9
591
- *
592
- * @return bool
593
- */
594
- abstract function is_business();
595
-
596
- #endregion
597
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-freemius.php DELETED
@@ -1,26243 +0,0 @@
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 2.2.1
38
- *
39
- * @var string
40
- */
41
- private $_premium_plugin_basename;
42
- /**
43
- * @since 1.0.0
44
- *
45
- * @var string
46
- */
47
- private $_free_plugin_basename;
48
- /**
49
- * @since 1.0.0
50
- *
51
- * @var string
52
- */
53
- private $_plugin_dir_path;
54
- /**
55
- * @since 1.0.0
56
- *
57
- * @var string
58
- */
59
- private $_plugin_dir_name;
60
- /**
61
- * @since 1.0.0
62
- *
63
- * @var string
64
- */
65
- private $_plugin_main_file_path;
66
- /**
67
- * @var string[]
68
- */
69
- private $_plugin_data;
70
- /**
71
- * @since 1.0.9
72
- *
73
- * @var string
74
- */
75
- private $_plugin_name;
76
- /**
77
- * @since 1.2.2
78
- *
79
- * @var string
80
- */
81
- private $_module_type;
82
-
83
- #endregion Plugin Info
84
-
85
- /**
86
- * @since 1.0.9
87
- *
88
- * @var bool If false, don't turn Freemius on.
89
- */
90
- private $_is_on;
91
-
92
- /**
93
- * @since 1.1.3
94
- *
95
- * @var bool If false, don't turn Freemius on.
96
- */
97
- private $_is_anonymous;
98
-
99
- /**
100
- * @since 1.0.9
101
- * @var bool If false, issues with connectivity to Freemius API.
102
- */
103
- private $_has_api_connection;
104
-
105
- /**
106
- * @since 1.0.9
107
- * @since 2.0.0 Default to true since we need the property during the instance construction, prior to the dynamic_init() execution.
108
- * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
109
- */
110
- private $_enable_anonymous = true;
111
-
112
- /**
113
- * @since 1.1.7.5
114
- * @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
115
- */
116
- private $_anonymous_mode;
117
-
118
- /**
119
- * @since 1.1.9
120
- * @var bool Hints the SDK if plugin have any free plans.
121
- */
122
- private $_is_premium_only;
123
-
124
- /**
125
- * @since 1.2.1.6
126
- * @var bool Hints the SDK if plugin have premium code version at all.
127
- */
128
- private $_has_premium_version;
129
-
130
- /**
131
- * @since 1.2.1.6
132
- * @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
133
- */
134
- private $_ignore_pending_mode;
135
-
136
- /**
137
- * @since 1.0.8
138
- * @var bool Hints the SDK if the plugin has any paid plans.
139
- */
140
- private $_has_paid_plans;
141
-
142
- /**
143
- * @since 1.2.1.5
144
- * @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
145
- * without a specified period, if positive - the number of trial days.
146
- */
147
- private $_trial_days = - 1;
148
-
149
- /**
150
- * @since 1.2.1.5
151
- * @var bool Hints the SDK if the trial requires a payment method or not.
152
- */
153
- private $_is_trial_require_payment = false;
154
-
155
- /**
156
- * @since 1.0.7
157
- * @var bool Hints the SDK if the plugin is WordPress.org compliant.
158
- */
159
- private $_is_org_compliant;
160
-
161
- /**
162
- * @since 1.0.7
163
- * @var bool Hints the SDK if the plugin is has add-ons.
164
- */
165
- private $_has_addons;
166
-
167
- /**
168
- * @since 2.4.5
169
- * @var string Navigation type: 'menu' or 'tabs'.
170
- */
171
- private $_navigation;
172
-
173
- const NAVIGATION_MENU = 'menu';
174
- const NAVIGATION_TABS = 'tabs';
175
-
176
- /**
177
- * @since 1.1.6
178
- * @var string[]bool.
179
- */
180
- private $_permissions;
181
-
182
- /**
183
- * @var FS_Storage
184
- */
185
- private $_storage;
186
-
187
- /**
188
- * @since 1.2.2.7
189
- * @var FS_Cache_Manager
190
- */
191
- private $_cache;
192
-
193
- /**
194
- * @since 1.0.0
195
- *
196
- * @var FS_Logger
197
- */
198
- private $_logger;
199
- /**
200
- * @since 1.0.4
201
- *
202
- * @var FS_Plugin
203
- */
204
- private $_plugin = false;
205
- /**
206
- * @since 1.0.4
207
- *
208
- * @var FS_Plugin|false
209
- */
210
- private $_parent_plugin = false;
211
- /**
212
- * @since 1.1.1
213
- *
214
- * @var Freemius
215
- */
216
- private $_parent = false;
217
- /**
218
- * @since 1.0.1
219
- *
220
- * @var FS_User
221
- */
222
- private $_user = false;
223
- /**
224
- * @since 1.0.1
225
- *
226
- * @var FS_Site
227
- */
228
- private $_site = false;
229
- /**
230
- * @since 1.0.1
231
- *
232
- * @var FS_Plugin_License
233
- */
234
- private $_license;
235
- /**
236
- * @since 1.0.2
237
- *
238
- * @var FS_Plugin_Plan[]
239
- */
240
- private $_plans = false;
241
- /**
242
- * @var FS_Plugin_License[]
243
- * @since 1.0.5
244
- */
245
- private $_licenses = false;
246
-
247
- /**
248
- * @since 1.0.1
249
- *
250
- * @var FS_Admin_Menu_Manager
251
- */
252
- private $_menu;
253
-
254
- /**
255
- * @var FS_Admin_Notices
256
- */
257
- private $_admin_notices;
258
-
259
- /**
260
- * @since 1.1.6
261
- *
262
- * @var FS_Admin_Notices
263
- */
264
- private static $_global_admin_notices;
265
-
266
- /**
267
- * @var FS_Logger
268
- * @since 1.0.0
269
- */
270
- private static $_static_logger;
271
-
272
- /**
273
- * @var FS_Options
274
- * @since 1.0.2
275
- */
276
- private static $_accounts;
277
-
278
- /**
279
- * @since 1.2.2
280
- *
281
- * @var number
282
- */
283
- private $_module_id;
284
-
285
- /**
286
- * @var Freemius[]
287
- */
288
- private static $_instances = array();
289
-
290
- /**
291
- * @since 1.2.3
292
- *
293
- * @var FS_Affiliate
294
- */
295
- private $affiliate = null;
296
-
297
- /**
298
- * @since 1.2.3
299
- *
300
- * @var FS_AffiliateTerms
301
- */
302
- private $plugin_affiliate_terms = null;
303
-
304
- /**
305
- * @since 1.2.3
306
- *
307
- * @var FS_AffiliateTerms
308
- */
309
- private $custom_affiliate_terms = null;
310
-
311
- /**
312
- * @since 2.0.0
313
- *
314
- * @var bool
315
- */
316
- private $_is_multisite_integrated;
317
-
318
- /**
319
- * @since 2.0.0
320
- *
321
- * @var bool True if the current request is for a network admin screen and the plugin is network active.
322
- */
323
- private $_is_network_active;
324
-
325
- /**
326
- * @since 2.0.0
327
- *
328
- * @var int|null The original blog ID the plugin was loaded with.
329
- */
330
- private $_blog_id = null;
331
-
332
- /**
333
- * @since 2.0.0
334
- *
335
- * @var int|null The current execution context. When true, run on network context. When int, run on the specified blog context.
336
- */
337
- private $_context_is_network_or_blog_id = null;
338
-
339
- /**
340
- * @since 2.0.0
341
- *
342
- * @var string
343
- */
344
- private $_dynamically_added_top_level_page_hook_name = '';
345
-
346
- /**
347
- * @author Leo Fajardo (@leorw)
348
- * @since 2.3.1
349
- *
350
- * @var bool
351
- */
352
- private $is_whitelabeled;
353
-
354
- /**
355
- * @author Leo Fajardo (@leorw)
356
- * @since 2.4.0
357
- *
358
- * @var bool
359
- */
360
- private $_is_bundle_license_auto_activation_enabled = false;
361
-
362
- #region Uninstall Reasons IDs
363
-
364
- const REASON_NO_LONGER_NEEDED = 1;
365
- const REASON_FOUND_A_BETTER_PLUGIN = 2;
366
- const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
367
- const REASON_BROKE_MY_SITE = 4;
368
- const REASON_SUDDENLY_STOPPED_WORKING = 5;
369
- const REASON_CANT_PAY_ANYMORE = 6;
370
- const REASON_OTHER = 7;
371
- const REASON_DIDNT_WORK = 8;
372
- const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
373
- const REASON_COULDNT_MAKE_IT_WORK = 10;
374
- const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
375
- const REASON_NOT_WORKING = 12;
376
- const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
377
- const REASON_DIDNT_WORK_AS_EXPECTED = 14;
378
- const REASON_TEMPORARY_DEACTIVATION = 15;
379
-
380
- /**
381
- * @author Leo Fajardo (@leorw)
382
- * @since 2.3.1
383
- *
384
- * @var boolean|null
385
- */
386
- private $_use_external_pricing = null;
387
- /**
388
- * @author Leo Fajardo (@leorw)
389
- * @since 2.4.2
390
- *
391
- * @var string|null
392
- */
393
- private $_pricing_js_path = null;
394
-
395
- #endregion
396
-
397
- /* Ctor
398
- ------------------------------------------------------------------------------------------------------------------*/
399
-
400
- /**
401
- * Main singleton instance.
402
- *
403
- * @author Vova Feldman (@svovaf)
404
- * @since 1.0.0
405
- *
406
- * @param number $module_id
407
- * @param string|bool $slug
408
- * @param bool $is_init Since 1.2.1 Is initiation sequence.
409
- */
410
- private function __construct( $module_id, $slug = false, $is_init = false ) {
411
- $main_file = false;
412
-
413
- if ( $is_init && is_numeric( $module_id ) && is_string( $slug ) ) {
414
- $main_file = $this->store_id_slug_type_path_map( $module_id, $slug );
415
- }
416
-
417
- $this->_module_id = $module_id;
418
- $this->_slug = $this->get_slug();
419
- $this->_module_type = $this->get_module_type();
420
-
421
- $this->_blog_id = is_multisite() ? get_current_blog_id() : null;
422
-
423
- $this->_storage = FS_Storage::instance( $this->_module_type, $this->_slug );
424
-
425
- $this->_cache = FS_Cache_Manager::get_manager( WP_FS___OPTION_PREFIX . "cache_{$module_id}" );
426
-
427
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $this->get_unique_affix(), WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
428
-
429
- $this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init, $main_file );
430
- $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
431
- $this->_plugin_basename = $this->get_plugin_basename();
432
- $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
433
-
434
- $this->_is_multisite_integrated = (
435
- defined( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) &&
436
- ( true === constant( "WP_FS__PRODUCT_{$module_id}_MULTISITE" ) )
437
- );
438
-
439
- $this->_is_network_active = (
440
- is_multisite() &&
441
- $this->_is_multisite_integrated &&
442
- // Themes are always network activated, but the ACTUAL activation is per site.
443
- $this->is_plugin() &&
444
- (
445
- is_plugin_active_for_network( $this->_plugin_basename ) ||
446
- // Plugin network level activation or uninstall.
447
- ( fs_is_network_admin() && is_plugin_inactive( $this->_plugin_basename ) )
448
- )
449
- );
450
-
451
- $this->_storage->set_network_active(
452
- $this->_is_network_active,
453
- $this->is_delegated_connection()
454
- );
455
-
456
- if ( ! isset( $this->_storage->is_network_activated ) ) {
457
- $this->_storage->is_network_activated = $this->_is_network_active;
458
- }
459
-
460
- if ( $this->_storage->is_network_activated != $this->_is_network_active ) {
461
- // Update last activation level.
462
- $this->_storage->is_network_activated = $this->_is_network_active;
463
-
464
- $this->maybe_adjust_storage();
465
- }
466
-
467
- #region Migration
468
-
469
- if ( is_multisite() ) {
470
- /**
471
- * If the install_timestamp exists on the site level but doesn't exist on the
472
- * network level storage, it means that we need to process the storage with migration.
473
- *
474
- * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, install_timestamp will be already set in the network level storage.
475
- *
476
- * @author Vova Feldman (@svovaf)
477
- * @since 2.0.0
478
- */
479
- if ( false === $this->_storage->get( 'install_timestamp', false, true ) &&
480
- false !== $this->_storage->get( 'install_timestamp', false, false )
481
- ) {
482
- // Initiate storage migration.
483
- $this->_storage->migrate_to_network();
484
-
485
- // Migrate module cache to network level storage.
486
- $this->_cache->migrate_to_network();
487
- }
488
- }
489
-
490
- #endregion
491
-
492
- $base_name_split = explode( '/', $this->_plugin_basename );
493
- $this->_plugin_dir_name = $base_name_split[0];
494
-
495
- if ( $this->_logger->is_on() ) {
496
- $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
497
- $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
498
- $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
499
- $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
500
- $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
501
- }
502
-
503
- // Remember link between file to slug.
504
- $this->store_file_slug_map();
505
-
506
- // Store plugin's initial install timestamp.
507
- if ( ! isset( $this->_storage->install_timestamp ) ) {
508
- $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
509
- }
510
-
511
- if ( ! is_object( $this->_plugin ) ) {
512
- $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->get();
513
- }
514
-
515
- $this->_admin_notices = FS_Admin_Notices::instance(
516
- $this->_slug . ( $this->is_theme() ? ':theme' : '' ),
517
- /**
518
- * Ensure that the admin notice will always have a title by using the stored plugin title if available and
519
- * retrieving the title via the "get_plugin_name" method if there is no stored plugin title available.
520
- *
521
- * @author Leo Fajardo (@leorw)
522
- * @since 1.2.2
523
- */
524
- ( is_object( $this->_plugin ) && isset( $this->_plugin->title ) ?
525
- $this->_plugin->title :
526
- $this->get_plugin_name()
527
- ),
528
- $this->get_unique_affix()
529
- );
530
-
531
- if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
532
- fs_request_is_action( 'restart_freemius' )
533
- ) {
534
- FS_Api::clear_cache();
535
- $this->_cache->clear();
536
- }
537
-
538
- $this->register_constructor_hooks();
539
-
540
- /**
541
- * Starting from version 2.0.0, `FS_Site` entities no longer have the `plan` property and have `plan_id`
542
- * instead. This should be called before calling `_load_account()`, otherwise, `$this->_site` will not be
543
- * loaded in `_load_account` for versions of SDK starting from 2.0.0.
544
- *
545
- * @author Leo Fajardo (@leorw)
546
- */
547
- self::migrate_install_plan_to_plan_id( $this->_storage );
548
-
549
- $this->_load_account();
550
-
551
- $this->_version_updates_handler();
552
- }
553
-
554
- /**
555
- * @author Leo Fajardo (@leorw)
556
- * @since 2.3.0
557
- */
558
- private function maybe_adjust_storage() {
559
- $install_timestamp = null;
560
- $prev_is_premium = null;
561
-
562
- $options_to_update = array();
563
-
564
- $is_network_admin = fs_is_network_admin();
565
-
566
- $network_install_timestamp = $this->_storage->get( 'install_timestamp', null, true );
567
-
568
- if ( ! $is_network_admin ) {
569
- if ( is_null( $network_install_timestamp ) ) {
570
- // Plugin was not network-activated before.
571
- return;
572
- }
573
-
574
- if ( is_null( $this->_storage->get( 'install_timestamp', null, false ) ) ) {
575
- // Set the `install_timestamp` only if it's not yet set.
576
- $install_timestamp = $network_install_timestamp;
577
- }
578
-
579
- $prev_is_premium = $this->_storage->get( 'prev_is_premium', null, true );
580
- } else {
581
- $current_wp_user = self::_get_current_wp_user();
582
- $current_fs_user = self::_get_user_by_email( $current_wp_user->user_email );
583
- $network_user_info = array();
584
-
585
- $skips_count = 0;
586
-
587
- $sites = self::get_sites();
588
- $sites_count = count( $sites );
589
-
590
- $blog_id_2_install_map = array();
591
-
592
- $is_first_non_ignored_blog = true;
593
-
594
- foreach ( $sites as $site ) {
595
- $blog_id = self::get_site_blog_id( $site );
596
-
597
- $blog_install_timestamp = $this->_storage->get( 'install_timestamp', null, $blog_id );
598
-
599
- if ( is_null( $blog_install_timestamp ) ) {
600
- // Plugin has not been installed on this blog.
601
- continue;
602
- }
603
-
604
- $is_earlier_install = (
605
- ! is_null( $install_timestamp ) &&
606
- $blog_install_timestamp < $install_timestamp
607
- );
608
-
609
- $install = $this->get_install_by_blog_id( $blog_id );
610
-
611
- $update_network_user_info = false;
612
-
613
- if ( ! is_object( $install ) ) {
614
- if ( ! $this->_storage->get( 'is_anonymous', false, $blog_id ) ) {
615
- // The opt-in decision (whether to skip or opt in) is yet to be made.
616
- continue;
617
- }
618
-
619
- $skips_count ++;
620
- } else {
621
- $blog_id_2_install_map[ $blog_id ] = $install;
622
-
623
- if ( empty( $network_user_info ) ) {
624
- // Set the network user info for the 1st time. Choose any user information whether or not it is for the current WP user.
625
- $update_network_user_info = true;
626
- }
627
-
628
- if ( ! $update_network_user_info &&
629
- is_object( $current_fs_user ) &&
630
- $network_user_info['user_id'] != $current_fs_user->id &&
631
- $install->user_id == $current_fs_user->id
632
- ) {
633
- // If an install that is owned by the current WP user is found, use its user information instead.
634
- $update_network_user_info = true;
635
- }
636
-
637
- if ( ! $update_network_user_info &&
638
- $is_earlier_install &&
639
- ( ! is_object( $current_fs_user ) || $current_fs_user->id == $install->user_id )
640
- ) {
641
- // Update to the earliest install info if there's no install found so far that is owned by the current WP user; OR only if the found install is owned by the current WP user.
642
- $update_network_user_info = true;
643
- }
644
- }
645
-
646
- if ( $update_network_user_info ) {
647
- $network_user_info = array(
648
- 'user_id' => $install->user_id,
649
- 'blog_id' => $blog_id
650
- );
651
- }
652
-
653
- $site_prev_is_premium = $this->_storage->get( 'prev_is_premium', null, $blog_id );
654
-
655
- if ( $is_first_non_ignored_blog ) {
656
- $prev_is_premium = $site_prev_is_premium;
657
-
658
- if ( is_null( $network_install_timestamp ) ) {
659
- $install_timestamp = $blog_install_timestamp;
660
- }
661
-
662
- $is_first_non_ignored_blog = false;
663
-
664
- continue;
665
- }
666
-
667
- if ( ! is_null( $prev_is_premium ) && $prev_is_premium !== $site_prev_is_premium ) {
668
- // If a different `$site_prev_is_premium` value is found, do not include the option in the collection of options to update.
669
- $prev_is_premium = null;
670
- }
671
-
672
- if ( $is_earlier_install ) {
673
- // If an earlier install timestamp is found.
674
- $install_timestamp = $blog_install_timestamp;
675
- }
676
- }
677
-
678
- $installs_count = count( $blog_id_2_install_map );
679
-
680
- if ( $sites_count === ( $installs_count + $skips_count ) ) {
681
- if ( ! empty( $network_user_info ) ) {
682
- $options_to_update['network_user_id'] = $network_user_info['user_id'];
683
- $options_to_update['network_install_blog_id'] = $network_user_info['blog_id'];
684
-
685
- foreach ( $blog_id_2_install_map as $blog_id => $install ) {
686
- if ( $install->user_id == $network_user_info['user_id'] ) {
687
- continue;
688
- }
689
-
690
- $this->_storage->store( 'is_delegated_connection', true, $blog_id );
691
- }
692
- }
693
-
694
- if ( $sites_count === $skips_count ) {
695
- /**
696
- * Assume network-level skipping as the intended action if all actions identified were only
697
- * skipping of the connection (i.e., no opt-ins and delegated connections so far).
698
- */
699
- $options_to_update['is_anonymous_ms'] = true;
700
- } else if ( $sites_count === $installs_count ) {
701
- /**
702
- * Assume network-level opt-in as the intended action if all actions identified were only opt-ins
703
- * (i.e., no delegation and skipping of the connections so far).
704
- */
705
- $options_to_update['is_network_connected'] = true;
706
- }
707
- }
708
- }
709
-
710
- if ( ! is_null( $install_timestamp ) ) {
711
- $options_to_update['install_timestamp'] = $install_timestamp;
712
- }
713
-
714
- if ( ! is_null( $prev_is_premium ) ) {
715
- $options_to_update['prev_is_premium'] = $prev_is_premium;
716
- }
717
-
718
- if ( ! empty( $options_to_update ) ) {
719
- $this->adjust_storage( $options_to_update, $is_network_admin );
720
- }
721
- }
722
-
723
- /**
724
- * @author Leo Fajardo (@leorw)
725
- * @since 2.3.0
726
- *
727
- * @param array $options
728
- * @param bool $is_network_admin
729
- */
730
- private function adjust_storage( $options, $is_network_admin ) {
731
- foreach ( $options as $name => $value ) {
732
- $this->_storage->store( $name, $value, $is_network_admin ? true : null );
733
- }
734
- }
735
-
736
- /**
737
- * Checks whether this module has a settings menu.
738
- *
739
- * @author Leo Fajardo (@leorw)
740
- * @since 1.2.2
741
- *
742
- * @return bool
743
- */
744
- function has_settings_menu() {
745
- return ( $this->_is_network_active && fs_is_network_admin() ) ?
746
- $this->_menu->has_network_menu() :
747
- $this->_menu->has_menu();
748
- }
749
-
750
- /**
751
- * If `true` the opt-in should be shown as a modal dialog box on the themes.php page. WordPress.org themes guidelines prohibit from redirecting the user from the themes.php page after activating a theme.
752
- *
753
- * @author Vova Feldman (@svovaf)
754
- * @since 2.4.5
755
- *
756
- * @return bool
757
- */
758
- function show_opt_in_on_themes_page() {
759
- if ( ! $this->is_free_wp_org_theme() ) {
760
- return false;
761
- }
762
-
763
- if ( ! $this->has_settings_menu() ) {
764
- return true;
765
- }
766
-
767
- return $this->show_settings_with_tabs();
768
- }
769
-
770
- /**
771
- * If `true` the opt-in should be shown on the product's main setting page.
772
- *
773
- * @author Vova Feldman (@svovaf)
774
- * @since 2.4.5
775
- *
776
- * @return bool
777
- *
778
- * @uses show_opt_in_on_themes_page();
779
- */
780
- function show_opt_in_on_setting_page() {
781
- return ! $this->show_opt_in_on_themes_page();
782
- }
783
-
784
- /**
785
- * If `true` the settings should be shown using tabs.
786
- *
787
- * @author Vova Feldman (@svovaf)
788
- * @since 2.4.5
789
- *
790
- * @return bool
791
- */
792
- function show_settings_with_tabs() {
793
- return ( self::NAVIGATION_TABS === $this->_navigation );
794
- }
795
-
796
- /**
797
- * Check if the context module is free wp.org theme.
798
- *
799
- * This method is helpful because:
800
- * 1. wp.org themes are limited to a single submenu item,
801
- * and sub-submenu items are most likely not allowed (never verified).
802
- * 2. wp.org themes are not allowed to redirect the user
803
- * after the theme activation, therefore, the agreed UX
804
- * is showing the opt-in as a modal dialog box after
805
- * activation (approved by @otto42, @emiluzelac, @greenshady, @grapplerulrich).
806
- *
807
- * @author Vova Feldman (@svovaf)
808
- * @since 1.2.2.7
809
- *
810
- * @return bool
811
- */
812
- function is_free_wp_org_theme() {
813
- return (
814
- $this->is_theme() &&
815
- $this->is_org_repo_compliant() &&
816
- ! $this->is_premium()
817
- );
818
- }
819
-
820
- /**
821
- * Checks whether this a submenu item is visible.
822
- *
823
- * @author Vova Feldman (@svovaf)
824
- * @since 1.2.2.6
825
- * @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.
826
- *
827
- * @param string $slug
828
- * @param bool $is_tabs_visibility_check This is used to decide if the associated tab should be shown or hidden.
829
- *
830
- * @return bool
831
- */
832
- function is_submenu_item_visible( $slug, $is_tabs_visibility_check = false ) {
833
- if ( $this->is_admin_page( $slug ) ) {
834
- /**
835
- * It is the current context page, so show the submenu item
836
- * so the user will have the right context page, even if it
837
- * was set to hidden.
838
- */
839
- return true;
840
- }
841
-
842
- if ( ! $this->has_settings_menu() ) {
843
- // No menu settings at all.
844
- return false;
845
- }
846
-
847
- if (
848
- ! $is_tabs_visibility_check &&
849
- $this->is_org_repo_compliant() &&
850
- $this->show_settings_with_tabs()
851
- ) {
852
- /**
853
- * wp.org themes are limited to a single submenu item, and
854
- * sub-submenu items are most likely not allowed (never verified).
855
- */
856
- return false;
857
- }
858
-
859
- return $this->_menu->is_submenu_item_visible( $slug );
860
- }
861
-
862
- /**
863
- * Check if a Freemius page should be accessible via the UI.
864
- *
865
- * @author Vova Feldman (@svovaf)
866
- * @since 1.2.2.7
867
- *
868
- * @param string $slug
869
- *
870
- * @return bool
871
- */
872
- function is_page_visible( $slug ) {
873
- if ( $this->is_admin_page( $slug ) ) {
874
- return true;
875
- }
876
-
877
- return $this->_menu->is_submenu_item_visible( $slug, true, true );
878
- }
879
-
880
- /**
881
- * @author Vova Feldman (@svovaf)
882
- * @since 1.0.9
883
- */
884
- private function _version_updates_handler() {
885
- if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
886
- // Freemius version upgrade mode.
887
- $this->_storage->sdk_last_version = $this->_storage->sdk_version;
888
- $this->_storage->sdk_version = $this->version;
889
-
890
- if ( empty( $this->_storage->sdk_last_version ) ||
891
- version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
892
- ) {
893
- $this->_storage->sdk_upgrade_mode = true;
894
- $this->_storage->sdk_downgrade_mode = false;
895
- } else {
896
- $this->_storage->sdk_downgrade_mode = true;
897
- $this->_storage->sdk_upgrade_mode = false;
898
-
899
- }
900
-
901
- $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
902
- }
903
-
904
- $plugin_version = $this->get_plugin_version();
905
- if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
906
- // Plugin version upgrade mode.
907
- $this->_storage->plugin_last_version = $this->_storage->plugin_version;
908
- $this->_storage->plugin_version = $plugin_version;
909
-
910
- if ( empty( $this->_storage->plugin_last_version ) ||
911
- version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
912
- ) {
913
- $this->_storage->plugin_upgrade_mode = true;
914
- $this->_storage->plugin_downgrade_mode = false;
915
- } else {
916
- $this->_storage->plugin_downgrade_mode = true;
917
- $this->_storage->plugin_upgrade_mode = false;
918
- }
919
-
920
- if ( ! empty( $this->_storage->plugin_last_version ) ) {
921
- // Different version of the plugin was installed before, therefore it's an update.
922
- $this->_storage->is_plugin_new_install = false;
923
- }
924
-
925
- $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
926
- }
927
- }
928
-
929
- #--------------------------------------------------------------------------------
930
- #region Data Migration on SDK Update
931
- #--------------------------------------------------------------------------------
932
-
933
- /**
934
- * @author Vova Feldman (@svovaf)
935
- * @since 1.1.5
936
- *
937
- * @param string $sdk_prev_version
938
- * @param string $sdk_version
939
- */
940
- function _sdk_version_update( $sdk_prev_version, $sdk_version ) {
941
- /**
942
- * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
943
- */
944
- if ( empty( $sdk_prev_version ) ) {
945
- return;
946
- }
947
-
948
- if ( version_compare( $sdk_prev_version, '2.1.0', '<' ) &&
949
- version_compare( $sdk_version, '2.1.0', '>=' )
950
- ) {
951
- $this->_storage->handle_gdpr_admin_notice = true;
952
- }
953
-
954
- if ( version_compare( $sdk_prev_version, '2.0.0', '<' ) &&
955
- version_compare( $sdk_version, '2.0.0', '>=' )
956
- ) {
957
- $this->migrate_to_subscriptions_collection();
958
-
959
- $this->consolidate_licenses();
960
-
961
- // Clear trial_plan since it's now loaded from the plans collection when needed.
962
- $this->_storage->remove( 'trial_plan', true, false );
963
- }
964
-
965
- if ( version_compare( $sdk_prev_version, '1.2.3', '<' ) &&
966
- version_compare( $sdk_version, '1.2.3', '>=' )
967
- ) {
968
- /**
969
- * Starting from version 1.2.3, paths are stored as relative instead of absolute and some of them can be
970
- * invalid.
971
- *
972
- * @author Leo Fajardo (@leorw)
973
- */
974
- $this->remove_invalid_paths();
975
- }
976
-
977
- if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
978
- version_compare( $sdk_version, '1.1.5', '>=' )
979
- ) {
980
- // On version 1.1.5 merged connectivity and is_on data.
981
- if ( isset( $this->_storage->connectivity_test ) ) {
982
- if ( ! isset( $this->_storage->is_on ) ) {
983
- unset( $this->_storage->connectivity_test );
984
- } else {
985
- $connectivity_data = $this->_storage->connectivity_test;
986
- $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
987
- $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
988
-
989
- // Override.
990
- $this->_storage->connectivity_test = $connectivity_data;
991
-
992
- // Remove previous structure.
993
- unset( $this->_storage->is_on );
994
- }
995
-
996
- }
997
- }
998
-
999
- if (
1000
- version_compare( $sdk_prev_version, '2.2.1', '<' ) &&
1001
- version_compare( $sdk_version, '2.2.1', '>=' )
1002
- ) {
1003
- /**
1004
- * Clear the file cache without storing the previous path since it could be a wrong path. For example,
1005
- * in the versions of the SDK lower than 2.2.1, it's possible for the path of an add-on to be the same
1006
- * as the parent plugin's when the add-on was auto-installed since the relevant method names were not
1007
- * skipped in the logic that determines the right path in the `get_caller_main_file_and_type` method
1008
- * (e.g. `try_activate_plugin`). Since it was an auto-installation, the caller was the parent plugin
1009
- * and so its path was used. In case the stored path is wrong, clearing the cache will resolve issues
1010
- * related to data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
1011
- *
1012
- * @author Leo Fajardo (@leorw)
1013
- * @since 2.2.1
1014
- */
1015
- $this->clear_module_main_file_cache( false );
1016
- }
1017
- }
1018
-
1019
- /**
1020
- * @author Leo Fajardo (@leorw)
1021
- * @since 2.0.0
1022
- *
1023
- * @param \FS_Storage $storage
1024
- * @param bool|int|null $blog_id
1025
- */
1026
- private static function migrate_install_plan_to_plan_id( FS_Storage $storage, $blog_id = null ) {
1027
- if ( empty( $storage->sdk_version ) ) {
1028
- // New installation of the plugin, no need to upgrade.
1029
- return;
1030
- }
1031
-
1032
- if ( ! version_compare( $storage->sdk_version, '2.0.0', '<' ) ) {
1033
- // Previous version is >= 2.0.0, so no need to migrate.
1034
- return;
1035
- }
1036
-
1037
- // Alias.
1038
- $module_type = $storage->get_module_type();
1039
- $module_slug = $storage->get_module_slug();
1040
-
1041
- $installs = self::get_all_sites( $module_type, $blog_id );
1042
- $install = isset( $installs[ $module_slug ] ) ? $installs[ $module_slug ] : null;
1043
-
1044
- if ( ! is_object( $install ) ) {
1045
- return;
1046
- }
1047
-
1048
- if ( isset( $install->plan ) && is_object( $install->plan ) ) {
1049
- if ( isset( $install->plan->id ) && ! empty( $install->plan->id ) ) {
1050
- $install->plan_id = self::_decrypt( $install->plan->id );
1051
- }
1052
-
1053
- unset( $install->plan );
1054
-
1055
- $installs[ $module_slug ] = clone $install;
1056
-
1057
- self::set_account_option_by_module(
1058
- $module_type,
1059
- 'sites',
1060
- $installs,
1061
- true,
1062
- $blog_id
1063
- );
1064
- }
1065
- }
1066
-
1067
- /**
1068
- * @author Leo Fajardo (@leorw)
1069
- * @since 2.0.0
1070
- */
1071
- private function migrate_to_subscriptions_collection() {
1072
- if ( ! is_object( $this->_site ) ) {
1073
- return;
1074
- }
1075
-
1076
- if ( isset( $this->_storage->subscription ) && is_object( $this->_storage->subscription ) ) {
1077
- $this->_storage->subscriptions = array( fs_get_entity( $this->_storage->subscription, FS_Subscription::get_class_name() ) );
1078
- }
1079
- }
1080
-
1081
- /**
1082
- * @author Leo Fajardo (@leorw)
1083
- * @since 2.0.0
1084
- */
1085
- private function consolidate_licenses() {
1086
- $plugin_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_PLUGIN );
1087
- if ( isset( $plugin_licenses[ $this->_slug ] ) ) {
1088
- $plugin_licenses = $plugin_licenses[ $this->_slug ];
1089
- } else {
1090
- $plugin_licenses = array();
1091
- }
1092
-
1093
- $theme_licenses = self::get_account_option( 'licenses', WP_FS__MODULE_TYPE_THEME );
1094
- if ( isset( $theme_licenses[ $this->_slug ] ) ) {
1095
- $theme_licenses = $theme_licenses[ $this->_slug ];
1096
- } else {
1097
- $theme_licenses = array();
1098
- }
1099
-
1100
- if ( empty( $plugin_licenses ) && empty( $theme_licenses ) ) {
1101
- return;
1102
- }
1103
-
1104
- $all_licenses = array();
1105
- $user_id_license_ids_map = array();
1106
-
1107
- foreach ( $plugin_licenses as $user_id => $user_licenses ) {
1108
- if ( is_array( $user_licenses ) ) {
1109
- if ( ! isset( $user_license_ids[ $user_id ] ) ) {
1110
- $user_id_license_ids_map[ $user_id ] = array();
1111
- }
1112
-
1113
- foreach ( $user_licenses as $user_license ) {
1114
- $all_licenses[] = $user_license;
1115
- $user_id_license_ids_map[ $user_id ][] = $user_license->id;
1116
- }
1117
- }
1118
- }
1119
-
1120
- foreach ( $theme_licenses as $user_id => $user_licenses ) {
1121
- if ( is_array( $user_licenses ) ) {
1122
- if ( ! isset( $user_license_ids[ $user_id ] ) ) {
1123
- $user_id_license_ids_map[ $user_id ] = array();
1124
- }
1125
-
1126
- foreach ( $user_licenses as $user_license ) {
1127
- $all_licenses[] = $user_license;
1128
- $user_id_license_ids_map[ $user_id ][] = $user_license->id;
1129
- }
1130
- }
1131
- }
1132
-
1133
- self::store_user_id_license_ids_map(
1134
- $user_id_license_ids_map,
1135
- $this->_module_id
1136
- );
1137
-
1138
- $this->_store_licenses( true, $this->_module_id, $all_licenses );
1139
- }
1140
-
1141
- /**
1142
- * Remove invalid paths.
1143
- *
1144
- * @author Leo Fajardo (@leorw)
1145
- * @since 1.2.3
1146
- */
1147
- private function remove_invalid_paths() {
1148
- // Remove invalid path that is still associated with the current slug if there's any.
1149
- $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
1150
- foreach ( $file_slug_map as $plugin_basename => $slug ) {
1151
- if ( $slug === $this->_slug &&
1152
- $plugin_basename !== $this->_plugin_basename &&
1153
- ! file_exists( $this->get_absolute_path( $plugin_basename ) )
1154
- ) {
1155
- unset( $file_slug_map[ $plugin_basename ] );
1156
- self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
1157
-
1158
- break;
1159
- }
1160
- }
1161
- }
1162
-
1163
- /**
1164
- * @author Vova Feldman (@svovaf)
1165
- * @since 1.2.2.7
1166
- *
1167
- * @param string $plugin_prev_version
1168
- * @param string $plugin_version
1169
- */
1170
- function _after_version_update( $plugin_prev_version, $plugin_version ) {
1171
- if ( $this->is_theme() ) {
1172
- // Expire the cache of the previous tabs since the theme may
1173
- // have setting updates.
1174
- $this->_cache->expire( 'tabs' );
1175
- $this->_cache->expire( 'tabs_stylesheets' );
1176
- }
1177
- }
1178
-
1179
- /**
1180
- * A special migration logic for the $_accounts, executed for all the plugins in the system:
1181
- * - Moves some data to the network level storage.
1182
- * - If the plugin's connection was skipped for all sites, set the plugin as if it was network skipped.
1183
- * - If the plugin's connection was ignored for all sites, don't do anything in terms of the network connection.
1184
- * - If the plugin was connected to all sites by the same super-admin, set the plugin as if was network opted-in for all sites.
1185
- * - If there's at least one site that was connected by a super-admin, find the "main super-admin" (the one that installed the majority of the plugin installs) and set the plugin as if was network activated with the main super-admin, set all the sites that were skipped or opted-in with a different user to delegated mode. Then, prompt the currently logged super-admin to choose what to do with the ignored sites.
1186
- * - If there are any sites in the network which the connection decision was not yet taken for, set this plugin into network activation mode so a super-admin can choose what to do with the rest of the sites.
1187
- *
1188
- * @author Vova Feldman (@svovaf)
1189
- * @since 2.0.0
1190
- */
1191
- private static function migrate_accounts_to_network() {
1192
- $sites = self::get_sites();
1193
- $sites_count = count( $sites );
1194
- $connection_status = array();
1195
- $plugin_slugs = array();
1196
- foreach ( $sites as $site ) {
1197
- $blog_id = self::get_site_blog_id( $site );
1198
-
1199
- self::$_accounts->migrate_to_network( $blog_id );
1200
-
1201
- /**
1202
- * Build a list of all Freemius powered plugins slugs.
1203
- */
1204
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array(), $blog_id );
1205
- foreach ( $id_slug_type_path_map as $module_id => $data ) {
1206
- if ( WP_FS__MODULE_TYPE_PLUGIN === $data['type'] ) {
1207
- $plugin_slugs[ $data['slug'] ] = true;
1208
- }
1209
- }
1210
-
1211
- $installs = self::get_account_option( 'sites', WP_FS__MODULE_TYPE_PLUGIN, $blog_id );
1212
-
1213
- if ( is_array( $installs ) ) {
1214
- foreach ( $installs as $slug => $install ) {
1215
- if ( ! isset( $connection_status[ $slug ] ) ) {
1216
- $connection_status[ $slug ] = array();
1217
- }
1218
-
1219
- if ( is_object( $install ) &&
1220
- FS_Site::is_valid_id( $install->id ) &&
1221
- FS_User::is_valid_id( $install->user_id )
1222
- ) {
1223
- $connection_status[ $slug ][ $blog_id ] = $install->user_id;
1224
- }
1225
- }
1226
- }
1227
- }
1228
-
1229
- foreach ( $plugin_slugs as $slug => $true ) {
1230
- if ( ! isset( $connection_status[ $slug ] ) ) {
1231
- $connection_status[ $slug ] = array();
1232
- }
1233
-
1234
- foreach ( $sites as $site ) {
1235
- $blog_id = self::get_site_blog_id( $site );
1236
-
1237
- if ( isset( $connection_status[ $slug ][ $blog_id ] ) ) {
1238
- continue;
1239
- }
1240
-
1241
- $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
1242
-
1243
- $is_anonymous = $storage->get( 'is_anonymous', null, $blog_id );
1244
-
1245
- if ( ! is_null( $is_anonymous ) ) {
1246
- // Since 1.1.3 is_anonymous is an array.
1247
- if ( is_array( $is_anonymous ) && isset( $is_anonymous['is'] ) ) {
1248
- $is_anonymous = $is_anonymous['is'];
1249
- }
1250
-
1251
- if ( is_bool( $is_anonymous ) && true === $is_anonymous ) {
1252
- $connection_status[ $slug ][ $blog_id ] = 'skipped';
1253
- }
1254
- }
1255
-
1256
- if ( ! isset( $connection_status[ $slug ][ $blog_id ] ) ) {
1257
- $connection_status[ $slug ][ $blog_id ] = 'ignored';
1258
- }
1259
- }
1260
- }
1261
-
1262
- $super_admins = array();
1263
-
1264
- foreach ( $connection_status as $slug => $blogs_status ) {
1265
- $skips = 0;
1266
- $ignores = 0;
1267
- $connections = 0;
1268
- $opted_in_users = array();
1269
- $opted_in_super_admins = array();
1270
-
1271
- $storage = FS_Storage::instance( WP_FS__MODULE_TYPE_PLUGIN, $slug );
1272
-
1273
- foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
1274
- if ( 'skipped' === $status_or_user_id ) {
1275
- $skips ++;
1276
- } else if ( 'ignored' === $status_or_user_id ) {
1277
- $ignores ++;
1278
- } else if ( FS_User::is_valid_id( $status_or_user_id ) ) {
1279
- $connections ++;
1280
-
1281
- if ( ! isset( $opted_in_users[ $status_or_user_id ] ) ) {
1282
- $opted_in_users[ $status_or_user_id ] = array();
1283
- }
1284
-
1285
- $opted_in_users[ $status_or_user_id ][] = $blog_id;
1286
-
1287
- if ( isset( $super_admins[ $status_or_user_id ] ) ||
1288
- self::is_super_admin( $status_or_user_id )
1289
- ) {
1290
- // Cache super-admin data.
1291
- $super_admins[ $status_or_user_id ] = true;
1292
-
1293
- // Remember opted-in super-admins for the plugin.
1294
- $opted_in_super_admins[ $status_or_user_id ] = true;
1295
- }
1296
- }
1297
- }
1298
-
1299
- $main_super_admin_user_id = null;
1300
- $all_migrated = false;
1301
- if ( $sites_count == $skips ) {
1302
- // All sites were skipped -> network skip by copying the anonymous mode from any of the sites.
1303
- $storage->is_anonymous_ms = $storage->is_anonymous;
1304
-
1305
- $all_migrated = true;
1306
- } else if ( $sites_count == $ignores ) {
1307
- // Don't do anything, still in activation mode.
1308
-
1309
- $all_migrated = true;
1310
- } else if ( 0 < count( $opted_in_super_admins ) ) {
1311
- // Find the super-admin with the majority of installs.
1312
- $max_installs_by_super_admin = 0;
1313
- foreach ( $opted_in_super_admins as $user_id => $true ) {
1314
- $installs_count = count( $opted_in_users[ $user_id ] );
1315
-
1316
- if ( $installs_count > $max_installs_by_super_admin ) {
1317
- $max_installs_by_super_admin = $installs_count;
1318
- $main_super_admin_user_id = $user_id;
1319
- }
1320
- }
1321
-
1322
- if ( $sites_count == $connections && 1 == count( $opted_in_super_admins ) ) {
1323
- // Super-admin opted-in for all sites in the network.
1324
- $storage->is_network_connected = true;
1325
-
1326
- $all_migrated = true;
1327
- }
1328
-
1329
- // Store network user.
1330
- $storage->network_user_id = $main_super_admin_user_id;
1331
-
1332
- $storage->network_install_blog_id = ( $sites_count == $connections ) ?
1333
- // Since all sites are opted-in, associating with the main site.
1334
- get_current_blog_id() :
1335
- // Associating with the 1st found opted-in site.
1336
- $opted_in_users[ $main_super_admin_user_id ][0];
1337
-
1338
- /**
1339
- * Make sure we migrate the plan ID of the network install, otherwise, if after the migration
1340
- * the 1st page that will be loaded is the network level WP Admin and $storage->network_install_blog_id
1341
- * is different than the main site of the network, the $this->_site will not be set since the plan_id
1342
- * will be empty.
1343
- */
1344
- $storage->migrate_to_network();
1345
- self::migrate_install_plan_to_plan_id( $storage, $storage->network_install_blog_id );
1346
- } else {
1347
- // At least one opt-in. All the opt-in were created by a non-super-admin.
1348
- if ( 0 == $ignores ) {
1349
- // All sites were opted-in or skipped, all by non-super-admin. So delegate all.
1350
- $storage->store( 'is_delegated_connection', true, true );
1351
-
1352
- $all_migrated = true;
1353
- }
1354
- }
1355
-
1356
- if ( ! $all_migrated ) {
1357
- /**
1358
- * Delegate all sites that were:
1359
- * 1) Opted-in by a user that is NOT the main-super-admin.
1360
- * 2) Skipped and non of the sites was opted-in by a super-admin. If any site was opted-in by a super-admin, there will be a main-super-admin, and we consider the skip as if it was done by that user.
1361
- */
1362
- foreach ( $blogs_status as $blog_id => $status_or_user_id ) {
1363
- if ( $status_or_user_id == $main_super_admin_user_id ) {
1364
- continue;
1365
- }
1366
-
1367
- if ( FS_User::is_valid_id( $status_or_user_id ) ||
1368
- ( 'skipped' === $status_or_user_id && is_null( $main_super_admin_user_id ) )
1369
- ) {
1370
- $storage->store( 'is_delegated_connection', true, $blog_id );
1371
- }
1372
- }
1373
- }
1374
-
1375
-
1376
- if ( ( $connections + $skips > 0 ) ) {
1377
- if ( $ignores > 0 ) {
1378
- /**
1379
- * If admin already opted-in or skipped in any of the network sites, and also
1380
- * have sites which the connection decision was not yet taken, set this plugin
1381
- * into network activation mode so the super-admin can choose what to do with
1382
- * the rest of the sites.
1383
- */
1384
- self::set_network_upgrade_mode( $storage );
1385
- }
1386
- }
1387
- }
1388
- }
1389
-
1390
- /**
1391
- * Set a module into network upgrade mode.
1392
- *
1393
- * @author Vova Feldman (@svovaf)
1394
- * @since 2.0.0
1395
- *
1396
- * @param \FS_Storage $storage
1397
- *
1398
- * @return bool
1399
- */
1400
- private static function set_network_upgrade_mode( FS_Storage $storage ) {
1401
- return $storage->is_network_activation = true;
1402
- }
1403
-
1404
- /**
1405
- * Will return true after upgrading to the SDK with the network level integration,
1406
- * when the super-admin involvement is required regarding the rest of the sites.
1407
- *
1408
- * @author Vova Feldman (@svovaf)
1409
- * @since 2.0.0
1410
- *
1411
- * @return bool
1412
- */
1413
- function is_network_upgrade_mode() {
1414
- return $this->_storage->get( 'is_network_activation' );
1415
- }
1416
-
1417
- /**
1418
- * Clear flag after the upgrade mode completion.
1419
- *
1420
- * @author Vova Feldman (@svovaf)
1421
- * @since 2.0.0
1422
- *
1423
- * @return bool True if network activation was on and now completed.
1424
- */
1425
- private function network_upgrade_mode_completed() {
1426
- if ( fs_is_network_admin() && $this->is_network_upgrade_mode() ) {
1427
- $this->_storage->remove( 'is_network_activation' );
1428
-
1429
- return true;
1430
- }
1431
-
1432
- return false;
1433
- }
1434
-
1435
- #endregion
1436
-
1437
- /**
1438
- * This action is connected to the 'plugins_loaded' hook and helps to determine
1439
- * if this is a new plugin installation or a plugin update.
1440
- *
1441
- * There are 3 different use-cases:
1442
- * 1) New plugin installation right with Freemius:
1443
- * 1.1 _activate_plugin_event_hook() will be executed first
1444
- * 1.2 Since $this->_storage->is_plugin_new_install is not set,
1445
- * and $this->_storage->plugin_last_version is not set,
1446
- * $this->_storage->is_plugin_new_install will be set to TRUE.
1447
- * 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1448
- * be already set to TRUE.
1449
- *
1450
- * 2) Plugin update, didn't have Freemius before, and now have the SDK:
1451
- * 2.1 _activate_plugin_event_hook() will not be executed, because
1452
- * the activation hook do NOT fires on updates since WP 3.1.
1453
- * 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
1454
- * be empty, therefore, it will be set to FALSE.
1455
- *
1456
- * 3) Plugin update, had Freemius in prev version as well:
1457
- * 3.1 _version_updates_handler() will be executed 1st, since FS was installed
1458
- * before, $this->_storage->plugin_last_version will NOT be empty,
1459
- * therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
1460
- * 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
1461
- * already set, therefore, it will not be modified.
1462
- *
1463
- * Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
1464
- *
1465
- * NOTE:
1466
- * The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
1467
- * and then, the next immediate PageView is the plugin's main settings page, it will not
1468
- * show the opt-in right away. The reason it will happen is because Freemius execution
1469
- * will be turned off till the plugin is fully loaded at least once
1470
- * (till $this->_storage->was_plugin_loaded is TRUE).
1471
- *
1472
- * @author Vova Feldman (@svovaf)
1473
- * @since 1.1.9
1474
- *
1475
- */
1476
- function _plugins_loaded() {
1477
- // Update flag that plugin was loaded with Freemius at least once.
1478
- $this->_storage->was_plugin_loaded = true;
1479
-
1480
- /**
1481
- * Bug fix - only set to false when it's a plugin, due to the
1482
- * execution sequence of the theme hooks and our methods, if
1483
- * this will be set for themes, Freemius will always assume
1484
- * it's a theme update.
1485
- *
1486
- * @author Vova Feldman (@svovaf)
1487
- * @since 1.2.2.2
1488
- */
1489
- if ( $this->is_plugin() &&
1490
- ! isset( $this->_storage->is_plugin_new_install )
1491
- ) {
1492
- $this->_storage->is_plugin_new_install = (
1493
- ! is_plugin_active( $this->_plugin_basename ) &&
1494
- empty( $this->_storage->plugin_last_version )
1495
- );
1496
- }
1497
- }
1498
-
1499
- /**
1500
- * Add special parameter to WP admin AJAX calls so when we
1501
- * process AJAX calls we can identify its source properly.
1502
- *
1503
- * @author Leo Fajardo (@leorw)
1504
- * @since 2.0.0
1505
- */
1506
- static function _enrich_ajax_url() {
1507
- $admin_param = is_network_admin() ?
1508
- '_fs_network_admin' :
1509
- '_fs_blog_admin';
1510
- ?>
1511
- <script type="text/javascript">
1512
- (function ($) {
1513
- $(document).ajaxSend(function (event, jqxhr, settings) {
1514
- if (settings.url &&
1515
- -1 < settings.url.indexOf('admin-ajax.php') &&
1516
- ! ( settings.url.indexOf( '<?php echo $admin_param ?>' ) > 0 )
1517
- ) {
1518
- if (
1519
- 'string' === typeof settings.data &&
1520
- settings.data.indexOf( 'action=heartbeat' ) > 0
1521
- ) {
1522
- return;
1523
- }
1524
-
1525
- if (settings.url.indexOf('?') > 0) {
1526
- settings.url += '&';
1527
- } else {
1528
- settings.url += '?';
1529
- }
1530
-
1531
- settings.url += '<?php echo $admin_param ?>=true';
1532
- }
1533
- });
1534
- })(jQuery);
1535
- </script>
1536
- <?php
1537
- }
1538
-
1539
- /**
1540
- * Opens the support forum subemenu item in a new browser page.
1541
- *
1542
- * @author Vova Feldman (@svovaf)
1543
- * @since 2.1.4
1544
- */
1545
- static function _open_support_forum_in_new_page() {
1546
- ?>
1547
- <script type="text/javascript">
1548
- (function ($) {
1549
- $('.fs-submenu-item.wp-support-forum').parent().attr( { target: '_blank', rel: 'noopener noreferrer' } );
1550
- })(jQuery);
1551
- </script>
1552
- <?php
1553
- }
1554
-
1555
- /**
1556
- * @author Vova Feldman (@svovaf)
1557
- * @since 1.0.9
1558
- */
1559
- private function register_constructor_hooks() {
1560
- $this->_logger->entrance();
1561
-
1562
- if ( is_admin() ) {
1563
- add_action( 'admin_init', array( &$this, '_hook_action_links_and_register_account_hooks' ) );
1564
-
1565
- if ( $this->is_plugin() ) {
1566
- if ( self::is_plugin_install_page() && true !== fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) {
1567
- /**
1568
- * Unless the `fs_allow_updater_and_dialog` URL param exists and its value is `true`, make
1569
- * Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php)
1570
- * so that they won't interfere with the .org plugins' functionalities on that page (e.g.
1571
- * updating of a .org plugin).
1572
- */
1573
- add_filter( 'site_transient_update_plugins', array( 'Freemius', '_remove_fs_updates_from_plugin_install_page' ), 10, 2 );
1574
- } else if ( self::is_plugins_page() || self::is_updates_page() ) {
1575
- /**
1576
- * On the "Plugins" and "Updates" admin pages, if there are premium or non–org-compliant plugins, modify their details dialog URLs (add a Freemius-specific param) so that the SDK can determine if the plugin information dialog should show information from Freemius.
1577
- *
1578
- * @author Leo Fajardo (@leorw)
1579
- * @since 2.2.3
1580
- */
1581
- add_action( 'admin_footer', array( 'Freemius', '_prepend_fs_allow_updater_and_dialog_flag_url_param' ) );
1582
- }
1583
-
1584
- $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
1585
-
1586
- /**
1587
- * @since 1.2.2
1588
- *
1589
- * Hook to both free and premium version activations to support
1590
- * auto deactivation on the other version activation.
1591
- */
1592
- register_activation_hook(
1593
- $plugin_dir . $this->_free_plugin_basename,
1594
- array( &$this, '_activate_plugin_event_hook' )
1595
- );
1596
-
1597
- register_activation_hook(
1598
- $plugin_dir . $this->premium_plugin_basename(),
1599
- array( &$this, '_activate_plugin_event_hook' )
1600
- );
1601
- } else {
1602
- add_action( 'after_switch_theme', array( &$this, '_activate_theme_event_hook' ), 10, 2 );
1603
-
1604
- add_action( 'admin_footer', array( &$this, '_style_premium_theme' ) );
1605
- }
1606
-
1607
- /**
1608
- * Part of the mechanism to identify new plugin install vs. plugin update.
1609
- *
1610
- * @author Vova Feldman (@svovaf)
1611
- * @since 1.1.9
1612
- */
1613
- if ( empty( $this->_storage->was_plugin_loaded ) ) {
1614
- /**
1615
- * During the plugin activation (not theme), 'plugins_loaded' will be already executed
1616
- * when the logic gets here since the activation logic first add the activate plugins,
1617
- * then triggers 'plugins_loaded', and only then include the code of the plugin that
1618
- * is activated. Which means that _plugins_loaded() will NOT be executed during the
1619
- * plugin activation, and that IS intentional.
1620
- *
1621
- * @author Vova Feldman (@svovaf)
1622
- */
1623
- if ( $this->is_plugin() &&
1624
- $this->is_activation_mode( false ) &&
1625
- 0 == did_action( 'plugins_loaded' )
1626
- ) {
1627
- add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
1628
- } else {
1629
- // If was activated before, then it was already loaded before.
1630
- $this->_plugins_loaded();
1631
- }
1632
- }
1633
-
1634
- if ( ! self::is_ajax() ) {
1635
- if ( ! $this->is_addon() ) {
1636
- add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
1637
- }
1638
- }
1639
-
1640
- if ( $this->_storage->handle_gdpr_admin_notice ) {
1641
- add_action( 'init', array( &$this, '_maybe_show_gdpr_admin_notice' ) );
1642
- }
1643
-
1644
- add_action( 'init', array( &$this, '_maybe_add_gdpr_optin_ajax_handler') );
1645
- add_action( 'init', array( &$this, '_maybe_add_pricing_ajax_handler' ) );
1646
- }
1647
-
1648
- if ( $this->is_plugin() ) {
1649
- if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
1650
- add_action( 'wpmu_new_blog', array( $this, '_after_new_blog_callback' ), 10, 6 );
1651
- } else {
1652
- add_action( 'wp_initialize_site', array( $this, '_after_wp_initialize_site_callback' ), 11, 2 );
1653
- }
1654
-
1655
- register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
1656
- }
1657
-
1658
- if ( is_multisite() ) {
1659
- add_action( 'deactivate_blog', array( &$this, '_after_site_deactivated_callback' ) );
1660
- add_action( 'archive_blog', array( &$this, '_after_site_deactivated_callback' ) );
1661
- add_action( 'make_spam_blog', array( &$this, '_after_site_deactivated_callback' ) );
1662
-
1663
- if ( version_compare( $GLOBALS['wp_version'], '5.1', '<' ) ) {
1664
- add_action( 'deleted_blog', array( $this, '_after_site_deleted_callback' ), 10, 2 );
1665
- } else {
1666
- add_action( 'wp_delete_site', array( $this, '_after_wpsite_deleted_callback' ) );
1667
- }
1668
-
1669
- add_action( 'activate_blog', array( &$this, '_after_site_reactivated_callback' ) );
1670
- add_action( 'unarchive_blog', array( &$this, '_after_site_reactivated_callback' ) );
1671
- add_action( 'make_ham_blog', array( &$this, '_after_site_reactivated_callback' ) );
1672
- }
1673
-
1674
- if ( $this->is_theme() &&
1675
- self::is_customizer() &&
1676
- $this->apply_filters( 'show_customizer_upsell', true )
1677
- ) {
1678
- // Register customizer upsell.
1679
- add_action( 'customize_register', array( &$this, '_customizer_register' ) );
1680
- }
1681
-
1682
- add_action( 'admin_init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
1683
-
1684
- if ( $this->is_theme() && ! $this->is_migration() ) {
1685
- add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
1686
- }
1687
-
1688
- add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
1689
- add_action( 'admin_init', array( &$this, '_add_premium_version_upgrade_selection' ) );
1690
- add_action( 'admin_init', array( &$this, '_add_beta_mode_update_handler' ) );
1691
- add_action( 'admin_init', array( &$this, '_add_user_change_option' ) );
1692
- add_action( 'admin_init', array( &$this, '_add_email_address_update_option' ) );
1693
-
1694
- $this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
1695
- $this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
1696
- $this->add_ajax_action( 'set_data_debug_mode', array( &$this, '_set_data_debug_mode' ) );
1697
- $this->add_ajax_action( 'toggle_whitelabel_mode', array( &$this, '_toggle_whitelabel_mode_ajax_handler' ) );
1698
-
1699
- if ( $this->_is_network_active && fs_is_network_admin() ) {
1700
- $this->add_ajax_action( 'network_activate', array( &$this, '_network_activate_ajax_action' ) );
1701
- }
1702
-
1703
- $this->add_ajax_action( 'install_premium_version', array(
1704
- &$this,
1705
- '_install_premium_version_ajax_action'
1706
- ) );
1707
-
1708
- $this->add_ajax_action( 'submit_affiliate_application', array( &$this, '_submit_affiliate_application' ) );
1709
-
1710
- $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
1711
-
1712
- $this->add_action( 'sdk_version_update', array( &$this, '_sdk_version_update' ), WP_FS__DEFAULT_PRIORITY, 2 );
1713
-
1714
- $this->add_action(
1715
- 'plugin_version_update',
1716
- array( &$this, '_after_version_update' ),
1717
- WP_FS__DEFAULT_PRIORITY,
1718
- 2
1719
- );
1720
- $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
1721
-
1722
- add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
1723
- add_action( 'admin_init', array( &$this, '_add_affiliate_program_notice' ) );
1724
- add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_common_css' ) );
1725
-
1726
- /**
1727
- * Handle request to reset anonymous mode for `get_reconnect_url()`.
1728
- *
1729
- * @author Vova Feldman (@svovaf)
1730
- * @since 1.2.1.5
1731
- */
1732
- if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
1733
- $this->get_unique_affix() === fs_request_get( 'fs_unique_affix' )
1734
- ) {
1735
- add_action( 'admin_init', array( &$this, 'connect_again' ) );
1736
- }
1737
- }
1738
-
1739
- /**
1740
- * Register the required hooks right after the settings parse is completed.
1741
- *
1742
- * @author Vova Feldman (@svovaf)
1743
- * @since 2.3.1
1744
- */
1745
- private function register_after_settings_parse_hooks() {
1746
- if ( is_admin() &&
1747
- $this->is_theme() &&
1748
- $this->is_premium() &&
1749
- ! $this->has_active_valid_license()
1750
- ) {
1751
- $this->add_ajax_action(
1752
- 'delete_theme_update_data',
1753
- array( &$this, '_delete_theme_update_data_action' )
1754
- );
1755
- }
1756
-
1757
- if ( $this->show_settings_with_tabs() ) {
1758
- /**
1759
- * Include the required hooks to capture the theme settings' page tabs
1760
- * and cache them.
1761
- *
1762
- * @author Vova Feldman (@svovaf)
1763
- * @since 1.2.2.7
1764
- */
1765
- if ( ! $this->_cache->has_valid( 'tabs' ) ) {
1766
- add_action( 'admin_footer', array( &$this, '_tabs_capture' ) );
1767
- // Add license activation AJAX callback.
1768
- $this->add_ajax_action( 'store_tabs', array( &$this, '_store_tabs_ajax_action' ) );
1769
-
1770
- add_action( 'admin_enqueue_scripts', array( &$this, '_store_tabs_styles' ), 9999999 );
1771
- }
1772
-
1773
- add_action(
1774
- 'admin_footer',
1775
- array( &$this, '_add_freemius_tabs' ),
1776
- /**
1777
- * The tabs JS code must be executed after the tabs capture logic (_tabs_capture()).
1778
- * That's why the priority is 11 while the tabs capture logic is added
1779
- * with priority 10.
1780
- *
1781
- * @author Vova Feldman (@svovaf)
1782
- */
1783
- 11
1784
- );
1785
- }
1786
-
1787
- if ( ! self::is_ajax() ) {
1788
- if ( ! $this->is_addon() || $this->is_only_premium() ) {
1789
- add_action(
1790
- ( $this->_is_network_active && fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu',
1791
- array( &$this, '_prepare_admin_menu' ),
1792
- WP_FS__LOWEST_PRIORITY
1793
- );
1794
- }
1795
- }
1796
- }
1797
-
1798
- /**
1799
- * Makes Freemius-related updates unavailable on the "Add Plugins" admin page (/plugin-install.php) so that
1800
- * they won't interfere with the .org plugins' functionalities on that page (e.g. updating of a .org plugin).
1801
- *
1802
- * @author Leo Fajardo (@leorw)
1803
- * @since 2.2.3
1804
- *
1805
- * @param object $updates
1806
- * @param string|null $transient
1807
- *
1808
- * @return object
1809
- */
1810
- static function _remove_fs_updates_from_plugin_install_page( $updates, $transient = null ) {
1811
- if ( is_object( $updates ) && isset( $updates->response ) ) {
1812
- foreach ( $updates->response as $file => $plugin ) {
1813
- if ( isset( $plugin->package ) && false !== strpos( $plugin->package, 'api.freemius' ) ) {
1814
- unset( $updates->response[ $file ] );
1815
- }
1816
- }
1817
- }
1818
-
1819
- return $updates;
1820
- }
1821
-
1822
- /**
1823
- * Prepends the `fs_allow_updater_and_dialog` param to the plugin information URLs to tell the SDK to handle
1824
- * the information that is shown on the plugin details dialog that is shown when the relevant link is clicked.
1825
- *
1826
- * @author Leo Fajardo (@leorw)
1827
- * @since 2.2.3
1828
- *
1829
- * @return string
1830
- */
1831
- static function _prepend_fs_allow_updater_and_dialog_flag_url_param() {
1832
- $slug_basename_map = array();
1833
- foreach ( self::$_instances as $instance ) {
1834
- if ( ! $instance->is_plugin() ) {
1835
- continue;
1836
- }
1837
-
1838
- $slug_basename_map[ $instance->get_slug() ] = $instance->premium_plugin_basename();
1839
- }
1840
- ?>
1841
- <script type="text/javascript">
1842
- (function( $ ) {
1843
- var slugBasenameMap = <?php echo json_encode( $slug_basename_map ) ?>;
1844
- for ( var slug in slugBasenameMap ) {
1845
- var basename = slugBasenameMap[ slug ];
1846
-
1847
- // Try to get the plugin rows if on the "Plugins" page.
1848
- var $pluginRows = $( '.wp-list-table.plugins tr[data-plugin="' + basename + '"]');
1849
-
1850
- if ( 0 === $pluginRows.length ) {
1851
- // Try to get the plugin rows if on the "Updates" page.
1852
- var $pluginCheckbox = $( '#update-plugins-table input[type="checkbox"][value="' + basename + '"]' );
1853
- if ( 0 !== $pluginCheckbox.length ) {
1854
- $pluginRows = $pluginCheckbox.parents( 'tr:first' );
1855
- }
1856
- }
1857
-
1858
- if ( 0 === $pluginRows.length ) {
1859
- // No plugin rows found.
1860
- continue;
1861
- }
1862
-
1863
- // Find the "View details" links and add the `fs_allow_updater_and_dialog` param to the URL.
1864
- $pluginRows.find( 'a[href*="plugin-install.php?tab=plugin-information"]' ).each(function() {
1865
- var $this = $( this ),
1866
- href = $this.attr( 'href' ).replace( '?tab=', '?fs_allow_updater_and_dialog=true&tab=');
1867
-
1868
- $this.attr( 'href', href );
1869
- });
1870
- }
1871
- })( jQuery );
1872
- </script>
1873
- <?php
1874
- }
1875
-
1876
- /**
1877
- * @author Leo Fajardo (@leorw)
1878
- * @since 2.3.0
1879
- */
1880
- static function _maybe_add_beta_label_styles() {
1881
- $has_any_beta_version = false;
1882
-
1883
- foreach ( self::$_instances as $instance ) {
1884
- if ( $instance->is_beta() ) {
1885
- $has_any_beta_version = true;
1886
- break;
1887
- }
1888
- }
1889
-
1890
- if ( $has_any_beta_version ) {
1891
- fs_enqueue_local_style( 'fs_plugins', '/admin/plugins.css' );
1892
- }
1893
- }
1894
-
1895
- /**
1896
- * @author Leo Fajardo (@leorw)
1897
- * @since 2.3.0
1898
- */
1899
- static function _maybe_add_beta_label_to_plugins_and_handle_confirmation() {
1900
- $beta_data = array();
1901
-
1902
- foreach ( self::$_instances as $instance ) {
1903
- if ( ! $instance->is_premium() ) {
1904
- continue;
1905
- }
1906
-
1907
- /**
1908
- * If there's an available beta version update, a confirmation message will be shown when the
1909
- * "Update now" link on the "Plugins" or "Themes" page is clicked.
1910
- */
1911
- $has_beta_update = $instance->has_beta_update();
1912
-
1913
- $is_beta = (
1914
- // The "Beta" label is added separately for themes.
1915
- $instance->is_plugin() &&
1916
- $instance->is_beta()
1917
- );
1918
-
1919
- if ( ! $is_beta && ! $has_beta_update ) {
1920
- continue;
1921
- }
1922
-
1923
- $beta_data[ $instance->get_plugin_basename() ] = array( 'is_installed_version_beta' => $is_beta );
1924
-
1925
- if ( ! $has_beta_update ) {
1926
- continue;
1927
- }
1928
-
1929
- $beta_data[ $instance->get_plugin_basename() ]['beta_version_update_confirmation_message'] = sprintf(
1930
- '%s %s',
1931
- sprintf(
1932
- fs_esc_attr_inline(
1933
- 'An update to a Beta version will replace your installed version of %s with the latest Beta release - use with caution, and not on production sites. You have been warned.',
1934
- 'beta-version-update-caution',
1935
- $instance->get_slug()
1936
- ),
1937
- $instance->get_plugin_title()
1938
- ),
1939
- fs_esc_attr_inline( 'Would you like to proceed with the update?', 'update-confirmation', $instance->get_slug() )
1940
- );
1941
- }
1942
-
1943
- if ( empty( $beta_data ) ) {
1944
- return;
1945
- }
1946
- ?>
1947
- <script type="text/javascript">
1948
- ( function( $ ) {
1949
- var betaData = <?php echo json_encode( $beta_data ) ?>;
1950
-
1951
- for ( var pluginBasename in betaData ) {
1952
- if ( ! betaData.hasOwnProperty( pluginBasename ) ) {
1953
- continue;
1954
- }
1955
-
1956
- if ( ! betaData[ pluginBasename ].is_installed_version_beta ) {
1957
- continue;
1958
- }
1959
-
1960
- var $parentContainer = $( '.wp-list-table.plugins tr[data-plugin="' + pluginBasename + '"]' );
1961
- if ( 0 === $parentContainer.length ) {
1962
- continue;
1963
- }
1964
-
1965
- $parentContainer.find( '.plugin-title > strong:first-child').append(
1966
- '<span class="fs-tag fs-info"><?php fs_esc_js_echo_inline( 'Beta', 'beta' ) ?></span>'
1967
- );
1968
- }
1969
-
1970
- setTimeout( function() {
1971
- // Wait a little bit before adding the event handler, otherwise, it will be overridden by the core WP logic.
1972
- $( '.plugins .update-message .update-link, .themes .theme .update-message' ).on( 'click', function() {
1973
- var $parentContainer = $( this ).parents( 'tr:first' );
1974
- pluginBasename = ( 0 !== $parentContainer.length ) ?
1975
- $parentContainer.data( 'plugin' ) :
1976
- $( this ).parents( '.theme:first' ).data( 'slug' );
1977
-
1978
- if (
1979
- betaData[ pluginBasename ] &&
1980
- betaData[ pluginBasename ].beta_version_update_confirmation_message &&
1981
- ! confirm( betaData[ pluginBasename ].beta_version_update_confirmation_message )
1982
- ) {
1983
- return false;
1984
- }
1985
- } );
1986
- }, 20 );
1987
- } )( jQuery );
1988
- </script>
1989
- <?php
1990
- }
1991
-
1992
- /**
1993
- * Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
1994
- * could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
1995
- * plugin will trigger inclusion of the free or premium version and if one of them is active during the
1996
- * uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
1997
- *
1998
- * @author Leo Fajardo (@leorw)
1999
- *
2000
- * @since 1.2.0
2001
- */
2002
- private function unregister_uninstall_hook() {
2003
- $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
2004
- unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
2005
- unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
2006
-
2007
- update_option( 'uninstall_plugins', $uninstallable_plugins );
2008
- }
2009
-
2010
- /**
2011
- * @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
2012
- *
2013
- * @param bool $store_prev_path
2014
- */
2015
- private function clear_module_main_file_cache( $store_prev_path = true ) {
2016
- if ( ! isset( $this->_storage->plugin_main_file ) ||
2017
- empty( $this->_storage->plugin_main_file->path )
2018
- ) {
2019
- return;
2020
- }
2021
-
2022
- if ( ! $store_prev_path ) {
2023
- /**
2024
- * Storing the previous path is not needed when clearing the cache after an SDK version update since
2025
- * the main purpose of the cache clearing in that event is to correct a wrong plugin main file path
2026
- * which causes data mix-up between plugins (e.g. titles and versions of an add-on and its parent plugin).
2027
- *
2028
- * @author Leo Fajardo (@leorw)
2029
- * @since 2.2.1
2030
- */
2031
- unset( $this->_storage->plugin_main_file->path );
2032
- } else {
2033
- $plugin_main_file = clone $this->_storage->plugin_main_file;
2034
-
2035
- // Store cached path (2nd layer cache).
2036
- $plugin_main_file->prev_path = $plugin_main_file->path;
2037
-
2038
- // Clear cached path.
2039
- unset( $plugin_main_file->path );
2040
-
2041
- $this->_storage->plugin_main_file = $plugin_main_file;
2042
- }
2043
-
2044
- /**
2045
- * Clear global cached path.
2046
- *
2047
- * @author Leo Fajardo (@leorw)
2048
- * @since 1.2.2
2049
- */
2050
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map' );
2051
- unset( $id_slug_type_path_map[ $this->_module_id ]['path'] );
2052
- self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
2053
- }
2054
-
2055
- /**
2056
- * @author Leo Fajardo (@leorw)
2057
- * @since 2.0.0
2058
- */
2059
- function _hook_action_links_and_register_account_hooks() {
2060
- if ( $this->is_migration() ) {
2061
- return;
2062
- }
2063
-
2064
- $this->_add_tracking_links();
2065
-
2066
- if ( self::is_plugins_page() && $this->is_plugin() ) {
2067
- $this->hook_plugin_action_links();
2068
- }
2069
-
2070
- $this->_register_account_hooks();
2071
- }
2072
-
2073
- /**
2074
- * @author Vova Feldman (@svovaf)
2075
- * @since 1.0.9
2076
- */
2077
- private function _register_account_hooks() {
2078
- if ( ! is_admin() ) {
2079
- return;
2080
- }
2081
-
2082
- /**
2083
- * Always show the deactivation feedback form since we added
2084
- * automatic free version deactivation upon premium code activation.
2085
- *
2086
- * @since 1.2.1.6
2087
- */
2088
- $this->add_ajax_action(
2089
- 'submit_uninstall_reason',
2090
- array( &$this, '_submit_uninstall_reason_action' )
2091
- );
2092
-
2093
- $this->add_ajax_action(
2094
- 'cancel_subscription_or_trial',
2095
- array( &$this, 'cancel_subscription_or_trial_ajax_action' )
2096
- );
2097
-
2098
- if ( ! $this->is_addon() || $this->is_parent_plugin_installed() ) {
2099
- if ( ( $this->is_plugin() && self::is_plugins_page() ) ||
2100
- ( $this->is_theme() && self::is_themes_page() )
2101
- ) {
2102
- add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
2103
- }
2104
- }
2105
- }
2106
-
2107
- /**
2108
- * Leverage backtrace to find caller plugin file path.
2109
- *
2110
- * @param bool $is_init Is initiation sequence.
2111
- * @param string $main_file Since 2.5.0 expects the module's main file path to potentially purge the cached path.
2112
- *
2113
- * @return string
2114
- * @since 1.0.6
2115
- *
2116
- * @author Vova Feldman (@svovaf)
2117
- */
2118
- private function _find_caller_plugin_file( $is_init = false, $main_file = '' ) {
2119
- // Try to load the cached value of the file path.
2120
- if ( isset( $this->_storage->plugin_main_file ) ) {
2121
- $plugin_main_file = $this->_storage->plugin_main_file;
2122
- if ( ! empty( $plugin_main_file->path ) ) {
2123
- $absolute_path = $this->get_absolute_path( $plugin_main_file->path );
2124
- if ( file_exists( $absolute_path ) ) {
2125
- if ( $is_init && $absolute_path !== $this->get_absolute_path( $main_file ) ) {
2126
- // Update cached path if not matching the actual path.
2127
- $plugin_main_file->path = $main_file;
2128
- $this->_storage->plugin_main_file = $plugin_main_file;
2129
- }
2130
-
2131
- return $absolute_path;
2132
- }
2133
- }
2134
- }
2135
-
2136
- /**
2137
- * @since 1.2.1
2138
- *
2139
- * `clear_module_main_file_cache()` is clearing the plugin's cached path on
2140
- * deactivation. Therefore, if any plugin/theme was initiating `Freemius`
2141
- * with that plugin's slug, it was overriding the empty plugin path with a wrong path.
2142
- *
2143
- * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
2144
- * when the class instantiator isn't the module.
2145
- */
2146
- if ( ! $is_init ) {
2147
- // Fetch prev path cache.
2148
- if ( isset( $this->_storage->plugin_main_file ) &&
2149
- ! empty( $this->_storage->plugin_main_file->prev_path )
2150
- ) {
2151
- $absolute_path = $this->get_absolute_path( $this->_storage->plugin_main_file->prev_path );
2152
- if ( file_exists( $absolute_path ) ) {
2153
- return $absolute_path;
2154
- }
2155
- }
2156
-
2157
- wp_die(
2158
- $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' ) .
2159
- " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
2160
- $this->get_text_inline( 'Error', 'error' ),
2161
- array( 'back_link' => true )
2162
- );
2163
- }
2164
-
2165
- /**
2166
- * @since 1.2.1
2167
- *
2168
- * Only the original instantiator that calls dynamic_init can modify the module's path.
2169
- */
2170
- // Find caller module.
2171
- $this->_storage->plugin_main_file = (object) array(
2172
- 'path' => $main_file,
2173
- );
2174
-
2175
- return $this->get_absolute_path( $main_file );
2176
- }
2177
-
2178
- /**
2179
- * @author Leo Fajardo (@leorw)
2180
- * @since 1.2.3
2181
- *
2182
- * @param string $path
2183
- *
2184
- * @return string
2185
- */
2186
- private function get_relative_path( $path ) {
2187
- $module_root_dir = $this->get_module_root_dir_path();
2188
- if ( 0 === strpos( $path, $module_root_dir ) ) {
2189
- $path = substr( $path, strlen( $module_root_dir ) );
2190
- }
2191
-
2192
- return $path;
2193
- }
2194
-
2195
- /**
2196
- * @author Leo Fajardo (@leorw)
2197
- * @since 1.2.3
2198
- *
2199
- * @param string $path
2200
- * @param string|bool $module_type
2201
- *
2202
- * @return string
2203
- */
2204
- private function get_absolute_path( $path, $module_type = false ) {
2205
- $module_root_dir = $this->get_module_root_dir_path( $module_type );
2206
- if ( 0 !== strpos( $path, $module_root_dir ) ) {
2207
- $path = fs_normalize_path( $module_root_dir . $path );
2208
- }
2209
-
2210
- return $path;
2211
- }
2212
-
2213
- /**
2214
- * @author Leo Fajardo (@leorw)
2215
- * @since 1.2.3
2216
- *
2217
- * @param string|bool $module_type
2218
- *
2219
- * @return string
2220
- */
2221
- private function get_module_root_dir_path( $module_type = false ) {
2222
- $is_plugin = empty( $module_type ) ?
2223
- $this->is_plugin() :
2224
- ( WP_FS__MODULE_TYPE_PLUGIN === $module_type );
2225
-
2226
- return fs_normalize_path( trailingslashit( $is_plugin ?
2227
- WP_PLUGIN_DIR :
2228
- get_theme_root( get_stylesheet() ) ) );
2229
- }
2230
-
2231
- /**
2232
- * @author Leo Fajardo (@leorw)
2233
- *
2234
- * @param number $module_id
2235
- * @param string $slug
2236
- *
2237
- * @return string Since 2.5.0 return the module's main file path.
2238
- *
2239
- * @since 1.2.2
2240
- */
2241
- private function store_id_slug_type_path_map( $module_id, $slug ) {
2242
- $id_slug_type_path_map = self::$_accounts->get_option( 'id_slug_type_path_map', array() );
2243
-
2244
- $store_option = false;
2245
-
2246
- if ( ! isset( $id_slug_type_path_map[ $module_id ] ) ) {
2247
- $id_slug_type_path_map[ $module_id ] = array(
2248
- 'slug' => $slug
2249
- );
2250
-
2251
- $store_option = true;
2252
- } else if (
2253
- isset( $id_slug_type_path_map[ $module_id ]['slug'] ) &&
2254
- $slug !== $id_slug_type_path_map[ $module_id ]['slug']
2255
- ) {
2256
- $id_slug_type_path_map[ $module_id ]['slug'] = $slug;
2257
- $store_option = true;
2258
- }
2259
-
2260
- $find_caller = empty( $id_slug_type_path_map[ $module_id ]['path'] );
2261
-
2262
- if ( ! $find_caller ) {
2263
- /**
2264
- * This verification is for cases when suddenly the same module
2265
- * is installed but with a different folder name.
2266
- *
2267
- * @author Vova Feldman (@svovaf)
2268
- * @since 1.2.3
2269
- */
2270
- $find_caller = ! file_exists( $this->get_absolute_path(
2271
- $id_slug_type_path_map[ $module_id ]['path'],
2272
- $id_slug_type_path_map[ $module_id ]['type']
2273
- ) );
2274
- }
2275
-
2276
- foreach ( $id_slug_type_path_map as $id => $data ) {
2277
- if ( empty( $id ) ) {
2278
- // Remove maps with empty module ID.
2279
- unset( $id_slug_type_path_map[ $id ] );
2280
- $store_option = true;
2281
- continue;
2282
- }
2283
-
2284
- /**
2285
- * If the module's main file path is identical to the main file path of another module then it means that the cached path of the current module or the other one with the same path is wrong, and therefore, we need to recalculate those paths.
2286
- *
2287
- * @author Vova Feldman (@svovaf)
2288
- * @since 2.5.0
2289
- */
2290
- if ( ! $find_caller ) {
2291
- if ( $id == $module_id ) {
2292
- continue;
2293
- }
2294
-
2295
- if (
2296
- isset( $data['path'] ) &&
2297
- $data['path'] === $id_slug_type_path_map[ $module_id ]['path']
2298
- ) {
2299
- $find_caller = true;
2300
- }
2301
- }
2302
- }
2303
-
2304
- if ( $find_caller ) {
2305
- $caller_main_file_and_type = $this->get_caller_main_file_and_type( $module_id );
2306
-
2307
- $id_slug_type_path_map[ $module_id ]['type'] = $caller_main_file_and_type->module_type;
2308
- $id_slug_type_path_map[ $module_id ]['path'] = $caller_main_file_and_type->path;
2309
-
2310
- $store_option = true;
2311
- }
2312
-
2313
- if ( $store_option ) {
2314
- self::$_accounts->set_option( 'id_slug_type_path_map', $id_slug_type_path_map, true );
2315
- }
2316
-
2317
- return $id_slug_type_path_map[ $module_id ]['path'];
2318
- }
2319
-
2320
- /**
2321
- * Identifies the caller type: plugin or theme.
2322
- *
2323
- * @author Leo Fajardo (@leorw)
2324
- * @since 1.2.2
2325
- *
2326
- * @author Vova Feldman (@svovaf)
2327
- * @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases when
2328
- * add-ons are relying on loading the SDK from the parent module, and also allows themes including the
2329
- * SDK an internal file instead of directly from functions.php.
2330
- * @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
2331
- *
2332
- * @param number $module_id @since 2.5.0
2333
- */
2334
- private function get_caller_main_file_and_type( $module_id ) {
2335
- self::require_plugin_essentials();
2336
-
2337
- $all_plugins = fs_get_plugins( true );
2338
- $all_plugins_paths = array();
2339
-
2340
- // Get active plugin's main files real full names (might be symlinks).
2341
- foreach ( $all_plugins as $relative_path => $data ) {
2342
- if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
2343
- /**
2344
- * Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
2345
- * can't really include the SDK.
2346
- *
2347
- * @author Vova Feldman
2348
- * @since 1.2.1.7
2349
- */
2350
- continue;
2351
- }
2352
-
2353
- $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
2354
- }
2355
-
2356
- $caller_file_candidate = false;
2357
- $caller_map = array();
2358
- $module_type = WP_FS__MODULE_TYPE_PLUGIN;
2359
- $themes_dir = fs_normalize_path( get_theme_root( get_stylesheet() ) );
2360
- $plugin_dir_to_skip = false;
2361
-
2362
- for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
2363
- if ( empty( $bt[ $i ]['file'] ) ) {
2364
- continue;
2365
- }
2366
-
2367
- if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
2368
- // If file same as the prev file in the stack, skip it.
2369
- continue;
2370
- }
2371
-
2372
- if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
2373
- 'do_action',
2374
- 'apply_filter',
2375
- // The string split is stupid, but otherwise, theme check
2376
- // throws info notices.
2377
- 'requir' . 'e_once',
2378
- 'requir' . 'e',
2379
- 'includ' . 'e_once',
2380
- 'includ' . 'e',
2381
- 'install_and_activate_plugin',
2382
- 'try_activate_plugin',
2383
- 'activate_plugin'
2384
- ) )
2385
- ) {
2386
- if ( 'activate_plugin' === $bt[ $i ]['function'] ) {
2387
- /**
2388
- * Store the directory of the activator plugin so that any other file that starts with it
2389
- * cannot be mistakenly chosen as a candidate caller file.
2390
- *
2391
- * @author Leo Fajardo
2392
- *
2393
- * @since 2.3.0
2394
- */
2395
- $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
2396
-
2397
- foreach ( $all_plugins_paths as $plugin_path ) {
2398
- $plugin_dir = fs_normalize_path( dirname( $plugin_path ) . '/' );
2399
- if ( false !== strpos( $caller_file_path, $plugin_dir ) ) {
2400
- $plugin_dir_to_skip = $plugin_dir;
2401
-
2402
- break;
2403
- }
2404
- }
2405
- }
2406
-
2407
- // Ignore call stack hooks and files inclusion.
2408
- continue;
2409
- }
2410
-
2411
- $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
2412
-
2413
- if ( ! empty( $plugin_dir_to_skip ) ) {
2414
- /**
2415
- * Skip if it's an activator plugin file to avoid mistakenly choosing it as a candidate caller file.
2416
- *
2417
- * @author Leo Fajardo
2418
- *
2419
- * @since 2.3.0
2420
- */
2421
- if ( 0 === strpos( $caller_file_path, $plugin_dir_to_skip ) ) {
2422
- continue;
2423
- }
2424
- }
2425
-
2426
- if ( 'functions.php' === basename( $caller_file_path ) ) {
2427
- /**
2428
- * 1. Assumes that theme's starting execution file is functions.php.
2429
- * 2. This complex logic fixes symlink issues (e.g. with Vargant).
2430
- *
2431
- * @author Vova Feldman (@svovaf)
2432
- * @since 1.2.2.5
2433
- */
2434
-
2435
- if ( $caller_file_path == fs_normalize_path( realpath( trailingslashit( $themes_dir ) . basename( dirname( $caller_file_path ) ) . '/' . basename( $caller_file_path ) ) ) ) {
2436
- $module_type = WP_FS__MODULE_TYPE_THEME;
2437
-
2438
- /**
2439
- * Relative path of the theme, e.g.:
2440
- * `my-theme/functions.php`
2441
- *
2442
- * @author Leo Fajardo (@leorw)
2443
- */
2444
- $caller_file_candidate = basename( dirname( $caller_file_path ) ) .
2445
- '/' .
2446
- basename( $caller_file_path );
2447
-
2448
- continue;
2449
- }
2450
- }
2451
-
2452
- $caller_file_hash = md5( $caller_file_path );
2453
-
2454
- if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
2455
- foreach ( $all_plugins_paths as $plugin_path ) {
2456
- if ( empty( $plugin_path ) ) {
2457
- continue;
2458
- }
2459
-
2460
- if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
2461
- $caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
2462
- break;
2463
- }
2464
- }
2465
- }
2466
-
2467
- if ( isset( $caller_map[ $caller_file_hash ] ) ) {
2468
- $module_type = WP_FS__MODULE_TYPE_PLUGIN;
2469
- $caller_file_candidate = plugin_basename( $caller_map[ $caller_file_hash ] );
2470
- }
2471
- }
2472
-
2473
- $caller_main_file_and_type = (object) array(
2474
- 'module_type' => $module_type,
2475
- 'path' => $caller_file_candidate
2476
- );
2477
-
2478
- return apply_filters( "fs_{$module_id}_caller_main_file_and_type", $caller_main_file_and_type );
2479
- }
2480
-
2481
- #----------------------------------------------------------------------------------
2482
- #region Deactivation Feedback Form
2483
- #----------------------------------------------------------------------------------
2484
-
2485
- /**
2486
- * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
2487
- * page.
2488
- *
2489
- * @author Vova Feldman (@svovaf)
2490
- * @author Leo Fajardo (@leorw)
2491
- *
2492
- * @since 1.1.2
2493
- */
2494
- function _add_deactivation_feedback_dialog_box() {
2495
- if (
2496
- $this->is_clone() ||
2497
- ( is_object( $this->_site ) && ! $this->is_registered() )
2498
- ) {
2499
- return;
2500
- }
2501
-
2502
- $subscription_cancellation_dialog_box_template_params = $this->apply_filters( 'show_deactivation_subscription_cancellation', true ) ?
2503
- $this->_get_subscription_cancellation_dialog_box_template_params() :
2504
- array();
2505
-
2506
- /**
2507
- * @since 2.3.0 Developers can optionally hide the deactivation feedback form using the 'show_deactivation_feedback_form' filter.
2508
- */
2509
- $show_deactivation_feedback_form = ! self::is_deactivation_snoozed();
2510
- if ( $this->has_filter( 'show_deactivation_feedback_form' ) ) {
2511
- $show_deactivation_feedback_form = $this->apply_filters( 'show_deactivation_feedback_form', true );
2512
- } else if ( $this->is_addon() ) {
2513
- /**
2514
- * If the add-on's 'show_deactivation_feedback_form' is not set, try to inherit the value from the parent.
2515
- */
2516
- $show_deactivation_feedback_form = $this->get_parent_instance()->apply_filters( 'show_deactivation_feedback_form', true );
2517
- }
2518
-
2519
- $uninstall_confirmation_message = $this->apply_filters( 'uninstall_confirmation_message', '' );
2520
-
2521
- if (
2522
- empty( $subscription_cancellation_dialog_box_template_params ) &&
2523
- ! $show_deactivation_feedback_form &&
2524
- empty( $uninstall_confirmation_message )
2525
- ) {
2526
- return;
2527
- }
2528
-
2529
- $vars = array( 'id' => $this->_module_id );
2530
-
2531
- if ( $show_deactivation_feedback_form ) {
2532
- /* Check the type of user:
2533
- * 1. Long-term (long-term)
2534
- * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
2535
- * 3. Short-term (short-term)
2536
- */
2537
- $is_long_term_user = true;
2538
-
2539
- // Check if the site is at least 2 days old.
2540
- $time_installed = $this->_storage->install_timestamp;
2541
-
2542
- // Difference in seconds.
2543
- $date_diff = time() - $time_installed;
2544
-
2545
- // Convert seconds to days.
2546
- $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
2547
-
2548
- if ( $date_diff_days < 2 ) {
2549
- $is_long_term_user = false;
2550
- }
2551
-
2552
- $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
2553
-
2554
- if ( $is_long_term_user ) {
2555
- $user_type = 'long-term';
2556
- } else {
2557
- if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
2558
- $user_type = 'non-registered-and-non-anonymous-short-term';
2559
- } else {
2560
- $user_type = 'short-term';
2561
- }
2562
- }
2563
-
2564
- $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
2565
-
2566
- $vars['reasons'] = $uninstall_reasons;
2567
- }
2568
-
2569
- $vars['subscription_cancellation_dialog_box_template_params'] = &$subscription_cancellation_dialog_box_template_params;
2570
- $vars['show_deactivation_feedback_form'] = $show_deactivation_feedback_form;
2571
- $vars['uninstall_confirmation_message'] = $uninstall_confirmation_message;
2572
-
2573
- /**
2574
- * Load the HTML template for the deactivation feedback dialog box.
2575
- *
2576
- * @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.
2577
- */
2578
- fs_require_template( 'forms/deactivation/form.php', $vars );
2579
- }
2580
-
2581
- /**
2582
- * @author Leo Fajardo (@leorw)
2583
- * @since 1.1.2
2584
- *
2585
- * @param string $user_type
2586
- *
2587
- * @return array The uninstall reasons for the specified user type.
2588
- */
2589
- function _get_uninstall_reasons( $user_type = 'long-term' ) {
2590
- $module_type = $this->_module_type;
2591
-
2592
- $internal_message_template_var = array(
2593
- 'id' => $this->_module_id
2594
- );
2595
-
2596
- $plan = $this->get_plan();
2597
-
2598
- if ( $this->is_registered() && is_object( $plan ) && $plan->has_technical_support() ) {
2599
- $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
2600
- } else {
2601
- $contact_support_template = '';
2602
- }
2603
-
2604
- $reason_found_better_plugin = array(
2605
- 'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
2606
- 'text' => sprintf( $this->get_text_inline( 'I found a better %s', 'reason-found-a-better-plugin' ), $module_type ),
2607
- 'input_type' => 'textfield',
2608
- 'input_placeholder' => sprintf( $this->get_text_inline( "What's the %s's name?", 'placeholder-plugin-name' ), $module_type ),
2609
- );
2610
-
2611
- $reason_temporary_deactivation = array(
2612
- 'id' => self::REASON_TEMPORARY_DEACTIVATION,
2613
- 'text' => sprintf(
2614
- $this->get_text_inline( "It's a temporary %s - I'm troubleshooting an issue", 'reason-temporary-x' ),
2615
- strtolower( $this->is_plugin() ?
2616
- $this->get_text_inline( 'Deactivation', 'deactivation' ) :
2617
- $this->get_text_inline( 'Theme Switch', 'theme-switch' )
2618
- )
2619
- ),
2620
- 'input_type' => '',
2621
- 'input_placeholder' => ''
2622
- );
2623
-
2624
- $reason_other = array(
2625
- 'id' => self::REASON_OTHER,
2626
- 'text' => $this->get_text_inline( 'Other', 'reason-other' ),
2627
- 'input_type' => 'textfield',
2628
- 'input_placeholder' => ''
2629
- );
2630
-
2631
- $long_term_user_reasons = array(
2632
- array(
2633
- 'id' => self::REASON_NO_LONGER_NEEDED,
2634
- 'text' => sprintf( $this->get_text_inline( 'I no longer need the %s', 'reason-no-longer-needed' ), $module_type ),
2635
- 'input_type' => '',
2636
- 'input_placeholder' => ''
2637
- ),
2638
- $reason_found_better_plugin,
2639
- array(
2640
- 'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
2641
- 'text' => sprintf( $this->get_text_inline( 'I only needed the %s for a short period', 'reason-needed-for-a-short-period' ), $module_type ),
2642
- 'input_type' => '',
2643
- 'input_placeholder' => ''
2644
- ),
2645
- array(
2646
- 'id' => self::REASON_BROKE_MY_SITE,
2647
- 'text' => sprintf( $this->get_text_inline( 'The %s broke my site', 'reason-broke-my-site' ), $module_type ),
2648
- 'input_type' => '',
2649
- 'input_placeholder' => '',
2650
- 'internal_message' => $contact_support_template
2651
- ),
2652
- array(
2653
- 'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
2654
- 'text' => sprintf( $this->get_text_inline( 'The %s suddenly stopped working', 'reason-suddenly-stopped-working' ), $module_type ),
2655
- 'input_type' => '',
2656
- 'input_placeholder' => '',
2657
- 'internal_message' => $contact_support_template
2658
- )
2659
- );
2660
-
2661
- if ( $this->is_paying() ) {
2662
- $long_term_user_reasons[] = array(
2663
- 'id' => self::REASON_CANT_PAY_ANYMORE,
2664
- 'text' => $this->get_text_inline( "I can't pay for it anymore", 'reason-cant-pay-anymore' ),
2665
- 'input_type' => 'textfield',
2666
- 'input_placeholder' => $this->get_text_inline( 'What price would you feel comfortable paying?', 'placeholder-comfortable-price' )
2667
- );
2668
- }
2669
-
2670
- $reason_dont_share_info = array(
2671
- 'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
2672
- 'text' => $this->get_text_inline( "I don't like to share my information with you", 'reason-dont-like-to-share-my-information' ),
2673
- 'input_type' => '',
2674
- 'input_placeholder' => ''
2675
- );
2676
-
2677
- /**
2678
- * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
2679
- * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
2680
- * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
2681
- * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
2682
- * button in the opt-in form is shown/hidden).
2683
- */
2684
- if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
2685
- $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
2686
- }
2687
-
2688
- $uninstall_reasons = array(
2689
- 'long-term' => $long_term_user_reasons,
2690
- 'non-registered-and-non-anonymous-short-term' => array(
2691
- array(
2692
- 'id' => self::REASON_DIDNT_WORK,
2693
- 'text' => sprintf( $this->get_text_inline( "The %s didn't work", 'reason-didnt-work' ), $module_type ),
2694
- 'input_type' => '',
2695
- 'input_placeholder' => ''
2696
- ),
2697
- $reason_dont_share_info,
2698
- $reason_found_better_plugin
2699
- ),
2700
- 'short-term' => array(
2701
- array(
2702
- 'id' => self::REASON_COULDNT_MAKE_IT_WORK,
2703
- 'text' => $this->get_text_inline( "I couldn't understand how to make it work", 'reason-couldnt-make-it-work' ),
2704
- 'input_type' => '',
2705
- 'input_placeholder' => '',
2706
- 'internal_message' => $contact_support_template
2707
- ),
2708
- $reason_found_better_plugin,
2709
- array(
2710
- 'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
2711
- '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 ),
2712
- 'input_type' => 'textarea',
2713
- 'input_placeholder' => $this->get_text_inline( 'What feature?', 'placeholder-feature' )
2714
- ),
2715
- array(
2716
- 'id' => self::REASON_NOT_WORKING,
2717
- 'text' => sprintf( $this->get_text_inline( 'The %s is not working', 'reason-not-working' ), $module_type ),
2718
- 'input_type' => 'textarea',
2719
- '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' )
2720
- ),
2721
- array(
2722
- 'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
2723
- 'text' => $this->get_text_inline( "It's not what I was looking for", 'reason-not-what-i-was-looking-for' ),
2724
- 'input_type' => 'textarea',
2725
- 'input_placeholder' => $this->get_text_inline( "What you've been looking for?", 'placeholder-what-youve-been-looking-for' )
2726
- ),
2727
- array(
2728
- 'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
2729
- 'text' => sprintf( $this->get_text_inline( "The %s didn't work as expected", 'reason-didnt-work-as-expected' ), $module_type ),
2730
- 'input_type' => 'textarea',
2731
- 'input_placeholder' => $this->get_text_inline( 'What did you expect?', 'placeholder-what-did-you-expect' )
2732
- )
2733
- )
2734
- );
2735
-
2736
- // Randomize the reasons for the current user type.
2737
- shuffle( $uninstall_reasons[ $user_type ] );
2738
-
2739
- // Keep the following reasons as the last items in the list.
2740
- $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
2741
- $uninstall_reasons[ $user_type ][] = $reason_other;
2742
-
2743
- $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
2744
-
2745
- return $uninstall_reasons[ $user_type ];
2746
- }
2747
-
2748
- /**
2749
- * Called after the user has submitted his reason for deactivating the plugin.
2750
- *
2751
- * @author Leo Fajardo (@leorw)
2752
- * @since 1.1.2
2753
- */
2754
- function _submit_uninstall_reason_action() {
2755
- $this->_logger->entrance();
2756
-
2757
- $this->check_ajax_referer( 'submit_uninstall_reason' );
2758
-
2759
- $reason_id = fs_request_get( 'reason_id' );
2760
-
2761
- // Check if the given reason ID is an unsigned integer.
2762
- if ( ! ctype_digit( $reason_id ) ) {
2763
- exit;
2764
- }
2765
-
2766
- $reason_info = trim( fs_request_get( 'reason_info', '' ) );
2767
- if ( ! empty( $reason_info ) ) {
2768
- $reason_info = substr( $reason_info, 0, 128 );
2769
- }
2770
-
2771
- $reason = (object) array(
2772
- 'id' => $reason_id,
2773
- 'info' => $reason_info,
2774
- 'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
2775
- );
2776
-
2777
- $this->_storage->store( 'uninstall_reason', $reason );
2778
-
2779
- if ( self::REASON_TEMPORARY_DEACTIVATION == $reason->id ) {
2780
- $snooze_period = fs_request_get( 'snooze_period' );
2781
-
2782
- if ( is_numeric( $snooze_period ) && 0 < $snooze_period ) {
2783
- self::snooze_deactivation_form( (int) $snooze_period );
2784
- }
2785
- }
2786
-
2787
- /**
2788
- * If the module type is "theme", trigger the uninstall event here (on theme deactivation) since themes do
2789
- * not support uninstall hook.
2790
- *
2791
- * @author Leo Fajardo (@leorw)
2792
- * @since 1.2.2
2793
- */
2794
- if ( $this->is_theme() ) {
2795
- if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
2796
- FS_Plugin_Updater::instance( $this )->delete_update_data();
2797
- }
2798
-
2799
- $this->_uninstall_plugin_event( false );
2800
- $this->remove_sdk_reference();
2801
- }
2802
-
2803
- // Print '1' for successful operation.
2804
- echo 1;
2805
- exit;
2806
- }
2807
-
2808
- #--------------------------------------------------------------------------------
2809
- #region Deactivation Feedback Snoozing
2810
- #--------------------------------------------------------------------------------
2811
-
2812
- /**
2813
- * @author Vova Feldman (@svovaf)
2814
- * @since 2.4.3
2815
- *
2816
- * @param int $period
2817
- *
2818
- * @return bool True if the value was set, false otherwise.
2819
- */
2820
- private static function snooze_deactivation_form( $period ) {
2821
- return ( 0 < $period && self::reset_deactivation_snoozing( $period ) );
2822
- }
2823
-
2824
- /**
2825
- * Check if deactivation feedback form is snoozed.
2826
- *
2827
- * @author Vova Feldman (@svovaf)
2828
- * @since 2.4.3
2829
- *
2830
- * @return bool
2831
- */
2832
- static function is_deactivation_snoozed() {
2833
- $is_snoozed = ( ! is_multisite() || fs_is_network_admin() ) ?
2834
- get_transient( 'fs_snooze_period' ) :
2835
- get_site_transient( 'fs_snooze_period' );
2836
-
2837
-
2838
- return ( 'true' === $is_snoozed );
2839
- }
2840
-
2841
- /**
2842
- * Reset deactivation snoozing. When `$period` is `0` will stop deactivation snoozing by deleting the transients. Otherwise, will set the transients for the selected period.
2843
- *
2844
- * @param int $period Period in seconds.
2845
- *
2846
- * @author Vova Feldman (@svovaf)
2847
- * @since 2.4.3
2848
- */
2849
- private static function reset_deactivation_snoozing( $period = 0 ) {
2850
- $value = ( 0 === $period ) ? null : 'true';
2851
-
2852
- if ( ! is_multisite() || fs_is_network_admin() ) {
2853
- return set_transient( 'fs_snooze_period', $value, $period );
2854
- } else {
2855
- return set_site_transient( 'fs_snooze_period', $value, $period );
2856
- }
2857
- }
2858
-
2859
- /**
2860
- * The deactivation snooze expiration UNIX timestamp (in sec).
2861
- *
2862
- * @author Vova Feldman (@svovaf)
2863
- * @since 2.4.3
2864
- *
2865
- * @return int
2866
- */
2867
- static function deactivation_snooze_expires_at() {
2868
- return ( ! is_multisite() || fs_is_network_admin() ) ?
2869
- (int) get_option( '_transient_timeout_fs_snooze_period' ) :
2870
- (int) get_site_option( '_site_transient_timeout_fs_snooze_period' );
2871
- }
2872
-
2873
- #endregion
2874
-
2875
- /**
2876
- * @author Leo Fajardo (@leorw)
2877
- * @since 2.1.4
2878
- */
2879
- function cancel_subscription_or_trial_ajax_action() {
2880
- $this->_logger->entrance();
2881
-
2882
- $this->check_ajax_referer( 'cancel_subscription_or_trial' );
2883
-
2884
- $result = $this->cancel_subscription_or_trial( fs_request_get( 'plugin_id', $this->get_id() ), false );
2885
-
2886
- if ( $this->is_api_error( $result ) ) {
2887
- $this->shoot_ajax_failure( $result->error->message );
2888
- }
2889
-
2890
- $this->shoot_ajax_success();
2891
- }
2892
-
2893
- /**
2894
- * @author Leo Fajardo (@leorw)
2895
- * @since 2.1.4
2896
- *
2897
- * @param number $plugin_id
2898
- *
2899
- * @return object
2900
- */
2901
- private function cancel_subscription_or_trial( $plugin_id ) {
2902
- $fs = null;
2903
- if ( $plugin_id == $this->get_id() ) {
2904
- $fs = $this;
2905
- } else if ( $this->is_addon_activated( $plugin_id ) ) {
2906
- $fs = self::get_instance_by_id( $plugin_id );
2907
- }
2908
-
2909
- $result = null;
2910
-
2911
- if ( ! is_null( $fs ) ) {
2912
- $result = $fs->is_paid_trial() ?
2913
- $fs->_cancel_trial() :
2914
- $fs->_downgrade_site();
2915
- }
2916
-
2917
- return $result;
2918
- }
2919
-
2920
- /**
2921
- * @author Leo Fajardo (@leorw)
2922
- * @since 2.0.2
2923
- */
2924
- function _delete_theme_update_data_action() {
2925
- FS_Plugin_Updater::instance( $this )->delete_update_data();
2926
- }
2927
-
2928
- #endregion
2929
-
2930
- #----------------------------------------------------------------------------------
2931
- #region Instance
2932
- #----------------------------------------------------------------------------------
2933
-
2934
- /**
2935
- * Main singleton instance.
2936
- *
2937
- * @author Vova Feldman (@svovaf)
2938
- * @since 1.0.0
2939
- *
2940
- * @param number $module_id
2941
- * @param string|bool $slug
2942
- * @param bool $is_init Is initiation sequence.
2943
- *
2944
- * @return Freemius|false
2945
- */
2946
- static function instance( $module_id, $slug = false, $is_init = false ) {
2947
- if ( empty( $module_id ) ) {
2948
- return false;
2949
- }
2950
-
2951
- /**
2952
- * Load the essential static data prior to initiating FS_Plugin_Manager since there's an essential MS network migration logic that needs to be executed prior to the initiation.
2953
- */
2954
- self::_load_required_static();
2955
-
2956
- if ( ! is_numeric( $module_id ) ) {
2957
- if ( ! $is_init && true === $slug ) {
2958
- $is_init = true;
2959
- }
2960
-
2961
- $slug = $module_id;
2962
-
2963
- $module = FS_Plugin_Manager::instance( $slug )->get();
2964
-
2965
- if ( is_object( $module ) ) {
2966
- $module_id = $module->id;
2967
- }
2968
- }
2969
-
2970
- $key = 'm_' . $module_id;
2971
-
2972
- if ( ! isset( self::$_instances[ $key ] ) ) {
2973
- self::$_instances[ $key ] = new Freemius( $module_id, $slug, $is_init );
2974
- }
2975
-
2976
- return self::$_instances[ $key ];
2977
- }
2978
-
2979
- /**
2980
- * @author Vova Feldman (@svovaf)
2981
- * @since 1.0.6
2982
- *
2983
- * @param number $addon_id
2984
- *
2985
- * @return bool
2986
- */
2987
- private static function has_instance( $addon_id ) {
2988
- return isset( self::$_instances[ 'm_' . $addon_id ] );
2989
- }
2990
-
2991
- /**
2992
- * @author Leo Fajardo (@leorw)
2993
- * @since 1.2.2
2994
- *
2995
- * @param string|number $id_or_slug
2996
- * @param string $module_type
2997
- *
2998
- * @return number|false
2999
- */
3000
- private static function get_module_id( $id_or_slug, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
3001
- if ( is_numeric( $id_or_slug ) ) {
3002
- return $id_or_slug;
3003
- }
3004
-
3005
- foreach ( self::$_instances as $instance ) {
3006
- // Also check the module type since there can be a plugin and a theme with the same slug.
3007
- if ( ( $module_type === $instance->get_module_type() ) && ( $id_or_slug === $instance->get_slug() ) ) {
3008
- return $instance->get_id();
3009
- }
3010
- }
3011
-
3012
- return false;
3013
- }
3014
-
3015
- /**
3016
- * @author Vova Feldman (@svovaf)
3017
- * @since 1.0.6
3018
- *
3019
- * @param number $id
3020
- *
3021
- * @return false|Freemius
3022
- */
3023
- static function get_instance_by_id( $id ) {
3024
- return isset ( self::$_instances[ 'm_' . $id ] ) ?
3025
- self::$_instances[ 'm_' . $id ] :
3026
- false;
3027
- }
3028
-
3029
- /**
3030
- *
3031
- * @author Vova Feldman (@svovaf)
3032
- * @since 1.0.1
3033
- *
3034
- * @param string $plugin_file
3035
- * @param string $module_type
3036
- *
3037
- * @return false|Freemius
3038
- */
3039
- static function get_instance_by_file( $plugin_file, $module_type = WP_FS__MODULE_TYPE_PLUGIN ) {
3040
- $slug = self::find_slug_by_basename( $plugin_file );
3041
-
3042
- return ( false !== $slug ) ?
3043
- self::instance( self::get_module_id( $slug, $module_type ) ) :
3044
- false;
3045
- }
3046
-
3047
- /**
3048
- * @author Vova Feldman (@svovaf)
3049
- * @since 1.0.6
3050
- *
3051
- * @return false|Freemius
3052
- */
3053
- function get_parent_instance() {
3054
- return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
3055
- }
3056
-
3057
- /**
3058
- * @author Vova Feldman (@svovaf)
3059
- * @since 1.0.6
3060
- *
3061
- * @param string|number $id_or_slug
3062
- *
3063
- * @return false|Freemius
3064
- */
3065
- function get_addon_instance( $id_or_slug ) {
3066
- $addon_id = self::get_module_id( $id_or_slug );
3067
-
3068
- return self::instance( $addon_id );
3069
- }
3070
-
3071
- /**
3072
- * @return Freemius[]
3073
- */
3074
- static function _get_all_instances() {
3075
- return self::$_instances;
3076
- }
3077
-
3078
- #endregion ------------------------------------------------------------------
3079
-
3080
- /**
3081
- * @author Vova Feldman (@svovaf)
3082
- * @since 1.0.6
3083
- *
3084
- * @return bool
3085
- */
3086
- function is_parent_plugin_installed() {
3087
- $is_active = self::has_instance( $this->_plugin->parent_plugin_id );
3088
-
3089
- if ( $is_active ) {
3090
- return true;
3091
- }
3092
-
3093
- /**
3094
- * Parent module might be a theme. If that's the case, the add-on's FS
3095
- * instance will be loaded prior to the theme's FS instance, therefore,
3096
- * we need to check if it's active with a "look ahead".
3097
- *
3098
- * @author Vova Feldman
3099
- * @since 1.2.2.3
3100
- */
3101
- global $fs_active_plugins;
3102
- if ( is_object( $fs_active_plugins ) && is_array( $fs_active_plugins->plugins ) ) {
3103
- $active_theme = wp_get_theme();
3104
-
3105
- foreach ( $fs_active_plugins->plugins as $sdk => $module ) {
3106
- if ( WP_FS__MODULE_TYPE_THEME === $module->type ) {
3107
- if ( $module->plugin_path == $active_theme->get_stylesheet() ) {
3108
- // Parent module is a theme and it's currently active.
3109
- return true;
3110
- }
3111
- }
3112
- }
3113
- }
3114
-
3115
- return false;
3116
- }
3117
-
3118
- /**
3119
- * Check if add-on parent plugin in activation mode.
3120
- *
3121
- * @author Vova Feldman (@svovaf)
3122
- * @since 1.0.7
3123
- *
3124
- * @return bool
3125
- */
3126
- function is_parent_in_activation() {
3127
- $parent_fs = $this->get_parent_instance();
3128
- if ( ! is_object( $parent_fs ) ) {
3129
- return false;
3130
- }
3131
-
3132
- return ( $parent_fs->is_activation_mode() );
3133
- }
3134
-
3135
- /**
3136
- * Is plugin in activation mode.
3137
- *
3138
- * @author Vova Feldman (@svovaf)
3139
- * @since 1.0.7
3140
- *
3141
- * @param bool $and_on
3142
- *
3143
- * @return bool
3144
- */
3145
- function is_activation_mode( $and_on = true ) {
3146
- return fs_is_network_admin() ?
3147
- $this->is_network_activation_mode( $and_on ) :
3148
- $this->is_site_activation_mode( $and_on );
3149
- }
3150
-
3151
- /**
3152
- * Is plugin in activation mode.
3153
- *
3154
- * @author Vova Feldman (@svovaf)
3155
- * @since 1.0.7
3156
- *
3157
- * @param bool $and_on
3158
- *
3159
- * @return bool
3160
- */
3161
- function is_site_activation_mode( $and_on = true ) {
3162
- return (
3163
- ( $this->is_on() || ! $and_on ) &&
3164
- (
3165
- ( $this->is_premium() && true === $this->_storage->require_license_activation ) ||
3166
- (
3167
- ( ! $this->is_registered() ||
3168
- ( $this->is_only_premium() && ! $this->has_features_enabled_license() ) ) &&
3169
- ( ! $this->is_enable_anonymous() ||
3170
- ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
3171
- )
3172
- )
3173
- );
3174
- }
3175
-
3176
- /**
3177
- * Checks if the SDK in network activation mode.
3178
- *
3179
- * @author Leo Fajardo (@leorw)
3180
- * @since 2.0.0
3181
- *
3182
- * @param bool $and_on
3183
- *
3184
- * @return bool
3185
- */
3186
- private function is_network_activation_mode( $and_on = true ) {
3187
- if ( ! $this->_is_network_active ) {
3188
- // Not network activated.
3189
- return false;
3190
- }
3191
-
3192
- if ( $this->is_network_upgrade_mode() ) {
3193
- // Special flag to enforce network activation mode to decide what to do with the sites that are not yet opted-in nor skipped.
3194
- return true;
3195
- }
3196
-
3197
- if ( ! $this->is_site_activation_mode( $and_on ) ) {
3198
- // Whether the context is single site or the network, if the plugin is no longer in activation mode then it is not in network activation mode as well.
3199
- return false;
3200
- }
3201
-
3202
- if ( $this->is_network_delegated_connection() ) {
3203
- // Super-admin delegated the connection to the site admins -> not activation mode.
3204
- return false;
3205
- }
3206
-
3207
- if ( $this->is_network_anonymous() && true !== $this->_storage->require_license_activation ) {
3208
- // Super-admin skipped the connection network wide -> not activation mode.
3209
- return false;
3210
- }
3211
-
3212
- if ( $this->is_network_registered() ) {
3213
- // Super-admin connected at least one site -> not activation mode.
3214
- return false;
3215
- }
3216
-
3217
- return true;
3218
- }
3219
-
3220
- /**
3221
- * Check if current page is the opt-in/pending-activation page.
3222
- *
3223
- * @author Vova Feldman (@svovaf)
3224
- * @since 1.2.1.7
3225
- *
3226
- * @return bool
3227
- */
3228
- function is_activation_page() {
3229
- if ( $this->_menu->is_activation_page( $this->show_opt_in_on_themes_page() ) ) {
3230
- return true;
3231
- }
3232
-
3233
- if ( ! $this->is_activation_mode() ) {
3234
- return false;
3235
- }
3236
-
3237
- // Check if current page is matching the activation page.
3238
- return $this->is_matching_url( $this->get_activation_url() );
3239
- }
3240
-
3241
- /**
3242
- * Check if URL path's are matching and that all querystring
3243
- * arguments of the $sub_url exist in the $url with the same values.
3244
- *
3245
- * WARNING:
3246
- * 1. This method doesn't check if the sub/domain are matching.
3247
- * 2. Ignore case sensitivity.
3248
- *
3249
- * @author Vova Feldman (@svovaf)
3250
- * @since 1.2.1.7
3251
- *
3252
- * @param string $sub_url
3253
- * @param string $url If argument is not set, check if the sub_url matching the current's page URL.
3254
- *
3255
- * @return bool
3256
- */
3257
- private function is_matching_url( $sub_url, $url = '' ) {
3258
- if ( empty( $url ) ) {
3259
- $url = $_SERVER['REQUEST_URI'];
3260
- }
3261
-
3262
- $url = strtolower( $url );
3263
- $sub_url = strtolower( $sub_url );
3264
-
3265
- if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
3266
- // Different path - DO NOT OVERRIDE PAGE.
3267
- return false;
3268
- }
3269
-
3270
- $url_params = array();
3271
- parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
3272
-
3273
- $sub_url_params = array();
3274
- parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
3275
-
3276
- foreach ( $sub_url_params as $key => $val ) {
3277
- if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
3278
- // Not matching query string - DO NOT OVERRIDE PAGE.
3279
- return false;
3280
- }
3281
- }
3282
-
3283
- return true;
3284
- }
3285
-
3286
- /**
3287
- * Get the basenames of all active plugins for specific blog. Including network activated plugins.
3288
- *
3289
- * @author Vova Feldman (@svovaf)
3290
- * @since 2.0.0
3291
- *
3292
- * @param int $blog_id
3293
- *
3294
- * @return string[]
3295
- */
3296
- private static function get_active_plugins_basenames( $blog_id = 0 ) {
3297
- if ( is_multisite() && $blog_id > 0 ) {
3298
- $active_basenames = get_blog_option( $blog_id, 'active_plugins' );
3299
- } else {
3300
- $active_basenames = get_option( 'active_plugins' );
3301
- }
3302
-
3303
- if ( ! is_array( $active_basenames ) ) {
3304
- $active_basenames = array();
3305
- }
3306
-
3307
- if ( is_multisite() ) {
3308
- $network_active_basenames = get_site_option( 'active_sitewide_plugins' );
3309
-
3310
- if ( is_array( $network_active_basenames ) && ! empty( $network_active_basenames ) ) {
3311
- $active_basenames = array_merge( $active_basenames, array_keys( $network_active_basenames ) );
3312
- }
3313
- }
3314
-
3315
- return $active_basenames;
3316
- }
3317
-
3318
- /**
3319
- * @author Leo Fajardo (@leorw)
3320
- * @since 2.3.0
3321
- *
3322
- * @param int $blog_id
3323
- *
3324
- * @return array
3325
- */
3326
- static function get_active_plugins_directories_map( $blog_id = 0 ) {
3327
- $active_basenames = self::get_active_plugins_basenames( $blog_id );
3328
-
3329
- $map = array();
3330
-
3331
- foreach ( $active_basenames as $active_basename ) {
3332
- $active_basename = fs_normalize_path( $active_basename );
3333
-
3334
- if ( false === strpos( $active_basename, '/' ) ) {
3335
- continue;
3336
- }
3337
-
3338
- $map[ dirname( $active_basename ) ] = true;
3339
- }
3340
-
3341
- return $map;
3342
- }
3343
-
3344
- /**
3345
- * Get collection of all active plugins. Including network activated plugins.
3346
- *
3347
- * @author Vova Feldman (@svovaf)
3348
- * @since 1.0.9
3349
- *
3350
- * @param int $blog_id Since 2.0.0
3351
- *
3352
- * @return array[string]array
3353
- */
3354
- private static function get_active_plugins( $blog_id = 0 ) {
3355
- self::require_plugin_essentials();
3356
-
3357
- $active_plugin = array();
3358
- $all_plugins = fs_get_plugins();
3359
- $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
3360
-
3361
- foreach ( $active_plugins_basenames as $plugin_basename ) {
3362
- $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
3363
- }
3364
-
3365
- return $active_plugin;
3366
- }
3367
-
3368
- /**
3369
- * Get collection of all site active plugins for a specified blog.
3370
- *
3371
- * @author Vova Feldman (@svovaf)
3372
- * @since 2.0.0
3373
- *
3374
- * @param int $blog_id
3375
- *
3376
- * @return array[string]array
3377
- */
3378
- private static function get_site_active_plugins( $blog_id = 0 ) {
3379
- $active_basenames = ( is_multisite() && $blog_id > 0 ) ?
3380
- get_blog_option( $blog_id, 'active_plugins' ) :
3381
- get_option( 'active_plugins' );
3382
-
3383
- $active = array();
3384
-
3385
- if ( ! is_array( $active_basenames ) ) {
3386
- return $active;
3387
- }
3388
-
3389
- foreach ( $active_basenames as $basename ) {
3390
- $active[ $basename ] = array(
3391
- 'is_active' => true,
3392
- 'Version' => '1.0', // Dummy version.
3393
- 'slug' => self::get_plugin_slug( $basename ),
3394
- );
3395
- }
3396
-
3397
- return $active;
3398
- }
3399
-
3400
- /**
3401
- * Get collection of all plugins with their activation status for a specified blog.
3402
- *
3403
- * @author Vova Feldman (@svovaf)
3404
- * @since 1.1.8
3405
- *
3406
- * @param int $blog_id Since 2.0.0
3407
- *
3408
- * @return array Key is the plugin file path and the value is an array of the plugin data.
3409
- */
3410
- private static function get_all_plugins( $blog_id = 0 ) {
3411
- self::require_plugin_essentials();
3412
-
3413
- $all_plugins = fs_get_plugins();
3414
-
3415
- $active_plugins_basenames = self::get_active_plugins_basenames( $blog_id );
3416
-
3417
- foreach ( $all_plugins as $basename => &$data ) {
3418
- // By default set to inactive (next foreach update the active plugins).
3419
- $data['is_active'] = false;
3420
- // Enrich with plugin slug.
3421
- $data['slug'] = self::get_plugin_slug( $basename );
3422
- }
3423
-
3424
- // Flag active plugins.
3425
- foreach ( $active_plugins_basenames as $basename ) {
3426
- if ( isset( $all_plugins[ $basename ] ) ) {
3427
- $all_plugins[ $basename ]['is_active'] = true;
3428
- }
3429
- }
3430
-
3431
- return $all_plugins;
3432
- }
3433
-
3434
- /**
3435
- * Get collection of all plugins and if they are network level activated.
3436
- *
3437
- * @author Vova Feldman (@svovaf)
3438
- * @since 2.0.0
3439
- *
3440
- * @return array Key is the plugin basename and the value is an array of the plugin data.
3441
- */
3442
- private static function get_network_plugins() {
3443
- self::require_plugin_essentials();
3444
-
3445
- $all_plugins = fs_get_plugins();
3446
-
3447
- $network_active_basenames = is_multisite() ?
3448
- get_site_option( 'active_sitewide_plugins' ) :
3449
- array();
3450
-
3451
- foreach ( $all_plugins as $basename => &$data ) {
3452
- // By default set to inactive (next foreach update the active plugins).
3453
- $data['is_active'] = false;
3454
- // Enrich with plugin slug.
3455
- $data['slug'] = self::get_plugin_slug( $basename );
3456
- }
3457
-
3458
- // Flag active plugins.
3459
- foreach ( $network_active_basenames as $basename ) {
3460
- if ( isset( $all_plugins[ $basename ] ) ) {
3461
- $all_plugins[ $basename ]['is_active'] = true;
3462
- }
3463
- }
3464
-
3465
- return $all_plugins;
3466
- }
3467
-
3468
- /**
3469
- * Cached result of get_site_transient( 'update_plugins' )
3470
- *
3471
- * @author Vova Feldman (@svovaf)
3472
- * @since 1.1.8
3473
- *
3474
- * @var object
3475
- */
3476
- private static $_plugins_info;
3477
-
3478
- /**
3479
- * Helper function to get specified plugin's slug.
3480
- *
3481
- * @author Vova Feldman (@svovaf)
3482
- * @since 1.1.8
3483
- *
3484
- * @param $basename
3485
- *
3486
- * @return string
3487
- */
3488
- private static function get_plugin_slug( $basename ) {
3489
- if ( ! isset( self::$_plugins_info ) ) {
3490
- self::$_plugins_info = get_site_transient( 'update_plugins' );
3491
- }
3492
-
3493
- $slug = '';
3494
-
3495
- if ( is_object( self::$_plugins_info ) ) {
3496
- if ( isset( self::$_plugins_info->no_update ) &&
3497
- isset( self::$_plugins_info->no_update[ $basename ] ) &&
3498
- ! empty( self::$_plugins_info->no_update[ $basename ]->slug )
3499
- ) {
3500
- $slug = self::$_plugins_info->no_update[ $basename ]->slug;
3501
- } else if ( isset( self::$_plugins_info->response ) &&
3502
- isset( self::$_plugins_info->response[ $basename ] ) &&
3503
- ! empty( self::$_plugins_info->response[ $basename ]->slug )
3504
- ) {
3505
- $slug = self::$_plugins_info->response[ $basename ]->slug;
3506
- }
3507
- }
3508
-
3509
- if ( empty( $slug ) ) {
3510
- // Try to find slug from FS data.
3511
- $slug = self::find_slug_by_basename( $basename );
3512
- }
3513
-
3514
- if ( empty( $slug ) ) {
3515
- // Fallback to plugin's folder name.
3516
- $slug = dirname( $basename );
3517
- }
3518
-
3519
- return $slug;
3520
- }
3521
-
3522
- private static $_statics_loaded = false;
3523
-
3524
- /**
3525
- * Load static resources.
3526
- *
3527
- * @author Vova Feldman (@svovaf)
3528
- * @since 1.0.1
3529
- */
3530
- private static function _load_required_static() {
3531
- if ( self::$_statics_loaded ) {
3532
- return;
3533
- }
3534
-
3535
- self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
3536
-
3537
- self::$_static_logger->entrance();
3538
-
3539
- self::$_accounts = FS_Options::instance( WP_FS__ACCOUNTS_OPTION_NAME, true );
3540
-
3541
- if ( is_multisite() ) {
3542
- $has_skipped_migration = (
3543
- // 'id_slug_type_path_map' - was never stored on older versions, therefore, not exists on the site level.
3544
- null === self::$_accounts->get_option( 'id_slug_type_path_map', null, false ) &&
3545
- // 'file_slug_map' stored on the site level, so it was running an SDK version before it was integrated with MS-network.
3546
- null !== self::$_accounts->get_option( 'file_slug_map', null, false )
3547
- );
3548
-
3549
- /**
3550
- * If the file_slug_map exists on the site level but doesn't exist on the
3551
- * network level storage, it means that we need to process the storage with migration.
3552
- *
3553
- * The code in this `if` scope will only be executed once and only for the first site that will execute it because once we migrate the storage data, file_slug_map will be already set in the network level storage.
3554
- *
3555
- * @author Vova Feldman (@svovaf)
3556
- * @since 2.0.0
3557
- */
3558
- if (
3559
- ( $has_skipped_migration && true !== self::$_accounts->get_option( 'ms_migration_complete', false, true ) ) ||
3560
- ( null === self::$_accounts->get_option( 'file_slug_map', null, true ) &&
3561
- null !== self::$_accounts->get_option( 'file_slug_map', null, false ) )
3562
- ) {
3563
- self::migrate_options_to_network();
3564
- }
3565
- }
3566
-
3567
- self::$_global_admin_notices = FS_Admin_Notices::instance( 'global' );
3568
-
3569
- if ( ! WP_FS__DEMO_MODE ) {
3570
- add_action( ( fs_is_network_admin() ? 'network_' : '' ) . 'admin_menu', array(
3571
- 'Freemius',
3572
- '_add_debug_section'
3573
- ) );
3574
- }
3575
-
3576
- add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
3577
-
3578
- self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
3579
-
3580
- self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
3581
-
3582
- self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
3583
-
3584
- if ( 0 == did_action( 'plugins_loaded' ) ) {
3585
- add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
3586
- }
3587
-
3588
- $clone_manager = FS_Clone_Manager::instance();
3589
- add_action( 'init', array( $clone_manager, '_init' ) );
3590
-
3591
- add_action( 'admin_footer', array( 'Freemius', '_enrich_ajax_url' ) );
3592
- add_action( 'admin_footer', array( 'Freemius', '_open_support_forum_in_new_page' ) );
3593
-
3594
- if ( self::is_plugins_page() || self::is_themes_page() ) {
3595
- add_action( 'admin_print_footer_scripts', array( 'Freemius', '_maybe_add_beta_label_styles' ), 9 );
3596
-
3597
- /**
3598
- * Specifically use this hook so that the JS event handlers will work properly on the "Themes"
3599
- * page.
3600
- *
3601
- * @author Leo Fajardo (@leorw)
3602
- * @since 2.3.0
3603
- */
3604
- add_action( 'admin_footer-' . self::get_current_page(), array( 'Freemius', '_maybe_add_beta_label_to_plugins_and_handle_confirmation') );
3605
- }
3606
-
3607
- self::$_statics_loaded = true;
3608
- }
3609
-
3610
- #--------------------------------------------------------------------------------
3611
- #region Clone
3612
- #--------------------------------------------------------------------------------
3613
-
3614
- /**
3615
- * @author Leo Fajardo (@leorw)
3616
- * @since 2.5.0
3617
- *
3618
- * @return bool
3619
- */
3620
- private function is_unresolved_clone() {
3621
- if ( ! $this->is_clone() ) {
3622
- return false;
3623
- }
3624
-
3625
- return FS_Clone_Manager::instance()->has_temporary_duplicate_mode_expired();
3626
- }
3627
-
3628
- /**
3629
- * @author Leo Fajardo (@leorw)
3630
- * @since 2.5.0
3631
- */
3632
- function is_clone() {
3633
- if ( ! is_object( $this->_site ) ) {
3634
- return false;
3635
- }
3636
-
3637
- return (
3638
- fs_strip_url_protocol( trailingslashit( $this->_site->url ) ) !== fs_strip_url_protocol( trailingslashit( self::get_site_url() ) )
3639
- );
3640
- }
3641
-
3642
- /**
3643
- * @author Leo Fajardo (@leorw)
3644
- * @since 2.5.0
3645
- *
3646
- * @param int|null $blog_id
3647
- *
3648
- * @return string
3649
- */
3650
- static function get_site_url( $blog_id = null ) {
3651
- global $wp_filter;
3652
-
3653
- $site_url_filters = array(
3654
- 'site_url' => null,
3655
- 'pre_option_siteurl' => null,
3656
- 'default_option_siteurl' => null,
3657
- 'option_siteurl' => null,
3658
- );
3659
-
3660
- foreach ( $site_url_filters as $hook_name => $site_url_filter ) {
3661
- if ( ! empty( $wp_filter[ $hook_name ] ) ) {
3662
- $site_url_filters[ $hook_name ] = $wp_filter[ $hook_name ];
3663
- unset( $wp_filter[ $hook_name ] );
3664
- }
3665
- }
3666
-
3667
- $url = get_site_url( $blog_id );
3668
-
3669
- foreach ( $site_url_filters as $hook_name => $site_url_filter ) {
3670
- if ( ! empty( $site_url_filter ) ) {
3671
- $wp_filter[ $hook_name ] = $site_url_filter;
3672
- }
3673
- }
3674
-
3675
- return $url;
3676
- }
3677
-
3678
- /**
3679
- * @author Leo Fajardo (@leorw)
3680
- * @since 2.5.0
3681
- *
3682
- * @param number $site_id
3683
- */
3684
- function fetch_install_by_id( $site_id ) {
3685
- return $this->get_current_or_network_user_api_scope()->get( "/installs/{$site_id}.json" );
3686
- }
3687
-
3688
- /**
3689
- * @author Leo Fajardo (@leorw)
3690
- * @since 2.5.0
3691
- *
3692
- * @return string|object|bool
3693
- */
3694
- function _handle_long_term_duplicate() {
3695
- $this->_logger->entrance();
3696
-
3697
- $this->delete_current_install( false );
3698
-
3699
- $license_key = false;
3700
-
3701
- if (
3702
- is_object( $this->_license ) &&
3703
- ! $this->_license->is_utilized(
3704
- ( WP_FS__IS_LOCALHOST_FOR_SERVER || FS_Site::is_localhost_by_address( self::get_site_url() ) )
3705
- )
3706
- ) {
3707
- $license_key = $this->_license->secret_key;
3708
- }
3709
-
3710
- return $this->opt_in(
3711
- false,
3712
- false,
3713
- false,
3714
- $license_key,
3715
- false,
3716
- false,
3717
- false,
3718
- null,
3719
- array(),
3720
- false
3721
- );
3722
- }
3723
-
3724
- #endregion
3725
-
3726
- /**
3727
- * @author Leo Fajardo (@leorw)
3728
- *
3729
- * @since 2.1.3
3730
- */
3731
- private static function migrate_options_to_network() {
3732
- self::migrate_accounts_to_network();
3733
-
3734
- // Migrate API options from site level to network level.
3735
- $api_network_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true, true );
3736
- $api_network_options->migrate_to_network();
3737
-
3738
- // Migrate API cache to network level storage.
3739
- FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME )->migrate_to_network();
3740
-
3741
- self::$_accounts->set_option( 'ms_migration_complete', true, true );
3742
- }
3743
-
3744
- #----------------------------------------------------------------------------------
3745
- #region Localization
3746
- #----------------------------------------------------------------------------------
3747
-
3748
- /**
3749
- * Load framework's text domain.
3750
- *
3751
- * @author Vova Feldman (@svovaf)
3752
- * @since 1.2.1
3753
- */
3754
- static function _load_textdomain() {
3755
- if ( ! is_admin() ) {
3756
- return;
3757
- }
3758
-
3759
- global $fs_active_plugins;
3760
-
3761
- // Works both for plugins and themes.
3762
- load_plugin_textdomain(
3763
- 'freemius',
3764
- false,
3765
- $fs_active_plugins->newest->sdk_path . '/languages/'
3766
- );
3767
- }
3768
-
3769
- #endregion
3770
-
3771
- #----------------------------------------------------------------------------------
3772
- #region Debugging
3773
- #----------------------------------------------------------------------------------
3774
-
3775
- /**
3776
- * @author Vova Feldman (@svovaf)
3777
- * @since 1.0.8
3778
- */
3779
- static function _add_debug_section() {
3780
- if ( ! is_super_admin() ) {
3781
- // Add debug page only for super-admins.
3782
- return;
3783
- }
3784
-
3785
- self::$_static_logger->entrance();
3786
-
3787
- $title = sprintf( '%s [v.%s]', fs_text_inline( 'Freemius Debug' ), WP_FS__SDK_VERSION );
3788
-
3789
- if ( WP_FS__DEV_MODE ) {
3790
- // Add top-level debug menu item.
3791
- $hook = FS_Admin_Menu_Manager::add_page(
3792
- $title,
3793
- $title,
3794
- 'manage_options',
3795
- 'freemius',
3796
- array( 'Freemius', '_debug_page_render' )
3797
- );
3798
- } else {
3799
- // Add hidden debug page.
3800
- $hook = FS_Admin_Menu_Manager::add_subpage(
3801
- null,
3802
- $title,
3803
- $title,
3804
- 'manage_options',
3805
- 'freemius',
3806
- array( 'Freemius', '_debug_page_render' )
3807
- );
3808
- }
3809
-
3810
- if ( ! empty( $hook ) ) {
3811
- add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
3812
- }
3813
- }
3814
-
3815
- /**
3816
- * @author Vova Feldman (@svovaf)
3817
- * @since 1.1.7.3
3818
- */
3819
- static function _toggle_debug_mode() {
3820
- check_admin_referer( 'fs_toggle_debug_mode' );
3821
-
3822
- if ( ! is_super_admin() ) {
3823
- return;
3824
- }
3825
-
3826
- $is_on = fs_request_get( 'is_on', false, 'post' );
3827
-
3828
- if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
3829
- update_option( 'fs_debug_mode', $is_on );
3830
-
3831
- // Turn on/off storage logging.
3832
- FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
3833
- }
3834
-
3835
- exit;
3836
- }
3837
-
3838
- /**
3839
- * @author Vova Feldman (@svovaf)
3840
- * @since 1.2.1.6
3841
- */
3842
- static function _get_debug_log() {
3843
- check_admin_referer( 'fs_get_debug_log' );
3844
-
3845
- if ( ! is_super_admin() ) {
3846
- return;
3847
- }
3848
-
3849
- $limit = min( ! empty( $_POST['limit'] ) ? absint( $_POST['limit'] ) : 200, 200 );
3850
- $offset = min( ! empty( $_POST['offset'] ) ? absint( $_POST['offset'] ) : 200, 200 );
3851
-
3852
- $logs = FS_Logger::load_db_logs(
3853
- fs_request_get( 'filters', false, 'post' ),
3854
- $limit,
3855
- $offset
3856
- );
3857
-
3858
- self::shoot_ajax_success( $logs );
3859
- }
3860
-
3861
- /**
3862
- * @author Vova Feldman (@svovaf)
3863
- * @since 1.2.1.7
3864
- */
3865
- static function _get_db_option() {
3866
- check_admin_referer( 'fs_get_db_option' );
3867
-
3868
- $option_name = fs_request_get( 'option_name' );
3869
-
3870
- if ( ! is_super_admin() ||
3871
- ! fs_starts_with( $option_name, 'fs_' )
3872
- ) {
3873
- self::shoot_ajax_failure();
3874
- }
3875
-
3876
- $value = get_option( $option_name );
3877
-
3878
- $result = array(
3879
- 'name' => $option_name,
3880
- );
3881
-
3882
- if ( false !== $value ) {
3883
- if ( ! is_string( $value ) ) {
3884
- $value = json_encode( $value );
3885
- }
3886
-
3887
- $result['value'] = $value;
3888
- }
3889
-
3890
- self::shoot_ajax_success( $result );
3891
- }
3892
-
3893
- /**
3894
- * @author Vova Feldman (@svovaf)
3895
- * @since 1.2.1.7
3896
- */
3897
- static function _set_db_option() {
3898
- check_admin_referer( 'fs_set_db_option' );
3899
-
3900
- $option_name = fs_request_get( 'option_name' );
3901
-
3902
- if ( ! is_super_admin() ||
3903
- ! fs_starts_with( $option_name, 'fs_' )
3904
- ) {
3905
- self::shoot_ajax_failure();
3906
- }
3907
-
3908
- $option_value = fs_request_get( 'option_value' );
3909
-
3910
- if ( ! empty( $option_value ) ) {
3911
- update_option( $option_name, $option_value );
3912
- }
3913
-
3914
- self::shoot_ajax_success();
3915
- }
3916
-
3917
- /**
3918
- * @author Vova Feldman (@svovaf)
3919
- * @since 1.0.8
3920
- */
3921
- static function _debug_page_actions() {
3922
- self::_clean_admin_content_section();
3923
-
3924
- if ( fs_request_is_action( 'restart_freemius' ) ) {
3925
- check_admin_referer( 'restart_freemius' );
3926
-
3927
- if ( ! is_multisite() ) {
3928
- // Clear accounts data.
3929
- self::$_accounts->clear( null, true );
3930
- } else {
3931
- $sites = self::get_sites();
3932
- foreach ( $sites as $site ) {
3933
- $blog_id = self::get_site_blog_id( $site );
3934
- self::$_accounts->clear( $blog_id, true );
3935
- }
3936
-
3937
- // Clear network level storage.
3938
- self::$_accounts->clear( true, true );
3939
- }
3940
-
3941
- // Clear SDK reference cache.
3942
- delete_option( 'fs_active_plugins' );
3943
- } else if ( fs_request_is_action( 'clear_updates_data' ) ) {
3944
- check_admin_referer( 'clear_updates_data' );
3945
-
3946
- if ( ! is_multisite() ) {
3947
- set_site_transient( 'update_plugins', null );
3948
- set_site_transient( 'update_themes', null );
3949
- } else {
3950
- $current_blog_id = get_current_blog_id();
3951
-
3952
- $sites = self::get_sites();
3953
- foreach ( $sites as $site ) {
3954
- switch_to_blog( self::get_site_blog_id( $site ) );
3955
-
3956
- set_site_transient( 'update_plugins', null );
3957
- set_site_transient( 'update_themes', null );
3958
- }
3959
-
3960
- switch_to_blog( $current_blog_id );
3961
- }
3962
- } else if ( fs_request_is_action( 'reset_deactivation_snoozing' ) ) {
3963
- check_admin_referer( 'reset_deactivation_snoozing' );
3964
-
3965
- self::reset_deactivation_snoozing();
3966
- } else if ( fs_request_is_action( 'simulate_trial' ) ) {
3967
- check_admin_referer( 'simulate_trial' );
3968
-
3969
- $fs = freemius( fs_request_get( 'module_id' ) );
3970
-
3971
- // Update SDK install to at least 24 hours before.
3972
- $fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
3973
- // Unset the trial shown timestamp.
3974
- unset( $fs->_storage->trial_promotion_shown );
3975
- } else if ( fs_request_is_action( 'simulate_network_upgrade' ) ) {
3976
- check_admin_referer( 'simulate_network_upgrade' );
3977
-
3978
- $fs = freemius( fs_request_get( 'module_id' ) );
3979
-
3980
- self::set_network_upgrade_mode( $fs->_storage );
3981
- } else if ( fs_request_is_action( 'delete_install' ) ) {
3982
- check_admin_referer( 'delete_install' );
3983
-
3984
- self::_delete_site_by_slug(
3985
- fs_request_get( 'slug' ),
3986
- fs_request_get( 'module_type' ),
3987
- true,
3988
- fs_request_get( 'blog_id', null )
3989
- );
3990
- } else if ( fs_request_is_action( 'delete_user' ) ) {
3991
- check_admin_referer( 'delete_user' );
3992
-
3993
- self::delete_user( fs_request_get( 'user_id' ) );
3994
- } else if ( fs_request_is_action( 'download_logs' ) ) {
3995
- check_admin_referer( 'download_logs' );
3996
-
3997
- $download_url = FS_Logger::download_db_logs(
3998
- fs_request_get( 'filters', false, 'post' )
3999
- );
4000
-
4001
- if ( false === $download_url ) {
4002
- 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.' );
4003
- }
4004
-
4005
- fs_redirect( $download_url );
4006
- } else if ( fs_request_is_action( 'migrate_options_to_network' ) ) {
4007
- check_admin_referer( 'migrate_options_to_network' );
4008
-
4009
- self::migrate_options_to_network();
4010
- }
4011
- }
4012
-
4013
- /**
4014
- * @author Leo Fajardo (@leorw)
4015
- * @since 2.5.0
4016
- *
4017
- * @return array
4018
- */
4019
- static function get_all_modules_sites() {
4020
- self::$_static_logger->entrance();
4021
-
4022
- $sites_by_type = array(
4023
- WP_FS__MODULE_TYPE_PLUGIN => array(),
4024
- WP_FS__MODULE_TYPE_THEME => array(),
4025
- );
4026
-
4027
- $module_types = array_keys( $sites_by_type );
4028
-
4029
- if ( ! is_multisite() ) {
4030
- foreach ( $module_types as $type ) {
4031
- $sites_by_type[ $type ] = self::get_all_sites( $type );
4032
-
4033
- foreach ( $sites_by_type[ $type ] as $slug => $install ) {
4034
- $sites_by_type[ $type ][ $slug ] = array( $install );
4035
- }
4036
- }
4037
- } else {
4038
- $sites = self::get_sites();
4039
-
4040
- foreach ( $sites as $site ) {
4041
- $blog_id = self::get_site_blog_id( $site );
4042
-
4043
- foreach ( $module_types as $type ) {
4044
- $installs = self::get_all_sites( $type, $blog_id );
4045
-
4046
- foreach ( $installs as $slug => $install ) {
4047
- if ( ! isset( $sites_by_type[ $type ][ $slug ] ) ) {
4048
- $sites_by_type[ $type ][ $slug ] = array();
4049
- }
4050
-
4051
- $install->blog_id = $blog_id;
4052
-
4053
- $sites_by_type[ $type ][ $slug ][] = $install;
4054
- }
4055
-
4056
- }
4057
- }
4058
- }
4059
-
4060
- return $sites_by_type;
4061
- }
4062
-
4063
- /**
4064
- * @author Vova Feldman (@svovaf)
4065
- * @since 1.0.8
4066
- */
4067
- static function _debug_page_render() {
4068
- self::$_static_logger->entrance();
4069
-
4070
- $all_modules_sites = self::get_all_modules_sites();
4071
-
4072
- $licenses_by_module_type = self::get_all_licenses_by_module_type();
4073
-
4074
- $vars = array(
4075
- 'plugin_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_PLUGIN ],
4076
- 'theme_sites' => $all_modules_sites[ WP_FS__MODULE_TYPE_THEME ],
4077
- 'users' => self::get_all_users(),
4078
- 'addons' => self::get_all_addons(),
4079
- 'account_addons' => self::get_all_account_addons(),
4080
- 'plugin_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_PLUGIN ],
4081
- 'theme_licenses' => $licenses_by_module_type[ WP_FS__MODULE_TYPE_THEME ]
4082
- );
4083
-
4084
- fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
4085
- fs_require_once_template( 'debug.php', $vars );
4086
- }
4087
-
4088
- #endregion
4089
-
4090
- #----------------------------------------------------------------------------------
4091
- #region Connectivity Issues
4092
- #----------------------------------------------------------------------------------
4093
-
4094
- /**
4095
- * Check if Freemius should be turned on for the current plugin install.
4096
- *
4097
- * Note:
4098
- * $this->_is_on is updated in has_api_connectivity()
4099
- *
4100
- * @author Vova Feldman (@svovaf)
4101
- * @since 1.0.9
4102
- *
4103
- * @return bool
4104
- */
4105
- function is_on() {
4106
- self::$_static_logger->entrance();
4107
-
4108
- if ( is_object( $this->_site ) && ! $this->is_registered() ) {
4109
- return false;
4110
- }
4111
-
4112
- if ( isset( $this->_is_on ) ) {
4113
- return $this->_is_on;
4114
- }
4115
-
4116
- // If already installed or pending then sure it's on :)
4117
- if ( $this->is_registered() || $this->is_pending_activation() ) {
4118
- $this->_is_on = true;
4119
-
4120
- return true;
4121
- }
4122
-
4123
- return false;
4124
- }
4125
-
4126
- /**
4127
- * @author Vova Feldman (@svovaf)
4128
- * @since 1.1.7.3
4129
- *
4130
- * @param bool $flush_if_no_connectivity
4131
- *
4132
- * @return bool
4133
- */
4134
- private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
4135
- if ( ! isset( $this->_storage->connectivity_test ) ) {
4136
- // Connectivity test was never executed, or cache was cleared.
4137
- return true;
4138
- }
4139
-
4140
- if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
4141
- if ( WP_FS__IS_HTTP_REQUEST ) {
4142
- if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
4143
- // Domain changed.
4144
- return true;
4145
- }
4146
-
4147
- if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
4148
- // Server IP changed.
4149
- return true;
4150
- }
4151
- }
4152
- }
4153
-
4154
- if ( $this->_storage->connectivity_test['is_connected'] &&
4155
- $this->_storage->connectivity_test['is_active']
4156
- ) {
4157
- // API connected and Freemius is active - no need to run connectivity check.
4158
- return false;
4159
- }
4160
-
4161
- if ( $flush_if_no_connectivity ) {
4162
- /**
4163
- * If explicitly asked to flush when no connectivity - do it only
4164
- * if at least 10 sec passed from the last API connectivity test.
4165
- */
4166
- return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
4167
- ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
4168
- }
4169
-
4170
- /**
4171
- * @since 1.1.7 Don't check for connectivity on plugin downgrade.
4172
- */
4173
- $version = $this->get_plugin_version();
4174
- if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
4175
- // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
4176
- return true;
4177
- }
4178
-
4179
- return false;
4180
- }
4181
-
4182
- /**
4183
- * @author Vova Feldman (@svovaf)
4184
- * @since 1.1.7.4
4185
- *
4186
- * @param int|null $blog_id Since 2.0.0.
4187
- * @param bool $is_gdpr_test Since 2.0.2. Perform only the GDPR test.
4188
- *
4189
- * @return object|false
4190
- */
4191
- private function ping( $blog_id = null, $is_gdpr_test = false ) {
4192
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
4193
- return false;
4194
- }
4195
-
4196
- $version = $this->get_plugin_version();
4197
-
4198
- $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
4199
-
4200
- $params = array(
4201
- 'is_update' => json_encode( $is_update ),
4202
- 'version' => $version,
4203
- 'sdk' => $this->version,
4204
- 'is_admin' => json_encode( is_admin() ),
4205
- 'is_ajax' => json_encode( self::is_ajax() ),
4206
- 'is_cron' => json_encode( self::is_cron() ),
4207
- 'is_gdpr_test' => $is_gdpr_test,
4208
- 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
4209
- );
4210
-
4211
- if ( is_multisite() && function_exists( 'get_network' ) ) {
4212
- $params['network_uid'] = $this->get_anonymous_network_id();
4213
- }
4214
-
4215
- return $this->get_api_plugin_scope()->ping(
4216
- $this->get_anonymous_id( $blog_id ),
4217
- $params
4218
- );
4219
- }
4220
-
4221
- /**
4222
- * Check if there's any connectivity issue to Freemius API.
4223
- *
4224
- * @author Vova Feldman (@svovaf)
4225
- * @since 1.0.9
4226
- *
4227
- * @param bool $flush_if_no_connectivity
4228
- *
4229
- * @return bool
4230
- */
4231
- function has_api_connectivity( $flush_if_no_connectivity = false ) {
4232
- $this->_logger->entrance();
4233
-
4234
- if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
4235
- return $this->_has_api_connection;
4236
- }
4237
-
4238
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
4239
- isset( $this->_storage->connectivity_test ) &&
4240
- true === $this->_storage->connectivity_test['is_connected']
4241
- ) {
4242
- unset( $this->_storage->connectivity_test );
4243
- }
4244
-
4245
- if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
4246
- $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
4247
- /**
4248
- * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
4249
- *
4250
- * @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.
4251
- */
4252
- $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
4253
- $this->is_premium() ||
4254
- ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
4255
-
4256
- return $this->_has_api_connection;
4257
- }
4258
-
4259
- $pong = $this->ping();
4260
- $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
4261
-
4262
- if ( ! $is_connected ) {
4263
- // API failure.
4264
- $this->_add_connectivity_issue_message( $pong );
4265
- }
4266
-
4267
- if ( $is_connected ) {
4268
- FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
4269
- }
4270
-
4271
- $this->store_connectivity_info( $pong, $is_connected );
4272
-
4273
- return $this->_has_api_connection;
4274
- }
4275
-
4276
- /**
4277
- * @author Vova Feldman (@svovaf)
4278
- * @since 1.1.7.4
4279
- *
4280
- * @param object $pong
4281
- * @param bool $is_connected
4282
- */
4283
- private function store_connectivity_info( $pong, $is_connected ) {
4284
- $this->_logger->entrance();
4285
-
4286
- $version = $this->get_plugin_version();
4287
-
4288
- if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
4289
- $is_active = false;
4290
- } else {
4291
- $is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
4292
- }
4293
-
4294
- $is_active = $this->apply_filters(
4295
- 'is_on',
4296
- $is_active,
4297
- $this->is_plugin_update(),
4298
- $version
4299
- );
4300
-
4301
- $this->_storage->connectivity_test = array(
4302
- 'is_connected' => $is_connected,
4303
- 'host' => $_SERVER['HTTP_HOST'],
4304
- 'server_ip' => WP_FS__REMOTE_ADDR,
4305
- 'is_active' => $is_active,
4306
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
4307
- // Last version with connectivity attempt.
4308
- 'version' => $version,
4309
- );
4310
-
4311
- $this->_has_api_connection = $is_connected;
4312
- $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
4313
- }
4314
-
4315
- /**
4316
- * Force turning Freemius on.
4317
- *
4318
- * @author Vova Feldman (@svovaf)
4319
- * @since 1.1.8.1
4320
- *
4321
- * @return bool TRUE if successfully turned on.
4322
- */
4323
- private function turn_on() {
4324
- $this->_logger->entrance();
4325
-
4326
- if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
4327
- return false;
4328
- }
4329
-
4330
- $updated_connectivity = $this->_storage->connectivity_test;
4331
- $updated_connectivity['is_active'] = true;
4332
- $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
4333
- $this->_storage->connectivity_test = $updated_connectivity;
4334
-
4335
- $this->_is_on = true;
4336
-
4337
- return true;
4338
- }
4339
-
4340
- /**
4341
- * Anonymous and unique site identifier (Hash).
4342
- *
4343
- * @author Vova Feldman (@svovaf)
4344
- * @since 1.1.0
4345
- *
4346
- * @param null|int $blog_id Since 2.0.0
4347
- *
4348
- * @return string
4349
- */
4350
- function get_anonymous_id( $blog_id = null ) {
4351
- $unique_id = self::$_accounts->get_option( 'unique_id', null, $blog_id );
4352
-
4353
- if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
4354
- $key = fs_strip_url_protocol( self::get_site_url( $blog_id ) );
4355
-
4356
- $secure_auth = defined( 'SECURE_AUTH_KEY' ) ? SECURE_AUTH_KEY : '';
4357
- if ( empty( $secure_auth ) ||
4358
- false !== strpos( $secure_auth, ' ' ) ||
4359
- 'put your unique phrase here' === $secure_auth
4360
- ) {
4361
- // Protect against default auth key.
4362
- $secure_auth = md5( microtime() );
4363
- }
4364
-
4365
- /**
4366
- * Base the unique identifier on the WP secure authentication key. Which
4367
- * turns the key into a secret anonymous identifier. This will help us
4368
- * to avoid duplicate installs generation on the backend upon opt-in.
4369
- *
4370
- * @author Vova Feldman (@svovaf)
4371
- * @since 1.2.3
4372
- */
4373
- $unique_id = md5( $key . $secure_auth );
4374
-
4375
- self::$_accounts->set_option( 'unique_id', $unique_id, true, $blog_id );
4376
- }
4377
-
4378
- $this->_logger->departure( $unique_id );
4379
-
4380
- return $unique_id;
4381
- }
4382
-
4383
- /**
4384
- * Returns anonymous network ID.
4385
- *
4386
- * @since 2.4.3
4387
- *
4388
- * @return string
4389
- */
4390
- function get_anonymous_network_id() {
4391
- return $this->get_anonymous_id( get_network()->site_id );
4392
- }
4393
-
4394
- /**
4395
- * @author Vova Feldman (@svovaf)
4396
- * @since 1.1.7.4
4397
- *
4398
- * @return \WP_User
4399
- */
4400
- static function _get_current_wp_user() {
4401
- self::require_pluggable_essentials();
4402
- self::wp_cookie_constants();
4403
-
4404
- return wp_get_current_user();
4405
- }
4406
-
4407
- /**
4408
- * Define cookie constants which are required by Freemius::_get_current_wp_user() since
4409
- * it uses wp_get_current_user() which needs the cookie constants set. When a plugin
4410
- * is network activated the cookie constants are only configured after the network
4411
- * plugins activation, therefore, if we don't define those constants WP will throw
4412
- * PHP warnings/notices.
4413
- *
4414
- * @author Vova Feldman (@svovaf)
4415
- * @since 2.1.1
4416
- */
4417
- private static function wp_cookie_constants() {
4418
- if ( defined( 'LOGGED_IN_COOKIE' ) &&
4419
- ( defined( 'AUTH_COOKIE' ) || defined( 'SECURE_AUTH_COOKIE' ) )
4420
- ) {
4421
- return;
4422
- }
4423
-
4424
- /**
4425
- * Used to guarantee unique hash cookies
4426
- *
4427
- * @since 1.5.0
4428
- */
4429
- if ( ! defined( 'COOKIEHASH' ) ) {
4430
- $siteurl = get_site_option( 'siteurl' );
4431
- if ( $siteurl ) {
4432
- define( 'COOKIEHASH', md5( $siteurl ) );
4433
- } else {
4434
- define( 'COOKIEHASH', '' );
4435
- }
4436
- }
4437
-
4438
- if ( ! defined( 'LOGGED_IN_COOKIE' ) ) {
4439
- define( 'LOGGED_IN_COOKIE', 'wordpress_logged_in_' . COOKIEHASH );
4440
- }
4441
-
4442
- /**
4443
- * @since 2.5.0
4444
- */
4445
- if ( ! defined( 'AUTH_COOKIE' ) ) {
4446
- define( 'AUTH_COOKIE', 'wordpress_' . COOKIEHASH );
4447
- }
4448
-
4449
- /**
4450
- * @since 2.6.0
4451
- */
4452
- if ( ! defined( 'SECURE_AUTH_COOKIE' ) ) {
4453
- define( 'SECURE_AUTH_COOKIE', 'wordpress_sec_' . COOKIEHASH );
4454
- }
4455
- }
4456
-
4457
- /**
4458
- * @author Vova Feldman (@svovaf)
4459
- * @since 2.1.0
4460
- *
4461
- * @return int
4462
- */
4463
- static function get_current_wp_user_id() {
4464
- $wp_user = self::_get_current_wp_user();
4465
-
4466
- return $wp_user->ID;
4467
- }
4468
-
4469
- /**
4470
- * @author Vova Feldman (@svovaf)
4471
- * @since 1.2.1.7
4472
- *
4473
- * @param string $email
4474
- *
4475
- * @return bool
4476
- */
4477
- static function is_valid_email( $email ) {
4478
- if ( false === filter_var( $email, FILTER_VALIDATE_EMAIL ) ) {
4479
- return false;
4480
- }
4481
-
4482
- $parts = explode( '@', $email );
4483
-
4484
- if ( 2 !== count( $parts ) || empty( $parts[1] ) ) {
4485
- return false;
4486
- }
4487
-
4488
- $blacklist = array(
4489
- 'admin.',
4490
- 'webmaster.',
4491
- 'localhost.',
4492
- 'dev.',
4493
- 'development.',
4494
- 'test.',
4495
- 'stage.',
4496
- 'staging.',
4497
- );
4498
-
4499
- // Make sure domain is not one of the blacklisted.
4500
- foreach ( $blacklist as $invalid ) {
4501
- if ( 0 === strpos( $parts[1], $invalid ) ) {
4502
- return false;
4503
- }
4504
- }
4505
-
4506
- // Get the UTF encoded domain name.
4507
- $domain = idn_to_ascii( $parts[1] ) . '.';
4508
-
4509
- return ( checkdnsrr( $domain, 'MX' ) || checkdnsrr( $domain, 'A' ) );
4510
- }
4511
-
4512
- /**
4513
- * Generate API connectivity issue message.
4514
- *
4515
- * @author Vova Feldman (@svovaf)
4516
- * @since 1.0.9
4517
- *
4518
- * @param mixed $api_result
4519
- * @param bool $is_first_failure
4520
- */
4521
- function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
4522
- if ( ! $this->is_premium() && $this->_enable_anonymous ) {
4523
- // Don't add message if it's the free version and can run anonymously.
4524
- return;
4525
- }
4526
-
4527
- if ( ! function_exists( 'wp_nonce_url' ) ) {
4528
- require_once ABSPATH . 'wp-includes/functions.php';
4529
- }
4530
-
4531
- $current_user = self::_get_current_wp_user();
4532
- // $admin_email = get_option( 'admin_email' );
4533
- $admin_email = $current_user->user_email;
4534
-
4535
- // Aliases.
4536
- $deactivate_plugin_title = $this->esc_html_inline( 'That\'s exhausting, please deactivate', 'deactivate-plugin-title' );
4537
- $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' );
4538
- $install_previous_title = $this->esc_html_inline( 'Let\'s try your previous version', 'install-previous-title' );
4539
- $install_previous_desc = $this->esc_html_inline( 'Uninstall this version and install the previous one.', 'install-previous-desc' );
4540
- $fix_issue_title = $this->esc_html_inline( 'Yes - I\'m giving you a chance to fix it', 'fix-issue-title' );
4541
- $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' );
4542
- /* translators: %s: product title (e.g. "Awesome Plugin" requires an access to...) */
4543
- $x_requires_access_to_api = $this->esc_html_inline( '%s requires an access to our API.', 'x-requires-access-to-api' );
4544
- $sysadmin_title = $this->esc_html_inline( 'I\'m a system administrator', 'sysadmin-title' );
4545
- $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' );
4546
-
4547
- $message = false;
4548
- if ( is_object( $api_result ) &&
4549
- isset( $api_result->error ) &&
4550
- isset( $api_result->error->code )
4551
- ) {
4552
- switch ( $api_result->error->code ) {
4553
- case 'curl_missing':
4554
- $missing_methods = '';
4555
- if ( is_array( $api_result->missing_methods ) &&
4556
- ! empty( $api_result->missing_methods )
4557
- ) {
4558
- foreach ( $api_result->missing_methods as $m ) {
4559
- if ( 'curl_version' === $m ) {
4560
- continue;
4561
- }
4562
-
4563
- if ( ! empty( $missing_methods ) ) {
4564
- $missing_methods .= ', ';
4565
- }
4566
-
4567
- $missing_methods .= sprintf( '<code>%s</code>', $m );
4568
- }
4569
-
4570
- if ( ! empty( $missing_methods ) ) {
4571
- $missing_methods = sprintf(
4572
- '<br><br><b>%s</b> %s',
4573
- $this->esc_html_inline( 'Disabled method(s):', 'curl-disabled-methods' ),
4574
- $missing_methods
4575
- );
4576
- }
4577
- }
4578
-
4579
- $message = sprintf(
4580
- $x_requires_access_to_api . ' ' .
4581
- $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' ) . ' ' .
4582
- $missing_methods .
4583
- ' %s',
4584
- '<b>' . $this->get_plugin_name() . '</b>',
4585
- sprintf(
4586
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4587
- sprintf(
4588
- '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
4589
- $this->get_text_inline( 'I don\'t know what is cURL or how to install it, help me!', 'curl-missing-no-clue-title' ),
4590
- ' - ' . sprintf(
4591
- $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' ),
4592
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4593
- )
4594
- ),
4595
- sprintf(
4596
- '<b>%s</b> - %s',
4597
- $sysadmin_title,
4598
- 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 ) ) )
4599
- ),
4600
- sprintf(
4601
- '<a href="%s"><b>%s</b></a> - %s',
4602
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4603
- $deactivate_plugin_title,
4604
- $deactivate_plugin_desc
4605
- )
4606
- )
4607
- );
4608
- break;
4609
- case 'cloudflare_ddos_protection':
4610
- $message = sprintf(
4611
- $x_requires_access_to_api . ' ' .
4612
- $this->esc_html_inline( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'cloudflare-blocks-connection-message' ) . ' ' .
4613
- $happy_to_resolve_issue_asap .
4614
- ' %s',
4615
- '<b>' . $this->get_plugin_name() . '</b>',
4616
- sprintf(
4617
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4618
- sprintf(
4619
- '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
4620
- $fix_issue_title,
4621
- ' - ' . sprintf(
4622
- $fix_issue_desc,
4623
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4624
- )
4625
- ),
4626
- sprintf(
4627
- '<a href="%s" target="_blank" rel="noopener noreferrer"><b>%s</b></a> - %s',
4628
- sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
4629
- $install_previous_title,
4630
- $install_previous_desc
4631
- ),
4632
- sprintf(
4633
- '<a href="%s"><b>%s</b></a> - %s',
4634
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
4635
- $deactivate_plugin_title,
4636
- $deactivate_plugin_desc
4637
- )
4638
- )
4639
- );
4640
- break;
4641
- case 'squid_cache_block':
4642
- $message = sprintf(
4643
- $x_requires_access_to_api . ' ' .
4644
- $this->esc_html_inline( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'squid-blocks-connection-message' ) .
4645
- ' %s',
4646
- '<b>' . $this->get_plugin_name() . '</b>',
4647
- sprintf(
4648
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4649
- sprintf(
4650
- '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a> - %s',
4651
- $this->esc_html_inline( 'I don\'t know what is Squid or ACL, help me!', 'squid-no-clue-title' ),
4652
- sprintf(
4653
- $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' ),
4654
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4655
- )
4656
- ),
4657
- sprintf(
4658
- '<b>%s</b> - %s',
4659
- $sysadmin_title,
4660
- sprintf(
4661
- $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' ),
4662
- // We use a filter since the plugin might require additional API connectivity.
4663
- '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array(
4664
- 'api.freemius.com',
4665
- 'wp.freemius.com'
4666
- ) ) ) . '</b>',
4667
- $this->_module_type
4668
- )
4669
- ),
4670
- sprintf(
4671
- '<a href="%s"><b>%s</b></a> - %s',
4672
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4673
- $deactivate_plugin_title,
4674
- $deactivate_plugin_desc
4675
- )
4676
- )
4677
- );
4678
- break;
4679
- // default:
4680
- // $message = $this->get_text_inline( 'connectivity-test-fails-message' );
4681
- // break;
4682
- }
4683
- }
4684
-
4685
- $message_id = 'failed_connect_api';
4686
- $type = 'error';
4687
-
4688
- $connectivity_test_fails_message = $this->esc_html_inline( 'From unknown reason, the API connectivity test failed.', 'connectivity-test-fails-message' );
4689
-
4690
- if ( false === $message ) {
4691
- if ( $is_first_failure ) {
4692
- // First attempt failed.
4693
- $message = sprintf(
4694
- $x_requires_access_to_api . ' ' .
4695
- $connectivity_test_fails_message . ' ' .
4696
- $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>' .
4697
- '%s',
4698
- '<b>' . $this->get_plugin_name() . '</b>',
4699
- sprintf(
4700
- '<div id="fs_firewall_issue_options">%s %s</div>',
4701
- sprintf(
4702
- '<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
4703
- $this->get_text_inline( 'Yes - do your thing', 'yes-do-your-thing' )
4704
- ),
4705
- sprintf(
4706
- '<a href="%s" class="button">%s</a>',
4707
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4708
- $this->get_text_inline( 'No - just deactivate', 'no-deactivate' )
4709
- )
4710
- )
4711
- );
4712
-
4713
- $message_id = 'failed_connect_api_first';
4714
- $type = 'promotion';
4715
- } else {
4716
- // Second connectivity attempt failed.
4717
- $message = sprintf(
4718
- $x_requires_access_to_api . ' ' .
4719
- $connectivity_test_fails_message . ' ' .
4720
- $happy_to_resolve_issue_asap .
4721
- ' %s',
4722
- '<b>' . $this->get_plugin_name() . '</b>',
4723
- sprintf(
4724
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
4725
- sprintf(
4726
- '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
4727
- $fix_issue_title,
4728
- ' - ' . sprintf(
4729
- $fix_issue_desc,
4730
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4731
- )
4732
- ),
4733
- sprintf(
4734
- '<a href="%s" target="_blank" rel="noopener noreferrer"><b>%s</b></a> - %s',
4735
- sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
4736
- $install_previous_title,
4737
- $install_previous_desc
4738
- ),
4739
- sprintf(
4740
- '<a href="%s"><b>%s</b></a> - %s',
4741
- wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=all&amp;paged=1&amp;s=', 'deactivate-plugin_' . $this->_plugin_basename ),
4742
- $deactivate_plugin_title,
4743
- $deactivate_plugin_desc
4744
- )
4745
- )
4746
- );
4747
- }
4748
- }
4749
-
4750
- $this->_admin_notices->add_sticky(
4751
- $message,
4752
- $message_id,
4753
- $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
4754
- $type
4755
- );
4756
- }
4757
-
4758
- /**
4759
- * Handle user request to resolve connectivity issue.
4760
- * This method will send an email to Freemius API technical staff for resolution.
4761
- * The email will contain server's info and installed plugins (might be caching issue).
4762
- *
4763
- * @author Vova Feldman (@svovaf)
4764
- * @since 1.0.9
4765
- */
4766
- function _email_about_firewall_issue() {
4767
- check_admin_referer( 'fs_resolve_firewall_issues' );
4768
-
4769
- if ( ! current_user_can( is_multisite() ? 'manage_options' : 'activate_plugins' ) ) {
4770
- return;
4771
- }
4772
-
4773
- $this->_admin_notices->remove_sticky( 'failed_connect_api' );
4774
-
4775
- $pong = $this->ping();
4776
-
4777
- $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
4778
-
4779
- if ( $is_connected ) {
4780
- FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
4781
-
4782
- $this->store_connectivity_info( $pong, $is_connected );
4783
-
4784
- echo $this->get_after_plugin_activation_redirect_url();
4785
- exit;
4786
- }
4787
-
4788
- $current_user = self::_get_current_wp_user();
4789
- $admin_email = $current_user->user_email;
4790
-
4791
- $error_type = fs_request_get( 'error_type', 'general' );
4792
-
4793
- switch ( $error_type ) {
4794
- case 'squid':
4795
- $title = 'Squid ACL Blocking Issue';
4796
- break;
4797
- case 'cloudflare':
4798
- $title = 'CloudFlare Blocking Issue';
4799
- break;
4800
- default:
4801
- $title = 'API Connectivity Issue';
4802
- break;
4803
- }
4804
-
4805
- $custom_email_sections = array();
4806
-
4807
- // Add 'API Error' custom email section.
4808
- $custom_email_sections['api_error'] = array(
4809
- 'title' => 'API Error',
4810
- 'rows' => array(
4811
- 'ping' => array(
4812
- 'API Error',
4813
- is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
4814
- ),
4815
- )
4816
- );
4817
-
4818
- // Send email with technical details to resolve API connectivity issues.
4819
- $this->send_email(
4820
- 'api@freemius.com', // recipient
4821
- $title . ' [' . $this->get_plugin_name() . ']', // subject
4822
- $custom_email_sections,
4823
- array( "Reply-To: $admin_email <$admin_email>" ) // headers
4824
- );
4825
-
4826
- $this->_admin_notices->add_sticky(
4827
- sprintf(
4828
- $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' ),
4829
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
4830
- ),
4831
- 'server_details_sent'
4832
- );
4833
-
4834
- // Action was taken, tell that API connectivity troubleshooting should be off now.
4835
-
4836
- echo "1";
4837
- exit;
4838
- }
4839
-
4840
- /**
4841
- * Handle connectivity test retry approved by the user.
4842
- *
4843
- * @author Vova Feldman (@svovaf)
4844
- * @since 1.1.7.4
4845
- */
4846
- function _retry_connectivity_test() {
4847
- check_admin_referer( 'fs_retry_connectivity_test' );
4848
-
4849
- if ( ! current_user_can( is_multisite() ? 'manage_options' : 'activate_plugins' ) ) {
4850
- return;
4851
- }
4852
-
4853
- $this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
4854
-
4855
- $pong = $this->ping();
4856
-
4857
- $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
4858
-
4859
- if ( $is_connected ) {
4860
- FS_GDPR_Manager::instance()->store_is_required( $pong->is_gdpr_required );
4861
-
4862
- $this->store_connectivity_info( $pong, $is_connected );
4863
-
4864
- echo $this->get_after_plugin_activation_redirect_url();
4865
- } else {
4866
- // Add connectivity issue message after 2nd failed attempt.
4867
- $this->_add_connectivity_issue_message( $pong, false );
4868
-
4869
- echo "1";
4870
- }
4871
-
4872
- exit;
4873
- }
4874
-
4875
- static function _add_firewall_issues_javascript() {
4876
- $params = array();
4877
- fs_require_once_template( 'firewall-issues-js.php', $params );
4878
- }
4879
-
4880
- #endregion
4881
-
4882
- #----------------------------------------------------------------------------------
4883
- #region Email
4884
- #----------------------------------------------------------------------------------
4885
-
4886
- /**
4887
- * Generates and sends an HTML email with customizable sections.
4888
- *
4889
- * @author Leo Fajardo (@leorw)
4890
- * @since 1.1.2
4891
- *
4892
- * @param string $to_address
4893
- * @param string $subject
4894
- * @param array $sections
4895
- * @param array $headers
4896
- *
4897
- * @return bool Whether the email contents were sent successfully.
4898
- */
4899
- private function send_email(
4900
- $to_address,
4901
- $subject,
4902
- $sections = array(),
4903
- $headers = array()
4904
- ) {
4905
- $default_sections = $this->get_email_sections();
4906
-
4907
- // Insert new sections or replace the default email sections.
4908
- if ( is_array( $sections ) && ! empty( $sections ) ) {
4909
- foreach ( $sections as $section_id => $custom_section ) {
4910
- if ( ! isset( $default_sections[ $section_id ] ) ) {
4911
- // If the section does not exist, add it.
4912
- $default_sections[ $section_id ] = $custom_section;
4913
- } else {
4914
- // If the section already exists, override it.
4915
- $current_section = $default_sections[ $section_id ];
4916
-
4917
- // Replace the current section's title if a custom section title exists.
4918
- if ( isset( $custom_section['title'] ) ) {
4919
- $current_section['title'] = $custom_section['title'];
4920
- }
4921
-
4922
- // Insert new rows under the current section or replace the default rows.
4923
- if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
4924
- foreach ( $custom_section['rows'] as $row_id => $row ) {
4925
- $current_section['rows'][ $row_id ] = $row;
4926
- }
4927
- }
4928
-
4929
- $default_sections[ $section_id ] = $current_section;
4930
- }
4931
- }
4932
- }
4933
-
4934
- $vars = array( 'sections' => $default_sections );
4935
- $message = fs_get_template( 'email.php', $vars );
4936
-
4937
- // Set the type of email to HTML.
4938
- $headers[] = 'Content-type: text/html; charset=UTF-8';
4939
-
4940
- $header_string = implode( "\r\n", $headers );
4941
-
4942
- return wp_mail(
4943
- $to_address,
4944
- $subject,
4945
- $message,
4946
- $header_string
4947
- );
4948
- }
4949
-
4950
- /**
4951
- * Generates the data for the sections of the email content.
4952
- *
4953
- * @author Leo Fajardo (@leorw)
4954
- * @since 1.1.2
4955
- *
4956
- * @return array
4957
- */
4958
- private function get_email_sections() {
4959
- // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
4960
- $current_user = self::_get_current_wp_user();
4961
-
4962
- // Retrieve the cURL version information so that we can get the version number below.
4963
- $curl_version_information = curl_version();
4964
-
4965
- $active_plugin = self::get_active_plugins();
4966
-
4967
- // Generate the list of active plugins separated by new line.
4968
- $active_plugin_string = '';
4969
- foreach ( $active_plugin as $plugin ) {
4970
- $active_plugin_string .= sprintf(
4971
- '<a href="%s">%s</a> [v%s]<br>',
4972
- $plugin['PluginURI'],
4973
- $plugin['Name'],
4974
- $plugin['Version']
4975
- );
4976
- }
4977
-
4978
- $server_ip = WP_FS__REMOTE_ADDR;
4979
-
4980
- // Add PHP info for deeper investigation.
4981
- ob_start();
4982
- phpinfo();
4983
- $php_info = ob_get_clean();
4984
-
4985
- $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
4986
-
4987
- // Generate the default email sections.
4988
- $sections = array(
4989
- 'sdk' => array(
4990
- 'title' => 'SDK',
4991
- 'rows' => array(
4992
- 'fs_version' => array( 'FS Version', $this->version ),
4993
- 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
4994
- )
4995
- ),
4996
- 'plugin' => array(
4997
- 'title' => ucfirst( $this->get_module_type() ),
4998
- 'rows' => array(
4999
- 'name' => array( 'Name', $this->get_plugin_name() ),
5000
- 'version' => array( 'Version', $this->get_plugin_version() )
5001
- )
5002
- ),
5003
- 'api' => array(
5004
- 'title' => 'API Subdomain',
5005
- 'rows' => array(
5006
- 'dns' => array(
5007
- 'DNS_CNAME',
5008
- function_exists( 'dns_get_record' ) ?
5009
- var_export( dns_get_record( $api_domain, DNS_CNAME ), true ) :
5010
- 'dns_get_record() disabled/blocked'
5011
- ),
5012
- 'ip' => array(
5013
- 'IP',
5014
- function_exists( 'gethostbyname' ) ?
5015
- gethostbyname( $api_domain ) :
5016
- 'gethostbyname() disabled/blocked'
5017
- ),
5018
- ),
5019
- ),
5020
- 'site' => array(
5021
- 'title' => 'Site',
5022
- 'rows' => array(
5023
- 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
5024
- 'address' => array( 'Address', site_url() ),
5025
- 'host' => array(
5026
- 'HTTP_HOST',
5027
- ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
5028
- ),
5029
- 'hosting' => array(
5030
- 'Hosting Company' => fs_request_has( 'hosting_company' ) ?
5031
- fs_request_get( 'hosting_company' ) :
5032
- 'Unknown',
5033
- ),
5034
- 'server_addr' => array(
5035
- 'SERVER_ADDR',
5036
- '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
5037
- )
5038
- )
5039
- ),
5040
- 'user' => array(
5041
- 'title' => 'User',
5042
- 'rows' => array(
5043
- 'email' => array( 'Email', $current_user->user_email ),
5044
- 'first' => array( 'First', $current_user->user_firstname ),
5045
- 'last' => array( 'Last', $current_user->user_lastname )
5046
- )
5047
- ),
5048
- 'plugins' => array(
5049
- 'title' => 'Plugins',
5050
- 'rows' => array(
5051
- 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
5052
- )
5053
- ),
5054
- 'php_info' => array(
5055
- 'title' => 'PHP Info',
5056
- 'rows' => array(
5057
- 'info' => array( $php_info )
5058
- ),
5059
- )
5060
- );
5061
-
5062
- // Allow the sections to be modified by other code.
5063
- $sections = $this->apply_filters( 'email_template_sections', $sections );
5064
-
5065
- return $sections;
5066
- }
5067
-
5068
- #endregion
5069
-
5070
- #----------------------------------------------------------------------------------
5071
- #region Initialization
5072
- #----------------------------------------------------------------------------------
5073
-
5074
- /**
5075
- * Init plugin's Freemius instance.
5076
- *
5077
- * @author Vova Feldman (@svovaf)
5078
- * @since 1.0.1
5079
- *
5080
- * @param number $id
5081
- * @param string $public_key
5082
- * @param bool $is_live
5083
- * @param bool $is_premium
5084
- */
5085
- function init( $id, $public_key, $is_live = true, $is_premium = true ) {
5086
- $this->_logger->entrance();
5087
-
5088
- $this->dynamic_init( array(
5089
- 'id' => $id,
5090
- 'public_key' => $public_key,
5091
- 'is_live' => $is_live,
5092
- 'is_premium' => $is_premium,
5093
- ) );
5094
- }
5095
-
5096
- /**
5097
- * Dynamic initiator, originally created to support initiation
5098
- * with parent_id for add-ons.
5099
- *
5100
- * @author Vova Feldman (@svovaf)
5101
- * @since 1.0.6
5102
- *
5103
- * @param array $plugin_info
5104
- *
5105
- * @throws Freemius_Exception
5106
- */
5107
- function dynamic_init( array $plugin_info ) {
5108
- $this->_logger->entrance();
5109
-
5110
- $this->parse_settings( $plugin_info );
5111
-
5112
- $this->register_after_settings_parse_hooks();
5113
-
5114
- if ( $this->should_stop_execution() ) {
5115
- return;
5116
- }
5117
-
5118
- if ( ! $this->is_registered() ) {
5119
- if ( $this->is_anonymous() ) {
5120
- // If user skipped, no need to test connectivity.
5121
- $this->_has_api_connection = true;
5122
- $this->_is_on = true;
5123
- } else {
5124
- if ( ! $this->has_api_connectivity() ) {
5125
- if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
5126
- $this->_admin_notices->has_sticky( 'failed_connect_api' )
5127
- ) {
5128
- if ( ! $this->_enable_anonymous || $this->is_premium() ) {
5129
- // If anonymous mode is disabled, add firewall admin-notice message.
5130
- add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
5131
-
5132
- $ajax_action_suffix = $this->_slug . ( $this->is_theme() ? ':theme' : '' );
5133
- add_action( "wp_ajax_fs_resolve_firewall_issues_{$ajax_action_suffix}", array(
5134
- &$this,
5135
- '_email_about_firewall_issue'
5136
- ) );
5137
-
5138
- add_action( "wp_ajax_fs_retry_connectivity_test_{$ajax_action_suffix}", array(
5139
- &$this,
5140
- '_retry_connectivity_test'
5141
- ) );
5142
-
5143
- /**
5144
- * Currently the admin notice manager relies on the module's type and slug. The new AJAX actions manager uses module IDs, hence, consider to replace the if block above with the commented code below after adjusting the admin notices manager to work with module IDs.
5145
- *
5146
- * @author Vova Feldman (@svovaf)
5147
- * @since 2.0.0
5148
- */
5149
- /*$this->add_ajax_action( 'resolve_firewall_issues', array(
5150
- &$this,
5151
- '_email_about_firewall_issue'
5152
- ) );
5153
-
5154
- $this->add_ajax_action( 'retry_connectivity_test', array(
5155
- &$this,
5156
- '_retry_connectivity_test'
5157
- ) );*/
5158
- }
5159
- }
5160
-
5161
- return;
5162
- } else {
5163
- $this->_admin_notices->remove_sticky( array(
5164
- 'failed_connect_api_first',
5165
- 'failed_connect_api',
5166
- ) );
5167
-
5168
- if ( $this->_anonymous_mode ) {
5169
- // Simulate anonymous mode.
5170
- $this->_is_anonymous = true;
5171
- }
5172
- }
5173
- }
5174
- }
5175
-
5176
- /**
5177
- * This should be executed even if Freemius is off for the core module,
5178
- * otherwise, the add-ons dialogbox won't work properly. This is esepcially
5179
- * relevant when the developer decided to turn FS off for existing users.
5180
- *
5181
- * @author Vova Feldman (@svovaf)
5182
- */
5183
- if ( $this->is_user_in_admin() &&
5184
- 'plugin-information' === fs_request_get( 'tab', false ) &&
5185
- $this->should_use_freemius_updater_and_dialog() &&
5186
- (
5187
- ( $this->is_addon() && $this->get_slug() == fs_request_get( 'plugin', false ) ) ||
5188
- ( $this->has_addons() && $this->get_id() == fs_request_get( 'parent_plugin_id', false ) )
5189
- )
5190
- ) {
5191
- require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
5192
-
5193
- new FS_Plugin_Info_Dialog( $this->is_addon() ? $this->get_parent_instance() : $this );
5194
- }
5195
-
5196
- // Check if Freemius is on for the current plugin.
5197
- // This MUST be executed after all the plugin variables has been loaded.
5198
- if ( ! $this->is_registered() && ! $this->is_on() ) {
5199
- return;
5200
- }
5201
-
5202
- if ( $this->has_api_connectivity() ) {
5203
- if ( self::is_cron() ) {
5204
- $this->hook_callback_to_sync_cron();
5205
- } else if ( $this->is_user_in_admin() ) {
5206
- /**
5207
- * Schedule daily data sync cron if:
5208
- *
5209
- * 1. User opted-in (for tracking).
5210
- * 2. If skipped, but later upgraded (opted-in via upgrade).
5211
- *
5212
- * @author Vova Feldman (@svovaf)
5213
- * @since 1.1.7.3
5214
- *
5215
- */
5216
- if ( $this->is_registered() && $this->is_tracking_allowed() ) {
5217
- $this->maybe_schedule_sync_cron();
5218
- }
5219
-
5220
- /**
5221
- * Check if requested for manual blocking background sync.
5222
- */
5223
- if ( fs_request_has( 'background_sync' ) ) {
5224
- $this->run_manual_sync();
5225
- }
5226
- }
5227
- }
5228
-
5229
- if ( $this->is_registered() ) {
5230
- FS_Clone_Manager::instance()->maybe_resolve_new_subsite_install_automatically( $this );
5231
-
5232
- $this->hook_callback_to_install_sync();
5233
- }
5234
-
5235
- if ( $this->is_addon() ) {
5236
- if ( $this->is_parent_plugin_installed() ) {
5237
- // Link to parent FS.
5238
- $this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
5239
-
5240
- // Get parent plugin reference.
5241
- $this->_parent_plugin = $this->_parent->get_plugin();
5242
- }
5243
- }
5244
-
5245
- if ( $this->is_user_in_admin() ) {
5246
- if ( $this->is_registered() && fs_request_has( 'purchase_completed' ) ) {
5247
- $this->_admin_notices->add_sticky(
5248
- sprintf(
5249
- /* translators: %s: License type (e.g. you have a professional license) */
5250
- $this->get_text_inline( 'You have purchased a %s license.', 'you-have-x-license' ),
5251
- fs_request_get( 'purchased_plan' )
5252
- ) .
5253
- sprintf(
5254
- $this->get_text_inline(" The %s's %sdownload link%s, license key, and installation instructions have been sent to %s. If you can't find the email after 5 min, please check your spam box.", 'post-purchase-email-sent-message' ),
5255
- $this->get_module_label( true ),
5256
- ( FS_Plugin::is_valid_id( $this->get_bundle_id() ) ? "products' " : '' ),
5257
- ( FS_Plugin::is_valid_id( $this->get_bundle_id() ) ? 's' : '' ),
5258
- sprintf(
5259
- '<strong>%s</strong>',
5260
- fs_request_get( 'purchase_email' )
5261
- )
5262
- ),
5263
- 'plan_purchased',
5264
- $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
5265
- );
5266
- }
5267
-
5268
- if ( $this->is_addon() ) {
5269
- if ( ! $this->is_parent_plugin_installed() ) {
5270
- $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
5271
-
5272
- if ( isset( $plugin_info['parent'] ) ) {
5273
- $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
5274
- }
5275
-
5276
- $this->_admin_notices->add(
5277
- ( ! empty( $parent_name ) ?
5278
- 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 ) :
5279
- 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() )
5280
- ),
5281
- $this->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...',
5282
- 'error'
5283
- );
5284
-
5285
- return;
5286
- } else {
5287
- $is_network_admin = fs_is_network_admin();
5288
-
5289
- if ( ! $this->_parent->is_registered() && $this->is_registered() ) {
5290
- // If add-on activated and parent not, automatically install parent for the user.
5291
- $this->activate_parent_account( $this->_parent );
5292
- } else if (
5293
- $this->_parent->is_registered() &&
5294
- ! $this->is_registered() &&
5295
- /**
5296
- * If not registered for add-on and the following conditions for the add-on are met, activate add-on account.
5297
- * * Network active and in network admin - network activate add-on account.
5298
- * * Network active and not in network admin - activate add-on account for the current blog.
5299
- * * Not network active and not in network admin - activate add-on account for the current blog.
5300
- *
5301
- * If not registered for add-on, not network active, and in network admin, do not handle the add-on activation.
5302
- *
5303
- * @author Leo Fajardo (@leorw)
5304
- * @since 2.3.0
5305
- */
5306
- ( $this->is_network_active() || ! $is_network_admin )
5307
- ) {
5308
- $premium_license = null;
5309
-
5310
- if (
5311
- ! $this->has_free_plan() &&
5312
- $this->is_bundle_license_auto_activation_enabled() &&
5313
- $this->_parent->is_activated_with_bundle_license()
5314
- ) {
5315
- /**
5316
- * If the add-on has no free plan, try to activate the account only when there's a bundle license.
5317
- *
5318
- * @author Leo Fajardo (@leorw)
5319
- * @since 2.4.0
5320
- */
5321
- $bundle_license = $this->get_active_parent_license( $this->_parent->_get_license()->secret_key, false );
5322
-
5323
- if (
5324
- is_object( $bundle_license ) &&
5325
- ! empty( $bundle_license->products ) &&
5326
- in_array( $this->get_id(), $bundle_license->products )
5327
- ) {
5328
- $premium_license = $bundle_license;
5329
- }
5330
- }
5331
-
5332
- if ( $this->has_free_plan() || is_object( $premium_license) ) {
5333
- // If parent plugin activated, automatically install add-on for the user.
5334
- $this->_activate_addon_account(
5335
- $this->_parent,
5336
- ( $this->is_network_active() && $is_network_admin ) ?
5337
- true :
5338
- get_current_blog_id(),
5339
- $premium_license
5340
- );
5341
- }
5342
- }
5343
-
5344
- // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
5345
- if ( $this->is_premium() ) {
5346
- // Remove add-on download admin-notice.
5347
- $this->_parent->_admin_notices->remove_sticky( array(
5348
- 'addon_plan_upgraded_' . $this->_slug,
5349
- 'no_addon_license_' . $this->_slug,
5350
- ) );
5351
- }
5352
-
5353
- // $this->deactivate_premium_only_addon_without_license();
5354
- }
5355
- }
5356
-
5357
- add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
5358
-
5359
- // if ( $this->is_registered() ||
5360
- // $this->is_anonymous() ||
5361
- // $this->is_pending_activation()
5362
- // ) {
5363
- // $this->_init_admin();
5364
- // }
5365
- }
5366
-
5367
- /**
5368
- * Should be called outside `$this->is_user_in_admin()` scope
5369
- * because the updater has some logic that needs to be executed
5370
- * during AJAX calls.
5371
- *
5372
- * Currently we need to hook to the `http_request_host_is_external` filter.
5373
- * In the future, there might be additional logic added.
5374
- *
5375
- * @author Vova Feldman
5376
- * @since 1.2.1.6
5377
- */
5378
- if (
5379
- $this->should_use_freemius_updater_and_dialog() &&
5380
- (
5381
- $this->is_premium() ||
5382
- /**
5383
- * If not premium but the premium version is installed, also instantiate the updater so that the
5384
- * plugin information dialog of the premium version will have the information from the server.
5385
- *
5386
- * @author Leo Fajardo (@leorw)
5387
- * @since 2.2.3
5388
- */
5389
- ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->premium_plugin_basename() ) ) )
5390
- ) &&
5391
- $this->has_release_on_freemius() &&
5392
- ( ! $this->is_unresolved_clone() )
5393
- ) {
5394
- FS_Plugin_Updater::instance( $this );
5395
- }
5396
-
5397
- $this->do_action( 'initiated' );
5398
-
5399
- if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
5400
- if ( isset( $this->_storage->prev_is_premium ) ) {
5401
- $this->apply_filters(
5402
- 'after_code_type_change',
5403
- // New code type.
5404
- $this->_plugin->is_premium
5405
- );
5406
- } else {
5407
- // Set for code type for the first time.
5408
- $this->_storage->prev_is_premium = $this->_plugin->is_premium;
5409
- }
5410
- }
5411
-
5412
- if ( ! $this->is_addon() ) {
5413
- if ( $this->is_registered() ) {
5414
- // Fix for upgrade from versions < 1.0.9.
5415
- if ( ! isset( $this->_storage->activation_timestamp ) ) {
5416
- $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
5417
- }
5418
-
5419
- $this->do_action( 'after_init_plugin_registered' );
5420
- } else if ( $this->is_anonymous() ) {
5421
- $this->do_action( 'after_init_plugin_anonymous' );
5422
- } else if ( $this->is_pending_activation() ) {
5423
- $this->do_action( 'after_init_plugin_pending_activations' );
5424
- }
5425
- } else {
5426
- if ( $this->is_registered() ) {
5427
- $this->do_action( 'after_init_addon_registered' );
5428
- } else if ( $this->is_anonymous() ) {
5429
- $this->do_action( 'after_init_addon_anonymous' );
5430
- } else if ( $this->is_pending_activation() ) {
5431
- $this->do_action( 'after_init_addon_pending_activations' );
5432
- }
5433
- }
5434
- }
5435
-
5436
- /**
5437
- * @author Leo Fajardo (@leorw)
5438
- * @since 2.2.3
5439
- *
5440
- * @return bool
5441
- */
5442
- private function should_use_freemius_updater_and_dialog() {
5443
- return (
5444
- /**
5445
- * Allow updater and dialog when the `fs_allow_updater_and_dialog` URL query param exists and has `true`
5446
- * value, or when the current page is not the "Add Plugins" page (/plugin-install.php) and the `action`
5447
- * URL query param doesn't exist or its value is not `install-plugin` so that there will be no conflicts
5448
- * with the .org plugins' functionalities (e.g. installation from the "Add Plugins" page and viewing
5449
- * plugin details from .org).
5450
- */
5451
- ( true === fs_request_get_bool( 'fs_allow_updater_and_dialog' ) ) ||
5452
- (
5453
- ! self::is_plugin_install_page() &&
5454
- // Disallow updater and dialog when installing a plugin, otherwise .org "add-on" plugins will be affected.
5455
- ( 'install-plugin' !== fs_request_get( 'action' ) )
5456
- )
5457
- );
5458
- }
5459
-
5460
- /**
5461
- * @author Leo Fajardo (@leorw)
5462
- *
5463
- * @since 1.2.1.5
5464
- */
5465
- function _stop_tracking_callback() {
5466
- $this->_logger->entrance();
5467
-
5468
- $this->check_ajax_referer( 'stop_tracking' );
5469
-
5470
- $result = $this->stop_tracking( fs_is_network_admin() );
5471
-
5472
- if ( true === $result ) {
5473
- self::shoot_ajax_success();
5474
- }
5475
-
5476
- $this->_logger->api_error( $result );
5477
-
5478
- self::shoot_ajax_failure(
5479
- sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
5480
- ( $this->is_api_error( $result ) && isset( $result->error ) ?
5481
- $result->error->message :
5482
- var_export( $result, true ) )
5483
- );
5484
- }
5485
-
5486
- /**
5487
- * @author Leo Fajardo (@leorw)
5488
- * @since 1.2.1.5
5489
- */
5490
- function _allow_tracking_callback() {
5491
- $this->_logger->entrance();
5492
-
5493
- $this->check_ajax_referer( 'allow_tracking' );
5494
-
5495
- $result = $this->allow_tracking( fs_is_network_admin() );
5496
-
5497
- if ( true === $result ) {
5498
- self::shoot_ajax_success();
5499
- }
5500
-
5501
- $this->_logger->api_error( $result );
5502
-
5503
- self::shoot_ajax_failure(
5504
- sprintf( $this->get_text_inline( 'Unexpected API error. Please contact the %s\'s author with the following error.', 'unexpected-api-error' ), $this->_module_type ) .
5505
- ( $this->is_api_error( $result ) && isset( $result->error ) ?
5506
- $result->error->message :
5507
- var_export( $result, true ) )
5508
- );
5509
- }
5510
-
5511
- /**
5512
- * Opt-out from usage tracking.
5513
- *
5514
- * Note: This will not delete the account information but will stop all tracking.
5515
- *
5516
- * Returns:
5517
- * 1. FALSE - If the user never opted-in.
5518
- * 2. TRUE - If successfully opted-out.
5519
- * 3. object - API result on failure.
5520
- *
5521
- * @author Leo Fajardo (@leorw)
5522
- * @since 1.2.1.5
5523
- *
5524
- * @return bool|object
5525
- */
5526
- function stop_site_tracking() {
5527
- $this->_logger->entrance();
5528
-
5529
- if ( ! $this->is_registered() ) {
5530
- // User never opted-in.
5531
- return false;
5532
- }
5533
-
5534
- if ( $this->is_tracking_prohibited() ) {
5535
- // Already disconnected.
5536
- return true;
5537
- }
5538
-
5539
- // Send update to FS.
5540
- $result = $this->api_site_call( '/?fields=is_disconnected', 'put', array(
5541
- 'is_disconnected' => true
5542
- ) );
5543
-
5544
- if ( ! $this->is_api_result_entity( $result ) ||
5545
- ! isset( $result->is_disconnected ) ||
5546
- ! $result->is_disconnected
5547
- ) {
5548
- $this->_logger->api_error( $result );
5549
-
5550
- return $result;
5551
- }
5552
-
5553
- $this->_site->is_disconnected = $result->is_disconnected;
5554
- $this->_store_site();
5555
-
5556
- $this->clear_sync_cron();
5557
-
5558
- // Successfully disconnected.
5559
- return true;
5560
- }
5561
-
5562
- /**
5563
- * Opt-out network from usage tracking.
5564
- *
5565
- * Note: This will not delete the account information but will stop all tracking.
5566
- *
5567
- * Returns:
5568
- * 1. FALSE - If the user never opted-in.
5569
- * 2. TRUE - If successfully opted-out.
5570
- * 3. object - API result on failure.
5571
- *
5572
- * @author Leo Fajardo (@leorw)
5573
- * @since 1.2.1.5
5574
- *
5575
- * @return bool|object
5576
- */
5577
- function stop_network_tracking() {
5578
- $this->_logger->entrance();
5579
-
5580
- if ( ! $this->is_registered() ) {
5581
- // User never opted-in.
5582
- return false;
5583
- }
5584
-
5585
- $install_id_2_blog_id = array();
5586
- $installs_map = $this->get_blog_install_map();
5587
-
5588
- $opt_out_all = true;
5589
-
5590
- $params = array();
5591
- foreach ( $installs_map as $blog_id => $install ) {
5592
- if ( $install->is_tracking_prohibited() ) {
5593
- // Already opted-out.
5594
- continue;
5595
- }
5596
-
5597
- if ( $this->is_site_delegated_connection( $blog_id ) ) {
5598
- // Opt-out only from non-delegated installs.
5599
- $opt_out_all = false;
5600
- continue;
5601
- }
5602
-
5603
- $params[] = array( 'id' => $install->id );
5604
-
5605
- $install_id_2_blog_id[ $install->id ] = $blog_id;
5606
- }
5607
-
5608
- if ( empty( $install_id_2_blog_id ) ) {
5609
- return true;
5610
- }
5611
-
5612
- $params[] = array( 'is_disconnected' => true );
5613
-
5614
- // Send update to FS.
5615
- $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
5616
-
5617
- if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
5618
- $this->_logger->api_error( $result );
5619
-
5620
- return $result;
5621
- }
5622
-
5623
- foreach ( $result->installs as $r_install ) {
5624
- $blog_id = $install_id_2_blog_id[ $r_install->id ];
5625
- $install = $installs_map[ $blog_id ];
5626
- $install->is_disconnected = $r_install->is_disconnected;
5627
- $this->_store_site( true, $blog_id, $install );
5628
- }
5629
-
5630
- $this->clear_sync_cron( $opt_out_all );
5631
-
5632
- // Successfully disconnected.
5633
- return true;
5634
- }
5635
-
5636
- /**
5637
- * Opt-out from usage tracking.
5638
- *
5639
- * Note: This will not delete the account information but will stop all tracking.
5640
- *
5641
- * Returns:
5642
- * 1. FALSE - If the user never opted-in.
5643
- * 2. TRUE - If successfully opted-out.
5644
- * 3. object - API result on failure.
5645
- *
5646
- * @author Leo Fajardo (@leorw)
5647
- * @since 1.2.1.5
5648
- *
5649
- * @param bool $is_network_action
5650
- *
5651
- * @return bool|object
5652
- */
5653
- function stop_tracking( $is_network_action = false ) {
5654
- $this->_logger->entrance();
5655
-
5656
- return $is_network_action ?
5657
- $this->stop_network_tracking() :
5658
- $this->stop_site_tracking();
5659
- }
5660
-
5661
- /**
5662
- * Opt-in back into usage tracking.
5663
- *
5664
- * Note: This will only work if the user opted-in previously.
5665
- *
5666
- * Returns:
5667
- * 1. FALSE - If the user never opted-in.
5668
- * 2. TRUE - If successfully opted-in back to usage tracking.
5669
- * 3. object - API result on failure.
5670
- *
5671
- * @author Leo Fajardo (@leorw)
5672
- * @since 1.2.1.5
5673
- *
5674
- * @return bool|object
5675
- */
5676
- function allow_site_tracking() {
5677
- $this->_logger->entrance();
5678
-
5679
- if ( ! $this->is_registered() ) {
5680
- // User never opted-in.
5681
- return false;
5682
- }
5683
-
5684
- if ( $this->is_tracking_allowed() ) {
5685
- // Tracking already allowed.
5686
- return true;
5687
- }
5688
-
5689
- $result = $this->api_site_call( '/?is_disconnected', 'put', array(
5690
- 'is_disconnected' => false
5691
- ) );
5692
-
5693
- if ( ! $this->is_api_result_entity( $result ) ||
5694
- ! isset( $result->is_disconnected ) ||
5695
- $result->is_disconnected
5696
- ) {
5697
- $this->_logger->api_error( $result );
5698
-
5699
- return $result;
5700
- }
5701
-
5702
- $this->_site->is_disconnected = $result->is_disconnected;
5703
- $this->_store_site();
5704
-
5705
- $this->schedule_sync_cron();
5706
-
5707
- // Successfully reconnected.
5708
- return true;
5709
- }
5710
-
5711
- /**
5712
- * Opt-in network back into usage tracking.
5713
- *
5714
- * Note: This will only work if the user opted-in previously.
5715
- *
5716
- * Returns:
5717
- * 1. FALSE - If the user never opted-in.
5718
- * 2. TRUE - If successfully opted-in back to usage tracking.
5719
- * 3. object - API result on failure.
5720
- *
5721
- * @author Leo Fajardo (@leorw)
5722
- * @since 1.2.1.5
5723
- *
5724
- * @return bool|object
5725
- */
5726
- function allow_network_tracking() {
5727
- $this->_logger->entrance();
5728
-
5729
- if ( ! $this->is_registered() ) {
5730
- // User never opted-in.
5731
- return false;
5732
- }
5733
-
5734
- $install_id_2_blog_id = array();
5735
- $installs_map = $this->get_blog_install_map();
5736
-
5737
- $params = array();
5738
- foreach ( $installs_map as $blog_id => $install ) {
5739
- if ( $install->is_tracking_allowed() ) {
5740
- continue;
5741
- }
5742
-
5743
- $params[] = array( 'id' => $install->id );
5744
-
5745
- $install_id_2_blog_id[ $install->id ] = $blog_id;
5746
- }
5747
-
5748
- if ( empty( $install_id_2_blog_id ) ) {
5749
- return true;
5750
- }
5751
-
5752
- $params[] = array( 'is_disconnected' => false );
5753
-
5754
- // Send update to FS.
5755
- $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json", 'put', $params );
5756
-
5757
-
5758
- if ( ! $this->is_api_result_object( $result, 'installs' ) ) {
5759
- $this->_logger->api_error( $result );
5760
-
5761
- return $result;
5762
- }
5763
-
5764
- foreach ( $result->installs as $r_install ) {
5765
- $blog_id = $install_id_2_blog_id[ $r_install->id ];
5766
- $install = $installs_map[ $blog_id ];
5767
- $install->is_disconnected = $r_install->is_disconnected;
5768
- $this->_store_site( true, $blog_id, $install );
5769
- }
5770
-
5771
- $this->schedule_sync_cron();
5772
-
5773
- // Successfully reconnected.
5774
- return true;
5775
- }
5776
-
5777
- /**
5778
- * Opt-in back into usage tracking.
5779
- *
5780
- * Note: This will only work if the user opted-in previously.
5781
- *
5782
- * Returns:
5783
- * 1. FALSE - If the user never opted-in.
5784
- * 2. TRUE - If successfully opted-in back to usage tracking.
5785
- * 3. object - API result on failure.
5786
- *
5787
- * @author Leo Fajardo (@leorw)
5788
- * @since 1.2.1.5
5789
- *
5790
- * @param bool $is_network_action
5791
- *
5792
- * @return bool|object
5793
- */
5794
- function allow_tracking( $is_network_action = false ) {
5795
- $this->_logger->entrance();
5796
-
5797
- return $is_network_action ?
5798
- $this->allow_network_tracking() :
5799
- $this->allow_site_tracking();
5800
- }
5801
-
5802
- /**
5803
- * If user opted-in and later disabled usage-tracking,
5804
- * re-allow tracking for licensing and updates.
5805
- *
5806
- * @author Leo Fajardo (@leorw)
5807
- * @since 1.2.1.5
5808
- *
5809
- * @param bool $is_context_single_site
5810
- */
5811
- private function reconnect_locally( $is_context_single_site = false ) {
5812
- $this->_logger->entrance();
5813
-
5814
- if ( ! $this->is_registered() ) {
5815
- return;
5816
- }
5817
-
5818
- if ( ! fs_is_network_admin() || $is_context_single_site ) {
5819
- if ( $this->is_tracking_prohibited() ) {
5820
- $this->_site->is_disconnected = false;
5821
- $this->_store_site();
5822
- }
5823
- } else {
5824
- $installs_map = $this->get_blog_install_map();
5825
- foreach ( $installs_map as $blog_id => $install ) {
5826
- /**
5827
- * @var FS_Site $install
5828
- */
5829
- if ( $install->is_tracking_prohibited() ) {
5830
- $install->is_disconnected = false;
5831
- $this->_store_site( true, $blog_id, $install );
5832
- }
5833
- }
5834
- }
5835
- }
5836
-
5837
- /**
5838
- * @author Vova Feldman (@svovaf)
5839
- * @since 2.3.2
5840
- *
5841
- * @return bool
5842
- */
5843
- function is_extensions_tracking_allowed() {
5844
- return ( true === $this->apply_filters(
5845
- 'is_extensions_tracking_allowed',
5846
- $this->_storage->get( 'is_extensions_tracking_allowed', null )
5847
- ) );
5848
- }
5849
-
5850
- /**
5851
- * @author Vova Feldman (@svovaf)
5852
- * @since 2.3.2
5853
- */
5854
- function _update_tracking_permission_callback() {
5855
- $this->_logger->entrance();
5856
-
5857
- $this->check_ajax_referer( 'update_tracking_permission' );
5858
-
5859
- $is_enabled = fs_request_get_bool( 'is_enabled', null );
5860
-
5861
- if ( ! is_bool( $is_enabled ) ) {
5862
- self::shoot_ajax_failure();
5863
- }
5864
-
5865
- $permission = fs_request_get( 'permission' );
5866
-
5867
- switch ( $permission ) {
5868
- case 'extensions':
5869
- $this->update_extensions_tracking_flag( $is_enabled );
5870
- break;
5871
- default:
5872
- $permission = 'no_match';
5873
- }
5874
-
5875
- if ( 'no_match' === $permission ) {
5876
- self::shoot_ajax_failure();
5877
- }
5878
-
5879
- self::shoot_ajax_success( array(
5880
- 'permissions' => array(
5881
- $permission => $is_enabled,
5882
- )
5883
- ) );
5884
- }
5885
-
5886
- /**
5887
- * @author Leo Fajardo (@leorw)
5888
- * @since 2.3.2
5889
- *
5890
- * @param bool|null $is_enabled
5891
- */
5892
- function update_extensions_tracking_flag( $is_enabled ) {
5893
- if ( is_bool( $is_enabled ) ) {
5894
- $this->_storage->store( 'is_extensions_tracking_allowed', $is_enabled );
5895
- }
5896
- }
5897
-
5898
- /**
5899
- * Parse plugin's settings (as defined by the plugin dev).
5900
- *
5901
- * @author Vova Feldman (@svovaf)
5902
- * @since 1.1.7.3
5903
- *
5904
- * @param array $plugin_info
5905
- *
5906
- * @throws \Freemius_Exception
5907
- */
5908
- private function parse_settings( &$plugin_info ) {
5909
- $this->_logger->entrance();
5910
-
5911
- $id = $this->get_numeric_option( $plugin_info, 'id', false );
5912
- $public_key = $this->get_option( $plugin_info, 'public_key', false );
5913
- $secret_key = $this->get_option( $plugin_info, 'secret_key', null );
5914
- $parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
5915
- $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
5916
-
5917
- /**
5918
- * @author Vova Feldman (@svovaf)
5919
- * @since 1.1.9 Try to pull secret key from external config.
5920
- */
5921
- if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
5922
- $secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
5923
- }
5924
-
5925
- if ( isset( $plugin_info['parent'] ) ) {
5926
- $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
5927
- // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
5928
- // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
5929
- // $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
5930
- }
5931
-
5932
- if ( false === $id ) {
5933
- throw new Freemius_Exception( array(
5934
- 'error' => array(
5935
- 'type' => 'ParameterNotSet',
5936
- 'message' => 'Plugin id parameter is not set.',
5937
- 'code' => 'plugin_id_not_set',
5938
- 'http' => 500,
5939
- )
5940
- ) );
5941
- }
5942
- if ( false === $public_key ) {
5943
- throw new Freemius_Exception( array(
5944
- 'error' => array(
5945
- 'type' => 'ParameterNotSet',
5946
- 'message' => 'Plugin public_key parameter is not set.',
5947
- 'code' => 'plugin_public_key_not_set',
5948
- 'http' => 500,
5949
- )
5950
- ) );
5951
- }
5952
-
5953
- $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
5954
- $this->_plugin :
5955
- new FS_Plugin();
5956
-
5957
- $premium_suffix = $this->get_option( $plugin_info, 'premium_suffix', '(Premium)' );
5958
-
5959
- $plugin->update( array(
5960
- 'id' => $id,
5961
- 'type' => $this->get_option( $plugin_info, 'type', $this->_module_type ),
5962
- 'public_key' => $public_key,
5963
- 'slug' => $this->_slug,
5964
- 'premium_slug' => $this->get_option( $plugin_info, 'premium_slug', "{$this->_slug}-premium" ),
5965
- 'parent_plugin_id' => $parent_id,
5966
- 'version' => $this->get_plugin_version(),
5967
- 'title' => $this->get_plugin_name( $premium_suffix ),
5968
- 'file' => $this->_plugin_basename,
5969
- 'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
5970
- 'premium_suffix' => $premium_suffix,
5971
- 'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
5972
- 'affiliate_moderation' => $this->get_option( $plugin_info, 'has_affiliation' ),
5973
- 'bundle_id' => $this->get_option( $plugin_info, 'bundle_id', null ),
5974
- 'bundle_public_key' => $this->get_option( $plugin_info, 'bundle_public_key', null ),
5975
- ) );
5976
-
5977
- if ( $plugin->is_updated() ) {
5978
- // Update plugin details.
5979
- $this->_plugin = FS_Plugin_Manager::instance( $this->_module_id )->store( $plugin );
5980
- }
5981
- // Set the secret key after storing the plugin, we don't want to store the key in the storage.
5982
- $this->_plugin->secret_key = $secret_key;
5983
-
5984
- /**
5985
- * If the product is network integrated and activated and the current view is in the network level Admin dashboard, if the product's network-level menu located differently from the sub-site level, then use the network menu details (when set).
5986
- *
5987
- * @author Vova Feldman
5988
- * @since 2.4.5
5989
- */
5990
- if ( $this->is_network_active() && fs_is_network_admin() ) {
5991
- if ( isset( $plugin_info['menu_network'] ) &&
5992
- is_array( $plugin_info['menu_network'] ) &&
5993
- ! empty( $plugin_info['menu_network'] )
5994
- ) {
5995
- $plugin_info['menu'] = $plugin_info['menu_network'];
5996
- }
5997
- }
5998
-
5999
- if ( ! isset( $plugin_info['menu'] ) ) {
6000
- $plugin_info['menu'] = array();
6001
-
6002
- if ( ! empty( $this->_storage->sdk_last_version ) &&
6003
- version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
6004
- ) {
6005
- // Backward compatibility to 1.1.2
6006
- $plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
6007
- $plugin_info['menu_slug'] :
6008
- $this->_slug;
6009
- }
6010
- }
6011
-
6012
- $this->_menu = FS_Admin_Menu_Manager::instance(
6013
- $this->_module_id,
6014
- $this->_module_type,
6015
- $this->get_unique_affix()
6016
- );
6017
-
6018
- $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
6019
-
6020
- $this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
6021
- $this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
6022
- $this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
6023
- $this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
6024
- $this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
6025
- $this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
6026
- if ( $this->_is_premium_only ) {
6027
- // If premium only plugin, disable anonymous mode.
6028
- $this->_enable_anonymous = false;
6029
- $this->_anonymous_mode = false;
6030
- } else {
6031
- $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
6032
- $this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
6033
- }
6034
- $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
6035
- $this->_is_bundle_license_auto_activation_enabled = $this->get_option( $plugin_info, 'bundle_license_auto_activation', false );
6036
-
6037
- if ( ! empty( $plugin_info['trial'] ) ) {
6038
- $this->_trial_days = $this->get_numeric_option(
6039
- $plugin_info['trial'],
6040
- 'days',
6041
- // Default to 0 - trial without days specification.
6042
- 0
6043
- );
6044
-
6045
- $this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
6046
- }
6047
-
6048
- $this->_navigation = $this->get_option(
6049
- $plugin_info,
6050
- 'navigation',
6051
- $this->is_free_wp_org_theme() ?
6052
- self::NAVIGATION_TABS :
6053
- self::NAVIGATION_MENU
6054
- );
6055
- }
6056
-
6057
- /**
6058
- * @param string[] $options
6059
- * @param string $key
6060
- * @param mixed $default
6061
- *
6062
- * @return bool
6063
- */
6064
- private function get_option( &$options, $key, $default = false ) {
6065
- return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
6066
- }
6067
-
6068
- private function get_bool_option( &$options, $key, $default = false ) {
6069
- return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
6070
- }
6071
-
6072
- private function get_numeric_option( &$options, $key, $default = false ) {
6073
- return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
6074
- }
6075
-
6076
- /**
6077
- * Gate keeper.
6078
- *
6079
- * @author Vova Feldman (@svovaf)
6080
- * @since 1.1.7.3
6081
- *
6082
- * @return bool
6083
- */
6084
- private function should_stop_execution() {
6085
- if ( empty( $this->_storage->was_plugin_loaded ) ) {
6086
- /**
6087
- * Don't execute Freemius until plugin was fully loaded at least once,
6088
- * to give the opportunity for the activation hook to run before pinging
6089
- * the API for connectivity test. This logic is relevant for the
6090
- * identification of new plugin install vs. plugin update.
6091
- *
6092
- * @author Vova Feldman (@svovaf)
6093
- * @since 1.1.9
6094
- */
6095
- return true;
6096
- }
6097
-
6098
- if ( $this->is_activation_mode() ) {
6099
- if ( ! is_admin() ) {
6100
- /**
6101
- * If in activation mode, don't execute Freemius outside of the
6102
- * admin dashboard.
6103
- *
6104
- * @author Vova Feldman (@svovaf)
6105
- * @since 1.1.7.3
6106
- */
6107
- return true;
6108
- }
6109
-
6110
- if ( ! WP_FS__IS_HTTP_REQUEST ) {
6111
- /**
6112
- * If in activation and executed without HTTP context (e.g. CLI, Cronjob),
6113
- * then don't start Freemius.
6114
- *
6115
- * @author Vova Feldman (@svovaf)
6116
- * @since 1.1.6.3
6117
- *
6118
- * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
6119
- */
6120
- return true;
6121
- }
6122
-
6123
- if ( self::is_cron() ) {
6124
- /**
6125
- * If in activation mode, don't execute Freemius during wp crons
6126
- * (wp crons have HTTP context - called as HTTP request).
6127
- *
6128
- * @author Vova Feldman (@svovaf)
6129
- * @since 1.1.7.3
6130
- */
6131
- return true;
6132
- }
6133
-
6134
- if ( self::is_ajax() &&
6135
- ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
6136
- ! $this->_admin_notices->has_sticky( 'failed_connect_api' )
6137
- ) {
6138
- /**
6139
- * During activation, if running in AJAX mode, unless there's a sticky
6140
- * connectivity issue notice, don't run Freemius.
6141
- *
6142
- * @author Vova Feldman (@svovaf)
6143
- * @since 1.1.7.3
6144
- */
6145
- return true;
6146
- }
6147
- }
6148
-
6149
- return false;
6150
- }
6151
-
6152
- /**
6153
- * Triggered after code type has changed.
6154
- *
6155
- * @author Vova Feldman (@svovaf)
6156
- * @since 1.1.9.1
6157
- */
6158
- function _after_code_type_change() {
6159
- $this->_logger->entrance();
6160
-
6161
- if ( $this->is_theme() ) {
6162
- // Expire the cache of the previous tabs since the theme may
6163
- // have setting updates after code type has changed.
6164
- $this->_cache->expire( 'tabs' );
6165
- $this->_cache->expire( 'tabs_stylesheets' );
6166
- }
6167
-
6168
- if ( $this->is_registered() ) {
6169
- if ( ! $this->is_addon() ) {
6170
- add_action(
6171
- is_admin() ? 'admin_init' : 'init',
6172
- array( &$this, '_plugin_code_type_changed' )
6173
- );
6174
- }
6175
-
6176
- if ( $this->is_premium() ) {
6177
- // Purge cached payments after switching to the premium version.
6178
- // @todo This logic doesn't handle purging the cache for serviceware module upgrade.
6179
- $this->get_api_user_scope()->purge_cache( "/plugins/{$this->_module_id}/payments.json?include_addons=true" );
6180
- }
6181
- }
6182
- }
6183
-
6184
- /**
6185
- * Handles plugin's code type change (free <--> premium).
6186
- *
6187
- * @author Vova Feldman (@svovaf)
6188
- * @since 1.0.9
6189
- */
6190
- function _plugin_code_type_changed() {
6191
- $this->_logger->entrance();
6192
-
6193
- if ( $this->is_premium() ) {
6194
- $this->reconnect_locally();
6195
-
6196
- // Activated premium code.
6197
- $this->do_action( 'after_premium_version_activation' );
6198
-
6199
- // Remove all sticky messages related to download of the premium version.
6200
- $this->_admin_notices->remove_sticky( array(
6201
- 'trial_started',
6202
- 'plan_upgraded',
6203
- 'plan_changed',
6204
- 'license_activated',
6205
- ) );
6206
-
6207
- $notice = '';
6208
- if ( ! $this->is_only_premium() ) {
6209
- $notice = sprintf( $this->get_text_inline( 'Premium %s version was successfully activated.', 'premium-activated-message' ), $this->_module_type );
6210
- }
6211
-
6212
- $license_notice = $this->get_license_network_activation_notice();
6213
- if ( ! empty( $license_notice ) ) {
6214
- $notice .= ' ' . $license_notice;
6215
- }
6216
-
6217
- if ( ! empty( $notice ) ) {
6218
- $this->_admin_notices->add_sticky(
6219
- trim( $notice ),
6220
- 'premium_activated',
6221
- $this->get_text_x_inline( 'W00t',
6222
- 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
6223
- );
6224
- }
6225
- } else {
6226
- // Remove sticky message related to premium code activation.
6227
- $this->_admin_notices->remove_sticky( 'premium_activated' );
6228
-
6229
- // Activated free code (after had the premium before).
6230
- $this->do_action( 'after_free_version_reactivation' );
6231
-
6232
- if ( $this->is_paying() && ! $this->is_premium() ) {
6233
- $this->_admin_notices->add_sticky(
6234
- sprintf(
6235
- /* translators: %s: License type (e.g. you have a professional license) */
6236
- $this->get_text_inline( 'You have a %s license.', 'you-have-x-license' ),
6237
- $this->get_plan_title()
6238
- ) . $this->get_complete_upgrade_instructions(),
6239
- 'plan_upgraded',
6240
- $this->get_text_x_inline( 'Yee-haw', 'interjection expressing joy or exuberance', 'yee-haw' ) . '!'
6241
- );
6242
- }
6243
- }
6244
-
6245
- // Schedule code type changes event.
6246
- $this->schedule_install_sync();
6247
-
6248
- /**
6249
- * Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
6250
- * triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
6251
- * of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
6252
- * activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
6253
- * the main file of the "free" version will be loaded first before calling the hooked callback. Since the
6254
- * free and premium versions are almost identical (same class or have same functions), a fatal error like
6255
- * "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
6256
- */
6257
- $this->unregister_uninstall_hook();
6258
-
6259
- $this->clear_module_main_file_cache();
6260
-
6261
- // Update is_premium of latest version.
6262
- $this->_storage->prev_is_premium = $this->_plugin->is_premium;
6263
- }
6264
-
6265
- #endregion
6266
-
6267
- #----------------------------------------------------------------------------------
6268
- #region Add-ons
6269
- #----------------------------------------------------------------------------------
6270
-
6271
- /**
6272
- * Check if add-on installed and activated on site.
6273
- *
6274
- * @author Vova Feldman (@svovaf)
6275
- * @since 1.0.6
6276
- *
6277
- * @param string|number $id_or_slug
6278
- * @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
6279
- *
6280
- * @return bool
6281
- */
6282
- function is_addon_activated( $id_or_slug, $is_premium = null ) {
6283
- $this->_logger->entrance();
6284
-
6285
- $addon_id = self::get_module_id( $id_or_slug );
6286
- $is_activated = self::has_instance( $addon_id );
6287
-
6288
- if ( ! $is_activated ) {
6289
- return false;
6290
- }
6291
-
6292
- if ( is_bool( $is_premium ) ) {
6293
- // Check if the specified code version is activate.
6294
- $addon = $this->get_addon_instance( $addon_id );
6295
- $is_activated = ( $is_premium === $addon->is_premium() );
6296
- }
6297
-
6298
- return $is_activated;
6299
- }
6300
-
6301
- /**
6302
- * Check if add-on was connected to install
6303
- *
6304
- * @author Vova Feldman (@svovaf)
6305
- * @since 1.1.7
6306
- *
6307
- * @param string|number $id_or_slug
6308
- *
6309
- * @return bool
6310
- */
6311
- function is_addon_connected( $id_or_slug ) {
6312
- $this->_logger->entrance();
6313
-
6314
- $sites = self::get_all_sites( WP_FS__MODULE_TYPE_PLUGIN );
6315
-
6316
- $addon_id = self::get_module_id( $id_or_slug );
6317
- $addon = $this->get_addon( $addon_id );
6318
- $slug = $addon->slug;
6319
- if ( ! isset( $sites[ $slug ] ) ) {
6320
- return false;
6321
- }
6322
-
6323
- $site = $sites[ $slug ];
6324
-
6325
- $plugin = FS_Plugin_Manager::instance( $addon_id )->get();
6326
-
6327
- if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
6328
- // The given slug do NOT belong to any of the plugin's add-ons.
6329
- return false;
6330
- }
6331
-
6332
- return ( is_object( $site ) &&
6333
- is_numeric( $site->id ) &&
6334
- is_numeric( $site->user_id ) &&
6335
- FS_Plugin_Plan::is_valid_id( $site->plan_id )
6336
- );
6337
- }
6338
-
6339
- /**
6340
- * Determines if add-on installed.
6341
- *
6342
- * NOTE: This is a heuristic and only works if the folder/file named as the slug.
6343
- *
6344
- * @author Vova Feldman (@svovaf)
6345
- * @since 1.0.6
6346
- *
6347
- * @param string|number $id_or_slug
6348
- *
6349
- * @return bool
6350
- */
6351
- function is_addon_installed( $id_or_slug ) {
6352
- $this->_logger->entrance();
6353
-
6354
- $addon_id = self::get_module_id( $id_or_slug );
6355
-
6356
- return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $addon_id ) ) );
6357
- }
6358
-
6359
- /**
6360
- * Get add-on basename.
6361
- *
6362
- * @author Vova Feldman (@svovaf)
6363
- * @since 1.0.6
6364
- *
6365
- * @param string|number $id_or_slug
6366
- *
6367
- * @return string
6368
- */
6369
- function get_addon_basename( $id_or_slug ) {
6370
- $addon_id = self::get_module_id( $id_or_slug );
6371
-
6372
- if ( $this->is_addon_activated( $addon_id ) ) {
6373
- return self::instance( $addon_id )->get_plugin_basename();
6374
- }
6375
-
6376
- $addon = $this->get_addon( $addon_id );
6377
- $premium_basename = "{$addon->premium_slug}/{$addon->slug}.php";
6378
-
6379
- if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
6380
- return $premium_basename;
6381
- }
6382
-
6383
- $all_plugins = $this->get_all_plugins();
6384
-
6385
- foreach ( $all_plugins as $basename => $data ) {
6386
- if ( $addon->slug === $data['slug'] ||
6387
- $addon->premium_slug === $data['slug']
6388
- ) {
6389
- return $basename;
6390
- }
6391
- }
6392
-
6393
- $free_basename = "{$addon->slug}/{$addon->slug}.php";
6394
-
6395
- return $free_basename;
6396
- }
6397
-
6398
- /**
6399
- * Get installed add-ons instances.
6400
- *
6401
- * @author Vova Feldman (@svovaf)
6402
- * @since 1.0.6
6403
- *
6404
- * @return Freemius[]
6405
- */
6406
- function get_installed_addons() {
6407
- if ( $this->is_addon() ) {
6408
- // Add-on cannot have add-ons.
6409
- return array();
6410
- }
6411
-
6412
- $installed_addons = array();
6413
-
6414
- foreach ( self::$_instances as $instance ) {
6415
- if ( $instance->is_addon_of( $this->_plugin->id ) ) {
6416
- $installed_addons[] = $instance;
6417
- }
6418
- }
6419
-
6420
- return $installed_addons;
6421
- }
6422
-
6423
- /**
6424
- * Check if any add-ons of the plugin are installed.
6425
- *
6426
- * @author Leo Fajardo (@leorw)
6427
- * @since 1.1.1
6428
- *
6429
- * @return bool
6430
- */
6431
- function has_installed_addons() {
6432
- if ( ! $this->has_addons() ) {
6433
- return false;
6434
- }
6435
-
6436
- foreach ( self::$_instances as $instance ) {
6437
- if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
6438
- if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
6439
- return true;
6440
- }
6441
- }
6442
- }
6443
-
6444
- return false;
6445
- }
6446
-
6447
- /**
6448
- * Tell Freemius that the current plugin is an add-on.
6449
- *
6450
- * @author Vova Feldman (@svovaf)
6451
- * @since 1.0.6
6452
- *
6453
- * @param number $parent_plugin_id The parent plugin ID
6454
- */
6455
- function init_addon( $parent_plugin_id ) {
6456
- $this->_plugin->parent_plugin_id = $parent_plugin_id;
6457
- }
6458
-
6459
- /**
6460
- * @author Vova Feldman (@svovaf)
6461
- * @since 1.0.6
6462
- *
6463
- * @return bool
6464
- */
6465
- function is_addon() {
6466
- return (
6467
- isset( $this->_plugin->parent_plugin_id ) &&
6468
- is_numeric( $this->_plugin->parent_plugin_id )
6469
- );
6470
- }
6471
-
6472
- /**
6473
- * @author Vova Feldman (@svovaf)
6474
- * @since 2.3.2
6475
- *
6476
- * @param number $parent_product_id
6477
- *
6478
- * @return bool
6479
- */
6480
- function is_addon_of( $parent_product_id ) {
6481
- return (
6482
- $this->is_addon() &&
6483
- $parent_product_id == $this->_plugin->parent_plugin_id
6484
- );
6485
- }
6486
-
6487
- /**
6488
- * Deactivate add-on if it's premium only and the user does't have a valid license.
6489
- *
6490
- * @param bool $is_after_trial_cancel
6491
- *
6492
- * @return bool If add-on was deactivated.
6493
- */
6494
- private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
6495
- if ( ! $this->has_free_plan() &&
6496
- ! $this->has_features_enabled_license() &&
6497
- ! $this->_has_premium_license()
6498
- ) {
6499
- if ( $this->is_registered() ) {
6500
- // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
6501
- // if (empty($this->_storage->activation_timestamp) ||
6502
- // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
6503
- // ) {
6504
- /**
6505
- * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
6506
- *
6507
- * Retry syncing the user add-on licenses.
6508
- */
6509
- // Sync licenses.
6510
- $this->_sync_licenses();
6511
- // }
6512
-
6513
- // Try to activate premium license.
6514
- $this->_activate_license( true );
6515
- }
6516
-
6517
- if ( ! $this->has_free_plan() &&
6518
- ! $this->has_features_enabled_license() &&
6519
- ! $this->_has_premium_license()
6520
- ) {
6521
- // @todo Check if deactivate plugins also call the deactivation hook.
6522
-
6523
- $this->_parent->_admin_notices->add_sticky(
6524
- sprintf(
6525
- ( $is_after_trial_cancel ?
6526
- $this->_parent->get_text_inline(
6527
- '%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.',
6528
- 'addon-trial-cancelled-message'
6529
- ) :
6530
- $this->_parent->get_text_inline(
6531
- '%s is a premium only add-on. You have to purchase a license first before activating the plugin.',
6532
- 'addon-no-license-message'
6533
- )
6534
- ),
6535
- '<b>' . $this->_plugin->title . '</b>'
6536
- ) . ' ' . sprintf(
6537
- '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
6538
- $this->_parent->addon_url( $this->_slug ),
6539
- esc_attr( sprintf( $this->_parent->get_text_inline( 'More information about %s', 'more-information-about-x' ), $this->_plugin->title ) ),
6540
- $this->_parent->get_text_inline( 'Purchase License', 'purchase-license' )
6541
- ),
6542
- 'no_addon_license_' . $this->_slug,
6543
- ( $is_after_trial_cancel ? '' : $this->_parent->get_text_x_inline( 'Oops', 'exclamation', 'oops' ) . '...' ),
6544
- ( $is_after_trial_cancel ? 'success' : 'error' )
6545
- );
6546
-
6547
- deactivate_plugins( array( $this->_plugin_basename ), true );
6548
-
6549
- return true;
6550
- }
6551
- }
6552
-
6553
- return false;
6554
- }
6555
-
6556
- #endregion
6557
-
6558
- #----------------------------------------------------------------------------------
6559
- #region Sandbox
6560
- #----------------------------------------------------------------------------------
6561
-
6562
- /**
6563
- * Set Freemius into sandbox mode for debugging.
6564
- *
6565
- * @author Vova Feldman (@svovaf)
6566
- * @since 1.0.4
6567
- *
6568
- * @param string $secret_key
6569
- */
6570
- function init_sandbox( $secret_key ) {
6571
- $this->_plugin->secret_key = $secret_key;
6572
-
6573
- // Update plugin details.
6574
- FS_Plugin_Manager::instance( $this->_module_id )->update( $this->_plugin, true );
6575
- }
6576
-
6577
- /**
6578
- * Check if running payments in sandbox mode.
6579
- *
6580
- * @author Vova Feldman (@svovaf)
6581
- * @since 1.0.4
6582
- *
6583
- * @return bool
6584
- */
6585
- function is_payments_sandbox() {
6586
- return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
6587
- }
6588
-
6589
- #endregion
6590
-
6591
- /**
6592
- * Check if running test vs. live plugin.
6593
- *
6594
- * @author Vova Feldman (@svovaf)
6595
- * @since 1.0.5
6596
- *
6597
- * @return bool
6598
- */
6599
- function is_live() {
6600
- return $this->_plugin->is_live;
6601
- }
6602
-
6603
- /**
6604
- * Check if super-admin skipped connection for all sites in the network.
6605
- *
6606
- * @author Vova Feldman (@svovaf)
6607
- * @since 2.0.0
6608
- */
6609
- function is_network_anonymous() {
6610
- if ( ! $this->_is_network_active ) {
6611
- return false;
6612
- }
6613
-
6614
- $is_anonymous_ms = $this->_storage->get( 'is_anonymous_ms' );
6615
-
6616
- if ( empty( $is_anonymous_ms ) ) {
6617
- return false;
6618
- }
6619
-
6620
- return $is_anonymous_ms['is'];
6621
- }
6622
-
6623
- /**
6624
- * Check if super-admin opted-in for all sites in the network.
6625
- *
6626
- * @author Vova Feldman (@svovaf)
6627
- * @since 2.0.0
6628
- */
6629
- function is_network_connected() {
6630
- if ( ! $this->_is_network_active ) {
6631
- return false;
6632
- }
6633
-
6634
- return $this->_storage->get( 'is_network_connected' );
6635
- }
6636
-
6637
- /**
6638
- * Check if the user skipped connecting the account with Freemius.
6639
- *
6640
- * @author Vova Feldman (@svovaf)
6641
- * @since 1.0.7
6642
- *
6643
- * @return bool
6644
- */
6645
- function is_anonymous() {
6646
- if ( ! isset( $this->_is_anonymous ) ) {
6647
- if ( $this->is_network_anonymous() ) {
6648
- $this->_is_anonymous = true;
6649
- } else if ( ! fs_is_network_admin() ) {
6650
- if ( ! isset( $this->_storage->is_anonymous ) ) {
6651
- // Not skipped.
6652
- $this->_is_anonymous = false;
6653
- } else if ( is_bool( $this->_storage->is_anonymous ) ) {
6654
- // For back compatibility, since the variable was boolean before.
6655
- $this->_is_anonymous = $this->_storage->is_anonymous;
6656
-
6657
- // Upgrade stored data format to 1.1.3 format.
6658
- $this->set_anonymous_mode( $this->_storage->is_anonymous );
6659
- } else {
6660
- // Version 1.1.3 and later.
6661
- $this->_is_anonymous = $this->_storage->is_anonymous['is'];
6662
- }
6663
- }
6664
- }
6665
-
6666
- return $this->_is_anonymous;
6667
- }
6668
-
6669
- /**
6670
- * Check if the user skipped the connection of a specified site.
6671
- *
6672
- * @author Vova Feldman (@svovaf)
6673
- * @since 2.0.0
6674
- *
6675
- * @param int $blog_id
6676
- *
6677
- * @return bool
6678
- */
6679
- function is_anonymous_site( $blog_id = 0 ) {
6680
- if ( $this->is_network_anonymous() ) {
6681
- return true;
6682
- }
6683
-
6684
- $is_anonymous = $this->_storage->get( 'is_anonymous', false, $blog_id );
6685
-
6686
- if ( empty( $is_anonymous ) ) {
6687
- return false;
6688
- }
6689
-
6690
- return $is_anonymous['is'];
6691
- }
6692
-
6693
- /**
6694
- * Check if user connected his account and install pending email activation.
6695
- *
6696
- * @author Vova Feldman (@svovaf)
6697
- * @since 1.0.7
6698
- *
6699
- * @return bool
6700
- */
6701
- function is_pending_activation() {
6702
- return $this->_storage->get( 'is_pending_activation', false );
6703
- }
6704
-
6705
- /**
6706
- * Check if plugin must be WordPress.org compliant.
6707
- *
6708
- * @since 1.0.7
6709
- *
6710
- * @return bool
6711
- */
6712
- function is_org_repo_compliant() {
6713
- return $this->_is_org_compliant;
6714
- }
6715
-
6716
- #--------------------------------------------------------------------------------
6717
- #region WP Cron Common
6718
- #--------------------------------------------------------------------------------
6719
-
6720
- /**
6721
- * @author Vova Feldman (@svovaf)
6722
- * @since 2.0.0
6723
- *
6724
- * @param string $name Cron name.
6725
- *
6726
- * @return object
6727
- */
6728
- private function get_cron_data( $name ) {
6729
- $this->_logger->entrance( $name );
6730
-
6731
- /**
6732
- * @var object $cron_data
6733
- */
6734
- return $this->_storage->get( "{$name}_cron", null );
6735
- }
6736
-
6737
- /**
6738
- * @author Vova Feldman (@svovaf)
6739
- * @since 2.0.0
6740
- *
6741
- * @param string $name Cron name.
6742
- */
6743
- private function clear_cron_data( $name ) {
6744
- $this->_logger->entrance( $name );
6745
-
6746
- $this->_storage->remove( "{$name}_cron" );
6747
- }
6748
-
6749
- /**
6750
- * @author Vova Feldman (@svovaf)
6751
- * @since 2.0.0
6752
- *
6753
- * @param string $name Cron name.
6754
- * @param int $cron_blog_id The cron executing blog ID.
6755
- */
6756
- private function set_cron_data( $name, $cron_blog_id = 0 ) {
6757
- $this->_logger->entrance( $name );
6758
-
6759
- $this->_storage->store( "{$name}_cron", (object) array(
6760
- 'version' => $this->get_plugin_version(),
6761
- 'blog_id' => $cron_blog_id,
6762
- 'sdk_version' => $this->version,
6763
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
6764
- 'on' => true,
6765
- ) );
6766
- }
6767
-
6768
- /**
6769
- * Get the cron's executing blog ID.
6770
- *
6771
- * @author Vova Feldman (@svovaf)
6772
- * @since 2.0.0
6773
- *
6774
- * @param string $name Cron name.
6775
- *
6776
- * @return int
6777
- */
6778
- private function get_cron_blog_id( $name ) {
6779
- $this->_logger->entrance( $name );
6780
-
6781
- /**
6782
- * @var object $cron_data
6783
- */
6784
- $cron_data = $this->get_cron_data( $name );
6785
-
6786
- return ( is_object( $cron_data ) && is_numeric( $cron_data->blog_id ) ) ?
6787
- $cron_data->blog_id :
6788
- 0;
6789
- }
6790
-
6791
- /**
6792
- * @author Vova Feldman (@svovaf)
6793
- * @since 2.0.0
6794
- *
6795
- * @param string $name Cron name.
6796
- *
6797
- * @return bool
6798
- */
6799
- private function is_cron_on( $name ) {
6800
- $this->_logger->entrance( $name );
6801
-
6802
- /**
6803
- * @var object $cron_data
6804
- */
6805
- $cron_data = $this->get_cron_data( $name );
6806
-
6807
- return ( ! is_null( $cron_data ) && true === $cron_data->on );
6808
- }
6809
-
6810
- /**
6811
- * Unix timestamp for previous cron execution or false if never executed.
6812
- *
6813
- * @author Vova Feldman (@svovaf)
6814
- * @since 2.0.0
6815
- *
6816
- * @param string $name Cron name.
6817
- *
6818
- * @return int|false
6819
- */
6820
- private function cron_last_execution( $name ) {
6821
- $this->_logger->entrance( $name );
6822
-
6823
- return $this->_storage->get( "{$name}_timestamp" );
6824
- }
6825
-
6826
- /**
6827
- * Set cron execution time to now.
6828
- *
6829
- * @author Vova Feldman (@svovaf)
6830
- * @since 2.0.0
6831
- *
6832
- * @param string $name Cron name.
6833
- */
6834
- private function set_cron_execution_timestamp( $name ) {
6835
- $this->_logger->entrance( $name );
6836
-
6837
- $this->_storage->store( "{$name}_timestamp", time() );
6838
- }
6839
-
6840
- /**
6841
- * Sets the keepalive time to now.
6842
- *
6843
- * @author Leo Fajardo (@leorw)
6844
- * @since 2.2.3
6845
- *
6846
- * @param bool|null $use_network_level_storage
6847
- */
6848
- private function set_keepalive_timestamp( $use_network_level_storage = null ) {
6849
- $this->_logger->entrance();
6850
-
6851
- $this->_storage->store( 'keepalive_timestamp', time(), $use_network_level_storage );
6852
- }
6853
-
6854
- /**
6855
- * Check if cron was executed in the last $period of seconds.
6856
- *
6857
- * @author Vova Feldman (@svovaf)
6858
- * @since 2.0.0
6859
- *
6860
- * @param string $name Cron name.
6861
- * @param int $period In seconds
6862
- *
6863
- * @return bool
6864
- */
6865
- private function is_cron_executed( $name, $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
6866
- $this->_logger->entrance( $name );
6867
-
6868
- $last_execution = $this->cron_last_execution( $name );
6869
-
6870
- if ( ! is_numeric( $last_execution ) ) {
6871
- return false;
6872
- }
6873
-
6874
- return ( $last_execution > ( WP_FS__SCRIPT_START_TIME - $period ) );
6875
- }
6876
-
6877
- /**
6878
- * WP Cron is executed on a site level. When running in a multisite network environment
6879
- * with the network integration activated, for optimization reasons, we are consolidating
6880
- * the installs data sync cron to be executed only from a single site.
6881
- *
6882
- * @author Vova Feldman (@svovaf)
6883
- * @since 2.0.0
6884
- *
6885
- * @param int $except_blog_id Target any except the excluded blog ID.
6886
- *
6887
- * @return int
6888
- */
6889
- private function get_cron_target_blog_id( $except_blog_id = 0 ) {
6890
- if ( ! is_multisite() ) {
6891
- return 0;
6892
- }
6893
-
6894
- if ( $this->_is_network_active &&
6895
- is_numeric( $this->_storage->network_install_blog_id ) &&
6896
- $except_blog_id != $this->_storage->network_install_blog_id &&
6897
- self::is_site_active( $this->_storage->network_install_blog_id )
6898
- ) {
6899
- // Try to run cron from the main network blog.
6900
- $install = $this->get_install_by_blog_id( $this->_storage->network_install_blog_id );
6901
-
6902
- if ( is_object( $install ) &&
6903
- ( $this->is_premium() || $install->is_tracking_allowed() )
6904
- ) {
6905
- return $this->_storage->network_install_blog_id;
6906
- }
6907
- }
6908
-
6909
- // Get first opted-in blog ID with active tracking.
6910
- $installs = $this->get_blog_install_map();
6911
- foreach ( $installs as $blog_id => $install ) {
6912
- if ( $except_blog_id != $blog_id &&
6913
- self::is_site_active( $blog_id ) &&
6914
- ( $this->is_premium() || $install->is_tracking_allowed() )
6915
- ) {
6916
- return $blog_id;
6917
- }
6918
- }
6919
-
6920
- return 0;
6921
- }
6922
-
6923
- /**
6924
- * @author Vova Feldman (@svovaf)
6925
- * @since 2.0.0
6926
- *
6927
- * @param string $name Cron name.
6928
- * @param string $action_tag Callback action tag.
6929
- * @param bool $is_network_clear If set to TRUE, clear sync cron even if there are installs that are still connected.
6930
- */
6931
- private function clear_cron( $name, $action_tag = '', $is_network_clear = false ) {
6932
- $this->_logger->entrance( $name );
6933
-
6934
- if ( ! $this->is_cron_on( $name ) ) {
6935
- return;
6936
- }
6937
-
6938
- $clear_cron = true;
6939
- if ( ! $is_network_clear && $this->_is_network_active ) {
6940
- $installs = $this->get_blog_install_map();
6941
-
6942
- foreach ( $installs as $blog_id => $install ) {
6943
- /**
6944
- * @var FS_Site $install
6945
- */
6946
- if ( $install->is_tracking_allowed() ) {
6947
- $clear_cron = false;
6948
- break;
6949
- }
6950
- }
6951
- }
6952
-
6953
- if ( ! $clear_cron ) {
6954
- return;
6955
- }
6956
-
6957
- /**
6958
- * @var object $cron_data
6959
- */
6960
- $cron_data = $this->get_cron_data( $name );
6961
-
6962
- $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
6963
- $cron_data->blog_id :
6964
- 0;
6965
-
6966
- $this->clear_cron_data( $name );
6967
-
6968
- if ( 0 < $cron_blog_id ) {
6969
- switch_to_blog( $cron_blog_id );
6970
- }
6971
-
6972
- if ( empty( $action_tag ) ) {
6973
- $action_tag = $name;
6974
- }
6975
-
6976
- wp_clear_scheduled_hook( $this->get_action_tag( $action_tag ) );
6977
-
6978
- if ( 0 < $cron_blog_id ) {
6979
- restore_current_blog();
6980
- }
6981
- }
6982
-
6983
- /**
6984
- * Unix timestamp for next cron execution or false if not scheduled.
6985
- *
6986
- * @author Vova Feldman (@svovaf)
6987
- * @since 2.0.0
6988
- *
6989
- * @param string $name Cron name.
6990
- * @param string $action_tag Callback action tag.
6991
- *
6992
- * @return int|false
6993
- */
6994
- private function get_next_scheduled_cron( $name, $action_tag = '' ) {
6995
- $this->_logger->entrance( $name );
6996
-
6997
- if ( ! $this->is_cron_on( $name ) ) {
6998
- return false;
6999
- }
7000
-
7001
- /**
7002
- * @var object $cron_data
7003
- */
7004
- $cron_data = $this->get_cron_data( $name );
7005
-
7006
- $cron_blog_id = is_object( $cron_data ) && isset( $cron_data->blog_id ) ?
7007
- $cron_data->blog_id :
7008
- 0;
7009
-
7010
- if ( 0 < $cron_blog_id ) {
7011
- switch_to_blog( $cron_blog_id );
7012
- }
7013
-
7014
- if ( empty( $action_tag ) ) {
7015
- $action_tag = $name;
7016
- }
7017
-
7018
- $next_scheduled = wp_next_scheduled( $this->get_action_tag( $action_tag ) );
7019
-
7020
- if ( 0 < $cron_blog_id ) {
7021
- restore_current_blog();
7022
- }
7023
-
7024
- return $next_scheduled;
7025
- }
7026
-
7027
- /**
7028
- * @author Vova Feldman (@svovaf)
7029
- * @since 2.0.0
7030
- *
7031
- * @param string $name Cron name.
7032
- * @param string $action_tag Callback action tag.
7033
- * @param string $recurrence 'single' or 'daily'.
7034
- * @param int $start_at Defaults to now.
7035
- * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
7036
- * @param int $except_blog_id Target any except the excluded blog ID.
7037
- */
7038
- private function schedule_cron(
7039
- $name,
7040
- $action_tag = '',
7041
- $recurrence = 'single',
7042
- $start_at = WP_FS__SCRIPT_START_TIME,
7043
- $randomize_start = true,
7044
- $except_blog_id = 0
7045
- ) {
7046
- $this->_logger->entrance( $name );
7047
-
7048
- $this->clear_cron( $name, $action_tag, true );
7049
-
7050
- $cron_blog_id = $this->get_cron_target_blog_id( $except_blog_id );
7051
-
7052
- if ( is_multisite() && 0 == $cron_blog_id ) {
7053
- // Don't schedule cron since couldn't find a target blog.
7054
- return;
7055
- }
7056
-
7057
- if ( 0 < $cron_blog_id ) {
7058
- switch_to_blog( $cron_blog_id );
7059
- }
7060
-
7061
- if ( 'daily' === $recurrence ) {
7062
- if ( $randomize_start ) {
7063
- // Schedule first sync with a random 12 hour time range from now.
7064
- $start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
7065
- }
7066
-
7067
- // Schedule daily WP cron.
7068
- wp_schedule_event(
7069
- $start_at,
7070
- 'daily',
7071
- $this->get_action_tag( $action_tag )
7072
- );
7073
- } else if ( 'single' === $recurrence ) {
7074
- // Schedule single cron.
7075
- wp_schedule_single_event(
7076
- $start_at,
7077
- $this->get_action_tag( $action_tag )
7078
- );
7079
- }
7080
-
7081
- $this->set_cron_data( $name, $cron_blog_id );
7082
-
7083
- if ( 0 < $cron_blog_id ) {
7084
- restore_current_blog();
7085
- }
7086
- }
7087
-
7088
- /**
7089
- * Consolidated cron execution for performance optimization. The max number of API requests is based on the number of unique opted-in users.
7090
- * that doesn't halt page loading.
7091
- *
7092
- * @author Vova Feldman (@svovaf)
7093
- * @since 2.0.0
7094
- *
7095
- * @param string $name Cron name.
7096
- * @param callable $callable The function that should be executed.
7097
- */
7098
- private function execute_cron( $name, $callable ) {
7099
- $this->_logger->entrance( $name );
7100
-
7101
- // Store the last time data sync was executed.
7102
- $this->set_cron_execution_timestamp( $name );
7103
-
7104
- // Check if API is temporary down.
7105
- if ( FS_Api::is_temporary_down() ) {
7106
- return;
7107
- }
7108
-
7109
- // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
7110
-
7111
- $users_2_blog_ids = array();
7112
-
7113
- if ( ! is_multisite() ) {
7114
- // Add dummy blog.
7115
- $users_2_blog_ids[0] = array( 0 );
7116
- } else {
7117
- $installs = $this->get_blog_install_map();
7118
- foreach ( $installs as $blog_id => $install ) {
7119
- if ( $this->is_premium() || $install->is_tracking_allowed() ) {
7120
- if ( ! isset( $users_2_blog_ids[ $install->user_id ] ) ) {
7121
- $users_2_blog_ids[ $install->user_id ] = array();
7122
- }
7123
-
7124
- $users_2_blog_ids[ $install->user_id ][] = $blog_id;
7125
- }
7126
- }
7127
- }
7128
-
7129
- $current_blog_id = get_current_blog_id();
7130
-
7131
- foreach ( $users_2_blog_ids as $user_id => $blog_ids ) {
7132
- if ( 0 < $blog_ids[0] ) {
7133
- $this->switch_to_blog( $blog_ids[0] );
7134
- }
7135
-
7136
- call_user_func_array( $callable, array( $blog_ids, ( is_multisite() ? $current_blog_id : null ) ) );
7137
-
7138
- foreach ( $blog_ids as $blog_id ) {
7139
- $this->do_action( "after_{$name}_cron", $blog_id );
7140
- }
7141
- }
7142
-
7143
- if ( is_multisite() ) {
7144
- $this->switch_to_blog( $current_blog_id, fs_is_network_admin() ? $this->get_network_install() : null );
7145
-
7146
- $this->do_action( "after_{$name}_cron_multisite" );
7147
- }
7148
- }
7149
-
7150
- #endregion
7151
-
7152
- #----------------------------------------------------------------------------------
7153
- #region Daily Sync Cron
7154
- #----------------------------------------------------------------------------------
7155
-
7156
-
7157
- /**
7158
- * @author Vova Feldman (@svovaf)
7159
- * @since 2.0.0
7160
- *
7161
- * @return bool
7162
- */
7163
- private function is_sync_cron_scheduled() {
7164
- return $this->is_cron_on( 'sync' );
7165
- }
7166
-
7167
- /**
7168
- * Get the sync cron's executing blog ID.
7169
- *
7170
- * @author Vova Feldman (@svovaf)
7171
- * @since 2.0.0
7172
- *
7173
- * @return int
7174
- */
7175
- private function get_sync_cron_blog_id() {
7176
- return $this->get_cron_blog_id( 'sync' );
7177
- }
7178
-
7179
- /**
7180
- * @author Vova Feldman (@svovaf)
7181
- * @since 1.1.7.3
7182
- */
7183
- private function run_manual_sync() {
7184
- self::require_pluggable_essentials();
7185
-
7186
- if ( ! $this->is_user_admin() ) {
7187
- return;
7188
- }
7189
-
7190
- // Run manual sync.
7191
- $this->_sync_cron();
7192
-
7193
- // Reschedule next cron to run 24 hours from now (performance optimization).
7194
- $this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
7195
- }
7196
-
7197
- /**
7198
- * Data sync cron job. Replaces the background sync non blocking HTTP request
7199
- * that doesn't halt page loading.
7200
- *
7201
- * @author Vova Feldman (@svovaf)
7202
- * @since 1.1.7.3
7203
- * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
7204
- */
7205
- function _sync_cron() {
7206
- $this->_logger->entrance();
7207
-
7208
- $this->execute_cron( 'sync', array( &$this, '_sync_cron_method' ) );
7209
- }
7210
-
7211
- /**
7212
- * The actual data sync cron logic.
7213
- *
7214
- * @author Vova Feldman (@svovaf)
7215
- * @since 2.0.0
7216
- *
7217
- * @param int[] $blog_ids
7218
- * @param int|null $current_blog_id @since 2.2.3. This is passed from the `execute_cron` method and used by the
7219
- * `_sync_plugin_license` method in order to switch to the previous blog when sending
7220
- * updates for a single site in case `execute_cron` has switched to a different blog.
7221
- */
7222
- function _sync_cron_method( array $blog_ids, $current_blog_id = null ) {
7223
- if ( $this->is_registered() ) {
7224
- if ( $this->has_paid_plan() ) {
7225
- // Initiate background plan sync.
7226
- $this->_sync_license( true, false, $current_blog_id );
7227
-
7228
- if ( $this->is_paying() ) {
7229
- // Check for premium plugin updates.
7230
- $this->check_updates( true );
7231
- }
7232
- } else {
7233
- // Sync install(s) (only if something changed locally).
7234
- if ( 1 < count( $blog_ids ) ) {
7235
- $this->sync_installs();
7236
- } else {
7237
- $this->sync_install();
7238
- }
7239
-
7240
- $this->maybe_sync_install_user();
7241
- }
7242
- }
7243
- }
7244
-
7245
- /**
7246
- * Check if sync was executed in the last $period of seconds.
7247
- *
7248
- * @author Vova Feldman (@svovaf)
7249
- * @since 1.1.7.3
7250
- *
7251
- * @param int $period In seconds
7252
- *
7253
- * @return bool
7254
- */
7255
- private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
7256
- return $this->is_cron_executed( 'sync', $period );
7257
- }
7258
-
7259
- /**
7260
- * @author Vova Feldman (@svovaf)
7261
- * @since 1.1.7.3
7262
- *
7263
- * @return bool
7264
- */
7265
- private function is_sync_cron_on() {
7266
- return $this->is_cron_on( 'sync' );
7267
- }
7268
-
7269
- /**
7270
- * @author Leo Fajardo (@leorw)
7271
- * @since 2.5.0
7272
- */
7273
- private function maybe_schedule_sync_cron() {
7274
- $next_schedule = $this->next_sync_cron();
7275
-
7276
- // The event is properly scheduled, so no need to reschedule it.
7277
- if (
7278
- is_numeric( $next_schedule ) &&
7279
- $next_schedule > time()
7280
- ) {
7281
- return;
7282
- }
7283
-
7284
- $this->schedule_sync_cron();
7285
- }
7286
-
7287
- /**
7288
- * @author Vova Feldman (@svovaf)
7289
- * @since 1.1.7.3
7290
- *
7291
- * @param int $start_at Defaults to now.
7292
- * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise, schedule job to start right away.
7293
- * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
7294
- */
7295
- private function schedule_sync_cron(
7296
- $start_at = WP_FS__SCRIPT_START_TIME,
7297
- $randomize_start = true,
7298
- $except_blog_id = 0
7299
- ) {
7300
- $this->schedule_cron(
7301
- 'sync',
7302
- 'data_sync',
7303
- 'daily',
7304
- $start_at,
7305
- $randomize_start,
7306
- $except_blog_id
7307
- );
7308
- }
7309
-
7310
- /**
7311
- * Add the actual sync function to the cron job hook.
7312
- *
7313
- * @author Vova Feldman (@svovaf)
7314
- * @since 1.1.7.3
7315
- */
7316
- private function hook_callback_to_sync_cron() {
7317
- $this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
7318
- }
7319
-
7320
- /**
7321
- * @author Vova Feldman (@svovaf)
7322
- * @since 1.1.7.3
7323
- *
7324
- * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
7325
- */
7326
- private function clear_sync_cron( $is_network_clear = false ) {
7327
- $this->_logger->entrance();
7328
-
7329
- $this->clear_cron( 'sync', 'data_sync', $is_network_clear );
7330
- }
7331
-
7332
- /**
7333
- * Unix timestamp for next sync cron execution or false if not scheduled.
7334
- *
7335
- * @author Vova Feldman (@svovaf)
7336
- * @since 1.1.7.3
7337
- *
7338
- * @return int|false
7339
- */
7340
- function next_sync_cron() {
7341
- return $this->get_next_scheduled_cron( 'sync', 'data_sync' );
7342
- }
7343
-
7344
- /**
7345
- * Unix timestamp for previous sync cron execution or false if never executed.
7346
- *
7347
- * @author Vova Feldman (@svovaf)
7348
- * @since 1.1.7.3
7349
- *
7350
- * @return int|false
7351
- */
7352
- function last_sync_cron() {
7353
- return $this->cron_last_execution( 'sync' );
7354
- }
7355
-
7356
- #endregion Daily Sync Cron ------------------------------------------------------------------
7357
-
7358
- #----------------------------------------------------------------------------------
7359
- #region Async Install Sync
7360
- #----------------------------------------------------------------------------------
7361
-
7362
- /**
7363
- * @author Vova Feldman (@svovaf)
7364
- * @since 1.1.7.3
7365
- *
7366
- * @return bool
7367
- */
7368
- private function is_install_sync_scheduled() {
7369
- return $this->is_cron_on( 'install_sync' );
7370
- }
7371
-
7372
- /**
7373
- * Get the sync cron's executing blog ID.
7374
- *
7375
- * @author Vova Feldman (@svovaf)
7376
- * @since 2.0.0
7377
- *
7378
- * @return int
7379
- */
7380
- private function get_install_sync_cron_blog_id() {
7381
- return $this->get_cron_blog_id( 'install_sync' );
7382
- }
7383
-
7384
- /**
7385
- * Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
7386
- *
7387
- * @author Vova Feldman (@svovaf)
7388
- * @since 1.1.7.3
7389
- *
7390
- * @param int $except_blog_id Since 2.0.0 when running in a multisite network environment, the cron execution is consolidated. This param allows excluding excluded specified blog ID from being the cron executor.
7391
- */
7392
- private function schedule_install_sync( $except_blog_id = 0 ) {
7393
- $this->schedule_cron( 'install_sync', 'install_sync', 'single', WP_FS__SCRIPT_START_TIME, false, $except_blog_id );
7394
- }
7395
-
7396
- /**
7397
- * Unix timestamp for previous install sync cron execution or false if never executed.
7398
- *
7399
- * @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being updated. But for sure the sync event is working.
7400
- *
7401
- * @author Vova Feldman (@svovaf)
7402
- * @since 1.1.7.3
7403
- *
7404
- * @return int|false
7405
- */
7406
- function last_install_sync() {
7407
- return $this->cron_last_execution( 'install_sync' );
7408
- }
7409
-
7410
- /**
7411
- * Unix timestamp for next install sync cron execution or false if not scheduled.
7412
- *
7413
- * @author Vova Feldman (@svovaf)
7414
- * @since 1.1.7.3
7415
- *
7416
- * @return int|false
7417
- */
7418
- function next_install_sync() {
7419
- return $this->get_next_scheduled_cron( 'install_sync', 'install_sync' );
7420
- }
7421
-
7422
- /**
7423
- * Add the actual install sync function to the cron job hook.
7424
- *
7425
- * @author Vova Feldman (@svovaf)
7426
- * @since 1.1.7.3
7427
- */
7428
- private function hook_callback_to_install_sync() {
7429
- $this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
7430
- }
7431
-
7432
- /**
7433
- * @author Vova Feldman (@svovaf)
7434
- * @since 1.1.7.3
7435
- *
7436
- * @param bool $is_network_clear Since 2.0.0 If set to TRUE, clear sync cron even if there are installs that are still connected.
7437
- */
7438
- private function clear_install_sync_cron( $is_network_clear = false ) {
7439
- $this->_logger->entrance();
7440
-
7441
- $this->clear_cron( 'install_sync', 'install_sync', $is_network_clear );
7442
- }
7443
-
7444
- /**
7445
- * @author Vova Feldman (@svovaf)
7446
- * @since 1.1.7.3
7447
- * @since 2.0.0 Consolidate all the data sync into the same cron for performance optimization. The max number of API requests is based on the number of unique opted-in users.
7448
- */
7449
- public function _run_sync_install() {
7450
- $this->_logger->entrance();
7451
-
7452
- $this->execute_cron( 'sync', array( &$this, '_sync_install_cron_method' ) );
7453
- }
7454
-
7455
- /**
7456
- * The actual install(s) sync cron logic.
7457
- *
7458
- * @author Vova Feldman (@svovaf)
7459
- * @since 2.0.0
7460
- *
7461
- * @param int[] $blog_ids
7462
- * @param int|null $current_blog_id
7463
- */
7464
- function _sync_install_cron_method( array $blog_ids, $current_blog_id = null ) {
7465
- if ( $this->is_clone() ) {
7466
- return;
7467
- }
7468
-
7469
- if ( $this->is_registered() ) {
7470
- if ( 1 < count( $blog_ids ) ) {
7471
- $this->sync_installs( array(), true );
7472
- } else {
7473
- $this->sync_install( array(), true );
7474
- }
7475
-
7476
- $this->maybe_sync_install_user();
7477
- }
7478
- }
7479
-
7480
- #endregion Async Install Sync ------------------------------------------------------------------
7481
-
7482
- /**
7483
- * Show a notice that activation is currently pending.
7484
- *
7485
- * @todo Add some sort of mechanism to allow users to update the email address they would like to opt-in with when $is_suspicious_email is true.
7486
- *
7487
- * @author Vova Feldman (@svovaf)
7488
- * @since 1.0.7
7489
- *
7490
- * @param bool|string $email
7491
- * @param bool $is_pending_trial Since 1.2.1.5
7492
- * @param bool $is_suspicious_email Since 2.5.0 Set to true when there's an indication that email address the user opted in with is fake/dummy/placeholder.
7493
- */
7494
- function _add_pending_activation_notice(
7495
- $email = false,
7496
- $is_pending_trial = false,
7497
- $is_suspicious_email = false
7498
- ) {
7499
- if ( ! is_string( $email ) ) {
7500
- $current_user = self::_get_current_wp_user();
7501
- $email = $current_user->user_email;
7502
- }
7503
-
7504
- $this->_admin_notices->add_sticky(
7505
- sprintf(
7506
- $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' ),
7507
- '<b>' . $this->get_plugin_name() . '</b>',
7508
- '<b>' . $email . '</b>',
7509
- ( $is_pending_trial ?
7510
- $this->get_text_inline( 'start the trial', 'start-the-trial' ) :
7511
- $this->get_text_inline( 'complete the install', 'complete-the-install' ) )
7512
- ),
7513
- 'activation_pending',
7514
- 'Thanks!'
7515
- );
7516
- }
7517
-
7518
- /**
7519
- * Check if currently in plugin activation.
7520
- *
7521
- * @author Vova Feldman (@svovaf)
7522
- * @since 1.1.4
7523
- *
7524
- * @return bool
7525
- */
7526
- function is_plugin_activation() {
7527
- $result = get_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
7528
-
7529
- return !empty($result);
7530
- }
7531
-
7532
- /**
7533
- *
7534
- * NOTE: admin_menu action executed before admin_init.
7535
- *
7536
- * @author Vova Feldman (@svovaf)
7537
- * @since 1.0.7
7538
- */
7539
- function _admin_init_action() {
7540
- $is_migration = $this->is_migration();
7541
-
7542
- /**
7543
- * Automatically redirect to connect/activation page after plugin activation.
7544
- *
7545
- * @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
7546
- */
7547
- if ( $this->is_plugin_activation() ) {
7548
- delete_transient( "fs_{$this->_module_type}_{$this->_slug}_activated" );
7549
-
7550
- if ( isset( $_GET['activate-multi'] ) ) {
7551
- /**
7552
- * Don't redirect if activating multiple plugins at once (bulk activation).
7553
- */
7554
- } else if (
7555
- self::is_deactivation_snoozed() &&
7556
- (
7557
- // Either running the free code base.
7558
- ! $this->is_premium() ||
7559
- // Or if has a free version.
7560
- ! $this->is_only_premium() ||
7561
- // If premium only, don't redirect if license is activated.
7562
- ( $this->is_registered() && ! $this->can_use_premium_code() )
7563
- )
7564
- ) {
7565
- /**
7566
- * Don't redirect if activating during the deactivation snooze period (aka troubleshooting), unless activating a paid product version that the admin didn't enter its license key yet.
7567
- */
7568
- } else if ( ! $is_migration ) {
7569
- $this->_redirect_on_activation_hook();
7570
- return;
7571
- }
7572
- }
7573
-
7574
- if ( $is_migration ) {
7575
- return;
7576
- }
7577
-
7578
- if ( fs_request_is_action( $this->get_unique_affix() . '_skip_activation' ) ) {
7579
- check_admin_referer( $this->get_unique_affix() . '_skip_activation' );
7580
-
7581
- $this->skip_connection( null, fs_is_network_admin() );
7582
-
7583
- fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) );
7584
- }
7585
-
7586
- if ( $this->is_network_activation_mode() &&
7587
- fs_request_is_action( $this->get_unique_affix() . '_delegate_activation' )
7588
- ) {
7589
- check_admin_referer( $this->get_unique_affix() . '_delegate_activation' );
7590
-
7591
- $this->delegate_connection();
7592
-
7593
- fs_redirect( $this->get_after_activation_url( 'after_delegation_url' ) );
7594
- }
7595
-
7596
- $this->_add_upgrade_action_link();
7597
-
7598
- if ( ! ( ! $this->_is_network_active && fs_is_network_admin() ) &&
7599
- (
7600
- ( true === $this->_storage->require_license_activation ) ||
7601
- // Not registered nor anonymous.
7602
- ( ! $this->is_registered() && ! $this->is_anonymous() ) ||
7603
- // OR, network level and in network upgrade mode.
7604
- ( fs_is_network_admin() && $this->_is_network_active && $this->is_network_upgrade_mode() )
7605
- )
7606
- ) {
7607
- if ( ! $this->is_pending_activation() ) {
7608
- if ( ! $this->is_activation_page() ) {
7609
- /**
7610
- * If a user visits any other admin page before activating the premium-only theme with a valid
7611
- * license, reactivate the previous theme.
7612
- *
7613
- * @author Leo Fajardo (@leorw)
7614
- * @since 1.2.2
7615
- */
7616
- if ( $this->is_theme() &&
7617
- ! $this->has_settings_menu() &&
7618
- ! isset( $_REQUEST['fs_action'] ) &&
7619
- $this->can_activate_previous_theme()
7620
- ) {
7621
- if ( $this->is_only_premium() ) {
7622
- $this->activate_previous_theme();
7623
- return;
7624
- }
7625
-
7626
- if ( true === $this->_storage->require_license_activation ) {
7627
- $this->_storage->require_license_activation = false;
7628
- }
7629
- }
7630
-
7631
- if ( ! fs_is_network_admin() &&
7632
- $this->is_network_activation_mode() &&
7633
- ! $this->is_delegated_connection()
7634
- ) {
7635
- return;
7636
- }
7637
-
7638
- if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
7639
- if ( ! $this->_anonymous_mode &&
7640
- ( ! $this->is_addon() || ! $this->_parent->is_anonymous() ) ) {
7641
- // Show notice for new plugin installations.
7642
- $this->_admin_notices->add(
7643
- sprintf(
7644
- $this->get_text_inline( 'You are just one step away - %s', 'you-are-step-away' ),
7645
- sprintf( '<b><a href="%s">%s</a></b>',
7646
- $this->get_activation_url( array(), ! $this->is_delegated_connection() ),
7647
- sprintf( $this->get_text_x_inline( 'Complete "%s" Activation Now',
7648
- '%s - plugin name. As complete "PluginX" activation now', 'activate-x-now' ), $this->get_plugin_name() )
7649
- )
7650
- ),
7651
- '',
7652
- 'update-nag'
7653
- );
7654
- }
7655
- } else {
7656
- if ( $this->should_add_sticky_optin_notice() ) {
7657
- $this->add_sticky_optin_admin_notice();
7658
- }
7659
-
7660
- if ( $this->has_filter( 'optin_pointer_element' ) ) {
7661
- // Don't show admin nag if plugin update.
7662
- wp_enqueue_script( 'wp-pointer' );
7663
- wp_enqueue_style( 'wp-pointer' );
7664
-
7665
- $this->_enqueue_connect_essentials();
7666
-
7667
- add_action( 'admin_print_footer_scripts', array(
7668
- $this,
7669
- '_add_connect_pointer_script'
7670
- ) );
7671
- }
7672
- }
7673
- }
7674
- }
7675
-
7676
- if ( $this->show_opt_in_on_themes_page() &&
7677
- $this->is_activation_page()
7678
- ) {
7679
- $this->_show_theme_activation_optin_dialog();
7680
- }
7681
- }
7682
- }
7683
-
7684
- /**
7685
- * @author Vova Feldman (@svovaf)
7686
- * @since 2.0.0
7687
- *
7688
- * @return bool
7689
- */
7690
- private function should_add_sticky_optin_notice() {
7691
- if ( $this->is_addon() && $this->_parent->is_anonymous() ) {
7692
- return false;
7693
- }
7694
-
7695
- if ( fs_is_network_admin() ) {
7696
- if ( ! $this->_is_network_active ) {
7697
- return false;
7698
- }
7699
-
7700
- if ( ! $this->is_network_activation_mode() ) {
7701
- return false;
7702
- }
7703
-
7704
- return ! isset( $this->_storage->sticky_optin_added_ms );
7705
- }
7706
-
7707
- if ( ! $this->is_activation_mode() ) {
7708
- return false;
7709
- }
7710
-
7711
- // If running from a blog admin and delegated the connection.
7712
- return ! isset( $this->_storage->sticky_optin_added );
7713
- }
7714
-
7715
- /**
7716
- * @author Leo Fajardo (@leorw)
7717
- * @since 2.0.0
7718
- */
7719
- private function add_sticky_optin_admin_notice() {
7720
- if ( ! $this->_is_network_active || ! fs_is_network_admin() ) {
7721
- $this->_storage->sticky_optin_added = true;
7722
- } else {
7723
- $this->_storage->sticky_optin_added_ms = true;
7724
- }
7725
-
7726
- // Show notice for new plugin installations.
7727
- $this->_admin_notices->add_sticky(
7728
- sprintf(
7729
- $this->get_text_inline( 'We made a few tweaks to the %s, %s', 'few-plugin-tweaks' ),
7730
- $this->_module_type,
7731
- sprintf( '<b><a href="%s">%s</a></b>',
7732
- $this->get_activation_url(),
7733
- sprintf( $this->get_text_inline( 'Opt in to make "%s" better!', 'optin-x-now' ), $this->get_plugin_name() )
7734
- )
7735
- ),
7736
- 'connect_account',
7737
- '',
7738
- 'update-nag'
7739
- );
7740
- }
7741
-
7742
- /**
7743
- * Enqueue connect requires scripts and styles.
7744
- *
7745
- * @author Vova Feldman (@svovaf)
7746
- * @since 1.1.4
7747
- */
7748
- function _enqueue_connect_essentials() {
7749
- wp_enqueue_script( 'jquery' );
7750
- wp_enqueue_script( 'json2' );
7751
-
7752
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
7753
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
7754
- }
7755
-
7756
- /**
7757
- * Add connect / opt-in pointer.
7758
- *
7759
- * @author Vova Feldman (@svovaf)
7760
- * @since 1.1.4
7761
- */
7762
- function _add_connect_pointer_script() {
7763
- $vars = array( 'id' => $this->_module_id );
7764
- $pointer_content = fs_get_template( 'connect.php', $vars );
7765
- ?>
7766
- <script type="text/javascript">// <![CDATA[
7767
- jQuery(document).ready(function ($) {
7768
- if ('undefined' !== typeof(jQuery().pointer)) {
7769
-
7770
- var element = <?php echo $this->apply_filters( 'optin_pointer_element', '$("#non_existing_element");' ) ?>;
7771
-
7772
- if (element.length > 0) {
7773
- var optin = $(element).pointer($.extend(true, {}, {
7774
- content : <?php echo json_encode( $pointer_content ) ?>,
7775
- position : {
7776
- edge : 'left',
7777
- align: 'center'
7778
- },
7779
- buttons : function () {
7780
- // Don't show pointer buttons.
7781
- return '';
7782
- },
7783
- pointerWidth: 482
7784
- }, <?php echo $this->apply_filters( 'optin_pointer_options_json', '{}' ) ?>));
7785
-
7786
- <?php
7787
- echo $this->apply_filters( 'optin_pointer_execute', "
7788
-
7789
- optin.pointer('open');
7790
-
7791
- // Tag the opt-in pointer with custom class.
7792
- $('.wp-pointer #fs_connect')
7793
- .parents('.wp-pointer.wp-pointer-top')
7794
- .addClass('fs-opt-in-pointer');
7795
-
7796
- ", 'element', 'optin' ) ?>
7797
- }
7798
- }
7799
- });
7800
- // ]]></script>
7801
- <?php
7802
- }
7803
-
7804
- /**
7805
- * Return current page's URL.
7806
- *
7807
- * @author Vova Feldman (@svovaf)
7808
- * @since 1.0.7
7809
- *
7810
- * @return string
7811
- */
7812
- function current_page_url() {
7813
- $url = 'http';
7814
-
7815
- if ( isset( $_SERVER["HTTPS"] ) ) {
7816
- if ( $_SERVER["HTTPS"] == "on" ) {
7817
- $url .= "s";
7818
- }
7819
- }
7820
- $url .= "://";
7821
- if ( $_SERVER["SERVER_PORT"] != "80" ) {
7822
- $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
7823
- } else {
7824
- $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
7825
- }
7826
-
7827
- return esc_url( $url );
7828
- }
7829
-
7830
- /**
7831
- * Check if the current page is the plugin's main admin settings page.
7832
- *
7833
- * @author Vova Feldman (@svovaf)
7834
- * @since 1.0.7
7835
- *
7836
- * @return bool
7837
- */
7838
- function _is_plugin_page() {
7839
- return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
7840
- fs_is_plugin_page( $this->_slug );
7841
- }
7842
-
7843
- /* Events
7844
- ------------------------------------------------------------------------------------------------------------------*/
7845
- /**
7846
- * Delete site install from Database.
7847
- *
7848
- * @author Vova Feldman (@svovaf)
7849
- * @since 1.0.1
7850
- *
7851
- * @param bool $store
7852
- * @param int|null $blog_id Since 2.0.0
7853
- *
7854
- * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
7855
- */
7856
- function _delete_site( $store = true, $blog_id = null ) {
7857
- return self::_delete_site_by_slug( $this->_slug, $this->_module_type, $store, $blog_id );
7858
- }
7859
-
7860
- /**
7861
- * Delete site install from Database.
7862
- *
7863
- * @author Vova Feldman (@svovaf)
7864
- * @since 1.2.2.7
7865
- *
7866
- * @param string $slug
7867
- * @param string $module_type
7868
- * @param bool $store
7869
- * @param int|null $blog_id Since 2.0.0
7870
- *
7871
- * @return false|int The install ID if deleted. Otherwise, FALSE (when install not exist).
7872
- */
7873
- static function _delete_site_by_slug( $slug, $module_type, $store = true, $blog_id = null ) {
7874
- $sites = self::get_all_sites( $module_type, $blog_id );
7875
-
7876
- $install_id = false;
7877
-
7878
- if ( isset( $sites[ $slug ] ) ) {
7879
- if ( is_object( $sites[ $slug ] ) ) {
7880
- $install_id = $sites[ $slug ]->id;
7881
- }
7882
-
7883
- unset( $sites[ $slug ] );
7884
-
7885
- self::set_account_option_by_module( $module_type, 'sites', $sites, $store, $blog_id );
7886
- }
7887
-
7888
- return $install_id;
7889
- }
7890
-
7891
- /**
7892
- * Delete user.
7893
- *
7894
- * @author Vova Feldman (@svovaf)
7895
- * @since 2.0.0
7896
- *
7897
- * @param number $user_id
7898
- * @param bool $store
7899
- *
7900
- * @return false|int The user ID if deleted. Otherwise, FALSE (when install not exist).
7901
- */
7902
- private static function delete_user( $user_id, $store = true ) {
7903
- $users = self::get_all_users();
7904
-
7905
- if ( ! is_array( $users ) || ! isset( $users[ $user_id ] ) ) {
7906
- return false;
7907
- }
7908
-
7909
- unset( $users[ $user_id ] );
7910
-
7911
- self::$_accounts->set_option( 'users', $users, $store );
7912
-
7913
- return $user_id;
7914
- }
7915
-
7916
- /**
7917
- * Delete plugin's plans information.
7918
- *
7919
- * @param bool $store Flush to Database if true.
7920
- * @param bool $keep_associated_plans If set to false, delete all plans, even if a plan is associated with an install.
7921
- *
7922
- * @author Vova Feldman (@svovaf)
7923
- * @since 1.0.9
7924
- */
7925
- private function _delete_plans( $store = true, $keep_associated_plans = true ) {
7926
- $this->_logger->entrance();
7927
-
7928
- $plans = self::get_all_plans( $this->_module_type );
7929
-
7930
- $plans_to_keep = array();
7931
-
7932
- if ( $keep_associated_plans ) {
7933
- $plans_ids_to_keep = $this->get_plans_ids_associated_with_installs();
7934
- foreach ( $plans_ids_to_keep as $plan_id ) {
7935
- $plan = self::_get_plan_by_id( $plan_id );
7936
- if ( is_object( $plan ) ) {
7937
- $plans_to_keep[] = self::_encrypt_entity( $plan );
7938
- }
7939
- }
7940
- }
7941
-
7942
- if ( ! empty( $plans_to_keep ) ) {
7943
- $plans[ $this->_slug ] = $plans_to_keep;
7944
- } else {
7945
- unset( $plans[ $this->_slug ] );
7946
- }
7947
-
7948
- $this->set_account_option( 'plans', $plans, $store );
7949
- }
7950
-
7951
- /**
7952
- * Delete all plugin licenses.
7953
- *
7954
- * @author Vova Feldman (@svovaf)
7955
- * @since 1.0.9
7956
- *
7957
- * @param bool $store
7958
- */
7959
- private function _delete_licenses( $store = true ) {
7960
- $this->_logger->entrance();
7961
-
7962
- $all_licenses = self::get_all_licenses();
7963
-
7964
- unset( $all_licenses[ $this->_module_id ] );
7965
-
7966
- self::$_accounts->set_option( 'all_licenses', $all_licenses, $store );
7967
- }
7968
-
7969
- /**
7970
- * Check if Freemius was added on new plugin installation.
7971
- *
7972
- * @author Vova Feldman (@svovaf)
7973
- * @since 1.1.5
7974
- *
7975
- * @return bool
7976
- */
7977
- function is_plugin_new_install() {
7978
- return isset( $this->_storage->is_plugin_new_install ) &&
7979
- $this->_storage->is_plugin_new_install;
7980
- }
7981
-
7982
- /**
7983
- * Check if it's the first plugin release that is running Freemius.
7984
- *
7985
- * @author Vova Feldman (@svovaf)
7986
- * @since 1.2.1.5
7987
- *
7988
- * @return bool
7989
- */
7990
- function is_first_freemius_powered_version() {
7991
- return empty( $this->_storage->plugin_last_version );
7992
- }
7993
-
7994
- /**
7995
- * @author Leo Fajardo (@leorw)
7996
- * @since 1.2.2
7997
- *
7998
- * @return bool|string
7999
- */
8000
- private function get_previous_theme_slug() {
8001
- return isset( $this->_storage->previous_theme ) ?
8002
- $this->_storage->previous_theme :
8003
- false;
8004
- }
8005
-
8006
- /**
8007
- * @author Leo Fajardo (@leorw)
8008
- * @since 1.2.2
8009
- *
8010
- * @return string
8011
- */
8012
- private function can_activate_previous_theme() {
8013
- $slug = $this->get_previous_theme_slug();
8014
- if ( false !== $slug && current_user_can( 'switch_themes' ) ) {
8015
- $theme_instance = wp_get_theme( $slug );
8016
-
8017
- return $theme_instance->exists();
8018
- }
8019
-
8020
- return false;
8021
- }
8022
-
8023
- /**
8024
- * @author Leo Fajardo (@leorw)
8025
- * @since 1.2.2
8026
- */
8027
- private function activate_previous_theme() {
8028
- switch_theme( $this->get_previous_theme_slug() );
8029
- unset( $this->_storage->previous_theme );
8030
-
8031
- global $pagenow;
8032
- if ( 'themes.php' === $pagenow ) {
8033
- /**
8034
- * Refresh the active theme information.
8035
- *
8036
- * @author Leo Fajardo (@leorw)
8037
- * @since 1.2.2
8038
- */
8039
- fs_redirect( $this->admin_url( $pagenow ) );
8040
- }
8041
- }
8042
-
8043
- /**
8044
- * @author Leo Fajardo (@leorw)
8045
- * @since 1.2.2
8046
- *
8047
- * @return string
8048
- */
8049
- function get_previous_theme_activation_url() {
8050
- if ( ! $this->can_activate_previous_theme() ) {
8051
- return '';
8052
- }
8053
-
8054
- /**
8055
- * Activation URL
8056
- *
8057
- * @author Leo Fajardo (@leorw)
8058
- * @since 1.2.2
8059
- */
8060
- return wp_nonce_url(
8061
- $this->admin_url( 'themes.php?action=activate&stylesheet=' . urlencode( $this->get_previous_theme_slug() ) ),
8062
- 'switch-theme_' . $this->get_previous_theme_slug()
8063
- );
8064
- }
8065
-
8066
- /**
8067
- * Saves the slug of the previous theme if it still exists so that it can be used by the logic in the opt-in
8068
- * form that decides whether to add a close button to the opt-in dialog or not. So after a premium-only theme is
8069
- * activated, the close button will appear and will reactivate the previous theme if clicked. If the previous
8070
- * theme doesn't exist, then there will be no close button.
8071
- *
8072
- * @author Leo Fajardo (@leorw)
8073
- * @since 1.2.2
8074
- *
8075
- * @param string $slug_or_name Old theme's slug or name.
8076
- * @param bool|WP_Theme $old_theme WP_Theme instance of the old theme if it still exists.
8077
- */
8078
- function _activate_theme_event_hook( $slug_or_name, $old_theme = false ) {
8079
- $this->_storage->previous_theme = ( false !== $old_theme ) ?
8080
- $old_theme->get_stylesheet() :
8081
- $slug_or_name;
8082
-
8083
- $this->_activate_plugin_event_hook();
8084
- }
8085
-
8086
- /**
8087
- * Plugin activated hook.
8088
- *
8089
- * @author Vova Feldman (@svovaf)
8090
- * @since 1.0.1
8091
- *
8092
- * @uses FS_Api
8093
- */
8094
- function _activate_plugin_event_hook() {
8095
- $this->_logger->entrance( 'slug = ' . $this->_slug );
8096
-
8097
- if ( ! $this->is_user_admin() ) {
8098
- return;
8099
- }
8100
-
8101
- $this->unregister_uninstall_hook();
8102
-
8103
- // Clear API cache on activation.
8104
- FS_Api::clear_cache();
8105
-
8106
- $is_premium_version_activation = $this->is_plugin() ?
8107
- ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) ) :
8108
- $this->is_premium();
8109
-
8110
- $this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
8111
-
8112
- if ( $this->is_plugin() ) {
8113
- // This logic is relevant only to plugins since both the free and premium versions of a plugin can be active at the same time.
8114
- // 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
8115
- // 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
8116
- $other_version_basename = $is_premium_version_activation ?
8117
- $this->_free_plugin_basename :
8118
- $this->premium_plugin_basename();
8119
-
8120
- if ( ! $this->_is_network_active ) {
8121
- /**
8122
- * Themes are always network activated, but the ACTUAL activation is per site.
8123
- *
8124
- * During the activation, the plugin isn't yet active, therefore,
8125
- * _is_network_active will be set to false even if it's a network level
8126
- * activation. So we need to fix that by looking at the is_network_admin() value.
8127
- *
8128
- * @author Vova Feldman
8129
- */
8130
- $this->_is_network_active = (
8131
- $this->_is_multisite_integrated &&
8132
- fs_is_network_admin()
8133
- );
8134
- }
8135
-
8136
- /**
8137
- * If the other module version is active, deactivate it.
8138
- *
8139
- * is_plugin_active() checks if the plugin is active on the site or the network level and
8140
- * deactivate_plugins() deactivates the plugin whether it's activated on the site or network level.
8141
- *
8142
- * @author Leo Fajardo (@leorw)
8143
- * @since 1.2.2
8144
- */
8145
- if (
8146
- is_plugin_active( $other_version_basename ) &&
8147
- $this->apply_filters( 'deactivate_on_activation', true )
8148
- ) {
8149
- deactivate_plugins( $other_version_basename );
8150
- }
8151
- }
8152
-
8153
- if ( $this->is_registered() ) {
8154
- if ( $is_premium_version_activation ) {
8155
- $this->reconnect_locally();
8156
- }
8157
-
8158
-
8159
- // Schedule re-activation event and sync.
8160
- // $this->sync_install( array(), true );
8161
- $this->schedule_install_sync();
8162
-
8163
- // If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
8164
- if ( $is_premium_version_activation ) {
8165
- $this->_admin_notices->add(
8166
- sprintf( $this->get_text_inline( 'The upgrade of %s was successfully completed.', 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
8167
- $this->get_text_x_inline( 'W00t',
8168
- 'Used to express elation, enthusiasm, or triumph (especially in electronic communication).', 'woot' ) . '!'
8169
- );
8170
- }
8171
- } else if ( $this->is_anonymous() ) {
8172
- if ( isset( $this->_storage->is_anonymous_ms ) && $this->_storage->is_anonymous_ms['is'] ) {
8173
- $plugin_version = $this->_storage->is_anonymous_ms['version'];
8174
- $network = true;
8175
- } else {
8176
- $plugin_version = isset( $this->_storage->is_anonymous ) ?
8177
- $this->_storage->is_anonymous['version'] :
8178
- null;
8179
- $network = false;
8180
- }
8181
-
8182
- /**
8183
- * Reset "skipped" click cache on the following:
8184
- * 1. Freemius DEV mode.
8185
- * 2. WordPress DEBUG mode.
8186
- * 3. If a plugin and the user skipped the exact same version before.
8187
- *
8188
- * @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).
8189
- *
8190
- * @todo 4. If explicitly asked to retry after every activation.
8191
- */
8192
- if ( WP_FS__DEV_MODE ||
8193
- (
8194
- ( $this->is_plugin() || ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ) &&
8195
- $this->get_plugin_version() == $plugin_version
8196
- )
8197
- ) {
8198
- $this->reset_anonymous_mode( $network );
8199
- }
8200
- }
8201
-
8202
- $is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
8203
-
8204
- if ( $this->is_addon() && ! $is_trial_or_has_features_enabled_license ) {
8205
- /**
8206
- * When activating an add-on, try to also activate a license.
8207
- *
8208
- * @author Leo Fajardo (@leorw)
8209
- * @since 2.3.0
8210
- */
8211
- if ( ! $this->_is_network_active ) {
8212
- $this->maybe_activate_addon_license();
8213
- } else {
8214
- $this->maybe_network_activate_addon_license();
8215
- }
8216
-
8217
- /**
8218
- * Avoid redirecting to the license activation screen after automatically activating an add-on license.
8219
- *
8220
- * @author Leo Fajardo (@leorw)
8221
- * @since 2.3.0
8222
- */
8223
- $is_trial_or_has_features_enabled_license = ( $this->is_trial() || $this->has_features_enabled_license() );
8224
-
8225
- if ( $is_trial_or_has_features_enabled_license && true === $this->_storage->require_license_activation ) {
8226
- $this->_storage->require_license_activation = false;
8227
- }
8228
- }
8229
-
8230
- if (
8231
- $is_premium_version_activation &&
8232
- (
8233
- ( ! $this->is_registered() && $this->is_anonymous() ) ||
8234
- (
8235
- $this->is_registered() &&
8236
- ! $is_trial_or_has_features_enabled_license
8237
- )
8238
- )
8239
- ) {
8240
- $this->_storage->require_license_activation = true;
8241
- }
8242
-
8243
- if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
8244
- /**
8245
- * If no previous version of plugin's version exist, it means that it's either
8246
- * the first time that the plugin installed on the site, or the plugin was installed
8247
- * before but didn't have Freemius integrated.
8248
- *
8249
- * Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
8250
- * on manual activation via the dashboard, is_plugin_activation() is TRUE
8251
- * only after immediate activation.
8252
- *
8253
- * @since 1.1.4
8254
- * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
8255
- */
8256
- $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
8257
- }
8258
-
8259
- /**
8260
- * Also flush when activating the premium version so that even if Freemius was off before, the API
8261
- * connectivity test can be run again.
8262
- *
8263
- * @author Leo Fajardo (@leorw)
8264
- * @since 2.2.3.1
8265
- */
8266
- $has_api_connectivity = $this->has_api_connectivity( WP_FS__DEV_MODE || $is_premium_version_activation );
8267
-
8268
- if ( ! $this->_anonymous_mode &&
8269
- $has_api_connectivity &&
8270
- ! $this->_isAutoInstall
8271
- ) {
8272
- // Store hint that the plugin was just activated to enable auto-redirection to settings.
8273
- set_transient( "fs_{$this->_module_type}_{$this->_slug}_activated", true, 60 );
8274
- }
8275
-
8276
- /**
8277
- * Activation hook is executed after the plugin's main file is loaded, therefore,
8278
- * after the plugin was loaded. The logic is located at activate_plugin()
8279
- * ./wp-admin/includes/plugin.php.
8280
- *
8281
- * @author Vova Feldman (@svovaf)
8282
- * @since 1.1.9
8283
- */
8284
- $this->_storage->was_plugin_loaded = true;
8285
- }
8286
-
8287
- /**
8288
- * @author Leo Fajardo (@leorw)
8289
- * @since 2.3.0
8290
- */
8291
- private function maybe_activate_addon_license() {
8292
- $parent_fs = $this->get_parent_instance();
8293
-
8294
- if (
8295
- ! is_object( $parent_fs ) ||
8296
- ( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() )
8297
- ) {
8298
- // Try to activate a license only if the parent plugin is active and has a valid `install`.
8299
- return;
8300
- }
8301
-
8302
- $license = $this->get_active_parent_license();
8303
- if ( ! is_object( $license ) ) {
8304
- return;
8305
- }
8306
-
8307
- if (
8308
- $this->is_bundle_license_auto_activation_enabled() &&
8309
- ! empty( $license->products )
8310
- ) {
8311
- $this->activate_bundle_license( $license );
8312
-
8313
- return;
8314
- }
8315
-
8316
- if ( ! $this->is_registered() ) {
8317
- // Opt in with a license key.
8318
- $this->opt_in(
8319
- $parent_fs->get_current_or_network_user()->email,
8320
- false,
8321
- false,
8322
- $license->secret_key
8323
- );
8324
- } else {
8325
- // Activate the license.
8326
- $install = $this->api_site_call(
8327
- '/',
8328
- 'put',
8329
- array( 'license_key' => $this->apply_filters( 'license_key', $license->secret_key ) )
8330
- );
8331
-
8332
- if ( ! FS_Api::is_api_error( $install ) ) {
8333
- $this->_sync_addon_license( $this->get_id(), true );
8334
- }
8335
- }
8336
- }
8337
-
8338
- /**
8339
- * @author Leo Fajardo (@leorw)
8340
- * @since 2.3.0
8341
- *
8342
- * @param FS_Plugin_License $license
8343
- */
8344
- private function maybe_network_activate_addon_license( $license = null ) {
8345
- $parent_fs = $this->get_parent_instance();
8346
- if ( ! is_object( $parent_fs ) || ( ! $parent_fs->is_registered() && ! $parent_fs->is_network_registered() ) ) {
8347
- // Try to activate a license only if the parent plugin is active and has a valid `install`.
8348
- return;
8349
- }
8350
-
8351
- $license = ( ! is_null( $license ) ) ?
8352
- $license :
8353
- $this->get_active_parent_license();
8354
-
8355
- if ( ! is_object( $license ) ) {
8356
- return;
8357
- }
8358
-
8359
- if (
8360
- $this->is_bundle_license_auto_activation_enabled() &&
8361
- ! empty( $license->products )
8362
- ) {
8363
- $this->activate_bundle_license( $license );
8364
-
8365
- return;
8366
- }
8367
-
8368
- if ( ! $this->is_network_registered() ) {
8369
- $sites = $this->get_sites_for_network_level_optin();
8370
-
8371
- if ( count( $sites ) > $license->left() ) {
8372
- // If the add-on is network active, try to activate the license only if it can be activated on all sites.
8373
- return;
8374
- }
8375
-
8376
- // Opt in with a license key.
8377
- $this->opt_in(
8378
- $parent_fs->get_user()->email,
8379
- false,
8380
- false,
8381
- $license->secret_key,
8382
- false,
8383
- false,
8384
- false,
8385
- null,
8386
- $sites
8387
- );
8388
- } else {
8389
- $blog_2_install_map = array();
8390
- $site_ids = array();
8391
-
8392
- $all_sites = Freemius::get_sites();
8393
-
8394
- foreach ( $all_sites as $site ) {
8395
- $blog_id = Freemius::get_site_blog_id( $site );
8396
- $install = $this->get_install_by_blog_id( $blog_id );
8397
-
8398
- if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) {
8399
- // Skip license activation for installs that are already associated with a license.
8400
- continue;
8401
- }
8402
-
8403
- if ( is_object( $install ) ) {
8404
- $blog_2_install_map[ $blog_id ] = $install;
8405
- } else {
8406
- $site_ids[] = $blog_id;
8407
- }
8408
- }
8409
-
8410
- if ( ( count( $blog_2_install_map ) + count( $site_ids ) ) > $license->left() ) {
8411
- return;
8412
- }
8413
-
8414
- $user = $this->get_current_or_network_user();
8415
-
8416
- if ( ! empty( $blog_2_install_map ) ) {
8417
- $result = $this->activate_license_on_many_installs( $user, $license->secret_key, $blog_2_install_map );
8418
-
8419
- if ( true !== $result ) {
8420
- return;
8421
- }
8422
- }
8423
-
8424
- if ( ! empty( $site_ids ) ) {
8425
- $this->activate_license_on_many_sites( $user, $license->secret_key, $site_ids );
8426
- }
8427
- }
8428
- }
8429
-
8430
- /**
8431
- * Tries to activate a bundle license for all supported products if the current product is activated with a bundle license. This is called after activating an available license (not via the license activation dialog but by clicking on a license activation button) for a product via its "Account" page.
8432
- *
8433
- * @author Leo Fajardo (@leorw)
8434
- * @since 2.4.0
8435
- *
8436
- * @param FS_Plugin_License $license
8437
- * @param array $sites
8438
- * @param int $blog_id
8439
- */
8440
- private function maybe_activate_bundle_license( FS_Plugin_License $license = null, $sites = array(), $blog_id = 0 ) {
8441
- if ( ! is_object( $license ) && $this->has_active_valid_license() ) {
8442
- $license = $this->_license;
8443
- }
8444
-
8445
- if ( ! is_object( $license ) ) {
8446
- return;
8447
- }
8448
-
8449
- $parent_license = ( ! empty( $license->products ) ) ?
8450
- $license :
8451
- $this->get_active_parent_license( $license->secret_key );
8452
-
8453
- if ( is_object( $parent_license ) ) {
8454
- $this->activate_bundle_license( $parent_license, $sites, $blog_id );
8455
- }
8456
- }
8457
-
8458
- /**
8459
- * Try to activate a bundle license for all the bundle products installed on the site.
8460
- * (1) If a child product install already has a license, the bundle license won't be activated.
8461
- * (2) On multi-site networks, if the attempt to activate the bundle license is triggered from the network admin, the bundle license activation will only work for non-delegated sites and only if none of them is associated with a license. Even if one of the sites has the product installed with a license key, skip the bundle license activation for the product.
8462
- * (3) On multi-site networks, if the attempt to activate the bundle license is triggered from a site-level admin, only activate the license if the product is site-level activated or delegated, and the product installation is not yet associated with a license.
8463
- *
8464
- * @author Leo Fajardo (@leorw)
8465
- * @since 2.4.0
8466
- *
8467
- * @param FS_Plugin_License $license
8468
- * @param array $sites
8469
- * @param int $current_blog_id
8470
- */
8471
- private function activate_bundle_license( $license, $sites = array(), $current_blog_id = 0 ) {
8472
- $is_network_admin = fs_is_network_admin();
8473
-
8474
- $installs_by_blog_map = array();
8475
- $site_info_by_blog_map = array();
8476
-
8477
- /**
8478
- * Try to activate the license for all supported products.
8479
- *
8480
- * @author Leo Fajardo
8481
- */
8482
- foreach ( $license->products as $product_id ) {
8483
- $fs = self::get_instance_by_id( $product_id );
8484
-
8485
- if ( ! is_object( $fs ) ) {
8486
- continue;
8487
- }
8488
-
8489
- if ( ! $fs->has_paid_plan() ) {
8490
- continue;
8491
- }
8492
-
8493
- if (
8494
- ! $fs->is_addon() &&
8495
- ! FS_Plan_Manager::instance()->has_paid_plan( $fs->_plans )
8496
- ) {
8497
- /**
8498
- * The parent product can be free-only but can have its `has_paid_plan` flag set to `true` when
8499
- * there is a context bundle.
8500
- */
8501
- continue;
8502
- }
8503
-
8504
- if ( $current_blog_id > 0 ) {
8505
- $fs->switch_to_blog( $current_blog_id );
8506
- }
8507
-
8508
- if ( $fs->has_active_valid_license() ) {
8509
- continue;
8510
- }
8511
-
8512
- if ( ! $is_network_admin || $current_blog_id > 0 ) {
8513
- if ( $fs->is_network_active() && ! $fs->is_delegated_connection( $current_blog_id ) ) {
8514
- // Do not try to activate the license in the site level if the product is network active and the connection was not delegated.
8515
- continue;
8516
- }
8517
- } else {
8518
- if ( ! $fs->is_network_active() ) {
8519
- // Do not try to activate the license in the network level if the product is not network active.
8520
- continue;
8521
- }
8522
-
8523
- if ( $fs->is_network_delegated_connection() ) {
8524
- // Do not try to activate the license in the network level if the activation has been delegated to site admins.
8525
- continue;
8526
- }
8527
-
8528
- $has_install_with_license = false;
8529
-
8530
- // Collection of sites that have an install entity that is not activated with a license or non-delegated sites that have no install entity, or both types of site.
8531
- $filtered_sites = array();
8532
-
8533
- if ( empty( $sites ) ) {
8534
- $all_sites = self::get_sites();
8535
-
8536
- foreach ( $all_sites as $site ) {
8537
- $sites[] = array( 'blog_id' => self::get_site_blog_id( $site ) );
8538
- }
8539
- } else {
8540
- // Populate the map here to avoid calling `$fs->get_site_info( $site );` in the other `for` loop below.
8541
- foreach ( $sites as $site ) {
8542
- if ( ! isset( $site['blog_id'] ) || ! is_numeric( $site['blog_id'] ) ) {
8543
- continue;
8544
- }
8545
-
8546
- $site_info_by_blog_map[ $site['blog_id'] ] = $site;
8547
- }
8548
- }
8549
-
8550
- foreach ( $sites as $site ) {
8551
- if ( ! isset( $site['blog_id'] ) || ! is_numeric( $site['blog_id'] ) ) {
8552
- continue;
8553
- }
8554
-
8555
- $blog_id = $site['blog_id'];
8556
-
8557
- if ( ! isset( $installs_by_blog_map[ $blog_id ] ) ) {
8558
- $installs_by_blog_map[ $blog_id ] = self::get_all_sites( $fs->get_module_type(), $blog_id );
8559
- }
8560
-
8561
- $installs = $installs_by_blog_map[ $blog_id ];
8562
- $install = null;
8563
-
8564
- if ( isset( $installs[ $fs->get_slug() ] ) ) {
8565
- $install = $installs[ $fs->get_slug() ];
8566
-
8567
- if (
8568
- is_object( $install ) &&
8569
- (
8570
- ! FS_Site::is_valid_id( $install->id ) ||
8571
- ! FS_User::is_valid_id( $install->user_id ) ||
8572
- ! FS_Plugin_Plan::is_valid_id( $install->plan_id )
8573
- )
8574
- ) {
8575
- $install = null;
8576
- }
8577
- }
8578
-
8579
- if (
8580
- is_object( $install ) &&
8581
- FS_Plugin_License::is_valid_id( $install->license_id )
8582
- ) {
8583
- $has_install_with_license = true;
8584
- break;
8585
- }
8586
-
8587
- if ( $fs->is_site_delegated_connection( $blog_id ) ) {
8588
- // Site activation delegated, don't activate bundle license on the site in the network admin.
8589
- continue;
8590
- }
8591
-
8592
- if ( ! isset( $site_info_by_blog_map[ $blog_id ] ) ) {
8593
- $site_info_by_blog_map[ $blog_id ] = $fs->get_site_info( $site );
8594
- }
8595
-
8596
- $filtered_sites[] = $site_info_by_blog_map[ $blog_id ];
8597
- }
8598
-
8599
- if ( $has_install_with_license || empty( $filtered_sites ) ) {
8600
- // Do not try to activate the license at the network level if there's any install with a license or there's no site to activate the license on.
8601
- continue;
8602
- }
8603
-
8604
- $sites = $filtered_sites;
8605
- }
8606
-
8607
- $fs->activate_migrated_license(
8608
- $license->secret_key,
8609
- null,
8610
- null,
8611
- $sites,
8612
- ( $current_blog_id > 0 ? $current_blog_id : null )
8613
- );
8614
- }
8615
- }
8616
-
8617
- /**
8618
- * Returns a parent license that can be activated for the context product.
8619
- *
8620
- * @author Leo Fajardo (@leorw)
8621
- * @since 2.3.0
8622
- *
8623
- * @param string|null $license_key
8624
- * @param bool $flush
8625
- *
8626
- * @return FS_Plugin_License
8627
- */
8628
- function get_active_parent_license( $license_key = null, $flush = true ) {
8629
- $parent_licenses_endpoint = "/plugins/{$this->get_id()}/parent_licenses.json?filter=activatable";
8630
-
8631
- $fs = $this;
8632
-
8633
- if ( $this->is_addon() ) {
8634
- $parent_instance = $this->get_parent_instance();
8635
-
8636
- if ( is_object( $parent_instance ) && $parent_instance->is_registered() ) {
8637
- $fs = $parent_instance;
8638
- }
8639
- }
8640
-
8641
- $foreign_licenses = $fs->get_foreign_licenses_info(
8642
- self::get_all_licenses( $this->get_parent_id() )
8643
- );
8644
-
8645
- if ( ! empty ( $foreign_licenses ) ) {
8646
- $foreign_licenses = array(
8647
- // Prefix with `+` to tell the server to include foreign licenses in the licenses collection.
8648
- 'ids' => ( urlencode( '+' ) . implode( ',', $foreign_licenses['ids'] ) ),
8649
- 'license_keys' => implode( ',', array_map( 'urlencode', $foreign_licenses['license_keys'] ) )
8650
- );
8651
-
8652
- $parent_licenses_endpoint = add_query_arg( $foreign_licenses, $parent_licenses_endpoint );
8653
- }
8654
-
8655
- $result = $fs->get_current_or_network_user_api_scope()->get( $parent_licenses_endpoint, $flush );
8656
-
8657
- if (
8658
- ! $this->is_api_result_object( $result, 'licenses' ) ||
8659
- ! is_array( $result->licenses ) ||
8660
- empty( $result->licenses )
8661
- ) {
8662
- return null;
8663
- }
8664
-
8665
- $parent_license = null;
8666
-
8667
- if ( empty( $license_key ) ) {
8668
- $parent_license = $result->licenses[0];
8669
- } else {
8670
- foreach ( $result->licenses as $license ) {
8671
- if ( $license_key === $license->secret_key ) {
8672
- $parent_license = $license;
8673
- break;
8674
- }
8675
- }
8676
- }
8677
-
8678
- if ( ! is_null( $parent_license ) ) {
8679
- $parent_license = new FS_Plugin_License( $parent_license );
8680
- }
8681
-
8682
- return $parent_license;
8683
- }
8684
-
8685
- /**
8686
- * @author Leo Fajardo (@leorw)
8687
- * @since 2.3.0
8688
- *
8689
- * @return array
8690
- */
8691
- function get_sites_for_network_level_optin() {
8692
- $sites = array();
8693
- $all_sites = self::get_sites();
8694
-
8695
- foreach ( $all_sites as $site ) {
8696
- $blog_id = self::get_site_blog_id( $site );
8697
-
8698
- if ( ! $this->is_site_delegated_connection( $blog_id ) &&
8699
- ! $this->is_installed_on_site( $blog_id )
8700
- ) {
8701
- $sites[] = $this->get_site_info( $site );
8702
- }
8703
- }
8704
-
8705
- return $sites;
8706
- }
8707
-
8708
- /**
8709
- * Delete account.
8710
- *
8711
- * @author Vova Feldman (@svovaf)
8712
- * @since 1.0.3
8713
- *
8714
- * @param bool $check_user Enforce checking if user have plugins activation privileges.
8715
- */
8716
- function delete_account_event( $check_user = true ) {
8717
- $this->_logger->entrance( 'slug = ' . $this->_slug );
8718
-
8719
- if ( $check_user && ! $this->is_user_admin() ) {
8720
- return;
8721
- }
8722
-
8723
- $this->do_action( 'before_account_delete' );
8724
-
8725
- // Clear all admin notices.
8726
- $this->_admin_notices->clear_all_sticky( false );
8727
-
8728
- $this->_delete_site( false );
8729
-
8730
- $delete_network_common_data = true;
8731
-
8732
- if ( $this->_is_network_active ) {
8733
- $installs = $this->get_blog_install_map();
8734
-
8735
- // Don't delete common network data unless no other installs left.
8736
- $delete_network_common_data = empty( $installs );
8737
- }
8738
-
8739
- if ( $delete_network_common_data ) {
8740
- $this->_delete_plans( false );
8741
-
8742
- $this->_delete_licenses( false );
8743
-
8744
- // Delete add-ons related to plugin's account.
8745
- $this->_delete_account_addons( false );
8746
- }
8747
-
8748
- // @todo Delete plans and licenses of add-ons.
8749
-
8750
- self::$_accounts->store();
8751
-
8752
- /**
8753
- * IMPORTANT:
8754
- * Clear crons must be executed before clearing all storage.
8755
- * Otherwise, the cron will not be cleared.
8756
- */
8757
- if ( $delete_network_common_data ) {
8758
- $this->clear_sync_cron();
8759
- }
8760
-
8761
- $this->clear_install_sync_cron();
8762
-
8763
- // Clear all storage data.
8764
- $this->_storage->clear_all( true, array(
8765
- 'is_delegated_connection',
8766
- 'connectivity_test',
8767
- 'is_on',
8768
- ), false );
8769
-
8770
- // Send delete event.
8771
- $this->get_api_site_scope()->call( '/', 'delete' );
8772
-
8773
- $this->do_action( 'after_account_delete' );
8774
- }
8775
-
8776
- /**
8777
- * Delete network level account.
8778
- *
8779
- * @author Vova Feldman (@svovaf)
8780
- * @since 2.0.0
8781
- *
8782
- * @param bool $check_user Enforce checking if user have plugins activation privileges.
8783
- */
8784
- function delete_network_account_event( $check_user = true ) {
8785
- $this->_logger->entrance( 'slug = ' . $this->_slug );
8786
-
8787
- if ( $check_user && ! $this->is_user_admin() ) {
8788
- return;
8789
- }
8790
-
8791
- $this->do_action( 'before_network_account_delete' );
8792
-
8793
- // Clear all admin notices.
8794
- $this->_admin_notices->clear_all_sticky();
8795
-
8796
- $this->_delete_plans( false, false );
8797
-
8798
- $this->_delete_licenses( false );
8799
-
8800
- // Delete add-ons related to plugin's account.
8801
- $this->_delete_account_addons( false );
8802
-
8803
- // @todo Delete plans and licenses of add-ons.
8804
-
8805
- self::$_accounts->store( true );
8806
-
8807
- /**
8808
- * IMPORTANT:
8809
- * Clear crons must be executed before clearing all storage.
8810
- * Otherwise, the cron will not be cleared.
8811
- */
8812
- $this->clear_sync_cron( true );
8813
- $this->clear_install_sync_cron( true );
8814
-
8815
- $sites = self::get_sites();
8816
-
8817
- $install_ids = array();
8818
- foreach ( $sites as $site ) {
8819
- $blog_id = self::get_site_blog_id( $site );
8820
-
8821
- if ( $this->is_site_delegated_connection( $blog_id ) ) {
8822
- continue;
8823
- }
8824
-
8825
- $install_id = $this->_delete_site( true, $blog_id );
8826
-
8827
- // Clear all storage data.
8828
- $this->_storage->clear_all( true, array( 'connectivity_test' ), $blog_id );
8829
-
8830
- if ( FS_Site::is_valid_id( $install_id ) ) {
8831
- $install_ids[] = $install_id;
8832
- }
8833
-
8834
- switch_to_blog( $blog_id );
8835
-
8836
- $this->do_action( 'after_account_delete' );
8837
-
8838
- restore_current_blog();
8839
- }
8840
-
8841
- $this->_storage->clear_all( true, array(
8842
- 'connectivity_test',
8843
- 'is_on',
8844
- ), true );
8845
-
8846
- // Send delete event.
8847
- if ( ! empty( $install_ids ) ) {
8848
- $result = $this->get_current_or_network_user_api_scope()->call( "/plugins/{$this->_module_id}/installs.json?ids=" . implode( ',', $install_ids ), 'delete' );
8849
- }
8850
-
8851
- $this->do_action( 'after_network_account_delete' );
8852
- }
8853
-
8854
- /**
8855
- * Plugin deactivation hook.
8856
- *
8857
- * @author Vova Feldman (@svovaf)
8858
- * @since 1.0.1
8859
- */
8860
- function _deactivate_plugin_hook() {
8861
- $this->_logger->entrance( 'slug = ' . $this->_slug );
8862
-
8863
- if ( ! $this->is_user_admin() ) {
8864
- return;
8865
- }
8866
-
8867
- $is_network_deactivation = fs_is_network_admin();
8868
- $storage_keys_for_removal = array();
8869
-
8870
- $this->_admin_notices->clear_all_sticky();
8871
-
8872
- $storage_keys_for_removal[] = 'sticky_optin_added';
8873
- if ( isset( $this->_storage->sticky_optin_added ) ) {
8874
- unset( $this->_storage->sticky_optin_added );
8875
- }
8876
-
8877
- if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
8878
- // Remember that plugin was already installed.
8879
- $this->_storage->is_plugin_new_install = false;
8880
- }
8881
-
8882
- // Hook to plugin uninstall.
8883
- register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
8884
-
8885
- $this->clear_module_main_file_cache();
8886
- $this->clear_sync_cron( $this->_is_network_active );
8887
- $this->clear_install_sync_cron();
8888
-
8889
- if ( $this->is_registered() ) {
8890
- if ( $this->is_premium() && ! $this->has_active_valid_license() ) {
8891
- FS_Plugin_Updater::instance( $this )->delete_update_data();
8892
- }
8893
-
8894
- if ( $is_network_deactivation ) {
8895
- // Send deactivation event.
8896
- $this->sync_installs( array(
8897
- 'is_active' => false,
8898
- ) );
8899
- } else {
8900
- // Send deactivation event.
8901
- $this->sync_install( array(
8902
- 'is_active' => false,
8903
- ) );
8904
- }
8905
- } else {
8906
- if ( ! $this->has_api_connectivity() ) {
8907
- // Reset connectivity test cache.
8908
- unset( $this->_storage->connectivity_test );
8909
-
8910
- $storage_keys_for_removal[] = 'connectivity_test';
8911
- }
8912
- }
8913
-
8914
- if ( $is_network_deactivation ) {
8915
- if ( isset( $this->_storage->sticky_optin_added_ms ) ) {
8916
- unset( $this->_storage->sticky_optin_added_ms );
8917
- }
8918
-
8919
- if ( ! empty( $storage_keys_for_removal ) ) {
8920
- $sites = self::get_sites();
8921
-
8922
- foreach ( $sites as $site ) {
8923
- $blog_id = self::get_site_blog_id( $site );
8924
-
8925
- foreach ( $storage_keys_for_removal as $key ) {
8926
- $this->_storage->remove( $key, false, $blog_id );
8927
- }
8928
-
8929
- $this->_storage->save( $blog_id );
8930
- }
8931
- }
8932
- }
8933
-
8934
- // Clear API cache on deactivation.
8935
- FS_Api::clear_cache();
8936
-
8937
- $this->remove_sdk_reference();
8938
- }
8939
-
8940
- /**
8941
- * @author Vova Feldman (@svovaf)
8942
- * @since 1.1.6
8943
- */
8944
- private function remove_sdk_reference() {
8945
- global $fs_active_plugins;
8946
-
8947
- foreach ( $fs_active_plugins->plugins as $sdk_path => $data ) {
8948
- if ( $this->_plugin_basename == $data->plugin_path ) {
8949
- unset( $fs_active_plugins->plugins[ $sdk_path ] );
8950
- break;
8951
- }
8952
- }
8953
-
8954
- fs_fallback_to_newest_active_sdk();
8955
- }
8956
-
8957
- /**
8958
- * @author Vova Feldman (@svovaf)
8959
- * @since 1.1.3
8960
- *
8961
- * @param bool $is_anonymous
8962
- * @param bool|int $network_or_blog_id Since 2.0.0
8963
- */
8964
- private function set_anonymous_mode( $is_anonymous = true, $network_or_blog_id = 0 ) {
8965
- // Store information regarding skip to try and opt-in the user
8966
- // again in the future.
8967
- $skip_info = array(
8968
- 'is' => $is_anonymous,
8969
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
8970
- 'version' => $this->get_plugin_version(),
8971
- );
8972
-
8973
- if ( true === $network_or_blog_id ) {
8974
- $this->_storage->is_anonymous_ms = $skip_info;
8975
- } else {
8976
- $this->_storage->store( 'is_anonymous', $skip_info, $network_or_blog_id );
8977
- }
8978
-
8979
- $this->network_upgrade_mode_completed();
8980
-
8981
- // Update anonymous mode cache.
8982
- $this->_is_anonymous = $is_anonymous;
8983
- }
8984
-
8985
- /**
8986
- * @author Vova Feldman (@svovaf)
8987
- * @since 2.0.0
8988
- *
8989
- * @param int $blog_id Site ID.
8990
- * @param int $user_id User ID.
8991
- * @param string $domain Site domain.
8992
- * @param string $path Site path.
8993
- * @param int $network_id Network ID. Only relevant on multi-network installations.
8994
- * @param array $meta Metadata. Used to set initial site options.
8995
- *
8996
- * @uses Freemius::is_license_network_active() to check if the context license was network activated by the super-admin.
8997
- * @uses Freemius::is_network_connected() to check if the super-admin network opted-in.
8998
- * @uses Freemius::is_network_anonymous() to check if the super-admin network skipped.
8999
- * @uses Freemius::is_network_delegated_connection() to check if the super-admin network delegated the connection to the site admins.
9000
- */
9001
- public function _after_new_blog_callback( $blog_id, $user_id, $domain, $path, $network_id, $meta ) {
9002
- $this->_logger->entrance();
9003
-
9004
- if ( ! $this->_is_network_active ) {
9005
- FS_Clone_Manager::instance()->store_new_blog_install_info( $blog_id );
9006
- return;
9007
- }
9008
-
9009
- $site = null;
9010
- $new_blog_id = $blog_id;
9011
-
9012
- if ( $this->is_premium() &&
9013
- $this->is_network_connected() &&
9014
- is_object( $this->_license ) &&
9015
- $this->_license->can_activate( FS_Site::is_localhost_by_address( $domain ) ) &&
9016
- $this->is_license_network_active( $blog_id )
9017
- ) {
9018
- /**
9019
- * Running the premium version, the license was network activated, and the license can also be activated on the current site -> so try to opt-in with the license key.
9020
- */
9021
- $current_blog_id = get_current_blog_id();
9022
- $license = clone $this->_license;
9023
-
9024
- $this->switch_to_blog( $blog_id );
9025
-
9026
- // Opt-in with network user.
9027
- $this->install_with_user(
9028
- $this->get_network_user(),
9029
- $license->secret_key,
9030
- false,
9031
- false,
9032
- false
9033
- );
9034
-
9035
- if ( is_object( $this->_site ) ) {
9036
- if ( $this->_site->license_id == $license->id ) {
9037
- /**
9038
- * If the license was activated successfully, sync the license data from the remote server.
9039
- */
9040
- $this->_license = $license;
9041
- $this->sync_site_license();
9042
- }
9043
- }
9044
-
9045
- $site = $this->_site;
9046
-
9047
- $this->switch_to_blog( $current_blog_id );
9048
-
9049
- if ( is_object( $site ) ) {
9050
- FS_Clone_Manager::instance()->store_new_blog_install_info( $blog_id, $site );
9051
-
9052
- // Already connected (with or without a license), so no need to continue.
9053
- return;
9054
- }
9055
- }
9056
-
9057
- if ( $this->is_network_anonymous() ) {
9058
- /**
9059
- * Opt-in was network skipped so automatically skip the opt-in for the new site.
9060
- */
9061
- $this->skip_site_connection( $blog_id );
9062
- } else if ( $this->is_network_delegated_connection() ) {
9063
- /**
9064
- * Opt-in was network delegated so automatically delegate the opt-in for the new site's admin.
9065
- */
9066
- $this->delegate_site_connection( $blog_id );
9067
- } else if ( $this->is_network_connected() ) {
9068
- /**
9069
- * Opt-in was network activated so automatically opt-in with the network user and new site admin.
9070
- */
9071
- $current_blog_id = get_current_blog_id();
9072
-
9073
- $this->switch_to_blog( $blog_id );
9074
-
9075
- // Opt-in with network user.
9076
- $this->install_with_user(
9077
- $this->get_network_user(),
9078
- false,
9079
- false,
9080
- false,
9081
- false
9082
- );
9083
-
9084
- $site = $this->_site;
9085
-
9086
- $this->switch_to_blog( $current_blog_id );
9087
- } else {
9088
- /**
9089
- * If the super-admin mixed different options (connect, skip, delegated):
9090
- * a) If at least one site connection was delegated, then automatically delegate connection.
9091
- * b) Otherwise, it means that at least one site was skipped and at least one site was connected. For a simplified UX in the initial release of the multisite network integration, skip the connection for the newly created site. If the super-admin will want to opt-in they can still do that from the network level Account page.
9092
- */
9093
- $has_delegated_site = false;
9094
-
9095
- $sites = self::get_sites();
9096
- foreach ( $sites as $wp_site ) {
9097
- $blog_id = self::get_site_blog_id( $wp_site );
9098
-
9099
- if ( $this->is_site_delegated_connection( $blog_id ) ) {
9100
- $has_delegated_site = true;
9101
- break;
9102
- }
9103
- }
9104
-
9105
- if ( $has_delegated_site ) {
9106
- $this->delegate_site_connection( $blog_id );
9107
- } else {
9108
- $this->skip_site_connection( $blog_id );
9109
- }
9110
- }
9111
-
9112
- /**
9113
- * Store the new blog's information even if there's no install so that when a clone install is stored in the new blog's storage, we can try to resolve it automatically.
9114
- *
9115
- * @author Leo Fajardo (@leorw)
9116
- * @since 2.5.0
9117
- */
9118
- FS_Clone_Manager::instance()->store_new_blog_install_info( $new_blog_id, $site );
9119
- }
9120
-
9121
- /**
9122
- * @author Vova Feldman (@svovaf)
9123
- * @since 2.5.0
9124
- *
9125
- * @param \WP_Site $new_site
9126
- * @param array $args
9127
- */
9128
- public function _after_wp_initialize_site_callback( WP_Site $new_site, $args ) {
9129
- $this->_logger->entrance();
9130
-
9131
- $this->_after_new_blog_callback(
9132
- $new_site->id,
9133
- // Dummy user ID (not in use).
9134
- 0,
9135
- $new_site->domain,
9136
- $new_site->path,
9137
- $new_site->network_id,
9138
- // Dummy meta, not in use.
9139
- array()
9140
- );
9141
- }
9142
-
9143
- /**
9144
- * @author Vova Feldman (@svovaf)
9145
- * @since 1.1.3
9146
- *
9147
- * @param bool|int $network_or_blog_id Since 2.0.0.
9148
- */
9149
- private function reset_anonymous_mode( $network_or_blog_id = 0 ) {
9150
- if ( true === $network_or_blog_id ) {
9151
- unset( $this->_storage->is_anonymous_ms );
9152
- } else {
9153
- $this->_storage->remove( 'is_anonymous', true, $network_or_blog_id );
9154
- }
9155
-
9156
- /**
9157
- * Ensure that this field is also "false", otherwise, if the current module's type is "theme" and the module
9158
- * has no menus, the opt-in popup will not be shown immediately (in this case, the user will have to click
9159
- * on the admin notice that contains the opt-in link in order to trigger the opt-in popup).
9160
- *
9161
- * @author Leo Fajardo (@leorw)
9162
- * @since 1.2.2
9163
- */
9164
- if ( ! $this->_is_network_active ||
9165
- 0 === $network_or_blog_id ||
9166
- get_current_blog_id() == $network_or_blog_id ||
9167
- ( true === $network_or_blog_id && fs_is_network_admin() )
9168
- ) {
9169
- $this->_is_anonymous = null;
9170
- }
9171
- }
9172
-
9173
- /**
9174
- * This is used to ensure that before redirecting to the opt-in page after resetting the anonymous mode or
9175
- * deleting the account in the network level, the URL of the page to redirect to is correct.
9176
- *
9177
- * @author Leo Fajardo (@leorw)
9178
- *
9179
- * @since 2.1.3
9180
- */
9181
- private function maybe_set_slug_and_network_menu_exists_flag() {
9182
- if ( ! empty( $this->_dynamically_added_top_level_page_hook_name ) ) {
9183
- $this->_menu->set_slug_and_network_menu_exists_flag( $this->_menu->has_menu() ?
9184
- $this->_menu->get_slug() :
9185
- $this->_slug
9186
- );
9187
- }
9188
- }
9189
-
9190
- /**
9191
- * Clears the anonymous mode and redirects to the opt-in screen.
9192
- *
9193
- * @author Vova Feldman (@svovaf)
9194
- * @since 1.1.7
9195
- */
9196
- function connect_again() {
9197
- if ( ! $this->is_anonymous() ) {
9198
- return;
9199
- }
9200
-
9201
- $this->reset_anonymous_mode( fs_is_network_admin() );
9202
-
9203
- $this->maybe_set_slug_and_network_menu_exists_flag();
9204
-
9205
- fs_redirect( $this->get_activation_url() );
9206
- }
9207
-
9208
- /**
9209
- * Skip account connect, and set anonymous mode.
9210
- *
9211
- * @author Vova Feldman (@svovaf)
9212
- * @since 1.1.1
9213
- *
9214
- * @param array|null $sites Since 2.0.0. Specific sites.
9215
- * @param bool $skip_all_network Since 2.0.0. If true, skip connection for all sites.
9216
- */
9217
- function skip_connection( $sites = null, $skip_all_network = false ) {
9218
- $this->_logger->entrance();
9219
-
9220
- $this->_admin_notices->remove_sticky( 'connect_account' );
9221
-
9222
- if ( $skip_all_network ) {
9223
- $this->set_anonymous_mode( true, true );
9224
- }
9225
-
9226
- if ( ! $skip_all_network && empty( $sites ) ) {
9227
- $this->skip_site_connection();
9228
- } else {
9229
- $uids = array();
9230
-
9231
- if ( $skip_all_network ) {
9232
- $this->set_anonymous_mode( true, true );
9233
-
9234
- $sites = self::get_sites();
9235
- foreach ( $sites as $site ) {
9236
- $blog_id = self::get_site_blog_id( $site );
9237
- $this->skip_site_connection( $blog_id, false );
9238
- $uids[] = $this->get_anonymous_id( $blog_id );
9239
- }
9240
- } else if ( ! empty( $sites ) ) {
9241
- foreach ( $sites as $site ) {
9242
- $uids[] = $site['uid'];
9243
- $this->skip_site_connection( $site['blog_id'], false );
9244
- }
9245
- }
9246
-
9247
- // Send anonymous skip event.
9248
- // No user identified info nor any tracking will be sent after the user skips the opt-in.
9249
- $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
9250
- 'uids' => $uids,
9251
- ) );
9252
- }
9253
-
9254
- $this->network_upgrade_mode_completed();
9255
- }
9256
-
9257
- /**
9258
- * Skip connection for specific site in the network.
9259
- *
9260
- * @author Vova Feldman (@svovaf)
9261
- * @since 2.0.0
9262
- *
9263
- * @param int|null $blog_id
9264
- * @param bool $send_skip
9265
- */
9266
- private function skip_site_connection( $blog_id = null, $send_skip = true ) {
9267
- $this->_logger->entrance();
9268
-
9269
- $this->_admin_notices->remove_sticky( 'connect_account', $blog_id );
9270
-
9271
- $this->set_anonymous_mode( true, $blog_id );
9272
-
9273
- if ( $send_skip ) {
9274
- $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
9275
- 'uids' => array( $this->get_anonymous_id( $blog_id ) ),
9276
- ) );
9277
- }
9278
- }
9279
-
9280
- /**
9281
- * Plugin version update hook.
9282
- *
9283
- * @author Vova Feldman (@svovaf)
9284
- * @since 1.0.4
9285
- */
9286
- private function update_plugin_version_event() {
9287
- $this->_logger->entrance();
9288
-
9289
- if ( ! $this->is_registered() ) {
9290
- return;
9291
- }
9292
-
9293
- $this->schedule_install_sync();
9294
- // $this->sync_install( array(), true );
9295
- }
9296
-
9297
- /**
9298
- * Generate an MD5 signature of a plugins collection.
9299
- * This helper methods used to identify changes in a plugins collection.
9300
- *
9301
- * @author Vova Feldman (@svovaf)
9302
- * @since 2.0.0
9303
- *
9304
- * @param array [string]array $plugins
9305
- *
9306
- * @return string
9307
- */
9308
- private function get_plugins_thumbprint( $plugins ) {
9309
- ksort( $plugins );
9310
-
9311
- $thumbprint = '';
9312
- foreach ( $plugins as $basename => $data ) {
9313
- $thumbprint .= $data['slug'] . ',' .
9314
- $data['Version'] . ',' .
9315
- ( $data['is_active'] ? '1' : '0' ) . ';';
9316
- }
9317
-
9318
- return md5( $thumbprint );
9319
- }
9320
-
9321
- /**
9322
- * Return a list of modified plugins since the last sync.
9323
- *
9324
- * Note:
9325
- * There's no point to store a plugins counter since even if the number of
9326
- * plugins didn't change, we still need to check if the versions are all the
9327
- * same and the activity state is similar.
9328
- *
9329
- * @author Vova Feldman (@svovaf)
9330
- * @since 1.1.8
9331
- *
9332
- * @return array|false
9333
- */
9334
- private function get_plugins_data_for_api() {
9335
- // Alias.
9336
- $site_active_plugins_option_name = 'active_plugins';
9337
- $network_plugins_option_name = 'all_plugins';
9338
-
9339
- /**
9340
- * Collection of all site level active plugins.
9341
- */
9342
- $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
9343
-
9344
- if ( ! is_object( $site_active_plugins_cache ) ) {
9345
- $site_active_plugins_cache = (object) array(
9346
- 'timestamp' => '',
9347
- 'md5' => '',
9348
- 'plugins' => array(),
9349
- );
9350
- }
9351
-
9352
- $time = time();
9353
-
9354
- if ( ! empty( $site_active_plugins_cache->timestamp ) &&
9355
- ( $time - $site_active_plugins_cache->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
9356
- ) {
9357
- // Don't send plugin updates if last update was in the past 5 min.
9358
- return false;
9359
- }
9360
-
9361
- // Write timestamp to lock the logic.
9362
- $site_active_plugins_cache->timestamp = $time;
9363
- self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
9364
-
9365
- // Reload options from DB.
9366
- self::$_accounts->load( true );
9367
- $site_active_plugins_cache = self::$_accounts->get_option( $site_active_plugins_option_name );
9368
-
9369
- if ( $time != $site_active_plugins_cache->timestamp ) {
9370
- // If timestamp is different, then another thread captured the lock.
9371
- return false;
9372
- }
9373
-
9374
- /**
9375
- * Collection of all plugins (network level).
9376
- */
9377
- $network_plugins_cache = self::$_accounts->get_option( $network_plugins_option_name );
9378
-
9379
- if ( ! is_object( $network_plugins_cache ) ) {
9380
- $network_plugins_cache = (object) array(
9381
- 'timestamp' => '',
9382
- 'md5' => '',
9383
- 'plugins' => array(),
9384
- );
9385
- }
9386
-
9387
- // Check if there's a change in plugins.
9388
- $network_plugins = self::get_network_plugins();
9389
- $site_active_plugins = self::get_site_active_plugins();
9390
-
9391
- $network_plugins_thumbprint = $this->get_plugins_thumbprint( $network_plugins );
9392
- $site_active_plugins_thumbprint = $this->get_plugins_thumbprint( $site_active_plugins );
9393
-
9394
- // Check if plugins status changed (version or active/inactive).
9395
- $network_plugins_changed = ( $network_plugins_cache->md5 !== $network_plugins_thumbprint );
9396
- $site_active_plugins_changed = ( $site_active_plugins_cache->md5 !== $site_active_plugins_thumbprint );
9397
-
9398
- if ( ! $network_plugins_changed &&
9399
- ! $site_active_plugins_changed
9400
- ) {
9401
- // No changes.
9402
- return array();
9403
- }
9404
-
9405
- $plugins_update_data = array();
9406
-
9407
- foreach ( $network_plugins_cache->plugins as $basename => $data ) {
9408
- if ( ! isset( $network_plugins[ $basename ] ) ) {
9409
- // Plugin uninstalled.
9410
- $uninstalled_plugin_data = $data;
9411
- $uninstalled_plugin_data['is_active'] = false;
9412
- $uninstalled_plugin_data['is_uninstalled'] = true;
9413
- $plugins_update_data[] = $uninstalled_plugin_data;
9414
-
9415
- unset( $network_plugins[ $basename ] );
9416
-
9417
- unset( $network_plugins_cache->plugins[ $basename ] );
9418
- unset( $site_active_plugins_cache->plugins[ $basename ] );
9419
-
9420
- continue;
9421
- }
9422
-
9423
- $was_active = $data['is_active'] ||
9424
- ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
9425
- true === $site_active_plugins_cache->plugins[ $basename ]['is_active'] );
9426
- $is_active = $network_plugins[ $basename ]['is_active'] ||
9427
- ( isset( $site_active_plugins[ $basename ] ) &&
9428
- $site_active_plugins[ $basename ]['is_active'] );
9429
-
9430
- if ( ! isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
9431
- isset( $site_active_plugins[ $basename ] )
9432
- ) {
9433
- // Plugin was site level activated.
9434
- $site_active_plugins_cache->plugins[ $basename ] = $network_plugins[ $basename ];
9435
- $site_active_plugins_cache->plugins[ $basename ]['is_active'] = true;
9436
- } else if ( isset( $site_active_plugins_cache->plugins[ $basename ] ) &&
9437
- ! isset( $site_active_plugins[ $basename ] )
9438
- ) {
9439
- // Plugin was site level deactivated.
9440
- unset( $site_active_plugins_cache->plugins[ $basename ] );
9441
- }
9442
-
9443
- $prev_version = $data['version'];
9444
- $current_version = $network_plugins[ $basename ]['Version'];
9445
-
9446
- if ( $was_active !== $is_active || $prev_version !== $current_version ) {
9447
- // Plugin activated or deactivated, or version changed.
9448
-
9449
- if ( $was_active !== $is_active ) {
9450
- if ( $data['is_active'] != $network_plugins[ $basename ]['is_active'] ) {
9451
- $network_plugins_cache->plugins[ $basename ]['is_active'] = $data['is_active'];
9452
- }
9453
- }
9454
-
9455
- if ( $prev_version !== $current_version ) {
9456
- $network_plugins_cache->plugins[ $basename ]['Version'] = $current_version;
9457
- }
9458
-
9459
- $updated_plugin_data = $data;
9460
- $updated_plugin_data['is_active'] = $is_active;
9461
- $updated_plugin_data['version'] = $current_version;
9462
- $updated_plugin_data['title'] = $network_plugins[ $basename ]['Name'];
9463
- $plugins_update_data[] = $updated_plugin_data;
9464
- }
9465
- }
9466
-
9467
- // Find new plugins that weren't yet seen before.
9468
- foreach ( $network_plugins as $basename => $data ) {
9469
- if ( ! isset( $network_plugins_cache->plugins[ $basename ] ) ) {
9470
- // New plugin.
9471
- $new_plugin = array(
9472
- 'slug' => $data['slug'],
9473
- 'version' => $data['Version'],
9474
- 'title' => $data['Name'],
9475
- 'is_active' => $data['is_active'],
9476
- 'is_uninstalled' => false,
9477
- );
9478
-
9479
- $network_plugins_cache->plugins[ $basename ] = $new_plugin;
9480
-
9481
- $is_site_level_active = (
9482
- isset( $site_active_plugins[ $basename ] ) &&
9483
- $site_active_plugins[ $basename ]['is_active']
9484
- );
9485
-
9486
- /**
9487
- * If not network active, set the activity status based on the site-level plugin status.
9488
- */
9489
- if ( ! $new_plugin['is_active'] ) {
9490
- $new_plugin['is_active'] = $is_site_level_active;
9491
- }
9492
-
9493
- $plugins_update_data[] = $new_plugin;
9494
-
9495
- if ( isset( $site_active_plugins[ $basename ] ) ) {
9496
- $site_active_plugins_cache->plugins[ $basename ] = $new_plugin;
9497
- $site_active_plugins_cache->plugins[ $basename ]['is_active'] = $is_site_level_active;
9498
- }
9499
- }
9500
- }
9501
-
9502
- $site_active_plugins_cache->md5 = $site_active_plugins_thumbprint;
9503
- $site_active_plugins_cache->timestamp = $time;
9504
- self::$_accounts->set_option( $site_active_plugins_option_name, $site_active_plugins_cache, true );
9505
-
9506
- $network_plugins_cache->md5 = $network_plugins_thumbprint;
9507
- $network_plugins_cache->timestamp = $time;
9508
- self::$_accounts->set_option( $network_plugins_option_name, $network_plugins_cache, true );
9509
-
9510
- return $plugins_update_data;
9511
- }
9512
-
9513
- /**
9514
- * Return a list of modified themes since the last sync.
9515
- *
9516
- * Note:
9517
- * There's no point to store a themes counter since even if the number of
9518
- * themes didn't change, we still need to check if the versions are all the
9519
- * same and the activity state is similar.
9520
- *
9521
- * @author Vova Feldman (@svovaf)
9522
- * @since 1.1.8
9523
- *
9524
- * @return array|false
9525
- */
9526
- private function get_themes_data_for_api() {
9527
- // Alias.
9528
- $option_name = 'all_themes';
9529
-
9530
- $all_cached_themes = self::$_accounts->get_option( $option_name );
9531
-
9532
- if ( ! is_object( $all_cached_themes ) ) {
9533
- $all_cached_themes = (object) array(
9534
- 'timestamp' => '',
9535
- 'md5' => '',
9536
- 'themes' => array(),
9537
- );
9538
- }
9539
-
9540
- $time = time();
9541
-
9542
- if ( ! empty( $all_cached_themes->timestamp ) &&
9543
- ( $time - $all_cached_themes->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
9544
- ) {
9545
- // Don't send theme updates if last update was in the past 5 min.
9546
- return false;
9547
- }
9548
-
9549
- // Write timestamp to lock the logic.
9550
- $all_cached_themes->timestamp = $time;
9551
- self::$_accounts->set_option( $option_name, $all_cached_themes, true );
9552
-
9553
- // Reload options from DB.
9554
- self::$_accounts->load( true );
9555
- $all_cached_themes = self::$_accounts->get_option( $option_name );
9556
-
9557
- if ( $time != $all_cached_themes->timestamp ) {
9558
- // If timestamp is different, then another thread captured the lock.
9559
- return false;
9560
- }
9561
-
9562
- // Get active theme.
9563
- $active_theme = wp_get_theme();
9564
- $active_theme_stylesheet = $active_theme->get_stylesheet();
9565
-
9566
- // Check if there's a change in themes.
9567
- $all_themes = wp_get_themes();
9568
-
9569
- // Check if themes changed.
9570
- ksort( $all_themes );
9571
-
9572
- $themes_signature = '';
9573
- foreach ( $all_themes as $slug => $data ) {
9574
- $is_active = ( $slug === $active_theme_stylesheet );
9575
- $themes_signature .= $slug . ',' .
9576
- $data->version . ',' .
9577
- ( $is_active ? '1' : '0' ) . ';';
9578
- }
9579
-
9580
- // Check if themes status changed (version or active/inactive).
9581
- $themes_changed = ( $all_cached_themes->md5 !== md5( $themes_signature ) );
9582
-
9583
- $themes_update_data = array();
9584
-
9585
- if ( $themes_changed ) {
9586
- // Change in themes, report changes.
9587
-
9588
- // Update existing themes info.
9589
- foreach ( $all_cached_themes->themes as $slug => $data ) {
9590
- $is_active = ( $slug === $active_theme_stylesheet );
9591
-
9592
- if ( ! isset( $all_themes[ $slug ] ) ) {
9593
- // Plugin uninstalled.
9594
- $uninstalled_theme_data = $data;
9595
- $uninstalled_theme_data['is_active'] = false;
9596
- $uninstalled_theme_data['is_uninstalled'] = true;
9597
- $themes_update_data[] = $uninstalled_theme_data;
9598
-
9599
- unset( $all_themes[ $slug ] );
9600
- unset( $all_cached_themes->themes[ $slug ] );
9601
- } else if ( $data['is_active'] !== $is_active ||
9602
- $data['version'] !== $all_themes[ $slug ]->version
9603
- ) {
9604
- // Plugin activated or deactivated, or version changed.
9605
-
9606
- $all_cached_themes->themes[ $slug ]['is_active'] = $is_active;
9607
- $all_cached_themes->themes[ $slug ]['version'] = $all_themes[ $slug ]->version;
9608
-
9609
- $themes_update_data[] = $all_cached_themes->themes[ $slug ];
9610
- }
9611
- }
9612
-
9613
- // Find new themes that weren't yet seen before.
9614
- foreach ( $all_themes as $slug => $data ) {
9615
- if ( ! isset( $all_cached_themes->themes[ $slug ] ) ) {
9616
- $is_active = ( $slug === $active_theme_stylesheet );
9617
-
9618
- // New plugin.
9619
- $new_plugin = array(
9620
- 'slug' => $slug,
9621
- 'version' => $data->version,
9622
- 'title' => $data->name,
9623
- 'is_active' => $is_active,
9624
- 'is_uninstalled' => false,
9625
- );
9626
-
9627
- $themes_update_data[] = $new_plugin;
9628
- $all_cached_themes->themes[ $slug ] = $new_plugin;
9629
- }
9630
- }
9631
-
9632
- $all_cached_themes->md5 = md5( $themes_signature );
9633
- $all_cached_themes->timestamp = time();
9634
- self::$_accounts->set_option( $option_name, $all_cached_themes, true );
9635
- }
9636
-
9637
- return $themes_update_data;
9638
- }
9639
-
9640
- /**
9641
- * Get site data for API install request.
9642
- *
9643
- * @author Vova Feldman (@svovaf)
9644
- * @since 1.1.2
9645
- *
9646
- * @param string[] $override
9647
- * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
9648
- * @param bool $include_themes Since 1.1.8 by default include plugin changes.
9649
- * @param bool $include_blog_data Since 2.3.0 by default include the current blog's data (language, charset, title, and URL).
9650
- *
9651
- * @return array
9652
- */
9653
- private function get_install_data_for_api(
9654
- array $override,
9655
- $include_plugins = true,
9656
- $include_themes = true,
9657
- $include_blog_data = true
9658
- ) {
9659
- if ( $this->is_extensions_tracking_allowed() ) {
9660
- if ( ! defined( 'WP_FS__TRACK_PLUGINS' ) || false !== WP_FS__TRACK_PLUGINS ) {
9661
- /**
9662
- * @since 1.1.8 Also send plugin updates.
9663
- */
9664
- if ( $include_plugins && ! isset( $override['plugins'] ) ) {
9665
- $plugins = $this->get_plugins_data_for_api();
9666
- if ( ! empty( $plugins ) ) {
9667
- $override['plugins'] = $plugins;
9668
- }
9669
- }
9670
- }
9671
-
9672
- if ( ! defined( 'WP_FS__TRACK_THEMES' ) || false !== WP_FS__TRACK_THEMES ) {
9673
- /**
9674
- * @since 1.1.8 Also send themes updates.
9675
- */
9676
- if ( $include_themes && ! isset( $override['themes'] ) ) {
9677
- $themes = $this->get_themes_data_for_api();
9678
- if ( ! empty( $themes ) ) {
9679
- $override['themes'] = $themes;
9680
- }
9681
- }
9682
- }
9683
- }
9684
-
9685
- $versions = $this->get_versions();
9686
-
9687
- $blog_data = $include_blog_data ?
9688
- array(
9689
- 'language' => get_bloginfo( 'language' ),
9690
- 'charset' => get_bloginfo( 'charset' ),
9691
- 'title' => get_bloginfo( 'name' ),
9692
- 'url' => self::get_site_url(),
9693
- ) :
9694
- array();
9695
-
9696
- return array_merge( $versions, $blog_data, array(
9697
- 'version' => $this->get_plugin_version(),
9698
- 'is_premium' => $this->is_premium(),
9699
- // Special params.
9700
- 'is_active' => true,
9701
- 'is_disconnected' => $this->is_tracking_prohibited(),
9702
- 'is_uninstalled' => false,
9703
- ), $override );
9704
- }
9705
-
9706
- /**
9707
- * Update installs details.
9708
- *
9709
- * @todo V1 of multiste network support doesn't support plugin and theme data sending.
9710
- *
9711
- * @author Vova Feldman (@svovaf)
9712
- * @since 2.0.0
9713
- *
9714
- * @param string[] string $override
9715
- * @param bool $only_diff
9716
- * @param bool $is_keepalive
9717
- * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
9718
- * @param bool $include_themes Since 1.1.8 by default include plugin changes.
9719
- *
9720
- * @return array
9721
- */
9722
- private function get_installs_data_for_api(
9723
- array $override,
9724
- $only_diff = false,
9725
- $is_keepalive = false,
9726
- $include_plugins = true,
9727
- $include_themes = true
9728
- ) {
9729
- /**
9730
- * @since 1.1.8 Also send plugin updates.
9731
- */
9732
- // if ( $include_plugins && ! isset( $override['plugins'] ) ) {
9733
- // $plugins = $this->get_plugins_data_for_api();
9734
- // if ( ! empty( $plugins ) ) {
9735
- // $override['plugins'] = $plugins;
9736
- // }
9737
- // }
9738
- /**
9739
- * @since 1.1.8 Also send themes updates.
9740
- */
9741
- // if ( $include_themes && ! isset( $override['themes'] ) ) {
9742
- // $themes = $this->get_themes_data_for_api();
9743
- // if ( ! empty( $themes ) ) {
9744
- // $override['themes'] = $themes;
9745
- // }
9746
- // }
9747
-
9748
- // Common properties.
9749
- $versions = $this->get_versions();
9750
- $common = array_merge( $versions, array(
9751
- 'version' => $this->get_plugin_version(),
9752
- 'is_premium' => $this->is_premium(),
9753
- ), $override );
9754
-
9755
-
9756
- $is_common_diff_for_any_site = false;
9757
- $common_diff_union = array();
9758
-
9759
- $installs_data = array();
9760
-
9761
- $sites = self::get_sites();
9762
-
9763
- $subsite_data_by_install_id = array();
9764
- $install_url_by_install_id = array();
9765
-
9766
- foreach ( $sites as $site ) {
9767
- $blog_id = self::get_site_blog_id( $site );
9768
-
9769
- $install = $this->get_install_by_blog_id( $blog_id );
9770
-
9771
- if ( is_object( $install ) ) {
9772
- if ( $install->user_id != $this->_user->id ) {
9773
- // Install belongs to a different owner.
9774
- continue;
9775
- }
9776
-
9777
- if ( ! $this->is_premium() && $install->is_tracking_prohibited() ) {
9778
- // Don't send updates regarding opted-out installs.
9779
- continue;
9780
- }
9781
-
9782
- $install_data = $this->get_site_info( $site );
9783
-
9784
- if ( FS_Clone_Manager::instance()->is_temporary_duplicate_by_blog_id( $install_data['blog_id'] ) ) {
9785
- continue;
9786
- }
9787
-
9788
- $uid = $install_data['uid'];
9789
- $url = $install_data['url'];
9790
-
9791
- if ( isset( $subsite_data_by_install_id[ $install->id ] ) ) {
9792
- $clone_subsite_data = $subsite_data_by_install_id[ $install->id ];
9793
- $clone_install_url = $install_url_by_install_id[ $install->id ];
9794
-
9795
- if (
9796
- /**
9797
- * If we already have an install with the same URL as the subsite it's stored in, skip the current subsite. Otherwise, replace the existing install's data with the current subsite's install's data if the URLs match.
9798
- *
9799
- * @author Leo Fajardo (@leorw)
9800
- * @since 2.5.0
9801
- */
9802
- fs_strip_url_protocol( untrailingslashit( $clone_install_url ) ) === fs_strip_url_protocol( untrailingslashit( $clone_subsite_data['url'] ) ) ||
9803
- fs_strip_url_protocol( untrailingslashit( $install->url ) ) !== fs_strip_url_protocol( untrailingslashit( $url ) )
9804
- ) {
9805
- continue;
9806
- }
9807
- }
9808
-
9809
- unset( $install_data['blog_id'] );
9810
- unset( $install_data['uid'] );
9811
- unset( $install_data['url'] );
9812
-
9813
- $install_data['is_disconnected'] = $install->is_disconnected;
9814
- $install_data['is_active'] = $this->is_active_for_site( $blog_id );
9815
- $install_data['is_uninstalled'] = $install->is_uninstalled;
9816
-
9817
- $common_diff = null;
9818
- $is_common_diff = false;
9819
- if ( $only_diff ) {
9820
- $install_data = $this->get_install_diff_for_api( $install_data, $install, $override );
9821
- $common_diff = $this->get_install_diff_for_api( $common, $install, $override );
9822
-
9823
- $is_common_diff = ! empty( $common_diff );
9824
-
9825
- if ( $is_common_diff ) {
9826
- foreach ( $common_diff as $k => $v ) {
9827
- if ( ! isset( $common_diff_union[ $k ] ) ) {
9828
- $common_diff_union[ $k ] = $v;
9829
- }
9830
- }
9831
- }
9832
-
9833
- $is_common_diff_for_any_site = $is_common_diff_for_any_site || $is_common_diff;
9834
- }
9835
-
9836
- if ( ! empty( $install_data ) || $is_common_diff || $is_keepalive ) {
9837
- // Add install ID and site unique ID.
9838
- $install_data['id'] = $install->id;
9839
- $install_data['uid'] = $uid;
9840
- $install_data['url'] = $url;
9841
-
9842
- $subsite_data_by_install_id[ $install->id ] = $install_data;
9843
- $install_url_by_install_id[ $install->id ] = $install->url;
9844
- }
9845
- }
9846
- }
9847
-
9848
- restore_current_blog();
9849
-
9850
- $installs_data = array_merge(
9851
- $installs_data,
9852
- array_values( $subsite_data_by_install_id )
9853
- );
9854
-
9855
- if ( 0 < count( $installs_data ) && ( $is_common_diff_for_any_site || ! $only_diff ) ) {
9856
- if ( ! $only_diff ) {
9857
- $installs_data[] = $common;
9858
- } else if ( ! empty( $common_diff_union ) ) {
9859
- $installs_data[] = $common_diff_union;
9860
- }
9861
- }
9862
-
9863
- foreach ( $installs_data as &$data ) {
9864
- $data = (object) $data;
9865
- }
9866
-
9867
- return $installs_data;
9868
- }
9869
-
9870
- /**
9871
- * Compare site actual data to the stored install data and return the differences for an API data sync.
9872
- *
9873
- * @author Vova Feldman (@svovaf)
9874
- * @since 2.0.0
9875
- *
9876
- * @param array $site
9877
- * @param FS_Site $install
9878
- * @param string[] string $override
9879
- *
9880
- * @return array
9881
- */
9882
- private function get_install_diff_for_api( $site, $install, $override = array() ) {
9883
- $diff = array();
9884
- $special = array();
9885
- $special_override = false;
9886
-
9887
- foreach ( $site as $p => $v ) {
9888
- if ( property_exists( $install, $p ) ) {
9889
- if ( ( is_bool( $install->{$p} ) || ! empty( $install->{$p} ) ) &&
9890
- $install->{$p} != $v
9891
- ) {
9892
- $install->{$p} = $v;
9893
- $diff[ $p ] = $v;
9894
- }
9895
- } else {
9896
- $special[ $p ] = $v;
9897
-
9898
- if ( isset( $override[ $p ] ) ||
9899
- 'plugins' === $p ||
9900
- 'themes' === $p
9901
- ) {
9902
- $special_override = true;
9903
- }
9904
- }
9905
- }
9906
-
9907
- if ( $special_override || 0 < count( $diff ) ) {
9908
- // Add special params only if has at least one
9909
- // standard param, or if explicitly requested to
9910
- // override a special param or a param which is not exist
9911
- // in the install object.
9912
- $diff = array_merge( $diff, $special );
9913
- }
9914
-
9915
- return $diff;
9916
- }
9917
-
9918
- /**
9919
- * Update install only if changed.
9920
- *
9921
- * @author Vova Feldman (@svovaf)
9922
- * @since 1.0.9
9923
- *
9924
- * @param string[] string $override
9925
- * @param bool $flush
9926
- * @param bool $is_two_way_sync @since 2.5.0 If true and there's a successful API request, the install sync cron will be cleared.
9927
- *
9928
- * @return false|object|string
9929
- */
9930
- private function send_install_update( $override = array(), $flush = false, $is_two_way_sync = false ) {
9931
- $this->_logger->entrance();
9932
-
9933
- $check_properties = $this->get_install_data_for_api( $override );
9934
-
9935
- if ( $flush ) {
9936
- $params = $check_properties;
9937
- } else {
9938
- $params = $this->get_install_diff_for_api( $check_properties, $this->_site, $override );
9939
- }
9940
-
9941
- $keepalive_only_update = false;
9942
- if ( empty( $params ) ) {
9943
- $keepalive_only_update = $this->should_send_keepalive_update();
9944
-
9945
- if ( ! $keepalive_only_update ) {
9946
- /**
9947
- * There are no updates to send including keepalive.
9948
- *
9949
- * @author Leo Fajardo (@leorw)
9950
- * @since 2.2.3
9951
- */
9952
- return false;
9953
- }
9954
- }
9955
-
9956
- if ( $is_two_way_sync ) {
9957
- /**
9958
- * Update last install sync timestamp during a two-way sync call as we expect that updates are sent during this call.
9959
- *
9960
- * @author Leo Fajardo (@leorw)
9961
- * @since 2.2.3
9962
- */
9963
- if ( ! is_multisite() ) {
9964
- // Update last install sync timestamp.
9965
- $this->set_cron_execution_timestamp( 'install_sync' );
9966
- }
9967
-
9968
- $params['uid'] = $this->get_anonymous_id();
9969
- }
9970
-
9971
- $this->set_keepalive_timestamp();
9972
-
9973
- // Send updated values to FS.
9974
- $site = $this->api_site_call( '/', 'put', $params, true );
9975
-
9976
- if ( $is_two_way_sync && $this->is_api_result_entity( $site ) ) {
9977
- /**
9978
- * Clear scheduled install sync after a two-way sync call.
9979
- *
9980
- * @author Leo Fajardo (@leorw)
9981
- * @since 2.2.3
9982
- */
9983