| @@ -24,8 +24,17 @@ | ||
| 24 | 24 | $is_freemium = $fs->is_freemium(); |
| 25 | 25 | |
| 26 | 26 | $fs->_enqueue_connect_essentials(); |
| 27 | 27 | |
| 28 | + /** | |
| 29 | + * Enqueueing the styles in `_enqueue_connect_essentials()` is too late, as we need them in the HEADER. Therefore, inject the styles inline to avoid FOUC. | |
| 30 | + * | |
| 31 | + * @author Vova Feldman (@svovaf) | |
| 32 | + */ | |
| 33 | + echo "<style>\n"; | |
| 34 | + include WP_FS__DIR_CSS . '/admin/connect.css'; | |
| 35 | + echo "</style>\n"; | |
| 36 | + | |
| 28 | 37 | $current_user = Freemius::_get_current_wp_user(); |
| 29 | 38 | |
| 30 | 39 | $first_name = $current_user->user_firstname; |
| 31 | 40 | if ( empty( $first_name ) ) { |
| @@ -31,36 +40,33 @@ | ||
| 31 | 40 | if ( empty( $first_name ) ) { |
| 32 | 41 | $first_name = $current_user->nickname; |
| 33 | 42 | } |
| 34 | 43 | |
| 35 | - $site_url = get_site_url(); | |
| 44 | + $site_url = Freemius::get_unfiltered_site_url(); | |
| 36 | 45 | $protocol_pos = strpos( $site_url, '://' ); |
| 37 | 46 | if ( false !== $protocol_pos ) { |
| 38 | 47 | $site_url = substr( $site_url, $protocol_pos + 3 ); |
| 39 | 48 | } |
| 40 | 49 | |
| 41 | - $freemius_site_www = 'https://freemius.com'; | |
| 42 | - | |
| 43 | 50 | $freemius_usage_tracking_url = $fs->get_usage_tracking_terms_url(); |
| 44 | 51 | $freemius_plugin_terms_url = $fs->get_eula_url(); |
| 45 | 52 | |
| 46 | - $freemius_site_url = $fs->is_premium() ? | |
| 47 | - $freemius_site_www : | |
| 48 | - $freemius_usage_tracking_url; | |
| 53 | + $error = fs_request_get( 'error' ); | |
| 49 | 54 | |
| 50 | - if ( $fs->is_premium() ) { | |
| 51 | - $freemius_site_url .= '?' . http_build_query( array( | |
| 52 | - 'id' => $fs->get_id(), | |
| 53 | - 'slug' => $slug, | |
| 54 | - ) ); | |
| 55 | - } | |
| 55 | + $has_release_on_freemius = $fs->has_release_on_freemius(); | |
| 56 | 56 | |
| 57 | - $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" rel="noopener" tabindex="1">freemius.com</a>'; | |
| 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 | + ); | |
| 58 | 63 | |
| 59 | - $error = fs_request_get( 'error' ); | |
| 64 | + $freemius_activation_terms_url = ($fs->is_premium() && $require_license_key) ? | |
| 65 | + $fs->get_license_activation_terms_url() : | |
| 66 | + $freemius_usage_tracking_url; | |
| 60 | 67 | |
| 61 | - $require_license_key = $is_premium_only || | |
| 62 | - ( $is_freemium && $is_premium_code && fs_request_get_bool( 'require_license', true ) ); | |
| 68 | + $freemius_activation_terms_html = '<a href="' . esc_url( $freemius_activation_terms_url ) . '" target="_blank" rel="noopener" tabindex="1">freemius.com</a>'; | |
| 63 | 69 | |
| 64 | 70 | if ( $is_pending_activation ) { |
| 65 | 71 | $require_license_key = false; |
| 66 | 72 | } |
| @@ -110,15 +116,15 @@ | ||
| 110 | 116 | |
| 111 | 117 | /* translators: %s: name (e.g. Hey John,) */ |
| 112 | 118 | $hey_x_text = esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $first_name ) ); |
| 113 | 119 | |
| 114 | - $is_gdpr_required = ( ! $is_pending_activation && ! $require_license_key ) ? | |
| 115 | - FS_GDPR_Manager::instance()->is_required() : | |
| 116 | - false; | |
| 117 | - | |
| 118 | - if ( is_null( $is_gdpr_required ) ) { | |
| 119 | - $is_gdpr_required = $fs->fetch_and_store_current_user_gdpr_anonymously(); | |
| 120 | - } | |
| 120 | + $activation_state = array( | |
| 121 | + 'is_license_activation' => $require_license_key, | |
| 122 | + 'is_pending_activation' => $is_pending_activation, | |
| 123 | + 'is_gdpr_required' => true, | |
| 124 | + 'is_network_level_activation' => $is_network_level_activation, | |
| 125 | + 'is_dialog' => $is_optin_dialog, | |
| 126 | + ); | |
| 121 | 127 | ?> |
| 122 | 128 | <?php |
| 123 | 129 | if ( $is_optin_dialog ) { ?> |
| 124 | 130 | <div id="fs_theme_connect_wrapper"> |
| @@ -137,28 +143,56 @@ | ||
| 137 | 143 | * |
| 138 | 144 | * @author Vova Feldman |
| 139 | 145 | * @since 2.3.2 |
| 140 | 146 | */ |
| 141 | - $fs->do_action( 'connect/before' ); | |
| 147 | + $fs->do_action( 'connect/before', $activation_state ); | |
| 142 | 148 | ?> |
| 143 | 149 | <div id="fs_connect" |
| 144 | 150 | class="wrap<?php if ( ! fs_is_network_admin() && ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) ) { |
| 145 | 151 | echo ' fs-anonymous-disabled'; |
| 146 | 152 | } ?><?php echo $require_license_key ? ' require-license-key' : '' ?>"> |
| 147 | - <div class="fs-visual"> | |
| 148 | - <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b> | |
| 149 | - <i class="dashicons dashicons-plus fs-first"></i> | |
| 150 | - <?php | |
| 151 | - $vars = array( 'id' => $fs->get_id() ); | |
| 152 | - fs_require_once_template( 'plugin-icon.php', $vars ); | |
| 153 | - ?> | |
| 154 | - <i class="dashicons dashicons-plus fs-second"></i> | |
| 155 | - <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/> | |
| 156 | - </div> | |
| 153 | + <div class="fs-header"> | |
| 154 | + <!-- <b class="fs-site-icon"><i class="dashicons dashicons-wordpress-alt"></i></b>--> | |
| 155 | + <?php | |
| 156 | + $size = 50; | |
| 157 | + $vars = array( | |
| 158 | + 'id' => $fs->get_id(), | |
| 159 | + 'size' => $size, | |
| 160 | + ); | |
| 161 | + | |
| 162 | + fs_require_once_template( 'plugin-icon.php', $vars ); | |
| 163 | + ?> | |
| 164 | + <!-- <img class="fs-connect-logo" width="--><?php //echo $size ?><!--" height="--><?php //echo $size ?><!--" src="//img.freemius.com/logo/connect.svg"/>--> | |
| 165 | + </div> | |
| 166 | + <div class="fs-box-container"> | |
| 157 | 167 | <div class="fs-content"> |
| 168 | + <?php $fs->do_action( 'connect/before_message', $activation_state ) ?> | |
| 169 | + | |
| 158 | 170 | <?php if ( ! empty( $error ) ) : ?> |
| 159 | - <p class="fs-error"><?php echo esc_html( $error ) ?></p> | |
| 171 | + <div class="fs-error"><?php echo $fs->apply_filters( 'connect_error_esc_html', esc_html( $error ) ) ?></div> | |
| 160 | 172 | <?php endif ?> |
| 173 | + <?php | |
| 174 | + if ( ! $is_pending_activation && ! $require_license_key ) { | |
| 175 | + if ( ! $fs->is_plugin_update() ) { | |
| 176 | + echo $fs->apply_filters( 'connect-header', sprintf( | |
| 177 | + '<h2 style="text-align: center">%s</h2>', | |
| 178 | + esc_html( fs_text_inline( 'Never miss an important update', 'connect-header' ) ) | |
| 179 | + ) ); | |
| 180 | + } else { | |
| 181 | + echo $fs->apply_filters( 'connect-header_on-update', sprintf( | |
| 182 | + '<h2>%s</h2>', | |
| 183 | + sprintf( | |
| 184 | + esc_html( | |
| 185 | + /* translators: %1$s: plugin name (e.g., "Awesome Plugin"); %2$s: version (e.g., "1.2.3") */ | |
| 186 | + fs_text_inline('Thank you for updating to %1$s v%2$s!', 'connect-header_on-update' ) | |
| 187 | + ), | |
| 188 | + esc_html( $fs->get_plugin_name() ), | |
| 189 | + $fs->get_plugin_version() | |
| 190 | + ) | |
| 191 | + ) ); | |
| 192 | + } | |
| 193 | + } | |
| 194 | + ?> | |
| 161 | 195 | <p><?php |
| 162 | 196 | $button_label = fs_text_inline( 'Allow & Continue', 'opt-in-connect', $slug ); |
| 163 | 197 | $message = ''; |
| 164 | 198 | |
| @@ -167,46 +201,50 @@ | ||
| 167 | 201 | |
| 168 | 202 | $message = $fs->apply_filters( 'pending_activation_message', sprintf( |
| 169 | 203 | /* translators: %s: name (e.g. Thanks John!) */ |
| 170 | 204 | fs_text_inline( 'Thanks %s!', 'thanks-x', $slug ) . '<br>' . |
| 171 | - fs_text_inline( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to %s.', 'pending-activation-message', $slug ), | |
| 205 | + 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 ), | |
| 172 | 206 | $first_name, |
| 173 | 207 | '<b>' . $fs->get_plugin_name() . '</b>', |
| 174 | 208 | '<b>' . $current_user->user_email . '</b>', |
| 175 | - fs_text_inline( 'complete the install', 'complete-the-install', $slug ) | |
| 209 | + fs_text_inline( 'complete the opt-in', 'complete-the-opt-in', $slug ) | |
| 176 | 210 | ) ); |
| 177 | 211 | } else if ( $require_license_key ) { |
| 178 | - $button_label = $is_network_upgrade_mode ? | |
| 179 | - fs_text_inline( 'Activate License', 'agree-activate-license', $slug ) : | |
| 180 | - fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug ); | |
| 212 | + $button_label = fs_text_inline( 'Activate License', 'activate-license', $slug ); | |
| 181 | 213 | |
| 182 | 214 | $message = $fs->apply_filters( |
| 183 | 215 | 'connect-message_on-premium', |
| 184 | - ($is_network_upgrade_mode ? | |
| 185 | - '' : | |
| 186 | - /* translators: %s: name (e.g. Hey John,) */ | |
| 187 | - $hey_x_text . '<br>' | |
| 188 | - ) . | |
| 189 | - sprintf( fs_text_inline( 'Thanks for purchasing %s! To get started, please enter your license key:', 'thanks-for-purchasing', $slug ), '<b>' . $fs->get_plugin_name() . '</b>' ), | |
| 216 | + 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>' ), | |
| 190 | 217 | $first_name, |
| 191 | 218 | $fs->get_plugin_name() |
| 192 | 219 | ); |
| 193 | 220 | } else { |
| 194 | - $filter = 'connect_message'; | |
| 195 | - $default_optin_message = $is_gdpr_required ? | |
| 196 | - fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with %4$s.', 'connect-message', $slug) : | |
| 197 | - fs_text_inline( 'Never miss an important update - opt in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s.', 'connect-message', $slug); | |
| 221 | + $filter = 'connect_message'; | |
| 198 | 222 | |
| 199 | - if ( $fs->is_plugin_update() ) { | |
| 223 | + if ( ! $fs->is_plugin_update() ) { | |
| 224 | + $default_optin_message = esc_html( | |
| 225 | + sprintf( | |
| 226 | + /* translators: %s: module type (plugin, theme, or add-on) */ | |
| 227 | + 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 ), | |
| 228 | + $fs->get_module_label( true ) | |
| 229 | + ) | |
| 230 | + ); | |
| 231 | + } else { | |
| 200 | 232 | // If Freemius was added on a plugin update, set different |
| 201 | 233 | // opt-in message. |
| 202 | - $default_optin_message = $is_gdpr_required ? | |
| 203 | - fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, educational content, offers, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug ) : | |
| 204 | - fs_text_inline( 'Never miss an important update - opt in to our security & feature updates notifications, and non-sensitive diagnostic tracking with %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug ); | |
| 205 | 234 | |
| 206 | - // If user customized the opt-in message on update, use | |
| 235 | + /* translators: %s: module type (plugin, theme, or add-on) */ | |
| 236 | + $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 ) ) ); | |
| 237 | + | |
| 238 | + $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 ) ); | |
| 239 | + | |
| 240 | + if ( $fs->is_enable_anonymous() ) { | |
| 241 | + $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 ) ); | |
| 242 | + } | |
| 243 | + | |
| 244 | + // If user customized the opt-in message on update, use | |
| 207 | 245 | // that message. Otherwise, fallback to regular opt-in |
| 208 | - // custom message if exist. | |
| 246 | + // custom message if exists. | |
| 209 | 247 | if ( $fs->has_filter( 'connect_message_on_update' ) ) { |
| 210 | 248 | $filter = 'connect_message_on_update'; |
| 211 | 249 | } |
| 212 | 250 | } |
| @@ -212,26 +250,21 @@ | ||
| 212 | 250 | } |
| 213 | 251 | |
| 214 | 252 | $message = $fs->apply_filters( |
| 215 | 253 | $filter, |
| 216 | - ($is_network_upgrade_mode ? | |
| 217 | - '' : | |
| 218 | - /* translators: %s: name (e.g. Hey John,) */ | |
| 219 | - $hey_x_text . '<br>' | |
| 220 | - ) . | |
| 221 | 254 | sprintf( |
| 222 | - esc_html( $default_optin_message ), | |
| 255 | + $default_optin_message, | |
| 223 | 256 | '<b>' . esc_html( $fs->get_plugin_name() ) . '</b>', |
| 224 | 257 | '<b>' . $current_user->user_login . '</b>', |
| 225 | 258 | '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>', |
| 226 | - $freemius_link | |
| 259 | + $freemius_activation_terms_html | |
| 227 | 260 | ), |
| 228 | 261 | $first_name, |
| 229 | 262 | $fs->get_plugin_name(), |
| 230 | 263 | $current_user->user_login, |
| 231 | 264 | '<a href="' . $site_url . '" target="_blank" rel="noopener noreferrer">' . $site_url . '</a>', |
| 232 | - $freemius_link, | |
| 233 | - $is_gdpr_required | |
| 265 | + $freemius_activation_terms_html, | |
| 266 | + true | |
| 234 | 267 | ); |
| 235 | 268 | } |
| 236 | 269 | |
| 237 | 270 | if ( $is_network_upgrade_mode ) { |
| @@ -270,9 +303,9 @@ | ||
| 270 | 303 | * |
| 271 | 304 | * @author Vova Feldman |
| 272 | 305 | * @since 2.1.2 |
| 273 | 306 | */ |
| 274 | - $fs->do_action( 'connect/after_license_input' ); | |
| 307 | + $fs->do_action( 'connect/after_license_input', $activation_state ); | |
| 275 | 308 | ?> |
| 276 | 309 | |
| 277 | 310 | <?php |
| 278 | 311 | $send_updates_text = sprintf( |
| @@ -315,10 +348,14 @@ | ||
| 315 | 348 | |
| 316 | 349 | echo fs_get_template( 'partials/network-activation.php', $vars ); |
| 317 | 350 | ?> |
| 318 | 351 | <?php endif ?> |
| 352 | + | |
| 353 | + <?php $fs->do_action( 'connect/after_message', $activation_state ) ?> | |
| 319 | 354 | </div> |
| 320 | 355 | <div class="fs-actions"> |
| 356 | + <?php $fs->do_action( 'connect/before_actions', $activation_state ) ?> | |
| 357 | + | |
| 321 | 358 | <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ( ! $require_license_key || $is_network_upgrade_mode ) ) : ?> |
| 322 | 359 | <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' ) ?>" |
| 323 | 360 | class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?></a> |
| 324 | 361 | <?php endif ?> |
| @@ -327,11 +364,12 @@ | ||
| 327 | 364 | <?php endif ?> |
| 328 | 365 | <?php if ( $activate_with_current_user ) : ?> |
| 329 | 366 | <form action="" method="POST"> |
| 330 | 367 | <input type="hidden" name="fs_action" |
| 331 | - value="<?php echo $fs->get_unique_affix() ?>_activate_existing"> | |
| 332 | - <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?> | |
| 368 | + value="<?php echo esc_attr( $fs->get_unique_affix() . '_activate_existing' ) ?>"> | |
| 369 | + <?php wp_nonce_field( $fs->get_unique_affix() . '_activate_existing' ) ?> | |
| 333 | 370 | <input type="hidden" name="is_extensions_tracking_allowed" value="1"> |
| 371 | + <input type="hidden" name="is_diagnostic_tracking_allowed" value="1"> | |
| 334 | 372 | <button class="button button-primary" tabindex="1" |
| 335 | 373 | type="submit"><?php echo esc_html( $button_label ) ?></button> |
| 336 | 374 | </form> |
| 337 | 375 | <?php else : ?> |
| @@ -337,11 +375,12 @@ | ||
| 337 | 375 | <?php else : ?> |
| 338 | 376 | <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/"> |
| 339 | 377 | <?php unset( $optin_params['sites']); ?> |
| 340 | 378 | <?php foreach ( $optin_params as $name => $value ) : ?> |
| 341 | - <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>"> | |
| 379 | + <input type="hidden" name="<?php echo esc_attr( $name ) ?>" value="<?php echo esc_attr( $value ) ?>"> | |
| 342 | 380 | <?php endforeach ?> |
| 343 | 381 | <input type="hidden" name="is_extensions_tracking_allowed" value="1"> |
| 382 | + <input type="hidden" name="is_diagnostic_tracking_allowed" value="1"> | |
| 344 | 383 | <button class="button button-primary" tabindex="1" |
| 345 | 384 | type="submit"<?php if ( $require_license_key ) { |
| 346 | 385 | echo ' disabled="disabled"'; |
| 347 | 386 | } ?>><?php echo esc_html( $button_label ) ?></button> |
| @@ -346,104 +385,49 @@ | ||
| 346 | 385 | echo ' disabled="disabled"'; |
| 347 | 386 | } ?>><?php echo esc_html( $button_label ) ?></button> |
| 348 | 387 | </form> |
| 349 | 388 | <?php endif ?> |
| 389 | + <?php if ( $require_license_key ) : ?> | |
| 390 | + <a id="license_issues_link" | |
| 391 | + href="<?php echo esc_url( $fs->apply_filters( 'known_license_issues_url', 'https://freemius.com/help/documentation/wordpress-sdk/license-activation-issues/' ) ) ?>" | |
| 392 | + target="_blank"><?php fs_esc_html_echo_inline( 'License issues?', 'license-issues', $slug ) ?></a> | |
| 393 | + <?php endif ?> | |
| 394 | + | |
| 395 | + <?php $fs->do_action( 'connect/after_actions', $activation_state ) ?> | |
| 350 | 396 | </div><?php |
| 397 | + $permission_manager = FS_Permission_Manager::instance( $fs ); | |
| 351 | 398 | |
| 352 | 399 | // Set core permission list items. |
| 353 | 400 | $permissions = array(); |
| 354 | 401 | |
| 355 | - /** | |
| 356 | - * When activating a license key the information of the admin is not collected, we gather the user info from the license. | |
| 357 | - * | |
| 358 | - * @since 2.3.2 | |
| 359 | - * @author Vova Feldman | |
| 360 | - */ | |
| 361 | - if ( ! $require_license_key ) { | |
| 362 | - $permissions['profile'] = array( | |
| 363 | - 'icon-class' => 'dashicons dashicons-admin-users', | |
| 364 | - 'label' => $fs->get_text_inline( 'Your Profile Overview', 'permissions-profile' ), | |
| 365 | - 'desc' => $fs->get_text_inline( 'Name and email address', 'permissions-profile_desc' ), | |
| 366 | - 'priority' => 5, | |
| 367 | - ); | |
| 368 | - } | |
| 402 | + // Add newsletter permissions if enabled. | |
| 403 | + if ( $fs->is_permission_requested( 'newsletter' ) ) { | |
| 404 | + $permissions[] = $permission_manager->get_newsletter_permission(); | |
| 405 | + } | |
| 369 | 406 | |
| 370 | - $permissions['site'] = array( | |
| 371 | - 'icon-class' => 'dashicons dashicons-admin-settings', | |
| 372 | - 'label' => $fs->get_text_inline( 'Your Site Overview', 'permissions-site' ), | |
| 373 | - 'desc' => $fs->get_text_inline( 'Site URL, WP version, PHP info', 'permissions-site_desc' ), | |
| 374 | - 'priority' => 10, | |
| 375 | - ); | |
| 407 | + $permissions = $permission_manager->get_permissions( | |
| 408 | + $require_license_key, | |
| 409 | + $permissions | |
| 410 | + ); | |
| 376 | 411 | |
| 377 | - $permissions['notices'] = array( | |
| 378 | - 'icon-class' => 'dashicons dashicons-testimonial', | |
| 379 | - 'label' => $fs->get_text_inline( 'Admin Notices', 'permissions-admin-notices' ), | |
| 380 | - 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ), | |
| 381 | - 'priority' => 13, | |
| 382 | - ); | |
| 383 | - | |
| 384 | - $permissions['events'] = array( | |
| 385 | - 'icon-class' => 'dashicons dashicons-admin-' . ( $fs->is_plugin() ? 'plugins' : 'appearance' ), | |
| 386 | - 'label' => sprintf( $fs->get_text_inline( 'Current %s Events', 'permissions-events' ), ucfirst( $fs->get_module_type() ) ), | |
| 387 | - 'desc' => $fs->get_text_inline( 'Activation, deactivation and uninstall', 'permissions-events_desc' ), | |
| 388 | - 'priority' => 20, | |
| 389 | - ); | |
| 390 | - | |
| 391 | - // Add newsletter permissions if enabled. | |
| 392 | - if ( $is_gdpr_required || $fs->is_permission_requested( 'newsletter' ) ) { | |
| 393 | - $permissions['newsletter'] = array( | |
| 394 | - 'icon-class' => 'dashicons dashicons-email-alt', | |
| 395 | - 'label' => $fs->get_text_inline( 'Newsletter', 'permissions-newsletter' ), | |
| 396 | - 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ), | |
| 397 | - 'priority' => 15, | |
| 398 | - ); | |
| 399 | - } | |
| 400 | - | |
| 401 | - $permissions['extensions'] = array( | |
| 402 | - 'icon-class' => 'dashicons dashicons-menu', | |
| 403 | - 'label' => $fs->get_text_inline( 'Plugins & Themes', 'permissions-extensions' ), | |
| 404 | - 'desc' => $fs->get_text_inline( 'Title, slug, version, and is active', 'permissions-extensions_desc' ), | |
| 405 | - 'priority' => 25, | |
| 406 | - 'optional' => true, | |
| 407 | - 'default' => $fs->apply_filters( 'permission_extensions_default', true ) | |
| 408 | - ); | |
| 409 | - | |
| 410 | - // Allow filtering of the permissions list. | |
| 411 | - $permissions = $fs->apply_filters( 'permission_list', $permissions ); | |
| 412 | - | |
| 413 | - // Sort by priority. | |
| 414 | - uasort( $permissions, 'fs_sort_by_priority' ); | |
| 415 | - | |
| 416 | 412 | if ( ! empty( $permissions ) ) : ?> |
| 417 | 413 | <div class="fs-permissions"> |
| 418 | - <?php if ( $require_license_key ) : ?> | |
| 419 | - <p class="fs-license-sync-disclaimer"><?php | |
| 420 | - echo sprintf( | |
| 421 | - fs_esc_html_inline( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ), | |
| 422 | - $fs->get_module_label( true ), | |
| 423 | - $freemius_link | |
| 424 | - ) ?></p> | |
| 425 | - <?php endif ?> | |
| 426 | - <a class="fs-trigger" href="#" tabindex="1"><?php fs_esc_html_echo_inline( 'What permissions are being granted?', 'what-permissions', $slug ) ?></a> | |
| 414 | + <?php if ( $require_license_key ) : ?> | |
| 415 | + <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php echo sprintf( | |
| 416 | + 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>', | |
| 417 | + sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', esc_html( $fs->get_plugin_title() ) ) | |
| 418 | + ) ?></a> | |
| 419 | + <?php else : ?> | |
| 420 | + <a class="fs-trigger wp-core-ui" href="#" tabindex="1" style="color: inherit;"><?php printf( | |
| 421 | + fs_esc_html_inline( 'This will allow %s to', 'this-will-allow-x', $slug ) . '<b class="fs-arrow"></b>', | |
| 422 | + sprintf( '<nobr class="button-link" style="color: inherit;">%s</nobr>', esc_html( $fs->get_plugin_title() ) ) | |
| 423 | + ) ?></a> | |
| 424 | + <?php endif ?> | |
| 427 | 425 | <ul><?php |
| 428 | - foreach ( $permissions as $id => $permission ) : ?> | |
| 429 | - <li id="fs-permission-<?php echo esc_attr( $id ); ?>" | |
| 430 | - class="fs-permission fs-<?php echo esc_attr( $id ); ?>"> | |
| 431 | - <i class="<?php echo esc_attr( $permission['icon-class'] ); ?>"></i> | |
| 432 | - <?php if ( isset( $permission['optional'] ) && true === $permission['optional'] ) : ?> | |
| 433 | - <div class="fs-switch fs-small fs-round fs-<?php echo (! isset( $permission['default'] ) || true === $permission['default'] ) ? 'on' : 'off' ?>"> | |
| 434 | - <div class="fs-toggle"></div> | |
| 435 | - </div> | |
| 436 | - <?php endif ?> | |
| 437 | - | |
| 438 | - <div class="fs-permission-description"> | |
| 439 | - <span><?php echo esc_html( $permission['label'] ); ?></span> | |
| 440 | - | |
| 441 | - <p><?php echo esc_html( $permission['desc'] ); ?></p> | |
| 442 | - </div> | |
| 443 | - </li> | |
| 444 | - <?php endforeach; ?> | |
| 445 | - </ul> | |
| 426 | + foreach ( $permissions as $permission ) { | |
| 427 | + $permission_manager->render_permission( $permission ); | |
| 428 | + } | |
| 429 | + ?></ul> | |
| 446 | 430 | </div> |
| 447 | 431 | <?php endif ?> |
| 448 | 432 | <?php if ( $is_premium_code && $is_freemium ) : ?> |
| 449 | 433 | <div class="fs-freemium-licensing"> |
| @@ -457,13 +441,20 @@ | ||
| 457 | 441 | <?php endif ?> |
| 458 | 442 | </p> |
| 459 | 443 | </div> |
| 460 | 444 | <?php endif ?> |
| 445 | + </div> | |
| 461 | 446 | <div class="fs-terms"> |
| 447 | + <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> | |
| 448 | + - | |
| 462 | 449 | <a href="https://freemius.com/privacy/" target="_blank" rel="noopener" |
| 463 | 450 | tabindex="1"><?php fs_esc_html_echo_inline( 'Privacy Policy', 'privacy-policy', $slug ) ?></a> |
| 464 | 451 | - |
| 465 | - <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> | |
| 452 | + <?php if ($require_license_key) : ?> | |
| 453 | + <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> | |
| 454 | + <?php else : ?> | |
| 455 | + <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> | |
| 456 | + <?php endif; ?> | |
| 466 | 457 | </div> |
| 467 | 458 | </div> |
| 468 | 459 | <?php |
| 469 | 460 | /** |
| @@ -471,9 +462,9 @@ | ||
| 471 | 462 | * |
| 472 | 463 | * @author Vova Feldman |
| 473 | 464 | * @since 2.3.2 |
| 474 | 465 | */ |
| 475 | - $fs->do_action( 'connect/after' ); | |
| 466 | + $fs->do_action( 'connect/after', $activation_state ); | |
| 476 | 467 | |
| 477 | 468 | if ( $is_optin_dialog ) { ?> |
| 478 | 469 | </div> |
| 479 | 470 | <?php |
| @@ -525,15 +516,14 @@ | ||
| 525 | 516 | resetLoadingMode = function() { |
| 526 | 517 | // Reset loading mode. |
| 527 | 518 | $primaryCta.html(primaryCtaLabel); |
| 528 | 519 | $primaryCta.prop('disabled', false); |
| 529 | - $(document.body).css({'cursor': 'auto'}); | |
| 530 | - $('.fs-loading').removeClass('fs-loading'); | |
| 520 | + $( '.fs-loading' ).removeClass( 'fs-loading' ); | |
| 531 | 521 | |
| 532 | 522 | console.log('resetLoadingMode - Primary button was enabled'); |
| 533 | 523 | }, |
| 534 | 524 | setLoadingMode = function () { |
| 535 | - $(document.body).css({'cursor': 'wait'}); | |
| 525 | + $( document.body ).addClass( 'fs-loading' ); | |
| 536 | 526 | }; |
| 537 | 527 | |
| 538 | 528 | $('.fs-actions .button').on('click', function () { |
| 539 | 529 | setLoadingMode(); |
| @@ -595,8 +585,13 @@ | ||
| 595 | 585 | |
| 596 | 586 | updatePrimaryCtaText( actionType ); |
| 597 | 587 | }); |
| 598 | 588 | |
| 589 | + $sitesListContainer.delegate( 'td:not(:first-child)', 'click', function() { | |
| 590 | + // If a site row is clicked, trigger a click on the checkbox. | |
| 591 | + $( this ).parent().find( 'td:first-child input' ).click(); | |
| 592 | + } ); | |
| 593 | + | |
| 599 | 594 | $sitesListContainer.delegate( '.action', 'click', function( evt ) { |
| 600 | 595 | var $this = $( evt.target ); |
| 601 | 596 | if ( $this.hasClass( 'selected' ) ) { |
| 602 | 597 | return false; |
| @@ -701,12 +696,29 @@ | ||
| 701 | 696 | |
| 702 | 697 | var ajaxOptin = ( requireLicenseKey || isNetworkActive ); |
| 703 | 698 | |
| 704 | 699 | $form.on('submit', function () { |
| 705 | - var isExtensionsTrackingAllowed = $( '#fs-permission-extensions .fs-switch' ).hasClass( 'fs-on' ); | |
| 700 | + var $extensionsPermission = $( '#fs_permission_extensions .fs-switch' ), | |
| 701 | + isExtensionsTrackingAllowed = ( $extensionsPermission.length > 0 ) ? | |
| 702 | + $extensionsPermission.hasClass( 'fs-on' ) : | |
| 703 | + null; | |
| 706 | 704 | |
| 707 | - $( 'input[name=is_extensions_tracking_allowed]' ).val( isExtensionsTrackingAllowed ? 1 : 0 ); | |
| 705 | + var $diagnosticPermission = $( '#fs_permission_diagnostic .fs-switch' ), | |
| 706 | + isDiagnosticTrackingAllowed = ( $diagnosticPermission.length > 0 ) ? | |
| 707 | + $diagnosticPermission.hasClass( 'fs-on' ) : | |
| 708 | + null; | |
| 708 | 709 | |
| 710 | + if ( null === isExtensionsTrackingAllowed ) { | |
| 711 | + $( 'input[name=is_extensions_tracking_allowed]' ).remove(); | |
| 712 | + } else { | |
| 713 | + $( 'input[name=is_extensions_tracking_allowed]' ).val( isExtensionsTrackingAllowed ? 1 : 0 ); | |
| 714 | + } | |
| 715 | + | |
| 716 | + // 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. | |
| 717 | + if ( null !== isDiagnosticTrackingAllowed ) { | |
| 718 | + $( 'input[name=is_diagnostic_tracking_allowed]' ).val( isDiagnosticTrackingAllowed ? 1 : 0 ); | |
| 719 | + } | |
| 720 | + | |
| 709 | 721 | /** |
| 710 | 722 | * @author Vova Feldman (@svovaf) |
| 711 | 723 | * @since 1.1.9 |
| 712 | 724 | */ |
| @@ -759,8 +771,10 @@ | ||
| 759 | 771 | |
| 760 | 772 | data.is_marketing_allowed = isMarketingAllowed; |
| 761 | 773 | |
| 762 | 774 | data.is_extensions_tracking_allowed = isExtensionsTrackingAllowed; |
| 775 | + | |
| 776 | + data.is_diagnostic_tracking_allowed = isDiagnosticTrackingAllowed; | |
| 763 | 777 | } |
| 764 | 778 | |
| 765 | 779 | $marketingOptin.removeClass( 'error' ); |
| 766 | 780 | |
| @@ -781,9 +795,8 @@ | ||
| 781 | 795 | uid : $this.find( '.uid' ).val(), |
| 782 | 796 | url : $this.find( '.url' ).val(), |
| 783 | 797 | title : $this.find( '.title' ).val(), |
| 784 | 798 | language: $this.find( '.language' ).val(), |
| 785 | - charset : $this.find( '.charset' ).val(), | |
| 786 | 799 | blog_id : $this.find( '.blog-id' ).find( 'span' ).text() |
| 787 | 800 | }; |
| 788 | 801 | |
| 789 | 802 | if ( ! requireLicenseKey) { |
| @@ -809,9 +822,9 @@ | ||
| 809 | 822 | * @author Vova Feldman (@svovaf) |
| 810 | 823 | * @since 1.2.1.5 |
| 811 | 824 | */ |
| 812 | 825 | $.ajax({ |
| 813 | - url : ajaxurl, | |
| 826 | + url : <?php echo Freemius::ajax_url() ?>, | |
| 814 | 827 | method : 'POST', |
| 815 | 828 | data : data, |
| 816 | 829 | success: function (result) { |
| 817 | 830 | var resultObj = $.parseJSON(result); |
| @@ -821,9 +834,9 @@ | ||
| 821 | 834 | } else { |
| 822 | 835 | resetLoadingMode(); |
| 823 | 836 | |
| 824 | 837 | // Show error. |
| 825 | - $('.fs-content').prepend('<p class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</p>'); | |
| 838 | + $('.fs-content').prepend('<div class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</div>'); | |
| 826 | 839 | } |
| 827 | 840 | }, |
| 828 | 841 | error: function () { |
| 829 | 842 | resetLoadingMode(); |
| @@ -845,8 +858,17 @@ | ||
| 845 | 858 | |
| 846 | 859 | return true; |
| 847 | 860 | }); |
| 848 | 861 | |
| 862 | + $( '#fs_connect .fs-permissions .fs-switch' ).on( 'click', function () { | |
| 863 | + $( this ) | |
| 864 | + .toggleClass( 'fs-on' ) | |
| 865 | + .toggleClass( 'fs-off' ); | |
| 866 | + | |
| 867 | + $( this ).closest( '.fs-permission' ) | |
| 868 | + .toggleClass( 'fs-disabled' ); | |
| 869 | + }); | |
| 870 | + | |
| 849 | 871 | $primaryCta.on('click', function () { |
| 850 | 872 | console.log('Primary button was clicked'); |
| 851 | 873 | |
| 852 | 874 | $(this).addClass('fs-loading'); |
| @@ -861,14 +883,8 @@ | ||
| 861 | 883 | |
| 862 | 884 | return false; |
| 863 | 885 | }); |
| 864 | 886 | |
| 865 | - $( '.fs-switch' ).click( function () { | |
| 866 | - $(this) | |
| 867 | - .toggleClass( 'fs-on' ) | |
| 868 | - .toggleClass( 'fs-off' ); | |
| 869 | - }); | |
| 870 | - | |
| 871 | 887 | if (requireLicenseKey) { |
| 872 | 888 | /** |
| 873 | 889 | * Submit license key on enter. |
| 874 | 890 | * |
| @@ -992,9 +1008,9 @@ | ||
| 992 | 1008 | $primaryCta.attr('disabled', 'disabled'); |
| 993 | 1009 | $primaryCta.html('<?php fs_esc_js_echo_inline( 'Please wait', 'please-wait', $slug ) ?>...'); |
| 994 | 1010 | |
| 995 | 1011 | $.ajax({ |
| 996 | - url : ajaxurl, | |
| 1012 | + url : <?php echo Freemius::ajax_url() ?>, | |
| 997 | 1013 | method : 'POST', |
| 998 | 1014 | data : { |
| 999 | 1015 | action : '<?php echo $fs->get_ajax_action( 'fetch_is_marketing_required_flag_value' ) ?>', |
| 1000 | 1016 | security : '<?php echo $fs->get_ajax_security( 'fetch_is_marketing_required_flag_value' ) ?>', |
| @@ -1022,5 +1038,7 @@ | ||
| 1022 | 1038 | } |
| 1023 | 1039 | |
| 1024 | 1040 | //endregion |
| 1025 | 1041 | })(jQuery); |
| 1026 | -</script> | |
| 1042 | +</script> | |
| 1043 | +<?php | |
| 1044 | + fs_require_once_template( 'api-connectivity-message-js.php' ); | |