Passed
Push — master ( f198a7...6b8347 )
by Stiofan
31:55
created
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Indentation   +438 added lines, -438 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
  * @info        GetPaid Setup Wizard.
12 12
  */
13 13
 if ( ! defined( 'ABSPATH' ) ) {
14
-	exit;
14
+    exit;
15 15
 }
16 16
 
17 17
 /**
@@ -19,84 +19,84 @@  discard block
 block discarded – undo
19 19
  */
20 20
 class GetPaid_Admin_Setup_Wizard {
21 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();
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 100
 
101 101
 
102 102
 
@@ -108,21 +108,21 @@  discard block
 block discarded – undo
108 108
 //			call_user_func( $this->steps[ $this->step ]['handler'], $this );
109 109
 //		}
110 110
 
111
-		ob_start();
112
-		$this->setup_wizard_header();
111
+        ob_start();
112
+        $this->setup_wizard_header();
113 113
 //		$this->setup_wizard_steps();
114
-		$this->setup_wizard_content();
115
-		$this->setup_wizard_footer();
116
-		exit;
117
-	}
118
-
119
-	/**
120
-	 * Setup Wizard Header.
121
-	 *
122
-	 * @since 2.0.0
123
-	 */
114
+        $this->setup_wizard_content();
115
+        $this->setup_wizard_footer();
116
+        exit;
117
+    }
118
+
119
+    /**
120
+     * Setup Wizard Header.
121
+     *
122
+     * @since 2.0.0
123
+     */
124 124
 public function setup_wizard_header() {
125
-	?>
125
+    ?>
126 126
 	<!DOCTYPE html>
127 127
 	<html <?php language_attributes(); ?> class="bsui">
128 128
 	<head>
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
 		<title><?php esc_html_e( 'GetPaid &rsaquo; Setup Wizard', 'invoicing' ); ?></title>
132 132
 		<?php
133 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' ); ?>
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 137
 		<?php do_action( 'admin_head' ); ?>
138 138
 		<style>
139 139
 			body,p{
@@ -142,22 +142,22 @@  discard block
 block discarded – undo
142 142
 			}
143 143
 
144 144
 			<?php
145
-				$aui_settings = AyeCode_UI_Settings::instance();
146
-				echo $aui_settings::css_primary('#009874',true);
147
-			 ?>
145
+                $aui_settings = AyeCode_UI_Settings::instance();
146
+                echo $aui_settings::css_primary('#009874',true);
147
+                ?>
148 148
 
149 149
 
150 150
 		</style>
151 151
 	</head>
152 152
 	<body class="gp-setup wp-core-ui bg-lightx mx-auto text-dark scrollbars-ios" style="background: #f3f6ff;">
153 153
 	<?php
154
-	if(isset($_REQUEST['step'])){
155
-	$this->setup_wizard_steps();
156
-	}else{
157
-	echo "<div class='mb-3'>&nbsp;</div>";
158
-	}
154
+    if(isset($_REQUEST['step'])){
155
+    $this->setup_wizard_steps();
156
+    }else{
157
+    echo "<div class='mb-3'>&nbsp;</div>";
158
+    }
159 159
 
160
-	?>
160
+    ?>
161 161
 	<h1 class="h2 text-center pb-3">
162 162
 		<a class=" text-decoration-none" href="https://wpgetpaid.com/">
163 163
 			<span class="text-black-50">
@@ -166,61 +166,61 @@  discard block
 block discarded – undo
166 166
 		</a>
167 167
 	</h1>
168 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
-		?>
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 180
 		<ol class="gp-setup-steps mb-0 pb-4 mw-100 list-group list-group-horizontal text-center">
181 181
 			<?php
182
-			$current = '';
183
-			foreach ( $ouput_steps as $step_key => $step ) : ?>
182
+            $current = '';
183
+            foreach ( $ouput_steps as $step_key => $step ) : ?>
184 184
 				<li class="list-group-item flex-fill rounded-0 <?php
185
-				$maybe_hide = 'd-none';
186
-				if ( $step_key === $this->step ) {
187
-					$current = $this->step;
188
-					echo 'active';
189
-					$maybe_hide = '';
190
-				} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
191
-					echo 'done ';
192
-				}
193
-
194
-				echo ' '.$maybe_hide. ' d-md-block ';
195
-				$done = !$current ? 'text-success' : '';
196
-				?>"><i class="far fa-check-circle <?php echo $done ;?>"></i> <?php echo esc_html( $step['name'] ); ?></li>
185
+                $maybe_hide = 'd-none';
186
+                if ( $step_key === $this->step ) {
187
+                    $current = $this->step;
188
+                    echo 'active';
189
+                    $maybe_hide = '';
190
+                } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
191
+                    echo 'done ';
192
+                }
193
+
194
+                echo ' '.$maybe_hide. ' d-md-block ';
195
+                $done = !$current ? 'text-success' : '';
196
+                ?>"><i class="far fa-check-circle <?php echo $done ;?>"></i> <?php echo esc_html( $step['name'] ); ?></li>
197 197
 			<?php endforeach; ?>
198 198
 		</ol>
199 199
 		<?php
200
-	}
201
-
202
-	/**
203
-	 * Output the content for the current step.
204
-	 *
205
-	 * @since 2.0.0
206
-	 */
207
-	public function setup_wizard_content() {
208
-		echo '<div class="gp-setup-content rowx mw-100 text-center mb-3">';
209
-		echo '<div class="col-12 col-md-5 m-auto">';
210
-		echo '<div class="card shadow-sm">';
211
-		call_user_func( $this->steps[ $this->step ]['view'], $this );
212
-		echo '</div>';
213
-		echo '</div>';
214
-		echo '</div>';
215
-	}
216
-
217
-	/**
218
-	 * Setup Wizard Footer.
219
-	 *
220
-	 * @since 2.0.0
221
-	 */
222
-	public function setup_wizard_footer() {
223
-	?>
200
+    }
201
+
202
+    /**
203
+     * Output the content for the current step.
204
+     *
205
+     * @since 2.0.0
206
+     */
207
+    public function setup_wizard_content() {
208
+        echo '<div class="gp-setup-content rowx mw-100 text-center mb-3">';
209
+        echo '<div class="col-12 col-md-5 m-auto">';
210
+        echo '<div class="card shadow-sm">';
211
+        call_user_func( $this->steps[ $this->step ]['view'], $this );
212
+        echo '</div>';
213
+        echo '</div>';
214
+        echo '</div>';
215
+    }
216
+
217
+    /**
218
+     * Setup Wizard Footer.
219
+     *
220
+     * @since 2.0.0
221
+     */
222
+    public function setup_wizard_footer() {
223
+    ?>
224 224
 	<?php if ( 'next_steps' === $this->step ){ ?>
225 225
 		<p class="gd-return-to-dashboard-wrap"><a class="gd-return-to-dashboard btn btn-link d-block text-muted"
226 226
 		                                          href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'invoicing' ); ?></a>
@@ -234,13 +234,13 @@  discard block
 block discarded – undo
234 234
 	<?php
235 235
 }
236 236
 
237
-	/**
238
-	 * Introduction step.
239
-	 *
240
-	 * @since 2.0.0
241
-	 */
242
-	public function setup_introduction() {
243
-		?>
237
+    /**
238
+     * Introduction step.
239
+     *
240
+     * @since 2.0.0
241
+     */
242
+    public function setup_introduction() {
243
+        ?>
244 244
 		<h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1"><?php esc_html_e( 'Welcome to GetPaid!', 'invoicing' ); ?></h1>
245 245
 		<div class="card-body text-muted ">
246 246
 			<p class=""><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
@@ -346,50 +346,50 @@  discard block
 block discarded – undo
346 346
 			   class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
347 347
 		</div>
348 348
 		<?php
349
-	}
350
-
351
-	/**
352
-	 * Get the URL for the next step's screen.
353
-	 *
354
-	 * @param string step   slug (default: current step)
355
-	 *
356
-	 * @return string       URL for next step if a next step exists.
357
-	 *                      Admin URL if it's the last step.
358
-	 *                      Empty string on failure.
359
-	 * @since 3.0.0
360
-	 */
361
-	public function get_next_step_link( $step = '' ) {
362
-		if ( ! $step ) {
363
-			$step = $this->step;
364
-		}
365
-
366
-		$keys = array_keys( $this->steps );
367
-		if ( end( $keys ) === $step ) {
368
-			return admin_url();
369
-		}
370
-
371
-		$step_index = array_search( $step, $keys );
372
-		if ( false === $step_index ) {
373
-			return '';
374
-		}
375
-
376
-		return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
377
-	}
378
-
379
-	/**
380
-	 * Setup maps api.
381
-	 *
382
-	 * @since 2.0.0
383
-	 */
384
-	public function setup_business() {
385
-		?>
349
+    }
350
+
351
+    /**
352
+     * Get the URL for the next step's screen.
353
+     *
354
+     * @param string step   slug (default: current step)
355
+     *
356
+     * @return string       URL for next step if a next step exists.
357
+     *                      Admin URL if it's the last step.
358
+     *                      Empty string on failure.
359
+     * @since 3.0.0
360
+     */
361
+    public function get_next_step_link( $step = '' ) {
362
+        if ( ! $step ) {
363
+            $step = $this->step;
364
+        }
365
+
366
+        $keys = array_keys( $this->steps );
367
+        if ( end( $keys ) === $step ) {
368
+            return admin_url();
369
+        }
370
+
371
+        $step_index = array_search( $step, $keys );
372
+        if ( false === $step_index ) {
373
+            return '';
374
+        }
375
+
376
+        return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
377
+    }
378
+
379
+    /**
380
+     * Setup maps api.
381
+     *
382
+     * @since 2.0.0
383
+     */
384
+    public function setup_business() {
385
+        ?>
386 386
 		<form method="post" class="text-left card-body" action="options.php">
387 387
 			<?php
388 388
 
389
-			settings_fields( 'wpinv_settings' );
389
+            settings_fields( 'wpinv_settings' );
390 390
 
391
-			// override http referer to make it send back to the next step
392
-				?>
391
+            // override http referer to make it send back to the next step
392
+                ?>
393 393
 			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
394 394
 
395 395
 			<table class="gp-setup-maps w-100 " cellspacing="0">
@@ -398,21 +398,21 @@  discard block
 block discarded – undo
398 398
 
399 399
 				<?php
400 400
 
401
-				global $wp_settings_fields;
401
+                global $wp_settings_fields;
402 402
 
403
-				$page = 'wpinv_settings_general_main';
404
-				$section = 'wpinv_settings_general_main';
405
-				if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
406
-			        return;
407
-			    }
403
+                $page = 'wpinv_settings_general_main';
404
+                $section = 'wpinv_settings_general_main';
405
+                if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
406
+                    return;
407
+                }
408 408
 
409
-			    $settings =  $wp_settings_fields[ $page ][ $section ];
409
+                $settings =  $wp_settings_fields[ $page ][ $section ];
410 410
 
411
-				// unset title
412
-				unset($settings["wpinv_settings[location_settings]"]);
411
+                // unset title
412
+                unset($settings["wpinv_settings[location_settings]"]);
413 413
 
414
-			    $this->output_fields($settings);
415
-				?>
414
+                $this->output_fields($settings);
415
+                ?>
416 416
 
417 417
 
418 418
 				</tbody>
@@ -425,64 +425,64 @@  discard block
 block discarded – undo
425 425
 			</p>
426 426
 		</form>
427 427
 		<?php
428
-	}
428
+    }
429 429
 
430
-	public function output_fields($settings){
430
+    public function output_fields($settings){
431 431
 
432
-	    if ( empty($settings)) {
433
-	        return;
434
-	    }
432
+        if ( empty($settings)) {
433
+            return;
434
+        }
435 435
 
436 436
 //print_r($settings);
437
-	    foreach ( (array) $settings as $key => $field ) {
437
+        foreach ( (array) $settings as $key => $field ) {
438 438
 
439 439
 
440
-	        $class = '';
440
+            $class = '';
441 441
 
442
-	        if ( ! empty( $field['args']['class'] ) ) {
443
-	            $class = esc_attr( $field['args']['class'] );
444
-	        }
442
+            if ( ! empty( $field['args']['class'] ) ) {
443
+                $class = esc_attr( $field['args']['class'] );
444
+            }
445 445
 
446
-	       // echo '<div class="form-group '.$class.'">';
446
+            // echo '<div class="form-group '.$class.'">';
447 447
 
448 448
 
449
-	        if ( ! empty( $field['args']['label_for'] ) ) {
450
-	            $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" ';
451
-	        } else {
452
-	            $for = '';
453
-	        }
449
+            if ( ! empty( $field['args']['label_for'] ) ) {
450
+                $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" ';
451
+            } else {
452
+                $for = '';
453
+            }
454 454
 
455
-			$value  = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
456
-			$value  = wpinv_get_option( $field['args']['id'], $value );
455
+            $value  = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
456
+            $value  = wpinv_get_option( $field['args']['id'], $value );
457 457
 
458
-			if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){
458
+            if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){
459 459
 
460 460
 
461
-			// hide the logo inputs, we need to set them as hidden so they don't blank the current values.
462
-			$help_text = isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '';
463
-			$type = $field['callback'] == 'wpinv_number_callback'  ? 'number' : 'text';
464
-			$label = isset($field['args']['name']) ? esc_attr($field['args']['name']) : '';
461
+            // hide the logo inputs, we need to set them as hidden so they don't blank the current values.
462
+            $help_text = isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '';
463
+            $type = $field['callback'] == 'wpinv_number_callback'  ? 'number' : 'text';
464
+            $label = isset($field['args']['name']) ? esc_attr($field['args']['name']) : '';
465 465
 
466
-			if(in_array($field['id'],array('wpinv_settings[logo]','wpinv_settings[logo_width]','wpinv_settings[logo_height]'))){
467
-				$type = 'hidden';
468
-				$help_text = '';
469
-				$label = '';
470
-			}
466
+            if(in_array($field['id'],array('wpinv_settings[logo]','wpinv_settings[logo_width]','wpinv_settings[logo_height]'))){
467
+                $type = 'hidden';
468
+                $help_text = '';
469
+                $label = '';
470
+            }
471 471
 
472
-				echo aui()->input(array(
473
-									'type'  =>  $type,
474
-									'id'    =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
475
-									'name'    =>  isset($field['id']) ? esc_attr($field['id']) : '',
476
-									'value' =>   is_scalar( $value ) ? esc_attr( $value ) : '',
477
-									'required'  => false,
478
-									'help_text' => $help_text,
479
-									'label' => $label,
480
-									'label_type'    => 'floating'
481
-								));
482
-			}elseif($field['callback'] == 'wpinv_select_callback' || $field['callback'] == 'wpinv_country_states_callback'){
472
+                echo aui()->input(array(
473
+                                    'type'  =>  $type,
474
+                                    'id'    =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
475
+                                    'name'    =>  isset($field['id']) ? esc_attr($field['id']) : '',
476
+                                    'value' =>   is_scalar( $value ) ? esc_attr( $value ) : '',
477
+                                    'required'  => false,
478
+                                    'help_text' => $help_text,
479
+                                    'label' => $label,
480
+                                    'label_type'    => 'floating'
481
+                                ));
482
+            }elseif($field['callback'] == 'wpinv_select_callback' || $field['callback'] == 'wpinv_country_states_callback'){
483 483
 
484 484
 if($field['id']=='wpinv_settings[default_state]'){
485
-			$country_value  = wpinv_get_option( 'wpinv_settings[default_country]', 'US');
485
+            $country_value  = wpinv_get_option( 'wpinv_settings[default_country]', 'US');
486 486
 $options = wpinv_get_country_states($country_value);//echo $value .'###'.$country_value;
487 487
 }else{
488 488
 $options = isset($field['args']['options']) ? $field['args']['options'] : array();
@@ -490,78 +490,78 @@  discard block
 block discarded – undo
490 490
 
491 491
 //print_r($options );echo '###';
492 492
 
493
-				echo aui()->select( array(
494
-					'id'              =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
495
-					'name'            =>  isset($field['id']) ? esc_attr($field['id']) : '',
496
-					'placeholder'     => '',
493
+                echo aui()->select( array(
494
+                    'id'              =>  isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
495
+                    'name'            =>  isset($field['id']) ? esc_attr($field['id']) : '',
496
+                    'placeholder'     => '',
497 497
 //					'title'           => $site_title,
498
-					'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
499
-					'required'        => false,
500
-					'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
501
-					'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
502
-					'options'         => $options,
503
-					'select2'         => true,
504
-					'label_type'    => 'floating'
498
+                    'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
499
+                    'required'        => false,
500
+                    'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
501
+                    'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
502
+                    'options'         => $options,
503
+                    'select2'         => true,
504
+                    'label_type'    => 'floating'
505 505
 //					'wrap_class'      => isset( $field->css_class ) ? $field->css_class : '',
506
-				) );
507
-			}elseif($field['callback'] == 'wpinv_textarea_callback'){
508
-				$textarea =  aui()->textarea( array(
509
-					'id'              => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
510
-					'name'            => isset($field['id']) ? esc_attr($field['id']) : '',
511
-					'placeholder'     => '',
506
+                ) );
507
+            }elseif($field['callback'] == 'wpinv_textarea_callback'){
508
+                $textarea =  aui()->textarea( array(
509
+                    'id'              => isset($field['args']['id']) ? esc_attr($field['args']['id']) : '',
510
+                    'name'            => isset($field['id']) ? esc_attr($field['id']) : '',
511
+                    'placeholder'     => '',
512 512
 //					'title'           => $site_title,
513
-					'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
514
-					'required'        => false,
515
-					'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
516
-					'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
517
-					'rows'            => '4',
518
-					'label_type'    => 'floating'
513
+                    'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
514
+                    'required'        => false,
515
+                    'help_text'       => isset($field['args']['desc']) ? esc_attr($field['args']['desc']) : '',
516
+                    'label'           => isset($field['args']['name']) ? esc_attr($field['args']['name']) : '',
517
+                    'rows'            => '4',
518
+                    'label_type'    => 'floating'
519 519
 //					'wrap_class'      => isset( $field->css_class ) ? $field->css_class : '',
520
-				) );
520
+                ) );
521 521
 
522
-				// bug fixed in AUI 0.1.51 for name stripping []
523
-				$textarea = str_replace(sanitize_html_class($field['args']['id']),esc_attr($field['args']['id']),$textarea );
522
+                // bug fixed in AUI 0.1.51 for name stripping []
523
+                $textarea = str_replace(sanitize_html_class($field['args']['id']),esc_attr($field['args']['id']),$textarea );
524 524
 
525
-				echo $textarea;
526
-			}
525
+                echo $textarea;
526
+            }
527 527
 
528
-			//echo "<div>";
528
+            //echo "<div>";
529 529
 
530
-	    }
531
-	}
530
+        }
531
+    }
532 532
 
533
-	/**
534
-	 * Save Maps Settings.
535
-	 *
536
-	 * @since 2.0.0
537
-	 */
538
-	public function setup_business_save() {
533
+    /**
534
+     * Save Maps Settings.
535
+     *
536
+     * @since 2.0.0
537
+     */
538
+    public function setup_business_save() {
539 539
 
540
-	// nothing required here as options.php will send to next step
541
-		//check_admin_referer( 'gp-setup' );
540
+    // nothing required here as options.php will send to next step
541
+        //check_admin_referer( 'gp-setup' );
542 542
 
543 543
 //print_r($_POST);exit;
544 544
 //		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
545 545
 //		exit;
546
-	}
546
+    }
547 547
 
548
-	/**
549
-	 * Default Location settings.
550
-	 *
551
-	 * @since 2.0.0
552
-	 */
553
-	public function setup_currency() {
548
+    /**
549
+     * Default Location settings.
550
+     *
551
+     * @since 2.0.0
552
+     */
553
+    public function setup_currency() {
554 554
 
555
-		?>
555
+        ?>
556 556
 
557 557
 		<form method="post" class="text-left card-body" action="options.php">
558 558
 			<?php
559 559
 
560 560
 
561
-			settings_fields( 'wpinv_settings' );
561
+            settings_fields( 'wpinv_settings' );
562 562
 
563
-			// override http referer to make it send back to the next step
564
-				?>
563
+            // override http referer to make it send back to the next step
564
+                ?>
565 565
 			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
566 566
 
567 567
 			<table class="gp-setup-maps w-100 " cellspacing="0">
@@ -570,20 +570,20 @@  discard block
 block discarded – undo
570 570
 
571 571
 				<?php
572 572
 
573
-				global $wp_settings_fields;
573
+                global $wp_settings_fields;
574 574
 
575
-				$page = 'wpinv_settings_general_currency_section';
576
-				$section = 'wpinv_settings_general_currency_section';
577
-				if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
578
-			        return;
579
-			    }
575
+                $page = 'wpinv_settings_general_currency_section';
576
+                $section = 'wpinv_settings_general_currency_section';
577
+                if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
578
+                    return;
579
+                }
580 580
 
581
-			    $settings =  $wp_settings_fields[ $page ][ $section ];
581
+                $settings =  $wp_settings_fields[ $page ][ $section ];
582 582
 
583 583
 //				print_r($settings);exit;
584 584
 
585
-			    $this->output_fields($settings);
586
-				?>
585
+                $this->output_fields($settings);
586
+                ?>
587 587
 
588 588
 
589 589
 				</tbody>
@@ -597,35 +597,35 @@  discard block
 block discarded – undo
597 597
 		</form>
598 598
 
599 599
 		<?php
600
-	}
600
+    }
601 601
 
602 602
 
603
-	/**
604
-	 * Save Default Location Settings.
605
-	 *
606
-	 * @since 2.0.0
607
-	 */
608
-	public function setup_currency_save() {
609
-		check_admin_referer( 'gp-setup' );
603
+    /**
604
+     * Save Default Location Settings.
605
+     *
606
+     * @since 2.0.0
607
+     */
608
+    public function setup_currency_save() {
609
+        check_admin_referer( 'gp-setup' );
610 610
 
611
-		$generalSettings = new GeoDir_Settings_General();
612
-		$settings        = $generalSettings->get_settings( 'location' );
613
-		GeoDir_Admin_Settings::save_fields( $settings );
611
+        $generalSettings = new GeoDir_Settings_General();
612
+        $settings        = $generalSettings->get_settings( 'location' );
613
+        GeoDir_Admin_Settings::save_fields( $settings );
614 614
 
615
-		do_action( 'geodir_setup_wizard_default_location_saved', $settings );
615
+        do_action( 'geodir_setup_wizard_default_location_saved', $settings );
616 616
 
617
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
618
-		exit;
619
-	}
617
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
618
+        exit;
619
+    }
620 620
 
621
-	/**
622
-	 * Dummy Data setup.
623
-	 *
624
-	 * @since 2.0.0
625
-	 */
626
-	public function setup_recommend() {
621
+    /**
622
+     * Dummy Data setup.
623
+     *
624
+     * @since 2.0.0
625
+     */
626
+    public function setup_recommend() {
627 627
 
628
-		?>
628
+        ?>
629 629
 		<form method="post" class="text-center card-body">
630 630
 			<div class="gd-wizard-recommend">
631 631
 
@@ -636,22 +636,22 @@  discard block
 block discarded – undo
636 636
 
637 637
 				<?php
638 638
 
639
-				include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
639
+                include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
640 640
 
641
-				$recommend_wp_plugins = self::get_recommend_wp_plugins();
641
+                $recommend_wp_plugins = self::get_recommend_wp_plugins();
642 642
 
643
-				//			$status = install_plugin_install_status( array("slug"=>"two-factor","version"=>""));
644
-				//			print_r($status);
643
+                //			$status = install_plugin_install_status( array("slug"=>"two-factor","version"=>""));
644
+                //			print_r($status);
645 645
 
646
-				if ( ! empty( $recommend_wp_plugins ) ) {
646
+                if ( ! empty( $recommend_wp_plugins ) ) {
647 647
 
648
-				?>
648
+                ?>
649 649
 				<ul class="list-group">
650 650
 					<?php
651
-						foreach ( $recommend_wp_plugins as $plugin ) {
652
-						$status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) );
653
-						$plugin_status = isset( $status['status'] ) ? $status['status'] : '';
654
-						?>
651
+                        foreach ( $recommend_wp_plugins as $plugin ) {
652
+                        $status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) );
653
+                        $plugin_status = isset( $status['status'] ) ? $status['status'] : '';
654
+                        ?>
655 655
 							<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
656 656
 							    <span class="mr-auto"><?php echo esc_attr($plugin['name']); ?></span>
657 657
 								<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
@@ -664,16 +664,16 @@  discard block
 block discarded – undo
664 664
 								<small class="w-100"><?php echo esc_attr($plugin['desc'] );?></small>
665 665
 							 </li>
666 666
 						<?php
667
-						}
667
+                        }
668 668
                     ?>
669 669
 				</ul>
670 670
 				<?php
671 671
 
672
-				}
672
+                }
673 673
 
674 674
 
675 675
 
676
-				?>
676
+                ?>
677 677
 
678 678
 
679 679
 
@@ -684,57 +684,57 @@  discard block
 block discarded – undo
684 684
 			</p>
685 685
 		</form>
686 686
 		<?php
687
-	}
688
-
689
-		/**
690
-	 * A list of recommended wp.org plugins.
691
-	 * @return array
692
-	 */
693
-	public static function get_recommend_wp_plugins(){
694
-		$plugins = array(
695
-			'ayecode-connect' => array(
696
-				'url'   => 'https://wordpress.org/plugins/ayecode-connect/',
697
-				'slug'   => 'ayecode-connect',
698
-				'name'   => 'AyeCode Connect',
699
-				'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
700
-			),
701
-			'ninja-forms' => array(
702
-				'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
703
-				'slug'   => 'invoicing-quotes',
704
-				'name'   => 'Customer Quotes',
705
-				'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
706
-			),
707
-			'userswp' => array(
708
-				'url'   => 'https://wordpress.org/plugins/userswp/',
709
-				'slug'   => 'userswp',
710
-				'name'   => 'UsersWP',
711
-				'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
712
-			),
713
-		);
714
-
715
-		return $plugins;
716
-	}
717
-
718
-	/**
719
-	 * Dummy data save.
720
-	 *
721
-	 * This is done via ajax so we just pass onto the next step.
722
-	 *
723
-	 * @since 2.0.0
724
-	 */
725
-	public function setup_recommend_save() {
726
-		check_admin_referer( 'gp-setup' );
727
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
728
-		exit;
729
-	}
730
-
731
-	/**
732
-	 * Dummy Data setup.
733
-	 *
734
-	 * @since 2.0.0
735
-	 */
736
-	public function setup_payments() {
737
-		?>
687
+    }
688
+
689
+        /**
690
+         * A list of recommended wp.org plugins.
691
+         * @return array
692
+         */
693
+    public static function get_recommend_wp_plugins(){
694
+        $plugins = array(
695
+            'ayecode-connect' => array(
696
+                'url'   => 'https://wordpress.org/plugins/ayecode-connect/',
697
+                'slug'   => 'ayecode-connect',
698
+                'name'   => 'AyeCode Connect',
699
+                'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
700
+            ),
701
+            'ninja-forms' => array(
702
+                'url'   => 'https://wordpress.org/plugins/invoicing-quotes/',
703
+                'slug'   => 'invoicing-quotes',
704
+                'name'   => 'Customer Quotes',
705
+                'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
706
+            ),
707
+            'userswp' => array(
708
+                'url'   => 'https://wordpress.org/plugins/userswp/',
709
+                'slug'   => 'userswp',
710
+                'name'   => 'UsersWP',
711
+                'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
712
+            ),
713
+        );
714
+
715
+        return $plugins;
716
+    }
717
+
718
+    /**
719
+     * Dummy data save.
720
+     *
721
+     * This is done via ajax so we just pass onto the next step.
722
+     *
723
+     * @since 2.0.0
724
+     */
725
+    public function setup_recommend_save() {
726
+        check_admin_referer( 'gp-setup' );
727
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
728
+        exit;
729
+    }
730
+
731
+    /**
732
+     * Dummy Data setup.
733
+     *
734
+     * @since 2.0.0
735
+     */
736
+    public function setup_payments() {
737
+        ?>
738 738
 		<form method="post" class="text-center card-body">
739 739
 			<div class="gp-wizard-payments">
740 740
 
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 
776 776
 
777 777
 
778
-				?>
778
+                ?>
779 779
 
780 780
 
781 781
 			</div>
@@ -785,29 +785,29 @@  discard block
 block discarded – undo
785 785
 			</p>
786 786
 		</form>
787 787
 		<?php
788
-	}
789
-
790
-	/**
791
-	 * Dummy data save.
792
-	 *
793
-	 * This is done via ajax so we just pass onto the next step.
794
-	 *
795
-	 * @since 2.0.0
796
-	 */
797
-	public function setup_payments_save() {
798
-		check_admin_referer( 'gp-setup' );
799
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
800
-		exit;
801
-	}
802
-
803
-	/**
804
-	 * Final step.
805
-	 *
806
-	 * @since 2.0.0
807
-	 */
808
-	public function setup_ready() {
809
-		$this->setup_ready_actions();
810
-		?>
788
+    }
789
+
790
+    /**
791
+     * Dummy data save.
792
+     *
793
+     * This is done via ajax so we just pass onto the next step.
794
+     *
795
+     * @since 2.0.0
796
+     */
797
+    public function setup_payments_save() {
798
+        check_admin_referer( 'gp-setup' );
799
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
800
+        exit;
801
+    }
802
+
803
+    /**
804
+     * Final step.
805
+     *
806
+     * @since 2.0.0
807
+     */
808
+    public function setup_ready() {
809
+        $this->setup_ready_actions();
810
+        ?>
811 811
 
812 812
 		<div class="text-center card-body">
813 813
 			<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to GetPaid', 'invoicing' ); ?></h1>
@@ -848,24 +848,24 @@  discard block
 block discarded – undo
848 848
 			</div>
849 849
 		</div>
850 850
 		<?php
851
-	}
852
-
853
-	/**
854
-	 * Actions on the final step.
855
-	 *
856
-	 * @since 2.0.0
857
-	 */
858
-	private function setup_ready_actions() {
859
-		GeoDir_Admin_Notices::remove_notice( 'install' );
860
-
861
-		if ( isset( $_GET['gd_tracker_optin'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optin' ) ) {
862
-			geodir_update_option( 'usage_tracking', true );
863
-			GeoDir_Admin_Tracker::send_tracking_data( true );
864
-
865
-		} elseif ( isset( $_GET['gd_tracker_optout'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optout' ) ) {
866
-			geodir_update_option( 'usage_tracking', false );
867
-		}
868
-	}
851
+    }
852
+
853
+    /**
854
+     * Actions on the final step.
855
+     *
856
+     * @since 2.0.0
857
+     */
858
+    private function setup_ready_actions() {
859
+        GeoDir_Admin_Notices::remove_notice( 'install' );
860
+
861
+        if ( isset( $_GET['gd_tracker_optin'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optin' ) ) {
862
+            geodir_update_option( 'usage_tracking', true );
863
+            GeoDir_Admin_Tracker::send_tracking_data( true );
864
+
865
+        } elseif ( isset( $_GET['gd_tracker_optout'] ) && isset( $_GET['gd_tracker_nonce'] ) && wp_verify_nonce( $_GET['gd_tracker_nonce'], 'gd_tracker_optout' ) ) {
866
+            geodir_update_option( 'usage_tracking', false );
867
+        }
868
+    }
869 869
 
870 870
 
871 871
 }
Please login to merge, or discard this patch.