Passed
Push — master ( e50c18...f198a7 )
by Stiofan
86:03 queued 31:21
created
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Indentation   +434 added lines, -434 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,57 +166,57 @@  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
-				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>
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 193
 			<?php endforeach; ?>
194 194
 		</ol>
195 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
-	?>
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 220
 	<?php if ( 'next_steps' === $this->step ){ ?>
221 221
 		<p class="gd-return-to-dashboard-wrap"><a class="gd-return-to-dashboard btn btn-link d-block text-muted"
222 222
 		                                          href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Return to the WordPress Dashboard', 'invoicing' ); ?></a>
@@ -230,13 +230,13 @@  discard block
 block discarded – undo
230 230
 	<?php
231 231
 }
232 232
 
233
-	/**
234
-	 * Introduction step.
235
-	 *
236
-	 * @since 2.0.0
237
-	 */
238
-	public function setup_introduction() {
239
-		?>
233
+    /**
234
+     * Introduction step.
235
+     *
236
+     * @since 2.0.0
237
+     */
238
+    public function setup_introduction() {
239
+        ?>
240 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 241
 		<div class="card-body text-muted ">
242 242
 			<p class=""><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
@@ -342,50 +342,50 @@  discard block
 block discarded – undo
342 342
 			   class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
343 343
 		</div>
344 344
 		<?php
345
-	}
346
-
347
-	/**
348
-	 * Get the URL for the next step's screen.
349
-	 *
350
-	 * @param string step   slug (default: current step)
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
-		?>
345
+    }
346
+
347
+    /**
348
+     * Get the URL for the next step's screen.
349
+     *
350
+     * @param string step   slug (default: current step)
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 382
 		<form method="post" class="text-left card-body" action="options.php">
383 383
 			<?php
384 384
 
385
-			settings_fields( 'wpinv_settings' );
385
+            settings_fields( 'wpinv_settings' );
386 386
 
387
-			// override http referer to make it send back to the next step
388
-				?>
387
+            // override http referer to make it send back to the next step
388
+                ?>
389 389
 			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
390 390
 
391 391
 			<table class="gp-setup-maps w-100 " cellspacing="0">
@@ -394,21 +394,21 @@  discard block
 block discarded – undo
394 394
 
395 395
 				<?php
396 396
 
397
-				global $wp_settings_fields;
397
+                global $wp_settings_fields;
398 398
 
399
-				$page = 'wpinv_settings_general_main';
400
-				$section = 'wpinv_settings_general_main';
401
-				if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
402
-			        return;
403
-			    }
399
+                $page = 'wpinv_settings_general_main';
400
+                $section = 'wpinv_settings_general_main';
401
+                if ( ! isset( $wp_settings_fields[ $page ][ $section ] ) ) {
402
+                    return;
403
+                }
404 404
 
405
-			    $settings =  $wp_settings_fields[ $page ][ $section ];
405
+                $settings =  $wp_settings_fields[ $page ][ $section ];
406 406
 
407
-				// unset title
408
-				unset($settings["wpinv_settings[location_settings]"]);
407
+                // unset title
408
+                unset($settings["wpinv_settings[location_settings]"]);
409 409
 
410
-			    $this->output_fields($settings);
411
-				?>
410
+                $this->output_fields($settings);
411
+                ?>
412 412
 
413 413
 
414 414
 				</tbody>
@@ -421,64 +421,64 @@  discard block
 block discarded – undo
421 421
 			</p>
422 422
 		</form>
423 423
 		<?php
424
-	}
424
+    }
425 425
 
426
-	public function output_fields($settings){
426
+    public function output_fields($settings){
427 427
 
428
-	    if ( empty($settings)) {
429
-	        return;
430
-	    }
428
+        if ( empty($settings)) {
429
+            return;
430
+        }
431 431
 
432 432
 //print_r($settings);
433
-	    foreach ( (array) $settings as $key => $field ) {
433
+        foreach ( (array) $settings as $key => $field ) {
434 434
 
435 435
 
436
-	        $class = '';
436
+            $class = '';
437 437
 
438
-	        if ( ! empty( $field['args']['class'] ) ) {
439
-	            $class = esc_attr( $field['args']['class'] );
440
-	        }
438
+            if ( ! empty( $field['args']['class'] ) ) {
439
+                $class = esc_attr( $field['args']['class'] );
440
+            }
441 441
 
442
-	       // echo '<div class="form-group '.$class.'">';
442
+            // echo '<div class="form-group '.$class.'">';
443 443
 
444 444
 
445
-	        if ( ! empty( $field['args']['label_for'] ) ) {
446
-	            $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" ';
447
-	        } else {
448
-	            $for = '';
449
-	        }
445
+            if ( ! empty( $field['args']['label_for'] ) ) {
446
+                $for = ' for="' . esc_attr( $field['args']['label_for'] ) . '" ';
447
+            } else {
448
+                $for = '';
449
+            }
450 450
 
451
-			$value  = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
452
-			$value  = wpinv_get_option( $field['args']['id'], $value );
451
+            $value  = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
452
+            $value  = wpinv_get_option( $field['args']['id'], $value );
453 453
 
454
-			if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){
454
+            if($field['callback'] == 'wpinv_text_callback' || $field['callback'] == 'wpinv_number_callback' ){
455 455
 
456 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']) : '';
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 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
-			}
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 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'){
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 479
 
480 480
 if($field['id']=='wpinv_settings[default_state]'){
481
-			$country_value  = wpinv_get_option( 'wpinv_settings[default_country]', 'US');
481
+            $country_value  = wpinv_get_option( 'wpinv_settings[default_country]', 'US');
482 482
 $options = wpinv_get_country_states($country_value);//echo $value .'###'.$country_value;
483 483
 }else{
484 484
 $options = isset($field['args']['options']) ? $field['args']['options'] : array();
@@ -486,78 +486,78 @@  discard block
 block discarded – undo
486 486
 
487 487
 //print_r($options );echo '###';
488 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'     => '',
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 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'
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 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'     => '',
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 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'
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 515
 //					'wrap_class'      => isset( $field->css_class ) ? $field->css_class : '',
516
-				) );
516
+                ) );
517 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 );
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 520
 
521
-				echo $textarea;
522
-			}
521
+                echo $textarea;
522
+            }
523 523
 
524
-			//echo "<div>";
524
+            //echo "<div>";
525 525
 
526
-	    }
527
-	}
526
+        }
527
+    }
528 528
 
529
-	/**
530
-	 * Save Maps Settings.
531
-	 *
532
-	 * @since 2.0.0
533
-	 */
534
-	public function setup_business_save() {
529
+    /**
530
+     * Save Maps Settings.
531
+     *
532
+     * @since 2.0.0
533
+     */
534
+    public function setup_business_save() {
535 535
 
536
-	// nothing required here as options.php will send to next step
537
-		//check_admin_referer( 'gp-setup' );
536
+    // nothing required here as options.php will send to next step
537
+        //check_admin_referer( 'gp-setup' );
538 538
 
539 539
 //print_r($_POST);exit;
540 540
 //		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
541 541
 //		exit;
542
-	}
542
+    }
543 543
 
544
-	/**
545
-	 * Default Location settings.
546
-	 *
547
-	 * @since 2.0.0
548
-	 */
549
-	public function setup_currency() {
544
+    /**
545
+     * Default Location settings.
546
+     *
547
+     * @since 2.0.0
548
+     */
549
+    public function setup_currency() {
550 550
 
551
-		?>
551
+        ?>
552 552
 
553 553
 		<form method="post" class="text-left card-body" action="options.php">
554 554
 			<?php
555 555
 
556 556
 
557
-			settings_fields( 'wpinv_settings' );
557
+            settings_fields( 'wpinv_settings' );
558 558
 
559
-			// override http referer to make it send back to the next step
560
-				?>
559
+            // override http referer to make it send back to the next step
560
+                ?>
561 561
 			<input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $this->get_next_step_link() ); ?>">
562 562
 
563 563
 			<table class="gp-setup-maps w-100 " cellspacing="0">
@@ -566,20 +566,20 @@  discard block
 block discarded – undo
566 566
 
567 567
 				<?php
568 568
 
569
-				global $wp_settings_fields;
569
+                global $wp_settings_fields;
570 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
-			    }
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 576
 
577
-			    $settings =  $wp_settings_fields[ $page ][ $section ];
577
+                $settings =  $wp_settings_fields[ $page ][ $section ];
578 578
 
579 579
 //				print_r($settings);exit;
580 580
 
581
-			    $this->output_fields($settings);
582
-				?>
581
+                $this->output_fields($settings);
582
+                ?>
583 583
 
584 584
 
585 585
 				</tbody>
@@ -593,35 +593,35 @@  discard block
 block discarded – undo
593 593
 		</form>
594 594
 
595 595
 		<?php
596
-	}
596
+    }
597 597
 
598 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' );
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 606
 
607
-		$generalSettings = new GeoDir_Settings_General();
608
-		$settings        = $generalSettings->get_settings( 'location' );
609
-		GeoDir_Admin_Settings::save_fields( $settings );
607
+        $generalSettings = new GeoDir_Settings_General();
608
+        $settings        = $generalSettings->get_settings( 'location' );
609
+        GeoDir_Admin_Settings::save_fields( $settings );
610 610
 
611
-		do_action( 'geodir_setup_wizard_default_location_saved', $settings );
611
+        do_action( 'geodir_setup_wizard_default_location_saved', $settings );
612 612
 
613
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
614
-		exit;
615
-	}
613
+        wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
614
+        exit;
615
+    }
616 616
 
617
-	/**
618
-	 * Dummy Data setup.
619
-	 *
620
-	 * @since 2.0.0
621
-	 */
622
-	public function setup_recommend() {
617
+    /**
618
+     * Dummy Data setup.
619
+     *
620
+     * @since 2.0.0
621
+     */
622
+    public function setup_recommend() {
623 623
 
624
-		?>
624
+        ?>
625 625
 		<form method="post" class="text-center card-body">
626 626
 			<div class="gd-wizard-recommend">
627 627
 
@@ -632,22 +632,22 @@  discard block
 block discarded – undo
632 632
 
633 633
 				<?php
634 634
 
635
-				include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
635
+                include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); //for plugins_api..
636 636
 
637
-				$recommend_wp_plugins = self::get_recommend_wp_plugins();
637
+                $recommend_wp_plugins = self::get_recommend_wp_plugins();
638 638
 
639
-				//			$status = install_plugin_install_status( array("slug"=>"two-factor","version"=>""));
640
-				//			print_r($status);
639
+                //			$status = install_plugin_install_status( array("slug"=>"two-factor","version"=>""));
640
+                //			print_r($status);
641 641
 
642
-				if ( ! empty( $recommend_wp_plugins ) ) {
642
+                if ( ! empty( $recommend_wp_plugins ) ) {
643 643
 
644
-				?>
644
+                ?>
645 645
 				<ul class="list-group">
646 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'] : '';
650
-						?>
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'] : '';
650
+                        ?>
651 651
 							<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
652 652
 							    <span class="mr-auto"><?php echo esc_attr($plugin['name']); ?></span>
653 653
 								<div class="spinner-border spinner-border-sm mr-2 d-none text-muted" role="status">
@@ -660,16 +660,16 @@  discard block
 block discarded – undo
660 660
 								<small class="w-100"><?php echo esc_attr($plugin['desc'] );?></small>
661 661
 							 </li>
662 662
 						<?php
663
-						}
663
+                        }
664 664
                     ?>
665 665
 				</ul>
666 666
 				<?php
667 667
 
668
-				}
668
+                }
669 669
 
670 670
 
671 671
 
672
-				?>
672
+                ?>
673 673
 
674 674
 
675 675
 
@@ -680,57 +680,57 @@  discard block
 block discarded – undo
680 680
 			</p>
681 681
 		</form>
682 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;
725
-	}
726
-
727
-	/**
728
-	 * Dummy Data setup.
729
-	 *
730
-	 * @since 2.0.0
731
-	 */
732
-	public function setup_payments() {
733
-		?>
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;
725
+    }
726
+
727
+    /**
728
+     * Dummy Data setup.
729
+     *
730
+     * @since 2.0.0
731
+     */
732
+    public function setup_payments() {
733
+        ?>
734 734
 		<form method="post" class="text-center card-body">
735 735
 			<div class="gp-wizard-payments">
736 736
 
@@ -771,7 +771,7 @@  discard block
 block discarded – undo
771 771
 
772 772
 
773 773
 
774
-				?>
774
+                ?>
775 775
 
776 776
 
777 777
 			</div>
@@ -781,29 +781,29 @@  discard block
 block discarded – undo
781 781
 			</p>
782 782
 		</form>
783 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;
797
-	}
798
-
799
-	/**
800
-	 * Final step.
801
-	 *
802
-	 * @since 2.0.0
803
-	 */
804
-	public function setup_ready() {
805
-		$this->setup_ready_actions();
806
-		?>
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;
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 807
 
808 808
 		<div class="text-center card-body">
809 809
 			<h1 class="h3"><?php esc_html_e( 'Awesome, you are ready to GetPaid', 'invoicing' ); ?></h1>
@@ -844,24 +844,24 @@  discard block
 block discarded – undo
844 844
 			</div>
845 845
 		</div>
846 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' );
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 );
859
-			GeoDir_Admin_Tracker::send_tracking_data( true );
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
-	}
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' );
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 );
859
+            GeoDir_Admin_Tracker::send_tracking_data( true );
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 865
 
866 866
 
867 867
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -14,87 +14,87 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
66 66
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
72
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
73
-		do_action( 'getpaid_init_admin_hooks', $this );
74
-
75
-		// Setup/welcome
76
-		if ( ! empty( $_GET['page'] ) ) {
77
-			switch ( $_GET['page'] ) {
78
-				case 'gp-setup' :
79
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
80
-					break;
81
-			}
82
-		}
67
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
68
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
69
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
72
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
73
+        do_action( 'getpaid_init_admin_hooks', $this );
74
+
75
+        // Setup/welcome
76
+        if ( ! empty( $_GET['page'] ) ) {
77
+            switch ( $_GET['page'] ) {
78
+                case 'gp-setup' :
79
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
80
+                    break;
81
+            }
82
+        }
83 83
 
84 84
     }
85 85
 
86 86
     /**
87
-	 * Register admin scripts
88
-	 *
89
-	 */
90
-	public function enqeue_scripts() {
87
+     * Register admin scripts
88
+     *
89
+     */
90
+    public function enqeue_scripts() {
91 91
         global $current_screen, $pagenow;
92 92
 
93
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
94
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
93
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
94
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
95 95
 
96 96
         if ( ! empty( $current_screen->post_type ) ) {
97
-			$page = $current_screen->post_type;
97
+            $page = $current_screen->post_type;
98 98
         }
99 99
 
100 100
         // General styles.
@@ -115,54 +115,54 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
         // Payment form scripts.
118
-		if ( 'wpi_payment_form' == $page && $editing ) {
118
+        if ( 'wpi_payment_form' == $page && $editing ) {
119 119
             $this->load_payment_form_scripts();
120 120
         }
121 121
 
122
-		if ( $page == 'wpinv-subscriptions' ) {
123
-			wp_enqueue_script( 'postbox' );
124
-		}
122
+        if ( $page == 'wpinv-subscriptions' ) {
123
+            wp_enqueue_script( 'postbox' );
124
+        }
125 125
 
126 126
     }
127 127
 
128 128
     /**
129
-	 * Returns admin js translations.
130
-	 *
131
-	 */
132
-	protected function get_admin_i18() {
129
+     * Returns admin js translations.
130
+     *
131
+     */
132
+    protected function get_admin_i18() {
133 133
         global $post;
134 134
 
135
-		$date_range = array(
136
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
137
-		);
135
+        $date_range = array(
136
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
137
+        );
138 138
 
139
-		if ( $date_range['period'] == 'custom' ) {
139
+        if ( $date_range['period'] == 'custom' ) {
140 140
 			
141
-			if ( isset( $_GET['from'] ) ) {
142
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
143
-			}
141
+            if ( isset( $_GET['from'] ) ) {
142
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
143
+            }
144 144
 
145
-			if ( isset( $_GET['to'] ) ) {
146
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['to'] ) ) {
146
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
147
+            }
148 148
 
149
-		}
149
+        }
150 150
 
151 151
         $i18n = array(
152 152
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
153 153
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
154
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
155
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
156
-			'rest_root'                 => esc_url_raw( rest_url() ),
157
-			'date_range'                => $date_range,
154
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
155
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
156
+            'rest_root'                 => esc_url_raw( rest_url() ),
157
+            'date_range'                => $date_range,
158 158
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
159 159
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
160 160
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
161 161
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
162 162
             'tax'                       => wpinv_tax_amount(),
163 163
             'discount'                  => 0,
164
-			'currency_symbol'           => wpinv_currency_symbol(),
165
-			'currency'                  => wpinv_get_currency(),
164
+            'currency_symbol'           => wpinv_currency_symbol(),
165
+            'currency'                  => wpinv_get_currency(),
166 166
             'currency_pos'              => wpinv_currency_position(),
167 167
             'thousand_sep'              => wpinv_thousands_separator(),
168 168
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -182,118 +182,118 @@  discard block
 block discarded – undo
182 182
             'item_description'          => __( 'Item Description', 'invoicing' ),
183 183
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
184 184
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
185
-			'searching'                 => __( 'Searching', 'invoicing' ),
186
-			'loading'                   => __( 'Loading...', 'invoicing' ),
187
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
188
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
185
+            'searching'                 => __( 'Searching', 'invoicing' ),
186
+            'loading'                   => __( 'Loading...', 'invoicing' ),
187
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
188
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
189 189
         );
190 190
 
191
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
191
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
192 192
 
193
-			$invoice              = new WPInv_Invoice( $post );
194
-			$i18n['save_invoice'] = sprintf(
195
-				__( 'Save %s', 'invoicing' ),
196
-				ucfirst( $invoice->get_invoice_quote_type() )
197
-			);
193
+            $invoice              = new WPInv_Invoice( $post );
194
+            $i18n['save_invoice'] = sprintf(
195
+                __( 'Save %s', 'invoicing' ),
196
+                ucfirst( $invoice->get_invoice_quote_type() )
197
+            );
198 198
 
199
-			$i18n['invoice_description'] = sprintf(
200
-				__( '%s Description', 'invoicing' ),
201
-				ucfirst( $invoice->get_invoice_quote_type() )
202
-			);
199
+            $i18n['invoice_description'] = sprintf(
200
+                __( '%s Description', 'invoicing' ),
201
+                ucfirst( $invoice->get_invoice_quote_type() )
202
+            );
203 203
 
204
-		}
205
-		return $i18n;
206
-	}
204
+        }
205
+        return $i18n;
206
+    }
207 207
 
208
-	/**
209
-	 * Change the admin footer text on GetPaid admin pages.
210
-	 *
211
-	 * @since  2.0.0
212
-	 * @param  string $footer_text
213
-	 * @return string
214
-	 */
215
-	public function admin_footer_text( $footer_text ) {
216
-		global $current_screen;
208
+    /**
209
+     * Change the admin footer text on GetPaid admin pages.
210
+     *
211
+     * @since  2.0.0
212
+     * @param  string $footer_text
213
+     * @return string
214
+     */
215
+    public function admin_footer_text( $footer_text ) {
216
+        global $current_screen;
217 217
 
218
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
218
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
219 219
 
220 220
         if ( ! empty( $current_screen->post_type ) ) {
221
-			$page = $current_screen->post_type;
221
+            $page = $current_screen->post_type;
222 222
         }
223 223
 
224 224
         // General styles.
225 225
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
226 226
 
227
-			// Change the footer text
228
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
229
-
230
-				$rating_url  = esc_url(
231
-					wp_nonce_url(
232
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
233
-						'getpaid-nonce',
234
-						'getpaid-nonce'
235
-						)
236
-				);
237
-
238
-				$footer_text = sprintf(
239
-					/* translators: %s: five stars */
240
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
241
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
242
-				);
243
-
244
-			} else {
245
-
246
-				$footer_text = sprintf(
247
-					/* translators: %s: GetPaid */
248
-					__( 'Thank you for using %s!', 'invoicing' ),
249
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
250
-				);
251
-
252
-			}
253
-
254
-		}
255
-
256
-		return $footer_text;
257
-	}
258
-
259
-	/**
260
-	 * Redirects to wp.org to rate the plugin.
261
-	 *
262
-	 * @since  2.0.0
263
-	 */
264
-	public function redirect_to_wordpress_rating_page() {
265
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
266
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
267
-		exit;
268
-	}
227
+            // Change the footer text
228
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
229
+
230
+                $rating_url  = esc_url(
231
+                    wp_nonce_url(
232
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
233
+                        'getpaid-nonce',
234
+                        'getpaid-nonce'
235
+                        )
236
+                );
237
+
238
+                $footer_text = sprintf(
239
+                    /* translators: %s: five stars */
240
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
241
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
242
+                );
243
+
244
+            } else {
245
+
246
+                $footer_text = sprintf(
247
+                    /* translators: %s: GetPaid */
248
+                    __( 'Thank you for using %s!', 'invoicing' ),
249
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
250
+                );
251
+
252
+            }
253
+
254
+        }
255
+
256
+        return $footer_text;
257
+    }
269 258
 
270 259
     /**
271
-	 * Loads payment form js.
272
-	 *
273
-	 */
274
-	protected function load_payment_form_scripts() {
260
+     * Redirects to wp.org to rate the plugin.
261
+     *
262
+     * @since  2.0.0
263
+     */
264
+    public function redirect_to_wordpress_rating_page() {
265
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
266
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
267
+        exit;
268
+    }
269
+
270
+    /**
271
+     * Loads payment form js.
272
+     *
273
+     */
274
+    protected function load_payment_form_scripts() {
275 275
         global $post;
276 276
 
277 277
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
278
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
279
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
278
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
279
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
280 280
 
281
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
282
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
281
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
282
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable' ),  $version );
283 283
 
284
-		wp_localize_script(
284
+        wp_localize_script(
285 285
             'wpinv-admin-payment-form-script',
286 286
             'wpinvPaymentFormAdmin',
287 287
             array(
288
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
289
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
290
-				'currency'      => wpinv_currency_symbol(),
291
-				'position'      => wpinv_currency_position(),
292
-				'decimals'      => (int) wpinv_decimals(),
293
-				'thousands_sep' => wpinv_thousands_separator(),
294
-				'decimals_sep'  => wpinv_decimal_separator(),
295
-				'form_items'    => gepaid_get_form_items( $post->ID ),
296
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
288
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
289
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
290
+                'currency'      => wpinv_currency_symbol(),
291
+                'position'      => wpinv_currency_position(),
292
+                'decimals'      => (int) wpinv_decimals(),
293
+                'thousands_sep' => wpinv_thousands_separator(),
294
+                'decimals_sep'  => wpinv_decimal_separator(),
295
+                'form_items'    => gepaid_get_form_items( $post->ID ),
296
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
297 297
             )
298 298
         );
299 299
 
@@ -302,20 +302,20 @@  discard block
 block discarded – undo
302 302
     }
303 303
 
304 304
     /**
305
-	 * Add our classes to admin pages.
305
+     * Add our classes to admin pages.
306 306
      *
307 307
      * @param string $classes
308 308
      * @return string
309
-	 *
310
-	 */
309
+     *
310
+     */
311 311
     public function admin_body_class( $classes ) {
312
-		global $pagenow, $post, $current_screen;
312
+        global $pagenow, $post, $current_screen;
313 313
 
314 314
 
315 315
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
316 316
 
317 317
         if ( ! empty( $current_screen->post_type ) ) {
318
-			$page = $current_screen->post_type;
318
+            $page = $current_screen->post_type;
319 319
         }
320 320
 
321 321
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -324,59 +324,59 @@  discard block
 block discarded – undo
324 324
 
325 325
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
326 326
             $classes .= ' wpinv-cpt wpinv';
327
-		}
327
+        }
328 328
 		
329
-		if ( getpaid_is_invoice_post_type( $page ) ) {
329
+        if ( getpaid_is_invoice_post_type( $page ) ) {
330 330
             $classes .= ' getpaid-is-invoice-cpt';
331 331
         }
332 332
 
333
-		return $classes;
333
+        return $classes;
334 334
     }
335 335
 
336 336
     /**
337
-	 * Maybe show the AyeCode Connect Notice.
338
-	 */
339
-	public function init_ayecode_connect_helper(){
337
+     * Maybe show the AyeCode Connect Notice.
338
+     */
339
+    public function init_ayecode_connect_helper(){
340 340
 
341 341
         new AyeCode_Connect_Helper(
342 342
             array(
343
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
344
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
345
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
346
-				'connect_button'    => __("Connect Site","invoicing"),
347
-				'connecting_button'    => __("Connecting...","invoicing"),
348
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
349
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
343
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
344
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
345
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
346
+                'connect_button'    => __("Connect Site","invoicing"),
347
+                'connecting_button'    => __("Connecting...","invoicing"),
348
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
349
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
350 350
             ),
351 351
             array( 'wpi-addons' )
352 352
         );
353 353
 
354 354
     }
355 355
 
356
-	/**
357
-	 * Redirect users to settings on activation.
358
-	 *
359
-	 * @return void
360
-	 */
361
-	public function activation_redirect() {
356
+    /**
357
+     * Redirect users to settings on activation.
358
+     *
359
+     * @return void
360
+     */
361
+    public function activation_redirect() {
362 362
 
363
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
363
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
364 364
 
365
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
366
-			return;
367
-		}
365
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
366
+            return;
367
+        }
368 368
 
369
-		// Bail if activating from network, or bulk
370
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
371
-			return;
372
-		}
369
+        // Bail if activating from network, or bulk
370
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
371
+            return;
372
+        }
373 373
 
374
-	    update_option( 'wpinv_redirected_to_settings', 1 );
374
+        update_option( 'wpinv_redirected_to_settings', 1 );
375 375
 
376 376
         wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
377 377
         exit;
378 378
 
379
-	}
379
+    }
380 380
 
381 381
     /**
382 382
      * Fires an admin action after verifying that a user can fire them.
@@ -390,384 +390,384 @@  discard block
 block discarded – undo
390 390
 
391 391
     }
392 392
 
393
-	/**
393
+    /**
394 394
      * Sends a payment reminder to a customer.
395
-	 * 
396
-	 * @param array $args
395
+     * 
396
+     * @param array $args
397 397
      */
398 398
     public function send_customer_invoice( $args ) {
399
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
399
+        $sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
400 400
 
401
-		if ( $sent ) {
402
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
403
-		} else {
404
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
405
-		}
401
+        if ( $sent ) {
402
+            $this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
403
+        } else {
404
+            $this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
405
+        }
406 406
 
407
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
408
-		exit;
409
-	}
407
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
408
+        exit;
409
+    }
410 410
 
411
-	/**
411
+    /**
412 412
      * Sends a payment reminder to a customer.
413
-	 * 
414
-	 * @param array $args
413
+     * 
414
+     * @param array $args
415 415
      */
416 416
     public function send_customer_payment_reminder( $args ) {
417
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
417
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
418 418
 
419
-		if ( $sent ) {
420
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
421
-		} else {
422
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
423
-		}
419
+        if ( $sent ) {
420
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
421
+        } else {
422
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
423
+        }
424 424
 
425
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
426
-		exit;
427
-	}
425
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
426
+        exit;
427
+    }
428 428
 
429
-	/**
429
+    /**
430 430
      * Resets tax rates.
431
-	 * 
431
+     * 
432 432
      */
433 433
     public function admin_reset_tax_rates() {
434 434
 
435
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
436
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
437
-		exit;
435
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
436
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
437
+        exit;
438 438
 
439
-	}
439
+    }
440 440
 
441
-	/**
441
+    /**
442 442
      * Resets admin pages.
443
-	 * 
443
+     * 
444 444
      */
445 445
     public function admin_create_missing_pages() {
446
-		$installer = new GetPaid_Installer();
447
-		$installer->create_pages();
448
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
449
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
450
-		exit;
451
-	}
452
-
453
-	/**
446
+        $installer = new GetPaid_Installer();
447
+        $installer->create_pages();
448
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
449
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
450
+        exit;
451
+    }
452
+
453
+    /**
454 454
      * Creates an missing admin tables.
455
-	 * 
455
+     * 
456 456
      */
457 457
     public function admin_create_missing_tables() {
458
-		global $wpdb;
459
-		$installer = new GetPaid_Installer();
458
+        global $wpdb;
459
+        $installer = new GetPaid_Installer();
460 460
 
461
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
462
-			$installer->create_subscriptions_table();
461
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
462
+            $installer->create_subscriptions_table();
463 463
 
464
-			if ( $wpdb->last_error !== '' ) {
465
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
466
-			}
467
-		}
464
+            if ( $wpdb->last_error !== '' ) {
465
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
466
+            }
467
+        }
468 468
 
469
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
470
-			$installer->create_invoices_table();
469
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
470
+            $installer->create_invoices_table();
471 471
 
472
-			if ( $wpdb->last_error !== '' ) {
473
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
474
-			}
475
-		}
472
+            if ( $wpdb->last_error !== '' ) {
473
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
474
+            }
475
+        }
476 476
 
477
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
478
-			$installer->create_invoice_items_table();
477
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
478
+            $installer->create_invoice_items_table();
479 479
 
480
-			if ( $wpdb->last_error !== '' ) {
481
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
482
-			}
483
-		}
480
+            if ( $wpdb->last_error !== '' ) {
481
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
482
+            }
483
+        }
484 484
 
485
-		if ( ! $this->has_notices() ) {
486
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
487
-		}
485
+        if ( ! $this->has_notices() ) {
486
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
487
+        }
488 488
 
489
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
490
-		exit;
491
-	}
489
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
490
+        exit;
491
+    }
492 492
 
493
-	/**
493
+    /**
494 494
      * Migrates old invoices to the new database tables.
495
-	 * 
495
+     * 
496 496
      */
497 497
     public function admin_migrate_old_invoices() {
498 498
 
499
-		// Migrate the invoices.
500
-		$installer = new GetPaid_Installer();
501
-		$installer->migrate_old_invoices();
499
+        // Migrate the invoices.
500
+        $installer = new GetPaid_Installer();
501
+        $installer->migrate_old_invoices();
502 502
 
503
-		// Show an admin message.
504
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
503
+        // Show an admin message.
504
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
505 505
 
506
-		// Redirect the admin.
507
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
508
-		exit;
506
+        // Redirect the admin.
507
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
508
+        exit;
509 509
 
510
-	}
510
+    }
511 511
 
512
-	/**
512
+    /**
513 513
      * Download customers.
514
-	 * 
514
+     * 
515 515
      */
516 516
     public function admin_download_customers() {
517
-		global $wpdb;
517
+        global $wpdb;
518 518
 
519
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
519
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
520 520
 
521
-		header( "Content-Type:text/csv" );
522
-		header( "Content-Disposition:attachment;filename=customers.csv" );
521
+        header( "Content-Type:text/csv" );
522
+        header( "Content-Disposition:attachment;filename=customers.csv" );
523 523
 
524
-		$post_types = '';
524
+        $post_types = '';
525 525
 
526
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
527
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
528
-		}
526
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
527
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
528
+        }
529 529
 
530
-		$post_types = rtrim( $post_types, ' OR' );
530
+        $post_types = rtrim( $post_types, ' OR' );
531 531
 
532
-		$customers = $wpdb->get_col(
533
-			$wpdb->prepare(
534
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
535
-			)
536
-		);
532
+        $customers = $wpdb->get_col(
533
+            $wpdb->prepare(
534
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
535
+            )
536
+        );
537 537
 
538
-		$columns = array(
539
-			'name'     => __( 'Name', 'invoicing' ),
540
-			'email'    => __( 'Email', 'invoicing' ),
541
-			'country'  => __( 'Country', 'invoicing' ),
542
-			'state'    => __( 'State', 'invoicing' ),
543
-			'city'     => __( 'City', 'invoicing' ),
544
-			'zip'      => __( 'ZIP', 'invoicing' ),
545
-			'address'  => __( 'Address', 'invoicing' ),
546
-			'phone'    => __( 'Phone', 'invoicing' ),
547
-			'company'  => __( 'Company', 'invoicing' ),
548
-			'invoices' => __( 'Invoices', 'invoicing' ),
549
-			'total'    => __( 'Total Spend', 'invoicing' ),
550
-			'signup'   => __( 'Date created', 'invoicing' ),
551
-		);
538
+        $columns = array(
539
+            'name'     => __( 'Name', 'invoicing' ),
540
+            'email'    => __( 'Email', 'invoicing' ),
541
+            'country'  => __( 'Country', 'invoicing' ),
542
+            'state'    => __( 'State', 'invoicing' ),
543
+            'city'     => __( 'City', 'invoicing' ),
544
+            'zip'      => __( 'ZIP', 'invoicing' ),
545
+            'address'  => __( 'Address', 'invoicing' ),
546
+            'phone'    => __( 'Phone', 'invoicing' ),
547
+            'company'  => __( 'Company', 'invoicing' ),
548
+            'invoices' => __( 'Invoices', 'invoicing' ),
549
+            'total'    => __( 'Total Spend', 'invoicing' ),
550
+            'signup'   => __( 'Date created', 'invoicing' ),
551
+        );
552 552
 
553
-		// Output the csv column headers.
554
-		fputcsv( $output, array_values( $columns ) );
553
+        // Output the csv column headers.
554
+        fputcsv( $output, array_values( $columns ) );
555 555
 
556
-		// Loop through
557
-		$table = new WPInv_Customers_Table();
558
-		foreach ( $customers as $customer_id ) {
556
+        // Loop through
557
+        $table = new WPInv_Customers_Table();
558
+        foreach ( $customers as $customer_id ) {
559 559
 
560
-			$user = get_user_by( 'id', $customer_id );
561
-			$row  = array();
562
-			if ( empty( $user ) ) {
563
-				continue;
564
-			}
560
+            $user = get_user_by( 'id', $customer_id );
561
+            $row  = array();
562
+            if ( empty( $user ) ) {
563
+                continue;
564
+            }
565 565
 
566
-			foreach ( array_keys( $columns ) as $column ) {
566
+            foreach ( array_keys( $columns ) as $column ) {
567 567
 
568
-				$method = 'column_' . $column;
568
+                $method = 'column_' . $column;
569 569
 
570
-				if ( 'name' == $column ) {
571
-					$value = sanitize_text_field( $user->display_name );
572
-				} else if( 'email' == $column ) {
573
-					$value = sanitize_email( $user->user_email );
574
-				} else if ( is_callable( array( $table, $method ) ) ) {
575
-					$value = strip_tags( $table->$method( $user ) );
576
-				}
570
+                if ( 'name' == $column ) {
571
+                    $value = sanitize_text_field( $user->display_name );
572
+                } else if( 'email' == $column ) {
573
+                    $value = sanitize_email( $user->user_email );
574
+                } else if ( is_callable( array( $table, $method ) ) ) {
575
+                    $value = strip_tags( $table->$method( $user ) );
576
+                }
577 577
 
578
-				if ( empty( $value ) ) {
579
-					$value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
580
-				}
578
+                if ( empty( $value ) ) {
579
+                    $value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
580
+                }
581 581
 
582
-				$row[] = $value;
582
+                $row[] = $value;
583 583
 
584
-			}
584
+            }
585 585
 
586
-			fputcsv( $output, $row );
587
-		}
586
+            fputcsv( $output, $row );
587
+        }
588 588
 
589
-		fclose( $output );
590
-		exit;
589
+        fclose( $output );
590
+        exit;
591 591
 
592
-	}
592
+    }
593 593
 
594
-	/**
594
+    /**
595 595
      * Recalculates discounts.
596
-	 * 
596
+     * 
597 597
      */
598 598
     public function admin_recalculate_discounts() {
599
-		global $wpdb;
599
+        global $wpdb;
600 600
 
601
-		// Fetch all invoices that have discount codes.
602
-		$table    = $wpdb->prefix . 'getpaid_invoices';
603
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
601
+        // Fetch all invoices that have discount codes.
602
+        $table    = $wpdb->prefix . 'getpaid_invoices';
603
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
604 604
 
605
-		foreach ( $invoices as $invoice ) {
605
+        foreach ( $invoices as $invoice ) {
606 606
 
607
-			$invoice = new WPInv_Invoice( $invoice );
607
+            $invoice = new WPInv_Invoice( $invoice );
608 608
 
609
-			if ( ! $invoice->exists() ) {
610
-				continue;
611
-			}
609
+            if ( ! $invoice->exists() ) {
610
+                continue;
611
+            }
612 612
 
613
-			// Abort if the discount does not exist or does not apply here.
614
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
615
-			if ( ! $discount->exists() ) {
616
-				continue;
617
-			}
613
+            // Abort if the discount does not exist or does not apply here.
614
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
615
+            if ( ! $discount->exists() ) {
616
+                continue;
617
+            }
618 618
 
619
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
620
-			$invoice->recalculate_total();
619
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
620
+            $invoice->recalculate_total();
621 621
 
622
-			if ( $invoice->get_total_discount() > 0 ) {
623
-				$invoice->save();
624
-			}
622
+            if ( $invoice->get_total_discount() > 0 ) {
623
+                $invoice->save();
624
+            }
625 625
 
626
-		}
626
+        }
627 627
 
628
-		// Show an admin message.
629
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
628
+        // Show an admin message.
629
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
630 630
 
631
-		// Redirect the admin.
632
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
633
-		exit;
631
+        // Redirect the admin.
632
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
633
+        exit;
634 634
 
635
-	}
635
+    }
636 636
 
637 637
     /**
638
-	 * Returns an array of admin notices.
639
-	 *
640
-	 * @since       1.0.19
638
+     * Returns an array of admin notices.
639
+     *
640
+     * @since       1.0.19
641 641
      * @return array
642
-	 */
643
-	public function get_notices() {
644
-		$notices = get_option( 'wpinv_admin_notices' );
642
+     */
643
+    public function get_notices() {
644
+        $notices = get_option( 'wpinv_admin_notices' );
645 645
         return is_array( $notices ) ? $notices : array();
646
-	}
646
+    }
647 647
 
648
-	/**
649
-	 * Checks if we have any admin notices.
650
-	 *
651
-	 * @since       2.0.4
648
+    /**
649
+     * Checks if we have any admin notices.
650
+     *
651
+     * @since       2.0.4
652 652
      * @return array
653
-	 */
654
-	public function has_notices() {
655
-		return count( $this->get_notices() ) > 0;
656
-	}
657
-
658
-	/**
659
-	 * Clears all admin notices
660
-	 *
661
-	 * @access      public
662
-	 * @since       1.0.19
663
-	 */
664
-	public function clear_notices() {
665
-		delete_option( 'wpinv_admin_notices' );
666
-	}
667
-
668
-	/**
669
-	 * Saves a new admin notice
670
-	 *
671
-	 * @access      public
672
-	 * @since       1.0.19
673
-	 */
674
-	public function save_notice( $type, $message ) {
675
-		$notices = $this->get_notices();
676
-
677
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
678
-			$notices[ $type ] = array();
679
-		}
680
-
681
-		$notices[ $type ][] = $message;
682
-
683
-		update_option( 'wpinv_admin_notices', $notices );
684
-	}
685
-
686
-	/**
687
-	 * Displays a success notice
688
-	 *
689
-	 * @param       string $msg The message to qeue.
690
-	 * @access      public
691
-	 * @since       1.0.19
692
-	 */
693
-	public function show_success( $msg ) {
694
-		$this->save_notice( 'success', $msg );
695
-	}
696
-
697
-	/**
698
-	 * Displays a error notice
699
-	 *
700
-	 * @access      public
701
-	 * @param       string $msg The message to qeue.
702
-	 * @since       1.0.19
703
-	 */
704
-	public function show_error( $msg ) {
705
-		$this->save_notice( 'error', $msg );
706
-	}
707
-
708
-	/**
709
-	 * Displays a warning notice
710
-	 *
711
-	 * @access      public
712
-	 * @param       string $msg The message to qeue.
713
-	 * @since       1.0.19
714
-	 */
715
-	public function show_warning( $msg ) {
716
-		$this->save_notice( 'warning', $msg );
717
-	}
718
-
719
-	/**
720
-	 * Displays a info notice
721
-	 *
722
-	 * @access      public
723
-	 * @param       string $msg The message to qeue.
724
-	 * @since       1.0.19
725
-	 */
726
-	public function show_info( $msg ) {
727
-		$this->save_notice( 'info', $msg );
728
-	}
729
-
730
-	/**
731
-	 * Show notices
732
-	 *
733
-	 * @access      public
734
-	 * @since       1.0.19
735
-	 */
736
-	public function show_notices() {
653
+     */
654
+    public function has_notices() {
655
+        return count( $this->get_notices() ) > 0;
656
+    }
657
+
658
+    /**
659
+     * Clears all admin notices
660
+     *
661
+     * @access      public
662
+     * @since       1.0.19
663
+     */
664
+    public function clear_notices() {
665
+        delete_option( 'wpinv_admin_notices' );
666
+    }
667
+
668
+    /**
669
+     * Saves a new admin notice
670
+     *
671
+     * @access      public
672
+     * @since       1.0.19
673
+     */
674
+    public function save_notice( $type, $message ) {
675
+        $notices = $this->get_notices();
676
+
677
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
678
+            $notices[ $type ] = array();
679
+        }
680
+
681
+        $notices[ $type ][] = $message;
682
+
683
+        update_option( 'wpinv_admin_notices', $notices );
684
+    }
685
+
686
+    /**
687
+     * Displays a success notice
688
+     *
689
+     * @param       string $msg The message to qeue.
690
+     * @access      public
691
+     * @since       1.0.19
692
+     */
693
+    public function show_success( $msg ) {
694
+        $this->save_notice( 'success', $msg );
695
+    }
696
+
697
+    /**
698
+     * Displays a error notice
699
+     *
700
+     * @access      public
701
+     * @param       string $msg The message to qeue.
702
+     * @since       1.0.19
703
+     */
704
+    public function show_error( $msg ) {
705
+        $this->save_notice( 'error', $msg );
706
+    }
707
+
708
+    /**
709
+     * Displays a warning notice
710
+     *
711
+     * @access      public
712
+     * @param       string $msg The message to qeue.
713
+     * @since       1.0.19
714
+     */
715
+    public function show_warning( $msg ) {
716
+        $this->save_notice( 'warning', $msg );
717
+    }
718
+
719
+    /**
720
+     * Displays a info notice
721
+     *
722
+     * @access      public
723
+     * @param       string $msg The message to qeue.
724
+     * @since       1.0.19
725
+     */
726
+    public function show_info( $msg ) {
727
+        $this->save_notice( 'info', $msg );
728
+    }
729
+
730
+    /**
731
+     * Show notices
732
+     *
733
+     * @access      public
734
+     * @since       1.0.19
735
+     */
736
+    public function show_notices() {
737 737
 
738 738
         $notices = $this->get_notices();
739 739
         $this->clear_notices();
740 740
 
741
-		foreach ( $notices as $type => $messages ) {
741
+        foreach ( $notices as $type => $messages ) {
742 742
 
743
-			if ( ! is_array( $messages ) ) {
744
-				continue;
745
-			}
743
+            if ( ! is_array( $messages ) ) {
744
+                continue;
745
+            }
746 746
 
747 747
             $type  = sanitize_key( $type );
748
-			foreach ( $messages as $message ) {
748
+            foreach ( $messages as $message ) {
749 749
                 $message = wp_kses_post( $message );
750
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
750
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
751 751
             }
752 752
 
753 753
         }
754 754
 
755
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
756
-
757
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
758
-				$url     = wp_nonce_url(
759
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
760
-					'getpaid-nonce',
761
-					'getpaid-nonce'
762
-				);
763
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
764
-				$message2 = __( 'Generate Pages', 'invoicing' );
765
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
766
-				break;
767
-			}
755
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
756
+
757
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
758
+                $url     = wp_nonce_url(
759
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
760
+                    'getpaid-nonce',
761
+                    'getpaid-nonce'
762
+                );
763
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
764
+                $message2 = __( 'Generate Pages', 'invoicing' );
765
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
766
+                break;
767
+            }
768 768
 
769
-		}
769
+        }
770 770
 
771
-	}
771
+    }
772 772
 
773 773
 }
Please login to merge, or discard this patch.
includes/admin/html-admin-page-addons.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 if ( ! defined( 'ABSPATH' ) ) {
7
-	exit;
7
+    exit;
8 8
 }
9 9
 add_ThickBox();
10 10
 ?>
@@ -14,18 +14,18 @@  discard block
 block discarded – undo
14 14
 	<?php if ( $tabs ){ ?>
15 15
 		<nav class="nav-tab-wrapper wpi-nav-tab-wrapper">
16 16
 			<?php
17
-			foreach ( $tabs as $name => $label ) {
18
-				echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
-			}
20
-			do_action( 'wpi_addons_tabs' );
21
-			?>
17
+            foreach ( $tabs as $name => $label ) {
18
+                echo '<a href="' . admin_url( 'admin.php?page=wpi-addons&tab=' . $name ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>';
19
+            }
20
+            do_action( 'wpi_addons_tabs' );
21
+            ?>
22 22
 		</nav>
23 23
 
24 24
 		<?php
25 25
 
26
-		if($current_tab == 'membership'){
26
+        if($current_tab == 'membership'){
27 27
 
28
-			?>
28
+            ?>
29 29
 
30 30
 			<div class="wpi-membership-tab-conatiner">
31 31
 				<div class="membership-content">
@@ -36,9 +36,9 @@  discard block
 block discarded – undo
36 36
 					<h2><?php _e("Have a membership key?","invoicing");?></h2>
37 37
 					<p>
38 38
 						<?php
39
-						$wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
-						echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
-						?>
39
+                        $wpeu_admin = new External_Updates_Admin('wpinvoicing.com','1');
40
+                        echo $wpeu_admin->render_licence_actions('wpinvoicing.com', 'membership',array(95, 106, 108,12351));
41
+                        ?>
42 42
 					</p>
43 43
 				<?php }?>
44 44
 
@@ -48,13 +48,13 @@  discard block
 block discarded – undo
48 48
 							<div class="feature-list">
49 49
 								<ul>
50 50
 									<?php
51
-									$addon_obj = new WPInv_Admin_Addons();
52
-									if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
-										foreach ( $addons as $addon ) {
54
-											echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
-										}
56
-									}
57
-									?>
51
+                                    $addon_obj = new WPInv_Admin_Addons();
52
+                                    if ($addons = $addon_obj->get_section_data( 'addons' ) ) {
53
+                                        foreach ( $addons as $addon ) {
54
+                                            echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
55
+                                        }
56
+                                    }
57
+                                    ?>
58 58
 									</ul>
59 59
 
60 60
 									<div class="feature-cta">
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 									<h3><?php _e("Included Gateways:","invoicing");?></h3>
66 66
 									<ul>
67 67
 										<?php
68
-										if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
-											foreach ( $addons as $addon ) {
70
-												echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
-											}
72
-										}
73
-										?>
68
+                                        if ($addons = $addon_obj->get_section_data( 'gateways' ) ) {
69
+                                            foreach ( $addons as $addon ) {
70
+                                                echo '<li><i class="far fa-check-circle fa-sm"></i> '.esc_html( $addon->info->title ).'</li>';
71
+                                            }
72
+                                        }
73
+                                        ?>
74 74
 								</ul>
75 75
 							</div>
76 76
 
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
 						<div class="testimonial-content">
82 82
 							<div class="t-image">
83 83
 								<?php
84
-									echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
-								?>
84
+                                    echo '<img src="' . plugins_url( 'images/t-image2.png', dirname(__FILE__) ) . '" > ';
85
+                                ?>
86 86
 							</div>
87 87
 							<div class="t-content">
88 88
 								<p>
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 						<div class="testimonial-content">
102 102
 							<div class="t-image">
103 103
 								<?php
104
-									echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
-								?>
104
+                                    echo '<img src="' . plugins_url( 'images/t-image1.png', dirname(__FILE__) ) . '" > ';
105
+                                ?>
106 106
 							</div>
107 107
 							<div class="t-content">
108 108
 								<p>
@@ -126,21 +126,21 @@  discard block
 block discarded – undo
126 126
 			</div>
127 127
 		</div>
128 128
 			<?php
129
-		}else{
130
-			$installed_plugins = get_plugins();
129
+        }else{
130
+            $installed_plugins = get_plugins();
131 131
             $addon_obj = new WPInv_Admin_Addons();
132
-			if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
-				//print_r($addons);
134
-				?>
132
+            if ($addons = $addon_obj->get_section_data( $current_tab ) ) :
133
+                //print_r($addons);
134
+                ?>
135 135
 				<ul class="wpi-products"><?php foreach ( $addons as $addon ) :
136 136
                         if(965==$addon->info->id){continue;}// don't show quote add on
137
-						?><li class="wpi-product">
137
+                        ?><li class="wpi-product">
138 138
 								<div class="wpi-product-title">
139 139
 									<h3><?php
140
-										if ( ! empty( $addon->info->excerpt) ){
141
-											echo wpi_help_tip( $addon->info->excerpt );
142
-										}
143
-										echo esc_html( $addon->info->title ); ?></h3>
140
+                                        if ( ! empty( $addon->info->excerpt) ){
141
+                                            echo wpi_help_tip( $addon->info->excerpt );
142
+                                        }
143
+                                        echo esc_html( $addon->info->title ); ?></h3>
144 144
 								</div>
145 145
 
146 146
 								<span class="wpi-product-image">
@@ -148,32 +148,32 @@  discard block
 block discarded – undo
148 148
 										<img src="<?php echo esc_attr( $addon->info->thumbnail ); ?>"/>
149 149
 									<?php endif;
150 150
 
151
-									if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
-										$addon->info->slug = 'getpaid-stripe-payments';
153
-										$addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
-									}
155
-
156
-									if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
-										echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
-										echo '</a>';
160
-									}elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
-										if(defined('WP_EASY_UPDATES_ACTIVE')){
162
-											$url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
-										}else{
164
-											// if installed show activation link
165
-											if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
-											}else{
168
-												$url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
-											}
170
-										}
171
-										echo '<a href="'.$url.'" class="thickbox">';
172
-										echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
-										echo '</a>';
174
-									}
175
-
176
-									?>
151
+                                    if ( 'stripe-payment-gateway' == $addon->info->slug ) {
152
+                                        $addon->info->slug = 'getpaid-stripe-payments';
153
+                                        $addon->info->link = 'https://wordpress.org/plugins/getpaid-stripe-payments/';
154
+                                    }
155
+
156
+                                    if(isset($addon->info->link) && substr( $addon->info->link, 0, 21 ) === "https://wordpress.org"){
157
+                                        echo '<a href="'.admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug).'&width=770&height=660&TB_iframe=true" class="thickbox" >';
158
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
159
+                                        echo '</a>';
160
+                                    }elseif(isset($addon->info->link) && ( substr( $addon->info->link, 0, 23 ) === "https://wpinvoicing.com" || substr( $addon->info->link, 0, 21 ) === "https://wpgetpaid.com" ) ){
161
+                                        if(defined('WP_EASY_UPDATES_ACTIVE')){
162
+                                            $url = admin_url('/plugin-install.php?tab=plugin-information&plugin='.$addon->info->slug.'&width=770&height=660&item_id='.$addon->info->id.'&update_url=https://wpgetpaid.com&TB_iframe=true');
163
+                                        }else{
164
+                                            // if installed show activation link
165
+                                            if(isset($installed_plugins['wp-easy-updates/external-updates.php'])){
166
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-activation';
167
+                                            }else{
168
+                                                $url = '#TB_inline?width=600&height=50&inlineId=wpi-wpeu-required-for-external';
169
+                                            }
170
+                                        }
171
+                                        echo '<a href="'.$url.'" class="thickbox">';
172
+                                        echo '<span class="wpi-product-info">'.__('More info','invoicing').'</span>';
173
+                                        echo '</a>';
174
+                                    }
175
+
176
+                                    ?>
177 177
 
178 178
 								</span>
179 179
 
@@ -181,15 +181,15 @@  discard block
 block discarded – undo
181 181
 								<span class="wpi-product-button">
182 182
 									<?php
183 183
                                     $addon_obj->output_button( $addon );
184
-									?>
184
+                                    ?>
185 185
 								</span>
186 186
 
187 187
 								<span class="wpi-price"><?php //print_r($addon); //echo wp_kses_post( $addon->price ); ?></span></li><?php endforeach; ?></ul>
188 188
 			<?php endif;
189
-		}
189
+        }
190 190
 
191
-	}
192
-	?>
191
+    }
192
+    ?>
193 193
 
194 194
 
195 195
 	<div class="clearfix" ></div>
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 			<input class="wpeu-licence-key" type="text" placeholder="<?php _e("Enter your licence key",'invoicing');?>"> <button class="button-primary wpeu-licence-popup-button" ><?php _e("Install",'invoicing');?></button>
209 209
 			<br>
210 210
 			<?php
211
-			echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
-			?>
211
+            echo sprintf( __('%sFind your licence key here%s OR %sBuy one here%s', 'invoicing'), '<a href="https://wpinvoicing.com/your-account/" target="_blank">','</a>','<a class="wpeu-licence-link" href="https://wpinvoicing.com/downloads/category/addons/" target="_blank">','</a>' );
212
+            ?>
213 213
 		</span>
214 214
 	</div>
215 215
 
Please login to merge, or discard this patch.