PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
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
← All changes | includes/Admin/Setup_Wizard.php +60 -311 2.3.1 → 2.4.1 View file →
@@ -11,8 +11,13 @@
11 11
12 12 /**
13 13 * Setup Wizard
14 14 *
15 + * The wizard UI is the React quick-setup app (src/admin/quick-setup), mounted by
16 + * views/better-payment-quick-setup.php. The PHP-rendered steps, footer and their
17 + * jQuery script (src/js/setup-wizard.js) predated it and were no longer called,
18 + * so they have been removed.
19 + *
15 20 * @since 0.0.2
16 21 */
17 22 class Setup_Wizard
18 23 {
@@ -36,9 +41,9 @@
36 41 }
37 42
38 43 /**
39 44 * Remove all notice in setup wizard page
40 - *
45 + *
41 46 * @since 0.0.2
42 47 */
43 48 public function remove_notice()
44 49 {
@@ -51,9 +56,9 @@
51 56 /**
52 57 * setup_wizard_scripts
53 58 * @param $hook
54 59 * @return array
55 - *
60 + *
56 61 * @since 0.0.2
57 62 */
58 63 public function setup_wizard_scripts($hook)
59 64 {
@@ -73,34 +78,24 @@
73 78 // Enqueue React Quick Setup JS with WordPress dependencies
74 79 wp_enqueue_script(
75 80 'bp-quick-setup-js',
76 81 BETTER_PAYMENT_ASSETS . '/admin/quick-setup/quick-setup' . $js_ext,
77 - array('wp-element', 'wp-i18n'),
82 + // wp-hooks: the PayPal step's refund-credentials slot, which Pro fills (utils/proHandoff.js).
83 + array('wp-element', 'wp-i18n', 'wp-hooks'),
78 84 $this->file_version,
79 85 true
80 86 );
81 87
82 - // Localize script with necessary data
88 + // Localize script with the data the React wizard reads.
83 89 wp_localize_script('bp-quick-setup-js', 'betterPaymentObjWizard', array(
84 90 'admin_nonce' => wp_create_nonce('better_payment_admin_nonce'),
85 91 'ajaxUrl' => admin_url('admin-ajax.php'),
86 - 'assetsUrl' => BETTER_PAYMENT_ASSETS . '/admin/quick-setup',
87 - 'success_image' => BETTER_PAYMENT_ASSETS . '/img/success.gif',
88 92 'settings' => DB::get_settings(),
89 93 'is_tracking' => get_option('better_payment_settings_opt_in') === 'yes' ? 1 : 0,
90 94 'currencies' => $this->get_currency_list(),
91 95 'is_pro' => defined('BETTER_PAYMENT_PRO_VERSION') && BETTER_PAYMENT_PRO_VERSION ? true : false,
92 - 'alerts' => [
93 - 'confirm' => esc_html__('Are you sure?', 'better-payment'),
94 - 'confirm_description' => esc_html__("You won't be able to revert this!", 'better-payment'),
95 - 'yes' => esc_html__('Yes, delete it!', 'better-payment'),
96 - 'no' => esc_html__('No, cancel!', 'better-payment'),
97 - ],
98 - 'messages' => [
99 - 'success' => esc_html__('Changes saved successfully!', 'better-payment'),
100 - 'error' => esc_html__('Opps! something went wrong!', 'better-payment'),
101 - 'no_action_taken' => esc_html__('No action taken!', 'better-payment'),
102 - ]
96 + // Arrives as '1' / '' (wp_localize_script casts scalars); read it with parseProEnabled().
97 + 'pro_enabled' => \Better_Payment\Lite\Classes\ProCompatibility::pro_enabled(),
103 98 ));
104 99 }
105 100 return [];
106 101 }
@@ -106,9 +101,9 @@
106 101 }
107 102
108 103 /**
109 104 * Create admin menu for setup wizard
110 - *
105 + *
111 106 * @since 0.0.2
112 107 */
113 108 public function admin_menu()
114 109 {
@@ -123,272 +118,10 @@
123 118 );
124 119 }
125 120
126 121 /**
127 - * Render tab step
128 - *
129 - * @since 0.0.2
130 - */
131 - public function tab_step()
132 - {
133 - $wizard_column = 'four';
134 - ?>
135 - <ul class="better-payment-setup-wizard <?php echo esc_attr( $wizard_column ); ?>" data-step="0">
136 - <li class="step">
137 - <div class="icon">
138 - <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">
139 - <g>
140 - <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
141 - 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
142 - 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
143 - 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
144 - 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
145 - 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
146 - 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
147 - 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" />
148 - </g>
149 - </svg>
150 - </div>
151 - <div class="name"><?php esc_html_e('Getting Started', 'better-payment'); ?></div>
152 - </li>
153 - <li class="step">
154 - <div class="icon">
155 - <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">
156 - <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
157 -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
158 -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
159 -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
160 -l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
161 - </svg>
162 - </div>
163 - <div class="name"><?php esc_html_e('PayPal Configuration', 'better-payment'); ?></div>
164 - </li>
165 - <li class="step">
166 - <div class="icon">
167 - <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">
168 - <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
169 -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
170 -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
171 -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
172 -l-5.2-5.2l8.8-8.8C50.4,20.4,50.4,18,48.9,16.6z" />
173 - </svg>
174 - </div>
175 - <div class="name"><?php esc_html_e('Stripe Configuration', 'better-payment'); ?></div>
176 - </li>
177 - <li class="step">
178 - <div class="icon">
179 - <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">
180 - <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
181 -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
182 -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" />
183 - </svg>
184 - </div>
185 - <div class="name"><?php esc_html_e('Finalize', 'better-payment'); ?></div>
186 - </li>
187 - </ul>
188 - <?php
189 - }
190 -
191 - /**
192 - * Tav view content
193 - *
194 - * @since 0.0.2
195 - */
196 - public function tab_content($bp_admin_saved_settings)
197 - {
198 - $bp_admin_saved_settings = DB::get_settings();
199 - $currency_list = $this->get_currency_list();
200 - ?>
201 - <div class="better-payment-setup-body better-payment">
202 - <form method="post" id="better-payment-admin-settings-form" class="better-payment-setup-wizard-form" action="#">
203 -
204 - <div id="configuration" class="setup-content active">
205 - <div id="general" class="sidebar__tab__content show payment__options better-payment-box">
206 - <div class="payment__option">
207 - <div class="payment__option__content">
208 - <h4><?php esc_html_e('PayPal', 'better-payment'); ?></h4>
209 - <p><?php esc_html_e('Enable PayPal if you want to make transaction using PayPal.', 'better-payment'); ?></p>
210 - </div>
211 - <div class="active__status">
212 - <label class="bp-switch">
213 - <input type="hidden" name="better_payment_settings_general_general_paypal" value="no">
214 - <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' : '' ?>>
215 - <span class="switch__btn"></span>
216 - </label>
217 - </div>
218 - </div>
219 - <div class="payment__option">
220 - <div class="payment__option__content">
221 - <h4><?php esc_html_e('Stripe', 'better-payment'); ?></h4>
222 - <p><?php esc_html_e('Enable Stripe if you want to accept payment via Stripe.', 'better-payment'); ?></p>
223 - </div>
224 - <div class="active__status">
225 - <label class="bp-switch">
226 - <input type="hidden" name="better_payment_settings_general_general_stripe" value="no">
227 - <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' : '' ?>>
228 - <span class="switch__btn"></span>
229 - </label>
230 - </div>
231 - </div>
232 - <div class="payment__option">
233 - <div class="payment__option__content">
234 - <h4><?php esc_html_e('Email Notification', 'better-payment'); ?></h4>
235 - <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>
236 - </div>
237 - <div class="active__status">
238 - <label class="bp-switch">
239 - <input type="hidden" name="better_payment_settings_general_general_email" value="no">
240 - <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' : '' ?>>
241 - <span class="switch__btn"></span>
242 - </label>
243 - </div>
244 - </div>
245 - <div class="payment__option">
246 - <div class="payment__option__content">
247 - <h4><?php esc_html_e('Currency', 'better-payment'); ?></h4>
248 - <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>
249 - </div>
250 - <div class="active__status">
251 - <div class="bp-select">
252 - <select name="better_payment_settings_general_general_currency">
253 - <option value="" disabled> <?php esc_html_e('Select Currency', 'better-payment'); ?> </option>
254 - <?php foreach ($currency_list as $key => $value){
255 - $selected = isset($bp_admin_saved_settings['better_payment_settings_general_general_currency']) && $bp_admin_saved_settings['better_payment_settings_general_general_currency'] == $key?'selected':'';
256 - printf( '<option value="%s" %s >%s</option>', esc_attr( $key ), esc_attr( $selected ), esc_html__( $key, 'better-payment' ) );
257 - } ?>
258 - </select>
259 - </div>
260 - </div>
261 - </div>
262 - </div>
263 - </div>
264 -
265 - <div id="quick-setup-paypal" class="setup-content quick-setup-paypal better-payment-box">
266 - <div class="payment__options ">
267 - <div class="payment__option">
268 - <div class="payment__option__content">
269 - <h4><?php esc_html_e('Live Mode', 'better-payment'); ?></h4>
270 - <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>
271 - </div>
272 - <div class="active__status">
273 - <label class="bp-switch">
274 - <input type="hidden" name="better_payment_settings_payment_paypal_live_mode" value="no">
275 - <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' : '' ?>>
276 - <span class="switch__btn"></span>
277 - </label>
278 - </div>
279 - </div>
280 - <div class="payment__option">
281 - <div class="payment__option__content">
282 - <h4><?php esc_html_e('Business Email', 'better-payment'); ?></h4>
283 - <p><?php esc_html_e('Your PayPal account email address to accept payment via PayPal.', 'better-payment'); ?></p>
284 - </div>
285 - <div class="active__status input__wrap">
286 - <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'] ) : '' ?>">
287 - </div>
288 - </div>
289 - </div>
290 - </div>
291 -
292 - <div id="quick-setup-stripe" class="setup-content quick-setup-stripe">
293 - <div class="payment__options">
294 - <div class="payment__option">
295 - <div class="payment__option__content">
296 - <h4><?php esc_html_e('Live Mode', 'better-payment'); ?></h4>
297 - <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>
298 - </div>
299 - <div class="active__status">
300 - <label class="bp-switch">
301 - <input type="hidden" name="better_payment_settings_payment_stripe_live_mode" value="no">
302 - <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' : '' ?>>
303 - <span class="switch__btn"></span>
304 - </label>
305 - </div>
306 - </div>
307 -
308 - <?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'; ?>
309 -
310 - <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' ?>">
311 - <div class="payment__option__content">
312 - <h4><?php esc_html_e('Live Public Key', 'better-payment'); ?></h4>
313 - <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>
314 - </div>
315 - <div class="active__status input__wrap">
316 - <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'); ?>">
317 - </div>
318 - </div>
319 - <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' ?>">
320 - <div class="payment__option__content">
321 - <h4><?php esc_html_e('Live Secret Key', 'better-payment'); ?></h4>
322 - <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>
323 - </div>
324 - <div class="active__status input__wrap">
325 - <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'] ) : '' ?>">
326 - </div>
327 - </div>
328 - <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' ?> ">
329 - <div class="payment__option__content">
330 - <h4><?php esc_html_e('Test Public Key', 'better-payment'); ?></h4>
331 - <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>
332 - </div>
333 - <div class="active__status input__wrap">
334 - <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'] ) : '' ?>">
335 - </div>
336 - </div>
337 - <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' ?> ">
338 - <div class="payment__option__content">
339 - <h4><?php esc_html_e('Test Secret Key', 'better-payment'); ?></h4>
340 - <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>
341 - </div>
342 - <div class="active__status input__wrap">
343 - <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'] ) : '' ?>">
344 - </div>
345 - </div>
346 - </div>
347 - </div>
348 -
349 - <div id="finalize" class="setup-content better-payment-box">
350 - <header class="pb31 text-center">
351 - <div class="bp-container">
352 - <div class="bp-row">
353 - <div class="bp-col">
354 - <div class="logo">
355 - <a href="javascript:void(0)"><img src="<?php echo esc_url( BETTER_PAYMENT_ASSETS . '/img/logo.svg' ); ?>" alt="Better Payment logo"></a>
356 - </div>
357 - </div>
358 - </div>
359 - </div>
360 - </header>
361 - <h2 class="text-center"><?php esc_html_e('Great Job! Your Configuration is Complete ', 'better-payment'); ?>🎉</h2>
362 - <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' : '' ?>>
363 - <label for="better_payment_settings_opt_in"><?php esc_html_e('Share non-sensitive diagnostic data and plugin usage information.', 'better-payment'); ?></label>
364 - </p>
365 - <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>
366 - </div>
367 - </form>
368 - </div>
369 - <?php
370 - }
371 -
372 - /**
373 - * Footer content
374 - *
375 - * @since 0.0.1
376 - */
377 - public function setup_wizard_footer()
378 - {
379 - ?>
380 - <div class="better-payment better-payment-setup-footer">
381 - <button id="better-payment-prev" class="button button__active better-payment-admin-settings-button"><?php esc_html_e('< Previous', 'better-payment') ?></button>
382 - <button id="better-payment-next" class="button button__active better-payment-admin-settings-button"><?php esc_html_e('Next >', 'better-payment') ?></button>
383 - <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>
384 - </div>
385 - <?php
386 - }
387 -
388 - /**
389 122 * render_wizard
390 - *
123 + *
391 124 * @since 0.0.1
392 125 */
393 126 public function render_wizard()
394 127 {
@@ -394,14 +127,8 @@
394 127 {
395 128 ?>
396 129 <div class="better-payment-setup-wizard-wrap">
397 130 <?php
398 - // $bp_admin_saved_settings = DB::get_settings();
399 -
400 - // $this->change_site_title();
401 - // $this->tab_step();
402 - // $this->tab_content($bp_admin_saved_settings);
403 - // $this->setup_wizard_footer();
404 131 include BETTER_PAYMENT_ADMIN_VIEWS_PATH . '/better-payment-quick-setup.php';
405 132 ?>
406 133 </div>
407 134 <?php
@@ -418,10 +145,28 @@
418 145 wp_send_json_error( __( 'Insufficient permissions.', 'better-payment' ) );
419 146 return;
420 147 }
421 148
149 + $context = isset( $_POST['context'] ) ? sanitize_key( wp_unslash( $_POST['context'] ) ) : 'proceed';
150 +
422 151 if ( isset( $_POST[ 'is_tracking' ] ) && $_POST[ 'is_tracking' ] === 'true' ) {
423 - update_option('better_payment_settings_opt_in', 'yes');
152 + /**
153 + * `better_payment_settings_opt_in` is NOT the tracking gate — that is
154 + * `wpins_allow_tracking`, written by wpins_process() below. This option
155 + * is wizard UI state: it is localized as `is_tracking` (see
156 + * setup_wizard_scripts()) and makes QuickSetupWizard open on the
157 + * Settings step with back-navigation to Start disabled.
158 + *
159 + * So the Skip path deliberately does not write it. Skip must leave the
160 + * wizard behaving exactly as it does today — Start screen shown, Back
161 + * still available — while still turning tracking on.
162 + *
163 + * @since 2.3.2
164 + */
165 + if ( 'skip' !== $context ) {
166 + update_option('better_payment_settings_opt_in', 'yes');
167 + }
168 +
424 169 self::wpins_process();
425 170 wp_send_json_success( __( 'Tracking data saved successfully.', 'better-payment' ) );
426 171 } else {
427 172 wp_send_json_error( __( 'Invalid tracking parameter.', 'better-payment' ) );
@@ -429,9 +174,9 @@
429 174 }
430 175
431 176 /**
432 177 * Save setup wizard data
433 - *
178 + *
434 179 * @since 0.0.1
435 180 */
436 181 public static function save_setup_wizard_data()
437 182 {
@@ -444,9 +189,9 @@
444 189
445 190 if (!current_user_can('manage_options')) {
446 191 return;
447 192 }
448 -
193 +
449 194 try{
450 195 Settings::save_default_settings(1);
451 196 Settings::save_settings(json_decode(stripslashes($_POST['form_data']), true));
452 197
@@ -457,20 +202,35 @@
457 202 // }else {
458 203 wp_send_json_success( [ 'redirect_url' => admin_url( 'admin.php?page=better-payment-admin&tab=dashboard' ) ] );
459 204 // }
460 205 }catch (\Exception $e) {
461 - wp_send_json_error($e->getMessage());
206 + wp_send_json_error($e->getMessage());
462 207 }
463 -
208 +
464 209 die;
465 210 }
466 211
467 212 /**
468 213 * WPIns process
469 - *
214 + *
215 + * The single tracking-activation routine. Every path that turns usage
216 + * tracking on goes through here — the wizard's "Proceed To Next Step" and
217 + * "Skip It" buttons, and the automatic opt-in for fresh installs in
218 + * Traits\Helper::maybe_auto_enable_usage_tracking().
219 + *
220 + * @param bool $force_send Send the payload immediately. True for the wizard
221 + * buttons, which run inside an AJAX request. Pass
222 + * FALSE from anything that runs during a page render:
223 + * send_data() posts with `blocking => true` and a 30s
224 + * timeout, so a forced send there would stall the
225 + * response. Consent alone is enough — the caller's
226 + * Plugin_Usage_Tracker::init() schedules the daily
227 + * event and the first run sends.
228 + *
229 + * @return void
470 230 * @since 0.0.1
471 231 */
472 - public static function wpins_process(){
232 + public static function wpins_process( $force_send = true ){
473 233 $plugin_name = basename( BETTER_PAYMENT_FILE, '.php' );
474 234
475 235 if ( class_exists( '\Better_Payment\Lite\Classes\Plugin_Usage_Tracker' ) ){
476 236 $tracker = Plugin_Usage_Tracker::get_instance( BETTER_PAYMENT_FILE, [
@@ -478,15 +238,18 @@
478 238 'goodbye_form' => true,
479 239 'item_id' => '64e1f724b5e14edb343e'
480 240 ] );
481 241 $tracker->set_is_tracking_allowed( true );
482 - $tracker->do_tracking( true );
242 +
243 + if ( $force_send ) {
244 + $tracker->do_tracking( true );
245 + }
483 246 }
484 247 }
485 248
486 249 /**
487 250 * Redirect
488 - *
251 + *
489 252 * @since 0.0.1
490 253 */
491 254 public static function redirect()
492 255 {
@@ -492,19 +255,5 @@
492 255 {
493 256 update_option('better_payment_setup_wizard', 'init');
494 257 wp_redirect(admin_url('admin.php?page=better-payment-setup-wizard'));
495 258 }
496 -
497 - /**
498 - * Site title
499 - *
500 - * @since 0.0.1
501 - */
502 - public function change_site_title()
503 - {
504 - ?>
505 - <script>
506 - document.title = "<?php esc_html_e('Quick Setup Wizard - Better Payment', 'better-payment'); ?>"
507 - </script>
508 - <?php
509 - }
510 -}
259 +}