@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
35 | 35 | |
36 | 36 | // Items table columns. |
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
43 | 43 | |
44 | 44 | // Payment forms columns. |
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Discount table columns. |
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
52 | 52 | |
53 | 53 | // Deleting posts. |
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
56 | 56 | |
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Post updated messages. |
62 | 62 | */ |
63 | - public static function post_updated_messages( $messages ) { |
|
63 | + public static function post_updated_messages($messages) { |
|
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | $messages['wpi_discount'] = array( |
67 | 67 | 0 => '', |
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
68 | + 1 => __('Discount updated.', 'invoicing'), |
|
69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
71 | + 4 => __('Discount updated.', 'invoicing'), |
|
72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
73 | + 6 => __('Discount updated.', 'invoicing'), |
|
74 | + 7 => __('Discount saved.', 'invoicing'), |
|
75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $messages['wpi_payment_form'] = array( |
81 | 81 | 0 => '', |
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | return $messages; |
@@ -98,19 +98,19 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Post row actions. |
100 | 100 | */ |
101 | - public static function post_row_actions( $actions, $post ) { |
|
101 | + public static function post_row_actions($actions, $post) { |
|
102 | 102 | |
103 | - $post = get_post( $post ); |
|
103 | + $post = get_post($post); |
|
104 | 104 | |
105 | 105 | // We do not want to edit the default payment form. |
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
106 | + if ('wpi_payment_form' == $post->post_type) { |
|
107 | 107 | |
108 | - if ( $post->ID == wpinv_get_default_payment_form() ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
108 | + if ($post->ID == wpinv_get_default_payment_form()) { |
|
109 | + unset($actions['trash']); |
|
110 | + unset($actions['inline hide-if-no-js']); |
|
111 | 111 | } |
112 | 112 | |
113 | - $actions['duplicate'] = sprintf( |
|
113 | + $actions['duplicate'] = sprintf( |
|
114 | 114 | '<a href="%1$s">%2$s</a>', |
115 | 115 | esc_url( |
116 | 116 | wp_nonce_url( |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | 'getpaid-nonce' |
125 | 125 | ) |
126 | 126 | ), |
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
127 | + esc_html(__('Duplicate', 'invoicing')) |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Link to item payment form. |
133 | - if ( 'wpi_item' == $post->post_type && get_post_meta( $post->ID, '_wpinv_type', true ) == 'custom' ) { |
|
133 | + if ('wpi_item' == $post->post_type && get_post_meta($post->ID, '_wpinv_type', true) == 'custom') { |
|
134 | 134 | |
135 | - $actions['buy'] = sprintf( |
|
135 | + $actions['buy'] = sprintf( |
|
136 | 136 | '<a href="%1$s">%2$s</a>', |
137 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
138 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
137 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
138 | + esc_html(__('Buy', 'invoicing')) |
|
139 | 139 | ); |
140 | 140 | |
141 | 141 | } |
@@ -151,31 +151,31 @@ discard block |
||
151 | 151 | * @param WP_Post $post |
152 | 152 | * @return array $actions actions without edit option |
153 | 153 | */ |
154 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
154 | + public static function filter_invoice_row_actions($actions, $post) { |
|
155 | 155 | |
156 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
156 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
157 | 157 | |
158 | 158 | $actions = array(); |
159 | - $invoice = new WPInv_Invoice( $post ); |
|
159 | + $invoice = new WPInv_Invoice($post); |
|
160 | 160 | |
161 | - $actions['edit'] = sprintf( |
|
161 | + $actions['edit'] = sprintf( |
|
162 | 162 | '<a href="%1$s">%2$s</a>', |
163 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
164 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
163 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
164 | + esc_html(__('Edit', 'invoicing')) |
|
165 | 165 | ); |
166 | 166 | |
167 | - if ( ! $invoice->is_draft() ) { |
|
167 | + if (!$invoice->is_draft()) { |
|
168 | 168 | |
169 | - $actions['view'] = sprintf( |
|
169 | + $actions['view'] = sprintf( |
|
170 | 170 | '<a href="%1$s">%2$s</a>', |
171 | - esc_url( $invoice->get_view_url() ), |
|
171 | + esc_url($invoice->get_view_url()), |
|
172 | 172 | sprintf( |
173 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
174 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
173 | + esc_html(__('View %s', 'invoicing')), |
|
174 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
175 | 175 | ) |
176 | 176 | ); |
177 | 177 | |
178 | - $actions['send'] = sprintf( |
|
178 | + $actions['send'] = sprintf( |
|
179 | 179 | '<a href="%1$s">%2$s</a>', |
180 | 180 | esc_url( |
181 | 181 | wp_nonce_url( |
@@ -189,12 +189,12 @@ discard block |
||
189 | 189 | 'getpaid-nonce' |
190 | 190 | ) |
191 | 191 | ), |
192 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
192 | + esc_html(__('Send to Customer', 'invoicing')) |
|
193 | 193 | ); |
194 | 194 | |
195 | 195 | } |
196 | 196 | |
197 | - $actions['duplicate'] = sprintf( |
|
197 | + $actions['duplicate'] = sprintf( |
|
198 | 198 | '<a href="%1$s">%2$s</a>', |
199 | 199 | esc_url( |
200 | 200 | wp_nonce_url( |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | 'getpaid-nonce' |
209 | 209 | ) |
210 | 210 | ), |
211 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
211 | + esc_html(__('Duplicate', 'invoicing')) |
|
212 | 212 | ); |
213 | 213 | |
214 | 214 | } |
@@ -219,42 +219,42 @@ discard block |
||
219 | 219 | /** |
220 | 220 | * Returns an array of invoice table columns. |
221 | 221 | */ |
222 | - public static function invoice_columns( $columns ) { |
|
222 | + public static function invoice_columns($columns) { |
|
223 | 223 | |
224 | 224 | $columns = array( |
225 | 225 | 'cb' => $columns['cb'], |
226 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
227 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
228 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
229 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
230 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
231 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
232 | - 'status' => __( 'Status', 'invoicing' ), |
|
226 | + 'number' => __('Invoice', 'invoicing'), |
|
227 | + 'customer' => __('Customer', 'invoicing'), |
|
228 | + 'invoice_date' => __('Created', 'invoicing'), |
|
229 | + 'payment_date' => __('Completed', 'invoicing'), |
|
230 | + 'amount' => __('Amount', 'invoicing'), |
|
231 | + 'recurring' => __('Recurring', 'invoicing'), |
|
232 | + 'status' => __('Status', 'invoicing'), |
|
233 | 233 | ); |
234 | 234 | |
235 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
235 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Displays invoice table columns. |
240 | 240 | */ |
241 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
241 | + public static function display_invoice_columns($column_name, $post_id) { |
|
242 | 242 | |
243 | - $invoice = new WPInv_Invoice( $post_id ); |
|
243 | + $invoice = new WPInv_Invoice($post_id); |
|
244 | 244 | |
245 | - switch ( $column_name ) { |
|
245 | + switch ($column_name) { |
|
246 | 246 | |
247 | 247 | case 'invoice_date' : |
248 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
249 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
248 | + $date_time = esc_attr($invoice->get_created_date()); |
|
249 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
250 | 250 | echo "<span title='$date_time'>$date</span>"; |
251 | 251 | break; |
252 | 252 | |
253 | 253 | case 'payment_date' : |
254 | 254 | |
255 | - if ( $invoice->is_paid() ) { |
|
256 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
257 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
255 | + if ($invoice->is_paid()) { |
|
256 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
257 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
258 | 258 | echo "<span title='$date_time'>$date</span>"; |
259 | 259 | } else { |
260 | 260 | echo "—"; |
@@ -265,17 +265,17 @@ discard block |
||
265 | 265 | case 'amount' : |
266 | 266 | |
267 | 267 | $amount = $invoice->get_total(); |
268 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
268 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
269 | 269 | |
270 | - if ( $invoice->is_refunded() ) { |
|
271 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
270 | + if ($invoice->is_refunded()) { |
|
271 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
272 | 272 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
273 | 273 | } else { |
274 | 274 | |
275 | 275 | $discount = $invoice->get_total_discount(); |
276 | 276 | |
277 | - if ( ! empty( $discount ) ) { |
|
278 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
277 | + if (!empty($discount)) { |
|
278 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
279 | 279 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
280 | 280 | } else { |
281 | 281 | echo $formated_amount; |
@@ -286,13 +286,13 @@ discard block |
||
286 | 286 | break; |
287 | 287 | |
288 | 288 | case 'status' : |
289 | - $status = esc_html( $invoice->get_status() ); |
|
290 | - $status_label = esc_html( $invoice->get_status_nicename() ); |
|
289 | + $status = esc_html($invoice->get_status()); |
|
290 | + $status_label = esc_html($invoice->get_status_nicename()); |
|
291 | 291 | |
292 | 292 | // If it is paid, show the gateway title. |
293 | - if ( $invoice->is_paid() ) { |
|
294 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
295 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
293 | + if ($invoice->is_paid()) { |
|
294 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
295 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
296 | 296 | |
297 | 297 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
298 | 298 | } else { |
@@ -300,22 +300,22 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // If it is not paid, display the overdue and view status. |
303 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
303 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
304 | 304 | |
305 | 305 | // Invoice view status. |
306 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
307 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
306 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
307 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
308 | 308 | } else { |
309 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
309 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | // Display the overview status. |
313 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
313 | + if (wpinv_get_option('overdue_active')) { |
|
314 | 314 | $due_date = $invoice->get_due_date(); |
315 | - $fomatted = getpaid_format_date( $due_date ); |
|
315 | + $fomatted = getpaid_format_date($due_date); |
|
316 | 316 | |
317 | - if ( ! empty( $fomatted ) ) { |
|
318 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
317 | + if (!empty($fomatted)) { |
|
318 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
319 | 319 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
320 | 320 | } |
321 | 321 | } |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | |
327 | 327 | case 'recurring': |
328 | 328 | |
329 | - if ( $invoice->is_recurring() ) { |
|
329 | + if ($invoice->is_recurring()) { |
|
330 | 330 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
331 | 331 | } else { |
332 | 332 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | |
336 | 336 | case 'number' : |
337 | 337 | |
338 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
339 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
340 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
338 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
339 | + $invoice_number = esc_html($invoice->get_number()); |
|
340 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
341 | 341 | |
342 | 342 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
343 | 343 | |
@@ -347,13 +347,13 @@ discard block |
||
347 | 347 | |
348 | 348 | $customer_name = $invoice->get_user_full_name(); |
349 | 349 | |
350 | - if ( empty( $customer_name ) ) { |
|
350 | + if (empty($customer_name)) { |
|
351 | 351 | $customer_name = $invoice->get_email(); |
352 | 352 | } |
353 | 353 | |
354 | - if ( ! empty( $customer_name ) ) { |
|
355 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
356 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
354 | + if (!empty($customer_name)) { |
|
355 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
356 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
357 | 357 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
358 | 358 | } else { |
359 | 359 | echo '<div>—</div>'; |
@@ -368,27 +368,27 @@ discard block |
||
368 | 368 | /** |
369 | 369 | * Displays invoice bulk actions. |
370 | 370 | */ |
371 | - public static function invoice_bulk_actions( $actions ) { |
|
372 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
371 | + public static function invoice_bulk_actions($actions) { |
|
372 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
373 | 373 | return $actions; |
374 | 374 | } |
375 | 375 | |
376 | 376 | /** |
377 | 377 | * Processes invoice bulk actions. |
378 | 378 | */ |
379 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
379 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
380 | 380 | |
381 | - if ( $action == 'resend-invoice' ) { |
|
381 | + if ($action == 'resend-invoice') { |
|
382 | 382 | |
383 | 383 | $success = false; |
384 | - foreach ( $post_ids as $post_id ) { |
|
385 | - $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
384 | + foreach ($post_ids as $post_id) { |
|
385 | + $success = getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
386 | 386 | } |
387 | 387 | |
388 | - if ( $success ) { |
|
389 | - getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) ); |
|
388 | + if ($success) { |
|
389 | + getpaid_admin()->show_success(__('Invoices were successfully sent', 'invoicing')); |
|
390 | 390 | } else { |
391 | - getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) ); |
|
391 | + getpaid_admin()->show_error(__('Could not send some invoices', 'invoicing')); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | } |
@@ -400,50 +400,50 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Returns an array of payment forms table columns. |
402 | 402 | */ |
403 | - public static function payment_form_columns( $columns ) { |
|
403 | + public static function payment_form_columns($columns) { |
|
404 | 404 | |
405 | 405 | $columns = array( |
406 | 406 | 'cb' => $columns['cb'], |
407 | - 'title' => __( 'Name', 'invoicing' ), |
|
408 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
409 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
410 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
411 | - 'items' => __( 'Items', 'invoicing' ), |
|
412 | - 'date' => __( 'Date', 'invoicing' ), |
|
407 | + 'title' => __('Name', 'invoicing'), |
|
408 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
409 | + 'earnings' => __('Revenue', 'invoicing'), |
|
410 | + 'refunds' => __('Refunded', 'invoicing'), |
|
411 | + 'items' => __('Items', 'invoicing'), |
|
412 | + 'date' => __('Date', 'invoicing'), |
|
413 | 413 | ); |
414 | 414 | |
415 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
415 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
416 | 416 | |
417 | 417 | } |
418 | 418 | |
419 | 419 | /** |
420 | 420 | * Displays payment form table columns. |
421 | 421 | */ |
422 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
422 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
423 | 423 | |
424 | 424 | // Retrieve the payment form. |
425 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
425 | + $form = new GetPaid_Payment_Form($post_id); |
|
426 | 426 | |
427 | - switch ( $column_name ) { |
|
427 | + switch ($column_name) { |
|
428 | 428 | |
429 | 429 | case 'earnings' : |
430 | - echo wpinv_price( $form->get_earned() ); |
|
430 | + echo wpinv_price($form->get_earned()); |
|
431 | 431 | break; |
432 | 432 | |
433 | 433 | case 'refunds' : |
434 | - echo wpinv_price( $form->get_refunded() ); |
|
434 | + echo wpinv_price($form->get_refunded()); |
|
435 | 435 | break; |
436 | 436 | |
437 | 437 | case 'refunds' : |
438 | - echo wpinv_price( $form->get_refunded() ); |
|
438 | + echo wpinv_price($form->get_refunded()); |
|
439 | 439 | break; |
440 | 440 | |
441 | 441 | case 'shortcode' : |
442 | 442 | |
443 | - if ( $form->is_default() ) { |
|
443 | + if ($form->is_default()) { |
|
444 | 444 | echo '—'; |
445 | 445 | } else { |
446 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
446 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
447 | 447 | } |
448 | 448 | |
449 | 449 | break; |
@@ -452,29 +452,29 @@ discard block |
||
452 | 452 | |
453 | 453 | $items = $form->get_items(); |
454 | 454 | |
455 | - if ( $form->is_default() || empty( $items ) ) { |
|
455 | + if ($form->is_default() || empty($items)) { |
|
456 | 456 | echo '—'; |
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | 460 | $_items = array(); |
461 | 461 | |
462 | - foreach ( $items as $item ) { |
|
462 | + foreach ($items as $item) { |
|
463 | 463 | $url = $item->get_edit_url(); |
464 | 464 | |
465 | - if ( empty( $url ) ) { |
|
466 | - $_items[] = esc_html( $item->get_name() ); |
|
465 | + if (empty($url)) { |
|
466 | + $_items[] = esc_html($item->get_name()); |
|
467 | 467 | } else { |
468 | 468 | $_items[] = sprintf( |
469 | 469 | '<a href="%s">%s</a>', |
470 | - esc_url( $url ), |
|
471 | - esc_html( $item->get_name() ) |
|
470 | + esc_url($url), |
|
471 | + esc_html($item->get_name()) |
|
472 | 472 | ); |
473 | 473 | } |
474 | 474 | |
475 | 475 | } |
476 | 476 | |
477 | - echo implode( '<br>', $_items ); |
|
477 | + echo implode('<br>', $_items); |
|
478 | 478 | |
479 | 479 | break; |
480 | 480 | |
@@ -485,10 +485,10 @@ discard block |
||
485 | 485 | /** |
486 | 486 | * Filters post states. |
487 | 487 | */ |
488 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
488 | + public static function filter_payment_form_state($post_states, $post) { |
|
489 | 489 | |
490 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
491 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
490 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
491 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | return $post_states; |
@@ -498,35 +498,35 @@ discard block |
||
498 | 498 | /** |
499 | 499 | * Returns an array of coupon table columns. |
500 | 500 | */ |
501 | - public static function discount_columns( $columns ) { |
|
501 | + public static function discount_columns($columns) { |
|
502 | 502 | |
503 | 503 | $columns = array( |
504 | 504 | 'cb' => $columns['cb'], |
505 | - 'title' => __( 'Name', 'invoicing' ), |
|
506 | - 'code' => __( 'Code', 'invoicing' ), |
|
507 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
508 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
509 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
510 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
505 | + 'title' => __('Name', 'invoicing'), |
|
506 | + 'code' => __('Code', 'invoicing'), |
|
507 | + 'amount' => __('Amount', 'invoicing'), |
|
508 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
509 | + 'start_date' => __('Start Date', 'invoicing'), |
|
510 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
511 | 511 | ); |
512 | 512 | |
513 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
513 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Filters post states. |
518 | 518 | */ |
519 | - public static function filter_discount_state( $post_states, $post ) { |
|
519 | + public static function filter_discount_state($post_states, $post) { |
|
520 | 520 | |
521 | - if ( 'wpi_discount' == $post->post_type ) { |
|
521 | + if ('wpi_discount' == $post->post_type) { |
|
522 | 522 | |
523 | - $discount = new WPInv_Discount( $post ); |
|
523 | + $discount = new WPInv_Discount($post); |
|
524 | 524 | |
525 | 525 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
526 | 526 | |
527 | - if ( $status != 'publish' ) { |
|
527 | + if ($status != 'publish') { |
|
528 | 528 | return array( |
529 | - 'discount_status' => wpinv_discount_status( $status ), |
|
529 | + 'discount_status' => wpinv_discount_status($status), |
|
530 | 530 | ); |
531 | 531 | } |
532 | 532 | |
@@ -541,30 +541,30 @@ discard block |
||
541 | 541 | /** |
542 | 542 | * Returns an array of items table columns. |
543 | 543 | */ |
544 | - public static function item_columns( $columns ) { |
|
544 | + public static function item_columns($columns) { |
|
545 | 545 | |
546 | 546 | $columns = array( |
547 | 547 | 'cb' => $columns['cb'], |
548 | - 'title' => __( 'Name', 'invoicing' ), |
|
549 | - 'price' => __( 'Price', 'invoicing' ), |
|
550 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
551 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
552 | - 'type' => __( 'Type', 'invoicing' ), |
|
553 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
548 | + 'title' => __('Name', 'invoicing'), |
|
549 | + 'price' => __('Price', 'invoicing'), |
|
550 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
551 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
552 | + 'type' => __('Type', 'invoicing'), |
|
553 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
554 | 554 | ); |
555 | 555 | |
556 | - if ( ! wpinv_use_taxes() ) { |
|
557 | - unset( $columns['vat_rule'] ); |
|
558 | - unset( $columns['vat_class'] ); |
|
556 | + if (!wpinv_use_taxes()) { |
|
557 | + unset($columns['vat_rule']); |
|
558 | + unset($columns['vat_class']); |
|
559 | 559 | } |
560 | 560 | |
561 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
561 | + return apply_filters('wpi_item_table_columns', $columns); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
565 | 565 | * Returns an array of sortable items table columns. |
566 | 566 | */ |
567 | - public static function sortable_item_columns( $columns ) { |
|
567 | + public static function sortable_item_columns($columns) { |
|
568 | 568 | |
569 | 569 | return array_merge( |
570 | 570 | $columns, |
@@ -581,49 +581,49 @@ discard block |
||
581 | 581 | /** |
582 | 582 | * Displays items table columns. |
583 | 583 | */ |
584 | - public static function display_item_columns( $column_name, $post_id ) { |
|
584 | + public static function display_item_columns($column_name, $post_id) { |
|
585 | 585 | |
586 | - $item = new WPInv_Item( $post_id ); |
|
586 | + $item = new WPInv_Item($post_id); |
|
587 | 587 | |
588 | - switch ( $column_name ) { |
|
588 | + switch ($column_name) { |
|
589 | 589 | |
590 | 590 | case 'price' : |
591 | 591 | |
592 | - if ( ! $item->is_recurring() ) { |
|
592 | + if (!$item->is_recurring()) { |
|
593 | 593 | echo $item->get_the_price(); |
594 | 594 | break; |
595 | 595 | } |
596 | 596 | |
597 | 597 | $price = wp_sprintf( |
598 | - __( '%s / %s', 'invoicing' ), |
|
598 | + __('%s / %s', 'invoicing'), |
|
599 | 599 | $item->get_the_price(), |
600 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
600 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
601 | 601 | ); |
602 | 602 | |
603 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
603 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
604 | 604 | echo $price; |
605 | 605 | break; |
606 | 606 | } |
607 | 607 | |
608 | 608 | echo $item->get_the_initial_price(); |
609 | 609 | |
610 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
610 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
611 | 611 | break; |
612 | 612 | |
613 | 613 | case 'vat_rule' : |
614 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
614 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
615 | 615 | break; |
616 | 616 | |
617 | 617 | case 'vat_class' : |
618 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
618 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
619 | 619 | break; |
620 | 620 | |
621 | 621 | case 'shortcode' : |
622 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
622 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
623 | 623 | break; |
624 | 624 | |
625 | 625 | case 'type' : |
626 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
626 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
627 | 627 | break; |
628 | 628 | |
629 | 629 | } |
@@ -633,21 +633,21 @@ discard block |
||
633 | 633 | /** |
634 | 634 | * Lets users filter items using taxes. |
635 | 635 | */ |
636 | - public static function add_item_filters( $post_type ) { |
|
636 | + public static function add_item_filters($post_type) { |
|
637 | 637 | |
638 | 638 | // Abort if we're not dealing with items. |
639 | - if ( $post_type != 'wpi_item' ) { |
|
639 | + if ($post_type != 'wpi_item') { |
|
640 | 640 | return; |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Filter by vat rules. |
644 | - if ( wpinv_use_taxes() ) { |
|
644 | + if (wpinv_use_taxes()) { |
|
645 | 645 | |
646 | 646 | // Sanitize selected vat rule. |
647 | 647 | $vat_rule = ''; |
648 | 648 | $vat_rules = getpaid_get_tax_rules(); |
649 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
650 | - $vat_rule = $_GET['vat_rule']; |
|
649 | + if (isset($_GET['vat_rule'])) { |
|
650 | + $vat_rule = $_GET['vat_rule']; |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | // Filter by VAT rule. |
@@ -655,13 +655,13 @@ discard block |
||
655 | 655 | array( |
656 | 656 | 'options' => array_merge( |
657 | 657 | array( |
658 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
658 | + '' => __('All VAT rules', 'invoicing') |
|
659 | 659 | ), |
660 | 660 | $vat_rules |
661 | 661 | ), |
662 | 662 | 'name' => 'vat_rule', |
663 | 663 | 'id' => 'vat_rule', |
664 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
664 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
665 | 665 | 'show_option_all' => false, |
666 | 666 | 'show_option_none' => false, |
667 | 667 | ) |
@@ -672,21 +672,21 @@ discard block |
||
672 | 672 | // Sanitize selected vat rule. |
673 | 673 | $vat_class = ''; |
674 | 674 | $vat_classes = getpaid_get_tax_classes(); |
675 | - if ( isset( $_GET['vat_class'] ) ) { |
|
676 | - $vat_class = $_GET['vat_class']; |
|
675 | + if (isset($_GET['vat_class'])) { |
|
676 | + $vat_class = $_GET['vat_class']; |
|
677 | 677 | } |
678 | 678 | |
679 | 679 | echo wpinv_html_select( |
680 | 680 | array( |
681 | 681 | 'options' => array_merge( |
682 | 682 | array( |
683 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
683 | + '' => __('All VAT classes', 'invoicing') |
|
684 | 684 | ), |
685 | 685 | $vat_classes |
686 | 686 | ), |
687 | 687 | 'name' => 'vat_class', |
688 | 688 | 'id' => 'vat_class', |
689 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
689 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
690 | 690 | 'show_option_all' => false, |
691 | 691 | 'show_option_none' => false, |
692 | 692 | ) |
@@ -695,22 +695,22 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | // Filter by item type. |
698 | - $type = ''; |
|
699 | - if ( isset( $_GET['type'] ) ) { |
|
700 | - $type = $_GET['type']; |
|
698 | + $type = ''; |
|
699 | + if (isset($_GET['type'])) { |
|
700 | + $type = $_GET['type']; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | echo wpinv_html_select( |
704 | 704 | array( |
705 | 705 | 'options' => array_merge( |
706 | 706 | array( |
707 | - '' => __( 'All item types', 'invoicing' ) |
|
707 | + '' => __('All item types', 'invoicing') |
|
708 | 708 | ), |
709 | 709 | wpinv_get_item_types() |
710 | 710 | ), |
711 | 711 | 'name' => 'type', |
712 | 712 | 'id' => 'type', |
713 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
713 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
714 | 714 | 'show_option_all' => false, |
715 | 715 | 'show_option_none' => false, |
716 | 716 | ) |
@@ -721,45 +721,45 @@ discard block |
||
721 | 721 | /** |
722 | 722 | * Filters the item query. |
723 | 723 | */ |
724 | - public static function filter_item_query( $query ) { |
|
724 | + public static function filter_item_query($query) { |
|
725 | 725 | |
726 | 726 | // modify the query only if it admin and main query. |
727 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
727 | + if (!(is_admin() && $query->is_main_query())) { |
|
728 | 728 | return $query; |
729 | 729 | } |
730 | 730 | |
731 | 731 | // we want to modify the query for our items. |
732 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
732 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
733 | 733 | return $query; |
734 | 734 | } |
735 | 735 | |
736 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
736 | + if (empty($query->query_vars['meta_query'])) { |
|
737 | 737 | $query->query_vars['meta_query'] = array(); |
738 | 738 | } |
739 | 739 | |
740 | 740 | // Filter vat rule type |
741 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
741 | + if (!empty($_GET['vat_rule'])) { |
|
742 | 742 | $query->query_vars['meta_query'][] = array( |
743 | 743 | 'key' => '_wpinv_vat_rule', |
744 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
744 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
745 | 745 | 'compare' => '=' |
746 | 746 | ); |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Filter vat class |
750 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
750 | + if (!empty($_GET['vat_class'])) { |
|
751 | 751 | $query->query_vars['meta_query'][] = array( |
752 | 752 | 'key' => '_wpinv_vat_class', |
753 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
753 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
754 | 754 | 'compare' => '=' |
755 | 755 | ); |
756 | 756 | } |
757 | 757 | |
758 | 758 | // Filter item type |
759 | - if ( ! empty( $_GET['type'] ) ) { |
|
759 | + if (!empty($_GET['type'])) { |
|
760 | 760 | $query->query_vars['meta_query'][] = array( |
761 | 761 | 'key' => '_wpinv_type', |
762 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
762 | + 'value' => sanitize_text_field($_GET['type']), |
|
763 | 763 | 'compare' => '=' |
764 | 764 | ); |
765 | 765 | } |
@@ -769,15 +769,15 @@ discard block |
||
769 | 769 | /** |
770 | 770 | * Reorders items. |
771 | 771 | */ |
772 | - public static function reorder_items( $vars ) { |
|
772 | + public static function reorder_items($vars) { |
|
773 | 773 | global $typenow; |
774 | 774 | |
775 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
775 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
776 | 776 | return $vars; |
777 | 777 | } |
778 | 778 | |
779 | 779 | // By item type. |
780 | - if ( 'type' == $vars['orderby'] ) { |
|
780 | + if ('type' == $vars['orderby']) { |
|
781 | 781 | return array_merge( |
782 | 782 | $vars, |
783 | 783 | array( |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | } |
789 | 789 | |
790 | 790 | // By vat class. |
791 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
791 | + if ('vat_class' == $vars['orderby']) { |
|
792 | 792 | return array_merge( |
793 | 793 | $vars, |
794 | 794 | array( |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | } |
800 | 800 | |
801 | 801 | // By vat rule. |
802 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
802 | + if ('vat_rule' == $vars['orderby']) { |
|
803 | 803 | return array_merge( |
804 | 804 | $vars, |
805 | 805 | array( |
@@ -810,7 +810,7 @@ discard block |
||
810 | 810 | } |
811 | 811 | |
812 | 812 | // By price. |
813 | - if ( 'price' == $vars['orderby'] ) { |
|
813 | + if ('price' == $vars['orderby']) { |
|
814 | 814 | return array_merge( |
815 | 815 | $vars, |
816 | 816 | array( |
@@ -827,27 +827,27 @@ discard block |
||
827 | 827 | /** |
828 | 828 | * Fired when deleting a post. |
829 | 829 | */ |
830 | - public static function delete_post( $post_id ) { |
|
830 | + public static function delete_post($post_id) { |
|
831 | 831 | |
832 | - switch ( get_post_type( $post_id ) ) { |
|
832 | + switch (get_post_type($post_id)) { |
|
833 | 833 | |
834 | 834 | case 'wpi_item' : |
835 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
835 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
836 | 836 | break; |
837 | 837 | |
838 | 838 | case 'wpi_payment_form' : |
839 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
839 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
840 | 840 | break; |
841 | 841 | |
842 | 842 | case 'wpi_discount' : |
843 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
843 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
844 | 844 | break; |
845 | 845 | |
846 | 846 | case 'wpi_invoice' : |
847 | - $invoice = new WPInv_Invoice( $post_id ); |
|
848 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
849 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
850 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
847 | + $invoice = new WPInv_Invoice($post_id); |
|
848 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
849 | + $invoice->get_data_store()->delete_items($invoice); |
|
850 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
851 | 851 | break; |
852 | 852 | } |
853 | 853 | } |
@@ -860,29 +860,29 @@ discard block |
||
860 | 860 | * |
861 | 861 | * @return mixed |
862 | 862 | */ |
863 | - public static function add_display_post_states( $post_states, $post ) { |
|
863 | + public static function add_display_post_states($post_states, $post) { |
|
864 | 864 | |
865 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
866 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
865 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
866 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
867 | 867 | } |
868 | 868 | |
869 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
869 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
870 | 870 | |
871 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
871 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
872 | 872 | $post_states["getpaid_{$post_type}_history_page"] = sprintf( |
873 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
873 | + __('GetPaid %s History Page', 'invoicing'), |
|
874 | 874 | $label |
875 | 875 | ); |
876 | 876 | } |
877 | 877 | |
878 | 878 | } |
879 | 879 | |
880 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
881 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' ); |
|
880 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
881 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing'); |
|
882 | 882 | } |
883 | 883 | |
884 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
885 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
884 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
885 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | return $post_states; |