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