Passed
Push — master ( f76276...ca99e2 )
by Stiofan
03:29
created
includes/wpinv-post-types.php 1 patch
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14
-add_action( 'init', 'wpinv_register_post_types', 1 );
14
+add_action('init', 'wpinv_register_post_types', 1);
15 15
 function wpinv_register_post_types() {    
16 16
     $labels = array(
17
-        'name'               => _x( 'Invoices', 'post type general name', 'invoicing' ),
18
-        'singular_name'      => _x( 'Invoice', 'post type singular name', 'invoicing' ),
19
-        'menu_name'          => _x( 'Invoices', 'admin menu', 'invoicing' ),
20
-        'name_admin_bar'     => _x( 'Invoice', 'add new on admin bar', 'invoicing' ),
21
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
22
-        'add_new_item'       => __( 'Add New Invoice', 'invoicing' ),
23
-        'new_item'           => __( 'New Invoice', 'invoicing' ),
24
-        'edit_item'          => __( 'Edit Invoice', 'invoicing' ),
25
-        'view_item'          => __( 'View Invoice', 'invoicing' ),
26
-        'all_items'          => __( 'Invoices', 'invoicing' ),
27
-        'search_items'       => __( 'Search Invoices', 'invoicing' ),
28
-        'parent_item_colon'  => __( 'Parent Invoices:', 'invoicing' ),
29
-        'not_found'          => __( 'No invoices found.', 'invoicing' ),
30
-        'not_found_in_trash' => __( 'No invoices found in trash.', 'invoicing' )
17
+        'name'               => _x('Invoices', 'post type general name', 'invoicing'),
18
+        'singular_name'      => _x('Invoice', 'post type singular name', 'invoicing'),
19
+        'menu_name'          => _x('Invoices', 'admin menu', 'invoicing'),
20
+        'name_admin_bar'     => _x('Invoice', 'add new on admin bar', 'invoicing'),
21
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
22
+        'add_new_item'       => __('Add New Invoice', 'invoicing'),
23
+        'new_item'           => __('New Invoice', 'invoicing'),
24
+        'edit_item'          => __('Edit Invoice', 'invoicing'),
25
+        'view_item'          => __('View Invoice', 'invoicing'),
26
+        'all_items'          => __('Invoices', 'invoicing'),
27
+        'search_items'       => __('Search Invoices', 'invoicing'),
28
+        'parent_item_colon'  => __('Parent Invoices:', 'invoicing'),
29
+        'not_found'          => __('No invoices found.', 'invoicing'),
30
+        'not_found_in_trash' => __('No invoices found in trash.', 'invoicing')
31 31
     );
32
-    $labels = apply_filters( 'wpinv_labels', $labels );
32
+    $labels = apply_filters('wpinv_labels', $labels);
33 33
     
34 34
     $menu_icon = WPINV_PLUGIN_URL . '/assets/images/favicon.ico';
35
-    $menu_icon = apply_filters( 'wpinv_menu_icon_invoice', $menu_icon );
35
+    $menu_icon = apply_filters('wpinv_menu_icon_invoice', $menu_icon);
36 36
 
37 37
     $cap_type = 'wpi_invoice';
38 38
     $args = array(
39 39
         'labels'             => $labels,
40
-        'description'        => __( 'This is where invoices are stored.', 'invoicing' ),
40
+        'description'        => __('This is where invoices are stored.', 'invoicing'),
41 41
         'public'             => true,
42 42
         'can_export'         => true,
43 43
         '_builtin'           => false,
44 44
         'publicly_queryable' => true,
45 45
         'exclude_from_search'=> true,
46 46
         'show_ui'            => true,
47
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : true,
47
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : true,
48 48
         'query_var'          => false,
49 49
         'rewrite'            => true,
50 50
         'capability_type'    => 'wpi_invoice',
@@ -68,38 +68,38 @@  discard block
 block discarded – undo
68 68
         'has_archive'        => false,
69 69
         'hierarchical'       => false,
70 70
         'menu_position'      => null,
71
-        'supports'           => array( 'title', 'author' ),
71
+        'supports'           => array('title', 'author'),
72 72
         'menu_icon'          => $menu_icon,
73 73
     );
74 74
             
75
-    $args = apply_filters( 'wpinv_register_post_type_invoice', $args );
75
+    $args = apply_filters('wpinv_register_post_type_invoice', $args);
76 76
     
77
-    register_post_type( 'wpi_invoice', $args );
77
+    register_post_type('wpi_invoice', $args);
78 78
     
79 79
     $items_labels = array(
80
-        'name'               => _x( 'Items', 'post type general name', 'invoicing' ),
81
-        'singular_name'      => _x( 'Item', 'post type singular name', 'invoicing' ),
82
-        'menu_name'          => _x( 'Items', 'admin menu', 'invoicing' ),
83
-        'add_new'            => _x( 'Add New', 'wpi_item', 'invoicing' ),
84
-        'add_new_item'       => __( 'Add New Item', 'invoicing' ),
85
-        'new_item'           => __( 'New Item', 'invoicing' ),
86
-        'edit_item'          => __( 'Edit Item', 'invoicing' ),
87
-        'view_item'          => __( 'View Item', 'invoicing' ),
88
-        'all_items'          => __( 'Items', 'invoicing' ),
89
-        'search_items'       => __( 'Search Items', 'invoicing' ),
80
+        'name'               => _x('Items', 'post type general name', 'invoicing'),
81
+        'singular_name'      => _x('Item', 'post type singular name', 'invoicing'),
82
+        'menu_name'          => _x('Items', 'admin menu', 'invoicing'),
83
+        'add_new'            => _x('Add New', 'wpi_item', 'invoicing'),
84
+        'add_new_item'       => __('Add New Item', 'invoicing'),
85
+        'new_item'           => __('New Item', 'invoicing'),
86
+        'edit_item'          => __('Edit Item', 'invoicing'),
87
+        'view_item'          => __('View Item', 'invoicing'),
88
+        'all_items'          => __('Items', 'invoicing'),
89
+        'search_items'       => __('Search Items', 'invoicing'),
90 90
         'parent_item_colon'  => '',
91
-        'not_found'          => __( 'No items found.', 'invoicing' ),
92
-        'not_found_in_trash' => __( 'No items found in trash.', 'invoicing' )
91
+        'not_found'          => __('No items found.', 'invoicing'),
92
+        'not_found_in_trash' => __('No items found in trash.', 'invoicing')
93 93
     );
94
-    $items_labels = apply_filters( 'wpinv_items_labels', $items_labels );
94
+    $items_labels = apply_filters('wpinv_items_labels', $items_labels);
95 95
 
96 96
     $cap_type = 'wpi_item';
97 97
     $invoice_item_args = array(
98 98
         'labels'                => $items_labels,
99 99
         'public'                => false,
100 100
         'show_ui'               => true,
101
-        'show_in_menu'          => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
102
-        'supports'              => array( 'title', 'excerpt' ),
101
+        'show_in_menu'          => current_user_can('manage_invoicing') ? 'wpinv' : false,
102
+        'supports'              => array('title', 'excerpt'),
103 103
         'register_meta_box_cb'  => 'wpinv_register_item_meta_boxes',
104 104
         'rewrite'               => false,
105 105
         'query_var'             => false,
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
         ),
124 124
         'can_export'            => true,
125 125
     );
126
-    $invoice_item_args = apply_filters( 'wpinv_register_post_type_invoice_item', $invoice_item_args );
126
+    $invoice_item_args = apply_filters('wpinv_register_post_type_invoice_item', $invoice_item_args);
127 127
 
128
-    register_post_type( 'wpi_item', $invoice_item_args );
128
+    register_post_type('wpi_item', $invoice_item_args);
129 129
     
130 130
     $labels = array(
131
-        'name'               => _x( 'Discounts', 'post type general name', 'invoicing' ),
132
-        'singular_name'      => _x( 'Discount', 'post type singular name', 'invoicing' ),
133
-        'menu_name'          => _x( 'Discounts', 'admin menu', 'invoicing' ),
134
-        'name_admin_bar'     => _x( 'Discount', 'add new on admin bar', 'invoicing' ),
135
-        'add_new'            => _x( 'Add New', 'book', 'invoicing' ),
136
-        'add_new_item'       => __( 'Add New Discount', 'invoicing' ),
137
-        'new_item'           => __( 'New Discount', 'invoicing' ),
138
-        'edit_item'          => __( 'Edit Discount', 'invoicing' ),
139
-        'view_item'          => __( 'View Discount', 'invoicing' ),
140
-        'all_items'          => __( 'Discounts', 'invoicing' ),
141
-        'search_items'       => __( 'Search Discounts', 'invoicing' ),
142
-        'parent_item_colon'  => __( 'Parent Discounts:', 'invoicing' ),
143
-        'not_found'          => __( 'No discounts found.', 'invoicing' ),
144
-        'not_found_in_trash' => __( 'No discounts found in trash.', 'invoicing' )
131
+        'name'               => _x('Discounts', 'post type general name', 'invoicing'),
132
+        'singular_name'      => _x('Discount', 'post type singular name', 'invoicing'),
133
+        'menu_name'          => _x('Discounts', 'admin menu', 'invoicing'),
134
+        'name_admin_bar'     => _x('Discount', 'add new on admin bar', 'invoicing'),
135
+        'add_new'            => _x('Add New', 'book', 'invoicing'),
136
+        'add_new_item'       => __('Add New Discount', 'invoicing'),
137
+        'new_item'           => __('New Discount', 'invoicing'),
138
+        'edit_item'          => __('Edit Discount', 'invoicing'),
139
+        'view_item'          => __('View Discount', 'invoicing'),
140
+        'all_items'          => __('Discounts', 'invoicing'),
141
+        'search_items'       => __('Search Discounts', 'invoicing'),
142
+        'parent_item_colon'  => __('Parent Discounts:', 'invoicing'),
143
+        'not_found'          => __('No discounts found.', 'invoicing'),
144
+        'not_found_in_trash' => __('No discounts found in trash.', 'invoicing')
145 145
     );
146
-    $labels = apply_filters( 'wpinv_discounts_labels', $labels );
146
+    $labels = apply_filters('wpinv_discounts_labels', $labels);
147 147
 
148 148
     $cap_type = 'wpi_discount';
149 149
     
150 150
     $args = array(
151 151
         'labels'             => $labels,
152
-        'description'        => __( 'This is where you can add new discounts that users can use in invoices.', 'invoicing' ),
152
+        'description'        => __('This is where you can add new discounts that users can use in invoices.', 'invoicing'),
153 153
         'public'             => false,
154 154
         'can_export'         => true,
155 155
         '_builtin'           => false,
156 156
         'publicly_queryable' => false,
157 157
         'exclude_from_search'=> true,
158 158
         'show_ui'            => true,
159
-        'show_in_menu'       => current_user_can( 'manage_invoicing' ) ? 'wpinv' : false,
159
+        'show_in_menu'       => current_user_can('manage_invoicing') ? 'wpinv' : false,
160 160
         'query_var'          => false,
161 161
         'rewrite'            => false,
162 162
         'capability_type'    => $cap_type,
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
         ),
180 180
         'has_archive'        => false,
181 181
         'hierarchical'       => false,
182
-        'supports'           => array( 'title', 'excerpt' ),
182
+        'supports'           => array('title', 'excerpt'),
183 183
         'register_meta_box_cb'  => 'wpinv_register_discount_meta_boxes',
184 184
         'show_in_nav_menus'  => false,
185 185
         'show_in_admin_bar'  => true,
@@ -187,107 +187,107 @@  discard block
 block discarded – undo
187 187
         'menu_position'      => null,
188 188
     );
189 189
             
190
-    $args = apply_filters( 'wpinv_register_post_type_discount', $args );
190
+    $args = apply_filters('wpinv_register_post_type_discount', $args);
191 191
     
192
-    register_post_type( 'wpi_discount', $args );
192
+    register_post_type('wpi_discount', $args);
193 193
 }
194 194
 
195 195
 function wpinv_get_default_labels() {
196 196
     $defaults = array(
197
-       'singular' => __( 'Invoice', 'invoicing' ),
198
-       'plural'   => __( 'Invoices', 'invoicing' )
197
+       'singular' => __('Invoice', 'invoicing'),
198
+       'plural'   => __('Invoices', 'invoicing')
199 199
     );
200 200
     
201
-    return apply_filters( 'wpinv_default_invoices_name', $defaults );
201
+    return apply_filters('wpinv_default_invoices_name', $defaults);
202 202
 }
203 203
 
204
-function wpinv_get_label_singular( $lowercase = false ) {
204
+function wpinv_get_label_singular($lowercase = false) {
205 205
     $defaults = wpinv_get_default_labels();
206 206
     
207
-    return ($lowercase) ? strtolower( $defaults['singular'] ) : $defaults['singular'];
207
+    return ($lowercase) ? strtolower($defaults['singular']) : $defaults['singular'];
208 208
 }
209 209
 
210
-function wpinv_get_label_plural( $lowercase = false ) {
210
+function wpinv_get_label_plural($lowercase = false) {
211 211
     $defaults = wpinv_get_default_labels();
212 212
     
213
-    return ( $lowercase ) ? strtolower( $defaults['plural'] ) : $defaults['plural'];
213
+    return ($lowercase) ? strtolower($defaults['plural']) : $defaults['plural'];
214 214
 }
215 215
 
216
-function wpinv_change_default_title( $title ) {
217
-     if ( !is_admin() ) {
216
+function wpinv_change_default_title($title) {
217
+     if (!is_admin()) {
218 218
         $label = wpinv_get_label_singular();
219
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
219
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
220 220
         return $title;
221 221
      }
222 222
 
223 223
      $screen = get_current_screen();
224 224
 
225
-     if ( 'wpi_invoice' == $screen->post_type ) {
225
+     if ('wpi_invoice' == $screen->post_type) {
226 226
         $label = wpinv_get_label_singular();
227
-        $title = sprintf( __( 'Enter %s name here', 'invoicing' ), $label );
227
+        $title = sprintf(__('Enter %s name here', 'invoicing'), $label);
228 228
      }
229 229
 
230 230
      return $title;
231 231
 }
232
-add_filter( 'enter_title_here', 'wpinv_change_default_title' );
232
+add_filter('enter_title_here', 'wpinv_change_default_title');
233 233
 
234 234
 function wpinv_register_post_status() {
235
-    register_post_status( 'wpi-pending', array(
236
-        'label'                     => _x( 'Pending', 'Invoice status', 'invoicing' ),
235
+    register_post_status('wpi-pending', array(
236
+        'label'                     => _x('Pending', 'Invoice status', 'invoicing'),
237 237
         'public'                    => true,
238 238
         'exclude_from_search'       => true,
239 239
         'show_in_admin_all_list'    => true,
240 240
         'show_in_admin_status_list' => true,
241
-        'label_count'               => _n_noop( 'Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing' )
242
-    ) );
243
-    register_post_status( 'wpi-processing', array(
244
-        'label'                     => _x( 'Processing', 'Invoice status', 'invoicing' ),
241
+        'label_count'               => _n_noop('Pending <span class="count">(%s)</span>', 'Pending <span class="count">(%s)</span>', 'invoicing')
242
+    ));
243
+    register_post_status('wpi-processing', array(
244
+        'label'                     => _x('Processing', 'Invoice status', 'invoicing'),
245 245
         'public'                    => true,
246 246
         'exclude_from_search'       => true,
247 247
         'show_in_admin_all_list'    => true,
248 248
         'show_in_admin_status_list' => true,
249
-        'label_count'               => _n_noop( 'Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing' )
250
-    ) );
251
-    register_post_status( 'wpi-onhold', array(
252
-        'label'                     => _x( 'On Hold', 'Invoice status', 'invoicing' ),
249
+        'label_count'               => _n_noop('Processing <span class="count">(%s)</span>', 'Processing <span class="count">(%s)</span>', 'invoicing')
250
+    ));
251
+    register_post_status('wpi-onhold', array(
252
+        'label'                     => _x('On Hold', 'Invoice status', 'invoicing'),
253 253
         'public'                    => true,
254 254
         'exclude_from_search'       => true,
255 255
         'show_in_admin_all_list'    => true,
256 256
         'show_in_admin_status_list' => true,
257
-        'label_count'               => _n_noop( 'On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing' )
258
-    ) );
259
-    register_post_status( 'wpi-cancelled', array(
260
-        'label'                     => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
257
+        'label_count'               => _n_noop('On Hold <span class="count">(%s)</span>', 'On Hold <span class="count">(%s)</span>', 'invoicing')
258
+    ));
259
+    register_post_status('wpi-cancelled', array(
260
+        'label'                     => _x('Cancelled', 'Invoice status', 'invoicing'),
261 261
         'public'                    => true,
262 262
         'exclude_from_search'       => true,
263 263
         'show_in_admin_all_list'    => true,
264 264
         'show_in_admin_status_list' => true,
265
-        'label_count'               => _n_noop( 'Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing' )
266
-    ) );
267
-    register_post_status( 'wpi-refunded', array(
268
-        'label'                     => _x( 'Refunded', 'Invoice status', 'invoicing' ),
265
+        'label_count'               => _n_noop('Cancelled <span class="count">(%s)</span>', 'Cancelled <span class="count">(%s)</span>', 'invoicing')
266
+    ));
267
+    register_post_status('wpi-refunded', array(
268
+        'label'                     => _x('Refunded', 'Invoice status', 'invoicing'),
269 269
         'public'                    => true,
270 270
         'exclude_from_search'       => true,
271 271
         'show_in_admin_all_list'    => true,
272 272
         'show_in_admin_status_list' => true,
273
-        'label_count'               => _n_noop( 'Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing' )
274
-    ) );
275
-    register_post_status( 'wpi-failed', array(
276
-        'label'                     => _x( 'Failed', 'Invoice status', 'invoicing' ),
273
+        'label_count'               => _n_noop('Refunded <span class="count">(%s)</span>', 'Refunded <span class="count">(%s)</span>', 'invoicing')
274
+    ));
275
+    register_post_status('wpi-failed', array(
276
+        'label'                     => _x('Failed', 'Invoice status', 'invoicing'),
277 277
         'public'                    => true,
278 278
         'exclude_from_search'       => true,
279 279
         'show_in_admin_all_list'    => true,
280 280
         'show_in_admin_status_list' => true,
281
-        'label_count'               => _n_noop( 'Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing' )
282
-    ) );
283
-    register_post_status( 'wpi-renewal', array(
284
-        'label'                     => _x( 'Renewal', 'Invoice status', 'invoicing' ),
281
+        'label_count'               => _n_noop('Failed <span class="count">(%s)</span>', 'Failed <span class="count">(%s)</span>', 'invoicing')
282
+    ));
283
+    register_post_status('wpi-renewal', array(
284
+        'label'                     => _x('Renewal', 'Invoice status', 'invoicing'),
285 285
         'public'                    => true,
286 286
         'exclude_from_search'       => true,
287 287
         'show_in_admin_all_list'    => true,
288 288
         'show_in_admin_status_list' => true,
289
-        'label_count'               => _n_noop( 'Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing' )
290
-    ) );
289
+        'label_count'               => _n_noop('Renewal <span class="count">(%s)</span>', 'Renewal <span class="count">(%s)</span>', 'invoicing')
290
+    ));
291 291
 }
292
-add_action( 'init', 'wpinv_register_post_status', 10 );
292
+add_action('init', 'wpinv_register_post_status', 10);
293 293
 
Please login to merge, or discard this patch.
includes/wpinv-user-functions.php 1 patch
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -1,21 +1,21 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-function wpinv_get_users_invoices( $user = 0, $number = 20, $pagination = false, $status = 'publish' ) {
6
-    if ( empty( $user ) ) {
5
+function wpinv_get_users_invoices($user = 0, $number = 20, $pagination = false, $status = 'publish') {
6
+    if (empty($user)) {
7 7
         $user = get_current_user_id();
8 8
     }
9 9
 
10
-    if ( 0 === $user ) {
10
+    if (0 === $user) {
11 11
         return false;
12 12
     }
13 13
 
14
-    if ( $pagination ) {
15
-        if ( get_query_var( 'paged' ) )
14
+    if ($pagination) {
15
+        if (get_query_var('paged'))
16 16
             $paged = get_query_var('paged');
17
-        else if ( get_query_var( 'page' ) )
18
-            $paged = get_query_var( 'page' );
17
+        else if (get_query_var('page'))
18
+            $paged = get_query_var('page');
19 19
         else
20 20
             $paged = 1;
21 21
     }
@@ -24,21 +24,21 @@  discard block
 block discarded – undo
24 24
         'post_type'      => 'wpi_invoice',
25 25
         'posts_per_page' => 20,
26 26
         'paged'          => null,
27
-        'post_status'    => array( 'publish', 'wpi-pending' ),
27
+        'post_status'    => array('publish', 'wpi-pending'),
28 28
         'user'           => $user,
29 29
         'order'          => 'date',
30 30
     );
31 31
 
32
-    $invoices = get_posts( $args );
32
+    $invoices = get_posts($args);
33 33
 
34 34
     // No invoices
35
-    if ( ! $invoices )
35
+    if (!$invoices)
36 36
         return false;
37 37
 
38 38
     return $invoices;
39 39
 }
40 40
 
41
-function wpinv_dropdown_users( $args = '' ) {
41
+function wpinv_dropdown_users($args = '') {
42 42
     $defaults = array(
43 43
         'show_option_all' => '', 'show_option_none' => '', 'hide_if_only_one_author' => '',
44 44
         'orderby' => 'display_name', 'order' => 'ASC',
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
         'option_none_value' => -1
50 50
     );
51 51
 
52
-    $defaults['selected'] = is_author() ? get_query_var( 'author' ) : 0;
52
+    $defaults['selected'] = is_author() ? get_query_var('author') : 0;
53 53
 
54
-    $r = wp_parse_args( $args, $defaults );
54
+    $r = wp_parse_args($args, $defaults);
55 55
 
56
-    $query_args = wp_array_slice_assoc( $r, array( 'blog_id', 'include', 'exclude', 'orderby', 'order', 'who' ) );
56
+    $query_args = wp_array_slice_assoc($r, array('blog_id', 'include', 'exclude', 'orderby', 'order', 'who'));
57 57
 
58
-    $fields = array( 'ID', 'user_login', 'user_email' );
58
+    $fields = array('ID', 'user_login', 'user_email');
59 59
 
60
-    $show = ! empty( $r['show'] ) ? $r['show'] : 'display_name';
61
-    if ( 'display_name_with_login' === $show ) {
60
+    $show = !empty($r['show']) ? $r['show'] : 'display_name';
61
+    if ('display_name_with_login' === $show) {
62 62
         $fields[] = 'display_name';
63
-    } else if ( 'display_name_with_email' === $show ) {
63
+    } else if ('display_name_with_email' === $show) {
64 64
         $fields[] = 'display_name';
65 65
     } else {
66 66
         $fields[] = $show;
@@ -72,99 +72,99 @@  discard block
 block discarded – undo
72 72
     $show_option_none = $r['show_option_none'];
73 73
     $option_none_value = $r['option_none_value'];
74 74
 
75
-    $query_args = apply_filters( 'wpinv_dropdown_users_args', $query_args, $r );
75
+    $query_args = apply_filters('wpinv_dropdown_users_args', $query_args, $r);
76 76
 
77
-    $users = get_users( $query_args );
77
+    $users = get_users($query_args);
78 78
 
79 79
     $output = '';
80
-    if ( ! empty( $users ) && ( empty( $r['hide_if_only_one_author'] ) || count( $users ) > 1 ) ) {
81
-        $name = esc_attr( $r['name'] );
82
-        if ( $r['multi'] && ! $r['id'] ) {
80
+    if (!empty($users) && (empty($r['hide_if_only_one_author']) || count($users) > 1)) {
81
+        $name = esc_attr($r['name']);
82
+        if ($r['multi'] && !$r['id']) {
83 83
             $id = '';
84 84
         } else {
85
-            $id = $r['id'] ? " id='" . esc_attr( $r['id'] ) . "'" : " id='$name'";
85
+            $id = $r['id'] ? " id='" . esc_attr($r['id']) . "'" : " id='$name'";
86 86
         }
87 87
         $output = "<select name='{$name}'{$id} class='" . $r['class'] . "'>\n";
88 88
 
89
-        if ( $show_option_all ) {
89
+        if ($show_option_all) {
90 90
             $output .= "\t<option value='0'>$show_option_all</option>\n";
91 91
         }
92 92
 
93
-        if ( $show_option_none ) {
94
-            $_selected = selected( $option_none_value, $r['selected'], false );
95
-            $output .= "\t<option value='" . esc_attr( $option_none_value ) . "'$_selected>$show_option_none</option>\n";
93
+        if ($show_option_none) {
94
+            $_selected = selected($option_none_value, $r['selected'], false);
95
+            $output .= "\t<option value='" . esc_attr($option_none_value) . "'$_selected>$show_option_none</option>\n";
96 96
         }
97 97
 
98
-        if ( $r['include_selected'] && ( $r['selected'] > 0 ) ) {
98
+        if ($r['include_selected'] && ($r['selected'] > 0)) {
99 99
             $found_selected = false;
100
-            $r['selected'] = (int) $r['selected'];
101
-            foreach ( (array) $users as $user ) {
102
-                $user->ID = (int) $user->ID;
103
-                if ( $user->ID === $r['selected'] ) {
100
+            $r['selected'] = (int)$r['selected'];
101
+            foreach ((array)$users as $user) {
102
+                $user->ID = (int)$user->ID;
103
+                if ($user->ID === $r['selected']) {
104 104
                     $found_selected = true;
105 105
                 }
106 106
             }
107 107
 
108
-            if ( ! $found_selected ) {
109
-                $users[] = get_userdata( $r['selected'] );
108
+            if (!$found_selected) {
109
+                $users[] = get_userdata($r['selected']);
110 110
             }
111 111
         }
112 112
 
113
-        foreach ( (array) $users as $user ) {
114
-            if ( 'display_name_with_login' === $show ) {
113
+        foreach ((array)$users as $user) {
114
+            if ('display_name_with_login' === $show) {
115 115
                 /* translators: 1: display name, 2: user_login */
116
-                $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_login );
117
-            } elseif ( 'display_name_with_email' === $show ) {
116
+                $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_login);
117
+            } elseif ('display_name_with_email' === $show) {
118 118
                 /* translators: 1: display name, 2: user_email */
119
-                if ( $user->display_name == $user->user_email ) {
119
+                if ($user->display_name == $user->user_email) {
120 120
                     $display = $user->display_name;
121 121
                 } else {
122
-                    $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown' ), $user->display_name, $user->user_email );
122
+                    $display = sprintf(_x('%1$s (%2$s)', 'user dropdown'), $user->display_name, $user->user_email);
123 123
                 }
124
-            } elseif ( ! empty( $user->$show ) ) {
124
+            } elseif (!empty($user->$show)) {
125 125
                 $display = $user->$show;
126 126
             } else {
127 127
                 $display = '(' . $user->user_login . ')';
128 128
             }
129 129
 
130
-            $_selected = selected( $user->ID, $r['selected'], false );
131
-            $output .= "\t<option value='$user->ID'$_selected>" . esc_html( $display ) . "</option>\n";
130
+            $_selected = selected($user->ID, $r['selected'], false);
131
+            $output .= "\t<option value='$user->ID'$_selected>" . esc_html($display) . "</option>\n";
132 132
         }
133 133
 
134 134
         $output .= "</select>";
135 135
     }
136 136
 
137
-    $html = apply_filters( 'wpinv_dropdown_users', $output );
137
+    $html = apply_filters('wpinv_dropdown_users', $output);
138 138
 
139
-    if ( $r['echo'] ) {
139
+    if ($r['echo']) {
140 140
         echo $html;
141 141
     }
142 142
     return $html;
143 143
 }
144 144
 
145
-function wpinv_guest_redirect( $redirect_to, $user_id = 0 ) {
146
-    if ( (int)wpinv_get_option( 'guest_checkout' ) && $user_id > 0 ) {
147
-        wpinv_login_user( $user_id );
145
+function wpinv_guest_redirect($redirect_to, $user_id = 0) {
146
+    if ((int)wpinv_get_option('guest_checkout') && $user_id > 0) {
147
+        wpinv_login_user($user_id);
148 148
     } else {
149
-        $redirect_to = wp_login_url( $redirect_to );
149
+        $redirect_to = wp_login_url($redirect_to);
150 150
     }
151 151
     
152
-    $redirect_to = apply_filters( 'wpinv_invoice_link_guest_redirect', $redirect_to, $user_id );
152
+    $redirect_to = apply_filters('wpinv_invoice_link_guest_redirect', $redirect_to, $user_id);
153 153
     
154
-    wp_redirect( $redirect_to );
154
+    wp_redirect($redirect_to);
155 155
 }
156 156
 
157
-function wpinv_login_user( $user_id ) {
158
-    if ( is_user_logged_in() ) {
157
+function wpinv_login_user($user_id) {
158
+    if (is_user_logged_in()) {
159 159
         return true;
160 160
     }
161 161
     
162
-    $user = get_user_by( 'id', $user_id );
162
+    $user = get_user_by('id', $user_id);
163 163
     
164
-    if ( !empty( $user ) && !is_wp_error( $user ) && !empty( $user->user_login ) ) {
165
-        wp_set_current_user( $user_id, $user->user_login );
166
-        wp_set_auth_cookie( $user_id );
167
-        do_action( 'wp_login', $user->user_login );
164
+    if (!empty($user) && !is_wp_error($user) && !empty($user->user_login)) {
165
+        wp_set_current_user($user_id, $user->user_login);
166
+        wp_set_auth_cookie($user_id);
167
+        do_action('wp_login', $user->user_login);
168 168
         
169 169
         return true;
170 170
     }
Please login to merge, or discard this patch.
includes/gateways/bank_transfer.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -1,12 +1,12 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_bank_transfer_cc_form', '__return_false' );
5
+add_action('wpinv_bank_transfer_cc_form', '__return_false');
6 6
 
7
-function wpinv_process_bank_transfer_payment( $purchase_data ) {
8
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
9
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
7
+function wpinv_process_bank_transfer_payment($purchase_data) {
8
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
9
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
10 10
     }
11 11
 
12 12
     // Collect payment data
@@ -24,37 +24,37 @@  discard block
 block discarded – undo
24 24
     );
25 25
 
26 26
     // Record the pending payment
27
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
27
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
28 28
     
29
-    if ( !empty( $invoice ) ) {
30
-        wpinv_set_payment_transaction_id( $invoice->ID, $invoice->generate_key() );
31
-        wpinv_update_payment_status( $invoice, 'wpi-pending' );
29
+    if (!empty($invoice)) {
30
+        wpinv_set_payment_transaction_id($invoice->ID, $invoice->generate_key());
31
+        wpinv_update_payment_status($invoice, 'wpi-pending');
32 32
         
33 33
         // Empty the shopping cart
34 34
         wpinv_empty_cart();
35 35
         
36
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
36
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
37 37
     } else {
38
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
38
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed while processing a bank transfer payment. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
39 39
         // If errors are present, send the user back to the purchase page so they can be corrected
40
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
40
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
41 41
     }
42 42
 }
43
-add_action( 'wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment' );
43
+add_action('wpinv_gateway_bank_transfer', 'wpinv_process_bank_transfer_payment');
44 44
 
45
-function wpinv_show_bank_info( $invoice ) {
46
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'wpi-pending' ) {
47
-        $bank_info = wpinv_get_bank_info( true );
45
+function wpinv_show_bank_info($invoice) {
46
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'wpi-pending') {
47
+        $bank_info = wpinv_get_bank_info(true);
48 48
         ?>
49 49
         <div class="wpinv-bank-details">
50
-            <?php if ( $instructions = wpinv_get_bank_instructions() ) { ?>
51
-            <div class="alert bg-info"><?php echo wpautop( wp_kses_post( $instructions ) ); ?></div>
50
+            <?php if ($instructions = wpinv_get_bank_instructions()) { ?>
51
+            <div class="alert bg-info"><?php echo wpautop(wp_kses_post($instructions)); ?></div>
52 52
             <?php } ?>
53
-            <?php if ( !empty( $bank_info ) ) { ?>
54
-            <h3 class="wpinv-bank-t"><?php echo apply_filters( 'wpinv_receipt_bank_details_title', __( 'Our Bank Details', 'invoicing' ) ); ?></h3>
53
+            <?php if (!empty($bank_info)) { ?>
54
+            <h3 class="wpinv-bank-t"><?php echo apply_filters('wpinv_receipt_bank_details_title', __('Our Bank Details', 'invoicing')); ?></h3>
55 55
             <table class="table table-bordered table-sm wpi-bank-details">
56
-                <?php foreach ( $bank_info as $key => $info ) { ?>
57
-                <tr class="wpi-<?php echo sanitize_html_class( $key );?>"><th class="text-left"><?php echo $info['label'] ;?></th><td><?php echo $info['value'] ;?></td></tr>
56
+                <?php foreach ($bank_info as $key => $info) { ?>
57
+                <tr class="wpi-<?php echo sanitize_html_class($key); ?>"><th class="text-left"><?php echo $info['label']; ?></th><td><?php echo $info['value']; ?></td></tr>
58 58
                 <?php } ?>
59 59
             </table>
60 60
             <?php } ?>
@@ -62,15 +62,15 @@  discard block
 block discarded – undo
62 62
         <?php
63 63
     }
64 64
 }
65
-add_action( 'wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1 );
65
+add_action('wpinv_before_receipt_details', 'wpinv_show_bank_info', 10, 1);
66 66
 
67
-function wpinv_invoice_print_bank_info( $invoice ) {
68
-    if ( !empty( $invoice ) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'wpi-pending' ) {
67
+function wpinv_invoice_print_bank_info($invoice) {
68
+    if (!empty($invoice) && $invoice->gateway == 'bank_transfer' && $invoice->status == 'wpi-pending') {
69 69
         ?>
70 70
         <div class="row wpinv-bank-info">
71
-            <?php echo wpinv_show_bank_info( $invoice ); ?>
71
+            <?php echo wpinv_show_bank_info($invoice); ?>
72 72
         </div>
73 73
         <?php
74 74
     }
75 75
 }
76
-add_action( 'wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1 );
77 76
\ No newline at end of file
77
+add_action('wpinv_invoice_print_after_top_content', 'wpinv_invoice_print_bank_info', 10, 1);
78 78
\ No newline at end of file
Please login to merge, or discard this patch.
includes/gateways/paypal.php 1 patch
Spacing   +258 added lines, -258 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8
-function wpinv_process_paypal_payment( $purchase_data ) {
9
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
10
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
8
+function wpinv_process_paypal_payment($purchase_data) {
9
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
10
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
11 11
     }
12 12
 
13 13
     // Collect payment data
@@ -25,30 +25,30 @@  discard block
 block discarded – undo
25 25
     );
26 26
 
27 27
     // Record the pending payment
28
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
28
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
29 29
 
30 30
     // Check payment
31
-    if ( ! $invoice ) {
31
+    if (!$invoice) {
32 32
         // Record the error
33
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $payment );
33
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $payment);
34 34
         // Problems? send back
35
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
35
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
36 36
     } else {
37 37
         // Only send to PayPal if the pending payment is created successfully
38
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
38
+        $listener_url = wpinv_get_ipn_url('paypal');
39 39
 
40 40
         // Get the success url
41
-        $return_url = add_query_arg( array(
41
+        $return_url = add_query_arg(array(
42 42
                 'payment-confirm' => 'paypal',
43 43
                 'invoice-id' => $invoice->ID
44
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
44
+            ), get_permalink(wpinv_get_option('success_page', false)));
45 45
 
46 46
         // Get the PayPal redirect uri
47
-        $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?';
47
+        $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?';
48 48
 
49 49
         // Setup PayPal arguments
50 50
         $paypal_args = array(
51
-            'business'      => wpinv_get_option( 'paypal_email', false ),
51
+            'business'      => wpinv_get_option('paypal_email', false),
52 52
             'email'         => $invoice->get_email(),
53 53
             'first_name'    => $invoice->get_first_name(),
54 54
             'last_name'     => $invoice->get_last_name(),
@@ -57,13 +57,13 @@  discard block
 block discarded – undo
57 57
             'shipping'      => '0',
58 58
             'no_note'       => '1',
59 59
             'currency_code' => wpinv_get_currency(),
60
-            'charset'       => get_bloginfo( 'charset' ),
60
+            'charset'       => get_bloginfo('charset'),
61 61
             'custom'        => $invoice->ID,
62 62
             'rm'            => '2',
63 63
             'return'        => $return_url,
64
-            'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ),
64
+            'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID),
65 65
             'notify_url'    => $listener_url,
66
-            'cbt'           => get_bloginfo( 'name' ),
66
+            'cbt'           => get_bloginfo('name'),
67 67
             'bn'            => 'WPInvoicing_SP',
68 68
 	        'lc'            => 'US' // this will force paypal site to english
69 69
         );
@@ -79,57 +79,57 @@  discard block
 block discarded – undo
79 79
             'upload' => '1'
80 80
         );
81 81
 
82
-        $paypal_args = array_merge( $paypal_extra_args, $paypal_args );
82
+        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
83 83
 
84 84
         // Add cart items
85 85
         $i = 1;
86
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
87
-            foreach ( $purchase_data['cart_details'] as $item ) {
86
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
87
+            foreach ($purchase_data['cart_details'] as $item) {
88 88
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
89
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
89
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
90 90
 
91
-                if ( $item_amount <= 0 ) {
91
+                if ($item_amount <= 0) {
92 92
                     $item_amount = 0;
93 93
                 }
94 94
 
95
-                $paypal_args['item_number_' . $i ]      = $item['id'];
96
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
97
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
98
-                $paypal_args['amount_' . $i ]           = $item_amount;
99
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
95
+                $paypal_args['item_number_' . $i]      = $item['id'];
96
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
97
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
98
+                $paypal_args['amount_' . $i]           = $item_amount;
99
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
100 100
 
101 101
                 $i++;
102 102
             }
103 103
         }
104 104
 
105 105
         // Add taxes to the cart
106
-        if ( wpinv_use_taxes() ) {
107
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax(), 2 );
106
+        if (wpinv_use_taxes()) {
107
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax(), 2);
108 108
         }
109 109
 
110
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
110
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
111 111
 
112 112
         // Build query
113
-        $paypal_redirect .= http_build_query( $paypal_args );
113
+        $paypal_redirect .= http_build_query($paypal_args);
114 114
 
115 115
         // Fix for some sites that encode the entities
116
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
116
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
117 117
 
118 118
         // Get rid of cart contents
119 119
         wpinv_empty_cart();
120 120
         
121 121
         // Redirect to PayPal
122
-        wp_redirect( $paypal_redirect );
122
+        wp_redirect($paypal_redirect);
123 123
         exit;
124 124
     }
125 125
 }
126
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
126
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
127 127
 
128
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
129
-    if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) {
130
-        $item   = new WPInv_Item( $item_id );
128
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
129
+    if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) {
130
+        $item = new WPInv_Item($item_id);
131 131
         
132
-        if ( empty( $item ) ) {
132
+        if (empty($item)) {
133 133
             return $paypal_args;
134 134
         }
135 135
 
@@ -137,24 +137,24 @@  discard block
 block discarded – undo
137 137
         $interval           = $item->get_recurring_interval();
138 138
         $bill_times         = (int)$item->get_recurring_limit();
139 139
         
140
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
141
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
140
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
141
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
142 142
         
143 143
         $paypal_args['cmd'] = '_xclick-subscriptions';
144 144
         $paypal_args['sra'] = '1';
145 145
         $paypal_args['src'] = '1';
146 146
         
147 147
         // Set item description
148
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( array( 'id' => $item->ID ) ), ENT_COMPAT, 'UTF-8' ) );
148
+        $paypal_args['item_name'] = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name(array('id' => $item->ID)), ENT_COMPAT, 'UTF-8'));
149 149
         
150
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
150
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
151 151
             $paypal_args['a1']  = $initial_amount;
152 152
             $paypal_args['p1']  = $item->get_trial_interval();
153 153
             $paypal_args['t1']  = $item->get_trial_period();
154 154
             
155 155
             // Set the recurring amount
156 156
             $paypal_args['a3']  = $recurring_amount;
157
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
157
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
158 158
             $paypal_args['a1']  = $initial_amount;
159 159
             $paypal_args['p1']  = $interval;
160 160
             $paypal_args['t1']  = $period;
@@ -162,63 +162,63 @@  discard block
 block discarded – undo
162 162
             // Set the recurring amount
163 163
             $paypal_args['a3']  = $recurring_amount;
164 164
             
165
-            if ( $bill_times > 1 ) {
165
+            if ($bill_times > 1) {
166 166
                 $bill_times--;
167 167
             }
168 168
         } else {
169
-            $paypal_args['a3']  = $initial_amount;
169
+            $paypal_args['a3'] = $initial_amount;
170 170
         }
171 171
         
172 172
         $paypal_args['p3']  = $interval;
173 173
         $paypal_args['t3']  = $period;
174 174
         
175
-        if ( $bill_times > 1 ) {
175
+        if ($bill_times > 1) {
176 176
             // Make sure it's not over the max of 52
177
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
177
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
178 178
         }
179 179
                 
180 180
         // Remove cart items
181 181
         $i = 1;
182
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
183
-            foreach ( $purchase_data['cart_details'] as $item ) {                
184
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
185
-                    unset( $paypal_args['item_number_' . $i] );
182
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
183
+            foreach ($purchase_data['cart_details'] as $item) {                
184
+                if (isset($paypal_args['item_number_' . $i])) {
185
+                    unset($paypal_args['item_number_' . $i]);
186 186
                 }
187
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
188
-                    unset( $paypal_args['item_name_' . $i] );
187
+                if (isset($paypal_args['item_name_' . $i])) {
188
+                    unset($paypal_args['item_name_' . $i]);
189 189
                 }
190
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
191
-                    unset( $paypal_args['quantity_' . $i] );
190
+                if (isset($paypal_args['quantity_' . $i])) {
191
+                    unset($paypal_args['quantity_' . $i]);
192 192
                 }
193
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
194
-                    unset( $paypal_args['amount_' . $i] );
193
+                if (isset($paypal_args['amount_' . $i])) {
194
+                    unset($paypal_args['amount_' . $i]);
195 195
                 }
196
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
197
-                    unset( $paypal_args['discount_amount_' . $i] );
196
+                if (isset($paypal_args['discount_amount_' . $i])) {
197
+                    unset($paypal_args['discount_amount_' . $i]);
198 198
                 }
199 199
 
200 200
                 $i++;
201 201
             }
202 202
         }
203 203
         
204
-        if ( isset( $paypal_args['tax_cart'] ) ) {
205
-            unset( $paypal_args['tax_cart'] );
204
+        if (isset($paypal_args['tax_cart'])) {
205
+            unset($paypal_args['tax_cart']);
206 206
         }
207 207
                 
208
-        if ( isset( $paypal_args['upload'] ) ) {
209
-            unset( $paypal_args['upload'] );
208
+        if (isset($paypal_args['upload'])) {
209
+            unset($paypal_args['upload']);
210 210
         }
211 211
         
212
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
212
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
213 213
     }
214 214
     
215 215
     return $paypal_args;
216 216
 }
217
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
217
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
218 218
 
219 219
 function wpinv_process_paypal_ipn() {
220 220
 	// Check the request method is POST
221
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
221
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
222 222
 		return;
223 223
 	}
224 224
 
@@ -226,11 +226,11 @@  discard block
 block discarded – undo
226 226
 	$post_data = '';
227 227
 
228 228
 	// Fallback just in case post_max_size is lower than needed
229
-	if ( ini_get( 'allow_url_fopen' ) ) {
230
-		$post_data = file_get_contents( 'php://input' );
229
+	if (ini_get('allow_url_fopen')) {
230
+		$post_data = file_get_contents('php://input');
231 231
 	} else {
232 232
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
233
-		ini_set( 'post_max_size', '12M' );
233
+		ini_set('post_max_size', '12M');
234 234
 	}
235 235
 	// Start the encoded data collection with notification command
236 236
 	$encoded_data = 'cmd=_notify-validate';
@@ -239,43 +239,43 @@  discard block
 block discarded – undo
239 239
 	$arg_separator = wpinv_get_php_arg_separator_output();
240 240
 
241 241
 	// Verify there is a post_data
242
-	if ( $post_data || strlen( $post_data ) > 0 ) {
242
+	if ($post_data || strlen($post_data) > 0) {
243 243
 		// Append the data
244
-		$encoded_data .= $arg_separator.$post_data;
244
+		$encoded_data .= $arg_separator . $post_data;
245 245
 	} else {
246 246
 		// Check if POST is empty
247
-		if ( empty( $_POST ) ) {
247
+		if (empty($_POST)) {
248 248
 			// Nothing to do
249 249
 			return;
250 250
 		} else {
251 251
 			// Loop through each POST
252
-			foreach ( $_POST as $key => $value ) {
252
+			foreach ($_POST as $key => $value) {
253 253
 				// Encode the value and append the data
254
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
254
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
255 255
 			}
256 256
 		}
257 257
 	}
258 258
 
259 259
 	// Convert collected post data to an array
260
-	parse_str( $encoded_data, $encoded_data_array );
260
+	parse_str($encoded_data, $encoded_data_array);
261 261
 
262
-	foreach ( $encoded_data_array as $key => $value ) {
263
-		if ( false !== strpos( $key, 'amp;' ) ) {
264
-			$new_key = str_replace( '&amp;', '&', $key );
265
-			$new_key = str_replace( 'amp;', '&' , $new_key );
262
+	foreach ($encoded_data_array as $key => $value) {
263
+		if (false !== strpos($key, 'amp;')) {
264
+			$new_key = str_replace('&amp;', '&', $key);
265
+			$new_key = str_replace('amp;', '&', $new_key);
266 266
 
267
-			unset( $encoded_data_array[ $key ] );
268
-			$encoded_data_array[ $new_key ] = $value;
267
+			unset($encoded_data_array[$key]);
268
+			$encoded_data_array[$new_key] = $value;
269 269
 		}
270 270
 	}
271 271
 
272 272
 	// Get the PayPal redirect uri
273
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
273
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
274 274
 
275
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
275
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
276 276
 		// Validate the IPN
277 277
 
278
-		$remote_post_vars      = array(
278
+		$remote_post_vars = array(
279 279
 			'method'           => 'POST',
280 280
 			'timeout'          => 45,
281 281
 			'redirection'      => 5,
@@ -293,21 +293,21 @@  discard block
 block discarded – undo
293 293
 		);
294 294
 
295 295
 		// Get response
296
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
296
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
297 297
 
298
-		if ( is_wp_error( $api_response ) ) {
299
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
298
+		if (is_wp_error($api_response)) {
299
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
300 300
 			return; // Something went wrong
301 301
 		}
302 302
 
303
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
304
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
303
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
304
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
305 305
 			return; // Response not okay
306 306
 		}
307 307
 	}
308 308
 
309 309
 	// Check if $post_data_array has been populated
310
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
310
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
311 311
 		return;
312 312
 
313 313
 	$defaults = array(
@@ -315,215 +315,215 @@  discard block
 block discarded – undo
315 315
 		'payment_status' => ''
316 316
 	);
317 317
 
318
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
318
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
319 319
 
320
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
320
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
321 321
     
322
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
322
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
323 323
 
324
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
324
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
325 325
 		// Allow PayPal IPN types to be processed separately
326
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
326
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
327 327
 	} else {
328 328
 		// Fallback to web accept just in case the txn_type isn't present
329
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
329
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
330 330
 	}
331 331
 	exit;
332 332
 }
333
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
333
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
334 334
 
335
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
336
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
335
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
336
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
337 337
 		return;
338 338
 	}
339 339
 
340
-	if( empty( $invoice_id ) ) {
340
+	if (empty($invoice_id)) {
341 341
 		return;
342 342
 	}
343 343
 
344 344
 	// Collect payment details
345
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
345
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
346 346
 	$paypal_amount  = $data['mc_gross'];
347
-	$payment_status = strtolower( $data['payment_status'] );
348
-	$currency_code  = strtolower( $data['mc_currency'] );
349
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
350
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
347
+	$payment_status = strtolower($data['payment_status']);
348
+	$currency_code  = strtolower($data['mc_currency']);
349
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
350
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
351 351
 
352
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
352
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
353 353
 		return; // this isn't a PayPal standard IPN
354 354
 	}
355 355
 
356 356
 	// Verify payment recipient
357
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
358
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
359
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
360
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) );
357
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
358
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
359
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
360
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'));
361 361
 		return;
362 362
 	}
363 363
 
364 364
 	// Verify payment currency
365
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
366
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
367
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
368
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) );
365
+	if ($currency_code != strtolower($payment_meta['currency'])) {
366
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
367
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
368
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'));
369 369
 		return;
370 370
 	}
371 371
 
372
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
372
+	if (!wpinv_get_payment_user_email($invoice_id)) {
373 373
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
374 374
 		// No email associated with purchase, so store from PayPal
375
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
375
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
376 376
 
377 377
 		// Setup and store the customer's details
378 378
 		$user_info = array(
379 379
 			'user_id'    => '-1',
380
-			'email'      => sanitize_text_field( $data['payer_email'] ),
381
-			'first_name' => sanitize_text_field( $data['first_name'] ),
382
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
380
+			'email'      => sanitize_text_field($data['payer_email']),
381
+			'first_name' => sanitize_text_field($data['first_name']),
382
+			'last_name'  => sanitize_text_field($data['last_name']),
383 383
 			'discount'   => '',
384 384
 		);
385
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
386
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
387
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
388
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
389
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
385
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
386
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
387
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
388
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
389
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
390 390
 
391 391
 		$payment_meta['user_info'] = $user_info;
392
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
392
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
393 393
 	}
394 394
 
395
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
395
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
396 396
 		// Process a refund
397
-		wpinv_process_paypal_refund( $data, $invoice_id );
397
+		wpinv_process_paypal_refund($data, $invoice_id);
398 398
 	} else {
399
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
399
+		if (get_post_status($invoice_id) == 'publish') {
400 400
 			return; // Only paid payments once
401 401
 		}
402 402
 
403 403
 		// Retrieve the total purchase amount (before PayPal)
404
-		$payment_amount = wpinv_payment_total( $invoice_id );
404
+		$payment_amount = wpinv_payment_total($invoice_id);
405 405
 
406
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
406
+		if (number_format((float)$paypal_amount, 2) < number_format((float)$payment_amount, 2)) {
407 407
 			// The prices don't match
408
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
409
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
410
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) );
408
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
409
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
410
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'));
411 411
 			return;
412 412
 		}
413
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
413
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
414 414
 			// Purchase keys don't match
415
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
416
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
417
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) );
415
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
416
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
417
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'));
418 418
 			return;
419 419
 		}
420 420
 
421
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
422
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) );
423
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
424
-			wpinv_update_payment_status( $invoice_id, 'publish' );
425
-		} else if ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) {
421
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
422
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']));
423
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
424
+			wpinv_update_payment_status($invoice_id, 'publish');
425
+		} else if ('wpi-pending' == $payment_status && isset($data['pending_reason'])) {
426 426
 			// Look for possible pending reasons, such as an echeck
427 427
 			$note = '';
428 428
 
429
-			switch( strtolower( $data['pending_reason'] ) ) {
429
+			switch (strtolower($data['pending_reason'])) {
430 430
 				case 'echeck' :
431
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
431
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
432 432
 					break;
433 433
 				
434 434
                 case 'address' :
435
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
435
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
436 436
 					break;
437 437
 				
438 438
                 case 'intl' :
439
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
439
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
440 440
 					break;
441 441
 				
442 442
                 case 'multi-currency' :
443
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
443
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
444 444
 					break;
445 445
 				
446 446
                 case 'paymentreview' :
447 447
                 case 'regulatory_review' :
448
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
448
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
449 449
 					break;
450 450
 				
451 451
                 case 'unilateral' :
452
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
452
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
453 453
 					break;
454 454
 				
455 455
                 case 'upgrade' :
456
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
456
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
457 457
 					break;
458 458
 				
459 459
                 case 'verify' :
460
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
460
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
461 461
 					break;
462 462
 
463 463
 				case 'other' :
464
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
464
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
465 465
 					break;
466 466
 			}
467 467
 
468
-			if ( ! empty( $note ) ) {
469
-				wpinv_insert_payment_note( $invoice_id, $note );
468
+			if (!empty($note)) {
469
+				wpinv_insert_payment_note($invoice_id, $note);
470 470
 			}
471 471
 		} else {
472
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) );
472
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status));
473 473
 		}
474 474
 	}
475 475
 }
476
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
476
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
477 477
 
478 478
 // Process PayPal subscription sign ups
479
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
479
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
480 480
 
481 481
 // Process PayPal subscription payments
482
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
482
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
483 483
 
484 484
 // Process PayPal subscription cancellations
485
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
485
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
486 486
 
487 487
 // Process PayPal subscription end of term notices
488
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
488
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
489 489
 
490 490
 // Process PayPal payment failed
491
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
491
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
492 492
 
493 493
 
494 494
 /**
495 495
  * Process the subscription started IPN.
496 496
  */
497
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
498
-    $parent_invoice_id = absint( $ipn_data['custom'] );
499
-    if( empty( $parent_invoice_id ) ) {
497
+function wpinv_process_paypal_subscr_signup($ipn_data) {
498
+    $parent_invoice_id = absint($ipn_data['custom']);
499
+    if (empty($parent_invoice_id)) {
500 500
         return;
501 501
     }
502 502
 
503
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
504
-    if ( empty( $invoice ) ) {
503
+    $invoice = wpinv_get_invoice($parent_invoice_id);
504
+    if (empty($invoice)) {
505 505
         return;
506 506
     }
507 507
 
508
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
509
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ) );
510
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['invoice'] );
508
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
509
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']));
510
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['invoice']);
511 511
     }
512 512
     
513
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
513
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
514 514
     sleep(1);
515
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ) );
515
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']));
516 516
     
517
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
518
-    if ( false === $subscription ) {
517
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
518
+    if (false === $subscription) {
519 519
         return;
520 520
     }
521 521
 
522
-    $cart_details   = $invoice->cart_details;
522
+    $cart_details = $invoice->cart_details;
523 523
 
524
-    if ( !empty( $cart_details ) ) {
525
-        foreach ( $cart_details as $cart_item ) {
526
-            $item = new WPInv_Item( $cart_item['id'] );
524
+    if (!empty($cart_details)) {
525
+        foreach ($cart_details as $cart_item) {
526
+            $item = new WPInv_Item($cart_item['id']);
527 527
             
528 528
             $status = $invoice->is_free_trial() && $item->has_free_trial() ? 'trialing' : 'active';
529 529
             
@@ -532,15 +532,15 @@  discard block
 block discarded – undo
532 532
                 'status'            => $status,
533 533
                 'period'            => $item->get_recurring_period(),
534 534
                 'initial_amount'    => $invoice->get_total(),
535
-                'recurring_amount'  => $invoice->get_recurring_details( 'total' ),
535
+                'recurring_amount'  => $invoice->get_recurring_details('total'),
536 536
                 'interval'          => $item->get_recurring_interval(),
537 537
                 'bill_times'        => $item->get_recurring_limit(),
538
-                'expiration'        => $invoice->get_new_expiration( $cart_item['id'] ),
538
+                'expiration'        => $invoice->get_new_expiration($cart_item['id']),
539 539
                 'profile_id'        => $ipn_data['subscr_id'],
540
-                'created'           => date_i18n( 'Y-m-d H:i:s', strtotime( $ipn_data['subscr_date'] ) )
540
+                'created'           => date_i18n('Y-m-d H:i:s', strtotime($ipn_data['subscr_date']))
541 541
             );
542 542
             
543
-            if ( $item->has_free_trial() ) {
543
+            if ($item->has_free_trial()) {
544 544
                 $args['trial_period']      = $item->get_trial_period();
545 545
                 $args['trial_interval']    = $item->get_trial_interval();
546 546
             } else {
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
             }
550 550
             
551 551
 
552
-            $subscription->update_subscription( $args );
552
+            $subscription->update_subscription($args);
553 553
         }
554 554
     }
555 555
 }
@@ -557,39 +557,39 @@  discard block
 block discarded – undo
557 557
 /**
558 558
  * Process the subscription payment received IPN.
559 559
  */
560
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
561
-    $parent_invoice_id = absint( $ipn_data['custom'] );
560
+function wpinv_process_paypal_subscr_payment($ipn_data) {
561
+    $parent_invoice_id = absint($ipn_data['custom']);
562 562
     
563
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
564
-    if ( false === $subscription ) {
563
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
564
+    if (false === $subscription) {
565 565
         return;
566 566
     }
567 567
     
568
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
569
-    $signup_date    = strtotime( $subscription->get_subscription_created() );
570
-    $today          = date_i18n( 'Y-m-d', $signup_date ) == date_i18n( 'Y-m-d', strtotime( $ipn_data['payment_date'] ) );
568
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
569
+    $signup_date    = strtotime($subscription->get_subscription_created());
570
+    $today          = date_i18n('Y-m-d', $signup_date) == date_i18n('Y-m-d', strtotime($ipn_data['payment_date']));
571 571
 
572 572
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
573
-    if ( $today && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
574
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
573
+    if ($today && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
574
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
575 575
         sleep(1);
576 576
         
577 577
         // This is the very first payment
578
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
579
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) );
578
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
579
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']));
580 580
         return;
581 581
     }
582 582
     
583
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
583
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
584 584
         return; // Payment already recorded
585 585
     }
586 586
 
587
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
587
+    $currency_code = strtolower($ipn_data['mc_currency']);
588 588
 
589 589
     // verify details
590
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
590
+    if ($currency_code != strtolower(wpinv_get_currency())) {
591 591
         // the currency code is invalid
592
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
592
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
593 593
         return;
594 594
     }
595 595
 
@@ -598,11 +598,11 @@  discard block
 block discarded – undo
598 598
         'transaction_id' => $ipn_data['txn_id']
599 599
     );
600 600
     
601
-    $invoice = wpinv_recurring_add_subscription_payment( $parent_invoice_id, $args );
601
+    $invoice = wpinv_recurring_add_subscription_payment($parent_invoice_id, $args);
602 602
     
603
-    if ( !empty( $invoice ) ) {
603
+    if (!empty($invoice)) {
604 604
         sleep(1);
605
-        wpinv_insert_payment_note( $invoice->ID, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ) );
605
+        wpinv_insert_payment_note($invoice->ID, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']));
606 606
 
607 607
         $invoice->renew_subscription();
608 608
     }
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 /**
612 612
  * Process the subscription canceled IPN.
613 613
  */
614
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
615
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
614
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
615
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
616 616
 
617
-    if( false === $subscription ) {
617
+    if (false === $subscription) {
618 618
         return;
619 619
     }
620 620
 
@@ -624,10 +624,10 @@  discard block
 block discarded – undo
624 624
 /**
625 625
  * Process the subscription expired IPN.
626 626
  */
627
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
628
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
627
+function wpinv_process_paypal_subscr_eot($ipn_data) {
628
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
629 629
 
630
-    if( false === $subscription ) {
630
+    if (false === $subscription) {
631 631
         return;
632 632
     }
633 633
 
@@ -637,45 +637,45 @@  discard block
 block discarded – undo
637 637
 /**
638 638
  * Process the subscription payment failed IPN.
639 639
  */
640
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
641
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
640
+function wpinv_process_paypal_subscr_failed($ipn_data) {
641
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
642 642
 
643
-    if( false === $subscription ) {
643
+    if (false === $subscription) {
644 644
         return;
645 645
     }
646 646
 
647 647
     $subscription->failing_subscription();
648 648
 
649
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
649
+    do_action('wpinv_recurring_payment_failed', $subscription);
650 650
 }
651 651
 
652 652
 /**
653 653
  * Retrieve the subscription this IPN notice is for.
654 654
  */
655
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
656
-    $parent_invoice_id = absint( $ipn_data['custom'] );
655
+function wpinv_get_paypal_subscription($ipn_data = array()) {
656
+    $parent_invoice_id = absint($ipn_data['custom']);
657 657
 
658
-    if( empty( $parent_invoice_id ) ) {
658
+    if (empty($parent_invoice_id)) {
659 659
         return false;
660 660
     }
661 661
 
662
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
663
-    if ( empty( $invoice ) ) {
662
+    $invoice = wpinv_get_invoice($parent_invoice_id);
663
+    if (empty($invoice)) {
664 664
         return false;
665 665
     }
666 666
 
667
-    $subscription = wpinv_get_subscription( $ipn_data['subscr_id'], true );
667
+    $subscription = wpinv_get_subscription($ipn_data['subscr_id'], true);
668 668
 
669
-    if ( empty( $subscription ) ) {
670
-        $subs         = wpinv_get_subscriptions( array( 'parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1 ) );
671
-        $subscription = reset( $subs );
669
+    if (empty($subscription)) {
670
+        $subs         = wpinv_get_subscriptions(array('parent_invoice_id' => $parent_invoice_id, 'numberposts' => 1));
671
+        $subscription = reset($subs);
672 672
 
673
-        if ( $subscription && $subscription->ID > 0 ) {
673
+        if ($subscription && $subscription->ID > 0) {
674 674
             // Update the profile ID so it is set for future renewals
675
-            $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
675
+            $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
676 676
         } else {
677 677
             $subscription = $invoice;
678
-            $subscription->update_subscription( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
678
+            $subscription->update_subscription(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
679 679
             // No subscription found with a matching payment ID, bail
680 680
             //return false;
681 681
         }
@@ -685,39 +685,39 @@  discard block
 block discarded – undo
685 685
 
686 686
 }
687 687
 
688
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
688
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
689 689
 	// Collect payment details
690 690
 
691
-	if( empty( $invoice_id ) ) {
691
+	if (empty($invoice_id)) {
692 692
 		return;
693 693
 	}
694 694
 
695
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
695
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
696 696
 		return; // Only refund payments once
697 697
 	}
698 698
 
699
-	$payment_amount = wpinv_payment_total( $invoice_id );
699
+	$payment_amount = wpinv_payment_total($invoice_id);
700 700
 	$refund_amount  = $data['mc_gross'] * -1;
701 701
 
702
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
703
-		wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) );
702
+	if (number_format((float)$refund_amount, 2) < number_format((float)$payment_amount, 2)) {
703
+		wpinv_insert_payment_note($invoice_id, sprintf(__('Partial PayPal refund processed: %s', 'invoicing'), $data['parent_txn_id']));
704 704
 		return; // This is a partial refund
705 705
 	}
706 706
 
707
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) );
708
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) );
709
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
707
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']));
708
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']));
709
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
710 710
 }
711 711
 
712
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
713
-    if ( is_ssl() || ! $ssl_check ) {
712
+function wpinv_get_paypal_redirect($ssl_check = false) {
713
+    if (is_ssl() || !$ssl_check) {
714 714
         $protocol = 'https://';
715 715
     } else {
716 716
         $protocol = 'http://';
717 717
     }
718 718
 
719 719
     // Check the current payment mode
720
-    if ( wpinv_is_test_mode( 'paypal' ) ) {
720
+    if (wpinv_is_test_mode('paypal')) {
721 721
         // Test mode
722 722
         $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
723 723
     } else {
@@ -725,67 +725,67 @@  discard block
 block discarded – undo
725 725
         $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
726 726
     }
727 727
 
728
-    return apply_filters( 'wpinv_paypal_uri', $paypal_uri );
728
+    return apply_filters('wpinv_paypal_uri', $paypal_uri);
729 729
 }
730 730
 
731
-function wpinv_paypal_success_page_content( $content ) {
731
+function wpinv_paypal_success_page_content($content) {
732 732
     global $wpi_invoice;
733 733
     
734 734
     $session = wpinv_get_checkout_session();
735 735
 
736
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
736
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
737 737
         return $content;
738 738
     }
739 739
 
740
-    $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
740
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
741 741
 
742
-    if ( empty(  $invoice_id ) ) {
742
+    if (empty($invoice_id)) {
743 743
         return $content;
744 744
     }
745 745
 
746
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
746
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
747 747
     
748
-    if ( !empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
748
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
749 749
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
750 750
         ob_start();
751
-        wpinv_get_template_part( 'wpinv-payment-processing' );
751
+        wpinv_get_template_part('wpinv-payment-processing');
752 752
         $content = ob_get_clean();
753 753
     }
754 754
 
755 755
     return $content;
756 756
 }
757
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
757
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
758 758
 
759
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
759
+function wpinv_paypal_get_transaction_id($invoice_id) {
760 760
     $transaction_id = '';
761
-    $notes = wpinv_get_invoice_notes( $invoice_id );
761
+    $notes = wpinv_get_invoice_notes($invoice_id);
762 762
 
763
-    foreach ( $notes as $note ) {
764
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
763
+    foreach ($notes as $note) {
764
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
765 765
             $transaction_id = $match[1];
766 766
             continue;
767 767
         }
768 768
     }
769 769
 
770
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
770
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
771 771
 }
772
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
772
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
773 773
 
774
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
775
-    if ( $invoice->is_free_trial() || $transaction_id == $invoice_id ) { // Free trial does not have transaction at PayPal.
774
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
775
+    if ($invoice->is_free_trial() || $transaction_id == $invoice_id) { // Free trial does not have transaction at PayPal.
776 776
         $transaction_url = $invoice->get_view_url();
777 777
     } else {
778
-        $sandbox = wpinv_is_test_mode( 'paypal' ) ? '.sandbox' : '';
778
+        $sandbox = wpinv_is_test_mode('paypal') ? '.sandbox' : '';
779 779
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_view-a-trans&id=' . $transaction_id;
780 780
     }
781 781
 
782
-    $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
782
+    $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
783 783
 
784
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice );
784
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $invoice);
785 785
 }
786
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
786
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
787 787
 
788 788
 function wpinv_gateway_paypal_button_label($label) {
789
-    return __( 'Proceed to PayPal', 'invoicing' );
789
+    return __('Proceed to PayPal', 'invoicing');
790 790
 }
791
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
792 791
\ No newline at end of file
792
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
793 793
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-email-functions.php 1 patch
Spacing   +506 added lines, -506 removed lines patch added patch discarded remove patch
@@ -7,12 +7,12 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_init_transactional_emails() {
15
-    $email_actions = apply_filters( 'wpinv_email_actions', array(
15
+    $email_actions = apply_filters('wpinv_email_actions', array(
16 16
         'wpinv_status_wpi-pending_to_wpi-processing',
17 17
         'wpinv_status_wpi-pending_to_publish',
18 18
         'wpinv_status_wpi-pending_to_wpi-cancelled',
@@ -28,79 +28,79 @@  discard block
 block discarded – undo
28 28
         'wpinv_fully_refunded',
29 29
         'wpinv_partially_refunded',
30 30
         'wpinv_new_invoice_note'
31
-    ) );
31
+    ));
32 32
 
33
-    foreach ( $email_actions as $action ) {
34
-        add_action( $action, 'wpinv_send_transactional_email', 10, 10 );
33
+    foreach ($email_actions as $action) {
34
+        add_action($action, 'wpinv_send_transactional_email', 10, 10);
35 35
     }
36 36
 }
37
-add_action( 'init', 'wpinv_init_transactional_emails' );
37
+add_action('init', 'wpinv_init_transactional_emails');
38 38
 
39 39
 // New invoice email
40
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
41
-add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' );
42
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
43
-add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' );
44
-add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' );
45
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' );
40
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
41
+add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification');
42
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
43
+add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification');
44
+add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification');
45
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification');
46 46
 
47 47
 // Cancelled invoice email
48
-add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
49
-add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' );
48
+add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
49
+add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification');
50 50
 
51 51
 // Failed invoice email
52
-add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
53
-add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' );
52
+add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
53
+add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification');
54 54
 
55 55
 // On hold invoice email
56
-add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
57
-add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' );
56
+add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
57
+add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification');
58 58
 
59 59
 // Processing invoice email
60
-add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' );
60
+add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification');
61 61
 
62 62
 // Paid invoice email
63
-add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' );
63
+add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification');
64 64
 
65 65
 // Refunded invoice email
66
-add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' );
67
-add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' );
66
+add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification');
67
+add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification');
68 68
 
69 69
 // Invoice note
70
-add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' );
70
+add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification');
71 71
 
72
-add_action( 'wpinv_email_header', 'wpinv_email_header' );
73
-add_action( 'wpinv_email_footer', 'wpinv_email_footer' );
74
-add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 );
75
-add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 );
76
-add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 );
77
-add_action( 'wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4 );
72
+add_action('wpinv_email_header', 'wpinv_email_header');
73
+add_action('wpinv_email_footer', 'wpinv_email_footer');
74
+add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3);
75
+add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3);
76
+add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3);
77
+add_action('wpinv_email_before_note_details', 'wpinv_email_before_note_details', 10, 4);
78 78
 
79 79
 function wpinv_send_transactional_email() {
80 80
     $args       = func_get_args();
81 81
     $function   = current_filter() . '_notification';
82
-    do_action_ref_array( $function, $args );
82
+    do_action_ref_array($function, $args);
83 83
 }
84 84
     
85
-function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) {
85
+function wpinv_new_invoice_notification($invoice_id, $new_status = '') {
86 86
     global $wpinv_email_search, $wpinv_email_replace;
87 87
     
88 88
     $email_type = 'new_invoice';
89
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
89
+    if (!wpinv_email_is_enabled($email_type)) {
90 90
         return false;
91 91
     }
92 92
     
93
-    $invoice = wpinv_get_invoice( $invoice_id );
94
-    if ( empty( $invoice ) ) {
93
+    $invoice = wpinv_get_invoice($invoice_id);
94
+    if (empty($invoice)) {
95 95
         return false;
96 96
     }
97 97
 
98
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
98
+    if (!("wpi_invoice" === $invoice->post_type)) {
99 99
         return false;
100 100
     }
101 101
     
102
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
103
-    if ( !is_email( $recipient ) ) {
102
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
103
+    if (!is_email($recipient)) {
104 104
         return false;
105 105
     }
106 106
         
@@ -117,41 +117,41 @@  discard block
 block discarded – undo
117 117
     $wpinv_email_search     = $search;
118 118
     $wpinv_email_replace    = $replace;
119 119
     
120
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
121
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
122
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
123
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
120
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
121
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
122
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
123
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
124 124
     
125
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
125
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
126 126
             'invoice'       => $invoice,
127 127
             'email_type'    => $email_type,
128 128
             'email_heading' => $email_heading,
129 129
             'sent_to_admin' => true,
130 130
             'plain_text'    => false,
131
-        ) );
131
+        ));
132 132
     
133
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
133
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
134 134
 }
135 135
 
136
-function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) {
136
+function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') {
137 137
     global $wpinv_email_search, $wpinv_email_replace;
138 138
     
139 139
     $email_type = 'cancelled_invoice';
140
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
140
+    if (!wpinv_email_is_enabled($email_type)) {
141 141
         return false;
142 142
     }
143 143
     
144
-    $invoice = wpinv_get_invoice( $invoice_id );
145
-    if ( empty( $invoice ) ) {
144
+    $invoice = wpinv_get_invoice($invoice_id);
145
+    if (empty($invoice)) {
146 146
         return false;
147 147
     }
148 148
 
149
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
149
+    if (!("wpi_invoice" === $invoice->post_type)) {
150 150
         return false;
151 151
     }
152 152
     
153
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
154
-    if ( !is_email( $recipient ) ) {
153
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
154
+    if (!is_email($recipient)) {
155 155
         return false;
156 156
     }
157 157
         
@@ -168,41 +168,41 @@  discard block
 block discarded – undo
168 168
     $wpinv_email_search     = $search;
169 169
     $wpinv_email_replace    = $replace;
170 170
     
171
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
172
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
173
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
174
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
171
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
172
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
173
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
174
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
175 175
     
176
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
176
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
177 177
             'invoice'       => $invoice,
178 178
             'email_type'    => $email_type,
179 179
             'email_heading' => $email_heading,
180 180
             'sent_to_admin' => true,
181 181
             'plain_text'    => false,
182
-        ) );
182
+        ));
183 183
     
184
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
184
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
185 185
 }
186 186
 
187
-function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) {
187
+function wpinv_failed_invoice_notification($invoice_id, $new_status = '') {
188 188
     global $wpinv_email_search, $wpinv_email_replace;
189 189
     
190 190
     $email_type = 'failed_invoice';
191
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
191
+    if (!wpinv_email_is_enabled($email_type)) {
192 192
         return false;
193 193
     }
194 194
     
195
-    $invoice = wpinv_get_invoice( $invoice_id );
196
-    if ( empty( $invoice ) ) {
195
+    $invoice = wpinv_get_invoice($invoice_id);
196
+    if (empty($invoice)) {
197 197
         return false;
198 198
     }
199 199
 
200
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
200
+    if (!("wpi_invoice" === $invoice->post_type)) {
201 201
         return false;
202 202
     }
203 203
     
204
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
205
-    if ( !is_email( $recipient ) ) {
204
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
205
+    if (!is_email($recipient)) {
206 206
         return false;
207 207
     }
208 208
         
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
     $wpinv_email_search     = $search;
220 220
     $wpinv_email_replace    = $replace;
221 221
     
222
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
223
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
224
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
225
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
222
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
223
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
224
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
225
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
226 226
     
227
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
227
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
228 228
             'invoice'       => $invoice,
229 229
             'email_type'    => $email_type,
230 230
             'email_heading' => $email_heading,
231 231
             'sent_to_admin' => true,
232 232
             'plain_text'    => false,
233
-        ) );
233
+        ));
234 234
     
235
-    return wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
235
+    return wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
236 236
 }
237 237
 
238
-function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) {
238
+function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') {
239 239
     global $wpinv_email_search, $wpinv_email_replace;
240 240
     
241 241
     $email_type = 'onhold_invoice';
242
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
242
+    if (!wpinv_email_is_enabled($email_type)) {
243 243
         return false;
244 244
     }
245 245
     
246
-    $invoice = wpinv_get_invoice( $invoice_id );
247
-    if ( empty( $invoice ) ) {
246
+    $invoice = wpinv_get_invoice($invoice_id);
247
+    if (empty($invoice)) {
248 248
         return false;
249 249
     }
250 250
 
251
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
251
+    if (!("wpi_invoice" === $invoice->post_type)) {
252 252
         return false;
253 253
     }
254 254
     
255
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
256
-    if ( !is_email( $recipient ) ) {
255
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
256
+    if (!is_email($recipient)) {
257 257
         return false;
258 258
     }
259 259
         
@@ -270,49 +270,49 @@  discard block
 block discarded – undo
270 270
     $wpinv_email_search     = $search;
271 271
     $wpinv_email_replace    = $replace;
272 272
     
273
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
274
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
275
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
276
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
273
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
274
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
275
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
276
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
277 277
     
278
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
278
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
279 279
             'invoice'       => $invoice,
280 280
             'email_type'    => $email_type,
281 281
             'email_heading' => $email_heading,
282 282
             'sent_to_admin' => false,
283 283
             'plain_text'    => false,
284
-        ) );
284
+        ));
285 285
     
286
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
286
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
287 287
     
288
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
289
-        $recipient  = wpinv_get_admin_email();
290
-        $subject    .= ' - ADMIN BCC COPY';
291
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
288
+    if (wpinv_mail_admin_bcc_active($email_type)) {
289
+        $recipient = wpinv_get_admin_email();
290
+        $subject .= ' - ADMIN BCC COPY';
291
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
292 292
     }
293 293
     
294 294
     return $sent;
295 295
 }
296 296
 
297
-function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) {
297
+function wpinv_processing_invoice_notification($invoice_id, $new_status = '') {
298 298
     global $wpinv_email_search, $wpinv_email_replace;
299 299
     
300 300
     $email_type = 'processing_invoice';
301
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
301
+    if (!wpinv_email_is_enabled($email_type)) {
302 302
         return false;
303 303
     }
304 304
     
305
-    $invoice = wpinv_get_invoice( $invoice_id );
306
-    if ( empty( $invoice ) ) {
305
+    $invoice = wpinv_get_invoice($invoice_id);
306
+    if (empty($invoice)) {
307 307
         return false;
308 308
     }
309 309
 
310
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
310
+    if (!("wpi_invoice" === $invoice->post_type)) {
311 311
         return false;
312 312
     }
313 313
     
314
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
315
-    if ( !is_email( $recipient ) ) {
314
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
315
+    if (!is_email($recipient)) {
316 316
         return false;
317 317
     }
318 318
         
@@ -329,49 +329,49 @@  discard block
 block discarded – undo
329 329
     $wpinv_email_search     = $search;
330 330
     $wpinv_email_replace    = $replace;
331 331
     
332
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
333
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
334
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
335
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
332
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
333
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
334
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
335
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
336 336
     
337
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
337
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
338 338
             'invoice'       => $invoice,
339 339
             'email_type'    => $email_type,
340 340
             'email_heading' => $email_heading,
341 341
             'sent_to_admin' => false,
342 342
             'plain_text'    => false,
343
-        ) );
343
+        ));
344 344
     
345
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
345
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
346 346
     
347
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
348
-        $recipient  = wpinv_get_admin_email();
349
-        $subject    .= ' - ADMIN BCC COPY';
350
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
347
+    if (wpinv_mail_admin_bcc_active($email_type)) {
348
+        $recipient = wpinv_get_admin_email();
349
+        $subject .= ' - ADMIN BCC COPY';
350
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
351 351
     }
352 352
     
353 353
     return $sent;
354 354
 }
355 355
 
356
-function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) {
356
+function wpinv_completed_invoice_notification($invoice_id, $new_status = '') {
357 357
     global $wpinv_email_search, $wpinv_email_replace;
358 358
     
359 359
     $email_type = 'completed_invoice';
360
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
360
+    if (!wpinv_email_is_enabled($email_type)) {
361 361
         return false;
362 362
     }
363 363
     
364
-    $invoice = wpinv_get_invoice( $invoice_id );
365
-    if ( empty( $invoice ) ) {
364
+    $invoice = wpinv_get_invoice($invoice_id);
365
+    if (empty($invoice)) {
366 366
         return false;
367 367
     }
368 368
 
369
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
369
+    if (!("wpi_invoice" === $invoice->post_type)) {
370 370
         return false;
371 371
     }
372 372
     
373
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
374
-    if ( !is_email( $recipient ) ) {
373
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
374
+    if (!is_email($recipient)) {
375 375
         return false;
376 376
     }
377 377
         
@@ -388,49 +388,49 @@  discard block
 block discarded – undo
388 388
     $wpinv_email_search     = $search;
389 389
     $wpinv_email_replace    = $replace;
390 390
     
391
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
392
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
393
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
394
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
391
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
392
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
393
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
394
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
395 395
     
396
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
396
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
397 397
             'invoice'       => $invoice,
398 398
             'email_type'    => $email_type,
399 399
             'email_heading' => $email_heading,
400 400
             'sent_to_admin' => false,
401 401
             'plain_text'    => false,
402
-        ) );
402
+        ));
403 403
     
404
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
404
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
405 405
     
406
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
407
-        $recipient  = wpinv_get_admin_email();
408
-        $subject    .= ' - ADMIN BCC COPY';
409
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
406
+    if (wpinv_mail_admin_bcc_active($email_type)) {
407
+        $recipient = wpinv_get_admin_email();
408
+        $subject .= ' - ADMIN BCC COPY';
409
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
410 410
     }
411 411
     
412 412
     return $sent;
413 413
 }
414 414
 
415
-function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) {
415
+function wpinv_fully_refunded_notification($invoice_id, $new_status = '') {
416 416
     global $wpinv_email_search, $wpinv_email_replace;
417 417
     
418 418
     $email_type = 'refunded_invoice';
419
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
419
+    if (!wpinv_email_is_enabled($email_type)) {
420 420
         return false;
421 421
     }
422 422
     
423
-    $invoice = wpinv_get_invoice( $invoice_id );
424
-    if ( empty( $invoice ) ) {
423
+    $invoice = wpinv_get_invoice($invoice_id);
424
+    if (empty($invoice)) {
425 425
         return false;
426 426
     }
427 427
 
428
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
428
+    if (!("wpi_invoice" === $invoice->post_type)) {
429 429
         return false;
430 430
     }
431 431
     
432
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
433
-    if ( !is_email( $recipient ) ) {
432
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
433
+    if (!is_email($recipient)) {
434 434
         return false;
435 435
     }
436 436
         
@@ -447,50 +447,50 @@  discard block
 block discarded – undo
447 447
     $wpinv_email_search     = $search;
448 448
     $wpinv_email_replace    = $replace;
449 449
     
450
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
451
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
452
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
453
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
450
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
451
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
452
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
453
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
454 454
     
455
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
455
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
456 456
             'invoice'           => $invoice,
457 457
             'email_type'        => $email_type,
458 458
             'email_heading'     => $email_heading,
459 459
             'sent_to_admin'     => false,
460 460
             'plain_text'        => false,
461 461
             'partial_refund'    => false
462
-        ) );
462
+        ));
463 463
     
464
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
464
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
465 465
     
466
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
467
-        $recipient  = wpinv_get_admin_email();
468
-        $subject    .= ' - ADMIN BCC COPY';
469
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
466
+    if (wpinv_mail_admin_bcc_active($email_type)) {
467
+        $recipient = wpinv_get_admin_email();
468
+        $subject .= ' - ADMIN BCC COPY';
469
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
470 470
     }
471 471
     
472 472
     return $sent;
473 473
 }
474 474
 
475
-function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) {
475
+function wpinv_partially_refunded_notification($invoice_id, $new_status = '') {
476 476
     global $wpinv_email_search, $wpinv_email_replace;
477 477
     
478 478
     $email_type = 'refunded_invoice';
479
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
479
+    if (!wpinv_email_is_enabled($email_type)) {
480 480
         return false;
481 481
     }
482 482
     
483
-    $invoice = wpinv_get_invoice( $invoice_id );
484
-    if ( empty( $invoice ) ) {
483
+    $invoice = wpinv_get_invoice($invoice_id);
484
+    if (empty($invoice)) {
485 485
         return false;
486 486
     }
487 487
 
488
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
488
+    if (!("wpi_invoice" === $invoice->post_type)) {
489 489
         return false;
490 490
     }
491 491
     
492
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
493
-    if ( !is_email( $recipient ) ) {
492
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
493
+    if (!is_email($recipient)) {
494 494
         return false;
495 495
     }
496 496
         
@@ -507,53 +507,53 @@  discard block
 block discarded – undo
507 507
     $wpinv_email_search     = $search;
508 508
     $wpinv_email_replace    = $replace;
509 509
     
510
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
511
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
512
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
513
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
510
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
511
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
512
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
513
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
514 514
     
515
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
515
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
516 516
             'invoice'           => $invoice,
517 517
             'email_type'        => $email_type,
518 518
             'email_heading'     => $email_heading,
519 519
             'sent_to_admin'     => false,
520 520
             'plain_text'        => false,
521 521
             'partial_refund'    => true
522
-        ) );
522
+        ));
523 523
     
524
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
524
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
525 525
     
526
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
527
-        $recipient  = wpinv_get_admin_email();
528
-        $subject    .= ' - ADMIN BCC COPY';
529
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
526
+    if (wpinv_mail_admin_bcc_active($email_type)) {
527
+        $recipient = wpinv_get_admin_email();
528
+        $subject .= ' - ADMIN BCC COPY';
529
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
530 530
     }
531 531
     
532 532
     return $sent;
533 533
 }
534 534
 
535
-function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) {
535
+function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') {
536 536
 }
537 537
 
538
-function wpinv_user_invoice_notification( $invoice_id ) {
538
+function wpinv_user_invoice_notification($invoice_id) {
539 539
     global $wpinv_email_search, $wpinv_email_replace;
540 540
     
541 541
     $email_type = 'user_invoice';
542
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
542
+    if (!wpinv_email_is_enabled($email_type)) {
543 543
         return false;
544 544
     }
545 545
     
546
-    $invoice = wpinv_get_invoice( $invoice_id );
547
-    if ( empty( $invoice ) ) {
546
+    $invoice = wpinv_get_invoice($invoice_id);
547
+    if (empty($invoice)) {
548 548
         return false;
549 549
     }
550 550
 
551
-    if ( !("wpi_invoice" === $invoice->post_type) ) {
551
+    if (!("wpi_invoice" === $invoice->post_type)) {
552 552
         return false;
553 553
     }
554 554
     
555
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
556
-    if ( !is_email( $recipient ) ) {
555
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
556
+    if (!is_email($recipient)) {
557 557
         return false;
558 558
     }
559 559
         
@@ -570,53 +570,53 @@  discard block
 block discarded – undo
570 570
     $wpinv_email_search     = $search;
571 571
     $wpinv_email_replace    = $replace;
572 572
     
573
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
574
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
575
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
576
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
573
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
574
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
575
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
576
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
577 577
     
578
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
578
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
579 579
             'invoice'       => $invoice,
580 580
             'email_type'    => $email_type,
581 581
             'email_heading' => $email_heading,
582 582
             'sent_to_admin' => false,
583 583
             'plain_text'    => false,
584
-        ) );
584
+        ));
585 585
     
586
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
586
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
587 587
     
588
-    if ( $sent ) {
589
-        $note = __( 'Invoice has been emailed to the user.', 'invoicing' );
588
+    if ($sent) {
589
+        $note = __('Invoice has been emailed to the user.', 'invoicing');
590 590
     } else {
591
-        $note = __( 'Fail to send invoice to the user!', 'invoicing' );
591
+        $note = __('Fail to send invoice to the user!', 'invoicing');
592 592
     }
593 593
     
594
-    $invoice->add_note( $note, '', '', true ); // Add system note.
594
+    $invoice->add_note($note, '', '', true); // Add system note.
595 595
 
596
-    if ( wpinv_mail_admin_bcc_active( $email_type ) ) {
597
-        $recipient  = wpinv_get_admin_email();
598
-        $subject    .= ' - ADMIN BCC COPY';
599
-        wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
596
+    if (wpinv_mail_admin_bcc_active($email_type)) {
597
+        $recipient = wpinv_get_admin_email();
598
+        $subject .= ' - ADMIN BCC COPY';
599
+        wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
600 600
     }
601 601
     
602 602
     return $sent;
603 603
 }
604 604
 
605
-function wpinv_user_note_notification( $invoice_id, $args = array() ) {
605
+function wpinv_user_note_notification($invoice_id, $args = array()) {
606 606
     global $wpinv_email_search, $wpinv_email_replace;
607 607
     
608 608
     $email_type = 'user_note';
609
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
609
+    if (!wpinv_email_is_enabled($email_type)) {
610 610
         return false;
611 611
     }
612 612
     
613
-    $invoice = wpinv_get_invoice( $invoice_id );
614
-    if ( empty( $invoice ) ) {
613
+    $invoice = wpinv_get_invoice($invoice_id);
614
+    if (empty($invoice)) {
615 615
         return false;
616 616
     }
617 617
     
618
-    $recipient      = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
619
-    if ( !is_email( $recipient ) ) {
618
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
619
+    if (!is_email($recipient)) {
620 620
         return false;
621 621
     }
622 622
     
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
         'user_note' => ''
625 625
     );
626 626
 
627
-    $args = wp_parse_args( $args, $defaults );
627
+    $args = wp_parse_args($args, $defaults);
628 628
         
629 629
     $search                     = array();
630 630
     $search['invoice_number']   = '{invoice_number}';
@@ -643,46 +643,46 @@  discard block
 block discarded – undo
643 643
     $wpinv_email_search     = $search;
644 644
     $wpinv_email_replace    = $replace;
645 645
     
646
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
647
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
648
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
649
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
646
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
647
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
648
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
649
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
650 650
     
651
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
651
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
652 652
             'invoice'       => $invoice,
653 653
             'email_type'    => $email_type,
654 654
             'email_heading' => $email_heading,
655 655
             'sent_to_admin' => false,
656 656
             'plain_text'    => false,
657 657
             'customer_note' => $args['user_note']
658
-        ) );
658
+        ));
659 659
         
660
-    $content        = wpinv_email_format_text( $content );
660
+    $content = wpinv_email_format_text($content);
661 661
     
662
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
662
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
663 663
         
664 664
     return $sent;
665 665
 }
666 666
 
667 667
 function wpinv_mail_get_from_address() {
668
-    $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) );
669
-    return sanitize_email( $from_address );
668
+    $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from'));
669
+    return sanitize_email($from_address);
670 670
 }
671 671
 
672 672
 function wpinv_mail_get_from_name() {
673
-    $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) );
674
-    return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES );
673
+    $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name'));
674
+    return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES);
675 675
 }
676 676
 
677
-function wpinv_mail_admin_bcc_active( $mail_type = '' ) {
678
-    $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) );
679
-    return ( $active ? true : false );
677
+function wpinv_mail_admin_bcc_active($mail_type = '') {
678
+    $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc'));
679
+    return ($active ? true : false);
680 680
 }
681 681
     
682
-function wpinv_mail_get_content_type(  $content_type = 'text/html', $email_type = 'html' ) {
683
-    $email_type = apply_filters( 'wpinv_mail_content_type', $email_type );
682
+function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') {
683
+    $email_type = apply_filters('wpinv_mail_content_type', $email_type);
684 684
     
685
-    switch ( $email_type ) {
685
+    switch ($email_type) {
686 686
         case 'html' :
687 687
             $content_type = 'text/html';
688 688
             break;
@@ -697,35 +697,35 @@  discard block
 block discarded – undo
697 697
     return $content_type;
698 698
 }
699 699
     
700
-function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) {
701
-    add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
702
-    add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
703
-    add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
700
+function wpinv_mail_send($to, $subject, $message, $headers, $attachments) {
701
+    add_filter('wp_mail_from', 'wpinv_mail_get_from_address');
702
+    add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
703
+    add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
704 704
 
705
-    $message = wpinv_email_style_body( $message );
706
-    $message = apply_filters( 'wpinv_mail_content', $message );
705
+    $message = wpinv_email_style_body($message);
706
+    $message = apply_filters('wpinv_mail_content', $message);
707 707
     
708
-    $sent  = wp_mail( $to, $subject, $message, $headers, $attachments );
708
+    $sent = wp_mail($to, $subject, $message, $headers, $attachments);
709 709
     
710
-    if ( !$sent ) {
711
-        $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject );
712
-        wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ );
710
+    if (!$sent) {
711
+        $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject);
712
+        wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__);
713 713
     }
714 714
 
715
-    remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' );
716
-    remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' );
717
-    remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' );
715
+    remove_filter('wp_mail_from', 'wpinv_mail_get_from_address');
716
+    remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name');
717
+    remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type');
718 718
 
719 719
     return $sent;
720 720
 }
721 721
     
722 722
 function wpinv_get_emails() {
723 723
     $overdue_days_options       = array();
724
-    $overdue_days_options[0]    = __( 'On the Due Date', 'invoicing' );
725
-    $overdue_days_options[1]    = __( '1 day after Due Date', 'invoicing' );
724
+    $overdue_days_options[0]    = __('On the Due Date', 'invoicing');
725
+    $overdue_days_options[1]    = __('1 day after Due Date', 'invoicing');
726 726
     
727
-    for ( $i = 2; $i <= 10; $i++ ) {
728
-        $overdue_days_options[$i]   = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i );
727
+    for ($i = 2; $i <= 10; $i++) {
728
+        $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i);
729 729
     }
730 730
 
731 731
     // Default, built-in gateways
@@ -733,130 +733,130 @@  discard block
 block discarded – undo
733 733
             'new_invoice' => array(
734 734
             'email_new_invoice_header' => array(
735 735
                 'id'   => 'email_new_invoice_header',
736
-                'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>',
737
-                'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ),
736
+                'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>',
737
+                'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'),
738 738
                 'type' => 'header',
739 739
             ),
740 740
             'email_new_invoice_active' => array(
741 741
                 'id'   => 'email_new_invoice_active',
742
-                'name' => __( 'Enable/Disable', 'invoicing' ),
743
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
742
+                'name' => __('Enable/Disable', 'invoicing'),
743
+                'desc' => __('Enable this email notification', 'invoicing'),
744 744
                 'type' => 'checkbox',
745 745
                 'std'  => 1
746 746
             ),
747 747
             'email_new_invoice_subject' => array(
748 748
                 'id'   => 'email_new_invoice_subject',
749
-                'name' => __( 'Subject', 'invoicing' ),
750
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
749
+                'name' => __('Subject', 'invoicing'),
750
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
751 751
                 'type' => 'text',
752
-                'std'  => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ),
752
+                'std'  => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'),
753 753
                 'size' => 'large'
754 754
             ),
755 755
             'email_new_invoice_heading' => array(
756 756
                 'id'   => 'email_new_invoice_heading',
757
-                'name' => __( 'Email Heading', 'invoicing' ),
758
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
757
+                'name' => __('Email Heading', 'invoicing'),
758
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
759 759
                 'type' => 'text',
760
-                'std'  => __( 'New payment invoice', 'invoicing' ),
760
+                'std'  => __('New payment invoice', 'invoicing'),
761 761
                 'size' => 'large'
762 762
             ),
763 763
         ),
764 764
         'cancelled_invoice' => array(
765 765
             'email_cancelled_invoice_header' => array(
766 766
                 'id'   => 'email_cancelled_invoice_header',
767
-                'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>',
768
-                'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ),
767
+                'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>',
768
+                'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'),
769 769
                 'type' => 'header',
770 770
             ),
771 771
             'email_cancelled_invoice_active' => array(
772 772
                 'id'   => 'email_cancelled_invoice_active',
773
-                'name' => __( 'Enable/Disable', 'invoicing' ),
774
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
773
+                'name' => __('Enable/Disable', 'invoicing'),
774
+                'desc' => __('Enable this email notification', 'invoicing'),
775 775
                 'type' => 'checkbox',
776 776
                 'std'  => 1
777 777
             ),
778 778
             'email_cancelled_invoice_subject' => array(
779 779
                 'id'   => 'email_cancelled_invoice_subject',
780
-                'name' => __( 'Subject', 'invoicing' ),
781
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
780
+                'name' => __('Subject', 'invoicing'),
781
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
782 782
                 'type' => 'text',
783
-                'std'  => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ),
783
+                'std'  => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'),
784 784
                 'size' => 'large'
785 785
             ),
786 786
             'email_cancelled_invoice_heading' => array(
787 787
                 'id'   => 'email_cancelled_invoice_heading',
788
-                'name' => __( 'Email Heading', 'invoicing' ),
789
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
788
+                'name' => __('Email Heading', 'invoicing'),
789
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
790 790
                 'type' => 'text',
791
-                'std'  => __( 'Cancelled invoice', 'invoicing' ),
791
+                'std'  => __('Cancelled invoice', 'invoicing'),
792 792
                 'size' => 'large'
793 793
             ),
794 794
         ),
795 795
         'failed_invoice' => array(
796 796
             'email_failed_invoice_header' => array(
797 797
                 'id'   => 'email_failed_invoice_header',
798
-                'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>',
799
-                'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ),
798
+                'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>',
799
+                'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'),
800 800
                 'type' => 'header',
801 801
             ),
802 802
             'email_failed_invoice_active' => array(
803 803
                 'id'   => 'email_failed_invoice_active',
804
-                'name' => __( 'Enable/Disable', 'invoicing' ),
805
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
804
+                'name' => __('Enable/Disable', 'invoicing'),
805
+                'desc' => __('Enable this email notification', 'invoicing'),
806 806
                 'type' => 'checkbox',
807 807
                 'std'  => 1
808 808
             ),
809 809
             'email_failed_invoice_subject' => array(
810 810
                 'id'   => 'email_failed_invoice_subject',
811
-                'name' => __( 'Subject', 'invoicing' ),
812
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
811
+                'name' => __('Subject', 'invoicing'),
812
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
813 813
                 'type' => 'text',
814
-                'std'  => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ),
814
+                'std'  => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'),
815 815
                 'size' => 'large'
816 816
             ),
817 817
             'email_failed_invoice_heading' => array(
818 818
                 'id'   => 'email_failed_invoice_heading',
819
-                'name' => __( 'Email Heading', 'invoicing' ),
820
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
819
+                'name' => __('Email Heading', 'invoicing'),
820
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
821 821
                 'type' => 'text',
822
-                'std'  => __( 'Failed invoice', 'invoicing' ),
822
+                'std'  => __('Failed invoice', 'invoicing'),
823 823
                 'size' => 'large'
824 824
             )
825 825
         ),
826 826
         'onhold_invoice' => array(
827 827
             'email_onhold_invoice_header' => array(
828 828
                 'id'   => 'email_onhold_invoice_header',
829
-                'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>',
830
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ),
829
+                'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>',
830
+                'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'),
831 831
                 'type' => 'header',
832 832
             ),
833 833
             'email_onhold_invoice_active' => array(
834 834
                 'id'   => 'email_onhold_invoice_active',
835
-                'name' => __( 'Enable/Disable', 'invoicing' ),
836
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
835
+                'name' => __('Enable/Disable', 'invoicing'),
836
+                'desc' => __('Enable this email notification', 'invoicing'),
837 837
                 'type' => 'checkbox',
838 838
                 'std'  => 1
839 839
             ),
840 840
             'email_onhold_invoice_subject' => array(
841 841
                 'id'   => 'email_onhold_invoice_subject',
842
-                'name' => __( 'Subject', 'invoicing' ),
843
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
842
+                'name' => __('Subject', 'invoicing'),
843
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
844 844
                 'type' => 'text',
845
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
845
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
846 846
                 'size' => 'large'
847 847
             ),
848 848
             'email_onhold_invoice_heading' => array(
849 849
                 'id'   => 'email_onhold_invoice_heading',
850
-                'name' => __( 'Email Heading', 'invoicing' ),
851
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
850
+                'name' => __('Email Heading', 'invoicing'),
851
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
852 852
                 'type' => 'text',
853
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
853
+                'std'  => __('Thank you for your invoice', 'invoicing'),
854 854
                 'size' => 'large'
855 855
             ),
856 856
             'email_onhold_invoice_admin_bcc' => array(
857 857
                 'id'   => 'email_onhold_invoice_admin_bcc',
858
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
859
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
858
+                'name' => __('Enable Admin BCC', 'invoicing'),
859
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
860 860
                 'type' => 'checkbox',
861 861
                 'std'  => 1
862 862
             ),
@@ -864,37 +864,37 @@  discard block
 block discarded – undo
864 864
         'processing_invoice' => array(
865 865
             'email_processing_invoice_header' => array(
866 866
                 'id'   => 'email_processing_invoice_header',
867
-                'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>',
868
-                'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ),
867
+                'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>',
868
+                'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'),
869 869
                 'type' => 'header',
870 870
             ),
871 871
             'email_processing_invoice_active' => array(
872 872
                 'id'   => 'email_processing_invoice_active',
873
-                'name' => __( 'Enable/Disable', 'invoicing' ),
874
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
873
+                'name' => __('Enable/Disable', 'invoicing'),
874
+                'desc' => __('Enable this email notification', 'invoicing'),
875 875
                 'type' => 'checkbox',
876 876
                 'std'  => 1
877 877
             ),
878 878
             'email_processing_invoice_subject' => array(
879 879
                 'id'   => 'email_processing_invoice_subject',
880
-                'name' => __( 'Subject', 'invoicing' ),
881
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
880
+                'name' => __('Subject', 'invoicing'),
881
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
882 882
                 'type' => 'text',
883
-                'std'  => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ),
883
+                'std'  => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'),
884 884
                 'size' => 'large'
885 885
             ),
886 886
             'email_processing_invoice_heading' => array(
887 887
                 'id'   => 'email_processing_invoice_heading',
888
-                'name' => __( 'Email Heading', 'invoicing' ),
889
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
888
+                'name' => __('Email Heading', 'invoicing'),
889
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
890 890
                 'type' => 'text',
891
-                'std'  => __( 'Thank you for your invoice', 'invoicing' ),
891
+                'std'  => __('Thank you for your invoice', 'invoicing'),
892 892
                 'size' => 'large'
893 893
             ),
894 894
             'email_processing_invoice_admin_bcc' => array(
895 895
                 'id'   => 'email_processing_invoice_admin_bcc',
896
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
897
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
896
+                'name' => __('Enable Admin BCC', 'invoicing'),
897
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
898 898
                 'type' => 'checkbox',
899 899
                 'std'  => 1
900 900
             ),
@@ -902,37 +902,37 @@  discard block
 block discarded – undo
902 902
         'completed_invoice' => array(
903 903
             'email_completed_invoice_header' => array(
904 904
                 'id'   => 'email_completed_invoice_header',
905
-                'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>',
906
-                'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ),
905
+                'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>',
906
+                'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'),
907 907
                 'type' => 'header',
908 908
             ),
909 909
             'email_completed_invoice_active' => array(
910 910
                 'id'   => 'email_completed_invoice_active',
911
-                'name' => __( 'Enable/Disable', 'invoicing' ),
912
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
911
+                'name' => __('Enable/Disable', 'invoicing'),
912
+                'desc' => __('Enable this email notification', 'invoicing'),
913 913
                 'type' => 'checkbox',
914 914
                 'std'  => 1
915 915
             ),
916 916
             'email_completed_invoice_subject' => array(
917 917
                 'id'   => 'email_completed_invoice_subject',
918
-                'name' => __( 'Subject', 'invoicing' ),
919
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
918
+                'name' => __('Subject', 'invoicing'),
919
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
920 920
                 'type' => 'text',
921
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ),
921
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'),
922 922
                 'size' => 'large'
923 923
             ),
924 924
             'email_completed_invoice_heading' => array(
925 925
                 'id'   => 'email_completed_invoice_heading',
926
-                'name' => __( 'Email Heading', 'invoicing' ),
927
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
926
+                'name' => __('Email Heading', 'invoicing'),
927
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
928 928
                 'type' => 'text',
929
-                'std'  => __( 'Your invoice has been paid', 'invoicing' ),
929
+                'std'  => __('Your invoice has been paid', 'invoicing'),
930 930
                 'size' => 'large'
931 931
             ),
932 932
             'email_completed_invoice_admin_bcc' => array(
933 933
                 'id'   => 'email_completed_invoice_admin_bcc',
934
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
935
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
934
+                'name' => __('Enable Admin BCC', 'invoicing'),
935
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
936 936
                 'type' => 'checkbox',
937 937
             ),
938 938
             'std'  => 1
@@ -940,37 +940,37 @@  discard block
 block discarded – undo
940 940
         'refunded_invoice' => array(
941 941
             'email_refunded_invoice_header' => array(
942 942
                 'id'   => 'email_refunded_invoice_header',
943
-                'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>',
944
-                'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ),
943
+                'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>',
944
+                'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'),
945 945
                 'type' => 'header',
946 946
             ),
947 947
             'email_refunded_invoice_active' => array(
948 948
                 'id'   => 'email_refunded_invoice_active',
949
-                'name' => __( 'Enable/Disable', 'invoicing' ),
950
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
949
+                'name' => __('Enable/Disable', 'invoicing'),
950
+                'desc' => __('Enable this email notification', 'invoicing'),
951 951
                 'type' => 'checkbox',
952 952
                 'std'  => 1
953 953
             ),
954 954
             'email_refunded_invoice_subject' => array(
955 955
                 'id'   => 'email_refunded_invoice_subject',
956
-                'name' => __( 'Subject', 'invoicing' ),
957
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
956
+                'name' => __('Subject', 'invoicing'),
957
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
958 958
                 'type' => 'text',
959
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ),
959
+                'std'  => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'),
960 960
                 'size' => 'large'
961 961
             ),
962 962
             'email_refunded_invoice_heading' => array(
963 963
                 'id'   => 'email_refunded_invoice_heading',
964
-                'name' => __( 'Email Heading', 'invoicing' ),
965
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
964
+                'name' => __('Email Heading', 'invoicing'),
965
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
966 966
                 'type' => 'text',
967
-                'std'  => __( 'Your invoice has been refunded', 'invoicing' ),
967
+                'std'  => __('Your invoice has been refunded', 'invoicing'),
968 968
                 'size' => 'large'
969 969
             ),
970 970
             'email_refunded_invoice_admin_bcc' => array(
971 971
                 'id'   => 'email_refunded_invoice_admin_bcc',
972
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
973
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
972
+                'name' => __('Enable Admin BCC', 'invoicing'),
973
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
974 974
                 'type' => 'checkbox',
975 975
                 'std'  => 1
976 976
             ),
@@ -978,37 +978,37 @@  discard block
 block discarded – undo
978 978
         'user_invoice' => array(
979 979
             'email_user_invoice_header' => array(
980 980
                 'id'   => 'email_user_invoice_header',
981
-                'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>',
982
-                'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ),
981
+                'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>',
982
+                'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'),
983 983
                 'type' => 'header',
984 984
             ),
985 985
             'email_user_invoice_active' => array(
986 986
                 'id'   => 'email_user_invoice_active',
987
-                'name' => __( 'Enable/Disable', 'invoicing' ),
988
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
987
+                'name' => __('Enable/Disable', 'invoicing'),
988
+                'desc' => __('Enable this email notification', 'invoicing'),
989 989
                 'type' => 'checkbox',
990 990
                 'std'  => 1
991 991
             ),
992 992
             'email_user_invoice_subject' => array(
993 993
                 'id'   => 'email_user_invoice_subject',
994
-                'name' => __( 'Subject', 'invoicing' ),
995
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
994
+                'name' => __('Subject', 'invoicing'),
995
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
996 996
                 'type' => 'text',
997
-                'std'  => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ),
997
+                'std'  => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'),
998 998
                 'size' => 'large'
999 999
             ),
1000 1000
             'email_user_invoice_heading' => array(
1001 1001
                 'id'   => 'email_user_invoice_heading',
1002
-                'name' => __( 'Email Heading', 'invoicing' ),
1003
-                'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ),
1002
+                'name' => __('Email Heading', 'invoicing'),
1003
+                'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'),
1004 1004
                 'type' => 'text',
1005
-                'std'  => __( 'Your invoice {invoice_number} details', 'invoicing' ),
1005
+                'std'  => __('Your invoice {invoice_number} details', 'invoicing'),
1006 1006
                 'size' => 'large'
1007 1007
             ),
1008 1008
             'email_user_invoice_admin_bcc' => array(
1009 1009
                 'id'   => 'email_user_invoice_admin_bcc',
1010
-                'name' => __( 'Enable Admin BCC', 'invoicing' ),
1011
-                'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ),
1010
+                'name' => __('Enable Admin BCC', 'invoicing'),
1011
+                'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'),
1012 1012
                 'type' => 'checkbox',
1013 1013
                 'std'  => 1
1014 1014
             ),
@@ -1016,177 +1016,177 @@  discard block
 block discarded – undo
1016 1016
         'user_note' => array(
1017 1017
             'email_user_note_header' => array(
1018 1018
                 'id'   => 'email_user_note_header',
1019
-                'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>',
1020
-                'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ),
1019
+                'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>',
1020
+                'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'),
1021 1021
                 'type' => 'header',
1022 1022
             ),
1023 1023
             'email_user_note_active' => array(
1024 1024
                 'id'   => 'email_user_note_active',
1025
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1026
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1025
+                'name' => __('Enable/Disable', 'invoicing'),
1026
+                'desc' => __('Enable this email notification', 'invoicing'),
1027 1027
                 'type' => 'checkbox',
1028 1028
                 'std'  => 1
1029 1029
             ),
1030 1030
             'email_user_note_subject' => array(
1031 1031
                 'id'   => 'email_user_note_subject',
1032
-                'name' => __( 'Subject', 'invoicing' ),
1033
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1032
+                'name' => __('Subject', 'invoicing'),
1033
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1034 1034
                 'type' => 'text',
1035
-                'std'  => __( '[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing' ),
1035
+                'std'  => __('[{site_title}] Note added to your {invoice_quote} #{invoice_number} from {invoice_date}', 'invoicing'),
1036 1036
                 'size' => 'large'
1037 1037
             ),
1038 1038
             'email_user_note_heading' => array(
1039 1039
                 'id'   => 'email_user_note_heading',
1040
-                'name' => __( 'Email Heading', 'invoicing' ),
1041
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1040
+                'name' => __('Email Heading', 'invoicing'),
1041
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1042 1042
                 'type' => 'text',
1043
-                'std'  => __( 'A note has been added to your {invoice_quote}', 'invoicing' ),
1043
+                'std'  => __('A note has been added to your {invoice_quote}', 'invoicing'),
1044 1044
                 'size' => 'large'
1045 1045
             ),
1046 1046
         ),
1047 1047
         'overdue' => array(
1048 1048
             'email_overdue_header' => array(
1049 1049
                 'id'   => 'email_overdue_header',
1050
-                'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>',
1051
-                'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ),
1050
+                'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>',
1051
+                'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'),
1052 1052
                 'type' => 'header',
1053 1053
             ),
1054 1054
             'email_overdue_active' => array(
1055 1055
                 'id'   => 'email_overdue_active',
1056
-                'name' => __( 'Enable/Disable', 'invoicing' ),
1057
-                'desc' => __( 'Enable this email notification', 'invoicing' ),
1056
+                'name' => __('Enable/Disable', 'invoicing'),
1057
+                'desc' => __('Enable this email notification', 'invoicing'),
1058 1058
                 'type' => 'checkbox',
1059 1059
                 'std'  => 1
1060 1060
             ),
1061 1061
             'email_due_reminder_days' => array(
1062 1062
                 'id'        => 'email_due_reminder_days',
1063
-                'name'      => __( 'When to Send', 'sliced-invoices' ),
1064
-                'desc'      => __( 'Check when you would like payment reminders sent out.', 'invoicing' ),
1063
+                'name'      => __('When to Send', 'sliced-invoices'),
1064
+                'desc'      => __('Check when you would like payment reminders sent out.', 'invoicing'),
1065 1065
                 'default'   => '',
1066 1066
                 'type'      => 'multicheck',
1067 1067
                 'options'   => $overdue_days_options,
1068 1068
             ),
1069 1069
             'email_overdue_subject' => array(
1070 1070
                 'id'   => 'email_overdue_subject',
1071
-                'name' => __( 'Subject', 'invoicing' ),
1072
-                'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ),
1071
+                'name' => __('Subject', 'invoicing'),
1072
+                'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'),
1073 1073
                 'type' => 'text',
1074
-                'std'  => __( '[{site_title}] Payment Reminder', 'invoicing' ),
1074
+                'std'  => __('[{site_title}] Payment Reminder', 'invoicing'),
1075 1075
                 'size' => 'large'
1076 1076
             ),
1077 1077
             'email_overdue_heading' => array(
1078 1078
                 'id'   => 'email_overdue_heading',
1079
-                'name' => __( 'Email Heading', 'invoicing' ),
1080
-                'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ),
1079
+                'name' => __('Email Heading', 'invoicing'),
1080
+                'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'),
1081 1081
                 'type' => 'text',
1082
-                'std'  => __( 'Payment reminder for your invoice', 'invoicing' ),
1082
+                'std'  => __('Payment reminder for your invoice', 'invoicing'),
1083 1083
                 'size' => 'large'
1084 1084
             ),
1085 1085
             'email_overdue_body' => array(
1086 1086
                 'id'   => 'email_overdue_body',
1087
-                'name' => __( 'Email Content', 'invoicing' ),
1088
-                'desc' => __( 'The content of the email.', 'invoicing' ),
1087
+                'name' => __('Email Content', 'invoicing'),
1088
+                'desc' => __('The content of the email.', 'invoicing'),
1089 1089
                 'type' => 'rich_editor',
1090
-                'std'  => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing' ),
1090
+                'std'  => __('<p>Hi {full_name},</p><p>This is just a friendly reminder your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To pay now for this invoice please use the following link: <a href="{invoice_pay_link}">Pay Now</a></p>', 'invoicing'),
1091 1091
                 'class' => 'large',
1092 1092
                 'size'  => 10,
1093 1093
             ),
1094 1094
         ),
1095 1095
     );
1096 1096
 
1097
-    return apply_filters( 'wpinv_get_emails', $emails );
1097
+    return apply_filters('wpinv_get_emails', $emails);
1098 1098
 }
1099 1099
 
1100
-function wpinv_settings_emails( $settings = array() ) {
1100
+function wpinv_settings_emails($settings = array()) {
1101 1101
     $emails = wpinv_get_emails();
1102 1102
     
1103
-    if ( !empty( $emails ) ) {
1104
-        foreach ( $emails as $key => $email ) {
1103
+    if (!empty($emails)) {
1104
+        foreach ($emails as $key => $email) {
1105 1105
             $settings[$key] = $email;
1106 1106
         }
1107 1107
     }
1108 1108
     
1109
-    return apply_filters( 'wpinv_settings_get_emails', $settings );
1109
+    return apply_filters('wpinv_settings_get_emails', $settings);
1110 1110
 }
1111
-add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 );
1111
+add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1);
1112 1112
 
1113
-function wpinv_settings_sections_emails( $settings ) {
1113
+function wpinv_settings_sections_emails($settings) {
1114 1114
     $emails = wpinv_get_emails();
1115 1115
     
1116 1116
     if (!empty($emails)) {
1117
-        foreach  ($emails as $key => $email) {
1118
-            $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key;
1117
+        foreach ($emails as $key => $email) {
1118
+            $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key;
1119 1119
         }
1120 1120
     }
1121 1121
     
1122 1122
     return $settings;    
1123 1123
 }
1124
-add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 );
1124
+add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1);
1125 1125
 
1126
-function wpinv_email_is_enabled( $email_type ) {
1126
+function wpinv_email_is_enabled($email_type) {
1127 1127
     $emails = wpinv_get_emails();
1128
-    $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false;
1128
+    $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false;
1129 1129
 
1130
-    return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type );
1130
+    return apply_filters('wpinv_email_is_enabled', $enabled, $email_type);
1131 1131
 }
1132 1132
 
1133
-function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1134
-    switch ( $email_type ) {
1133
+function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) {
1134
+    switch ($email_type) {
1135 1135
         case 'new_invoice':
1136 1136
         case 'cancelled_invoice':
1137 1137
         case 'failed_invoice':
1138 1138
             $recipient  = wpinv_get_admin_email();
1139 1139
         break;
1140 1140
         default:
1141
-            $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1142
-            $recipient  = !empty( $invoice ) ? $invoice->get_email() : '';
1141
+            $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1142
+            $recipient  = !empty($invoice) ? $invoice->get_email() : '';
1143 1143
         break;
1144 1144
     }
1145 1145
     
1146
-    return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice );
1146
+    return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice);
1147 1147
 }
1148 1148
 
1149
-function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1150
-    $subject    = wpinv_get_option( 'email_' . $email_type . '_subject' );
1149
+function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) {
1150
+    $subject    = wpinv_get_option('email_' . $email_type . '_subject');
1151 1151
     
1152
-    $subject    = wpinv_email_format_text( $subject );
1152
+    $subject    = wpinv_email_format_text($subject);
1153 1153
     
1154
-    return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice );
1154
+    return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice);
1155 1155
 }
1156 1156
 
1157
-function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1158
-    $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' );
1157
+function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) {
1158
+    $email_heading = wpinv_get_option('email_' . $email_type . '_heading');
1159 1159
     
1160
-    $email_heading = wpinv_email_format_text( $email_heading );
1160
+    $email_heading = wpinv_email_format_text($email_heading);
1161 1161
     
1162
-    return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice );
1162
+    return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice);
1163 1163
 }
1164 1164
 
1165
-function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1166
-    $content    = wpinv_get_option( 'email_' . $email_type . '_body' );
1165
+function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) {
1166
+    $content    = wpinv_get_option('email_' . $email_type . '_body');
1167 1167
     
1168
-    $content    = wpinv_email_format_text( $content );
1168
+    $content    = wpinv_email_format_text($content);
1169 1169
     
1170
-    return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice );
1170
+    return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice);
1171 1171
 }
1172 1172
 
1173
-function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1173
+function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) {
1174 1174
     $from_name = wpinv_mail_get_from_address();
1175 1175
     $from_email = wpinv_mail_get_from_address();
1176 1176
     
1177
-    $invoice    = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL );
1177
+    $invoice    = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL);
1178 1178
     
1179
-    $headers    = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
1180
-    $headers    .= "Reply-To: ". $from_email . "\r\n";
1179
+    $headers    = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n";
1180
+    $headers    .= "Reply-To: " . $from_email . "\r\n";
1181 1181
     $headers    .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n";
1182 1182
     
1183
-    return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice );
1183
+    return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice);
1184 1184
 }
1185 1185
 
1186
-function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) {
1186
+function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) {
1187 1187
     $attachments = array();
1188 1188
     
1189
-    return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice );
1189
+    return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice);
1190 1190
 }
1191 1191
 
1192 1192
 function wpinv_email_global_vars() {
@@ -1203,73 +1203,73 @@  discard block
 block discarded – undo
1203 1203
     $replace['sitename']    = $blogname;
1204 1204
     $replace['site-title']  = $blogname;
1205 1205
     
1206
-    return apply_filters( 'wpinv_email_global_vars', array( $search, $replace ) );
1206
+    return apply_filters('wpinv_email_global_vars', array($search, $replace));
1207 1207
 }
1208 1208
 
1209
-function wpinv_email_format_text( $content ) {
1209
+function wpinv_email_format_text($content) {
1210 1210
     global $wpinv_email_search, $wpinv_email_replace;
1211 1211
     
1212
-    if ( empty( $wpinv_email_search ) ) {
1212
+    if (empty($wpinv_email_search)) {
1213 1213
         $wpinv_email_search = array();
1214 1214
     }
1215 1215
     
1216
-    if ( empty( $wpinv_email_replace ) ) {
1216
+    if (empty($wpinv_email_replace)) {
1217 1217
         $wpinv_email_replace = array();
1218 1218
     }
1219 1219
     
1220
-    $wpinv_email_search     = (array)apply_filters( 'wpinv_email_format_text_search', $wpinv_email_search );
1221
-    $wpinv_email_replace    = (array)apply_filters( 'wpinv_email_format_text_replace', $wpinv_email_replace );
1220
+    $wpinv_email_search     = (array)apply_filters('wpinv_email_format_text_search', $wpinv_email_search);
1221
+    $wpinv_email_replace    = (array)apply_filters('wpinv_email_format_text_replace', $wpinv_email_replace);
1222 1222
     
1223 1223
     $global_vars    = wpinv_email_global_vars();
1224 1224
     
1225
-    $search         = array_merge( $global_vars[0], $wpinv_email_search );
1226
-    $replace        = array_merge( $global_vars[1], $wpinv_email_replace );
1225
+    $search         = array_merge($global_vars[0], $wpinv_email_search);
1226
+    $replace        = array_merge($global_vars[1], $wpinv_email_replace);
1227 1227
     
1228
-    if ( empty( $search ) || empty( $replace ) || !is_array( $search ) || !is_array( $replace ) ) {
1228
+    if (empty($search) || empty($replace) || !is_array($search) || !is_array($replace)) {
1229 1229
         return  $content;
1230 1230
     }
1231 1231
         
1232
-    return str_replace( $search, $replace, $content );
1232
+    return str_replace($search, $replace, $content);
1233 1233
 }
1234 1234
 
1235
-function wpinv_email_style_body( $content ) {
1235
+function wpinv_email_style_body($content) {
1236 1236
     // make sure we only inline CSS for html emails
1237
-    if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) {
1237
+    if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) {
1238 1238
         ob_start();
1239
-        wpinv_get_template( 'emails/wpinv-email-styles.php' );
1240
-        $css = apply_filters( 'wpinv_email_styles', ob_get_clean() );
1239
+        wpinv_get_template('emails/wpinv-email-styles.php');
1240
+        $css = apply_filters('wpinv_email_styles', ob_get_clean());
1241 1241
         
1242 1242
         // apply CSS styles inline for picky email clients
1243 1243
         try {
1244
-            $emogrifier = new Emogrifier( $content, $css );
1244
+            $emogrifier = new Emogrifier($content, $css);
1245 1245
             $content    = $emogrifier->emogrify();
1246
-        } catch ( Exception $e ) {
1247
-            wpinv_error_log( $e->getMessage(), 'emogrifier' );
1246
+        } catch (Exception $e) {
1247
+            wpinv_error_log($e->getMessage(), 'emogrifier');
1248 1248
         }
1249 1249
     }
1250 1250
     return $content;
1251 1251
 }
1252 1252
 
1253
-function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1254
-    wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1253
+function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) {
1254
+    wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1255 1255
 }
1256 1256
 
1257 1257
 /**
1258 1258
  * Get the email footer.
1259 1259
  */
1260
-function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) {
1261
-    wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1260
+function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) {
1261
+    wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1262 1262
 }
1263 1263
 
1264
-function wpinv_email_wrap_message( $message ) {
1264
+function wpinv_email_wrap_message($message) {
1265 1265
     // Buffer
1266 1266
     ob_start();
1267 1267
 
1268
-    do_action( 'wpinv_email_header' );
1268
+    do_action('wpinv_email_header');
1269 1269
 
1270
-    echo wpautop( wptexturize( $message ) );
1270
+    echo wpautop(wptexturize($message));
1271 1271
 
1272
-    do_action( 'wpinv_email_footer' );
1272
+    do_action('wpinv_email_footer');
1273 1273
 
1274 1274
     // Get contents
1275 1275
     $message = ob_get_clean();
@@ -1277,86 +1277,86 @@  discard block
 block discarded – undo
1277 1277
     return $message;
1278 1278
 }
1279 1279
 
1280
-function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1281
-    wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1280
+function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) {
1281
+    wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1282 1282
 }
1283 1283
 
1284
-function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) {
1285
-    wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1284
+function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) {
1285
+    wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1286 1286
 }
1287 1287
 
1288
-function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) {
1289
-    wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) );
1288
+function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) {
1289
+    wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin));
1290 1290
 }
1291 1291
 
1292
-function wpinv_send_customer_invoice( $data = array() ) {
1293
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1292
+function wpinv_send_customer_invoice($data = array()) {
1293
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1294 1294
     
1295
-    if ( empty( $invoice_id ) ) {
1295
+    if (empty($invoice_id)) {
1296 1296
         return;
1297 1297
     }
1298 1298
 
1299
-    if ( !current_user_can( 'manage_options' ) ) {
1300
-        wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1299
+    if (!current_user_can('manage_options')) {
1300
+        wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1301 1301
     }
1302 1302
     
1303
-    $sent = wpinv_user_invoice_notification( $invoice_id );
1303
+    $sent = wpinv_user_invoice_notification($invoice_id);
1304 1304
     
1305 1305
     $status = $sent ? 'email_sent' : 'email_fail';
1306 1306
     
1307
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1308
-    wp_redirect( $redirect );
1307
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1308
+    wp_redirect($redirect);
1309 1309
     exit;
1310 1310
 }
1311
-add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' );
1311
+add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice');
1312 1312
 
1313
-function wpinv_send_overdue_reminder( $data = array() ) {
1314
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1313
+function wpinv_send_overdue_reminder($data = array()) {
1314
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1315 1315
     
1316
-    if ( empty( $invoice_id ) ) {
1316
+    if (empty($invoice_id)) {
1317 1317
         return;
1318 1318
     }
1319 1319
 
1320
-    if ( !current_user_can( 'manage_options' ) ) {
1321
-        wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
1320
+    if (!current_user_can('manage_options')) {
1321
+        wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
1322 1322
     }
1323 1323
     
1324
-    $sent = wpinv_send_payment_reminder_notification( $invoice_id );
1324
+    $sent = wpinv_send_payment_reminder_notification($invoice_id);
1325 1325
     
1326 1326
     $status = $sent ? 'email_sent' : 'email_fail';
1327 1327
     
1328
-    $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) );
1329
-    wp_redirect( $redirect );
1328
+    $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false));
1329
+    wp_redirect($redirect);
1330 1330
     exit;
1331 1331
 }
1332
-add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' );
1332
+add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder');
1333 1333
 
1334
-function wpinv_send_customer_note_email( $data ) {
1335
-    $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL;
1334
+function wpinv_send_customer_note_email($data) {
1335
+    $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL;
1336 1336
     
1337
-    if ( empty( $invoice_id ) ) {
1337
+    if (empty($invoice_id)) {
1338 1338
         return;
1339 1339
     }
1340 1340
     
1341
-    $sent = wpinv_user_note_notification( $invoice_id, $data );
1341
+    $sent = wpinv_user_note_notification($invoice_id, $data);
1342 1342
 }
1343
-add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 );
1343
+add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1);
1344 1344
 
1345
-function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) {
1346
-    if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) {
1347
-        $date_format = get_option( 'date_format' );
1348
-        $time_format = get_option( 'time_format' );
1345
+function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) {
1346
+    if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) {
1347
+        $date_format = get_option('date_format');
1348
+        $time_format = get_option('time_format');
1349 1349
         ?>
1350 1350
         <div id="wpinv-email-notes">
1351
-            <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3>
1351
+            <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3>
1352 1352
             <ol class="wpinv-notes-lists">
1353 1353
         <?php
1354
-        foreach ( $invoice_notes as $note ) {
1355
-            $note_time = strtotime( $note->comment_date );
1354
+        foreach ($invoice_notes as $note) {
1355
+            $note_time = strtotime($note->comment_date);
1356 1356
             ?>
1357 1357
             <li class="comment wpinv-note">
1358
-            <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p>
1359
-            <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div>
1358
+            <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p>
1359
+            <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div>
1360 1360
             </li>
1361 1361
             <?php
1362 1362
         }
@@ -1365,21 +1365,21 @@  discard block
 block discarded – undo
1365 1365
         <?php
1366 1366
     }
1367 1367
 }
1368
-add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 );
1368
+add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3);
1369 1369
 
1370 1370
 function wpinv_email_payment_reminders() {    
1371 1371
     global $wpi_auto_reminder;
1372
-    if ( !wpinv_get_option( 'email_overdue_active' ) ) {
1372
+    if (!wpinv_get_option('email_overdue_active')) {
1373 1373
         return;
1374 1374
     }
1375 1375
     
1376
-    if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) {
1377
-        $reminder_days  = is_array( $reminder_days ) ? array_values( $reminder_days ) : '';
1376
+    if ($reminder_days = wpinv_get_option('email_due_reminder_days')) {
1377
+        $reminder_days  = is_array($reminder_days) ? array_values($reminder_days) : '';
1378 1378
         
1379
-        if ( empty( $reminder_days ) ) {
1379
+        if (empty($reminder_days)) {
1380 1380
             return;
1381 1381
         }
1382
-        $reminder_days  = array_unique( array_map( 'absint', $reminder_days ) );
1382
+        $reminder_days = array_unique(array_map('absint', $reminder_days));
1383 1383
         
1384 1384
         $args = array(
1385 1385
             'post_type'     => 'wpi_invoice',
@@ -1389,7 +1389,7 @@  discard block
 block discarded – undo
1389 1389
             'meta_query'    => array(
1390 1390
                 array(
1391 1391
                     'key'       =>  '_wpinv_due_date',
1392
-                    'value'     =>  array( '', 'none' ),
1392
+                    'value'     =>  array('', 'none'),
1393 1393
                     'compare'   =>  'NOT IN',
1394 1394
                 )
1395 1395
             ),
@@ -1398,64 +1398,64 @@  discard block
 block discarded – undo
1398 1398
             'order'         => 'ASC',
1399 1399
         );
1400 1400
         
1401
-        $invoices = get_posts( $args );
1401
+        $invoices = get_posts($args);
1402 1402
         
1403
-        if ( empty( $invoices ) ) {
1403
+        if (empty($invoices)) {
1404 1404
             return;
1405 1405
         }
1406 1406
         
1407
-        $date_to_send   = array();
1407
+        $date_to_send = array();
1408 1408
         
1409
-        foreach ( $invoices as $id ) {
1410
-            $due_date = get_post_meta( $id, '_wpinv_due_date', true );
1409
+        foreach ($invoices as $id) {
1410
+            $due_date = get_post_meta($id, '_wpinv_due_date', true);
1411 1411
             
1412
-            foreach ( $reminder_days as $key => $days ) {
1413
-                if ( $days !== '' ) {
1414
-                    $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) );
1412
+            foreach ($reminder_days as $key => $days) {
1413
+                if ($days !== '') {
1414
+                    $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS));
1415 1415
                 }
1416 1416
             }
1417 1417
         }
1418 1418
 
1419
-        $today              = date_i18n( 'Y-m-d' );
1419
+        $today              = date_i18n('Y-m-d');
1420 1420
         $wpi_auto_reminder  = true;
1421 1421
 
1422
-        foreach ( $date_to_send as $id => $values ) {
1423
-            if ( in_array( $today, $values ) ) {
1424
-                $sent = get_post_meta( $id, '_wpinv_reminder_sent', true );
1422
+        foreach ($date_to_send as $id => $values) {
1423
+            if (in_array($today, $values)) {
1424
+                $sent = get_post_meta($id, '_wpinv_reminder_sent', true);
1425 1425
 
1426
-                if ( isset( $sent ) && !empty( $sent ) ) {
1427
-                    if ( !in_array( $today, $sent ) ) {
1428
-                        do_action( 'wpinv_send_payment_reminder_notification', $id );
1426
+                if (isset($sent) && !empty($sent)) {
1427
+                    if (!in_array($today, $sent)) {
1428
+                        do_action('wpinv_send_payment_reminder_notification', $id);
1429 1429
                     }
1430 1430
                 } else {
1431
-                    do_action( 'wpinv_send_payment_reminder_notification', $id );
1431
+                    do_action('wpinv_send_payment_reminder_notification', $id);
1432 1432
                 }
1433 1433
             }
1434 1434
         }
1435 1435
         
1436
-        $wpi_auto_reminder  = false;
1436
+        $wpi_auto_reminder = false;
1437 1437
     }
1438 1438
 }
1439 1439
 
1440
-function wpinv_send_payment_reminder_notification( $invoice_id ) {
1440
+function wpinv_send_payment_reminder_notification($invoice_id) {
1441 1441
     global $wpinv_email_search, $wpinv_email_replace;
1442 1442
     
1443 1443
     $email_type = 'overdue';
1444
-    if ( !wpinv_email_is_enabled( $email_type ) ) {
1444
+    if (!wpinv_email_is_enabled($email_type)) {
1445 1445
         return false;
1446 1446
     }
1447 1447
     
1448
-    $invoice    = wpinv_get_invoice( $invoice_id );
1449
-    if ( empty( $invoice ) ) {
1448
+    $invoice = wpinv_get_invoice($invoice_id);
1449
+    if (empty($invoice)) {
1450 1450
         return false;
1451 1451
     }
1452 1452
     
1453
-    if ( !$invoice->needs_payment() ) {
1453
+    if (!$invoice->needs_payment()) {
1454 1454
         return false;
1455 1455
     }
1456 1456
     
1457
-    $recipient  = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice );
1458
-    if ( !is_email( $recipient ) ) {
1457
+    $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice);
1458
+    if (!is_email($recipient)) {
1459 1459
         return false;
1460 1460
     }
1461 1461
         
@@ -1471,70 +1471,70 @@  discard block
 block discarded – undo
1471 1471
     $replace                    = array();
1472 1472
     $replace['full_name']       = $invoice->get_user_full_name();
1473 1473
     $replace['invoice_number']  = $invoice->get_number();
1474
-    $replace['invoice_due_date']= $invoice->get_due_date( true );
1475
-    $replace['invoice_total']   = $invoice->get_total( true );
1476
-    $replace['invoice_link']    = $invoice->get_view_url( true );
1477
-    $replace['invoice_pay_link']= $invoice->get_checkout_payment_url( false, true );
1478
-    $replace['is_was']          = strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' );
1474
+    $replace['invoice_due_date'] = $invoice->get_due_date(true);
1475
+    $replace['invoice_total']   = $invoice->get_total(true);
1476
+    $replace['invoice_link']    = $invoice->get_view_url(true);
1477
+    $replace['invoice_pay_link'] = $invoice->get_checkout_payment_url(false, true);
1478
+    $replace['is_was']          = strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing');
1479 1479
 
1480 1480
     $wpinv_email_search         = $search;
1481 1481
     $wpinv_email_replace        = $replace;
1482 1482
     
1483
-    $subject        = wpinv_email_get_subject( $email_type, $invoice_id, $invoice );
1484
-    $email_heading  = wpinv_email_get_heading( $email_type, $invoice_id, $invoice );
1485
-    $headers        = wpinv_email_get_headers( $email_type, $invoice_id, $invoice );
1486
-    $attachments    = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice );
1483
+    $subject        = wpinv_email_get_subject($email_type, $invoice_id, $invoice);
1484
+    $email_heading  = wpinv_email_get_heading($email_type, $invoice_id, $invoice);
1485
+    $headers        = wpinv_email_get_headers($email_type, $invoice_id, $invoice);
1486
+    $attachments    = wpinv_email_get_attachments($email_type, $invoice_id, $invoice);
1487 1487
     
1488
-    $message_body   = wpinv_email_get_content( $email_type, $invoice_id, $invoice );
1488
+    $message_body   = wpinv_email_get_content($email_type, $invoice_id, $invoice);
1489 1489
     
1490
-    $content        = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array(
1490
+    $content        = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array(
1491 1491
             'invoice'       => $invoice,
1492 1492
             'email_type'    => $email_type,
1493 1493
             'email_heading' => $email_heading,
1494 1494
             'sent_to_admin' => false,
1495 1495
             'plain_text'    => false,
1496 1496
             'message_body'  => $message_body
1497
-        ) );
1497
+        ));
1498 1498
         
1499
-    $content        = wpinv_email_format_text( $content );
1499
+    $content = wpinv_email_format_text($content);
1500 1500
 
1501
-    $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments );
1502
-    if ( $sent ) {
1503
-        do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice );
1501
+    $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments);
1502
+    if ($sent) {
1503
+        do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice);
1504 1504
     }
1505 1505
         
1506 1506
     return $sent;
1507 1507
 }
1508
-add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 );
1508
+add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1);
1509 1509
 
1510
-function wpinv_payment_reminder_sent( $invoice_id, $invoice ) {
1510
+function wpinv_payment_reminder_sent($invoice_id, $invoice) {
1511 1511
     global $wpi_auto_reminder;
1512 1512
     
1513
-    $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true );
1513
+    $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true);
1514 1514
     
1515
-    if ( empty( $sent ) ) {
1515
+    if (empty($sent)) {
1516 1516
         $sent = array();
1517 1517
     }
1518
-    $sent[] = date_i18n( 'Y-m-d' );
1518
+    $sent[] = date_i18n('Y-m-d');
1519 1519
     
1520
-    update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent );
1520
+    update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent);
1521 1521
     
1522
-    if ( $wpi_auto_reminder ) { // Auto reminder note.
1523
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1524
-        $invoice->add_note( $note, false, false, true );
1522
+    if ($wpi_auto_reminder) { // Auto reminder note.
1523
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1524
+        $invoice->add_note($note, false, false, true);
1525 1525
     } else { // Menual reminder note.
1526
-        $note = __( 'Manual reminder sent to the user.', 'invoicing' );
1527
-        $invoice->add_note( $note );
1526
+        $note = __('Manual reminder sent to the user.', 'invoicing');
1527
+        $invoice->add_note($note);
1528 1528
     }
1529 1529
 }
1530
-add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 );
1530
+add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2);
1531 1531
 
1532
-function wpinv_email_before_note_details( $invoice, $email_type, $sent_to_admin, $customer_note ) {
1532
+function wpinv_email_before_note_details($invoice, $email_type, $sent_to_admin, $customer_note) {
1533 1533
     if ("wpi_invoice" === $invoice->post_type && !empty($customer_note)) {
1534 1534
         $before_note = '';
1535
-        $before_note .= __( 'Hello, a note has just been added to your invoice:', 'invoicing' );
1536
-        $before_note .= '<blockquote class="wpinv-note">'.wpautop( wptexturize( $customer_note ) ).'</blockquote>';
1537
-        $before_note .= __( 'For your reference, your invoice details are shown below.', 'invoicing' );
1535
+        $before_note .= __('Hello, a note has just been added to your invoice:', 'invoicing');
1536
+        $before_note .= '<blockquote class="wpinv-note">' . wpautop(wptexturize($customer_note)) . '</blockquote>';
1537
+        $before_note .= __('For your reference, your invoice details are shown below.', 'invoicing');
1538 1538
         echo $before_note;
1539 1539
     }
1540 1540
 }
1541 1541
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-gd-functions.php 1 patch
Spacing   +266 added lines, -266 removed lines patch added patch discarded remove patch
@@ -1,23 +1,23 @@  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 7
 function wpinv_gd_active() {
8
-    return (bool)defined( 'GEODIRECTORY_VERSION' );
8
+    return (bool)defined('GEODIRECTORY_VERSION');
9 9
 }
10 10
 
11 11
 function wpinv_pm_active() {
12
-    return (bool)wpinv_gd_active() && (bool)defined( 'GEODIRPAYMENT_VERSION' );
12
+    return (bool)wpinv_gd_active() && (bool)defined('GEODIRPAYMENT_VERSION');
13 13
 }
14 14
 
15
-function wpinv_is_gd_post_type( $post_type ) {
15
+function wpinv_is_gd_post_type($post_type) {
16 16
     global $gd_posttypes;
17 17
     
18
-    $gd_posttypes = !empty( $gd_posttypes ) && is_array( $gd_posttypes ) ? $gd_posttypes : geodir_get_posttypes();
18
+    $gd_posttypes = !empty($gd_posttypes) && is_array($gd_posttypes) ? $gd_posttypes : geodir_get_posttypes();
19 19
     
20
-    if ( !empty( $post_type ) && !empty( $gd_posttypes ) && in_array( $post_type, $gd_posttypes ) ) {
20
+    if (!empty($post_type) && !empty($gd_posttypes) && in_array($post_type, $gd_posttypes)) {
21 21
         return true;
22 22
     }
23 23
     
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
         return;
30 30
     }
31 31
     
32
-    if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
32
+    if (!(defined('DOING_AJAX') && DOING_AJAX)) {
33 33
         // Add  fields for force upgrade
34
-        if ( defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column') ) {
35
-            geodir_add_column_if_not_exist( INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0' );
34
+        if (defined('INVOICE_TABLE') && !get_option('wpinv_gdp_column')) {
35
+            geodir_add_column_if_not_exist(INVOICE_TABLE, 'invoice_id', 'INT( 11 ) NOT NULL DEFAULT 0');
36 36
             
37 37
             update_option('wpinv_gdp_column', '1');
38 38
         }
@@ -40,39 +40,39 @@  discard block
 block discarded – undo
40 40
         wpinv_merge_gd_packages_to_items();
41 41
     }
42 42
 }
43
-add_action( 'admin_init', 'wpinv_geodir_integration' );
43
+add_action('admin_init', 'wpinv_geodir_integration');
44 44
 
45
-function wpinv_get_gdp_package_type( $item_types ) {
46
-    if ( wpinv_pm_active() ) {
47
-        $item_types['package'] = __( 'Package', 'invoicing' );
45
+function wpinv_get_gdp_package_type($item_types) {
46
+    if (wpinv_pm_active()) {
47
+        $item_types['package'] = __('Package', 'invoicing');
48 48
     }
49 49
         
50 50
     return $item_types;
51 51
 }
52
-add_filter( 'wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1 );
52
+add_filter('wpinv_get_item_types', 'wpinv_get_gdp_package_type', 10, 1);
53 53
 
54 54
 function wpinv_update_package_item($package_id) {
55 55
     return wpinv_merge_gd_package_to_item($package_id, true);
56 56
 }
57 57
 add_action('geodir_after_save_package', 'wpinv_update_package_item', 10, 1);
58 58
 
59
-function wpinv_merge_gd_packages_to_items( $force = false ) {    
60
-    if ( $merged = get_option( 'wpinv_merge_gd_packages' ) && !$force ) {
59
+function wpinv_merge_gd_packages_to_items($force = false) {    
60
+    if ($merged = get_option('wpinv_merge_gd_packages') && !$force) {
61 61
         return true;
62 62
     }
63 63
 
64
-    if(!function_exists('geodir_package_list_info')){
64
+    if (!function_exists('geodir_package_list_info')) {
65 65
         return false;
66 66
     }
67 67
     
68 68
     $packages = geodir_package_list_info();
69 69
     
70
-    foreach ( $packages as $key => $package ) {
71
-        wpinv_merge_gd_package_to_item( $package->pid, $force, $package );
70
+    foreach ($packages as $key => $package) {
71
+        wpinv_merge_gd_package_to_item($package->pid, $force, $package);
72 72
     }
73 73
     
74
-    if ( !$merged ) {
75
-        update_option( 'wpinv_merge_gd_packages', 1 );
74
+    if (!$merged) {
75
+        update_option('wpinv_merge_gd_packages', 1);
76 76
     }
77 77
     
78 78
     return true;
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 
102 102
     $package = empty($package) ? geodir_get_package_info_by_id($package_id, '') : $package;
103 103
 
104
-    if ( empty($package) || !wpinv_is_gd_post_type( $package->post_type ) ) {
104
+    if (empty($package) || !wpinv_is_gd_post_type($package->post_type)) {
105 105
         return false;
106 106
     }
107 107
         
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
     $meta['custom_id']              = $package_id;
111 111
     $meta['custom_singular_name']   = get_post_type_singular_label($package->post_type);
112 112
     $meta['custom_name']            = get_post_type_plural_label($package->post_type);
113
-    $meta['price']                  = wpinv_round_amount( $package->amount );
113
+    $meta['price']                  = wpinv_round_amount($package->amount);
114 114
     $meta['vat_rule']               = 'digital';
115 115
     $meta['vat_class']              = '_standard';
116 116
     
117
-    if ( !empty( $package->sub_active ) ) {
118
-        $sub_num_trial_days = absint( $package->sub_num_trial_days );
117
+    if (!empty($package->sub_active)) {
118
+        $sub_num_trial_days = absint($package->sub_num_trial_days);
119 119
         
120 120
         $meta['is_recurring']       = 1;
121 121
         $meta['recurring_period']   = $package->sub_units;
122
-        $meta['recurring_interval'] = absint( $package->sub_units_num );
123
-        $meta['recurring_limit']    = absint( $package->sub_units_num_times );
122
+        $meta['recurring_interval'] = absint($package->sub_units_num);
123
+        $meta['recurring_limit']    = absint($package->sub_units_num_times);
124 124
         $meta['free_trial']         = $sub_num_trial_days > 0 ? 1 : 0;
125 125
         $meta['trial_period']       = $package->sub_num_trial_units;
126 126
         $meta['trial_interval']     = $sub_num_trial_days;
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $meta['trial_interval']     = '';
135 135
     }
136 136
     
137
-    $data  = array( 
137
+    $data = array( 
138 138
         'post_title'    => $package->title,
139 139
         'post_excerpt'  => $package->title_desc,
140 140
         'post_status'   => $package->status == 1 ? 'publish' : 'pending',
@@ -151,48 +151,48 @@  discard block
 block discarded – undo
151 151
     return $item;
152 152
 }
153 153
 
154
-function wpinv_gdp_to_wpi_gateway( $payment_method ) {
155
-    switch( $payment_method ) {
154
+function wpinv_gdp_to_wpi_gateway($payment_method) {
155
+    switch ($payment_method) {
156 156
         case 'prebanktransfer':
157 157
             $gateway = 'bank_transfer';
158 158
         break;
159 159
         default:
160
-            $gateway = empty( $payment_method ) ? 'manual' : $payment_method;
160
+            $gateway = empty($payment_method) ? 'manual' : $payment_method;
161 161
         break;
162 162
     }
163 163
     
164
-    return apply_filters( 'wpinv_gdp_to_wpi_gateway', $gateway, $payment_method );
164
+    return apply_filters('wpinv_gdp_to_wpi_gateway', $gateway, $payment_method);
165 165
 }
166 166
 
167
-function wpinv_gdp_to_wpi_gateway_title( $payment_method ) {
168
-    $gateway = wpinv_gdp_to_wpi_gateway( $payment_method );
167
+function wpinv_gdp_to_wpi_gateway_title($payment_method) {
168
+    $gateway = wpinv_gdp_to_wpi_gateway($payment_method);
169 169
     
170
-    $gateway_title = wpinv_get_gateway_checkout_label( $gateway );
170
+    $gateway_title = wpinv_get_gateway_checkout_label($gateway);
171 171
     
172
-    if ( $gateway == $gateway_title ) {
173
-        $gateway_title = geodir_payment_method_title( $gateway );
172
+    if ($gateway == $gateway_title) {
173
+        $gateway_title = geodir_payment_method_title($gateway);
174 174
     }
175 175
     
176
-    return apply_filters( 'wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method );
176
+    return apply_filters('wpinv_gdp_to_wpi_gateway_title', $gateway_title, $payment_method);
177 177
 }
178 178
 
179 179
 function wpinv_print_checkout_errors() {
180 180
     global $wpi_session;
181 181
     wpinv_print_errors();
182 182
 }
183
-add_action( 'geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10 );
183
+add_action('geodir_checkout_page_content', 'wpinv_print_checkout_errors', -10);
184 184
 
185
-function wpinv_cpt_save( $invoice_id, $update = false, $pre_status = NULL ) {
185
+function wpinv_cpt_save($invoice_id, $update = false, $pre_status = NULL) {
186 186
     global $wpi_nosave, $wpi_zero_tax, $wpi_gdp_inv_merge;
187 187
     
188
-    $invoice_info = geodir_get_invoice( $invoice_id );
188
+    $invoice_info = geodir_get_invoice($invoice_id);
189 189
     
190
-    $wpi_invoice_id  = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : 0;
190
+    $wpi_invoice_id  = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : 0;
191 191
     
192 192
     if (!empty($invoice_info)) {
193
-        $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice( $wpi_invoice_id ) : NULL;
193
+        $wpi_invoice = $wpi_invoice_id > 0 ? wpinv_get_invoice($wpi_invoice_id) : NULL;
194 194
         
195
-        if ( !empty( $wpi_invoice ) ) { // update invoice
195
+        if (!empty($wpi_invoice)) { // update invoice
196 196
             $save = false;
197 197
             if ($invoice_info->coupon_code !== $wpi_invoice->discount_code || (float)$invoice_info->discount < (float)$wpi_invoice->discount || (float)$invoice_info->discount > (float)$wpi_invoice->discount) {
198 198
                 $save = true;
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
             
203 203
             if ($invoice_info->paymentmethod !== $wpi_invoice->gateway) {
204 204
                 $save = true;
205
-                $gateway = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : '';
206
-                $gateway = wpinv_gdp_to_wpi_gateway( $gateway );
207
-                $gateway_title = wpinv_gdp_to_wpi_gateway_title( $gateway );
208
-                $wpi_invoice->set('gateway', $gateway );
209
-                $wpi_invoice->set('gateway_title', $gateway_title );
205
+                $gateway = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : '';
206
+                $gateway = wpinv_gdp_to_wpi_gateway($gateway);
207
+                $gateway_title = wpinv_gdp_to_wpi_gateway_title($gateway);
208
+                $wpi_invoice->set('gateway', $gateway);
209
+                $wpi_invoice->set('gateway_title', $gateway_title);
210 210
             }
211 211
             
212
-            if ( ( $status = wpinv_gdp_to_wpi_status( $invoice_info->status ) ) !== $wpi_invoice->status ) {
212
+            if (($status = wpinv_gdp_to_wpi_status($invoice_info->status)) !== $wpi_invoice->status) {
213 213
                 $save = true;
214
-                $wpi_invoice->set( 'status', $status );
214
+                $wpi_invoice->set('status', $status);
215 215
             }
216 216
             
217 217
             if ($save) {
@@ -222,16 +222,16 @@  discard block
 block discarded – undo
222 222
             
223 223
             return $wpi_invoice;
224 224
         } else { // create invoice
225
-            $user_info = get_userdata( $invoice_info->user_id );
225
+            $user_info = get_userdata($invoice_info->user_id);
226 226
             
227
-            if ( !empty( $pre_status ) ) {
227
+            if (!empty($pre_status)) {
228 228
                 $invoice_info->status = $pre_status;
229 229
             }
230
-            $status = wpinv_gdp_to_wpi_status( $invoice_info->status );
230
+            $status = wpinv_gdp_to_wpi_status($invoice_info->status);
231 231
             
232 232
             $wpi_zero_tax = false;
233 233
             
234
-            if ( $wpi_gdp_inv_merge && in_array( $status, array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) {
234
+            if ($wpi_gdp_inv_merge && in_array($status, array('publish', 'wpi-processing', 'wpi-renewal'))) {
235 235
                 $wpi_zero_tax = true;
236 236
             }
237 237
             
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
             $invoice_data['user_id']        = $invoice_info->user_id;
242 242
             $invoice_data['created_via']    = 'API';
243 243
             
244
-            if ( !empty( $invoice_info->date ) ) {
245
-                $invoice_data['created_date']   = $invoice_info->date;
244
+            if (!empty($invoice_info->date)) {
245
+                $invoice_data['created_date'] = $invoice_info->date;
246 246
             }
247 247
             
248
-            $paymentmethod = !empty( $invoice_info->paymentmethod ) ? $invoice_info->paymentmethod : '';
249
-            $paymentmethod = wpinv_gdp_to_wpi_gateway( $paymentmethod );
250
-            $payment_method_title = wpinv_gdp_to_wpi_gateway_title( $paymentmethod );
248
+            $paymentmethod = !empty($invoice_info->paymentmethod) ? $invoice_info->paymentmethod : '';
249
+            $paymentmethod = wpinv_gdp_to_wpi_gateway($paymentmethod);
250
+            $payment_method_title = wpinv_gdp_to_wpi_gateway_title($paymentmethod);
251 251
             
252 252
             $invoice_data['payment_details'] = array( 
253 253
                 'gateway'           => $paymentmethod, 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
                 'currency'          => geodir_get_currency_type(),
256 256
             );
257 257
             
258
-            $user_address = wpinv_get_user_address( $invoice_info->user_id, false );
258
+            $user_address = wpinv_get_user_address($invoice_info->user_id, false);
259 259
             
260 260
             $invoice_data['user_info'] = array( 
261 261
                 'user_id'       => $invoice_info->user_id, 
@@ -278,14 +278,14 @@  discard block
 block discarded – undo
278 278
             
279 279
             $post_item = wpinv_get_gd_package_item($invoice_info->package_id);
280 280
 
281
-            if ( $invoice_info->invoice_type == 'add_franchise' ) {
281
+            if ($invoice_info->invoice_type == 'add_franchise') {
282 282
                 $custom_price = $invoice_info->amount;
283 283
             } else {
284 284
                 $custom_price = '';
285 285
             }
286 286
 
287
-            if ( !empty( $post_item ) ) {
288
-                $cart_details  = array();
287
+            if (!empty($post_item)) {
288
+                $cart_details = array();
289 289
                 $cart_details[] = array(
290 290
                     'id'            => $post_item->ID,
291 291
                     'name'          => $post_item->get_name(),
@@ -299,19 +299,19 @@  discard block
 block discarded – undo
299 299
                     ),
300 300
                 );
301 301
                 
302
-                $invoice_data['cart_details']  = $cart_details;
302
+                $invoice_data['cart_details'] = $cart_details;
303 303
             }
304 304
 
305
-            $data = array( 'invoice' => $invoice_data );
305
+            $data = array('invoice' => $invoice_data);
306 306
 
307 307
             $wpinv_api = new WPInv_API();
308
-            $data = $wpinv_api->insert_invoice( $data );
308
+            $data = $wpinv_api->insert_invoice($data);
309 309
             
310
-            if ( is_wp_error( $data ) ) {
311
-                wpinv_error_log( 'WPInv_Invoice: ' . $data->get_error_message() );
310
+            if (is_wp_error($data)) {
311
+                wpinv_error_log('WPInv_Invoice: ' . $data->get_error_message());
312 312
             } else {
313
-                if ( !empty( $data ) ) {
314
-                    update_post_meta( $data->ID, '_wpinv_gdp_id', $invoice_id );
313
+                if (!empty($data)) {
314
+                    update_post_meta($data->ID, '_wpinv_gdp_id', $invoice_id);
315 315
                     
316 316
                     $update_data = array();
317 317
                     $update_data['tax_amount'] = $data->get_tax();
@@ -319,14 +319,14 @@  discard block
 block discarded – undo
319 319
                     $update_data['invoice_id'] = $data->ID;
320 320
                     
321 321
                     global $wpdb;
322
-                    $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $invoice_id ) );
322
+                    $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $invoice_id));
323 323
                     
324 324
                     return $data;
325 325
                 } else {
326
-                    if ( $update ) {
327
-                        wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to update invoice.', 'invoicing' ) );
326
+                    if ($update) {
327
+                        wpinv_error_log('WPInv_Invoice: ' . __('Fail to update invoice.', 'invoicing'));
328 328
                     } else {
329
-                        wpinv_error_log( 'WPInv_Invoice: ' . __( 'Fail to create invoice.', 'invoicing' ) );
329
+                        wpinv_error_log('WPInv_Invoice: ' . __('Fail to create invoice.', 'invoicing'));
330 330
                     }
331 331
                 }
332 332
             }
@@ -337,59 +337,59 @@  discard block
 block discarded – undo
337 337
 }
338 338
 add_action('geodir_payment_invoice_created', 'wpinv_cpt_save', 11, 3);
339 339
 
340
-function wpinv_cpt_update( $invoice_id ) {
341
-    return wpinv_cpt_save( $invoice_id, true );
340
+function wpinv_cpt_update($invoice_id) {
341
+    return wpinv_cpt_save($invoice_id, true);
342 342
 }
343 343
 add_action('geodir_payment_invoice_updated', 'wpinv_cpt_update', 11, 1);
344 344
 
345
-function wpinv_payment_status_changed( $invoice_id, $new_status, $old_status = 'wpi-pending', $subscription = false ) {
346
-    $invoice_info = geodir_get_invoice( $invoice_id );
347
-    if ( empty( $invoice_info ) ) {
345
+function wpinv_payment_status_changed($invoice_id, $new_status, $old_status = 'wpi-pending', $subscription = false) {
346
+    $invoice_info = geodir_get_invoice($invoice_id);
347
+    if (empty($invoice_info)) {
348 348
         return false;
349 349
     }
350 350
 
351
-    $invoice = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL;
352
-    if ( !empty( $invoice ) ) {
351
+    $invoice = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL;
352
+    if (!empty($invoice)) {
353 353
         $new_status = wpinv_gdp_to_wpi_status($new_status);
354
-        $invoice    = wpinv_update_payment_status( $invoice->ID, $new_status );
354
+        $invoice    = wpinv_update_payment_status($invoice->ID, $new_status);
355 355
     } else {
356
-        $invoice = wpinv_cpt_save( $invoice_id );
356
+        $invoice = wpinv_cpt_save($invoice_id);
357 357
     }
358 358
     
359 359
     return $invoice;
360 360
 }
361
-add_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 );
361
+add_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4);
362 362
 
363
-function wpinv_transaction_details_note( $invoice_id, $html ) {
364
-    $invoice_info = geodir_get_invoice( $invoice_id );
365
-    if ( empty( $invoice_info ) ) {
363
+function wpinv_transaction_details_note($invoice_id, $html) {
364
+    $invoice_info = geodir_get_invoice($invoice_id);
365
+    if (empty($invoice_info)) {
366 366
         return false;
367 367
     }
368 368
 
369
-    $wpi_invoice_id = !empty( $invoice_info->invoice_id ) ? $invoice_info->invoice_id : NULL;
369
+    $wpi_invoice_id = !empty($invoice_info->invoice_id) ? $invoice_info->invoice_id : NULL;
370 370
     
371
-    if ( !$wpi_invoice_id ) {
372
-        $invoice = wpinv_cpt_save( $invoice_id, false, $old_status );
371
+    if (!$wpi_invoice_id) {
372
+        $invoice = wpinv_cpt_save($invoice_id, false, $old_status);
373 373
         
374
-        if ( !empty( $invoice ) ) {
374
+        if (!empty($invoice)) {
375 375
             $wpi_invoice_id = $invoice->ID;
376 376
         }
377 377
     }
378 378
 
379
-    $invoice = wpinv_get_invoice( $wpi_invoice_id );
379
+    $invoice = wpinv_get_invoice($wpi_invoice_id);
380 380
     
381
-    if ( empty( $invoice ) ) {
381
+    if (empty($invoice)) {
382 382
         return false;
383 383
     }
384 384
     
385
-    return $invoice->add_note( $html, true );
385
+    return $invoice->add_note($html, true);
386 386
 }
387
-add_action( 'geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2 );
387
+add_action('geodir_payment_invoice_transaction_details_changed', 'wpinv_transaction_details_note', 11, 2);
388 388
 
389
-function wpinv_gdp_to_wpi_status( $status ) {
389
+function wpinv_gdp_to_wpi_status($status) {
390 390
     $inv_status = $status ? $status : 'wpi-pending';
391 391
     
392
-    switch ( $status ) {
392
+    switch ($status) {
393 393
         case 'pending':
394 394
             $inv_status = 'wpi-pending';
395 395
         break;
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
     return $inv_status;
413 413
 }
414 414
 
415
-function wpinv_wpi_to_gdp_status( $status ) {
415
+function wpinv_wpi_to_gdp_status($status) {
416 416
     $inv_status = $status ? $status : 'pending';
417 417
     
418
-    switch ( $status ) {
418
+    switch ($status) {
419 419
         case 'wpi-pending':
420 420
             $inv_status = 'pending';
421 421
         break;
@@ -441,72 +441,72 @@  discard block
 block discarded – undo
441 441
     return $inv_status;
442 442
 }
443 443
 
444
-function wpinv_wpi_to_gdp_id( $invoice_id ) {
444
+function wpinv_wpi_to_gdp_id($invoice_id) {
445 445
     global $wpdb;
446 446
     
447
-    return $wpdb->get_var( $wpdb->prepare( "SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array( (int)$invoice_id ) ) );
447
+    return $wpdb->get_var($wpdb->prepare("SELECT `id` FROM `" . INVOICE_TABLE . "` WHERE `invoice_id` = %d AND `invoice_id` > 0 ORDER BY id DESC LIMIT 1", array((int)$invoice_id)));
448 448
 }
449 449
 
450
-function wpinv_gdp_to_wpi_id( $invoice_id ) {
451
-    $invoice = geodir_get_invoice( $invoice_id );    
452
-    return ( empty( $invoice->invoice_id ) ? $invoice->invoice_id : false);
450
+function wpinv_gdp_to_wpi_id($invoice_id) {
451
+    $invoice = geodir_get_invoice($invoice_id);    
452
+    return (empty($invoice->invoice_id) ? $invoice->invoice_id : false);
453 453
 }
454 454
 
455
-function wpinv_to_gdp_recalculate_total( $invoice, $wpi_nosave ) {
455
+function wpinv_to_gdp_recalculate_total($invoice, $wpi_nosave) {
456 456
     global $wpdb;
457 457
     
458
-    if ( !empty( $wpi_nosave ) ) {
458
+    if (!empty($wpi_nosave)) {
459 459
         return;
460 460
     }
461 461
     
462
-    $gdp_invoice_id = wpinv_wpi_to_gdp_id( $invoice->ID );
462
+    $gdp_invoice_id = wpinv_wpi_to_gdp_id($invoice->ID);
463 463
     
464
-    if ( $gdp_invoice_id > 0 ) {
464
+    if ($gdp_invoice_id > 0) {
465 465
         $update_data = array();
466 466
         $update_data['tax_amount']      = $invoice->tax;
467 467
         $update_data['paied_amount']    = $invoice->total;
468 468
         $update_data['discount']        = $invoice->discount;
469 469
         $update_data['coupon_code']     = $invoice->discount_code;
470 470
         
471
-        $wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $gdp_invoice_id ) );
471
+        $wpdb->update(INVOICE_TABLE, $update_data, array('id' => $gdp_invoice_id));
472 472
     }
473 473
     
474 474
     return;
475 475
 }
476 476
 //add_action( 'wpinv_invoice_recalculate_total', 'wpinv_to_gdp_recalculate_total', 10, 2 );
477 477
 
478
-function wpinv_gdp_to_wpi_invoice( $invoice_id ) {
479
-    $invoice = geodir_get_invoice( $invoice_id );
480
-    if ( empty( $invoice->invoice_id ) ) {
478
+function wpinv_gdp_to_wpi_invoice($invoice_id) {
479
+    $invoice = geodir_get_invoice($invoice_id);
480
+    if (empty($invoice->invoice_id)) {
481 481
         return false;
482 482
     }
483 483
     
484
-    return wpinv_get_invoice( $invoice->invoice_id );
484
+    return wpinv_get_invoice($invoice->invoice_id);
485 485
 }
486 486
 
487
-function wpinv_payment_set_coupon_code( $status, $invoice_id, $coupon_code ) {
488
-    $invoice = wpinv_gdp_to_wpi_invoice( $invoice_id );
489
-    if ( empty( $invoice ) ) {
487
+function wpinv_payment_set_coupon_code($status, $invoice_id, $coupon_code) {
488
+    $invoice = wpinv_gdp_to_wpi_invoice($invoice_id);
489
+    if (empty($invoice)) {
490 490
         return $status;
491 491
     }
492 492
 
493
-    if ( $status === 1 || $status === 0 ) {
494
-        if ( $status === 1 ) {
495
-            $discount = geodir_get_discount_amount( $coupon_code, $invoice->get_subtotal() );
493
+    if ($status === 1 || $status === 0) {
494
+        if ($status === 1) {
495
+            $discount = geodir_get_discount_amount($coupon_code, $invoice->get_subtotal());
496 496
         } else {
497 497
             $discount = '';
498 498
             $coupon_code = '';
499 499
         }
500 500
         
501
-        $invoice->set( 'discount', $discount );
502
-        $invoice->set( 'discount_code', $coupon_code );
501
+        $invoice->set('discount', $discount);
502
+        $invoice->set('discount_code', $coupon_code);
503 503
         $invoice->save();
504 504
         $invoice->recalculate_total();
505 505
     }
506 506
     
507 507
     return $status;
508 508
 }
509
-add_filter( 'geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3 );
509
+add_filter('geodir_payment_set_coupon_code', 'wpinv_payment_set_coupon_code', 10, 3);
510 510
 
511 511
 function wpinv_merge_gd_invoices() {
512 512
     if (!defined('GEODIRPAYMENT_VERSION')) {
@@ -514,157 +514,157 @@  discard block
 block discarded – undo
514 514
     }
515 515
     ?>
516 516
     <tr>
517
-        <td><?php _e( 'Merge Price Packages', 'invoicing' ); ?></td>
518
-        <td><p><?php _e( 'Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing' ); ?></p></td>
519
-        <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td>
517
+        <td><?php _e('Merge Price Packages', 'invoicing'); ?></td>
518
+        <td><p><?php _e('Merge GeoDirectory Payment Manager price packages to the Invoicing items.', 'invoicing'); ?></p></td>
519
+        <td><input type="button" data-tool="merge_packages" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td>
520 520
     </tr>
521 521
     <tr>
522
-        <td><?php _e( 'Merge Invoices', 'invoicing' ); ?></td>
523
-        <td><p><?php _e( 'Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing' ); ?></p></td>
524
-        <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td>
522
+        <td><?php _e('Merge Invoices', 'invoicing'); ?></td>
523
+        <td><p><?php _e('Merge GeoDirectory Payment Manager invoices to the Invoicing.', 'invoicing'); ?></p></td>
524
+        <td><input type="button" data-tool="merge_invoices" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td>
525 525
     </tr>
526 526
 	<tr>
527
-        <td><?php _e( 'Fix Taxes for Merged Invoices', 'invoicing' ); ?></td>
528
-        <td><p><?php _e( 'Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing' ); ?></p></td>
529
-        <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td>
527
+        <td><?php _e('Fix Taxes for Merged Invoices', 'invoicing'); ?></td>
528
+        <td><p><?php _e('Fix taxes for NON-PAID invoices which are merged before, from GeoDirectory Payment Manager invoices to Invoicing. This will recalculate taxes for non-paid merged invoices.', 'invoicing'); ?></p></td>
529
+        <td><input type="button" data-tool="merge_fix_taxes" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td>
530 530
     </tr>
531 531
     <tr>
532
-        <td><?php _e( 'Merge Coupons', 'invoicing' ); ?></td>
533
-        <td><p><?php _e( 'Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing' ); ?></p></td>
534
-        <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e( 'Run', 'invoicing' ); ?>"></td>
532
+        <td><?php _e('Merge Coupons', 'invoicing'); ?></td>
533
+        <td><p><?php _e('Merge GeoDirectory Payment Manager coupons to the Invoicing.', 'invoicing'); ?></p></td>
534
+        <td><input type="button" data-tool="merge_coupons" class="button-primary wpinv-tool" value="<?php esc_attr_e('Run', 'invoicing'); ?>"></td>
535 535
     </tr>
536 536
     <?php
537 537
 }
538
-add_action( 'wpinv_tools_row', 'wpinv_merge_gd_invoices', 10 );
538
+add_action('wpinv_tools_row', 'wpinv_merge_gd_invoices', 10);
539 539
 
540 540
 function wpinv_tool_merge_packages() {
541 541
     $packages = geodir_package_list_info();
542 542
     
543 543
     $count = 0;
544 544
     
545
-    if ( !empty( $packages ) ) {
545
+    if (!empty($packages)) {
546 546
         $success = true;
547 547
         
548
-        foreach ( $packages as $key => $package ) {
548
+        foreach ($packages as $key => $package) {
549 549
             $item = wpinv_get_item_by('custom_id', $package->pid, 'package');
550
-            if ( !empty( $item ) ) {
550
+            if (!empty($item)) {
551 551
                 continue;
552 552
             }
553 553
             
554
-            $merged = wpinv_merge_gd_package_to_item( $package->pid, false, $package );
554
+            $merged = wpinv_merge_gd_package_to_item($package->pid, false, $package);
555 555
             
556
-            if ( !empty( $merged ) ) {
557
-                wpinv_error_log( 'Package merge S : ' . $package->pid );
556
+            if (!empty($merged)) {
557
+                wpinv_error_log('Package merge S : ' . $package->pid);
558 558
                 $count++;
559 559
             } else {
560
-                wpinv_error_log( 'Package merge F : ' . $package->pid );
560
+                wpinv_error_log('Package merge F : ' . $package->pid);
561 561
             }
562 562
         }
563 563
         
564
-        if ( $count > 0 ) {
565
-            $message = sprintf( _n( 'Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing' ), $count );
564
+        if ($count > 0) {
565
+            $message = sprintf(_n('Total <b>%d</b> price package is merged successfully.', 'Total <b>%d</b> price packages are merged successfully.', $count, 'invoicing'), $count);
566 566
         } else {
567
-            $message = __( 'No price packages merged.', 'invoicing' );
567
+            $message = __('No price packages merged.', 'invoicing');
568 568
         }
569 569
     } else {
570 570
         $success = false;
571
-        $message = __( 'No price packages found to merge!', 'invoicing' );
571
+        $message = __('No price packages found to merge!', 'invoicing');
572 572
     }
573 573
     
574 574
     $response = array();
575 575
     $response['success'] = $success;
576 576
     $response['data']['message'] = $message;
577
-    wp_send_json( $response );
577
+    wp_send_json($response);
578 578
 }
579
-add_action( 'wpinv_tool_merge_packages', 'wpinv_tool_merge_packages' );
579
+add_action('wpinv_tool_merge_packages', 'wpinv_tool_merge_packages');
580 580
 
581 581
 function wpinv_tool_merge_invoices() {
582 582
     global $wpdb, $wpi_gdp_inv_merge, $wpi_tax_rates;
583 583
     
584 584
     $sql = "SELECT `gdi`.`id`, `gdi`.`date`, `gdi`.`date_updated` FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NULL ORDER BY `gdi`.`id` ASC";
585 585
 
586
-    $items = $wpdb->get_results( $sql );
586
+    $items = $wpdb->get_results($sql);
587 587
     
588 588
     $count = 0;
589 589
     
590
-    if ( !empty( $items ) ) {
590
+    if (!empty($items)) {
591 591
         $success = true;
592 592
         $wpi_gdp_inv_merge = true;
593 593
         
594
-        foreach ( $items as $item ) {
594
+        foreach ($items as $item) {
595 595
             $wpi_tax_rates = NULL;
596 596
             
597
-            $wpdb->query( "UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'" );
597
+            $wpdb->query("UPDATE `" . INVOICE_TABLE . "` SET `invoice_id` = 0 WHERE id = '" . $item->id . "'");
598 598
             
599
-            $merged = wpinv_cpt_save( $item->id );
599
+            $merged = wpinv_cpt_save($item->id);
600 600
             
601
-            if ( !empty( $merged ) && !empty( $merged->ID ) ) {
601
+            if (!empty($merged) && !empty($merged->ID)) {
602 602
                 $count++;
603 603
                 
604
-                $post_date = !empty( $item->date ) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time( 'mysql' );
605
-                $post_date_gmt = get_gmt_from_date( $post_date );
606
-                $post_modified = !empty( $item->date_updated ) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date;
607
-                $post_modified_gmt = get_gmt_from_date( $post_modified );
604
+                $post_date = !empty($item->date) && $item->date != '0000-00-00 00:00:00' ? $item->date : current_time('mysql');
605
+                $post_date_gmt = get_gmt_from_date($post_date);
606
+                $post_modified = !empty($item->date_updated) && $item->date_updated != '0000-00-00 00:00:00' ? $item->date_updated : $post_date;
607
+                $post_modified_gmt = get_gmt_from_date($post_modified);
608 608
                 
609
-                $wpdb->update( $wpdb->posts, array( 'post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt ), array( 'ID' => $merged->ID ) );
609
+                $wpdb->update($wpdb->posts, array('post_date' => $post_date, 'post_date_gmt' => $post_date_gmt, 'post_modified' => $post_modified, 'post_modified_gmt' => $post_modified_gmt), array('ID' => $merged->ID));
610 610
                 
611
-                if ( $merged->is_paid() ) {
612
-                    update_post_meta( $merged->ID, '_wpinv_completed_date', $post_modified );
611
+                if ($merged->is_paid()) {
612
+                    update_post_meta($merged->ID, '_wpinv_completed_date', $post_modified);
613 613
                 }
614 614
                 
615
-                clean_post_cache( $merged->ID );
615
+                clean_post_cache($merged->ID);
616 616
                 
617
-                wpinv_error_log( 'Invoice merge S : ' . $item->id . ' => ' . $merged->ID );
617
+                wpinv_error_log('Invoice merge S : ' . $item->id . ' => ' . $merged->ID);
618 618
             } else {
619
-                wpinv_error_log( 'Invoice merge F : ' . $item->id );
619
+                wpinv_error_log('Invoice merge F : ' . $item->id);
620 620
             }
621 621
         }
622 622
         
623 623
         $wpi_gdp_inv_merge = false;
624 624
         
625
-        if ( $count > 0 ) {
626
-            $message = sprintf( _n( 'Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing' ), $count );
625
+        if ($count > 0) {
626
+            $message = sprintf(_n('Total <b>%d</b> invoice is merged successfully.', 'Total <b>%d</b> invoices are merged successfully.', $count, 'invoicing'), $count);
627 627
         } else {
628
-            $message = __( 'No invoices merged.', 'invoicing' );
628
+            $message = __('No invoices merged.', 'invoicing');
629 629
         }
630 630
     } else {
631 631
         $success = false;
632
-        $message = __( 'No invoices found to merge!', 'invoicing' );
632
+        $message = __('No invoices found to merge!', 'invoicing');
633 633
     }
634 634
     
635 635
     $response = array();
636 636
     $response['success'] = $success;
637 637
     $response['data']['message'] = $message;
638
-    wp_send_json( $response );
638
+    wp_send_json($response);
639 639
 }
640
-add_action( 'wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices' );
640
+add_action('wpinv_tool_merge_invoices', 'wpinv_tool_merge_invoices');
641 641
 
642 642
 function wpinv_tool_merge_coupons() {
643 643
     global $wpdb;
644 644
     
645 645
     $sql = "SELECT * FROM `" . COUPON_TABLE . "` WHERE `coupon_code` IS NOT NULL AND `coupon_code` != '' ORDER BY `cid` ASC";
646
-    $items = $wpdb->get_results( $sql );
646
+    $items = $wpdb->get_results($sql);
647 647
     $count = 0;
648 648
     
649
-    if ( !empty( $items ) ) {
649
+    if (!empty($items)) {
650 650
         $success = true;
651 651
         
652
-        foreach ( $items as $item ) {
653
-            if ( wpinv_get_discount_by_code( $item->coupon_code ) ) {
652
+        foreach ($items as $item) {
653
+            if (wpinv_get_discount_by_code($item->coupon_code)) {
654 654
                 continue;
655 655
             }
656 656
             
657 657
             $args = array(
658 658
                 'post_type'   => 'wpi_discount',
659 659
                 'post_title'  => $item->coupon_code,
660
-                'post_status' => !empty( $item->status ) ? 'publish' : 'pending'
660
+                'post_status' => !empty($item->status) ? 'publish' : 'pending'
661 661
             );
662 662
 
663
-            $merged = wp_insert_post( $args );
663
+            $merged = wp_insert_post($args);
664 664
             
665 665
             $item_id = $item->cid;
666 666
             
667
-            if ( $merged ) {
667
+            if ($merged) {
668 668
                 $meta = array(
669 669
                     'code'              => $item->coupon_code,
670 670
                     'type'              => $item->discount_type != 'per' ? 'flat' : 'percent',
@@ -672,65 +672,65 @@  discard block
 block discarded – undo
672 672
                     'max_uses'          => (int)$item->usage_limit,
673 673
                     'uses'              => (int)$item->usage_count,
674 674
                 );
675
-                wpinv_store_discount( $merged, $meta, get_post( $merged ) );
675
+                wpinv_store_discount($merged, $meta, get_post($merged));
676 676
                 
677 677
                 $count++;
678 678
                 
679
-                wpinv_error_log( 'Coupon merge S : ' . $item_id . ' => ' . $merged );
679
+                wpinv_error_log('Coupon merge S : ' . $item_id . ' => ' . $merged);
680 680
             } else {
681
-                wpinv_error_log( 'Coupon merge F : ' . $item_id );
681
+                wpinv_error_log('Coupon merge F : ' . $item_id);
682 682
             }
683 683
         }
684 684
         
685
-        if ( $count > 0 ) {
686
-            $message = sprintf( _n( 'Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing' ), $count );
685
+        if ($count > 0) {
686
+            $message = sprintf(_n('Total <b>%d</b> coupon is merged successfully.', 'Total <b>%d</b> coupons are merged successfully.', $count, 'invoicing'), $count);
687 687
         } else {
688
-            $message = __( 'No coupons merged.', 'invoicing' );
688
+            $message = __('No coupons merged.', 'invoicing');
689 689
         }
690 690
     } else {
691 691
         $success = false;
692
-        $message = __( 'No coupons found to merge!', 'invoicing' );
692
+        $message = __('No coupons found to merge!', 'invoicing');
693 693
     }
694 694
     
695 695
     $response = array();
696 696
     $response['success'] = $success;
697 697
     $response['data']['message'] = $message;
698
-    wp_send_json( $response );
698
+    wp_send_json($response);
699 699
 }
700
-add_action( 'wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons' );
700
+add_action('wpinv_tool_merge_coupons', 'wpinv_tool_merge_coupons');
701 701
 
702
-function wpinv_gdp_to_wpi_currency( $value, $option = '' ) {
702
+function wpinv_gdp_to_wpi_currency($value, $option = '') {
703 703
     return wpinv_get_currency();
704 704
 }
705
-add_filter( 'pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2 );
705
+add_filter('pre_option_geodir_currency', 'wpinv_gdp_to_wpi_currency', 10, 2);
706 706
 
707
-function wpinv_gdp_to_wpi_currency_sign( $value, $option = '' ) {
707
+function wpinv_gdp_to_wpi_currency_sign($value, $option = '') {
708 708
     return wpinv_currency_symbol();
709 709
 }
710
-add_filter( 'pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2 );
710
+add_filter('pre_option_geodir_currencysym', 'wpinv_gdp_to_wpi_currency_sign', 10, 2);
711 711
 
712
-function wpinv_gdp_to_wpi_display_price( $price, $amount, $display = true , $decimal_sep, $thousand_sep ) {
713
-    if ( !$display ) {
714
-        $price = wpinv_round_amount( $amount );
712
+function wpinv_gdp_to_wpi_display_price($price, $amount, $display = true, $decimal_sep, $thousand_sep) {
713
+    if (!$display) {
714
+        $price = wpinv_round_amount($amount);
715 715
     } else {
716
-        $price = wpinv_price( wpinv_format_amount( $amount ) );
716
+        $price = wpinv_price(wpinv_format_amount($amount));
717 717
     }
718 718
     
719 719
     return $price;
720 720
 }
721
-add_filter( 'geodir_payment_price' , 'wpinv_gdp_to_wpi_display_price', 10000, 5 );
721
+add_filter('geodir_payment_price', 'wpinv_gdp_to_wpi_display_price', 10000, 5);
722 722
 
723
-function wpinv_gdp_to_inv_checkout_redirect( $redirect_url ) {
723
+function wpinv_gdp_to_inv_checkout_redirect($redirect_url) {
724 724
     $invoice_id         = geodir_payment_cart_id();
725
-    $invoice_info       = geodir_get_invoice( $invoice_id );
726
-    $wpi_invoice        = !empty( $invoice_info->invoice_id ) ? wpinv_get_invoice( $invoice_info->invoice_id ) : NULL;
725
+    $invoice_info       = geodir_get_invoice($invoice_id);
726
+    $wpi_invoice        = !empty($invoice_info->invoice_id) ? wpinv_get_invoice($invoice_info->invoice_id) : NULL;
727 727
     
728
-    if ( !( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) ) {
729
-        $wpi_invoice_id = wpinv_cpt_save( $invoice_id );
730
-        $wpi_invoice    = wpinv_get_invoice( $wpi_invoice_id );
728
+    if (!(!empty($wpi_invoice) && !empty($wpi_invoice->ID))) {
729
+        $wpi_invoice_id = wpinv_cpt_save($invoice_id);
730
+        $wpi_invoice    = wpinv_get_invoice($wpi_invoice_id);
731 731
     }
732 732
     
733
-    if ( !empty( $wpi_invoice ) && !empty( $wpi_invoice->ID ) ) {
733
+    if (!empty($wpi_invoice) && !empty($wpi_invoice->ID)) {
734 734
         
735 735
         // Clear cart
736 736
         geodir_payment_clear_cart();
@@ -740,121 +740,121 @@  discard block
 block discarded – undo
740 740
     
741 741
     return $redirect_url;
742 742
 }
743
-add_filter( 'geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1 );
743
+add_filter('geodir_payment_checkout_redirect_url', 'wpinv_gdp_to_inv_checkout_redirect', 100, 1);
744 744
 
745
-function wpinv_gdp_dashboard_invoice_history_link( $dashboard_links ) {    
746
-    if ( get_current_user_id() ) {        
747
-        $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url( wpinv_get_history_page_uri() ) . '">' . __( 'My Invoice History', 'invoicing' ) . '</a></li>';
745
+function wpinv_gdp_dashboard_invoice_history_link($dashboard_links) {    
746
+    if (get_current_user_id()) {        
747
+        $dashboard_links .= '<li><i class="fa fa-shopping-cart"></i><a class="gd-invoice-link" href="' . esc_url(wpinv_get_history_page_uri()) . '">' . __('My Invoice History', 'invoicing') . '</a></li>';
748 748
     }
749 749
 
750 750
     return $dashboard_links;
751 751
 }
752
-add_action( 'geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link' );
753
-remove_action( 'geodir_dashboard_links', 'geodir_payment_invoices_list_page_link' );
752
+add_action('geodir_dashboard_links', 'wpinv_gdp_dashboard_invoice_history_link');
753
+remove_action('geodir_dashboard_links', 'geodir_payment_invoices_list_page_link');
754 754
 
755
-function wpinv_wpi_to_gdp_update_status( $invoice_id, $new_status, $old_status ) {
755
+function wpinv_wpi_to_gdp_update_status($invoice_id, $new_status, $old_status) {
756 756
     if (!defined('GEODIRPAYMENT_VERSION')) {
757 757
         return false;
758 758
     }
759 759
     
760
-    $invoice    = wpinv_get_invoice( $invoice_id );
761
-    if ( empty( $invoice ) ) {
760
+    $invoice = wpinv_get_invoice($invoice_id);
761
+    if (empty($invoice)) {
762 762
         return false;
763 763
     }
764 764
     
765
-    remove_action( 'geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4 );
765
+    remove_action('geodir_payment_invoice_status_changed', 'wpinv_payment_status_changed', 11, 4);
766 766
     
767
-    $invoice_id = wpinv_wpi_to_gdp_id( $invoice_id );
768
-    $new_status = wpinv_wpi_to_gdp_status( $new_status );
767
+    $invoice_id = wpinv_wpi_to_gdp_id($invoice_id);
768
+    $new_status = wpinv_wpi_to_gdp_status($new_status);
769 769
     
770
-    geodir_update_invoice_status( $invoice_id, $new_status, $invoice->is_recurring() );
770
+    geodir_update_invoice_status($invoice_id, $new_status, $invoice->is_recurring());
771 771
 }
772
-add_action( 'wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3 );
772
+add_action('wpinv_update_status', 'wpinv_wpi_to_gdp_update_status', 999, 3);
773 773
 
774
-function wpinv_gdp_to_wpi_delete_package( $gd_package_id ) {
775
-    $item = wpinv_get_item_by( 'custom_id', $gd_package_id, 'package' );
774
+function wpinv_gdp_to_wpi_delete_package($gd_package_id) {
775
+    $item = wpinv_get_item_by('custom_id', $gd_package_id, 'package');
776 776
     
777
-    if ( !empty( $item ) ) {
778
-        wpinv_remove_item( $item, true );
777
+    if (!empty($item)) {
778
+        wpinv_remove_item($item, true);
779 779
     }
780 780
 }
781
-add_action( 'geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1 ) ;
781
+add_action('geodir_payment_post_delete_package', 'wpinv_gdp_to_wpi_delete_package', 10, 1);
782 782
 
783
-function wpinv_can_delete_package_item( $return, $post_id ) {
784
-    if ( $return && function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && $package_id = get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
785
-        $gd_package = geodir_get_package_info_by_id( $package_id, '' );
783
+function wpinv_can_delete_package_item($return, $post_id) {
784
+    if ($return && function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && $package_id = get_post_meta($post_id, '_wpinv_custom_id', true)) {
785
+        $gd_package = geodir_get_package_info_by_id($package_id, '');
786 786
         
787
-        if ( !empty( $gd_package ) ) {
787
+        if (!empty($gd_package)) {
788 788
             $return = false;
789 789
         }
790 790
     }
791 791
 
792 792
     return $return;
793 793
 }
794
-add_filter( 'wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2 );
794
+add_filter('wpinv_can_delete_item', 'wpinv_can_delete_package_item', 10, 2);
795 795
 
796
-function wpinv_package_item_classes( $classes, $class, $post_id ) {
796
+function wpinv_package_item_classes($classes, $class, $post_id) {
797 797
     global $typenow;
798 798
 
799
-    if ( $typenow == 'wpi_item' && in_array( 'wpi-gd-package', $classes ) ) {
800
-        if ( wpinv_item_in_use( $post_id ) ) {
799
+    if ($typenow == 'wpi_item' && in_array('wpi-gd-package', $classes)) {
800
+        if (wpinv_item_in_use($post_id)) {
801 801
             $classes[] = 'wpi-inuse-pkg';
802
-        } else if ( !( function_exists( 'geodir_get_package_info_by_id' ) && get_post_meta( $post_id, '_wpinv_type', true ) == 'package' && geodir_get_package_info_by_id( (int)get_post_meta( $post_id, '_wpinv_custom_id', true ), '' ) ) ) {
802
+        } else if (!(function_exists('geodir_get_package_info_by_id') && get_post_meta($post_id, '_wpinv_type', true) == 'package' && geodir_get_package_info_by_id((int)get_post_meta($post_id, '_wpinv_custom_id', true), ''))) {
803 803
             $classes[] = 'wpi-delete-pkg';
804 804
         }
805 805
     }
806 806
 
807 807
     return $classes;
808 808
 }
809
-add_filter( 'post_class', 'wpinv_package_item_classes', 10, 3 );
809
+add_filter('post_class', 'wpinv_package_item_classes', 10, 3);
810 810
 
811
-function wpinv_gdp_package_type_info( $post ) {
812
-    if ( wpinv_pm_active() ) {
813
-        ?><p class="wpi-m0"><?php _e( 'Package: GeoDirectory price packages items.', 'invoicing' );?></p>
811
+function wpinv_gdp_package_type_info($post) {
812
+    if (wpinv_pm_active()) {
813
+        ?><p class="wpi-m0"><?php _e('Package: GeoDirectory price packages items.', 'invoicing'); ?></p>
814 814
         <?php
815 815
     }
816 816
 }
817
-add_action( 'wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1 ) ;
817
+add_action('wpinv_item_info_metabox_after', 'wpinv_gdp_package_type_info', 10, 1);
818 818
 
819
-function wpinv_gdp_to_gdi_set_zero_tax( $is_taxable, $item_id, $country , $state ) {
819
+function wpinv_gdp_to_gdi_set_zero_tax($is_taxable, $item_id, $country, $state) {
820 820
     global $wpi_zero_tax;
821 821
 
822
-    if ( $wpi_zero_tax ) {
822
+    if ($wpi_zero_tax) {
823 823
         $is_taxable = false;
824 824
     }
825 825
 
826 826
     return $is_taxable;
827 827
 }
828
-add_action( 'wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4 ) ;
828
+add_action('wpinv_item_is_taxable', 'wpinv_gdp_to_gdi_set_zero_tax', 10, 4);
829 829
 
830 830
 function wpinv_tool_merge_fix_taxes() {
831 831
     global $wpdb;
832 832
     
833 833
 	$sql = "SELECT DISTINCT p.ID FROM `" . $wpdb->posts . "` AS p LEFT JOIN " . $wpdb->postmeta . " AS pm ON pm.post_id = p.ID WHERE p.post_type = 'wpi_item' AND pm.meta_key = '_wpinv_type' AND pm.meta_value = 'package'";
834
-	$items = $wpdb->get_results( $sql );
834
+	$items = $wpdb->get_results($sql);
835 835
 	
836
-	if ( !empty( $items ) ) {
837
-		foreach ( $items as $item ) {
838
-			if ( get_post_meta( $item->ID, '_wpinv_vat_class', true ) == '_exempt' ) {
839
-				update_post_meta( $item->ID, '_wpinv_vat_class', '_standard' );
836
+	if (!empty($items)) {
837
+		foreach ($items as $item) {
838
+			if (get_post_meta($item->ID, '_wpinv_vat_class', true) == '_exempt') {
839
+				update_post_meta($item->ID, '_wpinv_vat_class', '_standard');
840 840
 			}
841 841
 		}
842 842
 	}
843 843
 		
844 844
     $sql = "SELECT `p`.`ID`, gdi.id AS gdp_id FROM `" . INVOICE_TABLE . "` AS gdi LEFT JOIN `" . $wpdb->posts . "` AS p ON `p`.`ID` = `gdi`.`invoice_id` AND `p`.`post_type` = 'wpi_invoice' WHERE `p`.`ID` IS NOT NULL AND p.post_status NOT IN( 'publish', 'wpi-processing', 'wpi-renewal' ) ORDER BY `gdi`.`id` ASC";
845
-    $items = $wpdb->get_results( $sql );
845
+    $items = $wpdb->get_results($sql);
846 846
 	
847
-	if ( !empty( $items ) ) {
847
+	if (!empty($items)) {
848 848
 		$success = false;
849
-        $message = __( 'Taxes fixed for non-paid merged GD invoices.', 'invoicing' );
849
+        $message = __('Taxes fixed for non-paid merged GD invoices.', 'invoicing');
850 850
 		
851 851
 		global $wpi_userID, $wpinv_ip_address_country, $wpi_tax_rates;
852 852
 		
853
-		foreach ( $items as $item ) {
853
+		foreach ($items as $item) {
854 854
 			$wpi_tax_rates = NULL;               
855 855
 			$data = wpinv_get_invoice($item->ID);
856 856
 
857
-			if ( empty( $data ) ) {
857
+			if (empty($data)) {
858 858
 				continue;
859 859
 			}
860 860
 			
@@ -862,51 +862,51 @@  discard block
 block discarded – undo
862 862
 			
863 863
 			$data_session                   = array();
864 864
 			$data_session['invoice_id']     = $data->ID;
865
-			$data_session['cart_discounts'] = $data->get_discounts( true );
865
+			$data_session['cart_discounts'] = $data->get_discounts(true);
866 866
 			
867
-			wpinv_set_checkout_session( $data_session );
867
+			wpinv_set_checkout_session($data_session);
868 868
 			
869 869
 			$wpi_userID         = (int)$data->get_user_id();
870 870
 			$_POST['country']   = !empty($data->country) ? $data->country : wpinv_get_default_country();
871 871
 				
872
-			$data->country      = sanitize_text_field( $_POST['country'] );
873
-			$data->set( 'country', sanitize_text_field( $_POST['country'] ) );
872
+			$data->country      = sanitize_text_field($_POST['country']);
873
+			$data->set('country', sanitize_text_field($_POST['country']));
874 874
 			
875 875
 			$wpinv_ip_address_country = $data->country;
876 876
 			
877 877
 			$data->recalculate_totals(true);
878 878
 			
879
-			wpinv_set_checkout_session( $checkout_session );
879
+			wpinv_set_checkout_session($checkout_session);
880 880
 			
881 881
 			$update_data = array();
882 882
 			$update_data['tax_amount'] = $data->get_tax();
883 883
 			$update_data['paied_amount'] = $data->get_total();
884 884
 			$update_data['invoice_id'] = $data->ID;
885 885
 			
886
-			$wpdb->update( INVOICE_TABLE, $update_data, array( 'id' => $item->gdp_id ) );
886
+			$wpdb->update(INVOICE_TABLE, $update_data, array('id' => $item->gdp_id));
887 887
 		}
888 888
 	} else {
889 889
         $success = false;
890
-        $message = __( 'No invoices found to fix taxes!', 'invoicing' );
890
+        $message = __('No invoices found to fix taxes!', 'invoicing');
891 891
     }
892 892
 	
893 893
 	$response = array();
894 894
     $response['success'] = $success;
895 895
     $response['data']['message'] = $message;
896
-    wp_send_json( $response );
896
+    wp_send_json($response);
897 897
 }
898
-add_action( 'wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes' );
899
-remove_action( 'geodir_before_detail_fields' , 'geodir_build_coupon', 2 );
898
+add_action('wpinv_tool_merge_fix_taxes', 'wpinv_tool_merge_fix_taxes');
899
+remove_action('geodir_before_detail_fields', 'geodir_build_coupon', 2);
900 900
 
901
-function wpinv_wpi_to_gdp_handle_subscription_cancel( $invoice_id, $invoice ) {
902
-    if ( wpinv_pm_active() && !empty( $invoice ) && $invoice->is_recurring() ) {
903
-        if ( $invoice->is_renewal() ) {
901
+function wpinv_wpi_to_gdp_handle_subscription_cancel($invoice_id, $invoice) {
902
+    if (wpinv_pm_active() && !empty($invoice) && $invoice->is_recurring()) {
903
+        if ($invoice->is_renewal()) {
904 904
             $invoice = $invoice->get_parent_payment();
905 905
         }
906 906
         
907
-        if ( !empty( $invoice ) ) {
908
-            wpinv_wpi_to_gdp_update_status( $invoice->ID, 'wpi-cancelled', $invoice->get_status() );
907
+        if (!empty($invoice)) {
908
+            wpinv_wpi_to_gdp_update_status($invoice->ID, 'wpi-cancelled', $invoice->get_status());
909 909
         }
910 910
     }
911 911
 }
912
-add_action( 'wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2 );
913 912
\ No newline at end of file
913
+add_action('wpinv_subscription_cancelled', 'wpinv_wpi_to_gdp_handle_subscription_cancel', 10, 2);
914 914
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Spacing   +252 added lines, -252 removed lines patch added patch discarded remove patch
@@ -7,206 +7,206 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 function wpinv_get_payment_gateways() {
15 15
     // Default, built-in gateways
16 16
     $gateways = array(
17 17
         'paypal' => array(
18
-            'admin_label'    => __( 'PayPal Standard', 'invoicing' ),
19
-            'checkout_label' => __( 'PayPal Standard', 'invoicing' ),
18
+            'admin_label'    => __('PayPal Standard', 'invoicing'),
19
+            'checkout_label' => __('PayPal Standard', 'invoicing'),
20 20
             'ordering'       => 1,
21 21
         ),
22 22
         'authorizenet' => array(
23
-            'admin_label'    => __( 'Authorize.Net (AIM)', 'invoicing' ),
24
-            'checkout_label' => __( 'Authorize.Net - Credit Card / Debit Card', 'invoicing' ),
23
+            'admin_label'    => __('Authorize.Net (AIM)', 'invoicing'),
24
+            'checkout_label' => __('Authorize.Net - Credit Card / Debit Card', 'invoicing'),
25 25
             'ordering'       => 4,
26 26
         ),
27 27
         'worldpay' => array(
28
-            'admin_label'    => __( 'Worldpay', 'invoicing' ),
29
-            'checkout_label' => __( 'Worldpay - Credit Card / Debit Card', 'invoicing' ),
28
+            'admin_label'    => __('Worldpay', 'invoicing'),
29
+            'checkout_label' => __('Worldpay - Credit Card / Debit Card', 'invoicing'),
30 30
             'ordering'       => 5,
31 31
         ),
32 32
         'bank_transfer' => array(
33
-            'admin_label'    => __( 'Pre Bank Transfer', 'invoicing' ),
34
-            'checkout_label' => __( 'Pre Bank Transfer', 'invoicing' ),
33
+            'admin_label'    => __('Pre Bank Transfer', 'invoicing'),
34
+            'checkout_label' => __('Pre Bank Transfer', 'invoicing'),
35 35
             'ordering'       => 11,
36 36
         ),
37 37
         'manual' => array(
38
-            'admin_label'    => __( 'Test Payment', 'invoicing' ),
39
-            'checkout_label' => __( 'Test Payment', 'invoicing' ),
38
+            'admin_label'    => __('Test Payment', 'invoicing'),
39
+            'checkout_label' => __('Test Payment', 'invoicing'),
40 40
             'ordering'       => 12,
41 41
         ),
42 42
     );
43 43
 
44
-    return apply_filters( 'wpinv_payment_gateways', $gateways );
44
+    return apply_filters('wpinv_payment_gateways', $gateways);
45 45
 }
46 46
 
47
-function wpinv_payment_gateway_titles( $all_gateways ) {
47
+function wpinv_payment_gateway_titles($all_gateways) {
48 48
     global $wpinv_options;
49 49
     
50 50
     $gateways = array();
51
-    foreach ( $all_gateways as $key => $gateway ) {
52
-        if ( !empty( $wpinv_options[$key . '_title'] ) ) {
53
-            $all_gateways[$key]['checkout_label'] = __( $wpinv_options[$key . '_title'], 'invoicing' );
51
+    foreach ($all_gateways as $key => $gateway) {
52
+        if (!empty($wpinv_options[$key . '_title'])) {
53
+            $all_gateways[$key]['checkout_label'] = __($wpinv_options[$key . '_title'], 'invoicing');
54 54
         }
55 55
         
56
-        $gateways[$key] = isset( $wpinv_options[$key . '_ordering'] ) ? $wpinv_options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' );
56
+        $gateways[$key] = isset($wpinv_options[$key . '_ordering']) ? $wpinv_options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : '');
57 57
     }
58 58
 
59
-    asort( $gateways );
59
+    asort($gateways);
60 60
     
61
-    foreach ( $gateways as $gateway => $key ) {
61
+    foreach ($gateways as $gateway => $key) {
62 62
         $gateways[$gateway] = $all_gateways[$gateway];
63 63
     }
64 64
     
65 65
     return $gateways;
66 66
 }
67
-add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 );
67
+add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1);
68 68
 
69
-function wpinv_get_enabled_payment_gateways( $sort = false ) {
69
+function wpinv_get_enabled_payment_gateways($sort = false) {
70 70
     $gateways = wpinv_get_payment_gateways();
71
-    $enabled  = wpinv_get_option( 'gateways', false );
71
+    $enabled  = wpinv_get_option('gateways', false);
72 72
 
73 73
     $gateway_list = array();
74 74
 
75
-    foreach ( $gateways as $key => $gateway ) {
76
-        if ( isset( $enabled[ $key ] ) && $enabled[ $key ] == 1 ) {
77
-            $gateway_list[ $key ] = $gateway;
75
+    foreach ($gateways as $key => $gateway) {
76
+        if (isset($enabled[$key]) && $enabled[$key] == 1) {
77
+            $gateway_list[$key] = $gateway;
78 78
         }
79 79
     }
80 80
 
81
-    if ( true === $sort ) {
82
-        uasort( $gateway_list, 'wpinv_sort_gateway_order' );
81
+    if (true === $sort) {
82
+        uasort($gateway_list, 'wpinv_sort_gateway_order');
83 83
         
84 84
         // Reorder our gateways so the default is first
85 85
         $default_gateway_id = wpinv_get_default_gateway();
86 86
 
87
-        if ( wpinv_is_gateway_active( $default_gateway_id ) ) {
88
-            $default_gateway    = array( $default_gateway_id => $gateway_list[ $default_gateway_id ] );
89
-            unset( $gateway_list[ $default_gateway_id ] );
87
+        if (wpinv_is_gateway_active($default_gateway_id)) {
88
+            $default_gateway = array($default_gateway_id => $gateway_list[$default_gateway_id]);
89
+            unset($gateway_list[$default_gateway_id]);
90 90
 
91
-            $gateway_list = array_merge( $default_gateway, $gateway_list );
91
+            $gateway_list = array_merge($default_gateway, $gateway_list);
92 92
         }
93 93
     }
94 94
 
95
-    return apply_filters( 'wpinv_enabled_payment_gateways', $gateway_list );
95
+    return apply_filters('wpinv_enabled_payment_gateways', $gateway_list);
96 96
 }
97 97
 
98
-function wpinv_sort_gateway_order( $a, $b ) {
98
+function wpinv_sort_gateway_order($a, $b) {
99 99
     return $a['ordering'] - $b['ordering'];
100 100
 }
101 101
 
102
-function wpinv_is_gateway_active( $gateway ) {
102
+function wpinv_is_gateway_active($gateway) {
103 103
     $gateways = wpinv_get_enabled_payment_gateways();
104 104
 
105
-    $ret = is_array($gateways) && $gateway ?  array_key_exists( $gateway, $gateways ) : false;
105
+    $ret = is_array($gateways) && $gateway ?  array_key_exists($gateway, $gateways) : false;
106 106
 
107
-    return apply_filters( 'wpinv_is_gateway_active', $ret, $gateway, $gateways );
107
+    return apply_filters('wpinv_is_gateway_active', $ret, $gateway, $gateways);
108 108
 }
109 109
 
110 110
 function wpinv_get_default_gateway() {
111
-    $default = wpinv_get_option( 'default_gateway', 'paypal' );
111
+    $default = wpinv_get_option('default_gateway', 'paypal');
112 112
 
113
-    if ( !wpinv_is_gateway_active( $default ) ) {
113
+    if (!wpinv_is_gateway_active($default)) {
114 114
         $gateways = wpinv_get_enabled_payment_gateways();
115
-        $gateways = array_keys( $gateways );
116
-        $default  = reset( $gateways );
115
+        $gateways = array_keys($gateways);
116
+        $default  = reset($gateways);
117 117
     }
118 118
 
119
-    return apply_filters( 'wpinv_default_gateway', $default );
119
+    return apply_filters('wpinv_default_gateway', $default);
120 120
 }
121 121
 
122
-function wpinv_get_gateway_admin_label( $gateway ) {
122
+function wpinv_get_gateway_admin_label($gateway) {
123 123
     $gateways = wpinv_get_payment_gateways();
124
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway;
125
-    $payment  = isset( $_GET['id'] ) ? absint( $_GET['id'] ) : false;
124
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway;
125
+    $payment  = isset($_GET['id']) ? absint($_GET['id']) : false;
126 126
 
127
-    if( $gateway == 'manual' && $payment ) {
128
-        if( wpinv_get_payment_amount( $payment ) == 0 ) {
129
-            $label = __( 'Manual Payment', 'invoicing' );
127
+    if ($gateway == 'manual' && $payment) {
128
+        if (wpinv_get_payment_amount($payment) == 0) {
129
+            $label = __('Manual Payment', 'invoicing');
130 130
         }
131 131
     }
132 132
 
133
-    return apply_filters( 'wpinv_gateway_admin_label', $label, $gateway );
133
+    return apply_filters('wpinv_gateway_admin_label', $label, $gateway);
134 134
 }
135 135
 
136
-function wpinv_get_gateway_description( $gateway ) {
136
+function wpinv_get_gateway_description($gateway) {
137 137
     global $wpinv_options;
138 138
 
139
-    $description = isset( $wpinv_options[$gateway . '_desc'] ) ? $wpinv_options[$gateway . '_desc'] : '';
139
+    $description = isset($wpinv_options[$gateway . '_desc']) ? $wpinv_options[$gateway . '_desc'] : '';
140 140
 
141
-    return apply_filters( 'wpinv_gateway_description', $description, $gateway );
141
+    return apply_filters('wpinv_gateway_description', $description, $gateway);
142 142
 }
143 143
 
144
-function wpinv_get_gateway_button_label( $gateway ) {
145
-    return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' );
144
+function wpinv_get_gateway_button_label($gateway) {
145
+    return apply_filters('wpinv_gateway_' . $gateway . '_button_label', '');
146 146
 }
147 147
 
148
-function wpinv_get_gateway_checkout_label( $gateway ) {
148
+function wpinv_get_gateway_checkout_label($gateway) {
149 149
     $gateways = wpinv_get_payment_gateways();
150
-    $label    = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway;
150
+    $label    = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway;
151 151
 
152
-    if( $gateway == 'manual' ) {
153
-        $label = __( 'Manual Payment', 'invoicing' );
152
+    if ($gateway == 'manual') {
153
+        $label = __('Manual Payment', 'invoicing');
154 154
     }
155 155
 
156
-    return apply_filters( 'wpinv_gateway_checkout_label', $label, $gateway );
156
+    return apply_filters('wpinv_gateway_checkout_label', $label, $gateway);
157 157
 }
158 158
 
159
-function wpinv_settings_sections_gateways( $settings ) {
159
+function wpinv_settings_sections_gateways($settings) {
160 160
     $gateways = wpinv_get_payment_gateways();
161 161
     
162 162
     if (!empty($gateways)) {
163
-        foreach  ($gateways as $key => $gateway) {
163
+        foreach ($gateways as $key => $gateway) {
164 164
             $settings[$key] = $gateway['admin_label'];
165 165
         }
166 166
     }
167 167
     
168 168
     return $settings;    
169 169
 }
170
-add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 );
170
+add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1);
171 171
 
172
-function wpinv_settings_gateways( $settings ) {
172
+function wpinv_settings_gateways($settings) {
173 173
     $gateways = wpinv_get_payment_gateways();
174 174
     
175 175
     if (!empty($gateways)) {
176
-        foreach  ($gateways as $key => $gateway) {
176
+        foreach ($gateways as $key => $gateway) {
177 177
             $setting = array();
178 178
             $setting[$key . '_header'] = array(
179 179
                     'id'   => 'gateway_header',
180
-                    'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>',
180
+                    'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>',
181 181
                     'custom' => $key,
182 182
                     'type' => 'gateway_header',
183 183
                 );
184 184
             $setting[$key . '_active'] = array(
185 185
                     'id'   => $key . '_active',
186
-                    'name' => __( 'Active', 'invoicing' ),
187
-                    'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ),
186
+                    'name' => __('Active', 'invoicing'),
187
+                    'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']),
188 188
                     'type' => 'checkbox',
189 189
                 );
190 190
                 
191 191
             $setting[$key . '_title'] = array(
192 192
                     'id'   => $key . '_title',
193
-                    'name' => __( 'Title', 'invoicing' ),
194
-                    'desc' => __( 'This controls the title which the user sees during checkout.', 'invoicing' ),
193
+                    'name' => __('Title', 'invoicing'),
194
+                    'desc' => __('This controls the title which the user sees during checkout.', 'invoicing'),
195 195
                     'type' => 'text',
196 196
                     'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : ''
197 197
                 );
198 198
             
199 199
             $setting[$key . '_desc'] = array(
200 200
                     'id'   => $key . '_desc',
201
-                    'name' => __( 'Description', 'invoicing' ),
202
-                    'desc' => __( 'This controls the description which the user sees during checkout.', 'invoicing' ),
201
+                    'name' => __('Description', 'invoicing'),
202
+                    'desc' => __('This controls the description which the user sees during checkout.', 'invoicing'),
203 203
                     'type' => 'text',
204 204
                     'size' => 'large'
205 205
                 );
206 206
                 
207 207
             $setting[$key . '_ordering'] = array(
208 208
                     'id'   => $key . '_ordering',
209
-                    'name' => __( 'Display Order', 'invoicing' ),
209
+                    'name' => __('Display Order', 'invoicing'),
210 210
                     'type' => 'number',
211 211
                     'size' => 'small',
212 212
                     'std'  => isset($gateway['ordering']) ? $gateway['ordering'] : '10',
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
                     'step' => '1'
216 216
                 );
217 217
                 
218
-            $setting = apply_filters( 'wpinv_gateway_settings', $setting, $key );
219
-            $setting = apply_filters( 'wpinv_gateway_settings_' . $key, $setting );
218
+            $setting = apply_filters('wpinv_gateway_settings', $setting, $key);
219
+            $setting = apply_filters('wpinv_gateway_settings_' . $key, $setting);
220 220
             
221 221
             $settings[$key] = $setting;
222 222
         }
@@ -224,106 +224,106 @@  discard block
 block discarded – undo
224 224
     
225 225
     return $settings;    
226 226
 }
227
-add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 );
227
+add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1);
228 228
 
229
-function wpinv_gateway_header_callback( $args ) {
230
-    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />';
229
+function wpinv_gateway_header_callback($args) {
230
+    echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />';
231 231
 }
232 232
 
233
-function wpinv_get_gateway_supports( $gateway ) {
233
+function wpinv_get_gateway_supports($gateway) {
234 234
     $gateways = wpinv_get_enabled_payment_gateways();
235
-    $supports = isset( $gateways[ $gateway ]['supports'] ) ? $gateways[ $gateway ]['supports'] : array();
236
-    return apply_filters( 'wpinv_gateway_supports', $supports, $gateway );
235
+    $supports = isset($gateways[$gateway]['supports']) ? $gateways[$gateway]['supports'] : array();
236
+    return apply_filters('wpinv_gateway_supports', $supports, $gateway);
237 237
 }
238 238
 
239
-function wpinv_gateway_supports_buy_now( $gateway ) {
240
-    $supports = wpinv_get_gateway_supports( $gateway );
241
-    $ret = in_array( 'buy_now', $supports );
242
-    return apply_filters( 'wpinv_gateway_supports_buy_now', $ret, $gateway );
239
+function wpinv_gateway_supports_buy_now($gateway) {
240
+    $supports = wpinv_get_gateway_supports($gateway);
241
+    $ret = in_array('buy_now', $supports);
242
+    return apply_filters('wpinv_gateway_supports_buy_now', $ret, $gateway);
243 243
 }
244 244
 
245 245
 function wpinv_shop_supports_buy_now() {
246 246
     $gateways = wpinv_get_enabled_payment_gateways();
247 247
     $ret      = false;
248 248
 
249
-    if ( !wpinv_use_taxes()  && $gateways ) {
250
-        foreach ( $gateways as $gateway_id => $gateway ) {
251
-            if ( wpinv_gateway_supports_buy_now( $gateway_id ) ) {
249
+    if (!wpinv_use_taxes() && $gateways) {
250
+        foreach ($gateways as $gateway_id => $gateway) {
251
+            if (wpinv_gateway_supports_buy_now($gateway_id)) {
252 252
                 $ret = true;
253 253
                 break;
254 254
             }
255 255
         }
256 256
     }
257 257
 
258
-    return apply_filters( 'wpinv_shop_supports_buy_now', $ret );
258
+    return apply_filters('wpinv_shop_supports_buy_now', $ret);
259 259
 }
260 260
 
261
-function wpinv_send_to_gateway( $gateway, $payment_data ) {
262
-    $payment_data['gateway_nonce'] = wp_create_nonce( 'wpi-gateway' );
261
+function wpinv_send_to_gateway($gateway, $payment_data) {
262
+    $payment_data['gateway_nonce'] = wp_create_nonce('wpi-gateway');
263 263
 
264 264
     // $gateway must match the ID used when registering the gateway
265
-    do_action( 'wpinv_gateway_' . $gateway, $payment_data );
265
+    do_action('wpinv_gateway_' . $gateway, $payment_data);
266 266
 }
267 267
 
268 268
 function wpinv_show_gateways() {
269 269
     $gateways = wpinv_get_enabled_payment_gateways();
270 270
     $show_gateways = false;
271 271
 
272
-    $chosen_gateway = isset( $_GET['payment-mode'] ) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode'] ) : false;
272
+    $chosen_gateway = isset($_GET['payment-mode']) ? preg_replace('/[^a-zA-Z0-9-_]+/', '', $_GET['payment-mode']) : false;
273 273
 
274
-    if ( count( $gateways ) > 1 && empty( $chosen_gateway ) ) {
274
+    if (count($gateways) > 1 && empty($chosen_gateway)) {
275 275
         $show_gateways = true;
276
-        if ( wpinv_get_cart_total() <= 0 ) {
276
+        if (wpinv_get_cart_total() <= 0) {
277 277
             $show_gateways = false;
278 278
         }
279 279
     }
280 280
     
281
-    if ( !$show_gateways && wpinv_cart_has_recurring_item() ) {
281
+    if (!$show_gateways && wpinv_cart_has_recurring_item()) {
282 282
         $show_gateways = true;
283 283
     }
284 284
 
285
-    return apply_filters( 'wpinv_show_gateways', $show_gateways );
285
+    return apply_filters('wpinv_show_gateways', $show_gateways);
286 286
 }
287 287
 
288
-function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
288
+function wpinv_get_chosen_gateway($invoice_id = 0) {
289
+	$gateways = array_keys(wpinv_get_enabled_payment_gateways());
290 290
 
291 291
     $chosen = false;
292
-    if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
292
+    if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+	$chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
298
+	if (false !== $chosen) {
299
+		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen);
300 300
 	}
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
302
+	if (!empty ($chosen)) {
303
+		$enabled_gateway = urldecode($chosen);
304
+	} else if (!empty($invoice) && (float)$invoice->get_subtotal() <= 0) {
305 305
 		$enabled_gateway = 'manual';
306 306
 	} else {
307 307
 		$enabled_gateway = wpinv_get_default_gateway();
308 308
 	}
309 309
     
310
-    if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311
-        if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
310
+    if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) {
311
+        if (wpinv_is_gateway_active(wpinv_get_default_gateway())) {
312 312
             $enabled_gateway = wpinv_get_default_gateway();
313
-        }else{
313
+        } else {
314 314
             $enabled_gateway = $gateways[0];
315 315
         }
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+	return apply_filters('wpinv_chosen_gateway', $enabled_gateway);
320 320
 }
321 321
 
322
-function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
323
-    return wpinv_error_log( $message, $title );
322
+function wpinv_record_gateway_error($title = '', $message = '', $parent = 0) {
323
+    return wpinv_error_log($message, $title);
324 324
 }
325 325
 
326
-function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
326
+function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') {
327 327
 	$ret  = 0;
328 328
 	$args = array(
329 329
 		'meta_key'    => '_wpinv_gateway',
@@ -334,48 +334,48 @@  discard block
 block discarded – undo
334 334
 		'fields'      => 'ids'
335 335
 	);
336 336
 
337
-	$payments = new WP_Query( $args );
337
+	$payments = new WP_Query($args);
338 338
 
339
-	if( $payments )
339
+	if ($payments)
340 340
 		$ret = $payments->post_count;
341 341
 	return $ret;
342 342
 }
343 343
 
344
-function wpinv_settings_update_gateways( $input ) {
344
+function wpinv_settings_update_gateways($input) {
345 345
     global $wpinv_options;
346 346
     
347
-    if ( !empty( $input['save_gateway'] ) ) {
348
-        $gateways = wpinv_get_option( 'gateways', false );
347
+    if (!empty($input['save_gateway'])) {
348
+        $gateways = wpinv_get_option('gateways', false);
349 349
         $gateways = !empty($gateways) ? $gateways : array();
350 350
         $gateway = $input['save_gateway'];
351 351
         
352
-        if ( !empty( $input[$gateway . '_active'] ) ) {
352
+        if (!empty($input[$gateway . '_active'])) {
353 353
             $gateways[$gateway] = 1;
354 354
         } else {
355
-            if ( isset( $gateways[$gateway] ) ) {
356
-                unset( $gateways[$gateway] );
355
+            if (isset($gateways[$gateway])) {
356
+                unset($gateways[$gateway]);
357 357
             }
358 358
         }
359 359
         
360 360
         $input['gateways'] = $gateways;
361 361
     }
362 362
     
363
-    if ( !empty( $input['default_gateway'] ) ) {
363
+    if (!empty($input['default_gateway'])) {
364 364
         $gateways = wpinv_get_payment_gateways();
365 365
         
366
-        foreach ( $gateways as $key => $gateway ) {
367
-            $active   = 0;
368
-            if ( !empty( $input['gateways'] ) && !empty( $input['gateways'][$key] ) ) {
366
+        foreach ($gateways as $key => $gateway) {
367
+            $active = 0;
368
+            if (!empty($input['gateways']) && !empty($input['gateways'][$key])) {
369 369
                 $active = 1;
370 370
             }
371 371
             
372 372
             $input[$key . '_active'] = $active;
373 373
             
374
-            if ( empty( $wpinv_options[$key . '_title'] ) ) {
374
+            if (empty($wpinv_options[$key . '_title'])) {
375 375
                 $input[$key . '_title'] = $gateway['checkout_label'];
376 376
             }
377 377
             
378
-            if ( !isset( $wpinv_options[$key . '_ordering'] ) && isset( $gateway['ordering'] ) ) {
378
+            if (!isset($wpinv_options[$key . '_ordering']) && isset($gateway['ordering'])) {
379 379
                 $input[$key . '_ordering'] = $gateway['ordering'];
380 380
             }
381 381
         }
@@ -383,26 +383,26 @@  discard block
 block discarded – undo
383 383
     
384 384
     return $input;
385 385
 }
386
-add_filter( 'wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1 );
386
+add_filter('wpinv_settings_tab_gateways_sanitize', 'wpinv_settings_update_gateways', 10, 1);
387 387
 
388 388
 // PayPal Standard settings
389
-function wpinv_gateway_settings_paypal( $setting ) {    
390
-    $setting['paypal_desc']['std'] = __( 'Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing' );
389
+function wpinv_gateway_settings_paypal($setting) {    
390
+    $setting['paypal_desc']['std'] = __('Pay via PayPal: you can pay with your credit card if you don\'t have a PayPal account.', 'invoicing');
391 391
     
392 392
     $setting['paypal_sandbox'] = array(
393 393
             'type' => 'checkbox',
394 394
             'id'   => 'paypal_sandbox',
395
-            'name' => __( 'PayPal Sandbox', 'invoicing' ),
396
-            'desc' => __( 'PayPal sandbox can be used to test payments.', 'invoicing' ),
395
+            'name' => __('PayPal Sandbox', 'invoicing'),
396
+            'desc' => __('PayPal sandbox can be used to test payments.', 'invoicing'),
397 397
             'std'  => 1
398 398
         );
399 399
         
400 400
     $setting['paypal_email'] = array(
401 401
             'type' => 'text',
402 402
             'id'   => 'paypal_email',
403
-            'name' => __( 'PayPal Email', 'invoicing' ),
404
-            'desc' => __( 'Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing' ),
405
-            'std' => __( '[email protected]', 'invoicing' ),
403
+            'name' => __('PayPal Email', 'invoicing'),
404
+            'desc' => __('Please enter your PayPal account\'s email address. Ex: [email protected]', 'invoicing'),
405
+            'std' => __('[email protected]', 'invoicing'),
406 406
         );
407 407
     /*
408 408
     $setting['paypal_ipn_url'] = array(
@@ -416,116 +416,116 @@  discard block
 block discarded – undo
416 416
         
417 417
     return $setting;
418 418
 }
419
-add_filter( 'wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1 );
419
+add_filter('wpinv_gateway_settings_paypal', 'wpinv_gateway_settings_paypal', 10, 1);
420 420
 
421 421
 // Pre Bank Transfer settings
422
-function wpinv_gateway_settings_bank_transfer( $setting ) {
423
-    $setting['bank_transfer_desc']['std'] = __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' );
422
+function wpinv_gateway_settings_bank_transfer($setting) {
423
+    $setting['bank_transfer_desc']['std'] = __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing');
424 424
     
425 425
     $setting['bank_transfer_ac_name'] = array(
426 426
             'type' => 'text',
427 427
             'id' => 'bank_transfer_ac_name',
428
-            'name' => __( 'Account Name', 'invoicing' ),
429
-            'desc' => __( 'Enter the bank account name to which you want to transfer payment.', 'invoicing' ),
430
-            'std'  =>  __( 'Mr. John Martin', 'invoicing' ),
428
+            'name' => __('Account Name', 'invoicing'),
429
+            'desc' => __('Enter the bank account name to which you want to transfer payment.', 'invoicing'),
430
+            'std'  =>  __('Mr. John Martin', 'invoicing'),
431 431
         );
432 432
     
433 433
     $setting['bank_transfer_ac_no'] = array(
434 434
             'type' => 'text',
435 435
             'id' => 'bank_transfer_ac_no',
436
-            'name' => __( 'Account Number', 'invoicing' ),
437
-            'desc' => __( 'Enter your bank account number.', 'invoicing' ),
438
-            'std'  =>  __( 'TEST1234567890', 'invoicing' ),
436
+            'name' => __('Account Number', 'invoicing'),
437
+            'desc' => __('Enter your bank account number.', 'invoicing'),
438
+            'std'  =>  __('TEST1234567890', 'invoicing'),
439 439
         );
440 440
     
441 441
     $setting['bank_transfer_bank_name'] = array(
442 442
             'type' => 'text',
443 443
             'id'   => 'bank_transfer_bank_name',
444
-            'name' => __( 'Bank Name', 'invoicing' ),
445
-            'desc' => __( 'Enter the bank name to which you want to transfer payment.', 'invoicing' ),
446
-            'std' => __( 'ICICI Bank', 'invoicing' ),
444
+            'name' => __('Bank Name', 'invoicing'),
445
+            'desc' => __('Enter the bank name to which you want to transfer payment.', 'invoicing'),
446
+            'std' => __('ICICI Bank', 'invoicing'),
447 447
         );
448 448
     
449 449
     $setting['bank_transfer_ifsc'] = array(
450 450
             'type' => 'text',
451 451
             'id'   => 'bank_transfer_ifsc',
452
-            'name' => __( 'IFSC code', 'invoicing' ),
453
-            'desc' => __( 'Enter your bank IFSC code.', 'invoicing' ),
454
-            'std'  =>  __( 'ICIC0001234', 'invoicing' ),
452
+            'name' => __('IFSC code', 'invoicing'),
453
+            'desc' => __('Enter your bank IFSC code.', 'invoicing'),
454
+            'std'  =>  __('ICIC0001234', 'invoicing'),
455 455
         );
456 456
         
457 457
     $setting['bank_transfer_iban'] = array(
458 458
             'type' => 'text',
459 459
             'id'   => 'bank_transfer_iban',
460
-            'name' => __( 'IBAN', 'invoicing' ),
461
-            'desc' => __( 'Enter your International Bank Account Number(IBAN).', 'invoicing' ),
462
-            'std'  =>  __( 'GB29NWBK60161331926819', 'invoicing' ),
460
+            'name' => __('IBAN', 'invoicing'),
461
+            'desc' => __('Enter your International Bank Account Number(IBAN).', 'invoicing'),
462
+            'std'  =>  __('GB29NWBK60161331926819', 'invoicing'),
463 463
         );
464 464
         
465 465
     $setting['bank_transfer_bic'] = array(
466 466
             'type' => 'text',
467 467
             'id'   => 'bank_transfer_bic',
468
-            'name' => __( 'BIC/Swift code', 'invoicing' ),
469
-            'std'  =>  __( 'ICICGB2L129', 'invoicing' ),
468
+            'name' => __('BIC/Swift code', 'invoicing'),
469
+            'std'  =>  __('ICICGB2L129', 'invoicing'),
470 470
         );
471 471
         
472 472
     $setting['bank_transfer_info'] = array(
473 473
             'id'   => 'bank_transfer_info',
474
-            'name' => __( 'Instructions', 'invoicing' ),
475
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
474
+            'name' => __('Instructions', 'invoicing'),
475
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
476 476
             'type' => 'textarea',
477
-            'std' => __( 'Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing' ),
477
+            'std' => __('Make your payment directly into our bank account. Please use your Invoice ID as the payment reference. Your invoice won\'t be processed until the funds have cleared in our account.', 'invoicing'),
478 478
             'cols' => 37,
479 479
             'rows' => 5
480 480
         );
481 481
         
482 482
     return $setting;
483 483
 }
484
-add_filter( 'wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1 );
484
+add_filter('wpinv_gateway_settings_bank_transfer', 'wpinv_gateway_settings_bank_transfer', 10, 1);
485 485
 
486 486
 // Authorize.Net settings
487
-function wpinv_gateway_settings_authorizenet( $setting ) {
488
-    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __( '( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing' );
489
-    $setting['authorizenet_desc']['std'] = __( 'Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing' );
487
+function wpinv_gateway_settings_authorizenet($setting) {
488
+    $setting['authorizenet_active']['desc'] = $setting['authorizenet_active']['desc'] . ' ' . __('( currencies supported: AUD, CAD, CHF, DKK, EUR, GBP, JPY, NOK, NZD, PLN, SEK, USD, ZAR )', 'invoicing');
489
+    $setting['authorizenet_desc']['std'] = __('Pay using a Authorize.Net to process credit card / debit card transactions.', 'invoicing');
490 490
     
491 491
     $setting['authorizenet_sandbox'] = array(
492 492
             'type' => 'checkbox',
493 493
             'id'   => 'authorizenet_sandbox',
494
-            'name' => __( 'Authorize.Net Test Mode', 'invoicing' ),
495
-            'desc' => __( 'Enable Authorize.Net test mode to test payments.', 'invoicing' ),
494
+            'name' => __('Authorize.Net Test Mode', 'invoicing'),
495
+            'desc' => __('Enable Authorize.Net test mode to test payments.', 'invoicing'),
496 496
             'std'  => 1
497 497
         );
498 498
         
499 499
     $setting['authorizenet_login_id'] = array(
500 500
             'type' => 'text',
501 501
             'id'   => 'authorizenet_login_id',
502
-            'name' => __( 'API Login ID', 'invoicing' ),
503
-            'desc' => __( 'API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing' ),
502
+            'name' => __('API Login ID', 'invoicing'),
503
+            'desc' => __('API Login ID can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 2j4rBekUnD', 'invoicing'),
504 504
             'std' => '2j4rBekUnD',
505 505
         );
506 506
     
507 507
     $setting['authorizenet_transaction_key'] = array(
508 508
             'type' => 'text',
509 509
             'id'   => 'authorizenet_transaction_key',
510
-            'name' => __( 'Transaction Key', 'invoicing' ),
511
-            'desc' => __( 'Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing' ),
510
+            'name' => __('Transaction Key', 'invoicing'),
511
+            'desc' => __('Transaction Key can be obtained from Authorize.Net Account > Settings > Security Settings > General Security Settings > API Credentials & Keys. Example : 4vyBUOJgR74679xa', 'invoicing'),
512 512
             'std' => '4vyBUOJgR74679xa',
513 513
         );
514 514
         
515 515
     $setting['authorizenet_md5_hash'] = array(
516 516
             'type' => 'text',
517 517
             'id'   => 'authorizenet_md5_hash',
518
-            'name' => __( 'MD5-Hash', 'invoicing' ),
519
-            'desc' => __( 'The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing' ),
518
+            'name' => __('MD5-Hash', 'invoicing'),
519
+            'desc' => __('The MD5 Hash security feature allows you to authenticate transaction responses from the Authorize.Net. If you are accepting recurring payments then md5 hash will helps to validate response from Authorize.net. It can be obtained from Authorize.Net Account > Settings > Security Settings > General Settings > MD5 Hash.', 'invoicing'),
520 520
             'std' => '',
521 521
         );
522 522
         
523 523
     $setting['authorizenet_ipn_url'] = array(
524 524
             'type' => 'ipn_url',
525 525
             'id'   => 'authorizenet_ipn_url',
526
-            'name' => __( 'Silent Post URL', 'invoicing' ),
527
-            'std' => wpinv_get_ipn_url( 'authorizenet' ),
528
-            'desc' => __( 'If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing' ),
526
+            'name' => __('Silent Post URL', 'invoicing'),
527
+            'std' => wpinv_get_ipn_url('authorizenet'),
528
+            'desc' => __('If you are accepting recurring payments then you must set this url at Authorize.Net Account > Settings > Transaction Format Settings > Transaction Response Settings > Silent Post URL.', 'invoicing'),
529 529
             'size' => 'large',
530 530
             'custom' => 'authorizenet',
531 531
             'readonly' => true
@@ -533,25 +533,25 @@  discard block
 block discarded – undo
533 533
         
534 534
     return $setting;
535 535
 }
536
-add_filter( 'wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1 );
536
+add_filter('wpinv_gateway_settings_authorizenet', 'wpinv_gateway_settings_authorizenet', 10, 1);
537 537
 
538 538
 // Worldpay settings
539
-function wpinv_gateway_settings_worldpay( $setting ) {
540
-    $setting['worldpay_desc']['std'] = __( 'Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing' );
539
+function wpinv_gateway_settings_worldpay($setting) {
540
+    $setting['worldpay_desc']['std'] = __('Pay using a Worldpay account to process credit card / debit card transactions.', 'invoicing');
541 541
     
542 542
     $setting['worldpay_sandbox'] = array(
543 543
             'type' => 'checkbox',
544 544
             'id'   => 'worldpay_sandbox',
545
-            'name' => __( 'Worldpay Test Mode', 'invoicing' ),
546
-            'desc' => __( 'This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing' ),
545
+            'name' => __('Worldpay Test Mode', 'invoicing'),
546
+            'desc' => __('This provides a special Test Environment to enable you to test your installation and integration to your website before going live.', 'invoicing'),
547 547
             'std'  => 1
548 548
         );
549 549
         
550 550
     $setting['worldpay_instId'] = array(
551 551
             'type' => 'text',
552 552
             'id'   => 'worldpay_instId',
553
-            'name' => __( 'Installation Id', 'invoicing' ),
554
-            'desc' => __( 'Your installation id. Ex: 211616', 'invoicing' ),
553
+            'name' => __('Installation Id', 'invoicing'),
554
+            'desc' => __('Your installation id. Ex: 211616', 'invoicing'),
555 555
             'std' => '211616',
556 556
         );
557 557
     /*
@@ -567,9 +567,9 @@  discard block
 block discarded – undo
567 567
     $setting['worldpay_ipn_url'] = array(
568 568
             'type' => 'ipn_url',
569 569
             'id'   => 'worldpay_ipn_url',
570
-            'name' => __( 'Worldpay Callback Url', 'invoicing' ),
571
-            'std' => wpinv_get_ipn_url( 'worldpay' ),
572
-            'desc' => wp_sprintf( __( 'Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing' ), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url( 'worldpay' ) . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>' ),
570
+            'name' => __('Worldpay Callback Url', 'invoicing'),
571
+            'std' => wpinv_get_ipn_url('worldpay'),
572
+            'desc' => wp_sprintf(__('Login to your Worldpay Merchant Interface then enable Payment Response & Shopper Response. Next, go to the Payment Response URL field and type "%s" or "%s" for a dynamic payment response.', 'invoicing'), '<font style="color:#000;font-style:normal">' . wpinv_get_ipn_url('worldpay') . '</font>', '<font style="color:#000;font-style:normal">&lt;wpdisplay item=MC_callback&gt;</font>'),
573 573
             'size' => 'large',
574 574
             'custom' => 'worldpay',
575 575
             'readonly' => true
@@ -577,94 +577,94 @@  discard block
 block discarded – undo
577 577
         
578 578
     return $setting;
579 579
 }
580
-add_filter( 'wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1 );
580
+add_filter('wpinv_gateway_settings_worldpay', 'wpinv_gateway_settings_worldpay', 10, 1);
581 581
 
582
-function wpinv_ipn_url_callback( $args ) {    
583
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
582
+function wpinv_ipn_url_callback($args) {    
583
+    $sanitize_id = wpinv_sanitize_key($args['id']);
584 584
     
585 585
     $attrs = $args['readonly'] ? ' readonly' : '';
586 586
 
587
-    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
-    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">'  . $args['desc'] . '</label>';
587
+    $html = '<input style="background-color:#fefefe" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" class="large-text">';
588
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>';
589 589
 
590 590
     echo $html;
591 591
 }
592 592
 
593
-function wpinv_is_test_mode( $gateway = '' ) {
594
-    if ( empty( $gateway ) ) {
593
+function wpinv_is_test_mode($gateway = '') {
594
+    if (empty($gateway)) {
595 595
         return false;
596 596
     }
597 597
     
598
-    $is_test_mode = wpinv_get_option( $gateway . '_sandbox', false );
598
+    $is_test_mode = wpinv_get_option($gateway . '_sandbox', false);
599 599
     
600
-    return apply_filters( 'wpinv_is_test_mode', $is_test_mode, $gateway );
600
+    return apply_filters('wpinv_is_test_mode', $is_test_mode, $gateway);
601 601
 }
602 602
 
603
-function wpinv_get_ipn_url( $gateway = '', $args = array() ) {
604
-    $data = array( 'wpi-listener' => 'IPN' );
603
+function wpinv_get_ipn_url($gateway = '', $args = array()) {
604
+    $data = array('wpi-listener' => 'IPN');
605 605
     
606
-    if ( !empty( $gateway ) ) {
607
-        $data['wpi-gateway'] = wpinv_sanitize_key( $gateway );
606
+    if (!empty($gateway)) {
607
+        $data['wpi-gateway'] = wpinv_sanitize_key($gateway);
608 608
     }
609 609
     
610
-    $args = !empty( $args ) && is_array( $args ) ? array_merge( $data, $args ) : $data;
610
+    $args = !empty($args) && is_array($args) ? array_merge($data, $args) : $data;
611 611
     
612
-    $ipn_url = add_query_arg( $args,  home_url( 'index.php' ) );
612
+    $ipn_url = add_query_arg($args, home_url('index.php'));
613 613
     
614
-    return apply_filters( 'wpinv_ipn_url', $ipn_url );
614
+    return apply_filters('wpinv_ipn_url', $ipn_url);
615 615
 }
616 616
 
617 617
 function wpinv_listen_for_payment_ipn() {
618 618
     // Regular PayPal IPN
619
-    if ( isset( $_GET['wpi-listener'] ) && $_GET['wpi-listener'] == 'IPN' ) {
620
-        do_action( 'wpinv_verify_payment_ipn' );
619
+    if (isset($_GET['wpi-listener']) && $_GET['wpi-listener'] == 'IPN') {
620
+        do_action('wpinv_verify_payment_ipn');
621 621
         
622
-        if ( !empty( $_GET['wpi-gateway'] ) ) {
623
-            wpinv_error_log( sanitize_text_field( $_GET['wpi-gateway'] ), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__ );
624
-            do_action( 'wpinv_verify_' . sanitize_text_field( $_GET['wpi-gateway'] ) . '_ipn' );
622
+        if (!empty($_GET['wpi-gateway'])) {
623
+            wpinv_error_log(sanitize_text_field($_GET['wpi-gateway']), 'wpinv_listen_for_payment_ipn()', __FILE__, __LINE__);
624
+            do_action('wpinv_verify_' . sanitize_text_field($_GET['wpi-gateway']) . '_ipn');
625 625
         }
626 626
     }
627 627
 }
628
-add_action( 'init', 'wpinv_listen_for_payment_ipn' );
628
+add_action('init', 'wpinv_listen_for_payment_ipn');
629 629
 
630 630
 function wpinv_get_bank_instructions() {
631
-    $bank_instructions = wpinv_get_option( 'bank_transfer_info' );
631
+    $bank_instructions = wpinv_get_option('bank_transfer_info');
632 632
     
633
-    return apply_filters( 'wpinv_bank_instructions', $bank_instructions );
633
+    return apply_filters('wpinv_bank_instructions', $bank_instructions);
634 634
 }
635 635
 
636
-function wpinv_get_bank_info( $filtered = false ) {
636
+function wpinv_get_bank_info($filtered = false) {
637 637
     $bank_fields = array(
638
-        'bank_transfer_ac_name' => __( 'Account Name', 'invoicing' ),
639
-        'bank_transfer_ac_no' => __( 'Account Number', 'invoicing' ),
640
-        'bank_transfer_bank_name' => __( 'Bank Name', 'invoicing' ),
641
-        'bank_transfer_ifsc' => __( 'IFSC code', 'invoicing' ),
642
-        'bank_transfer_iban' => __( 'IBAN', 'invoicing' ),
643
-        'bank_transfer_bic' => __( 'BIC/Swift code', 'invoicing' )
638
+        'bank_transfer_ac_name' => __('Account Name', 'invoicing'),
639
+        'bank_transfer_ac_no' => __('Account Number', 'invoicing'),
640
+        'bank_transfer_bank_name' => __('Bank Name', 'invoicing'),
641
+        'bank_transfer_ifsc' => __('IFSC code', 'invoicing'),
642
+        'bank_transfer_iban' => __('IBAN', 'invoicing'),
643
+        'bank_transfer_bic' => __('BIC/Swift code', 'invoicing')
644 644
     );
645 645
     
646 646
     $bank_info = array();
647
-    foreach ( $bank_fields as $field => $label ) {
648
-        if ( $filtered && !( $value = wpinv_get_option( $field ) ) ) {
647
+    foreach ($bank_fields as $field => $label) {
648
+        if ($filtered && !($value = wpinv_get_option($field))) {
649 649
             continue;
650 650
         }
651 651
         
652
-        $bank_info[$field] = array( 'label' => $label, 'value' => $value );
652
+        $bank_info[$field] = array('label' => $label, 'value' => $value);
653 653
     }
654 654
     
655
-    return apply_filters( 'wpinv_bank_info', $bank_info, $filtered );
655
+    return apply_filters('wpinv_bank_info', $bank_info, $filtered);
656 656
 }
657 657
 
658
-function wpinv_process_before_send_to_gateway( $invoice, $invoice_data = array() ) {
659
-    if ( !empty( $invoice ) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring( true ) ) {        
658
+function wpinv_process_before_send_to_gateway($invoice, $invoice_data = array()) {
659
+    if (!empty($invoice) && $invoice->is_recurring() && $subscription_item = $invoice->get_recurring(true)) {        
660 660
         $args                          = array();
661 661
         $args['item_id']               = $subscription_item->ID;
662
-        $args['initial_amount']        = wpinv_round_amount( $invoice->get_total() );
663
-        $args['recurring_amount']      = wpinv_round_amount( $invoice->get_recurring_details( 'total' ) );
662
+        $args['initial_amount']        = wpinv_round_amount($invoice->get_total());
663
+        $args['recurring_amount']      = wpinv_round_amount($invoice->get_recurring_details('total'));
664 664
         $args['currency']              = $invoice->get_currency();
665 665
         $args['period']                = $subscription_item->get_recurring_period();
666 666
         $args['interval']              = $subscription_item->get_recurring_interval();
667
-        if ( $subscription_item->has_free_trial() ) {
667
+        if ($subscription_item->has_free_trial()) {
668 668
             $args['trial_period']      = $subscription_item->get_trial_period();
669 669
             $args['trial_interval']    = $subscription_item->get_trial_interval();
670 670
         } else {
@@ -673,25 +673,25 @@  discard block
 block discarded – undo
673 673
         }
674 674
         $args['bill_times']            = (int)$subscription_item->get_recurring_limit();
675 675
         
676
-        $invoice->update_subscription( $args );
676
+        $invoice->update_subscription($args);
677 677
     }
678 678
 }
679
-add_action( 'wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2 );
679
+add_action('wpinv_checkout_before_send_to_gateway', 'wpinv_process_before_send_to_gateway', 10, 2);
680 680
 
681
-function wpinv_get_post_data( $method = 'request' ) {
681
+function wpinv_get_post_data($method = 'request') {
682 682
     $data       = array();
683 683
     $request    = $_REQUEST;
684 684
     
685
-    if ( $method == 'post' ) {
686
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
685
+    if ($method == 'post') {
686
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
687 687
             return $data;
688 688
         }
689 689
         
690 690
         $request = $_POST;
691 691
     }
692 692
     
693
-    if ( $method == 'get' ) {
694
-        if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'GET' ) {
693
+    if ($method == 'get') {
694
+        if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'GET') {
695 695
             return $data;
696 696
         }
697 697
         
@@ -702,11 +702,11 @@  discard block
 block discarded – undo
702 702
     $post_data = '';
703 703
     
704 704
     // Fallback just in case post_max_size is lower than needed
705
-    if ( ini_get( 'allow_url_fopen' ) ) {
706
-        $post_data = file_get_contents( 'php://input' );
705
+    if (ini_get('allow_url_fopen')) {
706
+        $post_data = file_get_contents('php://input');
707 707
     } else {
708 708
         // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
709
-        ini_set( 'post_max_size', '12M' );
709
+        ini_set('post_max_size', '12M');
710 710
     }
711 711
     // Start the encoded data collection with notification command
712 712
     $encoded_data = 'cmd=_notify-validate';
@@ -715,58 +715,58 @@  discard block
 block discarded – undo
715 715
     $arg_separator = wpinv_get_php_arg_separator_output();
716 716
 
717 717
     // Verify there is a post_data
718
-    if ( $post_data || strlen( $post_data ) > 0 ) {
718
+    if ($post_data || strlen($post_data) > 0) {
719 719
         // Append the data
720 720
         $encoded_data .= $arg_separator . $post_data;
721 721
     } else {
722 722
         // Check if POST is empty
723
-        if ( empty( $request ) ) {
723
+        if (empty($request)) {
724 724
             // Nothing to do
725 725
             return;
726 726
         } else {
727 727
             // Loop through each POST
728
-            foreach ( $request as $key => $value ) {
728
+            foreach ($request as $key => $value) {
729 729
                 // Encode the value and append the data
730
-                $encoded_data .= $arg_separator . "$key=" . urlencode( $value );
730
+                $encoded_data .= $arg_separator . "$key=" . urlencode($value);
731 731
             }
732 732
         }
733 733
     }
734 734
 
735 735
     // Convert collected post data to an array
736
-    parse_str( $encoded_data, $data );
736
+    parse_str($encoded_data, $data);
737 737
 
738
-    foreach ( $data as $key => $value ) {
739
-        if ( false !== strpos( $key, 'amp;' ) ) {
740
-            $new_key = str_replace( '&amp;', '&', $key );
741
-            $new_key = str_replace( 'amp;', '&' , $new_key );
738
+    foreach ($data as $key => $value) {
739
+        if (false !== strpos($key, 'amp;')) {
740
+            $new_key = str_replace('&amp;', '&', $key);
741
+            $new_key = str_replace('amp;', '&', $new_key);
742 742
 
743
-            unset( $data[ $key ] );
744
-            $data[ $new_key ] = sanitize_text_field( $value );
743
+            unset($data[$key]);
744
+            $data[$new_key] = sanitize_text_field($value);
745 745
         }
746 746
     }
747 747
     
748 748
     return $data;
749 749
 }
750 750
 
751
-function wpinv_gateway_support_subscription( $gateway ) {
751
+function wpinv_gateway_support_subscription($gateway) {
752 752
     $return = false;
753 753
     
754
-    if ( wpinv_is_gateway_active( $gateway ) ) {
755
-        $return = apply_filters( 'wpinv_' . $gateway . '_support_subscription', false );
754
+    if (wpinv_is_gateway_active($gateway)) {
755
+        $return = apply_filters('wpinv_' . $gateway . '_support_subscription', false);
756 756
     }
757 757
     
758 758
     return $return;
759 759
 }
760 760
 
761
-function wpinv_payment_gateways_on_cart( $gateways = array() ) {
762
-    if ( !empty( $gateways ) && wpinv_cart_has_recurring_item() ) {
763
-        foreach ( $gateways as $gateway => $info ) {
764
-            if ( !wpinv_gateway_support_subscription( $gateway ) ) {
765
-                unset( $gateways[$gateway] );
761
+function wpinv_payment_gateways_on_cart($gateways = array()) {
762
+    if (!empty($gateways) && wpinv_cart_has_recurring_item()) {
763
+        foreach ($gateways as $gateway => $info) {
764
+            if (!wpinv_gateway_support_subscription($gateway)) {
765
+                unset($gateways[$gateway]);
766 766
             }
767 767
         }
768 768
     }
769 769
     
770 770
     return $gateways;
771 771
 }
772
-add_filter( 'wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1 );
773 772
\ No newline at end of file
773
+add_filter('wpinv_payment_gateways_on_cart', 'wpinv_payment_gateways_on_cart', 10, 1);
774 774
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Spacing   +495 added lines, -495 removed lines patch added patch discarded remove patch
@@ -1,66 +1,66 @@  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
-function wpinv_get_option( $key = '', $default = false ) {
7
+function wpinv_get_option($key = '', $default = false) {
8 8
     global $wpinv_options;
9 9
 
10
-    $value = isset( $wpinv_options[ $key ] ) ? $wpinv_options[ $key ] : $default;
11
-    $value = apply_filters( 'wpinv_get_option', $value, $key, $default );
10
+    $value = isset($wpinv_options[$key]) ? $wpinv_options[$key] : $default;
11
+    $value = apply_filters('wpinv_get_option', $value, $key, $default);
12 12
 
13
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
13
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
14 14
 }
15 15
 
16
-function wpinv_update_option( $key = '', $value = false ) {
16
+function wpinv_update_option($key = '', $value = false) {
17 17
     // If no key, exit
18
-    if ( empty( $key ) ) {
18
+    if (empty($key)) {
19 19
         return false;
20 20
     }
21 21
 
22
-    if ( empty( $value ) ) {
23
-        $remove_option = wpinv_delete_option( $key );
22
+    if (empty($value)) {
23
+        $remove_option = wpinv_delete_option($key);
24 24
         return $remove_option;
25 25
     }
26 26
 
27 27
     // First let's grab the current settings
28
-    $options = get_option( 'wpinv_settings' );
28
+    $options = get_option('wpinv_settings');
29 29
 
30 30
     // Let other plugin alter the value
31
-    $value = apply_filters( 'wpinv_update_option', $value, $key );
31
+    $value = apply_filters('wpinv_update_option', $value, $key);
32 32
 
33 33
     // Next let's try to update the value
34
-    $options[ $key ] = $value;
35
-    $did_update = update_option( 'wpinv_settings', $options );
34
+    $options[$key] = $value;
35
+    $did_update = update_option('wpinv_settings', $options);
36 36
 
37 37
     // If it's updated, let's update the global variable
38
-    if ( $did_update ) {
38
+    if ($did_update) {
39 39
         global $wpinv_options;
40
-        $wpinv_options[ $key ] = $value;
40
+        $wpinv_options[$key] = $value;
41 41
     }
42 42
 
43 43
     return $did_update;
44 44
 }
45 45
 
46
-function wpinv_delete_option( $key = '' ) {
46
+function wpinv_delete_option($key = '') {
47 47
     // If no key, exit
48
-    if ( empty( $key ) ) {
48
+    if (empty($key)) {
49 49
         return false;
50 50
     }
51 51
 
52 52
     // First let's grab the current settings
53
-    $options = get_option( 'wpinv_settings' );
53
+    $options = get_option('wpinv_settings');
54 54
 
55 55
     // Next let's try to update the value
56
-    if( isset( $options[ $key ] ) ) {
57
-        unset( $options[ $key ] );
56
+    if (isset($options[$key])) {
57
+        unset($options[$key]);
58 58
     }
59 59
 
60
-    $did_update = update_option( 'wpinv_settings', $options );
60
+    $did_update = update_option('wpinv_settings', $options);
61 61
 
62 62
     // If it updated, let's update the global variable
63
-    if ( $did_update ){
63
+    if ($did_update) {
64 64
         global $wpinv_options;
65 65
         $wpinv_options = $options;
66 66
     }
@@ -69,37 +69,37 @@  discard block
 block discarded – undo
69 69
 }
70 70
 
71 71
 function wpinv_get_settings() {
72
-    $settings = get_option( 'wpinv_settings' );
72
+    $settings = get_option('wpinv_settings');
73 73
 
74
-    if ( empty( $settings ) ) {
74
+    if (empty($settings)) {
75 75
         // Update old settings with new single option
76
-        $general_settings   = is_array( get_option( 'wpinv_settings_general' ) )    ? get_option( 'wpinv_settings_general' )    : array();
77
-        $gateways_settings  = is_array( get_option( 'wpinv_settings_gateways' ) )   ? get_option( 'wpinv_settings_gateways' )   : array();
78
-        $email_settings     = is_array( get_option( 'wpinv_settings_emails' ) )     ? get_option( 'wpinv_settings_emails' )     : array();
79
-        $tax_settings       = is_array( get_option( 'wpinv_settings_taxes' ) )      ? get_option( 'wpinv_settings_taxes' )      : array();
80
-        $misc_settings      = is_array( get_option( 'wpinv_settings_misc' ) )       ? get_option( 'wpinv_settings_misc' )       : array();
81
-        $tool_settings      = is_array( get_option( 'wpinv_settings_tools' ) )      ? get_option( 'wpinv_settings_tools' )      : array();
76
+        $general_settings   = is_array(get_option('wpinv_settings_general')) ? get_option('wpinv_settings_general') : array();
77
+        $gateways_settings  = is_array(get_option('wpinv_settings_gateways')) ? get_option('wpinv_settings_gateways') : array();
78
+        $email_settings     = is_array(get_option('wpinv_settings_emails')) ? get_option('wpinv_settings_emails') : array();
79
+        $tax_settings       = is_array(get_option('wpinv_settings_taxes')) ? get_option('wpinv_settings_taxes') : array();
80
+        $misc_settings      = is_array(get_option('wpinv_settings_misc')) ? get_option('wpinv_settings_misc') : array();
81
+        $tool_settings      = is_array(get_option('wpinv_settings_tools')) ? get_option('wpinv_settings_tools') : array();
82 82
 
83
-        $settings = array_merge( $general_settings, $gateways_settings, $tax_settings, $tool_settings );
83
+        $settings = array_merge($general_settings, $gateways_settings, $tax_settings, $tool_settings);
84 84
 
85
-        update_option( 'wpinv_settings', $settings );
85
+        update_option('wpinv_settings', $settings);
86 86
 
87 87
     }
88
-    return apply_filters( 'wpinv_get_settings', $settings );
88
+    return apply_filters('wpinv_get_settings', $settings);
89 89
 }
90 90
 
91 91
 function wpinv_register_settings() {
92
-    if ( false == get_option( 'wpinv_settings' ) ) {
93
-        add_option( 'wpinv_settings' );
92
+    if (false == get_option('wpinv_settings')) {
93
+        add_option('wpinv_settings');
94 94
     }
95 95
     
96 96
     $register_settings = wpinv_get_registered_settings();
97 97
     
98
-    foreach ( $register_settings as $tab => $sections ) {
99
-        foreach ( $sections as $section => $settings) {
98
+    foreach ($register_settings as $tab => $sections) {
99
+        foreach ($sections as $section => $settings) {
100 100
             // Check for backwards compatibility
101
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
102
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
101
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
102
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
103 103
                 $section = 'main';
104 104
                 $settings = $sections;
105 105
             }
@@ -111,42 +111,42 @@  discard block
 block discarded – undo
111 111
                 'wpinv_settings_' . $tab . '_' . $section
112 112
             );
113 113
 
114
-            foreach ( $settings as $option ) {
114
+            foreach ($settings as $option) {
115 115
                 // For backwards compatibility
116
-                if ( empty( $option['id'] ) ) {
116
+                if (empty($option['id'])) {
117 117
                     continue;
118 118
                 }
119 119
 
120
-                $name = isset( $option['name'] ) ? $option['name'] : '';
120
+                $name = isset($option['name']) ? $option['name'] : '';
121 121
 
122 122
                 add_settings_field(
123 123
                     'wpinv_settings[' . $option['id'] . ']',
124 124
                     $name,
125
-                    function_exists( 'wpinv_' . $option['type'] . '_callback' ) ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
125
+                    function_exists('wpinv_' . $option['type'] . '_callback') ? 'wpinv_' . $option['type'] . '_callback' : 'wpinv_missing_callback',
126 126
                     'wpinv_settings_' . $tab . '_' . $section,
127 127
                     'wpinv_settings_' . $tab . '_' . $section,
128 128
                     array(
129 129
                         'section'     => $section,
130
-                        'id'          => isset( $option['id'] )          ? $option['id']          : null,
131
-                        'desc'        => ! empty( $option['desc'] )      ? $option['desc']        : '',
132
-                        'name'        => isset( $option['name'] )        ? $option['name']        : null,
133
-                        'size'        => isset( $option['size'] )        ? $option['size']        : null,
134
-                        'options'     => isset( $option['options'] )     ? $option['options']     : '',
135
-                        'selected'    => isset( $option['selected'] )    ? $option['selected']    : null,
136
-                        'std'         => isset( $option['std'] )         ? $option['std']         : '',
137
-                        'min'         => isset( $option['min'] )         ? $option['min']         : null,
138
-                        'max'         => isset( $option['max'] )         ? $option['max']         : null,
139
-                        'step'        => isset( $option['step'] )        ? $option['step']        : null,
140
-                        'chosen'      => isset( $option['chosen'] )      ? $option['chosen']      : null,
141
-                        'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
142
-                        'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
143
-                        'readonly'    => isset( $option['readonly'] )    ? $option['readonly']    : false,
144
-                        'faux'        => isset( $option['faux'] )        ? $option['faux']        : false,
145
-                        'onchange'    => !empty( $option['onchange'] )   ? $option['onchange']    : '',
146
-                        'custom'      => !empty( $option['custom'] )     ? $option['custom']      : '',
147
-                        'class'       =>  !empty( $option['class'] )     ? $option['class']      : '',
148
-                        'cols'        => !empty( $option['cols'] ) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
-                        'rows'        => !empty( $option['rows'] ) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
130
+                        'id'          => isset($option['id']) ? $option['id'] : null,
131
+                        'desc'        => !empty($option['desc']) ? $option['desc'] : '',
132
+                        'name'        => isset($option['name']) ? $option['name'] : null,
133
+                        'size'        => isset($option['size']) ? $option['size'] : null,
134
+                        'options'     => isset($option['options']) ? $option['options'] : '',
135
+                        'selected'    => isset($option['selected']) ? $option['selected'] : null,
136
+                        'std'         => isset($option['std']) ? $option['std'] : '',
137
+                        'min'         => isset($option['min']) ? $option['min'] : null,
138
+                        'max'         => isset($option['max']) ? $option['max'] : null,
139
+                        'step'        => isset($option['step']) ? $option['step'] : null,
140
+                        'chosen'      => isset($option['chosen']) ? $option['chosen'] : null,
141
+                        'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null,
142
+                        'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true,
143
+                        'readonly'    => isset($option['readonly']) ? $option['readonly'] : false,
144
+                        'faux'        => isset($option['faux']) ? $option['faux'] : false,
145
+                        'onchange'    => !empty($option['onchange']) ? $option['onchange'] : '',
146
+                        'custom'      => !empty($option['custom']) ? $option['custom'] : '',
147
+                        'class'       =>  !empty($option['class']) ? $option['class'] : '',
148
+                        'cols'        => !empty($option['cols']) && (int)$option['cols'] > 0 ? (int)$option['cols'] : 50,
149
+                        'rows'        => !empty($option['rows']) && (int)$option['rows'] > 0 ? (int)$option['rows'] : 5,
150 150
                     )
151 151
                 );
152 152
             }
@@ -154,21 +154,21 @@  discard block
 block discarded – undo
154 154
     }
155 155
 
156 156
     // Creates our settings in the options table
157
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
157
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
158 158
 }
159
-add_action( 'admin_init', 'wpinv_register_settings' );
159
+add_action('admin_init', 'wpinv_register_settings');
160 160
 
161 161
 function wpinv_get_registered_settings() {
162
-    $pages = wpinv_get_pages( true );
162
+    $pages = wpinv_get_pages(true);
163 163
     
164 164
     $due_payment_options       = array();
165
-    $due_payment_options[0]    = __( 'Now', 'invoicing' );
166
-    for ( $i = 1; $i <= 30; $i++ ) {
165
+    $due_payment_options[0]    = __('Now', 'invoicing');
166
+    for ($i = 1; $i <= 30; $i++) {
167 167
         $due_payment_options[$i] = $i;
168 168
     }
169 169
     
170 170
     $invoice_number_padd_options = array();
171
-    for ( $i = 0; $i <= 20; $i++ ) {
171
+    for ($i = 0; $i <= 20; $i++) {
172 172
         $invoice_number_padd_options[$i] = $i;
173 173
     }
174 174
     
@@ -177,141 +177,141 @@  discard block
 block discarded – undo
177 177
     $alert_wrapper_start = '<p style="color: #F00">';
178 178
     $alert_wrapper_close = '</p>';
179 179
     $wpinv_settings = array(
180
-        'general' => apply_filters( 'wpinv_settings_general',
180
+        'general' => apply_filters('wpinv_settings_general',
181 181
             array(
182 182
                 'main' => array(
183 183
                     'location_settings' => array(
184 184
                         'id'   => 'location_settings',
185
-                        'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>',
185
+                        'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>',
186 186
                         'desc' => '',
187 187
                         'type' => 'header',
188 188
                     ),
189 189
                     'default_country' => array(
190 190
                         'id'      => 'default_country',
191
-                        'name'    => __( 'Default Country', 'invoicing' ),
192
-                        'desc'    => __( 'Where does your store operate from?', 'invoicing' ),
191
+                        'name'    => __('Default Country', 'invoicing'),
192
+                        'desc'    => __('Where does your store operate from?', 'invoicing'),
193 193
                         'type'    => 'select',
194 194
                         'options' => wpinv_get_country_list(),
195 195
                         'std'     => 'GB',
196 196
                         'chosen'  => true,
197
-                        'placeholder' => __( 'Select a country', 'invoicing' ),
197
+                        'placeholder' => __('Select a country', 'invoicing'),
198 198
                     ),
199 199
                     'default_state' => array(
200 200
                         'id'      => 'default_state',
201
-                        'name'    => __( 'Default State / Province', 'invoicing' ),
202
-                        'desc'    => __( 'What state / province does your store operate from?', 'invoicing' ),
201
+                        'name'    => __('Default State / Province', 'invoicing'),
202
+                        'desc'    => __('What state / province does your store operate from?', 'invoicing'),
203 203
                         'type'    => 'country_states',
204
-                        'placeholder' => __( 'Select a state', 'invoicing' ),
204
+                        'placeholder' => __('Select a state', 'invoicing'),
205 205
                     ),
206 206
                     'store_name' => array(
207 207
                         'id'   => 'store_name',
208
-                        'name' => __( 'Store Name', 'invoicing' ),
209
-                        'desc' => __( 'Store name to print on invoices.', 'invoicing' ),
208
+                        'name' => __('Store Name', 'invoicing'),
209
+                        'desc' => __('Store name to print on invoices.', 'invoicing'),
210 210
                         'std'     => get_option('blogname'),
211 211
                         'type' => 'text',
212 212
                     ),
213 213
                     'logo' => array(
214 214
                         'id'   => 'logo',
215
-                        'name' => __( 'Logo URL', 'invoicing' ),
216
-                        'desc' => __( 'Store logo to print on invoices.', 'invoicing' ),
215
+                        'name' => __('Logo URL', 'invoicing'),
216
+                        'desc' => __('Store logo to print on invoices.', 'invoicing'),
217 217
                         'type' => 'text',
218 218
                     ),
219 219
                     'store_address' => array(
220 220
                         'id'   => 'store_address',
221
-                        'name' => __( 'Store Address', 'invoicing' ),
222
-                        'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ),
221
+                        'name' => __('Store Address', 'invoicing'),
222
+                        'desc' => __('Enter the store address to display on invoice', 'invoicing'),
223 223
                         'type' => 'textarea',
224 224
                     ),
225 225
                     'page_settings' => array(
226 226
                         'id'   => 'page_settings',
227
-                        'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>',
227
+                        'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>',
228 228
                         'desc' => '',
229 229
                         'type' => 'header',
230 230
                     ),
231 231
                     'checkout_page' => array(
232 232
                         'id'          => 'checkout_page',
233
-                        'name'        => __( 'Checkout Page', 'invoicing' ),
234
-                        'desc'        => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ),
233
+                        'name'        => __('Checkout Page', 'invoicing'),
234
+                        'desc'        => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'),
235 235
                         'type'        => 'select',
236 236
                         'options'     => $pages,
237 237
                         'chosen'      => true,
238
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
238
+                        'placeholder' => __('Select a page', 'invoicing'),
239 239
                     ),
240 240
                     'success_page' => array(
241 241
                         'id'          => 'success_page',
242
-                        'name'        => __( 'Success Page', 'invoicing' ),
243
-                        'desc'        => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ),
242
+                        'name'        => __('Success Page', 'invoicing'),
243
+                        'desc'        => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'),
244 244
                         'type'        => 'select',
245 245
                         'options'     => $pages,
246 246
                         'chosen'      => true,
247
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
247
+                        'placeholder' => __('Select a page', 'invoicing'),
248 248
                     ),
249 249
                     'failure_page' => array(
250 250
                         'id'          => 'failure_page',
251
-                        'name'        => __( 'Failed Transaction Page', 'invoicing' ),
252
-                        'desc'        => __( 'This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing' ),
251
+                        'name'        => __('Failed Transaction Page', 'invoicing'),
252
+                        'desc'        => __('This is the page buyers are sent to if their transaction is cancelled or fails', 'invoicing'),
253 253
                         'type'        => 'select',
254 254
                         'options'     => $pages,
255 255
                         'chosen'      => true,
256
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
256
+                        'placeholder' => __('Select a page', 'invoicing'),
257 257
                     ),
258 258
                     'invoice_history_page' => array(
259 259
                         'id'          => 'invoice_history_page',
260
-                        'name'        => __( 'Invoice History Page', 'invoicing' ),
261
-                        'desc'        => __( 'This page shows an invoice history for the current user', 'invoicing' ),
260
+                        'name'        => __('Invoice History Page', 'invoicing'),
261
+                        'desc'        => __('This page shows an invoice history for the current user', 'invoicing'),
262 262
                         'type'        => 'select',
263 263
                         'options'     => $pages,
264 264
                         'chosen'      => true,
265
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
265
+                        'placeholder' => __('Select a page', 'invoicing'),
266 266
                     )
267 267
                 ),
268 268
                 'currency_section' => array(
269 269
                     'currency_settings' => array(
270 270
                         'id'   => 'currency_settings',
271
-                        'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>',
271
+                        'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>',
272 272
                         'desc' => '',
273 273
                         'type' => 'header',
274 274
                     ),
275 275
                     'currency' => array(
276 276
                         'id'      => 'currency',
277
-                        'name'    => __( 'Currency', 'invoicing' ),
278
-                        'desc'    => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ),
277
+                        'name'    => __('Currency', 'invoicing'),
278
+                        'desc'    => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'),
279 279
                         'type'    => 'select',
280 280
                         'options' => wpinv_get_currencies(),
281 281
                         'chosen'  => true,
282 282
                     ),
283 283
                     'currency_position' => array(
284 284
                         'id'      => 'currency_position',
285
-                        'name'    => __( 'Currency Position', 'invoicing' ),
286
-                        'desc'    => __( 'Choose the location of the currency sign.', 'invoicing' ),
285
+                        'name'    => __('Currency Position', 'invoicing'),
286
+                        'desc'    => __('Choose the location of the currency sign.', 'invoicing'),
287 287
                         'type'    => 'select',
288 288
                         'options'  => array(
289
-                            'left'        => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')',
290
-                            'right'       => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')',
291
-                            'left_space'  => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')',
292
-                            'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')'
289
+                            'left'        => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')',
290
+                            'right'       => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')',
291
+                            'left_space'  => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')',
292
+                            'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')'
293 293
                         )
294 294
                     ),
295 295
                     'thousands_separator' => array(
296 296
                         'id'   => 'thousands_separator',
297
-                        'name' => __( 'Thousands Separator', 'invoicing' ),
298
-                        'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ),
297
+                        'name' => __('Thousands Separator', 'invoicing'),
298
+                        'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'),
299 299
                         'type' => 'text',
300 300
                         'size' => 'small',
301 301
                         'std'  => ',',
302 302
                     ),
303 303
                     'decimal_separator' => array(
304 304
                         'id'   => 'decimal_separator',
305
-                        'name' => __( 'Decimal Separator', 'invoicing' ),
306
-                        'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ),
305
+                        'name' => __('Decimal Separator', 'invoicing'),
306
+                        'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'),
307 307
                         'type' => 'text',
308 308
                         'size' => 'small',
309 309
                         'std'  => '.',
310 310
                     ),
311 311
                     'decimals' => array(
312 312
                         'id'   => 'decimals',
313
-                        'name' => __( 'Number of Decimals', 'invoicing' ),
314
-                        'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ),
313
+                        'name' => __('Number of Decimals', 'invoicing'),
314
+                        'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'),
315 315
                         'type' => 'number',
316 316
                         'size' => 'small',
317 317
                         'std'  => '2',
@@ -323,29 +323,29 @@  discard block
 block discarded – undo
323 323
                 'labels' => array(
324 324
                     'labels' => array(
325 325
                         'id'   => 'labels_settings',
326
-                        'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>',
326
+                        'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>',
327 327
                         'desc' => '',
328 328
                         'type' => 'header',
329 329
                     ),
330 330
                     'vat_name' => array(
331 331
                         'id' => 'vat_name',
332
-                        'name' => __( 'VAT Name', 'invoicing' ),
333
-                        'desc' => __( 'Enter the VAT name', 'invoicing' ),
332
+                        'name' => __('VAT Name', 'invoicing'),
333
+                        'desc' => __('Enter the VAT name', 'invoicing'),
334 334
                         'type' => 'text',
335 335
                         'size' => 'regular',
336 336
                         'std' => 'VAT'
337 337
                     ),
338 338
                     'vat_invoice_notice_label' => array(
339 339
                         'id' => 'vat_invoice_notice_label',
340
-                        'name' => __( 'Invoice Notice Label', 'invoicing' ),
341
-                        'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ),
340
+                        'name' => __('Invoice Notice Label', 'invoicing'),
341
+                        'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'),
342 342
                         'type' => 'text',
343 343
                         'size' => 'regular',
344 344
                     ),
345 345
                     'vat_invoice_notice' => array(
346 346
                         'id' => 'vat_invoice_notice',
347
-                        'name' => __( 'Invoice notice', 'invoicing' ),
348
-                        'desc' =>   __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ),
347
+                        'name' => __('Invoice notice', 'invoicing'),
348
+                        'desc' =>   __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'),
349 349
                         'type' => 'text',
350 350
                         'size' => 'regular',
351 351
                     )
@@ -357,22 +357,22 @@  discard block
 block discarded – undo
357 357
                 'main' => array(
358 358
                     'gateway_settings' => array(
359 359
                         'id'   => 'api_header',
360
-                        'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>',
360
+                        'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>',
361 361
                         'desc' => '',
362 362
                         'type' => 'header',
363 363
                     ),
364 364
                     'gateways' => array(
365 365
                         'id'      => 'gateways',
366
-                        'name'    => __( 'Payment Gateways', 'invoicing' ),
367
-                        'desc'    => __( 'Choose the payment gateways you want to enable.', 'invoicing' ),
366
+                        'name'    => __('Payment Gateways', 'invoicing'),
367
+                        'desc'    => __('Choose the payment gateways you want to enable.', 'invoicing'),
368 368
                         'type'    => 'gateways',
369 369
                         'std'     => array('manual'=>1),
370 370
                         'options' => wpinv_get_payment_gateways(),
371 371
                     ),
372 372
                     'default_gateway' => array(
373 373
                         'id'      => 'default_gateway',
374
-                        'name'    => __( 'Default Gateway', 'invoicing' ),
375
-                        'desc'    => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ),
374
+                        'name'    => __('Default Gateway', 'invoicing'),
375
+                        'desc'    => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'),
376 376
                         'type'    => 'gateway_select',
377 377
                         'std'     => 'manual',
378 378
                         'options' => wpinv_get_payment_gateways(),
@@ -386,19 +386,19 @@  discard block
 block discarded – undo
386 386
                 'main' => array(
387 387
                     'tax_settings' => array(
388 388
                         'id'   => 'tax_settings',
389
-                        'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>',
389
+                        'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>',
390 390
                         'type' => 'header',
391 391
                     ),
392 392
                     'enable_taxes' => array(
393 393
                         'id'   => 'enable_taxes',
394
-                        'name' => __( 'Enable Taxes', 'invoicing' ),
395
-                        'desc' => __( 'Check this to enable taxes on invoices.', 'invoicing' ),
394
+                        'name' => __('Enable Taxes', 'invoicing'),
395
+                        'desc' => __('Check this to enable taxes on invoices.', 'invoicing'),
396 396
                         'type' => 'checkbox',
397 397
                     ),
398 398
                     'tax_rate' => array(
399 399
                         'id'   => 'tax_rate',
400
-                        'name' => __( 'Fallback Tax Rate', 'invoicing' ),
401
-                        'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ),
400
+                        'name' => __('Fallback Tax Rate', 'invoicing'),
401
+                        'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'),
402 402
                         'type' => 'number',
403 403
                         'size' => 'small',
404 404
                         'min'  => '0',
@@ -410,8 +410,8 @@  discard block
 block discarded – undo
410 410
                 'rates' => array(
411 411
                     'tax_rates' => array(
412 412
                         'id'   => 'tax_rates',
413
-                        'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>',
414
-                        'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ),
413
+                        'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>',
414
+                        'desc' => __('Enter tax rates for specific regions.', 'invoicing'),
415 415
                         'type' => 'tax_rates',
416 416
                     ),
417 417
                 )
@@ -423,62 +423,62 @@  discard block
 block discarded – undo
423 423
                 'main' => array(
424 424
                     'email_settings_header' => array(
425 425
                         'id'   => 'email_settings_header',
426
-                        'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>',
426
+                        'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>',
427 427
                         'type' => 'header',
428 428
                     ),
429 429
                     'email_from_name' => array(
430 430
                         'id'   => 'email_from_name',
431
-                        'name' => __( 'From Name', 'invoicing' ),
432
-                        'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ),
433
-                        'std' => esc_attr( get_bloginfo( 'name', 'display' ) ),
431
+                        'name' => __('From Name', 'invoicing'),
432
+                        'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'),
433
+                        'std' => esc_attr(get_bloginfo('name', 'display')),
434 434
                         'type' => 'text',
435 435
                     ),
436 436
                     'email_from' => array(
437 437
                         'id'   => 'email_from',
438
-                        'name' => __( 'From Email', 'invoicing' ),
439
-                        'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close),
440
-                        'std' => get_option( 'admin_email' ),
438
+                        'name' => __('From Email', 'invoicing'),
439
+                        'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close),
440
+                        'std' => get_option('admin_email'),
441 441
                         'type' => 'text',
442 442
                     ),
443 443
                     'overdue_settings_header' => array(
444 444
                         'id'   => 'overdue_settings_header',
445
-                        'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>',
445
+                        'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>',
446 446
                         'type' => 'header',
447 447
                     ),
448 448
                     'overdue_active' => array(
449 449
                         'id'   => 'overdue_active',
450
-                        'name' => __( 'Enable Due Date', 'invoicing' ),
451
-                        'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ),
450
+                        'name' => __('Enable Due Date', 'invoicing'),
451
+                        'desc' => __('Check this to enable due date option for invoices.', 'invoicing'),
452 452
                         'type' => 'checkbox',
453 453
                         'std'  => false,
454 454
                     ),
455 455
                     'overdue_days' => array(
456 456
                         'id'          => 'overdue_days',
457
-                        'name'        => __( 'Default Due Date', 'invoicing' ),
458
-                        'desc'        => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ),
457
+                        'name'        => __('Default Due Date', 'invoicing'),
458
+                        'desc'        => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'),
459 459
                         'type'        => 'select',
460 460
                         'options'     => $due_payment_options,
461 461
                         'chosen'      => true,
462 462
                         'std'         => 0,
463
-                        'placeholder' => __( 'Select a page', 'invoicing' ),
463
+                        'placeholder' => __('Select a page', 'invoicing'),
464 464
                     ),
465 465
                     'email_template_header' => array(
466 466
                         'id'   => 'email_template_header',
467
-                        'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>',
467
+                        'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>',
468 468
                         'type' => 'header',
469 469
                     ),
470 470
                     'email_header_image' => array(
471 471
                         'id'   => 'email_header_image',
472
-                        'name' => __( 'Header Image', 'invoicing' ),
473
-                        'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ),
472
+                        'name' => __('Header Image', 'invoicing'),
473
+                        'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'),
474 474
                         'std' => '',
475 475
                         'type' => 'text',
476 476
                     ),
477 477
                     'email_footer_text' => array(
478 478
                         'id'   => 'email_footer_text',
479
-                        'name' => __( 'Footer Text', 'invoicing' ),
480
-                        'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ),
481
-                        'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GeoDirectory', 'invoicing' ),
479
+                        'name' => __('Footer Text', 'invoicing'),
480
+                        'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'),
481
+                        'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GeoDirectory', 'invoicing'),
482 482
                         'type' => 'textarea',
483 483
                         'class' => 'regular-text',
484 484
                         'rows' => 2,
@@ -486,29 +486,29 @@  discard block
 block discarded – undo
486 486
                     ),
487 487
                     'email_base_color' => array(
488 488
                         'id'   => 'email_base_color',
489
-                        'name' => __( 'Base Color', 'invoicing' ),
490
-                        'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ),
489
+                        'name' => __('Base Color', 'invoicing'),
490
+                        'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'),
491 491
                         'std' => '#557da2',
492 492
                         'type' => 'color',
493 493
                     ),
494 494
                     'email_background_color' => array(
495 495
                         'id'   => 'email_background_color',
496
-                        'name' => __( 'Background Color', 'invoicing' ),
497
-                        'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ),
496
+                        'name' => __('Background Color', 'invoicing'),
497
+                        'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'),
498 498
                         'std' => '#f5f5f5',
499 499
                         'type' => 'color',
500 500
                     ),
501 501
                     'email_body_background_color' => array(
502 502
                         'id'   => 'email_body_background_color',
503
-                        'name' => __( 'Body Background Color', 'invoicing' ),
504
-                        'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ),
503
+                        'name' => __('Body Background Color', 'invoicing'),
504
+                        'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'),
505 505
                         'std' => '#fdfdfd',
506 506
                         'type' => 'color',
507 507
                     ),
508 508
                     'email_text_color' => array(
509 509
                         'id'   => 'email_text_color',
510
-                        'name' => __( 'Body Text Color', 'invoicing' ),
511
-                        'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ),
510
+                        'name' => __('Body Text Color', 'invoicing'),
511
+                        'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'),
512 512
                         'std' => '#505050',
513 513
                         'type' => 'color',
514 514
                     ),
@@ -527,73 +527,73 @@  discard block
 block discarded – undo
527 527
                 'main' => array(
528 528
                     'fields_settings' => array(
529 529
                         'id'   => 'fields_settings',
530
-                        'name' => '<h3>' . __( 'Fields Settings', 'invoicing' ) . '</h3>',
531
-                        'desc' => __( 'Tick fields which are mandatory in invoice address fields.', 'invoicing' ),
530
+                        'name' => '<h3>' . __('Fields Settings', 'invoicing') . '</h3>',
531
+                        'desc' => __('Tick fields which are mandatory in invoice address fields.', 'invoicing'),
532 532
                         'type' => 'header',
533 533
                     ),
534 534
                     'fname_mandatory' => array(
535 535
                         'id'   => 'fname_mandatory',
536
-                        'name' => __( 'First Name', 'invoicing' ),
536
+                        'name' => __('First Name', 'invoicing'),
537 537
                         'type' => 'checkbox',
538 538
                         'std'  => true,
539 539
                     ),
540 540
                     'lname_mandatory' => array(
541 541
                         'id'   => 'lname_mandatory',
542
-                        'name' => __( 'Last Name', 'invoicing' ),
542
+                        'name' => __('Last Name', 'invoicing'),
543 543
                         'type' => 'checkbox',
544 544
                         'std'  => true,
545 545
                     ),
546 546
                     'address_mandatory' => array(
547 547
                         'id'   => 'address_mandatory',
548
-                        'name' => __( 'Address', 'invoicing' ),
548
+                        'name' => __('Address', 'invoicing'),
549 549
                         'type' => 'checkbox',
550 550
                         'std'  => true,
551 551
                     ),
552 552
                     'city_mandatory' => array(
553 553
                         'id'   => 'city_mandatory',
554
-                        'name' => __( 'City', 'invoicing' ),
554
+                        'name' => __('City', 'invoicing'),
555 555
                         'type' => 'checkbox',
556 556
                         'std'  => true,
557 557
                     ),
558 558
                     'country_mandatory' => array(
559 559
                         'id'   => 'country_mandatory',
560
-                        'name' => __( 'Country', 'invoicing' ),
560
+                        'name' => __('Country', 'invoicing'),
561 561
                         'type' => 'checkbox',
562 562
                         'std'  => true,
563 563
                     ),
564 564
                     'state_mandatory' => array(
565 565
                         'id'   => 'state_mandatory',
566
-                        'name' => __( 'State / Province', 'invoicing' ),
566
+                        'name' => __('State / Province', 'invoicing'),
567 567
                         'type' => 'checkbox',
568 568
                         'std'  => true,
569 569
                     ),
570 570
                     'zip_mandatory' => array(
571 571
                         'id'   => 'zip_mandatory',
572
-                        'name' => __( 'ZIP / Postcode', 'invoicing' ),
572
+                        'name' => __('ZIP / Postcode', 'invoicing'),
573 573
                         'type' => 'checkbox',
574 574
                         'std'  => true,
575 575
                     ),
576 576
                     'phone_mandatory' => array(
577 577
                         'id'   => 'phone_mandatory',
578
-                        'name' => __( 'Phone Number', 'invoicing' ),
578
+                        'name' => __('Phone Number', 'invoicing'),
579 579
                         'type' => 'checkbox',
580 580
                         'std'  => true,
581 581
                     ),
582 582
                     'invoice_number_format_settings' => array(
583 583
                         'id'   => 'invoice_number_format_settings',
584
-                        'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>',
584
+                        'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>',
585 585
                         'type' => 'header',
586 586
                     ),
587 587
                     'sequential_invoice_number' => array(
588 588
                         'id'   => 'sequential_invoice_number',
589
-                        'name' => __( 'Sequential Invoice Numbers', 'invoicing' ),
590
-                        'desc' => __( 'Check this box to enable sequential invoice numbers.', 'invoicing' ),
589
+                        'name' => __('Sequential Invoice Numbers', 'invoicing'),
590
+                        'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing'),
591 591
                         'type' => 'checkbox',
592 592
                     ),
593 593
                     'invoice_sequence_start' => array(
594 594
                         'id'   => 'invoice_sequence_start',
595
-                        'name' => __( 'Sequential Starting Number', 'easy-digital-downloads' ),
596
-                        'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ),
595
+                        'name' => __('Sequential Starting Number', 'easy-digital-downloads'),
596
+                        'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing'),
597 597
                         'type' => 'number',
598 598
                         'size' => 'small',
599 599
                         'std'  => '1',
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
                     ),
602 602
                     'invoice_number_padd' => array(
603 603
                         'id'      => 'invoice_number_padd',
604
-                        'name'    => __( 'Minimum Digits', 'invoicing' ),
605
-                        'desc'    => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ),
604
+                        'name'    => __('Minimum Digits', 'invoicing'),
605
+                        'desc'    => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'),
606 606
                         'type'    => 'select',
607 607
                         'options' => $invoice_number_padd_options,
608 608
                         'std'     => 5,
@@ -610,8 +610,8 @@  discard block
 block discarded – undo
610 610
                     ),
611 611
                     'invoice_number_prefix' => array(
612 612
                         'id' => 'invoice_number_prefix',
613
-                        'name' => __( 'Invoice Number Prefix', 'invoicing' ),
614
-                        'desc' => __( 'Prefix for all invoice numbers. Ex: WPINV-', 'invoicing' ),
613
+                        'name' => __('Invoice Number Prefix', 'invoicing'),
614
+                        'desc' => __('Prefix for all invoice numbers. Ex: WPINV-', 'invoicing'),
615 615
                         'type' => 'text',
616 616
                         'size' => 'regular',
617 617
                         'std' => 'WPINV-',
@@ -619,44 +619,44 @@  discard block
 block discarded – undo
619 619
                     ),
620 620
                     'invoice_number_postfix' => array(
621 621
                         'id' => 'invoice_number_postfix',
622
-                        'name' => __( 'Invoice Number Postfix', 'invoicing' ),
623
-                        'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ),
622
+                        'name' => __('Invoice Number Postfix', 'invoicing'),
623
+                        'desc' => __('Postfix for all invoice numbers.', 'invoicing'),
624 624
                         'type' => 'text',
625 625
                         'size' => 'regular',
626 626
                         'std' => ''
627 627
                     ),
628 628
                     'guest_checkout_settings' => array(
629 629
                         'id'   => 'guest_checkout_settings',
630
-                        'name' => '<h3>' . __( 'Pay via Invoice Link', 'invoicing' ) . '</h3>',
630
+                        'name' => '<h3>' . __('Pay via Invoice Link', 'invoicing') . '</h3>',
631 631
                         'type' => 'header',
632 632
                     ),
633 633
                     'guest_checkout' => array(
634 634
                         'type'    => 'radio',
635 635
                         'id'      => 'guest_checkout',
636
-                        'name'    => __( 'Pay via Invoice Link for non logged in user', 'invoicing' ),
637
-                        'desc'    => __( 'Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing' ),
636
+                        'name'    => __('Pay via Invoice Link for non logged in user', 'invoicing'),
637
+                        'desc'    => __('Select how invoice should be paid when non logged in user clicks on the invoice link sent to them via email to pay for invoice.', 'invoicing'),
638 638
                         'options' => array(
639
-                            0 => __( 'Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing' ),
640
-                            1 => __( 'Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing' ),
639
+                            0 => __('Ask them to log-in and redirect back to invoice checkout to pay.', 'invoicing'),
640
+                            1 => __('Auto log-in the user via invoice link and take them to invoice checkout to pay.', 'invoicing'),
641 641
                         ),
642 642
                         'std'     => 0,
643 643
                     ),
644 644
                     'address_autofill_settings' => array(
645 645
                         'id'   => 'address_autofill_settings',
646
-                        'name' => '<h3>' . __( 'Google Address Auto Complete', 'invoicing' ) . '</h3>',
646
+                        'name' => '<h3>' . __('Google Address Auto Complete', 'invoicing') . '</h3>',
647 647
                         'type' => 'header',
648 648
                     ),
649 649
                     'address_autofill_active' => array(
650 650
                         'id'   => 'address_autofill_active',
651
-                        'name' => __( 'Enable/Disable', 'invoicing' ),
652
-                        'desc' => __( 'Enable google address auto complete', 'invoicing' ),
651
+                        'name' => __('Enable/Disable', 'invoicing'),
652
+                        'desc' => __('Enable google address auto complete', 'invoicing'),
653 653
                         'type' => 'checkbox',
654 654
                         'std'  => 0
655 655
                     ),
656 656
                     'address_autofill_api' => array(
657 657
                         'id' => 'address_autofill_api',
658
-                        'name' => __( 'Google Place API Key', 'invoicing' ),
659
-                        'desc' => wp_sprintf(__( 'Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing' ), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>' ),
658
+                        'name' => __('Google Place API Key', 'invoicing'),
659
+                        'desc' => wp_sprintf(__('Enter google place API key. For more information go to google place API %sdocumenation%s', 'invoicing'), '<a href="https://developers.google.com/maps/documentation/javascript/places-autocomplete" target="_blank">', '</a>'),
660 660
                         'type' => 'text',
661 661
                         'size' => 'regular',
662 662
                         'std' => ''
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
                 'main' => array(
672 672
                     'tool_settings' => array(
673 673
                         'id'   => 'tool_settings',
674
-                        'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>',
675
-                        'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ),
674
+                        'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>',
675
+                        'desc' => __('Invoicing diagnostic tools', 'invoicing'),
676 676
                         'type' => 'tools',
677 677
                     ),
678 678
                 ),
@@ -680,135 +680,135 @@  discard block
 block discarded – undo
680 680
         )
681 681
     );
682 682
 
683
-    return apply_filters( 'wpinv_registered_settings', $wpinv_settings );
683
+    return apply_filters('wpinv_registered_settings', $wpinv_settings);
684 684
 }
685 685
 
686
-function wpinv_settings_sanitize( $input = array() ) {
686
+function wpinv_settings_sanitize($input = array()) {
687 687
     global $wpinv_options;
688 688
 
689
-    if ( empty( $_POST['_wp_http_referer'] ) ) {
689
+    if (empty($_POST['_wp_http_referer'])) {
690 690
         return $input;
691 691
     }
692 692
 
693
-    parse_str( $_POST['_wp_http_referer'], $referrer );
693
+    parse_str($_POST['_wp_http_referer'], $referrer);
694 694
 
695 695
     $settings = wpinv_get_registered_settings();
696
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
697
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
696
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
697
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
698 698
 
699 699
     $input = $input ? $input : array();
700
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
701
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
700
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
701
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
702 702
 
703 703
     // Loop through each setting being saved and pass it through a sanitization filter
704
-    foreach ( $input as $key => $value ) {
704
+    foreach ($input as $key => $value) {
705 705
         // Get the setting type (checkbox, select, etc)
706
-        $type = isset( $settings[ $tab ][ $key ]['type'] ) ? $settings[ $tab ][ $key ]['type'] : false;
706
+        $type = isset($settings[$tab][$key]['type']) ? $settings[$tab][$key]['type'] : false;
707 707
 
708
-        if ( $type ) {
708
+        if ($type) {
709 709
             // Field type specific filter
710
-            $input[$key] = apply_filters( 'wpinv_settings_sanitize_' . $type, $value, $key );
710
+            $input[$key] = apply_filters('wpinv_settings_sanitize_' . $type, $value, $key);
711 711
         }
712 712
 
713 713
         // General filter
714
-        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
714
+        $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
715 715
     }
716 716
 
717 717
     // Loop through the whitelist and unset any that are empty for the tab being saved
718
-    $main_settings    = $section == 'main' ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
719
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
718
+    $main_settings    = $section == 'main' ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
719
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
720 720
 
721
-    $found_settings = array_merge( $main_settings, $section_settings );
721
+    $found_settings = array_merge($main_settings, $section_settings);
722 722
 
723
-    if ( ! empty( $found_settings ) ) {
724
-        foreach ( $found_settings as $key => $value ) {
723
+    if (!empty($found_settings)) {
724
+        foreach ($found_settings as $key => $value) {
725 725
 
726 726
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
727
-            if ( is_numeric( $key ) ) {
727
+            if (is_numeric($key)) {
728 728
                 $key = $value['id'];
729 729
             }
730 730
 
731
-            if ( empty( $input[ $key ] ) ) {
732
-                unset( $wpinv_options[ $key ] );
731
+            if (empty($input[$key])) {
732
+                unset($wpinv_options[$key]);
733 733
             }
734 734
         }
735 735
     }
736 736
 
737 737
     // Merge our new settings with the existing
738
-    $output = array_merge( $wpinv_options, $input );
738
+    $output = array_merge($wpinv_options, $input);
739 739
 
740
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
740
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
741 741
 
742 742
     return $output;
743 743
 }
744 744
 
745
-function wpinv_settings_sanitize_misc_accounting( $input ) {
745
+function wpinv_settings_sanitize_misc_accounting($input) {
746 746
     global $wpinv_options, $wpi_session;
747 747
 
748
-    if ( !current_user_can( 'manage_options' ) ) {
748
+    if (!current_user_can('manage_options')) {
749 749
         return $input;
750 750
     }
751 751
 
752
-    if( ! empty( $input['enable_sequential'] ) && !wpinv_get_option( 'enable_sequential' ) ) {
752
+    if (!empty($input['enable_sequential']) && !wpinv_get_option('enable_sequential')) {
753 753
         // Shows an admin notice about upgrading previous order numbers
754
-        $wpi_session->set( 'upgrade_sequential', '1' );
754
+        $wpi_session->set('upgrade_sequential', '1');
755 755
     }
756 756
 
757 757
     return $input;
758 758
 }
759
-add_filter( 'wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting' );
759
+add_filter('wpinv_settings_misc-accounting_sanitize', 'wpinv_settings_sanitize_misc_accounting');
760 760
 
761
-function wpinv_settings_sanitize_tax_rates( $input ) {
762
-    if( !current_user_can( 'manage_options' ) ) {
761
+function wpinv_settings_sanitize_tax_rates($input) {
762
+    if (!current_user_can('manage_options')) {
763 763
         return $input;
764 764
     }
765 765
 
766
-    $new_rates = !empty( $_POST['tax_rates'] ) ? array_values( $_POST['tax_rates'] ) : array();
766
+    $new_rates = !empty($_POST['tax_rates']) ? array_values($_POST['tax_rates']) : array();
767 767
 
768 768
     $tax_rates = array();
769 769
 
770
-    if ( !empty( $new_rates ) ) {
771
-        foreach ( $new_rates as $rate ) {
772
-            if ( isset( $rate['country'] ) && empty( $rate['country'] ) && empty( $rate['state'] ) ) {
770
+    if (!empty($new_rates)) {
771
+        foreach ($new_rates as $rate) {
772
+            if (isset($rate['country']) && empty($rate['country']) && empty($rate['state'])) {
773 773
                 continue;
774 774
             }
775 775
             
776
-            $rate['rate'] = wpinv_sanitize_amount( $rate['rate'], 4 );
776
+            $rate['rate'] = wpinv_sanitize_amount($rate['rate'], 4);
777 777
             
778 778
             $tax_rates[] = $rate;
779 779
         }
780 780
     }
781 781
 
782
-    update_option( 'wpinv_tax_rates', $tax_rates );
782
+    update_option('wpinv_tax_rates', $tax_rates);
783 783
 
784 784
     return $input;
785 785
 }
786
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
786
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
787 787
 
788
-function wpinv_sanitize_text_field( $input ) {
789
-    return trim( $input );
788
+function wpinv_sanitize_text_field($input) {
789
+    return trim($input);
790 790
 }
791
-add_filter( 'wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field' );
791
+add_filter('wpinv_settings_sanitize_text', 'wpinv_sanitize_text_field');
792 792
 
793 793
 function wpinv_get_settings_tabs() {
794 794
     $tabs             = array();
795
-    $tabs['general']  = __( 'General', 'invoicing' );
796
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
797
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
798
-    $tabs['emails']   = __( 'Emails', 'invoicing' );
799
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
800
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
801
-
802
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
795
+    $tabs['general']  = __('General', 'invoicing');
796
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
797
+    $tabs['taxes']    = __('Taxes', 'invoicing');
798
+    $tabs['emails']   = __('Emails', 'invoicing');
799
+    $tabs['misc']     = __('Misc', 'invoicing');
800
+    $tabs['tools']    = __('Tools', 'invoicing');
801
+
802
+    return apply_filters('wpinv_settings_tabs', $tabs);
803 803
 }
804 804
 
805
-function wpinv_get_settings_tab_sections( $tab = false ) {
805
+function wpinv_get_settings_tab_sections($tab = false) {
806 806
     $tabs     = false;
807 807
     $sections = wpinv_get_registered_settings_sections();
808 808
 
809
-    if( $tab && ! empty( $sections[ $tab ] ) ) {
810
-        $tabs = $sections[ $tab ];
811
-    } else if ( $tab ) {
809
+    if ($tab && !empty($sections[$tab])) {
810
+        $tabs = $sections[$tab];
811
+    } else if ($tab) {
812 812
         $tabs = false;
813 813
     }
814 814
 
@@ -818,135 +818,135 @@  discard block
 block discarded – undo
818 818
 function wpinv_get_registered_settings_sections() {
819 819
     static $sections = false;
820 820
 
821
-    if ( false !== $sections ) {
821
+    if (false !== $sections) {
822 822
         return $sections;
823 823
     }
824 824
 
825 825
     $sections = array(
826
-        'general' => apply_filters( 'wpinv_settings_sections_general', array(
827
-            'main' => __( 'General Settings', 'invoicing' ),
828
-            'currency_section' => __( 'Currency Settings', 'invoicing' ),
829
-            'labels' => __( 'Label Texts', 'invoicing' ),
830
-        ) ),
831
-        'gateways' => apply_filters( 'wpinv_settings_sections_gateways', array(
832
-            'main' => __( 'Gateway Settings', 'invoicing' ),
833
-        ) ),
834
-        'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
835
-            'main' => __( 'Tax Settings', 'invoicing' ),
836
-            'rates' => __( 'Tax Rates', 'invoicing' ),
837
-        ) ),
838
-        'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
839
-            'main' => __( 'Email Settings', 'invoicing' ),
840
-        ) ),
841
-        'misc' => apply_filters( 'wpinv_settings_sections_misc', array(
842
-            'main' => __( 'Misc Settings', 'invoicing' ),
843
-        ) ),
844
-        'tools' => apply_filters( 'wpinv_settings_sections_tools', array(
845
-            'main' => __( 'Diagnostic Tools', 'invoicing' ),
846
-        ) ),
826
+        'general' => apply_filters('wpinv_settings_sections_general', array(
827
+            'main' => __('General Settings', 'invoicing'),
828
+            'currency_section' => __('Currency Settings', 'invoicing'),
829
+            'labels' => __('Label Texts', 'invoicing'),
830
+        )),
831
+        'gateways' => apply_filters('wpinv_settings_sections_gateways', array(
832
+            'main' => __('Gateway Settings', 'invoicing'),
833
+        )),
834
+        'taxes' => apply_filters('wpinv_settings_sections_taxes', array(
835
+            'main' => __('Tax Settings', 'invoicing'),
836
+            'rates' => __('Tax Rates', 'invoicing'),
837
+        )),
838
+        'emails' => apply_filters('wpinv_settings_sections_emails', array(
839
+            'main' => __('Email Settings', 'invoicing'),
840
+        )),
841
+        'misc' => apply_filters('wpinv_settings_sections_misc', array(
842
+            'main' => __('Misc Settings', 'invoicing'),
843
+        )),
844
+        'tools' => apply_filters('wpinv_settings_sections_tools', array(
845
+            'main' => __('Diagnostic Tools', 'invoicing'),
846
+        )),
847 847
     );
848 848
 
849
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
849
+    $sections = apply_filters('wpinv_settings_sections', $sections);
850 850
 
851 851
     return $sections;
852 852
 }
853 853
 
854
-function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
854
+function wpinv_get_pages($with_slug = false, $default_label = NULL) {
855 855
 	$pages_options = array();
856 856
 
857
-	if( $default_label !== NULL && $default_label !== false ) {
858
-		$pages_options = array( '' => $default_label ); // Blank option
857
+	if ($default_label !== NULL && $default_label !== false) {
858
+		$pages_options = array('' => $default_label); // Blank option
859 859
 	}
860 860
 
861 861
 	$pages = get_pages();
862
-	if ( $pages ) {
863
-		foreach ( $pages as $page ) {
862
+	if ($pages) {
863
+		foreach ($pages as $page) {
864 864
 			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
865
-            $pages_options[ $page->ID ] = $title;
865
+            $pages_options[$page->ID] = $title;
866 866
 		}
867 867
 	}
868 868
 
869 869
 	return $pages_options;
870 870
 }
871 871
 
872
-function wpinv_header_callback( $args ) {
873
-	if ( !empty( $args['desc'] ) ) {
872
+function wpinv_header_callback($args) {
873
+	if (!empty($args['desc'])) {
874 874
         echo $args['desc'];
875 875
     }
876 876
 }
877 877
 
878
-function wpinv_hidden_callback( $args ) {
878
+function wpinv_hidden_callback($args) {
879 879
 	global $wpinv_options;
880 880
 
881
-	if ( isset( $args['set_value'] ) ) {
881
+	if (isset($args['set_value'])) {
882 882
 		$value = $args['set_value'];
883
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
884
-		$value = $wpinv_options[ $args['id'] ];
883
+	} elseif (isset($wpinv_options[$args['id']])) {
884
+		$value = $wpinv_options[$args['id']];
885 885
 	} else {
886
-		$value = isset( $args['std'] ) ? $args['std'] : '';
886
+		$value = isset($args['std']) ? $args['std'] : '';
887 887
 	}
888 888
 
889
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
889
+	if (isset($args['faux']) && true === $args['faux']) {
890 890
 		$args['readonly'] = true;
891
-		$value = isset( $args['std'] ) ? $args['std'] : '';
891
+		$value = isset($args['std']) ? $args['std'] : '';
892 892
 		$name  = '';
893 893
 	} else {
894
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
894
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
895 895
 	}
896 896
 
897
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
897
+	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key($args['id']) . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '" />';
898 898
     
899 899
 	echo $html;
900 900
 }
901 901
 
902
-function wpinv_checkbox_callback( $args ) {
902
+function wpinv_checkbox_callback($args) {
903 903
 	global $wpinv_options;
904 904
     
905
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
905
+    $sanitize_id = wpinv_sanitize_key($args['id']);
906 906
 
907
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
907
+	if (isset($args['faux']) && true === $args['faux']) {
908 908
 		$name = '';
909 909
 	} else {
910 910
 		$name = 'name="wpinv_settings[' . $sanitize_id . ']"';
911 911
 	}
912 912
 
913
-	$checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : '';
913
+	$checked = isset($wpinv_options[$args['id']]) ? checked(1, $wpinv_options[$args['id']], false) : '';
914 914
 	$html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>';
915
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
915
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
916 916
 
917 917
 	echo $html;
918 918
 }
919 919
 
920
-function wpinv_multicheck_callback( $args ) {
920
+function wpinv_multicheck_callback($args) {
921 921
 	global $wpinv_options;
922 922
 	
923
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
923
+	$sanitize_id = wpinv_sanitize_key($args['id']);
924 924
 	
925
-	if ( ! empty( $args['options'] ) ) {
926
-		foreach( $args['options'] as $key => $option ):
927
-			$sanitize_key = wpinv_sanitize_key( $key );
928
-			if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { 
925
+	if (!empty($args['options'])) {
926
+		foreach ($args['options'] as $key => $option):
927
+			$sanitize_key = wpinv_sanitize_key($key);
928
+			if (isset($wpinv_options[$args['id']][$sanitize_key])) { 
929 929
 				$enabled = $sanitize_key;
930 930
 			} else { 
931 931
 				$enabled = NULL; 
932 932
 			}
933
-			echo '<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;';
934
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>';
933
+			echo '<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;';
934
+			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post($option) . '</label><br/>';
935 935
 		endforeach;
936 936
 		echo '<p class="description">' . $args['desc'] . '</p>';
937 937
 	}
938 938
 }
939 939
 
940
-function wpinv_payment_icons_callback( $args ) {
940
+function wpinv_payment_icons_callback($args) {
941 941
 	global $wpinv_options;
942 942
     
943
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
943
+    $sanitize_id = wpinv_sanitize_key($args['id']);
944 944
 
945
-	if ( ! empty( $args['options'] ) ) {
946
-		foreach( $args['options'] as $key => $option ) {
947
-            $sanitize_key = wpinv_sanitize_key( $key );
945
+	if (!empty($args['options'])) {
946
+		foreach ($args['options'] as $key => $option) {
947
+            $sanitize_key = wpinv_sanitize_key($key);
948 948
             
949
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
949
+			if (isset($wpinv_options[$args['id']][$key])) {
950 950
 				$enabled = $option;
951 951
 			} else {
952 952
 				$enabled = NULL;
@@ -954,196 +954,196 @@  discard block
 block discarded – undo
954 954
 
955 955
 			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
956 956
 
957
-				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;';
957
+				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;';
958 958
 
959
-				if ( wpinv_string_is_image_url( $key ) ) {
960
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
959
+				if (wpinv_string_is_image_url($key)) {
960
+					echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
961 961
 				} else {
962
-					$card = strtolower( str_replace( ' ', '', $option ) );
962
+					$card = strtolower(str_replace(' ', '', $option));
963 963
 
964
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
965
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
964
+					if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
965
+						$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
966 966
 					} else {
967
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
967
+						$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
968 968
 						$content_dir = WP_CONTENT_DIR;
969 969
 
970
-						if ( function_exists( 'wp_normalize_path' ) ) {
970
+						if (function_exists('wp_normalize_path')) {
971 971
 							// Replaces backslashes with forward slashes for Windows systems
972
-							$image = wp_normalize_path( $image );
973
-							$content_dir = wp_normalize_path( $content_dir );
972
+							$image = wp_normalize_path($image);
973
+							$content_dir = wp_normalize_path($content_dir);
974 974
 						}
975 975
 
976
-						$image = str_replace( $content_dir, content_url(), $image );
976
+						$image = str_replace($content_dir, content_url(), $image);
977 977
 					}
978 978
 
979
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
979
+					echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
980 980
 				}
981 981
 			echo $option . '</label>';
982 982
 		}
983
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
983
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
984 984
 	}
985 985
 }
986 986
 
987
-function wpinv_radio_callback( $args ) {
987
+function wpinv_radio_callback($args) {
988 988
 	global $wpinv_options;
989 989
     
990
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
990
+    $sanitize_id = wpinv_sanitize_key($args['id']);
991 991
     
992
-    foreach ( $args['options'] as $key => $option ) :
993
-		$sanitize_key = wpinv_sanitize_key( $key );
992
+    foreach ($args['options'] as $key => $option) :
993
+		$sanitize_key = wpinv_sanitize_key($key);
994 994
         
995 995
         $checked = false;
996 996
 
997
-		if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key )
997
+		if (isset($wpinv_options[$args['id']]) && $wpinv_options[$args['id']] == $key)
998 998
 			$checked = true;
999
-		elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) )
999
+		elseif (isset($args['std']) && $args['std'] == $key && !isset($wpinv_options[$args['id']]))
1000 1000
 			$checked = true;
1001 1001
 
1002 1002
 		echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/>&nbsp;';
1003
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>';
1003
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option) . '</label><br/>';
1004 1004
 	endforeach;
1005 1005
 
1006
-	echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
1006
+	echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
1007 1007
 }
1008 1008
 
1009
-function wpinv_gateways_callback( $args ) {
1009
+function wpinv_gateways_callback($args) {
1010 1010
 	global $wpinv_options;
1011 1011
     
1012
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1012
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1013 1013
 
1014
-	foreach ( $args['options'] as $key => $option ) :
1015
-		$sanitize_key = wpinv_sanitize_key( $key );
1014
+	foreach ($args['options'] as $key => $option) :
1015
+		$sanitize_key = wpinv_sanitize_key($key);
1016 1016
         
1017
-        if ( isset( $wpinv_options['gateways'][ $key ] ) )
1017
+        if (isset($wpinv_options['gateways'][$key]))
1018 1018
 			$enabled = '1';
1019 1019
 		else
1020 1020
 			$enabled = null;
1021 1021
 
1022
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1023
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
1022
+		echo '<input name="wpinv_settings[' . esc_attr($args['id']) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
1023
+		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html($option['admin_label']) . '</label><br/>';
1024 1024
 	endforeach;
1025 1025
 }
1026 1026
 
1027 1027
 function wpinv_gateway_select_callback($args) {
1028 1028
 	global $wpinv_options;
1029 1029
     
1030
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1030
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1031 1031
 
1032 1032
 	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">';
1033 1033
 
1034
-	foreach ( $args['options'] as $key => $option ) :
1035
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1036
-            $selected = selected( $key, $args['selected'], false );
1034
+	foreach ($args['options'] as $key => $option) :
1035
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1036
+            $selected = selected($key, $args['selected'], false);
1037 1037
         } else {
1038
-            $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
1038
+            $selected = isset($wpinv_options[$args['id']]) ? selected($key, $wpinv_options[$args['id']], false) : '';
1039 1039
         }
1040
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
1040
+		echo '<option value="' . wpinv_sanitize_key($key) . '"' . $selected . '>' . esc_html($option['admin_label']) . '</option>';
1041 1041
 	endforeach;
1042 1042
 
1043 1043
 	echo '</select>';
1044
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1044
+	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1045 1045
 }
1046 1046
 
1047
-function wpinv_text_callback( $args ) {
1047
+function wpinv_text_callback($args) {
1048 1048
 	global $wpinv_options;
1049 1049
     
1050
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1050
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1051 1051
 
1052
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1053
-		$value = $wpinv_options[ $args['id'] ];
1052
+	if (isset($wpinv_options[$args['id']])) {
1053
+		$value = $wpinv_options[$args['id']];
1054 1054
 	} else {
1055
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1055
+		$value = isset($args['std']) ? $args['std'] : '';
1056 1056
 	}
1057 1057
 
1058
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1058
+	if (isset($args['faux']) && true === $args['faux']) {
1059 1059
 		$args['readonly'] = true;
1060
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1060
+		$value = isset($args['std']) ? $args['std'] : '';
1061 1061
 		$name  = '';
1062 1062
 	} else {
1063
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1063
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1064 1064
 	}
1065
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1065
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1066 1066
 
1067 1067
 	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1068
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1069
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
1070
-	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1068
+	$size     = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1069
+	$html     = '<input type="text" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"' . $readonly . '/>';
1070
+	$html    .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1071 1071
 
1072 1072
 	echo $html;
1073 1073
 }
1074 1074
 
1075
-function wpinv_number_callback( $args ) {
1075
+function wpinv_number_callback($args) {
1076 1076
 	global $wpinv_options;
1077 1077
     
1078
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1078
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1079 1079
 
1080
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1081
-		$value = $wpinv_options[ $args['id'] ];
1080
+	if (isset($wpinv_options[$args['id']])) {
1081
+		$value = $wpinv_options[$args['id']];
1082 1082
 	} else {
1083
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1083
+		$value = isset($args['std']) ? $args['std'] : '';
1084 1084
 	}
1085 1085
 
1086
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
1086
+	if (isset($args['faux']) && true === $args['faux']) {
1087 1087
 		$args['readonly'] = true;
1088
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1088
+		$value = isset($args['std']) ? $args['std'] : '';
1089 1089
 		$name  = '';
1090 1090
 	} else {
1091
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
1091
+		$name = 'name="wpinv_settings[' . esc_attr($args['id']) . ']"';
1092 1092
 	}
1093 1093
 
1094
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
1095
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
1096
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
1097
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
1094
+	$max  = isset($args['max']) ? $args['max'] : 999999;
1095
+	$min  = isset($args['min']) ? $args['min'] : 0;
1096
+	$step = isset($args['step']) ? $args['step'] : 1;
1097
+	$class = !empty($args['class']) ? sanitize_html_class($args['class']) : '';
1098 1098
 
1099
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1100
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1101
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1099
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1100
+	$html = '<input type="number" step="' . esc_attr($step) . '" max="' . esc_attr($max) . '" min="' . esc_attr($min) . '" class="' . sanitize_html_class($size) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr(stripslashes($value)) . '"/>';
1101
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1102 1102
 
1103 1103
 	echo $html;
1104 1104
 }
1105 1105
 
1106
-function wpinv_textarea_callback( $args ) {
1106
+function wpinv_textarea_callback($args) {
1107 1107
 	global $wpinv_options;
1108 1108
     
1109
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1109
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1110 1110
 
1111
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1112
-		$value = $wpinv_options[ $args['id'] ];
1111
+	if (isset($wpinv_options[$args['id']])) {
1112
+		$value = $wpinv_options[$args['id']];
1113 1113
 	} else {
1114
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1114
+		$value = isset($args['std']) ? $args['std'] : '';
1115 1115
 	}
1116 1116
     
1117
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1118
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
1117
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1118
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
1119 1119
 
1120
-	$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>';
1121
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1120
+	$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>';
1121
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1122 1122
 
1123 1123
 	echo $html;
1124 1124
 }
1125 1125
 
1126
-function wpinv_password_callback( $args ) {
1126
+function wpinv_password_callback($args) {
1127 1127
 	global $wpinv_options;
1128 1128
     
1129
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1129
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1130 1130
 
1131
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1132
-		$value = $wpinv_options[ $args['id'] ];
1131
+	if (isset($wpinv_options[$args['id']])) {
1132
+		$value = $wpinv_options[$args['id']];
1133 1133
 	} else {
1134
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1134
+		$value = isset($args['std']) ? $args['std'] : '';
1135 1135
 	}
1136 1136
 
1137
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1138
-	$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 ) . '"/>';
1139
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1137
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1138
+	$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) . '"/>';
1139
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1140 1140
 
1141 1141
 	echo $html;
1142 1142
 }
1143 1143
 
1144 1144
 function wpinv_missing_callback($args) {
1145 1145
 	printf(
1146
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
1146
+		__('The callback function used for the %s setting is missing.', 'invoicing'),
1147 1147
 		'<strong>' . $args['id'] . '</strong>'
1148 1148
 	);
1149 1149
 }
@@ -1151,137 +1151,137 @@  discard block
 block discarded – undo
1151 1151
 function wpinv_select_callback($args) {
1152 1152
 	global $wpinv_options;
1153 1153
     
1154
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1154
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1155 1155
 
1156
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1157
-		$value = $wpinv_options[ $args['id'] ];
1156
+	if (isset($wpinv_options[$args['id']])) {
1157
+		$value = $wpinv_options[$args['id']];
1158 1158
 	} else {
1159
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1159
+		$value = isset($args['std']) ? $args['std'] : '';
1160 1160
 	}
1161 1161
     
1162
-    if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
1162
+    if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
1163 1163
         $value = $args['selected'];
1164 1164
     }
1165 1165
 
1166
-	if ( isset( $args['placeholder'] ) ) {
1166
+	if (isset($args['placeholder'])) {
1167 1167
 		$placeholder = $args['placeholder'];
1168 1168
 	} else {
1169 1169
 		$placeholder = '';
1170 1170
 	}
1171 1171
 
1172
-	if ( isset( $args['chosen'] ) ) {
1172
+	if (isset($args['chosen'])) {
1173 1173
 		$chosen = 'class="wpinv-chosen"';
1174 1174
 	} else {
1175 1175
 		$chosen = '';
1176 1176
 	}
1177 1177
     
1178
-    if( !empty( $args['onchange'] ) ) {
1179
-        $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
1178
+    if (!empty($args['onchange'])) {
1179
+        $onchange = ' onchange="' . esc_attr($args['onchange']) . '"';
1180 1180
     } else {
1181 1181
         $onchange = '';
1182 1182
     }
1183 1183
 
1184
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
1184
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" ' . $chosen . 'data-placeholder="' . esc_html($placeholder) . '"' . $onchange . ' />';
1185 1185
 
1186
-	foreach ( $args['options'] as $option => $name ) {
1187
-		$selected = selected( $option, $value, false );
1188
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1186
+	foreach ($args['options'] as $option => $name) {
1187
+		$selected = selected($option, $value, false);
1188
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1189 1189
 	}
1190 1190
 
1191 1191
 	$html .= '</select>';
1192
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1192
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1193 1193
 
1194 1194
 	echo $html;
1195 1195
 }
1196 1196
 
1197
-function wpinv_color_select_callback( $args ) {
1197
+function wpinv_color_select_callback($args) {
1198 1198
 	global $wpinv_options;
1199 1199
     
1200
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1200
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1201 1201
 
1202
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1203
-		$value = $wpinv_options[ $args['id'] ];
1202
+	if (isset($wpinv_options[$args['id']])) {
1203
+		$value = $wpinv_options[$args['id']];
1204 1204
 	} else {
1205
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1205
+		$value = isset($args['std']) ? $args['std'] : '';
1206 1206
 	}
1207 1207
 
1208
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
1208
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
1209 1209
 
1210
-	foreach ( $args['options'] as $option => $color ) {
1211
-		$selected = selected( $option, $value, false );
1212
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
1210
+	foreach ($args['options'] as $option => $color) {
1211
+		$selected = selected($option, $value, false);
1212
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($color['label']) . '</option>';
1213 1213
 	}
1214 1214
 
1215 1215
 	$html .= '</select>';
1216
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1216
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1217 1217
 
1218 1218
 	echo $html;
1219 1219
 }
1220 1220
 
1221
-function wpinv_rich_editor_callback( $args ) {
1221
+function wpinv_rich_editor_callback($args) {
1222 1222
 	global $wpinv_options, $wp_version;
1223 1223
     
1224
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1224
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1225 1225
 
1226
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1227
-		$value = $wpinv_options[ $args['id'] ];
1226
+	if (isset($wpinv_options[$args['id']])) {
1227
+		$value = $wpinv_options[$args['id']];
1228 1228
 
1229
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
1230
-			$value = isset( $args['std'] ) ? $args['std'] : '';
1229
+		if (empty($args['allow_blank']) && empty($value)) {
1230
+			$value = isset($args['std']) ? $args['std'] : '';
1231 1231
 		}
1232 1232
 	} else {
1233
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1233
+		$value = isset($args['std']) ? $args['std'] : '';
1234 1234
 	}
1235 1235
 
1236
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
1236
+	$rows = isset($args['size']) ? $args['size'] : 20;
1237 1237
 
1238
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
1238
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
1239 1239
 		ob_start();
1240
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) );
1240
+		wp_editor(stripslashes($value), 'wpinv_settings_' . esc_attr($args['id']), array('textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', 'textarea_rows' => absint($rows)));
1241 1241
 		$html = ob_get_clean();
1242 1242
 	} else {
1243
-		$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>';
1243
+		$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>';
1244 1244
 	}
1245 1245
 
1246
-	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1246
+	$html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1247 1247
 
1248 1248
 	echo $html;
1249 1249
 }
1250 1250
 
1251
-function wpinv_upload_callback( $args ) {
1251
+function wpinv_upload_callback($args) {
1252 1252
 	global $wpinv_options;
1253 1253
     
1254
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1254
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1255 1255
 
1256
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1256
+	if (isset($wpinv_options[$args['id']])) {
1257 1257
 		$value = $wpinv_options[$args['id']];
1258 1258
 	} else {
1259 1259
 		$value = isset($args['std']) ? $args['std'] : '';
1260 1260
 	}
1261 1261
 
1262
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1263
-	$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 ) ) . '"/>';
1264
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
1265
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1262
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
1263
+	$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)) . '"/>';
1264
+	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __('Upload File', 'invoicing') . '"/></span>';
1265
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1266 1266
 
1267 1267
 	echo $html;
1268 1268
 }
1269 1269
 
1270
-function wpinv_color_callback( $args ) {
1270
+function wpinv_color_callback($args) {
1271 1271
 	global $wpinv_options;
1272 1272
     
1273
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1273
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1274 1274
 
1275
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
1276
-		$value = $wpinv_options[ $args['id'] ];
1275
+	if (isset($wpinv_options[$args['id']])) {
1276
+		$value = $wpinv_options[$args['id']];
1277 1277
 	} else {
1278
-		$value = isset( $args['std'] ) ? $args['std'] : '';
1278
+		$value = isset($args['std']) ? $args['std'] : '';
1279 1279
 	}
1280 1280
 
1281
-	$default = isset( $args['std'] ) ? $args['std'] : '';
1281
+	$default = isset($args['std']) ? $args['std'] : '';
1282 1282
 
1283
-	$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( $default ) . '" />';
1284
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1283
+	$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($default) . '" />';
1284
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1285 1285
 
1286 1286
 	echo $html;
1287 1287
 }
@@ -1289,9 +1289,9 @@  discard block
 block discarded – undo
1289 1289
 function wpinv_country_states_callback($args) {
1290 1290
 	global $wpinv_options;
1291 1291
     
1292
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
1292
+    $sanitize_id = wpinv_sanitize_key($args['id']);
1293 1293
 
1294
-	if ( isset( $args['placeholder'] ) ) {
1294
+	if (isset($args['placeholder'])) {
1295 1295
 		$placeholder = $args['placeholder'];
1296 1296
 	} else {
1297 1297
 		$placeholder = '';
@@ -1299,17 +1299,17 @@  discard block
 block discarded – undo
1299 1299
 
1300 1300
 	$states = wpinv_get_country_states();
1301 1301
 
1302
-	$chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' );
1303
-	$class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1304
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
1302
+	$chosen = ($args['chosen'] ? ' wpinv-chosen' : '');
1303
+	$class = empty($states) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"';
1304
+	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"' . $class . 'data-placeholder="' . esc_html($placeholder) . '"/>';
1305 1305
 
1306
-	foreach ( $states as $option => $name ) {
1307
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
1308
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
1306
+	foreach ($states as $option => $name) {
1307
+		$selected = isset($wpinv_options[$args['id']]) ? selected($option, $wpinv_options[$args['id']], false) : '';
1308
+		$html .= '<option value="' . esc_attr($option) . '" ' . $selected . '>' . esc_html($name) . '</option>';
1309 1309
 	}
1310 1310
 
1311 1311
 	$html .= '</select>';
1312
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
1312
+	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post($args['desc']) . '</label>';
1313 1313
 
1314 1314
 	echo $html;
1315 1315
 }
@@ -1324,25 +1324,25 @@  discard block
 block discarded – undo
1324 1324
 	<table id="wpinv_tax_rates" class="wp-list-table widefat fixed posts">
1325 1325
 		<thead>
1326 1326
 			<tr>
1327
-				<th scope="col" class="wpinv_tax_country"><?php _e( 'Country', 'invoicing' ); ?></th>
1328
-				<th scope="col" class="wpinv_tax_state"><?php _e( 'State / Province', 'invoicing' ); ?></th>
1329
-                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e( 'Apply rate to whole country, regardless of state / province', 'invoicing' ); ?>"><?php _e( 'Country Wide', 'invoicing' ); ?></th>
1330
-                <th scope="col" class="wpinv_tax_rate"><?php _e( 'Rate %', 'invoicing' ); ?></th> 
1331
-                <th scope="col" class="wpinv_tax_name"><?php _e( 'Tax Name', 'invoicing' ); ?></th>
1332
-				<th scope="col" class="wpinv_tax_action"><?php _e( 'Remove', 'invoicing' ); ?></th>
1327
+				<th scope="col" class="wpinv_tax_country"><?php _e('Country', 'invoicing'); ?></th>
1328
+				<th scope="col" class="wpinv_tax_state"><?php _e('State / Province', 'invoicing'); ?></th>
1329
+                <th scope="col" class="wpinv_tax_global" title="<?php esc_attr_e('Apply rate to whole country, regardless of state / province', 'invoicing'); ?>"><?php _e('Country Wide', 'invoicing'); ?></th>
1330
+                <th scope="col" class="wpinv_tax_rate"><?php _e('Rate %', 'invoicing'); ?></th> 
1331
+                <th scope="col" class="wpinv_tax_name"><?php _e('Tax Name', 'invoicing'); ?></th>
1332
+				<th scope="col" class="wpinv_tax_action"><?php _e('Remove', 'invoicing'); ?></th>
1333 1333
 			</tr>
1334 1334
 		</thead>
1335 1335
         <tbody>
1336
-		<?php if( !empty( $rates ) ) : ?>
1337
-			<?php foreach( $rates as $key => $rate ) : ?>
1336
+		<?php if (!empty($rates)) : ?>
1337
+			<?php foreach ($rates as $key => $rate) : ?>
1338 1338
             <?php 
1339
-            $sanitized_key = wpinv_sanitize_key( $key );
1339
+            $sanitized_key = wpinv_sanitize_key($key);
1340 1340
             ?>
1341 1341
 			<tr>
1342 1342
 				<td class="wpinv_tax_country">
1343 1343
 					<?php
1344
-					echo wpinv_html_select( array(
1345
-						'options'          => wpinv_get_country_list( true ),
1344
+					echo wpinv_html_select(array(
1345
+						'options'          => wpinv_get_country_list(true),
1346 1346
 						'name'             => 'tax_rates[' . $sanitized_key . '][country]',
1347 1347
                         'id'               => 'tax_rates[' . $sanitized_key . '][country]',
1348 1348
 						'selected'         => $rate['country'],
@@ -1350,72 +1350,72 @@  discard block
 block discarded – undo
1350 1350
 						'show_option_none' => false,
1351 1351
 						'class'            => 'wpinv-tax-country',
1352 1352
 						'chosen'           => false,
1353
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1354
-					) );
1353
+						'placeholder'      => __('Choose a country', 'invoicing')
1354
+					));
1355 1355
 					?>
1356 1356
 				</td>
1357 1357
 				<td class="wpinv_tax_state">
1358 1358
 					<?php
1359
-					$states = wpinv_get_country_states( $rate['country'] );
1360
-					if( !empty( $states ) ) {
1361
-						echo wpinv_html_select( array(
1362
-							'options'          => array_merge( array( '' => '' ), $states ),
1359
+					$states = wpinv_get_country_states($rate['country']);
1360
+					if (!empty($states)) {
1361
+						echo wpinv_html_select(array(
1362
+							'options'          => array_merge(array('' => ''), $states),
1363 1363
 							'name'             => 'tax_rates[' . $sanitized_key . '][state]',
1364 1364
                             'id'               => 'tax_rates[' . $sanitized_key . '][state]',
1365 1365
 							'selected'         => $rate['state'],
1366 1366
 							'show_option_all'  => false,
1367 1367
 							'show_option_none' => false,
1368 1368
 							'chosen'           => false,
1369
-							'placeholder'      => __( 'Choose a state', 'invoicing' )
1370
-						) );
1369
+							'placeholder'      => __('Choose a state', 'invoicing')
1370
+						));
1371 1371
 					} else {
1372
-						echo wpinv_html_text( array(
1372
+						echo wpinv_html_text(array(
1373 1373
 							'name'  => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'],
1374
-							'value' => ! empty( $rate['state'] ) ? $rate['state'] : '',
1374
+							'value' => !empty($rate['state']) ? $rate['state'] : '',
1375 1375
                             'id'    => 'tax_rates[' . $sanitized_key . '][state]',
1376
-						) );
1376
+						));
1377 1377
 					}
1378 1378
 					?>
1379 1379
 				</td>
1380 1380
 				<td class="wpinv_tax_global">
1381
-					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/>
1382
-					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1381
+					<input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked(true, !empty($rate['global'])); ?>/>
1382
+					<label for="tax_rates[<?php echo $sanitized_key; ?>][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1383 1383
 				</td>
1384
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html( $rate['rate'] ); ?>"/></td>
1385
-                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html( $rate['name'] ); ?>"/></td>
1386
-				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1384
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[<?php echo $sanitized_key; ?>][rate]" value="<?php echo esc_html($rate['rate']); ?>"/></td>
1385
+                <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[<?php echo $sanitized_key; ?>][name]" value="<?php echo esc_html($rate['name']); ?>"/></td>
1386
+				<td class="wpinv_tax_action"><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1387 1387
 			</tr>
1388 1388
 			<?php endforeach; ?>
1389 1389
 		<?php else : ?>
1390 1390
 			<tr>
1391 1391
 				<td class="wpinv_tax_country">
1392 1392
 					<?php
1393
-					echo wpinv_html_select( array(
1394
-						'options'          => wpinv_get_country_list( true ),
1393
+					echo wpinv_html_select(array(
1394
+						'options'          => wpinv_get_country_list(true),
1395 1395
 						'name'             => 'tax_rates[0][country]',
1396 1396
 						'show_option_all'  => false,
1397 1397
 						'show_option_none' => false,
1398 1398
 						'class'            => 'wpinv-tax-country',
1399 1399
 						'chosen'           => false,
1400
-						'placeholder'      => __( 'Choose a country', 'invoicing' )
1401
-					) ); ?>
1400
+						'placeholder'      => __('Choose a country', 'invoicing')
1401
+					)); ?>
1402 1402
 				</td>
1403 1403
 				<td class="wpinv_tax_state">
1404
-					<?php echo wpinv_html_text( array(
1404
+					<?php echo wpinv_html_text(array(
1405 1405
 						'name' => 'tax_rates[0][state]'
1406
-					) ); ?>
1406
+					)); ?>
1407 1407
 				</td>
1408 1408
 				<td class="wpinv_tax_global">
1409 1409
 					<input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/>
1410
-					<label for="tax_rates[0][global]"><?php _e( 'Apply to whole country', 'invoicing' ); ?></label>
1410
+					<label for="tax_rates[0][global]"><?php _e('Apply to whole country', 'invoicing'); ?></label>
1411 1411
 				</td>
1412
-				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>" value="<?php echo (float)wpinv_get_option( 'tax_rate', 0 ) ;?>"/></td>
1412
+				<td class="wpinv_tax_rate"><input type="number" class="small-text" step="any" min="0" max="99" name="tax_rates[0][rate]" placeholder="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>" value="<?php echo (float)wpinv_get_option('tax_rate', 0); ?>"/></td>
1413 1413
                 <td class="wpinv_tax_name"><input type="text" class="regular-text" name="tax_rates[0][name]" /></td>
1414
-				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e( 'Remove Rate', 'invoicing' ); ?></span></td>
1414
+				<td><span class="wpinv_remove_tax_rate button-secondary"><?php _e('Remove Rate', 'invoicing'); ?></span></td>
1415 1415
 			</tr>
1416 1416
 		<?php endif; ?>
1417 1417
         </tbody>
1418
-        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot>
1418
+        <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e('Add Tax Rate', 'invoicing'); ?></span></td></tr></tfoot>
1419 1419
 	</table>
1420 1420
 	<?php
1421 1421
 	echo ob_get_clean();
@@ -1426,44 +1426,44 @@  discard block
 block discarded – undo
1426 1426
     ob_start(); ?>
1427 1427
     </td><tr>
1428 1428
     <td colspan="2" class="wpinv_tools_tdbox">
1429
-    <?php if ( $args['desc'] ) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1430
-    <?php do_action( 'wpinv_tools_before' ); ?>
1429
+    <?php if ($args['desc']) { ?><p><?php echo $args['desc']; ?></p><?php } ?>
1430
+    <?php do_action('wpinv_tools_before'); ?>
1431 1431
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1432 1432
         <thead>
1433 1433
             <tr>
1434
-                <th scope="col" class="wpinv-th-tool"><?php _e( 'Tool', 'invoicing' ); ?></th>
1435
-                <th scope="col" class="wpinv-th-desc"><?php _e( 'Description', 'invoicing' ); ?></th>
1436
-                <th scope="col" class="wpinv-th-action"><?php _e( 'Action', 'invoicing' ); ?></th>
1434
+                <th scope="col" class="wpinv-th-tool"><?php _e('Tool', 'invoicing'); ?></th>
1435
+                <th scope="col" class="wpinv-th-desc"><?php _e('Description', 'invoicing'); ?></th>
1436
+                <th scope="col" class="wpinv-th-action"><?php _e('Action', 'invoicing'); ?></th>
1437 1437
             </tr>
1438 1438
         </thead>
1439
-            <?php do_action( 'wpinv_tools_row' ); ?>
1439
+            <?php do_action('wpinv_tools_row'); ?>
1440 1440
         <tbody>
1441 1441
         </tbody>
1442 1442
     </table>
1443
-    <?php do_action( 'wpinv_tools_after' ); ?>
1443
+    <?php do_action('wpinv_tools_after'); ?>
1444 1444
     <?php
1445 1445
     echo ob_get_clean();
1446 1446
 }
1447 1447
 
1448
-function wpinv_descriptive_text_callback( $args ) {
1449
-	echo wp_kses_post( $args['desc'] );
1448
+function wpinv_descriptive_text_callback($args) {
1449
+	echo wp_kses_post($args['desc']);
1450 1450
 }
1451 1451
 
1452
-function wpinv_hook_callback( $args ) {
1453
-	do_action( 'wpinv_' . $args['id'], $args );
1452
+function wpinv_hook_callback($args) {
1453
+	do_action('wpinv_' . $args['id'], $args);
1454 1454
 }
1455 1455
 
1456 1456
 function wpinv_set_settings_cap() {
1457 1457
 	return 'manage_options';
1458 1458
 }
1459
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1459
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1460 1460
 
1461
-function wpinv_settings_sanitize_input( $value, $key ) {
1462
-    if ( $key == 'tax_rate' || $key == 'eu_fallback_rate' ) {
1463
-        $value = wpinv_sanitize_amount( $value, 4 );
1461
+function wpinv_settings_sanitize_input($value, $key) {
1462
+    if ($key == 'tax_rate' || $key == 'eu_fallback_rate') {
1463
+        $value = wpinv_sanitize_amount($value, 4);
1464 1464
         $value = $value >= 100 ? 99 : $value;
1465 1465
     }
1466 1466
         
1467 1467
     return $value;
1468 1468
 }
1469
-add_filter( 'wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2 );
1470 1469
\ No newline at end of file
1470
+add_filter('wpinv_settings_sanitize', 'wpinv_settings_sanitize_input', 10, 2);
1471 1471
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-address.php 1 patch
Spacing   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -1,34 +1,34 @@  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 7
 class WPInv_Meta_Box_Billing_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         global $user_ID;
10
-        $post_id    = !empty( $post->ID ) ? $post->ID : 0;
11
-        $invoice    = new WPInv_Invoice( $post_id );
10
+        $post_id    = !empty($post->ID) ? $post->ID : 0;
11
+        $invoice    = new WPInv_Invoice($post_id);
12 12
 ?>
13 13
 <div class="gdmbx2-wrap form-table">
14 14
     <div id="gdmbx2-metabox-wpinv_address" class="gdmbx2-metabox gdmbx-field-list wpinv-address gdmbx-row">
15 15
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-user-id table-layout">
16 16
             <div class="gdmbx-th">
17
-                <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
17
+                <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
18 18
             </div>
19 19
             <div class="gdmbx-td gdmbx-customer-div">
20
-            <?php wpinv_dropdown_users( array(
20
+            <?php wpinv_dropdown_users(array(
21 21
                             'name' => 'post_author_override',
22 22
                             'selected' => empty($post->ID) ? $user_ID : $post->post_author,
23 23
                             'include_selected' => true,
24 24
                             'show' => 'user_email',
25 25
                             'orderby' => 'user_email',
26 26
                             'class' => 'gdmbx2-text-large'
27
-                        ) ); ?>
27
+                        )); ?>
28 28
             </div>
29 29
         </div>
30 30
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-email table-layout" style="display:none">
31
-            <div class="gdmbx-th"><label for="wpinv_email"><?php _e( 'Email', 'invoicing' );?> <span class="required">*</span></label>
31
+            <div class="gdmbx-th"><label for="wpinv_email"><?php _e('Email', 'invoicing'); ?> <span class="required">*</span></label>
32 32
             </div>
33 33
             <div class="gdmbx-td">
34 34
                 <input type="hidden" id="wpinv_new_user" name="wpinv_new_user" value="" />
@@ -36,58 +36,58 @@  discard block
 block discarded – undo
36 36
             </div>
37 37
         </div>
38 38
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-btns table-layout">
39
-            <div class="gdmbx-th"><label><?php _e( 'Actions', 'invoicing' );?></label>
39
+            <div class="gdmbx-th"><label><?php _e('Actions', 'invoicing'); ?></label>
40 40
             </div>
41
-            <?php if($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))){ ?>
41
+            <?php if ($invoice->has_status(array('wpi-pending', 'wpi-quote-pending'))) { ?>
42 42
                 <div class="gdmbx-td">
43
-                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e( 'Fill User Details', 'invoicing' );?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e( 'Fill User Details', 'invoicing' );?></a>
44
-                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e( 'Add New User', 'invoicing' );?></a>
45
-                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e( 'Cancel', 'invoicing' );?> </a>
43
+                    <a id="wpinv-fill-user-details" class="button button-small button-secondary" title="<?php esc_attr_e('Fill User Details', 'invoicing'); ?>" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-refresh"></i><?php _e('Fill User Details', 'invoicing'); ?></a>
44
+                    <a class="wpinv-new-user button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-plus"></i><?php _e('Add New User', 'invoicing'); ?></a>
45
+                    <a style="display:none" class="wpinv-new-cancel button button-small button-secondary" href="javascript:void(0)"><i aria-hidden="true" class="fa fa-close"></i><?php _e('Cancel', 'invoicing'); ?> </a>
46 46
                 </div>
47 47
             <?php } ?>
48 48
         </div>
49 49
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-first-name table-layout">
50
-            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e( 'First Name', 'invoicing' );?></label></div>
50
+            <div class="gdmbx-th"><label for="wpinv_first_name"><?php _e('First Name', 'invoicing'); ?></label></div>
51 51
             <div class="gdmbx-td">
52
-                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr( $invoice->first_name );?>" />
52
+                <input type="text" class="gdmbx2-text-large" name="wpinv_first_name" id="wpinv_first_name" value="<?php echo esc_attr($invoice->first_name); ?>" />
53 53
             </div>
54 54
         </div>
55 55
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-last-name table-layout">
56
-            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e( 'Last Name', 'invoicing' );?></label></div>
56
+            <div class="gdmbx-th"><label for="wpinv_last_name"><?php _e('Last Name', 'invoicing'); ?></label></div>
57 57
             <div class="gdmbx-td">
58
-                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr( $invoice->last_name );?>" />
58
+                <input type="text" class="gdmbx2-text-large" name="wpinv_last_name" id="wpinv_last_name" value="<?php echo esc_attr($invoice->last_name); ?>" />
59 59
             </div>
60 60
         </div>
61 61
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-company table-layout">
62
-            <div class="gdmbx-th"><label for="wpinv_company"><?php _e( 'Company', 'invoicing' );?></label></div>
62
+            <div class="gdmbx-th"><label for="wpinv_company"><?php _e('Company', 'invoicing'); ?></label></div>
63 63
             <div class="gdmbx-td">
64
-                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr( $invoice->company );?>" />
64
+                <input type="text" class="gdmbx2-text-large" name="wpinv_company" id="wpinv_company" value="<?php echo esc_attr($invoice->company); ?>" />
65 65
             </div>
66 66
         </div>
67 67
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-vat-number table-layout">
68
-            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e( 'Vat Number', 'invoicing' );?></label></div>
68
+            <div class="gdmbx-th"><label for="wpinv_vat_number"><?php _e('Vat Number', 'invoicing'); ?></label></div>
69 69
             <div class="gdmbx-td">
70
-                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr( $invoice->vat_number );?>" />
70
+                <input type="text" class="gdmbx2-text-large" name="wpinv_vat_number" id="wpinv_vat_number" value="<?php echo esc_attr($invoice->vat_number); ?>" />
71 71
             </div>
72 72
         </div>
73 73
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-address table-layout">
74
-            <div class="gdmbx-th"><label for="wpinv_address"><?php _e( 'Address', 'invoicing' );?></label></div>
74
+            <div class="gdmbx-th"><label for="wpinv_address"><?php _e('Address', 'invoicing'); ?></label></div>
75 75
             <div class="gdmbx-td">
76
-                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr( $invoice->address );?>" />
76
+                <input type="text" class="gdmbx2-text-large" name="wpinv_address" id="wpinv_address" value="<?php echo esc_attr($invoice->address); ?>" />
77 77
             </div>
78 78
         </div>
79 79
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-city table-layout">
80
-            <div class="gdmbx-th"><label for="wpinv_city"><?php _e( 'City', 'invoicing' );?></label></div>
80
+            <div class="gdmbx-th"><label for="wpinv_city"><?php _e('City', 'invoicing'); ?></label></div>
81 81
             <div class="gdmbx-td">
82
-                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr( $invoice->city );?>" />
82
+                <input type="text" class="gdmbx2-text-large" name="wpinv_city" id="wpinv_city" value="<?php echo esc_attr($invoice->city); ?>" />
83 83
             </div>
84 84
         </div>
85 85
         <div class="gdmbx-row gdmbx-type-select gdmbx-wpinv-country table-layout">
86
-            <div class="gdmbx-th"><label for="wpinv_country"><?php _e( 'Country', 'invoicing' );?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
86
+            <div class="gdmbx-th"><label for="wpinv_country"><?php _e('Country', 'invoicing'); ?> <span class="wpi-loader"><i class="fa fa-refresh fa-spin"></i></span></label></div>
87 87
             <div class="gdmbx-td">
88 88
                 <?php
89
-                echo wpinv_html_select( array(
90
-                    'options'          => array_merge( array( '' => __( 'Choose a country', 'invoicing' ) ), wpinv_get_country_list() ),
89
+                echo wpinv_html_select(array(
90
+                    'options'          => array_merge(array('' => __('Choose a country', 'invoicing')), wpinv_get_country_list()),
91 91
                     'name'             => 'wpinv_country',
92 92
                     'id'               => 'wpinv_country',
93 93
                     'selected'         => $invoice->country,
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
                     'show_option_none' => false,
96 96
                     'class'            => 'gdmbx2-text-large',
97 97
                     'chosen'           => false,
98
-                    'placeholder'      => __( 'Choose a country', 'invoicing' ),
98
+                    'placeholder'      => __('Choose a country', 'invoicing'),
99 99
                     'required'         => false,
100
-                ) );
100
+                ));
101 101
                 ?>
102 102
             </div>
103 103
         </div>
104 104
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-state table-layout">
105
-            <div class="gdmbx-th"><label for="wpinv_state"><?php _e( 'State', 'invoicing' );?></label></div>
105
+            <div class="gdmbx-th"><label for="wpinv_state"><?php _e('State', 'invoicing'); ?></label></div>
106 106
             <div class="gdmbx-td">
107 107
                 <?php
108
-                $states = wpinv_get_country_states( $invoice->country );
109
-                if( !empty( $states ) ) {
110
-                    echo wpinv_html_select( array(
111
-                        'options'          => array_merge( array( '' => __( 'Choose a state', 'invoicing' ) ), $states ),
108
+                $states = wpinv_get_country_states($invoice->country);
109
+                if (!empty($states)) {
110
+                    echo wpinv_html_select(array(
111
+                        'options'          => array_merge(array('' => __('Choose a state', 'invoicing')), $states),
112 112
                         'name'             => 'wpinv_state',
113 113
                         'id'               => 'wpinv_state',
114 114
                         'selected'         => $invoice->state,
@@ -116,44 +116,44 @@  discard block
 block discarded – undo
116 116
                         'show_option_none' => false,
117 117
                         'class'            => 'gdmbx2-text-large',
118 118
                         'chosen'           => false,
119
-                        'placeholder'      => __( 'Choose a state', 'invoicing' ),
119
+                        'placeholder'      => __('Choose a state', 'invoicing'),
120 120
                         'required'         => false,
121
-                    ) );
121
+                    ));
122 122
                 } else {
123
-                    echo wpinv_html_text( array(
123
+                    echo wpinv_html_text(array(
124 124
                         'name'  => 'wpinv_state',
125
-                        'value' => ! empty( $invoice->state ) ? $invoice->state : '',
125
+                        'value' => !empty($invoice->state) ? $invoice->state : '',
126 126
                         'id'    => 'wpinv_state',
127 127
                         'class' => 'gdmbx2-text-large',
128 128
                         'required' => false,
129
-                    ) );
129
+                    ));
130 130
                 }
131 131
                 ?>
132 132
             </div>
133 133
         </div>
134 134
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-zip table-layout">
135
-            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e( 'Zipcode', 'invoicing' );?></label></div>
135
+            <div class="gdmbx-th"><label for="wpinv_zip"><?php _e('Zipcode', 'invoicing'); ?></label></div>
136 136
             <div class="gdmbx-td">
137
-                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr( $invoice->zip );?>" />
137
+                <input type="text" class="gdmbx2-text-large" name="wpinv_zip" id="wpinv_zip" value="<?php echo esc_attr($invoice->zip); ?>" />
138 138
             </div>
139 139
         </div>
140 140
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-phone table-layout">
141
-            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e( 'Phone', 'invoicing' );?></label></div>
141
+            <div class="gdmbx-th"><label for="wpinv_phone"><?php _e('Phone', 'invoicing'); ?></label></div>
142 142
             <div class="gdmbx-td">
143
-                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr( $invoice->phone );?>" />
143
+                <input type="text" class="gdmbx2-text-large" name="wpinv_phone" id="wpinv_phone" value="<?php echo esc_attr($invoice->phone); ?>" />
144 144
             </div>
145 145
         </div>
146 146
         <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-ip table-layout">
147
-            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e( 'IP Address', 'invoicing' );?><?php if ($invoice->ip) { ?>
148
-                &nbsp;&nbsp;<a href="<?php echo admin_url( 'admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip ); ?>" title="<?php esc_attr_e( 'View IP information', 'invoicing' );?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
147
+            <div class="gdmbx-th"><label for="wpinv_ip"><?php _e('IP Address', 'invoicing'); ?><?php if ($invoice->ip) { ?>
148
+                &nbsp;&nbsp;<a href="<?php echo admin_url('admin-ajax.php?action=wpinv_ip_geolocation&ip=' . $invoice->ip); ?>" title="<?php esc_attr_e('View IP information', 'invoicing'); ?>" target="_blank"><i class="fa fa-external-link" aria-hidden="true"></i></a>
149 149
                 <?php } ?></label></div>
150 150
             <div class="gdmbx-td">
151
-                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr( $invoice->ip );?>" readonly />
151
+                <input type="text" class="gdmbx2-text-large" value="<?php echo esc_attr($invoice->ip); ?>" readonly />
152 152
             </div>
153 153
         </div>
154 154
     </div>
155 155
 </div>
156
-<?php wp_nonce_field( 'wpinv_save_invoice', 'wpinv_save_invoice' ) ;?>
156
+<?php wp_nonce_field('wpinv_save_invoice', 'wpinv_save_invoice'); ?>
157 157
 <?php
158 158
     }
159 159
 }
Please login to merge, or discard this patch.