PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 1.7.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v1.7.1
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 / resend-key.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
resend-key.php
248 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.2.0
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 $send_button_text = __fs( 'send-license-key', $slug );
20 $cancel_button_text = __fs( 'cancel', $slug );
21 $email_address_placeholder = fs_esc_attr( 'email-address', $slug );
22 $other_text = __fs( 'reason-other', $slug );
23
24 $is_freemium = $fs->is_freemium();
25
26 $send_button_text_html = esc_html($send_button_text);
27
28 $button_html = <<< HTML
29 <div class="button-container">
30 <a href="#" class="button button-primary button-send-license-key" tabindex="2">{$send_button_text_html}</a>
31 </div>
32 HTML;
33
34 if ( $is_freemium ) {
35 $current_user = Freemius::_get_current_wp_user();
36 $email = $current_user->user_email;
37 $esc_email = esc_attr( $email );
38 $form_html = <<< HTML
39 <div class="email-address-container">
40 <label><input name="email-address" type="radio" checked="checked" tabindex="1" value="{$esc_email}"> {$email}</label>
41 <label><input name="email-address" type="radio" tabindex="1" value="other">{$other_text}: <input class="email-address" type="text" placeholder="{$email_address_placeholder}"></label>
42 </div>
43 {$button_html}
44 HTML;
45 } else {
46 $email = '';
47 $form_html = <<< HTML
48 {$button_html}
49 <div class="email-address-container">
50 <input class="email-address" type="text" placeholder="{$email_address_placeholder}" tabindex="1">
51 </div>
52 HTML;
53 }
54
55 $message_above_input_field = esc_html( __fs( 'ask-for-upgrade-email-address', $slug ) );
56 $modal_content_html = <<< HTML
57 <div class="notice notice-error inline license-resend-message"><p></p></div>
58 <p>{$message_above_input_field}</p>
59 <div class="input-container">
60 {$form_html}
61 </div>
62 HTML;
63
64 fs_enqueue_local_style( 'dialog-boxes', '/admin/dialog-boxes.css' );
65 ?>
66 <script type="text/javascript">
67 (function ($) {
68 $(document).ready(function () {
69 var contentHtml = <?php echo json_encode( $modal_content_html ); ?>,
70 modalHtml =
71 '<div class="fs-modal fs-modal-license-key-resend <?php echo $is_freemium ? 'fs-freemium' : 'fs-premium' ?>">'
72 + ' <div class="fs-modal-dialog">'
73 + ' <div class="fs-modal-header">'
74 + ' <h4><?php echo esc_js( $send_button_text ) ?></h4>'
75 + ' <a href="#!" class="fs-close" tabindex="3" title="Close"><i class="dashicons dashicons-no" title="<?php fs_esc_js_echo( 'dismiss', $slug ) ?>"></i></a>'
76 + ' </div>'
77 + ' <div class="fs-modal-body">'
78 + ' <div class="fs-modal-panel active">' + contentHtml + '</div>'
79 + ' </div>'
80 + ' </div>'
81 + '</div>',
82 $modal = $(modalHtml),
83 $sendButton = $modal.find('.button-send-license-key'),
84 $emailInput = $modal.find('input.email-address'),
85 $feedbackMessage = $modal.find('.license-resend-message'),
86 moduleSlug = '<?php echo $slug; ?>',
87 isFreemium = <?php echo json_encode( $is_freemium ) ?>,
88 userEmail =<?php echo json_encode( $email ) ?>,
89 isChild = false;
90
91 $modal.appendTo($('body'));
92
93 function registerEventHandlers() {
94 $('a.show-license-resend-modal-' + moduleSlug).click(function (evt) {
95 evt.preventDefault();
96
97 showModal();
98 });
99
100 if (isFreemium) {
101 $modal.on('change', 'input[type=radio][name=email-address]', function () {
102 updateButtonState();
103 });
104
105 $modal.on('focus', 'input.email-address', function () {
106 // Check custom email radio button on email input focus.
107 $($modal.find('input[type=radio]')[1]).prop('checked', true);
108
109 updateButtonState();
110 });
111 }
112
113 $modal.on('input propertychange', 'input.email-address', function () {
114 updateButtonState();
115 });
116
117 $modal.on('blur', 'input.email-address', function () {
118 updateButtonState();
119 });
120
121 $modal.on('click', '.fs-close', function () {
122 closeModal();
123 return false;
124 });
125
126 $modal.on('click', '.button', function (evt) {
127 evt.preventDefault();
128
129 if ($(this).hasClass('disabled')) {
130 return;
131 }
132
133 var email = getEmail();
134
135 disableButton();
136
137 if (!(-1 < email.indexOf('@'))) {
138 return;
139 }
140
141 $.ajax({
142 url : ajaxurl,
143 method : 'POST',
144 data : {
145 action: '<?php echo $fs->get_action_tag( 'resend_license_key' ) ?>',
146 slug : moduleSlug,
147 email : email
148 },
149 beforeSend: function () {
150 $sendButton.text(<?php fs_json_encode_echo( 'sending-license-key', $slug ) ?> + '...');
151 },
152 success : function (result) {
153 var resultObj = $.parseJSON(result);
154 if (resultObj.success) {
155 closeModal();
156 } else {
157 showError(resultObj.error);
158 resetButton();
159 }
160 }
161 });
162 });
163 }
164
165 registerEventHandlers();
166
167 resetButton();
168
169 function showModal() {
170 resetModal();
171
172 // Display the dialog box.
173 $modal.addClass('active');
174
175 if (!isFreemium)
176 $emailInput.focus();
177
178 var $body = $('body');
179
180 isChild = $body.hasClass('has-fs-modal');
181 if (isChild) {
182 return;
183 }
184
185 $body.addClass('has-fs-modal');
186 }
187
188 function closeModal() {
189 $modal.removeClass('active');
190
191 // If child modal, do not remove the "has-fs-modal" class of the <body> element to keep its scrollbars hidden.
192 if (isChild) {
193 return;
194 }
195
196 $('body').removeClass('has-fs-modal');
197 }
198
199 function resetButton() {
200 updateButtonState();
201 $sendButton.text(<?php echo json_encode($send_button_text) ?>);
202 }
203
204 function resetModal() {
205 hideError();
206 resetButton();
207 $emailInput.val('');
208 }
209
210 function getEmail() {
211 var email = $emailInput.val().trim();
212
213 if (isFreemium) {
214 if ('other' != $modal.find('input[type=radio][name=email-address]:checked').val()) {
215 email = userEmail;
216 }
217 }
218
219 return email;
220 }
221
222 function updateButtonState() {
223 /**
224 * If email address is not empty, enable the send license key button.
225 */
226 $sendButton.toggleClass('disabled', !( -1 < getEmail().indexOf('@') ));
227 }
228
229 function enableButton() {
230 $sendButton.removeClass('disabled');
231 }
232
233 function disableButton() {
234 $sendButton.addClass('disabled');
235 }
236
237 function hideError() {
238 $feedbackMessage.hide();
239 }
240
241 function showError(msg) {
242 $feedbackMessage.find(' > p').html(msg);
243 $feedbackMessage.show();
244 }
245 });
246 })(jQuery);
247 </script>
248