PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.3
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.3
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / connect.php

connect.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.3, at freemius/templates/connect.php

503 lines 18.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $current_user = Freemius::_get_current_wp_user();
29
30 $first_name = $current_user->user_firstname;
31 if ( empty( $first_name ) ) {
32 $first_name = $current_user->nickname;
33 }
34
35 $site_url = get_site_url();
36 $protocol_pos = strpos( $site_url, '://' );
37 if ( false !== $protocol_pos ) {
38 $site_url = substr( $site_url, $protocol_pos + 3 );
39 }
40
41 $freemius_site_www = 'https://freemius.com';
42
43 $freemius_site_url = $freemius_site_www . '/' . ( $fs->is_premium() ?
44 'wordpress/' :
45 // Insights platform information.
46 'wordpress/usage-tracking/' . $fs->get_id() . "/{$slug}/" );
47
48 if ( $fs->is_premium() ) {
49 $freemius_site_url .= '?' . http_build_query( array(
50 'id' => $fs->get_id(),
51 'slug' => $slug,
52 ) );
53 }
54
55 $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="1">freemius.com</a>';
56
57 $error = fs_request_get( 'error' );
58
59 $require_license_key = $is_premium_only ||
60 ( $is_freemium && $is_premium_code && fs_request_get_bool( 'require_license', true ) );
61
62 if ( $is_pending_activation ) {
63 $require_license_key = false;
64 }
65
66 if ( $require_license_key ) {
67 $fs->_add_license_activation_dialog_box();
68 }
69
70 $is_optin_dialog = (
71 $fs->is_theme() &&
72 $fs->is_themes_page() &&
73 ( ! $fs->has_settings_menu() || $fs->is_free_wp_org_theme() )
74 );
75
76 if ( $is_optin_dialog ) {
77 $show_close_button = false;
78 $previous_theme_activation_url = '';
79
80 if ( ! $is_premium_code ) {
81 $show_close_button = true;
82 } else if ( $is_premium_only ) {
83 $previous_theme_activation_url = $fs->get_previous_theme_activation_url();
84 $show_close_button = ( ! empty( $previous_theme_activation_url ) );
85 }
86 }
87
88 $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
89 $activate_with_current_user = (
90 is_object( $fs_user ) &&
91 ! $is_pending_activation &&
92 // If requires a license for activation, use the user associated with the license for the opt-in.
93 ! $require_license_key
94 );
95 ?>
96 <?php
97 if ( $is_optin_dialog ) { ?>
98 <div id="fs_theme_connect_wrapper">
99 <?php
100 if ( $show_close_button ) { ?>
101 <button class="close dashicons dashicons-no"><span class="screen-reader-text">Close connect dialog</span>
102 </button>
103 <?php
104 }
105 ?>
106 <?php
107 }
108 ?>
109 <div id="fs_connect"
110 class="wrap<?php if ( ! $fs->is_enable_anonymous() || $is_pending_activation || $require_license_key ) {
111 echo ' fs-anonymous-disabled';
112 } ?>">
113 <div class="fs-visual">
114 <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
115 <i class="dashicons dashicons-plus fs-first"></i>
116 <?php
117 $vars = array( 'id' => $fs->get_id() );
118 fs_require_once_template( 'plugin-icon.php', $vars );
119 ?>
120 <i class="dashicons dashicons-plus fs-second"></i>
121 <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
122 </div>
123 <div class="fs-content">
124 <?php if ( ! empty( $error ) ) : ?>
125 <p class="fs-error"><?php echo esc_html( $error ) ?></p>
126 <?php endif ?>
127 <p><?php
128 $button_label = fs_text_inline( 'Allow & Continue', 'opt-in-connect', $slug );
129
130 if ( $is_pending_activation ) {
131 $button_label = fs_text_inline( 'Re-send activation email', 'resend-activation-email', $slug );
132
133 echo $fs->apply_filters( 'pending_activation_message', sprintf(
134 /* translators: %s: name (e.g. Thanks John!) */
135 fs_text_inline( 'Thanks %s!', 'thanks-x', $slug ) . '<br>' .
136 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 ),
137 $first_name,
138 '<b>' . $fs->get_plugin_name() . '</b>',
139 '<b>' . $current_user->user_email . '</b>',
140 fs_text_inline( 'complete the install', 'complete-the-install', $slug )
141 ) );
142 } else if ( $require_license_key ) {
143 $button_label = fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug );
144
145 echo $fs->apply_filters( 'connect-message_on-premium',
146 /* translators: %s: name (e.g. Hey John,) */
147 sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', $slug ), $first_name ) . '<br>' .
148 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>' ),
149 $first_name,
150 $fs->get_plugin_name()
151 );
152 } else {
153 $filter = 'connect_message';
154 $default_optin_message = 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);;
155
156 if ( $fs->is_plugin_update() ) {
157 // If Freemius was added on a plugin update, set different
158 // opt-in message.
159 $default_optin_message = fs_text_inline( 'Please help us improve %1$s! If you opt in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that\'s okay! %1$s will still work just fine.', 'connect-message_on-update', $slug );
160
161 // If user customized the opt-in message on update, use
162 // that message. Otherwise, fallback to regular opt-in
163 // custom message if exist.
164 if ( $fs->has_filter( 'connect_message_on_update' ) ) {
165 $filter = 'connect_message_on_update';
166 }
167 }
168
169 echo $fs->apply_filters( $filter,
170 esc_html( sprintf( fs_text_x_inline( 'Hey %s,', 'greeting', 'hey-x', $slug ), $first_name ) ) . '<br>' .
171 sprintf(
172 esc_html( $default_optin_message ),
173 '<b>' . esc_html( $fs->get_plugin_name() ) . '</b>',
174 '<b>' . $current_user->user_login . '</b>',
175 '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
176 $freemius_link
177 ),
178 $first_name,
179 $fs->get_plugin_name(),
180 $current_user->user_login,
181 '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
182 $freemius_link
183 );
184 }
185 ?></p>
186 <?php if ( $require_license_key ) : ?>
187 <div class="fs-license-key-container">
188 <input id="fs_license_key" name="fs_key" type="text" required maxlength="32"
189 placeholder="<?php fs_esc_attr_echo_inline( 'License key', 'license-key', $slug ) ?>" tabindex="1"/>
190 <i class="dashicons dashicons-admin-network"></i>
191 <a class="show-license-resend-modal show-license-resend-modal-<?php echo $fs->get_unique_affix() ?>"
192 href="#"><?php fs_esc_html_echo_inline( "Can't find your license key?", 'cant-find-license-key', $slug ); ?></a>
193 </div>
194 <?php endif ?>
195 </div>
196 <div class="fs-actions">
197 <?php if ( $fs->is_enable_anonymous() && ! $is_pending_activation && ! $require_license_key ) : ?>
198 <a href="<?php echo fs_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $fs->get_unique_affix() . '_skip_activation' ) ), $fs->get_unique_affix() . '_skip_activation' ) ?>"
199 class="button button-secondary" tabindex="2"><?php fs_esc_html_echo_x_inline( 'Skip', 'verb', 'skip', $slug ) ?></a>
200 <?php endif ?>
201
202 <?php if ( $activate_with_current_user ) : ?>
203 <form action="" method="POST">
204 <input type="hidden" name="fs_action"
205 value="<?php echo $fs->get_unique_affix() ?>_activate_existing">
206 <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
207 <button class="button button-primary" tabindex="1"
208 type="submit"><?php echo esc_html( $button_label ) ?></button>
209 </form>
210 <?php else : ?>
211 <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
212 <?php $params = $fs->get_opt_in_params() ?>
213 <?php foreach ( $params as $name => $value ) : ?>
214 <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
215 <?php endforeach ?>
216 <button class="button button-primary" tabindex="1"
217 type="submit"<?php if ( $require_license_key ) {
218 echo ' disabled="disabled"';
219 } ?>><?php echo esc_html( $button_label ) ?></button>
220 </form>
221 <?php endif ?>
222 </div><?php
223
224 // Set core permission list items.
225 $permissions = array(
226 'profile' => array(
227 'icon-class' => 'dashicons dashicons-admin-users',
228 'label' => $fs->get_text_inline( 'Your Profile Overview', 'permissions-profile' ),
229 'desc' => $fs->get_text_inline( 'Name and email address', 'permissions-profile_desc' ),
230 'priority' => 5,
231 ),
232 'site' => array(
233 'icon-class' => 'dashicons dashicons-admin-settings',
234 'label' => $fs->get_text_inline( 'Your Site Overview', 'permissions-site' ),
235 'desc' => $fs->get_text_inline( 'Site URL, WP version, PHP info, plugins & themes', 'permissions-site_desc' ),
236 'priority' => 10,
237 ),
238 'notices' => array(
239 'icon-class' => 'dashicons dashicons-testimonial',
240 'label' => $fs->get_text_inline( 'Admin Notices', 'permissions-admin-notices' ),
241 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ),
242 'priority' => 13,
243 ),
244 'events' => array(
245 'icon-class' => 'dashicons dashicons-admin-plugins',
246 'label' => sprintf( $fs->get_text_inline( 'Current %s Events', 'permissions-events' ), ucfirst( $fs->get_module_type() ) ),
247 'desc' => $fs->get_text_inline( 'Activation, deactivation and uninstall', 'permissions-events_desc' ),
248 'priority' => 20,
249 ),
250 // 'plugins_themes' => array(
251 // 'icon-class' => 'dashicons dashicons-admin-settings',
252 // 'label' => fs_text_inline( 'Plugins & Themes', 'permissions-plugins_themes' ),
253 // 'desc' => fs_text_inline( 'Titles, versions and state.', 'permissions-plugins_themes_desc' ),
254 // 'priority' => 30,
255 // ),
256 );
257
258 // Add newsletter permissions if enabled.
259 if ( $fs->is_permission_requested( 'newsletter' ) ) {
260 $permissions['newsletter'] = array(
261 'icon-class' => 'dashicons dashicons-email-alt',
262 'label' => $fs->get_text_inline( 'Newsletter', 'permissions-newsletter' ),
263 'desc' => $fs->get_text_inline( 'Updates, announcements, marketing, no spam', 'permissions-newsletter_desc' ),
264 'priority' => 15,
265 );
266 }
267
268 // Allow filtering of the permissions list.
269 $permissions = $fs->apply_filters( 'permission_list', $permissions );
270
271 // Sort by priority.
272 uasort( $permissions, 'fs_sort_by_priority' );
273
274 if ( ! empty( $permissions ) ) : ?>
275 <div class="fs-permissions">
276 <?php if ( $require_license_key ) : ?>
277 <p class="fs-license-sync-disclaimer"><?php
278 echo sprintf(
279 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 ),
280 $fs->get_module_label( true ),
281 $freemius_link
282 ) ?></p>
283 <?php endif ?>
284 <a class="fs-trigger" href="#" tabindex="1"><?php fs_esc_html_echo_inline( 'What permissions are being granted?', 'what-permissions', $slug ) ?></a>
285 <ul><?php
286 foreach ( $permissions as $id => $permission ) : ?>
287 <li id="fs-permission-<?php echo esc_attr( $id ); ?>"
288 class="fs-permission fs-<?php echo esc_attr( $id ); ?>">
289 <i class="<?php echo esc_attr( $permission['icon-class'] ); ?>"></i>
290
291 <div>
292 <span><?php echo esc_html( $permission['label'] ); ?></span>
293
294 <p><?php echo esc_html( $permission['desc'] ); ?></p>
295 </div>
296 </li>
297 <?php endforeach; ?>
298 </ul>
299 </div>
300 <?php endif ?>
301 <?php if ( $is_premium_code && $is_freemium ) : ?>
302 <div class="fs-freemium-licensing">
303 <p>
304 <?php if ( $require_license_key ) : ?>
305 <?php fs_esc_html_echo_inline( 'Don\'t have a license key?', 'dont-have-license-key', $slug ) ?>
306 <a data-require-license="false" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate Free Version', 'activate-free-version', $slug ) ?></a>
307 <?php else : ?>
308 <?php fs_echo_inline( 'Have a license key?', 'have-license-key', $slug ) ?>
309 <a data-require-license="true" tabindex="1"><?php fs_esc_html_echo_inline( 'Activate License', 'activate-license', $slug ) ?></a>
310 <?php endif ?>
311 </p>
312 </div>
313 <?php endif ?>
314 <div class="fs-terms">
315 <a href="https://freemius.com/privacy/" target="_blank"
316 tabindex="1"><?php fs_esc_html_echo_inline( 'Privacy Policy', 'privacy-policy', $slug ) ?></a>
317 &nbsp;&nbsp;-&nbsp;&nbsp;
318 <a href="<?php echo $freemius_site_www ?>/terms/" target="_blank" tabindex="1"><?php fs_echo_inline( 'Terms of Service', 'tos', $slug ) ?></a>
319 </div>
320 </div>
321 <?php
322 if ( $is_optin_dialog ) { ?>
323 </div>
324 <?php
325 }
326 ?>
327 <script type="text/javascript">
328 (function ($) {
329 var $html = $('html');
330
331 <?php
332 if ( $is_optin_dialog ) {
333 if ( $show_close_button ) { ?>
334 var $themeConnectWrapper = $('#fs_theme_connect_wrapper');
335
336 $themeConnectWrapper.find('button.close').on('click', function () {
337 <?php if ( ! empty( $previous_theme_activation_url ) ) { ?>
338 location.href = '<?php echo html_entity_decode( $previous_theme_activation_url ); ?>';
339 <?php } else { ?>
340 $themeConnectWrapper.remove();
341 $html.css({overflow: $html.attr('fs-optin-overflow')});
342 <?php } ?>
343 });
344 <?php
345 }
346 ?>
347
348 $html.attr('fs-optin-overflow', $html.css('overflow'));
349 $html.css({overflow: 'hidden'});
350
351 <?php
352 }
353 ?>
354
355 var $primaryCta = $('.fs-actions .button.button-primary'),
356 $form = $('.fs-actions form'),
357 requireLicenseKey = <?php echo $require_license_key ? 'true' : 'false' ?>,
358 hasContextUser = <?php echo $activate_with_current_user ? 'true' : 'false' ?>,
359 $licenseSecret,
360 $licenseKeyInput = $('#fs_license_key');
361
362 $('.fs-actions .button').on('click', function () {
363 // Set loading mode.
364 $(document.body).css({'cursor': 'wait'});
365
366 var $this = $(this);
367 $this.css({'cursor': 'wait'});
368
369 setTimeout(function () {
370 $this.attr('disabled', 'disabled');
371 }, 200);
372 });
373
374 $form.on('submit', function () {
375 /**
376 * @author Vova Feldman (@svovaf)
377 * @since 1.1.9
378 */
379 if (requireLicenseKey) {
380 if (!hasContextUser) {
381 $('.fs-error').remove();
382
383 /**
384 * Use the AJAX opt-in when license key is required to potentially
385 * process the after install failure hook.
386 *
387 * @author Vova Feldman (@svovaf)
388 * @since 1.2.1.5
389 */
390 $.ajax({
391 url : ajaxurl,
392 method : 'POST',
393 data : {
394 action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
395 security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
396 license_key: $licenseKeyInput.val(),
397 module_id : '<?php echo $fs->get_id() ?>'
398 },
399 success: function (result) {
400 var resultObj = $.parseJSON(result);
401 if (resultObj.success) {
402 // Redirect to the "Account" page and sync the license.
403 window.location.href = resultObj.next_page;
404 } else {
405 // Show error.
406 $('.fs-content').prepend('<p class="fs-error">' + (resultObj.error.message ? resultObj.error.message : resultObj.error) + '</p>');
407
408 // Reset loading mode.
409 $primaryCta.removeClass('fs-loading').css({'cursor': 'auto'});
410 $primaryCta.html('<?php echo esc_js( $button_label ) ?>');
411 $primaryCta.prop('disabled', false);
412 $(document.body).css({'cursor': 'auto'});
413 }
414 }
415 });
416
417 return false;
418 }
419 else {
420 if (null == $licenseSecret) {
421 $licenseSecret = $('<input type="hidden" name="license_secret_key" value="" />');
422 $form.append($licenseSecret);
423 }
424
425 // Update secret key if premium only plugin.
426 $licenseSecret.val($licenseKeyInput.val());
427 }
428 }
429
430 return true;
431 });
432
433 $primaryCta.on('click', function () {
434 $(this).addClass('fs-loading');
435 $(this).html('<?php echo esc_js( $is_pending_activation ?
436 fs_text_x_inline( 'Sending email', 'as in the process of sending an email', 'sending-email', $slug ) :
437 fs_text_x_inline( 'Activating', 'as activating plugin', 'activating', $slug )
438 ) ?>...');
439 });
440
441 $('.fs-permissions .fs-trigger').on('click', function () {
442 $('.fs-permissions').toggleClass('fs-open');
443
444 return false;
445 });
446
447 if (requireLicenseKey) {
448 /**
449 * Submit license key on enter.
450 *
451 * @author Vova Feldman (@svovaf)
452 * @since 1.1.9
453 */
454 $licenseKeyInput.keypress(function (e) {
455 if (e.which == 13) {
456 if ('' !== $(this).val()) {
457 $primaryCta.click();
458 return false;
459 }
460 }
461 });
462
463 /**
464 * Disable activation button when empty license key.
465 *
466 * @author Vova Feldman (@svovaf)
467 * @since 1.1.9
468 */
469 $licenseKeyInput.on('keyup paste delete cut', function () {
470 setTimeout(function () {
471 if ('' === $licenseKeyInput.val()) {
472 $primaryCta.attr('disabled', 'disabled');
473 } else {
474 $primaryCta.prop('disabled', false);
475 }
476 }, 100);
477 }).focus();
478 }
479
480 /**
481 * Set license mode trigger URL.
482 *
483 * @author Vova Feldman (@svovaf)
484 * @since 1.1.9
485 */
486 var
487 $connectLicenseModeTrigger = $('#fs_connect .fs-freemium-licensing a'),
488 href = window.location.href;
489
490 if (href.indexOf('?') > 0) {
491 href += '&';
492 } else {
493 href += '?';
494 }
495
496 if ($connectLicenseModeTrigger.length > 0) {
497 $connectLicenseModeTrigger.attr(
498 'href',
499 href + 'require_license=' + $connectLicenseModeTrigger.attr('data-require-license')
500 );
501 }
502 })(jQuery);
503 </script>