@@ -13,646 +13,646 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
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 ); |
|
29 | - |
|
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 | - |
|
34 | - // Items table columns. |
|
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | - |
|
42 | - // Payment forms columns. |
|
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | - |
|
47 | - // Discount table columns. |
|
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | - |
|
51 | - // Deleting posts. |
|
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Post updated messages. |
|
58 | - */ |
|
59 | - public static function post_updated_messages( $messages ) { |
|
60 | - global $post; |
|
61 | - |
|
62 | - $messages['wpi_discount'] = array( |
|
63 | - 0 => '', |
|
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | - ); |
|
75 | - |
|
76 | - $messages['wpi_payment_form'] = array( |
|
77 | - 0 => '', |
|
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | - ); |
|
89 | - |
|
90 | - return $messages; |
|
91 | - |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Post row actions. |
|
96 | - */ |
|
97 | - public static function post_row_actions( $actions, $post ) { |
|
98 | - |
|
99 | - $post = get_post( $post ); |
|
100 | - |
|
101 | - // We do not want to edit the default payment form. |
|
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
105 | - } |
|
106 | - |
|
107 | - return $actions; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
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 ); |
|
29 | + |
|
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 | + |
|
34 | + // Items table columns. |
|
35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | + |
|
42 | + // Payment forms columns. |
|
43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | + |
|
47 | + // Discount table columns. |
|
48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + |
|
51 | + // Deleting posts. |
|
52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Post updated messages. |
|
58 | + */ |
|
59 | + public static function post_updated_messages( $messages ) { |
|
60 | + global $post; |
|
61 | + |
|
62 | + $messages['wpi_discount'] = array( |
|
63 | + 0 => '', |
|
64 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | + ); |
|
75 | + |
|
76 | + $messages['wpi_payment_form'] = array( |
|
77 | + 0 => '', |
|
78 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | + ); |
|
89 | + |
|
90 | + return $messages; |
|
91 | + |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Post row actions. |
|
96 | + */ |
|
97 | + public static function post_row_actions( $actions, $post ) { |
|
98 | + |
|
99 | + $post = get_post( $post ); |
|
100 | + |
|
101 | + // We do not want to edit the default payment form. |
|
102 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | + unset( $actions['trash'] ); |
|
104 | + unset( $actions['inline hide-if-no-js'] ); |
|
105 | + } |
|
106 | + |
|
107 | + return $actions; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | 111 | * Remove bulk edit option from admin side quote listing |
112 | 112 | * |
113 | 113 | * @since 1.0.0 |
114 | 114 | * @param array $actions post actions |
115 | - * @param WP_Post $post |
|
115 | + * @param WP_Post $post |
|
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | 118 | public static function filter_invoice_row_actions( $actions, $post ) { |
119 | 119 | |
120 | 120 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
121 | 121 | |
122 | - $actions = array(); |
|
123 | - $invoice = new WPInv_Invoice( $post ); |
|
124 | - |
|
125 | - $actions['edit'] = sprintf( |
|
126 | - '<a href="%1$s">%2$s</a>', |
|
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | - ); |
|
130 | - |
|
131 | - if ( ! $invoice->is_draft() ) { |
|
132 | - |
|
133 | - $actions['view'] = sprintf( |
|
134 | - '<a href="%1$s">%2$s</a>', |
|
135 | - esc_url( $invoice->get_view_url() ), |
|
136 | - sprintf( |
|
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | - ) |
|
140 | - ); |
|
141 | - |
|
142 | - $actions['send'] = sprintf( |
|
143 | - '<a href="%1$s">%2$s</a>', |
|
144 | - esc_url( |
|
145 | - wp_nonce_url( |
|
146 | - add_query_arg( |
|
147 | - array( |
|
148 | - 'getpaid-admin-action' => 'send_invoice', |
|
149 | - 'invoice_id' => $invoice->get_id() |
|
150 | - ) |
|
151 | - ), |
|
152 | - 'getpaid-nonce', |
|
153 | - 'getpaid-nonce' |
|
154 | - ) |
|
155 | - ), |
|
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | - ); |
|
158 | - |
|
159 | - } |
|
122 | + $actions = array(); |
|
123 | + $invoice = new WPInv_Invoice( $post ); |
|
124 | + |
|
125 | + $actions['edit'] = sprintf( |
|
126 | + '<a href="%1$s">%2$s</a>', |
|
127 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | + ); |
|
130 | + |
|
131 | + if ( ! $invoice->is_draft() ) { |
|
132 | + |
|
133 | + $actions['view'] = sprintf( |
|
134 | + '<a href="%1$s">%2$s</a>', |
|
135 | + esc_url( $invoice->get_view_url() ), |
|
136 | + sprintf( |
|
137 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | + ) |
|
140 | + ); |
|
141 | + |
|
142 | + $actions['send'] = sprintf( |
|
143 | + '<a href="%1$s">%2$s</a>', |
|
144 | + esc_url( |
|
145 | + wp_nonce_url( |
|
146 | + add_query_arg( |
|
147 | + array( |
|
148 | + 'getpaid-admin-action' => 'send_invoice', |
|
149 | + 'invoice_id' => $invoice->get_id() |
|
150 | + ) |
|
151 | + ), |
|
152 | + 'getpaid-nonce', |
|
153 | + 'getpaid-nonce' |
|
154 | + ) |
|
155 | + ), |
|
156 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | + ); |
|
158 | + |
|
159 | + } |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | return $actions; |
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Returns an array of invoice table columns. |
|
168 | - */ |
|
169 | - public static function invoice_columns( $columns ) { |
|
170 | - |
|
171 | - $columns = array( |
|
172 | - 'cb' => $columns['cb'], |
|
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | - 'status' => __( 'Status', 'invoicing' ), |
|
180 | - ); |
|
181 | - |
|
182 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Displays invoice table columns. |
|
187 | - */ |
|
188 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
189 | - |
|
190 | - $invoice = new WPInv_Invoice( $post_id ); |
|
191 | - |
|
192 | - switch ( $column_name ) { |
|
193 | - |
|
194 | - case 'invoice_date' : |
|
195 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | - echo "<span title='$date_time'>$date</span>"; |
|
198 | - break; |
|
199 | - |
|
200 | - case 'payment_date' : |
|
201 | - |
|
202 | - if ( $invoice->is_paid() ) { |
|
203 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
205 | - echo "<span title='$date_time'>$date</span>"; |
|
206 | - } else { |
|
207 | - echo "—"; |
|
208 | - } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Returns an array of invoice table columns. |
|
168 | + */ |
|
169 | + public static function invoice_columns( $columns ) { |
|
170 | + |
|
171 | + $columns = array( |
|
172 | + 'cb' => $columns['cb'], |
|
173 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | + 'status' => __( 'Status', 'invoicing' ), |
|
180 | + ); |
|
181 | + |
|
182 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Displays invoice table columns. |
|
187 | + */ |
|
188 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
189 | + |
|
190 | + $invoice = new WPInv_Invoice( $post_id ); |
|
191 | + |
|
192 | + switch ( $column_name ) { |
|
193 | + |
|
194 | + case 'invoice_date' : |
|
195 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | + echo "<span title='$date_time'>$date</span>"; |
|
198 | + break; |
|
199 | + |
|
200 | + case 'payment_date' : |
|
201 | + |
|
202 | + if ( $invoice->is_paid() ) { |
|
203 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
205 | + echo "<span title='$date_time'>$date</span>"; |
|
206 | + } else { |
|
207 | + echo "—"; |
|
208 | + } |
|
209 | 209 | |
210 | - break; |
|
210 | + break; |
|
211 | 211 | |
212 | - case 'amount' : |
|
212 | + case 'amount' : |
|
213 | 213 | |
214 | - $amount = $invoice->get_total(); |
|
215 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
214 | + $amount = $invoice->get_total(); |
|
215 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
216 | 216 | |
217 | - if ( $invoice->is_refunded() ) { |
|
218 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
220 | - } else { |
|
217 | + if ( $invoice->is_refunded() ) { |
|
218 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
220 | + } else { |
|
221 | 221 | |
222 | - $discount = $invoice->get_total_discount(); |
|
222 | + $discount = $invoice->get_total_discount(); |
|
223 | 223 | |
224 | - if ( ! empty( $discount ) ) { |
|
225 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
227 | - } else { |
|
228 | - echo $formated_amount; |
|
229 | - } |
|
224 | + if ( ! empty( $discount ) ) { |
|
225 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
227 | + } else { |
|
228 | + echo $formated_amount; |
|
229 | + } |
|
230 | 230 | |
231 | - } |
|
231 | + } |
|
232 | 232 | |
233 | - break; |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'status' : |
|
236 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
235 | + case 'status' : |
|
236 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
238 | 238 | |
239 | - // If it is paid, show the gateway title. |
|
240 | - if ( $invoice->is_paid() ) { |
|
241 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
239 | + // If it is paid, show the gateway title. |
|
240 | + if ( $invoice->is_paid() ) { |
|
241 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
243 | 243 | |
244 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
245 | - } else { |
|
246 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
247 | - } |
|
244 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
245 | + } else { |
|
246 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
247 | + } |
|
248 | 248 | |
249 | - // If it is not paid, display the overdue and view status. |
|
250 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
249 | + // If it is not paid, display the overdue and view status. |
|
250 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
251 | 251 | |
252 | - // Invoice view status. |
|
253 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | - } else { |
|
256 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | - } |
|
252 | + // Invoice view status. |
|
253 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | + } else { |
|
256 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | + } |
|
258 | 258 | |
259 | - // Display the overview status. |
|
260 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
261 | - $due_date = $invoice->get_due_date(); |
|
262 | - $fomatted = getpaid_format_date( $due_date ); |
|
259 | + // Display the overview status. |
|
260 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
261 | + $due_date = $invoice->get_due_date(); |
|
262 | + $fomatted = getpaid_format_date( $due_date ); |
|
263 | 263 | |
264 | - if ( ! empty( $fomatted ) ) { |
|
265 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
267 | - } |
|
268 | - } |
|
264 | + if ( ! empty( $fomatted ) ) { |
|
265 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - } |
|
270 | + } |
|
271 | 271 | |
272 | - break; |
|
272 | + break; |
|
273 | 273 | |
274 | - case 'recurring': |
|
274 | + case 'recurring': |
|
275 | 275 | |
276 | - if ( $invoice->is_recurring() ) { |
|
277 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
278 | - } else { |
|
279 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
280 | - } |
|
281 | - break; |
|
276 | + if ( $invoice->is_recurring() ) { |
|
277 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
278 | + } else { |
|
279 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
280 | + } |
|
281 | + break; |
|
282 | 282 | |
283 | - case 'number' : |
|
283 | + case 'number' : |
|
284 | 284 | |
285 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
285 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
288 | 288 | |
289 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
289 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
290 | 290 | |
291 | - break; |
|
291 | + break; |
|
292 | 292 | |
293 | - case 'customer' : |
|
293 | + case 'customer' : |
|
294 | 294 | |
295 | - $customer_name = $invoice->get_user_full_name(); |
|
295 | + $customer_name = $invoice->get_user_full_name(); |
|
296 | 296 | |
297 | - if ( empty( $customer_name ) ) { |
|
298 | - $customer_name = $invoice->get_email(); |
|
299 | - } |
|
297 | + if ( empty( $customer_name ) ) { |
|
298 | + $customer_name = $invoice->get_email(); |
|
299 | + } |
|
300 | 300 | |
301 | - if ( ! empty( $customer_name ) ) { |
|
302 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
304 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
305 | - } else { |
|
306 | - echo '<div>—</div>'; |
|
307 | - } |
|
301 | + if ( ! empty( $customer_name ) ) { |
|
302 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
304 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
305 | + } else { |
|
306 | + echo '<div>—</div>'; |
|
307 | + } |
|
308 | 308 | |
309 | - break; |
|
309 | + break; |
|
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - /** |
|
316 | - * Returns an array of payment forms table columns. |
|
317 | - */ |
|
318 | - public static function payment_form_columns( $columns ) { |
|
315 | + /** |
|
316 | + * Returns an array of payment forms table columns. |
|
317 | + */ |
|
318 | + public static function payment_form_columns( $columns ) { |
|
319 | 319 | |
320 | - $columns = array( |
|
321 | - 'cb' => $columns['cb'], |
|
322 | - 'title' => __( 'Name', 'invoicing' ), |
|
323 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | - 'items' => __( 'Items', 'invoicing' ), |
|
327 | - 'date' => __( 'Date', 'invoicing' ), |
|
328 | - ); |
|
320 | + $columns = array( |
|
321 | + 'cb' => $columns['cb'], |
|
322 | + 'title' => __( 'Name', 'invoicing' ), |
|
323 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | + 'items' => __( 'Items', 'invoicing' ), |
|
327 | + 'date' => __( 'Date', 'invoicing' ), |
|
328 | + ); |
|
329 | 329 | |
330 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
330 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
331 | 331 | |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Displays payment form table columns. |
|
336 | - */ |
|
337 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
334 | + /** |
|
335 | + * Displays payment form table columns. |
|
336 | + */ |
|
337 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
338 | 338 | |
339 | - // Retrieve the payment form. |
|
340 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
339 | + // Retrieve the payment form. |
|
340 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
341 | 341 | |
342 | - switch ( $column_name ) { |
|
342 | + switch ( $column_name ) { |
|
343 | 343 | |
344 | - case 'earnings' : |
|
345 | - echo wpinv_price( $form->get_earned() ); |
|
346 | - break; |
|
344 | + case 'earnings' : |
|
345 | + echo wpinv_price( $form->get_earned() ); |
|
346 | + break; |
|
347 | 347 | |
348 | - case 'refunds' : |
|
349 | - echo wpinv_price( $form->get_refunded() ); |
|
350 | - break; |
|
348 | + case 'refunds' : |
|
349 | + echo wpinv_price( $form->get_refunded() ); |
|
350 | + break; |
|
351 | 351 | |
352 | - case 'refunds' : |
|
353 | - echo wpinv_price( $form->get_refunded() ); |
|
354 | - break; |
|
352 | + case 'refunds' : |
|
353 | + echo wpinv_price( $form->get_refunded() ); |
|
354 | + break; |
|
355 | 355 | |
356 | - case 'shortcode' : |
|
356 | + case 'shortcode' : |
|
357 | 357 | |
358 | - if ( $form->is_default() ) { |
|
359 | - echo '—'; |
|
360 | - } else { |
|
361 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
362 | - } |
|
358 | + if ( $form->is_default() ) { |
|
359 | + echo '—'; |
|
360 | + } else { |
|
361 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
362 | + } |
|
363 | 363 | |
364 | - break; |
|
364 | + break; |
|
365 | 365 | |
366 | - case 'items' : |
|
366 | + case 'items' : |
|
367 | 367 | |
368 | - $items = $form->get_items(); |
|
368 | + $items = $form->get_items(); |
|
369 | 369 | |
370 | - if ( $form->is_default() || empty( $items ) ) { |
|
371 | - echo '—'; |
|
372 | - return; |
|
373 | - } |
|
370 | + if ( $form->is_default() || empty( $items ) ) { |
|
371 | + echo '—'; |
|
372 | + return; |
|
373 | + } |
|
374 | 374 | |
375 | - $_items = array(); |
|
375 | + $_items = array(); |
|
376 | 376 | |
377 | - foreach ( $items as $item ) { |
|
378 | - $url = $item->get_edit_url(); |
|
377 | + foreach ( $items as $item ) { |
|
378 | + $url = $item->get_edit_url(); |
|
379 | 379 | |
380 | - if ( empty( $url ) ) { |
|
381 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | - } else { |
|
383 | - $_items[] = sprintf( |
|
384 | - '<a href="%s">%s</a>', |
|
385 | - esc_url( $url ), |
|
386 | - sanitize_text_field( $item->get_name() ) |
|
387 | - ); |
|
388 | - } |
|
380 | + if ( empty( $url ) ) { |
|
381 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | + } else { |
|
383 | + $_items[] = sprintf( |
|
384 | + '<a href="%s">%s</a>', |
|
385 | + esc_url( $url ), |
|
386 | + sanitize_text_field( $item->get_name() ) |
|
387 | + ); |
|
388 | + } |
|
389 | 389 | |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - echo implode( '<br>', $_items ); |
|
392 | + echo implode( '<br>', $_items ); |
|
393 | 393 | |
394 | - break; |
|
394 | + break; |
|
395 | 395 | |
396 | - } |
|
396 | + } |
|
397 | 397 | |
398 | - } |
|
398 | + } |
|
399 | 399 | |
400 | - /** |
|
401 | - * Filters post states. |
|
402 | - */ |
|
403 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
400 | + /** |
|
401 | + * Filters post states. |
|
402 | + */ |
|
403 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
404 | 404 | |
405 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | - } |
|
405 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | + } |
|
408 | 408 | |
409 | - return $post_states; |
|
410 | - |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Returns an array of coupon table columns. |
|
415 | - */ |
|
416 | - public static function discount_columns( $columns ) { |
|
417 | - |
|
418 | - $columns = array( |
|
419 | - 'cb' => $columns['cb'], |
|
420 | - 'title' => __( 'Name', 'invoicing' ), |
|
421 | - 'code' => __( 'Code', 'invoicing' ), |
|
422 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
426 | - ); |
|
427 | - |
|
428 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
429 | - } |
|
430 | - |
|
431 | - /** |
|
432 | - * Filters post states. |
|
433 | - */ |
|
434 | - public static function filter_discount_state( $post_states, $post ) { |
|
435 | - |
|
436 | - if ( 'wpi_discount' == $post->post_type ) { |
|
437 | - |
|
438 | - $discount = new WPInv_Discount( $post ); |
|
439 | - |
|
440 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
441 | - |
|
442 | - if ( $status != 'publish' ) { |
|
443 | - return array( |
|
444 | - 'discount_status' => wpinv_discount_status( $status ), |
|
445 | - ); |
|
446 | - } |
|
447 | - |
|
448 | - return array(); |
|
449 | - |
|
450 | - } |
|
451 | - |
|
452 | - return $post_states; |
|
453 | - |
|
454 | - } |
|
455 | - |
|
456 | - /** |
|
457 | - * Returns an array of items table columns. |
|
458 | - */ |
|
459 | - public static function item_columns( $columns ) { |
|
460 | - |
|
461 | - $columns = array( |
|
462 | - 'cb' => $columns['cb'], |
|
463 | - 'title' => __( 'Name', 'invoicing' ), |
|
464 | - 'price' => __( 'Price', 'invoicing' ), |
|
465 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | - 'type' => __( 'Type', 'invoicing' ), |
|
468 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
469 | - ); |
|
470 | - |
|
471 | - if ( ! wpinv_use_taxes() ) { |
|
472 | - unset( $columns['vat_rule'] ); |
|
473 | - unset( $columns['vat_class'] ); |
|
474 | - } |
|
475 | - |
|
476 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Returns an array of sortable items table columns. |
|
481 | - */ |
|
482 | - public static function sortable_item_columns( $columns ) { |
|
483 | - |
|
484 | - return array_merge( |
|
485 | - $columns, |
|
486 | - array( |
|
487 | - 'price' => 'price', |
|
488 | - 'vat_rule' => 'vat_rule', |
|
489 | - 'vat_class' => 'vat_class', |
|
490 | - 'type' => 'type', |
|
491 | - ) |
|
492 | - ); |
|
493 | - |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * Displays items table columns. |
|
498 | - */ |
|
499 | - public static function display_item_columns( $column_name, $post_id ) { |
|
409 | + return $post_states; |
|
410 | + |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Returns an array of coupon table columns. |
|
415 | + */ |
|
416 | + public static function discount_columns( $columns ) { |
|
417 | + |
|
418 | + $columns = array( |
|
419 | + 'cb' => $columns['cb'], |
|
420 | + 'title' => __( 'Name', 'invoicing' ), |
|
421 | + 'code' => __( 'Code', 'invoicing' ), |
|
422 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
426 | + ); |
|
427 | + |
|
428 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
429 | + } |
|
430 | + |
|
431 | + /** |
|
432 | + * Filters post states. |
|
433 | + */ |
|
434 | + public static function filter_discount_state( $post_states, $post ) { |
|
435 | + |
|
436 | + if ( 'wpi_discount' == $post->post_type ) { |
|
437 | + |
|
438 | + $discount = new WPInv_Discount( $post ); |
|
439 | + |
|
440 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
441 | + |
|
442 | + if ( $status != 'publish' ) { |
|
443 | + return array( |
|
444 | + 'discount_status' => wpinv_discount_status( $status ), |
|
445 | + ); |
|
446 | + } |
|
447 | + |
|
448 | + return array(); |
|
449 | + |
|
450 | + } |
|
451 | + |
|
452 | + return $post_states; |
|
453 | + |
|
454 | + } |
|
455 | + |
|
456 | + /** |
|
457 | + * Returns an array of items table columns. |
|
458 | + */ |
|
459 | + public static function item_columns( $columns ) { |
|
460 | + |
|
461 | + $columns = array( |
|
462 | + 'cb' => $columns['cb'], |
|
463 | + 'title' => __( 'Name', 'invoicing' ), |
|
464 | + 'price' => __( 'Price', 'invoicing' ), |
|
465 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | + 'type' => __( 'Type', 'invoicing' ), |
|
468 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
469 | + ); |
|
470 | + |
|
471 | + if ( ! wpinv_use_taxes() ) { |
|
472 | + unset( $columns['vat_rule'] ); |
|
473 | + unset( $columns['vat_class'] ); |
|
474 | + } |
|
475 | + |
|
476 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Returns an array of sortable items table columns. |
|
481 | + */ |
|
482 | + public static function sortable_item_columns( $columns ) { |
|
483 | + |
|
484 | + return array_merge( |
|
485 | + $columns, |
|
486 | + array( |
|
487 | + 'price' => 'price', |
|
488 | + 'vat_rule' => 'vat_rule', |
|
489 | + 'vat_class' => 'vat_class', |
|
490 | + 'type' => 'type', |
|
491 | + ) |
|
492 | + ); |
|
493 | + |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * Displays items table columns. |
|
498 | + */ |
|
499 | + public static function display_item_columns( $column_name, $post_id ) { |
|
500 | 500 | |
501 | - $item = new WPInv_Item( $post_id ); |
|
501 | + $item = new WPInv_Item( $post_id ); |
|
502 | 502 | |
503 | - switch ( $column_name ) { |
|
503 | + switch ( $column_name ) { |
|
504 | 504 | |
505 | - case 'price' : |
|
505 | + case 'price' : |
|
506 | 506 | |
507 | - if ( ! $item->is_recurring() ) { |
|
508 | - echo $item->get_the_price(); |
|
509 | - break; |
|
510 | - } |
|
507 | + if ( ! $item->is_recurring() ) { |
|
508 | + echo $item->get_the_price(); |
|
509 | + break; |
|
510 | + } |
|
511 | 511 | |
512 | - $price = wp_sprintf( |
|
513 | - __( '%s / %s', 'invoicing' ), |
|
514 | - $item->get_the_price(), |
|
515 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
516 | - ); |
|
512 | + $price = wp_sprintf( |
|
513 | + __( '%s / %s', 'invoicing' ), |
|
514 | + $item->get_the_price(), |
|
515 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
516 | + ); |
|
517 | 517 | |
518 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
519 | - echo $price; |
|
520 | - break; |
|
521 | - } |
|
518 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
519 | + echo $price; |
|
520 | + break; |
|
521 | + } |
|
522 | 522 | |
523 | - echo $item->get_the_initial_price(); |
|
523 | + echo $item->get_the_initial_price(); |
|
524 | 524 | |
525 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
526 | - break; |
|
525 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
526 | + break; |
|
527 | 527 | |
528 | - case 'vat_rule' : |
|
529 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
530 | - break; |
|
528 | + case 'vat_rule' : |
|
529 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
530 | + break; |
|
531 | 531 | |
532 | - case 'vat_class' : |
|
533 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
534 | - break; |
|
532 | + case 'vat_class' : |
|
533 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
534 | + break; |
|
535 | 535 | |
536 | - case 'shortcode' : |
|
537 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | - break; |
|
536 | + case 'shortcode' : |
|
537 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | + break; |
|
539 | 539 | |
540 | - case 'type' : |
|
541 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | - break; |
|
540 | + case 'type' : |
|
541 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | + break; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - /** |
|
549 | - * Lets users filter items using taxes. |
|
550 | - */ |
|
551 | - public static function add_item_filters( $post_type ) { |
|
548 | + /** |
|
549 | + * Lets users filter items using taxes. |
|
550 | + */ |
|
551 | + public static function add_item_filters( $post_type ) { |
|
552 | 552 | |
553 | - // Abort if we're not dealing with items. |
|
554 | - if ( $post_type != 'wpi_item' ) { |
|
555 | - return; |
|
556 | - } |
|
553 | + // Abort if we're not dealing with items. |
|
554 | + if ( $post_type != 'wpi_item' ) { |
|
555 | + return; |
|
556 | + } |
|
557 | 557 | |
558 | - // Filter by vat rules. |
|
559 | - if ( wpinv_use_taxes() ) { |
|
558 | + // Filter by vat rules. |
|
559 | + if ( wpinv_use_taxes() ) { |
|
560 | 560 | |
561 | - // Sanitize selected vat rule. |
|
562 | - $vat_rule = ''; |
|
563 | - $vat_rules = getpaid_get_tax_rules(); |
|
564 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | - $vat_rule = $_GET['vat_rule']; |
|
566 | - } |
|
567 | - |
|
568 | - // Filter by VAT rule. |
|
569 | - echo wpinv_html_select( |
|
570 | - array( |
|
571 | - 'options' => array_merge( |
|
572 | - array( |
|
573 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
574 | - ), |
|
575 | - $vat_rules |
|
576 | - ), |
|
577 | - 'name' => 'vat_rule', |
|
578 | - 'id' => 'vat_rule', |
|
579 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
580 | - 'show_option_all' => false, |
|
581 | - 'show_option_none' => false, |
|
582 | - ) |
|
583 | - ); |
|
584 | - |
|
585 | - // Filter by VAT class. |
|
561 | + // Sanitize selected vat rule. |
|
562 | + $vat_rule = ''; |
|
563 | + $vat_rules = getpaid_get_tax_rules(); |
|
564 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | + $vat_rule = $_GET['vat_rule']; |
|
566 | + } |
|
567 | + |
|
568 | + // Filter by VAT rule. |
|
569 | + echo wpinv_html_select( |
|
570 | + array( |
|
571 | + 'options' => array_merge( |
|
572 | + array( |
|
573 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
574 | + ), |
|
575 | + $vat_rules |
|
576 | + ), |
|
577 | + 'name' => 'vat_rule', |
|
578 | + 'id' => 'vat_rule', |
|
579 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
580 | + 'show_option_all' => false, |
|
581 | + 'show_option_none' => false, |
|
582 | + ) |
|
583 | + ); |
|
584 | + |
|
585 | + // Filter by VAT class. |
|
586 | 586 | |
587 | - // Sanitize selected vat rule. |
|
588 | - $vat_class = ''; |
|
589 | - $vat_classes = getpaid_get_tax_classes(); |
|
590 | - if ( isset( $_GET['vat_class'] ) ) { |
|
591 | - $vat_class = $_GET['vat_class']; |
|
592 | - } |
|
593 | - |
|
594 | - echo wpinv_html_select( |
|
595 | - array( |
|
596 | - 'options' => array_merge( |
|
597 | - array( |
|
598 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
599 | - ), |
|
600 | - $vat_classes |
|
601 | - ), |
|
602 | - 'name' => 'vat_class', |
|
603 | - 'id' => 'vat_class', |
|
604 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
605 | - 'show_option_all' => false, |
|
606 | - 'show_option_none' => false, |
|
607 | - ) |
|
608 | - ); |
|
609 | - |
|
610 | - } |
|
611 | - |
|
612 | - // Filter by item type. |
|
613 | - $type = ''; |
|
614 | - if ( isset( $_GET['type'] ) ) { |
|
615 | - $type = $_GET['type']; |
|
616 | - } |
|
617 | - |
|
618 | - echo wpinv_html_select( |
|
619 | - array( |
|
620 | - 'options' => array_merge( |
|
621 | - array( |
|
622 | - '' => __( 'All item types', 'invoicing' ) |
|
623 | - ), |
|
624 | - wpinv_get_item_types() |
|
625 | - ), |
|
626 | - 'name' => 'type', |
|
627 | - 'id' => 'type', |
|
628 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
629 | - 'show_option_all' => false, |
|
630 | - 'show_option_none' => false, |
|
631 | - ) |
|
632 | - ); |
|
633 | - |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Filters the item query. |
|
638 | - */ |
|
639 | - public static function filter_item_query( $query ) { |
|
640 | - |
|
641 | - // modify the query only if it admin and main query. |
|
642 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
643 | - return $query; |
|
644 | - } |
|
645 | - |
|
646 | - // we want to modify the query for our items. |
|
647 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
648 | - return $query; |
|
649 | - } |
|
650 | - |
|
651 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
652 | - $query->query_vars['meta_query'] = array(); |
|
653 | - } |
|
654 | - |
|
655 | - // Filter vat rule type |
|
587 | + // Sanitize selected vat rule. |
|
588 | + $vat_class = ''; |
|
589 | + $vat_classes = getpaid_get_tax_classes(); |
|
590 | + if ( isset( $_GET['vat_class'] ) ) { |
|
591 | + $vat_class = $_GET['vat_class']; |
|
592 | + } |
|
593 | + |
|
594 | + echo wpinv_html_select( |
|
595 | + array( |
|
596 | + 'options' => array_merge( |
|
597 | + array( |
|
598 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
599 | + ), |
|
600 | + $vat_classes |
|
601 | + ), |
|
602 | + 'name' => 'vat_class', |
|
603 | + 'id' => 'vat_class', |
|
604 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
605 | + 'show_option_all' => false, |
|
606 | + 'show_option_none' => false, |
|
607 | + ) |
|
608 | + ); |
|
609 | + |
|
610 | + } |
|
611 | + |
|
612 | + // Filter by item type. |
|
613 | + $type = ''; |
|
614 | + if ( isset( $_GET['type'] ) ) { |
|
615 | + $type = $_GET['type']; |
|
616 | + } |
|
617 | + |
|
618 | + echo wpinv_html_select( |
|
619 | + array( |
|
620 | + 'options' => array_merge( |
|
621 | + array( |
|
622 | + '' => __( 'All item types', 'invoicing' ) |
|
623 | + ), |
|
624 | + wpinv_get_item_types() |
|
625 | + ), |
|
626 | + 'name' => 'type', |
|
627 | + 'id' => 'type', |
|
628 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
629 | + 'show_option_all' => false, |
|
630 | + 'show_option_none' => false, |
|
631 | + ) |
|
632 | + ); |
|
633 | + |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * Filters the item query. |
|
638 | + */ |
|
639 | + public static function filter_item_query( $query ) { |
|
640 | + |
|
641 | + // modify the query only if it admin and main query. |
|
642 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
643 | + return $query; |
|
644 | + } |
|
645 | + |
|
646 | + // we want to modify the query for our items. |
|
647 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
648 | + return $query; |
|
649 | + } |
|
650 | + |
|
651 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
652 | + $query->query_vars['meta_query'] = array(); |
|
653 | + } |
|
654 | + |
|
655 | + // Filter vat rule type |
|
656 | 656 | if ( ! empty( $_GET['vat_rule'] ) ) { |
657 | 657 | $query->query_vars['meta_query'][] = array( |
658 | 658 | 'key' => '_wpinv_vat_rule', |
@@ -677,94 +677,94 @@ discard block |
||
677 | 677 | 'value' => sanitize_text_field( $_GET['type'] ), |
678 | 678 | 'compare' => '=' |
679 | 679 | ); |
680 | - } |
|
681 | - |
|
682 | - } |
|
683 | - |
|
684 | - /** |
|
685 | - * Reorders items. |
|
686 | - */ |
|
687 | - public static function reorder_items( $vars ) { |
|
688 | - global $typenow; |
|
689 | - |
|
690 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
691 | - return $vars; |
|
692 | - } |
|
693 | - |
|
694 | - // By item type. |
|
695 | - if ( 'type' == $vars['orderby'] ) { |
|
696 | - return array_merge( |
|
697 | - $vars, |
|
698 | - array( |
|
699 | - 'meta_key' => '_wpinv_type', |
|
700 | - 'orderby' => 'meta_value' |
|
701 | - ) |
|
702 | - ); |
|
703 | - } |
|
704 | - |
|
705 | - // By vat class. |
|
706 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
707 | - return array_merge( |
|
708 | - $vars, |
|
709 | - array( |
|
710 | - 'meta_key' => '_wpinv_vat_class', |
|
711 | - 'orderby' => 'meta_value' |
|
712 | - ) |
|
713 | - ); |
|
714 | - } |
|
715 | - |
|
716 | - // By vat rule. |
|
717 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
718 | - return array_merge( |
|
719 | - $vars, |
|
720 | - array( |
|
721 | - 'meta_key' => '_wpinv_vat_rule', |
|
722 | - 'orderby' => 'meta_value' |
|
723 | - ) |
|
724 | - ); |
|
725 | - } |
|
726 | - |
|
727 | - // By price. |
|
728 | - if ( 'price' == $vars['orderby'] ) { |
|
729 | - return array_merge( |
|
730 | - $vars, |
|
731 | - array( |
|
732 | - 'meta_key' => '_wpinv_price', |
|
733 | - 'orderby' => 'meta_value_num' |
|
734 | - ) |
|
735 | - ); |
|
736 | - } |
|
737 | - |
|
738 | - return $vars; |
|
739 | - |
|
740 | - } |
|
741 | - |
|
742 | - /** |
|
743 | - * Fired when deleting a post. |
|
744 | - */ |
|
745 | - public static function delete_post( $post_id ) { |
|
746 | - |
|
747 | - switch ( get_post_type( $post_id ) ) { |
|
748 | - |
|
749 | - case 'wpi_item' : |
|
750 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
751 | - break; |
|
752 | - |
|
753 | - case 'wpi_payment_form' : |
|
754 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
755 | - break; |
|
756 | - |
|
757 | - case 'wpi_discount' : |
|
758 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
759 | - break; |
|
760 | - |
|
761 | - case 'wpi_invoice' : |
|
762 | - $invoice = new WPInv_Invoice( $post_id ); |
|
763 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
766 | - break; |
|
767 | - } |
|
768 | - } |
|
680 | + } |
|
681 | + |
|
682 | + } |
|
683 | + |
|
684 | + /** |
|
685 | + * Reorders items. |
|
686 | + */ |
|
687 | + public static function reorder_items( $vars ) { |
|
688 | + global $typenow; |
|
689 | + |
|
690 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
691 | + return $vars; |
|
692 | + } |
|
693 | + |
|
694 | + // By item type. |
|
695 | + if ( 'type' == $vars['orderby'] ) { |
|
696 | + return array_merge( |
|
697 | + $vars, |
|
698 | + array( |
|
699 | + 'meta_key' => '_wpinv_type', |
|
700 | + 'orderby' => 'meta_value' |
|
701 | + ) |
|
702 | + ); |
|
703 | + } |
|
704 | + |
|
705 | + // By vat class. |
|
706 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
707 | + return array_merge( |
|
708 | + $vars, |
|
709 | + array( |
|
710 | + 'meta_key' => '_wpinv_vat_class', |
|
711 | + 'orderby' => 'meta_value' |
|
712 | + ) |
|
713 | + ); |
|
714 | + } |
|
715 | + |
|
716 | + // By vat rule. |
|
717 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
718 | + return array_merge( |
|
719 | + $vars, |
|
720 | + array( |
|
721 | + 'meta_key' => '_wpinv_vat_rule', |
|
722 | + 'orderby' => 'meta_value' |
|
723 | + ) |
|
724 | + ); |
|
725 | + } |
|
726 | + |
|
727 | + // By price. |
|
728 | + if ( 'price' == $vars['orderby'] ) { |
|
729 | + return array_merge( |
|
730 | + $vars, |
|
731 | + array( |
|
732 | + 'meta_key' => '_wpinv_price', |
|
733 | + 'orderby' => 'meta_value_num' |
|
734 | + ) |
|
735 | + ); |
|
736 | + } |
|
737 | + |
|
738 | + return $vars; |
|
739 | + |
|
740 | + } |
|
741 | + |
|
742 | + /** |
|
743 | + * Fired when deleting a post. |
|
744 | + */ |
|
745 | + public static function delete_post( $post_id ) { |
|
746 | + |
|
747 | + switch ( get_post_type( $post_id ) ) { |
|
748 | + |
|
749 | + case 'wpi_item' : |
|
750 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
751 | + break; |
|
752 | + |
|
753 | + case 'wpi_payment_form' : |
|
754 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
755 | + break; |
|
756 | + |
|
757 | + case 'wpi_discount' : |
|
758 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
759 | + break; |
|
760 | + |
|
761 | + case 'wpi_invoice' : |
|
762 | + $invoice = new WPInv_Invoice( $post_id ); |
|
763 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
766 | + break; |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
@@ -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,70 +21,70 @@ 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 ); |
|
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 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Post updated messages. |
58 | 58 | */ |
59 | - public static function post_updated_messages( $messages ) { |
|
59 | + public static function post_updated_messages($messages) { |
|
60 | 60 | global $post; |
61 | 61 | |
62 | 62 | $messages['wpi_discount'] = array( |
63 | 63 | 0 => '', |
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
64 | + 1 => __('Discount updated.', 'invoicing'), |
|
65 | + 2 => __('Custom field updated.', 'invoicing'), |
|
66 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
67 | + 4 => __('Discount updated.', 'invoicing'), |
|
68 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
69 | + 6 => __('Discount updated.', 'invoicing'), |
|
70 | + 7 => __('Discount saved.', 'invoicing'), |
|
71 | + 8 => __('Discount submitted.', 'invoicing'), |
|
72 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
73 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $messages['wpi_payment_form'] = array( |
77 | 77 | 0 => '', |
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
78 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
79 | + 2 => __('Custom field updated.', 'invoicing'), |
|
80 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
81 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
83 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
85 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
86 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
87 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $messages; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Post row actions. |
96 | 96 | */ |
97 | - public static function post_row_actions( $actions, $post ) { |
|
97 | + public static function post_row_actions($actions, $post) { |
|
98 | 98 | |
99 | - $post = get_post( $post ); |
|
99 | + $post = get_post($post); |
|
100 | 100 | |
101 | 101 | // We do not want to edit the default payment form. |
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
102 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
103 | + unset($actions['trash']); |
|
104 | + unset($actions['inline hide-if-no-js']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $actions; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | * @param WP_Post $post |
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
118 | + public static function filter_invoice_row_actions($actions, $post) { |
|
119 | 119 | |
120 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
120 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
121 | 121 | |
122 | 122 | $actions = array(); |
123 | - $invoice = new WPInv_Invoice( $post ); |
|
123 | + $invoice = new WPInv_Invoice($post); |
|
124 | 124 | |
125 | - $actions['edit'] = sprintf( |
|
125 | + $actions['edit'] = sprintf( |
|
126 | 126 | '<a href="%1$s">%2$s</a>', |
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
127 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
128 | + esc_html(__('Edit', 'invoicing')) |
|
129 | 129 | ); |
130 | 130 | |
131 | - if ( ! $invoice->is_draft() ) { |
|
131 | + if (!$invoice->is_draft()) { |
|
132 | 132 | |
133 | - $actions['view'] = sprintf( |
|
133 | + $actions['view'] = sprintf( |
|
134 | 134 | '<a href="%1$s">%2$s</a>', |
135 | - esc_url( $invoice->get_view_url() ), |
|
135 | + esc_url($invoice->get_view_url()), |
|
136 | 136 | sprintf( |
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
137 | + esc_html(__('View %s', 'invoicing')), |
|
138 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
139 | 139 | ) |
140 | 140 | ); |
141 | 141 | |
142 | - $actions['send'] = sprintf( |
|
142 | + $actions['send'] = sprintf( |
|
143 | 143 | '<a href="%1$s">%2$s</a>', |
144 | 144 | esc_url( |
145 | 145 | wp_nonce_url( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'getpaid-nonce' |
154 | 154 | ) |
155 | 155 | ), |
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
156 | + esc_html(__('Send to Customer', 'invoicing')) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | } |
@@ -166,42 +166,42 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * Returns an array of invoice table columns. |
168 | 168 | */ |
169 | - public static function invoice_columns( $columns ) { |
|
169 | + public static function invoice_columns($columns) { |
|
170 | 170 | |
171 | 171 | $columns = array( |
172 | 172 | 'cb' => $columns['cb'], |
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | - 'status' => __( 'Status', 'invoicing' ), |
|
173 | + 'number' => __('Invoice', 'invoicing'), |
|
174 | + 'customer' => __('Customer', 'invoicing'), |
|
175 | + 'invoice_date' => __('Created', 'invoicing'), |
|
176 | + 'payment_date' => __('Completed', 'invoicing'), |
|
177 | + 'amount' => __('Amount', 'invoicing'), |
|
178 | + 'recurring' => __('Recurring', 'invoicing'), |
|
179 | + 'status' => __('Status', 'invoicing'), |
|
180 | 180 | ); |
181 | 181 | |
182 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
182 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Displays invoice table columns. |
187 | 187 | */ |
188 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
188 | + public static function display_invoice_columns($column_name, $post_id) { |
|
189 | 189 | |
190 | - $invoice = new WPInv_Invoice( $post_id ); |
|
190 | + $invoice = new WPInv_Invoice($post_id); |
|
191 | 191 | |
192 | - switch ( $column_name ) { |
|
192 | + switch ($column_name) { |
|
193 | 193 | |
194 | 194 | case 'invoice_date' : |
195 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
195 | + $date_time = esc_attr($invoice->get_created_date()); |
|
196 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
197 | 197 | echo "<span title='$date_time'>$date</span>"; |
198 | 198 | break; |
199 | 199 | |
200 | 200 | case 'payment_date' : |
201 | 201 | |
202 | - if ( $invoice->is_paid() ) { |
|
203 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
202 | + if ($invoice->is_paid()) { |
|
203 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
204 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
205 | 205 | echo "<span title='$date_time'>$date</span>"; |
206 | 206 | } else { |
207 | 207 | echo "—"; |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | case 'amount' : |
213 | 213 | |
214 | 214 | $amount = $invoice->get_total(); |
215 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
215 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
216 | 216 | |
217 | - if ( $invoice->is_refunded() ) { |
|
218 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
217 | + if ($invoice->is_refunded()) { |
|
218 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
219 | 219 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
220 | 220 | } else { |
221 | 221 | |
222 | 222 | $discount = $invoice->get_total_discount(); |
223 | 223 | |
224 | - if ( ! empty( $discount ) ) { |
|
225 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
224 | + if (!empty($discount)) { |
|
225 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
226 | 226 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
227 | 227 | } else { |
228 | 228 | echo $formated_amount; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'status' : |
236 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
236 | + $status = sanitize_text_field($invoice->get_status()); |
|
237 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
238 | 238 | |
239 | 239 | // If it is paid, show the gateway title. |
240 | - if ( $invoice->is_paid() ) { |
|
241 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
240 | + if ($invoice->is_paid()) { |
|
241 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
242 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
243 | 243 | |
244 | 244 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
245 | 245 | } else { |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | // If it is not paid, display the overdue and view status. |
250 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
250 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
251 | 251 | |
252 | 252 | // Invoice view status. |
253 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
253 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
254 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
255 | 255 | } else { |
256 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
256 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // Display the overview status. |
260 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
260 | + if (wpinv_get_option('overdue_active')) { |
|
261 | 261 | $due_date = $invoice->get_due_date(); |
262 | - $fomatted = getpaid_format_date( $due_date ); |
|
262 | + $fomatted = getpaid_format_date($due_date); |
|
263 | 263 | |
264 | - if ( ! empty( $fomatted ) ) { |
|
265 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
264 | + if (!empty($fomatted)) { |
|
265 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
266 | 266 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
267 | 267 | } |
268 | 268 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | case 'recurring': |
275 | 275 | |
276 | - if ( $invoice->is_recurring() ) { |
|
276 | + if ($invoice->is_recurring()) { |
|
277 | 277 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
278 | 278 | } else { |
279 | 279 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | |
283 | 283 | case 'number' : |
284 | 284 | |
285 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
285 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
286 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
287 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
288 | 288 | |
289 | 289 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
290 | 290 | |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | |
295 | 295 | $customer_name = $invoice->get_user_full_name(); |
296 | 296 | |
297 | - if ( empty( $customer_name ) ) { |
|
297 | + if (empty($customer_name)) { |
|
298 | 298 | $customer_name = $invoice->get_email(); |
299 | 299 | } |
300 | 300 | |
301 | - if ( ! empty( $customer_name ) ) { |
|
302 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
301 | + if (!empty($customer_name)) { |
|
302 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
303 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
304 | 304 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
305 | 305 | } else { |
306 | 306 | echo '<div>—</div>'; |
@@ -315,50 +315,50 @@ discard block |
||
315 | 315 | /** |
316 | 316 | * Returns an array of payment forms table columns. |
317 | 317 | */ |
318 | - public static function payment_form_columns( $columns ) { |
|
318 | + public static function payment_form_columns($columns) { |
|
319 | 319 | |
320 | 320 | $columns = array( |
321 | 321 | 'cb' => $columns['cb'], |
322 | - 'title' => __( 'Name', 'invoicing' ), |
|
323 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | - 'items' => __( 'Items', 'invoicing' ), |
|
327 | - 'date' => __( 'Date', 'invoicing' ), |
|
322 | + 'title' => __('Name', 'invoicing'), |
|
323 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
324 | + 'earnings' => __('Revenue', 'invoicing'), |
|
325 | + 'refunds' => __('Refunded', 'invoicing'), |
|
326 | + 'items' => __('Items', 'invoicing'), |
|
327 | + 'date' => __('Date', 'invoicing'), |
|
328 | 328 | ); |
329 | 329 | |
330 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
330 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
331 | 331 | |
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays payment form table columns. |
336 | 336 | */ |
337 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
337 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
338 | 338 | |
339 | 339 | // Retrieve the payment form. |
340 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
340 | + $form = new GetPaid_Payment_Form($post_id); |
|
341 | 341 | |
342 | - switch ( $column_name ) { |
|
342 | + switch ($column_name) { |
|
343 | 343 | |
344 | 344 | case 'earnings' : |
345 | - echo wpinv_price( $form->get_earned() ); |
|
345 | + echo wpinv_price($form->get_earned()); |
|
346 | 346 | break; |
347 | 347 | |
348 | 348 | case 'refunds' : |
349 | - echo wpinv_price( $form->get_refunded() ); |
|
349 | + echo wpinv_price($form->get_refunded()); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | case 'refunds' : |
353 | - echo wpinv_price( $form->get_refunded() ); |
|
353 | + echo wpinv_price($form->get_refunded()); |
|
354 | 354 | break; |
355 | 355 | |
356 | 356 | case 'shortcode' : |
357 | 357 | |
358 | - if ( $form->is_default() ) { |
|
358 | + if ($form->is_default()) { |
|
359 | 359 | echo '—'; |
360 | 360 | } else { |
361 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
361 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | break; |
@@ -367,29 +367,29 @@ discard block |
||
367 | 367 | |
368 | 368 | $items = $form->get_items(); |
369 | 369 | |
370 | - if ( $form->is_default() || empty( $items ) ) { |
|
370 | + if ($form->is_default() || empty($items)) { |
|
371 | 371 | echo '—'; |
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $_items = array(); |
376 | 376 | |
377 | - foreach ( $items as $item ) { |
|
377 | + foreach ($items as $item) { |
|
378 | 378 | $url = $item->get_edit_url(); |
379 | 379 | |
380 | - if ( empty( $url ) ) { |
|
381 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
380 | + if (empty($url)) { |
|
381 | + $_items[] = sanitize_text_field($item->get_name()); |
|
382 | 382 | } else { |
383 | 383 | $_items[] = sprintf( |
384 | 384 | '<a href="%s">%s</a>', |
385 | - esc_url( $url ), |
|
386 | - sanitize_text_field( $item->get_name() ) |
|
385 | + esc_url($url), |
|
386 | + sanitize_text_field($item->get_name()) |
|
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - echo implode( '<br>', $_items ); |
|
392 | + echo implode('<br>', $_items); |
|
393 | 393 | |
394 | 394 | break; |
395 | 395 | |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Filters post states. |
402 | 402 | */ |
403 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
403 | + public static function filter_payment_form_state($post_states, $post) { |
|
404 | 404 | |
405 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
405 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
406 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $post_states; |
@@ -413,35 +413,35 @@ discard block |
||
413 | 413 | /** |
414 | 414 | * Returns an array of coupon table columns. |
415 | 415 | */ |
416 | - public static function discount_columns( $columns ) { |
|
416 | + public static function discount_columns($columns) { |
|
417 | 417 | |
418 | 418 | $columns = array( |
419 | 419 | 'cb' => $columns['cb'], |
420 | - 'title' => __( 'Name', 'invoicing' ), |
|
421 | - 'code' => __( 'Code', 'invoicing' ), |
|
422 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
420 | + 'title' => __('Name', 'invoicing'), |
|
421 | + 'code' => __('Code', 'invoicing'), |
|
422 | + 'amount' => __('Amount', 'invoicing'), |
|
423 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
424 | + 'start_date' => __('Start Date', 'invoicing'), |
|
425 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
426 | 426 | ); |
427 | 427 | |
428 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
428 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Filters post states. |
433 | 433 | */ |
434 | - public static function filter_discount_state( $post_states, $post ) { |
|
434 | + public static function filter_discount_state($post_states, $post) { |
|
435 | 435 | |
436 | - if ( 'wpi_discount' == $post->post_type ) { |
|
436 | + if ('wpi_discount' == $post->post_type) { |
|
437 | 437 | |
438 | - $discount = new WPInv_Discount( $post ); |
|
438 | + $discount = new WPInv_Discount($post); |
|
439 | 439 | |
440 | 440 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
441 | 441 | |
442 | - if ( $status != 'publish' ) { |
|
442 | + if ($status != 'publish') { |
|
443 | 443 | return array( |
444 | - 'discount_status' => wpinv_discount_status( $status ), |
|
444 | + 'discount_status' => wpinv_discount_status($status), |
|
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
@@ -456,30 +456,30 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * Returns an array of items table columns. |
458 | 458 | */ |
459 | - public static function item_columns( $columns ) { |
|
459 | + public static function item_columns($columns) { |
|
460 | 460 | |
461 | 461 | $columns = array( |
462 | 462 | 'cb' => $columns['cb'], |
463 | - 'title' => __( 'Name', 'invoicing' ), |
|
464 | - 'price' => __( 'Price', 'invoicing' ), |
|
465 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | - 'type' => __( 'Type', 'invoicing' ), |
|
468 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
463 | + 'title' => __('Name', 'invoicing'), |
|
464 | + 'price' => __('Price', 'invoicing'), |
|
465 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
466 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
467 | + 'type' => __('Type', 'invoicing'), |
|
468 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
469 | 469 | ); |
470 | 470 | |
471 | - if ( ! wpinv_use_taxes() ) { |
|
472 | - unset( $columns['vat_rule'] ); |
|
473 | - unset( $columns['vat_class'] ); |
|
471 | + if (!wpinv_use_taxes()) { |
|
472 | + unset($columns['vat_rule']); |
|
473 | + unset($columns['vat_class']); |
|
474 | 474 | } |
475 | 475 | |
476 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
476 | + return apply_filters('wpi_item_table_columns', $columns); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
480 | 480 | * Returns an array of sortable items table columns. |
481 | 481 | */ |
482 | - public static function sortable_item_columns( $columns ) { |
|
482 | + public static function sortable_item_columns($columns) { |
|
483 | 483 | |
484 | 484 | return array_merge( |
485 | 485 | $columns, |
@@ -496,49 +496,49 @@ discard block |
||
496 | 496 | /** |
497 | 497 | * Displays items table columns. |
498 | 498 | */ |
499 | - public static function display_item_columns( $column_name, $post_id ) { |
|
499 | + public static function display_item_columns($column_name, $post_id) { |
|
500 | 500 | |
501 | - $item = new WPInv_Item( $post_id ); |
|
501 | + $item = new WPInv_Item($post_id); |
|
502 | 502 | |
503 | - switch ( $column_name ) { |
|
503 | + switch ($column_name) { |
|
504 | 504 | |
505 | 505 | case 'price' : |
506 | 506 | |
507 | - if ( ! $item->is_recurring() ) { |
|
507 | + if (!$item->is_recurring()) { |
|
508 | 508 | echo $item->get_the_price(); |
509 | 509 | break; |
510 | 510 | } |
511 | 511 | |
512 | 512 | $price = wp_sprintf( |
513 | - __( '%s / %s', 'invoicing' ), |
|
513 | + __('%s / %s', 'invoicing'), |
|
514 | 514 | $item->get_the_price(), |
515 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
515 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
516 | 516 | ); |
517 | 517 | |
518 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
518 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
519 | 519 | echo $price; |
520 | 520 | break; |
521 | 521 | } |
522 | 522 | |
523 | 523 | echo $item->get_the_initial_price(); |
524 | 524 | |
525 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
525 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
526 | 526 | break; |
527 | 527 | |
528 | 528 | case 'vat_rule' : |
529 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
529 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'vat_class' : |
533 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
533 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
534 | 534 | break; |
535 | 535 | |
536 | 536 | case 'shortcode' : |
537 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
537 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | 538 | break; |
539 | 539 | |
540 | 540 | case 'type' : |
541 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
541 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
@@ -548,21 +548,21 @@ discard block |
||
548 | 548 | /** |
549 | 549 | * Lets users filter items using taxes. |
550 | 550 | */ |
551 | - public static function add_item_filters( $post_type ) { |
|
551 | + public static function add_item_filters($post_type) { |
|
552 | 552 | |
553 | 553 | // Abort if we're not dealing with items. |
554 | - if ( $post_type != 'wpi_item' ) { |
|
554 | + if ($post_type != 'wpi_item') { |
|
555 | 555 | return; |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Filter by vat rules. |
559 | - if ( wpinv_use_taxes() ) { |
|
559 | + if (wpinv_use_taxes()) { |
|
560 | 560 | |
561 | 561 | // Sanitize selected vat rule. |
562 | 562 | $vat_rule = ''; |
563 | 563 | $vat_rules = getpaid_get_tax_rules(); |
564 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | - $vat_rule = $_GET['vat_rule']; |
|
564 | + if (isset($_GET['vat_rule'])) { |
|
565 | + $vat_rule = $_GET['vat_rule']; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | // Filter by VAT rule. |
@@ -570,13 +570,13 @@ discard block |
||
570 | 570 | array( |
571 | 571 | 'options' => array_merge( |
572 | 572 | array( |
573 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
573 | + '' => __('All VAT rules', 'invoicing') |
|
574 | 574 | ), |
575 | 575 | $vat_rules |
576 | 576 | ), |
577 | 577 | 'name' => 'vat_rule', |
578 | 578 | 'id' => 'vat_rule', |
579 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
579 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
580 | 580 | 'show_option_all' => false, |
581 | 581 | 'show_option_none' => false, |
582 | 582 | ) |
@@ -587,21 +587,21 @@ discard block |
||
587 | 587 | // Sanitize selected vat rule. |
588 | 588 | $vat_class = ''; |
589 | 589 | $vat_classes = getpaid_get_tax_classes(); |
590 | - if ( isset( $_GET['vat_class'] ) ) { |
|
591 | - $vat_class = $_GET['vat_class']; |
|
590 | + if (isset($_GET['vat_class'])) { |
|
591 | + $vat_class = $_GET['vat_class']; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | echo wpinv_html_select( |
595 | 595 | array( |
596 | 596 | 'options' => array_merge( |
597 | 597 | array( |
598 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
598 | + '' => __('All VAT classes', 'invoicing') |
|
599 | 599 | ), |
600 | 600 | $vat_classes |
601 | 601 | ), |
602 | 602 | 'name' => 'vat_class', |
603 | 603 | 'id' => 'vat_class', |
604 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
604 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
605 | 605 | 'show_option_all' => false, |
606 | 606 | 'show_option_none' => false, |
607 | 607 | ) |
@@ -610,22 +610,22 @@ discard block |
||
610 | 610 | } |
611 | 611 | |
612 | 612 | // Filter by item type. |
613 | - $type = ''; |
|
614 | - if ( isset( $_GET['type'] ) ) { |
|
615 | - $type = $_GET['type']; |
|
613 | + $type = ''; |
|
614 | + if (isset($_GET['type'])) { |
|
615 | + $type = $_GET['type']; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | echo wpinv_html_select( |
619 | 619 | array( |
620 | 620 | 'options' => array_merge( |
621 | 621 | array( |
622 | - '' => __( 'All item types', 'invoicing' ) |
|
622 | + '' => __('All item types', 'invoicing') |
|
623 | 623 | ), |
624 | 624 | wpinv_get_item_types() |
625 | 625 | ), |
626 | 626 | 'name' => 'type', |
627 | 627 | 'id' => 'type', |
628 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
628 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
629 | 629 | 'show_option_all' => false, |
630 | 630 | 'show_option_none' => false, |
631 | 631 | ) |
@@ -636,45 +636,45 @@ discard block |
||
636 | 636 | /** |
637 | 637 | * Filters the item query. |
638 | 638 | */ |
639 | - public static function filter_item_query( $query ) { |
|
639 | + public static function filter_item_query($query) { |
|
640 | 640 | |
641 | 641 | // modify the query only if it admin and main query. |
642 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
642 | + if (!(is_admin() && $query->is_main_query())) { |
|
643 | 643 | return $query; |
644 | 644 | } |
645 | 645 | |
646 | 646 | // we want to modify the query for our items. |
647 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
647 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
648 | 648 | return $query; |
649 | 649 | } |
650 | 650 | |
651 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
651 | + if (empty($query->query_vars['meta_query'])) { |
|
652 | 652 | $query->query_vars['meta_query'] = array(); |
653 | 653 | } |
654 | 654 | |
655 | 655 | // Filter vat rule type |
656 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
656 | + if (!empty($_GET['vat_rule'])) { |
|
657 | 657 | $query->query_vars['meta_query'][] = array( |
658 | 658 | 'key' => '_wpinv_vat_rule', |
659 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
659 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
660 | 660 | 'compare' => '=' |
661 | 661 | ); |
662 | 662 | } |
663 | 663 | |
664 | 664 | // Filter vat class |
665 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
665 | + if (!empty($_GET['vat_class'])) { |
|
666 | 666 | $query->query_vars['meta_query'][] = array( |
667 | 667 | 'key' => '_wpinv_vat_class', |
668 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
668 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
669 | 669 | 'compare' => '=' |
670 | 670 | ); |
671 | 671 | } |
672 | 672 | |
673 | 673 | // Filter item type |
674 | - if ( ! empty( $_GET['type'] ) ) { |
|
674 | + if (!empty($_GET['type'])) { |
|
675 | 675 | $query->query_vars['meta_query'][] = array( |
676 | 676 | 'key' => '_wpinv_type', |
677 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
677 | + 'value' => sanitize_text_field($_GET['type']), |
|
678 | 678 | 'compare' => '=' |
679 | 679 | ); |
680 | 680 | } |
@@ -684,15 +684,15 @@ discard block |
||
684 | 684 | /** |
685 | 685 | * Reorders items. |
686 | 686 | */ |
687 | - public static function reorder_items( $vars ) { |
|
687 | + public static function reorder_items($vars) { |
|
688 | 688 | global $typenow; |
689 | 689 | |
690 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
690 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
691 | 691 | return $vars; |
692 | 692 | } |
693 | 693 | |
694 | 694 | // By item type. |
695 | - if ( 'type' == $vars['orderby'] ) { |
|
695 | + if ('type' == $vars['orderby']) { |
|
696 | 696 | return array_merge( |
697 | 697 | $vars, |
698 | 698 | array( |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | // By vat class. |
706 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
706 | + if ('vat_class' == $vars['orderby']) { |
|
707 | 707 | return array_merge( |
708 | 708 | $vars, |
709 | 709 | array( |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | } |
715 | 715 | |
716 | 716 | // By vat rule. |
717 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
717 | + if ('vat_rule' == $vars['orderby']) { |
|
718 | 718 | return array_merge( |
719 | 719 | $vars, |
720 | 720 | array( |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | // By price. |
728 | - if ( 'price' == $vars['orderby'] ) { |
|
728 | + if ('price' == $vars['orderby']) { |
|
729 | 729 | return array_merge( |
730 | 730 | $vars, |
731 | 731 | array( |
@@ -742,27 +742,27 @@ discard block |
||
742 | 742 | /** |
743 | 743 | * Fired when deleting a post. |
744 | 744 | */ |
745 | - public static function delete_post( $post_id ) { |
|
745 | + public static function delete_post($post_id) { |
|
746 | 746 | |
747 | - switch ( get_post_type( $post_id ) ) { |
|
747 | + switch (get_post_type($post_id)) { |
|
748 | 748 | |
749 | 749 | case 'wpi_item' : |
750 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
750 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
751 | 751 | break; |
752 | 752 | |
753 | 753 | case 'wpi_payment_form' : |
754 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
754 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
755 | 755 | break; |
756 | 756 | |
757 | 757 | case 'wpi_discount' : |
758 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
758 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
759 | 759 | break; |
760 | 760 | |
761 | 761 | case 'wpi_invoice' : |
762 | - $invoice = new WPInv_Invoice( $post_id ); |
|
763 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
762 | + $invoice = new WPInv_Invoice($post_id); |
|
763 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
764 | + $invoice->get_data_store()->delete_items($invoice); |
|
765 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
766 | 766 | break; |
767 | 767 | } |
768 | 768 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ) ; |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | ?> |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | |
47 | 47 | <div class="bsui" style="margin-top: 1.5rem"> |
48 | 48 | |
49 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
50 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
49 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
50 | + <?php if (!$invoice->is_draft()) : ?> |
|
51 | 51 | <div class="form-group"> |
52 | - <strong><?php _e( 'Viewed by Customer:', 'invoicing' );?></strong> |
|
53 | - <?php ( $invoice->get_is_viewed() ) ? _e( 'Yes', 'invoicing' ) : _e( 'No', 'invoicing' ); ?> |
|
52 | + <strong><?php _e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
53 | + <?php ($invoice->get_is_viewed()) ? _e('Yes', 'invoicing') : _e('No', 'invoicing'); ?> |
|
54 | 54 | </div> |
55 | 55 | <?php endif; ?> |
56 | 56 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | |
59 | 59 | // Date created. |
60 | 60 | $label = sprintf( |
61 | - __( '%s Date:', 'invoicing' ), |
|
62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
61 | + __('%s Date:', 'invoicing'), |
|
62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
63 | 63 | ); |
64 | 64 | |
65 | - $info = sprintf( |
|
66 | - __( 'The date this %s was created.', 'invoicing' ), |
|
67 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
65 | + $info = sprintf( |
|
66 | + __('The date this %s was created.', 'invoicing'), |
|
67 | + strtolower($invoice->get_invoice_quote_type()) |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | echo aui()->input( |
@@ -72,11 +72,11 @@ discard block |
||
72 | 72 | 'type' => 'datepicker', |
73 | 73 | 'id' => 'wpinv_date_created', |
74 | 74 | 'name' => 'date_created', |
75 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
75 | + 'label' => $label . getpaid_get_help_tip($info), |
|
76 | 76 | 'label_type' => 'vertical', |
77 | 77 | 'placeholder' => 'YYYY-MM-DD 00:00', |
78 | 78 | 'class' => 'form-control-sm', |
79 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
79 | + 'value' => $invoice->get_date_created('edit'), |
|
80 | 80 | 'extra_attributes' => array( |
81 | 81 | 'data-enable-time' => 'true', |
82 | 82 | 'data-time_24hr' => 'true', |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | ); |
88 | 88 | |
89 | 89 | // Date paid. |
90 | - $date_paid = $invoice->get_date_completed( 'edit' ); |
|
91 | - if ( ! empty( $date_paid ) && $invoice->is_paid() ) { |
|
90 | + $date_paid = $invoice->get_date_completed('edit'); |
|
91 | + if (!empty($date_paid) && $invoice->is_paid()) { |
|
92 | 92 | |
93 | 93 | echo aui()->input( |
94 | 94 | array( |
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_date_completed', |
97 | 97 | 'name' => 'wpinv_date_completed', |
98 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
98 | + 'label' => __('Date Completed:', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'class' => 'form-control-sm', |
101 | 101 | 'value' => $date_paid, |
@@ -109,56 +109,56 @@ discard block |
||
109 | 109 | } |
110 | 110 | |
111 | 111 | // Due date. |
112 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( $invoice->needs_payment() || $invoice->is_draft() ) ) { |
|
112 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && ($invoice->needs_payment() || $invoice->is_draft())) { |
|
113 | 113 | |
114 | 114 | echo aui()->input( |
115 | 115 | array( |
116 | 116 | 'type' => 'text', |
117 | 117 | 'id' => 'wpinv_due_date', |
118 | 118 | 'name' => 'wpinv_due_date', |
119 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
119 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
120 | 120 | 'label_type' => 'vertical', |
121 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
121 | + 'placeholder' => __('No due date', 'invoicing'), |
|
122 | 122 | 'class' => 'form-control-sm', |
123 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
123 | + 'value' => $invoice->get_due_date('edit'), |
|
124 | 124 | ) |
125 | 125 | ); |
126 | 126 | |
127 | 127 | } |
128 | 128 | |
129 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
130 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
129 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
130 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
131 | 131 | |
132 | 132 | // Status. |
133 | 133 | $label = sprintf( |
134 | - __( '%s Status:', 'invoicing' ), |
|
135 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
134 | + __('%s Status:', 'invoicing'), |
|
135 | + ucfirst($invoice->get_invoice_quote_type()) |
|
136 | 136 | ); |
137 | 137 | |
138 | - $status = $invoice->get_status( 'edit' ); |
|
138 | + $status = $invoice->get_status('edit'); |
|
139 | 139 | echo aui()->select( |
140 | 140 | array( |
141 | 141 | 'id' => 'wpinv_status', |
142 | 142 | 'name' => 'wpinv_status', |
143 | 143 | 'label' => $label, |
144 | 144 | 'label_type' => 'vertical', |
145 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
146 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
145 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
146 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
147 | 147 | 'select2' => true, |
148 | 148 | 'data-allow-clear' => 'false', |
149 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ) |
|
149 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice) |
|
150 | 150 | ) |
151 | 151 | ); |
152 | 152 | |
153 | 153 | // Invoice number. |
154 | 154 | $label = sprintf( |
155 | - __( '%s Number:', 'invoicing' ), |
|
156 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
155 | + __('%s Number:', 'invoicing'), |
|
156 | + ucfirst($invoice->get_invoice_quote_type()) |
|
157 | 157 | ); |
158 | 158 | |
159 | - $info = sprintf( |
|
160 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
161 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
159 | + $info = sprintf( |
|
160 | + __('Each %s number must be unique.', 'invoicing'), |
|
161 | + strtolower($invoice->get_invoice_quote_type()) |
|
162 | 162 | ); |
163 | 163 | |
164 | 164 | echo aui()->input( |
@@ -166,11 +166,11 @@ discard block |
||
166 | 166 | 'type' => 'text', |
167 | 167 | 'id' => 'wpinv_number', |
168 | 168 | 'name' => 'wpinv_number', |
169 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
169 | + 'label' => $label . getpaid_get_help_tip($info), |
|
170 | 170 | 'label_type' => 'vertical', |
171 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
171 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
172 | 172 | 'class' => 'form-control-sm', |
173 | - 'value' => $invoice->get_number( 'edit' ), |
|
173 | + 'value' => $invoice->get_number('edit'), |
|
174 | 174 | ) |
175 | 175 | ); |
176 | 176 | |
@@ -180,25 +180,25 @@ discard block |
||
180 | 180 | 'type' => 'text', |
181 | 181 | 'id' => 'wpinv_cc', |
182 | 182 | 'name' => 'wpinv_cc', |
183 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
183 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
184 | 184 | 'label_type' => 'vertical', |
185 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
185 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
186 | 186 | 'class' => 'form-control-sm', |
187 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
187 | + 'value' => $invoice->get_email_cc('edit'), |
|
188 | 188 | ) |
189 | 189 | ); |
190 | 190 | |
191 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
191 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
192 | 192 | |
193 | 193 | // Disable taxes. |
194 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
194 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
195 | 195 | |
196 | 196 | echo aui()->input( |
197 | 197 | array( |
198 | 198 | 'id' => 'wpinv_taxable', |
199 | 199 | 'name' => 'disable_taxes', |
200 | 200 | 'type' => 'checkbox', |
201 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
201 | + 'label' => __('Disable taxes', 'invoicing'), |
|
202 | 202 | 'value' => '1', |
203 | 203 | 'checked' => (bool) $invoice->get_disable_taxes(), |
204 | 204 | ) |
@@ -207,17 +207,17 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | // Apply a discount. |
210 | - if ( $invoice->get_discount_code( 'edit' ) ) { |
|
210 | + if ($invoice->get_discount_code('edit')) { |
|
211 | 211 | |
212 | 212 | echo aui()->input( |
213 | 213 | array( |
214 | 214 | 'type' => 'text', |
215 | 215 | 'id' => 'wpinv_discount_code', |
216 | 216 | 'name' => 'wpinv_discount_code', |
217 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
217 | + 'label' => __('Discount Code:', 'invoicing'), |
|
218 | 218 | 'label_type' => 'vertical', |
219 | 219 | 'class' => 'form-control-sm', |
220 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
220 | + 'value' => $invoice->get_discount_code('edit'), |
|
221 | 221 | 'extra_attributes' => array( |
222 | 222 | 'onclick' => 'this.select();', |
223 | 223 | 'readonly' => 'true', |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | |
228 | 228 | } |
229 | 229 | |
230 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
230 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
231 | 231 | |
232 | 232 | ?> |
233 | 233 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -56,23 +56,23 @@ discard block |
||
56 | 56 | * |
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | */ |
59 | -function wpinv_sanitize_amount( $amount ) { |
|
59 | +function wpinv_sanitize_amount($amount) { |
|
60 | 60 | |
61 | - if ( is_numeric( $amount ) ) { |
|
62 | - return floatval( $amount ); |
|
61 | + if (is_numeric($amount)) { |
|
62 | + return floatval($amount); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Separate the decimals and thousands. |
66 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
66 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
67 | 67 | |
68 | 68 | // Remove thousands. |
69 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
69 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
70 | 70 | |
71 | 71 | // Convert back to string. |
72 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
72 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
73 | 73 | |
74 | 74 | // Cast the remaining to a float. |
75 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
75 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
76 | 76 | |
77 | 77 | } |
78 | 78 | |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * @param float $amount |
83 | 83 | * @param float|string|int|null $decimals |
84 | 84 | */ |
85 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
85 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
86 | 86 | |
87 | - if ( $decimals === null ) { |
|
87 | + if ($decimals === null) { |
|
88 | 88 | $decimals = wpinv_decimals(); |
89 | 89 | } |
90 | 90 | |
91 | - if ( $use_sprintf ) { |
|
92 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
91 | + if ($use_sprintf) { |
|
92 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
93 | 93 | } else { |
94 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
94 | + $amount = round((float) $amount, absint($decimals)); |
|
95 | 95 | } |
96 | 96 | |
97 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
97 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -106,32 +106,32 @@ discard block |
||
106 | 106 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
107 | 107 | * @return array |
108 | 108 | */ |
109 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
109 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
110 | 110 | |
111 | 111 | $invoice_statuses = array( |
112 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
113 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
114 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
115 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
116 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
117 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
118 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
119 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
112 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
113 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
114 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
115 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
116 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
117 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
118 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
119 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
120 | 120 | ); |
121 | 121 | |
122 | - if ( $draft ) { |
|
123 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
122 | + if ($draft) { |
|
123 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
124 | 124 | } |
125 | 125 | |
126 | - if ( $trashed ) { |
|
127 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
126 | + if ($trashed) { |
|
127 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
130 | + if ($invoice instanceof WPInv_Invoice) { |
|
131 | 131 | $invoice = $invoice->get_post_type(); |
132 | 132 | } |
133 | 133 | |
134 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
134 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | /** |
@@ -140,11 +140,11 @@ discard block |
||
140 | 140 | * @param string $status The raw status |
141 | 141 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
142 | 142 | */ |
143 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
144 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
145 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
143 | +function wpinv_status_nicename($status, $invoice = false) { |
|
144 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
145 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
146 | 146 | |
147 | - return sanitize_text_field( $status ); |
|
147 | + return sanitize_text_field($status); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | * |
153 | 153 | * @param string $current |
154 | 154 | */ |
155 | -function wpinv_get_currency( $current = '' ) { |
|
155 | +function wpinv_get_currency($current = '') { |
|
156 | 156 | |
157 | - if ( empty( $current ) ) { |
|
158 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
157 | + if (empty($current)) { |
|
158 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
159 | 159 | } |
160 | 160 | |
161 | - return trim( strtoupper( $current ) ); |
|
161 | + return trim(strtoupper($current)); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,25 +166,25 @@ discard block |
||
166 | 166 | * |
167 | 167 | * @param string|null $currency The currency code. Defaults to the default currency. |
168 | 168 | */ |
169 | -function wpinv_currency_symbol( $currency = null ) { |
|
169 | +function wpinv_currency_symbol($currency = null) { |
|
170 | 170 | |
171 | 171 | // Prepare the currency. |
172 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
172 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
173 | 173 | |
174 | 174 | // Fetch all symbols. |
175 | 175 | $symbols = wpinv_get_currency_symbols(); |
176 | 176 | |
177 | 177 | // Fetch this currencies symbol. |
178 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
178 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
179 | 179 | |
180 | 180 | // Filter the symbol. |
181 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
181 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | function wpinv_currency_position() { |
185 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
185 | + $position = wpinv_get_option('currency_position', 'left'); |
|
186 | 186 | |
187 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
187 | + return apply_filters('wpinv_currency_position', $position); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | /** |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @param $string|null $current |
194 | 194 | */ |
195 | -function wpinv_thousands_separator( $current = null ) { |
|
195 | +function wpinv_thousands_separator($current = null) { |
|
196 | 196 | |
197 | - if ( null == $current ) { |
|
198 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
197 | + if (null == $current) { |
|
198 | + $current = wpinv_get_option('thousands_separator', ','); |
|
199 | 199 | } |
200 | 200 | |
201 | - return trim( $current ); |
|
201 | + return trim($current); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -206,13 +206,13 @@ discard block |
||
206 | 206 | * |
207 | 207 | * @param $string|null $current |
208 | 208 | */ |
209 | -function wpinv_decimal_separator( $current = null ) { |
|
209 | +function wpinv_decimal_separator($current = null) { |
|
210 | 210 | |
211 | - if ( null == $current ) { |
|
212 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
211 | + if (null == $current) { |
|
212 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
213 | 213 | } |
214 | 214 | |
215 | - return trim( $current ); |
|
215 | + return trim($current); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,27 +220,27 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param $string|null $current |
222 | 222 | */ |
223 | -function wpinv_decimals( $current = null ) { |
|
223 | +function wpinv_decimals($current = null) { |
|
224 | 224 | |
225 | - if ( null == $current ) { |
|
226 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
225 | + if (null == $current) { |
|
226 | + $current = wpinv_get_option('decimals', 2); |
|
227 | 227 | } |
228 | 228 | |
229 | - return absint( $current ); |
|
229 | + return absint($current); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * Retrieves a list of all supported currencies. |
234 | 234 | */ |
235 | 235 | function wpinv_get_currencies() { |
236 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
236 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | /** |
240 | 240 | * Retrieves a list of all currency symbols. |
241 | 241 | */ |
242 | 242 | function wpinv_get_currency_symbols() { |
243 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
243 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | $currency_pos = wpinv_currency_position(); |
253 | 253 | $format = '%1$s%2$s'; |
254 | 254 | |
255 | - switch ( $currency_pos ) { |
|
255 | + switch ($currency_pos) { |
|
256 | 256 | case 'left': |
257 | 257 | $format = '%1$s%2$s'; |
258 | 258 | break; |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | break; |
268 | 268 | } |
269 | 269 | |
270 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
270 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,25 +277,25 @@ discard block |
||
277 | 277 | * @param string $currency Currency. |
278 | 278 | * @return string |
279 | 279 | */ |
280 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
280 | +function wpinv_price($amount = 0, $currency = '') { |
|
281 | 281 | |
282 | 282 | // Backwards compatibility. |
283 | - $amount = wpinv_sanitize_amount( $amount ); |
|
283 | + $amount = wpinv_sanitize_amount($amount); |
|
284 | 284 | |
285 | 285 | // Prepare variables. |
286 | - $currency = wpinv_get_currency( $currency ); |
|
286 | + $currency = wpinv_get_currency($currency); |
|
287 | 287 | $amount = (float) $amount; |
288 | 288 | $unformatted_amount = $amount; |
289 | 289 | $negative = $amount < 0; |
290 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
291 | - $amount = wpinv_format_amount( $amount ); |
|
290 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
291 | + $amount = wpinv_format_amount($amount); |
|
292 | 292 | |
293 | 293 | // Format the amount. |
294 | 294 | $format = getpaid_get_price_format(); |
295 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
295 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
296 | 296 | |
297 | 297 | // Filter the formatting. |
298 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
298 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -306,25 +306,25 @@ discard block |
||
306 | 306 | * @param bool $calculate Whether or not to apply separators. |
307 | 307 | * @return string |
308 | 308 | */ |
309 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
309 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
310 | 310 | $thousands_sep = wpinv_thousands_separator(); |
311 | 311 | $decimal_sep = wpinv_decimal_separator(); |
312 | - $decimals = wpinv_decimals( $decimals ); |
|
313 | - $amount = wpinv_sanitize_amount( $amount ); |
|
312 | + $decimals = wpinv_decimals($decimals); |
|
313 | + $amount = wpinv_sanitize_amount($amount); |
|
314 | 314 | |
315 | - if ( $calculate ) { |
|
315 | + if ($calculate) { |
|
316 | 316 | return $amount; |
317 | 317 | } |
318 | 318 | |
319 | 319 | // Fomart the amount. |
320 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
320 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
321 | 321 | } |
322 | 322 | |
323 | -function wpinv_sanitize_key( $key ) { |
|
323 | +function wpinv_sanitize_key($key) { |
|
324 | 324 | $raw_key = $key; |
325 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
325 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
326 | 326 | |
327 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
327 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | * |
333 | 333 | * @param $str the file whose extension should be retrieved. |
334 | 334 | */ |
335 | -function wpinv_get_file_extension( $str ) { |
|
336 | - $filetype = wp_check_filetype( $str ); |
|
335 | +function wpinv_get_file_extension($str) { |
|
336 | + $filetype = wp_check_filetype($str); |
|
337 | 337 | return $filetype['ext']; |
338 | 338 | } |
339 | 339 | |
@@ -342,16 +342,16 @@ discard block |
||
342 | 342 | * |
343 | 343 | * @param string $string |
344 | 344 | */ |
345 | -function wpinv_string_is_image_url( $string ) { |
|
346 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
347 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
345 | +function wpinv_string_is_image_url($string) { |
|
346 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
347 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | 351 | * Returns the current URL. |
352 | 352 | */ |
353 | 353 | function wpinv_get_current_page_url() { |
354 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
354 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
@@ -361,46 +361,46 @@ discard block |
||
361 | 361 | * @param string $name Constant name. |
362 | 362 | * @param mixed $value Value. |
363 | 363 | */ |
364 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
365 | - if ( ! defined( $name ) ) { |
|
366 | - define( $name, $value ); |
|
364 | +function getpaid_maybe_define_constant($name, $value) { |
|
365 | + if (!defined($name)) { |
|
366 | + define($name, $value); |
|
367 | 367 | } |
368 | 368 | } |
369 | 369 | |
370 | 370 | function wpinv_get_php_arg_separator_output() { |
371 | - return ini_get( 'arg_separator.output' ); |
|
371 | + return ini_get('arg_separator.output'); |
|
372 | 372 | } |
373 | 373 | |
374 | -function wpinv_rgb_from_hex( $color ) { |
|
375 | - $color = str_replace( '#', '', $color ); |
|
374 | +function wpinv_rgb_from_hex($color) { |
|
375 | + $color = str_replace('#', '', $color); |
|
376 | 376 | |
377 | 377 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
378 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
379 | - if ( empty( $color ) ) { |
|
378 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
379 | + if (empty($color)) { |
|
380 | 380 | return NULL; |
381 | 381 | } |
382 | 382 | |
383 | - $color = str_split( $color ); |
|
383 | + $color = str_split($color); |
|
384 | 384 | |
385 | 385 | $rgb = array(); |
386 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
387 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
388 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
386 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
387 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
388 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
389 | 389 | |
390 | 390 | return $rgb; |
391 | 391 | } |
392 | 392 | |
393 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
394 | - $base = wpinv_rgb_from_hex( $color ); |
|
393 | +function wpinv_hex_darker($color, $factor = 30) { |
|
394 | + $base = wpinv_rgb_from_hex($color); |
|
395 | 395 | $color = '#'; |
396 | 396 | |
397 | - foreach ( $base as $k => $v ) { |
|
397 | + foreach ($base as $k => $v) { |
|
398 | 398 | $amount = $v / 100; |
399 | - $amount = round( $amount * $factor ); |
|
399 | + $amount = round($amount * $factor); |
|
400 | 400 | $new_decimal = $v - $amount; |
401 | 401 | |
402 | - $new_hex_component = dechex( $new_decimal ); |
|
403 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
402 | + $new_hex_component = dechex($new_decimal); |
|
403 | + if (strlen($new_hex_component) < 2) { |
|
404 | 404 | $new_hex_component = "0" . $new_hex_component; |
405 | 405 | } |
406 | 406 | $color .= $new_hex_component; |
@@ -409,18 +409,18 @@ discard block |
||
409 | 409 | return $color; |
410 | 410 | } |
411 | 411 | |
412 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
413 | - $base = wpinv_rgb_from_hex( $color ); |
|
412 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
413 | + $base = wpinv_rgb_from_hex($color); |
|
414 | 414 | $color = '#'; |
415 | 415 | |
416 | - foreach ( $base as $k => $v ) { |
|
416 | + foreach ($base as $k => $v) { |
|
417 | 417 | $amount = 255 - $v; |
418 | 418 | $amount = $amount / 100; |
419 | - $amount = round( $amount * $factor ); |
|
419 | + $amount = round($amount * $factor); |
|
420 | 420 | $new_decimal = $v + $amount; |
421 | 421 | |
422 | - $new_hex_component = dechex( $new_decimal ); |
|
423 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
422 | + $new_hex_component = dechex($new_decimal); |
|
423 | + if (strlen($new_hex_component) < 2) { |
|
424 | 424 | $new_hex_component = "0" . $new_hex_component; |
425 | 425 | } |
426 | 426 | $color .= $new_hex_component; |
@@ -429,22 +429,22 @@ discard block |
||
429 | 429 | return $color; |
430 | 430 | } |
431 | 431 | |
432 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
433 | - $hex = str_replace( '#', '', $color ); |
|
432 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
433 | + $hex = str_replace('#', '', $color); |
|
434 | 434 | |
435 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
436 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
437 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
435 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
436 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
437 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
438 | 438 | |
439 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
439 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
440 | 440 | |
441 | 441 | return $brightness > 155 ? $dark : $light; |
442 | 442 | } |
443 | 443 | |
444 | -function wpinv_format_hex( $hex ) { |
|
445 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
444 | +function wpinv_format_hex($hex) { |
|
445 | + $hex = trim(str_replace('#', '', $hex)); |
|
446 | 446 | |
447 | - if ( strlen( $hex ) == 3 ) { |
|
447 | + if (strlen($hex) == 3) { |
|
448 | 448 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
449 | 449 | } |
450 | 450 | |
@@ -464,12 +464,12 @@ discard block |
||
464 | 464 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
465 | 465 | * @return string |
466 | 466 | */ |
467 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
468 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
469 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
467 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
468 | + if (function_exists('mb_strimwidth')) { |
|
469 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
470 | 470 | } |
471 | 471 | |
472 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
472 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -481,28 +481,28 @@ discard block |
||
481 | 481 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
482 | 482 | * @return int Returns the number of characters in string. |
483 | 483 | */ |
484 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
485 | - if ( function_exists( 'mb_strlen' ) ) { |
|
486 | - return mb_strlen( $str, $encoding ); |
|
484 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
485 | + if (function_exists('mb_strlen')) { |
|
486 | + return mb_strlen($str, $encoding); |
|
487 | 487 | } |
488 | 488 | |
489 | - return strlen( $str ); |
|
489 | + return strlen($str); |
|
490 | 490 | } |
491 | 491 | |
492 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
493 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
494 | - return mb_strtolower( $str, $encoding ); |
|
492 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
493 | + if (function_exists('mb_strtolower')) { |
|
494 | + return mb_strtolower($str, $encoding); |
|
495 | 495 | } |
496 | 496 | |
497 | - return strtolower( $str ); |
|
497 | + return strtolower($str); |
|
498 | 498 | } |
499 | 499 | |
500 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
501 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
502 | - return mb_strtoupper( $str, $encoding ); |
|
500 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
501 | + if (function_exists('mb_strtoupper')) { |
|
502 | + return mb_strtoupper($str, $encoding); |
|
503 | 503 | } |
504 | 504 | |
505 | - return strtoupper( $str ); |
|
505 | + return strtoupper($str); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -516,12 +516,12 @@ discard block |
||
516 | 516 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
517 | 517 | * @return int Returns the position of the first occurrence of search in the string. |
518 | 518 | */ |
519 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
520 | - if ( function_exists( 'mb_strpos' ) ) { |
|
521 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
519 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
520 | + if (function_exists('mb_strpos')) { |
|
521 | + return mb_strpos($str, $find, $offset, $encoding); |
|
522 | 522 | } |
523 | 523 | |
524 | - return strpos( $str, $find, $offset ); |
|
524 | + return strpos($str, $find, $offset); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -535,12 +535,12 @@ discard block |
||
535 | 535 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
536 | 536 | * @return int Returns the position of the last occurrence of search. |
537 | 537 | */ |
538 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
539 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
540 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
538 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
539 | + if (function_exists('mb_strrpos')) { |
|
540 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
541 | 541 | } |
542 | 542 | |
543 | - return strrpos( $str, $find, $offset ); |
|
543 | + return strrpos($str, $find, $offset); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -555,16 +555,16 @@ discard block |
||
555 | 555 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
556 | 556 | * @return string |
557 | 557 | */ |
558 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
559 | - if ( function_exists( 'mb_substr' ) ) { |
|
560 | - if ( $length === null ) { |
|
561 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
558 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
559 | + if (function_exists('mb_substr')) { |
|
560 | + if ($length === null) { |
|
561 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
562 | 562 | } else { |
563 | - return mb_substr( $str, $start, $length, $encoding ); |
|
563 | + return mb_substr($str, $start, $length, $encoding); |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - return substr( $str, $start, $length ); |
|
567 | + return substr($str, $start, $length); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -576,48 +576,48 @@ discard block |
||
576 | 576 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
577 | 577 | * @return string The width of string. |
578 | 578 | */ |
579 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
580 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
581 | - return mb_strwidth( $str, $encoding ); |
|
579 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
580 | + if (function_exists('mb_strwidth')) { |
|
581 | + return mb_strwidth($str, $encoding); |
|
582 | 582 | } |
583 | 583 | |
584 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
584 | + return wpinv_utf8_strlen($str, $encoding); |
|
585 | 585 | } |
586 | 586 | |
587 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
588 | - if ( function_exists( 'mb_strlen' ) ) { |
|
589 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
587 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
588 | + if (function_exists('mb_strlen')) { |
|
589 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
590 | 590 | $str_end = ""; |
591 | 591 | |
592 | - if ( $lower_str_end ) { |
|
593 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
592 | + if ($lower_str_end) { |
|
593 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
594 | 594 | } else { |
595 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
595 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | return $first_letter . $str_end; |
599 | 599 | } |
600 | 600 | |
601 | - return ucfirst( $str ); |
|
601 | + return ucfirst($str); |
|
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
605 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
606 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
604 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
605 | + if (function_exists('mb_convert_case')) { |
|
606 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
607 | 607 | } |
608 | 608 | |
609 | - return ucwords( $str ); |
|
609 | + return ucwords($str); |
|
610 | 610 | } |
611 | 611 | |
612 | -function wpinv_period_in_days( $period, $unit ) { |
|
613 | - $period = absint( $period ); |
|
612 | +function wpinv_period_in_days($period, $unit) { |
|
613 | + $period = absint($period); |
|
614 | 614 | |
615 | - if ( $period > 0 ) { |
|
616 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
615 | + if ($period > 0) { |
|
616 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
617 | 617 | $period = $period * 7; |
618 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
618 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
619 | 619 | $period = $period * 30; |
620 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
620 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
621 | 621 | $period = $period * 365; |
622 | 622 | } |
623 | 623 | } |
@@ -625,14 +625,14 @@ discard block |
||
625 | 625 | return $period; |
626 | 626 | } |
627 | 627 | |
628 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
629 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
630 | - return cal_days_in_month( $calendar, $month, $year ); |
|
628 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
629 | + if (function_exists('cal_days_in_month')) { |
|
630 | + return cal_days_in_month($calendar, $month, $year); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | // Fallback in case the calendar extension is not loaded in PHP |
634 | 634 | // Only supports Gregorian calendar |
635 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
635 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -643,12 +643,12 @@ discard block |
||
643 | 643 | * |
644 | 644 | * @return string |
645 | 645 | */ |
646 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
646 | +function wpi_help_tip($tip, $allow_html = false) { |
|
647 | 647 | |
648 | - if ( $allow_html ) { |
|
649 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
648 | + if ($allow_html) { |
|
649 | + $tip = wpi_sanitize_tooltip($tip); |
|
650 | 650 | } else { |
651 | - $tip = esc_attr( $tip ); |
|
651 | + $tip = esc_attr($tip); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -662,8 +662,8 @@ discard block |
||
662 | 662 | * @param string $var |
663 | 663 | * @return string |
664 | 664 | */ |
665 | -function wpi_sanitize_tooltip( $var ) { |
|
666 | - return wp_kses( html_entity_decode( $var ), array( |
|
665 | +function wpi_sanitize_tooltip($var) { |
|
666 | + return wp_kses(html_entity_decode($var), array( |
|
667 | 667 | 'br' => array(), |
668 | 668 | 'em' => array(), |
669 | 669 | 'strong' => array(), |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | 'li' => array(), |
675 | 675 | 'ol' => array(), |
676 | 676 | 'p' => array(), |
677 | - ) ); |
|
677 | + )); |
|
678 | 678 | } |
679 | 679 | |
680 | 680 | /** |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function wpinv_get_screen_ids() { |
686 | 686 | |
687 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
687 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
688 | 688 | |
689 | 689 | $screen_ids = array( |
690 | 690 | 'toplevel_page_' . $screen_id, |
@@ -702,7 +702,7 @@ discard block |
||
702 | 702 | 'invoicing_page_wpi-addons', |
703 | 703 | ); |
704 | 704 | |
705 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
705 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -713,14 +713,14 @@ discard block |
||
713 | 713 | * @param array|string $list List of values. |
714 | 714 | * @return array Sanitized array of values. |
715 | 715 | */ |
716 | -function wpinv_parse_list( $list ) { |
|
716 | +function wpinv_parse_list($list) { |
|
717 | 717 | |
718 | - if ( empty( $list ) ) { |
|
718 | + if (empty($list)) { |
|
719 | 719 | $list = array(); |
720 | 720 | } |
721 | 721 | |
722 | - if ( ! is_array( $list ) ) { |
|
723 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
722 | + if (!is_array($list)) { |
|
723 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
724 | 724 | } |
725 | 725 | |
726 | 726 | return $list; |
@@ -734,16 +734,16 @@ discard block |
||
734 | 734 | * @param string $key Type of data to fetch. |
735 | 735 | * @return mixed Fetched data. |
736 | 736 | */ |
737 | -function wpinv_get_data( $key ) { |
|
737 | +function wpinv_get_data($key) { |
|
738 | 738 | |
739 | 739 | // Try fetching it from the cache. |
740 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
741 | - if( $data ) { |
|
740 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
741 | + if ($data) { |
|
742 | 742 | return $data; |
743 | 743 | } |
744 | 744 | |
745 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
746 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
745 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
746 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
747 | 747 | |
748 | 748 | return $data; |
749 | 749 | } |
@@ -757,10 +757,10 @@ discard block |
||
757 | 757 | * @param bool $first_empty Whether or not the first item in the list should be empty |
758 | 758 | * @return mixed Fetched data. |
759 | 759 | */ |
760 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
760 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
761 | 761 | |
762 | - if ( ! empty( $options ) && $first_empty ) { |
|
763 | - return array_merge( array( '' => '' ), $options ); |
|
762 | + if (!empty($options) && $first_empty) { |
|
763 | + return array_merge(array('' => ''), $options); |
|
764 | 764 | } |
765 | 765 | return $options; |
766 | 766 | |
@@ -772,21 +772,21 @@ discard block |
||
772 | 772 | * @param mixed $var Data to sanitize. |
773 | 773 | * @return string|array |
774 | 774 | */ |
775 | -function wpinv_clean( $var ) { |
|
775 | +function wpinv_clean($var) { |
|
776 | 776 | |
777 | - if ( is_array( $var ) ) { |
|
778 | - return array_map( 'wpinv_clean', $var ); |
|
777 | + if (is_array($var)) { |
|
778 | + return array_map('wpinv_clean', $var); |
|
779 | 779 | } |
780 | 780 | |
781 | - if ( is_object( $var ) ) { |
|
782 | - $object_vars = get_object_vars( $var ); |
|
783 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
784 | - $var->$property_name = wpinv_clean( $property_value ); |
|
781 | + if (is_object($var)) { |
|
782 | + $object_vars = get_object_vars($var); |
|
783 | + foreach ($object_vars as $property_name => $property_value) { |
|
784 | + $var->$property_name = wpinv_clean($property_value); |
|
785 | 785 | } |
786 | 786 | return $var; |
787 | 787 | } |
788 | 788 | |
789 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
789 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -795,43 +795,43 @@ discard block |
||
795 | 795 | * @param string $str Data to convert. |
796 | 796 | * @return string|array |
797 | 797 | */ |
798 | -function getpaid_convert_price_string_to_options( $str ) { |
|
798 | +function getpaid_convert_price_string_to_options($str) { |
|
799 | 799 | |
800 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
801 | - $options = array(); |
|
800 | + $raw_options = array_map('trim', explode(',', $str)); |
|
801 | + $options = array(); |
|
802 | 802 | |
803 | - foreach ( $raw_options as $option ) { |
|
803 | + foreach ($raw_options as $option) { |
|
804 | 804 | |
805 | - if ( '' == $option ) { |
|
805 | + if ('' == $option) { |
|
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
809 | + $option = array_map('trim', explode('|', $option)); |
|
810 | 810 | |
811 | 811 | $price = null; |
812 | 812 | $label = null; |
813 | 813 | |
814 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
815 | - $label = $option[0]; |
|
814 | + if (isset($option[0]) && '' != $option[0]) { |
|
815 | + $label = $option[0]; |
|
816 | 816 | } |
817 | 817 | |
818 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
818 | + if (isset($option[1]) && '' != $option[1]) { |
|
819 | 819 | $price = $option[1]; |
820 | 820 | } |
821 | 821 | |
822 | - if ( ! isset( $price ) ) { |
|
822 | + if (!isset($price)) { |
|
823 | 823 | $price = $label; |
824 | 824 | } |
825 | 825 | |
826 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
826 | + if (!isset($price) || !is_numeric($price)) { |
|
827 | 827 | continue; |
828 | 828 | } |
829 | 829 | |
830 | - if ( ! isset( $label ) ) { |
|
830 | + if (!isset($label)) { |
|
831 | 831 | $label = $price; |
832 | 832 | } |
833 | 833 | |
834 | - $options[ $price ] = $label; |
|
834 | + $options[$price] = $label; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | return $options; |
@@ -840,27 +840,27 @@ discard block |
||
840 | 840 | /** |
841 | 841 | * Returns the help tip. |
842 | 842 | */ |
843 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
844 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
845 | - $tip = esc_attr__( $tip ); |
|
843 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
844 | + $additional_classes = sanitize_html_class($additional_classes); |
|
845 | + $tip = esc_attr__($tip); |
|
846 | 846 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
847 | 847 | } |
848 | 848 | |
849 | 849 | /** |
850 | 850 | * Formats a date |
851 | 851 | */ |
852 | -function getpaid_format_date( $date, $with_time = false ) { |
|
852 | +function getpaid_format_date($date, $with_time = false) { |
|
853 | 853 | |
854 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
854 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
855 | 855 | return ''; |
856 | 856 | } |
857 | 857 | |
858 | 858 | $format = getpaid_date_format(); |
859 | 859 | |
860 | - if ( $with_time ) { |
|
860 | + if ($with_time) { |
|
861 | 861 | $format .= ' ' . getpaid_time_format(); |
862 | 862 | } |
863 | - return date_i18n( $format, strtotime( $date ) ); |
|
863 | + return date_i18n($format, strtotime($date)); |
|
864 | 864 | |
865 | 865 | } |
866 | 866 | |
@@ -869,9 +869,9 @@ discard block |
||
869 | 869 | * |
870 | 870 | * @return string |
871 | 871 | */ |
872 | -function getpaid_format_date_value( $date, $default = "—", $with_time = false ) { |
|
873 | - $date = getpaid_format_date( $date, $with_time ); |
|
874 | - return empty( $date ) ? $default : $date; |
|
872 | +function getpaid_format_date_value($date, $default = "—", $with_time = false) { |
|
873 | + $date = getpaid_format_date($date, $with_time); |
|
874 | + return empty($date) ? $default : $date; |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | /** |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | * @return string |
881 | 881 | */ |
882 | 882 | function getpaid_date_format() { |
883 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
883 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
884 | 884 | } |
885 | 885 | |
886 | 886 | /** |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | * @return string |
890 | 890 | */ |
891 | 891 | function getpaid_time_format() { |
892 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
892 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
@@ -899,16 +899,16 @@ discard block |
||
899 | 899 | * @param integer $limit Limit size in characters. |
900 | 900 | * @return string |
901 | 901 | */ |
902 | -function getpaid_limit_length( $string, $limit ) { |
|
902 | +function getpaid_limit_length($string, $limit) { |
|
903 | 903 | $str_limit = $limit - 3; |
904 | 904 | |
905 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
906 | - if ( mb_strlen( $string ) > $limit ) { |
|
907 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
905 | + if (function_exists('mb_strimwidth')) { |
|
906 | + if (mb_strlen($string) > $limit) { |
|
907 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
908 | 908 | } |
909 | 909 | } else { |
910 | - if ( strlen( $string ) > $limit ) { |
|
911 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
910 | + if (strlen($string) > $limit) { |
|
911 | + $string = substr($string, 0, $str_limit) . '...'; |
|
912 | 912 | } |
913 | 913 | } |
914 | 914 | return $string; |
@@ -922,7 +922,7 @@ discard block |
||
922 | 922 | * @since 1.0.19 |
923 | 923 | */ |
924 | 924 | function getpaid_api() { |
925 | - return getpaid()->get( 'api' ); |
|
925 | + return getpaid()->get('api'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | /** |
@@ -932,7 +932,7 @@ discard block |
||
932 | 932 | * @since 1.0.19 |
933 | 933 | */ |
934 | 934 | function getpaid_post_types() { |
935 | - return getpaid()->get( 'post_types' ); |
|
935 | + return getpaid()->get('post_types'); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | /** |
@@ -942,7 +942,7 @@ discard block |
||
942 | 942 | * @since 1.0.19 |
943 | 943 | */ |
944 | 944 | function getpaid_session() { |
945 | - return getpaid()->get( 'session' ); |
|
945 | + return getpaid()->get('session'); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | /** |
@@ -952,7 +952,7 @@ discard block |
||
952 | 952 | * @since 1.0.19 |
953 | 953 | */ |
954 | 954 | function getpaid_notes() { |
955 | - return getpaid()->get( 'notes' ); |
|
955 | + return getpaid()->get('notes'); |
|
956 | 956 | } |
957 | 957 | |
958 | 958 | /** |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * @return GetPaid_Admin |
962 | 962 | */ |
963 | 963 | function getpaid_admin() { |
964 | - return getpaid()->get( 'admin' ); |
|
964 | + return getpaid()->get('admin'); |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | /** |
@@ -971,8 +971,8 @@ discard block |
||
971 | 971 | * @param string $base the base url |
972 | 972 | * @return string |
973 | 973 | */ |
974 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
975 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
974 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
975 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
976 | 976 | } |
977 | 977 | |
978 | 978 | /** |
@@ -980,11 +980,11 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @return string |
982 | 982 | */ |
983 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
983 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
984 | 984 | |
985 | - $post_type = get_post_type_object( $post_type ); |
|
985 | + $post_type = get_post_type_object($post_type); |
|
986 | 986 | |
987 | - if ( ! is_object( $post_type ) ) { |
|
987 | + if (!is_object($post_type)) { |
|
988 | 988 | return null; |
989 | 989 | } |
990 | 990 | |
@@ -997,18 +997,18 @@ discard block |
||
997 | 997 | * |
998 | 998 | * @return mixed|null |
999 | 999 | */ |
1000 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1000 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1001 | 1001 | |
1002 | - if ( ! is_array( $array ) ) { |
|
1002 | + if (!is_array($array)) { |
|
1003 | 1003 | return null; |
1004 | 1004 | } |
1005 | 1005 | |
1006 | - if ( ! empty( $secondary_key ) ) { |
|
1007 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1008 | - return getpaid_get_array_field( $array, $key ); |
|
1006 | + if (!empty($secondary_key)) { |
|
1007 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1008 | + return getpaid_get_array_field($array, $key); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1011 | + return isset($array[$key]) ? $array[$key] : null; |
|
1012 | 1012 | |
1013 | 1013 | } |
1014 | 1014 | |
@@ -1017,12 +1017,12 @@ discard block |
||
1017 | 1017 | * |
1018 | 1018 | * @return array |
1019 | 1019 | */ |
1020 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1020 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1021 | 1021 | |
1022 | - foreach ( $defaults as $key => $value ) { |
|
1022 | + foreach ($defaults as $key => $value) { |
|
1023 | 1023 | |
1024 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1025 | - $args[ $key ] = $value; |
|
1024 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1025 | + $args[$key] = $value; |
|
1026 | 1026 | } |
1027 | 1027 | |
1028 | 1028 | } |