Completed
Push — master ( b0d50b...dd166b )
by Stiofan
12s
created
includes/admin/wpinv-admin-functions.php 2 patches
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -155,65 +155,65 @@  discard block
 block discarded – undo
155 155
 }
156 156
 
157 157
 function wpinv_admin_messages() {
158
-	global $wpinv_options, $pagenow, $post;
158
+    global $wpinv_options, $pagenow, $post;
159 159
 
160
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
162
-	}
160
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
162
+    }
163 163
 
164
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
166
-	}
164
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
166
+    }
167 167
 
168
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
170
-	}
168
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
170
+    }
171 171
 
172
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
174
-	}
172
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
+            add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
174
+    }
175 175
 
176
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
178
-	}
176
+    if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
+        add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
178
+    }
179 179
 
180
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
182
-	}
180
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
+        add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
182
+    }
183 183
 
184
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
184
+    if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
+        add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
186 186
     }
187 187
     
188 188
     if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
189
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
189
+        add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
190 190
     }
191 191
 
192 192
     if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
193 193
         add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
194 194
     }
195 195
 
196
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
198
-	}
196
+    if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
+        add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
198
+    }
199 199
 
200
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
202
-	}
200
+    if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
+        add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
202
+    }
203 203
 
204
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
206
-	}
204
+    if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
+        add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
206
+    }
207 207
     
208
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
208
+    if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
+        $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
210 210
 
211
-		if ( !empty( $message ) ) {
212
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
213
-		}
214
-	}
211
+        if ( !empty( $message ) ) {
212
+            add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
213
+        }
214
+    }
215 215
 
216
-	settings_errors( 'wpinv-notices' );
216
+    settings_errors( 'wpinv-notices' );
217 217
 }
218 218
 add_action( 'admin_notices', 'wpinv_admin_messages' );
219 219
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
         break;
277 277
         case 'id' :
278 278
            echo $post->ID;
279
-           echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
279
+            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
280 280
                     <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
281 281
                     if ( $wpinv_euvat->allow_vat_rules() ) {
282 282
                         echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
Please login to merge, or discard this patch.
Spacing   +189 added lines, -189 removed lines patch added patch discarded remove patch
@@ -7,239 +7,239 @@  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_columns( $columns ) {
14
+function wpinv_columns($columns) {
15 15
     $columns = array(
16 16
         'cb'                => $columns['cb'],
17
-        'number'            => __( 'Number', 'invoicing' ),
18
-        'customer'          => __( 'Customer', 'invoicing' ),
19
-        'amount'            => __( 'Amount', 'invoicing' ),
20
-        'invoice_date'      => __( 'Date', 'invoicing' ),
21
-        'status'            => __( 'Status', 'invoicing' ),
22
-        'ID'                => __( 'ID', 'invoicing' ),
23
-        'wpi_actions'       => __( 'Actions', 'invoicing' ),
17
+        'number'            => __('Number', 'invoicing'),
18
+        'customer'          => __('Customer', 'invoicing'),
19
+        'amount'            => __('Amount', 'invoicing'),
20
+        'invoice_date'      => __('Date', 'invoicing'),
21
+        'status'            => __('Status', 'invoicing'),
22
+        'ID'                => __('ID', 'invoicing'),
23
+        'wpi_actions'       => __('Actions', 'invoicing'),
24 24
     );
25 25
 
26
-    return apply_filters( 'wpi_invoice_table_columns', $columns );
26
+    return apply_filters('wpi_invoice_table_columns', $columns);
27 27
 }
28
-add_filter( 'manage_wpi_invoice_posts_columns', 'wpinv_columns' );
28
+add_filter('manage_wpi_invoice_posts_columns', 'wpinv_columns');
29 29
 
30
-function wpinv_bulk_actions( $actions ) {
31
-    if ( isset( $actions['edit'] ) ) {
32
-        unset( $actions['edit'] );
30
+function wpinv_bulk_actions($actions) {
31
+    if (isset($actions['edit'])) {
32
+        unset($actions['edit']);
33 33
     }
34 34
 
35 35
     return $actions;
36 36
 }
37
-add_filter( 'bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions' );
38
-add_filter( 'bulk_actions-edit-wpi_item', 'wpinv_bulk_actions' );
37
+add_filter('bulk_actions-edit-wpi_invoice', 'wpinv_bulk_actions');
38
+add_filter('bulk_actions-edit-wpi_item', 'wpinv_bulk_actions');
39 39
 
40
-function wpinv_sortable_columns( $columns ) {
40
+function wpinv_sortable_columns($columns) {
41 41
     $columns = array(
42
-        'ID'            => array( 'ID', true ),
43
-        'number'        => array( 'number', false ),
44
-        'amount'        => array( 'amount', false ),
45
-        'invoice_date'  => array( 'date', false ),
46
-        'customer'      => array( 'customer', false ),
47
-        'status'        => array( 'status', false ),
42
+        'ID'            => array('ID', true),
43
+        'number'        => array('number', false),
44
+        'amount'        => array('amount', false),
45
+        'invoice_date'  => array('date', false),
46
+        'customer'      => array('customer', false),
47
+        'status'        => array('status', false),
48 48
     );
49 49
     
50
-    return apply_filters( 'wpi_invoice_table_sortable_columns', $columns );
50
+    return apply_filters('wpi_invoice_table_sortable_columns', $columns);
51 51
 }
52
-add_filter( 'manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns' );
52
+add_filter('manage_edit-wpi_invoice_sortable_columns', 'wpinv_sortable_columns');
53 53
 
54
-add_action( 'manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
-function wpinv_posts_custom_column( $column_name, $post_id = 0 ) {
54
+add_action('manage_wpi_invoice_posts_custom_column', 'wpinv_posts_custom_column');
55
+function wpinv_posts_custom_column($column_name, $post_id = 0) {
56 56
     global $post, $wpi_invoice;
57 57
     
58
-    if ( empty( $wpi_invoice ) || ( !empty( $wpi_invoice ) && $post->ID != $wpi_invoice->ID ) ) {
59
-        $wpi_invoice = new WPInv_Invoice( $post->ID );
58
+    if (empty($wpi_invoice) || (!empty($wpi_invoice) && $post->ID != $wpi_invoice->ID)) {
59
+        $wpi_invoice = new WPInv_Invoice($post->ID);
60 60
     }
61 61
 
62 62
     $value = NULL;
63 63
     
64
-    switch ( $column_name ) {
64
+    switch ($column_name) {
65 65
         case 'email' :
66
-            $value   = $wpi_invoice->get_email();
66
+            $value = $wpi_invoice->get_email();
67 67
             break;
68 68
         case 'customer' :
69 69
             $customer_name = $wpi_invoice->get_user_full_name();
70
-            $customer_name = $customer_name != '' ? $customer_name : __( 'Customer', 'invoicing' );
71
-            $value = '<a href="' . esc_url( get_edit_user_link( $wpi_invoice->get_user_id() ) ) . '">' . $customer_name . '</a>';
72
-            if ( $email = $wpi_invoice->get_email() ) {
70
+            $customer_name = $customer_name != '' ? $customer_name : __('Customer', 'invoicing');
71
+            $value = '<a href="' . esc_url(get_edit_user_link($wpi_invoice->get_user_id())) . '">' . $customer_name . '</a>';
72
+            if ($email = $wpi_invoice->get_email()) {
73 73
                 $value .= '<br><a class="email" href="mailto:' . $email . '">' . $email . '</a>';
74 74
             }
75 75
             break;
76 76
         case 'amount' :
77
-            echo $wpi_invoice->get_total( true );
77
+            echo $wpi_invoice->get_total(true);
78 78
             break;
79 79
         case 'invoice_date' :
80
-            $date_format = get_option( 'date_format' );
81
-            $time_format = get_option( 'time_format' );
82
-            $date_time_format = $date_format . ' '. $time_format;
80
+            $date_format = get_option('date_format');
81
+            $time_format = get_option('time_format');
82
+            $date_time_format = $date_format . ' ' . $time_format;
83 83
             
84
-            $t_time = get_the_time( $date_time_format );
84
+            $t_time = get_the_time($date_time_format);
85 85
             $m_time = $post->post_date;
86
-            $h_time = mysql2date( $date_format, $m_time );
86
+            $h_time = mysql2date($date_format, $m_time);
87 87
             
88 88
             $value   = '<abbr title="' . $t_time . '">' . $h_time . '</abbr>';
89 89
             break;
90 90
         case 'status' :
91
-            $value   = $wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
92
-            if ( $wpi_invoice->is_paid() && $gateway_title = $wpi_invoice->get_gateway_title() ) {
93
-                $value .= '<br><small class="meta gateway">' . wp_sprintf( __( 'Via %s', 'invoicing' ), $gateway_title ) . '</small>';
91
+            $value   = $wpi_invoice->get_status(true) . ($wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __('(r)', 'invoicing') . '</span>' : '');
92
+            if ($wpi_invoice->is_paid() && $gateway_title = $wpi_invoice->get_gateway_title()) {
93
+                $value .= '<br><small class="meta gateway">' . wp_sprintf(__('Via %s', 'invoicing'), $gateway_title) . '</small>';
94 94
             }
95 95
             break;
96 96
         case 'number' :
97
-            $edit_link = get_edit_post_link( $post->ID );
98
-            $value = '<a title="' . esc_attr__( 'View Invoice Details', 'invoicing' ) . '" href="' . esc_url( $edit_link ) . '">' . $wpi_invoice->get_number() . '</a>';
97
+            $edit_link = get_edit_post_link($post->ID);
98
+            $value = '<a title="' . esc_attr__('View Invoice Details', 'invoicing') . '" href="' . esc_url($edit_link) . '">' . $wpi_invoice->get_number() . '</a>';
99 99
             break;
100 100
         case 'wpi_actions' :
101 101
             $value = '';
102
-            if ( !empty( $post->post_name ) ) {
103
-                $value .= '<a title="' . esc_attr__( 'Print invoice', 'invoicing' ) . '" href="' . esc_url( get_permalink( $post->ID ) ) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
102
+            if (!empty($post->post_name)) {
103
+                $value .= '<a title="' . esc_attr__('Print invoice', 'invoicing') . '" href="' . esc_url(get_permalink($post->ID)) . '" class="button ui-tip column-act-btn" title="" target="_blank"><span class="dashicons dashicons-print"><i style="" class="fa fa-print"></i></span></a>';
104 104
             }
105 105
             
106
-            if ( $email = $wpi_invoice->get_email() ) {
107
-                $value .= '<a title="' . esc_attr__( 'Send invoice to customer', 'invoicing' ) . '" href="' . esc_url( add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) ) ) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
106
+            if ($email = $wpi_invoice->get_email()) {
107
+                $value .= '<a title="' . esc_attr__('Send invoice to customer', 'invoicing') . '" href="' . esc_url(add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID))) . '" class="button ui-tip column-act-btn"><span class="dashicons dashicons-email-alt"></span></a>';
108 108
             }
109 109
             
110 110
             break;
111 111
         default:
112
-            $value = isset( $post->$column_name ) ? $post->$column_name : '';
112
+            $value = isset($post->$column_name) ? $post->$column_name : '';
113 113
             break;
114 114
 
115 115
     }
116
-    $value = apply_filters( 'wpinv_payments_table_column', $value, $post->ID, $column_name );
116
+    $value = apply_filters('wpinv_payments_table_column', $value, $post->ID, $column_name);
117 117
     
118
-    if ( $value !== NULL ) {
118
+    if ($value !== NULL) {
119 119
         echo $value;
120 120
     }
121 121
 }
122 122
 
123
-function wpinv_admin_post_id( $id = 0 ) {
123
+function wpinv_admin_post_id($id = 0) {
124 124
     global $post;
125 125
 
126
-    if ( isset( $id ) && ! empty( $id ) ) {
126
+    if (isset($id) && !empty($id)) {
127 127
         return (int)$id;
128
-    } else if ( get_the_ID() ) {
129
-        return (int) get_the_ID();
130
-    } else if ( isset( $post->ID ) && !empty( $post->ID ) ) {
131
-        return (int) $post->ID;
132
-    } else if ( isset( $_GET['post'] ) && !empty( $_GET['post'] ) ) {
133
-        return (int) $_GET['post'];
134
-    } else if ( isset( $_GET['id'] ) && !empty( $_GET['id'] ) ) {
135
-        return (int) $_GET['id'];
136
-    } else if ( isset( $_POST['id'] ) && !empty( $_POST['id'] ) ) {
137
-        return (int) $_POST['id'];
128
+    } else if (get_the_ID()) {
129
+        return (int)get_the_ID();
130
+    } else if (isset($post->ID) && !empty($post->ID)) {
131
+        return (int)$post->ID;
132
+    } else if (isset($_GET['post']) && !empty($_GET['post'])) {
133
+        return (int)$_GET['post'];
134
+    } else if (isset($_GET['id']) && !empty($_GET['id'])) {
135
+        return (int)$_GET['id'];
136
+    } else if (isset($_POST['id']) && !empty($_POST['id'])) {
137
+        return (int)$_POST['id'];
138 138
     } 
139 139
 
140 140
     return null;
141 141
 }
142 142
     
143
-function wpinv_admin_post_type( $id = 0 ) {
144
-    if ( !$id ) {
143
+function wpinv_admin_post_type($id = 0) {
144
+    if (!$id) {
145 145
         $id = wpinv_admin_post_id();
146 146
     }
147 147
     
148
-    $type = get_post_type( $id );
148
+    $type = get_post_type($id);
149 149
     
150
-    if ( !$type ) {
151
-        $type = isset( $_GET['post_type'] ) && !empty( $_GET['post_type'] ) ? $_GET['post_type'] : null;
150
+    if (!$type) {
151
+        $type = isset($_GET['post_type']) && !empty($_GET['post_type']) ? $_GET['post_type'] : null;
152 152
     }
153 153
     
154
-    return apply_filters( 'wpinv_admin_post_type', $type, $id );
154
+    return apply_filters('wpinv_admin_post_type', $type, $id);
155 155
 }
156 156
 
157 157
 function wpinv_admin_messages() {
158 158
 	global $wpinv_options, $pagenow, $post;
159 159
 
160
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
161
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' );
160
+	if (isset($_GET['wpinv-message']) && 'discount_added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
161
+		 add_settings_error('wpinv-notices', 'wpinv-discount-added', __('Discount code added.', 'invoicing'), 'updated');
162 162
 	}
163 163
 
164
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
165
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' );
164
+	if (isset($_GET['wpinv-message']) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
165
+		add_settings_error('wpinv-notices', 'wpinv-discount-add-fail', __('There was a problem adding your discount code, please try again.', 'invoicing'), 'error');
166 166
 	}
167 167
 
168
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
169
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' );
168
+	if (isset($_GET['wpinv-message']) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
169
+		add_settings_error('wpinv-notices', 'wpinv-discount-exists', __('A discount with that code already exists, please use a different code.', 'invoicing'), 'error');
170 170
 	}
171 171
 
172
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
173
-		 add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' );
172
+	if (isset($_GET['wpinv-message']) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
173
+		 add_settings_error('wpinv-notices', 'wpinv-discount-updated', __('Discount code updated.', 'invoicing'), 'updated');
174 174
 	}
175 175
 
176
-	if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
177
-		add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' );
176
+	if (isset($_GET['wpinv-message']) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
177
+		add_settings_error('wpinv-notices', 'wpinv-discount-updated-fail', __('There was a problem updating your discount code, please try again.', 'invoicing'), 'error');
178 178
 	}
179 179
 
180
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
181
-		add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' );
180
+	if (isset($_GET['wpinv-message']) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
181
+		add_settings_error('wpinv-notices', 'wpinv-deleted', __('The invoice has been deleted.', 'invoicing'), 'updated');
182 182
 	}
183 183
 
184
-	if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
185
-		add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' );
184
+	if (isset($_GET['wpinv-message']) && 'email_sent' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
185
+		add_settings_error('wpinv-notices', 'wpinv-sent', __('The email has been sent to customer.', 'invoicing'), 'updated');
186 186
     }
187 187
     
188
-    if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
189
-		add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' );
188
+    if (isset($_GET['wpinv-message']) && 'email_fail' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
189
+		add_settings_error('wpinv-notices', 'wpinv-sent-fail', __('Fail to send email to the customer.', 'invoicing'), 'error');
190 190
     }
191 191
 
192
-    if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
193
-        add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' );
192
+    if (isset($_GET['wpinv-message']) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
193
+        add_settings_error('wpinv-notices', 'wpinv-note-deleted', __('The invoice note has been deleted.', 'invoicing'), 'updated');
194 194
     }
195 195
 
196
-	if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
197
-		add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' );
196
+	if (isset($_GET['wpinv-message']) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
197
+		add_settings_error('wpinv-notices', 'wpinv-settings-imported', __('The settings have been imported.', 'invoicing'), 'updated');
198 198
 	}
199 199
 
200
-	if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
201
-		add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' );
200
+	if (isset($_GET['wpinv-message']) && 'note-added' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
201
+		add_settings_error('wpinv-notices', 'wpinv-note-added', __('The invoice note has been added successfully.', 'invoicing'), 'updated');
202 202
 	}
203 203
 
204
-	if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) {
205
-		add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' );
204
+	if (isset($_GET['wpinv-message']) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can('manage_options')) {
205
+		add_settings_error('wpinv-notices', 'wpinv-updated', __('The invoice has been successfully updated.', 'invoicing'), 'updated');
206 206
 	}
207 207
     
208
-	if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) {
209
-		$message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID );
208
+	if ($pagenow == 'post.php' && !empty($post->post_type) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable($post)) {
209
+		$message = apply_filters('wpinv_item_non_editable_message', __('This item in not editable.', 'invoicing'), $post->ID);
210 210
 
211
-		if ( !empty( $message ) ) {
212
-			add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' );
211
+		if (!empty($message)) {
212
+			add_settings_error('wpinv-notices', 'wpinv-edit-n', $message, 'updated');
213 213
 		}
214 214
 	}
215 215
 
216
-	settings_errors( 'wpinv-notices' );
216
+	settings_errors('wpinv-notices');
217 217
 }
218
-add_action( 'admin_notices', 'wpinv_admin_messages' );
218
+add_action('admin_notices', 'wpinv_admin_messages');
219 219
 
220
-function wpinv_items_columns( $existing_columns ) {
220
+function wpinv_items_columns($existing_columns) {
221 221
     global $wpinv_euvat;
222 222
     
223 223
     $columns                = array();
224 224
     $columns['cb']          = $existing_columns['cb'];
225
-    $columns['title']       = __( 'Title', 'invoicing' );
226
-    $columns['price']       = __( 'Price', 'invoicing' );
227
-    if ( $wpinv_euvat->allow_vat_rules() ) {
228
-        $columns['vat_rule']    = __( 'VAT rule type', 'invoicing' );
225
+    $columns['title']       = __('Title', 'invoicing');
226
+    $columns['price']       = __('Price', 'invoicing');
227
+    if ($wpinv_euvat->allow_vat_rules()) {
228
+        $columns['vat_rule']    = __('VAT rule type', 'invoicing');
229 229
     }
230
-    if ( $wpinv_euvat->allow_vat_classes() ) {
231
-        $columns['vat_class']   = __( 'VAT class', 'invoicing' );
230
+    if ($wpinv_euvat->allow_vat_classes()) {
231
+        $columns['vat_class']   = __('VAT class', 'invoicing');
232 232
     }
233
-    $columns['type']        = __( 'Type', 'invoicing' );
234
-    $columns['recurring']   = __( 'Recurring', 'invoicing' );
235
-    $columns['date']        = __( 'Date', 'invoicing' );
236
-    $columns['id']          = __( 'ID', 'invoicing' );
233
+    $columns['type']        = __('Type', 'invoicing');
234
+    $columns['recurring']   = __('Recurring', 'invoicing');
235
+    $columns['date']        = __('Date', 'invoicing');
236
+    $columns['id']          = __('ID', 'invoicing');
237 237
 
238
-    return apply_filters( 'wpinv_items_columns', $columns );
238
+    return apply_filters('wpinv_items_columns', $columns);
239 239
 }
240
-add_filter( 'manage_wpi_item_posts_columns', 'wpinv_items_columns' );
240
+add_filter('manage_wpi_item_posts_columns', 'wpinv_items_columns');
241 241
 
242
-function wpinv_items_sortable_columns( $columns ) {
242
+function wpinv_items_sortable_columns($columns) {
243 243
     $columns['price']       = 'price';
244 244
     $columns['vat_rule']    = 'vat_rule';
245 245
     $columns['vat_class']   = 'vat_class';
@@ -249,156 +249,156 @@  discard block
 block discarded – undo
249 249
 
250 250
     return $columns;
251 251
 }
252
-add_filter( 'manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns' );
252
+add_filter('manage_edit-wpi_item_sortable_columns', 'wpinv_items_sortable_columns');
253 253
 
254
-function wpinv_items_table_custom_column( $column ) {
254
+function wpinv_items_table_custom_column($column) {
255 255
     global $wpinv_euvat, $post, $wpi_item;
256 256
     
257
-    if ( empty( $wpi_item ) || ( !empty( $wpi_item ) && $post->ID != $wpi_item->ID ) ) {
258
-        $wpi_item = new WPInv_Item( $post->ID );
257
+    if (empty($wpi_item) || (!empty($wpi_item) && $post->ID != $wpi_item->ID)) {
258
+        $wpi_item = new WPInv_Item($post->ID);
259 259
     }
260 260
 
261
-    switch ( $column ) {
261
+    switch ($column) {
262 262
         case 'price' :
263
-            echo wpinv_item_price( $post->ID );
263
+            echo wpinv_item_price($post->ID);
264 264
         break;
265 265
         case 'vat_rule' :
266
-            echo $wpinv_euvat->item_rule_label( $post->ID );
266
+            echo $wpinv_euvat->item_rule_label($post->ID);
267 267
         break;
268 268
         case 'vat_class' :
269
-            echo $wpinv_euvat->item_class_label( $post->ID );
269
+            echo $wpinv_euvat->item_class_label($post->ID);
270 270
         break;
271 271
         case 'type' :
272
-            echo wpinv_item_type( $post->ID ) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
272
+            echo wpinv_item_type($post->ID) . '<span class="meta">' . $wpi_item->get_custom_singular_name() . '</span>';
273 273
         break;
274 274
         case 'recurring' :
275
-            echo ( wpinv_is_recurring_item( $post->ID ) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>' );
275
+            echo (wpinv_is_recurring_item($post->ID) ? '<i class="fa fa-check fa-recurring-y"></i>' : '<i class="fa fa-close fa-recurring-n"></i>');
276 276
         break;
277 277
         case 'id' :
278 278
            echo $post->ID;
279 279
            echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '">
280
-                    <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>';
281
-                    if ( $wpinv_euvat->allow_vat_rules() ) {
282
-                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>';
280
+                    <div class="price">' . wpinv_get_item_price($post->ID) . '</div>';
281
+                    if ($wpinv_euvat->allow_vat_rules()) {
282
+                        echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule($post->ID) . '</div>';
283 283
                     }
284
-                    if ( $wpinv_euvat->allow_vat_classes() ) {
285
-                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class( $post->ID ) . '</div>';
284
+                    if ($wpinv_euvat->allow_vat_classes()) {
285
+                        echo '<div class="vat_class">' . $wpinv_euvat->get_item_class($post->ID) . '</div>';
286 286
                     }
287
-                    echo '<div class="type">' . wpinv_get_item_type( $post->ID ) . '</div>
287
+                    echo '<div class="type">' . wpinv_get_item_type($post->ID) . '</div>
288 288
                 </div>';
289 289
         break;
290 290
     }
291 291
     
292
-    do_action( 'wpinv_items_table_column_item_' . $column, $wpi_item, $post );
292
+    do_action('wpinv_items_table_column_item_' . $column, $wpi_item, $post);
293 293
 }
294
-add_action( 'manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column' );
294
+add_action('manage_wpi_item_posts_custom_column', 'wpinv_items_table_custom_column');
295 295
 
296 296
 function wpinv_add_items_filters() {
297 297
     global $wpinv_euvat, $typenow;
298 298
 
299 299
     // Checks if the current post type is 'item'
300
-    if ( $typenow == 'wpi_item') {
301
-        if ( $wpinv_euvat->allow_vat_rules() ) {
302
-            echo wpinv_html_select( array(
303
-                    'options'          => array_merge( array( '' => __( 'All VAT rules', 'invoicing' ) ), $wpinv_euvat->get_rules() ),
300
+    if ($typenow == 'wpi_item') {
301
+        if ($wpinv_euvat->allow_vat_rules()) {
302
+            echo wpinv_html_select(array(
303
+                    'options'          => array_merge(array('' => __('All VAT rules', 'invoicing')), $wpinv_euvat->get_rules()),
304 304
                     'name'             => 'vat_rule',
305 305
                     'id'               => 'vat_rule',
306
-                    'selected'         => ( isset( $_GET['vat_rule'] ) ? $_GET['vat_rule'] : '' ),
306
+                    'selected'         => (isset($_GET['vat_rule']) ? $_GET['vat_rule'] : ''),
307 307
                     'show_option_all'  => false,
308 308
                     'show_option_none' => false,
309 309
                     'class'            => 'gdmbx2-text-medium',
310
-                ) );
310
+                ));
311 311
         }
312 312
         
313
-        if ( $wpinv_euvat->allow_vat_classes() ) {
314
-            echo wpinv_html_select( array(
315
-                    'options'          => array_merge( array( '' => __( 'All VAT classes', 'invoicing' ) ), $wpinv_euvat->get_all_classes() ),
313
+        if ($wpinv_euvat->allow_vat_classes()) {
314
+            echo wpinv_html_select(array(
315
+                    'options'          => array_merge(array('' => __('All VAT classes', 'invoicing')), $wpinv_euvat->get_all_classes()),
316 316
                     'name'             => 'vat_class',
317 317
                     'id'               => 'vat_class',
318
-                    'selected'         => ( isset( $_GET['vat_class'] ) ? $_GET['vat_class'] : '' ),
318
+                    'selected'         => (isset($_GET['vat_class']) ? $_GET['vat_class'] : ''),
319 319
                     'show_option_all'  => false,
320 320
                     'show_option_none' => false,
321 321
                     'class'            => 'gdmbx2-text-medium',
322
-                ) );
322
+                ));
323 323
         }
324 324
             
325
-        echo wpinv_html_select( array(
326
-                'options'          => array_merge( array( '' => __( 'All item types', 'invoicing' ) ), wpinv_get_item_types() ),
325
+        echo wpinv_html_select(array(
326
+                'options'          => array_merge(array('' => __('All item types', 'invoicing')), wpinv_get_item_types()),
327 327
                 'name'             => 'type',
328 328
                 'id'               => 'type',
329
-                'selected'         => ( isset( $_GET['type'] ) ? $_GET['type'] : '' ),
329
+                'selected'         => (isset($_GET['type']) ? $_GET['type'] : ''),
330 330
                 'show_option_all'  => false,
331 331
                 'show_option_none' => false,
332 332
                 'class'            => 'gdmbx2-text-medium',
333
-            ) );
333
+            ));
334 334
 
335
-        if ( isset( $_REQUEST['all_posts'] ) && '1' === $_REQUEST['all_posts'] ) {
335
+        if (isset($_REQUEST['all_posts']) && '1' === $_REQUEST['all_posts']) {
336 336
             echo '<input type="hidden" name="all_posts" value="1" />';
337 337
         }
338 338
     }
339 339
 }
340
-add_action( 'restrict_manage_posts', 'wpinv_add_items_filters', 100 );
340
+add_action('restrict_manage_posts', 'wpinv_add_items_filters', 100);
341 341
 
342
-function wpinv_send_invoice_after_save( $post_id ) {
342
+function wpinv_send_invoice_after_save($post_id) {
343 343
     // If this is just a revision, don't send the email.
344
-    if ( wp_is_post_revision( $post_id ) ) {
344
+    if (wp_is_post_revision($post_id)) {
345 345
         return;
346 346
     }
347 347
     
348
-    if ( !current_user_can( 'manage_options' ) || !('wpi_invoice' == get_post_type( $post_id ))  ) {
348
+    if (!current_user_can('manage_options') || !('wpi_invoice' == get_post_type($post_id))) {
349 349
         return;
350 350
     }
351 351
     
352
-    if ( !empty( $_POST['wpi_save_send'] ) ) {
353
-        wpinv_user_invoice_notification( $post_id );
352
+    if (!empty($_POST['wpi_save_send'])) {
353
+        wpinv_user_invoice_notification($post_id);
354 354
     }
355 355
 }
356
-add_action( 'save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1 );
356
+add_action('save_post_wpi_invoice', 'wpinv_send_invoice_after_save', 100, 1);
357 357
 
358
-function wpinv_send_register_new_user( $data, $postarr ) {
359
-    if ( current_user_can( 'manage_options' ) && !empty( $data['post_type'] ) && ( 'wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'] ) ) {
360
-        $is_new_user = !empty( $postarr['wpinv_new_user'] ) ? true : false;
361
-        $email = !empty( $postarr['wpinv_email'] ) && $postarr['wpinv_email'] && is_email( $postarr['wpinv_email'] ) ? $postarr['wpinv_email'] : NULL;
358
+function wpinv_send_register_new_user($data, $postarr) {
359
+    if (current_user_can('manage_options') && !empty($data['post_type']) && ('wpi_invoice' == $data['post_type'] || 'wpi_quote' == $data['post_type'])) {
360
+        $is_new_user = !empty($postarr['wpinv_new_user']) ? true : false;
361
+        $email = !empty($postarr['wpinv_email']) && $postarr['wpinv_email'] && is_email($postarr['wpinv_email']) ? $postarr['wpinv_email'] : NULL;
362 362
         
363
-        if ( $is_new_user && $email && !email_exists( $email ) ) {
364
-            $first_name = !empty( $postarr['wpinv_first_name'] ) ? sanitize_text_field( $postarr['wpinv_first_name'] ) : '';
365
-            $last_name = !empty( $postarr['wpinv_last_name'] ) ? sanitize_text_field( $postarr['wpinv_last_name'] ) : '';
366
-            $display_name = $first_name || $last_name ? trim( $first_name . ' ' . $last_name ) : '';
367
-            $user_nicename = $display_name ? trim( $display_name ) : $email;
368
-            $user_company = !empty( $postarr['wpinv_company'] ) ? sanitize_text_field( $postarr['wpinv_company'] ) : '';
363
+        if ($is_new_user && $email && !email_exists($email)) {
364
+            $first_name = !empty($postarr['wpinv_first_name']) ? sanitize_text_field($postarr['wpinv_first_name']) : '';
365
+            $last_name = !empty($postarr['wpinv_last_name']) ? sanitize_text_field($postarr['wpinv_last_name']) : '';
366
+            $display_name = $first_name || $last_name ? trim($first_name . ' ' . $last_name) : '';
367
+            $user_nicename = $display_name ? trim($display_name) : $email;
368
+            $user_company = !empty($postarr['wpinv_company']) ? sanitize_text_field($postarr['wpinv_company']) : '';
369 369
             
370
-            $user_login = sanitize_user( str_replace( ' ', '', $display_name ), true );
371
-            if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
370
+            $user_login = sanitize_user(str_replace(' ', '', $display_name), true);
371
+            if (!(validate_username($user_login) && !username_exists($user_login))) {
372 372
                 $new_user_login = strstr($email, '@', true);
373
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
374
-                    $user_login = sanitize_user($new_user_login, true );
373
+                if (validate_username($user_login) && username_exists($user_login)) {
374
+                    $user_login = sanitize_user($new_user_login, true);
375 375
                 }
376
-                if ( validate_username( $user_login ) && username_exists( $user_login ) ) {
377
-                    $user_append_text = rand(10,1000);
378
-                    $user_login = sanitize_user($new_user_login.$user_append_text, true );
376
+                if (validate_username($user_login) && username_exists($user_login)) {
377
+                    $user_append_text = rand(10, 1000);
378
+                    $user_login = sanitize_user($new_user_login . $user_append_text, true);
379 379
                 }
380 380
                 
381
-                if ( !( validate_username( $user_login ) && !username_exists( $user_login ) ) ) {
381
+                if (!(validate_username($user_login) && !username_exists($user_login))) {
382 382
                     $user_login = $email;
383 383
                 }
384 384
             }
385 385
             
386 386
             $userdata = array(
387 387
                 'user_login' => $user_login,
388
-                'user_pass' => wp_generate_password( 12, false ),
389
-                'user_email' => sanitize_text_field( $email ),
388
+                'user_pass' => wp_generate_password(12, false),
389
+                'user_email' => sanitize_text_field($email),
390 390
                 'first_name' => $first_name,
391 391
                 'last_name' => $last_name,
392
-                'user_nicename' => wpinv_utf8_substr( $user_nicename, 0, 50 ),
392
+                'user_nicename' => wpinv_utf8_substr($user_nicename, 0, 50),
393 393
                 'nickname' => $display_name,
394 394
                 'display_name' => $display_name,
395 395
             );
396 396
 
397
-            $userdata = apply_filters( 'wpinv_register_new_user_data', $userdata );
397
+            $userdata = apply_filters('wpinv_register_new_user_data', $userdata);
398 398
             
399
-            $new_user_id = wp_insert_user( $userdata );
399
+            $new_user_id = wp_insert_user($userdata);
400 400
             
401
-            if ( !is_wp_error( $new_user_id ) ) {
401
+            if (!is_wp_error($new_user_id)) {
402 402
                 $data['post_author'] = $new_user_id;
403 403
                 $_POST['post_author'] = $new_user_id;
404 404
                 $_POST['post_author_override'] = $new_user_id;
@@ -419,27 +419,27 @@  discard block
 block discarded – undo
419 419
                 
420 420
                 $meta = array();
421 421
                 ///$meta['_wpinv_user_id'] = $new_user_id;
422
-                foreach ( $meta_fields as $field ) {
423
-                    $meta['_wpinv_' . $field] = isset( $postarr['wpinv_' . $field] ) ? sanitize_text_field( $postarr['wpinv_' . $field] ) : '';
422
+                foreach ($meta_fields as $field) {
423
+                    $meta['_wpinv_' . $field] = isset($postarr['wpinv_' . $field]) ? sanitize_text_field($postarr['wpinv_' . $field]) : '';
424 424
                 }
425 425
                 
426
-                $meta = apply_filters( 'wpinv_register_new_user_meta', $meta, $new_user_id );
426
+                $meta = apply_filters('wpinv_register_new_user_meta', $meta, $new_user_id);
427 427
 
428 428
                 // Update user meta.
429
-                foreach ( $meta as $key => $value ) {
430
-                    update_user_meta( $new_user_id, $key, $value );
429
+                foreach ($meta as $key => $value) {
430
+                    update_user_meta($new_user_id, $key, $value);
431 431
                 }
432 432
                 
433
-                if ( function_exists( 'wp_send_new_user_notifications' ) ) {
433
+                if (function_exists('wp_send_new_user_notifications')) {
434 434
                     // Send email notifications related to the creation of new user.
435
-                    wp_send_new_user_notifications( $new_user_id, 'user' );
435
+                    wp_send_new_user_notifications($new_user_id, 'user');
436 436
                 }
437 437
             } else {
438
-                wpinv_error_log( $new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__ );
438
+                wpinv_error_log($new_user_id->get_error_message(), 'Invoice add new user', __FILE__, __LINE__);
439 439
             }
440 440
         }
441 441
     }
442 442
     
443 443
     return $data;
444 444
 }
445
-add_filter( 'wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2 );
446 445
\ No newline at end of file
446
+add_filter('wp_insert_post_data', 'wpinv_send_register_new_user', 10, 2);
447 447
\ No newline at end of file
Please login to merge, or discard this patch.
includes/class-wpinv.php 1 patch
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -7,15 +7,15 @@  discard block
 block discarded – undo
7 7
  */
8 8
  
9 9
 // MUST have WordPress.
10
-if ( !defined( 'WPINC' ) ) {
11
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
10
+if (!defined('WPINC')) {
11
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
12 12
 }
13 13
 
14 14
 class WPInv_Plugin {
15 15
     private static $instance;
16 16
     
17 17
     public static function run() {
18
-        if ( !isset( self::$instance ) && !( self::$instance instanceof WPInv_Plugin ) ) {
18
+        if (!isset(self::$instance) && !(self::$instance instanceof WPInv_Plugin)) {
19 19
             self::$instance = new WPInv_Plugin;
20 20
             self::$instance->includes();
21 21
             self::$instance->actions();
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
             self::$instance->reports    = new WPInv_Reports();
24 24
         }
25 25
         
26
-        do_action( 'wpinv_loaded' );
26
+        do_action('wpinv_loaded');
27 27
         
28 28
         return self::$instance;
29 29
     }
@@ -33,31 +33,31 @@  discard block
 block discarded – undo
33 33
     }
34 34
     
35 35
     public function define_constants() {
36
-        define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) );
37
-        define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) );
36
+        define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE));
37
+        define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE));
38 38
     }
39 39
     
40 40
     private function actions() {
41 41
         /* Internationalize the text strings used. */
42
-        add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) );
42
+        add_action('plugins_loaded', array(&$this, 'plugins_loaded'));
43 43
         
44 44
         /* Perform actions on admin initialization. */
45
-        add_action( 'admin_init', array( &$this, 'admin_init') );
46
-        add_action( 'init', array( &$this, 'init' ), 3 );
47
-        add_action( 'init', array( 'WPInv_Shortcodes', 'init' ) );
48
-        add_action( 'init', array( &$this, 'wpinv_actions' ) );
45
+        add_action('admin_init', array(&$this, 'admin_init'));
46
+        add_action('init', array(&$this, 'init'), 3);
47
+        add_action('init', array('WPInv_Shortcodes', 'init'));
48
+        add_action('init', array(&$this, 'wpinv_actions'));
49 49
         
50
-        if ( class_exists( 'BuddyPress' ) ) {
51
-            add_action( 'bp_include', array( &$this, 'bp_invoicing_init' ) );
50
+        if (class_exists('BuddyPress')) {
51
+            add_action('bp_include', array(&$this, 'bp_invoicing_init'));
52 52
         }
53 53
 
54
-        add_action( 'wp_enqueue_scripts', array( &$this, 'enqueue_scripts' ) );
54
+        add_action('wp_enqueue_scripts', array(&$this, 'enqueue_scripts'));
55 55
         
56
-        if ( is_admin() ) {
57
-            add_action( 'admin_enqueue_scripts', array( &$this, 'admin_enqueue_scripts' ) );
58
-            add_action( 'admin_body_class', array( &$this, 'admin_body_class' ) );
56
+        if (is_admin()) {
57
+            add_action('admin_enqueue_scripts', array(&$this, 'admin_enqueue_scripts'));
58
+            add_action('admin_body_class', array(&$this, 'admin_body_class'));
59 59
         } else {
60
-            add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) );
60
+            add_filter('pre_get_posts', array(&$this, 'pre_get_posts'));
61 61
         }
62 62
         
63 63
         /**
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
          *
68 68
          * @param WPInv_Plugin $this. Current WPInv_Plugin instance. Passed by reference.
69 69
          */
70
-        do_action_ref_array( 'wpinv_actions', array( &$this ) );
70
+        do_action_ref_array('wpinv_actions', array(&$this));
71 71
 
72
-        add_action( 'admin_init', array( &$this, 'activation_redirect') );
72
+        add_action('admin_init', array(&$this, 'activation_redirect'));
73 73
     }
74 74
     
75 75
     public function plugins_loaded() {
@@ -83,193 +83,193 @@  discard block
 block discarded – undo
83 83
      * @since 1.0
84 84
      */
85 85
     public function load_textdomain() {
86
-        $locale = apply_filters( 'plugin_locale', get_locale(), 'invoicing' );
86
+        $locale = apply_filters('plugin_locale', get_locale(), 'invoicing');
87 87
         
88
-        load_textdomain( 'invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo' );
89
-        load_plugin_textdomain( 'invoicing', false, WPINV_PLUGIN_DIR . 'languages' );
88
+        load_textdomain('invoicing', WP_LANG_DIR . '/invoicing/invoicing-' . $locale . '.mo');
89
+        load_plugin_textdomain('invoicing', false, WPINV_PLUGIN_DIR . 'languages');
90 90
         
91 91
         /**
92 92
          * Define language constants.
93 93
          */
94
-        require_once( WPINV_PLUGIN_DIR . 'language.php' );
94
+        require_once(WPINV_PLUGIN_DIR . 'language.php');
95 95
     }
96 96
         
97 97
     public function includes() {
98 98
         global $wpinv_options;
99 99
         
100
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php' );
100
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/register-settings.php');
101 101
         $wpinv_options = wpinv_get_settings();
102 102
         
103
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php' );
104
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php' );
105
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php' );
106
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php' );
107
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php' );
108
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php' );
109
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php' );
110
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php' );
111
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php' );
112
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php' );
113
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php' );
114
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php' );
115
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php' );
116
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php' );
117
-        require_once( WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php' );
103
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-post-types.php');
104
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-email-functions.php');
105
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-general-functions.php');
106
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-helper-functions.php');
107
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-tax-functions.php');
108
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-template-functions.php');
109
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-address-functions.php');
110
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-invoice-functions.php');
111
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-item-functions.php');
112
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-discount-functions.php');
113
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gateway-functions.php');
114
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-payment-functions.php');
115
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-user-functions.php');
116
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-gd-functions.php');
117
+        require_once(WPINV_PLUGIN_DIR . 'includes/wpinv-error-functions.php');
118 118
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-db.php' );
119 119
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscriptions-db.php' );
120
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php' );
120
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-invoice.php');
121 121
         //require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-subscription.php' );
122
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php' );
123
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php' );
124
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php' );
125
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php' );
126
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php' );
127
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php' );
128
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php' );
129
-        if ( !class_exists( 'Geodir_EUVat' ) ) {
130
-            require_once( WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php' );
122
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-item.php');
123
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-notes.php');
124
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-session.php');
125
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-ajax.php');
126
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-api.php');
127
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-reports.php');
128
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-shortcodes.php');
129
+        if (!class_exists('Geodir_EUVat')) {
130
+            require_once(WPINV_PLUGIN_DIR . 'includes/libraries/wpinv-euvat/class-wpinv-euvat.php');
131 131
         }
132 132
         
133
-        $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
134
-        if ( !empty( $gateways ) ) {
135
-            foreach ( $gateways as $gateway ) {
136
-                if ( $gateway == 'manual' ) {
133
+        $gateways = array_keys(wpinv_get_enabled_payment_gateways());
134
+        if (!empty($gateways)) {
135
+            foreach ($gateways as $gateway) {
136
+                if ($gateway == 'manual') {
137 137
                     continue;
138 138
                 }
139 139
                 
140 140
                 $gateway_file = WPINV_PLUGIN_DIR . 'includes/gateways/' . $gateway . '.php';
141 141
                 
142
-                if ( file_exists( $gateway_file ) ) {
143
-                    require_once( $gateway_file );
142
+                if (file_exists($gateway_file)) {
143
+                    require_once($gateway_file);
144 144
                 }
145 145
             }
146 146
         }
147
-        require_once( WPINV_PLUGIN_DIR . 'includes/gateways/manual.php' );
147
+        require_once(WPINV_PLUGIN_DIR . 'includes/gateways/manual.php');
148 148
         
149
-        if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
150
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php' );
151
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php' );
152
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php' );
149
+        if (is_admin() || (defined('WP_CLI') && WP_CLI)) {
150
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-upgrade-functions.php');
151
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php');
152
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-meta-boxes.php');
153 153
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-recurring-admin.php' );
154
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php' );
155
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php' );
156
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php' );
157
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php' );
158
-            require_once( WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php' );
154
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-details.php');
155
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-items.php');
156
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-notes.php');
157
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/meta-boxes/class-mb-invoice-address.php');
158
+            require_once(WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php');
159 159
             //require_once( WPINV_PLUGIN_DIR . 'includes/admin/subscriptions.php' );
160 160
         }
161 161
         
162 162
         // include css inliner
163
-        if ( ! class_exists( 'Emogrifier' ) && class_exists( 'DOMDocument' ) ) {
164
-            include_once( WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php' );
163
+        if (!class_exists('Emogrifier') && class_exists('DOMDocument')) {
164
+            include_once(WPINV_PLUGIN_DIR . 'includes/libraries/class-emogrifier.php');
165 165
         }
166 166
         
167
-        require_once( WPINV_PLUGIN_DIR . 'includes/admin/install.php' );
167
+        require_once(WPINV_PLUGIN_DIR . 'includes/admin/install.php');
168 168
     }
169 169
     
170 170
     public function init() {
171 171
     }
172 172
     
173 173
     public function admin_init() {
174
-        if (!(defined( 'DOING_AJAX' ) && DOING_AJAX)) {
174
+        if (!(defined('DOING_AJAX') && DOING_AJAX)) {
175 175
         }
176 176
         
177
-        add_action( 'admin_print_scripts-edit.php', array( &$this, 'admin_print_scripts_edit_php' ) );
177
+        add_action('admin_print_scripts-edit.php', array(&$this, 'admin_print_scripts_edit_php'));
178 178
     }
179 179
 
180 180
     public function activation_redirect() {
181 181
         // Bail if no activation redirect
182
-        if ( !get_transient( '_wpinv_activation_redirect' ) ) {
182
+        if (!get_transient('_wpinv_activation_redirect')) {
183 183
             return;
184 184
         }
185 185
 
186 186
         // Delete the redirect transient
187
-        delete_transient( '_wpinv_activation_redirect' );
187
+        delete_transient('_wpinv_activation_redirect');
188 188
 
189 189
         // Bail if activating from network, or bulk
190
-        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
190
+        if (is_network_admin() || isset($_GET['activate-multi'])) {
191 191
             return;
192 192
         }
193 193
 
194
-        wp_safe_redirect( admin_url( 'admin.php?page=wpinv-settings&tab=general' ) );
194
+        wp_safe_redirect(admin_url('admin.php?page=wpinv-settings&tab=general'));
195 195
         exit;
196 196
     }
197 197
     
198 198
     public function enqueue_scripts() {
199
-        $suffix       = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
199
+        $suffix = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
200 200
         
201
-        wp_deregister_style( 'font-awesome' );
202
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
203
-        wp_enqueue_style( 'font-awesome' );
201
+        wp_deregister_style('font-awesome');
202
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
203
+        wp_enqueue_style('font-awesome');
204 204
         
205
-        wp_register_style( 'wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION );
206
-        wp_enqueue_style( 'wpinv_front_style' );
205
+        wp_register_style('wpinv_front_style', WPINV_PLUGIN_URL . 'assets/css/invoice-front.css', array(), WPINV_VERSION);
206
+        wp_enqueue_style('wpinv_front_style');
207 207
                
208 208
         // Register scripts
209
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
210
-        wp_register_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array( 'jquery', 'wpinv-vat-script' ),  WPINV_VERSION );
209
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
210
+        wp_register_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/invoice-front' . $suffix . '.js', array('jquery', 'wpinv-vat-script'), WPINV_VERSION);
211 211
         
212 212
         $localize                         = array();
213
-        $localize['ajax_url']             = admin_url( 'admin-ajax.php' );
214
-        $localize['nonce']                = wp_create_nonce( 'wpinv-nonce' );
213
+        $localize['ajax_url']             = admin_url('admin-ajax.php');
214
+        $localize['nonce']                = wp_create_nonce('wpinv-nonce');
215 215
         $localize['currency_symbol']      = wpinv_currency_symbol();
216 216
         $localize['currency_pos']         = wpinv_currency_position();
217 217
         $localize['thousand_sep']         = wpinv_thousands_separator();
218 218
         $localize['decimal_sep']          = wpinv_decimal_separator();
219 219
         $localize['decimals']             = wpinv_decimals();
220 220
         
221
-        $localize = apply_filters( 'wpinv_front_js_localize', $localize );
221
+        $localize = apply_filters('wpinv_front_js_localize', $localize);
222 222
         
223
-        wp_enqueue_script( 'jquery-blockui' );
224
-        wp_enqueue_script( 'wpinv-front-script' );
225
-        wp_localize_script( 'wpinv-front-script', 'WPInv', $localize );
223
+        wp_enqueue_script('jquery-blockui');
224
+        wp_enqueue_script('wpinv-front-script');
225
+        wp_localize_script('wpinv-front-script', 'WPInv', $localize);
226 226
     }
227 227
     
228 228
     public function admin_enqueue_scripts() {
229 229
         global $post, $pagenow;
230 230
         
231 231
         $post_type  = wpinv_admin_post_type();
232
-        $suffix     = '';//defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
232
+        $suffix     = ''; //defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
233 233
         
234
-        wp_deregister_style( 'font-awesome' );
235
-        wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0' );
236
-        wp_enqueue_style( 'font-awesome' );
234
+        wp_deregister_style('font-awesome');
235
+        wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome' . $suffix . '.css', array(), '4.7.0');
236
+        wp_enqueue_style('font-awesome');
237 237
         
238
-        wp_register_style( 'jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16' );
239
-        wp_enqueue_style( 'jquery-ui-css' );
238
+        wp_register_style('jquery-ui-css', WPINV_PLUGIN_URL . 'assets/css/jquery-ui' . $suffix . '.css', array(), '1.8.16');
239
+        wp_enqueue_style('jquery-ui-css');
240 240
         
241
-        wp_register_style( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2' );
242
-        wp_enqueue_style( 'jquery-chosen' );
241
+        wp_register_style('jquery-chosen', WPINV_PLUGIN_URL . 'assets/css/chosen' . $suffix . '.css', array(), '1.6.2');
242
+        wp_enqueue_style('jquery-chosen');
243 243
 
244
-        wp_register_script( 'jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6.2' );
245
-        wp_enqueue_script( 'jquery-chosen' );
244
+        wp_register_script('jquery-chosen', WPINV_PLUGIN_URL . 'assets/js/chosen.jquery' . $suffix . '.js', array('jquery'), '1.6.2');
245
+        wp_enqueue_script('jquery-chosen');
246 246
         
247
-        wp_register_style( 'wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION );
248
-        wp_enqueue_style( 'wpinv_meta_box_style' );
247
+        wp_register_style('wpinv_meta_box_style', WPINV_PLUGIN_URL . 'assets/css/meta-box.css', array(), WPINV_VERSION);
248
+        wp_enqueue_style('wpinv_meta_box_style');
249 249
         
250
-        wp_register_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION );
251
-        wp_enqueue_style( 'wpinv_admin_style' );
250
+        wp_register_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array(), WPINV_VERSION);
251
+        wp_enqueue_style('wpinv_admin_style');
252 252
         
253
-        if ( $post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ( $pagenow == 'post-new.php' || $pagenow == 'post.php' ) ) {
254
-            wp_enqueue_script( 'jquery-ui-datepicker' );
253
+        if ($post_type == 'wpi_discount' || $post_type == 'wpi_invoice' && ($pagenow == 'post-new.php' || $pagenow == 'post.php')) {
254
+            wp_enqueue_script('jquery-ui-datepicker');
255 255
         }
256 256
 
257
-        wp_enqueue_style( 'wp-color-picker' );
258
-        wp_enqueue_script( 'wp-color-picker' );
257
+        wp_enqueue_style('wp-color-picker');
258
+        wp_enqueue_script('wp-color-picker');
259 259
         
260
-        wp_register_script( 'jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array( 'jquery' ), '2.70', true );
260
+        wp_register_script('jquery-blockui', WPINV_PLUGIN_URL . 'assets/js/jquery.blockUI.min.js', array('jquery'), '2.70', true);
261 261
         
262
-        wp_register_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array( 'jquery', 'jquery-blockui' ),  WPINV_VERSION );
263
-        wp_enqueue_script( 'wpinv-admin-script' );
262
+        wp_register_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin' . $suffix . '.js', array('jquery', 'jquery-blockui'), WPINV_VERSION);
263
+        wp_enqueue_script('wpinv-admin-script');
264 264
         
265 265
         $localize                               = array();
266
-        $localize['ajax_url']                   = admin_url( 'admin-ajax.php' );
267
-        $localize['post_ID']                    = isset( $post->ID ) ? $post->ID : '';
268
-        $localize['wpinv_nonce']                = wp_create_nonce( 'wpinv-nonce' );
269
-        $localize['add_invoice_note_nonce']     = wp_create_nonce( 'add-invoice-note' );
270
-        $localize['delete_invoice_note_nonce']  = wp_create_nonce( 'delete-invoice-note' );
271
-        $localize['invoice_item_nonce']         = wp_create_nonce( 'invoice-item' );
272
-        $localize['billing_details_nonce']      = wp_create_nonce( 'get-billing-details' );
266
+        $localize['ajax_url']                   = admin_url('admin-ajax.php');
267
+        $localize['post_ID']                    = isset($post->ID) ? $post->ID : '';
268
+        $localize['wpinv_nonce']                = wp_create_nonce('wpinv-nonce');
269
+        $localize['add_invoice_note_nonce']     = wp_create_nonce('add-invoice-note');
270
+        $localize['delete_invoice_note_nonce']  = wp_create_nonce('delete-invoice-note');
271
+        $localize['invoice_item_nonce']         = wp_create_nonce('invoice-item');
272
+        $localize['billing_details_nonce']      = wp_create_nonce('get-billing-details');
273 273
         $localize['tax']                        = wpinv_tax_amount();
274 274
         $localize['discount']                   = wpinv_discount_amount();
275 275
         $localize['currency_symbol']            = wpinv_currency_symbol();
@@ -277,61 +277,61 @@  discard block
 block discarded – undo
277 277
         $localize['thousand_sep']               = wpinv_thousands_separator();
278 278
         $localize['decimal_sep']                = wpinv_decimal_separator();
279 279
         $localize['decimals']                   = wpinv_decimals();
280
-        $localize['save_invoice']               = __( 'Save Invoice', 'invoicing' );
281
-        $localize['status_publish']             = wpinv_status_nicename( 'publish' );
282
-        $localize['status_pending']             = wpinv_status_nicename( 'pending' );
283
-        $localize['delete_tax_rate']            = __( 'Are you sure you wish to delete this tax rate?', 'invoicing' );
284
-        $localize['OneItemMin']                 = __( 'Invoice must contain at least one item', 'invoicing' );
285
-        $localize['DeleteInvoiceItem']          = __( 'Are you sure you wish to delete this item?', 'invoicing' );
286
-        $localize['FillBillingDetails']         = __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' );
287
-        $localize['confirmCalcTotals']          = __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' );
288
-        $localize['AreYouSure']                 = __( 'Are you sure?', 'invoicing' );
280
+        $localize['save_invoice']               = __('Save Invoice', 'invoicing');
281
+        $localize['status_publish']             = wpinv_status_nicename('publish');
282
+        $localize['status_pending']             = wpinv_status_nicename('pending');
283
+        $localize['delete_tax_rate']            = __('Are you sure you wish to delete this tax rate?', 'invoicing');
284
+        $localize['OneItemMin']                 = __('Invoice must contain at least one item', 'invoicing');
285
+        $localize['DeleteInvoiceItem']          = __('Are you sure you wish to delete this item?', 'invoicing');
286
+        $localize['FillBillingDetails']         = __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing');
287
+        $localize['confirmCalcTotals']          = __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing');
288
+        $localize['AreYouSure']                 = __('Are you sure?', 'invoicing');
289 289
         $localize['hasGD']                      = wpinv_gd_active();
290 290
         $localize['hasPM']                      = wpinv_pm_active();
291
-        $localize['emptyInvoice']               = __( 'Add atleast one item to save invoice!', 'invoicing' );
292
-        $localize['deletePackage']              = __( 'GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing' );
293
-        $localize['deletePackages']             = __( 'GD package items should be deleted from GD payment manager only', 'invoicing' );
294
-        $localize['deleteInvoiceFirst']         = __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' );
291
+        $localize['emptyInvoice']               = __('Add atleast one item to save invoice!', 'invoicing');
292
+        $localize['deletePackage']              = __('GD package items should be deleted from GD payment manager only, otherwise it will break invoices that created with this package!', 'invoicing');
293
+        $localize['deletePackages']             = __('GD package items should be deleted from GD payment manager only', 'invoicing');
294
+        $localize['deleteInvoiceFirst']         = __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing');
295 295
 
296
-        $localize = apply_filters( 'wpinv_admin_js_localize', $localize );
296
+        $localize = apply_filters('wpinv_admin_js_localize', $localize);
297 297
 
298
-        wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', $localize );
298
+        wp_localize_script('wpinv-admin-script', 'WPInv_Admin', $localize);
299 299
     }
300 300
     
301
-    public function admin_body_class( $classes ) {
301
+    public function admin_body_class($classes) {
302 302
         global $pagenow, $post;
303 303
         
304
-        $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false;
304
+        $page = isset($_GET['page']) ? strtolower($_GET['page']) : false;
305 305
 
306 306
         $add_class = false;
307
-        if ( $pagenow == 'admin.php' && $page ) {
308
-            $add_class = strpos( $page, 'wpinv-' );
307
+        if ($pagenow == 'admin.php' && $page) {
308
+            $add_class = strpos($page, 'wpinv-');
309 309
         }
310 310
         
311 311
         $settings_class = array();
312
-        if ( $page == 'wpinv-settings' ) {
313
-            if ( !empty( $_REQUEST['tab'] ) ) {
314
-                $settings_class[] = sanitize_text_field( $_REQUEST['tab'] );
312
+        if ($page == 'wpinv-settings') {
313
+            if (!empty($_REQUEST['tab'])) {
314
+                $settings_class[] = sanitize_text_field($_REQUEST['tab']);
315 315
             }
316 316
             
317
-            if ( !empty( $_REQUEST['section'] ) ) {
318
-                $settings_class[] = sanitize_text_field( $_REQUEST['section'] );
317
+            if (!empty($_REQUEST['section'])) {
318
+                $settings_class[] = sanitize_text_field($_REQUEST['section']);
319 319
             }
320 320
             
321
-            $settings_class[] = isset( $_REQUEST['wpi_sub'] ) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field( $_REQUEST['wpi_sub'] ) : 'main';
321
+            $settings_class[] = isset($_REQUEST['wpi_sub']) && $_REQUEST['wpi_sub'] !== '' ? sanitize_text_field($_REQUEST['wpi_sub']) : 'main';
322 322
         }
323 323
         
324
-        if ( !empty( $settings_class ) ) {
325
-            $classes .= ' wpi-' . wpinv_sanitize_key( implode( $settings_class, '-' ) );
324
+        if (!empty($settings_class)) {
325
+            $classes .= ' wpi-' . wpinv_sanitize_key(implode($settings_class, '-'));
326 326
         }
327 327
         
328 328
         $post_type = wpinv_admin_post_type();
329 329
 
330
-        if ( $post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false ) {
330
+        if ($post_type == 'wpi_invoice' || $post_type == 'wpi_quote' || $add_class !== false) {
331 331
             return $classes .= ' wpinv';
332 332
         }
333 333
         
334
-        if ( $pagenow == 'post.php' && $post_type == 'wpi_item' && !empty( $post ) && !wpinv_item_is_editable( $post ) ) {
334
+        if ($pagenow == 'post.php' && $post_type == 'wpi_item' && !empty($post) && !wpinv_item_is_editable($post)) {
335 335
             $classes .= ' wpi-editable-n';
336 336
         }
337 337
 
@@ -343,20 +343,20 @@  discard block
 block discarded – undo
343 343
     }
344 344
     
345 345
     public function wpinv_actions() {
346
-        if ( isset( $_REQUEST['wpi_action'] ) ) {
347
-            do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST );
346
+        if (isset($_REQUEST['wpi_action'])) {
347
+            do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST);
348 348
         }
349 349
     }
350 350
     
351
-    public function pre_get_posts( $wp_query ) {
352
-        if ( !empty( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) {
353
-            $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses() );
351
+    public function pre_get_posts($wp_query) {
352
+        if (!empty($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'wpi_invoice' && is_user_logged_in() && is_single() && $wp_query->is_main_query()) {
353
+            $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses());
354 354
         }
355 355
         
356 356
         return $wp_query;
357 357
     }
358 358
     
359 359
     public function bp_invoicing_init() {
360
-        require_once( WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php' );
360
+        require_once(WPINV_PLUGIN_DIR . 'includes/class-wpinv-bp-core.php');
361 361
     }
362 362
 }
363 363
\ No newline at end of file
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-items.php 1 patch
Spacing   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -1,22 +1,22 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Items {
8
-    public static function output( $post ) {        
8
+    public static function output($post) {        
9 9
         global $wpinv_euvat, $ajax_cart_details;
10 10
         
11
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
12
-        $invoice            = new WPInv_Invoice( $post_id );
11
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
12
+        $invoice            = new WPInv_Invoice($post_id);
13 13
         $ajax_cart_details  = $invoice->get_cart_details();
14
-        $subtotal           = $invoice->get_subtotal( true );
14
+        $subtotal           = $invoice->get_subtotal(true);
15 15
         $discount_raw       = $invoice->get_discount();
16
-        $discount           = wpinv_price( $discount_raw, $invoice->get_currency() );
16
+        $discount           = wpinv_price($discount_raw, $invoice->get_currency());
17 17
         $discounts          = $discount_raw > 0 ? $invoice->get_discounts() : '';
18
-        $tax                = $invoice->get_tax( true );
19
-        $total              = $invoice->get_total( true );
18
+        $tax                = $invoice->get_tax(true);
19
+        $total              = $invoice->get_total(true);
20 20
         $item_quantities    = wpinv_item_quantities_enabled();
21 21
         $use_taxes          = wpinv_use_taxes();
22 22
         $item_types         = wpinv_get_item_types();
@@ -29,17 +29,17 @@  discard block
 block discarded – undo
29 29
         }
30 30
         
31 31
         $cols = 5;
32
-        if ( $item_quantities ) {
32
+        if ($item_quantities) {
33 33
             $cols++;
34 34
         }
35
-        if ( $use_taxes ) {
35
+        if ($use_taxes) {
36 36
             $cols++;
37 37
         }
38 38
         $class = '';
39
-        if ( $invoice->is_paid() ) {
39
+        if ($invoice->is_paid()) {
40 40
             $class .= ' wpinv-paid';
41 41
         }
42
-        if ( $is_recurring ) {
42
+        if ($is_recurring) {
43 43
             $class .= ' wpi-recurring';
44 44
         }
45 45
         ?>
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
             <table id="wpinv_items" class="wpinv-items" cellspacing="0" cellpadding="0">
48 48
                 <thead>
49 49
                     <tr>
50
-                        <th class="id"><?php _e( 'ID', 'invoicing' );?></th>
51
-                        <th class="title"><?php _e( 'Item', 'invoicing' );?></th>
52
-                        <th class="price"><?php _e( 'Price', 'invoicing' );?></th>
53
-                        <?php if ( $item_quantities ) { ?>
54
-                        <th class="qty"><?php _e( 'Qty', 'invoicing' );?></th>
50
+                        <th class="id"><?php _e('ID', 'invoicing'); ?></th>
51
+                        <th class="title"><?php _e('Item', 'invoicing'); ?></th>
52
+                        <th class="price"><?php _e('Price', 'invoicing'); ?></th>
53
+                        <?php if ($item_quantities) { ?>
54
+                        <th class="qty"><?php _e('Qty', 'invoicing'); ?></th>
55 55
                         <?php } ?>
56
-                        <th class="total"><?php _e( 'Total', 'invoicing' );?></th>
57
-                        <?php if ( $use_taxes ) { ?>
58
-                        <th class="tax"><?php _e( 'Tax (%)', 'invoicing' );?></th>
56
+                        <th class="total"><?php _e('Total', 'invoicing'); ?></th>
57
+                        <?php if ($use_taxes) { ?>
58
+                        <th class="tax"><?php _e('Tax (%)', 'invoicing'); ?></th>
59 59
                         <?php } ?>
60 60
                         <th class="action"></th>
61 61
                     </tr>
62 62
                 </thead>
63 63
                 <tbody class="wpinv-line-items">
64
-                    <?php echo wpinv_admin_get_line_items( $invoice ); ?>
64
+                    <?php echo wpinv_admin_get_line_items($invoice); ?>
65 65
                 </tbody>
66 66
                 <tfoot class="wpinv-totals">
67 67
                     <tr>
@@ -73,44 +73,44 @@  discard block
 block discarded – undo
73 73
                                         </td>
74 74
                                         <td class="title">
75 75
                                             <input type="text" class="regular-text" placeholder="Item name" value="" name="_wpinv_quick[name]">
76
-                                            <?php if ( $wpinv_euvat->allow_vat_rules() ) { ?>
76
+                                            <?php if ($wpinv_euvat->allow_vat_rules()) { ?>
77 77
                                             <div class="wp-clearfix">
78 78
                                                 <label class="wpi-vat-rule">
79
-                                                    <span class="title"><?php _e( 'VAT rule type', 'invoicing' );?></span>
79
+                                                    <span class="title"><?php _e('VAT rule type', 'invoicing'); ?></span>
80 80
                                                     <span class="input-text-wrap">
81
-                                                        <?php echo wpinv_html_select( array(
81
+                                                        <?php echo wpinv_html_select(array(
82 82
                                                             'options'          => $wpinv_euvat->get_rules(),
83 83
                                                             'name'             => '_wpinv_quick[vat_rule]',
84 84
                                                             'id'               => '_wpinv_quick_vat_rule',
85 85
                                                             'show_option_all'  => false,
86 86
                                                             'show_option_none' => false,
87 87
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-rule',
88
-                                                        ) ); ?>
88
+                                                        )); ?>
89 89
                                                     </span>
90 90
                                                 </label>
91 91
                                             </div>
92
-                                            <?php } if ( $wpinv_euvat->allow_vat_classes() ) { ?>
92
+                                            <?php } if ($wpinv_euvat->allow_vat_classes()) { ?>
93 93
                                             <div class="wp-clearfix">
94 94
                                                 <label class="wpi-vat-class">
95
-                                                    <span class="title"><?php _e( 'VAT class', 'invoicing' );?></span>
95
+                                                    <span class="title"><?php _e('VAT class', 'invoicing'); ?></span>
96 96
                                                     <span class="input-text-wrap">
97
-                                                        <?php echo wpinv_html_select( array(
97
+                                                        <?php echo wpinv_html_select(array(
98 98
                                                             'options'          => $wpinv_euvat->get_all_classes(),
99 99
                                                             'name'             => '_wpinv_quick[vat_class]',
100 100
                                                             'id'               => '_wpinv_quick_vat_class',
101 101
                                                             'show_option_all'  => false,
102 102
                                                             'show_option_none' => false,
103 103
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-vat-class',
104
-                                                        ) ); ?>
104
+                                                        )); ?>
105 105
                                                     </span>
106 106
                                                 </label>
107 107
                                             </div>
108 108
                                             <?php } ?>
109 109
                                             <div class="wp-clearfix">
110 110
                                                 <label class="wpi-item-type">
111
-                                                    <span class="title"><?php _e( 'Item type', 'invoicing' );?></span>
111
+                                                    <span class="title"><?php _e('Item type', 'invoicing'); ?></span>
112 112
                                                     <span class="input-text-wrap">
113
-                                                        <?php echo wpinv_html_select( array(
113
+                                                        <?php echo wpinv_html_select(array(
114 114
                                                             'options'          => $item_types,
115 115
                                                             'name'             => '_wpinv_quick[type]',
116 116
                                                             'id'               => '_wpinv_quick_type',
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
                                                             'show_option_all'  => false,
119 119
                                                             'show_option_none' => false,
120 120
                                                             'class'            => 'gdmbx2-text-medium wpinv-quick-type',
121
-                                                        ) ); ?>
121
+                                                        )); ?>
122 122
                                                     </span>
123 123
                                                 </label>
124 124
                                             </div>
@@ -131,11 +131,11 @@  discard block
 block discarded – undo
131 131
                                             </div>
132 132
                                         </td>
133 133
                                         <td class="price"><input type="text" placeholder="0.00" class="wpi-field-price wpi-price" name="_wpinv_quick[price]" /></td>
134
-                                        <?php if ( $item_quantities ) { ?>
134
+                                        <?php if ($item_quantities) { ?>
135 135
                                         <td class="qty"><input type="number" class="small-text" step="1" min="1" value="1" name="_wpinv_quick[qty]" /></td>
136 136
                                         <?php } ?>
137 137
                                         <td class="total"></td>
138
-                                        <?php if ( $use_taxes ) { ?>
138
+                                        <?php if ($use_taxes) { ?>
139 139
                                         <td class="tax"></td>
140 140
                                         <?php } ?>
141 141
                                         <td class="action"></td>
@@ -148,29 +148,29 @@  discard block
 block discarded – undo
148 148
                         <td colspan="<?php echo $cols; ?>"></td>
149 149
                     </tr>
150 150
                     <tr class="totals">
151
-                        <td colspan="<?php echo ( $cols - 4 ); ?>"></td>
151
+                        <td colspan="<?php echo ($cols - 4); ?>"></td>
152 152
                         <td colspan="4">
153 153
                             <table cellspacing="0" cellpadding="0">
154 154
                                 <tr class="subtotal">
155
-                                    <td class="name"><?php _e( 'Sub Total:', 'invoicing' );?></td>
156
-                                    <td class="total"><?php echo $subtotal;?></td>
155
+                                    <td class="name"><?php _e('Sub Total:', 'invoicing'); ?></td>
156
+                                    <td class="total"><?php echo $subtotal; ?></td>
157 157
                                     <td class="action"></td>
158 158
                                 </tr>
159 159
                                 <tr class="discount">
160
-                                    <td class="name"><?php wpinv_get_discount_label( wpinv_discount_code( $invoice->ID ) ); ?>:</td>
161
-                                    <td class="total"><?php echo wpinv_discount( $invoice->ID, true, true ); ?></td>
160
+                                    <td class="name"><?php wpinv_get_discount_label(wpinv_discount_code($invoice->ID)); ?>:</td>
161
+                                    <td class="total"><?php echo wpinv_discount($invoice->ID, true, true); ?></td>
162 162
                                     <td class="action"></td>
163 163
                                 </tr>
164
-                                <?php if ( $use_taxes ) { ?>
164
+                                <?php if ($use_taxes) { ?>
165 165
                                 <tr class="tax">
166
-                                    <td class="name"><?php _e( 'Tax:', 'invoicing' );?></td>
167
-                                    <td class="total"><?php echo $tax;?></td>
166
+                                    <td class="name"><?php _e('Tax:', 'invoicing'); ?></td>
167
+                                    <td class="total"><?php echo $tax; ?></td>
168 168
                                     <td class="action"></td>
169 169
                                 </tr>
170 170
                                 <?php } ?>
171 171
                                 <tr class="total">
172
-                                    <td class="name"><?php echo apply_filters( 'wpinv_invoice_items_total_label', __( 'Invoice Total:', 'invoicing' ), $invoice );?></td>
173
-                                    <td class="total"><?php echo $total;?></td>
172
+                                    <td class="name"><?php echo apply_filters('wpinv_invoice_items_total_label', __('Invoice Total:', 'invoicing'), $invoice); ?></td>
173
+                                    <td class="total"><?php echo $total; ?></td>
174 174
                                     <td class="action"></td>
175 175
                                 </tr>
176 176
                             </table>
@@ -180,89 +180,89 @@  discard block
 block discarded – undo
180 180
             </table>
181 181
             <div class="wpinv-actions">
182 182
                 <?php
183
-                    if ( !$invoice->is_paid() ) {
184
-                    if ( !$invoice->is_recurring() ) {
185
-                    echo wpinv_item_dropdown( array(
183
+                    if (!$invoice->is_paid()) {
184
+                    if (!$invoice->is_recurring()) {
185
+                    echo wpinv_item_dropdown(array(
186 186
                         'name'             => 'wpinv_invoice_item',
187 187
                         'id'               => 'wpinv_invoice_item',
188 188
                         'with_packages'    => false,
189 189
                         'show_recurring'   => true,
190
-                    ) );
190
+                    ));
191 191
                     ?>
192
-                <input type="button" value="<?php echo sprintf(esc_attr__( 'Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e( 'Create new item', 'invoicing' );?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e( 'Recalculate Totals', 'invoicing' );?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
192
+                <input type="button" value="<?php echo sprintf(esc_attr__('Add item to %s', 'invoicing'), $type_title); ?>" class="button button-primary" id="wpinv-add-item"><input type="button" value="<?php esc_attr_e('Create new item', 'invoicing'); ?>" class="button button-primary" id="wpinv-new-item"><?php } ?><input type="button" value="<?php esc_attr_e('Recalculate Totals', 'invoicing'); ?>" class="button button-primary wpinv-flr" id="wpinv-recalc-totals">
193 193
                     <?php } ?>
194
-                <?php do_action( 'wpinv_invoice_items_actions', $invoice ); ?>
194
+                <?php do_action('wpinv_invoice_items_actions', $invoice); ?>
195 195
             </div>
196 196
         </div>
197 197
         <?php
198 198
     }
199 199
     
200
-    public static function prices( $post ) {        
200
+    public static function prices($post) {        
201 201
         $symbol         = wpinv_currency_symbol();
202 202
         $position       = wpinv_currency_position();
203
-        $item           = new WPInv_Item( $post->ID );
203
+        $item           = new WPInv_Item($post->ID);
204 204
         
205 205
         $price          = $item->get_price();
206 206
         $is_recurring   = $item->is_recurring();
207 207
         $period         = $item->get_recurring_period();
208
-        $interval       = absint( $item->get_recurring_interval() );
209
-        $times          = absint( $item->get_recurring_limit() );
208
+        $interval       = absint($item->get_recurring_interval());
209
+        $times          = absint($item->get_recurring_limit());
210 210
         $free_trial     = $item->has_free_trial();
211 211
         $trial_interval = $item->get_trial_interval();
212 212
         $trial_period   = $item->get_trial_period();
213 213
         
214 214
         $intervals      = array();
215
-        for ( $i = 1; $i <= 90; $i++ ) {
215
+        for ($i = 1; $i <= 90; $i++) {
216 216
             $intervals[$i] = $i;
217 217
         }
218 218
         
219
-        $interval       = $interval > 0 ? $interval : 1;
219
+        $interval = $interval > 0 ? $interval : 1;
220 220
         
221 221
         $class = $is_recurring ? 'wpinv-recurring-y' : 'wpinv-recurring-n';
222 222
         ?>
223
-        <p class="wpinv-row-prices"><?php echo ( $position != 'right' ? $symbol . '&nbsp;' : '' );?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount( 0 ); ?>" value="<?php echo $price;?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled( $item->is_package(), true ); ?> /><?php echo ( $position == 'right' ? '&nbsp;' . $symbol : '' );?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce( 'wpinv_item_meta_box_save' ) ;?>" />
224
-        <?php if ( $item->is_package() ) { ?>
225
-        <span class="description"><?php _e( 'GD package item price can be edited only from GD payment manager.', 'invoicing' ); ?></span>
223
+        <p class="wpinv-row-prices"><?php echo ($position != 'right' ? $symbol . '&nbsp;' : ''); ?><input type="text" maxlength="12" placeholder="<?php echo wpinv_sanitize_amount(0); ?>" value="<?php echo $price; ?>" id="wpinv_item_price" name="wpinv_item_price" class="medium-text wpi-field-price wpi-price" <?php disabled($item->is_package(), true); ?> /><?php echo ($position == 'right' ? '&nbsp;' . $symbol : ''); ?><input type="hidden" name="wpinv_vat_meta_box_nonce" value="<?php echo wp_create_nonce('wpinv_item_meta_box_save'); ?>" />
224
+        <?php if ($item->is_package()) { ?>
225
+        <span class="description"><?php _e('GD package item price can be edited only from GD payment manager.', 'invoicing'); ?></span>
226 226
         <?php } ?>
227 227
         </p>
228 228
         <p class="wpinv-row-is-recurring">
229 229
             <label for="wpinv_is_recurring">
230
-                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked( 1, $is_recurring ); ?> />
231
-                <?php echo apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Is Recurring Item?', 'invoicing' ) ); ?>
230
+                <input type="checkbox" name="wpinv_is_recurring" id="wpinv_is_recurring" value="1" <?php checked(1, $is_recurring); ?> />
231
+                <?php echo apply_filters('wpinv_is_recurring_toggle_text', __('Is Recurring Item?', 'invoicing')); ?>
232 232
             </label>
233 233
         </p>
234
-        <p class="wpinv-row-recurring-fields <?php echo $class;?>">
235
-                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e( 'Recurring', 'invoicing' );?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e( 'day(s)', 'invoicing' ); ?>" <?php selected( 'D', $period );?>><?php _e( 'Daily', 'invoicing' ); ?></option><option value="W" data-text="<?php esc_attr_e( 'week(s)', 'invoicing' ); ?>" <?php selected( 'W', $period );?>><?php _e( 'Weekly', 'invoicing' ); ?></option><option value="M" data-text="<?php esc_attr_e( 'month(s)', 'invoicing' ); ?>" <?php selected( 'M', $period );?>><?php _e( 'Monthly', 'invoicing' ); ?></option><option value="Y" data-text="<?php esc_attr_e( 'year(s)', 'invoicing' ); ?>" <?php selected( 'Y', $period );?>><?php _e( 'Yearly', 'invoicing' ); ?></option></select></label>
236
-                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e( 'at every', 'invoicing' );?> <?php echo wpinv_html_select( array(
234
+        <p class="wpinv-row-recurring-fields <?php echo $class; ?>">
235
+                <label class="wpinv-period" for="wpinv_recurring_period"><?php _e('Recurring', 'invoicing'); ?> <select class="wpinv-select " id="wpinv_recurring_period" name="wpinv_recurring_period"><option value="D" data-text="<?php esc_attr_e('day(s)', 'invoicing'); ?>" <?php selected('D', $period); ?>><?php _e('Daily', 'invoicing'); ?></option><option value="W" data-text="<?php esc_attr_e('week(s)', 'invoicing'); ?>" <?php selected('W', $period); ?>><?php _e('Weekly', 'invoicing'); ?></option><option value="M" data-text="<?php esc_attr_e('month(s)', 'invoicing'); ?>" <?php selected('M', $period); ?>><?php _e('Monthly', 'invoicing'); ?></option><option value="Y" data-text="<?php esc_attr_e('year(s)', 'invoicing'); ?>" <?php selected('Y', $period); ?>><?php _e('Yearly', 'invoicing'); ?></option></select></label>
236
+                <label class="wpinv-interval" for="wpinv_recurring_interval"> <?php _e('at every', 'invoicing'); ?> <?php echo wpinv_html_select(array(
237 237
                     'options'          => $intervals,
238 238
                     'name'             => 'wpinv_recurring_interval',
239 239
                     'id'               => 'wpinv_recurring_interval',
240 240
                     'selected'         => $interval,
241 241
                     'show_option_all'  => false,
242 242
                     'show_option_none' => false
243
-                ) ); ?> <span id="wpinv_interval_text"><?php _e( 'day(s)', 'invoicing' );?></span></label>
244
-                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e( 'for', 'invoicing' );?> <input class="small-text" type="number" value="<?php echo $times;?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e( 'time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing' );?></label>
243
+                )); ?> <span id="wpinv_interval_text"><?php _e('day(s)', 'invoicing'); ?></span></label>
244
+                <label class="wpinv-times" for="wpinv_recurring_limit"> <?php _e('for', 'invoicing'); ?> <input class="small-text" type="number" value="<?php echo $times; ?>" size="4" id="wpinv_recurring_limit" name="wpinv_recurring_limit" step="1" min="0"> <?php _e('time(s) <i>(select 0 for recurring forever until cancelled</i>)', 'invoicing'); ?></label>
245 245
                 <span class="clear wpi-trial-clr"></span>
246 246
                 <label class="wpinv-free-trial" for="wpinv_free_trial">
247
-                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked( true, (bool)$free_trial ); ?> /> 
248
-                    <?php echo __( 'Offer free trial for', 'invoicing' ); ?>
247
+                    <input type="checkbox" name="wpinv_free_trial" id="wpinv_free_trial" value="1" <?php checked(true, (bool)$free_trial); ?> /> 
248
+                    <?php echo __('Offer free trial for', 'invoicing'); ?>
249 249
                 </label>
250 250
                 <label class="wpinv-trial-interval" for="wpinv_trial_interval">
251
-                    <input class="small-text" type="number" value="<?php echo $trial_interval;?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected( 'D', $trial_period );?>><?php _e( 'day(s)', 'invoicing' ); ?></option><option value="W" <?php selected( 'W', $trial_period );?>><?php _e( 'week(s)', 'invoicing' ); ?></option><option value="M" <?php selected( 'M', $trial_period );?>><?php _e( 'month(s)', 'invoicing' ); ?></option><option value="Y" <?php selected( 'Y', $trial_period );?>><?php _e( 'year(s)', 'invoicing' ); ?></option></select>
251
+                    <input class="small-text" type="number" value="<?php echo $trial_interval; ?>" size="4" id="wpinv_trial_interval" name="wpinv_trial_interval" step="1" min="1"> <select class="wpinv-select" id="wpinv_trial_period" name="wpinv_trial_period"><option value="D" <?php selected('D', $trial_period); ?>><?php _e('day(s)', 'invoicing'); ?></option><option value="W" <?php selected('W', $trial_period); ?>><?php _e('week(s)', 'invoicing'); ?></option><option value="M" <?php selected('M', $trial_period); ?>><?php _e('month(s)', 'invoicing'); ?></option><option value="Y" <?php selected('Y', $trial_period); ?>><?php _e('year(s)', 'invoicing'); ?></option></select>
252 252
                 </label>
253 253
         </p>
254
-        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type( $post->ID ); ?>" />
255
-        <?php do_action( 'wpinv_item_price_field', $post->ID ); ?>
254
+        <input type="hidden" id="_wpi_current_type" value="<?php echo wpinv_get_item_type($post->ID); ?>" />
255
+        <?php do_action('wpinv_item_price_field', $post->ID); ?>
256 256
         <?php
257 257
     }
258 258
     
259
-    public static function vat_rules( $post ) {
259
+    public static function vat_rules($post) {
260 260
         global $wpinv_euvat;
261 261
         
262
-        $rule_type = $wpinv_euvat->get_item_rule( $post->ID );
262
+        $rule_type = $wpinv_euvat->get_item_rule($post->ID);
263 263
         ?>
264
-        <p><label for="wpinv_vat_rules"><strong><?php _e( 'Select how VAT rules will be applied:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
265
-        <?php echo wpinv_html_select( array(
264
+        <p><label for="wpinv_vat_rules"><strong><?php _e('Select how VAT rules will be applied:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
265
+        <?php echo wpinv_html_select(array(
266 266
                     'options'          => $wpinv_euvat->get_rules(),
267 267
                     'name'             => 'wpinv_vat_rules',
268 268
                     'id'               => 'wpinv_vat_rules',
@@ -270,19 +270,19 @@  discard block
 block discarded – undo
270 270
                     'show_option_all'  => false,
271 271
                     'show_option_none' => false,
272 272
                     'class'            => 'gdmbx2-text-medium wpinv-vat-rules',
273
-                ) ); ?>
273
+                )); ?>
274 274
         </p>
275
-        <p class="wpi-m0"><?php _e( 'When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing' ); ?></p>
276
-        <p class="wpi-m0"><?php _e( 'If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing' ); ?></p>
275
+        <p class="wpi-m0"><?php _e('When you select physical product rules, only consumers and businesses in your country will be charged VAT.  The VAT rate used will be the rate in your country.', 'invoicing'); ?></p>
276
+        <p class="wpi-m0"><?php _e('If you select Digital product rules, VAT will be charged at the rate that applies in the country of the consumer.  Only businesses in your country will be charged VAT.', 'invoicing'); ?></p>
277 277
         <?php
278 278
     }
279 279
     
280
-    public static function vat_classes( $post ) {
280
+    public static function vat_classes($post) {
281 281
         global $wpinv_euvat;
282 282
         
283
-        $vat_class = $wpinv_euvat->get_item_class( $post->ID );
283
+        $vat_class = $wpinv_euvat->get_item_class($post->ID);
284 284
         ?>
285
-        <p><?php echo wpinv_html_select( array(
285
+        <p><?php echo wpinv_html_select(array(
286 286
                     'options'          => $wpinv_euvat->get_all_classes(),
287 287
                     'name'             => 'wpinv_vat_class',
288 288
                     'id'               => 'wpinv_vat_class',
@@ -290,18 +290,18 @@  discard block
 block discarded – undo
290 290
                     'show_option_all'  => false,
291 291
                     'show_option_none' => false,
292 292
                     'class'            => 'gdmbx2-text-medium wpinv-vat-class',
293
-                ) ); ?>
293
+                )); ?>
294 294
         </p>
295
-        <p class="wpi-m0"><?php _e( 'Select the VAT rate class to use for this invoice item.', 'invoicing' ); ?></p>
295
+        <p class="wpi-m0"><?php _e('Select the VAT rate class to use for this invoice item.', 'invoicing'); ?></p>
296 296
         <?php
297 297
     }
298 298
     
299
-    public static function item_info( $post ) {
300
-        $item_type = wpinv_get_item_type( $post->ID );
301
-        do_action( 'wpinv_item_info_metabox_before', $post );
299
+    public static function item_info($post) {
300
+        $item_type = wpinv_get_item_type($post->ID);
301
+        do_action('wpinv_item_info_metabox_before', $post);
302 302
         ?>
303
-        <p><label for="wpinv_item_type"><strong><?php _e( 'Type:', 'invoicing' );?></strong></label>&nbsp;&nbsp;&nbsp;
304
-        <?php echo wpinv_html_select( array(
303
+        <p><label for="wpinv_item_type"><strong><?php _e('Type:', 'invoicing'); ?></strong></label>&nbsp;&nbsp;&nbsp;
304
+        <?php echo wpinv_html_select(array(
305 305
                     'options'          => wpinv_get_item_types(),
306 306
                     'name'             => 'wpinv_item_type',
307 307
                     'id'               => 'wpinv_item_type',
@@ -310,114 +310,114 @@  discard block
 block discarded – undo
310 310
                     'show_option_none' => false,
311 311
                     'class'            => 'gdmbx2-text-medium wpinv-item-type',
312 312
                     //'disabled'         => $item_type == 'package' ? true : false,
313
-                ) ); ?>
313
+                )); ?>
314 314
         </p>
315
-        <p class="wpi-m0"><?php _e( 'Select item type.', 'invoicing' );?><br><?php _e( '<b>Standard:</b> Standard item type', 'invoicing' );?><br><?php _e( '<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing' );?></p>
315
+        <p class="wpi-m0"><?php _e('Select item type.', 'invoicing'); ?><br><?php _e('<b>Standard:</b> Standard item type', 'invoicing'); ?><br><?php _e('<b>Fee:</b> Like Registration Fee, Sign up Fee etc.', 'invoicing'); ?></p>
316 316
         <?php
317
-        do_action( 'wpinv_item_info_metabox_after', $post );
317
+        do_action('wpinv_item_info_metabox_after', $post);
318 318
     }
319 319
     
320
-    public static function meta_values( $post ) {
321
-        $meta_keys = apply_filters( 'wpinv_show_meta_values_for_keys', array(
320
+    public static function meta_values($post) {
321
+        $meta_keys = apply_filters('wpinv_show_meta_values_for_keys', array(
322 322
             'type',
323 323
             'custom_id'
324
-        ) );
324
+        ));
325 325
         
326
-        if ( empty( $meta_keys ) ) {
326
+        if (empty($meta_keys)) {
327 327
             return;
328 328
         }
329 329
         
330
-        do_action( 'wpinv_meta_values_metabox_before', $post );
330
+        do_action('wpinv_meta_values_metabox_before', $post);
331 331
         
332
-        foreach ( $meta_keys as $meta_key ) {
332
+        foreach ($meta_keys as $meta_key) {
333 333
             ?>
334
-            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta( $post->ID, '_wpinv_' . $meta_key, true ); ?></label></p>
334
+            <p class="wpi-mtb05"><label><strong><?php echo $meta_key; ?></strong>: <?php echo get_post_meta($post->ID, '_wpinv_' . $meta_key, true); ?></label></p>
335 335
             <?php 
336 336
         }
337 337
         
338
-        do_action( 'wpinv_meta_values_metabox_after', $post );
338
+        do_action('wpinv_meta_values_metabox_after', $post);
339 339
     }
340 340
     
341
-    public static function save( $post_id, $data, $post ) {
342
-        $invoice        = new WPInv_Invoice( $post_id );
341
+    public static function save($post_id, $data, $post) {
342
+        $invoice        = new WPInv_Invoice($post_id);
343 343
         
344 344
         // Billing
345
-        $first_name     = sanitize_text_field( $data['wpinv_first_name'] );
346
-        $last_name      = sanitize_text_field( $data['wpinv_last_name'] );
347
-        $company        = sanitize_text_field( $data['wpinv_company'] );
348
-        $vat_number     = sanitize_text_field( $data['wpinv_vat_number'] );
349
-        $phone          = sanitize_text_field( $data['wpinv_phone'] );
350
-        $address        = sanitize_text_field( $data['wpinv_address'] );
351
-        $city           = sanitize_text_field( $data['wpinv_city'] );
352
-        $zip            = sanitize_text_field( $data['wpinv_zip'] );
353
-        $country        = sanitize_text_field( $data['wpinv_country'] );
354
-        $state          = sanitize_text_field( $data['wpinv_state'] );
345
+        $first_name     = sanitize_text_field($data['wpinv_first_name']);
346
+        $last_name      = sanitize_text_field($data['wpinv_last_name']);
347
+        $company        = sanitize_text_field($data['wpinv_company']);
348
+        $vat_number     = sanitize_text_field($data['wpinv_vat_number']);
349
+        $phone          = sanitize_text_field($data['wpinv_phone']);
350
+        $address        = sanitize_text_field($data['wpinv_address']);
351
+        $city           = sanitize_text_field($data['wpinv_city']);
352
+        $zip            = sanitize_text_field($data['wpinv_zip']);
353
+        $country        = sanitize_text_field($data['wpinv_country']);
354
+        $state          = sanitize_text_field($data['wpinv_state']);
355 355
         
356 356
         // Details
357
-        $status         = sanitize_text_field( $data['wpinv_status'] );
358
-        $old_status     = !empty( $data['original_post_status'] ) ? sanitize_text_field( $data['original_post_status'] ) : $status;
359
-        $number         = sanitize_text_field( $data['wpinv_number'] );
360
-        $due_date       = isset( $data['wpinv_due_date'] ) ? sanitize_text_field( $data['wpinv_due_date'] ) : '';
357
+        $status         = sanitize_text_field($data['wpinv_status']);
358
+        $old_status     = !empty($data['original_post_status']) ? sanitize_text_field($data['original_post_status']) : $status;
359
+        $number         = sanitize_text_field($data['wpinv_number']);
360
+        $due_date       = isset($data['wpinv_due_date']) ? sanitize_text_field($data['wpinv_due_date']) : '';
361 361
         //$discounts      = sanitize_text_field( $data['wpinv_discounts'] );
362 362
         //$discount       = sanitize_text_field( $data['wpinv_discount'] );
363 363
         
364
-        $ip             = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
364
+        $ip = $invoice->get_ip() ? $invoice->get_ip() : wpinv_get_ip();
365 365
         
366
-        $invoice->set( 'due_date', $due_date );
367
-        $invoice->set( 'first_name', $first_name );
368
-        $invoice->set( 'last_name', $last_name );
369
-        $invoice->set( 'company', $company );
370
-        $invoice->set( 'vat_number', $vat_number );
371
-        $invoice->set( 'phone', $phone );
372
-        $invoice->set( 'address', $address );
373
-        $invoice->set( 'city', $city );
374
-        $invoice->set( 'zip', $zip );
375
-        $invoice->set( 'country', $country );
376
-        $invoice->set( 'state', $state );
377
-        $invoice->set( 'status', $status );
366
+        $invoice->set('due_date', $due_date);
367
+        $invoice->set('first_name', $first_name);
368
+        $invoice->set('last_name', $last_name);
369
+        $invoice->set('company', $company);
370
+        $invoice->set('vat_number', $vat_number);
371
+        $invoice->set('phone', $phone);
372
+        $invoice->set('address', $address);
373
+        $invoice->set('city', $city);
374
+        $invoice->set('zip', $zip);
375
+        $invoice->set('country', $country);
376
+        $invoice->set('state', $state);
377
+        $invoice->set('status', $status);
378 378
         //$invoice->set( 'number', $number );
379 379
         //$invoice->set( 'discounts', $discounts );
380 380
         //$invoice->set( 'discount', $discount );
381
-        $invoice->set( 'ip', $ip );
381
+        $invoice->set('ip', $ip);
382 382
         $invoice->old_status = $_POST['original_post_status'];
383 383
         $invoice->currency = wpinv_get_currency();
384
-        if ( !empty( $data['wpinv_gateway'] ) ) {
385
-            $invoice->set( 'gateway', sanitize_text_field( $data['wpinv_gateway'] ) );
384
+        if (!empty($data['wpinv_gateway'])) {
385
+            $invoice->set('gateway', sanitize_text_field($data['wpinv_gateway']));
386 386
         }
387 387
         $saved = $invoice->save();
388 388
         
389 389
         // Check for payment notes
390
-        if ( !empty( $data['invoice_note'] ) ) {
391
-            $note               = wp_kses( $data['invoice_note'], array() );
392
-            $note_type          = sanitize_text_field( $data['invoice_note_type'] );
390
+        if (!empty($data['invoice_note'])) {
391
+            $note               = wp_kses($data['invoice_note'], array());
392
+            $note_type          = sanitize_text_field($data['invoice_note_type']);
393 393
             $is_customer_note   = $note_type == 'customer' ? 1 : 0;
394 394
         
395
-            wpinv_insert_payment_note( $invoice->ID, $note, $is_customer_note );
395
+            wpinv_insert_payment_note($invoice->ID, $note, $is_customer_note);
396 396
         }
397 397
         
398 398
         // Update user address if empty.
399
-        if ( $saved && !empty( $invoice ) ) {
400
-            if ( $user_id = $invoice->get_user_id() ) {
401
-                $user_address = wpinv_get_user_address( $user_id, false );
399
+        if ($saved && !empty($invoice)) {
400
+            if ($user_id = $invoice->get_user_id()) {
401
+                $user_address = wpinv_get_user_address($user_id, false);
402 402
                 
403 403
                 if (empty($user_address['first_name'])) {
404
-                    update_user_meta( $user_id, '_wpinv_first_name', $first_name );
405
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
404
+                    update_user_meta($user_id, '_wpinv_first_name', $first_name);
405
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
406 406
                 } else if (empty($user_address['last_name']) && $user_address['first_name'] == $first_name) {
407
-                    update_user_meta( $user_id, '_wpinv_last_name', $last_name );
407
+                    update_user_meta($user_id, '_wpinv_last_name', $last_name);
408 408
                 }
409 409
                 
410 410
                 if (empty($user_address['address']) || empty($user_address['city']) || empty($user_address['state']) || empty($user_address['country'])) {
411
-                    update_user_meta( $user_id, '_wpinv_address', $address );
412
-                    update_user_meta( $user_id, '_wpinv_city', $city );
413
-                    update_user_meta( $user_id, '_wpinv_state', $state );
414
-                    update_user_meta( $user_id, '_wpinv_country', $country );
415
-                    update_user_meta( $user_id, '_wpinv_zip', $zip );
416
-                    update_user_meta( $user_id, '_wpinv_phone', $phone );
411
+                    update_user_meta($user_id, '_wpinv_address', $address);
412
+                    update_user_meta($user_id, '_wpinv_city', $city);
413
+                    update_user_meta($user_id, '_wpinv_state', $state);
414
+                    update_user_meta($user_id, '_wpinv_country', $country);
415
+                    update_user_meta($user_id, '_wpinv_zip', $zip);
416
+                    update_user_meta($user_id, '_wpinv_phone', $phone);
417 417
                 }
418 418
             }
419 419
             
420
-            do_action( 'wpinv_invoice_metabox_saved', $invoice );
420
+            do_action('wpinv_invoice_metabox_saved', $invoice);
421 421
         }
422 422
         
423 423
         return $saved;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-mb-invoice-details.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -1,30 +1,30 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7 7
 class WPInv_Meta_Box_Details {
8
-    public static function output( $post ) {
8
+    public static function output($post) {
9 9
         $currency_symbol    = wpinv_currency_symbol();
10 10
         $statuses           = wpinv_get_invoice_statuses();
11 11
         
12
-        $post_id            = !empty( $post->ID ) ? $post->ID : 0;
13
-        $invoice            = new WPInv_Invoice( $post_id );
12
+        $post_id            = !empty($post->ID) ? $post->ID : 0;
13
+        $invoice            = new WPInv_Invoice($post_id);
14 14
         
15
-        $status             = $invoice->get_status( false ); // Current status    
15
+        $status             = $invoice->get_status(false); // Current status    
16 16
         $discount           = $invoice->get_discount();
17 17
         $discount_code      = $discount > 0 ? $invoice->get_discount_code() : '';
18 18
         $invoice_number     = $invoice->get_number();
19 19
         
20 20
         $date_created       = $invoice->get_created_date();
21
-        $datetime_created   = strtotime( $date_created );
22
-        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), $datetime_created ) : '';
21
+        $datetime_created   = strtotime($date_created);
22
+        $date_created       = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), $datetime_created) : '';
23 23
         $date_completed     = $invoice->get_completed_date();
24
-        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n( get_option( 'date_format' ) . ' ' . get_option( 'time_format' ), strtotime( $date_completed ) ) : 'n/a';
25
-        $title['status'] = __( 'Invoice Status:', 'invoicing' );
26
-        $title['number'] = __( 'Invoice Number:', 'invoicing' );
27
-        $mail_notice = esc_attr__( 'After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing' );
24
+        $date_completed     = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? date_i18n(get_option('date_format') . ' ' . get_option('time_format'), strtotime($date_completed)) : 'n/a';
25
+        $title['status'] = __('Invoice Status:', 'invoicing');
26
+        $title['number'] = __('Invoice Number:', 'invoicing');
27
+        $mail_notice = esc_attr__('After saving invoice, this will send a copy of the invoice to the user&#8217;s email address.', 'invoicing');
28 28
         
29 29
         $title = apply_filters('wpinv_details_metabox_titles', $title, $invoice);
30 30
         $statuses = apply_filters('wpinv_invoice_statuses', $statuses, $invoice);
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 <div class="gdmbx2-wrap form-table">
35 35
     <div class="gdmbx2-metabox gdmbx-field-list" id="gdmbx2-metabox-wpinv_details">
36 36
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-created">
37
-            <div class="gdmbx-th"><label><?php _e( 'Date Created:', 'invoicing' );?></label></div>
38
-            <div class="gdmbx-td"><?php echo $date_created;?></div>
37
+            <div class="gdmbx-th"><label><?php _e('Date Created:', 'invoicing'); ?></label></div>
38
+            <div class="gdmbx-td"><?php echo $date_created; ?></div>
39 39
         </div>
40
-        <?php if ( wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->has_status( array( 'auto-draft' ) ) ) ) { ?>
40
+        <?php if (wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->has_status(array('auto-draft')))) { ?>
41 41
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-overdue">
42
-            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e( 'Due Date:', 'invoicing' );?></label></div>
42
+            <div class="gdmbx-th"><label for="wpinv_due_date"><?php _e('Due Date:', 'invoicing'); ?></label></div>
43 43
             <div class="gdmbx-td">
44
-                <input type="text" placeholder="<?php esc_attr_e( 'Y-m-d', 'invoicing' );?>" value="<?php echo esc_attr( $invoice->get_due_date() );?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr( date_i18n( 'Y-m-d', $datetime_created ) );?>" data-dateFormat="yy-mm-dd">
44
+                <input type="text" placeholder="<?php esc_attr_e('Y-m-d', 'invoicing'); ?>" value="<?php echo esc_attr($invoice->get_due_date()); ?>" id="wpinv_due_date" name="wpinv_due_date" class="regular-text wpiDatepicker" data-minDate="<?php echo esc_attr(date_i18n('Y-m-d', $datetime_created)); ?>" data-dateFormat="yy-mm-dd">
45 45
             </div>
46 46
         </div>
47 47
         <?php } ?>
48
-        <?php if ( $date_completed && $date_completed != 'n/a' ) { ?>
48
+        <?php if ($date_completed && $date_completed != 'n/a') { ?>
49 49
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-date-completed">
50
-            <div class="gdmbx-th"><label><?php _e( 'Payment Date:', 'invoicing' );?></label></div>
51
-            <div class="gdmbx-td"><?php echo $date_completed;?></div>
50
+            <div class="gdmbx-th"><label><?php _e('Payment Date:', 'invoicing'); ?></label></div>
51
+            <div class="gdmbx-td"><?php echo $date_completed; ?></div>
52 52
         </div>
53 53
         <?php } ?>
54 54
         <div class="gdmbx-row gdmbx-type-select gdmbx2-id-wpinv-status">
55 55
             <div class="gdmbx-th"><label for="wpinv_status"><?php echo $title['status']; ?></label></div>
56 56
             <div class="gdmbx-td">
57 57
                 <select required="required" id="wpinv_status" name="wpinv_status" class="gdmbx2_select">
58
-                    <?php foreach ( $statuses as $value => $label ) { ?>
59
-                    <option value="<?php echo $value;?>" <?php selected( $status, $value );?>><?php echo $label;?></option>
58
+                    <?php foreach ($statuses as $value => $label) { ?>
59
+                    <option value="<?php echo $value; ?>" <?php selected($status, $value); ?>><?php echo $label; ?></option>
60 60
                     <?php } ?>
61 61
                 </select>
62 62
             </div>
@@ -64,107 +64,107 @@  discard block
 block discarded – undo
64 64
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-number table-layout">
65 65
             <div class="gdmbx-th"><label for="wpinv_number"><?php echo $title['number']; ?></label></div>
66 66
             <div class="gdmbx-td">
67
-                <input type="text" value="<?php echo esc_attr( $invoice_number );?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
67
+                <input type="text" value="<?php echo esc_attr($invoice_number); ?>" id="wpinv_number" name="wpinv_number" class="regular-text" readonly>
68 68
             </div>
69 69
         </div>
70
-        <?php do_action( 'wpinv_meta_box_details_inner', $post_id ); ?>
71
-        <?php if ( !( $is_paid = $invoice->is_paid() ) || $discount_code ) { ?>
70
+        <?php do_action('wpinv_meta_box_details_inner', $post_id); ?>
71
+        <?php if (!($is_paid = $invoice->is_paid()) || $discount_code) { ?>
72 72
         <div class="gdmbx-row gdmbx-type-text gdmbx2-id-wpinv-discount-code table-layout">
73
-            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e( 'Discount Code:', 'invoicing' );?></label></div>
73
+            <div class="gdmbx-th"><label for="wpinv_discount_code"><?php _e('Discount Code:', 'invoicing'); ?></label></div>
74 74
             <div class="gdmbx-td">
75
-                <input type="text" value="<?php echo esc_attr( $discount_code ); ?>" id="wpinv_discount" class="medium-text" <?php echo ( $discount_code ? 'readonly' : '' ); ?> /><?php if ( !$is_paid ) { ?><input value="<?php echo esc_attr_e( 'Apply', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-hide' : 'wpi-inlineb' ); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e( 'Remove', 'invoicing' ); ?>" class="button button-small button-primary <?php echo ( $discount_code ? 'wpi-inlineb' : 'wpi-hide' ); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
75
+                <input type="text" value="<?php echo esc_attr($discount_code); ?>" id="wpinv_discount" class="medium-text" <?php echo ($discount_code ? 'readonly' : ''); ?> /><?php if (!$is_paid) { ?><input value="<?php echo esc_attr_e('Apply', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-hide' : 'wpi-inlineb'); ?>" id="wpinv-apply-code" type="button" /><input value="<?php echo esc_attr_e('Remove', 'invoicing'); ?>" class="button button-small button-primary <?php echo ($discount_code ? 'wpi-inlineb' : 'wpi-hide'); ?>" id="wpinv-remove-code" type="button" /><?php } ?>
76 76
             </div>
77 77
         </div>
78 78
         <?php } ?>
79 79
     </div>
80 80
 </div>
81 81
 <div class="gdmbx-row gdmbx-type-text gdmbx-wpinv-save-send table-layout">
82
-    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__( 'Send %s:', 'invoicing' ),$post_obj->labels->singular_name) ; ?></label>
82
+    <p class="wpi-meta-row wpi-save-send"><label for="wpi_save_send"><?php echo sprintf(__('Send %s:', 'invoicing'), $post_obj->labels->singular_name); ?></label>
83 83
         <select id="wpi_save_send" name="wpi_save_send">
84
-            <option value="1"><?php _e( 'Yes', 'invoicing' ); ?></option>
85
-            <option value="" selected="selected"><?php _e( 'No', 'invoicing' ); ?></option>
84
+            <option value="1"><?php _e('Yes', 'invoicing'); ?></option>
85
+            <option value="" selected="selected"><?php _e('No', 'invoicing'); ?></option>
86 86
         </select>
87 87
     </p>
88 88
     <p class="wpi-meta-row wpi-send-info"><?php echo $mail_notice; ?></p>
89 89
 </div>
90
-<?php wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ;?>
90
+<?php wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); ?>
91 91
         <?php
92 92
     }
93 93
     
94
-    public static function resend_invoice( $post ) {
94
+    public static function resend_invoice($post) {
95 95
         global $wpi_mb_invoice;
96 96
         
97
-        if ( empty( $wpi_mb_invoice ) ) {
97
+        if (empty($wpi_mb_invoice)) {
98 98
             return;
99 99
         }
100 100
         
101 101
         $text = array(
102
-            'message'       => esc_attr__( 'This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing' ),
103
-            'button_text'   =>  __( 'Resend Invoice', 'invoicing' ),
102
+            'message'       => esc_attr__('This will send a copy of the invoice to the customer&#8217;s email address.', 'invoicing'),
103
+            'button_text'   =>  __('Resend Invoice', 'invoicing'),
104 104
         );
105 105
             
106 106
         $text = apply_filters('wpinv_resend_invoice_metabox_text', $text);
107
-        do_action( 'wpinv_metabox_resend_invoice_before', $wpi_mb_invoice );
107
+        do_action('wpinv_metabox_resend_invoice_before', $wpi_mb_invoice);
108 108
         
109
-        if ( $email = $wpi_mb_invoice->get_email() ) {
109
+        if ($email = $wpi_mb_invoice->get_email()) {
110 110
             $email_actions = array();
111
-            $email_actions['email_url']      = add_query_arg( array( 'wpi_action' => 'send_invoice', 'invoice_id' => $post->ID ) );
112
-            $email_actions['reminder_url']   = add_query_arg( array( 'wpi_action' => 'send_reminder', 'invoice_id' => $post->ID ) );
111
+            $email_actions['email_url']      = add_query_arg(array('wpi_action' => 'send_invoice', 'invoice_id' => $post->ID));
112
+            $email_actions['reminder_url']   = add_query_arg(array('wpi_action' => 'send_reminder', 'invoice_id' => $post->ID));
113 113
             
114
-            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions );
114
+            $email_actions = apply_filters('wpinv_resend_invoice_email_actions', $email_actions);
115 115
         ?>
116 116
         <p class="wpi-meta-row wpi-resend-info"><?php echo $text['message']; ?></p>
117
-        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url( $email_actions['email_url'] ); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
-        <?php if ( wpinv_get_option( 'overdue_active' ) && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ( $due_date = $wpi_mb_invoice->get_due_date() ) ) { ?>
119
-        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e( 'Send overdue reminder notification to customer', 'invoicing' ); ?>" href="<?php echo esc_url( $email_actions['reminder_url'] ); ?>" class="button button-secondary"><?php esc_attr_e( 'Send Reminder', 'invoicing' ); ?></a></p>
117
+        <p class="wpi-meta-row wpi-resend-email"><a href="<?php echo esc_url($email_actions['email_url']); ?>" class="button button-secondary"><?php echo $text['button_text']; ?></a></p>
118
+        <?php if (wpinv_get_option('overdue_active') && "wpi_invoice" === $wpi_mb_invoice->post_type && $wpi_mb_invoice->needs_payment() && ($due_date = $wpi_mb_invoice->get_due_date())) { ?>
119
+        <p class="wpi-meta-row wpi-send-reminder"><a title="<?php esc_attr_e('Send overdue reminder notification to customer', 'invoicing'); ?>" href="<?php echo esc_url($email_actions['reminder_url']); ?>" class="button button-secondary"><?php esc_attr_e('Send Reminder', 'invoicing'); ?></a></p>
120 120
         <?php } ?>
121 121
         <?php
122 122
         }
123 123
         
124
-        do_action( 'wpinv_metabox_resend_invoice_after', $wpi_mb_invoice );
124
+        do_action('wpinv_metabox_resend_invoice_after', $wpi_mb_invoice);
125 125
     }
126 126
     
127
-    public static function subscriptions( $post ) {
127
+    public static function subscriptions($post) {
128 128
         global $wpi_mb_invoice;
129 129
         
130 130
         $invoice = $wpi_mb_invoice;
131 131
         
132
-        if ( !empty( $invoice ) && $invoice->is_recurring() && $invoice->is_parent() ) {
132
+        if (!empty($invoice) && $invoice->is_recurring() && $invoice->is_parent()) {
133 133
             $payments       = $invoice->get_child_payments();
134 134
             
135 135
             $total_payments = (int)$invoice->get_total_payments();
136 136
             $subscription   = $invoice->get_subscription_data();
137 137
 
138
-            $billing_cycle  = wpinv_get_billing_cycle( $subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency() );
139
-            $times_billed   = $total_payments . ' / ' . ( ( (int)$subscription['bill_times'] == 0 ) ? __( 'Until cancelled', 'invoicing' ) : $subscription['bill_times'] );
138
+            $billing_cycle  = wpinv_get_billing_cycle($subscription['initial_amount'], $subscription['recurring_amount'], $subscription['period'], $subscription['interval'], $subscription['bill_times'], $subscription['trial_period'], $subscription['trial_interval'], $invoice->get_currency());
139
+            $times_billed   = $total_payments . ' / ' . (((int)$subscription['bill_times'] == 0) ? __('Until cancelled', 'invoicing') : $subscription['bill_times']);
140 140
             $subscription_status = $invoice->get_subscription_status();
141 141
             ?>
142
-            <p class="wpi-meta-row wpi-sub-label"><?php _e( 'Recurring Payment', 'invoicing' );?></p>
143
-            <?php if ( $subscription_id = $invoice->get_subscription_id() ) { ?>
144
-            <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $subscription_id; ?></p>
142
+            <p class="wpi-meta-row wpi-sub-label"><?php _e('Recurring Payment', 'invoicing'); ?></p>
143
+            <?php if ($subscription_id = $invoice->get_subscription_id()) { ?>
144
+            <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $subscription_id; ?></p>
145 145
             <?php } ?>
146
-            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e( 'Billing Cycle:', 'invoicing' );?> </label><?php echo $billing_cycle; ?></p>
147
-            <p class="wpi-meta-row wpi-billed-times"><label><?php _e( 'Times Billed:', 'invoicing' );?> </label><?php echo $times_billed; ?></p>
148
-            <?php if ( !empty( $payments ) || $invoice->is_paid() ) { ?>
149
-                <p class="wpi-meta-row wpi-start-date"><label><?php _e( 'Start Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
-                <p class="wpi-meta-row wpi-end-date"><label><?php _e( 'Expiration Date:', 'invoicing' );?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
-                <?php if ( $status_label = $invoice->get_subscription_status_label( $subscription_status ) ) { ?>
152
-                <p class="wpi-meta-row wpi-sub-status"><label><?php _e( 'Subscription Status:', 'invoicing' );?> </label><?php echo $status_label; ?></p>
146
+            <p class="wpi-meta-row wpi-bill-cycle"><label><?php _e('Billing Cycle:', 'invoicing'); ?> </label><?php echo $billing_cycle; ?></p>
147
+            <p class="wpi-meta-row wpi-billed-times"><label><?php _e('Times Billed:', 'invoicing'); ?> </label><?php echo $times_billed; ?></p>
148
+            <?php if (!empty($payments) || $invoice->is_paid()) { ?>
149
+                <p class="wpi-meta-row wpi-start-date"><label><?php _e('Start Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_start(); ?></p>
150
+                <p class="wpi-meta-row wpi-end-date"><label><?php _e('Expiration Date:', 'invoicing'); ?> </label><?php echo $invoice->get_subscription_end(); ?></p>
151
+                <?php if ($status_label = $invoice->get_subscription_status_label($subscription_status)) { ?>
152
+                <p class="wpi-meta-row wpi-sub-status"><label><?php _e('Subscription Status:', 'invoicing'); ?> </label><?php echo $status_label; ?></p>
153 153
                 <?php } ?>
154
-                <?php if ( $subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date() ) { ?>
155
-                <p class="wpi-meta-row wpi-trial-date"><label><?php _e( 'Trial Until:', 'invoicing' );?> </label><?php echo $trial_end_date; ?></p>
154
+                <?php if ($subscription_status == 'trialing' && $trial_end_date = $invoice->get_trial_end_date()) { ?>
155
+                <p class="wpi-meta-row wpi-trial-date"><label><?php _e('Trial Until:', 'invoicing'); ?> </label><?php echo $trial_end_date; ?></p>
156 156
                 <?php } ?>
157
-                <?php if ( $cancelled_date = $invoice->get_cancelled_date() ) { ?>
158
-                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e( 'Cancelled On:', 'invoicing' );?> </label><?php echo $cancelled_date; ?></p>
157
+                <?php if ($cancelled_date = $invoice->get_cancelled_date()) { ?>
158
+                <p class="wpi-meta-row wpi-cancel-date"><label><?php _e('Cancelled On:', 'invoicing'); ?> </label><?php echo $cancelled_date; ?></p>
159 159
                 <?php } ?>
160
-                <?php if ( !empty( $payments ) ) { ?>
161
-                <p><strong><?php _e( 'Renewal Payments:', 'invoicing' ); ?></strong></p>
160
+                <?php if (!empty($payments)) { ?>
161
+                <p><strong><?php _e('Renewal Payments:', 'invoicing'); ?></strong></p>
162 162
                 <ul id="wpi-sub-payments">
163
-                <?php foreach ( $payments as $invoice_id ) { ?>
163
+                <?php foreach ($payments as $invoice_id) { ?>
164 164
                     <li>
165
-                        <a href="<?php echo esc_url( get_edit_post_link( $invoice_id ) ); ?>"><?php echo wpinv_get_invoice_number( $invoice_id ); ?></a>&nbsp;&ndash;&nbsp;
166
-                        <span><?php echo wpinv_get_invoice_date( $invoice_id ); ?>&nbsp;&ndash;&nbsp;</span>
167
-                        <span><?php echo wpinv_payment_total( $invoice_id, true ); ?></span>
165
+                        <a href="<?php echo esc_url(get_edit_post_link($invoice_id)); ?>"><?php echo wpinv_get_invoice_number($invoice_id); ?></a>&nbsp;&ndash;&nbsp;
166
+                        <span><?php echo wpinv_get_invoice_date($invoice_id); ?>&nbsp;&ndash;&nbsp;</span>
167
+                        <span><?php echo wpinv_payment_total($invoice_id, true); ?></span>
168 168
                     </li>
169 169
                 <?php } ?>
170 170
                 </ul>
@@ -172,47 +172,47 @@  discard block
 block discarded – undo
172 172
         }
173 173
     }
174 174
     
175
-    public static function renewals( $post ) {
175
+    public static function renewals($post) {
176 176
         global $wpi_mb_invoice;
177 177
         
178
-        if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
179
-            $parent_url = get_edit_post_link( $wpi_mb_invoice->parent_invoice );
180
-            $parent_id  = wpinv_get_invoice_number( $wpi_mb_invoice->parent_invoice );
178
+        if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
179
+            $parent_url = get_edit_post_link($wpi_mb_invoice->parent_invoice);
180
+            $parent_id  = wpinv_get_invoice_number($wpi_mb_invoice->parent_invoice);
181 181
         ?>
182
-        <p class="wpi-meta-row wpi-sub-id"><label><?php _e( 'Subscription ID:', 'invoicing' );?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
-        <p class="wpi-meta-row wpi-parent-id"><label><?php _e( 'Parent Invoice:', 'invoicing' );?> </label><a href="<?php echo esc_url( $parent_url ); ?>"><?php echo $parent_id; ?></a></p>
182
+        <p class="wpi-meta-row wpi-sub-id"><label><?php _e('Subscription ID:', 'invoicing'); ?> </label><?php echo $wpi_mb_invoice->get_subscription_id(); ?></p>
183
+        <p class="wpi-meta-row wpi-parent-id"><label><?php _e('Parent Invoice:', 'invoicing'); ?> </label><a href="<?php echo esc_url($parent_url); ?>"><?php echo $parent_id; ?></a></p>
184 184
         <?php
185 185
         }
186 186
     }
187 187
     
188
-    public static function payment_meta( $post ) {
188
+    public static function payment_meta($post) {
189 189
         global $wpi_mb_invoice;
190 190
 
191
-        $set_dateway = empty( $wpi_mb_invoice->gateway ) ? true : false;
192
-        if ( !$set_dateway && !$wpi_mb_invoice->get_meta( '_wpinv_checkout', true ) && !$wpi_mb_invoice->is_paid() ) {
191
+        $set_dateway = empty($wpi_mb_invoice->gateway) ? true : false;
192
+        if (!$set_dateway && !$wpi_mb_invoice->get_meta('_wpinv_checkout', true) && !$wpi_mb_invoice->is_paid()) {
193 193
             $set_dateway = true;
194 194
         }
195 195
         
196 196
         ?>
197 197
         <p class="wpi-meta-row">
198
-        <?php if ( $set_dateway ) { $gateways = wpinv_get_enabled_payment_gateways( true ); ?>
199
-            <label for="wpinv_gateway"><?php _e( 'Gateway:', 'invoicing' ) ; ?></label>
198
+        <?php if ($set_dateway) { $gateways = wpinv_get_enabled_payment_gateways(true); ?>
199
+            <label for="wpinv_gateway"><?php _e('Gateway:', 'invoicing'); ?></label>
200 200
             <select required="required" id="wpinv_gateway" name="wpinv_gateway">
201
-                <?php foreach ( $gateways as $name => $gateway ) {
202
-                    if ( $wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription( $name ) ) {
201
+                <?php foreach ($gateways as $name => $gateway) {
202
+                    if ($wpi_mb_invoice->is_recurring() && !wpinv_gateway_support_subscription($name)) {
203 203
                         continue;
204 204
                     }
205 205
                     ?>
206
-                <option value="<?php echo $name;?>" <?php selected( $wpi_mb_invoice->gateway, $name );?>><?php echo !empty( $gateway['admin_label'] ) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
206
+                <option value="<?php echo $name; ?>" <?php selected($wpi_mb_invoice->gateway, $name); ?>><?php echo !empty($gateway['admin_label']) ? $gateway['admin_label'] : $gateway['checkout_label']; ?></option>
207 207
                 <?php } ?>
208 208
             </select>
209 209
         <?php } else { 
210
-            echo wp_sprintf( __( '<label>Gateway:</label> %s', 'invoicing' ), wpinv_get_gateway_checkout_label( $wpi_mb_invoice->gateway ) );
210
+            echo wp_sprintf(__('<label>Gateway:</label> %s', 'invoicing'), wpinv_get_gateway_checkout_label($wpi_mb_invoice->gateway));
211 211
         } ?>
212 212
         </p>
213
-        <?php if ( $wpi_mb_invoice->is_paid() ) { ?>
214
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Key:</label> %s', 'invoicing' ), $wpi_mb_invoice->get_key() ); ?></p>
215
-        <p class="wpi-meta-row"><?php echo wp_sprintf( __( '<label>Transaction ID:</label> %s', 'invoicing' ), wpinv_payment_link_transaction_id( $wpi_mb_invoice ) ); ?></p>
213
+        <?php if ($wpi_mb_invoice->is_paid()) { ?>
214
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Key:</label> %s', 'invoicing'), $wpi_mb_invoice->get_key()); ?></p>
215
+        <p class="wpi-meta-row"><?php echo wp_sprintf(__('<label>Transaction ID:</label> %s', 'invoicing'), wpinv_payment_link_transaction_id($wpi_mb_invoice)); ?></p>
216 216
         <?php } ?>
217 217
         <?php
218 218
     }
Please login to merge, or discard this patch.
includes/admin/admin-meta-boxes.php 1 patch
Spacing   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -1,65 +1,65 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // MUST have WordPress.
3
-if ( !defined( 'WPINC' ) ) {
4
-    exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) );
3
+if (!defined('WPINC')) {
4
+    exit('Do NOT access this file directly: ' . basename(__FILE__));
5 5
 }
6 6
 
7
-function wpinv_add_meta_boxes( $post_type, $post ) {
7
+function wpinv_add_meta_boxes($post_type, $post) {
8 8
     global $wpi_mb_invoice;
9
-    if ( $post_type == 'wpi_invoice' && !empty( $post->ID ) ) {
10
-        $wpi_mb_invoice = wpinv_get_invoice( $post->ID );
9
+    if ($post_type == 'wpi_invoice' && !empty($post->ID)) {
10
+        $wpi_mb_invoice = wpinv_get_invoice($post->ID);
11 11
     }
12 12
     
13
-    if ( !empty( $wpi_mb_invoice ) && !$wpi_mb_invoice->has_status( array( 'draft', 'auto-draft' ) ) ) {
14
-        add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high' );
13
+    if (!empty($wpi_mb_invoice) && !$wpi_mb_invoice->has_status(array('draft', 'auto-draft'))) {
14
+        add_meta_box('wpinv-mb-resend-invoice', __('Resend Invoice', 'invoicing'), 'WPInv_Meta_Box_Details::resend_invoice', 'wpi_invoice', 'side', 'high');
15 15
     }
16 16
     
17
-    if ( !empty( $wpi_mb_invoice ) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent() ) {
18
-        add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscriptions', 'invoicing' ), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high' );
17
+    if (!empty($wpi_mb_invoice) && $wpi_mb_invoice->is_recurring() && $wpi_mb_invoice->is_parent()) {
18
+        add_meta_box('wpinv-mb-subscriptions', __('Subscriptions', 'invoicing'), 'WPInv_Meta_Box_Details::subscriptions', 'wpi_invoice', 'side', 'high');
19 19
     }
20 20
     
21
-    if ( wpinv_is_subscription_payment( $wpi_mb_invoice ) ) {
22
-        add_meta_box( 'wpinv-mb-renewals', __( 'Renewal Payment', 'invoicing' ), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high' );
21
+    if (wpinv_is_subscription_payment($wpi_mb_invoice)) {
22
+        add_meta_box('wpinv-mb-renewals', __('Renewal Payment', 'invoicing'), 'WPInv_Meta_Box_Details::renewals', 'wpi_invoice', 'side', 'high');
23 23
     }
24 24
     
25
-    add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default' );
26
-    add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default' );
25
+    add_meta_box('wpinv-details', __('Invoice Details', 'invoicing'), 'WPInv_Meta_Box_Details::output', 'wpi_invoice', 'side', 'default');
26
+    add_meta_box('wpinv-payment-meta', __('Payment Meta', 'invoicing'), 'WPInv_Meta_Box_Details::payment_meta', 'wpi_invoice', 'side', 'default');
27 27
    
28
-    add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high' );
29
-    add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high' );
30
-    add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
28
+    add_meta_box('wpinv-address', __('Billing Details', 'invoicing'), 'WPInv_Meta_Box_Billing_Details::output', 'wpi_invoice', 'normal', 'high');
29
+    add_meta_box('wpinv-items', __('Invoice Items', 'invoicing'), 'WPInv_Meta_Box_Items::output', 'wpi_invoice', 'normal', 'high');
30
+    add_meta_box('wpinv-notes', __('Invoice Notes', 'invoicing'), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high');
31 31
 }
32
-add_action( 'add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2 );
32
+add_action('add_meta_boxes', 'wpinv_add_meta_boxes', 30, 2);
33 33
 
34
-function wpinv_save_meta_boxes( $post_id, $post, $update = false ) {
35
-    remove_action( 'save_post', __FUNCTION__ );
34
+function wpinv_save_meta_boxes($post_id, $post, $update = false) {
35
+    remove_action('save_post', __FUNCTION__);
36 36
     
37 37
     // $post_id and $post are required
38
-    if ( empty( $post_id ) || empty( $post ) ) {
38
+    if (empty($post_id) || empty($post)) {
39 39
         return;
40 40
     }
41 41
         
42
-    if ( !current_user_can( 'edit_post', $post_id ) || empty( $post->post_type ) ) {
42
+    if (!current_user_can('edit_post', $post_id) || empty($post->post_type)) {
43 43
         return;
44 44
     }
45 45
     
46 46
     // Dont' save meta boxes for revisions or autosaves
47
-    if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
47
+    if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) {
48 48
         return;
49 49
     }
50 50
         
51
-    if ( $post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote' ) {
52
-        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
51
+    if ($post->post_type == 'wpi_invoice' or $post->post_type == 'wpi_quote') {
52
+        if ((defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
53 53
             return;
54 54
         }
55 55
     
56
-        if ( isset( $_POST['wpinv_save_invoice'] ) && wp_verify_nonce( $_POST['wpinv_save_invoice'], 'wpinv_save_invoice' ) ) {
57
-            WPInv_Meta_Box_Items::save( $post_id, $_POST, $post );
56
+        if (isset($_POST['wpinv_save_invoice']) && wp_verify_nonce($_POST['wpinv_save_invoice'], 'wpinv_save_invoice')) {
57
+            WPInv_Meta_Box_Items::save($post_id, $_POST, $post);
58 58
         }
59
-    } else if ( $post->post_type == 'wpi_item' ) {
59
+    } else if ($post->post_type == 'wpi_item') {
60 60
         // verify nonce
61
-        if ( isset( $_POST['wpinv_vat_meta_box_nonce'] ) && wp_verify_nonce( $_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save' ) ) {
62
-            $fields                                 = array();
61
+        if (isset($_POST['wpinv_vat_meta_box_nonce']) && wp_verify_nonce($_POST['wpinv_vat_meta_box_nonce'], 'wpinv_item_meta_box_save')) {
62
+            $fields = array();
63 63
             $fields['_wpinv_price']              = 'wpinv_item_price';
64 64
             $fields['_wpinv_vat_class']          = 'wpinv_vat_class';
65 65
             $fields['_wpinv_vat_rule']           = 'wpinv_vat_rules';
@@ -72,256 +72,256 @@  discard block
 block discarded – undo
72 72
             $fields['_wpinv_trial_period']       = 'wpinv_trial_period';
73 73
             $fields['_wpinv_trial_interval']     = 'wpinv_trial_interval';
74 74
             
75
-            if ( !isset( $_POST['wpinv_is_recurring'] ) ) {
75
+            if (!isset($_POST['wpinv_is_recurring'])) {
76 76
                 $_POST['wpinv_is_recurring'] = 0;
77 77
             }
78 78
             
79
-            if ( !isset( $_POST['wpinv_free_trial'] ) || empty( $_POST['wpinv_is_recurring'] ) ) {
79
+            if (!isset($_POST['wpinv_free_trial']) || empty($_POST['wpinv_is_recurring'])) {
80 80
                 $_POST['wpinv_free_trial'] = 0;
81 81
             }
82 82
             
83
-            foreach ( $fields as $field => $name ) {
84
-                if ( isset( $_POST[ $name ] ) ) {
85
-                    if ( $field == '_wpinv_price' ) {
86
-                        if ( get_post_meta( $post_id, '_wpinv_type', true ) === 'package' ) {
87
-                            $value = wpinv_sanitize_amount( get_post_meta( $post_id, '_wpinv_price', true ) ); // Don't allow edit GD package item price.
83
+            foreach ($fields as $field => $name) {
84
+                if (isset($_POST[$name])) {
85
+                    if ($field == '_wpinv_price') {
86
+                        if (get_post_meta($post_id, '_wpinv_type', true) === 'package') {
87
+                            $value = wpinv_sanitize_amount(get_post_meta($post_id, '_wpinv_price', true)); // Don't allow edit GD package item price.
88 88
                         } else {
89
-                            $value = wpinv_sanitize_amount( $_POST[ $name ] );
89
+                            $value = wpinv_sanitize_amount($_POST[$name]);
90 90
                         }
91 91
                     } else {
92
-                        $value = is_string( $_POST[ $name ] ) ? sanitize_text_field( $_POST[ $name ] ) : $_POST[ $name ];
92
+                        $value = is_string($_POST[$name]) ? sanitize_text_field($_POST[$name]) : $_POST[$name];
93 93
                     }
94 94
                     
95
-                    $value = apply_filters( 'wpinv_item_metabox_save_' . $field, $value, $name );
96
-                    update_post_meta( $post_id, $field, $value );
95
+                    $value = apply_filters('wpinv_item_metabox_save_' . $field, $value, $name);
96
+                    update_post_meta($post_id, $field, $value);
97 97
                 }
98 98
             }
99 99
             
100
-            if ( !get_post_meta( $post_id, '_wpinv_custom_id', true ) ) {
101
-                update_post_meta( $post_id, '_wpinv_custom_id', $post_id );
100
+            if (!get_post_meta($post_id, '_wpinv_custom_id', true)) {
101
+                update_post_meta($post_id, '_wpinv_custom_id', $post_id);
102 102
             }
103 103
         }
104 104
     }
105 105
 }
106
-add_action( 'save_post', 'wpinv_save_meta_boxes', 10, 3 );
106
+add_action('save_post', 'wpinv_save_meta_boxes', 10, 3);
107 107
 
108 108
 function wpinv_register_item_meta_boxes() {    
109 109
     global $wpinv_euvat;
110 110
     
111
-    add_meta_box( 'wpinv_field_prices', __( 'Item Price', 'invoicing' ), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high' );
111
+    add_meta_box('wpinv_field_prices', __('Item Price', 'invoicing'), 'WPInv_Meta_Box_Items::prices', 'wpi_item', 'normal', 'high');
112 112
 
113
-    if ( $wpinv_euvat->allow_vat_rules() ) {
114
-        add_meta_box( 'wpinv_field_vat_rules', __( 'VAT rules type to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high' );
113
+    if ($wpinv_euvat->allow_vat_rules()) {
114
+        add_meta_box('wpinv_field_vat_rules', __('VAT rules type to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_rules', 'wpi_item', 'normal', 'high');
115 115
     }
116 116
     
117
-    if ( $wpinv_euvat->allow_vat_classes() ) {
118
-        add_meta_box( 'wpinv_field_vat_classes', __( 'VAT rates class to use', 'invoicing' ), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high' );
117
+    if ($wpinv_euvat->allow_vat_classes()) {
118
+        add_meta_box('wpinv_field_vat_classes', __('VAT rates class to use', 'invoicing'), 'WPInv_Meta_Box_Items::vat_classes', 'wpi_item', 'normal', 'high');
119 119
     }
120 120
     
121
-    add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core' );
122
-    add_meta_box( 'wpinv_field_meta_values', __( 'Item Meta Values', 'invoicing' ), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core' );
121
+    add_meta_box('wpinv_field_item_info', __('Item info', 'invoicing'), 'WPInv_Meta_Box_Items::item_info', 'wpi_item', 'side', 'core');
122
+    add_meta_box('wpinv_field_meta_values', __('Item Meta Values', 'invoicing'), 'WPInv_Meta_Box_Items::meta_values', 'wpi_item', 'side', 'core');
123 123
 }
124 124
 
125 125
 function wpinv_register_discount_meta_boxes() {
126
-    add_meta_box( 'wpinv_discount_fields', __( 'Discount Details', 'invoicing' ), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high' );
126
+    add_meta_box('wpinv_discount_fields', __('Discount Details', 'invoicing'), 'wpinv_discount_metabox_details', 'wpi_discount', 'normal', 'high');
127 127
 }
128 128
 
129
-function wpinv_discount_metabox_details( $post ) {
129
+function wpinv_discount_metabox_details($post) {
130 130
     $discount_id    = $post->ID;
131
-    $discount       = wpinv_get_discount( $discount_id );
131
+    $discount       = wpinv_get_discount($discount_id);
132 132
     
133
-    $type           = wpinv_get_discount_type( $discount_id );
134
-    $item_reqs      = wpinv_get_discount_item_reqs( $discount_id );
135
-    $excluded_items = wpinv_get_discount_excluded_items( $discount_id );
136
-    $min_total      = wpinv_get_discount_min_total( $discount_id );
137
-    $max_total      = wpinv_get_discount_max_total( $discount_id );
138
-    $max_uses       = wpinv_get_discount_max_uses( $discount_id );
139
-    $single_use     = wpinv_discount_is_single_use( $discount_id );
140
-    $recurring      = (bool)wpinv_discount_is_recurring( $discount_id );
133
+    $type           = wpinv_get_discount_type($discount_id);
134
+    $item_reqs      = wpinv_get_discount_item_reqs($discount_id);
135
+    $excluded_items = wpinv_get_discount_excluded_items($discount_id);
136
+    $min_total      = wpinv_get_discount_min_total($discount_id);
137
+    $max_total      = wpinv_get_discount_max_total($discount_id);
138
+    $max_uses       = wpinv_get_discount_max_uses($discount_id);
139
+    $single_use     = wpinv_discount_is_single_use($discount_id);
140
+    $recurring      = (bool)wpinv_discount_is_recurring($discount_id);
141 141
     
142 142
     $min_total      = $min_total > 0 ? $min_total : '';
143 143
     $max_total      = $max_total > 0 ? $max_total : '';
144 144
     $max_uses       = $max_uses > 0 ? $max_uses : '';
145 145
 ?>
146
-<?php do_action( 'wpinv_discount_form_top', $post ); ?>
147
-<?php wp_nonce_field( 'wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce' ); ;?>
146
+<?php do_action('wpinv_discount_form_top', $post); ?>
147
+<?php wp_nonce_field('wpinv_discount_metabox_nonce', 'wpinv_discount_metabox_nonce'); ;?>
148 148
 <table class="form-table wpi-form-table">
149 149
     <tbody>
150
-        <?php do_action( 'wpinv_discount_form_first', $post ); ?>
151
-        <?php do_action( 'wpinv_discount_form_before_code', $post ); ?>
150
+        <?php do_action('wpinv_discount_form_first', $post); ?>
151
+        <?php do_action('wpinv_discount_form_before_code', $post); ?>
152 152
         <tr>
153 153
             <th valign="top" scope="row">
154
-                <label for="wpinv_discount_code"><?php _e( 'Discount Code', 'invoicing' ); ?></label>
154
+                <label for="wpinv_discount_code"><?php _e('Discount Code', 'invoicing'); ?></label>
155 155
             </th>
156 156
             <td>
157
-                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr( wpinv_get_discount_code( $discount_id ) ); ?>" required>
158
-                <p class="description"><?php _e( 'Enter a code for this discount, such as 10OFF', 'invoicing' ); ?></p>
157
+                <input type="text" name="code" id="wpinv_discount_code" class="medium-text" value="<?php echo esc_attr(wpinv_get_discount_code($discount_id)); ?>" required>
158
+                <p class="description"><?php _e('Enter a code for this discount, such as 10OFF', 'invoicing'); ?></p>
159 159
             </td>
160 160
         </tr>
161
-        <?php do_action( 'wpinv_discount_form_before_type', $post ); ?>
161
+        <?php do_action('wpinv_discount_form_before_type', $post); ?>
162 162
         <tr>
163 163
             <th valign="top" scope="row">
164
-                <label for="wpinv_discount_type"><?php _e( 'Discount Type', 'invoicing' ); ?></label>
164
+                <label for="wpinv_discount_type"><?php _e('Discount Type', 'invoicing'); ?></label>
165 165
             </th>
166 166
             <td>
167 167
                 <select id="wpinv_discount_type" name="type" class="medium-text">
168
-                    <?php foreach ( wpinv_get_discount_types() as $value => $label ) { ?>
169
-                    <option value="<?php echo $value ;?>" <?php selected( $type, $value ); ?>><?php echo $label; ?></option>
168
+                    <?php foreach (wpinv_get_discount_types() as $value => $label) { ?>
169
+                    <option value="<?php echo $value; ?>" <?php selected($type, $value); ?>><?php echo $label; ?></option>
170 170
                     <?php } ?>
171 171
                 </select>
172
-                <p class="description"><?php _e( 'The kind of discount to apply for this discount.', 'invoicing' ); ?></p>
172
+                <p class="description"><?php _e('The kind of discount to apply for this discount.', 'invoicing'); ?></p>
173 173
             </td>
174 174
         </tr>
175
-        <?php do_action( 'wpinv_discount_form_before_amount', $post ); ?>
175
+        <?php do_action('wpinv_discount_form_before_amount', $post); ?>
176 176
         <tr>
177 177
             <th valign="top" scope="row">
178
-                <label for="wpinv_discount_amount"><?php _e( 'Amount', 'invoicing' ); ?></label>
178
+                <label for="wpinv_discount_amount"><?php _e('Amount', 'invoicing'); ?></label>
179 179
             </th>
180 180
             <td>
181
-                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr( wpinv_get_discount_amount( $discount_id ) ); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol() ;?></font>
182
-                <p style="display:none;" class="description"><?php _e( 'Enter the discount amount in USD', 'invoicing' ); ?></p>
183
-                <p class="description"><?php _e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?></p>
181
+                <input type="text" name="amount" id="wpinv_discount_amount" class="wpi-field-price wpi-price" value="<?php echo esc_attr(wpinv_get_discount_amount($discount_id)); ?>" required> <font class="wpi-discount-p">%</font><font class="wpi-discount-f" style="display:none;"><?php echo wpinv_currency_symbol(); ?></font>
182
+                <p style="display:none;" class="description"><?php _e('Enter the discount amount in USD', 'invoicing'); ?></p>
183
+                <p class="description"><?php _e('Enter the discount value. Ex: 10', 'invoicing'); ?></p>
184 184
             </td>
185 185
         </tr>
186
-        <?php do_action( 'wpinv_discount_form_before_items', $post ); ?>
186
+        <?php do_action('wpinv_discount_form_before_items', $post); ?>
187 187
         <tr>
188 188
             <th valign="top" scope="row">
189
-                <label for="wpinv_discount_items"><?php _e( 'Items', 'invoicing' ); ?></label>
189
+                <label for="wpinv_discount_items"><?php _e('Items', 'invoicing'); ?></label>
190 190
             </th>
191 191
             <td>
192
-                <p><?php echo wpinv_item_dropdown( array(
192
+                <p><?php echo wpinv_item_dropdown(array(
193 193
                         'name'              => 'items[]',
194 194
                         'id'                => 'items',
195 195
                         'selected'          => $item_reqs,
196 196
                         'multiple'          => true,
197 197
                         'chosen'            => true,
198 198
                         'class'             => 'medium-text',
199
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
199
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
200 200
                         'show_recurring'    => true,
201
-                    ) ); ?>
201
+                    )); ?>
202 202
                 </p>
203
-                <p class="description"><?php _e( 'Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing' ); ?></p>
203
+                <p class="description"><?php _e('Items which need to be in the cart to use this discount or, for "Item Discounts", which items are discounted. If left blank, this discount can be used on any item.', 'invoicing'); ?></p>
204 204
             </td>
205 205
         </tr>
206
-        <?php do_action( 'wpinv_discount_form_before_excluded_items', $post ); ?>
206
+        <?php do_action('wpinv_discount_form_before_excluded_items', $post); ?>
207 207
         <tr>
208 208
             <th valign="top" scope="row">
209
-                <label for="wpinv_discount_excluded_items"><?php _e( 'Excluded Items', 'invoicing' ); ?></label>
209
+                <label for="wpinv_discount_excluded_items"><?php _e('Excluded Items', 'invoicing'); ?></label>
210 210
             </th>
211 211
             <td>
212
-                <p><?php echo wpinv_item_dropdown( array(
212
+                <p><?php echo wpinv_item_dropdown(array(
213 213
                         'name'              => 'excluded_items[]',
214 214
                         'id'                => 'excluded_items',
215 215
                         'selected'          => $excluded_items,
216 216
                         'multiple'          => true,
217 217
                         'chosen'            => true,
218 218
                         'class'             => 'medium-text',
219
-                        'placeholder'       => __( 'Select one or more Items', 'invoicing' ),
219
+                        'placeholder'       => __('Select one or more Items', 'invoicing'),
220 220
                         'show_recurring'    => true,
221
-                    ) ); ?>
221
+                    )); ?>
222 222
                 </p>
223
-                <p class="description"><?php _e( 'Items which are NOT allowed to use this discount.', 'invoicing' ); ?></p>
223
+                <p class="description"><?php _e('Items which are NOT allowed to use this discount.', 'invoicing'); ?></p>
224 224
             </td>
225 225
         </tr>
226
-        <?php do_action( 'wpinv_discount_form_before_start', $post ); ?>
226
+        <?php do_action('wpinv_discount_form_before_start', $post); ?>
227 227
         <tr>
228 228
             <th valign="top" scope="row">
229
-                <label for="wpinv_discount_start"><?php _e( 'Start Date', 'invoicing' ); ?></label>
229
+                <label for="wpinv_discount_start"><?php _e('Start Date', 'invoicing'); ?></label>
230 230
             </th>
231 231
             <td>
232
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr( wpinv_get_discount_start_date( $discount_id ) ); ?>">
233
-                <p class="description"><?php _e( 'Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?></p>
232
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_start" data-dateFormat="yy-mm-dd" name="start" value="<?php echo esc_attr(wpinv_get_discount_start_date($discount_id)); ?>">
233
+                <p class="description"><?php _e('Enter the start date for this discount code in the format of yyyy-mm-dd. For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?></p>
234 234
             </td>
235 235
         </tr>
236
-        <?php do_action( 'wpinv_discount_form_before_expiration', $post ); ?>
236
+        <?php do_action('wpinv_discount_form_before_expiration', $post); ?>
237 237
         <tr>
238 238
             <th valign="top" scope="row">
239
-                <label for="wpinv_discount_expiration"><?php _e( 'Expiration Date', 'invoicing' ); ?></label>
239
+                <label for="wpinv_discount_expiration"><?php _e('Expiration Date', 'invoicing'); ?></label>
240 240
             </th>
241 241
             <td>
242
-                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr( wpinv_get_discount_expiration( $discount_id ) ); ?>">
243
-                <p class="description"><?php _e( 'Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing' ); ?></p>
242
+                <input type="text" class="medium-text wpiDatepicker" id="wpinv_discount_expiration" data-dateFormat="yy-mm-dd" name="expiration" value="<?php echo esc_attr(wpinv_get_discount_expiration($discount_id)); ?>">
243
+                <p class="description"><?php _e('Enter the expiration date for this discount code in the format of yyyy-mm-dd. Leave blank for no expiration.', 'invoicing'); ?></p>
244 244
             </td>
245 245
         </tr>
246
-        <?php do_action( 'wpinv_discount_form_before_min_total', $post ); ?>
246
+        <?php do_action('wpinv_discount_form_before_min_total', $post); ?>
247 247
         <tr>
248 248
             <th valign="top" scope="row">
249
-                <label for="wpinv_discount_min_total"><?php _e( 'Minimum Amount', 'invoicing' ); ?></label>
249
+                <label for="wpinv_discount_min_total"><?php _e('Minimum Amount', 'invoicing'); ?></label>
250 250
             </th>
251 251
             <td>
252 252
                 <input type="text" name="min_total" id="wpinv_discount_min_total" class="wpi-field-price wpi-price" value="<?php echo $min_total; ?>">
253
-                <p class="description"><?php _e( 'This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
253
+                <p class="description"><?php _e('This allows you to set the minimum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
254 254
             </td>
255 255
         </tr>
256
-        <?php do_action( 'wpinv_discount_form_before_max_total', $post ); ?>
256
+        <?php do_action('wpinv_discount_form_before_max_total', $post); ?>
257 257
         <tr>
258 258
             <th valign="top" scope="row">
259
-                <label for="wpinv_discount_max_total"><?php _e( 'Maximum Amount', 'invoicing' ); ?></label>
259
+                <label for="wpinv_discount_max_total"><?php _e('Maximum Amount', 'invoicing'); ?></label>
260 260
             </th>
261 261
             <td>
262 262
                 <input type="text" name="max_total" id="wpinv_discount_max_total" class="wpi-field-price wpi-price" value="<?php echo $max_total; ?>">
263
-                <p class="description"><?php _e( 'This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing' ); ?></p>
263
+                <p class="description"><?php _e('This allows you to set the maximum amount (subtotal, including taxes) allowed when using the discount.', 'invoicing'); ?></p>
264 264
             </td>
265 265
         </tr>
266
-        <?php do_action( 'wpinv_discount_form_before_recurring', $post ); ?>
266
+        <?php do_action('wpinv_discount_form_before_recurring', $post); ?>
267 267
         <tr>
268 268
             <th valign="top" scope="row">
269
-                <label for="wpinv_discount_recurring"><?php _e( 'For recurring apply to', 'invoicing' ); ?></label>
269
+                <label for="wpinv_discount_recurring"><?php _e('For recurring apply to', 'invoicing'); ?></label>
270 270
             </th>
271 271
             <td>
272 272
                 <select id="wpinv_discount_recurring" name="recurring" class="medium-text">
273
-                    <option value="0" <?php selected( false, $recurring ); ?>><?php _e( 'All payments', 'invoicing' ); ?></option>
274
-                    <option value="1" <?php selected( true, $recurring ); ?>><?php _e( 'First payment only', 'invoicing' ); ?></option>
273
+                    <option value="0" <?php selected(false, $recurring); ?>><?php _e('All payments', 'invoicing'); ?></option>
274
+                    <option value="1" <?php selected(true, $recurring); ?>><?php _e('First payment only', 'invoicing'); ?></option>
275 275
                 </select>
276
-                <p class="description"><?php _e( '<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing' ); ?></p>
276
+                <p class="description"><?php _e('<b>All payments:</b> Apply this discount to all recurring payments of the recurring invoice. <br><b>First payment only:</b> Apply this discount to only first payment of the recurring invoice.', 'invoicing'); ?></p>
277 277
             </td>
278 278
         </tr>
279
-        <?php do_action( 'wpinv_discount_form_before_max_uses', $post ); ?>
279
+        <?php do_action('wpinv_discount_form_before_max_uses', $post); ?>
280 280
         <tr>
281 281
             <th valign="top" scope="row">
282
-                <label for="wpinv_discount_max_uses"><?php _e( 'Max Uses', 'invoicing' ); ?></label>
282
+                <label for="wpinv_discount_max_uses"><?php _e('Max Uses', 'invoicing'); ?></label>
283 283
             </th>
284 284
             <td>
285 285
                 <input type="number" min="0" step="1" id="wpinv_discount_max_uses" name="max_uses" class="medium-text" value="<?php echo $max_uses; ?>">
286
-                <p class="description"><?php _e( 'The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing' ); ?></p>
286
+                <p class="description"><?php _e('The maximum number of times this discount can be used. Leave blank for unlimited.', 'invoicing'); ?></p>
287 287
             </td>
288 288
         </tr>
289
-        <?php do_action( 'wpinv_discount_form_before_single_use', $post ); ?>
289
+        <?php do_action('wpinv_discount_form_before_single_use', $post); ?>
290 290
         <tr>
291 291
             <th valign="top" scope="row">
292
-                <label for="wpinv_discount_single_use"><?php _e( 'Use Once Per User', 'invoicing' ); ?></label>
292
+                <label for="wpinv_discount_single_use"><?php _e('Use Once Per User', 'invoicing'); ?></label>
293 293
             </th>
294 294
             <td>
295
-                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked( true, $single_use ); ?>>
296
-                <span class="description"><?php _e( 'Limit this discount to a single use per user?', 'invoicing' ); ?></span>
295
+                <input type="checkbox" value="1" name="single_use" id="wpinv_discount_single_use" <?php checked(true, $single_use); ?>>
296
+                <span class="description"><?php _e('Limit this discount to a single use per user?', 'invoicing'); ?></span>
297 297
             </td>
298 298
         </tr>
299
-        <?php do_action( 'wpinv_discount_form_last', $post ); ?>
299
+        <?php do_action('wpinv_discount_form_last', $post); ?>
300 300
     </tbody>
301 301
 </table>
302
-<?php do_action( 'wpinv_discount_form_bottom', $post ); ?>
302
+<?php do_action('wpinv_discount_form_bottom', $post); ?>
303 303
     <?php
304 304
 }
305 305
 
306
-function wpinv_discount_metabox_save( $post_id, $post, $update = false ) {
307
-    $post_type = !empty( $post ) ? $post->post_type : '';
306
+function wpinv_discount_metabox_save($post_id, $post, $update = false) {
307
+    $post_type = !empty($post) ? $post->post_type : '';
308 308
     
309
-    if ( $post_type != 'wpi_discount' ) {
309
+    if ($post_type != 'wpi_discount') {
310 310
         return;
311 311
     }
312 312
     
313
-    if ( !isset( $_POST['wpinv_discount_metabox_nonce'] ) || ( isset( $_POST['wpinv_discount_metabox_nonce'] ) && !wp_verify_nonce( $_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce' ) ) ) {
313
+    if (!isset($_POST['wpinv_discount_metabox_nonce']) || (isset($_POST['wpinv_discount_metabox_nonce']) && !wp_verify_nonce($_POST['wpinv_discount_metabox_nonce'], 'wpinv_discount_metabox_nonce'))) {
314 314
         return;
315 315
     }
316 316
     
317
-    if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
317
+    if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX) || isset($_REQUEST['bulk_edit'])) {
318 318
         return;
319 319
     }
320 320
     
321
-    if ( !current_user_can( 'manage_options', $post_id ) ) {
321
+    if (!current_user_can('manage_options', $post_id)) {
322 322
         return;
323 323
     }
324 324
     
325
-    return wpinv_store_discount( $post_id, $_POST, $post, $update );
325
+    return wpinv_store_discount($post_id, $_POST, $post, $update);
326 326
 }
327
-add_action( 'save_post', 'wpinv_discount_metabox_save', 10, 3 );
328 327
\ No newline at end of file
328
+add_action('save_post', 'wpinv_discount_metabox_save', 10, 3);
329 329
\ No newline at end of file
Please login to merge, or discard this patch.