PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.5.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.5.0
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / includes / freemius / templates / auto-installation.php
spider-elements / includes / freemius / templates Last commit date
account 1 year ago checkout 1 year ago connect 1 year ago debug 1 year ago forms 1 year ago js 1 year ago partials 1 year ago plugin-info 1 year ago account.php 1 year ago add-ons.php 1 year ago add-trial-to-pricing.php 1 year ago admin-notice.php 1 year ago ajax-loader.php 1 year ago api-connectivity-message-js.php 1 year ago auto-installation.php 1 year ago checkout.php 1 year ago clone-resolution-js.php 1 year ago connect.php 1 year ago contact.php 1 year ago debug.php 1 year ago email.php 1 year ago gdpr-optin-js.php 1 year ago index.php 1 year ago plugin-icon.php 1 year ago pricing.php 1 year ago secure-https-header.php 1 year ago sticky-admin-notice-js.php 1 year ago tabs-capture-js.php 1 year ago tabs.php 1 year ago
auto-installation.php
250 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 1.2.1.5
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $slug = $VARS['slug'];
18 $plugin_id = $VARS['target_module_id'];
19
20 $fs = freemius( $VARS['id'] );
21
22 $action = $fs->is_tracking_allowed() ?
23 'stop_tracking' :
24 'allow_tracking';
25
26 $title = $fs->get_plugin_title();
27
28 if ( $plugin_id != $fs->get_id() ) {
29 $addon = $fs->get_addon( $plugin_id );
30
31 if ( is_object( $addon ) ) {
32 $title = $addon->title . ' ' . fs_text_inline( 'Add-On', 'addon', $slug );
33 }
34 }
35
36 $plugin_title = sprintf(
37 '<strong>%s</strong>',
38 esc_html( $title )
39 );
40
41 $sec_countdown = 30;
42 $countdown_html = sprintf(
43 esc_js(
44 /* translators: %s: Number of seconds */
45 fs_text_inline( '%s sec', 'x-sec', $slug )
46 ),
47 sprintf( '<span class="fs-countdown">%s</span>', $sec_countdown )
48 );
49
50 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
51 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
52
53 $params = array();
54 $loader_html = fs_get_template( 'ajax-loader.php', $params );
55
56 // Pass unique auto installation URL if WP_Filesystem is needed.
57 $install_url = $fs->_get_sync_license_url(
58 $plugin_id,
59 true,
60 array( 'auto_install' => 'true' )
61 );
62
63
64 ob_start();
65
66 $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
67
68 $credentials = request_filesystem_credentials(
69 esc_url_raw( $install_url ),
70 $method,
71 false,
72 WP_PLUGIN_DIR,
73 array()
74 );
75
76 $credentials_form = ob_get_clean();
77
78 $require_credentials = ! empty( $credentials_form );
79 ?>
80 <div class="fs-modal fs-modal-auto-install">
81 <div class="fs-modal-dialog">
82 <div class="fs-modal-header">
83 <h4><?php echo esc_js( fs_text_inline( 'Automatic Installation', 'auto-installation', $slug ) ) ?></h4>
84 </div>
85 <div class="fs-modal-body">
86 <div class="fs-notice-error" style="display: none"><p></p></div>
87 <?php if ( $require_credentials ) : ?>
88 <div id="request-filesystem-credentials-dialog">
89 <?php echo $credentials_form ?>
90 </div>
91 <?php else : ?>
92 <p class="fs-installation-notice"><?php echo sprintf(
93 fs_esc_html_inline( 'An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now.', 'installing-in-n', $slug ),
94 $plugin_title,
95 sprintf(
96 '<a href="%s" target="_blank" rel="noopener">%s</a>',
97 'https://freemius.com',
98 'freemius.com'
99 ),
100 $countdown_html
101 ) ?></p>
102 <?php endif ?>
103 <p class="fs-installing"
104 style="display: none"><?php echo sprintf( fs_esc_html_inline( 'The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page.', 'installing-module-x', $slug ), $plugin_title ) ?></p>
105 </div>
106 <div class="fs-modal-footer">
107 <?php echo $loader_html ?>
108 <button
109 class="button button-secondary button-cancel"><?php fs_esc_html_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?><?php if ( ! $require_credentials ) : ?> (<?php echo $countdown_html ?>)<?php endif ?></button>
110 <button
111 class="button button-primary"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></button>
112 </div>
113 </div>
114 </div>'
115
116 <script type="text/javascript">
117 (function ($) {
118 $(document).ready(function () {
119 var $modal = $('.fs-modal-auto-install'),
120 $body = $('body'),
121 $countdown = $modal.find('.fs-countdown'),
122 requireCredentials = <?php echo json_encode( $require_credentials ) ?>,
123 $credentialsForm = $('#request-filesystem-credentials-dialog'),
124 $errorNotice = $modal.find('.fs-notice-error'),
125 installing = false;
126
127 $modal.appendTo($body);
128
129 var startAutoInstall = function () {
130 if (installing)
131 return;
132
133 installing = true;
134
135 // Start auto-install.
136 $modal.addClass('fs-warn');
137 if (requireCredentials) {
138 $credentialsForm.hide();
139 } else {
140 $modal.find('.fs-installation-notice').hide();
141 }
142
143 $errorNotice.hide();
144 $modal.find('.fs-installing').show();
145 $modal.find('button').hide();
146 $modal.find('.fs-ajax-loader').show();
147
148 var data = {
149 action : '<?php echo $fs->get_ajax_action( 'install_premium_version' ) ?>',
150 security : '<?php echo $fs->get_ajax_security( 'install_premium_version' ) ?>',
151 slug : '<?php echo $slug ?>',
152 module_id : '<?php echo $fs->get_id() ?>',
153 target_module_id: '<?php echo $plugin_id ?>'
154 };
155
156 if (requireCredentials) {
157 // Add filesystem credentials.
158 data.hostname = $('#hostname').val();
159 data.username = $('#username').val();
160 data.password = $('#password').val();
161 data.connection_type = $('input[name="connection_type"]:checked').val();
162 data.public_key = $('#public_key').val();
163 data.private_key = $('#private_key').val();
164 }
165
166 $.ajax({
167 url : <?php echo Freemius::ajax_url() ?>,
168 method : 'POST',
169 data : data,
170 success: function (resultObj) {
171 var reloadAccount = false;
172
173 if (resultObj.success) {
174 // Reload account page to show new data.
175 reloadAccount = true;
176 } else {
177 switch (resultObj.error.code) {
178 case 'invalid_module_id':
179 case 'premium_installed':
180 reloadAccount = true;
181 break;
182 case 'invalid_license':
183 case 'premium_version_missing':
184 case 'unable_to_connect_to_filesystem':
185 default:
186 $modal.removeClass('fs-warn');
187 $modal.find('.fs-installing').hide();
188 $modal.find('.fs-ajax-loader').hide();
189 $modal.find('.button-cancel').html(<?php fs_json_encode_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?>);
190 $modal.find('button').show();
191
192 $errorNotice.find('p').text(resultObj.error.message);
193 $errorNotice.addClass('notice notice-alt notice-error').show();
194 if (requireCredentials) {
195 $credentialsForm.show();
196 }
197 break;
198 }
199 }
200
201 if (reloadAccount) {
202 window.location = '<?php echo $fs->get_account_url() ?>';
203 }
204
205 installing = false;
206 }
207 });
208 };
209
210 var clearCountdown = function () {
211 clearInterval(countdownInterval);
212 countdownInterval = null;
213 };
214
215 var cancelAutoInstall = function () {
216 $modal.fadeOut(function () {
217 $modal.remove();
218 $body.removeClass('has-fs-modal');
219 });
220 };
221
222 var countdown = <?php echo $sec_countdown ?>,
223 countdownInterval = requireCredentials ? null : setInterval(function () {
224 $countdown.html(--countdown);
225 if (0 == countdown) {
226 clearCountdown();
227 startAutoInstall();
228 }
229 }, 1000);
230
231 $modal.addClass('active');
232 $body.addClass('has-fs-modal');
233
234 $modal.find('.button-primary').click(function () {
235 clearCountdown();
236 startAutoInstall();
237 });
238
239 $modal.find('.button-cancel').click(function () {
240 clearCountdown();
241 cancelAutoInstall();
242 });
243
244 if (requireCredentials) {
245
246 }
247 });
248 })(jQuery);
249 </script>
250