PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.4
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.4
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 / forms / license-activation.php

license-activation.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.4, at freemius/templates/forms/license-activation.php

217 lines 6.8 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.1.9
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var Freemius $fs
15 */
16 $fs = freemius( $VARS['id'] );
17 $slug = $fs->get_slug();
18
19 $cant_find_license_key_text = fs_text_inline( "Can't find your license key?", 'cant-find-license-key', $slug );
20 $message_above_input_field = fs_text_inline( 'Please enter the license key that you received in the email right after the purchase:', 'activate-license-message', $slug );
21 $message_below_input_field = '';
22
23 $header_title = $fs->is_free_plan() ?
24 fs_text_inline( 'Activate License', 'activate-license', $slug ) :
25 fs_text_inline( 'Update License', 'update-license', $slug );
26
27 if ( $fs->is_registered() ) {
28 $activate_button_text = $header_title;
29 } else {
30 $freemius_site_url = $fs->has_paid_plan() ?
31 'https://freemius.com/wordpress/' :
32 // Insights platform information.
33 'https://freemius.com/wordpress/usage-tracking/';
34
35 $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="0">freemius.com</a>';
36
37 $message_below_input_field = sprintf(
38 fs_text_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 ),
39 $fs->get_module_label( true ),
40 $freemius_link
41 );
42
43 $activate_button_text = fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug );
44 }
45
46 $license_key_text = fs_text_inline( 'License key', 'license-key' , $slug );
47
48 /**
49 * IMPORTANT:
50 * DO NOT ADD MAXLENGTH OR LIMIT THE LICENSE KEY LENGTH SINCE
51 * WE DO WANT TO ALLOW INPUT OF LONGER KEYS (E.G. WooCommerce Keys)
52 * FOR MIGRATED MODULES.
53 */
54 $modal_content_html = <<< HTML
55 <div class="notice notice-error inline license-activation-message"><p></p></div>
56 <p>{$message_above_input_field}</p>
57 <input class="license_key" type="text" placeholder="{$license_key_text}" tabindex="1" />
58 <a class="show-license-resend-modal show-license-resend-modal-{$fs->get_unique_affix()}" href="!#" tabindex="2">{$cant_find_license_key_text}</a>
59 <p>{$message_below_input_field}</p>
60 HTML;
61
62 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
63 ?>
64 <script type="text/javascript">
65 (function( $ ) {
66 $( document ).ready(function() {
67 var modalContentHtml = <?php echo json_encode($modal_content_html); ?>,
68 modalHtml =
69 '<div class="fs-modal fs-modal-license-activation">'
70 + ' <div class="fs-modal-dialog">'
71 + ' <div class="fs-modal-header">'
72 + ' <h4><?php echo esc_js($header_title) ?></h4>'
73 + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss', $slug ) ) ?>"></i></a>'
74 + ' </div>'
75 + ' <div class="fs-modal-body">'
76 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
77 + ' </div>'
78 + ' <div class="fs-modal-footer">'
79 + ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
80 + ' <button class="button button-primary button-activate-license" tabindex="3"><?php echo esc_js( $activate_button_text ) ?></button>'
81 + ' </div>'
82 + ' </div>'
83 + '</div>',
84 $modal = $(modalHtml),
85 $activateLicenseLink = $('span.activate-license.<?php echo $fs->get_unique_affix() ?> a, .activate-license-trigger.<?php echo $fs->get_unique_affix() ?>'),
86 $activateLicenseButton = $modal.find('.button-activate-license'),
87 $licenseKeyInput = $modal.find('input.license_key'),
88 $licenseActivationMessage = $modal.find( '.license-activation-message' );
89
90 $modal.appendTo($('body'));
91
92 function registerEventHandlers() {
93 $activateLicenseLink.click(function (evt) {
94 evt.preventDefault();
95
96 showModal();
97 });
98
99 $modal.on('input propertychange', 'input.license_key', function () {
100
101 var licenseKey = $(this).val().trim();
102
103 /**
104 * If license key is not empty, enable the license activation button.
105 */
106 if (licenseKey.length > 0) {
107 enableActivateLicenseButton();
108 }
109 });
110
111 $modal.on('blur', 'input.license_key', function () {
112 var licenseKey = $(this).val().trim();
113
114 /**
115 * If license key is empty, disable the license activation button.
116 */
117 if (0 === licenseKey.length) {
118 disableActivateLicenseButton();
119 }
120 });
121
122 $modal.on('click', '.button-activate-license', function (evt) {
123 evt.preventDefault();
124
125 if ($(this).hasClass('disabled')) {
126 return;
127 }
128
129 var licenseKey = $licenseKeyInput.val().trim();
130
131 disableActivateLicenseButton();
132
133 if (0 === licenseKey.length) {
134 return;
135 }
136
137 $.ajax({
138 url: ajaxurl,
139 method: 'POST',
140 data: {
141 action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
142 security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
143 license_key: licenseKey,
144 module_id : '<?php echo $fs->get_id() ?>'
145 },
146 beforeSend: function () {
147 $activateLicenseButton.text( '<?php fs_esc_js_echo_inline( 'Activating license', 'activating-license', $slug ) ?>...' );
148 },
149 success: function( result ) {
150 var resultObj = $.parseJSON( result );
151 if ( resultObj.success ) {
152 closeModal();
153
154 // Redirect to the "Account" page and sync the license.
155 window.location.href = resultObj.next_page;
156 } else {
157 showError( resultObj.error.message ? resultObj.error.message : resultObj.error );
158 resetActivateLicenseButton();
159 }
160 }
161 });
162 });
163
164 // If the user has clicked outside the window, close the modal.
165 $modal.on('click', '.fs-close, .button-secondary', function () {
166 closeModal();
167 return false;
168 });
169 }
170
171 registerEventHandlers();
172
173 function showModal() {
174 resetModal();
175
176 // Display the dialog box.
177 $modal.addClass('active');
178 $('body').addClass('has-fs-modal');
179
180 $licenseKeyInput.focus();
181 }
182
183 function closeModal() {
184 $modal.removeClass('active');
185 $('body').removeClass('has-fs-modal');
186 }
187
188 function resetActivateLicenseButton() {
189 enableActivateLicenseButton();
190 $activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
191 }
192
193 function resetModal() {
194 hideError();
195 resetActivateLicenseButton();
196 $licenseKeyInput.val( '' );
197 }
198
199 function enableActivateLicenseButton() {
200 $activateLicenseButton.removeClass( 'disabled' );
201 }
202
203 function disableActivateLicenseButton() {
204 $activateLicenseButton.addClass( 'disabled' );
205 }
206
207 function hideError() {
208 $licenseActivationMessage.hide();
209 }
210
211 function showError( msg ) {
212 $licenseActivationMessage.find( ' > p' ).html( msg );
213 $licenseActivationMessage.show();
214 }
215 });
216 })( jQuery );
217 </script>