Passed
Push — master ( 3a0618...5aee45 )
by Stiofan
05:13
created
includes/admin/admin-pages.php 1 patch
Spacing   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-add_action( 'manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column' );
8
-function wpinv_discount_custom_column( $column ) {
7
+add_action('manage_wpi_discount_posts_custom_column', 'wpinv_discount_custom_column');
8
+function wpinv_discount_custom_column($column) {
9 9
     global $post;
10 10
 
11
-    $discount = new WPInv_Discount( $post );
11
+    $discount = new WPInv_Discount($post);
12 12
 
13
-    switch ( $column ) {
13
+    switch ($column) {
14 14
         case 'code' :
15 15
             echo $discount->get_code();
16 16
         break;
@@ -21,33 +21,33 @@  discard block
 block discarded – undo
21 21
             echo $discount->get_usage();
22 22
         break;
23 23
         case 'start_date' :
24
-            echo getpaid_format_date_value( $discount->get_start_date() );
24
+            echo getpaid_format_date_value($discount->get_start_date());
25 25
         break;
26 26
         case 'expiry_date' :
27
-            echo getpaid_format_date_value( $discount->get_expiration_date(), __( 'Never', 'invoicing' ) );
27
+            echo getpaid_format_date_value($discount->get_expiration_date(), __('Never', 'invoicing'));
28 28
         break;
29 29
     }
30 30
 }
31 31
 
32
-add_filter( 'post_row_actions', 'wpinv_post_row_actions', 90, 2 );
33
-function wpinv_post_row_actions( $actions, $post ) {
34
-    $post_type = !empty( $post->post_type ) ? $post->post_type : '';
32
+add_filter('post_row_actions', 'wpinv_post_row_actions', 90, 2);
33
+function wpinv_post_row_actions($actions, $post) {
34
+    $post_type = !empty($post->post_type) ? $post->post_type : '';
35 35
 
36
-    if ( $post_type == 'wpi_discount' ) {
37
-        $actions = wpinv_discount_row_actions( $post, $actions );
36
+    if ($post_type == 'wpi_discount') {
37
+        $actions = wpinv_discount_row_actions($post, $actions);
38 38
     }
39 39
 
40 40
     return $actions;
41 41
 }
42 42
 
43
-function wpinv_discount_row_actions( $discount, $row_actions ) {
44
-    $row_actions  = array();
45
-    $edit_link = get_edit_post_link( $discount->ID );
46
-    $row_actions['edit'] = '<a href="' . esc_url( $edit_link ) . '">' . __( 'Edit', 'invoicing' ) . '</a>';
43
+function wpinv_discount_row_actions($discount, $row_actions) {
44
+    $row_actions = array();
45
+    $edit_link = get_edit_post_link($discount->ID);
46
+    $row_actions['edit'] = '<a href="' . esc_url($edit_link) . '">' . __('Edit', 'invoicing') . '</a>';
47 47
 
48
-    if ( in_array( strtolower( $discount->post_status ),  array(  'publish' ) ) ) {
48
+    if (in_array(strtolower($discount->post_status), array('publish'))) {
49 49
 
50
-        $url    = esc_url(
50
+        $url = esc_url(
51 51
                     wp_nonce_url(
52 52
                         add_query_arg(
53 53
                             array(
@@ -59,13 +59,13 @@  discard block
 block discarded – undo
59 59
                         'getpaid-nonce'
60 60
                     )
61 61
                 );
62
-		$anchor = __( 'Deactivate', 'invoicing' );
63
-		$title  = esc_attr__( 'Are you sure you want to deactivate this discount?', 'invoicing' );
62
+		$anchor = __('Deactivate', 'invoicing');
63
+		$title  = esc_attr__('Are you sure you want to deactivate this discount?', 'invoicing');
64 64
         $row_actions['deactivate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
65 65
 
66
-    } else if( in_array( strtolower( $discount->post_status ),  array( 'pending', 'draft' ) ) ) {
66
+    } else if (in_array(strtolower($discount->post_status), array('pending', 'draft'))) {
67 67
 
68
-        $url    = esc_url(
68
+        $url = esc_url(
69 69
             wp_nonce_url(
70 70
                 add_query_arg(
71 71
                     array(
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
                 'getpaid-nonce'
78 78
             )
79 79
         );
80
-		$anchor = __( 'Activate', 'invoicing' );
81
-		$title  = esc_attr__( 'Are you sure you want to activate this discount?', 'invoicing' );
80
+		$anchor = __('Activate', 'invoicing');
81
+		$title  = esc_attr__('Are you sure you want to activate this discount?', 'invoicing');
82 82
         $row_actions['activate'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
83 83
 
84 84
     }
85 85
 
86
-    $url    = esc_url(
86
+    $url = esc_url(
87 87
         wp_nonce_url(
88 88
             add_query_arg(
89 89
                 array(
@@ -95,11 +95,11 @@  discard block
 block discarded – undo
95 95
             'getpaid-nonce'
96 96
         )
97 97
     );
98
-	$anchor = __( 'Delete', 'invoicing' );
99
-	$title  = esc_attr__( 'Are you sure you want to delete this discount?', 'invoicing' );
98
+	$anchor = __('Delete', 'invoicing');
99
+	$title  = esc_attr__('Are you sure you want to delete this discount?', 'invoicing');
100 100
     $row_actions['delete'] = "<a href='$url' onclick='return confirm(\"$title\")'>$anchor</a>";
101 101
 
102
-    $row_actions = apply_filters( 'wpinv_discount_row_actions', $row_actions, $discount );
102
+    $row_actions = apply_filters('wpinv_discount_row_actions', $row_actions, $discount);
103 103
 
104 104
     return $row_actions;
105 105
 }
@@ -107,68 +107,68 @@  discard block
 block discarded – undo
107 107
 function wpinv_restrict_manage_posts() {
108 108
     global $typenow;
109 109
 
110
-    if( 'wpi_discount' == $typenow ) {
110
+    if ('wpi_discount' == $typenow) {
111 111
         wpinv_discount_filters();
112 112
     }
113 113
 }
114
-add_action( 'restrict_manage_posts', 'wpinv_restrict_manage_posts', 10 );
114
+add_action('restrict_manage_posts', 'wpinv_restrict_manage_posts', 10);
115 115
 
116 116
 function wpinv_discount_filters() {
117 117
 
118 118
     ?>
119 119
     <select name="discount_type" id="dropdown_wpinv_discount_type">
120
-        <option value=""><?php _e( 'Show all types', 'invoicing' ); ?></option>
120
+        <option value=""><?php _e('Show all types', 'invoicing'); ?></option>
121 121
         <?php
122 122
             $types = wpinv_get_discount_types();
123 123
 
124
-            foreach ( $types as $name => $type ) {
125
-                echo '<option value="' . esc_attr( $name ) . '"';
124
+            foreach ($types as $name => $type) {
125
+                echo '<option value="' . esc_attr($name) . '"';
126 126
 
127
-                if ( isset( $_GET['discount_type'] ) )
128
-                    selected( $name, $_GET['discount_type'] );
127
+                if (isset($_GET['discount_type']))
128
+                    selected($name, $_GET['discount_type']);
129 129
 
130
-                echo '>' . esc_html__( $type, 'invoicing' ) . '</option>';
130
+                echo '>' . esc_html__($type, 'invoicing') . '</option>';
131 131
             }
132 132
         ?>
133 133
     </select>
134 134
     <?php
135 135
 }
136 136
 
137
-function wpinv_request( $vars ) {
137
+function wpinv_request($vars) {
138 138
     global $typenow, $wp_post_statuses;
139 139
 
140
-    if ( getpaid_is_invoice_post_type( $typenow ) ) {
141
-        if ( ! isset( $vars['post_status'] ) ) {
142
-            $post_statuses = wpinv_get_invoice_statuses( false, false, $typenow );
140
+    if (getpaid_is_invoice_post_type($typenow)) {
141
+        if (!isset($vars['post_status'])) {
142
+            $post_statuses = wpinv_get_invoice_statuses(false, false, $typenow);
143 143
 
144
-            foreach ( $post_statuses as $status => $value ) {
145
-                if ( isset( $wp_post_statuses[ $status ] ) && false === $wp_post_statuses[ $status ]->show_in_admin_all_list ) {
146
-                    unset( $post_statuses[ $status ] );
144
+            foreach ($post_statuses as $status => $value) {
145
+                if (isset($wp_post_statuses[$status]) && false === $wp_post_statuses[$status]->show_in_admin_all_list) {
146
+                    unset($post_statuses[$status]);
147 147
                 }
148 148
             }
149 149
 
150
-            $vars['post_status'] = array_keys( $post_statuses );
150
+            $vars['post_status'] = array_keys($post_statuses);
151 151
         }
152 152
 
153
-    } else if ( 'wpi_discount' == $typenow ) {
154
-        $meta_query = !empty( $vars['meta_query'] ) ? $vars['meta_query'] : array();
153
+    } else if ('wpi_discount' == $typenow) {
154
+        $meta_query = !empty($vars['meta_query']) ? $vars['meta_query'] : array();
155 155
         // Filter vat rule type
156
-        if ( isset( $_GET['discount_type'] ) && $_GET['discount_type'] !== '' ) {
156
+        if (isset($_GET['discount_type']) && $_GET['discount_type'] !== '') {
157 157
             $meta_query[] = array(
158 158
                     'key'   => '_wpi_discount_type',
159
-                    'value' => sanitize_text_field( $_GET['discount_type'] ),
159
+                    'value' => sanitize_text_field($_GET['discount_type']),
160 160
                     'compare' => '='
161 161
                 );
162 162
         }
163 163
 
164
-        if ( !empty( $meta_query ) ) {
164
+        if (!empty($meta_query)) {
165 165
             $vars['meta_query'] = $meta_query;
166 166
         }
167 167
     }
168 168
 
169 169
     return $vars;
170 170
 }
171
-add_filter( 'request', 'wpinv_request' );
171
+add_filter('request', 'wpinv_request');
172 172
 
173 173
 /**
174 174
  * Create a page and store the ID in an option.
@@ -180,19 +180,19 @@  discard block
 block discarded – undo
180 180
  * @param int $post_parent (default: 0) Parent for the new page
181 181
  * @return int page ID
182 182
  */
183
-function wpinv_create_page( $slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0 ) {
183
+function wpinv_create_page($slug, $option = '', $page_title = '', $page_content = '', $post_parent = 0) {
184 184
     global $wpdb;
185 185
 
186
-    $option_value = wpinv_get_option( $option );
186
+    $option_value = wpinv_get_option($option);
187 187
 
188
-    if ( ! empty( $option_value ) && ( $page_object = get_post( $option_value ) ) ) {
189
-        if ( 'page' === $page_object->post_type && ! in_array( $page_object->post_status, array( 'pending', 'trash', 'future', 'auto-draft' ) ) ) {
188
+    if (!empty($option_value) && ($page_object = get_post($option_value))) {
189
+        if ('page' === $page_object->post_type && !in_array($page_object->post_status, array('pending', 'trash', 'future', 'auto-draft'))) {
190 190
             // Valid page is already in place
191 191
             return $page_object->ID;
192 192
         }
193 193
     }
194 194
 
195
-    if(!empty($post_parent)){
195
+    if (!empty($post_parent)) {
196 196
         $page = get_page_by_path($post_parent);
197 197
         if ($page) {
198 198
             $post_parent = $page->ID;
@@ -201,40 +201,40 @@  discard block
 block discarded – undo
201 201
         }
202 202
     }
203 203
 
204
-    if ( strlen( $page_content ) > 0 ) {
204
+    if (strlen($page_content) > 0) {
205 205
         // Search for an existing page with the specified page content (typically a shortcode)
206
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
206
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
207 207
     } else {
208 208
         // Search for an existing page with the specified page slug
209
-        $valid_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug ) );
209
+        $valid_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' )  AND post_name = %s LIMIT 1;", $slug));
210 210
     }
211 211
 
212
-    $valid_page_found = apply_filters( 'wpinv_create_page_id', $valid_page_found, $slug, $page_content );
212
+    $valid_page_found = apply_filters('wpinv_create_page_id', $valid_page_found, $slug, $page_content);
213 213
 
214
-    if ( $valid_page_found ) {
215
-        if ( $option ) {
216
-            wpinv_update_option( $option, $valid_page_found );
214
+    if ($valid_page_found) {
215
+        if ($option) {
216
+            wpinv_update_option($option, $valid_page_found);
217 217
         }
218 218
         return $valid_page_found;
219 219
     }
220 220
 
221 221
     // Search for a matching valid trashed page
222
-    if ( strlen( $page_content ) > 0 ) {
222
+    if (strlen($page_content) > 0) {
223 223
         // Search for an existing page with the specified page content (typically a shortcode)
224
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%" ) );
224
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_content LIKE %s LIMIT 1;", "%{$page_content}%"));
225 225
     } else {
226 226
         // Search for an existing page with the specified page slug
227
-        $trashed_page_found = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug ) );
227
+        $trashed_page_found = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status = 'trash' AND post_name = %s LIMIT 1;", $slug));
228 228
     }
229 229
 
230
-    if ( $trashed_page_found ) {
230
+    if ($trashed_page_found) {
231 231
         $page_id   = $trashed_page_found;
232 232
         $page_data = array(
233 233
             'ID'             => $page_id,
234 234
             'post_status'    => 'publish',
235 235
             'post_parent'    => $post_parent,
236 236
         );
237
-        wp_update_post( $page_data );
237
+        wp_update_post($page_data);
238 238
     } else {
239 239
         $page_data = array(
240 240
             'post_status'    => 'publish',
@@ -246,11 +246,11 @@  discard block
 block discarded – undo
246 246
             'post_parent'    => $post_parent,
247 247
             'comment_status' => 'closed',
248 248
         );
249
-        $page_id = wp_insert_post( $page_data );
249
+        $page_id = wp_insert_post($page_data);
250 250
     }
251 251
 
252
-    if ( $option ) {
253
-        wpinv_update_option( $option, (int) $page_id );
252
+    if ($option) {
253
+        wpinv_update_option($option, (int) $page_id);
254 254
     }
255 255
 
256 256
     return $page_id;
@@ -263,11 +263,11 @@  discard block
 block discarded – undo
263 263
  *
264 264
  * @return array
265 265
  */
266
-function wpinv_add_aui_screens($screen_ids){
266
+function wpinv_add_aui_screens($screen_ids) {
267 267
 
268 268
     // load on these pages if set
269
-    $screen_ids = array_merge( $screen_ids, wpinv_get_screen_ids() );
269
+    $screen_ids = array_merge($screen_ids, wpinv_get_screen_ids());
270 270
 
271 271
     return $screen_ids;
272 272
 }
273
-add_filter('aui_screen_ids','wpinv_add_aui_screens');
274 273
\ No newline at end of file
274
+add_filter('aui_screen_ids', 'wpinv_add_aui_screens');
275 275
\ No newline at end of file
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Spacing   +259 added lines, -259 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
  
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Are we supporting item quantities?
@@ -20,35 +20,35 @@  discard block
 block discarded – undo
20 20
  */
21 21
 function wpinv_get_ip() {
22 22
 
23
-    if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) {
24
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) );
23
+    if (isset($_SERVER['HTTP_X_REAL_IP'])) {
24
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP']));
25 25
     }
26 26
 
27
-    if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
27
+    if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
28 28
         // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2
29 29
         // Make sure we always only send through the first IP in the list which should always be the client IP.
30
-        return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) );
30
+        return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR']))))));
31 31
     }
32 32
 
33
-    if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) {
34
-        return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) );
33
+    if (isset($_SERVER['HTTP_CLIENT_IP'])) {
34
+        return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP']));
35 35
     }
36 36
 
37
-    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
38
-        return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
37
+    if (isset($_SERVER['REMOTE_ADDR'])) {
38
+        return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR']));
39 39
     }
40 40
 
41 41
     return '';
42 42
 }
43 43
 
44 44
 function wpinv_get_user_agent() {
45
-    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
46
-        $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] );
45
+    if (!empty($_SERVER['HTTP_USER_AGENT'])) {
46
+        $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']);
47 47
     } else {
48 48
         $user_agent = '';
49 49
     }
50 50
 
51
-    return apply_filters( 'wpinv_get_user_agent', $user_agent );
51
+    return apply_filters('wpinv_get_user_agent', $user_agent);
52 52
 }
53 53
 
54 54
 /**
@@ -56,23 +56,23 @@  discard block
 block discarded – undo
56 56
  * 
57 57
  * @param string $amount The amount to sanitize.
58 58
  */
59
-function wpinv_sanitize_amount( $amount ) {
59
+function wpinv_sanitize_amount($amount) {
60 60
 
61
-    if ( is_numeric( $amount ) ) {
62
-        return floatval( $amount );
61
+    if (is_numeric($amount)) {
62
+        return floatval($amount);
63 63
     }
64 64
 
65 65
     // Separate the decimals and thousands.
66
-    $amount    = explode( wpinv_decimal_separator(), $amount );
66
+    $amount    = explode(wpinv_decimal_separator(), $amount);
67 67
 
68 68
     // Remove thousands.
69
-    $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] );
69
+    $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]);
70 70
 
71 71
     // Convert back to string.
72
-    $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
72
+    $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0];
73 73
 
74 74
     // Cast the remaining to a float.
75
-    return (float) preg_replace( '/[^0-9\.\-]/', '', $amount );
75
+    return (float) preg_replace('/[^0-9\.\-]/', '', $amount);
76 76
 
77 77
 }
78 78
 
@@ -82,19 +82,19 @@  discard block
 block discarded – undo
82 82
  * @param float $amount
83 83
  * @param float|string|int|null $decimals
84 84
  */
85
-function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) {
85
+function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) {
86 86
 
87
-    if ( $decimals === null ) {
87
+    if ($decimals === null) {
88 88
         $decimals = wpinv_decimals();
89 89
     }
90 90
 
91
-    if ( $use_sprintf ) {
92
-        $amount = sprintf( "%.{$decimals}f", (float) $amount );
91
+    if ($use_sprintf) {
92
+        $amount = sprintf("%.{$decimals}f", (float) $amount);
93 93
     } else {
94
-        $amount = round( (float) $amount, absint( $decimals ) );
94
+        $amount = round((float) $amount, absint($decimals));
95 95
     }
96 96
 
97
-    return apply_filters( 'wpinv_round_amount', $amount, $decimals );
97
+    return apply_filters('wpinv_round_amount', $amount, $decimals);
98 98
 }
99 99
 
100 100
 /**
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
107 107
  * @return array
108 108
  */
109
-function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
109
+function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) {
110 110
 
111 111
 	$invoice_statuses = array(
112
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
113
-        'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
114
-        'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
115
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
116
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
117
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
118
-        'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
119
-        'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
112
+		'wpi-pending'    => _x('Pending payment', 'Invoice status', 'invoicing'),
113
+        'publish'        => _x('Paid', 'Invoice status', 'invoicing'),
114
+        'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'),
115
+		'wpi-onhold'     => _x('On hold', 'Invoice status', 'invoicing'),
116
+		'wpi-cancelled'  => _x('Cancelled', 'Invoice status', 'invoicing'),
117
+		'wpi-refunded'   => _x('Refunded', 'Invoice status', 'invoicing'),
118
+        'wpi-failed'     => _x('Failed', 'Invoice status', 'invoicing'),
119
+        'wpi-renewal'    => _x('Renewal Payment', 'Invoice status', 'invoicing'),
120 120
     );
121 121
 
122
-    if ( $draft ) {
123
-        $invoice_statuses['draft'] = __( 'Draft', 'invoicing' );
122
+    if ($draft) {
123
+        $invoice_statuses['draft'] = __('Draft', 'invoicing');
124 124
     }
125 125
 
126
-    if ( $trashed ) {
127
-        $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
126
+    if ($trashed) {
127
+        $invoice_statuses['trash'] = __('Trash', 'invoicing');
128 128
     }
129 129
 
130
-    if ( $invoice instanceof WPInv_Invoice ) {
130
+    if ($invoice instanceof WPInv_Invoice) {
131 131
         $invoice = $invoice->get_post_type();
132 132
     }
133 133
 
134
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
134
+	return apply_filters('wpinv_statuses', $invoice_statuses, $invoice);
135 135
 }
136 136
 
137 137
 /**
@@ -140,11 +140,11 @@  discard block
 block discarded – undo
140 140
  * @param string $status The raw status
141 141
  * @param string|WPInv_Invoice $invoice The invoice object|post type|type
142 142
  */
143
-function wpinv_status_nicename( $status, $invoice = false ) {
144
-    $statuses = wpinv_get_invoice_statuses( true, true, $invoice );
145
-    $status   = isset( $statuses[$status] ) ? $statuses[$status] : $status;
143
+function wpinv_status_nicename($status, $invoice = false) {
144
+    $statuses = wpinv_get_invoice_statuses(true, true, $invoice);
145
+    $status   = isset($statuses[$status]) ? $statuses[$status] : $status;
146 146
 
147
-    return sanitize_text_field( $status );
147
+    return sanitize_text_field($status);
148 148
 }
149 149
 
150 150
 /**
@@ -152,13 +152,13 @@  discard block
 block discarded – undo
152 152
  * 
153 153
  * @param string $current
154 154
  */
155
-function wpinv_get_currency( $current = '' ) {
155
+function wpinv_get_currency($current = '') {
156 156
 
157
-    if ( empty( $current ) ) {
158
-        $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) );
157
+    if (empty($current)) {
158
+        $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD'));
159 159
     }
160 160
 
161
-    return trim( strtoupper( $current ) );
161
+    return trim(strtoupper($current));
162 162
 }
163 163
 
164 164
 /**
@@ -166,25 +166,25 @@  discard block
 block discarded – undo
166 166
  * 
167 167
  * @param string|null $currency The currency code. Defaults to the default currency.
168 168
  */
169
-function wpinv_currency_symbol( $currency = null ) {
169
+function wpinv_currency_symbol($currency = null) {
170 170
 
171 171
     // Prepare the currency.
172
-    $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency );
172
+    $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency);
173 173
 
174 174
     // Fetch all symbols.
175 175
     $symbols = wpinv_get_currency_symbols();
176 176
 
177 177
     // Fetch this currencies symbol.
178
-    $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency;
178
+    $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency;
179 179
 
180 180
     // Filter the symbol.
181
-    return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency );
181
+    return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency);
182 182
 }
183 183
 
184 184
 function wpinv_currency_position() {
185
-    $position = wpinv_get_option( 'currency_position', 'left' );
185
+    $position = wpinv_get_option('currency_position', 'left');
186 186
     
187
-    return apply_filters( 'wpinv_currency_position', $position );
187
+    return apply_filters('wpinv_currency_position', $position);
188 188
 }
189 189
 
190 190
 /**
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
  * 
193 193
  * @param $string|null $current
194 194
  */
195
-function wpinv_thousands_separator( $current = null ) {
195
+function wpinv_thousands_separator($current = null) {
196 196
 
197
-    if ( null == $current ) {
198
-        $current = wpinv_get_option( 'thousands_separator', ',' );
197
+    if (null == $current) {
198
+        $current = wpinv_get_option('thousands_separator', ',');
199 199
     }
200 200
 
201
-    return trim( $current );
201
+    return trim($current);
202 202
 }
203 203
 
204 204
 /**
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
  * 
207 207
  * @param $string|null $current
208 208
  */
209
-function wpinv_decimal_separator( $current = null ) {
209
+function wpinv_decimal_separator($current = null) {
210 210
 
211
-    if ( null == $current ) {
212
-        $current = wpinv_get_option( 'decimal_separator', '.' );
211
+    if (null == $current) {
212
+        $current = wpinv_get_option('decimal_separator', '.');
213 213
     }
214 214
     
215
-    return trim( $current );
215
+    return trim($current);
216 216
 }
217 217
 
218 218
 /**
@@ -220,27 +220,27 @@  discard block
 block discarded – undo
220 220
  * 
221 221
  * @param $string|null $current
222 222
  */
223
-function wpinv_decimals( $current = null ) {
223
+function wpinv_decimals($current = null) {
224 224
 
225
-    if ( null == $current ) {
226
-        $current = wpinv_get_option( 'decimals', 2 );
225
+    if (null == $current) {
226
+        $current = wpinv_get_option('decimals', 2);
227 227
     }
228 228
     
229
-    return absint( $current );
229
+    return absint($current);
230 230
 }
231 231
 
232 232
 /**
233 233
  * Retrieves a list of all supported currencies.
234 234
  */
235 235
 function wpinv_get_currencies() {
236
-    return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) );
236
+    return apply_filters('wpinv_currencies', wpinv_get_data('currencies'));
237 237
 }
238 238
 
239 239
 /**
240 240
  * Retrieves a list of all currency symbols.
241 241
  */
242 242
 function wpinv_get_currency_symbols() {
243
-    return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) );
243
+    return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols'));
244 244
 }
245 245
 
246 246
 /**
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 	$currency_pos = wpinv_currency_position();
253 253
 	$format       = '%1$s%2$s';
254 254
 
255
-	switch ( $currency_pos ) {
255
+	switch ($currency_pos) {
256 256
 		case 'left':
257 257
 			$format = '%1$s%2$s';
258 258
 			break;
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 			break;
268 268
 	}
269 269
 
270
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
270
+	return apply_filters('getpaid_price_format', $format, $currency_pos);
271 271
 }
272 272
 
273 273
 /**
@@ -277,25 +277,25 @@  discard block
 block discarded – undo
277 277
  * @param  string $currency Currency.
278 278
  * @return string
279 279
  */
280
-function wpinv_price( $amount = 0, $currency = '' ) {
280
+function wpinv_price($amount = 0, $currency = '') {
281 281
 
282 282
     // Backwards compatibility.
283
-    $amount             = wpinv_sanitize_amount( $amount );
283
+    $amount             = wpinv_sanitize_amount($amount);
284 284
 
285 285
     // Prepare variables.
286
-    $currency           = wpinv_get_currency( $currency );
286
+    $currency           = wpinv_get_currency($currency);
287 287
     $amount             = (float) $amount;
288 288
     $unformatted_amount = $amount;
289 289
     $negative           = $amount < 0;
290
-    $amount             = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) );
291
-    $amount             = wpinv_format_amount( $amount );
290
+    $amount             = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount));
291
+    $amount             = wpinv_format_amount($amount);
292 292
 
293 293
     // Format the amount.
294 294
     $format             = getpaid_get_price_format();
295
-    $formatted_amount   = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount );
295
+    $formatted_amount   = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount);
296 296
 
297 297
     // Filter the formatting.
298
-    return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount );
298
+    return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount);
299 299
 }
300 300
 
301 301
 /**
@@ -306,25 +306,25 @@  discard block
 block discarded – undo
306 306
  * @param  bool     $calculate Whether or not to apply separators.
307 307
  * @return string
308 308
  */
309
-function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) {
309
+function wpinv_format_amount($amount, $decimals = null, $calculate = false) {
310 310
     $thousands_sep = wpinv_thousands_separator();
311 311
     $decimal_sep   = wpinv_decimal_separator();
312
-    $decimals      = wpinv_decimals( $decimals );
313
-    $amount        = wpinv_sanitize_amount( $amount );
312
+    $decimals      = wpinv_decimals($decimals);
313
+    $amount        = wpinv_sanitize_amount($amount);
314 314
 
315
-    if ( $calculate ) {
315
+    if ($calculate) {
316 316
         return $amount;
317 317
     }
318 318
 
319 319
     // Fomart the amount.
320
-    return number_format( $amount, $decimals, $decimal_sep, $thousands_sep );
320
+    return number_format($amount, $decimals, $decimal_sep, $thousands_sep);
321 321
 }
322 322
 
323
-function wpinv_sanitize_key( $key ) {
323
+function wpinv_sanitize_key($key) {
324 324
     $raw_key = $key;
325
-    $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
325
+    $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key);
326 326
 
327
-    return apply_filters( 'wpinv_sanitize_key', $key, $raw_key );
327
+    return apply_filters('wpinv_sanitize_key', $key, $raw_key);
328 328
 }
329 329
 
330 330
 /**
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
  * 
333 333
  * @param $str the file whose extension should be retrieved.
334 334
  */
335
-function wpinv_get_file_extension( $str ) {
336
-    $filetype = wp_check_filetype( $str );
335
+function wpinv_get_file_extension($str) {
336
+    $filetype = wp_check_filetype($str);
337 337
     return $filetype['ext'];
338 338
 }
339 339
 
@@ -342,16 +342,16 @@  discard block
 block discarded – undo
342 342
  * 
343 343
  * @param string $string
344 344
  */
345
-function wpinv_string_is_image_url( $string ) {
346
-    $extension = strtolower( wpinv_get_file_extension( $string ) );
347
-    return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true );
345
+function wpinv_string_is_image_url($string) {
346
+    $extension = strtolower(wpinv_get_file_extension($string));
347
+    return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true);
348 348
 }
349 349
 
350 350
 /**
351 351
  * Returns the current URL.
352 352
  */
353 353
 function wpinv_get_current_page_url() {
354
-    return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
354
+    return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
355 355
 }
356 356
 
357 357
 /**
@@ -361,46 +361,46 @@  discard block
 block discarded – undo
361 361
  * @param string $name  Constant name.
362 362
  * @param mixed  $value Value.
363 363
  */
364
-function getpaid_maybe_define_constant( $name, $value ) {
365
-	if ( ! defined( $name ) ) {
366
-		define( $name, $value );
364
+function getpaid_maybe_define_constant($name, $value) {
365
+	if (!defined($name)) {
366
+		define($name, $value);
367 367
 	}
368 368
 }
369 369
 
370 370
 function wpinv_get_php_arg_separator_output() {
371
-	return ini_get( 'arg_separator.output' );
371
+	return ini_get('arg_separator.output');
372 372
 }
373 373
 
374
-function wpinv_rgb_from_hex( $color ) {
375
-    $color = str_replace( '#', '', $color );
374
+function wpinv_rgb_from_hex($color) {
375
+    $color = str_replace('#', '', $color);
376 376
 
377 377
     // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF"
378
-    $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color );
379
-    if ( empty( $color ) ) {
378
+    $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color);
379
+    if (empty($color)) {
380 380
         return NULL;
381 381
     }
382 382
 
383
-    $color = str_split( $color );
383
+    $color = str_split($color);
384 384
 
385 385
     $rgb      = array();
386
-    $rgb['R'] = hexdec( $color[0] . $color[1] );
387
-    $rgb['G'] = hexdec( $color[2] . $color[3] );
388
-    $rgb['B'] = hexdec( $color[4] . $color[5] );
386
+    $rgb['R'] = hexdec($color[0] . $color[1]);
387
+    $rgb['G'] = hexdec($color[2] . $color[3]);
388
+    $rgb['B'] = hexdec($color[4] . $color[5]);
389 389
 
390 390
     return $rgb;
391 391
 }
392 392
 
393
-function wpinv_hex_darker( $color, $factor = 30 ) {
394
-    $base  = wpinv_rgb_from_hex( $color );
393
+function wpinv_hex_darker($color, $factor = 30) {
394
+    $base  = wpinv_rgb_from_hex($color);
395 395
     $color = '#';
396 396
 
397
-    foreach ( $base as $k => $v ) {
397
+    foreach ($base as $k => $v) {
398 398
         $amount      = $v / 100;
399
-        $amount      = round( $amount * $factor );
399
+        $amount      = round($amount * $factor);
400 400
         $new_decimal = $v - $amount;
401 401
 
402
-        $new_hex_component = dechex( $new_decimal );
403
-        if ( strlen( $new_hex_component ) < 2 ) {
402
+        $new_hex_component = dechex($new_decimal);
403
+        if (strlen($new_hex_component) < 2) {
404 404
             $new_hex_component = "0" . $new_hex_component;
405 405
         }
406 406
         $color .= $new_hex_component;
@@ -409,18 +409,18 @@  discard block
 block discarded – undo
409 409
     return $color;
410 410
 }
411 411
 
412
-function wpinv_hex_lighter( $color, $factor = 30 ) {
413
-    $base  = wpinv_rgb_from_hex( $color );
412
+function wpinv_hex_lighter($color, $factor = 30) {
413
+    $base  = wpinv_rgb_from_hex($color);
414 414
     $color = '#';
415 415
 
416
-    foreach ( $base as $k => $v ) {
416
+    foreach ($base as $k => $v) {
417 417
         $amount      = 255 - $v;
418 418
         $amount      = $amount / 100;
419
-        $amount      = round( $amount * $factor );
419
+        $amount      = round($amount * $factor);
420 420
         $new_decimal = $v + $amount;
421 421
 
422
-        $new_hex_component = dechex( $new_decimal );
423
-        if ( strlen( $new_hex_component ) < 2 ) {
422
+        $new_hex_component = dechex($new_decimal);
423
+        if (strlen($new_hex_component) < 2) {
424 424
             $new_hex_component = "0" . $new_hex_component;
425 425
         }
426 426
         $color .= $new_hex_component;
@@ -429,22 +429,22 @@  discard block
 block discarded – undo
429 429
     return $color;
430 430
 }
431 431
 
432
-function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
433
-    $hex = str_replace( '#', '', $color );
432
+function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') {
433
+    $hex = str_replace('#', '', $color);
434 434
 
435
-    $c_r = hexdec( substr( $hex, 0, 2 ) );
436
-    $c_g = hexdec( substr( $hex, 2, 2 ) );
437
-    $c_b = hexdec( substr( $hex, 4, 2 ) );
435
+    $c_r = hexdec(substr($hex, 0, 2));
436
+    $c_g = hexdec(substr($hex, 2, 2));
437
+    $c_b = hexdec(substr($hex, 4, 2));
438 438
 
439
-    $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
439
+    $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000;
440 440
 
441 441
     return $brightness > 155 ? $dark : $light;
442 442
 }
443 443
 
444
-function wpinv_format_hex( $hex ) {
445
-    $hex = trim( str_replace( '#', '', $hex ) );
444
+function wpinv_format_hex($hex) {
445
+    $hex = trim(str_replace('#', '', $hex));
446 446
 
447
-    if ( strlen( $hex ) == 3 ) {
447
+    if (strlen($hex) == 3) {
448 448
         $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2];
449 449
     }
450 450
 
@@ -464,12 +464,12 @@  discard block
 block discarded – undo
464 464
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
465 465
  * @return string
466 466
  */
467
-function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) {
468
-    if ( function_exists( 'mb_strimwidth' ) ) {
469
-        return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding );
467
+function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') {
468
+    if (function_exists('mb_strimwidth')) {
469
+        return mb_strimwidth($str, $start, $width, $trimmaker, $encoding);
470 470
     }
471 471
     
472
-    return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker;
472
+    return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker;
473 473
 }
474 474
 
475 475
 /**
@@ -481,28 +481,28 @@  discard block
 block discarded – undo
481 481
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
482 482
  * @return int Returns the number of characters in string.
483 483
  */
484
-function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) {
485
-    if ( function_exists( 'mb_strlen' ) ) {
486
-        return mb_strlen( $str, $encoding );
484
+function wpinv_utf8_strlen($str, $encoding = 'UTF-8') {
485
+    if (function_exists('mb_strlen')) {
486
+        return mb_strlen($str, $encoding);
487 487
     }
488 488
         
489
-    return strlen( $str );
489
+    return strlen($str);
490 490
 }
491 491
 
492
-function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) {
493
-    if ( function_exists( 'mb_strtolower' ) ) {
494
-        return mb_strtolower( $str, $encoding );
492
+function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') {
493
+    if (function_exists('mb_strtolower')) {
494
+        return mb_strtolower($str, $encoding);
495 495
     }
496 496
     
497
-    return strtolower( $str );
497
+    return strtolower($str);
498 498
 }
499 499
 
500
-function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) {
501
-    if ( function_exists( 'mb_strtoupper' ) ) {
502
-        return mb_strtoupper( $str, $encoding );
500
+function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') {
501
+    if (function_exists('mb_strtoupper')) {
502
+        return mb_strtoupper($str, $encoding);
503 503
     }
504 504
     
505
-    return strtoupper( $str );
505
+    return strtoupper($str);
506 506
 }
507 507
 
508 508
 /**
@@ -516,12 +516,12 @@  discard block
 block discarded – undo
516 516
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
517 517
  * @return int Returns the position of the first occurrence of search in the string.
518 518
  */
519
-function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
520
-    if ( function_exists( 'mb_strpos' ) ) {
521
-        return mb_strpos( $str, $find, $offset, $encoding );
519
+function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
520
+    if (function_exists('mb_strpos')) {
521
+        return mb_strpos($str, $find, $offset, $encoding);
522 522
     }
523 523
         
524
-    return strpos( $str, $find, $offset );
524
+    return strpos($str, $find, $offset);
525 525
 }
526 526
 
527 527
 /**
@@ -535,12 +535,12 @@  discard block
 block discarded – undo
535 535
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
536 536
  * @return int Returns the position of the last occurrence of search.
537 537
  */
538
-function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) {
539
-    if ( function_exists( 'mb_strrpos' ) ) {
540
-        return mb_strrpos( $str, $find, $offset, $encoding );
538
+function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') {
539
+    if (function_exists('mb_strrpos')) {
540
+        return mb_strrpos($str, $find, $offset, $encoding);
541 541
     }
542 542
         
543
-    return strrpos( $str, $find, $offset );
543
+    return strrpos($str, $find, $offset);
544 544
 }
545 545
 
546 546
 /**
@@ -555,16 +555,16 @@  discard block
 block discarded – undo
555 555
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
556 556
  * @return string
557 557
  */
558
-function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) {
559
-    if ( function_exists( 'mb_substr' ) ) {
560
-        if ( $length === null ) {
561
-            return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding );
558
+function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') {
559
+    if (function_exists('mb_substr')) {
560
+        if ($length === null) {
561
+            return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding);
562 562
         } else {
563
-            return mb_substr( $str, $start, $length, $encoding );
563
+            return mb_substr($str, $start, $length, $encoding);
564 564
         }
565 565
     }
566 566
         
567
-    return substr( $str, $start, $length );
567
+    return substr($str, $start, $length);
568 568
 }
569 569
 
570 570
 /**
@@ -576,48 +576,48 @@  discard block
 block discarded – undo
576 576
  * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8".
577 577
  * @return string The width of string.
578 578
  */
579
-function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) {
580
-    if ( function_exists( 'mb_strwidth' ) ) {
581
-        return mb_strwidth( $str, $encoding );
579
+function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') {
580
+    if (function_exists('mb_strwidth')) {
581
+        return mb_strwidth($str, $encoding);
582 582
     }
583 583
     
584
-    return wpinv_utf8_strlen( $str, $encoding );
584
+    return wpinv_utf8_strlen($str, $encoding);
585 585
 }
586 586
 
587
-function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) {
588
-    if ( function_exists( 'mb_strlen' ) ) {
589
-        $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding );
587
+function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') {
588
+    if (function_exists('mb_strlen')) {
589
+        $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding);
590 590
         $str_end = "";
591 591
         
592
-        if ( $lower_str_end ) {
593
-            $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding );
592
+        if ($lower_str_end) {
593
+            $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding);
594 594
         } else {
595
-            $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding );
595
+            $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding);
596 596
         }
597 597
 
598 598
         return $first_letter . $str_end;
599 599
     }
600 600
     
601
-    return ucfirst( $str );
601
+    return ucfirst($str);
602 602
 }
603 603
 
604
-function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) {
605
-    if ( function_exists( 'mb_convert_case' ) ) {
606
-        return mb_convert_case( $str, MB_CASE_TITLE, $encoding );
604
+function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') {
605
+    if (function_exists('mb_convert_case')) {
606
+        return mb_convert_case($str, MB_CASE_TITLE, $encoding);
607 607
     }
608 608
     
609
-    return ucwords( $str );
609
+    return ucwords($str);
610 610
 }
611 611
 
612
-function wpinv_period_in_days( $period, $unit ) {
613
-    $period = absint( $period );
612
+function wpinv_period_in_days($period, $unit) {
613
+    $period = absint($period);
614 614
     
615
-    if ( $period > 0 ) {
616
-        if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) {
615
+    if ($period > 0) {
616
+        if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) {
617 617
             $period = $period * 7;
618
-        } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) {
618
+        } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) {
619 619
             $period = $period * 30;
620
-        } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) {
620
+        } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) {
621 621
             $period = $period * 365;
622 622
         }
623 623
     }
@@ -625,14 +625,14 @@  discard block
 block discarded – undo
625 625
     return $period;
626 626
 }
627 627
 
628
-function wpinv_cal_days_in_month( $calendar, $month, $year ) {
629
-    if ( function_exists( 'cal_days_in_month' ) ) {
630
-        return cal_days_in_month( $calendar, $month, $year );
628
+function wpinv_cal_days_in_month($calendar, $month, $year) {
629
+    if (function_exists('cal_days_in_month')) {
630
+        return cal_days_in_month($calendar, $month, $year);
631 631
     }
632 632
 
633 633
     // Fallback in case the calendar extension is not loaded in PHP
634 634
     // Only supports Gregorian calendar
635
-    return date( 't', mktime( 0, 0, 0, $month, 1, $year ) );
635
+    return date('t', mktime(0, 0, 0, $month, 1, $year));
636 636
 }
637 637
 
638 638
 /**
@@ -643,12 +643,12 @@  discard block
 block discarded – undo
643 643
  *
644 644
  * @return string
645 645
  */
646
-function wpi_help_tip( $tip, $allow_html = false ) {
646
+function wpi_help_tip($tip, $allow_html = false) {
647 647
 
648
-    if ( $allow_html ) {
649
-        $tip = wpi_sanitize_tooltip( $tip );
648
+    if ($allow_html) {
649
+        $tip = wpi_sanitize_tooltip($tip);
650 650
     } else {
651
-        $tip = esc_attr( $tip );
651
+        $tip = esc_attr($tip);
652 652
     }
653 653
 
654 654
     return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
  * @param string $var
663 663
  * @return string
664 664
  */
665
-function wpi_sanitize_tooltip( $var ) {
666
-    return wp_kses( html_entity_decode( $var ), array(
665
+function wpi_sanitize_tooltip($var) {
666
+    return wp_kses(html_entity_decode($var), array(
667 667
         'br'     => array(),
668 668
         'em'     => array(),
669 669
         'strong' => array(),
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         'li'     => array(),
675 675
         'ol'     => array(),
676 676
         'p'      => array(),
677
-    ) );
677
+    ));
678 678
 }
679 679
 
680 680
 /**
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
  */
685 685
 function wpinv_get_screen_ids() {
686 686
 
687
-    $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) );
687
+    $screen_id = sanitize_title(__('Invoicing', 'invoicing'));
688 688
 
689 689
     $screen_ids = array(
690 690
         'toplevel_page_' . $screen_id,
@@ -705,7 +705,7 @@  discard block
 block discarded – undo
705 705
         'getpaid_page_wpinv-customers',
706 706
     );
707 707
 
708
-    return apply_filters( 'wpinv_screen_ids', $screen_ids );
708
+    return apply_filters('wpinv_screen_ids', $screen_ids);
709 709
 }
710 710
 
711 711
 /**
@@ -716,14 +716,14 @@  discard block
 block discarded – undo
716 716
  * @param array|string $list List of values.
717 717
  * @return array Sanitized array of values.
718 718
  */
719
-function wpinv_parse_list( $list ) {
719
+function wpinv_parse_list($list) {
720 720
 
721
-    if ( empty( $list ) ) {
721
+    if (empty($list)) {
722 722
         $list = array();
723 723
     }
724 724
 
725
-	if ( ! is_array( $list ) ) {
726
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
725
+	if (!is_array($list)) {
726
+		return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY);
727 727
 	}
728 728
 
729 729
 	return $list;
@@ -737,16 +737,16 @@  discard block
 block discarded – undo
737 737
  * @param string $key Type of data to fetch.
738 738
  * @return mixed Fetched data.
739 739
  */
740
-function wpinv_get_data( $key ) {
740
+function wpinv_get_data($key) {
741 741
 
742 742
     // Try fetching it from the cache.
743
-    $data = wp_cache_get( "wpinv-data-$key", 'wpinv' );
744
-    if( $data ) {
743
+    $data = wp_cache_get("wpinv-data-$key", 'wpinv');
744
+    if ($data) {
745 745
         return $data;
746 746
     }
747 747
 
748
-    $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
749
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
748
+    $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php");
749
+	wp_cache_set("wpinv-data-$key", $data, 'wpinv');
750 750
 
751 751
 	return $data;
752 752
 }
@@ -760,10 +760,10 @@  discard block
 block discarded – undo
760 760
  * @param bool $first_empty Whether or not the first item in the list should be empty
761 761
  * @return mixed Fetched data.
762 762
  */
763
-function wpinv_maybe_add_empty_option( $options, $first_empty ) {
763
+function wpinv_maybe_add_empty_option($options, $first_empty) {
764 764
 
765
-    if ( ! empty( $options ) && $first_empty ) {
766
-        return array_merge( array( '' => '' ), $options );
765
+    if (!empty($options) && $first_empty) {
766
+        return array_merge(array('' => ''), $options);
767 767
     }
768 768
     return $options;
769 769
 
@@ -775,21 +775,21 @@  discard block
 block discarded – undo
775 775
  * @param mixed $var Data to sanitize.
776 776
  * @return string|array
777 777
  */
778
-function wpinv_clean( $var ) {
778
+function wpinv_clean($var) {
779 779
 
780
-	if ( is_array( $var ) ) {
781
-		return array_map( 'wpinv_clean', $var );
780
+	if (is_array($var)) {
781
+		return array_map('wpinv_clean', $var);
782 782
     }
783 783
 
784
-    if ( is_object( $var ) ) {
785
-		$object_vars = get_object_vars( $var );
786
-		foreach ( $object_vars as $property_name => $property_value ) {
787
-			$var->$property_name = wpinv_clean( $property_value );
784
+    if (is_object($var)) {
785
+		$object_vars = get_object_vars($var);
786
+		foreach ($object_vars as $property_name => $property_value) {
787
+			$var->$property_name = wpinv_clean($property_value);
788 788
         }
789 789
         return $var;
790 790
 	}
791 791
     
792
-    return is_string( $var ) ? sanitize_text_field( $var ) : $var;
792
+    return is_string($var) ? sanitize_text_field($var) : $var;
793 793
 }
794 794
 
795 795
 /**
@@ -798,43 +798,43 @@  discard block
 block discarded – undo
798 798
  * @param string $str Data to convert.
799 799
  * @return string|array
800 800
  */
801
-function getpaid_convert_price_string_to_options( $str ) {
801
+function getpaid_convert_price_string_to_options($str) {
802 802
 
803
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
804
-    $options     = array();
803
+	$raw_options = array_map('trim', explode(',', $str));
804
+    $options = array();
805 805
 
806
-    foreach ( $raw_options as $option ) {
806
+    foreach ($raw_options as $option) {
807 807
 
808
-        if ( '' == $option ) {
808
+        if ('' == $option) {
809 809
             continue;
810 810
         }
811 811
 
812
-        $option = array_map( 'trim', explode( '|', $option ) );
812
+        $option = array_map('trim', explode('|', $option));
813 813
 
814 814
         $price = null;
815 815
         $label = null;
816 816
 
817
-        if ( isset( $option[0] ) && '' !=  $option[0] ) {
818
-            $label  = $option[0];
817
+        if (isset($option[0]) && '' != $option[0]) {
818
+            $label = $option[0];
819 819
         }
820 820
 
821
-        if ( isset( $option[1] ) && '' !=  $option[1] ) {
821
+        if (isset($option[1]) && '' != $option[1]) {
822 822
             $price = $option[1];
823 823
         }
824 824
 
825
-        if ( ! isset( $price ) ) {
825
+        if (!isset($price)) {
826 826
             $price = $label;
827 827
         }
828 828
 
829
-        if ( ! isset( $price ) || ! is_numeric( $price ) ) {
829
+        if (!isset($price) || !is_numeric($price)) {
830 830
             continue;
831 831
         }
832 832
 
833
-        if ( ! isset( $label ) ) {
833
+        if (!isset($label)) {
834 834
             $label = $price;
835 835
         }
836 836
 
837
-        $options[ $price ] = $label;
837
+        $options[$price] = $label;
838 838
     }
839 839
 
840 840
     return $options;
@@ -843,27 +843,27 @@  discard block
 block discarded – undo
843 843
 /**
844 844
  * Returns the help tip.
845 845
  */
846
-function getpaid_get_help_tip( $tip, $additional_classes = '' ) {
847
-    $additional_classes = sanitize_html_class( $additional_classes );
848
-    $tip                = esc_attr__( $tip );
846
+function getpaid_get_help_tip($tip, $additional_classes = '') {
847
+    $additional_classes = sanitize_html_class($additional_classes);
848
+    $tip                = esc_attr__($tip);
849 849
     return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>";
850 850
 }
851 851
 
852 852
 /**
853 853
  * Formats a date
854 854
  */
855
-function getpaid_format_date( $date, $with_time = false ) {
855
+function getpaid_format_date($date, $with_time = false) {
856 856
 
857
-    if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) {
857
+    if (empty($date) || $date == '0000-00-00 00:00:00') {
858 858
         return '';
859 859
     }
860 860
 
861 861
     $format = getpaid_date_format();
862 862
 
863
-    if ( $with_time ) {
863
+    if ($with_time) {
864 864
         $format .= ' ' . getpaid_time_format();
865 865
     }
866
-    return date_i18n( $format, strtotime( $date ) );
866
+    return date_i18n($format, strtotime($date));
867 867
 
868 868
 }
869 869
 
@@ -872,9 +872,9 @@  discard block
 block discarded – undo
872 872
  *
873 873
  * @return string
874 874
  */
875
-function getpaid_format_date_value( $date, $default = "&mdash;", $with_time = false ) {
876
-    $date = getpaid_format_date( $date, $with_time );
877
-    return empty( $date ) ? $default : $date;
875
+function getpaid_format_date_value($date, $default = "&mdash;", $with_time = false) {
876
+    $date = getpaid_format_date($date, $with_time);
877
+    return empty($date) ? $default : $date;
878 878
 }
879 879
 
880 880
 /**
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
  * @return string
884 884
  */
885 885
 function getpaid_date_format() {
886
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
886
+	return apply_filters('getpaid_date_format', get_option('date_format'));
887 887
 }
888 888
 
889 889
 /**
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
  * @return string
893 893
  */
894 894
 function getpaid_time_format() {
895
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
895
+	return apply_filters('getpaid_time_format', get_option('time_format'));
896 896
 }
897 897
 
898 898
 /**
@@ -902,16 +902,16 @@  discard block
 block discarded – undo
902 902
  * @param  integer $limit Limit size in characters.
903 903
  * @return string
904 904
  */
905
-function getpaid_limit_length( $string, $limit ) {
905
+function getpaid_limit_length($string, $limit) {
906 906
     $str_limit = $limit - 3;
907 907
 
908
-	if ( function_exists( 'mb_strimwidth' ) ) {
909
-		if ( mb_strlen( $string ) > $limit ) {
910
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
908
+	if (function_exists('mb_strimwidth')) {
909
+		if (mb_strlen($string) > $limit) {
910
+			$string = mb_strimwidth($string, 0, $str_limit) . '...';
911 911
 		}
912 912
 	} else {
913
-		if ( strlen( $string ) > $limit ) {
914
-			$string = substr( $string, 0, $str_limit ) . '...';
913
+		if (strlen($string) > $limit) {
914
+			$string = substr($string, 0, $str_limit) . '...';
915 915
 		}
916 916
 	}
917 917
     return $string;
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
  * @since 1.0.19
926 926
  */
927 927
 function getpaid_api() {
928
-    return getpaid()->get( 'api' );
928
+    return getpaid()->get('api');
929 929
 }
930 930
 
931 931
 /**
@@ -935,7 +935,7 @@  discard block
 block discarded – undo
935 935
  * @since 1.0.19
936 936
  */
937 937
 function getpaid_post_types() {
938
-    return getpaid()->get( 'post_types' );
938
+    return getpaid()->get('post_types');
939 939
 }
940 940
 
941 941
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @since 1.0.19
946 946
  */
947 947
 function getpaid_session() {
948
-    return getpaid()->get( 'session' );
948
+    return getpaid()->get('session');
949 949
 }
950 950
 
951 951
 /**
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
  * @since 1.0.19
956 956
  */
957 957
 function getpaid_notes() {
958
-    return getpaid()->get( 'notes' );
958
+    return getpaid()->get('notes');
959 959
 }
960 960
 
961 961
 /**
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
  * @return GetPaid_Admin
965 965
  */
966 966
 function getpaid_admin() {
967
-    return getpaid()->get( 'admin' );
967
+    return getpaid()->get('admin');
968 968
 }
969 969
 
970 970
 /**
@@ -974,8 +974,8 @@  discard block
 block discarded – undo
974 974
  * @param string $base the base url
975 975
  * @return string
976 976
  */
977
-function getpaid_get_authenticated_action_url( $action, $base = false ) {
978
-    return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' );
977
+function getpaid_get_authenticated_action_url($action, $base = false) {
978
+    return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce');
979 979
 }
980 980
 
981 981
 /**
@@ -983,11 +983,11 @@  discard block
 block discarded – undo
983 983
  *
984 984
  * @return string
985 985
  */
986
-function getpaid_get_post_type_label( $post_type, $plural = true ) {
986
+function getpaid_get_post_type_label($post_type, $plural = true) {
987 987
 
988
-    $post_type = get_post_type_object( $post_type );
988
+    $post_type = get_post_type_object($post_type);
989 989
 
990
-    if ( ! is_object( $post_type ) ) {
990
+    if (!is_object($post_type)) {
991 991
         return null;
992 992
     }
993 993
 
@@ -1000,18 +1000,18 @@  discard block
 block discarded – undo
1000 1000
  *
1001 1001
  * @return mixed|null
1002 1002
  */
1003
-function getpaid_get_array_field( $array, $key, $secondary_key = null ) {
1003
+function getpaid_get_array_field($array, $key, $secondary_key = null) {
1004 1004
 
1005
-    if ( ! is_array( $array ) ) {
1005
+    if (!is_array($array)) {
1006 1006
         return null;
1007 1007
     }
1008 1008
 
1009
-    if ( ! empty( $secondary_key ) ) {
1010
-        $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array();
1011
-        return getpaid_get_array_field( $array, $key );
1009
+    if (!empty($secondary_key)) {
1010
+        $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array();
1011
+        return getpaid_get_array_field($array, $key);
1012 1012
     }
1013 1013
 
1014
-    return isset( $array[ $key ] ) ? $array[ $key ] : null;
1014
+    return isset($array[$key]) ? $array[$key] : null;
1015 1015
 
1016 1016
 }
1017 1017
 
@@ -1020,12 +1020,12 @@  discard block
 block discarded – undo
1020 1020
  *
1021 1021
  * @return array
1022 1022
  */
1023
-function getpaid_array_merge_if_empty( $args, $defaults ) {
1023
+function getpaid_array_merge_if_empty($args, $defaults) {
1024 1024
 
1025
-    foreach ( $defaults as $key => $value ) {
1025
+    foreach ($defaults as $key => $value) {
1026 1026
 
1027
-        if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) {
1028
-            $args[ $key ] = $value;
1027
+        if (array_key_exists($key, $args) && empty($args[$key])) {
1028
+            $args[$key] = $value;
1029 1029
         }
1030 1030
 
1031 1031
     }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-bank-transfer-gateway.php 1 patch
Spacing   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Bank transfer Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-	protected $supports = array( 'addons' );
27
+	protected $supports = array('addons');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
 	public function __construct() {
40 40
         parent::__construct();
41 41
 
42
-        $this->title                = __( 'Direct bank transfer', 'invoicing' );
43
-        $this->method_title         = __( 'Bank transfer', 'invoicing' );
44
-        $this->checkout_button_text = __( 'Proceed', 'invoicing' );
45
-        $this->instructions         = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) );
42
+        $this->title                = __('Direct bank transfer', 'invoicing');
43
+        $this->method_title         = __('Bank transfer', 'invoicing');
44
+        $this->checkout_button_text = __('Proceed', 'invoicing');
45
+        $this->instructions         = apply_filters('wpinv_bank_instructions', $this->get_option('info'));
46 46
 
47
-		add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) );
48
-		add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 );
49
-		add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 );
50
-		add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 );
47
+		add_action('wpinv_receipt_end', array($this, 'thankyou_page'));
48
+		add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40);
49
+		add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11);
50
+		add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3);
51 51
 
52 52
     }
53 53
 
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
61 61
 	 * @return array
62 62
 	 */
63
-	public function process_payment( $invoice, $submission_data, $submission ) {
63
+	public function process_payment($invoice, $submission_data, $submission) {
64 64
 
65 65
         // Add a transaction id.
66
-        $invoice->set_transaction_id( $invoice->generate_key('trans_') );
66
+        $invoice->set_transaction_id($invoice->generate_key('trans_'));
67 67
 
68 68
         // Set it as pending payment.
69
-        if ( ! $invoice->needs_payment() ) {
69
+        if (!$invoice->needs_payment()) {
70 70
             $invoice->mark_paid();
71
-        } else if ( ! $invoice->is_paid() ) {
72
-            $invoice->set_status( 'wpi-onhold' );
71
+        } else if (!$invoice->is_paid()) {
72
+            $invoice->set_status('wpi-onhold');
73 73
         }
74 74
 
75 75
         // Save it.
76 76
         $invoice->save();
77 77
 
78 78
         // Send to the success page.
79
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
79
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
80 80
 
81 81
     }
82 82
 
@@ -85,17 +85,17 @@  discard block
 block discarded – undo
85 85
 	 *
86 86
 	 * @param WPInv_Invoice $invoice Invoice.
87 87
 	 */
88
-	public function thankyou_page( $invoice ) {
88
+	public function thankyou_page($invoice) {
89 89
 
90
-        if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
90
+        if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
91 91
 
92 92
 			echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL;
93 93
 
94
-            if ( ! empty( $this->instructions ) ) {
95
-                echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) );
94
+            if (!empty($this->instructions)) {
95
+                echo wp_kses_post(wpautop(wptexturize($this->instructions)));
96 96
 			}
97 97
 
98
-			$this->bank_details( $invoice );
98
+			$this->bank_details($invoice);
99 99
 
100 100
 			echo '</div>';
101 101
 
@@ -110,17 +110,17 @@  discard block
 block discarded – undo
110 110
 	 * @param string     $email_type Email format: plain text or HTML.
111 111
 	 * @param bool     $sent_to_admin Sent to admin.
112 112
 	 */
113
-	public function email_instructions( $invoice, $email_type, $sent_to_admin ) {
113
+	public function email_instructions($invoice, $email_type, $sent_to_admin) {
114 114
 
115
-		if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) {
115
+		if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) {
116 116
 
117 117
 			echo '<div class="wpi-email-row getpaid-bank-transfer-details">';
118 118
 
119
-			if ( $this->instructions ) {
120
-				echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL );
119
+			if ($this->instructions) {
120
+				echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL);
121 121
             }
122 122
 
123
-			$this->bank_details( $invoice );
123
+			$this->bank_details($invoice);
124 124
 			
125 125
 			echo '</div>';
126 126
 
@@ -133,51 +133,51 @@  discard block
 block discarded – undo
133 133
 	 *
134 134
 	 * @param WPInv_Invoice $invoice Invoice.
135 135
 	 */
136
-	protected function bank_details( $invoice ) {
136
+	protected function bank_details($invoice) {
137 137
 
138 138
 		// Get the invoice country and country $locale.
139 139
 		$country = $invoice->get_country();
140 140
 		$locale  = $this->get_country_locale();
141 141
 
142 142
 		// Get sortcode label in the $locale array and use appropriate one.
143
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
143
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
144 144
 
145 145
         $bank_fields = array(
146
-            'ac_name'     => __( 'Account Name', 'invoicing' ),
147
-            'ac_no'       => __( 'Account Number', 'invoicing' ),
148
-            'bank_name'   => __( 'Bank Name', 'invoicing' ),
149
-            'ifsc'        => __( 'IFSC code', 'invoicing' ),
150
-            'iban'        => __( 'IBAN', 'invoicing' ),
151
-            'bic'         => __( 'BIC/Swift code', 'invoicing' ),
146
+            'ac_name'     => __('Account Name', 'invoicing'),
147
+            'ac_no'       => __('Account Number', 'invoicing'),
148
+            'bank_name'   => __('Bank Name', 'invoicing'),
149
+            'ifsc'        => __('IFSC code', 'invoicing'),
150
+            'iban'        => __('IBAN', 'invoicing'),
151
+            'bic'         => __('BIC/Swift code', 'invoicing'),
152 152
             'sort_code'   => $sortcode,
153 153
         );
154 154
 
155 155
         $bank_info = array();
156 156
 
157
-        foreach ( $bank_fields as $field => $label ) {
158
-            $value = $this->get_option( $field );
157
+        foreach ($bank_fields as $field => $label) {
158
+            $value = $this->get_option($field);
159 159
 
160
-            if ( ! empty( $value ) ) {
161
-                $bank_info[$field] = array( 'label' => $label, 'value' => $value );
160
+            if (!empty($value)) {
161
+                $bank_info[$field] = array('label' => $label, 'value' => $value);
162 162
             }
163 163
 
164 164
         }
165 165
 
166
-        $bank_info = apply_filters( 'wpinv_bank_info', $bank_info );
166
+        $bank_info = apply_filters('wpinv_bank_info', $bank_info);
167 167
 
168
-        if ( empty( $bank_info ) ) {
168
+        if (empty($bank_info)) {
169 169
             return;
170 170
         }
171 171
 
172
-		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ) ) . '</h3>' . PHP_EOL;
172
+		echo '<h3 class="getpaid-bank-transfer-title"> ' . apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing')) . '</h3>' . PHP_EOL;
173 173
 
174 174
 		echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL;
175 175
 
176
-		foreach ( $bank_info as $key => $data ) {
176
+		foreach ($bank_info as $key => $data) {
177 177
 
178
-			$key   = sanitize_html_class( $key );
179
-			$label = wp_kses_post( $data['label'] );
180
-			$value = wp_kses_post( wptexturize( $data['value'] ) );
178
+			$key   = sanitize_html_class($key);
179
+			$label = wp_kses_post($data['label']);
180
+			$value = wp_kses_post(wptexturize($data['value']));
181 181
 
182 182
 			echo "<tr class='getpaid-bank-transfer-$key'><th class='font-weight-bold'>$label</th><td class='w-75'>$value</td></tr>" . PHP_EOL;
183 183
 		}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	 */
194 194
 	public function get_country_locale() {
195 195
 
196
-		if ( empty( $this->locale ) ) {
196
+		if (empty($this->locale)) {
197 197
 
198 198
 			// Locale information to be used - only those that are not 'Sort Code'.
199 199
 			$this->locale = apply_filters(
@@ -201,42 +201,42 @@  discard block
 block discarded – undo
201 201
 				array(
202 202
 					'AU' => array(
203 203
 						'sortcode' => array(
204
-							'label' => __( 'BSB', 'invoicing' ),
204
+							'label' => __('BSB', 'invoicing'),
205 205
 						),
206 206
 					),
207 207
 					'CA' => array(
208 208
 						'sortcode' => array(
209
-							'label' => __( 'Bank transit number', 'invoicing' ),
209
+							'label' => __('Bank transit number', 'invoicing'),
210 210
 						),
211 211
 					),
212 212
 					'IN' => array(
213 213
 						'sortcode' => array(
214
-							'label' => __( 'IFSC', 'invoicing' ),
214
+							'label' => __('IFSC', 'invoicing'),
215 215
 						),
216 216
 					),
217 217
 					'IT' => array(
218 218
 						'sortcode' => array(
219
-							'label' => __( 'Branch sort', 'invoicing' ),
219
+							'label' => __('Branch sort', 'invoicing'),
220 220
 						),
221 221
 					),
222 222
 					'NZ' => array(
223 223
 						'sortcode' => array(
224
-							'label' => __( 'Bank code', 'invoicing' ),
224
+							'label' => __('Bank code', 'invoicing'),
225 225
 						),
226 226
 					),
227 227
 					'SE' => array(
228 228
 						'sortcode' => array(
229
-							'label' => __( 'Bank code', 'invoicing' ),
229
+							'label' => __('Bank code', 'invoicing'),
230 230
 						),
231 231
 					),
232 232
 					'US' => array(
233 233
 						'sortcode' => array(
234
-							'label' => __( 'Routing number', 'invoicing' ),
234
+							'label' => __('Routing number', 'invoicing'),
235 235
 						),
236 236
 					),
237 237
 					'ZA' => array(
238 238
 						'sortcode' => array(
239
-							'label' => __( 'Branch code', 'invoicing' ),
239
+							'label' => __('Branch code', 'invoicing'),
240 240
 						),
241 241
 					),
242 242
 				)
@@ -253,51 +253,51 @@  discard block
 block discarded – undo
253 253
 	 * 
254 254
 	 * @param array $admin_settings
255 255
 	 */
256
-	public function admin_settings( $admin_settings ) {
256
+	public function admin_settings($admin_settings) {
257 257
 
258
-        $admin_settings['bank_transfer_desc']['std']    = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' );
259
-		$admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' );
258
+        $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing');
259
+		$admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing');
260 260
 
261
-		$locale  = $this->get_country_locale();
261
+		$locale = $this->get_country_locale();
262 262
 
263 263
 		// Get sortcode label in the $locale array and use appropriate one.
264 264
 		$country  = wpinv_default_billing_country();
265
-		$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' );
265
+		$sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing');
266 266
 
267 267
 		$admin_settings['bank_transfer_ac_name'] = array(
268 268
             'type' => 'text',
269 269
             'id'   => 'bank_transfer_ac_name',
270
-            'name' => __( 'Account Name', 'invoicing' ),
270
+            'name' => __('Account Name', 'invoicing'),
271 271
 		);
272 272
 		
273 273
 		$admin_settings['bank_transfer_ac_no'] = array(
274 274
             'type' => 'text',
275 275
             'id'   => 'bank_transfer_ac_no',
276
-            'name' => __( 'Account Number', 'invoicing' ),
276
+            'name' => __('Account Number', 'invoicing'),
277 277
 		);
278 278
 		
279 279
 		$admin_settings['bank_transfer_bank_name'] = array(
280 280
             'type' => 'text',
281 281
             'id'   => 'bank_transfer_bank_name',
282
-            'name' => __( 'Bank Name', 'invoicing' ),
282
+            'name' => __('Bank Name', 'invoicing'),
283 283
 		);
284 284
 
285 285
 		$admin_settings['bank_transfer_ifsc'] = array(
286 286
             'type' => 'text',
287 287
             'id'   => 'bank_transfer_ifsc',
288
-            'name' => __( 'IFSC Code', 'invoicing' ),
288
+            'name' => __('IFSC Code', 'invoicing'),
289 289
 		);
290 290
 
291 291
 		$admin_settings['bank_transfer_iban'] = array(
292 292
             'type' => 'text',
293 293
             'id'   => 'bank_transfer_iban',
294
-            'name' => __( 'IBAN', 'invoicing' ),
294
+            'name' => __('IBAN', 'invoicing'),
295 295
 		);
296 296
 
297 297
 		$admin_settings['bank_transfer_bic'] = array(
298 298
             'type' => 'text',
299 299
             'id'   => 'bank_transfer_bic',
300
-            'name' => __( 'BIC/Swift Code', 'invoicing' ),
300
+            'name' => __('BIC/Swift Code', 'invoicing'),
301 301
 		);
302 302
 		
303 303
 		$admin_settings['bank_transfer_sort_code'] = array(
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 
309 309
 		$admin_settings['bank_transfer_info'] = array(
310 310
             'id'   => 'bank_transfer_info',
311
-            'name' => __( 'Instructions', 'invoicing' ),
312
-            'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ),
311
+            'name' => __('Instructions', 'invoicing'),
312
+            'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'),
313 313
             'type' => 'textarea',
314
-            'std'  => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ),
314
+            'std'  => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'),
315 315
             'cols' => 50,
316 316
             'rows' => 5
317 317
         );
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @param GetPaid_Form_Item[] $items
327 327
 	 * @return WPInv_Invoice
328 328
 	 */
329
-	public function process_addons( $invoice, $items ) {
329
+	public function process_addons($invoice, $items) {
330 330
 
331
-        foreach ( $items as $item ) {
332
-            $invoice->add_item( $item );
331
+        foreach ($items as $item) {
332
+            $invoice->add_item($item);
333 333
         }
334 334
 
335 335
         $invoice->recalculate_total();
Please login to merge, or discard this patch.
templates/frontend-head.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
Please login to merge, or discard this patch.
templates/frontend-footer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 		<div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;">
17 17
 			<div class="modal-content">
18 18
 				<div class="modal-body">
19
-					<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__( 'Close', 'invoicing' ); ?>">
19
+					<button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__('Close', 'invoicing'); ?>">
20 20
 						<i class="fa fa-times" aria-hidden="true"></i>
21 21
 					</button>
22 22
 					<div class="modal-body-wrapper"></div>
Please login to merge, or discard this patch.
templates/invoice/company-address.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -7,17 +7,17 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 // Prepare the company name.
13
-$company_name = wpinv_get_option( 'vat_company_name' );
13
+$company_name = wpinv_get_option('vat_company_name');
14 14
 
15
-if ( empty( $company_name ) ) {
15
+if (empty($company_name)) {
16 16
     $company_name = wpinv_get_business_name();
17 17
 }
18 18
 
19 19
 // Prepare the VAT number.
20
-$vat_number = wpinv_get_option( 'vat_number' );
20
+$vat_number = wpinv_get_option('vat_number');
21 21
 
22 22
 ?>
23 23
     <div class="getpaid-company-address form-group">
@@ -25,36 +25,36 @@  discard block
 block discarded – undo
25 25
         <div class="row">
26 26
 
27 27
             <div class="invoice-company-address-label col-2">
28
-                <strong><?php _e( 'From:', 'invoicing' ) ?></strong>
28
+                <strong><?php _e('From:', 'invoicing') ?></strong>
29 29
             </div>
30 30
 
31 31
             <div class="invoice-company-address-value col-10">
32 32
 
33
-                <?php do_action( 'getpaid_company_address_top' ); ?>
33
+                <?php do_action('getpaid_company_address_top'); ?>
34 34
 
35 35
                 <div class="name">
36
-                    <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>">
37
-                        <?php echo esc_html( $company_name ); ?>
36
+                    <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>">
37
+                        <?php echo esc_html($company_name); ?>
38 38
                     </a>
39 39
                 </div>
40 40
 
41
-                <?php if ( $address = wpinv_get_business_address() ) { ?>
42
-                    <?php echo $address;?>
41
+                <?php if ($address = wpinv_get_business_address()) { ?>
42
+                    <?php echo $address; ?>
43 43
                 <?php } ?>
44 44
 
45
-                <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?>
45
+                <?php if ($email_from = wpinv_mail_get_from_address()) { ?>
46 46
                     <div class="email_from">
47
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?>
47
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?>
48 48
                     </div>
49 49
                 <?php } ?>
50 50
 
51
-                <?php if ( ! empty( $vat_number ) ) { ?>
51
+                <?php if (!empty($vat_number)) { ?>
52 52
                     <div class="email_from">
53
-                        <?php echo wp_sprintf( __( 'VAT Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) );?>
53
+                        <?php echo wp_sprintf(__('VAT Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?>
54 54
                     </div>
55 55
                 <?php } ?>
56 56
 
57
-                <?php do_action( 'getpaid_company_address_bottom' ); ?>
57
+                <?php do_action('getpaid_company_address_bottom'); ?>
58 58
 
59 59
             </div>
60 60
 
Please login to merge, or discard this patch.
templates/invoice/billing-address.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$invoice     = new WPInv_Invoice( $invoice );
13
-$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() );
12
+$invoice     = new WPInv_Invoice($invoice);
13
+$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info());
14 14
 $phone       = $invoice->get_phone();
15 15
 $email       = $invoice->get_email();
16 16
 $vat_number  = $invoice->get_vat_number();
@@ -21,41 +21,41 @@  discard block
 block discarded – undo
21 21
 
22 22
 
23 23
             <div class="invoice-billing-address-label col-2">
24
-                <strong><?php _e( 'To:', 'invoicing' ) ?></strong>
24
+                <strong><?php _e('To:', 'invoicing') ?></strong>
25 25
             </div>
26 26
 
27 27
 
28 28
             <div class="invoice-billing-address-value col-10">
29 29
 
30
-                <?php do_action( 'getpaid_billing_address_top' ); ?>
30
+                <?php do_action('getpaid_billing_address_top'); ?>
31 31
 
32
-                <?php if ( ! empty( $address_row ) ) : ?>
32
+                <?php if (!empty($address_row)) : ?>
33 33
                     <div class="billing-address">
34 34
                         <?php echo $address_row; ?>
35 35
                     </div>
36 36
                 <?php endif; ?>
37 37
 
38 38
 
39
-                <?php if ( ! empty( $phone ) ) : ?>
39
+                <?php if (!empty($phone)) : ?>
40 40
                     <div class="billing-phone">
41
-                        <?php echo wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?>
41
+                        <?php echo wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)); ?>
42 42
                     </div>
43 43
                 <?php endif; ?>
44 44
 
45 45
 
46
-                <?php if ( ! empty( $email ) ) : ?>
46
+                <?php if (!empty($email)) : ?>
47 47
                     <div class="billing-email">
48
-                        <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?>
48
+                        <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?>
49 49
                     </div>
50 50
                 <?php endif; ?>
51 51
 
52
-                <?php if ( ! empty( $vat_number ) ) : ?>
52
+                <?php if (!empty($vat_number)) : ?>
53 53
                     <div class="vat-number">
54
-                        <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) ); ?>
54
+                        <?php echo wp_sprintf(__('Vat Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?>
55 55
                     </div>
56 56
                 <?php endif; ?>
57 57
 
58
-                <?php do_action( 'getpaid_billing_address_bottom' ); ?>
58
+                <?php do_action('getpaid_billing_address_bottom'); ?>
59 59
 
60 60
             </div>
61 61
 
Please login to merge, or discard this patch.
templates/payment-forms/cart-item.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -7,116 +7,116 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-do_action( 'getpaid_before_payment_form_cart_item', $form, $item );
12
+do_action('getpaid_before_payment_form_cart_item', $form, $item);
13 13
 
14 14
 $currency = $form->get_currency();
15 15
 
16 16
 ?>
17
-<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required'  : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
17
+<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'>
18 18
 
19 19
 	<div class="form-row needs-validation">
20 20
 
21
-		<?php foreach ( array_keys( $columns ) as $key ) : ?>
21
+		<?php foreach (array_keys($columns) as $key) : ?>
22 22
 
23
-			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>">
23
+			<div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>">
24 24
 
25 25
 				<?php
26 26
 
27 27
 					// Fires before printing a line item column.
28
-					do_action( "getpaid_form_cart_item_before_$key", $item, $form );
28
+					do_action("getpaid_form_cart_item_before_$key", $item, $form);
29 29
 
30 30
 					// Item name.
31
-					if ( 'name' == $key ) {
31
+					if ('name' == $key) {
32 32
 
33 33
 						// Display the name.
34
-						echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>';
34
+						echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>';
35 35
 
36 36
 						// And an optional description.
37 37
                         $description = $item->get_description();
38 38
 
39
-                        if ( ! empty( $description ) ) {
40
-                            $description = wp_kses_post( $description );
39
+                        if (!empty($description)) {
40
+                            $description = wp_kses_post($description);
41 41
                             echo "<small class='form-text text-muted pr-2 m-0'>$description</small>";
42 42
 						}
43 43
 
44 44
 						// Price help text.
45
-                        $description = getpaid_item_recurring_price_help_text( $item, $currency );
46
-                        if ( $description ) {
45
+                        $description = getpaid_item_recurring_price_help_text($item, $currency);
46
+                        if ($description) {
47 47
                             echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>";
48 48
 						}
49 49
 
50 50
 					}
51 51
 
52 52
 					// Item price.
53
-					if ( 'price' == $key ) {
53
+					if ('price' == $key) {
54 54
 
55 55
 						// Set the currency position.
56 56
 						$position = wpinv_currency_position();
57 57
 
58
-						if ( $position == 'left_space' ) {
58
+						if ($position == 'left_space') {
59 59
 							$position = 'left';
60 60
 						}
61 61
 
62
-						if ( $position == 'right_space' ) {
62
+						if ($position == 'right_space') {
63 63
 							$position = 'right';
64 64
 						}
65 65
 
66
-						if ( $item->user_can_set_their_price() ) {
67
-							$price            = max( (float) $item->get_price(), (float) $item->get_minimum_price() );
66
+						if ($item->user_can_set_their_price()) {
67
+							$price            = max((float) $item->get_price(), (float) $item->get_minimum_price());
68 68
 							$minimum          = (float) $item->get_minimum_price();
69 69
 							$validate_minimum = '';
70 70
 							$class            = '';
71 71
 							$data_minimum     = '';
72 72
 
73
-							if ( $minimum > 0 ) {
73
+							if ($minimum > 0) {
74 74
 								$validate_minimum = sprintf(
75
-									esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ),
76
-									sanitize_text_field( wpinv_price( $minimum, $currency ) )
75
+									esc_attr__('The minimum allowed amount is %s', 'invoicing'),
76
+									sanitize_text_field(wpinv_price($minimum, $currency))
77 77
 								);
78 78
 
79 79
 								$class = 'getpaid-validate-minimum-amount';
80 80
 
81
-								$data_minimum     = "data-minimum-amount='$minimum'";
81
+								$data_minimum = "data-minimum-amount='$minimum'";
82 82
 							}
83 83
 
84 84
 							?>
85 85
 								<div class="input-group input-group-sm">
86
-									<?php if( 'left' == $position ) : ?>
86
+									<?php if ('left' == $position) : ?>
87 87
 										<div class="input-group-prepend">
88
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
88
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
89 89
 										</div>
90 90
 									<?php endif; ?>
91 91
 
92
-									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
92
+									<input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;">
93 93
 
94
-									<?php if ( ! empty( $validate_minimum ) ) : ?>
94
+									<?php if (!empty($validate_minimum)) : ?>
95 95
 										<div class="invalid-tooltip">
96 96
 											<?php echo $validate_minimum; ?>
97 97
 										</div>
98 98
 									<?php endif; ?>
99 99
 
100
-									<?php if( 'left' != $position ) : ?>
100
+									<?php if ('left' != $position) : ?>
101 101
 										<div class="input-group-append">
102
-											<span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span>
102
+											<span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span>
103 103
 										</div>
104 104
 									<?php endif; ?>
105 105
 								</div>
106 106
 
107 107
 							<?php
108 108
 						} else {
109
-							echo wpinv_price( $item->get_price(), $currency );
109
+							echo wpinv_price($item->get_price(), $currency);
110 110
 							?>
111
-								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'>
111
+								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'>
112 112
 							<?php
113 113
 						}
114 114
 					}
115 115
 
116 116
 					// Item quantity.
117
-					if ( 'quantity' == $key ) {
117
+					if ('quantity' == $key) {
118 118
 
119
-						if ( $item->allows_quantities() ) {
119
+						if ($item->allows_quantities()) {
120 120
 							?>
121 121
 								<input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required>
122 122
 							<?php
@@ -130,11 +130,11 @@  discard block
 block discarded – undo
130 130
 					}
131 131
 
132 132
 					// Item sub total.
133
-					if ( 'subtotal' == $key ) {
134
-						echo wpinv_price( $item->get_sub_total(), $currency );
133
+					if ('subtotal' == $key) {
134
+						echo wpinv_price($item->get_sub_total(), $currency);
135 135
 					}
136 136
 
137
-					do_action( "getpaid_payment_form_cart_item_$key", $item, $form );
137
+					do_action("getpaid_payment_form_cart_item_$key", $item, $form);
138 138
 				?>
139 139
 
140 140
 			</div>
@@ -145,4 +145,4 @@  discard block
 block discarded – undo
145 145
 
146 146
 </div>
147 147
 <?php
148
-do_action(  'getpaid_payment_form_cart_item', $form, $item );
148
+do_action('getpaid_payment_form_cart_item', $form, $item);
Please login to merge, or discard this patch.
includes/admin/wpinv-admin-functions.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -7,65 +7,65 @@  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
-function wpinv_bulk_actions( $actions ) {
15
-    if ( isset( $actions['edit'] ) ) {
16
-        unset( $actions['edit'] );
14
+function wpinv_bulk_actions($actions) {
15
+    if (isset($actions['edit'])) {
16
+        unset($actions['edit']);
17 17
     }
18 18
 
19 19
     return $actions;
20 20
 }
21
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
22
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
21
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
22
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
23 23
 
24
-function wpinv_admin_post_id( $id = 0 ) {
24
+function wpinv_admin_post_id($id = 0) {
25 25
     global $post;
26 26
 
27
-    if ( isset( $id ) && ! empty( $id ) ) {
28
-        return (int)$id;
29
-    } else if ( get_the_ID() ) {
27
+    if (isset($id) && !empty($id)) {
28
+        return (int) $id;
29
+    } else if (get_the_ID()) {
30 30
         return (int) get_the_ID();
31
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
31
+    } else if (isset($post->ID) && !empty($post->ID)) {
32 32
         return (int) $post->ID;
33
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
33
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
34 34
         return (int) $_GET['post'];
35
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
35
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
36 36
         return (int) $_GET['id'];
37
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
37
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
38 38
         return (int) $_POST['id'];
39 39
     } 
40 40
 
41 41
     return null;
42 42
 }
43 43
     
44
-function wpinv_admin_post_type( $id = 0 ) {
45
-    if ( !$id ) {
44
+function wpinv_admin_post_type($id = 0) {
45
+    if (!$id) {
46 46
         $id = wpinv_admin_post_id();
47 47
     }
48 48
     
49
-    $type = get_post_type( $id );
49
+    $type = get_post_type($id);
50 50
     
51
-    if ( !$type ) {
52
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
51
+    if (!$type) {
52
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
53 53
     }
54 54
     
55
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
55
+    return apply_filters('wpinv_admin_post_type', $type, $id);
56 56
 }
57 57
 
58 58
 function wpinv_admin_messages() {
59
-	settings_errors( 'wpinv-notices' );
59
+	settings_errors('wpinv-notices');
60 60
 }
61
-add_action( 'admin_notices', 'wpinv_admin_messages' );
61
+add_action('admin_notices', 'wpinv_admin_messages');
62 62
 
63
-add_action( 'admin_init', 'wpinv_show_test_payment_gateway_notice' );
64
-function wpinv_show_test_payment_gateway_notice(){
65
-    add_action( 'admin_notices', 'wpinv_test_payment_gateway_messages' );
63
+add_action('admin_init', 'wpinv_show_test_payment_gateway_notice');
64
+function wpinv_show_test_payment_gateway_notice() {
65
+    add_action('admin_notices', 'wpinv_test_payment_gateway_messages');
66 66
 }
67 67
 
68
-function wpinv_test_payment_gateway_messages(){
68
+function wpinv_test_payment_gateway_messages() {
69 69
     $gateways = wpinv_get_enabled_payment_gateways();
70 70
     $name = array(); $test_gateways = '';
71 71
     if ($gateways) {
@@ -76,9 +76,9 @@  discard block
 block discarded – undo
76 76
         }
77 77
         $test_gateways = implode(', ', $name);
78 78
     }
79
-    if(isset($test_gateways) && !empty($test_gateways)){
79
+    if (isset($test_gateways) && !empty($test_gateways)) {
80 80
         $link = admin_url('admin.php?page=wpinv-settings&tab=gateways');
81
-        $notice = wp_sprintf( __('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link );
81
+        $notice = wp_sprintf(__('<strong>Important:</strong> Payment Gateway(s) %s are in testing mode and will not receive real payments. Go to <a href="%s"> Gateway Settings</a>.', 'invoicing'), $test_gateways, $link);
82 82
         ?>
83 83
         <div class="notice notice-warning is-dismissible">
84 84
             <p><?php echo $notice; ?></p>
@@ -95,29 +95,29 @@  discard block
 block discarded – undo
95 95
     global $wpdb;
96 96
 
97 97
     // Only do this on our settings page.
98
-    if ( empty( $_GET[ 'page' ] ) || 'wpinv-settings' !== $_GET[ 'page' ] ) {
98
+    if (empty($_GET['page']) || 'wpinv-settings' !== $_GET['page']) {
99 99
         return;
100 100
     }
101 101
 
102 102
     // Check tables.
103
-    $tables             = array(
103
+    $tables = array(
104 104
         "{$wpdb->prefix}wpinv_subscriptions",
105 105
         "{$wpdb->prefix}getpaid_invoices",
106 106
         "{$wpdb->prefix}getpaid_invoice_items",
107 107
     );
108 108
 
109
-    foreach ( $tables as $table ) {
110
-        if ( $table != $wpdb->get_var( "SHOW TABLES LIKE '$table'" ) ) {
109
+    foreach ($tables as $table) {
110
+        if ($table != $wpdb->get_var("SHOW TABLES LIKE '$table'")) {
111 111
 
112
-            $url     = esc_url(
112
+            $url = esc_url(
113 113
                 wp_nonce_url(
114
-                    add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
114
+                    add_query_arg('getpaid-admin-action', 'create_missing_tables'),
115 115
                     'getpaid-nonce',
116 116
                     'getpaid-nonce'
117 117
                 )
118 118
             );
119
-            $message  = __( 'Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing' );
120
-            $message2 = __( 'Create Tables', 'invoicing' );
119
+            $message  = __('Some GetPaid database tables are missing. To use GetPaid without any issues, click on the button below to create the missing tables.', 'invoicing');
120
+            $message2 = __('Create Tables', 'invoicing');
121 121
             echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
122 122
             break;
123 123
 
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
     }
126 126
 
127 127
 }
128
-add_action( 'admin_notices', 'wpinv_check_for_missing_tables' );
128
+add_action('admin_notices', 'wpinv_check_for_missing_tables');
129 129
 
130 130
 add_action('admin_init', 'wpinv_admin_search_by_invoice');
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 function wpinv_admin_search_by_invoice() {
136 136
     global $typenow;
137 137
 
138
-    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote' ) {
138
+    if ($typenow === 'wpi_invoice' || $typenow === 'wpi_quote') {
139 139
         add_filter('posts_search', 'wpinv_posts_search_example_type', 10, 2);
140 140
     }
141 141
 }
@@ -150,9 +150,9 @@  discard block
 block discarded – undo
150 150
     global $wpdb;
151 151
 
152 152
     if ($query->is_main_query() && !empty($query->query['s'])) {
153
-        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql( $query->query['s'] ) . "%' )";
154
-        if ( ! empty( $search ) ) {
155
-            $search = preg_replace( '/^ AND /', '', $search );
153
+        $conditions_str = "{$wpdb->posts}.post_author IN ( SELECT ID FROM {$wpdb->users} WHERE user_email LIKE '%" . esc_sql($query->query['s']) . "%' )";
154
+        if (!empty($search)) {
155
+            $search = preg_replace('/^ AND /', '', $search);
156 156
             $search = " AND ( {$search} OR ( {$conditions_str} ) )";
157 157
         } else {
158 158
             $search = " AND ( {$conditions_str} )";
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 /**
166 166
  * Resets invoice counts.
167 167
  */
168
-function wpinv_reset_invoice_count(){
169
-    if ( ! empty( $_GET['reset_invoice_count'] ) && isset( $_GET['_nonce'] ) && wp_verify_nonce( $_GET['_nonce'], 'reset_invoice_count' ) ) {
168
+function wpinv_reset_invoice_count() {
169
+    if (!empty($_GET['reset_invoice_count']) && isset($_GET['_nonce']) && wp_verify_nonce($_GET['_nonce'], 'reset_invoice_count')) {
170 170
         wpinv_update_option('invoice_sequence_start', 1);
171 171
         delete_option('wpinv_last_invoice_number');
172
-        getpaid_admin()->show_success( __( 'Invoice number sequence reset successfully.', 'invoicing' ) );
173
-        $url = remove_query_arg( array('reset_invoice_count', '_nonce') );
172
+        getpaid_admin()->show_success(__('Invoice number sequence reset successfully.', 'invoicing'));
173
+        $url = remove_query_arg(array('reset_invoice_count', '_nonce'));
174 174
         wp_redirect($url);
175 175
         exit();
176 176
     }
177 177
 }
178
-add_action( 'admin_init', 'wpinv_reset_invoice_count' );
179 178
\ No newline at end of file
179
+add_action('admin_init', 'wpinv_reset_invoice_count');
180 180
\ No newline at end of file
Please login to merge, or discard this patch.