PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / trunk
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites vtrunk
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
← All changes | freemius/templates/connect.php +1061 -1046 2.6.1trunk View file →
@@ -1,1047 +1,1062 @@
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 - * @var array $VARS
15 - * @var Freemius $fs
16 - */
17 - $fs = freemius( $VARS['id'] );
18 - $slug = $fs->get_slug();
19 -
20 - $is_pending_activation = $fs->is_pending_activation();
21 - $is_premium_only = $fs->is_only_premium();
22 - $has_paid_plans = $fs->has_paid_plan();
23 - $is_premium_code = $fs->is_premium();
24 - $is_freemium = $fs->is_freemium();
25 -
26 - $fs->_enqueue_connect_essentials();
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 -
37 - $current_user = Freemius::_get_current_wp_user();
38 -
39 - $first_name = $current_user->user_firstname;
40 - if ( empty( $first_name ) ) {
41 - $first_name = $current_user->nickname;
42 - }
43 -
44 - $site_url = Freemius::get_unfiltered_site_url();
45 - $protocol_pos = strpos( $site_url, '://' );
46 - if ( false !== $protocol_pos ) {
47 - $site_url = substr( $site_url, $protocol_pos + 3 );
48 - }
49 -
50 - $freemius_site_www = 'https://freemius.com';
51 -
52 - $freemius_usage_tracking_url = $fs->get_usage_tracking_terms_url();
53 - $freemius_plugin_terms_url = $fs->get_eula_url();
54 -
55 - $freemius_site_url = $fs->is_premium() ?
56 - $freemius_site_www :
57 - $freemius_usage_tracking_url;
58 -
59 - if ( $fs->is_premium() ) {
60 - $freemius_site_url .= '?' . http_build_query( array(
61 - 'id' => $fs->get_id(),
62 - 'slug' => $slug,
63 - ) );
64 - }
65 -
66 - $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" rel="noopener" tabindex="1">freemius.com</a>';
67 -
68 - $error = fs_request_get( 'error' );
69 -
70 - $has_release_on_freemius = $fs->has_release_on_freemius();
71 -
72 - $require_license_key = $is_premium_only ||
73 - (
74 - $is_freemium &&
75 - ( $is_premium_code || ! $has_release_on_freemius ) &&
76 - fs_request_get_bool( 'require_license', ( $is_premium_code || $has_release_on_freemius ) )
77 - );
78 -
79 - if ( $is_pending_activation ) {
80 - $require_license_key = false;
81 - }
82 -
83 - if ( $require_license_key ) {
84 - $fs->_add_license_activation_dialog_box();
85 - }
86 -
87 - $is_optin_dialog = (
88 - $fs->is_theme() &&
89 - $fs->is_themes_page() &&
90 - $fs->show_opt_in_on_themes_page()
91 - );
92 -
93 - if ( $is_optin_dialog ) {
94 - $show_close_button = false;
95 - $previous_theme_activation_url = '';
96 -
97 - if ( ! $is_premium_code ) {
98 - $show_close_button = true;
99 - } else if ( $is_premium_only ) {
100 - $previous_theme_activation_url = $fs->get_previous_theme_activation_url();
101 - $show_close_button = ( ! empty( $previous_theme_activation_url ) );
102 - }
103 - }
104 -
105 - $is_network_level_activation = (
106 - fs_is_network_admin() &&
107 - $fs->is_network_active() &&
108 - ! $fs->is_network_delegated_connection()
109 - );
110 -
111 - $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
112 -
113 - $activate_with_current_user = (
114 - is_object( $fs_user ) &&
115 - ! $is_pending_activation &&
116 - // If requires a license for activation, use the user associated with the license for the opt-in.
117 - ! $require_license_key &&
118 - ! $is_network_level_activation
119 - );
120 -
121 - $optin_params = $fs->get_opt_in_params( array(), $is_network_level_activation );
122 - $sites = isset( $optin_params['sites'] ) ? $optin_params['sites'] : array();
123 -
124 - $is_network_upgrade_mode = ( fs_is_network_admin() && $fs->is_network_upgrade_mode() );
125 -
126 - /* translators: %s: name (e.g. Hey John,) */
127 - $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $first_name ) );
128 -
129 - $activation_state = array(
130 - 'is_license_activation' => $require_license_key,
131 - 'is_pending_activation' => $is_pending_activation,
132 - 'is_gdpr_required' => true,
133 - 'is_network_level_activation' => $is_network_level_activation,
134 - 'is_dialog' => $is_optin_dialog,
135 - );
136 -?>
137 -<?php
138 - if ( $is_optin_dialog ) { ?>
139 -<div id="fs_theme_connect_wrapper">
140 - <?php
141 - if ( $show_close_button ) { ?>
142 - <button class="close dashicons dashicons-no"><span class="screen-reader-text">Close connect dialog</span>
143 - </button>
144 - <?php
145 - }
146 - ?>
147 - <?php
148 - }
149 -
150 - /**
151 - * Allows developers to include custom HTML before the opt-in content.
152 - *
153 - * @author Vova Feldman
154 - * @since 2.3.2
155 - */
156 - $fs->do_action( 'connect/before', $activation_state );
157 - ?>
158 - <div id="fs_connect"
159 - class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) ) {
160 - echo ' fs-anonymous-disabled';
161 - } ?><?php echo $require_license_key ? ' require-license-key' : '' ?>">
162 - <div class="fs-header">
163 - <!-- <b class="fs-site-icon"><i class="dashicons dashicons-wordpress-alt"></i></b>-->
164 - <?php
165 - $size = 50;
166 - $vars = array(
167 - 'id' => $fs->get_id(),
168 - 'size' => $size,
169 - );
170 -
171 - fs_require_once_template( 'plugin-icon.php', $vars );
172 - ?>
173 - <!-- <img class="fs-connect-logo" width="--><?php //echo $size ?><!--" height="--><?php //echo $size ?><!--" src="//img.freemius.com/logo/connect.svg"/>-->
174 - </div>
175 - <div class="fs-box-container">
176 - <div class="fs-content">
177 - <?php $fs->do_action( 'connect/before_message', $activation_state ) ?>
178 -
179 - <?php if ( ! empty( $error ) ) : ?>
180 - <div class="fs-error"><?php echo $fs->apply_filters( 'connect_error_esc_html', esc_html( $error ) ) ?></div>
181 - <?php endif ?>
182 - <?php
183 - if ( ! $is_pending_activation && ! $require_license_key ) {
184 - if ( ! $fs->is_plugin_update() ) {
185 - echo $fs->apply_filters( 'connect-header', sprintf(
186 - '<h2 style="text-align: center">%s</h2>',
187 - esc_html( fs_text_inline( 'Never miss an important update', 'connect-header' ) )
188 - ) );
189 - } else {
190 - echo $fs->apply_filters( 'connect-header_on-update', sprintf(
191 - '<h2>%s</h2>',
192 - sprintf(
193 - esc_html(
194 - /* translators: %1$s: plugin name (e.g., "Awesome Plugin"); %2$s: version (e.g., "1.2.3") */
195 - fs_text_inline('Thank you for updating to %1$s v%2$s!', 'connect-header_on-update' )
196 - ),
197 - esc_html( $fs->get_plugin_name() ),
198 - $fs->get_plugin_version()
199 - )
200 - ) );
201 - }
202 - }
203 - ?>
204 - <p><?php
205 - $button_label = fs_text_inline( 'Allow & Continue', 'opt-in-connect', $slug );
206 - $message = '';
207 -
208 - if ( $is_pending_activation ) {
209 - $button_label = fs_text_inline( 'Re-send activation email', 'resend-activation-email', $slug );
210 -
211 - $message = $fs->apply_filters( 'pending_activation_message', sprintf(
212 - /* translators: %s: name (e.g. Thanks John!) */
213 - fs_text_inline( 'Thanks %s!', 'thanks-x', $slug ) . '<br>' .
214 - 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 ),
215 - $first_name,
216 - '<b>' . $fs->get_plugin_name() . '</b>',
217 - '<b>' . $current_user->user_email . '</b>',
218 - fs_text_inline( 'complete the opt-in', 'complete-the-opt-in', $slug )
219 - ) );
220 - } else if ( $require_license_key ) {
221 - $button_label = fs_text_inline( 'Activate License', 'activate-license', $slug );
222 -
223 - $message = $fs->apply_filters(
224 - 'connect-message_on-premium',
225 - 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>' ),
226 - $first_name,
227 - $fs->get_plugin_name()
228 - );
229 - } else {
230 - $filter = 'connect_message';
231 -
232 - if ( ! $fs->is_plugin_update() ) {
233 - $default_optin_message = esc_html(
234 - sprintf(
235 - /* translators: %s: module type (plugin, theme, or add-on) */
236 - 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 ),
237 - $fs->get_module_label( true )
238 - )
239 - );
240 - } else {
241 - // If Freemius was added on a plugin update, set different
242 - // opt-in message.
243 -
244 - /* translators: %s: module type (plugin, theme, or add-on) */
245 - $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 ) ) );
246 -
247 - $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 ) );
248 -
249 - if ( $fs->is_enable_anonymous() ) {
250 - $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 ) );
251 - }
252 -
253 - // If user customized the opt-in message on update, use
254 - // that message. Otherwise, fallback to regular opt-in
255 - // custom message if exists.
256 - if ( $fs->has_filter( 'connect_message_on_update' ) ) {
257 - $filter = 'connect_message_on_update';
258 - }
259 - }
260 -
261 - $message = $fs->apply_filters(
262 - $filter,
263 - sprintf(
264 - $default_optin_message,
265 - '<b>' . esc_html( $fs->get_plugin_name() ) . '</b>',
266 - '<b>' . $current_user->user_login . '</b>',
267 - '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
268 - $freemius_link
269 - ),
270 - $first_name,
271 - $fs->get_plugin_name(),
272 - $current_user->user_login,
273 - '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
274 - $freemius_link,
275 - true
276 - );
277 - }
278 -
279 - if ( $is_network_upgrade_mode ) {
280 - $network_integration_text = esc_html( fs_text_inline( 'We\'re excited to introduce the Freemius network-level integration.', 'connect_message_network_upgrade', $slug ) );
281 -
282 - if ($is_premium_code){
283 - $message = $network_integration_text . ' ' . sprintf( fs_text_inline( 'During the update process we detected %d site(s) that are still pending license activation.', 'connect_message_network_upgrade-premium', $slug ), count( $sites ) );
284 -
285 - $message .= '<br><br>' . sprintf( fs_text_inline( 'If you\'d like to use the %s on those sites, please enter your license key below and click the activation button.', 'connect_message_network_upgrade-premium-activate-license', $slug ), $is_premium_only ? $fs->get_module_label( true ) : sprintf(
286 - /* translators: %s: module type (plugin, theme, or add-on) */
287 - fs_text_inline( "%s's paid features", 'x-paid-features', $slug ),
288 - $fs->get_module_label( true )
289 - ) );
290 -
291 - /* translators: %s: module type (plugin, theme, or add-on) */
292 - $message .= ' ' . sprintf( fs_text_inline( 'Alternatively, you can skip it for now and activate the license later, in your %s\'s network-level Account page.', 'connect_message_network_upgrade-premium-skip-license', $slug ), $fs->get_module_label( true ) );
293 - }else {
294 - $message = $network_integration_text . ' ' . sprintf( fs_text_inline( 'During the update process we detected %s site(s) in the network that are still pending your attention.', 'connect_message_network_upgrade-free', $slug ), count( $sites ) ) . '<br><br>' . ( fs_starts_with( $message, $hey_x_text . '<br>' ) ? substr( $message, strlen( $hey_x_text . '<br>' ) ) : $message );
295 - }
296 - }
297 -
298 - echo $message;
299 - ?></p>
300 - <?php if ( $require_license_key ) : ?>
301 - <div class="fs-license-key-container">
302 - <input id="fs_license_key" name="fs_key" type="text" required maxlength="<?php echo $fs->apply_filters('license_key_maxlength', 32) ?>"
303 - placeholder="<?php fs_esc_attr_echo_inline( 'License key', 'license-key', $slug ) ?>" tabindex="1"/>
304 - <i class="dashicons dashicons-admin-network"></i>
305 - <a class="show-license-resend-modal show-license-resend-modal-<?php echo $fs->get_unique_affix() ?>"
306 - href="#"><?php fs_esc_html_echo_inline( "Can't find your license key?", 'cant-find-license-key', $slug ); ?></a>
307 - </div>
308 -
309 - <?php
310 - /**
311 - * Allows developers to include custom HTML after the license input container.
312 - *
313 - * @author Vova Feldman
314 - * @since 2.1.2
315 - */
316 - $fs->do_action( 'connect/after_license_input', $activation_state );
317 - ?>
318 -
319 - <?php
320 - $send_updates_text = sprintf(
321 - '%s<span class="action-description"> - %s</span>',
322 - $fs->get_text_inline( 'Yes', 'yes' ),
323 - $fs->get_text_inline( 'send me security & feature updates, educational content and offers.', 'send-updates' )
324 - );
325 -
326 - $do_not_send_updates_text = sprintf(
327 - '%s<span class="action-description"> - %s</span>',
328 - $fs->get_text_inline( 'No', 'no' ),
329 - sprintf(
330 - $fs->get_text_inline( 'do %sNOT%s send me security & feature updates, educational content and offers.', 'do-not-send-updates' ),
331 - '<span class="underlined">',
332 - '</span>'
333 - )
334 - );
335 - ?>
336 - <div id="fs_marketing_optin">
337 - <span class="fs-message"><?php fs_echo_inline( "Please let us know if you'd like us to contact you for security & feature updates, educational content, and occasional offers:", 'contact-for-updates' ) ?></span>
338 - <div class="fs-input-container">
339 - <label>
340 - <input type="radio" name="allow-marketing" value="true" tabindex="1" />
341 - <span class="fs-input-label"><?php echo $send_updates_text ?></span>
342 - </label>
343 - <label>
344 - <input type="radio" name="allow-marketing" value="false" tabindex="1" />
345 - <span class="fs-input-label"><?php echo $do_not_send_updates_text ?></span>
346 - </label>
347 - </div>
348 - </div>
349 - <?php endif ?>
350 - <?php if ( $is_network_level_activation ) : ?>
351 - <?php
352 - $vars = array(
353 - 'id' => $fs->get_id(),
354 - 'sites' => $sites,
355 - 'require_license_key' => $require_license_key
356 - );
357 -
358 - echo fs_get_template( 'partials/network-activation.php', $vars );
359 - ?>
360 - <?php endif ?>
361 -
362 - <?php $fs->do_action( 'connect/after_message', $activation_state ) ?>
363 - </div>
364 - <div class="fs-actions">
365 - <?php $fs->do_action( 'connect/before_actions', $activation_state ) ?>
366 -
367 - <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ( ! $require_license_key || $is_network_upgrade_mode ) ) : ?>
368 - <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' ) ?>"
369 - class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?></a>
370 - <?php endif ?>
371 - <?php if ( $is_network_level_activation && $fs->apply_filters( 'show_delegation_option', true ) ) : ?>
372 - <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>
373 - <?php endif ?>
374 - <?php if ( $activate_with_current_user ) : ?>
375 - <form action="" method="POST">
376 - <input type="hidden" name="fs_action"
377 - value="<?php echo $fs->get_unique_affix() ?>_activate_existing">
378 - <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
379 - <input type="hidden" name="is_extensions_tracking_allowed" value="1">
380 - <input type="hidden" name="is_diagnostic_tracking_allowed" value="1">
381 - <button class="button button-primary" tabindex="1"
382 - type="submit"><?php echo esc_html( $button_label ) ?></button>
383 - </form>
384 - <?php else : ?>
385 - <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
386 - <?php unset( $optin_params['sites']); ?>
387 - <?php foreach ( $optin_params as $name => $value ) : ?>
388 - <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
389 - <?php endforeach ?>
390 - <input type="hidden" name="is_extensions_tracking_allowed" value="1">
391 - <input type="hidden" name="is_diagnostic_tracking_allowed" value="1">
392 - <button class="button button-primary" tabindex="1"
393 - type="submit"<?php if ( $require_license_key ) {
394 - echo ' disabled="disabled"';
395 - } ?>><?php echo esc_html( $button_label ) ?></button>
396 - </form>
397 - <?php endif ?>
398 - <?php if ( $require_license_key ) : ?>
399 - <a id="license_issues_link" href="<?php echo $fs->apply_filters( 'known_license_issues_url', 'https://freemius.com/help/documentation/wordpress-sdk/license-activation-issues/' ) ?>" target="_blank"><?php fs_esc_html_echo_inline( 'License issues?', 'license-issues', $slug ) ?></a>
400 - <?php endif ?>
401 -
402 - <?php $fs->do_action( 'connect/after_actions', $activation_state ) ?>
403 - </div><?php
404 - $permission_manager = FS_Permission_Manager::instance( $fs );
405 -
406 - // Set core permission list items.
407 - $permissions = array();
408 -
409 - // Add newsletter permissions if enabled.
410 - if ( $fs->is_permission_requested( 'newsletter' ) ) {
411 - $permissions[] = $permission_manager->get_newsletter_permission();
412 - }
413 -
414 - $permissions = $permission_manager->get_permissions(
415 - $require_license_key,
416 - $permissions
417 - );
418 -
419 - if ( ! empty( $permissions ) ) : ?>
420 - <div class="fs-permissions">
421 - <?php if ( $require_license_key ) : ?>
422 - <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php echo sprintf(
423 - 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>',
424 - sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', $fs->get_plugin_title() )
425 - ) ?></a>
426 - <?php else : ?>
427 - <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php printf(
428 - fs_esc_html_inline( 'This will allow %s to', 'this-will-allow-x', $slug ) . '<b class="fs-arrow"></b>',
429 - sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', $fs->get_plugin_title() )
430 - ) ?></a>
431 - <?php endif ?>
432 - <ul><?php
433 - foreach ( $permissions as $permission ) {
434 - $permission_manager->render_permission( $permission );
435 - }
436 - ?></ul>
437 - </div>
438 - <?php endif ?>
439 - <?php if ( $is_premium_code && $is_freemium ) : ?>
440 - <div class="fs-freemium-licensing">
441 - <p>
442 - <?php if ( $require_license_key ) : ?>
443 - <?php fs_esc_html_echo_inline( 'Don\'t have a license key?', 'dont-have-license-key', $slug ) ?>
444 - <a data-require-license="false" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate Free Version', 'activate-free-version', $slug ) ?></a>
445 - <?php else : ?>
446 - <?php fs_echo_inline( 'Have a license key?', 'have-license-key', $slug ) ?>
447 - <a data-require-license="true" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
448 - <?php endif ?>
449 - </p>
450 - </div>
451 - <?php endif ?>
452 - </div>
453 - <div class="fs-terms">
454 - <a class="fs-tooltip-trigger<?php echo is_rtl() ? ' rtl' : '' ?>" href="<?php echo $freemius_site_url ?>" target="_blank" rel="noopener" tabindex="1">Powered by Freemius<?php if ( $require_license_key ) : ?> <span class="fs-tooltip" style="width: 170px"><?php echo $fs->get_text_inline( 'Freemius is our licensing and software updates engine', 'permissions-extensions_desc' ) ?></span><?php endif ?></a>
455 - &nbsp;&nbsp;-&nbsp;&nbsp;
456 - <a href="https://freemius.com/privacy/" target="_blank" rel="noopener"
457 - tabindex="1"><?php fs_esc_html_echo_inline( 'Privacy Policy', 'privacy-policy', $slug ) ?></a>
458 - &nbsp;&nbsp;-&nbsp;&nbsp;
459 - <a href="<?php echo $require_license_key ? $freemius_plugin_terms_url : $freemius_usage_tracking_url ?>" target="_blank" rel="noopener" tabindex="1"><?php $require_license_key ? fs_echo_inline( 'License Agreement', 'license-agreement', $slug ) : fs_echo_inline( 'Terms of Service', 'tos', $slug ) ?></a>
460 - </div>
461 - </div>
462 - <?php
463 - /**
464 - * Allows developers to include custom HTML after the opt-in content.
465 - *
466 - * @author Vova Feldman
467 - * @since 2.3.2
468 - */
469 - $fs->do_action( 'connect/after', $activation_state );
470 -
471 - if ( $is_optin_dialog ) { ?>
472 -</div>
473 -<?php
474 - }
475 -?>
476 -<script type="text/javascript">
477 - (function ($) {
478 - var $html = $('html');
479 -
480 - <?php
481 - if ( $is_optin_dialog ) {
482 - if ( $show_close_button ) { ?>
483 - var $themeConnectWrapper = $('#fs_theme_connect_wrapper');
484 -
485 - $themeConnectWrapper.find('button.close').on('click', function () {
486 - <?php if ( ! empty( $previous_theme_activation_url ) ) { ?>
487 - location.href = '<?php echo html_entity_decode( $previous_theme_activation_url ); ?>';
488 - <?php } else { ?>
489 - $themeConnectWrapper.remove();
490 - $html.css({overflow: $html.attr('fs-optin-overflow')});
491 - <?php } ?>
492 - });
493 - <?php
494 - }
495 - ?>
496 -
497 - $html.attr('fs-optin-overflow', $html.css('overflow'));
498 - $html.css({overflow: 'hidden'});
499 -
500 - <?php
501 - }
502 - ?>
503 -
504 - var $primaryCta = $('.fs-actions .button.button-primary'),
505 - primaryCtaLabel = $primaryCta.html(),
506 - $form = $('.fs-actions form'),
507 - isNetworkActive = <?php echo $is_network_level_activation ? 'true' : 'false' ?>,
508 - requireLicenseKey = <?php echo $require_license_key ? 'true' : 'false' ?>,
509 - hasContextUser = <?php echo $activate_with_current_user ? 'true' : 'false' ?>,
510 - isNetworkUpgradeMode = <?php echo $is_network_upgrade_mode ? 'true' : 'false' ?>,
511 - $licenseSecret,
512 - $licenseKeyInput = $('#fs_license_key'),
513 - pauseCtaLabelUpdate = false,
514 - isNetworkDelegating = false,
515 - /**
516 - * @author Leo Fajardo (@leorw)
517 - * @since 2.1.0
518 - */
519 - resetLoadingMode = function() {
520 - // Reset loading mode.
521 - $primaryCta.html(primaryCtaLabel);
522 - $primaryCta.prop('disabled', false);
523 - $( '.fs-loading' ).removeClass( 'fs-loading' );
524 -
525 - console.log('resetLoadingMode - Primary button was enabled');
526 - },
527 - setLoadingMode = function () {
528 - $( document.body ).addClass( 'fs-loading' );
529 - };
530 -
531 - $('.fs-actions .button').on('click', function () {
532 - setLoadingMode();
533 -
534 - var $this = $(this);
535 -
536 - setTimeout(function () {
537 - if ( ! requireLicenseKey || ! $marketingOptin.hasClass( 'error' ) ) {
538 - $this.attr('disabled', 'disabled');
539 - }
540 - }, 200);
541 - });
542 -
543 - if ( isNetworkActive ) {
544 - var
545 - $multisiteOptionsContainer = $( '.fs-multisite-options-container' ),
546 - $allSitesOptions = $( '.fs-all-sites-options' ),
547 - $applyOnAllSites = $( '.fs-apply-on-all-sites-checkbox' ),
548 - $sitesListContainer = $( '.fs-sites-list-container' ),
549 - totalSites = <?php echo count( $sites ) ?>,
550 - maxSitesListHeight = null,
551 - $skipActivationButton = $( '#skip_activation' ),
552 - $delegateToSiteAdminsButton = $( '#delegate_to_site_admins' ),
553 - hasAnyInstall = <?php echo ! is_null( $fs->find_first_install() ) ? 'true' : 'false' ?>;
554 -
555 - $applyOnAllSites.click(function() {
556 - var isChecked = $( this ).is( ':checked' );
557 -
558 - if ( isChecked ) {
559 - $multisiteOptionsContainer.find( '.action' ).removeClass( 'selected' );
560 - updatePrimaryCtaText( 'allow' );
561 - }
562 -
563 - $multisiteOptionsContainer.find( '.action-allow' ).addClass( 'selected' );
564 -
565 - $skipActivationButton.toggle();
566 -
567 - $delegateToSiteAdminsButton.toggle();
568 -
569 - $multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', isChecked );
570 -
571 - $sitesListContainer.toggle( ! isChecked );
572 - if ( ! isChecked && null === maxSitesListHeight ) {
573 - /**
574 - * Set the visible number of rows to 5 (5 * height of the first row).
575 - *
576 - * @author Leo Fajardo (@leorw)
577 - */
578 - maxSitesListHeight = ( 5 * $sitesListContainer.find( 'tr:first' ).height() );
579 - $sitesListContainer.css( 'max-height', maxSitesListHeight );
580 - }
581 - });
582 -
583 - $allSitesOptions.find( '.action' ).click(function( evt ) {
584 - var actionType = $( evt.target ).data( 'action-type' );
585 -
586 - $multisiteOptionsContainer.find( '.action' ).removeClass( 'selected' );
587 - $multisiteOptionsContainer.find( '.action-' + actionType ).toggleClass( 'selected' );
588 -
589 - updatePrimaryCtaText( actionType );
590 - });
591 -
592 - $sitesListContainer.delegate( 'td:not(:first-child)', 'click', function() {
593 - // If a site row is clicked, trigger a click on the checkbox.
594 - $( this ).parent().find( 'td:first-child input' ).click();
595 - } );
596 -
597 - $sitesListContainer.delegate( '.action', 'click', function( evt ) {
598 - var $this = $( evt.target );
599 - if ( $this.hasClass( 'selected' ) ) {
600 - return false;
601 - }
602 -
603 - $this.parents( 'tr:first' ).find( '.action' ).removeClass( 'selected' );
604 - $this.toggleClass( 'selected' );
605 -
606 - var
607 - singleSiteActionType = $this.data( 'action-type' ),
608 - totalSelected = $sitesListContainer.find( '.action-' + singleSiteActionType + '.selected' ).length;
609 -
610 - $allSitesOptions.find( '.action.selected' ).removeClass( 'selected' );
611 -
612 - if ( totalSelected === totalSites ) {
613 - $allSitesOptions.find( '.action-' + singleSiteActionType ).addClass( 'selected' );
614 -
615 - updatePrimaryCtaText( singleSiteActionType );
616 - } else {
617 - updatePrimaryCtaText( 'mixed' );
618 - }
619 - });
620 -
621 - if ( isNetworkUpgradeMode || hasAnyInstall ) {
622 - $skipActivationButton.click(function(){
623 - $delegateToSiteAdminsButton.hide();
624 -
625 - $skipActivationButton.html('<?php fs_esc_js_echo_inline( 'Skipping, please wait', 'skipping-wait', $slug ) ?>...');
626 -
627 - pauseCtaLabelUpdate = true;
628 -
629 - // Check all sites to be skipped.
630 - $allSitesOptions.find('.action.action-skip').click();
631 -
632 - $form.submit();
633 -
634 - pauseCtaLabelUpdate = false;
635 -
636 - return false;
637 - });
638 -
639 - $delegateToSiteAdminsButton.click(function(){
640 - $delegateToSiteAdminsButton.html('<?php fs_esc_js_echo_inline( 'Delegating, please wait', 'delegating-wait', $slug ) ?>...');
641 -
642 - pauseCtaLabelUpdate = true;
643 -
644 - /**
645 - * Set to true so that the form submission handler can differentiate delegation from license
646 - * activation and the proper AJAX action will be used (when delegating, the action should be
647 - * `network_activate` and not `activate_license`).
648 - *
649 - * @author Leo Fajardo (@leorw)
650 - * @since 2.3.0
651 - */
652 - isNetworkDelegating = true;
653 -
654 - // Check all sites to be skipped.
655 - $allSitesOptions.find('.action.action-delegate').click();
656 -
657 - $form.submit();
658 -
659 - pauseCtaLabelUpdate = false;
660 -
661 - /**
662 - * Set to false so that in case the previous AJAX request has failed, the form submission handler
663 - * can differentiate license activation from delegation and the proper AJAX action will be used
664 - * (when activating a license, the action should be `activate_license` and not `network_activate`).
665 - *
666 - * @author Leo Fajardo (@leorw)
667 - * @since 2.3.0
668 - */
669 - isNetworkDelegating = false;
670 -
671 - return false;
672 - });
673 - }
674 - }
675 -
676 - /**
677 - * @author Leo Fajardo (@leorw)
678 - */
679 - function updatePrimaryCtaText( actionType ) {
680 - if (pauseCtaLabelUpdate)
681 - return;
682 -
683 - var text = '<?php fs_esc_js_echo_inline( 'Continue', 'continue', $slug ) ?>';
684 -
685 - switch ( actionType ) {
686 - case 'allow':
687 - text = '<?php fs_esc_js_echo_inline( 'Allow & Continue', 'opt-in-connect', $slug ) ?>';
688 - break;
689 - case 'delegate':
690 - text = '<?php fs_esc_js_echo_inline( 'Delegate to Site Admins & Continue', 'delegate-to-site-admins-and-continue', $slug ) ?>';
691 - break;
692 - case 'skip':
693 - text = '<?php fs_esc_js_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?>';
694 - break;
695 - }
696 -
697 - $primaryCta.html( text );
698 - }
699 -
700 - var ajaxOptin = ( requireLicenseKey || isNetworkActive );
701 -
702 - $form.on('submit', function () {
703 - var $extensionsPermission = $( '#fs_permission_extensions .fs-switch' ),
704 - isExtensionsTrackingAllowed = ( $extensionsPermission.length > 0 ) ?
705 - $extensionsPermission.hasClass( 'fs-on' ) :
706 - null;
707 -
708 - var $diagnosticPermission = $( '#fs_permission_diagnostic .fs-switch' ),
709 - isDiagnosticTrackingAllowed = ( $diagnosticPermission.length > 0 ) ?
710 - $diagnosticPermission.hasClass( 'fs-on' ) :
711 - null;
712 -
713 - if ( null === isExtensionsTrackingAllowed ) {
714 - $( 'input[name=is_extensions_tracking_allowed]' ).remove();
715 - } else {
716 - $( 'input[name=is_extensions_tracking_allowed]' ).val( isExtensionsTrackingAllowed ? 1 : 0 );
717 - }
718 -
719 - // 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.
720 - if ( null !== isDiagnosticTrackingAllowed ) {
721 - $( 'input[name=is_diagnostic_tracking_allowed]' ).val( isDiagnosticTrackingAllowed ? 1 : 0 );
722 - }
723 -
724 - /**
725 - * @author Vova Feldman (@svovaf)
726 - * @since 1.1.9
727 - */
728 - if ( ajaxOptin ) {
729 - if (!hasContextUser || isNetworkUpgradeMode) {
730 - var action = null,
731 - security = null;
732 -
733 - if ( requireLicenseKey && ! isNetworkDelegating ) {
734 - action = '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>';
735 - security = '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>';
736 - } else {
737 - action = '<?php echo $fs->get_ajax_action( 'network_activate' ) ?>';
738 - security = '<?php echo $fs->get_ajax_security( 'network_activate' ) ?>';
739 - }
740 -
741 - $('.fs-error').remove();
742 -
743 - var
744 - licenseKey = $licenseKeyInput.val(),
745 - data = {
746 - action : action,
747 - security : security,
748 - license_key: licenseKey,
749 - module_id : '<?php echo $fs->get_id() ?>'
750 - };
751 -
752 - if (
753 - requireLicenseKey &&
754 - ! isNetworkDelegating &&
755 - isMarketingAllowedByLicense.hasOwnProperty(licenseKey)
756 - ) {
757 - var
758 - isMarketingAllowed = null,
759 - $isMarketingAllowed = $marketingOptin.find( 'input[type="radio"][name="allow-marketing"]:checked');
760 -
761 -
762 - if ($isMarketingAllowed.length > 0)
763 - isMarketingAllowed = ('true' == $isMarketingAllowed.val());
764 -
765 - if ( null == isMarketingAllowedByLicense[ licenseKey ] &&
766 - null == isMarketingAllowed
767 - ) {
768 - $marketingOptin.addClass( 'error' ).show();
769 - resetLoadingMode();
770 - return false;
771 - } else if ( null == isMarketingAllowed ) {
772 - isMarketingAllowed = isMarketingAllowedByLicense[ licenseKey ];
773 - }
774 -
775 - data.is_marketing_allowed = isMarketingAllowed;
776 -
777 - data.is_extensions_tracking_allowed = isExtensionsTrackingAllowed;
778 -
779 - data.is_diagnostic_tracking_allowed = isDiagnosticTrackingAllowed;
780 - }
781 -
782 - $marketingOptin.removeClass( 'error' );
783 -
784 - if ( isNetworkActive ) {
785 - var
786 - sites = [],
787 - applyOnAllSites = $applyOnAllSites.is( ':checked' );
788 -
789 - $sitesListContainer.find( 'tr' ).each(function() {
790 - var
791 - $this = $( this ),
792 - includeSite = ( ! requireLicenseKey || applyOnAllSites || $this.find( 'input' ).is( ':checked' ) );
793 -
794 - if ( ! includeSite )
795 - return;
796 -
797 - var site = {
798 - uid : $this.find( '.uid' ).val(),
799 - url : $this.find( '.url' ).val(),
800 - title : $this.find( '.title' ).val(),
801 - language: $this.find( '.language' ).val(),
802 - blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
803 - };
804 -
805 - if ( ! requireLicenseKey) {
806 - site.action = $this.find('.action.selected').data('action-type');
807 - } else if ( isNetworkDelegating ) {
808 - site.action = 'delegate';
809 - }
810 -
811 - sites.push( site );
812 - });
813 -
814 - data.sites = sites;
815 -
816 - if ( hasAnyInstall ) {
817 - data.has_any_install = hasAnyInstall;
818 - }
819 - }
820 -
821 - /**
822 - * Use the AJAX opt-in when license key is required to potentially
823 - * process the after install failure hook.
824 - *
825 - * @author Vova Feldman (@svovaf)
826 - * @since 1.2.1.5
827 - */
828 - $.ajax({
829 - url : <?php echo Freemius::ajax_url() ?>,
830 - method : 'POST',
831 - data : data,
832 - success: function (result) {
833 - var resultObj = $.parseJSON(result);
834 - if (resultObj.success) {
835 - // Redirect to the "Account" page and sync the license.
836 - window.location.href = resultObj.next_page;
837 - } else {
838 - resetLoadingMode();
839 -
840 - // Show error.
841 - $('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>');
842 - }
843 - },
844 - error: function () {
845 - resetLoadingMode();
846 - }
847 - });
848 -
849 - return false;
850 - }
851 - else {
852 - if (null == $licenseSecret) {
853 - $licenseSecret = $('<input type="hidden" name="license_secret_key" value="" />');
854 - $form.append($licenseSecret);
855 - }
856 -
857 - // Update secret key if premium only plugin.
858 - $licenseSecret.val($licenseKeyInput.val());
859 - }
860 - }
861 -
862 - return true;
863 - });
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 -
874 - $primaryCta.on('click', function () {
875 - console.log('Primary button was clicked');
876 -
877 - $(this).addClass('fs-loading');
878 - $(this).html('<?php echo esc_js( $is_pending_activation ?
879 - fs_text_x_inline( 'Sending email', 'as in the process of sending an email', 'sending-email', $slug ) :
880 - fs_text_x_inline( 'Activating', 'as activating plugin', 'activating', $slug )
881 - ) ?>...');
882 - });
883 -
884 - $('.fs-permissions .fs-trigger').on('click', function () {
885 - $('.fs-permissions').toggleClass('fs-open');
886 -
887 - return false;
888 - });
889 -
890 - if (requireLicenseKey) {
891 - /**
892 - * Submit license key on enter.
893 - *
894 - * @author Vova Feldman (@svovaf)
895 - * @since 1.1.9
896 - */
897 - $licenseKeyInput.keypress(function (e) {
898 - if (e.which == 13) {
899 - if ('' !== $(this).val()) {
900 - $primaryCta.click();
901 - return false;
902 - }
903 - }
904 - });
905 -
906 - /**
907 - * Disable activation button when empty license key.
908 - *
909 - * @author Vova Feldman (@svovaf)
910 - * @since 1.1.9
911 - */
912 - $licenseKeyInput.on('keyup paste delete cut', function () {
913 - setTimeout(function () {
914 - var key = $licenseKeyInput.val();
915 -
916 - if (key == previousLicenseKey){
917 - return;
918 - }
919 -
920 - if ('' === key) {
921 - $primaryCta.attr('disabled', 'disabled');
922 - $marketingOptin.hide();
923 - } else {
924 - $primaryCta.prop('disabled', false);
925 -
926 - if (32 <= key.length){
927 - fetchIsMarketingAllowedFlagAndToggleOptin();
928 - } else {
929 - $marketingOptin.hide();
930 - }
931 - }
932 -
933 - previousLicenseKey = key;
934 - }, 100);
935 - }).focus();
936 - }
937 -
938 - /**
939 - * Set license mode trigger URL.
940 - *
941 - * @author Vova Feldman (@svovaf)
942 - * @since 1.1.9
943 - */
944 - var
945 - $connectLicenseModeTrigger = $('#fs_connect .fs-freemium-licensing a'),
946 - href = window.location.href;
947 -
948 - if (href.indexOf('?') > 0) {
949 - href += '&';
950 - } else {
951 - href += '?';
952 - }
953 -
954 - if ($connectLicenseModeTrigger.length > 0) {
955 - $connectLicenseModeTrigger.attr(
956 - 'href',
957 - href + 'require_license=' + $connectLicenseModeTrigger.attr('data-require-license')
958 - );
959 - }
960 -
961 - //--------------------------------------------------------------------------------
962 - //region GDPR
963 - //--------------------------------------------------------------------------------
964 - var isMarketingAllowedByLicense = {},
965 - $marketingOptin = $('#fs_marketing_optin'),
966 - previousLicenseKey = null;
967 -
968 - if (requireLicenseKey) {
969 -
970 - var
971 - afterMarketingFlagLoaded = function () {
972 - var licenseKey = $licenseKeyInput.val();
973 -
974 - if (null == isMarketingAllowedByLicense[licenseKey]) {
975 - $marketingOptin.show();
976 -
977 - if ($marketingOptin.find('input[type=radio]:checked').length > 0){
978 - // Focus on button if GDPR opt-in already selected is already selected.
979 - $primaryCta.focus();
980 - } else {
981 - // Focus on the GDPR opt-in radio button.
982 - $($marketingOptin.find('input[type=radio]')[0]).focus();
983 - }
984 - } else {
985 - $marketingOptin.hide();
986 - $primaryCta.focus();
987 - }
988 - },
989 - /**
990 - * @author Leo Fajardo (@leorw)
991 - * @since 2.1.0
992 - */
993 - fetchIsMarketingAllowedFlagAndToggleOptin = function () {
994 - var licenseKey = $licenseKeyInput.val();
995 -
996 - if (licenseKey.length < 32) {
997 - $marketingOptin.hide();
998 - return;
999 - }
1000 -
1001 - if (isMarketingAllowedByLicense.hasOwnProperty(licenseKey)) {
1002 - afterMarketingFlagLoaded();
1003 - return;
1004 - }
1005 -
1006 - $marketingOptin.hide();
1007 -
1008 - setLoadingMode();
1009 -
1010 - $primaryCta.addClass('fs-loading');
1011 - $primaryCta.attr('disabled', 'disabled');
1012 - $primaryCta.html('<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...');
1013 -
1014 - $.ajax({
1015 - url : <?php echo Freemius::ajax_url() ?>,
1016 - method : 'POST',
1017 - data : {
1018 - action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>',
1019 - security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>',
1020 - license_key: licenseKey,
1021 - module_id : '<?php echo $fs->get_id() ?>'
1022 - },
1023 - success: function (result) {
1024 - resetLoadingMode();
1025 -
1026 - if (result.success) {
1027 - result = result.data;
1028 -
1029 - // Cache result.
1030 - isMarketingAllowedByLicense[licenseKey] = result.is_marketing_allowed;
1031 - }
1032 -
1033 - afterMarketingFlagLoaded();
1034 - }
1035 - });
1036 - };
1037 -
1038 - $marketingOptin.find( 'input' ).click(function() {
1039 - $marketingOptin.removeClass( 'error' );
1040 - });
1041 - }
1042 -
1043 - //endregion
1044 - })(jQuery);
1045 -</script>
1046 -<?php
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 + * @var array $VARS
15 + * @var Freemius $fs
16 + */
17 + $fs = freemius( $VARS['id'] );
18 + $slug = $fs->get_slug();
19 +
20 + $is_pending_activation = $fs->is_pending_activation();
21 + $is_premium_only = $fs->is_only_premium();
22 + $has_paid_plans = $fs->has_paid_plan();
23 + $is_premium_code = $fs->is_premium();
24 + $is_freemium = $fs->is_freemium();
25 +
26 + $fs->_enqueue_connect_essentials();
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 +
37 + $current_user = Freemius::_get_current_wp_user();
38 +
39 + $first_name = $current_user->user_firstname;
40 + if ( empty( $first_name ) ) {
41 + $first_name = $current_user->nickname;
42 + }
43 +
44 + $site_url = Freemius::get_unfiltered_site_url();
45 + $protocol_pos = strpos( $site_url, '://' );
46 + if ( false !== $protocol_pos ) {
47 + $site_url = substr( $site_url, $protocol_pos + 3 );
48 + }
49 +
50 + $freemius_usage_tracking_url = $fs->get_usage_tracking_terms_url();
51 + $freemius_plugin_terms_url = $fs->get_eula_url();
52 +
53 + $error = fs_request_get( 'error' );
54 +
55 + $has_release_on_freemius = $fs->has_release_on_freemius();
56 +
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 + );
63 +
64 + $freemius_activation_terms_url = ($fs->is_premium() && $require_license_key) ?
65 + $fs->get_license_activation_terms_url() :
66 + $freemius_usage_tracking_url;
67 +
68 + $freemius_activation_terms_html = '<a href="' . esc_url( $freemius_activation_terms_url ) . '" target="_blank" rel="noopener" tabindex="1">freemius.com</a>';
69 +
70 + if ( $is_pending_activation ) {
71 + $require_license_key = false;
72 + }
73 +
74 + if ( $require_license_key ) {
75 + $fs->_add_license_activation_dialog_box();
76 + }
77 +
78 + $is_optin_dialog = (
79 + $fs->is_theme() &&
80 + $fs->is_themes_page() &&
81 + $fs->show_opt_in_on_themes_page()
82 + );
83 +
84 + if ( $is_optin_dialog ) {
85 + $show_close_button = false;
86 + $previous_theme_activation_url = '';
87 +
88 + if ( ! $is_premium_code ) {
89 + $show_close_button = true;
90 + } else if ( $is_premium_only ) {
91 + $previous_theme_activation_url = $fs->get_previous_theme_activation_url();
92 + $show_close_button = ( ! empty( $previous_theme_activation_url ) );
93 + }
94 + }
95 +
96 + $is_network_level_activation = (
97 + fs_is_network_admin() &&
98 + $fs->is_network_active() &&
99 + ! $fs->is_network_delegated_connection()
100 + );
101 +
102 + $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
103 +
104 + $activate_with_current_user = (
105 + is_object( $fs_user ) &&
106 + ! $is_pending_activation &&
107 + // If requires a license for activation, use the user associated with the license for the opt-in.
108 + ! $require_license_key &&
109 + ! $is_network_level_activation
110 + );
111 +
112 + $optin_params = $fs->get_opt_in_params( array(), $is_network_level_activation );
113 + $sites = isset( $optin_params['sites'] ) ? $optin_params['sites'] : array();
114 +
115 + $is_network_upgrade_mode = ( fs_is_network_admin() && $fs->is_network_upgrade_mode() );
116 +
117 + /* translators: %s: name (e.g. Hey John,) */
118 + $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $first_name ) );
119 +
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 + );
127 +?>
128 +<?php
129 + if ( $is_optin_dialog ) { ?>
130 +<div id="fs_theme_connect_wrapper">
131 + <?php
132 + if ( $show_close_button ) { ?>
133 + <button class="close dashicons dashicons-no"><span class="screen-reader-text">Close connect dialog</span>
134 + </button>
135 + <?php
136 + }
137 + ?>
138 + <?php
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 );
148 + ?>
149 + <div id="fs_connect"
150 + class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) ) {
151 + echo ' fs-anonymous-disabled';
152 + } ?><?php echo $require_license_key ? ' require-license-key' : '' ?>">
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">
166 + <div class="fs-content">
167 + <?php $fs->do_action( 'connect/before_message', $activation_state ) ?>
168 +
169 + <?php if ( ! empty( $error ) ) : ?>
170 + <div class="fs-error"><?php echo $fs->apply_filters( 'connect_error_esc_html', esc_html( $error ) ) ?></div>
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 + ?>
194 + <p><?php
195 + $button_label = fs_text_inline( 'Allow & Continue', 'opt-in-connect', $slug );
196 + $message = '';
197 +
198 + if ( $is_pending_activation ) {
199 + $button_label = fs_text_inline( 'Re-send activation email', 'resend-activation-email', $slug );
200 +
201 + $message = $fs->apply_filters( 'pending_activation_message', sprintf(
202 + /* translators: %s: name (e.g. Thanks John!) */
203 + fs_text_inline( 'Thanks %s!', 'thanks-x', $slug ) . '<br>' .
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 ),
205 + $first_name,
206 + '<b>' . $fs->get_plugin_name() . '</b>',
207 + '<b>' . $current_user->user_email . '</b>',
208 + fs_text_inline( 'complete the opt-in', 'complete-the-opt-in', $slug )
209 + ) );
210 + } else if ( $require_license_key ) {
211 + $button_label = fs_text_inline( 'Activate License', 'activate-license', $slug );
212 +
213 + $message = $fs->apply_filters(
214 + 'connect-message_on-premium',
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>' ),
216 + $first_name,
217 + $fs->get_plugin_name()
218 + );
219 + } else {
220 + $filter = 'connect_message';
221 +
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 {
231 + // If Freemius was added on a plugin update, set different
232 + // opt-in message.
233 +
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
244 + // that message. Otherwise, fallback to regular opt-in
245 + // custom message if exists.
246 + if ( $fs->has_filter( 'connect_message_on_update' ) ) {
247 + $filter = 'connect_message_on_update';
248 + }
249 + }
250 +
251 + $message = $fs->apply_filters(
252 + $filter,
253 + sprintf(
254 + $default_optin_message,
255 + '<b>' . esc_html( $fs->get_plugin_name() ) . '</b>',
256 + '<b>' . $current_user->user_login . '</b>',
257 + '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
258 + $freemius_activation_terms_html
259 + ),
260 + $first_name,
261 + $fs->get_plugin_name(),
262 + $current_user->user_login,
263 + '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>',
264 + $freemius_activation_terms_html,
265 + true
266 + );
267 + }
268 +
269 + if ( $is_network_upgrade_mode ) {
270 + $network_integration_text = esc_html( fs_text_inline( 'We\'re excited to introduce the Freemius network-level integration.', 'connect_message_network_upgrade', $slug ) );
271 +
272 + if ($is_premium_code){
273 + $message = $network_integration_text . ' ' . sprintf( fs_text_inline( 'During the update process we detected %d site(s) that are still pending license activation.', 'connect_message_network_upgrade-premium', $slug ), count( $sites ) );
274 +
275 + $message .= '<br><br>' . sprintf( fs_text_inline( 'If you\'d like to use the %s on those sites, please enter your license key below and click the activation button.', 'connect_message_network_upgrade-premium-activate-license', $slug ), $is_premium_only ? $fs->get_module_label( true ) : sprintf(
276 + /* translators: %s: module type (plugin, theme, or add-on) */
277 + fs_text_inline( "%s's paid features", 'x-paid-features', $slug ),
278 + $fs->get_module_label( true )
279 + ) );
280 +
281 + /* translators: %s: module type (plugin, theme, or add-on) */
282 + $message .= ' ' . sprintf( fs_text_inline( 'Alternatively, you can skip it for now and activate the license later, in your %s\'s network-level Account page.', 'connect_message_network_upgrade-premium-skip-license', $slug ), $fs->get_module_label( true ) );
283 + }else {
284 + $message = $network_integration_text . ' ' . sprintf( fs_text_inline( 'During the update process we detected %s site(s) in the network that are still pending your attention.', 'connect_message_network_upgrade-free', $slug ), count( $sites ) ) . '<br><br>' . ( fs_starts_with( $message, $hey_x_text . '<br>' ) ? substr( $message, strlen( $hey_x_text . '<br>' ) ) : $message );
285 + }
286 + }
287 +
288 + echo $message;
289 + ?></p>
290 + <?php if ( $require_license_key ) : ?>
291 + <div class="fs-license-key-container">
292 + <input id="fs_license_key" name="fs_key" type="text" required maxlength="<?php echo $fs->apply_filters('license_key_maxlength', 32) ?>"
293 + placeholder="<?php fs_esc_attr_echo_inline( 'License key', 'license-key', $slug ) ?>" tabindex="1"/>
294 + <i class="dashicons dashicons-admin-network"></i>
295 + <a class="show-license-resend-modal show-license-resend-modal-<?php echo $fs->get_unique_affix() ?>"
296 + href="#"><?php fs_esc_html_echo_inline( "Can't find your license key?", 'cant-find-license-key', $slug ); ?></a>
297 + </div>
298 +
299 + <?php
300 + /**
301 + * Allows developers to include custom HTML after the license input container.
302 + *
303 + * @author Vova Feldman
304 + * @since 2.1.2
305 + */
306 + $fs->do_action( 'connect/after_license_input', $activation_state );
307 + ?>
308 +
309 + <?php
310 + $send_updates_text = sprintf(
311 + '%s<span class="action-description"> - %s</span>',
312 + $fs->get_text_inline( 'Yes', 'yes' ),
313 + $fs->get_text_inline( 'send me security & feature updates, educational content and offers.', 'send-updates' )
314 + );
315 +
316 + $do_not_send_updates_text = sprintf(
317 + '%s<span class="action-description"> - %s</span>',
318 + $fs->get_text_inline( 'No', 'no' ),
319 + sprintf(
320 + $fs->get_text_inline( 'do %sNOT%s send me security & feature updates, educational content and offers.', 'do-not-send-updates' ),
321 + '<span class="underlined">',
322 + '</span>'
323 + )
324 + );
325 + ?>
326 + <div id="fs_marketing_optin">
327 + <span class="fs-message"><?php fs_echo_inline( "Please let us know if you'd like us to contact you for security & feature updates, educational content, and occasional offers:", 'contact-for-updates' ) ?></span>
328 + <div class="fs-input-container">
329 + <label>
330 + <input type="radio" name="allow-marketing" value="true" tabindex="1" />
331 + <span class="fs-input-label"><?php echo $send_updates_text ?></span>
332 + </label>
333 + <label>
334 + <input type="radio" name="allow-marketing" value="false" tabindex="1" />
335 + <span class="fs-input-label"><?php echo $do_not_send_updates_text ?></span>
336 + </label>
337 + </div>
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>
342 + <?php endif ?>
343 + <?php if ( $is_network_level_activation ) : ?>
344 + <?php
345 + $vars = array(
346 + 'id' => $fs->get_id(),
347 + 'sites' => $sites,
348 + 'require_license_key' => $require_license_key
349 + );
350 +
351 + echo fs_get_template( 'partials/network-activation.php', $vars );
352 + ?>
353 + <?php endif ?>
354 +
355 + <?php $fs->do_action( 'connect/after_message', $activation_state ) ?>
356 + </div>
357 + <div class="fs-actions">
358 + <?php $fs->do_action( 'connect/before_actions', $activation_state ) ?>
359 +
360 + <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ( ! $require_license_key || $is_network_upgrade_mode ) ) : ?>
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' ) ?>"
362 + class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?></a>
363 + <?php endif ?>
364 + <?php if ( $is_network_level_activation && $fs->apply_filters( 'show_delegation_option', true ) ) : ?>
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>
366 + <?php endif ?>
367 + <?php if ( $activate_with_current_user ) : ?>
368 + <form action="" method="POST">
369 + <input type="hidden" name="fs_action"
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">
374 + <button class="button button-primary" tabindex="1"
375 + type="submit"><?php echo esc_html( $button_label ) ?></button>
376 + </form>
377 + <?php else : ?>
378 + <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
379 + <?php unset( $optin_params['sites']); ?>
380 + <?php foreach ( $optin_params as $name => $value ) : ?>
381 + <input type="hidden" name="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $value ) ?>">
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">
385 + <button class="button button-primary" tabindex="1"
386 + type="submit"<?php if ( $require_license_key ) {
387 + echo ' disabled="disabled"';
388 + } ?>><?php echo esc_html( $button_label ) ?></button>
389 + </form>
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 ) ?>
398 + </div><?php
399 + $permission_manager = FS_Permission_Manager::instance( $fs );
400 +
401 + // Set core permission list items.
402 + $permissions = array();
403 +
404 + // Add newsletter permissions if enabled.
405 + if ( $fs->is_permission_requested( 'newsletter' ) ) {
406 + $permissions[] = $permission_manager->get_newsletter_permission();
407 + }
408 +
409 + $permissions = $permission_manager->get_permissions(
410 + $require_license_key,
411 + $permissions
412 + );
413 +
414 + if ( ! empty( $permissions ) ) : ?>
415 + <div class="fs-permissions">
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 ?>
427 + <ul><?php
428 + foreach ( $permissions as $permission ) {
429 + $permission_manager->render_permission( $permission );
430 + }
431 + ?></ul>
432 + </div>
433 + <?php endif ?>
434 + <?php if ( $is_premium_code && $is_freemium ) : ?>
435 + <div class="fs-freemium-licensing">
436 + <p>
437 + <?php if ( $require_license_key ) : ?>
438 + <?php fs_esc_html_echo_inline( 'Don\'t have a license key?', 'dont-have-license-key', $slug ) ?>
439 + <a data-require-license="false" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate Free Version', 'activate-free-version', $slug ) ?></a>
440 + <?php else : ?>
441 + <?php fs_echo_inline( 'Have a license key?', 'have-license-key', $slug ) ?>
442 + <a data-require-license="true" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
443 + <?php endif ?>
444 + </p>
445 + </div>
446 + <?php endif ?>
447 + </div>
448 + <div class="fs-terms">
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"
452 + tabindex="1"><?php fs_esc_html_echo_inline( 'Privacy Policy', 'privacy-policy', $slug ) ?></a>
453 + &nbsp;&nbsp;-&nbsp;&nbsp;
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; ?>
459 + </div>
460 + </div>
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 +
470 + if ( $is_optin_dialog ) { ?>
471 +</div>
472 +<?php
473 + }
474 +?>
475 +<script type="text/javascript">
476 + (function ($) {
477 + var $html = $('html');
478 +
479 + <?php
480 + if ( $is_optin_dialog ) {
481 + if ( $show_close_button ) { ?>
482 + var $themeConnectWrapper = $('#fs_theme_connect_wrapper');
483 +
484 + $themeConnectWrapper.find('button.close').on('click', function () {
485 + <?php if ( ! empty( $previous_theme_activation_url ) ) { ?>
486 + location.href = '<?php echo html_entity_decode( $previous_theme_activation_url ); ?>';
487 + <?php } else { ?>
488 + $themeConnectWrapper.remove();
489 + $html.css({overflow: $html.attr('fs-optin-overflow')});
490 + <?php } ?>
491 + });
492 + <?php
493 + }
494 + ?>
495 +
496 + $html.attr('fs-optin-overflow', $html.css('overflow'));
497 + $html.css({overflow: 'hidden'});
498 +
499 + <?php
500 + }
501 + ?>
502 +
503 + var $primaryCta = $('.fs-actions .button.button-primary'),
504 + primaryCtaLabel = $primaryCta.html(),
505 + $form = $('.fs-actions form'),
506 + isNetworkActive = <?php echo $is_network_level_activation ? 'true' : 'false' ?>,
507 + requireLicenseKey = <?php echo $require_license_key ? 'true' : 'false' ?>,
508 + hasContextUser = <?php echo $activate_with_current_user ? 'true' : 'false' ?>,
509 + isNetworkUpgradeMode = <?php echo $is_network_upgrade_mode ? 'true' : 'false' ?>,
510 + $licenseSecret,
511 + $licenseKeyInput = $('#fs_license_key'),
512 + pauseCtaLabelUpdate = false,
513 + isNetworkDelegating = false,
514 + /**
515 + * @author Leo Fajardo (@leorw)
516 + * @since 2.1.0
517 + */
518 + resetLoadingMode = function() {
519 + // Reset loading mode.
520 + $primaryCta.html(primaryCtaLabel);
521 + $primaryCta.prop('disabled', false);
522 + $( '.fs-loading' ).removeClass( 'fs-loading' );
523 +
524 + console.log('resetLoadingMode - Primary button was enabled');
525 + },
526 + setLoadingMode = function () {
527 + $( document.body ).addClass( 'fs-loading' );
528 + };
529 +
530 + $('.fs-actions .button').on('click', function () {
531 + setLoadingMode();
532 +
533 + var $this = $(this);
534 +
535 + setTimeout(function () {
536 + if ( ! requireLicenseKey || ! $marketingOptin.hasClass( 'error' ) ) {
537 + $this.attr('disabled', 'disabled');
538 + }
539 + }, 200);
540 + });
541 +
542 + if ( isNetworkActive ) {
543 + var
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' ),
548 + totalSites = <?php echo count( $sites ) ?>,
549 + maxSitesListHeight = null,
550 + $skipActivationButton = $( '#skip_activation' ),
551 + $delegateToSiteAdminsButton = $( '#delegate_to_site_admins' ),
552 + hasAnyInstall = <?php echo ! is_null( $fs->find_first_install() ) ? 'true' : 'false' ?>;
553 +
554 + $applyOnAllSites.click(function() {
555 + var isChecked = $( this ).is( ':checked' );
556 +
557 + if ( isChecked ) {
558 + $multisiteOptionsContainer.find( '.action' ).removeClass( 'selected' );
559 + updatePrimaryCtaText( 'allow' );
560 + }
561 +
562 + $multisiteOptionsContainer.find( '.action-allow' ).addClass( 'selected' );
563 +
564 + $skipActivationButton.toggle();
565 +
566 + $delegateToSiteAdminsButton.toggle();
567 +
568 + $multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', isChecked );
569 +
570 + $sitesListContainer.toggle( ! isChecked );
571 + if ( ! isChecked && null === maxSitesListHeight ) {
572 + /**
573 + * Set the visible number of rows to 5 (5 * height of the first row).
574 + *
575 + * @author Leo Fajardo (@leorw)
576 + */
577 + maxSitesListHeight = ( 5 * $sitesListContainer.find( 'tr:first' ).height() );
578 + $sitesListContainer.css( 'max-height', maxSitesListHeight );
579 + }
580 + });
581 +
582 + $allSitesOptions.find( '.action' ).click(function( evt ) {
583 + var actionType = $( evt.target ).data( 'action-type' );
584 +
585 + $multisiteOptionsContainer.find( '.action' ).removeClass( 'selected' );
586 + $multisiteOptionsContainer.find( '.action-' + actionType ).toggleClass( 'selected' );
587 +
588 + updatePrimaryCtaText( actionType );
589 + });
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 +
596 + $sitesListContainer.delegate( '.action', 'click', function( evt ) {
597 + var $this = $( evt.target );
598 + if ( $this.hasClass( 'selected' ) ) {
599 + return false;
600 + }
601 +
602 + $this.parents( 'tr:first' ).find( '.action' ).removeClass( 'selected' );
603 + $this.toggleClass( 'selected' );
604 +
605 + var
606 + singleSiteActionType = $this.data( 'action-type' ),
607 + totalSelected = $sitesListContainer.find( '.action-' + singleSiteActionType + '.selected' ).length;
608 +
609 + $allSitesOptions.find( '.action.selected' ).removeClass( 'selected' );
610 +
611 + if ( totalSelected === totalSites ) {
612 + $allSitesOptions.find( '.action-' + singleSiteActionType ).addClass( 'selected' );
613 +
614 + updatePrimaryCtaText( singleSiteActionType );
615 + } else {
616 + updatePrimaryCtaText( 'mixed' );
617 + }
618 + });
619 +
620 + if ( isNetworkUpgradeMode || hasAnyInstall ) {
621 + $skipActivationButton.click(function(){
622 + $delegateToSiteAdminsButton.hide();
623 +
624 + $skipActivationButton.html('<?php fs_esc_js_echo_inline( 'Skipping, please wait', 'skipping-wait', $slug ) ?>...');
625 +
626 + pauseCtaLabelUpdate = true;
627 +
628 + // Check all sites to be skipped.
629 + $allSitesOptions.find('.action.action-skip').click();
630 +
631 + $form.submit();
632 +
633 + pauseCtaLabelUpdate = false;
634 +
635 + return false;
636 + });
637 +
638 + $delegateToSiteAdminsButton.click(function(){
639 + $delegateToSiteAdminsButton.html('<?php fs_esc_js_echo_inline( 'Delegating, please wait', 'delegating-wait', $slug ) ?>...');
640 +
641 + pauseCtaLabelUpdate = true;
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 +
653 + // Check all sites to be skipped.
654 + $allSitesOptions.find('.action.action-delegate').click();
655 +
656 + $form.submit();
657 +
658 + pauseCtaLabelUpdate = false;
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 +
670 + return false;
671 + });
672 + }
673 + }
674 +
675 + /**
676 + * @author Leo Fajardo (@leorw)
677 + */
678 + function updatePrimaryCtaText( actionType ) {
679 + if (pauseCtaLabelUpdate)
680 + return;
681 +
682 + var text = '<?php fs_esc_js_echo_inline( 'Continue', 'continue', $slug ) ?>';
683 +
684 + switch ( actionType ) {
685 + case 'allow':
686 + text = '<?php fs_esc_js_echo_inline( 'Allow & Continue', 'opt-in-connect', $slug ) ?>';
687 + break;
688 + case 'delegate':
689 + text = '<?php fs_esc_js_echo_inline( 'Delegate to Site Admins & Continue', 'delegate-to-site-admins-and-continue', $slug ) ?>';
690 + break;
691 + case 'skip':
692 + text = '<?php fs_esc_js_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?>';
693 + break;
694 + }
695 +
696 + $primaryCta.html( text );
697 + }
698 +
699 + var ajaxOptin = ( requireLicenseKey || isNetworkActive );
700 +
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 +
723 + /**
724 + * @author Vova Feldman (@svovaf)
725 + * @since 1.1.9
726 + */
727 + if ( ajaxOptin ) {
728 + if (!hasContextUser || isNetworkUpgradeMode) {
729 + var action = null,
730 + security = null;
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 +
740 + $('.fs-error').remove();
741 +
742 + var
743 + licenseKey = $licenseKeyInput.val(),
744 + data = {
745 + action : action,
746 + security : security,
747 + license_key : licenseKey,
748 + module_id : '<?php echo $fs->get_id() ?>',
749 + license_owner_id: licenseOwnerIDByLicense[ licenseKey ]
750 + };
751 +
752 + if (
753 + requireLicenseKey &&
754 + ! isNetworkDelegating &&
755 + isMarketingAllowedByLicense.hasOwnProperty(licenseKey)
756 + ) {
757 + var
758 + isMarketingAllowed = null,
759 + $isMarketingAllowed = $marketingOptin.find( 'input[type="radio"][name="allow-marketing"]:checked');
760 +
761 +
762 + if ($isMarketingAllowed.length > 0)
763 + isMarketingAllowed = ('true' == $isMarketingAllowed.val());
764 +
765 + if ( null == isMarketingAllowedByLicense[ licenseKey ] &&
766 + null == isMarketingAllowed
767 + ) {
768 + $marketingOptin.addClass( 'error' ).show();
769 + resetLoadingMode();
770 + return false;
771 + } else if ( null == isMarketingAllowed ) {
772 + isMarketingAllowed = isMarketingAllowedByLicense[ licenseKey ];
773 + }
774 +
775 + data.is_marketing_allowed = isMarketingAllowed;
776 +
777 + data.is_extensions_tracking_allowed = isExtensionsTrackingAllowed;
778 +
779 + data.is_diagnostic_tracking_allowed = isDiagnosticTrackingAllowed;
780 + }
781 +
782 + $marketingOptin.removeClass( 'error' );
783 +
784 + if ( isNetworkActive ) {
785 + var
786 + sites = [],
787 + applyOnAllSites = $applyOnAllSites.is( ':checked' );
788 +
789 + $sitesListContainer.find( 'tr' ).each(function() {
790 + var
791 + $this = $( this ),
792 + includeSite = ( ! requireLicenseKey || applyOnAllSites || $this.find( 'input' ).is( ':checked' ) );
793 +
794 + if ( ! includeSite )
795 + return;
796 +
797 + var site = {
798 + uid : $this.find( '.uid' ).val(),
799 + url : $this.find( '.url' ).val(),
800 + title : $this.find( '.title' ).val(),
801 + language: $this.find( '.language' ).val(),
802 + blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
803 + };
804 +
805 + if ( ! requireLicenseKey) {
806 + site.action = $this.find('.action.selected').data('action-type');
807 + } else if ( isNetworkDelegating ) {
808 + site.action = 'delegate';
809 + }
810 +
811 + sites.push( site );
812 + });
813 +
814 + data.sites = sites;
815 +
816 + if ( hasAnyInstall ) {
817 + data.has_any_install = hasAnyInstall;
818 + }
819 + }
820 +
821 + /**
822 + * Use the AJAX opt-in when license key is required to potentially
823 + * process the after install failure hook.
824 + *
825 + * @author Vova Feldman (@svovaf)
826 + * @since 1.2.1.5
827 + */
828 + $.ajax({
829 + url : <?php echo Freemius::ajax_url() ?>,
830 + method : 'POST',
831 + data : data,
832 + success: function (result) {
833 + var resultObj = $.parseJSON(result);
834 + if (resultObj.success) {
835 + // Redirect to the "Account" page and sync the license.
836 + window.location.href = resultObj.next_page;
837 + } else {
838 + resetLoadingMode();
839 +
840 + // Show error.
841 + $('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>');
842 + }
843 + },
844 + error: function () {
845 + resetLoadingMode();
846 + }
847 + });
848 +
849 + return false;
850 + }
851 + else {
852 + if (null == $licenseSecret) {
853 + $licenseSecret = $('<input type="hidden" name="license_secret_key" value="" />');
854 + $form.append($licenseSecret);
855 + }
856 +
857 + // Update secret key if premium only plugin.
858 + $licenseSecret.val($licenseKeyInput.val());
859 + }
860 + }
861 +
862 + return true;
863 + });
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 +
874 + $primaryCta.on('click', function () {
875 + console.log('Primary button was clicked');
876 +
877 + $(this).addClass('fs-loading');
878 + $(this).html('<?php echo esc_js( $is_pending_activation ?
879 + fs_text_x_inline( 'Sending email', 'as in the process of sending an email', 'sending-email', $slug ) :
880 + fs_text_x_inline( 'Activating', 'as activating plugin', 'activating', $slug )
881 + ) ?>...');
882 + });
883 +
884 + $('.fs-permissions .fs-trigger').on('click', function () {
885 + $('.fs-permissions').toggleClass('fs-open');
886 +
887 + return false;
888 + });
889 +
890 + if (requireLicenseKey) {
891 + /**
892 + * Submit license key on enter.
893 + *
894 + * @author Vova Feldman (@svovaf)
895 + * @since 1.1.9
896 + */
897 + $licenseKeyInput.keypress(function (e) {
898 + if (e.which == 13) {
899 + if ('' !== $(this).val()) {
900 + $primaryCta.click();
901 + return false;
902 + }
903 + }
904 + });
905 +
906 + /**
907 + * Disable activation button when empty license key.
908 + *
909 + * @author Vova Feldman (@svovaf)
910 + * @since 1.1.9
911 + */
912 + $licenseKeyInput.on('keyup paste delete cut', function () {
913 + setTimeout(function () {
914 + var key = $licenseKeyInput.val();
915 +
916 + if (key == previousLicenseKey){
917 + return;
918 + }
919 +
920 + if ('' === key) {
921 + $primaryCta.attr('disabled', 'disabled');
922 + hideOptinAndLicenseMessage();
923 + } else {
924 + $primaryCta.prop('disabled', false);
925 +
926 + if (32 <= key.length){
927 + fetchIsMarketingAllowedFlagAndToggleOptin();
928 + } else {
929 + hideOptinAndLicenseMessage();
930 + }
931 + }
932 +
933 + previousLicenseKey = key;
934 + }, 100);
935 + }).focus();
936 + }
937 +
938 + /**
939 + * Set license mode trigger URL.
940 + *
941 + * @author Vova Feldman (@svovaf)
942 + * @since 1.1.9
943 + */
944 + var
945 + $connectLicenseModeTrigger = $('#fs_connect .fs-freemium-licensing a'),
946 + href = window.location.href;
947 +
948 + if (href.indexOf('?') > 0) {
949 + href += '&';
950 + } else {
951 + href += '?';
952 + }
953 +
954 + if ($connectLicenseModeTrigger.length > 0) {
955 + $connectLicenseModeTrigger.attr(
956 + 'href',
957 + href + 'require_license=' + $connectLicenseModeTrigger.attr('data-require-license')
958 + );
959 + }
960 +
961 + //--------------------------------------------------------------------------------
962 + //region GDPR
963 + //--------------------------------------------------------------------------------
964 + var isMarketingAllowedByLicense = {},
965 + licenseOwnerIDByLicense = {},
966 + $marketingOptin = $( '#fs_marketing_optin' ),
967 + $orphanLicenseMessage = $( '#fs_orphan_license_message' ),
968 + previousLicenseKey = null;
969 +
970 + if (requireLicenseKey) {
971 +
972 + var
973 + afterMarketingFlagLoaded = function () {
974 + var licenseKey = $licenseKeyInput.val();
975 +
976 + if (null == isMarketingAllowedByLicense[licenseKey]) {
977 + $marketingOptin.show();
978 +
979 + if ($marketingOptin.find('input[type=radio]:checked').length > 0){
980 + // Focus on button if GDPR opt-in already selected is already selected.
981 + $primaryCta.focus();
982 + } else {
983 + // Focus on the GDPR opt-in radio button.
984 + $($marketingOptin.find('input[type=radio]')[0]).focus();
985 + }
986 + } else {
987 + $marketingOptin.hide();
988 + $primaryCta.focus();
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 + }
998 + },
999 + /**
1000 + * @author Leo Fajardo (@leorw)
1001 + * @since 2.1.0
1002 + */
1003 + fetchIsMarketingAllowedFlagAndToggleOptin = function () {
1004 + var licenseKey = $licenseKeyInput.val();
1005 +
1006 + if (licenseKey.length < 32) {
1007 + hideOptinAndLicenseMessage();
1008 +
1009 + return;
1010 + }
1011 +
1012 + if (isMarketingAllowedByLicense.hasOwnProperty(licenseKey)) {
1013 + afterMarketingFlagLoaded();
1014 + return;
1015 + }
1016 +
1017 + hideOptinAndLicenseMessage();
1018 + setLoadingMode();
1019 +
1020 + $primaryCta.addClass('fs-loading');
1021 + $primaryCta.attr('disabled', 'disabled');
1022 + $primaryCta.html('<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...');
1023 +
1024 + $.ajax({
1025 + url : <?php echo Freemius::ajax_url() ?>,
1026 + method : 'POST',
1027 + data : {
1028 + action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>',
1029 + security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>',
1030 + license_key: licenseKey,
1031 + module_id : '<?php echo $fs->get_id() ?>'
1032 + },
1033 + success: function (result) {
1034 + resetLoadingMode();
1035 +
1036 + if (result.success) {
1037 + result = result.data;
1038 +
1039 + // Cache result.
1040 + isMarketingAllowedByLicense[licenseKey] = result.is_marketing_allowed;
1041 + licenseOwnerIDByLicense[ licenseKey ] = result.license_owner_id;
1042 + }
1043 +
1044 + afterMarketingFlagLoaded();
1045 + }
1046 + });
1047 + },
1048 + hideOptinAndLicenseMessage = function() {
1049 + $marketingOptin.hide();
1050 + $orphanLicenseMessage.hide();
1051 + };
1052 +
1053 + $marketingOptin.find( 'input' ).click(function() {
1054 + $marketingOptin.removeClass( 'error' );
1055 + });
1056 + }
1057 +
1058 + //endregion
1059 + })(jQuery);
1060 +</script>
1061 +<?php
1047 1062 fs_require_once_template( 'api-connectivity-message-js.php' );