Passed
Push — master ( 027711...e6d0e0 )
by Stiofan
04:55
created
includes/admin/views/wizard-introduction.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
@@ -12,77 +12,77 @@  discard block
 block discarded – undo
12 12
     <div class="text-center pb-3 mt-5">
13 13
         <a class=" text-decoration-none" href="https://wpgetpaid.com/">
14 14
             <span class="text-black-50">
15
-                <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" />
15
+                <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'; ?>" />
16 16
             </span>
17 17
         </a>
18 18
 	</div>
19 19
 
20 20
     <h1 class="h4 card-header bg-white border-bottom-0 pt-4 pb-1">
21
-        <?php esc_html_e( 'Welcome to GetPaid!', 'invoicing' ); ?>
21
+        <?php esc_html_e('Welcome to GetPaid!', 'invoicing'); ?>
22 22
     </h1>
23 23
 
24 24
     <div class="card-body text-muted ">
25
-        <p><?php _e( 'Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing' ); ?></p>
25
+        <p><?php _e('Thank you for choosing GetPaid - The most Powerful Payments Plugin for WordPress', 'invoicing'); ?></p>
26 26
         <hr class="mt-4 pt-3 pb-0" />
27
-        <p class="small"><?php _e( 'This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing' ); ?></p>
27
+        <p class="small"><?php _e('This quick setup wizard will help you <b>configure the basic settings</b>. It’s <b>completely optional</b> and shouldn’t take longer than <b>five minutes</b>.', 'invoicing'); ?></p>
28 28
     </div>
29 29
 
30 30
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
31 31
         <a
32
-            href="<?php echo esc_url( $next_url ); ?>"
33
-            class="btn btn-primary button-next"><?php esc_html_e( "Let's go!", 'invoicing' ); ?></a>
32
+            href="<?php echo esc_url($next_url); ?>"
33
+            class="btn btn-primary button-next"><?php esc_html_e("Let's go!", 'invoicing'); ?></a>
34 34
         <a
35
-            href="<?php echo esc_url( admin_url() ); ?>"
36
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
35
+            href="<?php echo esc_url(admin_url()); ?>"
36
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
37 37
     </div>
38 38
 </div>
39 39
 
40 40
 <div class="card shadow-sm my-5">
41 41
     <h1 class="h4 card-header bg-white border-bottom-0  pt-4 pb-1">
42
-        <?php esc_html_e( 'GetPaid Features & Addons!', 'invoicing' ); ?>
42
+        <?php esc_html_e('GetPaid Features & Addons!', 'invoicing'); ?>
43 43
     </h1>
44 44
 
45 45
     <div class="card-body text-muted overflow-hidden">
46
-		<p><?php _e( 'Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing' ); ?></p>
46
+		<p><?php _e('Collect one time & recurring payments online within minutes. No complex setup required.', 'invoicing'); ?></p>
47 47
 		<hr>
48 48
 
49 49
 		<div class="row row-cols-2 text-left">
50 50
 			<div class="col mt-3">
51 51
 				<div class="media">
52
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg';?>" class="mr-3" alt="...">
52
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/buy.svg'; ?>" class="mr-3" alt="...">
53 53
                     <div class="media-body">
54
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via Buy Now Buttons', 'invoicing' );?></h6>
55
-                        <small><?php _e( 'Sell via buy now buttons anywhere on your site', 'invoicing' );?></small>
54
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Buy Now Buttons', 'invoicing'); ?></h6>
55
+                        <small><?php _e('Sell via buy now buttons anywhere on your site', 'invoicing'); ?></small>
56 56
                     </div>
57 57
                 </div>
58 58
 			</div>
59 59
 
60 60
             <div class="col mt-3">
61 61
                 <div class="media">
62
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg';?>" class="mr-3" alt="...">
62
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/report.svg'; ?>" class="mr-3" alt="...">
63 63
                         <div class="media-body">
64
-                        <h6 class="mt-0 font-weight-bold"><?php _e( 'GetPaid via payment form', 'invoicing' );?></h6>
65
-                        <small><?php _e( 'Payment forms are conversion-optimized checkout forms', 'invoicing' );?></small>
64
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via payment form', 'invoicing'); ?></h6>
65
+                        <small><?php _e('Payment forms are conversion-optimized checkout forms', 'invoicing'); ?></small>
66 66
                     </div>
67 67
                 </div>
68 68
 		    </div>
69 69
 
70 70
             <div class="col mt-3">
71 71
                 <div class="media">
72
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg';?>" class="mr-3" alt="...">
72
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/invoices.svg'; ?>" class="mr-3" alt="...">
73 73
                     <div class="media-body">
74
-                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice','invoicing');?></h6>
75
-                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard','invoicing');?></small>
74
+                        <h6 class="mt-0 font-weight-bold"><?php _e('GetPaid via Invoice', 'invoicing'); ?></h6>
75
+                        <small><?php _e('Create and send invoices for just about anything from the WordPress dashboard', 'invoicing'); ?></small>
76 76
                     </div>
77 77
                 </div>
78 78
 		    </div>
79 79
 
80 80
             <div class="col mt-3">
81 81
                 <div class="media">
82
-                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg';?>" class="mr-3" alt="...">
82
+                    <img src="<?php echo WPINV_PLUGIN_URL . 'assets/images/payment.svg'; ?>" class="mr-3" alt="...">
83 83
                     <div class="media-body">
84
-                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways','invoicing');?></h6>
85
-                        <small><?php _e('On average our gateways are over 66% cheaper than our competition','invoicing');?></small>
84
+                        <h6 class="mt-0 font-weight-bold"><?php _e('Affordable payment gateways', 'invoicing'); ?></h6>
85
+                        <small><?php _e('On average our gateways are over 66% cheaper than our competition', 'invoicing'); ?></small>
86 86
                     </div>
87 87
                 </div>
88 88
 		    </div>
@@ -93,51 +93,51 @@  discard block
 block discarded – undo
93 93
 	<div class="mt-5">
94 94
 		<a
95 95
             href="https://wpgetpaid.com/features-list/"
96
-			class="btn btn-primary"><?php esc_html_e( 'View All Features!', 'invoicing' ); ?></a>
96
+			class="btn btn-primary"><?php esc_html_e('View All Features!', 'invoicing'); ?></a>
97 97
 	</div>
98 98
 
99 99
 	<div class="mt-5 mx-n4 py-4" style="background:#eafaf6;">
100
-		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e( 'More with Membership!' , 'invoicing' );?></h4>
100
+		<h4 class="mt-0 font-weight-bold text-dark mb-4"><?php _e('More with Membership!', 'invoicing'); ?></h4>
101 101
 		<div class="row row-cols-2 text-left px-5">
102 102
 
103 103
 			<div class="col">
104 104
 				<ul class="list-unstyled">
105
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'PDF Invoices' , 'invoicing' );?></li>
106
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Gravity Forms' , 'invoicing' );?></li>
107
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Contact form 7' , 'invoicing' );?></li>
108
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'AffiliateWP Integration' , 'invoicing' );?></li>
105
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('PDF Invoices', 'invoicing'); ?></li>
106
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Gravity Forms', 'invoicing'); ?></li>
107
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Contact form 7', 'invoicing'); ?></li>
108
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('AffiliateWP Integration', 'invoicing'); ?></li>
109 109
 				</ul>
110 110
 			</div>
111 111
 
112 112
 			<div class="col">
113 113
 				<ul class="list-unstyled">
114
-			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Ninja forms' , 'invoicing' );?></li>
115
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Digital Downloads' , 'invoicing' );?></li>
116
-					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e( 'Wallet' , 'invoicing' );?></li>
114
+			    	<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Ninja forms', 'invoicing'); ?></li>
115
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Digital Downloads', 'invoicing'); ?></li>
116
+					<li class="my-2"><i class="far fa-check-circle text-success"></i> <?php _e('Wallet', 'invoicing'); ?></li>
117 117
 				</ul>
118 118
 			</div>
119 119
 		</div>
120 120
 
121
-		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From','invoicing');?></h5>
122
-		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e( '$49', 'invoicing' ); ?></h1>
121
+		<h5 class="mt-4 font-weight-bold text-dark mb-3"><?php _e('Membership Starts From', 'invoicing'); ?></h5>
122
+		<h1 class="mt-0 font-weight-bold text-dark mb-4 display-3"><?php esc_html_e('$49', 'invoicing'); ?></h1>
123 123
 
124 124
 		<div class="mt-2">
125 125
 			<a
126 126
                 href="https://wpgetpaid.com/downloads/membership/"
127
-				class="btn btn-primary"><?php esc_html_e( 'Buy Membership Now!', 'invoicing' ); ?></a>
127
+				class="btn btn-primary"><?php esc_html_e('Buy Membership Now!', 'invoicing'); ?></a>
128 128
 		</div>
129 129
 
130 130
 	</div>
131 131
 
132 132
     <div class="card-footer mb-0 bg-white gp-setup-actions step border-top-0">
133 133
         <a
134
-            href="<?php echo esc_url( $next_url ); ?>"
135
-            class="btn btn-outline-primary button-next"><?php esc_html_e( 'Launch the Setup Wizard!', 'invoicing' ); ?></a>
134
+            href="<?php echo esc_url($next_url); ?>"
135
+            class="btn btn-outline-primary button-next"><?php esc_html_e('Launch the Setup Wizard!', 'invoicing'); ?></a>
136 136
         <a
137 137
             href="https://docs.wpgetpaid.com/"
138
-            class="btn btn-outline-primary ml-4"><?php esc_html_e( 'Documentation', 'invoicing' ); ?></a>
138
+            class="btn btn-outline-primary ml-4"><?php esc_html_e('Documentation', 'invoicing'); ?></a>
139 139
         <a
140
-            href="<?php echo esc_url( admin_url() ); ?>"
141
-            class="btn btn-link d-block mt-2 "><?php esc_html_e( 'Not right now', 'invoicing' ); ?></a>
140
+            href="<?php echo esc_url(admin_url()); ?>"
141
+            class="btn btn-link d-block mt-2 "><?php esc_html_e('Not right now', 'invoicing'); ?></a>
142 142
     </div>
143 143
 </div>
Please login to merge, or discard this patch.
includes/admin/admin-pages.php 1 patch
Spacing   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,31 +21,31 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50 50
         $url = wp_nonce_url(
51 51
             add_query_arg(
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'getpaid-nonce',
58 58
             'getpaid-nonce'
59 59
         );
60
-		$anchor = __( 'Deactivate', 'invoicing' );
61
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
60
+		$anchor = __('Deactivate', 'invoicing');
61
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
62 62
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
63 63
 
64
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
64
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
65 65
 
66
-        $url    = wp_nonce_url(
66
+        $url = wp_nonce_url(
67 67
             add_query_arg(
68 68
                 array(
69 69
                     'getpaid-admin-action' => 'activate_discount',
@@ -73,13 +73,13 @@  discard block
 block discarded – undo
73 73
             'getpaid-nonce',
74 74
             'getpaid-nonce'
75 75
         );
76
-		$anchor = __( 'Activate', 'invoicing' );
77
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
76
+		$anchor = __('Activate', 'invoicing');
77
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
78 78
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
79 79
 
80 80
     }
81 81
 
82
-    $url    = esc_url(
82
+    $url = esc_url(
83 83
         wp_nonce_url(
84 84
             add_query_arg(
85 85
                 array(
@@ -91,11 +91,11 @@  discard block
 block discarded – undo
91 91
             'getpaid-nonce'
92 92
         )
93 93
     );
94
-	$anchor = __( 'Delete', 'invoicing' );
95
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
94
+	$anchor = __('Delete', 'invoicing');
95
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
96 96
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
97 97
 
98
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
98
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
99 99
 
100 100
     return $row_actions;
101 101
 }
@@ -103,68 +103,68 @@  discard block
 block discarded – undo
103 103
 function wpinv_restrict_manage_posts() {
104 104
     global $typenow;
105 105
 
106
-    if( 'wpi_discount' == $typenow ) {
106
+    if ('wpi_discount' == $typenow) {
107 107
         wpinv_discount_filters();
108 108
     }
109 109
 }
110
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
110
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
111 111
 
112 112
 function wpinv_discount_filters() {
113 113
 
114 114
     ?>
115 115
     <select name="discount_type" id="dropdown_wpinv_discount_type">
116
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
116
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
117 117
         <?php
118 118
             $types = wpinv_get_discount_types();
119 119
 
120
-            foreach ( $types as $name => $type ) {
121
-                echo '<option value="' . esc_attr( $name ) . '"';
120
+            foreach ($types as $name => $type) {
121
+                echo '<option value="' . esc_attr($name) . '"';
122 122
 
123
-                if ( isset( $_GET['discount_type'] ) )
124
-                    selected( $name, $_GET['discount_type'] );
123
+                if (isset($_GET['discount_type']))
124
+                    selected($name, $_GET['discount_type']);
125 125
 
126
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
126
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
127 127
             }
128 128
         ?>
129 129
     </select>
130 130
     <?php
131 131
 }
132 132
 
133
-function wpinv_request( $vars ) {
133
+function wpinv_request($vars) {
134 134
     global $typenow, $wp_post_statuses;
135 135
 
136
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
137
-        if ( ! isset( $vars['post_status'] ) ) {
138
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
136
+    if (getpaid_is_invoice_post_type($typenow)) {
137
+        if (!isset($vars['post_status'])) {
138
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
139 139
 
140
-            foreach ( $post_statuses as $status => $value ) {
141
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
142
-                    unset( $post_statuses[ $status ] );
140
+            foreach ($post_statuses as $status => $value) {
141
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
142
+                    unset($post_statuses[$status]);
143 143
                 }
144 144
             }
145 145
 
146
-            $vars['post_status'] = array_keys( $post_statuses );
146
+            $vars['post_status'] = array_keys($post_statuses);
147 147
         }
148 148
 
149
-    } else if ( 'wpi_discount' == $typenow ) {
150
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
149
+    } else if ('wpi_discount' == $typenow) {
150
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
151 151
         // Filter vat rule type
152
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
152
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
153 153
             $meta_query[] = array(
154 154
                     'key'   => '_wpi_discount_type',
155
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
155
+                    'value' => sanitize_text_field($_GET['discount_type']),
156 156
                     'compare' => '='
157 157
                 );
158 158
         }
159 159
 
160
-        if ( !empty( $meta_query ) ) {
160
+        if (!empty($meta_query)) {
161 161
             $vars['meta_query'] = $meta_query;
162 162
         }
163 163
     }
164 164
 
165 165
     return $vars;
166 166
 }
167
-add_filter( 'request', 'wpinv_request' );
167
+add_filter('request', 'wpinv_request');
168 168
 
169 169
 /**
170 170
  * Create a page and store the ID in an option.
@@ -176,19 +176,19 @@  discard block
 block discarded – undo
176 176
  * @param int $post_parent (default: 0) Parent for the new page
177 177
  * @return int page ID
178 178
  */
179
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
179
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
180 180
     global $wpdb;
181 181
 
182
-    $option_value = wpinv_get_option( $option );
182
+    $option_value = wpinv_get_option($option);
183 183
 
184
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
185
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
184
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
185
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
186 186
             // Valid page is already in place
187 187
             return $page_object->ID;
188 188
         }
189 189
     }
190 190
 
191
-    if(!empty($post_parent)){
191
+    if (!empty($post_parent)) {
192 192
         $page = get_page_by_path($post_parent);
193 193
         if ($page) {
194 194
             $post_parent = $page->ID;
@@ -197,40 +197,40 @@  discard block
 block discarded – undo
197 197
         }
198 198
     }
199 199
 
200
-    if ( strlen( $page_content ) > 0 ) {
200
+    if (strlen($page_content) > 0) {
201 201
         // Search for an existing page with the specified page content (typically a shortcode)
202
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
202
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
203 203
     } else {
204 204
         // Search for an existing page with the specified page slug
205
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
205
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
206 206
     }
207 207
 
208
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
208
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
209 209
 
210
-    if ( $valid_page_found ) {
211
-        if ( $option ) {
212
-            wpinv_update_option( $option, $valid_page_found );
210
+    if ($valid_page_found) {
211
+        if ($option) {
212
+            wpinv_update_option($option, $valid_page_found);
213 213
         }
214 214
         return $valid_page_found;
215 215
     }
216 216
 
217 217
     // Search for a matching valid trashed page
218
-    if ( strlen( $page_content ) > 0 ) {
218
+    if (strlen($page_content) > 0) {
219 219
         // Search for an existing page with the specified page content (typically a shortcode)
220
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
220
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
221 221
     } else {
222 222
         // Search for an existing page with the specified page slug
223
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
223
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
224 224
     }
225 225
 
226
-    if ( $trashed_page_found ) {
226
+    if ($trashed_page_found) {
227 227
         $page_id   = $trashed_page_found;
228 228
         $page_data = array(
229 229
             'ID'             => $page_id,
230 230
             'post_status'    => 'publish',
231 231
             'post_parent'    => $post_parent,
232 232
         );
233
-        wp_update_post( $page_data );
233
+        wp_update_post($page_data);
234 234
     } else {
235 235
         $page_data = array(
236 236
             'post_status'    => 'publish',
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
             'post_parent'    => $post_parent,
243 243
             'comment_status' => 'closed',
244 244
         );
245
-        $page_id = wp_insert_post( $page_data );
245
+        $page_id = wp_insert_post($page_data);
246 246
     }
247 247
 
248
-    if ( $option ) {
249
-        wpinv_update_option( $option, (int) $page_id );
248
+    if ($option) {
249
+        wpinv_update_option($option, (int) $page_id);
250 250
     }
251 251
 
252 252
     return $page_id;
@@ -259,11 +259,11 @@  discard block
 block discarded – undo
259 259
  *
260 260
  * @return array
261 261
  */
262
-function wpinv_add_aui_screens($screen_ids){
262
+function wpinv_add_aui_screens($screen_ids) {
263 263
 
264 264
     // load on these pages if set
265
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
265
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
266 266
 
267 267
     return $screen_ids;
268 268
 }
269
-add_filter('aui_screen_ids','wpinv_add_aui_screens');
270 269
\ No newline at end of file
270
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
271 271
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +367 added lines, -367 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
     global $wpinv_options;
44 44
 
45 45
     // Try fetching the saved options.
46
-    if ( empty( $wpinv_options ) ) {
47
-        $wpinv_options = get_option( 'wpinv_settings' );
46
+    if (empty($wpinv_options)) {
47
+        $wpinv_options = get_option('wpinv_settings');
48 48
     }
49 49
 
50 50
     // If that fails, don't fetch the default settings to prevent a loop.
51
-    if ( ! is_array( $wpinv_options ) ) {
51
+    if (!is_array($wpinv_options)) {
52 52
         $wpinv_options = array();
53 53
     }
54 54
 
@@ -62,13 +62,13 @@  discard block
 block discarded – undo
62 62
  * @param mixed $default The default value to use if the setting has not been set.
63 63
  * @return mixed
64 64
  */
65
-function wpinv_get_option( $key = '', $default = false ) {
65
+function wpinv_get_option($key = '', $default = false) {
66 66
 
67 67
     $options = wpinv_get_options();
68
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
69
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
68
+    $value   = isset($options[$key]) ? $options[$key] : $default;
69
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
70 70
 
71
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
71
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
72 72
 }
73 73
 
74 74
 /**
@@ -77,11 +77,11 @@  discard block
 block discarded – undo
77 77
  * @param array $options the new options.
78 78
  * @return bool
79 79
  */
80
-function wpinv_update_options( $options ) {
80
+function wpinv_update_options($options) {
81 81
     global $wpinv_options;
82 82
 
83 83
     // update the option.
84
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
84
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
85 85
         $wpinv_options = $options;
86 86
         return true;
87 87
     }
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
  * @param mixed $value The setting value.
97 97
  * @return bool
98 98
  */
99
-function wpinv_update_option( $key = '', $value = false ) {
99
+function wpinv_update_option($key = '', $value = false) {
100 100
 
101 101
     // If no key, exit.
102
-    if ( empty( $key ) ) {
102
+    if (empty($key)) {
103 103
         return false;
104 104
     }
105 105
 
106 106
     // Maybe delete the option instead.
107
-    if ( is_null( $value ) ) {
108
-        return wpinv_delete_option( $key );
107
+    if (is_null($value)) {
108
+        return wpinv_delete_option($key);
109 109
     }
110 110
 
111 111
     // Prepare the new options.
112 112
     $options         = wpinv_get_options();
113
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
113
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
114 114
 
115 115
     // Save the new options.
116
-    return wpinv_update_options( $options );
116
+    return wpinv_update_options($options);
117 117
 
118 118
 }
119 119
 
@@ -123,18 +123,18 @@  discard block
 block discarded – undo
123 123
  * @param string $key the setting key.
124 124
  * @return bool
125 125
  */
126
-function wpinv_delete_option( $key = '' ) {
126
+function wpinv_delete_option($key = '') {
127 127
 
128 128
     // If no key, exit
129
-    if ( empty( $key ) ) {
129
+    if (empty($key)) {
130 130
         return false;
131 131
     }
132 132
 
133 133
     $options = wpinv_get_options();
134 134
 
135
-    if ( isset( $options[ $key ] ) ) {
136
-        unset( $options[ $key ] );
137
-        return wpinv_update_options( $options );
135
+    if (isset($options[$key])) {
136
+        unset($options[$key]);
137
+        return wpinv_update_options($options);
138 138
     }
139 139
 
140 140
     return true;
@@ -148,14 +148,14 @@  discard block
 block discarded – undo
148 148
 function wpinv_register_settings() {
149 149
 
150 150
     // Loop through all tabs.
151
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
151
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
152 152
 
153 153
         // In each tab, loop through sections.
154
-        foreach ( $sections as $section => $settings ) {
154
+        foreach ($sections as $section => $settings) {
155 155
 
156 156
             // Check for backwards compatibility
157
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
158
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
157
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
158
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
159 159
                 $section = 'main';
160 160
                 $settings = $sections;
161 161
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
                 'wpinv_settings_' . $tab . '_' . $section
169 169
             );
170 170
 
171
-            foreach ( $settings as $option ) {
172
-                if ( ! empty( $option['id'] ) ) {
173
-                    wpinv_register_settings_option( $tab, $section, $option );
171
+            foreach ($settings as $option) {
172
+                if (!empty($option['id'])) {
173
+                    wpinv_register_settings_option($tab, $section, $option);
174 174
                 }
175 175
             }
176 176
 
@@ -178,9 +178,9 @@  discard block
 block discarded – undo
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 }
183
-add_action( 'admin_init', 'wpinv_register_settings' );
183
+add_action('admin_init', 'wpinv_register_settings');
184 184
 
185 185
 /**
186 186
  * Register a single settings option.
@@ -190,49 +190,49 @@  discard block
 block discarded – undo
190 190
  * @param string $option
191 191
  * 
192 192
  */
193
-function wpinv_register_settings_option( $tab, $section, $option ) {
193
+function wpinv_register_settings_option($tab, $section, $option) {
194 194
 
195
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
195
+    $name       = isset($option['name']) ? $option['name'] : '';
196 196
     $cb         = "wpinv_{$option['type']}_callback";
197 197
     $section    = "wpinv_settings_{$tab}_$section";
198
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
198
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
199 199
 
200
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
201
-		$tip   = wpinv_clean( $option['desc'] );
200
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
201
+		$tip   = wpinv_clean($option['desc']);
202 202
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
203
-		unset( $option['desc'] );
203
+		unset($option['desc']);
204 204
 	}
205 205
 
206 206
     // Loop through all tabs.
207 207
     add_settings_field(
208 208
         'wpinv_settings[' . $option['id'] . ']',
209 209
         $name,
210
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
210
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
211 211
         $section,
212 212
         $section,
213 213
         array(
214 214
             'section'     => $section,
215
-            'id'          => isset( $option['id'] )          ? $option['id']          : uniqid( 'wpinv-' ),
216
-            'desc'        => isset( $option['desc'] )        ? $option['desc']        : '',
215
+            'id'          => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
216
+            'desc'        => isset($option['desc']) ? $option['desc'] : '',
217 217
             'name'        => $name,
218
-            'size'        => isset( $option['size'] )        ? $option['size']        : null,
219
-            'options'     => isset( $option['options'] )     ? $option['options']     : '',
220
-            'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
221
-            'std'         => isset( $option['std'] )         ? $option['std']         : '',
222
-            'min'         => isset( $option['min'] )         ? $option['min']         : 0,
223
-            'max'         => isset( $option['max'] )         ? $option['max']         : 999999,
224
-            'step'        => isset( $option['step'] )        ? $option['step']        : 1,
225
-            'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
226
-            'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
227
-            'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
228
-            'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
229
-            'onchange'    => isset( $option['onchange'] )   ? $option['onchange']     : '',
230
-            'custom'      => isset( $option['custom'] )     ? $option['custom']       : '',
231
-			'default_content' => isset( $option['default_content'] )     ? $option['default_content']       : '',
232
-			'class'       => isset( $option['class'] )     ? $option['class']         : '',
233
-			'style'       => isset( $option['style'] )     ? $option['style']         : '',
234
-            'cols'        => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
-            'rows'        => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
218
+            'size'        => isset($option['size']) ? $option['size'] : null,
219
+            'options'     => isset($option['options']) ? $option['options'] : '',
220
+            'selected'    => isset($option['selected']) ? $option['selected'] : null,
221
+            'std'         => isset($option['std']) ? $option['std'] : '',
222
+            'min'         => isset($option['min']) ? $option['min'] : 0,
223
+            'max'         => isset($option['max']) ? $option['max'] : 999999,
224
+            'step'        => isset($option['step']) ? $option['step'] : 1,
225
+            'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
226
+            'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
227
+            'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
228
+            'faux'        => isset($option['faux']) ? $option['faux'] : false,
229
+            'onchange'    => isset($option['onchange']) ? $option['onchange'] : '',
230
+            'custom'      => isset($option['custom']) ? $option['custom'] : '',
231
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
232
+			'class'       => isset($option['class']) ? $option['class'] : '',
233
+			'style'       => isset($option['style']) ? $option['style'] : '',
234
+            'cols'        => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
235
+            'rows'        => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
236 236
         )
237 237
     );
238 238
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
  * @return array
245 245
  */
246 246
 function wpinv_get_registered_settings() {
247
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
247
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
248 248
 }
249 249
 
250 250
 /**
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
  * @return array
254 254
  */
255 255
 function getpaid_get_integration_settings() {
256
-    return apply_filters( 'getpaid_integration_settings', array() );
256
+    return apply_filters('getpaid_integration_settings', array());
257 257
 }
258 258
 
259 259
 /**
@@ -261,122 +261,122 @@  discard block
 block discarded – undo
261 261
  * 
262 262
  * @return array
263 263
  */
264
-function wpinv_settings_sanitize( $input = array() ) {
264
+function wpinv_settings_sanitize($input = array()) {
265 265
 
266 266
 	$wpinv_options = wpinv_get_options();
267 267
 	$raw_referrer  = wp_get_raw_referer();
268 268
 
269
-    if ( empty( $raw_referrer ) ) {
270
-		return array_merge( $wpinv_options, $input );
269
+    if (empty($raw_referrer)) {
270
+		return array_merge($wpinv_options, $input);
271 271
     }
272 272
 
273
-    wp_parse_str( $raw_referrer, $referrer );
273
+    wp_parse_str($raw_referrer, $referrer);
274 274
 
275 275
     $settings = wpinv_get_registered_settings();
276
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
277
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
276
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
277
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
278 278
 
279 279
     $input = $input ? $input : array();
280
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
281
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
280
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
281
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
282 282
 
283 283
     // Loop through each setting being saved and pass it through a sanitization filter
284
-    foreach ( $input as $key => $value ) {
284
+    foreach ($input as $key => $value) {
285 285
 
286 286
         // Get the setting type (checkbox, select, etc)
287
-        $type = isset( $settings[ $tab ][$section][ $key ]['type'] ) ? $settings[ $tab ][$section][ $key ]['type'] : false;
287
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
288 288
 
289
-        if ( $type ) {
289
+        if ($type) {
290 290
             // Field type specific filter
291
-            $input[$key] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
291
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
292 292
         }
293 293
 
294 294
         // General filter
295
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
295
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
296 296
 
297 297
 		// Key specific filter.
298
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
298
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
299 299
     }
300 300
 
301 301
     // Loop through the whitelist and unset any that are empty for the tab being saved
302
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
303
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
302
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
303
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
304 304
 
305
-    $found_settings   = array_merge( $main_settings, $section_settings );
305
+    $found_settings   = array_merge($main_settings, $section_settings);
306 306
 
307
-    if ( ! empty( $found_settings ) ) {
308
-        foreach ( $found_settings as $key => $value ) {
307
+    if (!empty($found_settings)) {
308
+        foreach ($found_settings as $key => $value) {
309 309
 
310 310
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
311
-            if ( is_numeric( $key ) ) {
311
+            if (is_numeric($key)) {
312 312
                 $key = $value['id'];
313 313
             }
314 314
 
315
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
316
-                unset( $wpinv_options[ $key ] );
315
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
316
+                unset($wpinv_options[$key]);
317 317
             }
318 318
         }
319 319
     }
320 320
 
321 321
     // Merge our new settings with the existing
322
-    $output = array_merge( $wpinv_options, $input );
322
+    $output = array_merge($wpinv_options, $input);
323 323
 
324
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
324
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
325 325
 
326 326
     return $output;
327 327
 }
328
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
329
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
328
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
329
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
330 330
 
331
-function wpinv_settings_sanitize_tax_rates( $input ) {
332
-    if( ! wpinv_current_user_can_manage_invoicing() ) {
331
+function wpinv_settings_sanitize_tax_rates($input) {
332
+    if (!wpinv_current_user_can_manage_invoicing()) {
333 333
         return $input;
334 334
     }
335 335
 
336
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
336
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
337 337
     $tax_rates = array();
338 338
 
339
-    foreach ( $new_rates as $rate ) {
339
+    foreach ($new_rates as $rate) {
340 340
 
341
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
342
-		$rate['name']    = sanitize_text_field( $rate['name'] );
343
-		$rate['state']   = sanitize_text_field( $rate['state'] );
344
-		$rate['country'] = sanitize_text_field( $rate['country'] );
345
-		$rate['global']  = empty( $rate['state'] );
341
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
342
+		$rate['name']    = sanitize_text_field($rate['name']);
343
+		$rate['state']   = sanitize_text_field($rate['state']);
344
+		$rate['country'] = sanitize_text_field($rate['country']);
345
+		$rate['global']  = empty($rate['state']);
346 346
 		$tax_rates[]     = $rate;
347 347
 
348 348
 	}
349 349
 
350
-    update_option( 'wpinv_tax_rates', $tax_rates );
350
+    update_option('wpinv_tax_rates', $tax_rates);
351 351
 
352 352
     return $input;
353 353
 }
354
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
354
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
355 355
 
356 356
 function wpinv_get_settings_tabs() {
357 357
     $tabs             = array();
358
-    $tabs['general']  = __( 'General', 'invoicing' );
359
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
360
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
361
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
358
+    $tabs['general']  = __('General', 'invoicing');
359
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
360
+    $tabs['taxes']    = __('Taxes', 'invoicing');
361
+	$tabs['emails'] = __('Emails', 'invoicing');
362 362
 
363
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
364
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
363
+	if (count(getpaid_get_integration_settings()) > 0) {
364
+		$tabs['integrations'] = __('Integrations', 'invoicing');
365 365
 	}
366 366
 
367
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
368
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
369
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
367
+    $tabs['privacy']  = __('Privacy', 'invoicing');
368
+    $tabs['misc']     = __('Misc', 'invoicing');
369
+    $tabs['tools']    = __('Tools', 'invoicing');
370 370
 
371
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
371
+    return apply_filters('wpinv_settings_tabs', $tabs);
372 372
 }
373 373
 
374
-function wpinv_get_settings_tab_sections( $tab = false ) {
374
+function wpinv_get_settings_tab_sections($tab = false) {
375 375
     $tabs     = false;
376 376
     $sections = wpinv_get_registered_settings_sections();
377 377
 
378
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
379
-        $tabs = $sections[ $tab ];
378
+    if ($tab && !empty($sections[$tab])) {
379
+        $tabs = $sections[$tab];
380 380
     }
381 381
 
382 382
     return $tabs;
@@ -385,89 +385,89 @@  discard block
 block discarded – undo
385 385
 function wpinv_get_registered_settings_sections() {
386 386
     static $sections = false;
387 387
 
388
-    if ( false !== $sections ) {
388
+    if (false !== $sections) {
389 389
         return $sections;
390 390
     }
391 391
 
392 392
     $sections = array(
393
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
394
-            'main' => __( 'General Settings', 'invoicing' ),
395
-            'page_section' => __( 'Page Settings', 'invoicing' ),
396
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
397
-            'labels' => __( 'Label Texts', 'invoicing' ),
398
-        ) ),
399
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
400
-            'main' => __( 'Gateway Settings', 'invoicing' ),
401
-        ) ),
402
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
403
-            'main'  => __( 'Tax Settings', 'invoicing' ),
404
-			'rates' => __( 'Tax Rates', 'invoicing' ),
405
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
406
-        ) ),
407
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
408
-            'main' => __( 'Email Settings', 'invoicing' ),
409
-		) ),
410
-
411
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
412
-
413
-        'privacy' => apply_filters( 'wpinv_settings_sections_privacy', array(
414
-            'main' => __( 'Privacy policy', 'invoicing' ),
415
-        ) ),
416
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
417
-            'main' => __( 'Miscellaneous', 'invoicing' ),
418
-            'custom-css' => __( 'Custom CSS', 'invoicing' ),
419
-        ) ),
420
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
421
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
422
-        ) ),
393
+        'general' => apply_filters('wpinv_settings_sections_general', array(
394
+            'main' => __('General Settings', 'invoicing'),
395
+            'page_section' => __('Page Settings', 'invoicing'),
396
+            'currency_section' => __('Currency Settings', 'invoicing'),
397
+            'labels' => __('Label Texts', 'invoicing'),
398
+        )),
399
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
400
+            'main' => __('Gateway Settings', 'invoicing'),
401
+        )),
402
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
403
+            'main'  => __('Tax Settings', 'invoicing'),
404
+			'rates' => __('Tax Rates', 'invoicing'),
405
+			'vat'   => __('EU VAT Settings', 'invoicing')
406
+        )),
407
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
408
+            'main' => __('Email Settings', 'invoicing'),
409
+		)),
410
+
411
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
412
+
413
+        'privacy' => apply_filters('wpinv_settings_sections_privacy', array(
414
+            'main' => __('Privacy policy', 'invoicing'),
415
+        )),
416
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
417
+            'main' => __('Miscellaneous', 'invoicing'),
418
+            'custom-css' => __('Custom CSS', 'invoicing'),
419
+        )),
420
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
421
+            'main' => __('Diagnostic Tools', 'invoicing'),
422
+        )),
423 423
     );
424 424
 
425
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
425
+    $sections = apply_filters('wpinv_settings_sections', $sections);
426 426
 
427 427
     return $sections;
428 428
 }
429 429
 
430
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
430
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
431 431
 	$pages_options = array();
432 432
 
433
-	if( $default_label !== NULL && $default_label !== false ) {
434
-		$pages_options = array( '' => $default_label ); // Blank option
433
+	if ($default_label !== NULL && $default_label !== false) {
434
+		$pages_options = array('' => $default_label); // Blank option
435 435
 	}
436 436
 
437 437
 	$pages = get_pages();
438
-	if ( $pages ) {
439
-		foreach ( $pages as $page ) {
438
+	if ($pages) {
439
+		foreach ($pages as $page) {
440 440
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
441
-            $pages_options[ $page->ID ] = $title;
441
+            $pages_options[$page->ID] = $title;
442 442
 		}
443 443
 	}
444 444
 
445 445
 	return $pages_options;
446 446
 }
447 447
 
448
-function wpinv_header_callback( $args ) {
449
-	if ( !empty( $args['desc'] ) ) {
448
+function wpinv_header_callback($args) {
449
+	if (!empty($args['desc'])) {
450 450
         echo $args['desc'];
451 451
     }
452 452
 }
453 453
 
454
-function wpinv_hidden_callback( $args ) {
454
+function wpinv_hidden_callback($args) {
455 455
 
456
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
457
-	$value   = wpinv_get_option( $args['id'], $std );
456
+	$std     = isset($args['std']) ? $args['std'] : '';
457
+	$value   = wpinv_get_option($args['id'], $std);
458 458
 
459
-	if ( isset( $args['set_value'] ) ) {
459
+	if (isset($args['set_value'])) {
460 460
 		$value = $args['set_value'];
461 461
 	}
462 462
 
463
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
463
+	if (isset($args['faux']) && true === $args['faux']) {
464 464
 		$args['readonly'] = true;
465
-		$name  = '';
465
+		$name = '';
466 466
 	} else {
467
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
467
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
468 468
 	}
469 469
 
470
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
470
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
471 471
     
472 472
 	echo $html;
473 473
 }
@@ -475,59 +475,59 @@  discard block
 block discarded – undo
475 475
 /**
476 476
  * Displays a checkbox settings callback.
477 477
  */
478
-function wpinv_checkbox_callback( $args ) {
478
+function wpinv_checkbox_callback($args) {
479 479
 
480
-	$std = isset( $args['std'] ) ? $args['std'] : '';
481
-	$std = wpinv_get_option( $args['id'], $std );
482
-	$id  = esc_attr( $args['id'] );
480
+	$std = isset($args['std']) ? $args['std'] : '';
481
+	$std = wpinv_get_option($args['id'], $std);
482
+	$id  = esc_attr($args['id']);
483 483
 
484
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
484
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
485 485
 	?>
486 486
 		<fieldset>
487 487
 			<label>
488
-				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
489
-				<?php echo wp_kses_post( $args['desc'] ); ?>
488
+				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox">
489
+				<?php echo wp_kses_post($args['desc']); ?>
490 490
 			</label>
491 491
 		</fieldset>
492 492
 	<?php
493 493
 }
494 494
 
495
-function wpinv_multicheck_callback( $args ) {
495
+function wpinv_multicheck_callback($args) {
496 496
 
497
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
498
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
497
+	$sanitize_id = wpinv_sanitize_key($args['id']);
498
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
499 499
 
500
-	if ( ! empty( $args['options'] ) ) {
500
+	if (!empty($args['options'])) {
501 501
 
502
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
503
-		$value   = wpinv_get_option( $args['id'], $std );
502
+		$std     = isset($args['std']) ? $args['std'] : array();
503
+		$value   = wpinv_get_option($args['id'], $std);
504 504
 
505 505
 		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
506
-        foreach( $args['options'] as $key => $option ):
507
-			$sanitize_key = wpinv_sanitize_key( $key );
508
-			if ( in_array( $sanitize_key, $value ) ) { 
506
+        foreach ($args['options'] as $key => $option):
507
+			$sanitize_key = wpinv_sanitize_key($key);
508
+			if (in_array($sanitize_key, $value)) { 
509 509
 				$enabled = $sanitize_key;
510 510
 			} else { 
511 511
 				$enabled = NULL; 
512 512
 			}
513
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
514
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
513
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
514
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label></div>';
515 515
 		endforeach;
516 516
 		echo '</div>';
517 517
 		echo '<p class="description">' . $args['desc'] . '</p>';
518 518
 	}
519 519
 }
520 520
 
521
-function wpinv_payment_icons_callback( $args ) {
521
+function wpinv_payment_icons_callback($args) {
522 522
     
523
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
524
-	$value   = wpinv_get_option( $args['id'], false);
523
+    $sanitize_id = wpinv_sanitize_key($args['id']);
524
+	$value = wpinv_get_option($args['id'], false);
525 525
 
526
-	if ( ! empty( $args['options'] ) ) {
527
-		foreach( $args['options'] as $key => $option ) {
528
-            $sanitize_key = wpinv_sanitize_key( $key );
526
+	if (!empty($args['options'])) {
527
+		foreach ($args['options'] as $key => $option) {
528
+            $sanitize_key = wpinv_sanitize_key($key);
529 529
             
530
-			if( empty( $value ) ) {
530
+			if (empty($value)) {
531 531
 				$enabled = $option;
532 532
 			} else {
533 533
 				$enabled = NULL;
@@ -535,67 +535,67 @@  discard block
 block discarded – undo
535 535
 
536 536
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
537 537
 
538
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
538
+				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
539 539
 
540
-				if ( wpinv_string_is_image_url( $key ) ) {
541
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
540
+				if (wpinv_string_is_image_url($key)) {
541
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
542 542
 				} else {
543
-					$card = strtolower( str_replace( ' ', '', $option ) );
543
+					$card = strtolower(str_replace(' ', '', $option));
544 544
 
545
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
546
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
545
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
546
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
547 547
 					} else {
548
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
548
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
549 549
 						$content_dir = WP_CONTENT_DIR;
550 550
 
551
-						if ( function_exists( 'wp_normalize_path' ) ) {
551
+						if (function_exists('wp_normalize_path')) {
552 552
 							// Replaces backslashes with forward slashes for Windows systems
553
-							$image = wp_normalize_path( $image );
554
-							$content_dir = wp_normalize_path( $content_dir );
553
+							$image = wp_normalize_path($image);
554
+							$content_dir = wp_normalize_path($content_dir);
555 555
 						}
556 556
 
557
-						$image = str_replace( $content_dir, content_url(), $image );
557
+						$image = str_replace($content_dir, content_url(), $image);
558 558
 					}
559 559
 
560
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
560
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
561 561
 				}
562 562
 			echo $option . '</label>';
563 563
 		}
564
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
564
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
565 565
 	}
566 566
 }
567 567
 
568 568
 /**
569 569
  * Displays a radio settings field.
570 570
  */
571
-function wpinv_radio_callback( $args ) {
571
+function wpinv_radio_callback($args) {
572 572
 
573
-	$std = isset( $args['std'] ) ? $args['std'] : '';
574
-	$std = wpinv_get_option( $args['id'], $std );
573
+	$std = isset($args['std']) ? $args['std'] : '';
574
+	$std = wpinv_get_option($args['id'], $std);
575 575
 	?>
576 576
 		<fieldset>
577
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
578
-				<?php foreach( $args['options'] as $key => $option ) : ?>
577
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
578
+				<?php foreach ($args['options'] as $key => $option) : ?>
579 579
 					<li>
580 580
 						<label>
581
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
582
-							<?php echo wp_kses_post( $option ); ?>
581
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
582
+							<?php echo wp_kses_post($option); ?>
583 583
 						</label>
584 584
 					</li>
585 585
 				<?php endforeach; ?>
586 586
 			</ul>
587 587
 		</fieldset>
588 588
 	<?php
589
-	getpaid_settings_description_callback( $args );
589
+	getpaid_settings_description_callback($args);
590 590
 }
591 591
 
592 592
 /**
593 593
  * Displays a description if available.
594 594
  */
595
-function getpaid_settings_description_callback( $args ) {
595
+function getpaid_settings_description_callback($args) {
596 596
 
597
-	if ( ! empty( $args['desc'] ) ) {
598
-		$description = wp_kses_post( $args['desc'] );
597
+	if (!empty($args['desc'])) {
598
+		$description = wp_kses_post($args['desc']);
599 599
 		echo "<p class='description'>$description</p>";
600 600
 	}
601 601
 
@@ -611,31 +611,31 @@  discard block
 block discarded – undo
611 611
 	</tr>
612 612
 	<tr class="bsui">
613 613
     	<td colspan="2" class="p-0">
614
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
614
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
615 615
 
616 616
 	<?php
617 617
 }
618 618
 
619 619
 function wpinv_gateway_select_callback($args) {
620 620
     
621
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
622
-    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
623
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
624
-	$value   = wpinv_get_option( $args['id'], $std );
621
+    $sanitize_id = wpinv_sanitize_key($args['id']);
622
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
623
+	$std     = isset($args['std']) ? $args['std'] : '';
624
+	$value   = wpinv_get_option($args['id'], $std);
625 625
 
626
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
626
+	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="' . $class . '" >';
627 627
 
628
-	foreach ( $args['options'] as $key => $option ) :
629
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
630
-            $selected = selected( $key, $args['selected'], false );
628
+	foreach ($args['options'] as $key => $option) :
629
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
630
+            $selected = selected($key, $args['selected'], false);
631 631
         } else {
632
-            $selected = selected( $key, $value, false );
632
+            $selected = selected($key, $value, false);
633 633
         }
634
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
634
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
635 635
 	endforeach;
636 636
 
637 637
 	echo '</select>';
638
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
638
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
639 639
 }
640 640
 
641 641
 /**
@@ -644,28 +644,28 @@  discard block
 block discarded – undo
644 644
  * @param array $args
645 645
  * @return string
646 646
  */
647
-function wpinv_settings_attrs_helper( $args ) {
647
+function wpinv_settings_attrs_helper($args) {
648 648
 
649
-	$value        = isset( $args['std'] ) ? $args['std'] : '';
650
-	$id           = esc_attr( $args['id'] );
651
-	$placeholder  = esc_attr( $args['placeholder'] );
649
+	$value        = isset($args['std']) ? $args['std'] : '';
650
+	$id           = esc_attr($args['id']);
651
+	$placeholder  = esc_attr($args['placeholder']);
652 652
 
653
-	if ( ! empty( $args['faux'] ) ) {
653
+	if (!empty($args['faux'])) {
654 654
 		$args['readonly'] = true;
655 655
 		$name             = '';
656 656
 	} else {
657
-		$value  = wpinv_get_option( $args['id'], $value );
657
+		$value  = wpinv_get_option($args['id'], $value);
658 658
 		$name   = "wpinv_settings[$id]";
659 659
 	}
660 660
 
661
-	$value    = is_scalar( $value ) ? esc_attr( $value ) : '';
662
-	$class    = esc_attr( $args['class'] );
663
-	$style    = esc_attr( $args['style'] );
664
-	$readonly = empty( $args['readonly'] ) ? '' : 'readonly onclick="this.select()"';
661
+	$value    = is_scalar($value) ? esc_attr($value) : '';
662
+	$class    = esc_attr($args['class']);
663
+	$style    = esc_attr($args['style']);
664
+	$readonly = empty($args['readonly']) ? '' : 'readonly onclick="this.select()"';
665 665
 
666 666
 	$onchange = '';
667
-    if ( ! empty( $args['onchange'] ) ) {
668
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
667
+    if (!empty($args['onchange'])) {
668
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
669 669
 	}
670 670
 
671 671
 	return "name='$name' id='wpinv-settings-$id' style='$style' value='$value' class='$class' placeholder='$placeholder' data-placeholder='$placeholder' $onchange $readonly";
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
 /**
675 675
  * Displays a text input settings callback.
676 676
  */
677
-function wpinv_text_callback( $args ) {
677
+function wpinv_text_callback($args) {
678 678
 
679
-	$desc = wp_kses_post( $args['desc'] );
680
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
681
-	$attr = wpinv_settings_attrs_helper( $args );
679
+	$desc = wp_kses_post($args['desc']);
680
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
681
+	$attr = wpinv_settings_attrs_helper($args);
682 682
 
683 683
 	?>
684 684
 		<label style="width: 100%;">
@@ -692,14 +692,14 @@  discard block
 block discarded – undo
692 692
 /**
693 693
  * Displays a number input settings callback.
694 694
  */
695
-function wpinv_number_callback( $args ) {
695
+function wpinv_number_callback($args) {
696 696
 
697
-	$desc = wp_kses_post( $args['desc'] );
698
-	$desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
699
-	$attr = wpinv_settings_attrs_helper( $args );
700
-	$max  = intval( $args['max'] );
701
-	$min  = intval( $args['min'] );
702
-	$step = floatval( $args['step'] );
697
+	$desc = wp_kses_post($args['desc']);
698
+	$desc = empty($desc) ? '' : "<p class='description'>$desc</p>";
699
+	$attr = wpinv_settings_attrs_helper($args);
700
+	$max  = intval($args['max']);
701
+	$min  = intval($args['min']);
702
+	$step = floatval($args['step']);
703 703
 
704 704
 	?>
705 705
 		<label style="width: 100%;">
@@ -710,37 +710,37 @@  discard block
 block discarded – undo
710 710
 
711 711
 }
712 712
 
713
-function wpinv_textarea_callback( $args ) {
713
+function wpinv_textarea_callback($args) {
714 714
     
715
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
716
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
717
-	$value   = wpinv_get_option( $args['id'], $std );
715
+    $sanitize_id = wpinv_sanitize_key($args['id']);
716
+	$std     = isset($args['std']) ? $args['std'] : '';
717
+	$value   = wpinv_get_option($args['id'], $std);
718 718
 
719
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
720
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
719
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
720
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
721 721
 
722
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
723
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
722
+	$html = '<textarea class="' . sanitize_html_class($class) . ' txtarea-' . sanitize_html_class($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
723
+	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
724 724
 
725 725
 	echo $html;
726 726
 }
727 727
 
728
-function wpinv_password_callback( $args ) {
728
+function wpinv_password_callback($args) {
729 729
     
730
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
731
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
732
-	$value   = wpinv_get_option( $args['id'], $std );
730
+    $sanitize_id = wpinv_sanitize_key($args['id']);
731
+	$std     = isset($args['std']) ? $args['std'] : '';
732
+	$value   = wpinv_get_option($args['id'], $std);
733 733
 
734
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
735
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
736
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
734
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
735
+	$html = '<input type="password" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
736
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
737 737
 
738 738
 	echo $html;
739 739
 }
740 740
 
741 741
 function wpinv_missing_callback($args) {
742 742
 	printf(
743
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
743
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
744 744
 		'<strong>' . $args['id'] . '</strong>'
745 745
 	);
746 746
 }
@@ -748,35 +748,35 @@  discard block
 block discarded – undo
748 748
 /**
749 749
  * Displays a number input settings callback.
750 750
  */
751
-function wpinv_select_callback( $args ) {
751
+function wpinv_select_callback($args) {
752 752
 
753
-	$desc   = wp_kses_post( $args['desc'] );
754
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
755
-	$attr   = wpinv_settings_attrs_helper( $args );
756
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
757
-	$value  = wpinv_get_option( $args['id'], $value );
758
-	$rand   = uniqid( 'random_id' );
753
+	$desc   = wp_kses_post($args['desc']);
754
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
755
+	$attr   = wpinv_settings_attrs_helper($args);
756
+	$value  = isset($args['std']) ? $args['std'] : '';
757
+	$value  = wpinv_get_option($args['id'], $value);
758
+	$rand   = uniqid('random_id');
759 759
 
760 760
 	?>
761 761
 		<label style="width: 100%;">
762 762
 			<select <?php echo $attr; ?>>
763
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
764
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo wpinv_clean( $name ); ?></option>
765
-				<?php endforeach;?>
763
+				<?php foreach ($args['options'] as $option => $name) : ?>
764
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo wpinv_clean($name); ?></option>
765
+				<?php endforeach; ?>
766 766
 			</select>
767 767
 
768
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
769
-				<a href="<?php echo get_edit_post_link( $value ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e( 'Edit Page', 'invoicing' ) ?></a>
768
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
769
+				<a href="<?php echo get_edit_post_link($value); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php _e('Edit Page', 'invoicing') ?></a>
770 770
 			<?php endif; ?>
771 771
 
772
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
773
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e( 'View Default Content', 'invoicing' ) ?></a>
772
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
773
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo $rand; ?>" class="button thickbox getpaid-page-setting-view-default"><?php _e('View Default Content', 'invoicing') ?></a>
774 774
 				<div id='<?php echo $rand; ?>' style='display:none;'>
775 775
 					<div>
776
-						<h3><?php _e( 'Original Content', 'invoicing' ) ?></h3>
777
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines( wp_kses_post( $args['default_content'] ) ); ?></textarea>
778
-						<h3><?php _e( 'Current Content', 'invoicing' ) ?></h3>
779
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : gepaid_trim_lines( wp_kses_post( $_post->post_content ) ); ?></textarea>
776
+						<h3><?php _e('Original Content', 'invoicing') ?></h3>
777
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo gepaid_trim_lines(wp_kses_post($args['default_content'])); ?></textarea>
778
+						<h3><?php _e('Current Content', 'invoicing') ?></h3>
779
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : gepaid_trim_lines(wp_kses_post($_post->post_content)); ?></textarea>
780 780
 					</div>
781 781
 				</div>
782 782
 			<?php endif; ?>
@@ -787,88 +787,88 @@  discard block
 block discarded – undo
787 787
 
788 788
 }
789 789
 
790
-function wpinv_color_select_callback( $args ) {
790
+function wpinv_color_select_callback($args) {
791 791
     
792
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
793
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
794
-	$value   = wpinv_get_option( $args['id'], $std );
792
+    $sanitize_id = wpinv_sanitize_key($args['id']);
793
+	$std     = isset($args['std']) ? $args['std'] : '';
794
+	$value   = wpinv_get_option($args['id'], $std);
795 795
 
796
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
796
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
797 797
 
798
-	foreach ( $args['options'] as $option => $color ) {
799
-		$selected = selected( $option, $value, false );
800
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
798
+	foreach ($args['options'] as $option => $color) {
799
+		$selected = selected($option, $value, false);
800
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
801 801
 	}
802 802
 
803 803
 	$html .= '</select>';
804
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
804
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
805 805
 
806 806
 	echo $html;
807 807
 }
808 808
 
809
-function wpinv_rich_editor_callback( $args ) {
809
+function wpinv_rich_editor_callback($args) {
810 810
 	global $wp_version;
811 811
     
812
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
812
+    $sanitize_id = wpinv_sanitize_key($args['id']);
813 813
 
814
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
815
-	$value   = wpinv_get_option( $args['id'], $std );
814
+	$std     = isset($args['std']) ? $args['std'] : '';
815
+	$value   = wpinv_get_option($args['id'], $std);
816 816
 	
817
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
817
+	if (!empty($args['allow_blank']) && empty($value)) {
818 818
 		$value = $std;
819 819
 	}
820 820
 
821
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
821
+	$rows = isset($args['size']) ? $args['size'] : 20;
822 822
 
823 823
 	$html = '<div class="getpaid-settings-editor-input">';
824
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
824
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
825 825
 		ob_start();
826
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
826
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows), 'media_buttons' => false));
827 827
 		$html .= ob_get_clean();
828 828
 	} else {
829
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
829
+		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
830 830
 	}
831 831
 
832
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
832
+	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
833 833
 
834 834
 	echo $html;
835 835
 }
836 836
 
837
-function wpinv_upload_callback( $args ) {
837
+function wpinv_upload_callback($args) {
838 838
     
839
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
839
+    $sanitize_id = wpinv_sanitize_key($args['id']);
840 840
 
841
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
842
-	$value   = wpinv_get_option( $args['id'], $std );
841
+	$std     = isset($args['std']) ? $args['std'] : '';
842
+	$value   = wpinv_get_option($args['id'], $std);
843 843
 
844
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
845
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
846
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
847
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
844
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
845
+	$html = '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
846
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
847
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
848 848
 
849 849
 	echo $html;
850 850
 }
851 851
 
852
-function wpinv_color_callback( $args ) {
852
+function wpinv_color_callback($args) {
853 853
 
854
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
855
-	$value       = wpinv_get_option( $args['id'], $std );
856
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
854
+	$std         = isset($args['std']) ? $args['std'] : '';
855
+	$value       = wpinv_get_option($args['id'], $std);
856
+    $sanitize_id = wpinv_sanitize_key($args['id']);
857 857
 
858
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
859
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
858
+	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
859
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
860 860
 
861 861
 	echo $html;
862 862
 }
863 863
 
864 864
 function wpinv_country_states_callback($args) {
865 865
 
866
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
867
-	$value   = wpinv_get_option( $args['id'], $std );
866
+	$std     = isset($args['std']) ? $args['std'] : '';
867
+	$value   = wpinv_get_option($args['id'], $std);
868 868
 
869
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
869
+    $sanitize_id = wpinv_sanitize_key($args['id']);
870 870
 
871
-	if ( isset( $args['placeholder'] ) ) {
871
+	if (isset($args['placeholder'])) {
872 872
 		$placeholder = $args['placeholder'];
873 873
 	} else {
874 874
 		$placeholder = '';
@@ -876,16 +876,16 @@  discard block
 block discarded – undo
876 876
 
877 877
 	$states = wpinv_get_country_states();
878 878
 
879
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
880
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
879
+	$class = empty($states) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
880
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
881 881
 
882
-	foreach ( $states as $option => $name ) {
883
-		$selected = selected( $option, $value, false );
884
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
882
+	foreach ($states as $option => $name) {
883
+		$selected = selected($option, $value, false);
884
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
885 885
 	}
886 886
 
887 887
 	$html .= '</select>';
888
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
888
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
889 889
 
890 890
 	echo $html;
891 891
 }
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	</tr>
901 901
 	<tr class="bsui">
902 902
     	<td colspan="2" class="p-0">
903
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
903
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
904 904
 
905 905
 	<?php
906 906
 
@@ -909,14 +909,14 @@  discard block
 block discarded – undo
909 909
 /**
910 910
  * Displays a tax rate' edit row.
911 911
  */
912
-function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
912
+function wpinv_tax_rate_callback($tax_rate, $key, $echo = true) {
913 913
 	ob_start();
914 914
 
915
-	$key                      = sanitize_key( $key );
916
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
917
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
915
+	$key                      = sanitize_key($key);
916
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
917
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
918 918
 
919
-	if ( $echo ) {
919
+	if ($echo) {
920 920
 		echo ob_get_clean();
921 921
 	} else {
922 922
 		return ob_get_clean(); 
@@ -929,124 +929,124 @@  discard block
 block discarded – undo
929 929
     ob_start(); ?>
930 930
     </td><tr>
931 931
     <td colspan="2" class="wpinv_tools_tdbox">
932
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
933
-    <?php do_action( 'wpinv_tools_before' ); ?>
932
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
933
+    <?php do_action('wpinv_tools_before'); ?>
934 934
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
935 935
         <thead>
936 936
             <tr>
937
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
938
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
939
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
937
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
938
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
939
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
940 940
             </tr>
941 941
         </thead>
942 942
 
943 943
         <tbody>
944 944
 			<tr>
945
-                <td><?php _e( 'Check Pages', 'invoicing' );?></td>
945
+                <td><?php _e('Check Pages', 'invoicing'); ?></td>
946 946
                 <td>
947
-                    <small><?php _e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
947
+                    <small><?php _e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
948 948
                 </td>
949 949
                 <td>
950 950
 					<a href="<?php
951 951
 						echo esc_url(
952 952
 							wp_nonce_url(
953
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
953
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
954 954
 								'getpaid-nonce',
955 955
 								'getpaid-nonce'
956 956
 							)
957 957
 						);
958
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
958
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
959 959
                 </td>
960 960
             </tr>
961 961
 			<tr>
962
-                <td><?php _e( 'Create Database Tables', 'invoicing' );?></td>
962
+                <td><?php _e('Create Database Tables', 'invoicing'); ?></td>
963 963
                 <td>
964
-                    <small><?php _e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
964
+                    <small><?php _e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
965 965
                 </td>
966 966
                 <td>
967 967
 					<a href="<?php
968 968
 						echo esc_url(
969 969
 							wp_nonce_url(
970
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
970
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
971 971
 								'getpaid-nonce',
972 972
 								'getpaid-nonce'
973 973
 							)
974 974
 						);
975
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
975
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
976 976
                 </td>
977 977
             </tr>
978 978
 			<tr>
979
-                <td><?php _e( 'Migrate old invoices', 'invoicing' );?></td>
979
+                <td><?php _e('Migrate old invoices', 'invoicing'); ?></td>
980 980
                 <td>
981
-                    <small><?php _e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
981
+                    <small><?php _e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
982 982
                 </td>
983 983
                 <td>
984 984
 					<a href="<?php
985 985
 						echo esc_url(
986 986
 							wp_nonce_url(
987
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
987
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
988 988
 								'getpaid-nonce',
989 989
 								'getpaid-nonce'
990 990
 							)
991 991
 						);
992
-					?>" class="button button-primary"><?php _e('Run', 'invoicing');?></a>
992
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
993 993
                 </td>
994 994
             </tr>
995 995
 
996 996
 			<tr>
997
-                <td><?php _e( 'Recalculate Discounts', 'invoicing' );?></td>
997
+                <td><?php _e('Recalculate Discounts', 'invoicing'); ?></td>
998 998
                 <td>
999
-                    <small><?php _e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
999
+                    <small><?php _e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1000 1000
                 </td>
1001 1001
                 <td>
1002 1002
 					<a href="<?php
1003 1003
 						echo esc_url(
1004 1004
 							wp_nonce_url(
1005
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1005
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1006 1006
 								'getpaid-nonce',
1007 1007
 								'getpaid-nonce'
1008 1008
 							)
1009 1009
 						);
1010
-					?>" class="button button-primary"><?php _e( 'Run', 'invoicing' );?></a>
1010
+					?>" class="button button-primary"><?php _e('Run', 'invoicing'); ?></a>
1011 1011
                 </td>
1012 1012
             </tr>
1013 1013
 
1014
-			<?php do_action( 'wpinv_tools_row' ); ?>
1014
+			<?php do_action('wpinv_tools_row'); ?>
1015 1015
         </tbody>
1016 1016
     </table>
1017
-    <?php do_action( 'wpinv_tools_after' ); ?>
1017
+    <?php do_action('wpinv_tools_after'); ?>
1018 1018
     <?php
1019 1019
     echo ob_get_clean();
1020 1020
 }
1021 1021
 
1022 1022
 
1023
-function wpinv_descriptive_text_callback( $args ) {
1024
-	echo wp_kses_post( $args['desc'] );
1023
+function wpinv_descriptive_text_callback($args) {
1024
+	echo wp_kses_post($args['desc']);
1025 1025
 }
1026 1026
 
1027
-function wpinv_raw_html_callback( $args ) {
1027
+function wpinv_raw_html_callback($args) {
1028 1028
 	echo $args['desc'];
1029 1029
 }
1030 1030
 
1031
-function wpinv_hook_callback( $args ) {
1032
-	do_action( 'wpinv_' . $args['id'], $args );
1031
+function wpinv_hook_callback($args) {
1032
+	do_action('wpinv_' . $args['id'], $args);
1033 1033
 }
1034 1034
 
1035 1035
 function wpinv_set_settings_cap() {
1036 1036
 	return wpinv_get_capability();
1037 1037
 }
1038
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1038
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1039 1039
 
1040 1040
 
1041
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1042
-    $old = !empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1043
-    $new = !empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1041
+function wpinv_on_update_settings($old_value, $value, $option) {
1042
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1043
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1044 1044
     
1045
-    if ( $old != $new ) {
1046
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1045
+    if ($old != $new) {
1046
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1047 1047
     }
1048 1048
 }
1049
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1049
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1050 1050
 
1051 1051
 /**
1052 1052
  * Returns the merge tags help text.
@@ -1055,16 +1055,16 @@  discard block
 block discarded – undo
1055 1055
  * 
1056 1056
  * @return string
1057 1057
  */
1058
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1058
+function wpinv_get_merge_tags_help_text($subscription = false) {
1059 1059
 
1060 1060
 	$url  = $subscription ? 'https://gist.github.com/picocodes/3d213982d57c34edf7a46fd3f0e8583e' : 'https://gist.github.com/picocodes/43bdc4d4bbba844534b2722e2af0b58f';
1061 1061
 	$link = sprintf(
1062 1062
 		'<strong><a href="%s" target="_blank">%s</a></strong>',
1063 1063
 		$url,
1064
-		esc_html__( 'View available merge tags.', 'wpinv-quotes' )
1064
+		esc_html__('View available merge tags.', 'wpinv-quotes')
1065 1065
 	);
1066 1066
 
1067
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1067
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1068 1068
 
1069 1069
 	return "$description $link";
1070 1070
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-items.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,42 +21,42 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice = new WPInv_Invoice( $post );
27
+        $invoice = new WPInv_Invoice($post);
28 28
 
29 29
         // Invoice items.
30 30
         $items = $invoice->get_items();
31 31
 
32 32
         // New item url.
33
-        $new_item = admin_url( 'post-new.php?post_type=wpi_item' );
33
+        $new_item = admin_url('post-new.php?post_type=wpi_item');
34 34
 
35 35
         $totals = array(
36 36
 
37 37
             'subtotal'  => array(
38
-                'label' => __( 'Items Subtotal', 'invoicing' ),
39
-                'value' => wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ),
38
+                'label' => __('Items Subtotal', 'invoicing'),
39
+                'value' => wpinv_price($invoice->get_subtotal(), $invoice->get_currency()),
40 40
             ),
41 41
 
42 42
             'discount'  => array(
43
-                'label' => __( 'Total Discount', 'invoicing' ),
44
-                'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ),
43
+                'label' => __('Total Discount', 'invoicing'),
44
+                'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()),
45 45
             ),
46 46
 
47 47
             'tax'       => array(
48
-                'label' => __( 'Total Tax', 'invoicing' ),
49
-                'value' => wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ),
48
+                'label' => __('Total Tax', 'invoicing'),
49
+                'value' => wpinv_price($invoice->get_total_tax(), $invoice->get_currency()),
50 50
             ),
51 51
 
52 52
             'total'     => array(
53
-                'label' => __( 'Invoice Total', 'invoicing' ),
54
-                'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
53
+                'label' => __('Invoice Total', 'invoicing'),
54
+                'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
55 55
             )
56 56
         );
57 57
 
58
-        if ( ! wpinv_use_taxes() ) {
59
-            unset( $totals['tax'] );
58
+        if (!wpinv_use_taxes()) {
59
+            unset($totals['tax']);
60 60
         }
61 61
 
62 62
         $item_args = array(
@@ -64,7 +64,7 @@  discard block
 block discarded – undo
64 64
             'orderby'        => 'title',
65 65
             'order'          => 'ASC',
66 66
             'posts_per_page' => -1,
67
-            'post_status'    => array( 'publish' ),
67
+            'post_status'    => array('publish'),
68 68
             'meta_query'     => array(
69 69
                 array(
70 70
                     'key'       => '_wpinv_type',
@@ -88,10 +88,10 @@  discard block
 block discarded – undo
88 88
             }
89 89
         </style>
90 90
 
91
-                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class( $invoice->get_template( 'edit' ) ); ?> <?php echo empty( $items ) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
91
+                <div class="bsui getpaid-invoice-items-inner <?php echo sanitize_html_class($invoice->get_template('edit')); ?> <?php echo empty($items) ? 'no-items' : 'has-items'; ?> <?php echo $invoice->is_paid() || $invoice->is_refunded() ? 'not-editable' : 'editable'; ?>" style="margin-top: 1.5rem">
92 92
 
93
-                    <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
94
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
93
+                    <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
94
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
95 95
 
96 96
                         <div class="row">
97 97
                             <div class="col-12 col-sm-6">
@@ -100,15 +100,15 @@  discard block
 block discarded – undo
100 100
                                         array(
101 101
                                             'id'          => 'wpinv_template',
102 102
                                             'name'        => 'wpinv_template',
103
-                                            'label'       => __( 'Template', 'invoicing' ),
103
+                                            'label'       => __('Template', 'invoicing'),
104 104
                                             'label_type'  => 'vertical',
105
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
105
+                                            'placeholder' => __('Choose a template', 'invoicing'),
106 106
                                             'class'       => 'form-control-sm',
107
-                                            'value'       => $invoice->get_template( 'edit' ),
107
+                                            'value'       => $invoice->get_template('edit'),
108 108
                                             'options'     => array(
109
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
110
-                                                'hours'    => __( 'Hours', 'invoicing' ),
111
-                                                'amount'   => __( 'Amount Only', 'invoicing' ),
109
+                                                'quantity' => __('Quantity', 'invoicing'),
110
+                                                'hours'    => __('Hours', 'invoicing'),
111
+                                                'amount'   => __('Amount Only', 'invoicing'),
112 112
                                             ),
113 113
                                             'data-allow-clear' => 'false',
114 114
                                             'select2'          => true,
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
                                         array(
125 125
                                             'id'          => 'wpinv_currency',
126 126
                                             'name'        => 'wpinv_currency',
127
-                                            'label'       => __( 'Currency', 'invoicing' ),
127
+                                            'label'       => __('Currency', 'invoicing'),
128 128
                                             'label_type'  => 'vertical',
129
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
129
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
130 130
                                             'class'       => 'form-control-sm',
131
-                                            'value'       => $invoice->get_currency( 'edit' ),
131
+                                            'value'       => $invoice->get_currency('edit'),
132 132
                                             'required'    => false,
133 133
                                             'data-allow-clear' => 'false',
134 134
                                             'select2'          => true,
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
                             </div>
141 141
                         </div>
142 142
 
143
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
143
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
144 144
                     <?php endif; ?>
145 145
 
146 146
                     <table cellpadding="0" cellspacing="0" class="getpaid_invoice_items">
147 147
                         <thead>
148 148
                             <tr>
149
-                                <th class="getpaid-item" colspan="2"><?php _e( 'Item', 'invoicing' ) ?></th>
149
+                                <th class="getpaid-item" colspan="2"><?php _e('Item', 'invoicing') ?></th>
150 150
                                 <th class="getpaid-quantity hide-if-amount text-right">
151
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
152
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
151
+                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
152
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
153 153
                                 </th>
154 154
                                 <th class="getpaid-price hide-if-amount text-right">
155
-                                    <span class="getpaid-hide-if-hours"><?php _e( 'Price', 'invoicing' ) ?></span>
156
-                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Rate', 'invoicing' ) ?></span>
155
+                                    <span class="getpaid-hide-if-hours"><?php _e('Price', 'invoicing') ?></span>
156
+                                    <span class="getpaid-hide-if-quantity"><?php _e('Rate', 'invoicing') ?></span>
157 157
                                 </th>
158 158
                                 <th class="getpaid-item-subtotal text-right">
159
-                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e( 'Amount', 'invoicing' ) ?></span>
160
-                                    <span class="hide-if-amount"><?php _e( 'Total', 'invoicing' ) ?></span>
159
+                                    <span class="getpaid-hide-if-hours getpaid-hide-if-quantity"><?php _e('Amount', 'invoicing') ?></span>
160
+                                    <span class="hide-if-amount"><?php _e('Total', 'invoicing') ?></span>
161 161
                                 </th>
162 162
                                 <th class="getpaid-item-actions hide-if-not-editable" width="70px">&nbsp;</th>
163 163
                             </tr>
@@ -165,8 +165,8 @@  discard block
 block discarded – undo
165 165
 		                <tbody class="getpaid_invoice_line_items">
166 166
                             <tr class="hide-if-has-items hide-if-not-editable">
167 167
                                 <td colspan="2" class="pt-4 pb-4">
168
-                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Items', 'invoicing' ) ?></button>
169
-	                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
168
+                                    <button type="button" class="button button-primary add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Items', 'invoicing') ?></button>
169
+	                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
170 170
                                 </td>
171 171
                                 <td class="hide-if-amount">&nbsp;</th>
172 172
                                 <td class="hide-if-amount">&nbsp;</th>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                             <div class="col-12 col-sm-6 offset-sm-6">
199 199
                                 <table class="getpaid-invoice-totals text-right w-100">
200 200
                                     <tbody>
201
-                                        <?php foreach ( apply_filters( 'getpaid_invoice_subtotal_rows', $totals, $invoice ) as $key => $data ) : ?>
202
-                                            <tr class="getpaid-totals-<?php echo sanitize_html_class( $key ); ?>">
203
-                                                <td class="label"><?php echo sanitize_text_field( $data['label'] ) ?>:</td>
201
+                                        <?php foreach (apply_filters('getpaid_invoice_subtotal_rows', $totals, $invoice) as $key => $data) : ?>
202
+                                            <tr class="getpaid-totals-<?php echo sanitize_html_class($key); ?>">
203
+                                                <td class="label"><?php echo sanitize_text_field($data['label']) ?>:</td>
204 204
                                                 <td width="1%"></td>
205
-                                                <td class="value"><?php echo wp_kses_post( $data['value'] ) ?></td>
205
+                                                <td class="value"><?php echo wp_kses_post($data['value']) ?></td>
206 206
                                             </tr>
207 207
                                         <?php endforeach; ?>
208 208
                                     </tbody>
@@ -215,18 +215,18 @@  discard block
 block discarded – undo
215 215
                     <div class="getpaid-invoice-item-actions hide-if-no-items hide-if-not-editable">
216 216
                         <div class="row">
217 217
                             <div class="text-left col-12 col-sm-8">
218
-                                <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e( 'Add Existing Item', 'invoicing' ) ?></button>
219
-                                <a href="<?php echo esc_url( $new_item ); ?>" target="_blank" class="button button-secondary"><?php _e( 'Create New Item', 'invoicing' ) ?></a>
220
-                                <?php do_action( 'getpaid-invoice-items-actions', $invoice ); ?>
218
+                                <button type="button" class="button add-invoice-item" data-toggle="modal" data-target="#getpaid-add-items-to-invoice"><?php _e('Add Existing Item', 'invoicing') ?></button>
219
+                                <a href="<?php echo esc_url($new_item); ?>" target="_blank" class="button button-secondary"><?php _e('Create New Item', 'invoicing') ?></a>
220
+                                <?php do_action('getpaid-invoice-items-actions', $invoice); ?>
221 221
                             </div>
222 222
                             <div class="text-right col-12 col-sm-4">
223
-                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e( 'Recalculate Totals', 'invoicing' ) ?></button>
223
+                                <button type="button" class="button button-primary recalculate-totals-button"><?php _e('Recalculate Totals', 'invoicing') ?></button>
224 224
                             </div>
225 225
                         </div>
226 226
                     </div>
227 227
 
228 228
                     <div class="getpaid-invoice-item-actions hide-if-editable">
229
-                        <p class="description m-2 text-right text-muted"><?php _e( 'This invoice is no longer editable', 'invoicing' ); ?></p>
229
+                        <p class="description m-2 text-right text-muted"><?php _e('This invoice is no longer editable', 'invoicing'); ?></p>
230 230
                     </div>
231 231
 
232 232
                     <!-- Add items to an invoice -->
@@ -234,8 +234,8 @@  discard block
 block discarded – undo
234 234
                         <div class="modal-dialog modal-dialog-centered" role="document">
235 235
                             <div class="modal-content">
236 236
                                 <div class="modal-header">
237
-                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e( "Add Item(s)", 'invoicing' ); ?></h5>
238
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
237
+                                    <h5 class="modal-title" id="getpaid-add-item-to-invoice-label"><?php _e("Add Item(s)", 'invoicing'); ?></h5>
238
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
239 239
                                         <span aria-hidden="true">&times;</span>
240 240
                                     </button>
241 241
                                 </div>
@@ -243,10 +243,10 @@  discard block
 block discarded – undo
243 243
                                     <table class="widefat">
244 244
                                         <thead>
245 245
                                             <tr>
246
-                                                <th class="pl-0 text-left"><?php _e( 'Item', 'invoicing' ) ?></th>
246
+                                                <th class="pl-0 text-left"><?php _e('Item', 'invoicing') ?></th>
247 247
                                                 <th class="pr-0 text-right hide-if-amount">
248
-                                                    <span class="getpaid-hide-if-hours"><?php _e( 'Quantity', 'invoicing' ) ?></span>
249
-                                                    <span class="getpaid-hide-if-quantity"><?php _e( 'Hours', 'invoicing' ) ?></span>
248
+                                                    <span class="getpaid-hide-if-hours"><?php _e('Quantity', 'invoicing') ?></span>
249
+                                                    <span class="getpaid-hide-if-quantity"><?php _e('Hours', 'invoicing') ?></span>
250 250
                                                 </th>
251 251
                                             </tr>
252 252
                                         </thead>
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 								            <tr>
255 255
 									            <td class="pl-0 text-left">
256 256
                                                     <select class="regular-text getpaid-add-invoice-item-select">
257
-                                                        <option value="" selected="selected" disabled><?php esc_html_e( 'Select an item…', 'invoicing' ); ?></option>
258
-                                                        <?php foreach ( get_posts( $item_args ) as $item ) : ?>
259
-                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags( $item->post_title ); ?></option>
257
+                                                        <option value="" selected="selected" disabled><?php esc_html_e('Select an item…', 'invoicing'); ?></option>
258
+                                                        <?php foreach (get_posts($item_args) as $item) : ?>
259
+                                                        <option value="<?php echo (int) $item->ID; ?>"><?php echo strip_tags($item->post_title); ?></option>
260 260
                                                         <?php endforeach; ?>
261 261
                                                     </select>
262 262
                                                 </td>
@@ -268,8 +268,8 @@  discard block
 block discarded – undo
268 268
 						            </table>
269 269
                                 </div>
270 270
                                 <div class="modal-footer">
271
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
272
-                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e( 'Add', 'invoicing' ); ?></button>
271
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
272
+                                    <button type="button" class="btn btn-primary getpaid-add" data-dismiss="modal"><?php _e('Add', 'invoicing'); ?></button>
273 273
                                 </div>
274 274
                             </div>
275 275
                         </div>
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
                         <div class="modal-dialog modal-dialog-centered" role="document">
281 281
                             <div class="modal-content">
282 282
                                 <div class="modal-header">
283
-                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e( "Edit Item", 'invoicing' ); ?></h5>
284
-                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e( "Close", 'invoicing' ); ?>">
283
+                                    <h5 class="modal-title" id="getpaid-edit-invoice-item-label"><?php _e("Edit Item", 'invoicing'); ?></h5>
284
+                                    <button type="button" class="close" data-dismiss="modal" aria-label="<?php _e("Close", 'invoicing'); ?>">
285 285
                                         <span aria-hidden="true">&times;</span>
286 286
                                     </button>
287 287
                                 </div>
@@ -289,27 +289,27 @@  discard block
 block discarded – undo
289 289
                                     <div class="getpaid-edit-item-div">
290 290
                                         <input type="hidden" name="id" class="form-control form-control-sm item-id">
291 291
                                         <label class="form-group w-100">
292
-                                            <span><?php _e( 'Name', 'invoicing' ); ?></span>
293
-                                            <input type="text" name="name" placeholder="<?php esc_attr_e( 'Item Name', 'invoicing' ); ?>" class="form-control form-control-sm item-name">
292
+                                            <span><?php _e('Name', 'invoicing'); ?></span>
293
+                                            <input type="text" name="name" placeholder="<?php esc_attr_e('Item Name', 'invoicing'); ?>" class="form-control form-control-sm item-name">
294 294
                                         </label>
295 295
                                         <label class="form-group w-100">
296
-                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e( 'Amount', 'invoicing' ); ?></span>
297
-                                            <span class="hide-if-amount"><?php _e( 'Price', 'invoicing' ); ?></span>
298
-                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount( 0 ); ?>" class="form-control form-control-sm item-price">
296
+                                            <span class="getpaid-hide-if-hours getpaid-hide-if-quantity item-price"><?php _e('Amount', 'invoicing'); ?></span>
297
+                                            <span class="hide-if-amount"><?php _e('Price', 'invoicing'); ?></span>
298
+                                            <input type="text" name="price" placeholder="<?php wpinv_sanitize_amount(0); ?>" class="form-control form-control-sm item-price">
299 299
                                         </label>
300 300
                                         <label class="form-group w-100 hide-if-amount">
301
-                                            <span><?php _e( 'Quantity', 'invoicing' ); ?></span>
301
+                                            <span><?php _e('Quantity', 'invoicing'); ?></span>
302 302
                                             <input type="text" name="quantity" placeholder="1" class="form-control form-control-sm item-quantity">
303 303
                                         </label>
304 304
                                         <label class="form-group w-100">
305
-                                            <span><?php _e( 'Item Description', 'invoicing' ); ?></span>
306
-                                            <textarea name="description" placeholder="<?php esc_attr_e( 'Enter a description for this item', 'invoicing' ); ?>" class="form-control item-description"></textarea>
305
+                                            <span><?php _e('Item Description', 'invoicing'); ?></span>
306
+                                            <textarea name="description" placeholder="<?php esc_attr_e('Enter a description for this item', 'invoicing'); ?>" class="form-control item-description"></textarea>
307 307
                                         </label>
308 308
                                     </div>
309 309
                                 </div>
310 310
                                 <div class="modal-footer">
311
-                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e( 'Cancel', 'invoicing' ); ?></button>
312
-                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e( 'Save', 'invoicing' ); ?></button>
311
+                                    <button type="button" class="btn btn-secondary getpaid-cancel" data-dismiss="modal"><?php _e('Cancel', 'invoicing'); ?></button>
312
+                                    <button type="button" class="btn btn-primary getpaid-save" data-dismiss="modal"><?php _e('Save', 'invoicing'); ?></button>
313 313
                                 </div>
314 314
                             </div>
315 315
                         </div>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Spacing   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,31 +54,31 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ) );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
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' ) );
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_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
74
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
75
-		do_action( 'getpaid_init_admin_hooks', $this );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'));
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
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'));
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_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin'));
73
+		add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway'));
74
+		add_filter('admin_footer_text', array($this, 'admin_footer_text'));
75
+		do_action('getpaid_init_admin_hooks', $this);
76 76
 
77 77
 		// Setup/welcome
78
-		if ( ! empty( $_GET['page'] ) ) {
79
-			switch ( $_GET['page'] ) {
78
+		if (!empty($_GET['page'])) {
79
+			switch ($_GET['page']) {
80 80
 				case 'gp-setup' :
81
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
81
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
82 82
 					break;
83 83
 			}
84 84
 		}
@@ -92,37 +92,37 @@  discard block
 block discarded – undo
92 92
 	public function enqeue_scripts() {
93 93
         global $current_screen, $pagenow;
94 94
 
95
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
95
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
96 96
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97 97
 
98
-        if ( ! empty( $current_screen->post_type ) ) {
98
+        if (!empty($current_screen->post_type)) {
99 99
 			$page = $current_screen->post_type;
100 100
         }
101 101
 
102 102
         // General styles.
103
-        if ( false !== stripos( $page, 'wpi' ) || 'gp-setup' == $page ) {
103
+        if (false !== stripos($page, 'wpi') || 'gp-setup' == $page) {
104 104
 
105 105
             // Styles.
106
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
107
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
108
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
106
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
107
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
108
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
109 109
 
110 110
             // Scripts.
111
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
111
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
112 112
 
113
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
114
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
115
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
113
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
114
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
115
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
116 116
 
117 117
         }
118 118
 
119 119
         // Payment form scripts.
120
-		if ( 'wpi_payment_form' == $page && $editing ) {
120
+		if ('wpi_payment_form' == $page && $editing) {
121 121
             $this->load_payment_form_scripts();
122 122
         }
123 123
 
124
-		if ( $page == 'wpinv-subscriptions' ) {
125
-			wp_enqueue_script( 'postbox' );
124
+		if ($page == 'wpinv-subscriptions') {
125
+			wp_enqueue_script('postbox');
126 126
 		}
127 127
 
128 128
     }
@@ -135,32 +135,32 @@  discard block
 block discarded – undo
135 135
         global $post;
136 136
 
137 137
 		$date_range = array(
138
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
138
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
139 139
 		);
140 140
 
141
-		if ( $date_range['period'] == 'custom' ) {
141
+		if ($date_range['period'] == 'custom') {
142 142
 			
143
-			if ( isset( $_GET['from'] ) ) {
144
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
143
+			if (isset($_GET['from'])) {
144
+				$date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS);
145 145
 			}
146 146
 
147
-			if ( isset( $_GET['to'] ) ) {
148
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
147
+			if (isset($_GET['to'])) {
148
+				$date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS);
149 149
 			}
150 150
 
151 151
 		}
152 152
 
153 153
         $i18n = array(
154
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
155
-            'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
156
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
157
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
158
-			'rest_root'                 => esc_url_raw( rest_url() ),
154
+            'ajax_url'                  => admin_url('admin-ajax.php'),
155
+            'post_ID'                   => isset($post->ID) ? $post->ID : '',
156
+			'wpinv_nonce'               => wp_create_nonce('wpinv-nonce'),
157
+			'rest_nonce'                => wp_create_nonce('wp_rest'),
158
+			'rest_root'                 => esc_url_raw(rest_url()),
159 159
 			'date_range'                => $date_range,
160
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
161
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
162
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
163
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
160
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
161
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
162
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
163
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
164 164
             'tax'                       => wpinv_tax_amount(),
165 165
             'discount'                  => 0,
166 166
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -169,38 +169,38 @@  discard block
 block discarded – undo
169 169
             'thousand_sep'              => wpinv_thousands_separator(),
170 170
             'decimal_sep'               => wpinv_decimal_separator(),
171 171
             'decimals'                  => wpinv_decimals(),
172
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
173
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
174
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
175
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
178
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
179
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
180
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
181
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
182
-            'action_edit'               => __( 'Edit', 'invoicing' ),
183
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
184
-            'item_description'          => __( 'Item Description', 'invoicing' ),
185
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
186
-            'discount_description'      => __( 'Discount Description', 'invoicing' ),
187
-			'searching'                 => __( 'Searching', 'invoicing' ),
188
-			'loading'                   => __( 'Loading...', 'invoicing' ),
189
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
190
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
172
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
173
+            'status_publish'            => wpinv_status_nicename('publish'),
174
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
175
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
178
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
179
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
180
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
181
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
182
+            'action_edit'               => __('Edit', 'invoicing'),
183
+            'action_cancel'             => __('Cancel', 'invoicing'),
184
+            'item_description'          => __('Item Description', 'invoicing'),
185
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
186
+            'discount_description'      => __('Discount Description', 'invoicing'),
187
+			'searching'                 => __('Searching', 'invoicing'),
188
+			'loading'                   => __('Loading...', 'invoicing'),
189
+			'search_customers'          => __('Enter customer name or email', 'invoicing'),
190
+			'search_items'              => __('Enter item name', 'invoicing'),
191 191
         );
192 192
 
193
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
193
+		if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) {
194 194
 
195
-			$invoice              = new WPInv_Invoice( $post );
195
+			$invoice              = new WPInv_Invoice($post);
196 196
 			$i18n['save_invoice'] = sprintf(
197
-				__( 'Save %s', 'invoicing' ),
198
-				ucfirst( $invoice->get_invoice_quote_type() )
197
+				__('Save %s', 'invoicing'),
198
+				ucfirst($invoice->get_invoice_quote_type())
199 199
 			);
200 200
 
201 201
 			$i18n['invoice_description'] = sprintf(
202
-				__( '%s Description', 'invoicing' ),
203
-				ucfirst( $invoice->get_invoice_quote_type() )
202
+				__('%s Description', 'invoicing'),
203
+				ucfirst($invoice->get_invoice_quote_type())
204 204
 			);
205 205
 
206 206
 		}
@@ -214,24 +214,24 @@  discard block
 block discarded – undo
214 214
 	 * @param  string $footer_text
215 215
 	 * @return string
216 216
 	 */
217
-	public function admin_footer_text( $footer_text ) {
217
+	public function admin_footer_text($footer_text) {
218 218
 		global $current_screen;
219 219
 
220
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
220
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
221 221
 
222
-        if ( ! empty( $current_screen->post_type ) ) {
222
+        if (!empty($current_screen->post_type)) {
223 223
 			$page = $current_screen->post_type;
224 224
         }
225 225
 
226 226
         // General styles.
227
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
227
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
228 228
 
229 229
 			// Change the footer text
230
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
230
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
231 231
 
232
-				$rating_url  = esc_url(
232
+				$rating_url = esc_url(
233 233
 					wp_nonce_url(
234
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
234
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
235 235
 						'getpaid-nonce',
236 236
 						'getpaid-nonce'
237 237
 						)
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 
240 240
 				$footer_text = sprintf(
241 241
 					/* translators: %s: five stars */
242
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
242
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
243 243
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
244 244
 				);
245 245
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 
248 248
 				$footer_text = sprintf(
249 249
 					/* translators: %s: GetPaid */
250
-					__( 'Thank you for using %s!', 'invoicing' ),
250
+					__('Thank you for using %s!', 'invoicing'),
251 251
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
252 252
 				);
253 253
 
@@ -264,8 +264,8 @@  discard block
 block discarded – undo
264 264
 	 * @since  2.0.0
265 265
 	 */
266 266
 	public function redirect_to_wordpress_rating_page() {
267
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
268
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
267
+		update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1);
268
+		wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post');
269 269
 		exit;
270 270
 	}
271 271
 
@@ -276,30 +276,30 @@  discard block
 block discarded – undo
276 276
 	protected function load_payment_form_scripts() {
277 277
         global $post;
278 278
 
279
-        wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION );
280
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
281
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
279
+        wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.js', array(), WPINV_VERSION);
280
+		wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION);
281
+		wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION);
282 282
 
283
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
284
-		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
+		$version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js');
284
+		wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array('wpinv-admin-script', 'vue_draggable'), $version);
285 285
 
286 286
 		wp_localize_script(
287 287
             'wpinv-admin-payment-form-script',
288 288
             'wpinvPaymentFormAdmin',
289 289
             array(
290
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
291
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
290
+				'elements'      => wpinv_get_data('payment-form-elements'),
291
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
292 292
 				'currency'      => wpinv_currency_symbol(),
293 293
 				'position'      => wpinv_currency_position(),
294 294
 				'decimals'      => (int) wpinv_decimals(),
295 295
 				'thousands_sep' => wpinv_thousands_separator(),
296 296
 				'decimals_sep'  => wpinv_decimal_separator(),
297
-				'form_items'    => gepaid_get_form_items( $post->ID ),
297
+				'form_items'    => gepaid_get_form_items($post->ID),
298 298
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
299 299
             )
300 300
         );
301 301
 
302
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
302
+        wp_enqueue_script('wpinv-admin-payment-form-script');
303 303
 
304 304
     }
305 305
 
@@ -310,25 +310,25 @@  discard block
 block discarded – undo
310 310
      * @return string
311 311
 	 *
312 312
 	 */
313
-    public function admin_body_class( $classes ) {
313
+    public function admin_body_class($classes) {
314 314
 		global $pagenow, $post, $current_screen;
315 315
 
316 316
 
317
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
317
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
318 318
 
319
-        if ( ! empty( $current_screen->post_type ) ) {
319
+        if (!empty($current_screen->post_type)) {
320 320
 			$page = $current_screen->post_type;
321 321
         }
322 322
 
323
-        if ( false !== stripos( $page, 'wpi' ) ) {
324
-            $classes .= ' wpi-' . sanitize_key( $page );
323
+        if (false !== stripos($page, 'wpi')) {
324
+            $classes .= ' wpi-' . sanitize_key($page);
325 325
         }
326 326
 
327
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
327
+        if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) {
328 328
             $classes .= ' wpinv-cpt wpinv';
329 329
 		}
330 330
 		
331
-		if ( getpaid_is_invoice_post_type( $page ) ) {
331
+		if (getpaid_is_invoice_post_type($page)) {
332 332
             $classes .= ' getpaid-is-invoice-cpt';
333 333
         }
334 334
 
@@ -338,19 +338,19 @@  discard block
 block discarded – undo
338 338
     /**
339 339
 	 * Maybe show the AyeCode Connect Notice.
340 340
 	 */
341
-	public function init_ayecode_connect_helper(){
341
+	public function init_ayecode_connect_helper() {
342 342
 
343 343
         new AyeCode_Connect_Helper(
344 344
             array(
345
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
346
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
347
-				'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>" ),
348
-				'connect_button'    => __("Connect Site","invoicing"),
349
-				'connecting_button'    => __("Connecting...","invoicing"),
350
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
351
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
345
+				'connect_title' => __("WP Invoicing - an AyeCode product!", "invoicing"),
346
+				'connect_external'  => __("Please confirm you wish to connect your site?", "invoicing"),
347
+				'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>"),
348
+				'connect_button'    => __("Connect Site", "invoicing"),
349
+				'connecting_button'    => __("Connecting...", "invoicing"),
350
+				'error_localhost'   => __("This service will only work with a live domain, not a localhost.", "invoicing"),
351
+				'error'             => __("Something went wrong, please refresh and try again.", "invoicing"),
352 352
             ),
353
-            array( 'wpi-addons' )
353
+            array('wpi-addons')
354 354
         );
355 355
 
356 356
     }
@@ -362,20 +362,20 @@  discard block
 block discarded – undo
362 362
 	 */
363 363
 	public function activation_redirect() {
364 364
 
365
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
365
+		$redirected = get_option('wpinv_redirected_to_settings');
366 366
 
367
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
367
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
368 368
 			return;
369 369
 		}
370 370
 
371 371
 		// Bail if activating from network, or bulk
372
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
372
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
373 373
 			return;
374 374
 		}
375 375
 
376
-	    update_option( 'wpinv_redirected_to_settings', 1 );
376
+	    update_option('wpinv_redirected_to_settings', 1);
377 377
 
378
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
378
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
379 379
         exit;
380 380
 
381 381
 	}
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
      */
386 386
     public function maybe_do_admin_action() {
387 387
 
388
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
389
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
390
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
388
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
389
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
390
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
391 391
         }
392 392
 
393 393
     }
@@ -397,16 +397,16 @@  discard block
 block discarded – undo
397 397
 	 * 
398 398
 	 * @param array $args
399 399
      */
400
-    public function send_customer_invoice( $args ) {
401
-		$sent = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
400
+    public function send_customer_invoice($args) {
401
+		$sent = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true);
402 402
 
403
-		if ( $sent ) {
404
-			$this->show_success( __( 'Invoice was successfully sent to the customer', 'invoicing' ) );
403
+		if ($sent) {
404
+			$this->show_success(__('Invoice was successfully sent to the customer', 'invoicing'));
405 405
 		} else {
406
-			$this->show_error( __( 'Could not send the invoice to the customer', 'invoicing' ) );
406
+			$this->show_error(__('Could not send the invoice to the customer', 'invoicing'));
407 407
 		}
408 408
 
409
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
409
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
410 410
 		exit;
411 411
 	}
412 412
 
@@ -415,16 +415,16 @@  discard block
 block discarded – undo
415 415
 	 * 
416 416
 	 * @param array $args
417 417
      */
418
-    public function send_customer_payment_reminder( $args ) {
419
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
418
+    public function send_customer_payment_reminder($args) {
419
+		$sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id']));
420 420
 
421
-		if ( $sent ) {
422
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
421
+		if ($sent) {
422
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
423 423
 		} else {
424
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
424
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
425 425
 		}
426 426
 
427
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
427
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
428 428
 		exit;
429 429
 	}
430 430
 
@@ -434,8 +434,8 @@  discard block
 block discarded – undo
434 434
      */
435 435
     public function admin_reset_tax_rates() {
436 436
 
437
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
438
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
437
+		update_option('wpinv_tax_rates', wpinv_get_data('tax-rates'));
438
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
439 439
 		exit;
440 440
 
441 441
 	}
@@ -447,8 +447,8 @@  discard block
 block discarded – undo
447 447
     public function admin_create_missing_pages() {
448 448
 		$installer = new GetPaid_Installer();
449 449
 		$installer->create_pages();
450
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
451
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
450
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
451
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
452 452
 		exit;
453 453
 	}
454 454
 
@@ -460,35 +460,35 @@  discard block
 block discarded – undo
460 460
 		global $wpdb;
461 461
 		$installer = new GetPaid_Installer();
462 462
 
463
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
463
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
464 464
 			$installer->create_subscriptions_table();
465 465
 
466
-			if ( $wpdb->last_error !== '' ) {
467
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
466
+			if ($wpdb->last_error !== '') {
467
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
468 468
 			}
469 469
 		}
470 470
 
471
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
471
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
472 472
 			$installer->create_invoices_table();
473 473
 
474
-			if ( $wpdb->last_error !== '' ) {
475
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
474
+			if ($wpdb->last_error !== '') {
475
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
476 476
 			}
477 477
 		}
478 478
 
479
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
479
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
480 480
 			$installer->create_invoice_items_table();
481 481
 
482
-			if ( $wpdb->last_error !== '' ) {
483
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
482
+			if ($wpdb->last_error !== '') {
483
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
484 484
 			}
485 485
 		}
486 486
 
487
-		if ( ! $this->has_notices() ) {
488
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
487
+		if (!$this->has_notices()) {
488
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
489 489
 		}
490 490
 
491
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
491
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
492 492
 		exit;
493 493
 	}
494 494
 
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 		$installer->migrate_old_invoices();
504 504
 
505 505
 		// Show an admin message.
506
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
506
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
507 507
 
508 508
 		// Redirect the admin.
509
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
509
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
510 510
 		exit;
511 511
 
512 512
 	}
@@ -518,18 +518,18 @@  discard block
 block discarded – undo
518 518
     public function admin_download_customers() {
519 519
 		global $wpdb;
520 520
 
521
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
521
+		$output = fopen('php://output', 'w') or die(__('Unsupported server', 'invoicing'));
522 522
 
523
-		header( "Content-Type:text/csv" );
524
-		header( "Content-Disposition:attachment;filename=customers.csv" );
523
+		header("Content-Type:text/csv");
524
+		header("Content-Disposition:attachment;filename=customers.csv");
525 525
 
526 526
 		$post_types = '';
527 527
 
528
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
529
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
528
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
529
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
530 530
 		}
531 531
 
532
-		$post_types = rtrim( $post_types, ' OR' );
532
+		$post_types = rtrim($post_types, ' OR');
533 533
 
534 534
 		$customers = $wpdb->get_col(
535 535
 			$wpdb->prepare(
@@ -538,57 +538,57 @@  discard block
 block discarded – undo
538 538
 		);
539 539
 
540 540
 		$columns = array(
541
-			'name'     => __( 'Name', 'invoicing' ),
542
-			'email'    => __( 'Email', 'invoicing' ),
543
-			'country'  => __( 'Country', 'invoicing' ),
544
-			'state'    => __( 'State', 'invoicing' ),
545
-			'city'     => __( 'City', 'invoicing' ),
546
-			'zip'      => __( 'ZIP', 'invoicing' ),
547
-			'address'  => __( 'Address', 'invoicing' ),
548
-			'phone'    => __( 'Phone', 'invoicing' ),
549
-			'company'  => __( 'Company', 'invoicing' ),
550
-			'invoices' => __( 'Invoices', 'invoicing' ),
551
-			'total'    => __( 'Total Spend', 'invoicing' ),
552
-			'signup'   => __( 'Date created', 'invoicing' ),
541
+			'name'     => __('Name', 'invoicing'),
542
+			'email'    => __('Email', 'invoicing'),
543
+			'country'  => __('Country', 'invoicing'),
544
+			'state'    => __('State', 'invoicing'),
545
+			'city'     => __('City', 'invoicing'),
546
+			'zip'      => __('ZIP', 'invoicing'),
547
+			'address'  => __('Address', 'invoicing'),
548
+			'phone'    => __('Phone', 'invoicing'),
549
+			'company'  => __('Company', 'invoicing'),
550
+			'invoices' => __('Invoices', 'invoicing'),
551
+			'total'    => __('Total Spend', 'invoicing'),
552
+			'signup'   => __('Date created', 'invoicing'),
553 553
 		);
554 554
 
555 555
 		// Output the csv column headers.
556
-		fputcsv( $output, array_values( $columns ) );
556
+		fputcsv($output, array_values($columns));
557 557
 
558 558
 		// Loop through
559 559
 		$table = new WPInv_Customers_Table();
560
-		foreach ( $customers as $customer_id ) {
560
+		foreach ($customers as $customer_id) {
561 561
 
562
-			$user = get_user_by( 'id', $customer_id );
562
+			$user = get_user_by('id', $customer_id);
563 563
 			$row  = array();
564
-			if ( empty( $user ) ) {
564
+			if (empty($user)) {
565 565
 				continue;
566 566
 			}
567 567
 
568
-			foreach ( array_keys( $columns ) as $column ) {
568
+			foreach (array_keys($columns) as $column) {
569 569
 
570 570
 				$method = 'column_' . $column;
571 571
 
572
-				if ( 'name' == $column ) {
573
-					$value = sanitize_text_field( $user->display_name );
574
-				} else if( 'email' == $column ) {
575
-					$value = sanitize_email( $user->user_email );
576
-				} else if ( is_callable( array( $table, $method ) ) ) {
577
-					$value = strip_tags( $table->$method( $user ) );
572
+				if ('name' == $column) {
573
+					$value = sanitize_text_field($user->display_name);
574
+				} else if ('email' == $column) {
575
+					$value = sanitize_email($user->user_email);
576
+				} else if (is_callable(array($table, $method))) {
577
+					$value = strip_tags($table->$method($user));
578 578
 				}
579 579
 
580
-				if ( empty( $value ) ) {
581
-					$value = sanitize_text_field( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
580
+				if (empty($value)) {
581
+					$value = sanitize_text_field(get_user_meta($user->ID, '_wpinv_' . $column, true));
582 582
 				}
583 583
 
584 584
 				$row[] = $value;
585 585
 
586 586
 			}
587 587
 
588
-			fputcsv( $output, $row );
588
+			fputcsv($output, $row);
589 589
 		}
590 590
 
591
-		fclose( $output );
591
+		fclose($output);
592 592
 		exit;
593 593
 
594 594
 	}
@@ -598,29 +598,29 @@  discard block
 block discarded – undo
598 598
 	 *
599 599
 	 * @param array $data
600 600
      */
601
-    public function admin_install_plugin( $data ) {
601
+    public function admin_install_plugin($data) {
602 602
 
603
-		if ( ! empty( $data['plugins'] ) ) {
603
+		if (!empty($data['plugins'])) {
604 604
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
605 605
 			wp_cache_flush();
606 606
 
607
-			foreach ( $data['plugins'] as $slug => $file ) {
608
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
609
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
610
-				$installed  = $upgrader->install( $plugin_zip );
607
+			foreach ($data['plugins'] as $slug => $file) {
608
+				$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip');
609
+				$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
610
+				$installed  = $upgrader->install($plugin_zip);
611 611
 
612
-				if ( ! is_wp_error( $installed ) && $installed ) {
613
-					activate_plugin( $file, '', false, true );
612
+				if (!is_wp_error($installed) && $installed) {
613
+					activate_plugin($file, '', false, true);
614 614
 				} else {
615
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
615
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
616 616
 				}
617 617
 
618 618
 			}
619 619
 
620 620
 		}
621 621
 
622
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
623
-		wp_safe_redirect( $redirect );
622
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
623
+		wp_safe_redirect($redirect);
624 624
 		exit;
625 625
 
626 626
 	}
@@ -630,39 +630,39 @@  discard block
 block discarded – undo
630 630
 	 *
631 631
 	 * @param array $data
632 632
      */
633
-    public function admin_connect_gateway( $data ) {
633
+    public function admin_connect_gateway($data) {
634 634
 
635
-		if ( ! empty( $data['plugin'] ) ) {
635
+		if (!empty($data['plugin'])) {
636 636
 
637
-			$gateway     = sanitize_key( $data['plugin'] );
638
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
637
+			$gateway     = sanitize_key($data['plugin']);
638
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
639 639
 
640
-			if ( ! empty( $connect_url ) ) {
641
-				wp_redirect( $connect_url );
640
+			if (!empty($connect_url)) {
641
+				wp_redirect($connect_url);
642 642
 				exit;
643 643
 			}
644 644
 
645
-			if ( 'stripe' == $data['plugin'] ) {
645
+			if ('stripe' == $data['plugin']) {
646 646
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
647 647
 
648
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
649
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
650
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
651
-					$upgrader->install( $plugin_zip );
648
+				if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) {
649
+					$plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip');
650
+					$upgrader   = new Plugin_Upgrader(new Automatic_Upgrader_Skin());
651
+					$upgrader->install($plugin_zip);
652 652
 				}
653 653
 
654
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
654
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
655 655
 			}
656 656
 
657
-			if ( ! empty( $connect_url ) ) {
658
-				wp_redirect( $connect_url );
657
+			if (!empty($connect_url)) {
658
+				wp_redirect($connect_url);
659 659
 				exit;
660 660
 			}
661 661
 
662 662
 		}
663 663
 
664
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
665
-		wp_safe_redirect( $redirect );
664
+		$redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways');
665
+		wp_safe_redirect($redirect);
666 666
 		exit;
667 667
 
668 668
 	}
@@ -676,36 +676,36 @@  discard block
 block discarded – undo
676 676
 
677 677
 		// Fetch all invoices that have discount codes.
678 678
 		$table    = $wpdb->prefix . 'getpaid_invoices';
679
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
679
+		$invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''");
680 680
 
681
-		foreach ( $invoices as $invoice ) {
681
+		foreach ($invoices as $invoice) {
682 682
 
683
-			$invoice = new WPInv_Invoice( $invoice );
683
+			$invoice = new WPInv_Invoice($invoice);
684 684
 
685
-			if ( ! $invoice->exists() ) {
685
+			if (!$invoice->exists()) {
686 686
 				continue;
687 687
 			}
688 688
 
689 689
 			// Abort if the discount does not exist or does not apply here.
690
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
691
-			if ( ! $discount->exists() ) {
690
+			$discount = new WPInv_Discount($invoice->get_discount_code());
691
+			if (!$discount->exists()) {
692 692
 				continue;
693 693
 			}
694 694
 
695
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
695
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
696 696
 			$invoice->recalculate_total();
697 697
 
698
-			if ( $invoice->get_total_discount() > 0 ) {
698
+			if ($invoice->get_total_discount() > 0) {
699 699
 				$invoice->save();
700 700
 			}
701 701
 
702 702
 		}
703 703
 
704 704
 		// Show an admin message.
705
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
705
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
706 706
 
707 707
 		// Redirect the admin.
708
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
708
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
709 709
 		exit;
710 710
 
711 711
 	}
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
      * @return array
718 718
 	 */
719 719
 	public function get_notices() {
720
-		$notices = get_option( 'wpinv_admin_notices' );
721
-        return is_array( $notices ) ? $notices : array();
720
+		$notices = get_option('wpinv_admin_notices');
721
+        return is_array($notices) ? $notices : array();
722 722
 	}
723 723
 
724 724
 	/**
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
      * @return array
729 729
 	 */
730 730
 	public function has_notices() {
731
-		return count( $this->get_notices() ) > 0;
731
+		return count($this->get_notices()) > 0;
732 732
 	}
733 733
 
734 734
 	/**
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 * @since       1.0.19
739 739
 	 */
740 740
 	public function clear_notices() {
741
-		delete_option( 'wpinv_admin_notices' );
741
+		delete_option('wpinv_admin_notices');
742 742
 	}
743 743
 
744 744
 	/**
@@ -747,16 +747,16 @@  discard block
 block discarded – undo
747 747
 	 * @access      public
748 748
 	 * @since       1.0.19
749 749
 	 */
750
-	public function save_notice( $type, $message ) {
750
+	public function save_notice($type, $message) {
751 751
 		$notices = $this->get_notices();
752 752
 
753
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
754
-			$notices[ $type ] = array();
753
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
754
+			$notices[$type] = array();
755 755
 		}
756 756
 
757
-		$notices[ $type ][] = $message;
757
+		$notices[$type][] = $message;
758 758
 
759
-		update_option( 'wpinv_admin_notices', $notices );
759
+		update_option('wpinv_admin_notices', $notices);
760 760
 	}
761 761
 
762 762
 	/**
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	 * @access      public
767 767
 	 * @since       1.0.19
768 768
 	 */
769
-	public function show_success( $msg ) {
770
-		$this->save_notice( 'success', $msg );
769
+	public function show_success($msg) {
770
+		$this->save_notice('success', $msg);
771 771
 	}
772 772
 
773 773
 	/**
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	 * @param       string $msg The message to qeue.
778 778
 	 * @since       1.0.19
779 779
 	 */
780
-	public function show_error( $msg ) {
781
-		$this->save_notice( 'error', $msg );
780
+	public function show_error($msg) {
781
+		$this->save_notice('error', $msg);
782 782
 	}
783 783
 
784 784
 	/**
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	 * @param       string $msg The message to qeue.
789 789
 	 * @since       1.0.19
790 790
 	 */
791
-	public function show_warning( $msg ) {
792
-		$this->save_notice( 'warning', $msg );
791
+	public function show_warning($msg) {
792
+		$this->save_notice('warning', $msg);
793 793
 	}
794 794
 
795 795
 	/**
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	 * @param       string $msg The message to qeue.
800 800
 	 * @since       1.0.19
801 801
 	 */
802
-	public function show_info( $msg ) {
803
-		$this->save_notice( 'info', $msg );
802
+	public function show_info($msg) {
803
+		$this->save_notice('info', $msg);
804 804
 	}
805 805
 
806 806
 	/**
@@ -814,30 +814,30 @@  discard block
 block discarded – undo
814 814
         $notices = $this->get_notices();
815 815
         $this->clear_notices();
816 816
 
817
-		foreach ( $notices as $type => $messages ) {
817
+		foreach ($notices as $type => $messages) {
818 818
 
819
-			if ( ! is_array( $messages ) ) {
819
+			if (!is_array($messages)) {
820 820
 				continue;
821 821
 			}
822 822
 
823
-            $type  = sanitize_key( $type );
824
-			foreach ( $messages as $message ) {
825
-                $message = wp_kses_post( $message );
823
+            $type = sanitize_key($type);
824
+			foreach ($messages as $message) {
825
+                $message = wp_kses_post($message);
826 826
 				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
827 827
             }
828 828
 
829 829
         }
830 830
 
831
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
831
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
832 832
 
833
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
834
-				$url     = wp_nonce_url(
835
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
833
+			if (!is_numeric(wpinv_get_option($page, false))) {
834
+				$url = wp_nonce_url(
835
+					add_query_arg('getpaid-admin-action', 'create_missing_pages'),
836 836
 					'getpaid-nonce',
837 837
 					'getpaid-nonce'
838 838
 				);
839
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
840
-				$message2 = __( 'Generate Pages', 'invoicing' );
839
+				$message  = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing');
840
+				$message2 = __('Generate Pages', 'invoicing');
841 841
 				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
842 842
 				break;
843 843
 			}
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 1 patch
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Paypal Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'single_subscription_group' );
27
+    protected $supports = array('subscription', 'sandbox', 'single_subscription_group');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 *
60 60
 	 * @var array
61 61
 	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
62
+	public $currencies = array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR');
63 63
 
64 64
     /**
65 65
 	 * URL to view a transaction.
@@ -80,15 +80,15 @@  discard block
 block discarded – undo
80 80
 	 */
81 81
 	public function __construct() {
82 82
 
83
-        $this->title                = __( 'PayPal Standard', 'invoicing' );
84
-        $this->method_title         = __( 'PayPal Standard', 'invoicing' );
85
-        $this->checkout_button_text = __( 'Proceed to PayPal', 'invoicing' );
86
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
83
+        $this->title                = __('PayPal Standard', 'invoicing');
84
+        $this->method_title         = __('PayPal Standard', 'invoicing');
85
+        $this->checkout_button_text = __('Proceed to PayPal', 'invoicing');
86
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
87 87
 
88
-		add_filter( 'getpaid_paypal_args', array( $this, 'process_subscription' ), 10, 2 );
89
-        add_filter( 'getpaid_paypal_sandbox_notice', array( $this, 'sandbox_notice' ) );
90
-		add_filter( 'getpaid_get_paypal_connect_url', array( $this, 'maybe_get_connect_url' ), 10, 2 );
91
-		add_action( 'getpaid_authenticated_admin_action_connect_paypal', array( $this, 'connect_paypal' ) );
88
+		add_filter('getpaid_paypal_args', array($this, 'process_subscription'), 10, 2);
89
+        add_filter('getpaid_paypal_sandbox_notice', array($this, 'sandbox_notice'));
90
+		add_filter('getpaid_get_paypal_connect_url', array($this, 'maybe_get_connect_url'), 10, 2);
91
+		add_action('getpaid_authenticated_admin_action_connect_paypal', array($this, 'connect_paypal'));
92 92
 
93 93
         parent::__construct();
94 94
     }
@@ -102,16 +102,16 @@  discard block
 block discarded – undo
102 102
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
103 103
 	 * @return array
104 104
 	 */
105
-	public function process_payment( $invoice, $submission_data, $submission ) {
105
+	public function process_payment($invoice, $submission_data, $submission) {
106 106
 
107 107
         // Get redirect url.
108
-        $paypal_redirect = $this->get_request_url( $invoice );
108
+        $paypal_redirect = $this->get_request_url($invoice);
109 109
 
110 110
         // Add a note about the request url.
111 111
         $invoice->add_note(
112 112
             sprintf(
113
-                __( 'Redirecting to PayPal: %s', 'invoicing' ),
114
-                esc_url( $paypal_redirect )
113
+                __('Redirecting to PayPal: %s', 'invoicing'),
114
+                esc_url($paypal_redirect)
115 115
             ),
116 116
             false,
117 117
             false,
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
         );
120 120
 
121 121
         // Redirect to PayPal
122
-        wp_redirect( $paypal_redirect );
122
+        wp_redirect($paypal_redirect);
123 123
         exit;
124 124
 
125 125
     }
@@ -130,21 +130,21 @@  discard block
 block discarded – undo
130 130
 	 * @param  WPInv_Invoice $invoice Invoice object.
131 131
 	 * @return string
132 132
 	 */
133
-	public function get_request_url( $invoice ) {
133
+	public function get_request_url($invoice) {
134 134
 
135 135
         // Endpoint for this request
136
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
136
+		$this->endpoint = $this->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
137 137
 
138 138
         // Retrieve paypal args.
139
-        $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
139
+        $paypal_args = map_deep($this->get_paypal_args($invoice), 'urlencode');
140 140
 
141
-        if ( $invoice->is_recurring() ) {
141
+        if ($invoice->is_recurring()) {
142 142
             $paypal_args['bn'] = 'GetPaid_Subscribe_WPS_US';
143 143
         } else {
144 144
             $paypal_args['bn'] = 'GetPaid_ShoppingCart_WPS_US';
145 145
         }
146 146
 
147
-        return add_query_arg( $paypal_args, $this->endpoint );
147
+        return add_query_arg($paypal_args, $this->endpoint);
148 148
 
149 149
 	}
150 150
 
@@ -154,25 +154,25 @@  discard block
 block discarded – undo
154 154
 	 * @param  WPInv_Invoice $invoice Invoice object.
155 155
 	 * @return array
156 156
 	 */
157
-	protected function get_paypal_args( $invoice ) {
157
+	protected function get_paypal_args($invoice) {
158 158
 
159 159
         // Whether or not to send the line items as one item.
160
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', true, $invoice );
160
+		$force_one_line_item = apply_filters('getpaid_paypal_force_one_line_item', true, $invoice);
161 161
 
162
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
162
+		if ($invoice->is_recurring() || (wpinv_use_taxes() && wpinv_prices_include_tax())) {
163 163
 			$force_one_line_item = true;
164 164
 		}
165 165
 
166 166
 		$paypal_args = apply_filters(
167 167
 			'getpaid_paypal_args',
168 168
 			array_merge(
169
-				$this->get_transaction_args( $invoice ),
170
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
+				$this->get_transaction_args($invoice),
170
+				$this->get_line_item_args($invoice, $force_one_line_item)
171 171
 			),
172 172
 			$invoice
173 173
 		);
174 174
 
175
-		return $this->fix_request_length( $invoice, $paypal_args );
175
+		return $this->fix_request_length($invoice, $paypal_args);
176 176
     }
177 177
 
178 178
     /**
@@ -181,11 +181,11 @@  discard block
 block discarded – undo
181 181
 	 * @param WPInv_Invoice $invoice Invoice object.
182 182
 	 * @return array
183 183
 	 */
184
-	protected function get_transaction_args( $invoice ) {
184
+	protected function get_transaction_args($invoice) {
185 185
 
186 186
 		return array(
187 187
             'cmd'           => '_cart',
188
-            'business'      => wpinv_get_option( 'paypal_email', false ),
188
+            'business'      => wpinv_get_option('paypal_email', false),
189 189
             'no_shipping'   => '1',
190 190
             'shipping'      => '0',
191 191
             'no_note'       => '1',
@@ -193,16 +193,16 @@  discard block
 block discarded – undo
193 193
             'rm'            => is_ssl() ? 2 : 1,
194 194
             'upload'        => 1,
195 195
             'currency_code' => $invoice->get_currency(), // https://developer.paypal.com/docs/nvp-soap-api/currency-codes/#paypal
196
-            'return'        => esc_url_raw( $this->get_return_url( $invoice ) ),
197
-            'cancel_return' => esc_url_raw( $invoice->get_checkout_payment_url() ),
198
-            'notify_url'    => getpaid_limit_length( $this->notify_url, 255 ),
199
-            'invoice'       => getpaid_limit_length( $invoice->get_number(), 127 ),
196
+            'return'        => esc_url_raw($this->get_return_url($invoice)),
197
+            'cancel_return' => esc_url_raw($invoice->get_checkout_payment_url()),
198
+            'notify_url'    => getpaid_limit_length($this->notify_url, 255),
199
+            'invoice'       => getpaid_limit_length($invoice->get_number(), 127),
200 200
             'custom'        => $invoice->get_id(),
201
-            'first_name'    => getpaid_limit_length( $invoice->get_first_name(), 32 ),
202
-            'last_name'     => getpaid_limit_length( $invoice->get_last_name(), 64 ),
203
-            'country'       => getpaid_limit_length( $invoice->get_country(), 2 ),
204
-            'email'         => getpaid_limit_length( $invoice->get_email(), 127 ),
205
-            'cbt'           => get_bloginfo( 'name' )
201
+            'first_name'    => getpaid_limit_length($invoice->get_first_name(), 32),
202
+            'last_name'     => getpaid_limit_length($invoice->get_last_name(), 64),
203
+            'country'       => getpaid_limit_length($invoice->get_country(), 2),
204
+            'email'         => getpaid_limit_length($invoice->get_email(), 127),
205
+            'cbt'           => get_bloginfo('name')
206 206
         );
207 207
 
208 208
     }
@@ -214,30 +214,30 @@  discard block
 block discarded – undo
214 214
 	 * @param  bool     $force_one_line_item Create only one item for this invoice.
215 215
 	 * @return array
216 216
 	 */
217
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
217
+	protected function get_line_item_args($invoice, $force_one_line_item = false) {
218 218
 
219 219
         // Maybe send invoice as a single item.
220
-		if ( $force_one_line_item ) {
221
-            return $this->get_line_item_args_single_item( $invoice );
220
+		if ($force_one_line_item) {
221
+            return $this->get_line_item_args_single_item($invoice);
222 222
         }
223 223
 
224 224
         // Send each line item individually.
225 225
         $line_item_args = array();
226 226
 
227 227
         // Prepare line items.
228
-        $this->prepare_line_items( $invoice );
228
+        $this->prepare_line_items($invoice);
229 229
 
230 230
         // Add taxes to the cart
231
-        if ( wpinv_use_taxes() && $invoice->is_taxable() ) {
232
-            $line_item_args['tax_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_tax(), 2 );
231
+        if (wpinv_use_taxes() && $invoice->is_taxable()) {
232
+            $line_item_args['tax_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_tax(), 2);
233 233
         }
234 234
 
235 235
         // Add discount.
236
-        if ( $invoice->get_total_discount() > 0 ) {
237
-            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236
+        if ($invoice->get_total_discount() > 0) {
237
+            $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount((float) $invoice->get_total_discount(), 2);
238 238
         }
239 239
 
240
-		return array_merge( $line_item_args, $this->get_line_items() );
240
+		return array_merge($line_item_args, $this->get_line_items());
241 241
 
242 242
     }
243 243
 
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 	 * @param  WPInv_Invoice $invoice Invoice object.
248 248
 	 * @return array
249 249
 	 */
250
-	protected function get_line_item_args_single_item( $invoice ) {
250
+	protected function get_line_item_args_single_item($invoice) {
251 251
 		$this->delete_line_items();
252 252
 
253
-        $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
254
-		$this->add_line_item( $item_name, 1, wpinv_round_amount( (float) $invoice->get_total(), 2, true ), $invoice->get_id() );
253
+        $item_name = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
254
+		$this->add_line_item($item_name, 1, wpinv_round_amount((float) $invoice->get_total(), 2, true), $invoice->get_id());
255 255
 
256 256
 		return $this->get_line_items();
257 257
     }
@@ -275,19 +275,19 @@  discard block
 block discarded – undo
275 275
 	 *
276 276
 	 * @param  WPInv_Invoice $invoice Invoice object.
277 277
 	 */
278
-	protected function prepare_line_items( $invoice ) {
278
+	protected function prepare_line_items($invoice) {
279 279
 		$this->delete_line_items();
280 280
 
281 281
 		// Items.
282
-		foreach ( $invoice->get_items() as $item ) {
282
+		foreach ($invoice->get_items() as $item) {
283 283
 			$amount   = $item->get_price();
284 284
 			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
285
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
285
+			$this->add_line_item($item->get_raw_name(), $quantity, $amount, $item->get_id());
286 286
         }
287 287
 
288 288
         // Fees.
289
-		foreach ( $invoice->get_fees() as $fee => $data ) {
290
-            $this->add_line_item( $fee, 1, wpinv_sanitize_amount( $data['initial_fee'] ) );
289
+		foreach ($invoice->get_fees() as $fee => $data) {
290
+            $this->add_line_item($fee, 1, wpinv_sanitize_amount($data['initial_fee']));
291 291
         }
292 292
 
293 293
     }
@@ -300,15 +300,15 @@  discard block
 block discarded – undo
300 300
 	 * @param  float  $amount Amount.
301 301
 	 * @param  string $item_number Item number.
302 302
 	 */
303
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
304
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
+	protected function add_line_item($item_name, $quantity = 1, $amount = 0.0, $item_number = '') {
304
+		$index = (count($this->line_items) / 4) + 1;
305 305
 
306 306
 		$item = apply_filters(
307 307
 			'getpaid_paypal_line_item',
308 308
 			array(
309
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
309
+				'item_name'   => html_entity_decode(getpaid_limit_length($item_name ? wp_strip_all_tags($item_name) : __('Item', 'invoicing'), 127), ENT_NOQUOTES, 'UTF-8'),
310 310
 				'quantity'    => (float) $quantity,
311
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
311
+				'amount'      => wpinv_sanitize_amount((float) $amount, 2),
312 312
 				'item_number' => $item_number,
313 313
 			),
314 314
 			$item_name,
@@ -317,12 +317,12 @@  discard block
 block discarded – undo
317 317
 			$item_number
318 318
 		);
319 319
 
320
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
321
-        $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320
+		$this->line_items['item_name_' . $index] = getpaid_limit_length($item['item_name'], 127);
321
+        $this->line_items['quantity_' . $index] = $item['quantity'];
322 322
 
323 323
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
324
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'] * $item['quantity'];
325
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324
+		$this->line_items['amount_' . $index]      = $item['amount'] * $item['quantity'];
325
+		$this->line_items['item_number_' . $index] = getpaid_limit_length($item['item_number'], 127);
326 326
     }
327 327
 
328 328
     /**
@@ -334,19 +334,19 @@  discard block
 block discarded – undo
334 334
 	 * @param array    $paypal_args Arguments sent to Paypal in the request.
335 335
 	 * @return array
336 336
 	 */
337
-	protected function fix_request_length( $invoice, $paypal_args ) {
337
+	protected function fix_request_length($invoice, $paypal_args) {
338 338
 		$max_paypal_length = 2083;
339
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
339
+		$query_candidate   = http_build_query($paypal_args, '', '&');
340 340
 
341
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
341
+		if (strlen($this->endpoint . $query_candidate) <= $max_paypal_length) {
342 342
 			return $paypal_args;
343 343
 		}
344 344
 
345 345
 		return apply_filters(
346 346
 			'getpaid_paypal_args',
347 347
 			array_merge(
348
-				$this->get_transaction_args( $invoice ),
349
-				$this->get_line_item_args( $invoice, true )
348
+				$this->get_transaction_args($invoice),
349
+				$this->get_line_item_args($invoice, true)
350 350
 			),
351 351
 			$invoice
352 352
 		);
@@ -359,10 +359,10 @@  discard block
 block discarded – undo
359 359
 	 * @param  array $paypal_args PayPal args.
360 360
 	 * @param  WPInv_Invoice    $invoice Invoice object.
361 361
 	 */
362
-	public function process_subscription( $paypal_args, $invoice ) {
362
+	public function process_subscription($paypal_args, $invoice) {
363 363
 
364 364
         // Make sure this is a subscription.
365
-        if ( ! $invoice->is_recurring() || ! $subscription = getpaid_get_invoice_subscription( $invoice ) ) {
365
+        if (!$invoice->is_recurring() || !$subscription = getpaid_get_invoice_subscription($invoice)) {
366 366
             return $paypal_args;
367 367
         }
368 368
 
@@ -370,17 +370,17 @@  discard block
 block discarded – undo
370 370
         $paypal_args['cmd'] = '_xclick-subscriptions';
371 371
 
372 372
         // Subscription name.
373
-        $paypal_args['item_name'] = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
373
+        $paypal_args['item_name'] = sprintf(__('Invoice #%s', 'invoicing'), $invoice->get_number());
374 374
 
375 375
         // Get subscription args.
376
-        $period                 = strtoupper( substr( $subscription->get_period(), 0, 1) );
376
+        $period                 = strtoupper(substr($subscription->get_period(), 0, 1));
377 377
         $interval               = (int) $subscription->get_frequency();
378 378
         $bill_times             = (int) $subscription->get_bill_times();
379
-        $initial_amount         = (float) wpinv_sanitize_amount( $invoice->get_initial_total(), 2 );
380
-        $recurring_amount       = (float) wpinv_sanitize_amount( $invoice->get_recurring_total(), 2 );
381
-        $subscription_item      = $invoice->get_recurring( true );
379
+        $initial_amount         = (float) wpinv_sanitize_amount($invoice->get_initial_total(), 2);
380
+        $recurring_amount       = (float) wpinv_sanitize_amount($invoice->get_recurring_total(), 2);
381
+        $subscription_item      = $invoice->get_recurring(true);
382 382
 
383
-        if ( $subscription_item->has_free_trial() ) {
383
+        if ($subscription_item->has_free_trial()) {
384 384
 
385 385
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
386 386
 
@@ -390,28 +390,28 @@  discard block
 block discarded – undo
390 390
 			// Trial period.
391 391
 			$paypal_args['t1'] = $subscription_item->get_trial_period();
392 392
 
393
-        } else if ( $initial_amount != $recurring_amount ) {
393
+        } else if ($initial_amount != $recurring_amount) {
394 394
 
395 395
             // No trial period, but initial amount includes a sign-up fee and/or other items, so charge it as a separate period.
396 396
 
397
-            if ( 1 == $bill_times ) {
397
+            if (1 == $bill_times) {
398 398
                 $param_number = 3;
399 399
             } else {
400 400
                 $param_number = 1;
401 401
             }
402 402
 
403
-            $paypal_args[ 'a' . $param_number ] = $initial_amount ? $initial_amount : 0;
403
+            $paypal_args['a' . $param_number] = $initial_amount ? $initial_amount : 0;
404 404
 
405 405
             // Sign Up interval
406
-            $paypal_args[ 'p' . $param_number ] = $interval;
406
+            $paypal_args['p' . $param_number] = $interval;
407 407
 
408 408
             // Sign Up unit of duration
409
-            $paypal_args[ 't' . $param_number ] = $period;
409
+            $paypal_args['t' . $param_number] = $period;
410 410
 
411 411
         }
412 412
 
413 413
         // We have a recurring payment
414
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
414
+		if (!isset($param_number) || 1 == $param_number) {
415 415
 
416 416
 			// Subscription price
417 417
 			$paypal_args['a3'] = $recurring_amount;
@@ -425,7 +425,7 @@  discard block
 block discarded – undo
425 425
         }
426 426
 
427 427
         // Recurring payments
428
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
428
+		if (1 == $bill_times || ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial() && 2 == $bill_times)) {
429 429
 
430 430
 			// Non-recurring payments
431 431
 			$paypal_args['src'] = 0;
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 
435 435
 			$paypal_args['src'] = 1;
436 436
 
437
-			if ( $bill_times > 0 ) {
437
+			if ($bill_times > 0) {
438 438
 
439 439
 				// An initial period is being used to charge a sign-up fee
440
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
440
+				if ($initial_amount != $recurring_amount && !$subscription_item->has_free_trial()) {
441 441
 					$bill_times--;
442 442
 				}
443 443
 
444 444
                 // Make sure it's not over the max of 52
445
-                $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
445
+                $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
446 446
 
447 447
 			}
448 448
         }
@@ -451,10 +451,10 @@  discard block
 block discarded – undo
451 451
         $paypal_args['rm'] = 2;
452 452
 
453 453
         // Get rid of redudant items.
454
-        foreach ( array( 'item_name_1', 'quantity_1', 'amount_1', 'item_number_1' ) as $arg ) {
454
+        foreach (array('item_name_1', 'quantity_1', 'amount_1', 'item_number_1') as $arg) {
455 455
 
456
-            if ( isset( $paypal_args[ $arg ] ) ) {
457
-                unset( $paypal_args[ $arg ] );
456
+            if (isset($paypal_args[$arg])) {
457
+                unset($paypal_args[$arg]);
458 458
             }
459 459
 
460 460
         }
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 	 * @return void
474 474
 	 */
475 475
 	public function verify_ipn() {
476
-        new GetPaid_Paypal_Gateway_IPN_Handler( $this );
476
+        new GetPaid_Paypal_Gateway_IPN_Handler($this);
477 477
     }
478 478
 
479 479
     /**
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function sandbox_notice() {
483 483
 
484 484
         return sprintf(
485
-			__( 'SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing' ),
485
+			__('SANDBOX ENABLED. You can use sandbox testing accounts only. See the %sPayPal Sandbox Testing Guide%s for more details.', 'invoicing'),
486 486
 			'<a href="https://developer.paypal.com/docs/classic/lifecycle/ug_sandbox/">',
487 487
 			'</a>'
488 488
 		);
@@ -494,32 +494,32 @@  discard block
 block discarded – undo
494 494
 	 *
495 495
 	 * @param array $admin_settings
496 496
 	 */
497
-	public function admin_settings( $admin_settings ) {
497
+	public function admin_settings($admin_settings) {
498 498
 
499 499
         $currencies = sprintf(
500
-            __( 'Supported Currencies: %s', 'invoicing' ),
501
-            implode( ', ', $this->currencies )
500
+            __('Supported Currencies: %s', 'invoicing'),
501
+            implode(', ', $this->currencies)
502 502
         );
503 503
 
504 504
         $admin_settings['paypal_active']['desc'] .= " ($currencies)";
505
-        $admin_settings['paypal_desc']['std']     = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
505
+        $admin_settings['paypal_desc']['std']     = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
506 506
 
507 507
 		// Access tokens.
508
-        $live_account    = wpinv_get_option( 'paypal_live_access_token' );
509
-        $sandbox_account = wpinv_get_option( 'paypal_test_access_token' );
508
+        $live_account    = wpinv_get_option('paypal_live_access_token');
509
+        $sandbox_account = wpinv_get_option('paypal_test_access_token');
510 510
 
511 511
 		$admin_settings['paypal_connect'] = array(
512 512
 			'type'       => 'raw_html',
513 513
 			'id'         => 'paypal_connect',
514
-			'name'       => __( 'Connect to PayPal', 'invoicing' ),
514
+			'name'       => __('Connect to PayPal', 'invoicing'),
515 515
 			'desc'       => sprintf(
516 516
 				'<div class="wpinv-paypal-connect-live"><a class="button button-primary" href="%s">%s</a><br><strong style="color: green">%s</strong></div><div class="wpinv-paypal-connect-sandbox"><a class="button button-primary" href="%s">%s</a><br><strong style="color: green">%s</strong></div>%s',
517
-				esc_url( self::get_connect_url( false ) ),
518
-				__( 'Connect to PayPal', 'invoicing' ),
519
-				__( 'Connected', 'invoicing' ),
520
-				esc_url( self::get_connect_url( true ) ),
521
-				__( 'Connect to PayPal Sandox', 'invoicing' ),
522
-				__( 'Connected', 'invoicing' ),
517
+				esc_url(self::get_connect_url(false)),
518
+				__('Connect to PayPal', 'invoicing'),
519
+				__('Connected', 'invoicing'),
520
+				esc_url(self::get_connect_url(true)),
521
+				__('Connect to PayPal Sandox', 'invoicing'),
522
+				__('Connected', 'invoicing'),
523 523
 				$this->get_js()
524 524
 			),
525 525
 		);
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 		$admin_settings['disable_paypal_connect'] = array(
528 528
 			'type'       => 'checkbox',
529 529
 			'id'         => 'disable_paypal_connect',
530
-			'name'       => __( 'Manual Mode', 'invoicing' ),
531
-			'desc'       => __( 'Manually enter your credentials', 'invoicing' ),
530
+			'name'       => __('Manual Mode', 'invoicing'),
531
+			'desc'       => __('Manually enter your credentials', 'invoicing'),
532 532
 			'std'        => false,
533 533
 		);
534 534
 
@@ -536,67 +536,67 @@  discard block
 block discarded – undo
536 536
             'type'  => 'text',
537 537
 			'class' => 'live-auth-data',
538 538
             'id'    => 'paypal_email',
539
-            'name'  => __( 'Live Email Address', 'invoicing' ),
540
-            'desc'  => __( 'The email address of your PayPal account.', 'invoicing' ),
539
+            'name'  => __('Live Email Address', 'invoicing'),
540
+            'desc'  => __('The email address of your PayPal account.', 'invoicing'),
541 541
         );
542 542
 
543 543
 		$admin_settings['paypal_merchant_id'] = array(
544 544
             'type'  => 'text',
545 545
 			'class' => 'live-auth-data',
546 546
             'id'    => 'paypal_merchant_id',
547
-            'name'  => __( 'Live Merchant ID', 'invoicing' ),
547
+            'name'  => __('Live Merchant ID', 'invoicing'),
548 548
         );
549 549
 
550 550
 		$admin_settings['paypal_client_id'] = array(
551 551
             'type'  => 'text',
552 552
 			'class' => 'live-auth-data',
553 553
             'id'    => 'paypal_client_id',
554
-            'name'  => __( 'Live Client ID', 'invoicing' ),
554
+            'name'  => __('Live Client ID', 'invoicing'),
555 555
         );
556 556
 
557 557
 		$admin_settings['paypal_client_secret'] = array(
558 558
             'type'  => 'text',
559 559
 			'class' => 'live-auth-data',
560 560
             'id'    => 'paypal_client_secret',
561
-            'name'  => __( 'Live Client Secret', 'invoicing' ),
561
+            'name'  => __('Live Client Secret', 'invoicing'),
562 562
         );
563 563
 
564 564
 		$admin_settings['paypal_sandbox_email'] = array(
565 565
             'type'  => 'text',
566 566
 			'class' => 'sandbox-auth-data',
567 567
             'id'    => 'paypal_sandbox_email',
568
-            'name'  => __( 'Sandbox Email Address', 'invoicing' ),
569
-            'desc'  => __( 'The email address of your sandbox PayPal account.', 'invoicing' ),
570
-			'std'   => wpinv_get_option( 'paypal_email', '' ),
568
+            'name'  => __('Sandbox Email Address', 'invoicing'),
569
+            'desc'  => __('The email address of your sandbox PayPal account.', 'invoicing'),
570
+			'std'   => wpinv_get_option('paypal_email', ''),
571 571
         );
572 572
 
573 573
 		$admin_settings['paypal_sandbox_merchant_id'] = array(
574 574
             'type'  => 'text',
575 575
 			'class' => 'sandbox-auth-data',
576 576
             'id'    => 'paypal_sandbox_merchant_id',
577
-            'name'  => __( 'Sandbox Merchant ID', 'invoicing' ),
577
+            'name'  => __('Sandbox Merchant ID', 'invoicing'),
578 578
         );
579 579
 
580 580
 		$admin_settings['paypal_sandbox_client_id'] = array(
581 581
             'type'  => 'text',
582 582
 			'class' => 'sandbox-auth-data',
583 583
             'id'    => 'paypal_sandbox_client_id',
584
-            'name'  => __( 'Sandbox Client ID', 'invoicing' ),
584
+            'name'  => __('Sandbox Client ID', 'invoicing'),
585 585
         );
586 586
 
587 587
 		$admin_settings['paypal_sandbox_client_secret'] = array(
588 588
             'type'  => 'text',
589 589
 			'class' => 'sandbox-auth-data',
590 590
             'id'    => 'paypal_sandbox_client_secret',
591
-            'name'  => __( 'Sandbox Client Secret', 'invoicing' ),
591
+            'name'  => __('Sandbox Client Secret', 'invoicing'),
592 592
         );
593 593
 
594 594
         $admin_settings['paypal_ipn_url'] = array(
595 595
             'type'     => 'ipn_url',
596 596
             'id'       => 'paypal_ipn_url',
597
-            'name'     => __( 'IPN Url', 'invoicing' ),
597
+            'name'     => __('IPN Url', 'invoicing'),
598 598
             'std'      => $this->notify_url,
599
-            'desc'     => __( "If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing' ) . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
599
+            'desc'     => __("If you've not enabled IPNs in your paypal account, use the above URL to enable them.", 'invoicing') . ' <a href="https://developer.paypal.com/docs/api-basics/notifications/ipn/"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
600 600
             'readonly' => true,
601 601
         );
602 602
 
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
      * @param array $data
611 611
      * @return string
612 612
 	 */
613
-	public static function maybe_get_connect_url( $data ) {
614
-		return self::get_connect_url( false, urldecode( $data['redirect'] ) );
613
+	public static function maybe_get_connect_url($data) {
614
+		return self::get_connect_url(false, urldecode($data['redirect']));
615 615
 	}
616 616
 
617 617
 	/**
@@ -622,25 +622,25 @@  discard block
 block discarded – undo
622 622
 	 * @param string $redirect
623 623
      * @return string
624 624
 	 */
625
-	public static function get_connect_url( $is_sandbox, $redirect = '' ) {
625
+	public static function get_connect_url($is_sandbox, $redirect = '') {
626 626
 
627 627
         $redirect_url = add_query_arg(
628 628
             array(
629 629
                 'getpaid-admin-action' => 'connect_paypal',
630 630
                 'page'                 => 'wpinv-settings',
631
-                'live_mode'            => (int) empty( $is_sandbox ),
631
+                'live_mode'            => (int) empty($is_sandbox),
632 632
                 'tab'                  => 'gateways',
633 633
                 'section'              => 'paypal',
634
-                'getpaid-nonce'        => wp_create_nonce( 'getpaid-nonce' ),
635
-				'redirect'             => urlencode( $redirect ),
634
+                'getpaid-nonce'        => wp_create_nonce('getpaid-nonce'),
635
+				'redirect'             => urlencode($redirect),
636 636
             ),
637
-            admin_url( 'admin.php' )
637
+            admin_url('admin.php')
638 638
         );
639 639
 
640 640
         return add_query_arg(
641 641
             array(
642
-                'live_mode'    => (int) empty( $is_sandbox ),
643
-                'redirect_url' => urlencode( str_replace( '&amp;', '&', $redirect_url ) )
642
+                'live_mode'    => (int) empty($is_sandbox),
643
+                'redirect_url' => urlencode(str_replace('&amp;', '&', $redirect_url))
644 644
             ),
645 645
             'https://ayecode.io/oauth/paypal'
646 646
         );
@@ -704,26 +704,26 @@  discard block
 block discarded – undo
704 704
 	 * @param array $data Connection data.
705 705
 	 * @return void
706 706
 	 */
707
-	public function connect_paypal( $data ) {
707
+	public function connect_paypal($data) {
708 708
 
709 709
 		$sandbox      = $this->is_sandbox();
710
-		$data         = wp_unslash( $data );
711
-		$access_token = empty( $data['access_token'] ) ? '' : sanitize_text_field( $data['access_token'] );
710
+		$data         = wp_unslash($data);
711
+		$access_token = empty($data['access_token']) ? '' : sanitize_text_field($data['access_token']);
712 712
 
713
-		if ( isset( $data['live_mode'] ) ) {
714
-			$sandbox = empty( $data['live_mode'] );
713
+		if (isset($data['live_mode'])) {
714
+			$sandbox = empty($data['live_mode']);
715 715
 		}
716 716
 
717
-		wpinv_update_option( 'stripe_sandbox', (int) $sandbox );
718
-		wpinv_update_option( 'stripe_active', 1 );
717
+		wpinv_update_option('stripe_sandbox', (int) $sandbox);
718
+		wpinv_update_option('stripe_active', 1);
719 719
 
720
-		if ( ! empty( $data['error_description'] ) ) {
721
-			getpaid_admin()->show_error( wp_kses_post( urldecode( $data['error_description'] ) ) );
720
+		if (!empty($data['error_description'])) {
721
+			getpaid_admin()->show_error(wp_kses_post(urldecode($data['error_description'])));
722 722
 		} else {
723 723
 
724 724
 			// Retrieve the user info.
725 725
 			$user_info = wp_remote_get(
726
-				! $sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
726
+				!$sandbox ? 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' : 'https://api-m.sandbox.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1',
727 727
 				array(
728 728
 
729 729
 					'headers' => array(
@@ -734,23 +734,23 @@  discard block
 block discarded – undo
734 734
 				)
735 735
 			);
736 736
 
737
-			if ( is_wp_error( $user_info ) ) {
738
-				getpaid_admin()->show_error( wp_kses_post( $user_info->get_error_message() ) );
737
+			if (is_wp_error($user_info)) {
738
+				getpaid_admin()->show_error(wp_kses_post($user_info->get_error_message()));
739 739
 			} else {
740 740
 
741 741
 				// Create application.
742
-				$user_info = json_decode( wp_remote_retrieve_body( $user_info ) );
742
+				$user_info = json_decode(wp_remote_retrieve_body($user_info));
743 743
 				$app       = wp_remote_post(
744
-					! $sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
744
+					!$sandbox ? 'https://api-m.paypal.com/v1/identity/applications' : 'https://api-m.sandbox.paypal.com/v1/identity/applications',
745 745
 					array(
746 746
 
747 747
 						'body'    => array(
748 748
 							'application_type' => 'web',
749 749
 							'redirect_uris'    => array(
750
-								add_query_arg( 'getpaid_oauth', 'paypal', home_url() ),
750
+								add_query_arg('getpaid_oauth', 'paypal', home_url()),
751 751
 							),
752 752
 							'client_name'      => 'GetPaid',
753
-							'contacts'         => array( $user_info->emails[0]->value ),
753
+							'contacts'         => array($user_info->emails[0]->value),
754 754
 							'payer_id'         => $user_info->payer_id,
755 755
 							'migrated_app'     => '',
756 756
 						),
@@ -762,29 +762,29 @@  discard block
 block discarded – undo
762 762
 					)
763 763
 				);
764 764
 
765
-				if ( is_wp_error( $app ) ) {
766
-					getpaid_admin()->show_error( wp_kses_post( $app->get_error_message() ) );
765
+				if (is_wp_error($app)) {
766
+					getpaid_admin()->show_error(wp_kses_post($app->get_error_message()));
767 767
 				} else {
768 768
 
769
-					$app = json_decode( $app );
770
-					if ( $sandbox ) {
771
-						wpinv_update_option( 'paypal_sandbox_email', sanitize_email( $user_info->emails[0]->value ) );
772
-						wpinv_update_option( 'paypal_sandbox_merchant_id', '' );
773
-						wpinv_update_option( 'paypal_sandbox_client_id', sanitize_text_field( '' ) );
774
-						wpinv_update_option( 'paypal_sandbox_client_secret', sanitize_text_field( '' ) );
775
-						wpinv_update_option( 'paypal_sandbox_client_secret_expires_at', sanitize_text_field( '' ) );
776
-						wpinv_update_option( 'paypal_sandbox_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
777
-						set_transient( 'getpaid_paypal_sandbox_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
778
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal sandbox account', 'wpinv-stripe' ) );
769
+					$app = json_decode($app);
770
+					if ($sandbox) {
771
+						wpinv_update_option('paypal_sandbox_email', sanitize_email($user_info->emails[0]->value));
772
+						wpinv_update_option('paypal_sandbox_merchant_id', '');
773
+						wpinv_update_option('paypal_sandbox_client_id', sanitize_text_field(''));
774
+						wpinv_update_option('paypal_sandbox_client_secret', sanitize_text_field(''));
775
+						wpinv_update_option('paypal_sandbox_client_secret_expires_at', sanitize_text_field(''));
776
+						wpinv_update_option('paypal_sandbox_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
777
+						set_transient('getpaid_paypal_sandbox_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
778
+						getpaid_admin()->show_success(__('Successfully connected your PayPal sandbox account', 'wpinv-stripe'));
779 779
 					} else {
780
-						wpinv_update_option( 'paypal_email', sanitize_email( $user_info->emails[0]->value ) );
781
-						wpinv_update_option( 'paypal_merchant_id', '' );
782
-						wpinv_update_option( 'paypal_client_id', sanitize_text_field( '' ) );
783
-						wpinv_update_option( 'paypal_client_secret', sanitize_text_field( '' ) );
784
-						wpinv_update_option( 'paypal_client_secret_expires_at', sanitize_text_field( '' ) );
785
-						wpinv_update_option( 'paypal_refresh_token', sanitize_text_field( urldecode( $data['refresh_token'] ) ) );
786
-						set_transient( 'getpaid_paypal_access_token', sanitize_text_field( urldecode( $data['access_token'] ) ), (int) $data['expires_in'] );
787
-						getpaid_admin()->show_success( __( 'Successfully connected your PayPal account', 'wpinv-stripe' ) );
780
+						wpinv_update_option('paypal_email', sanitize_email($user_info->emails[0]->value));
781
+						wpinv_update_option('paypal_merchant_id', '');
782
+						wpinv_update_option('paypal_client_id', sanitize_text_field(''));
783
+						wpinv_update_option('paypal_client_secret', sanitize_text_field(''));
784
+						wpinv_update_option('paypal_client_secret_expires_at', sanitize_text_field(''));
785
+						wpinv_update_option('paypal_refresh_token', sanitize_text_field(urldecode($data['refresh_token'])));
786
+						set_transient('getpaid_paypal_access_token', sanitize_text_field(urldecode($data['access_token'])), (int) $data['expires_in']);
787
+						getpaid_admin()->show_success(__('Successfully connected your PayPal account', 'wpinv-stripe'));
788 788
 					}
789 789
 
790 790
 				}
@@ -793,8 +793,8 @@  discard block
 block discarded – undo
793 793
 
794 794
 		}
795 795
 
796
-		$redirect = empty( $data['redirect'] ) ? admin_url( 'admin.php?page=wpinv-settings&tab=gateways&section=paypal' ) : urldecode( $data['redirect'] );
797
-		wp_redirect( $redirect );
796
+		$redirect = empty($data['redirect']) ? admin_url('admin.php?page=wpinv-settings&tab=gateways&section=paypal') : urldecode($data['redirect']);
797
+		wp_redirect($redirect);
798 798
 		exit;
799 799
 	}
800 800
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin-setup-wizard.php 1 patch
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
  * @version     2.4.0
11 11
  * @info        GetPaid Setup Wizard.
12 12
  */
13
-defined( 'ABSPATH' ) || exit;
13
+defined('ABSPATH') || exit;
14 14
 
15 15
 /**
16 16
  * GetPaid_Admin_Setup_Wizard class.
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	 */
45 45
 	public function __construct() {
46 46
 
47
-		if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) {
48
-			add_action( 'admin_menu', array( $this, 'add_menu' ) );
49
-			add_action( 'current_screen', array( $this, 'setup_wizard' ) );
47
+		if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) {
48
+			add_action('admin_menu', array($this, 'add_menu'));
49
+			add_action('current_screen', array($this, 'setup_wizard'));
50 50
 		}
51 51
 
52 52
 	}
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 	 * @since 2.4.0
58 58
 	 */
59 59
 	public function add_menu() {
60
-		add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' );
60
+		add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', '');
61 61
 	}
62 62
 
63 63
 	/**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 */
68 68
 	public function setup_wizard() {
69 69
 
70
-		if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) {
70
+		if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) {
71 71
 			$this->setup_globals();
72 72
 			$this->maybe_save_current_step();
73 73
 			$this->display_wizard();
@@ -94,8 +94,8 @@  discard block
 block discarded – undo
94 94
 	 * @since 2.4.0
95 95
 	 */
96 96
 	protected function maybe_save_current_step() {
97
-		if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) {
98
-			call_user_func( $this->steps[ $this->step ]['handler'], $this );
97
+		if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) {
98
+			call_user_func($this->steps[$this->step]['handler'], $this);
99 99
 		}
100 100
 	}
101 101
 
@@ -110,44 +110,44 @@  discard block
 block discarded – undo
110 110
 		$steps = array(
111 111
 
112 112
 			'introduction'     => array(
113
-				'name'    => __( 'Introduction', 'invoicing' ),
114
-				'view'    => array( $this, 'setup_introduction' ),
113
+				'name'    => __('Introduction', 'invoicing'),
114
+				'view'    => array($this, 'setup_introduction'),
115 115
 				'handler' => '',
116 116
 			),
117 117
 
118 118
 			'business_details'             => array(
119
-				'name'    => __( "Business Details", 'invoicing' ),
120
-				'view'    => array( $this, 'setup_business' ),
119
+				'name'    => __("Business Details", 'invoicing'),
120
+				'view'    => array($this, 'setup_business'),
121 121
 				'handler' => '',
122 122
 			),
123 123
 
124 124
 			'currency' => array(
125
-				'name'    => __( 'Currency', 'invoicing' ),
126
-				'view'    => array( $this, 'setup_currency' ),
125
+				'name'    => __('Currency', 'invoicing'),
126
+				'view'    => array($this, 'setup_currency'),
127 127
 				'handler' => '',
128 128
 			),
129 129
 
130 130
 			'payments'        => array(
131
-				'name'    => __( 'Payment Gateways', 'invoicing' ),
132
-				'view'    => array( $this, 'setup_payments' ),
133
-				'handler' => array( $this, 'setup_payments_save' ),
131
+				'name'    => __('Payment Gateways', 'invoicing'),
132
+				'view'    => array($this, 'setup_payments'),
133
+				'handler' => array($this, 'setup_payments_save'),
134 134
 			),
135 135
 
136 136
 			'recommend'          => array(
137
-				'name'    => __( 'Recommend', 'invoicing' ),
138
-				'view'    => array( $this, 'setup_recommend' ),
137
+				'name'    => __('Recommend', 'invoicing'),
138
+				'view'    => array($this, 'setup_recommend'),
139 139
 				'handler' => '',
140 140
 			),
141 141
 
142 142
 			'next_steps'       => array(
143
-				'name'    => __( 'Get Paid', 'invoicing' ),
144
-				'view'    => array( $this, 'setup_ready' ),
143
+				'name'    => __('Get Paid', 'invoicing'),
144
+				'view'    => array($this, 'setup_ready'),
145 145
 				'handler' => '',
146 146
 			),
147 147
 
148 148
 		);
149 149
 
150
-		return apply_filters( 'getpaid_setup_wizard_steps', $steps );
150
+		return apply_filters('getpaid_setup_wizard_steps', $steps);
151 151
 
152 152
 	}
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @return string
159 159
 	 */
160 160
 	protected function get_current_step() {
161
-		$step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : '';
162
-		return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) );
161
+		$step = isset($_GET['step']) ? sanitize_key($_GET['step']) : '';
162
+		return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps));
163 163
 	}
164 164
 
165 165
 	/**
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 
173 173
 		$previous = false;
174 174
 		$current  = $this->step;
175
-		foreach ( array_keys( $this->steps ) as $step ) {
176
-			if ( $current === $step ) {
175
+		foreach (array_keys($this->steps) as $step) {
176
+			if ($current === $step) {
177 177
 				return $previous;
178 178
 			}
179 179
 
@@ -193,13 +193,13 @@  discard block
 block discarded – undo
193 193
 
194 194
 		$on_current = false;
195 195
 		$current    = $this->step;
196
-		foreach ( array_keys( $this->steps ) as $step ) {
196
+		foreach (array_keys($this->steps) as $step) {
197 197
 
198
-			if ( $on_current ) {
198
+			if ($on_current) {
199 199
 				return $step;
200 200
 			}
201 201
 
202
-			if ( $current === $step ) {
202
+			if ($current === $step) {
203 203
 				return $on_current = true;
204 204
 			}
205 205
 
@@ -228,8 +228,8 @@  discard block
 block discarded – undo
228 228
 		$steps     = $this->steps;
229 229
 		$current   = $this->step;
230 230
 		$next_step = $this->next_step;
231
-		array_shift( $steps );
232
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php';
231
+		array_shift($steps);
232
+		include plugin_dir_path(__FILE__) . 'views/wizard-header.php';
233 233
 	}
234 234
 
235 235
 	/**
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		?>
242 242
 			<div class="gp-setup-content rowx mw-100 text-center mb-3">
243 243
 				<div class="col-12 col-md-5 m-auto">
244
-					<?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?>
244
+					<?php call_user_func($this->steps[$this->step]['view'], $this); ?>
245 245
 				</div>
246 246
 			</div>
247 247
 		<?php
@@ -254,9 +254,9 @@  discard block
 block discarded – undo
254 254
 	 */
255 255
 	public function display_footer() {
256 256
 
257
-		if ( isset( $_GET['step'] ) ) {
258
-			$next_url = esc_url( $this->get_next_step_link() );
259
-			$label    = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' );
257
+		if (isset($_GET['step'])) {
258
+			$next_url = esc_url($this->get_next_step_link());
259
+			$label    = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing');
260 260
 
261 261
 			echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . $next_url . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . $label . '</a></p>';
262 262
 		}
@@ -271,7 +271,7 @@  discard block
 block discarded – undo
271 271
 	 */
272 272
 	public function setup_introduction() {
273 273
 		$next_url = $this->get_next_step_link();
274
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php';
274
+		include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php';
275 275
 	}
276 276
 
277 277
 	/**
@@ -284,22 +284,22 @@  discard block
 block discarded – undo
284 284
 	 *                      Empty string on failure.
285 285
 	 * @since 3.0.0
286 286
 	 */
287
-	public function get_next_step_link( $step = '' ) {
288
-		if ( ! $step ) {
287
+	public function get_next_step_link($step = '') {
288
+		if (!$step) {
289 289
 			$step = $this->step;
290 290
 		}
291 291
 
292
-		$keys = array_keys( $this->steps );
293
-		if ( end( $keys ) === $step ) {
292
+		$keys = array_keys($this->steps);
293
+		if (end($keys) === $step) {
294 294
 			return admin_url();
295 295
 		}
296 296
 
297
-		$step_index = array_search( $step, $keys );
298
-		if ( false === $step_index ) {
297
+		$step_index = array_search($step, $keys);
298
+		if (false === $step_index) {
299 299
 			return '';
300 300
 		}
301 301
 
302
-		return remove_query_arg('settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ));
302
+		return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1]));
303 303
 	}
304 304
 
305 305
 	/**
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 		$wizard   = $this;
313 313
 		$page     = 'wpinv_settings_general_main';
314 314
 		$section  = 'wpinv_settings_general_main';
315
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
315
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
316 316
 	}
317 317
 
318 318
 	/**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 		$wizard   = $this;
326 326
 		$page     = 'wpinv_settings_general_currency_section';
327 327
 		$section  = 'wpinv_settings_general_currency_section';
328
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php';
328
+		include plugin_dir_path(__FILE__) . 'views/wizard-settings.php';
329 329
 	}
330 330
 
331 331
 	/**
@@ -336,35 +336,35 @@  discard block
 block discarded – undo
336 336
 	public function setup_recommend() {
337 337
 		$next_url            = $this->get_next_step_link();
338 338
 		$recommended_plugins = self::get_recommend_wp_plugins();
339
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php';
339
+		include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php';
340 340
 	}
341 341
 
342 342
 	/**
343 343
 	 * A list of recommended wp.org plugins.
344 344
 	 * @return array
345 345
 	 */
346
-	public static function get_recommend_wp_plugins(){
346
+	public static function get_recommend_wp_plugins() {
347 347
 		return array(
348 348
 			'ayecode-connect' => array(
349 349
 				'file'   => 'ayecode-connect/ayecode-connect.php',
350 350
 				'url'    => 'https://wordpress.org/plugins/ayecode-connect/',
351 351
 				'slug'   => 'ayecode-connect',
352 352
 				'name'   => 'AyeCode Connect',
353
-				'desc'   => __( 'Documentation and Support from within your WordPress admin.', 'geodirectory' ),
353
+				'desc'   => __('Documentation and Support from within your WordPress admin.', 'geodirectory'),
354 354
 			),
355 355
 			'invoicing-quotes' => array(
356 356
 				'file'   => 'invoicing-quotes/wpinv-quote.php',
357 357
 				'url'    => 'https://wordpress.org/plugins/invoicing-quotes/',
358 358
 				'slug'   => 'invoicing-quotes',
359 359
 				'name'   => 'Customer Quotes',
360
-				'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.','geodirectory'),
360
+				'desc'   => __('Create & Send Quotes to Customers and have them accept and pay.', 'geodirectory'),
361 361
 			),
362 362
 			'userswp'    => array(
363 363
 				'file'   => 'userswp/userswp.php',
364 364
 				'url'    => 'https://wordpress.org/plugins/userswp/',
365 365
 				'slug'   => 'userswp',
366 366
 				'name'   => 'UsersWP',
367
-				'desc'   => __('Frontend user login and registration as well as slick profile pages.','geodirectory'),
367
+				'desc'   => __('Frontend user login and registration as well as slick profile pages.', 'geodirectory'),
368 368
 			),
369 369
 		);
370 370
 	}
@@ -376,7 +376,7 @@  discard block
 block discarded – undo
376 376
 	 */
377 377
 	public function setup_payments() {
378 378
 		$next_url = $this->get_next_step_link();
379
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php';
379
+		include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php';
380 380
 	}
381 381
 
382 382
 	/**
@@ -387,9 +387,9 @@  discard block
 block discarded – undo
387 387
 	 * @since 2.0.0
388 388
 	 */
389 389
 	public function setup_payments_save() {
390
-		check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' );
391
-		wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) );
392
-		wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
390
+		check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard');
391
+		wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway']));
392
+		wp_redirect(esc_url_raw($this->get_next_step_link()));
393 393
 		exit;
394 394
 	}
395 395
 
@@ -399,7 +399,7 @@  discard block
 block discarded – undo
399 399
 	 * @since 2.0.0
400 400
 	 */
401 401
 	public function setup_ready() {
402
-		include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php';
402
+		include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php';
403 403
 	}
404 404
 
405 405
 }
Please login to merge, or discard this patch.
includes/admin/views/wizard-settings.php 1 patch
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
     <div class="text-center pb-3 mt-5">
13 13
         <a class=" text-decoration-none" href="https://wpgetpaid.com/">
14 14
             <span class="text-black-50">
15
-                <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png';?>" />
15
+                <img class="ml-n3x" src="<?php echo WPINV_PLUGIN_URL . 'assets/images/getpaid-logo.png'; ?>" />
16 16
             </span>
17 17
         </a>
18 18
 	</div>
19 19
 
20 20
     <form method="post" class="text-left card-body" action="options.php">
21
-        <?php settings_fields( 'wpinv_settings' ); ?>
22
-        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>">
21
+        <?php settings_fields('wpinv_settings'); ?>
22
+        <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>">
23 23
 
24 24
         <table class="gp-setup-maps w-100 " cellspacing="0">
25 25
             <tbody>
@@ -27,28 +27,28 @@  discard block
 block discarded – undo
27 27
 
28 28
                     global $wp_settings_fields;
29 29
 
30
-                    if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) {
31
-                        $settings =  $wp_settings_fields[ $page ][ $section ];
30
+                    if (isset($wp_settings_fields[$page][$section])) {
31
+                        $settings = $wp_settings_fields[$page][$section];
32 32
 
33
-                        foreach ( $settings as $field ) {
33
+                        foreach ($settings as $field) {
34 34
 
35
-                            $name      = esc_attr( $field['id'] );
36
-                            $id        = sanitize_key( $name );
35
+                            $name      = esc_attr($field['id']);
36
+                            $id        = sanitize_key($name);
37 37
                             $class     = '';
38
-                            $value     = isset( $field['args']['std'] ) ? $field['args']['std'] : '';
39
-                            $value     = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) );
40
-                            $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : '';
41
-                            $type      = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) );
42
-                            $label     = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : '';
43
-                            $options   = isset( $field['args']['options'] ) ? $field['args']['options'] : array();
38
+                            $value     = isset($field['args']['std']) ? $field['args']['std'] : '';
39
+                            $value     = wpinv_clean(wpinv_get_option($field['args']['id'], $value));
40
+                            $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : '';
41
+                            $type      = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback']));
42
+                            $label     = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : '';
43
+                            $options   = isset($field['args']['options']) ? $field['args']['options'] : array();
44 44
                         
45
-                            if ( false !== strpos( $name, 'logo') ) {
45
+                            if (false !== strpos($name, 'logo')) {
46 46
                                 $type = 'hidden';
47 47
                             }
48 48
                         
49
-                            if ( 'country_states' == $type ) {
49
+                            if ('country_states' == $type) {
50 50
                         
51
-                                if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) {
51
+                                if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) {
52 52
                                     $type = 'text';
53 53
                                 } else {
54 54
                                     $type = 'select';
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
                                 $class = 'getpaid_js_field-state';
58 58
                             }
59 59
                         
60
-                            if ( 'wpinv_settings[default_country]' == $name ) {
60
+                            if ('wpinv_settings[default_country]' == $name) {
61 61
                                 $class = 'getpaid_js_field-country';
62 62
                             }
63 63
                         
64
-                            switch ( $type ) {
64
+                            switch ($type) {
65 65
                         
66 66
                                 case 'hidden':
67 67
                                     echo "<input type='hidden' id='$id' name='$name' value='$value' />";
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
                                             'type'       => $type,
74 74
                                             'id'         => $id,
75 75
                                             'name'       => $name,
76
-                                            'value'      => is_scalar( $value ) ? esc_attr( $value ) : '',
76
+                                            'value'      => is_scalar($value) ? esc_attr($value) : '',
77 77
                                             'required'   => false,
78 78
                                             'help_text'  => $help_text,
79 79
                                             'label'      => $label,
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
                                         array(
90 90
                                             'id'              => $id,
91 91
                                             'name'            => $name,
92
-                                            'value'           => is_scalar( $value ) ? esc_textarea( $value ) : '',
92
+                                            'value'           => is_scalar($value) ? esc_textarea($value) : '',
93 93
                                             'required'        => false,
94 94
                                             'help_text'       => $help_text,
95 95
                                             'label'           => $label,
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
                                     );
102 102
                         
103 103
                                     // Bug fixed in AUI 0.1.51 for name stripping []
104
-                                    echo str_replace( sanitize_html_class( $name ), esc_attr( $name ), $textarea );
104
+                                    echo str_replace(sanitize_html_class($name), esc_attr($name), $textarea);
105 105
                         
106 106
                                     break;
107 107
                                 case 'select':
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
                                             'id'              =>  $id,
111 111
                                             'name'            =>  $name,
112 112
                                             'placeholder'     => '',
113
-                                            'value'           => is_scalar( $value ) ? esc_attr( $value ) : '',
113
+                                            'value'           => is_scalar($value) ? esc_attr($value) : '',
114 114
                                             'required'        => false,
115 115
                                             'help_text'       => $help_text,
116 116
                                             'label'           => $label,
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 				<input
136 136
                     type="submit"
137 137
                     class="btn btn-primary button-next"
138
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
138
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
139 139
 			</p>
140 140
         </table>
141 141
     </form>
Please login to merge, or discard this patch.
includes/admin/views/wizard-plugins.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -4,30 +4,30 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 ?>
10 10
 
11 11
 <div class="card shadow-sm my-5">'
12 12
 
13
-    <form method="post" class="text-center card-body" action="<?php echo esc_url( admin_url() ); ?>">
14
-		<?php getpaid_hidden_field( 'getpaid-admin-action', 'install_plugin' ); ?>
15
-		<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
16
-		<?php getpaid_hidden_field( 'redirect', $next_url ); ?>
13
+    <form method="post" class="text-center card-body" action="<?php echo esc_url(admin_url()); ?>">
14
+		<?php getpaid_hidden_field('getpaid-admin-action', 'install_plugin'); ?>
15
+		<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
16
+		<?php getpaid_hidden_field('redirect', $next_url); ?>
17 17
 		<div class="gd-wizard-recommend">
18 18
 
19
-			<h2 class="gd-settings-title h3"><?php _e( 'Recommended Plugins', 'invoicing' ); ?></h2>
20
-			<p><?php _e( 'Below are a few of our own plugins that may help you.', 'invoicing' ); ?></p>
19
+			<h2 class="gd-settings-title h3"><?php _e('Recommended Plugins', 'invoicing'); ?></h2>
20
+			<p><?php _e('Below are a few of our own plugins that may help you.', 'invoicing'); ?></p>
21 21
 
22 22
 			<ul class="list-group">
23
-				<?php foreach ( $recommended_plugins as $plugin ) : ?>
23
+				<?php foreach ($recommended_plugins as $plugin) : ?>
24 24
 				<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap text-left">
25
-					<span class="mr-auto"><?php echo esc_html( $plugin['name'] ); ?></span>
25
+					<span class="mr-auto"><?php echo esc_html($plugin['name']); ?></span>
26 26
 					<div class="custom-control custom-switch getpaid-install-plugin-siwtch-div mr-n2">
27
-						<input type="checkbox" name="plugins[<?php echo esc_attr( $plugin['slug'] ); ?>]" value="<?php echo esc_attr( $plugin['file'] ); ?>" class="custom-control-input"  <?php if( is_plugin_active( $plugin['slug'] ) ){echo "checked";} ?>>
27
+						<input type="checkbox" name="plugins[<?php echo esc_attr($plugin['slug']); ?>]" value="<?php echo esc_attr($plugin['file']); ?>" class="custom-control-input"  <?php if (is_plugin_active($plugin['slug'])) {echo "checked"; } ?>>
28 28
 						<label class="custom-control-label" for="ac-setting-updates"></label>
29 29
 					</div>
30
-					<small class="w-100"><?php echo esc_attr( $plugin['desc'] );?></small>
30
+					<small class="w-100"><?php echo esc_attr($plugin['desc']); ?></small>
31 31
 				</li>
32 32
 				<?php endforeach; ?>
33 33
 			</ul>
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 				<input
37 37
                 	type="submit"
38 38
                 	class="btn btn-primary button-next"
39
-				    value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/>
39
+				    value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/>
40 40
 			</p>
41 41
 
42 42
 		</div>
Please login to merge, or discard this patch.