Passed
Push — master ( e50c18...f198a7 )
by Stiofan
86:03 queued 31:21
created

GetPaid_Admin_Setup_Wizard::setup_payments_save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 * Setup Wizard Class
4
 *
5
 * Takes new users through some basic steps to setup GetPaid.
6
 *
7
 * @author      AyeCode
8
 * @category    Admin
9
 * @package     GetPaid/Admin
10
 * @version     2.4.0
11
 * @info        GetPaid Setup Wizard.
12
 */
13
if ( ! defined( 'ABSPATH' ) ) {
14
	exit;
15
}
16
17
/**
18
 * GetPaid_Admin_Setup_Wizard class.
19
 */
20
class GetPaid_Admin_Setup_Wizard {
21
22
	/** @var string Current Step */
23
	private $step = '';
24
25
	/** @var array Steps for the setup wizard */
26
	private $steps = array();
27
28
	/**
29
	 * Hook in tabs.
30
	 */
31
	public function __construct() {
32
		if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && current_user_can( 'manage_options' ) ) {
33
			add_action( 'admin_menu', array( $this, 'admin_menus' ) );
34
			add_action( 'current_screen', array( $this, 'setup_wizard' ) );
35
36
			// add default content action
37
			add_action( 'geodir_wizard_content_dummy_data', array( __CLASS__, 'content_dummy_data' ) );
38
			add_action( 'geodir_wizard_content_sidebars', array( __CLASS__, 'content_sidebars' ) );
39
			add_action( 'geodir_wizard_content_menus', array( __CLASS__, 'content_menus' ) );
40
		}
41
	}
42
43
	/**
44
	 * Add admin menus/screens.
45
	 */
46
	public function admin_menus() {
47
		add_dashboard_page( '', '', 'manage_options', 'gp-setup', '' );
48
	}
49
50
	/**
51
	 * Show the setup wizard.
52
	 *
53
	 * @since 2.0.0
54
	 */
55
	public function setup_wizard() {
56
		if ( empty( $_GET['page'] ) || 'gp-setup' !== $_GET['page'] ) {
57
			return;
58
		}
59
		$default_steps = array(
60
			'introduction'     => array(
61
				'name'    => __( 'Introduction', 'invoicing' ),
62
				'view'    => array( $this, 'setup_introduction' ),
63
				'handler' => '',
64
			),
65
			'business_details'             => array(
66
				'name'    => __( "Business Details", 'invoicing' ),
67
				'view'    => array( $this, 'setup_business' ),
68
				'handler' => array( $this, 'setup_business_save' ),
69
			),
70
			'currency' => array(
71
				'name'    => __( 'Currency', 'invoicing' ),
72
				'view'    => array( $this, 'setup_currency' ),
73
				'handler' => array( $this, 'setup_currency_save' ),
74
			),
75
			'payments'        => array(
76
				'name'    => __( 'Payment Gateways', 'invoicing' ),
77
				'view'    => array( $this, 'setup_payments' ),
78
				'handler' => array( $this, 'setup_payments_save' ),
79
			),
80
			'recommend'          => array(
81
				'name'    => __( 'Recommend', 'invoicing' ),
82
				'view'    => array( $this, 'setup_recommend' ),
83
				'handler' => array( $this, 'setup_recommend_save' ),
84
			),
85
			'next_steps'       => array(
86
				'name'    => __( 'Get Paid', 'invoicing' ),
87
				'view'    => array( $this, 'setup_ready' ),
88
				'handler' => '',
89
			),
90
		);
91
92
		$this->steps     = apply_filters( 'getpaid_setup_wizard_steps', $default_steps );
93
		$this->step      = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
94
95
96
		// enqueue the script
97
		$aui_settings = AyeCode_UI_Settings::instance();
98
		$aui_settings->enqueue_scripts();
99
		$aui_settings->enqueue_style();
100
101
102
103
//		if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
104
//			call_user_func( $this->steps[ $this->step ]['handler'], $this );
105
//		}
106
107
//		if ( ! empty( $_REQUEST['settings-updated'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
108
//			call_user_func( $this->steps[ $this->step ]['handler'], $this );
109
//		}
110
111
		ob_start();
112
		$this->setup_wizard_header();
113
//		$this->setup_wizard_steps();
114
		$this->setup_wizard_content();
115
		$this->setup_wizard_footer();
116
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
117
	}
118
119
	/**
120
	 * Setup Wizard Header.
121
	 *
122
	 * @since 2.0.0
123
	 */
124
public function setup_wizard_header() {
125
	?>
126
	<!DOCTYPE html>
127
	<html <?php language_attributes(); ?> class="bsui">
128
	<head>
129
		<meta name="viewport" content="width=device-width"/>
130
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
131
		<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
132
		<?php
133
134
		wp_register_style( 'font-awesome', 'https://use.fontawesome.com/releases/v5.13.0/css/all.css', array(  ), WPINV_VERSION );
135
		wp_enqueue_style( 'font-awesome' );
136
		do_action( 'admin_print_styles' ); ?>
137
		<?php do_action( 'admin_head' ); ?>
138
		<style>
139
			body,p{
140
				font-size: 16px;
141
				font-weight: normal;
142
			}
143
144
			<?php
145
				$aui_settings = AyeCode_UI_Settings::instance();
146
				echo $aui_settings::css_primary('#009874',true);
147
			 ?>
148
149
150
		</style>
151
	</head>
152
	<body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;">
153
	<?php
154
	if(isset($_REQUEST['step'])){
155
	$this->setup_wizard_steps();
156
	}else{
157
	echo "<div class='mb-3'>&nbsp;</div>";
158
	}
159
160
	?>
161
	<h1 class="h2 text-center pb-3">
162
		<a class=" text-decoration-none" href="https://wpgetpaid.com/">
163
			<span class="text-black-50">
164
				<img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" />
165
			</span>
166
		</a>
167
	</h1>
168
	<?php
169
	}
170
171
	/**
172
	 * Output the steps.
173
	 *
174
	 * @since 2.0.0
175
	 */
176
	public function setup_wizard_steps() {
177
		$ouput_steps = $this->steps;
178
		array_shift( $ouput_steps );
179
		?>
180
		<ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center">
181
			<?php
182
			$current = '';
183
			foreach ( $ouput_steps as $step_key => $step ) : ?>
184
				<li class="list-group-item flex-fill rounded-0 <?php
185
				if ( $step_key === $this->step ) {
186
					$current = $this->step;
187
					echo 'active';
188
				} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
189
					echo 'done';
190
				}
191
				$done = !$current ? 'text-success' : '';
192
				?>"><i class="far fa-check-circle <?php echo $done ;?>"></i> <?php echo esc_html( $step['name'] ); ?></li>
193
			<?php endforeach; ?>
194
		</ol>
195
		<?php
196
	}
197
198
	/**
199
	 * Output the content for the current step.
200
	 *
201
	 * @since 2.0.0
202
	 */
203
	public function setup_wizard_content() {
204
		echo '<div class="gp-setup-content rowx mw-100 text-center mb-3">';
205
		echo '<div class="col-5 m-auto">';
206
		echo '<div class="card shadow-sm">';
207
		call_user_func( $this->steps[ $this->step ]['view'], $this );
208
		echo '</div>';
209
		echo '</div>';
210
		echo '</div>';
211
	}
212
213
	/**
214
	 * Setup Wizard Footer.
215
	 *
216
	 * @since 2.0.0
217
	 */
218
	public function setup_wizard_footer() {
219
	?>
220
	<?php if ( 'next_steps' === $this->step ){ ?>
221
		<p class="gd-return-to-dashboard-wrap"><a class="gd-return-to-dashboard btn btn-link d-block text-muted"
222
		                                          href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'invoicing' ); ?></a>
223
		</p>
224
	<?php }else{ ?>
225
	<p class="gd-return-to-dashboard-wrap"><a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
226
		                class="btn btn-link d-block text-muted"><?php esc_html_e( 'Skip this step', 'invoicing' ); ?></a></p>
227
	<?php } ?>
228
	</body>
229
	</html>
230
	<?php
231
}
232
233
	/**
234
	 * Introduction step.
235
	 *
236
	 * @since 2.0.0
237
	 */
238
	public function setup_introduction() {
239
		?>
240
		<h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"><?php esc_html_e( 'Welcome to GetPaid!', 'invoicing' ); ?></h1>
241
		<div class="card-body text-muted ">
242
			<p class=""><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
243
			<hr class="mt-4 pt-3 pb-0" />
244
			<p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes<b/>.', 'invoicing' ); ?></p>
245
		</div>
246
		<div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
247
			<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
248
			   class="btn btn-primary button-next"><?php esc_html_e( 'Let\'s go!', 'invoicing' ); ?></a>
249
			<a href="<?php echo esc_url( admin_url() ); ?>"
250
			   class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
251
		</div>
252
253
254
		</div>
255
		<div class="card shadow-sm my-5">
256
		<h1 class="h4 card-header bg-white border-bottom-0  pt-4 pb-1"><?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?></h1>
257
		<div class="card-body text-muted overflow-hidden">
258
			<p class=""><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p>
259
			<hr class="">
260
261
			<div class="row row row-cols-2 text-left">
262
				<div class="col mt-3">
263
					<div class="media">
264
					  <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg';?>" class="mr-3" alt="...">
265
					  <div class="media-body">
266
					    <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons','invoicing');?></h6>
267
					    <small><?php _e('Sell via buy now buttons anywhere on your site','invoicing');?></small>
268
					  </div>
269
					</div>
270
				</div>
271
			    <div class="col mt-3">
272
					<div class="media">
273
					  <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg';?>" class="mr-3" alt="...">
274
					  <div class="media-body">
275
					    <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form','invoicing');?></h6>
276
					    <small><?php _e('Payment forms are conversion-optimized checkout forms','invoicing');?></small>
277
					  </div>
278
					</div>
279
				</div>
280
				<div class="col mt-3">
281
					<div class="media">
282
					  <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg';?>" class="mr-3" alt="...">
283
					  <div class="media-body">
284
					    <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6>
285
					    <small><?php _e('Create and send invoices for just about anything from the WOrdPress dashboard','invoicing');?></small>
286
					  </div>
287
					</div>
288
				</div>
289
				<div class="col mt-3">
290
					<div class="media">
291
					  <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg';?>" class="mr-3" alt="...">
292
					  <div class="media-body">
293
					    <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6>
294
					    <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small>
295
					  </div>
296
					</div>
297
				</div>
298
			</div>
299
300
			<div class="mt-5">
301
				<a href="https://wpgetpaid.com/features-list/"
302
				   class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a>
303
			</div>
304
			<div class="mt-5 mx-n4 py-4" style="background:#eafaf6;">
305
				<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!','invoicing');?></h4>
306
				<div class="row row-cols-2 text-left px-5">
307
					<div class="col">
308
						<ul class="list-unstyled">
309
							<li class="my-2"><i class="far fa-check-circle text-success"></i> PDF Invoices</li>
310
							<li class="my-2"><i class="far fa-check-circle text-success"></i> Gravity Forms</li>
311
							<li class="my-2"><i class="far fa-check-circle text-success"></i> Contact form 7</li>
312
							<li class="my-2"><i class="far fa-check-circle text-success"></i> AffiliateWP Integration</li>
313
						</ul>
314
					</div>
315
					<div class="col">
316
						<ul class="list-unstyled">
317
							<li class="my-2"><i class="far fa-check-circle text-success"></i> Ninja forms</li>
318
							<li class="my-2"><i class="far fa-check-circle text-success"></i> Digital Downloads</li>
319
							<li class="my-2"><i class="far fa-check-circle text-success"></i> Wallet</li>
320
						</ul>
321
					</div>
322
				</div>
323
324
				<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5>
325
				<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3">$49</h1>
326
327
				<div class="mt-2">
328
				<a href="https://wpgetpaid.com/downloads/membership/"
329
				   class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a>
330
			</div>
331
332
333
			</div>
334
335
		</div>
336
		<div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
337
			<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
338
			   class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a>
339
			   <a href="https://docs.wpgetpaid.com/"
340
			   class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
341
			<a href="<?php echo esc_url( admin_url() ); ?>"
342
			   class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
343
		</div>
344
		<?php
345
	}
346
347
	/**
348
	 * Get the URL for the next step's screen.
349
	 *
350
	 * @param string step   slug (default: current step)
0 ignored issues
show
Bug introduced by
The type step was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
351
	 *
352
	 * @return string       URL for next step if a next step exists.
353
	 *                      Admin URL if it's the last step.
354
	 *                      Empty string on failure.
355
	 * @since 3.0.0
356
	 */
357
	public function get_next_step_link( $step = '' ) {
358
		if ( ! $step ) {
359
			$step = $this->step;
360
		}
361
362
		$keys = array_keys( $this->steps );
363
		if ( end( $keys ) === $step ) {
364
			return admin_url();
365
		}
366
367
		$step_index = array_search( $step, $keys );
368
		if ( false === $step_index ) {
369
			return '';
370
		}
371
372
		return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
373
	}
374
375
	/**
376
	 * Setup maps api.
377
	 *
378
	 * @since 2.0.0
379
	 */
380
	public function setup_business() {
381
		?>
382
		<form method="post" class="text-left card-body" action="options.php">
383
			<?php
384
385
			settings_fields( 'wpinv_settings' );
386
387
			// override http referer to make it send back to the next step
388
				?>
389
			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
390
391
			<table class="gp-setup-maps w-100 " cellspacing="0">
392
393
				<tbody>
394
395
				<?php
396
397
				global $wp_settings_fields;
398
399
				$page = 'wpinv_settings_general_main';
400
				$section = 'wpinv_settings_general_main';
401
				if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
402
			        return;
403
			    }
404
405
			    $settings =  $wp_settings_fields[ $page ][ $section ];
406
407
				// unset title
408
				unset($settings["wpinv_settings[location_settings]"]);
409
410
			    $this->output_fields($settings);
411
				?>
412
413
414
				</tbody>
415
			</table>
416
417
418
			<p class="gp-setup-actions step text-center mt-4">
419
				<input type="submit" class="btn btn-primary button-next"
420
				       value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
421
			</p>
422
		</form>
423
		<?php
424
	}
425
426
	public function output_fields($settings){
427
428
	    if ( empty($settings)) {
429
	        return;
430
	    }
431
432
//print_r($settings);
433
	    foreach ( (array) $settings as $key => $field ) {
434
435
436
	        $class = '';
437
438
	        if ( ! empty( $field['args']['class'] ) ) {
439
	            $class = esc_attr( $field['args']['class'] );
0 ignored issues
show
Unused Code introduced by
The assignment to $class is dead and can be removed.
Loading history...
440
	        }
441
442
	       // echo '<div class="form-group '.$class.'">';
443
444
445
	        if ( ! empty( $field['args']['label_for'] ) ) {
446
	            $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" ';
0 ignored issues
show
Unused Code introduced by
The assignment to $for is dead and can be removed.
Loading history...
447
	        } else {
448
	            $for = '';
449
	        }
450
451
			$value  = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
452
			$value  = wpinv_get_option( $field['args']['id'], $value );
453
454
			if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){
455
456
457
			// hide the logo inputs, we need to set them as hidden so they don't blank the current values.
458
			$help_text = isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '';
459
			$type = $field['callback'] == 'wpinv_number_callback'  ? 'number' : 'text';
460
			$label = isset($field['args']['name']) ? esc_attr($field['args']['name']) : '';
461
462
			if(in_array($field['id'],array('wpinv_settings[logo]','wpinv_settings[logo_width]','wpinv_settings[logo_height]'))){
463
				$type = 'hidden';
464
				$help_text = '';
465
				$label = '';
466
			}
467
468
				echo aui()->input(array(
469
									'type'  =>  $type,
470
									'id'    =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
471
									'name'    =>  isset($field['id']) ? esc_attr($field['id']) : '',
472
									'value' =>   is_scalar( $value ) ? esc_attr( $value ) : '',
473
									'required'  => false,
474
									'help_text' => $help_text,
475
									'label' => $label,
476
									'label_type'    => 'floating'
477
								));
478
			}elseif($field['callback'] == 'wpinv_select_callback' || $field['callback'] == 'wpinv_country_states_callback'){
479
480
if($field['id']=='wpinv_settings[default_state]'){
481
			$country_value  = wpinv_get_option( 'wpinv_settings[default_country]', 'US');
482
$options = wpinv_get_country_states($country_value);//echo $value .'###'.$country_value;
483
}else{
484
$options = isset($field['args']['options']) ? $field['args']['options'] : array();
485
}
486
487
//print_r($options );echo '###';
488
489
				echo aui()->select( array(
490
					'id'              =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
491
					'name'            =>  isset($field['id']) ? esc_attr($field['id']) : '',
492
					'placeholder'     => '',
493
//					'title'           => $site_title,
494
					'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
495
					'required'        => false,
496
					'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
497
					'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
498
					'options'         => $options,
499
					'select2'         => true,
500
					'label_type'    => 'floating'
501
//					'wrap_class'      => isset( $field->css_class ) ? $field->css_class : '',
502
				) );
503
			}elseif($field['callback'] == 'wpinv_textarea_callback'){
504
				$textarea =  aui()->textarea( array(
505
					'id'              => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
506
					'name'            => isset($field['id']) ? esc_attr($field['id']) : '',
507
					'placeholder'     => '',
508
//					'title'           => $site_title,
509
					'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
510
					'required'        => false,
511
					'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
512
					'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
513
					'rows'            => '4',
514
					'label_type'    => 'floating'
515
//					'wrap_class'      => isset( $field->css_class ) ? $field->css_class : '',
516
				) );
517
518
				// bug fixed in AUI 0.1.51 for name stripping []
519
				$textarea = str_replace(sanitize_html_class($field['args']['id']),esc_attr($field['args']['id']),$textarea );
520
521
				echo $textarea;
522
			}
523
524
			//echo "<div>";
525
526
	    }
527
	}
528
529
	/**
530
	 * Save Maps Settings.
531
	 *
532
	 * @since 2.0.0
533
	 */
534
	public function setup_business_save() {
535
536
	// nothing required here as options.php will send to next step
537
		//check_admin_referer( 'gp-setup' );
538
539
//print_r($_POST);exit;
540
//		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
541
//		exit;
542
	}
543
544
	/**
545
	 * Default Location settings.
546
	 *
547
	 * @since 2.0.0
548
	 */
549
	public function setup_currency() {
550
551
		?>
552
553
		<form method="post" class="text-left card-body" action="options.php">
554
			<?php
555
556
557
			settings_fields( 'wpinv_settings' );
558
559
			// override http referer to make it send back to the next step
560
				?>
561
			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
562
563
			<table class="gp-setup-maps w-100 " cellspacing="0">
564
565
				<tbody>
566
567
				<?php
568
569
				global $wp_settings_fields;
570
571
				$page = 'wpinv_settings_general_currency_section';
572
				$section = 'wpinv_settings_general_currency_section';
573
				if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
574
			        return;
575
			    }
576
577
			    $settings =  $wp_settings_fields[ $page ][ $section ];
578
579
//				print_r($settings);exit;
580
581
			    $this->output_fields($settings);
582
				?>
583
584
585
				</tbody>
586
			</table>
587
588
589
			<p class="gp-setup-actions step text-center mt-4">
590
				<input type="submit" class="btn btn-primary"
591
				       value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
592
			</p>
593
		</form>
594
595
		<?php
596
	}
597
598
599
	/**
600
	 * Save Default Location Settings.
601
	 *
602
	 * @since 2.0.0
603
	 */
604
	public function setup_currency_save() {
605
		check_admin_referer( 'gp-setup' );
606
607
		$generalSettings = new GeoDir_Settings_General();
0 ignored issues
show
Bug introduced by
The type GeoDir_Settings_General was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
608
		$settings        = $generalSettings->get_settings( 'location' );
609
		GeoDir_Admin_Settings::save_fields( $settings );
0 ignored issues
show
Bug introduced by
The type GeoDir_Admin_Settings was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
610
611
		do_action( 'geodir_setup_wizard_default_location_saved', $settings );
612
613
		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
614
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
615
	}
616
617
	/**
618
	 * Dummy Data setup.
619
	 *
620
	 * @since 2.0.0
621
	 */
622
	public function setup_recommend() {
623
624
		?>
625
		<form method="post" class="text-center card-body">
626
			<div class="gd-wizard-recommend">
627
628
				<h2 class="gd-settings-title h3 "><?php _e( "Recommend Plugins", "geodirectory" ); ?></h2>
629
630
				<p><?php _e( "Below are a few of our own plugins that may help you.", "geodirectory" ); ?></p>
631
632
633
				<?php
634
635
				include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
636
637
				$recommend_wp_plugins = self::get_recommend_wp_plugins();
638
639
				//			$status = install_plugin_install_status( array("slug"=>"two-factor","version"=>""));
640
				//			print_r($status);
641
642
				if ( ! empty( $recommend_wp_plugins ) ) {
643
644
				?>
645
				<ul class="list-group">
646
					<?php
647
						foreach ( $recommend_wp_plugins as $plugin ) {
648
						$status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) );
649
						$plugin_status = isset( $status['status'] ) ? $status['status'] : '';
0 ignored issues
show
Unused Code introduced by
The assignment to $plugin_status is dead and can be removed.
Loading history...
650
						?>
651
							<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
652
							    <span class="mr-auto"><?php echo esc_attr($plugin['name']); ?></span>
653
								<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
654
									<span class="sr-only">Loading...</span>
655
								</div>
656
								<div class="custom-control custom-switch  mr-n2">
657
									<input type="checkbox" class="custom-control-input"  <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?> onclick="if(jQuery(this).is(':checked')){}else{}">
658
									<label class="custom-control-label" for="ac-setting-updates"></label>
659
								</div>
660
								<small class="w-100"><?php echo esc_attr($plugin['desc'] );?></small>
661
							 </li>
662
						<?php
663
						}
664
                    ?>
665
				</ul>
666
				<?php
667
668
				}
669
670
671
672
				?>
673
674
675
676
			</div>
677
678
			<p class="gp-setup-actions step text-center mt-4">
679
				<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="btn btn-primary"><?php esc_attr_e( 'Continue', 'invoicing' ); ?></a>
680
			</p>
681
		</form>
682
		<?php
683
	}
684
685
		/**
686
	 * A list of recommended wp.org plugins.
687
	 * @return array
688
	 */
689
	public static function get_recommend_wp_plugins(){
690
		$plugins = array(
691
			'ayecode-connect' => array(
692
				'url'   => 'https://wordpress.org/plugins/ayecode-connect/',
693
				'slug'   => 'ayecode-connect',
694
				'name'   => 'AyeCode Connect',
695
				'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
696
			),
697
			'ninja-forms' => array(
698
				'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
699
				'slug'   => 'invoicing-quotes',
700
				'name'   => 'Customer Quotes',
701
				'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
702
			),
703
			'userswp' => array(
704
				'url'   => 'https://wordpress.org/plugins/userswp/',
705
				'slug'   => 'userswp',
706
				'name'   => 'UsersWP',
707
				'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
708
			),
709
		);
710
711
		return $plugins;
712
	}
713
714
	/**
715
	 * Dummy data save.
716
	 *
717
	 * This is done via ajax so we just pass onto the next step.
718
	 *
719
	 * @since 2.0.0
720
	 */
721
	public function setup_recommend_save() {
722
		check_admin_referer( 'gp-setup' );
723
		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
724
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
725
	}
726
727
	/**
728
	 * Dummy Data setup.
729
	 *
730
	 * @since 2.0.0
731
	 */
732
	public function setup_payments() {
733
		?>
734
		<form method="post" class="text-center card-body">
735
			<div class="gp-wizard-payments">
736
737
				<h2 class="gd-settings-title h3 "><?php _e( "Gateway Setup", "geodirectory" ); ?></h2>
738
739
				<p><?php _e( "Below are a few gateways that can be setup in a few seconds.", "geodirectory" ); ?><br><?php _e( "We have 20+ Gateways that can be setup later.", "geodirectory" ); ?></p>
740
741
				<ul class="list-group">
742
				  <li class="list-group-item d-flex justify-content-between align-items-center">
743
				    <span class="mr-auto"><img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/stripe-verified.svg';?>" class="ml-n2" alt="Stripe"></span>
744
					<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
745
						<span class="sr-only">Loading...</span>
746
					</div>
747
				    <span class="btn btn-sm btn-outline-primary">Connect</span>
748
				  </li>
749
				  <li class="list-group-item d-flex justify-content-between align-items-center">
750
				    <span class="mr-auto"><img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/pp-logo-150px.webp';?>" class="" alt="PayPal" height="25"></span>
751
					<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
752
						<span class="sr-only">Loading...</span>
753
					</div>
754
				    <span class="btn btn-sm btn-outline-primary">Connect</span>
755
				  </li>
756
				  <li class="list-group-item d-flex justify-content-between align-items-center">
757
				    <span class="mr-auto">Test Gateway</span>
758
					<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
759
						<span class="sr-only">Loading...</span>
760
					</div>
761
					<div class="custom-control custom-switch">
762
						<input type="checkbox" class="custom-control-input" id="ac-setting-updates" checked="" onclick="if(jQuery(this).is(':checked')){}else{}">
763
						<label class="custom-control-label" for="ac-setting-updates"></label>
764
					</div>
765
				  </li>
766
				</ul>
767
768
				<?php
769
770
771
772
773
774
				?>
775
776
777
			</div>
778
779
			<p class="gp-setup-actions step text-center mt-4">
780
				<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="btn btn-primary"><?php esc_attr_e( 'Continue', 'invoicing' ); ?></a>
781
			</p>
782
		</form>
783
		<?php
784
	}
785
786
	/**
787
	 * Dummy data save.
788
	 *
789
	 * This is done via ajax so we just pass onto the next step.
790
	 *
791
	 * @since 2.0.0
792
	 */
793
	public function setup_payments_save() {
794
		check_admin_referer( 'gp-setup' );
795
		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
796
		exit;
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
797
	}
798
799
	/**
800
	 * Final step.
801
	 *
802
	 * @since 2.0.0
803
	 */
804
	public function setup_ready() {
805
		$this->setup_ready_actions();
806
		?>
807
808
		<div class="text-center card-body">
809
			<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to GetPaid', 'invoicing' ); ?></h1>
810
811
812
			<div class="geodirectory-message geodirectory-tracker">
813
				<p><?php _e( 'Thank you for choosing GetPaid!', 'invoicing' ); ?> <i class="far fa-smile-beam"></i></p>
814
			</div>
815
816
			<div class="gp-setup-next-steps">
817
				<div class="gp-setup-next-steps-first mb-4">
818
					<h2 class="h3"><?php esc_html_e( 'Next steps', 'invoicing' ); ?></h2>
819
					<a class="btn btn-primary btn-sm"
820
						                             href="<?php echo esc_url( admin_url( 'post-new.php?post_type=wpi_item' ) ); ?>"><?php esc_html_e( 'Create your first Item!', 'invoicing' ); ?></a>
821
				</div>
822
				<div class="gp-setup-next-steps-first mb-4">
823
					<h2 class="h3"><?php esc_html_e( 'Examples', 'invoicing' ); ?></h2>
824
					<a class="btn btn-primary btn-sm"
825
					target="_blank" href="https://demos.ayecode.io/getpaid/"><?php esc_html_e( "View What's Possible", 'invoicing' ); ?></a>
826
827
                     <a class="btn btn-outline-primary btn-sm"
828
                     target="_blank" href="https://demos.ayecode.io/getpaid/"><?php esc_html_e( "View What's Possible", 'invoicing' ); ?></a>
829
				</div>
830
				<div class="gp-setup-next-steps-last">
831
					<h2 class="h3"><?php _e( 'Learn more', 'invoicing' ); ?></h2>
832
					<a class="btn btn-outline-primary btn-sm" href="https://docs.wpgetpaid.com/collection/114-getting-started?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=invoicingplugin"
833
								target="_blank"><?php esc_html_e( 'Getting Started', 'invoicing' ); ?></a>
834
						<a class="btn btn-outline-primary btn-sm"
835
								href="https://docs.wpgetpaid.com/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingplugin"
836
								target="_blank"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
837
						<a class="btn btn-outline-primary btn-sm"
838
								href="https://wpgetpaid.com/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=invoicingyplugin"
839
								target="_blank"><?php esc_html_e( 'Support', 'invoicing' ); ?></a>
840
								<a class="btn btn-outline-primary btn-sm"
841
								href="https://demos.ayecode.io/getpaid/?utm_source=setupwizard&utm_medium=product&utm_content=demos&utm_campaign=invoicingyplugin"
842
								target="_blank"><?php esc_html_e( 'Demos', 'invoicing' ); ?></a>
843
				</div>
844
			</div>
845
		</div>
846
		<?php
847
	}
848
849
	/**
850
	 * Actions on the final step.
851
	 *
852
	 * @since 2.0.0
853
	 */
854
	private function setup_ready_actions() {
855
		GeoDir_Admin_Notices::remove_notice( 'install' );
0 ignored issues
show
Bug introduced by
The type GeoDir_Admin_Notices was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
856
857
		if ( isset( $_GET['gd_tracker_optin'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optin' ) ) {
858
			geodir_update_option( 'usage_tracking', true );
0 ignored issues
show
Bug introduced by
The function geodir_update_option was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

858
			/** @scrutinizer ignore-call */ 
859
   geodir_update_option( 'usage_tracking', true );
Loading history...
859
			GeoDir_Admin_Tracker::send_tracking_data( true );
0 ignored issues
show
Bug introduced by
The type GeoDir_Admin_Tracker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
860
861
		} elseif ( isset( $_GET['gd_tracker_optout'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optout' ) ) {
862
			geodir_update_option( 'usage_tracking', false );
863
		}
864
	}
865
866
867
}
868
869
new GetPaid_Admin_Setup_Wizard();
870