PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 2.0.0
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v2.0.0
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / freemius / templates / forms / license-activation.php
embedpress / freemius / templates / forms Last commit date
deactivation 9 years ago index.php 9 years ago license-activation.php 9 years ago optout.php 9 years ago resend-key.php 9 years ago trial-start.php 9 years ago
license-activation.php
213 lines
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6 * @since 1.1.9
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 */
16 $slug = $VARS['slug'];
17 $fs = freemius( $slug );
18
19 $cant_find_license_key_text = fs_text( 'cant-find-license-key', $slug );
20 $message_above_input_field = fs_text( 'activate-license-message', $slug );
21 $message_below_input_field = '';
22
23 $header_title = fs_text( $fs->is_free_plan() ? 'activate-license' : 'update-license', $slug );
24
25 if ( $fs->is_registered() ) {
26 $activate_button_text = $header_title;
27 } else {
28 $freemius_site_url = $fs->has_paid_plan() ?
29 'https://freemius.com/wordpress/' :
30 // Insights platform information.
31 'https://freemius.com/wordpress/usage-tracking/';
32
33 $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="0">freemius.com</a>';
34
35 $message_below_input_field = sprintf( fs_text( 'license-sync-disclaimer', $slug ), $freemius_link );
36
37 $activate_button_text = fs_text( 'agree-activate-license', $slug );
38 }
39
40 $license_key_text = fs_text( 'license-key' , $slug );
41
42 /**
43 * IMPORTANT:
44 * DO NOT ADD MAXLENGTH OR LIMIT THE LICENSE KEY LENGTH SINCE
45 * WE DO WANT TO ALLOW INPUT OF LONGER KEYS (E.G. WooCommerce Keys)
46 * FOR MIGRATED MODULES.
47 */
48 $modal_content_html = <<< HTML
49 <div class="notice notice-error inline license-activation-message"><p></p></div>
50 <p>{$message_above_input_field}</p>
51 <input class="license_key" type="text" placeholder="{$license_key_text}" tabindex="1" />
52 <a class="show-license-resend-modal show-license-resend-modal-{$slug}" href="!#" tabindex="2">{$cant_find_license_key_text}</a>
53 <p>{$message_below_input_field}</p>
54 HTML;
55
56 fs_enqueue_local_style( 'dialog-boxes', '/admin/dialog-boxes.css' );
57 ?>
58 <script type="text/javascript">
59 (function( $ ) {
60 $( document ).ready(function() {
61 var modalContentHtml = <?php echo json_encode($modal_content_html); ?>,
62 modalHtml =
63 '<div class="fs-modal fs-modal-license-activation">'
64 + ' <div class="fs-modal-dialog">'
65 + ' <div class="fs-modal-header">'
66 + ' <h4><?php echo esc_js($header_title) ?></h4>'
67 + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php fs_esc_attr_echo( 'dismiss', $slug ) ?>"></i></a>'
68 + ' </div>'
69 + ' <div class="fs-modal-body">'
70 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
71 + ' </div>'
72 + ' <div class="fs-modal-footer">'
73 + ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo( 'cancel', $slug ) ?></button>'
74 + ' <button class="button button-primary button-activate-license" tabindex="3"><?php echo esc_js( $activate_button_text ) ?></button>'
75 + ' </div>'
76 + ' </div>'
77 + '</div>',
78 $modal = $(modalHtml),
79 $activateLicenseLink = $('span.activate-license.<?php echo $VARS['slug'] ?> a, .activate-license-trigger.<?php echo $VARS['slug'] ?>'),
80 $activateLicenseButton = $modal.find('.button-activate-license'),
81 $licenseKeyInput = $modal.find('input.license_key'),
82 $licenseActivationMessage = $modal.find( '.license-activation-message' ),
83 pluginSlug = '<?php echo $slug ?>';
84
85 $modal.appendTo($('body'));
86
87 function registerEventHandlers() {
88 $activateLicenseLink.click(function (evt) {
89 evt.preventDefault();
90
91 showModal();
92 });
93
94 $modal.on('input propertychange', 'input.license_key', function () {
95
96 var licenseKey = $(this).val().trim();
97
98 /**
99 * If license key is not empty, enable the license activation button.
100 */
101 if (licenseKey.length > 0) {
102 enableActivateLicenseButton();
103 }
104 });
105
106 $modal.on('blur', 'input.license_key', function () {
107 var licenseKey = $(this).val().trim();
108
109 /**
110 * If license key is empty, disable the license activation button.
111 */
112 if (0 === licenseKey.length) {
113 disableActivateLicenseButton();
114 }
115 });
116
117 $modal.on('click', '.button-activate-license', function (evt) {
118 evt.preventDefault();
119
120 if ($(this).hasClass('disabled')) {
121 return;
122 }
123
124 var licenseKey = $licenseKeyInput.val().trim();
125
126 disableActivateLicenseButton();
127
128 if (0 === licenseKey.length) {
129 return;
130 }
131
132 $.ajax({
133 url: ajaxurl,
134 method: 'POST',
135 data: {
136 action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
137 security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
138 slug : pluginSlug,
139 license_key: licenseKey
140 },
141 beforeSend: function () {
142 $activateLicenseButton.text( <?php fs_json_encode_echo( 'activating-license', $slug ) ?> );
143 },
144 success: function( result ) {
145 var resultObj = $.parseJSON( result );
146 if ( resultObj.success ) {
147 closeModal();
148
149 // Redirect to the "Account" page and sync the license.
150 window.location.href = resultObj.next_page;
151 } else {
152 showError( resultObj.error.message ? resultObj.error.message : resultObj.error );
153 resetActivateLicenseButton();
154 }
155 }
156 });
157 });
158
159 // If the user has clicked outside the window, close the modal.
160 $modal.on('click', '.fs-close, .button-secondary', function () {
161 closeModal();
162 return false;
163 });
164 }
165
166 registerEventHandlers();
167
168 function showModal() {
169 resetModal();
170
171 // Display the dialog box.
172 $modal.addClass('active');
173 $('body').addClass('has-fs-modal');
174
175 $licenseKeyInput.focus();
176 }
177
178 function closeModal() {
179 $modal.removeClass('active');
180 $('body').removeClass('has-fs-modal');
181 }
182
183 function resetActivateLicenseButton() {
184 enableActivateLicenseButton();
185 $activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
186 }
187
188 function resetModal() {
189 hideError();
190 resetActivateLicenseButton();
191 $licenseKeyInput.val( '' );
192 }
193
194 function enableActivateLicenseButton() {
195 $activateLicenseButton.removeClass( 'disabled' );
196 }
197
198 function disableActivateLicenseButton() {
199 $activateLicenseButton.addClass( 'disabled' );
200 }
201
202 function hideError() {
203 $licenseActivationMessage.hide();
204 }
205
206 function showError( msg ) {
207 $licenseActivationMessage.find( ' > p' ).html( msg );
208 $licenseActivationMessage.show();
209 }
210 });
211 })( jQuery );
212 </script>
213