PluginProbe ʕ •ᴥ•ʔ
Royal Addons for Elementor – Addons and Templates Kit for Elementor / 1.7.1064
Royal Addons for Elementor – Addons and Templates Kit for Elementor v1.7.1064
1.7.1064 1.7.1063 1.7.1062 1.7.1061 1.7.1060 1.7.1059 1.7.1058 trunk 1.0.0 1.1.0 1.2 1.3 1.3.1 1.3.2 1.3.21 1.3.22 1.3.23 1.3.24 1.3.25 1.3.26 1.3.27 1.3.28 1.3.29 1.3.30 1.3.31 1.3.32 1.3.33 1.3.34 1.3.35 1.3.36 1.3.37 1.3.38 1.3.39 1.3.40 1.3.41 1.3.42 1.3.43 1.3.44 1.3.45 1.3.46 1.3.47 1.3.48 1.3.49 1.3.50 1.3.51 1.3.52 1.3.53 1.3.54 1.3.55 1.3.56 1.3.57 1.3.58 1.3.59 1.3.60 1.3.61 1.3.62 1.3.63 1.3.64 1.3.65 1.3.66 1.3.67 1.3.68 1.3.69 1.3.70 1.3.71 1.3.72 1.3.73 1.3.74 1.3.75 1.3.76 1.3.77 1.3.78 1.3.79 1.3.80 1.3.81 1.3.82 1.3.83 1.3.84 1.3.85 1.3.86 1.3.87 1.3.88 1.3.89 1.3.90 1.3.91 1.3.92 1.3.93 1.3.94 1.3.95 1.3.96 1.3.97 1.3.971 1.3.972 1.3.973 1.3.974 1.3.975 1.3.976 1.3.977 1.3.978 1.3.979 1.3.980 1.3.981 1.3.982 1.3.983 1.3.984 1.3.985 1.3.986 1.3.987 1.7.1 1.7.1001 1.7.1002 1.7.1003 1.7.1004 1.7.1005 1.7.1006 1.7.1007 1.7.1008 1.7.1009 1.7.1010 1.7.1011 1.7.1012 1.7.1013 1.7.1014 1.7.1015 1.7.1016 1.7.1017 1.7.1018 1.7.1019 1.7.1020 1.7.1021 1.7.1022 1.7.1023 1.7.1024 1.7.1025 1.7.1026 1.7.1027 1.7.1028 1.7.1029 1.7.1030 1.7.1031 1.7.1032 1.7.1033 1.7.1034 1.7.1035 1.7.1036 1.7.1037 1.7.1038 1.7.1039 1.7.1040 1.7.1041 1.7.1042 1.7.1043 1.7.1044 1.7.1045 1.7.1046 1.7.1047 1.7.1048 1.7.1049 1.7.1050 1.7.1051 1.7.1052 1.7.1053 1.7.1054 1.7.1055 1.7.1056 1.7.1057
royal-elementor-addons / freemius / templates / forms / user-change.php
royal-elementor-addons / freemius / templates / forms Last commit date
deactivation 5 days ago affiliation.php 5 days ago data-debug-mode.php 5 days ago email-address-update.php 5 days ago index.php 5 days ago license-activation.php 5 days ago optout.php 5 days ago premium-versions-upgrade-handler.php 5 days ago premium-versions-upgrade-metadata.php 5 days ago resend-key.php 5 days ago subscription-cancellation.php 5 days ago trial-start.php 5 days ago user-change.php 5 days ago
user-change.php
297 lines
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 2.3.2
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 *
16 * @var Freemius $fs
17 */
18 $fs = freemius( $VARS['id'] );
19 $slug = $fs->get_slug();
20
21 /**
22 * @var object[] $license_owners
23 */
24 $license_owners = $VARS['license_owners'];
25
26 $change_user_message = fs_text_inline( 'By changing the user, you agree to transfer the account ownership to:', 'change-user--message', $slug );
27 $header_title = fs_text_inline( 'Change User', 'change-user', $slug );
28 $user_change_button_text = fs_text_inline( 'I Agree - Change User', 'agree-change-user', $slug );
29 $other_text = fs_text_inline( 'Other', 'other', $slug );
30 $enter_email_address_placeholder_text = fs_text_inline( 'Enter email address', 'enter-email-address', $slug );
31
32 $user_change_options_html = <<< HTML
33 <div class="fs-user-change-options-container">
34 <table>
35 <tbody>
36 HTML;
37
38 foreach ( $license_owners as $license_owner ) {
39 $user_change_options_html .= <<< HTML
40 <tr class="fs-email-address-container">
41 <td><input id="fs_email_address_{$license_owner->id}" type="radio" name="fs_email_address" value="{$license_owner->id}"></td>
42 <td><label for="fs_email_address_{$license_owner->id}">{$license_owner->email}</label></td>
43 </tr>
44 HTML;
45 }
46
47 $user_change_options_html .= <<< HTML
48 <tr>
49 <td><input id="fs_other_email_address_radio" type="radio" name="fs_email_address" value="other"></td>
50 <td class="fs-other-email-address-container">
51 <div>
52 <label for="fs_email_address">{$other_text}: </label>
53 <div>
54 <input id="fs_other_email_address_text_field" class="fs-email-address" type="text" placeholder="{$enter_email_address_placeholder_text}" tabindex="1">
55 </div>
56 </div>
57 </td>
58 </tr>
59 </tbody>
60 </table>
61 </div>
62 HTML;
63
64 $modal_content_html = <<< HTML
65 <div class="notice notice-error inline fs-change-user-result-message"><p></p></div>
66 <p>{$change_user_message}</p>
67 {$user_change_options_html}
68 HTML;
69
70 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
71 ?>
72 <script type="text/javascript">
73 (function( $ ) {
74 $( document ).ready(function() {
75 var modalContentHtml = <?php echo json_encode( $modal_content_html ) ?>,
76 modalHtml =
77 '<div class="fs-modal fs-modal-change-user fs-modal-change-user-<?php echo $fs->get_unique_affix() ?>">'
78 + ' <div class="fs-modal-dialog">'
79 + ' <div class="fs-modal-header">'
80 + ' <h4><?php echo esc_js( $header_title ) ?></h4>'
81 + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'close window', 'dismiss', $slug ) ) ?>"></i></a>'
82 + ' </div>'
83 + ' <div class="fs-modal-body">'
84 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
85 + ' </div>'
86 + ' <div class="fs-modal-footer">'
87 + ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
88 + ' <button class="button button-primary fs-user-change-button" tabindex="3"><?php echo esc_js( $user_change_button_text ) ?></button>'
89 + ' </div>'
90 + ' </div>'
91 + '</div>',
92 $modal = $( modalHtml ),
93 $userChangeButton = $modal.find( '.fs-user-change-button' ),
94 $otherEmailAddressRadio = $modal.find( '#fs_other_email_address_radio' ),
95 $changeUserResultMessage = $modal.find( '.fs-change-user-result-message' ),
96 $otherEmailAddressContainer = $modal.find( '.fs-other-email-address-container' ),
97 $otherEmailAddressTextField = $modal.find( '#fs_other_email_address_text_field' ),
98 $licenseOwners = $modal.find( 'input[type="radio"][name="fs_email_address"]' );
99
100 $modal.appendTo( $( 'body' ) );
101
102 var previousEmailAddress = null;
103
104 function registerEventHandlers() {
105 $licenseOwners.change( function() {
106 var otherEmailAddress = $otherEmailAddressTextField.val().trim(),
107 otherEmailAddressIsSelected = isOtherEmailAddressSelected();
108
109 if ( otherEmailAddressIsSelected ) {
110 $otherEmailAddressTextField.focus();
111 }
112
113 if ( otherEmailAddress.length > 0 || ! otherEmailAddressIsSelected ) {
114 enableUserChangeButton();
115 } else {
116 disableUserChangeButton();
117 }
118 } );
119
120 $otherEmailAddressContainer.click( function () {
121 $otherEmailAddressRadio.click();
122 } );
123
124 // Handle for the "Change User" button on the "Account" page.
125 $( '#fs_change_user' ).click( function ( evt ) {
126 evt.preventDefault();
127
128 showModal( evt );
129 } );
130
131 /**
132 * Disables the "Change User" button when the email address is empty.
133 */
134 $modal.on( 'keyup paste delete cut', 'input#fs_other_email_address_text_field', function () {
135 setTimeout( function () {
136 var emailAddress = $otherEmailAddressRadio.val().trim();
137
138 if ( emailAddress === previousEmailAddress ) {
139 return;
140 }
141
142 if ( '' === emailAddress ) {
143 disableUserChangeButton();
144 } else {
145 enableUserChangeButton();
146 }
147
148 previousEmailAddress = emailAddress;
149 }, 100 );
150 } ).focus();
151
152 $modal.on( 'input propertychange', 'input#fs_other_email_address_text_field', function () {
153 var emailAddress = $( this ).val().trim();
154
155 /**
156 * If email address is not empty, enable the "Change User" button.
157 */
158 if ( emailAddress.length > 0 ) {
159 enableUserChangeButton();
160 }
161 } );
162
163 $modal.on( 'blur', 'input#fs_other_email_address_text_field', function( evt ) {
164 var emailAddress = $( this ).val().trim();
165
166 /**
167 * If email address is empty, disable the "Change User" button.
168 */
169 if ( 0 === emailAddress.length ) {
170 disableUserChangeButton();
171 }
172 } );
173
174 $modal.on( 'click', '.fs-user-change-button', function ( evt ) {
175 evt.preventDefault();
176
177 if ( $( this ).hasClass( 'disabled' ) ) {
178 return;
179 }
180
181 var emailAddress = '',
182 licenseOwnerID = null;
183
184 if ( ! isOtherEmailAddressSelected() ) {
185 licenseOwnerID = $licenseOwners.filter( ':checked' ).val();
186 } else {
187 emailAddress = $otherEmailAddressTextField.val().trim();
188
189 if ( 0 === emailAddress.length ) {
190 return;
191 }
192 }
193
194 disableUserChangeButton();
195
196 $.ajax( {
197 url : <?php echo Freemius::ajax_url() ?>,
198 method : 'POST',
199 data : {
200 action : '<?php echo $fs->get_ajax_action( 'change_user' ) ?>',
201 security : '<?php echo $fs->get_ajax_security( 'change_user' ) ?>',
202 email_address: emailAddress,
203 user_id : licenseOwnerID,
204 module_id : '<?php echo $fs->get_id() ?>'
205 },
206 beforeSend: function () {
207 $userChangeButton
208 .text( '<?php fs_esc_js_echo_inline( 'Changing user, please wait', 'changing-user-please-wait', $slug ) ?>...' )
209 .prepend('<i class="fs-ajax-spinner"></i>');
210
211 $(document.body).css({'cursor': 'wait'});
212 },
213 success : function( result ) {
214 if ( result.success ) {
215 // Redirect to the "Account" page.
216 window.location.reload();
217 } else {
218 $(document.body).css({'cursor': 'auto'});
219
220 showError( result.error.message ? result.error.message : result.error );
221 resetUserChangeButton();
222 }
223 },
224 error : function () {
225 $(document.body).css({'cursor': 'auto'});
226
227 showError( '<?php fs_esc_js_echo_inline( 'Unexpected error, try again in 5 minutes. If the error persists, please contact support.', 'unexpected-error', $slug ) ?>' );
228
229 resetUserChangeButton();
230 }
231 } );
232 } );
233
234 // If the user has clicked outside the window, close the modal.
235 $modal.on( 'click', '.fs-close, .button-secondary', function () {
236 closeModal();
237 return false;
238 } );
239 }
240
241 registerEventHandlers();
242
243 /**
244 * @returns {Boolean}
245 */
246 function isOtherEmailAddressSelected() {
247 return ( 'other' === $licenseOwners.filter( ':checked' ).val() );
248 }
249
250 function showModal() {
251 resetModal();
252
253 // Display the dialog box.
254 $modal.addClass( 'active' );
255 $( 'body' ).addClass( 'has-fs-modal' );
256
257 // Select the first radio button.
258 $licenseOwners.get( 0 ).click();
259
260 $otherEmailAddressTextField.val( '' );
261 }
262
263 function closeModal() {
264 $modal.removeClass( 'active' );
265 $( 'body' ).removeClass( 'has-fs-modal' );
266 }
267
268 function resetUserChangeButton() {
269 enableUserChangeButton();
270 $userChangeButton.text( <?php echo json_encode( $user_change_button_text ) ?> );
271 }
272
273 function resetModal() {
274 hideError();
275 resetUserChangeButton();
276 }
277
278 function enableUserChangeButton() {
279 $userChangeButton.removeClass( 'disabled' );
280 }
281
282 function disableUserChangeButton() {
283 $userChangeButton.addClass( 'disabled' );
284 }
285
286 function hideError() {
287 $changeUserResultMessage.hide();
288 }
289
290 function showError( msg ) {
291 $changeUserResultMessage.find( ' > p' ).html( msg );
292 $changeUserResultMessage.show();
293 }
294 });
295 })( jQuery );
296 </script>
297