PluginProbe
Tiered Pricing Table for WooCommerce / 8.0.2
Tiered Pricing Table for WooCommerce v8.0.2
8.0.2 7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 All 91 releases
← All changes | freemius/templates/account.php +385 -185 2.3.2 → 8.0.2 View file →
@@ -20,9 +20,11 @@
20 20
21 21 /**
22 22 * @var FS_Plugin_Tag $update
23 23 */
24 - $update = $fs->get_update( false, false, WP_FS__TIME_24_HOURS_IN_SEC / 24 );
24 + $update = $fs->has_release_on_freemius() ?
25 + $fs->get_update( false, false ) :
26 + null;
25 27
26 28 if ( is_object($update) ) {
27 29 /**
28 30 * This logic is particularly required for multisite environment.
@@ -43,8 +45,11 @@
43 45 $user = $fs->get_user();
44 46 $site = $fs->get_site();
45 47 $name = $user->get_name();
46 48 $license = $fs->_get_license();
49 + $is_license_foreign = ( is_object( $license ) && $user->id != $license->user_id );
50 + $is_data_debug_mode = $fs->is_data_debug_mode();
51 + $is_whitelabeled = $fs->is_whitelabeled();
47 52 $subscription = ( is_object( $license ) ?
48 53 $fs->_get_subscription( $license->id ) :
49 54 null );
50 55 $plan = $fs->get_plan();
@@ -49,16 +54,37 @@
49 54 null );
50 55 $plan = $fs->get_plan();
51 56 $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
52 57 $is_paid_trial = $fs->is_paid_trial();
53 - $has_paid_plan = $fs->has_paid_plan();
54 - $show_upgrade = ( $has_paid_plan && ! $is_paying && ! $is_paid_trial );
58 + $has_paid_plan = $fs->apply_filters( 'has_paid_plan_account', $fs->has_paid_plan() );
59 + $show_upgrade = ( ! $is_whitelabeled && $has_paid_plan && ! $is_paying && ! $is_paid_trial );
55 60 $trial_plan = $fs->get_trial_plan();
56 61
62 + $is_plan_change_supported = (
63 + ! $fs->is_single_plan() &&
64 + ! $fs->apply_filters( 'hide_plan_change', false )
65 + );
66 +
57 67 if ( $has_paid_plan ) {
58 68 $fs->_add_license_activation_dialog_box();
59 69 }
60 70
71 + if ( $fs->should_handle_user_change() ) {
72 + $fs->_add_email_address_update_dialog_box();
73 + }
74 +
75 + $ids_of_installs_activated_with_foreign_licenses = $fs->should_handle_user_change() ?
76 + $fs->get_installs_ids_with_foreign_licenses() :
77 + array();
78 +
79 + if ( ! empty( $ids_of_installs_activated_with_foreign_licenses ) ) {
80 + $fs->_add_user_change_dialog_box( $ids_of_installs_activated_with_foreign_licenses );
81 + }
82 +
83 + if ( $fs->is_whitelabeled( true ) || $fs->is_data_debug_mode() ) {
84 + $fs->_add_data_debug_mode_dialog_box();
85 + }
86 +
61 87 if ( fs_request_get_bool( 'auto_install' ) ) {
62 88 $fs->_add_auto_installation_dialog_box();
63 89 }
64 90
@@ -69,19 +95,18 @@
69 95 '_open_license_activation_dialog_box'
70 96 ) );
71 97 }
72 98
73 - $payments = $fs->_fetch_payments();
99 + $show_billing = ( ! $is_whitelabeled && ! $fs->apply_filters( 'hide_billing_and_payments_info', false ) );
100 + if ( $show_billing ) {
101 + $payments = $fs->_fetch_payments();
74 102
75 - $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
103 + $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
104 + }
76 105
77 106
78 - $has_tabs = $fs->_add_tabs_before_content();
107 + $has_tabs = $fs->_add_tabs_before_content();
79 108
80 - if ( $has_tabs ) {
81 - $query_params['tabs'] = 'true';
82 - }
83 -
84 109 // Aliases.
85 110 $download_latest_text = fs_text_x_inline( 'Download Latest', 'as download latest version', 'download-latest', $slug );
86 111 $downgrading_plan_text = fs_text_inline( 'Downgrading your plan', 'downgrading-plan', $slug );
87 112 $cancelling_subscription_text = fs_text_inline( 'Cancelling the subscription', 'cancelling-subscription', $slug );
@@ -123,8 +148,9 @@
123 148 $site_info = $fs->get_site_info( $s );
124 149 $install = $fs->get_install_by_blog_id( $site_info['blog_id'] );
125 150 $view_params = array(
126 151 'freemius' => $fs,
152 + 'user' => $fs->get_user(),
127 153 'license' => $license,
128 154 'site' => $site_info,
129 155 'install' => $install,
130 156 );
@@ -148,21 +174,30 @@
148 174 }
149 175 }
150 176 }
151 177
152 - $is_child_license = ( is_object( $license ) && FS_Plugin_License::is_valid_id( $license->parent_license_id ) );
153 - $bundle_subscription = null;
178 + $has_bundle_license = false;
154 179
180 + if ( is_object( $license ) &&
181 + FS_Plugin_License::is_valid_id( $license->parent_license_id )
182 + ) {
183 + // Context license has a parent license, therefore, the account has a bundle license.
184 + $has_bundle_license = true;
185 + }
186 +
187 + $bundle_subscription = null;
188 + $is_bundle_first_payment_pending = false;
189 +
155 190 if (
156 191 $show_plan_row &&
157 192 is_object( $license ) &&
158 - FS_Plugin_License::is_valid_id( $license->parent_license_id )
193 + $has_bundle_license
159 194 ) {
160 - $bundle_subscription = $fs->_get_subscription( $license->parent_license_id );
195 + $bundle_plan_title = strtoupper( $license->parent_plan_title );
196 + $bundle_subscription = $fs->_get_subscription( $license->parent_license_id );
197 + $is_bundle_first_payment_pending = $license->is_first_payment_pending();
161 198 }
162 199
163 - $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() );
164 -
165 200 $fs_blog_id = ( is_multisite() && ! is_network_admin() ) ?
166 201 get_current_blog_id() :
167 202 0;
168 203
@@ -168,22 +203,72 @@
168 203
169 204 $active_plugins_directories_map = Freemius::get_active_plugins_directories_map( $fs_blog_id );
170 205
171 206 $is_premium = $fs->is_premium();
207 +
208 + $account_addons = $fs->get_updated_account_addons();
209 + $installed_addons = $fs->get_installed_addons();
210 + $installed_addons_ids = array();
211 +
212 + /**
213 + * Store the installed add-ons' IDs into a collection which will be used in determining the add-ons to show on the "Account" page, and at the same time try to find an add-on that is activated with a bundle license if the core product is not.
214 + *
215 + * @author Leo Fajardo
216 + *
217 + * @since 2.4.0
218 + */
219 + foreach ( $installed_addons as $fs_addon ) {
220 + $installed_addons_ids[] = $fs_addon->get_id();
221 +
222 + if ( $has_bundle_license ) {
223 + // We already have the context bundle license details, skip.
224 + continue;
225 + }
226 +
227 + if (
228 + $show_plan_row &&
229 + $fs_addon->has_active_valid_license()
230 + ) {
231 + $addon_license = $fs_addon->_get_license();
232 +
233 + if ( FS_Plugin_License::is_valid_id( $addon_license->parent_license_id ) ) {
234 + // Add-on's license is associated with a parent/bundle license.
235 + $has_bundle_license = true;
236 +
237 + $bundle_plan_title = strtoupper( $addon_license->parent_plan_title );
238 + $bundle_subscription = $fs_addon->_get_subscription( $addon_license->parent_license_id );
239 + $is_bundle_first_payment_pending = $addon_license->is_first_payment_pending();
240 + }
241 + }
242 + }
243 +
244 + $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
245 +
246 + $is_active_bundle_subscription = ( is_object( $bundle_subscription ) && $bundle_subscription->is_active() );
247 +
248 + $available_license = ( $fs->is_free_plan() && ! fs_is_network_admin() ) ?
249 + $fs->_get_available_premium_license( $site->is_localhost() ) :
250 + null;
251 +
252 + $available_license_paid_plan = is_object( $available_license ) ?
253 + $fs->_get_plan_by_id( $available_license->plan_id ) :
254 + null;
255 +
256 + $is_dev_mode = ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE );
172 257 ?>
173 258 <div class="wrap fs-section">
174 259 <?php if ( ! $has_tabs && ! $fs->apply_filters( 'hide_account_tabs', false ) ) : ?>
175 260 <h2 class="nav-tab-wrapper">
176 - <a href="<?php echo $fs->get_account_url() ?>"
261 + <a href="<?php echo esc_url( $fs->get_account_url() ) ?>"
177 262 class="nav-tab nav-tab-active"><?php fs_esc_html_echo_inline( 'Account', 'account', $slug ) ?></a>
178 263 <?php if ( $fs->has_addons() ) : ?>
179 - <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>"
264 + <a href="<?php echo esc_url( $fs->_get_admin_page_url( 'addons' ) ) ?>"
180 265 class="nav-tab"><?php echo esc_html( $addons_text ) ?></a>
181 266 <?php endif ?>
182 267 <?php if ( $show_upgrade ) : ?>
183 - <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
268 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>" class="nav-tab"><?php echo esc_html( $upgrade_text ) ?></a>
184 269 <?php if ( $fs->apply_filters( 'show_trial', true ) && ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
185 - <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a>
270 + <a href="<?php echo esc_url( $fs->get_trial_url() ) ?>" class="nav-tab"><?php fs_esc_html_echo_inline( 'Free Trial', 'free-trial', $slug ) ?></a>
186 271 <?php endif ?>
187 272 <?php endif ?>
188 273 </h2>
189 274 <?php endif ?>
@@ -195,91 +280,99 @@
195 280 <div class="postbox">
196 281 <h3><span class="dashicons dashicons-businessman"></span> <?php fs_esc_html_echo_inline( 'Account Details', 'account-details', $slug ) ?></h3>
197 282 <div class="fs-header-actions">
198 283 <ul>
284 + <?php if ( $fs->is_whitelabeled( true ) ) : ?>
285 + <li>
286 + <a href="#" class="debug-license-trigger"><i class="dashicons dashicons-<?php echo $is_whitelabeled ? 'editor-code' : 'controls-pause' ?>"></i> <span><?php
287 + if ( $is_whitelabeled ) {
288 + fs_esc_html_echo_inline( 'Start Debug', 'start-debug-license', $slug );
289 + } else {
290 + fs_esc_html_echo_inline( 'Stop Debug', 'stop-debug-license', $slug );
291 + }
292 + ?></span></a>
293 + </li>
294 + <li>&nbsp;&bull;&nbsp;</li>
295 + <?php endif ?>
199 296 <?php if ( $show_billing ) : ?>
200 - <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></li>
297 + <li><a href="#fs_billing"><i class="dashicons dashicons-portfolio"></i> <?php fs_esc_html_echo_inline( 'Billing & Invoices', 'billing-invoices', $slug ) ?></a></li>
201 298 <li>&nbsp;&bull;&nbsp;</li>
202 299 <?php endif ?>
203 - <?php if ( ! $is_paying ) : ?>
204 - <li>
205 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
206 - <input type="hidden" name="fs_action" value="delete_account">
207 - <?php wp_nonce_field( 'delete_account' ) ?>
208 - <a class="fs-delete-account" href="#" onclick="if (confirm('<?php
209 - if ( $is_active_subscription ) {
210 - echo esc_attr( sprintf( fs_text_inline( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'delete-account-x-confirm', $slug ), $plan->title ) );
211 - } else {
212 - echo esc_attr( sprintf( fs_text_inline( 'Deletion is not temporary. Only delete if you no longer want to use this %s anymore. Are you sure you would like to continue with the deletion?', 'delete-account-confirm', $slug ), $fs->get_module_label( true ) ) );
213 - }
214 - ?>')) this.parentNode.submit(); return false;"><i
215 - class="dashicons dashicons-no"></i> <?php fs_esc_html_echo_inline( 'Delete Account', 'delete-account', $slug ) ?></a>
216 - </form>
217 - </li>
218 - <li>&nbsp;&bull;&nbsp;</li>
219 - <?php endif ?>
220 - <?php if ( $is_paying ) : ?>
221 - <?php if ( ! fs_is_network_admin() ) : ?>
222 - <li>
223 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
224 - <input type="hidden" name="fs_action" value="deactivate_license">
225 - <?php wp_nonce_field( 'deactivate_license' ) ?>
226 - <a href="#" class="fs-deactivate-license"><i
227 - class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?>
228 - </a>
229 - </form>
230 - </li>
231 - <li>&nbsp;&bull;&nbsp;</li>
300 + <?php if ( ! $is_whitelabeled ) : ?>
301 + <?php if ( ! $is_paying ) : ?>
302 + <li>
303 + <?php
304 + $view_params = array(
305 + 'freemius' => $fs,
306 + 'license' => $available_license,
307 + 'license_paid_plan' => $available_license_paid_plan,
308 + );
309 + fs_require_template( 'account/partials/disconnect-button.php', $view_params ); ?>
310 + </li>
311 + <li>&nbsp;&bull;&nbsp;</li>
232 312 <?php endif ?>
233 - <?php if ( ! $license->is_lifetime() &&
234 - $is_active_subscription
235 - ) : ?>
236 - <li>
237 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
238 - <input type="hidden" name="fs_action" value="downgrade_account">
239 - <?php wp_nonce_field( 'downgrade_account' ) ?>
240 - <a href="#"
241 - onclick="if ( confirm('<?php echo esc_attr( sprintf(
242 - $downgrade_x_confirm_text,
243 - ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
244 - $plan->title,
245 - human_time_diff( time(), strtotime( $license->expiration ) )
246 - ) ) ?> <?php if ( ! $license->is_block_features ) {
247 - echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) );
248 - } else {
249 - echo esc_attr( sprintf( $after_downgrade_blocking_text, $plan->title ) );
250 - }?> <?php echo esc_attr( $prices_increase_text ) ?> <?php fs_esc_attr_echo_inline( 'Are you sure you want to proceed?', 'proceed-confirmation', $slug ) ?>') ) this.parentNode.submit(); return false;"><i class="dashicons dashicons-download"></i> <?php echo esc_html( $fs->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ) ?></a>
251 - </form>
252 - </li>
253 - <li>&nbsp;&bull;&nbsp;</li>
254 - <?php endif ?>
255 - <?php if ( ! $fs->is_single_plan() ) : ?>
256 - <li>
257 - <a href="<?php echo $fs->get_upgrade_url() ?>"><i
258 - class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a>
259 - </li>
260 - <li>&nbsp;&bull;&nbsp;</li>
261 - <?php endif ?>
262 - <?php elseif ( $is_paid_trial ) : ?>
263 - <li>
264 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
265 - <input type="hidden" name="fs_action" value="cancel_trial">
266 - <?php wp_nonce_field( 'cancel_trial' ) ?>
267 - <a href="#" class="fs-cancel-trial"><i
268 - class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a>
269 - </form>
270 - </li>
271 - <li>&nbsp;&bull;&nbsp;</li>
272 - <?php endif ?>
273 - <li>
274 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
275 - <input type="hidden" name="fs_action" value="<?php echo $fs->get_unique_affix() ?>_sync_license">
276 - <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
277 - <a href="#" onclick="this.parentNode.submit(); return false;"><i
278 - class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a>
279 - </form>
280 - </li>
281 -
313 + <?php if ( $is_paying ) : ?>
314 + <?php if ( ! fs_is_network_admin() ) : ?>
315 + <li>
316 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
317 + <input type="hidden" name="fs_action" value="deactivate_license">
318 + <?php wp_nonce_field( 'deactivate_license' ) ?>
319 + <a href="#" class="fs-deactivate-license"><i
320 + class="dashicons dashicons-admin-network"></i> <?php fs_echo_inline( 'Deactivate License', 'deactivate-license', $slug ) ?>
321 + </a>
322 + </form>
323 + </li>
324 + <li>&nbsp;&bull;&nbsp;</li>
325 + <?php endif ?>
326 + <?php if ( ! $license->is_lifetime() &&
327 + $is_active_subscription
328 + ) : ?>
329 + <li>
330 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
331 + <input type="hidden" name="fs_action" value="downgrade_account">
332 + <?php wp_nonce_field( 'downgrade_account' ) ?>
333 + <a href="#"
334 + onclick="if ( confirm('<?php echo esc_attr( sprintf(
335 + $downgrade_x_confirm_text,
336 + ( $fs->is_only_premium() ? $cancelling_subscription_text : $downgrading_plan_text ),
337 + $plan->title,
338 + human_time_diff( time(), strtotime( $license->expiration ) )
339 + ) ) ?> <?php if ( ! $license->is_block_features ) {
340 + echo esc_attr( sprintf( $after_downgrade_non_blocking_text, $plan->title, $fs->get_module_label( true ) ) );
341 + } else {
342 + echo esc_attr( sprintf( $after_downgrade_blocking_text, $plan->title ) );
343 + }?> <?php echo esc_attr( $prices_increase_text ) ?> <?php fs_esc_attr_echo_inline( 'Are you sure you want to proceed?', 'proceed-confirmation', $slug ) ?>') ) this.parentNode.submit(); return false;"><i class="dashicons dashicons-download"></i> <?php echo esc_html( $fs->is_only_premium() ? fs_text_inline( 'Cancel Subscription', 'cancel-subscription', $slug ) : $downgrade_text ) ?></a>
344 + </form>
345 + </li>
346 + <li>&nbsp;&bull;&nbsp;</li>
347 + <?php endif ?>
348 + <?php if ( $is_plan_change_supported ) : ?>
349 + <li>
350 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"><i
351 + class="dashicons dashicons-grid-view"></i> <?php echo esc_html( $change_plan_text ) ?></a>
352 + </li>
353 + <li>&nbsp;&bull;&nbsp;</li>
354 + <?php endif ?>
355 + <?php elseif ( $is_paid_trial ) : ?>
356 + <li>
357 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
358 + <input type="hidden" name="fs_action" value="cancel_trial">
359 + <?php wp_nonce_field( 'cancel_trial' ) ?>
360 + <a href="#" class="fs-cancel-trial"><i
361 + class="dashicons dashicons-download"></i> <?php echo esc_html( $cancel_trial_text ) ?></a>
362 + </form>
363 + </li>
364 + <li>&nbsp;&bull;&nbsp;</li>
365 + <?php endif ?>
366 + <?php endif ?>
367 + <li>
368 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>" method="POST">
369 + <input type="hidden" name="fs_action" value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
370 + <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
371 + <a href="#" onclick="this.parentNode.submit(); return false;"><i
372 + class="dashicons dashicons-image-rotate"></i> <?php fs_esc_html_echo_x_inline( 'Sync', 'as synchronize', 'sync', $slug ) ?></a>
373 + </form>
374 + </li>
282 375 </ul>
283 376 </div>
284 377 <div class="inside">
285 378 <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
@@ -286,28 +379,31 @@
286 379 <?php
287 380 $hide_license_key = ( ! $show_license_row || $fs->apply_filters( 'hide_license_key', false ) );
288 381
289 382 $profile = array();
290 - $profile[] = array(
291 - 'id' => 'user_name',
292 - 'title' => fs_text_inline( 'Name', 'name', $slug ),
293 - 'value' => $name
294 - );
295 - // if (isset($user->email) && false !== strpos($user->email, '@'))
296 - $profile[] = array(
297 - 'id' => 'email',
298 - 'title' => fs_text_inline( 'Email', 'email', $slug ),
299 - 'value' => $user->email
300 - );
301 383
302 - if ( is_numeric( $user->id ) ) {
303 - $profile[] = array(
304 - 'id' => 'user_id',
305 - 'title' => fs_text_inline( 'User ID', 'user-id', $slug ),
306 - 'value' => $user->id
307 - );
308 - }
384 + if ( ! $is_whitelabeled ) {
385 + $profile[] = array(
386 + 'id' => 'user_name',
387 + 'title' => fs_text_inline( 'Name', 'name', $slug ),
388 + 'value' => $name
389 + );
390 + // if (isset($user->email) && false !== strpos($user->email, '@'))
391 + $profile[] = array(
392 + 'id' => 'email',
393 + 'title' => fs_text_inline( 'Email', 'email', $slug ),
394 + 'value' => $user->email
395 + );
309 396
397 + if ( is_numeric( $user->id ) ) {
398 + $profile[] = array(
399 + 'id' => 'user_id',
400 + 'title' => fs_text_inline( 'User ID', 'user-id', $slug ),
401 + 'value' => $user->id
402 + );
403 + }
404 + }
405 +
310 406 $profile[] = array(
311 407 'id' => 'product',
312 408 'title' => ( $fs->is_plugin() ?
313 409 fs_text_inline( 'Plugin', 'plugin', $slug ) :
@@ -353,17 +449,17 @@
353 449 'title' => $version_text,
354 450 'value' => $fs->get_plugin_version()
355 451 );
356 452
357 - if ( $is_premium ) {
453 + if ( ! fs_is_network_admin() && $is_premium ) {
358 454 $profile[] = array(
359 455 'id' => 'beta_program',
360 456 'title' => '',
361 - 'value' => $user->is_beta
457 + 'value' => $site->is_beta
362 458 );
363 459 }
364 460
365 - if ( $has_paid_plan ) {
461 + if ( $has_paid_plan || $has_bundle_license ) {
366 462 if ( $fs->is_trial() ) {
367 463 if ( $show_plan_row ) {
368 464 $profile[] = array(
369 465 'id' => 'plan',
@@ -376,9 +472,9 @@
376 472 } else {
377 473 if ( $show_plan_row ) {
378 474 $profile[] = array(
379 475 'id' => 'plan',
380 - 'title' => ( $is_child_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
476 + 'title' => ( $has_bundle_license ? ucfirst( $fs->get_module_type() ) . ' ' : '' ) . $plan_text,
381 477 'value' => strtoupper( is_string( $plan->name ) ?
382 478 $plan->title :
383 479 strtoupper( $free_text )
384 480 )
@@ -383,13 +479,13 @@
383 479 strtoupper( $free_text )
384 480 )
385 481 );
386 482
387 - if ( $is_child_license ) {
483 + if ( $has_bundle_license ) {
388 484 $profile[] = array(
389 485 'id' => 'bundle_plan',
390 486 'title' => $bundle_plan_text,
391 - 'value' => strtoupper( $license->parent_plan_title )
487 + 'value' => $bundle_plan_title
392 488 );
393 489 }
394 490 }
395 491
@@ -413,17 +509,19 @@
413 509 // to show current plan.
414 510 continue;
415 511 }
416 512 ?>
417 - <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
513 + <tr class="fs-field-<?php echo esc_attr( $p['id'] ) ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
418 514 <td>
419 - <nobr><?php echo $p['title'] ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
515 + <nobr><?php echo esc_html( $p['title'] ) ?><?php echo ( ! empty( $p['title'] ) ) ? ':' : '' ?></nobr>
420 516 </td>
421 517 <td<?php if ( 'plan' === $p['id'] || 'bundle_plan' === $p['id'] ) { echo ' colspan="2"'; }?>>
422 518 <?php if ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
423 - <code><?php echo htmlspecialchars( substr( $p['value'], 0, 6 ) ) . str_pad( '', 23 * 6, '&bull;' ) . htmlspecialchars( substr( $p['value'], - 3 ) ) ?></code>
424 - <input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none"
519 + <code><?php echo FS_Plugin_License::mask_secret_key_for_html( $p['value'] ) ?></code>
520 + <?php if ( ! $is_whitelabeled ) : ?>
521 + <input type="text" value="<?php echo htmlspecialchars( $p['value'] ) ?>" style="display: none"
425 522 readonly/>
523 + <?php endif ?>
426 524 <?php elseif ( 'beta_program' === $p['id'] ) : ?>
427 525 <label>
428 526 <input type="checkbox" class="fs-toggle-beta-mode" <?php checked( true, $p['value'] ) ?>/><span><?php
429 527 fs_esc_html_echo_inline( 'Join the Beta program', 'join-beta', $slug )
@@ -451,18 +549,17 @@
451 549 <?php endif ?>
452 550 <?php elseif ( $fs->is_trial() ) : ?>
453 551 <label class="fs-tag fs-warn"><?php echo esc_html( sprintf( $expires_in_text, human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ) ?></label>
454 552 <?php endif ?>
553 + <?php if ( ! $is_whitelabeled ) : ?>
455 554 <div class="button-group">
456 - <?php $available_license = $fs->is_free_plan() && ! fs_is_network_admin() ? $fs->_get_available_premium_license( $site->is_localhost() ) : false ?>
457 555 <?php if ( is_object( $available_license ) ) : ?>
458 - <?php $premium_plan = $fs->_get_plan_by_id( $available_license->plan_id ) ?>
459 556 <?php
460 557 $view_params = array(
461 558 'freemius' => $fs,
462 559 'slug' => $slug,
463 560 'license' => $available_license,
464 - 'plan' => $premium_plan,
561 + 'plan' => $available_license_paid_plan,
465 562 'is_localhost' => $site->is_localhost(),
466 563 'install_id' => $site->id,
467 564 'class' => 'button-primary',
468 565 );
@@ -467,20 +564,20 @@
467 564 'class' => 'button-primary',
468 565 );
469 566 fs_require_template( 'account/partials/activate-license-button.php', $view_params ); ?>
470 567 <?php else : ?>
471 - <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
568 + <form action="<?php echo esc_url( $fs->_get_admin_page_url( 'account' ) ) ?>"
472 569 method="POST" class="button-group">
473 570 <?php if ( $show_upgrade && $is_premium ) : ?>
474 - <a class="button activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
571 + <a class="button activate-license-trigger <?php echo esc_attr( $fs->get_unique_affix() ) ?>" href="#"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
475 572 <?php endif ?>
476 573 <input type="submit" class="button"
477 574 value="<?php echo esc_attr( $sync_license_text ) ?>">
478 575 <input type="hidden" name="fs_action"
479 - value="<?php echo $fs->get_unique_affix() ?>_sync_license">
576 + value="<?php echo esc_attr( $fs->get_unique_affix() ) ?>_sync_license">
480 577 <?php wp_nonce_field( $fs->get_unique_affix() . '_sync_license' ) ?>
481 - <?php if ( $show_upgrade || ! $fs->is_single_plan() ) : ?>
482 - <a href="<?php echo $fs->get_upgrade_url() ?>"
578 + <?php if ( $show_upgrade || $is_plan_change_supported ) : ?>
579 + <a href="<?php echo esc_url( $fs->get_upgrade_url() ) ?>"
483 580 class="button<?php
484 581 echo $show_upgrade ?
485 582 ' button-primary fs-upgrade' :
486 583 ' fs-change-plan'; ?> button-upgrade"><i
@@ -488,11 +585,12 @@
488 585 <?php endif ?>
489 586 </form>
490 587 <?php endif ?>
491 588 </div>
589 + <?php endif ?>
492 590 <?php elseif ( 'bundle_plan' === $p['id'] ) : ?>
493 591 <?php if ( is_object( $bundle_subscription ) ) : ?>
494 - <?php if ( $is_active_bundle_subscription && ! $license->is_first_payment_pending() ) : ?>
592 + <?php if ( $is_active_bundle_subscription && ! $is_bundle_first_payment_pending ) : ?>
495 593 <label class="fs-tag fs-success"><?php echo esc_html( sprintf( $renews_in_text, human_time_diff( time(), strtotime( $bundle_subscription->next_payment ) ) ) ) ?></label>
496 594 <?php endif ?>
497 595 <?php endif ?>
498 596 <?php elseif ( 'version' === $p['id'] && $has_paid_plan ) : ?>
@@ -520,13 +618,35 @@
520 618 <?php if ( $fs->has_release_on_freemius() ) : ?>
521 619 <div class="button-group">
522 620 <?php if ( $is_paying || $fs->is_trial() ) : ?>
523 621 <?php if ( ! $fs->is_allowed_to_install() ) : ?>
524 - <a target="_blank" class="button button-primary"
525 - href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf(
526 - /* translators: %s: plan name (e.g. Download "Professional" Version) */
527 - fs_text_inline( 'Download %s Version', 'download-x-version', $slug ),
528 - ( $fs->is_trial() ? $trial_plan->title : $plan->title ) ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
622 + <a target="_blank" rel="noopener" class="button button-primary"
623 + href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php
624 + $download_version_text_suffix = ( is_object( $update ) ? ' [' . $update->version . ']' : '' );
625 +
626 + $download_version_text = sprintf(
627 + /* translators: %s: plan name (e.g. Download "Professional" Version) */
628 + fs_text_inline( 'Download %s Version', 'download-x-version', $slug ),
629 + ( $fs->is_trial() ? $trial_plan->title : $plan->title )
630 + ) .
631 + $download_version_text_suffix;
632 +
633 + $download_version_text_length = function_exists( 'mb_strlen' ) ?
634 + mb_strlen( $download_version_text ) :
635 + strlen( $download_version_text );
636 +
637 + if ( $download_version_text_length > 31 ) {
638 + /**
639 + * Try to limit the number of characters to 31 for now.
640 + *
641 + * @author Leo Fajardo (@leorw)
642 + * @aince 2.3.2
643 + */
644 + $download_version_text = fs_text_inline( 'Download Paid Version', 'download-paid-version', $slug ) . $download_version_text_suffix;
645 + }
646 +
647 + echo $download_version_text;
648 + ?></a>
529 649 <?php elseif ( is_object( $update ) ) : ?>
530 650 <?php
531 651 $module_type = $fs->get_module_type();
532 652 ?>
@@ -537,12 +657,14 @@
537 657 </div>
538 658 <?php endif ?>
539 659 <?php
540 660 elseif ( in_array( $p['id'], array( 'license_key', 'site_secret_key' ) ) ) : ?>
541 - <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
542 - <?php if ('license_key' === $p['id']) : ?>
543 - <button class="button button-small activate-license-trigger <?php echo $fs->get_unique_affix() ?>"><?php fs_esc_html_echo_inline( 'Change License', 'change-license', $slug ) ?></button>
544 - <?php endif ?>
661 + <?php if ( ! $is_whitelabeled && ( 'site_secret_key' === $p['id'] || ! $is_license_foreign ) ) : ?>
662 + <button class="button button-small fs-toggle-visibility"><?php fs_esc_html_echo_x_inline( 'Show', 'verb', 'show', $slug ) ?></button>
663 + <?php endif ?>
664 + <?php if ('license_key' === $p['id']) : ?>
665 + <button class="button button-small activate-license-trigger <?php echo $fs->get_unique_affix() ?>"><?php fs_esc_html_echo_inline( 'Change License', 'change-license', $slug ) ?></button>
666 + <?php endif ?>
545 667 <?php
546 668 elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
547 669 ( is_string( $user->secret_key ) && in_array( $p['id'], array(
548 670 'email',
@@ -548,8 +670,9 @@
548 670 'email',
549 671 'user_name'
550 672 ) ) )
551 673 ) : ?>
674 + <?php if ( 'email' !== $p['id'] || ! fs_is_network_admin() ) : ?>
552 675 <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
553 676 onsubmit="var val = prompt('<?php echo esc_attr( sprintf(
554 677 /* translators: %s: User's account property (e.g. name, email) */
555 678 fs_text_inline( 'What is your %s?', 'what-is-your-x', $slug ),
@@ -558,11 +681,15 @@
558 681 <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
559 682 <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $fs->get_unique_affix() ?>"
560 683 value="">
561 684 <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
562 - <input type="submit" class="button button-small"
685 + <input type="submit" class="button button-small <?php if ( 'email' === $p['id'] ) echo 'button-edit-email-address' ?>"
563 686 value="<?php echo fs_esc_attr_x_inline( 'Edit', 'verb', 'edit', $slug ) ?>">
564 687 </form>
688 + <?php endif ?>
689 + <?php elseif ( 'user_id' === $p['id'] && ! empty( $ids_of_installs_activated_with_foreign_licenses ) ) : ?>
690 + <input id="fs_change_user" type="submit" class="button button-small"
691 + value="<?php echo fs_esc_attr_inline( 'Change User', 'change-user', $slug ) ?>">
565 692 <?php endif ?>
566 693 </td>
567 694 <?php endif ?>
568 695 </tr>
@@ -586,20 +713,21 @@
586 713 <?php if ( fs_is_network_admin() ) : ?>
587 714 <div id="fs_sites" class="postbox">
588 715 <h3><span class="dashicons dashicons-networking"></span> <?php fs_esc_html_echo_inline( 'Sites', 'sites', $slug ) ?></h3>
589 716 <div class="fs-header-actions">
590 - <?php $has_license = is_object( $license ) ?>
591 - <?php if ( $has_license || ( $show_upgrade && $is_premium ) ) : ?>
592 - <?php
593 - $activate_license_button_text = $has_license ?
594 - fs_esc_html_inline( 'Change License', 'change-license', $slug ) :
595 - fs_esc_html_inline( 'Activate License', 'activate-license', $slug );
596 - ?>
597 - <a class="button<?php echo ( ! $has_license ? ' button-primary' : '' ) ?> activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php echo $activate_license_button_text ?></a>
717 + <?php if ( ! $is_whitelabeled ) : ?>
718 + <?php $has_license = is_object( $license ) ?>
719 + <?php if ( $has_license || ( $show_upgrade && $is_premium ) ) : ?>
720 + <?php
721 + $activate_license_button_text = $has_license ?
722 + fs_esc_html_inline( 'Change License', 'change-license', $slug ) :
723 + fs_esc_html_inline( 'Activate License', 'activate-license', $slug );
724 + ?>
725 + <a class="button<?php echo ( ! $has_license ? ' button-primary' : '' ) ?> activate-license-trigger <?php echo $fs->get_unique_affix() ?>" href="#"><?php echo $activate_license_button_text ?></a>
726 + <?php endif ?>
598 727 <?php endif ?>
599 728 <input class="fs-search" type="text" placeholder="<?php fs_esc_attr_echo_inline( 'Search by address', 'search-by-address', $slug ) ?>..."><span class="dashicons dashicons-search"></span>
600 729 </div>
601 -
602 730 <div class="inside">
603 731 <div id="" class="fs-scrollable-table">
604 732 <div class="fs-table-head">
605 733 <table class="widefat">
@@ -616,14 +744,32 @@
616 744 </div>
617 745 <div class="fs-table-body">
618 746 <table class="widefat">
619 747 <?php
748 + $current_blog_id = get_current_blog_id();
749 +
620 750 foreach ( $site_view_params as $view_params ) {
621 751 fs_require_template(
622 752 'account/partials/site.php',
623 753 $view_params
624 754 );
625 - } ?>
755 + }
756 +
757 + /**
758 + * It's possible for the `Freemius::switch_to_blog()` method to be called within the `site.php` template and this changes the Freemius instance's context, so this check is for restoring the previous context based on the previously retrieved site.
759 + *
760 + * @author Leo Fajardo (@leorw)
761 + * @since 2.5.0
762 + */
763 + $current_install = $fs->get_site();
764 +
765 + if (
766 + is_object( $site ) &&
767 + ( ! is_object( $current_install ) || $current_install->id != $site->id )
768 + ) {
769 + $fs->switch_to_blog( $current_blog_id, $site, true );
770 + }
771 + ?>
626 772 </table>
627 773 </div>
628 774 </div>
629 775 </div>
@@ -628,20 +774,8 @@
628 774 </div>
629 775 </div>
630 776 </div>
631 777 <?php endif ?>
632 -
633 - <?php
634 - $account_addons = $fs->get_updated_account_addons();
635 -
636 - $installed_addons = $fs->get_installed_addons();
637 - $installed_addons_ids = array();
638 - foreach ( $installed_addons as $fs_addon ) {
639 - $installed_addons_ids[] = $fs_addon->get_id();
640 - }
641 -
642 - $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
643 - ?>
644 778 <?php if ( 0 < count( $addons_to_show ) ) : ?>
645 779 <!-- Add-Ons -->
646 780 <div class="postbox">
647 781 <div class="">
@@ -654,9 +788,9 @@
654 788 <th><?php echo esc_html( $version_text ) ?></th>
655 789 <th><?php echo esc_html( $plan_text ) ?></th>
656 790 <th><?php fs_esc_html_echo_x_inline( 'License', 'as software license', 'license', $slug ) ?></th>
657 791 <th></th>
658 - <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
792 + <?php if ( $is_dev_mode ) : ?>
659 793 <th></th>
660 794 <?php endif ?>
661 795 </tr>
662 796 </thead>
@@ -665,11 +799,50 @@
665 799 $odd = true;
666 800
667 801 $installed_addons_ids_map = array_flip( $installed_addons_ids );
668 802
803 + $addon_info_by_id = array();
804 + $hide_all_addons_data = false;
805 +
806 + if ( $fs->is_whitelabeled_by_flag() ) {
807 + $hide_all_addons_data = true;
808 +
809 + foreach ( $addons_to_show as $addon_id ) {
810 + $is_addon_installed = isset( $installed_addons_ids_map[ $addon_id ] );
811 + $addon_info = $fs->_get_addon_info( $addon_id, $is_addon_installed );
812 + $is_addon_connected = $addon_info['is_connected'];
813 +
814 + $fs_addon = ( $is_addon_connected && $is_addon_installed ) ?
815 + freemius( $addon_id ) :
816 + null;
817 +
818 + $is_whitelabeled = is_object( $fs_addon ) ?
819 + $fs_addon->is_whitelabeled( true ) :
820 + $addon_info['is_whitelabeled'];
821 +
822 + if ( ! $is_whitelabeled ) {
823 + $hide_all_addons_data = false;
824 + }
825 +
826 + if ( $is_data_debug_mode ) {
827 + $is_whitelabeled = false;
828 + }
829 +
830 + $addon_info_by_id[ $addon_id ] = $addon_info;
831 + }
832 + }
833 +
669 834 foreach ( $addons_to_show as $addon_id ) {
670 835 $is_addon_installed = isset( $installed_addons_ids_map[ $addon_id ] );
671 836
837 + if (
838 + $hide_all_addons_data &&
839 + ! $is_addon_installed &&
840 + ! file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $fs->get_addon_basename( $addon_id ) ) )
841 + ) {
842 + continue;
843 + }
844 +
672 845 $addon_view_params = array(
673 846 'parent_fs' => $fs,
674 847 'addon_id' => $addon_id,
675 848 'odd' => $odd,
@@ -675,15 +848,28 @@
675 848 'odd' => $odd,
676 849 'fs_blog_id' => $fs_blog_id,
677 850 'active_plugins_directories_map' => &$active_plugins_directories_map,
678 851 'is_addon_installed' => $is_addon_installed,
679 - 'addon_info' => $fs->_get_addon_info( $addon_id, $is_addon_installed )
852 + 'addon_info' => isset( $addon_info_by_id[ $addon_id ] ) ?
853 + $addon_info_by_id[ $addon_id ] :
854 + $fs->_get_addon_info( $addon_id, $is_addon_installed ),
855 + 'is_whitelabeled' => ( $is_whitelabeled && ! $is_data_debug_mode )
680 856 );
681 857
682 - fs_require_template(
683 - 'account/partials/addon.php',
684 - $addon_view_params
685 - );
858 + if ( ! empty($addon_view_params['addon_info'] ) ) {
859 + fs_require_template(
860 + 'account/partials/addon.php',
861 + $addon_view_params
862 + );
863 + } else {
864 + // If we are here it means there is an activation of an unreleased add-on and yet the SDK is not in development mode.
865 + echo '<tr>';
866 + echo '<td style="text-align: right;">' . esc_html( $addon_id ) . '</td>';
867 + echo '<td colspan="' . ( $is_dev_mode ? 6 : 5 ) . '" style="text-align: left;">';
868 + echo 'The add-on you have activated is no longer <a href="https://freemius.com/help/documentation/wordpress/selling-add-ons-extensions/#preparing-the-add-on-for-sale" rel="noreferrer noopener" target="_blank">listed</a> by the product owner, or the SDK is not running in <a href="https://freemius.com/help/documentation/wordpress-sdk/testing/" rel="noreferrer noopener" target="_blank">test mode</a>. Please <a href="' . esc_url( $fs->contact_url() ) . '">contact support</a> if you need further assistance.';
869 + echo '</td>';
870 + echo '</tr>';
871 + }
686 872
687 873 $odd = ! $odd;
688 874 } ?>
689 875 </tbody>
@@ -695,9 +881,9 @@
695 881 <?php $fs->do_action( 'after_account_details' ) ?>
696 882
697 883 <?php
698 884 if ( $show_billing ) {
699 - $view_params = array( 'id' => $VARS['id'] );
885 + $view_params = array( 'id' => $VARS['id'], 'payments' => $payments );
700 886 fs_require_once_template( 'account/billing.php', $view_params );
701 887 fs_require_once_template( 'account/payments.php', $view_params );
702 888 }
703 889 ?>
@@ -775,9 +961,9 @@
775 961 isChecked = $checkbox.is( ':checked' );
776 962
777 963 if ( ! isChecked || confirm( '<?php echo $confirmation_message ?>' ) ) {
778 964 $.ajax( {
779 - url : ajaxurl,
965 + url : <?php echo Freemius::ajax_url() ?>,
780 966 method: 'POST',
781 967 data : {
782 968 action : '<?php echo $fs->get_ajax_action( 'set_beta_mode' ) ?>',
783 969 security : '<?php echo $fs->get_ajax_security( 'set_beta_mode' ) ?>',
@@ -914,8 +1100,31 @@
914 1100 }
915 1101 });
916 1102 });
917 1103
1104 + $( '.fs-toggle-whitelabel-mode' ).click( function () {
1105 + var $toggleLink = $( this );
1106 +
1107 + $.ajax( {
1108 + url : <?php echo Freemius::ajax_url() ?>,
1109 + method: 'POST',
1110 + data : {
1111 + action : '<?php echo $fs->get_ajax_action( 'toggle_whitelabel_mode' ) ?>',
1112 + security : '<?php echo $fs->get_ajax_security( 'toggle_whitelabel_mode' ) ?>',
1113 + module_id: <?php echo $fs->get_id() ?>
1114 + },
1115 + beforeSend: function () {
1116 + $toggleLink.parent().text( '<?php
1117 + $is_whitelabeled ?
1118 + fs_esc_html_echo_inline( 'Disabling white-label mode', 'disabling-whitelabel-mode' ) :
1119 + fs_esc_html_echo_inline( 'Enabling white-label mode', 'enabling-whitelabel-mode' )
1120 + ?>' + '...' );
1121 + },
1122 + complete: function () {
1123 + location.reload();
1124 + }
1125 + } );
1126 + });
918 1127 })(jQuery);
919 1128 </script>
920 1129 <?php
921 1130 if ( $has_tabs ) {
@@ -920,13 +1129,4 @@
920 1129 <?php
921 1130 if ( $has_tabs ) {
922 1131 $fs->_add_tabs_after_content();
923 1132 }
924 -
925 - $params = array(
926 - 'page' => 'account',
927 - 'module_id' => $fs->get_id(),
928 - 'module_type' => $fs->get_module_type(),
929 - 'module_slug' => $slug,
930 - 'module_version' => $fs->get_plugin_version(),
931 - );
932 - fs_require_template( 'powered-by.php', $params );