PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 2.0.1
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v2.0.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
245 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_text( 'send-license-key', $slug );
20 $cancel_button_text = fs_text( 'cancel', $slug );
21 $email_address_placeholder = fs_esc_attr( 'email-address', $slug );
22 $other_text = fs_text( '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_text( '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_ajax_action( 'resend_license_key' ) ?>',
146 security : '<?php echo $fs->get_ajax_security( 'resend_license_key' ) ?>',
147 slug : moduleSlug,
148 email : email
149 },
150 beforeSend: function () {
151 $sendButton.text(<?php fs_json_encode_echo( 'sending-license-key', $slug ) ?> + '...');
152 },
153 success : function (result) {
154 var resultObj = $.parseJSON(result);
155 if (resultObj.success) {
156 closeModal();
157 } else {
158 showError(resultObj.error);
159 resetButton();
160 }
161 }
162 });
163 });
164 }
165
166 registerEventHandlers();
167
168 resetButton();
169
170 function showModal() {
171 resetModal();
172
173 // Display the dialog box.
174 $modal.addClass('active');
175
176 if (!isFreemium)
177 $emailInput.focus();
178
179 var $body = $('body');
180
181 isChild = $body.hasClass('has-fs-modal');
182 if (isChild) {
183 return;
184 }
185
186 $body.addClass('has-fs-modal');
187 }
188
189 function closeModal() {
190 $modal.removeClass('active');
191
192 // If child modal, do not remove the "has-fs-modal" class of the <body> element to keep its scrollbars hidden.
193 if (isChild) {
194 return;
195 }
196
197 $('body').removeClass('has-fs-modal');
198 }
199
200 function resetButton() {
201 updateButtonState();
202 $sendButton.text(<?php echo json_encode($send_button_text) ?>);
203 }
204
205 function resetModal() {
206 hideError();
207 resetButton();
208 $emailInput.val('');
209 }
210
211 function getEmail() {
212 var email = $emailInput.val().trim();
213
214 if (isFreemium) {
215 if ('other' != $modal.find('input[type=radio][name=email-address]:checked').val()) {
216 email = userEmail;
217 }
218 }
219
220 return email;
221 }
222
223 function updateButtonState() {
224 /**
225 * If email address is not empty, enable the send license key button.
226 */
227 $sendButton.toggleClass('disabled', !( -1 < getEmail().indexOf('@') ));
228 }
229
230 function disableButton() {
231 $sendButton.addClass('disabled');
232 }
233
234 function hideError() {
235 $feedbackMessage.hide();
236 }
237
238 function showError(msg) {
239 $feedbackMessage.find(' > p').html(msg);
240 $feedbackMessage.show();
241 }
242 });
243 })(jQuery);
244 </script>
245