PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.4
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.4
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / auto-installation.php

auto-installation.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.4, at freemius/templates/auto-installation.php

249 lines 7.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 */
16 $slug = $VARS['slug'];
17 $plugin_id = $VARS['target_module_id'];
18
19 $fs = freemius( $VARS['id'] );
20
21 $action = $fs->is_tracking_allowed() ?
22 'stop_tracking' :
23 'allow_tracking';
24
25 $title = $fs->get_plugin_title();
26
27 if ( $plugin_id != $fs->get_id() ) {
28 $addon = $fs->get_addon( $plugin_id );
29
30 if ( is_object( $addon ) ) {
31 $title = $addon->title . ' ' . fs_text_inline( 'Add-On', 'addon', $slug );
32 }
33 }
34
35 $plugin_title = sprintf(
36 '<strong>%s</strong>',
37 esc_html( $title )
38 );
39
40 $sec_countdown = 30;
41 $countdown_html = sprintf(
42 esc_js(
43 /* translators: %s: Number of seconds */
44 fs_text_inline( '%s sec', 'x-sec', $slug )
45 ),
46 sprintf( '<span class="fs-countdown">%s</span>', $sec_countdown )
47 );
48
49 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
50 fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
51
52 $params = array();
53 $loader_html = fs_get_template( 'ajax-loader.php', $params );
54
55 // Pass unique auto installation URL if WP_Filesystem is needed.
56 $install_url = $fs->_get_sync_license_url(
57 $plugin_id,
58 true,
59 array( 'auto_install' => 'true' )
60 );
61
62
63 ob_start();
64
65 $method = ''; // Leave blank so WP_Filesystem can populate it as necessary.
66
67 $credentials = request_filesystem_credentials(
68 esc_url_raw( $install_url ),
69 $method,
70 false,
71 WP_PLUGIN_DIR,
72 array()
73 );
74
75 $credentials_form = ob_get_clean();
76
77 $require_credentials = ! empty( $credentials_form );
78 ?>
79 <div class="fs-modal fs-modal-auto-install">
80 <div class="fs-modal-dialog">
81 <div class="fs-modal-header">
82 <h4><?php echo esc_js( fs_text_inline( 'Automatic Installation', 'auto-installation', $slug ) ) ?></h4>
83 </div>
84 <div class="fs-modal-body">
85 <div class="fs-notice-error" style="display: none"><p></p></div>
86 <?php if ( $require_credentials ) : ?>
87 <div id="request-filesystem-credentials-dialog">
88 <?php echo $credentials_form ?>
89 </div>
90 <?php else : ?>
91 <p class="fs-installation-notice"><?php echo sprintf(
92 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 ),
93 $plugin_title,
94 sprintf(
95 '<a href="%s" target="_blank">%s</a>',
96 'https://freemius.com',
97 'freemius.com'
98 ),
99 $countdown_html
100 ) ?></p>
101 <?php endif ?>
102 <p class="fs-installing"
103 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>
104 </div>
105 <div class="fs-modal-footer">
106 <?php echo $loader_html ?>
107 <button
108 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>
109 <button
110 class="button button-primary"><?php fs_esc_html_echo_inline( 'Install Now', 'install-now', $slug ) ?></button>
111 </div>
112 </div>
113 </div>'
114
115 <script type="text/javascript">
116 (function ($) {
117 $(document).ready(function () {
118 var $modal = $('.fs-modal-auto-install'),
119 $body = $('body'),
120 $countdown = $modal.find('.fs-countdown'),
121 requireCredentials = <?php echo json_encode( $require_credentials ) ?>,
122 $credentialsForm = $('#request-filesystem-credentials-dialog'),
123 $errorNotice = $modal.find('.fs-notice-error'),
124 installing = false;
125
126 $modal.appendTo($body);
127
128 var startAutoInstall = function () {
129 if (installing)
130 return;
131
132 installing = true;
133
134 // Start auto-install.
135 $modal.addClass('fs-warn');
136 if (requireCredentials) {
137 $credentialsForm.hide();
138 } else {
139 $modal.find('.fs-installation-notice').hide();
140 }
141
142 $errorNotice.hide();
143 $modal.find('.fs-installing').show();
144 $modal.find('button').hide();
145 $modal.find('.fs-ajax-loader').show();
146
147 var data = {
148 action : '<?php echo $fs->get_ajax_action( 'install_premium_version' ) ?>',
149 security : '<?php echo $fs->get_ajax_security( 'install_premium_version' ) ?>',
150 slug : '<?php echo $slug ?>',
151 module_id : '<?php echo $fs->get_id() ?>',
152 target_module_id: '<?php echo $plugin_id ?>'
153 };
154
155 if (requireCredentials) {
156 // Add filesystem credentials.
157 data.hostname = $('#hostname').val();
158 data.username = $('#username').val();
159 data.password = $('#password').val();
160 data.connection_type = $('input[name="connection_type"]:checked').val();
161 data.public_key = $('#public_key').val();
162 data.private_key = $('#private_key').val();
163 }
164
165 $.ajax({
166 url : ajaxurl,
167 method : 'POST',
168 data : data,
169 success: function (resultObj) {
170 var reloadAccount = false;
171
172 if (resultObj.success) {
173 // Reload account page to show new data.
174 reloadAccount = true;
175 } else {
176 switch (resultObj.error.code) {
177 case 'invalid_module_id':
178 case 'premium_installed':
179 reloadAccount = true;
180 break;
181 case 'invalid_license':
182 case 'premium_version_missing':
183 case 'unable_to_connect_to_filesystem':
184 default:
185 $modal.removeClass('fs-warn');
186 $modal.find('.fs-installing').hide();
187 $modal.find('.fs-ajax-loader').hide();
188 $modal.find('.button-cancel').html(<?php fs_json_encode_echo_inline( 'Cancel Installation', 'cancel-installation', $slug ) ?>);
189 $modal.find('button').show();
190
191 $errorNotice.find('p').text(resultObj.error.message);
192 $errorNotice.addClass('notice notice-alt notice-error').show();
193 if (requireCredentials) {
194 $credentialsForm.show();
195 }
196 break;
197 }
198 }
199
200 if (reloadAccount) {
201 window.location = '<?php echo $fs->get_account_url() ?>';
202 }
203
204 installing = false;
205 }
206 });
207 };
208
209 var clearCountdown = function () {
210 clearInterval(countdownInterval);
211 countdownInterval = null;
212 };
213
214 var cancelAutoInstall = function () {
215 $modal.fadeOut(function () {
216 $modal.remove();
217 $body.removeClass('has-fs-modal');
218 });
219 };
220
221 var countdown = <?php echo $sec_countdown ?>,
222 countdownInterval = requireCredentials ? null : setInterval(function () {
223 $countdown.html(--countdown);
224 if (0 == countdown) {
225 clearCountdown();
226 startAutoInstall();
227 }
228 }, 1000);
229
230 $modal.addClass('active');
231 $body.addClass('has-fs-modal');
232
233 $modal.find('.button-primary').click(function () {
234 clearCountdown();
235 startAutoInstall();
236 });
237
238 $modal.find('.button-cancel').click(function () {
239 clearCountdown();
240 cancelAutoInstall();
241 });
242
243 if (requireCredentials) {
244
245 }
246 });
247 })(jQuery);
248 </script>
249