PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 0.0.2
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v0.0.2
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 / admin / includes / class-better-payment-setup-wizard.php

class-better-payment-setup-wizard.php in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 0.0.2, at admin/includes/class-better-payment-setup-wizard.php

466 lines 27.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3
4 if (!defined('ABSPATH')) {
5 exit;
6 } // Exit if accessed directly.
7
8 class Better_Payment_Setup_Wizard
9 {
10 protected $file_version;
11
12 public function __construct()
13 {
14 $this->file_version = defined('WP_DEBUG') && WP_DEBUG ? time() : BETTER_PAYMENT_VERSION;
15 add_action('admin_enqueue_scripts', array($this, 'setup_wizard_scripts'));
16 add_action('admin_menu', array($this, 'admin_menu'));
17 add_action('wp_ajax_save_setup_wizard_data', [$this, 'save_setup_wizard_data']);
18 add_action('in_admin_header', [$this, 'remove_notice'], 1000);
19 }
20
21 /**
22 * Remove all notice in setup wizard page
23 */
24 public function remove_notice()
25 {
26 if (isset($_GET['page']) && $_GET['page'] == 'better-payment-setup-wizard') {
27 remove_all_actions('admin_notices');
28 remove_all_actions('all_admin_notices');
29 }
30 }
31
32 /**
33 * setup_wizard_scripts
34 * @param $hook
35 * @return array
36 */
37 public function setup_wizard_scripts($hook)
38 {
39 if (isset($hook) && $hook == 'admin_page_better-payment-setup-wizard') {
40 //Styles
41 wp_register_style('jquery-ui', '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.min.css');
42 wp_enqueue_style('jquery-ui');
43
44 wp_enqueue_style('bp-setup-wizard-style', BETTER_PAYMENT_ADMIN_ASSET_URL . 'css/setup-wizard.min.css', null, $this->file_version);
45 wp_enqueue_style('bp-settings-style', BETTER_PAYMENT_ADMIN_ASSET_URL . 'css/style.min.css', null, $this->file_version);
46 wp_enqueue_style('bp-icon-admin', BETTER_PAYMENT_ADMIN_ASSET_URL . 'icon/style.min.css');
47 wp_enqueue_style('sweetalert2-css', BETTER_PAYMENT_URL . 'asset/vendor/sweetalert2/css/sweetalert2.min.css');
48
49 //Scripts
50 wp_enqueue_script('bp-setup-wizard-js', BETTER_PAYMENT_ADMIN_ASSET_URL . 'js/setup-wizard.min.js', null, $this->file_version);
51
52 wp_localize_script('bp-setup-wizard-js', 'betterPaymentObjWizard', array(
53 'nonce' => wp_create_nonce('better_payment_admin_nonce'),
54 'success_image' => BETTER_PAYMENT_ADMIN_ASSET_URL . 'img/success.gif',
55 'alerts' => [
56 'confirm' => __('Are you sure?', 'better-payment'),
57 'confirm_description' => __("You won't be able to revert this!", 'better-payment'),
58 'yes' => __('Yes, delete it!', 'better-payment'),
59 'no' => __('No, cancel!', 'better-payment'),
60 ],
61 'messages' => [
62 'success' => __('Changes saved successfully!', 'better-payment'),
63 'error' => __('Opps! something went wrong!', 'better-payment'),
64 'no_action_taken' => __('No action taken!', 'better-payment'),
65 ]
66 ));
67
68 wp_enqueue_script('bp-setup-wizard-localize');
69
70 wp_enqueue_script('sweetalert2-js', BETTER_PAYMENT_URL . 'asset/vendor/sweetalert2/js/sweetalert2.min.js', array('jquery'), BETTER_PAYMENT_VERSION, true);
71 }
72 return [];
73 }
74
75 /**
76 * Create admin menu for setup wizard
77 */
78 public function admin_menu()
79 {
80
81 add_submenu_page(
82 null,
83 __('Better Payment ', 'better-payment'),
84 __('Better Payment ', 'better-payment'),
85 'manage_options',
86 'better-payment-setup-wizard',
87 [$this, 'render_wizard']
88 );
89 }
90
91 /**
92 * Render tab step
93 */
94 public function tab_step()
95 {
96 $wizard_column = 'four';
97 ?>
98 <ul class="better-payment-setup-wizard <?php echo $wizard_column; ?>" data-step="0">
99 <li class="step">
100 <div class="icon">
101 <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">
102 <g>
103 <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
104 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
105 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
106 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
107 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
108 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
109 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
110 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" />
111 </g>
112 </svg>
113 </div>
114 <div class="name"><?php _e('Getting Started', 'better-payment'); ?></div>
115 </li>
116 <li class="step">
117 <div class="icon">
118 <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">
119 <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
120 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
121 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
122 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
123 l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
124 </svg>
125 </div>
126 <div class="name"><?php _e('Stripe Configuration', 'better-payment'); ?></div>
127 </li>
128 <li class="step">
129 <div class="icon">
130 <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">
131 <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
132 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
133 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
134 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
135 l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
136 </svg>
137 </div>
138 <div class="name"><?php _e('PayPal Configuration', 'better-payment'); ?></div>
139 </li>
140 <li class="step">
141 <div class="icon">
142 <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">
143 <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
144 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
145 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" />
146 </svg>
147 </div>
148 <div class="name"><?php _e('Finalize', 'better-payment'); ?></div>
149 </li>
150 </ul>
151 <?php
152 }
153
154 public function get_currency_list(){
155 $currency_list = [
156 'AUD' => 'AUD',
157 'CAD' => 'CAD',
158 'CZK' => 'CZK',
159 'DKK' => 'DKK',
160 'EUR' => 'EUR',
161 'HKD' => 'HKD',
162 'HUF' => 'HUF',
163 'ILS' => 'ILS',
164 'JPY' => 'JPY',
165 'MXN' => 'MXN',
166 'NOK' => 'NOK',
167 'NZD' => 'NZD',
168 'PHP' => 'PHP',
169 'PLN' => 'PLN',
170 'GBP' => 'GBP',
171 'RUB' => 'RUB',
172 'SGD' => 'SGD',
173 'SEK' => 'SEK',
174 'CHF' => 'CHF',
175 'TWD' => 'TWD',
176 'THB' => 'THB',
177 'USD' => 'USD'
178 ];
179
180 return $currency_list;
181 }
182 /**
183 * Tav view content
184 */
185 public function tab_content($bp_admin_saved_settings)
186 {
187 $bp_admin_saved_settings = Better_Payment_DB::get_settings();
188 $currency_list = $this->get_currency_list();
189 ?>
190 <div class="better-payment-setup-body better-payment">
191 <form method="post" id="better-payment-admin-settings-form" class="better-payment-setup-wizard-form" action="#">
192
193 <div id="configuration" class="setup-content active">
194 <div id="general" class="sidebar__tab__content show payment__options better-payment-box">
195 <div class="payment__option">
196 <div class="payment__option__content">
197 <h4><?php _e('Stripe', 'better-payment'); ?></h4>
198 <p><?php _e('Enable Stripe if you want to accept payment via Stripe.', 'better-payment'); ?></p>
199 </div>
200 <div class="active__status">
201 <label class="bp-switch">
202 <input type="hidden" name="better_payment_settings_general_general_stripe" value="no">
203 <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' : '' ?>>
204 <span class="switch__btn"></span>
205 </label>
206 </div>
207 </div>
208 <div class="payment__option">
209 <div class="payment__option__content">
210 <h4><?php _e('PayPal', 'better-payment'); ?></h4>
211 <p><?php _e('Enable PayPal if you want to make transaction using PayPal.', 'better-payment'); ?></p>
212 </div>
213 <div class="active__status">
214 <label class="bp-switch">
215 <input type="hidden" name="better_payment_settings_general_general_paypal" value="no">
216 <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' : '' ?>>
217 <span class="switch__btn"></span>
218 </label>
219 </div>
220 </div>
221 <div class="payment__option">
222 <div class="payment__option__content">
223 <h4><?php _e('Email Notification', 'better-payment'); ?></h4>
224 <p><?php _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>
225 </div>
226 <div class="active__status">
227 <label class="bp-switch">
228 <input type="hidden" name="better_payment_settings_general_general_email" value="no">
229 <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' : '' ?>>
230 <span class="switch__btn"></span>
231 </label>
232 </div>
233 </div>
234 <div class="payment__option">
235 <div class="payment__option__content">
236 <h4><?php _e('Currency', 'better-payment'); ?></h4>
237 <p><?php _e('Select default currency for each transaction. You can also overwrite this setting from each widget control on elementor page builder.', 'better-payment'); ?></p>
238 </div>
239 <div class="active__status">
240 <div class="bp-select">
241 <select name="better_payment_settings_general_general_currency">
242 <option value="" disabled> <?php _e('Select Currency', 'better-payment'); ?> </option>
243 <?php foreach ($currency_list as $key => $value){
244 $selected = isset($bp_admin_saved_settings['better_payment_settings_general_general_currency']) && $bp_admin_saved_settings['better_payment_settings_general_general_currency'] == $key?'selected':'';
245 printf( '<option value="%s" %s >%s</option>', $key, $selected, __( $key, 'better-payment' ) );
246 } ?>
247 </select>
248 </div>
249 </div>
250 </div>
251 </div>
252 </div>
253
254 <div id="quick-setup-stripe" class="setup-content quick-setup-stripe">
255 <div class="payment__options">
256 <div class="payment__option">
257 <div class="payment__option__content">
258 <h4><?php _e('Live Mode', 'better-payment'); ?></h4>
259 <p><?php _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>
260 </div>
261 <div class="active__status">
262 <label class="bp-switch">
263 <input type="hidden" name="better_payment_settings_payment_stripe_live_mode" value="no">
264 <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' : '' ?>>
265 <span class="switch__btn"></span>
266 </label>
267 </div>
268 </div>
269
270 <?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'; ?>
271
272 <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' ?>">
273 <div class="payment__option__content">
274 <h4><?php _e('Live Public Key', 'better-payment'); ?></h4>
275 <p><?php _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>
276 </div>
277 <div class="active__status input__wrap">
278 <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']) ? $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_public'] : '' ?>" type="text" placeholder="<?php //_e('Live public key', 'better-payment'); ?>">
279 </div>
280 </div>
281 <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' ?>">
282 <div class="payment__option__content">
283 <h4><?php _e('Live Secret Key', 'better-payment'); ?></h4>
284 <p><?php _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>
285 </div>
286 <div class="active__status input__wrap">
287 <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']) ? $bp_admin_saved_settings['better_payment_settings_payment_stripe_live_secret'] : '' ?>">
288 </div>
289 </div>
290 <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' ?> ">
291 <div class="payment__option__content">
292 <h4><?php _e('Test Public Key', 'better-payment'); ?></h4>
293 <p><?php _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>
294 </div>
295 <div class="active__status input__wrap">
296 <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']) ? $bp_admin_saved_settings['better_payment_settings_payment_stripe_test_public'] : '' ?>">
297 </div>
298 </div>
299 <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' ?> ">
300 <div class="payment__option__content">
301 <h4><?php _e('Test Secret Key', 'better-payment'); ?></h4>
302 <p><?php _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>
303 </div>
304 <div class="active__status input__wrap">
305 <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']) ? $bp_admin_saved_settings['better_payment_settings_payment_stripe_test_secret'] : '' ?>">
306 </div>
307 </div>
308 </div>
309 </div>
310
311 <div id="quick-setup-paypal" class="setup-content quick-setup-paypal better-payment-box">
312 <div class="payment__options ">
313 <div class="payment__option">
314 <div class="payment__option__content">
315 <h4><?php _e('Live Mode', 'better-payment'); ?></h4>
316 <p><?php _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>
317 </div>
318 <div class="active__status">
319 <label class="bp-switch">
320 <input type="hidden" name="better_payment_settings_payment_paypal_live_mode" value="no">
321 <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' : '' ?>>
322 <span class="switch__btn"></span>
323 </label>
324 </div>
325 </div>
326 <div class="payment__option">
327 <div class="payment__option__content">
328 <h4><?php _e('Business Email', 'better-payment'); ?></h4>
329 <p><?php _e('Your PayPal account email address to accept payment via PayPal.', 'better-payment'); ?></p>
330 </div>
331 <div class="active__status input__wrap">
332 <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']) ? $bp_admin_saved_settings['better_payment_settings_payment_paypal_email'] : '' ?>">
333 </div>
334 </div>
335 </div>
336 </div>
337
338 <div id="finalize" class="setup-content better-payment-box">
339 <header class="pb31 text-center">
340 <div class="bp-container">
341 <div class="bp-row">
342 <div class="bp-col">
343 <div class="logo">
344 <a href="javascript:void(0)"><img src="<?php echo BETTER_PAYMENT_ADMIN_ASSET_URL . 'img/logo.svg'; ?>" alt=""></a>
345 </div>
346 </div>
347 </div>
348 </div>
349 </header>
350 <h2 class="text-center"><?php _e('Great Job! Your Configuration is Complete ', 'better-payment'); ?>🎉</h2>
351 <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' : '' ?>>
352 <label for="better_payment_settings_opt_in"><?php _e('Share non-sensitive diagnostic data and plugin usage information.', 'better-payment'); ?></label>
353 </p>
354 <p><?php _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>
355 </div>
356 </form>
357 </div>
358 <?php
359 }
360
361 /**
362 * Footer content
363 */
364 public function setup_wizard_footer()
365 {
366 ?>
367 <div class="better-payment better-payment-setup-footer">
368 <button id="better-payment-prev" class="button button__active better-payment-admin-settings-button"><?php _e('< Previous', 'better-payment') ?></button>
369 <button id="better-payment-next" class="button button__active better-payment-admin-settings-button"><?php _e('Next >', 'better-payment') ?></button>
370 <button id="better-payment-save" style="display: none" class="button button__active better-payment-admin-settings-button better-payment-setup-wizard-save"><?php _e('Finish', 'better-payment') ?></button>
371 </div>
372 <?php
373 }
374
375 /**
376 * render_wizard
377 */
378 public function render_wizard()
379 {
380 ?>
381 <div class="better-payment-setup-wizard-wrap">
382 <?php
383 $bp_admin_saved_settings = Better_Payment_DB::get_settings();
384
385 $this->change_site_title();
386 $this->tab_step();
387 $this->tab_content($bp_admin_saved_settings);
388 $this->setup_wizard_footer();
389 ?>
390 </div>
391 <?php
392 }
393
394 public static function save_setup_wizard_data()
395 {
396 /**
397 * Verify the Nonce
398 */
399 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'better_payment_admin_nonce')) {
400 return;
401 }
402
403 try{
404 Better_Payment_Settings::save_default_settings(1);
405 Better_Payment_Settings::save_settings($_POST['form_data']);
406
407 $posted_field_opt_in_val = '';
408 foreach ($_POST['form_data'] as $posted_field) {
409 $posted_field_name = sanitize_key($posted_field['name']);
410 $posted_field_value = sanitize_key($posted_field['value']);
411
412 if('better_payment_settings_opt_in' === $posted_field_name){
413 $posted_field_opt_in_val = $posted_field_value;
414 break;
415 }
416 }
417
418 if ( 'yes' === $posted_field_opt_in_val ) {
419 self::wpins_process();
420 }
421
422 update_option( 'better_payment_setup_wizard', 'complete' );
423
424 if (!did_action('elementor/loaded')) {
425 wp_send_json_success( [ 'redirect_url' => admin_url() ] );
426 }else {
427 wp_send_json_success( [ 'redirect_url' => admin_url( 'admin.php?page=better-payment-settings' ) ] );
428 }
429 }catch (Exception $e) {
430 wp_send_json_error($e->getMessage());
431 }
432
433 die;
434 }
435
436 public static function wpins_process(){
437 $plugin_name = basename( BETTER_PAYMENT_FILE, '.php' );
438
439 require_once BETTER_PAYMENT_PATH . 'includes/class-better-payment-plugin-usage-tracker.php';
440
441 if ( class_exists( 'Better_Payment_Plugin_Usage_Tracker' ) ){
442 $tracker = Better_Payment_Plugin_Usage_Tracker::get_instance( BETTER_PAYMENT_FILE, [
443 'opt_in' => true,
444 'goodbye_form' => true,
445 'item_id' => '64e1f724b5e14edb343e'
446 ] );
447 $tracker->set_is_tracking_allowed( true );
448 $tracker->do_tracking( true );
449 }
450 }
451
452 public static function redirect()
453 {
454 update_option('better_payment_setup_wizard', 'init');
455 wp_redirect(admin_url('admin.php?page=better-payment-setup-wizard'));
456 }
457
458 public function change_site_title()
459 {
460 ?>
461 <script>
462 document.title = "<?php _e('Quick Setup Wizard - Better Payment', 'better-payment'); ?>"
463 </script>
464 <?php
465 }
466 }