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/connect.php +296 -166 2.2.2 → 8.0.2 View file →
@@ -24,8 +24,17 @@
24 24 $is_freemium = $fs->is_freemium();
25 25
26 26 $fs->_enqueue_connect_essentials();
27 27
28 + /**
29 + * Enqueueing the styles in `_enqueue_connect_essentials()` is too late, as we need them in the HEADER. Therefore, inject the styles inline to avoid FOUC.
30 + *
31 + * @author Vova Feldman (@svovaf)
32 + */
33 + echo "<style>\n";
34 + include WP_FS__DIR_CSS . '/admin/connect.css';
35 + echo "</style>\n";
36 +
28 37 $current_user = Freemius::_get_current_wp_user();
29 38
30 39 $first_name = $current_user->user_firstname;
31 40 if ( empty( $first_name ) ) {
@@ -31,37 +40,34 @@
31 40 if ( empty( $first_name ) ) {
32 41 $first_name = $current_user->nickname;
33 42 }
34 43
35 - $site_url = get_site_url();
44 + $site_url = Freemius::get_unfiltered_site_url();
36 45 $protocol_pos = strpos( $site_url, '://' );
37 46 if ( false !== $protocol_pos ) {
38 47 $site_url = substr( $site_url, $protocol_pos + 3 );
39 48 }
40 49
41 - $freemius_site_www = 'https://freemius.com';
50 + $freemius_usage_tracking_url = $fs->get_usage_tracking_terms_url();
51 + $freemius_plugin_terms_url = $fs->get_eula_url();
42 52
43 - $freemius_usage_tracking_url = $freemius_site_www . '/wordpress/usage-tracking/' . $fs->get_id() . "/{$slug}/";
44 - $freemius_plugin_terms_url = $freemius_site_www . '/terms/' . $fs->get_id() . "/{$slug}/";
53 + $error = fs_request_get( 'error' );
45 54
46 - $freemius_site_url = $fs->is_premium() ?
47 - $freemius_site_www :
48 - $freemius_usage_tracking_url;
55 + $has_release_on_freemius = $fs->has_release_on_freemius();
49 56
50 - if ( $fs->is_premium() ) {
51 - $freemius_site_url .= '?' . http_build_query( array(
52 - 'id' => $fs->get_id(),
53 - 'slug' => $slug,
54 - ) );
55 - }
57 + $require_license_key = $is_premium_only ||
58 + (
59 + $is_freemium &&
60 + ( $is_premium_code || ! $has_release_on_freemius ) &&
61 + fs_request_get_bool( 'require_license', ( $is_premium_code || $has_release_on_freemius ) )
62 + );
56 63
57 - $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="1">freemius.com</a>';
64 + $freemius_activation_terms_url = ($fs->is_premium() && $require_license_key) ?
65 + $fs->get_license_activation_terms_url() :
66 + $freemius_usage_tracking_url;
58 67
59 - $error = fs_request_get( 'error' );
68 + $freemius_activation_terms_html = '<a href="' . esc_url( $freemius_activation_terms_url ) . '" target="_blank" rel="noopener" tabindex="1">freemius.com</a>';
60 69
61 - $require_license_key = $is_premium_only ||
62 - ( $is_freemium && $is_premium_code && fs_request_get_bool( 'require_license', true ) );
63 -
64 70 if ( $is_pending_activation ) {
65 71 $require_license_key = false;
66 72 }
67 73
@@ -71,9 +77,9 @@
71 77
72 78 $is_optin_dialog = (
73 79 $fs->is_theme() &&
74 80 $fs->is_themes_page() &&
75 - ( ! $fs->has_settings_menu() || $fs->is_free_wp_org_theme() )
81 + $fs->show_opt_in_on_themes_page()
76 82 );
77 83
78 84 if ( $is_optin_dialog ) {
79 85 $show_close_button = false;
@@ -110,15 +116,15 @@
110 116
111 117 /* translators: %s: name (e.g. Hey John,) */
112 118 $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $first_name ) );
113 119
114 - $is_gdpr_required = ( ! $is_pending_activation && ! $require_license_key ) ?
115 - FS_GDPR_Manager::instance()->is_required() :
116 - false;
117 -
118 - if ( is_null( $is_gdpr_required ) ) {
119 - $is_gdpr_required = $fs->fetch_and_store_current_user_gdpr_anonymously();
120 - }
120 + $activation_state = array(
121 + 'is_license_activation' => $require_license_key,
122 + 'is_pending_activation' => $is_pending_activation,
123 + 'is_gdpr_required' => true,
124 + 'is_network_level_activation' => $is_network_level_activation,
125 + 'is_dialog' => $is_optin_dialog,
126 + );
121 127 ?>
122 128 <?php
123 129 if ( $is_optin_dialog ) { ?>
124 130 <div id="fs_theme_connect_wrapper">
@@ -130,27 +136,62 @@
130 136 }
131 137 ?>
132 138 <?php
133 139 }
140 +
141 + /**
142 + * Allows developers to include custom HTML before the opt-in content.
143 + *
144 + * @author Vova Feldman
145 + * @since 2.3.2
146 + */
147 + $fs->do_action( 'connect/before', $activation_state );
134 148 ?>
135 149 <div id="fs_connect"
136 150 class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) ) {
137 151 echo ' fs-anonymous-disabled';
138 152 } ?><?php echo $require_license_key ? ' require-license-key' : '' ?>">
139 - <div class="fs-visual">
140 - <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
141 - <i class="dashicons dashicons-plus fs-first"></i>
142 - <?php
143 - $vars = array( 'id' => $fs->get_id() );
144 - fs_require_once_template( 'plugin-icon.php', $vars );
145 - ?>
146 - <i class="dashicons dashicons-plus fs-second"></i>
147 - <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
148 - </div>
153 + <div class="fs-header">
154 + <!-- <b class="fs-site-icon"><i class="dashicons dashicons-wordpress-alt"></i></b>-->
155 + <?php
156 + $size = 50;
157 + $vars = array(
158 + 'id' => $fs->get_id(),
159 + 'size' => $size,
160 + );
161 +
162 + fs_require_once_template( 'plugin-icon.php', $vars );
163 + ?>
164 + </div>
165 + <div class="fs-box-container">
149 166 <div class="fs-content">
167 + <?php $fs->do_action( 'connect/before_message', $activation_state ) ?>
168 +
150 169 <?php if ( ! empty( $error ) ) : ?>
151 - <p class="fs-error"><?php echo esc_html( $error ) ?></p>
170 + <div class="fs-error"><?php echo $fs->apply_filters( 'connect_error_esc_html', esc_html( $error ) ) ?></div>
152 171 <?php endif ?>
172 + <?php
173 + if ( ! $is_pending_activation && ! $require_license_key ) {
174 + if ( ! $fs->is_plugin_update() ) {
175 + echo $fs->apply_filters( 'connect-header', sprintf(
176 + '<h2 style="text-align: center">%s</h2>',
177 + esc_html( fs_text_inline( 'Never miss an important update', 'connect-header' ) )
178 + ) );
179 + } else {
180 + echo $fs->apply_filters( 'connect-header_on-update', sprintf(
181 + '<h2>%s</h2>',
182 + sprintf(
183 + esc_html(
184 + /* translators: %1$s: plugin name (e.g., "Awesome Plugin"); %2$s: version (e.g., "1.2.3") */
185 + fs_text_inline('Thank you for updating to %1$s v%2$s!', 'connect-header_on-update' )
186 + ),
187 + esc_html( $fs->get_plugin_name() ),
188 + $fs->get_plugin_version()
189 + )
190 + ) );
191 + }
192 + }
193 + ?>
153 194 <p><?php
154 195 $button_label = fs_text_inline( 'Allow & Continue', 'opt-in-connect', $slug );
155 196 $message = '';
156 197
@@ -159,46 +200,50 @@
159 200
160 201 $message = $fs->apply_filters( 'pending_activation_message', sprintf(
161 202 /* translators: %s: name (e.g. Thanks John!) */
162 203 fs_text_inline( 'Thanks %s!', 'thanks-x', $slug ) . '<br>' .
163 - fs_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', $slug ),
204 + fs_text_inline( 'You should receive a confirmation email for %s to your mailbox at %s. Please make sure you click the button in that email to %s.', 'pending-activation-message', $slug ),
164 205 $first_name,
165 206 '<b>' . $fs->get_plugin_name() . '</b>',
166 207 '<b>' . $current_user->user_email . '</b>',
167 - fs_text_inline( 'complete the install', 'complete-the-install', $slug )
208 + fs_text_inline( 'complete the opt-in', 'complete-the-opt-in', $slug )
168 209 ) );
169 210 } else if ( $require_license_key ) {
170 - $button_label = $is_network_upgrade_mode ?
171 - fs_text_inline( 'Activate License', 'agree-activate-license', $slug ) :
172 - fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug );
211 + $button_label = fs_text_inline( 'Activate License', 'activate-license', $slug );
173 212
174 213 $message = $fs->apply_filters(
175 214 'connect-message_on-premium',
176 - ($is_network_upgrade_mode ?
177 - '' :
178 - /* translators: %s: name (e.g. Hey John,) */
179 - $hey_x_text . '<br>'
180 - ) .
181 - sprintf( fs_text_inline( 'Thanks for purchasing %s! To get started, please enter your license key:', 'thanks-for-purchasing', $slug ), '<b>' . $fs->get_plugin_name() . '</b>' ),
215 + sprintf( fs_text_inline( 'Welcome to %s! To get started, please enter your license key:', 'thanks-for-purchasing', $slug ), '<b>' . $fs->get_plugin_name() . '</b>' ),
182 216 $first_name,
183 217 $fs->get_plugin_name()
184 218 );
185 219 } else {
186 - $filter = 'connect_message';
187 - $default_optin_message = $is_gdpr_required ?
188 - 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.', 'connect-message', $slug) :
189 - fs_text_inline( 'Never miss an important update - opt in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s.', 'connect-message', $slug);
220 + $filter = 'connect_message';
190 221
191 - if ( $fs->is_plugin_update() ) {
222 + if ( ! $fs->is_plugin_update() ) {
223 + $default_optin_message = esc_html(
224 + sprintf(
225 + /* translators: %s: module type (plugin, theme, or add-on) */
226 + fs_text_inline( 'Opt in to get email notifications for security & feature updates, educational content, and occasional offers, and to share some basic WordPress environment info. This will help us make the %s more compatible with your site and better at doing what you need it to.', 'connect-message', $slug ),
227 + $fs->get_module_label( true )
228 + )
229 + );
230 + } else {
192 231 // If Freemius was added on a plugin update, set different
193 232 // opt-in message.
194 - $default_optin_message = $is_gdpr_required ?
195 - 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 ) :
196 - 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 );
197 233
198 - // If user customized the opt-in message on update, use
234 + /* translators: %s: module type (plugin, theme, or add-on) */
235 + $default_optin_message = esc_html( sprintf( fs_text_inline( 'We have introduced this opt-in so you never miss an important update and help us make the %s more compatible with your site and better at doing what you need it to.', 'connect-message_on-update_why' ), $fs->get_module_label( true ) ) );
236 +
237 + $default_optin_message .= '<br><br>' . esc_html( fs_text_inline( 'Opt in to get email notifications for security & feature updates, educational content, and occasional offers, and to share some basic WordPress environment info.', 'connect-message_on-update', $slug ) );
238 +
239 + if ( $fs->is_enable_anonymous() ) {
240 + $default_optin_message .= ' ' . esc_html( fs_text_inline( 'If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update_skip', $slug ) );
241 + }
242 +
243 + // If user customized the opt-in message on update, use
199 244 // that message. Otherwise, fallback to regular opt-in
200 - // custom message if exist.
245 + // custom message if exists.
201 246 if ( $fs->has_filter( 'connect_message_on_update' ) ) {
202 247 $filter = 'connect_message_on_update';
203 248 }
204 249 }
@@ -204,26 +249,21 @@
204 249 }
205 250
206 251 $message = $fs->apply_filters(
207 252 $filter,
208 - ($is_network_upgrade_mode ?
209 - '' :
210 - /* translators: %s: name (e.g. Hey John,) */
211 - $hey_x_text . '<br>'
212 - ) .
213 253 sprintf(
214 - esc_html( $default_optin_message ),
254 + $default_optin_message,
215 255 '<b>' . esc_html( $fs->get_plugin_name() ) . '</b>',
216 256 '<b>' . $current_user->user_login . '</b>',
217 - '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
218 - $freemius_link
257 + '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
258 + $freemius_activation_terms_html
219 259 ),
220 260 $first_name,
221 261 $fs->get_plugin_name(),
222 262 $current_user->user_login,
223 - '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
224 - $freemius_link,
225 - $is_gdpr_required
263 + '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
264 + $freemius_activation_terms_html,
265 + true
226 266 );
227 267 }
228 268
229 269 if ( $is_network_upgrade_mode ) {
@@ -262,9 +302,9 @@
262 302 *
263 303 * @author Vova Feldman
264 304 * @since 2.1.2
265 305 */
266 - $fs->do_action( 'connect/after_license_input' );
306 + $fs->do_action( 'connect/after_license_input', $activation_state );
267 307 ?>
268 308
269 309 <?php
270 310 $send_updates_text = sprintf(
@@ -295,8 +335,11 @@
295 335 <span class="fs-input-label"><?php echo $do_not_send_updates_text ?></span>
296 336 </label>
297 337 </div>
298 338 </div>
339 + <div id="fs_orphan_license_message">
340 + <span class="fs-message"><?php fs_echo_inline( "A user has not yet been associated with the license, which is necessary to prevent unauthorized activation. To assign the license to your user, you agree to share your WordPress user's full name and email address." ) ?></span>
341 + </div>
299 342 <?php endif ?>
300 343 <?php if ( $is_network_level_activation ) : ?>
301 344 <?php
302 345 $vars = array(
@@ -307,22 +350,28 @@
307 350
308 351 echo fs_get_template( 'partials/network-activation.php', $vars );
309 352 ?>
310 353 <?php endif ?>
354 +
355 + <?php $fs->do_action( 'connect/after_message', $activation_state ) ?>
311 356 </div>
312 357 <div class="fs-actions">
358 + <?php $fs->do_action( 'connect/before_actions', $activation_state ) ?>
359 +
313 360 <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ( ! $require_license_key || $is_network_upgrade_mode ) ) : ?>
314 361 <a id="skip_activation" href="<?php echo fs_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $fs->get_unique_affix() . '_skip_activation' ), $is_network_level_activation ), $fs->get_unique_affix() . '_skip_activation' ) ?>"
315 362 class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?></a>
316 363 <?php endif ?>
317 - <?php if ( $is_network_level_activation ) : ?>
364 + <?php if ( $is_network_level_activation && $fs->apply_filters( 'show_delegation_option', true ) ) : ?>
318 365 <a id="delegate_to_site_admins" class="fs-tooltip-trigger <?php echo is_rtl() ? ' rtl' : '' ?>" href="<?php echo fs_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $fs->get_unique_affix() . '_delegate_activation' ) ), $fs->get_unique_affix() . '_delegate_activation' ) ?>"><?php fs_esc_html_echo_inline( 'Delegate to Site Admins', 'delegate-to-site-admins', $slug ) ?><span class="fs-tooltip"><?php fs_esc_html_echo_inline( 'If you click it, this decision will be delegated to the sites administrators.', 'delegate-sites-tooltip', $slug ) ?></span></a>
319 366 <?php endif ?>
320 367 <?php if ( $activate_with_current_user ) : ?>
321 368 <form action="" method="POST">
322 369 <input type="hidden" name="fs_action"
323 - value="<?php echo $fs->get_unique_affix() ?>_activate_existing">
324 - <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
370 + value="<?php echo esc_attr( $fs->get_unique_affix() . '_activate_existing' ) ?>">
371 + <?php wp_nonce_field( $fs->get_unique_affix() . '_activate_existing' ) ?>
372 + <input type="hidden" name="is_extensions_tracking_allowed" value="1">
373 + <input type="hidden" name="is_diagnostic_tracking_allowed" value="1">
325 374 <button class="button button-primary" tabindex="1"
326 375 type="submit"><?php echo esc_html( $button_label ) ?></button>
327 376 </form>
328 377 <?php else : ?>
@@ -328,10 +377,12 @@
328 377 <?php else : ?>
329 378 <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
330 379 <?php unset( $optin_params['sites']); ?>
331 380 <?php foreach ( $optin_params as $name => $value ) : ?>
332 - <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
381 + <input type="hidden" name="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $value ) ?>">
333 382 <?php endforeach ?>
383 + <input type="hidden" name="is_extensions_tracking_allowed" value="1">
384 + <input type="hidden" name="is_diagnostic_tracking_allowed" value="1">
334 385 <button class="button button-primary" tabindex="1"
335 386 type="submit"<?php if ( $require_license_key ) {
336 387 echo ' disabled="disabled"';
337 388 } ?>><?php echo esc_html( $button_label ) ?></button>
@@ -336,79 +387,49 @@
336 387 echo ' disabled="disabled"';
337 388 } ?>><?php echo esc_html( $button_label ) ?></button>
338 389 </form>
339 390 <?php endif ?>
391 + <?php if ( $require_license_key ) : ?>
392 + <a id="license_issues_link"
393 + href="<?php echo esc_url( $fs->apply_filters( 'known_license_issues_url', 'https://freemius.com/help/documentation/wordpress-sdk/license-activation-issues/' ) ) ?>"
394 + target="_blank"><?php fs_esc_html_echo_inline( 'License issues?', 'license-issues', $slug ) ?></a>
395 + <?php endif ?>
396 +
397 + <?php $fs->do_action( 'connect/after_actions', $activation_state ) ?>
340 398 </div><?php
399 + $permission_manager = FS_Permission_Manager::instance( $fs );
341 400
342 401 // Set core permission list items.
343 - $permissions = array(
344 - 'profile' => array(
345 - 'icon-class' => 'dashicons dashicons-admin-users',
346 - 'label' => $fs->get_text_inline( 'Your Profile Overview', 'permissions-profile' ),
347 - 'desc' => $fs->get_text_inline( 'Name and email address', 'permissions-profile_desc' ),
348 - 'priority' => 5,
349 - ),
350 - 'site' => array(
351 - 'icon-class' => 'dashicons dashicons-admin-settings',
352 - 'label' => $fs->get_text_inline( 'Your Site Overview', 'permissions-site' ),
353 - 'desc' => $fs->get_text_inline( 'Site URL, WP version, PHP info, plugins & themes', 'permissions-site_desc' ),
354 - 'priority' => 10,
355 - ),
356 - 'notices' => array(
357 - 'icon-class' => 'dashicons dashicons-testimonial',
358 - 'label' => $fs->get_text_inline( 'Admin Notices', 'permissions-admin-notices' ),
359 - 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ),
360 - 'priority' => 13,
361 - ),
362 - 'events' => array(
363 - 'icon-class' => 'dashicons dashicons-admin-plugins',
364 - 'label' => sprintf( $fs->get_text_inline( 'Current %s Events', 'permissions-events' ), ucfirst( $fs->get_module_type() ) ),
365 - 'desc' => $fs->get_text_inline( 'Activation, deactivation and uninstall', 'permissions-events_desc' ),
366 - 'priority' => 20,
367 - ),
368 - );
402 + $permissions = array();
369 403
370 - // Add newsletter permissions if enabled.
371 - if ( $is_gdpr_required || $fs->is_permission_requested( 'newsletter' ) ) {
372 - $permissions['newsletter'] = array(
373 - 'icon-class' => 'dashicons dashicons-email-alt',
374 - 'label' => $fs->get_text_inline( 'Newsletter', 'permissions-newsletter' ),
375 - 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ),
376 - 'priority' => 15,
377 - );
378 - }
404 + // Add newsletter permissions if enabled.
405 + if ( $fs->is_permission_requested( 'newsletter' ) ) {
406 + $permissions[] = $permission_manager->get_newsletter_permission();
407 + }
379 408
380 - // Allow filtering of the permissions list.
381 - $permissions = $fs->apply_filters( 'permission_list', $permissions );
409 + $permissions = $permission_manager->get_permissions(
410 + $require_license_key,
411 + $permissions
412 + );
382 413
383 - // Sort by priority.
384 - uasort( $permissions, 'fs_sort_by_priority' );
385 -
386 414 if ( ! empty( $permissions ) ) : ?>
387 415 <div class="fs-permissions">
388 - <?php if ( $require_license_key ) : ?>
389 - <p class="fs-license-sync-disclaimer"><?php
390 - echo sprintf(
391 - fs_esc_html_inline( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ),
392 - $fs->get_module_label( true ),
393 - $freemius_link
394 - ) ?></p>
395 - <?php endif ?>
396 - <a class="fs-trigger" href="#" tabindex="1"><?php fs_esc_html_echo_inline( 'What permissions are being granted?', 'what-permissions', $slug ) ?></a>
416 + <?php if ( $require_license_key ) : ?>
417 + <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php echo sprintf(
418 + fs_esc_html_inline( 'For delivery of security & feature updates, and license management, %s needs to', 'license-sync-disclaimer', $slug ) . '<b class="fs-arrow"></b>',
419 + sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', esc_html( $fs->get_plugin_title() ) )
420 + ) ?></a>
421 + <?php else : ?>
422 + <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php printf(
423 + fs_esc_html_inline( 'This will allow %s to', 'this-will-allow-x', $slug ) . '<b class="fs-arrow"></b>',
424 + sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', esc_html( $fs->get_plugin_title() ) )
425 + ) ?></a>
426 + <?php endif ?>
397 427 <ul><?php
398 - foreach ( $permissions as $id => $permission ) : ?>
399 - <li id="fs-permission-<?php echo esc_attr( $id ); ?>"
400 - class="fs-permission fs-<?php echo esc_attr( $id ); ?>">
401 - <i class="<?php echo esc_attr( $permission['icon-class'] ); ?>"></i>
402 -
403 - <div>
404 - <span><?php echo esc_html( $permission['label'] ); ?></span>
405 -
406 - <p><?php echo esc_html( $permission['desc'] ); ?></p>
407 - </div>
408 - </li>
409 - <?php endforeach; ?>
410 - </ul>
428 + foreach ( $permissions as $permission ) {
429 + $permission_manager->render_permission( $permission );
430 + }
431 + ?></ul>
411 432 </div>
412 433 <?php endif ?>
413 434 <?php if ( $is_premium_code && $is_freemium ) : ?>
414 435 <div class="fs-freemium-licensing">
@@ -422,16 +443,31 @@
422 443 <?php endif ?>
423 444 </p>
424 445 </div>
425 446 <?php endif ?>
447 + </div>
426 448 <div class="fs-terms">
427 - <a href="https://freemius.com/privacy/" target="_blank"
449 + <a class="fs-tooltip-trigger<?php echo is_rtl() ? ' rtl' : '' ?>" href="<?php echo esc_url( $freemius_activation_terms_url ) ?>" target="_blank" rel="noopener" tabindex="1">Powered by Freemius<?php if ( $require_license_key ) : ?> <span class="fs-tooltip" style="width: 170px"><?php echo esc_html( $fs->get_text_inline( 'Freemius is our licensing and software updates engine', 'permissions-extensions_desc' ) ) ?></span><?php endif ?></a>
450 + &nbsp;&nbsp;-&nbsp;&nbsp;
451 + <a href="https://freemius.com/privacy/" target="_blank" rel="noopener"
428 452 tabindex="1"><?php fs_esc_html_echo_inline( 'Privacy Policy', 'privacy-policy', $slug ) ?></a>
429 453 &nbsp;&nbsp;-&nbsp;&nbsp;
430 - <a href="<?php echo $require_license_key ? $freemius_plugin_terms_url : $freemius_usage_tracking_url ?>" target="_blank" tabindex="1"><?php $require_license_key ? fs_echo_inline( 'License Agreement', 'license-agreement', $slug ) : fs_echo_inline( 'Terms of Service', 'tos', $slug ) ?></a>
454 + <?php if ($require_license_key) : ?>
455 + <a href="<?php echo esc_url( $freemius_plugin_terms_url ) ?>" target="_blank" rel="noopener" tabindex="1"><?php fs_echo_inline( 'License Agreement', 'license-agreement', $slug ) ?></a>
456 + <?php else : ?>
457 + <a href="<?php echo esc_url( $freemius_usage_tracking_url ) ?>" target="_blank" rel="noopener" tabindex="1"><?php fs_echo_inline( 'Terms of Service', 'tos', $slug ) ?></a>
458 + <?php endif; ?>
431 459 </div>
432 460 </div>
433 461 <?php
462 + /**
463 + * Allows developers to include custom HTML after the opt-in content.
464 + *
465 + * @author Vova Feldman
466 + * @since 2.3.2
467 + */
468 + $fs->do_action( 'connect/after', $activation_state );
469 +
434 470 if ( $is_optin_dialog ) { ?>
435 471 </div>
436 472 <?php
437 473 }
@@ -473,8 +509,9 @@
473 509 isNetworkUpgradeMode = <?php echo $is_network_upgrade_mode ? 'true' : 'false' ?>,
474 510 $licenseSecret,
475 511 $licenseKeyInput = $('#fs_license_key'),
476 512 pauseCtaLabelUpdate = false,
513 + isNetworkDelegating = false,
477 514 /**
478 515 * @author Leo Fajardo (@leorw)
479 516 * @since 2.1.0
480 517 */
@@ -481,15 +518,14 @@
481 518 resetLoadingMode = function() {
482 519 // Reset loading mode.
483 520 $primaryCta.html(primaryCtaLabel);
484 521 $primaryCta.prop('disabled', false);
485 - $(document.body).css({'cursor': 'auto'});
486 - $('.fs-loading').removeClass('fs-loading');
522 + $( '.fs-loading' ).removeClass( 'fs-loading' );
487 523
488 524 console.log('resetLoadingMode - Primary button was enabled');
489 525 },
490 526 setLoadingMode = function () {
491 - $(document.body).css({'cursor': 'wait'});
527 + $( document.body ).addClass( 'fs-loading' );
492 528 };
493 529
494 530 $('.fs-actions .button').on('click', function () {
495 531 setLoadingMode();
@@ -504,16 +540,17 @@
504 540 });
505 541
506 542 if ( isNetworkActive ) {
507 543 var
508 - $multisiteOptionsContainer = $( '#multisite_options_container' ),
509 - $allSitesOptions = $( '#all_sites_options' ),
510 - $applyOnAllSites = $( '#apply_on_all_sites' ),
511 - $sitesListContainer = $( '#sites_list_container' ),
544 + $multisiteOptionsContainer = $( '.fs-multisite-options-container' ),
545 + $allSitesOptions = $( '.fs-all-sites-options' ),
546 + $applyOnAllSites = $( '.fs-apply-on-all-sites-checkbox' ),
547 + $sitesListContainer = $( '.fs-sites-list-container' ),
512 548 totalSites = <?php echo count( $sites ) ?>,
513 549 maxSitesListHeight = null,
514 550 $skipActivationButton = $( '#skip_activation' ),
515 - $delegateToSiteAdminsButton = $( '#delegate_to_site_admins' );
551 + $delegateToSiteAdminsButton = $( '#delegate_to_site_admins' ),
552 + hasAnyInstall = <?php echo ! is_null( $fs->find_first_install() ) ? 'true' : 'false' ?>;
516 553
517 554 $applyOnAllSites.click(function() {
518 555 var isChecked = $( this ).is( ':checked' );
519 556
@@ -527,9 +564,9 @@
527 564 $skipActivationButton.toggle();
528 565
529 566 $delegateToSiteAdminsButton.toggle();
530 567
531 - $multisiteOptionsContainer.toggleClass( 'apply-on-all-sites', isChecked );
568 + $multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', isChecked );
532 569
533 570 $sitesListContainer.toggle( ! isChecked );
534 571 if ( ! isChecked && null === maxSitesListHeight ) {
535 572 /**
@@ -550,8 +587,13 @@
550 587
551 588 updatePrimaryCtaText( actionType );
552 589 });
553 590
591 + $sitesListContainer.delegate( 'td:not(:first-child)', 'click', function() {
592 + // If a site row is clicked, trigger a click on the checkbox.
593 + $( this ).parent().find( 'td:first-child input' ).click();
594 + } );
595 +
554 596 $sitesListContainer.delegate( '.action', 'click', function( evt ) {
555 597 var $this = $( evt.target );
556 598 if ( $this.hasClass( 'selected' ) ) {
557 599 return false;
@@ -574,9 +616,9 @@
574 616 updatePrimaryCtaText( 'mixed' );
575 617 }
576 618 });
577 619
578 - if (isNetworkUpgradeMode) {
620 + if ( isNetworkUpgradeMode || hasAnyInstall ) {
579 621 $skipActivationButton.click(function(){
580 622 $delegateToSiteAdminsButton.hide();
581 623
582 624 $skipActivationButton.html('<?php fs_esc_js_echo_inline( 'Skipping, please wait', 'skipping-wait', $slug ) ?>...');
@@ -597,8 +639,18 @@
597 639 $delegateToSiteAdminsButton.html('<?php fs_esc_js_echo_inline( 'Delegating, please wait', 'delegating-wait', $slug ) ?>...');
598 640
599 641 pauseCtaLabelUpdate = true;
600 642
643 + /**
644 + * Set to true so that the form submission handler can differentiate delegation from license
645 + * activation and the proper AJAX action will be used (when delegating, the action should be
646 + * `network_activate` and not `activate_license`).
647 + *
648 + * @author Leo Fajardo (@leorw)
649 + * @since 2.3.0
650 + */
651 + isNetworkDelegating = true;
652 +
601 653 // Check all sites to be skipped.
602 654 $allSitesOptions.find('.action.action-delegate').click();
603 655
604 656 $form.submit();
@@ -604,8 +656,18 @@
604 656 $form.submit();
605 657
606 658 pauseCtaLabelUpdate = false;
607 659
660 + /**
661 + * Set to false so that in case the previous AJAX request has failed, the form submission handler
662 + * can differentiate license activation from delegation and the proper AJAX action will be used
663 + * (when activating a license, the action should be `activate_license` and not `network_activate`).
664 + *
665 + * @author Leo Fajardo (@leorw)
666 + * @since 2.3.0
667 + */
668 + isNetworkDelegating = false;
669 +
608 670 return false;
609 671 });
610 672 }
611 673 }
@@ -636,8 +698,29 @@
636 698
637 699 var ajaxOptin = ( requireLicenseKey || isNetworkActive );
638 700
639 701 $form.on('submit', function () {
702 + var $extensionsPermission = $( '#fs_permission_extensions .fs-switch' ),
703 + isExtensionsTrackingAllowed = ( $extensionsPermission.length > 0 ) ?
704 + $extensionsPermission.hasClass( 'fs-on' ) :
705 + null;
706 +
707 + var $diagnosticPermission = $( '#fs_permission_diagnostic .fs-switch' ),
708 + isDiagnosticTrackingAllowed = ( $diagnosticPermission.length > 0 ) ?
709 + $diagnosticPermission.hasClass( 'fs-on' ) :
710 + null;
711 +
712 + if ( null === isExtensionsTrackingAllowed ) {
713 + $( 'input[name=is_extensions_tracking_allowed]' ).remove();
714 + } else {
715 + $( 'input[name=is_extensions_tracking_allowed]' ).val( isExtensionsTrackingAllowed ? 1 : 0 );
716 + }
717 +
718 + // We are not showing switch to enable/disable diagnostic tracking while activating free version. So, don't remove hidden `is_diagnostic_tracking_allowed` element from DOM and change the value only if switch is available.
719 + if ( null !== isDiagnosticTrackingAllowed ) {
720 + $( 'input[name=is_diagnostic_tracking_allowed]' ).val( isDiagnosticTrackingAllowed ? 1 : 0 );
721 + }
722 +
640 723 /**
641 724 * @author Vova Feldman (@svovaf)
642 725 * @since 1.1.9
643 726 */
@@ -642,22 +725,34 @@
642 725 * @since 1.1.9
643 726 */
644 727 if ( ajaxOptin ) {
645 728 if (!hasContextUser || isNetworkUpgradeMode) {
646 - <?php $action = $require_license_key ? 'activate_license' : 'network_activate' ?>
729 + var action = null,
730 + security = null;
647 731
732 + if ( requireLicenseKey && ! isNetworkDelegating ) {
733 + action = '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>';
734 + security = '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>';
735 + } else {
736 + action = '<?php echo $fs->get_ajax_action( 'network_activate' ) ?>';
737 + security = '<?php echo $fs->get_ajax_security( 'network_activate' ) ?>';
738 + }
739 +
648 740 $('.fs-error').remove();
649 741
650 742 var
651 743 licenseKey = $licenseKeyInput.val(),
652 744 data = {
653 - action : '<?php echo $fs->get_ajax_action( $action ) ?>',
654 - security : '<?php echo $fs->get_ajax_security( $action ) ?>',
655 - license_key: licenseKey,
656 - module_id : '<?php echo $fs->get_id() ?>'
745 + action : action,
746 + security : security,
747 + license_key : licenseKey,
748 + module_id : '<?php echo $fs->get_id() ?>',
749 + license_owner_id: licenseOwnerIDByLicense[ licenseKey ]
657 750 };
658 751
659 - if (requireLicenseKey &&
752 + if (
753 + requireLicenseKey &&
754 + ! isNetworkDelegating &&
660 755 isMarketingAllowedByLicense.hasOwnProperty(licenseKey)
661 756 ) {
662 757 var
663 758 isMarketingAllowed = null,
@@ -677,8 +772,12 @@
677 772 isMarketingAllowed = isMarketingAllowedByLicense[ licenseKey ];
678 773 }
679 774
680 775 data.is_marketing_allowed = isMarketingAllowed;
776 +
777 + data.is_extensions_tracking_allowed = isExtensionsTrackingAllowed;
778 +
779 + data.is_diagnostic_tracking_allowed = isDiagnosticTrackingAllowed;
681 780 }
682 781
683 782 $marketingOptin.removeClass( 'error' );
684 783
@@ -699,14 +798,15 @@
699 798 uid : $this.find( '.uid' ).val(),
700 799 url : $this.find( '.url' ).val(),
701 800 title : $this.find( '.title' ).val(),
702 801 language: $this.find( '.language' ).val(),
703 - charset : $this.find( '.charset' ).val(),
704 802 blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
705 803 };
706 804
707 805 if ( ! requireLicenseKey) {
708 806 site.action = $this.find('.action.selected').data('action-type');
807 + } else if ( isNetworkDelegating ) {
808 + site.action = 'delegate';
709 809 }
710 810
711 811 sites.push( site );
712 812 });
@@ -711,8 +811,12 @@
711 811 sites.push( site );
712 812 });
713 813
714 814 data.sites = sites;
815 +
816 + if ( hasAnyInstall ) {
817 + data.has_any_install = hasAnyInstall;
818 + }
715 819 }
716 820
717 821 /**
718 822 * Use the AJAX opt-in when license key is required to potentially
@@ -721,9 +825,9 @@
721 825 * @author Vova Feldman (@svovaf)
722 826 * @since 1.2.1.5
723 827 */
724 828 $.ajax({
725 - url : ajaxurl,
829 + url : <?php echo Freemius::ajax_url() ?>,
726 830 method : 'POST',
727 831 data : data,
728 832 success: function (result) {
729 833 var resultObj = $.parseJSON(result);
@@ -733,9 +837,9 @@
733 837 } else {
734 838 resetLoadingMode();
735 839
736 840 // Show error.
737 - $('.fs-content').prepend('<p class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</p>');
841 + $('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>');
738 842 }
739 843 },
740 844 error: function () {
741 845 resetLoadingMode();
@@ -757,8 +861,17 @@
757 861
758 862 return true;
759 863 });
760 864
865 + $( '#fs_connect .fs-permissions .fs-switch' ).on( 'click', function () {
866 + $( this )
867 + .toggleClass( 'fs-on' )
868 + .toggleClass( 'fs-off' );
869 +
870 + $( this ).closest( '.fs-permission' )
871 + .toggleClass( 'fs-disabled' );
872 + });
873 +
761 874 $primaryCta.on('click', function () {
762 875 console.log('Primary button was clicked');
763 876
764 877 $(this).addClass('fs-loading');
@@ -805,9 +918,9 @@
805 918 }
806 919
807 920 if ('' === key) {
808 921 $primaryCta.attr('disabled', 'disabled');
809 - $marketingOptin.hide();
922 + hideOptinAndLicenseMessage();
810 923 } else {
811 924 $primaryCta.prop('disabled', false);
812 925
813 926 if (32 <= key.length){
@@ -812,9 +925,9 @@
812 925
813 926 if (32 <= key.length){
814 927 fetchIsMarketingAllowedFlagAndToggleOptin();
815 928 } else {
816 - $marketingOptin.hide();
929 + hideOptinAndLicenseMessage();
817 930 }
818 931 }
819 932
820 933 previousLicenseKey = key;
@@ -848,10 +961,12 @@
848 961 //--------------------------------------------------------------------------------
849 962 //region GDPR
850 963 //--------------------------------------------------------------------------------
851 964 var isMarketingAllowedByLicense = {},
852 - $marketingOptin = $('#fs_marketing_optin'),
853 - previousLicenseKey = null;
965 + licenseOwnerIDByLicense = {},
966 + $marketingOptin = $( '#fs_marketing_optin' ),
967 + $orphanLicenseMessage = $( '#fs_orphan_license_message' ),
968 + previousLicenseKey = null;
854 969
855 970 if (requireLicenseKey) {
856 971
857 972 var
@@ -871,8 +986,16 @@
871 986 } else {
872 987 $marketingOptin.hide();
873 988 $primaryCta.focus();
874 989 }
990 +
991 + $orphanLicenseMessage.toggle( false === licenseOwnerIDByLicense[ licenseKey ] );
992 +
993 + if ( false !== licenseOwnerIDByLicense[ licenseKey ] ) {
994 + $( 'input[name=user_firstname]' ).remove();
995 + $( 'input[name=user_lastname]' ).remove();
996 + $( 'input[name=user_email]' ).remove();
997 + }
875 998 },
876 999 /**
877 1000 * @author Leo Fajardo (@leorw)
878 1001 * @since 2.1.0
@@ -880,9 +1003,10 @@
880 1003 fetchIsMarketingAllowedFlagAndToggleOptin = function () {
881 1004 var licenseKey = $licenseKeyInput.val();
882 1005
883 1006 if (licenseKey.length < 32) {
884 - $marketingOptin.hide();
1007 + hideOptinAndLicenseMessage();
1008 +
885 1009 return;
886 1010 }
887 1011
888 1012 if (isMarketingAllowedByLicense.hasOwnProperty(licenseKey)) {
@@ -889,10 +1013,9 @@
889 1013 afterMarketingFlagLoaded();
890 1014 return;
891 1015 }
892 1016
893 - $marketingOptin.hide();
894 -
1017 + hideOptinAndLicenseMessage();
895 1018 setLoadingMode();
896 1019
897 1020 $primaryCta.addClass('fs-loading');
898 1021 $primaryCta.attr('disabled', 'disabled');
@@ -898,9 +1021,9 @@
898 1021 $primaryCta.attr('disabled', 'disabled');
899 1022 $primaryCta.html('<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...');
900 1023
901 1024 $.ajax({
902 - url : ajaxurl,
1025 + url : <?php echo Freemius::ajax_url() ?>,
903 1026 method : 'POST',
904 1027 data : {
905 1028 action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>',
906 1029 security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>',
@@ -914,13 +1037,18 @@
914 1037 result = result.data;
915 1038
916 1039 // Cache result.
917 1040 isMarketingAllowedByLicense[licenseKey] = result.is_marketing_allowed;
1041 + licenseOwnerIDByLicense[ licenseKey ] = result.license_owner_id;
918 1042 }
919 1043
920 1044 afterMarketingFlagLoaded();
921 1045 }
922 1046 });
1047 + },
1048 + hideOptinAndLicenseMessage = function() {
1049 + $marketingOptin.hide();
1050 + $orphanLicenseMessage.hide();
923 1051 };
924 1052
925 1053 $marketingOptin.find( 'input' ).click(function() {
926 1054 $marketingOptin.removeClass( 'error' );
@@ -928,5 +1056,7 @@
928 1056 }
929 1057
930 1058 //endregion
931 1059 })(jQuery);
932 -</script>
1060 +</script>
1061 +<?php
1062 + fs_require_once_template( 'api-connectivity-message-js.php' );