PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 1.0.4
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v1.0.4
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / includes / Admin / Setup_Wizard.php

Setup_Wizard.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 1.0.4, at includes/Admin/Setup_Wizard.php

519 lines 29.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Better_Payment\Lite\Admin;
4
5 use Better_Payment\Lite\Classes\Plugin_Usage_Tracker;
6
7 if (!defined('ABSPATH')) {
8 exit;
9 } // Exit if accessed directly.
10
11 /**
12 * Setup Wizard
13 *
14 * @since 0.0.2
15 */
16 class Setup_Wizard
17 {
18 protected $file_version;
19
20 /**
21 * Setup Wizard constructor.
22 *
23 * @since 0.0.2
24 */
25 public function __construct()
26 {
27 $this->file_version = defined('WP_DEBUG') && WP_DEBUG ? time() : BETTER_PAYMENT_VERSION;
28 add_action('admin_enqueue_scripts', array($this, 'setup_wizard_scripts'));
29 add_action('admin_menu', array($this, 'admin_menu'));
30 add_action('wp_ajax_save_setup_wizard_data', [$this, 'save_setup_wizard_data']);
31 add_action('in_admin_header', [$this, 'remove_notice'], 1000);
32 }
33
34 /**
35 * Remove all notice in setup wizard page
36 *
37 * @since 0.0.2
38 */
39 public function remove_notice()
40 {
41 if (isset($_GET['page']) && $_GET['page'] == 'better-payment-setup-wizard') {
42 remove_all_actions('admin_notices');
43 remove_all_actions('all_admin_notices');
44 }
45 }
46
47 /**
48 * setup_wizard_scripts
49 * @param $hook
50 * @return array
51 *
52 * @since 0.0.2
53 */
54 public function setup_wizard_scripts($hook)
55 {
56 if (isset($hook) && $hook == 'admin_page_better-payment-setup-wizard') {
57 //Styles
58 wp_register_style('jquery-ui', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.min.css');
59 wp_enqueue_style('jquery-ui');
60
61 wp_enqueue_style('bp-setup-wizard-style', BETTER_PAYMENT_ASSETS . '/css/setup-wizard.min.css', null, $this->file_version);
62 wp_enqueue_style('bp-settings-style', BETTER_PAYMENT_ASSETS . '/css/style.min.css', null, $this->file_version);
63 wp_enqueue_style('bp-icon-admin', BETTER_PAYMENT_ASSETS . '/icon/style.min.css');
64 wp_enqueue_style('sweetalert2-css', BETTER_PAYMENT_ASSETS . '/vendor/sweetalert2/css/sweetalert2.min.css');
65
66 //Scripts
67 wp_enqueue_script('bp-setup-wizard-js', BETTER_PAYMENT_ASSETS . '/js/setup-wizard.min.js', null, $this->file_version);
68
69 wp_localize_script('bp-setup-wizard-js', 'betterPaymentObjWizard', array(
70 'nonce' => wp_create_nonce('better_payment_admin_nonce'),
71 'success_image' => BETTER_PAYMENT_ASSETS . '/img/success.gif',
72 'alerts' => [
73 'confirm' => esc_html__('Are you sure?', 'better-payment'),
74 'confirm_description' => esc_html__("You won't be able to revert this!", 'better-payment'),
75 'yes' => esc_html__('Yes, delete it!', 'better-payment'),
76 'no' => esc_html__('No, cancel!', 'better-payment'),
77 ],
78 'messages' => [
79 'success' => esc_html__('Changes saved successfully!', 'better-payment'),
80 'error' => esc_html__('Opps! something went wrong!', 'better-payment'),
81 'no_action_taken' => esc_html__('No action taken!', 'better-payment'),
82 ]
83 ));
84
85 wp_enqueue_script('bp-setup-wizard-localize');
86
87 wp_enqueue_script('sweetalert2-js', BETTER_PAYMENT_ASSETS . '/vendor/sweetalert2/js/sweetalert2.min.js', array('jquery'), BETTER_PAYMENT_VERSION, true);
88 }
89 return [];
90 }
91
92 /**
93 * Create admin menu for setup wizard
94 *
95 * @since 0.0.2
96 */
97 public function admin_menu()
98 {
99
100 add_submenu_page(
101 '',
102 esc_html__('Better Payment ', 'better-payment'),
103 esc_html__('Better Payment ', 'better-payment'),
104 'manage_options',
105 'better-payment-setup-wizard',
106 [$this, 'render_wizard']
107 );
108 }
109
110 /**
111 * Render tab step
112 *
113 * @since 0.0.2
114 */
115 public function tab_step()
116 {
117 $wizard_column = 'four';
118 ?>
119 <ul class="better-payment-setup-wizard <?php echo esc_attr( $wizard_column ); ?>" data-step="0">
120 <li class="step">
121 <div class="icon">
122 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
123 <g>
124 <path class="st0" d="M50,25c0-1.9-1.3-3.8-3-4.4c-1.6-0.6-3.2-2-3.7-3.1c-0.5-1.1-0.3-3.3,0.4-4.9c0.8-1.6,0.3-3.9-1-5.2
125 c-1.3-1.3-3.7-1.8-5.2-1c-1.6,0.8-3.7,0.9-4.9,0.4C31.5,6.2,30,4.6,29.4,3c-0.6-1.7-2.6-3-4.4-3c-1.9,0-3.8,1.3-4.4,3
126 c-0.6,1.7-2,3.3-3.1,3.7c-1.1,0.5-3.3,0.3-4.9-0.4C11,5.5,8.6,6,7.3,7.3C6,8.6,5.5,11,6.3,12.6c0.8,1.6,0.9,3.7,0.4,4.9
127 C6.2,18.6,4.6,20,3,20.6c-1.7,0.6-3,2.6-3,4.4c0,1.9,1.3,3.8,3,4.4c1.7,0.6,3.2,2,3.7,3.1c0.5,1.1,0.3,3.3-0.4,4.9
128 c-0.8,1.6-0.3,3.9,1,5.2c1.3,1.3,3.7,1.8,5.2,1c1.6-0.8,3.7-0.9,4.9-0.4c1.1,0.5,2.6,2.1,3.1,3.7c0.6,1.7,2.6,3,4.4,3
129 c1.9,0,3.8-1.3,4.4-3c0.6-1.6,2-3.3,3.1-3.7c1.1-0.5,3.3-0.3,4.9,0.4c1.6,0.8,3.9,0.3,5.2-1c1.3-1.3,1.8-3.7,1-5.2
130 c-0.8-1.6-0.9-3.7-0.4-4.9c0.5-1.1,2.1-2.6,3.7-3.1C48.7,28.8,50,26.9,50,25L50,25z M25,34.2c-5.1,0-9.2-4.1-9.2-9.2
131 c0-5.1,4.1-9.2,9.2-9.2c5.1,0,9.2,4.1,9.2,9.2C34.2,30.1,30.1,34.2,25,34.2L25,34.2z M25,34.2" />
132 </g>
133 </svg>
134 </div>
135 <div class="name"><?php esc_html_e('Getting Started', 'better-payment'); ?></div>
136 </li>
137 <li class="step">
138 <div class="icon">
139 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
140 <path class="st0" d="M48.9,16.6c-0.7-0.7-1.6-1.1-2.6-1.1c-1,0-1.9,0.4-2.6,1.1l-8.8,8.8L24.7,15.1l8.8-8.8c0.7-0.7,1.1-1.6,1.1-2.6
141 c0-1-0.4-1.9-1.1-2.6C32.7,0.4,31.8,0,30.8,0c-1,0-1.9,0.4-2.6,1.1l-8.8,8.8l-5.6-5.6c-0.3-0.3-0.6-0.4-1-0.4c-0.4,0-0.7,0.2-1,0.4
142 c-8,8.8-3.7,28-3.2,29.9l-8.1,8.1c-0.3,0.2-0.4,0.6-0.4,0.9c0,0.4,0.1,0.7,0.4,0.9L5.5,49c0.3,0.3,0.6,0.4,0.9,0.4
143 c0.3,0,0.7-0.1,0.9-0.4l8.1-8.1c3.9,1,8.8,1.6,13.2,1.6c5.2,0,12.3-0.8,16.7-4.8c0.3-0.2,0.4-0.6,0.4-1c0-0.4-0.1-0.7-0.4-1
144 l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
145 </svg>
146 </div>
147 <div class="name"><?php esc_html_e('PayPal Configuration', 'better-payment'); ?></div>
148 </li>
149 <li class="step">
150 <div class="icon">
151 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
152 <path class="st0" d="M48.9,16.6c-0.7-0.7-1.6-1.1-2.6-1.1c-1,0-1.9,0.4-2.6,1.1l-8.8,8.8L24.7,15.1l8.8-8.8c0.7-0.7,1.1-1.6,1.1-2.6
153 c0-1-0.4-1.9-1.1-2.6C32.7,0.4,31.8,0,30.8,0c-1,0-1.9,0.4-2.6,1.1l-8.8,8.8l-5.6-5.6c-0.3-0.3-0.6-0.4-1-0.4c-0.4,0-0.7,0.2-1,0.4
154 c-8,8.8-3.7,28-3.2,29.9l-8.1,8.1c-0.3,0.2-0.4,0.6-0.4,0.9c0,0.4,0.1,0.7,0.4,0.9L5.5,49c0.3,0.3,0.6,0.4,0.9,0.4
155 c0.3,0,0.7-0.1,0.9-0.4l8.1-8.1c3.9,1,8.8,1.6,13.2,1.6c5.2,0,12.3-0.8,16.7-4.8c0.3-0.2,0.4-0.6,0.4-1c0-0.4-0.1-0.7-0.4-1
156 l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
157 </svg>
158 </div>
159 <div class="name"><?php esc_html_e('Stripe Configuration', 'better-payment'); ?></div>
160 </li>
161 <li class="step">
162 <div class="icon">
163 <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
164 <path class="st0" d="M48.5,3.1l-0.3-0.3c-0.9-0.9-2.1-1.4-3.3-1.3c-1.2,0-2.4,0.6-3.3,1.5L16.1,30.9l-0.5,0.2l-0.5-0.2l-6.3-7.4
165 c-0.9-1.1-2.2-1.7-3.6-1.8c-1.4-0.1-2.8,0.5-3.8,1.5c-1.6,1.6-1.8,4.1-0.5,5.9l13.1,18.3c0.7,1,1.9,1.7,3.2,1.7h1.1
166 c2.2,0,4.2-1.1,5.4-2.8L49.1,9.5C50.5,7.5,50.2,4.8,48.5,3.1z" />
167 </svg>
168 </div>
169 <div class="name"><?php esc_html_e('Finalize', 'better-payment'); ?></div>
170 </li>
171 </ul>
172 <?php
173 }
174
175 /**
176 * Get currency list
177 *
178 * @since 0.0.2
179 */
180 public function get_currency_list(){
181 $currency_list = [
182 'USD' => 'USD',
183 'EUR' => 'EUR',
184 'GBP' => 'GBP',
185 'AUD' => 'AUD',
186 'CAD' => 'CAD',
187 'CZK' => 'CZK',
188 'DKK' => 'DKK',
189 'HKD' => 'HKD',
190 'HUF' => 'HUF',
191 'ILS' => 'ILS',
192 'JPY' => 'JPY',
193 'MXN' => 'MXN',
194 'NOK' => 'NOK',
195 'NZD' => 'NZD',
196 'PHP' => 'PHP',
197 'PLN' => 'PLN',
198 'RUB' => 'RUB',
199 'SGD' => 'SGD',
200 'SEK' => 'SEK',
201 'CHF' => 'CHF',
202 'TWD' => 'TWD',
203 'THB' => 'THB',
204 ];
205
206 return $currency_list;
207 }
208
209 /**
210 * Tav view content
211 *
212 * @since 0.0.2
213 */
214 public function tab_content($bp_admin_saved_settings)
215 {
216 $bp_admin_saved_settings = DB::get_settings();
217 $currency_list = $this->get_currency_list();
218 ?>
219 <div class="better-payment-setup-body better-payment">
220 <form method="post" id="better-payment-admin-settings-form" class="better-payment-setup-wizard-form" action="#">
221
222 <div id="configuration" class="setup-content active">
223 <div id="general" class="sidebar__tab__content show payment__options better-payment-box">
224 <div class="payment__option">
225 <div class="payment__option__content">
226 <h4><?php esc_html_e('PayPal', 'better-payment'); ?></h4>
227 <p><?php esc_html_e('Enable PayPal if you want to make transaction using PayPal.', 'better-payment'); ?></p>
228 </div>
229 <div class="active__status">
230 <label class="bp-switch">
231 <input type="hidden" name="better_payment_settings_general_general_paypal" value="no">
232 <input type="checkbox" name="better_payment_settings_general_general_paypal" value="yes" <?php echo isset($bp_admin_saved_settings['better_payment_settings_general_general_paypal']) && $bp_admin_saved_settings['better_payment_settings_general_general_paypal'] == 'yes' ? ' checked' : '' ?>>
233 <span class="switch__btn"></span>
234 </label>
235 </div>
236 </div>
237 <div class="payment__option">
238 <div class="payment__option__content">
239 <h4><?php esc_html_e('Stripe', 'better-payment'); ?></h4>
240 <p><?php esc_html_e('Enable Stripe if you want to accept payment via Stripe.', 'better-payment'); ?></p>
241 </div>
242 <div class="active__status">
243 <label class="bp-switch">
244 <input type="hidden" name="better_payment_settings_general_general_stripe" value="no">
245 <input type="checkbox" name="better_payment_settings_general_general_stripe" value="yes" <?php echo isset($bp_admin_saved_settings['better_payment_settings_general_general_stripe']) && $bp_admin_saved_settings['better_payment_settings_general_general_stripe'] == 'yes' ? ' checked' : '' ?>>
246 <span class="switch__btn"></span>
247 </label>
248 </div>
249 </div>
250 <div class="payment__option">
251 <div class="payment__option__content">
252 <h4><?php esc_html_e('Email Notification', 'better-payment'); ?></h4>
253 <p><?php esc_html_e('Enable email notification for each transaction. It sends notification to the website admin and customer (who makes the payment). You can modify email settings as per your need.', 'better-payment'); ?></p>
254 </div>
255 <div class="active__status">
256 <label class="bp-switch">
257 <input type="hidden" name="better_payment_settings_general_general_email" value="no">
258 <input type="checkbox" name="better_payment_settings_general_general_email" value="yes" <?php echo isset($bp_admin_saved_settings['better_payment_settings_general_general_email']) && $bp_admin_saved_settings['better_payment_settings_general_general_email'] == 'yes' ? ' checked' : '' ?>>
259 <span class="switch__btn"></span>
260 </label>
261 </div>
262 </div>
263 <div class="payment__option">
264 <div class="payment__option__content">
265 <h4><?php esc_html_e('Currency', 'better-payment'); ?></h4>
266 <p><?php esc_html_e('Select default currency for each transaction. You can also overwrite this setting from each widget control on elementor page builder.', 'better-payment'); ?></p>
267 </div>
268 <div class="active__status">
269 <div class="bp-select">
270 <select name="better_payment_settings_general_general_currency">
271 <option value="" disabled> <?php esc_html_e('Select Currency', 'better-payment'); ?> </option>
272 <?php foreach ($currency_list as $key => $value){
273 $selected = isset($bp_admin_saved_settings['better_payment_settings_general_general_currency']) && $bp_admin_saved_settings['better_payment_settings_general_general_currency'] == $key?'selected':'';
274 printf( '<option value="%s" %s >%s</option>', esc_attr( $key ), esc_attr( $selected ), esc_html__( $key, 'better-payment' ) );
275 } ?>
276 </select>
277 </div>
278 </div>
279 </div>
280 </div>
281 </div>
282
283 <div id="quick-setup-paypal" class="setup-content quick-setup-paypal better-payment-box">
284 <div class="payment__options ">
285 <div class="payment__option">
286 <div class="payment__option__content">
287 <h4><?php esc_html_e('Live Mode', 'better-payment'); ?></h4>
288 <p><?php esc_html_e('Live mode allows you to process real transactions. It just requires PayPal business email to accept real payments.', 'better-payment'); ?></p>
289 </div>
290 <div class="active__status">
291 <label class="bp-switch">
292 <input type="hidden" name="better_payment_settings_payment_paypal_live_mode" value="no">
293 <input type="checkbox" name="better_payment_settings_payment_paypal_live_mode" value="yes" data-target="better-payment-settings-payment-paypal-live" <?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_paypal_live_mode']) && $bp_admin_saved_settings['better_payment_settings_payment_paypal_live_mode'] == 'yes' ? ' checked' : '' ?>>
294 <span class="switch__btn"></span>
295 </label>
296 </div>
297 </div>
298 <div class="payment__option">
299 <div class="payment__option__content">
300 <h4><?php esc_html_e('Business Email', 'better-payment'); ?></h4>
301 <p><?php esc_html_e('Your PayPal account email address to accept payment via PayPal.', 'better-payment'); ?></p>
302 </div>
303 <div class="active__status input__wrap">
304 <input type="email" class="form__control" name="better_payment_settings_payment_paypal_email" value="<?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_paypal_email']) ? esc_html( $bp_admin_saved_settings['better_payment_settings_payment_paypal_email'] ) : '' ?>">
305 </div>
306 </div>
307 </div>
308 </div>
309
310 <div id="quick-setup-stripe" class="setup-content quick-setup-stripe">
311 <div class="payment__options">
312 <div class="payment__option">
313 <div class="payment__option__content">
314 <h4><?php esc_html_e('Live Mode', 'better-payment'); ?></h4>
315 <p><?php esc_html_e('Live mode allows you to process real transactions. It just requires live Stripe keys (public and secret keys) to accept real payments.', 'better-payment'); ?></p>
316 </div>
317 <div class="active__status">
318 <label class="bp-switch">
319 <input type="hidden" name="better_payment_settings_payment_stripe_live_mode" value="no">
320 <input type="checkbox" name="better_payment_settings_payment_stripe_live_mode" value="yes" data-targettest="bp-stripe-test-key" data-targetlive="bp-stripe-live-key" <?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_live_mode']) && $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_mode'] == 'yes' ? ' checked' : '' ?>>
321 <span class="switch__btn"></span>
322 </label>
323 </div>
324 </div>
325
326 <?php $better_payment_settings_payment_stripe_live = isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_live_mode']) && $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_mode'] == 'yes'; ?>
327
328 <div class="payment__option bp-stripe-key bp-stripe-live-key <?php echo $better_payment_settings_payment_stripe_live ? 'bp-d-block' : 'bp-d-none' ?>">
329 <div class="payment__option__content">
330 <h4><?php esc_html_e('Live Public Key', 'better-payment'); ?></h4>
331 <p><?php esc_html_e('Stripe live public key is required to make payments via Stripe. For more help visit', 'better-payment'); ?> <a class="color__themeColor" target="_blank" rel="nofollow" href="https://stripe.com/docs/keys">https://stripe.com/docs/keys</a>.</p>
332 </div>
333 <div class="active__status input__wrap">
334 <input type="text" class="form__control mt15" name="better_payment_settings_payment_stripe_live_public" value="<?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_live_public']) ? esc_attr( $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_public'] ) : '' ?>" type="text" placeholder="<?php //esc_html_e('Live public key', 'better-payment'); ?>">
335 </div>
336 </div>
337 <div class="payment__option bp-stripe-key bp-stripe-live-key <?php echo $better_payment_settings_payment_stripe_live ? 'bp-d-block' : 'bp-d-none' ?>">
338 <div class="payment__option__content">
339 <h4><?php esc_html_e('Live Secret Key', 'better-payment'); ?></h4>
340 <p><?php esc_html_e('Stripe live secret key is required to make payments via Stripe. For more help visit', 'better-payment'); ?> <a class="color__themeColor" target="_blank" rel="nofollow" href="https://stripe.com/docs/keys">https://stripe.com/docs/keys</a>.</p>
341 </div>
342 <div class="active__status input__wrap">
343 <input type="password" class="form__control mt15" name="better_payment_settings_payment_stripe_live_secret" value="<?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_live_secret']) ? esc_attr( $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_secret'] ) : '' ?>">
344 </div>
345 </div>
346 <div class="payment__option bp-stripe-key bp-stripe-test-key <?php echo $better_payment_settings_payment_stripe_live ? 'bp-d-none' : 'bp-d-block' ?> ">
347 <div class="payment__option__content">
348 <h4><?php esc_html_e('Test Public Key', 'better-payment'); ?></h4>
349 <p><?php esc_html_e('Stripe test public key is required to make payments via Stripe. For more help visit', 'better-payment'); ?> <a class="color__themeColor" target="_blank" rel="nofollow" href="https://stripe.com/docs/keys">https://stripe.com/docs/keys</a>.</p>
350 </div>
351 <div class="active__status input__wrap">
352 <input type="text" class="form__control mt15" name="better_payment_settings_payment_stripe_test_public" value="<?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_test_public']) ? esc_attr( $bp_admin_saved_settings['better_payment_settings_payment_stripe_test_public'] ) : '' ?>">
353 </div>
354 </div>
355 <div class="payment__option bp-stripe-key bp-stripe-test-key <?php echo $better_payment_settings_payment_stripe_live ? 'bp-d-none' : 'bp-d-block' ?> ">
356 <div class="payment__option__content">
357 <h4><?php esc_html_e('Test Secret Key', 'better-payment'); ?></h4>
358 <p><?php esc_html_e('Stripe test secret key is required to make payments via Stripe. For more help visit', 'better-payment'); ?> <a class="color__themeColor" target="_blank" rel="nofollow" href="https://stripe.com/docs/keys">https://stripe.com/docs/keys</a>.</p>
359 </div>
360 <div class="active__status input__wrap">
361 <input type="password" class="form__control mt15" name="better_payment_settings_payment_stripe_test_secret" value="<?php echo isset($bp_admin_saved_settings['better_payment_settings_payment_stripe_test_secret']) ? esc_attr( $bp_admin_saved_settings['better_payment_settings_payment_stripe_test_secret'] ) : '' ?>">
362 </div>
363 </div>
364 </div>
365 </div>
366
367 <div id="finalize" class="setup-content better-payment-box">
368 <header class="pb31 text-center">
369 <div class="bp-container">
370 <div class="bp-row">
371 <div class="bp-col">
372 <div class="logo">
373 <a href="javascript:void(0)"><img src="<?php echo esc_url( BETTER_PAYMENT_ASSETS . '/img/logo.svg' ); ?>" alt="Better Payment logo"></a>
374 </div>
375 </div>
376 </div>
377 </div>
378 </header>
379 <h2 class="text-center"><?php esc_html_e('Great Job! Your Configuration is Complete ', 'better-payment'); ?>🎉</h2>
380 <p> <input class="better_payment_settings_opt_in" type="checkbox" name="better_payment_settings_opt_in" value="yes" <?php echo isset($bp_admin_saved_settings['better_payment_settings_opt_in']) && $bp_admin_saved_settings['better_payment_settings_opt_in'] == 'yes' ? ' checked' : '' ?>>
381 <label for="better_payment_settings_opt_in"><?php esc_html_e('Share non-sensitive diagnostic data and plugin usage information.', 'better-payment'); ?></label>
382 </p>
383 <p><?php esc_html_e('What do we collect? We collect non-sensitive diagnostic data and plugin usage information. Your site URL, WordPress & PHP version, plugins & themes and email address to send you the discount coupon. This data lets us make sure this plugin always stays compatible with the most popular plugins and themes. No spam, we promise.', 'better-payment'); ?></p>
384 </div>
385 </form>
386 </div>
387 <?php
388 }
389
390 /**
391 * Footer content
392 *
393 * @since 0.0.1
394 */
395 public function setup_wizard_footer()
396 {
397 ?>
398 <div class="better-payment better-payment-setup-footer">
399 <button id="better-payment-prev" class="button button__active better-payment-admin-settings-button"><?php esc_html_e('< Previous', 'better-payment') ?></button>
400 <button id="better-payment-next" class="button button__active better-payment-admin-settings-button"><?php esc_html_e('Next >', 'better-payment') ?></button>
401 <button id="better-payment-save" style="display: none" class="button button__active better-payment-admin-settings-button better-payment-setup-wizard-save"><?php esc_html_e('Finish', 'better-payment') ?></button>
402 </div>
403 <?php
404 }
405
406 /**
407 * render_wizard
408 *
409 * @since 0.0.1
410 */
411 public function render_wizard()
412 {
413 ?>
414 <div class="better-payment-setup-wizard-wrap">
415 <?php
416 $bp_admin_saved_settings = DB::get_settings();
417
418 $this->change_site_title();
419 $this->tab_step();
420 $this->tab_content($bp_admin_saved_settings);
421 $this->setup_wizard_footer();
422 ?>
423 </div>
424 <?php
425 }
426
427 /**
428 * Save setup wizard data
429 *
430 * @since 0.0.1
431 */
432 public static function save_setup_wizard_data()
433 {
434 /**
435 * Verify the Nonce
436 */
437 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'better_payment_admin_nonce')) {
438 return;
439 }
440
441 try{
442 Settings::save_default_settings(1);
443 Settings::save_settings($_POST['form_data']);
444
445 $posted_field_opt_in_val = '';
446 foreach ($_POST['form_data'] as $posted_field) {
447 $posted_field_name = sanitize_key($posted_field['name']);
448 $posted_field_value = sanitize_key($posted_field['value']);
449
450 if('better_payment_settings_opt_in' === $posted_field_name){
451 $posted_field_opt_in_val = $posted_field_value;
452 break;
453 }
454 }
455
456 if ( 'yes' === $posted_field_opt_in_val ) {
457 self::wpins_process();
458 }
459
460 update_option( 'better_payment_setup_wizard', 'complete' );
461
462 if (!did_action('elementor/loaded')) {
463 wp_send_json_success( [ 'redirect_url' => admin_url() ] );
464 }else {
465 wp_send_json_success( [ 'redirect_url' => admin_url( 'admin.php?page=better-payment-settings' ) ] );
466 }
467 }catch (\Exception $e) {
468 wp_send_json_error($e->getMessage());
469 }
470
471 die;
472 }
473
474 /**
475 * WPIns process
476 *
477 * @since 0.0.1
478 */
479 public static function wpins_process(){
480 $plugin_name = basename( BETTER_PAYMENT_FILE, '.php' );
481
482 require_once BETTER_PAYMENT_PATH . 'includes/class-better-payment-plugin-usage-tracker.php';
483
484 if ( class_exists( 'Plugin_Usage_Tracker' ) ){
485 $tracker = Plugin_Usage_Tracker::get_instance( BETTER_PAYMENT_FILE, [
486 'opt_in' => true,
487 'goodbye_form' => true,
488 'item_id' => '64e1f724b5e14edb343e'
489 ] );
490 $tracker->set_is_tracking_allowed( true );
491 $tracker->do_tracking( true );
492 }
493 }
494
495 /**
496 * Redirect
497 *
498 * @since 0.0.1
499 */
500 public static function redirect()
501 {
502 update_option('better_payment_setup_wizard', 'init');
503 wp_redirect(admin_url('admin.php?page=better-payment-setup-wizard'));
504 }
505
506 /**
507 * Site title
508 *
509 * @since 0.0.1
510 */
511 public function change_site_title()
512 {
513 ?>
514 <script>
515 document.title = "<?php esc_html_e('Quick Setup Wizard - Better Payment', 'better-payment'); ?>"
516 </script>
517 <?php
518 }
519 }