@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Post types Admin Class |
@@ -21,74 +21,74 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) ); |
|
34 | - add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | + add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions')); |
|
34 | + add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3); |
|
35 | 35 | |
36 | 36 | // Items table columns. |
37 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
38 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
39 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
40 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
41 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
42 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
37 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
38 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
39 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
40 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
41 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
42 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
43 | 43 | |
44 | 44 | // Payment forms columns. |
45 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
46 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
47 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
46 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
47 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
48 | 48 | |
49 | 49 | // Discount table columns. |
50 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
51 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
51 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
52 | 52 | |
53 | 53 | // Deleting posts. |
54 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
55 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
55 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
56 | 56 | |
57 | - add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 ); |
|
57 | + add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Post updated messages. |
62 | 62 | */ |
63 | - public static function post_updated_messages( $messages ) { |
|
63 | + public static function post_updated_messages($messages) { |
|
64 | 64 | global $post; |
65 | 65 | |
66 | 66 | $messages['wpi_discount'] = array( |
67 | 67 | 0 => '', |
68 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
69 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
70 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
71 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
72 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
73 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
74 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
75 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
76 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
77 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
68 | + 1 => __('Discount updated.', 'invoicing'), |
|
69 | + 2 => __('Custom field updated.', 'invoicing'), |
|
70 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
71 | + 4 => __('Discount updated.', 'invoicing'), |
|
72 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
73 | + 6 => __('Discount updated.', 'invoicing'), |
|
74 | + 7 => __('Discount saved.', 'invoicing'), |
|
75 | + 8 => __('Discount submitted.', 'invoicing'), |
|
76 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
77 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
78 | 78 | ); |
79 | 79 | |
80 | 80 | $messages['wpi_payment_form'] = array( |
81 | 81 | 0 => '', |
82 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
83 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
84 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
85 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
86 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
87 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
88 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
89 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
90 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
91 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
82 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
83 | + 2 => __('Custom field updated.', 'invoicing'), |
|
84 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
85 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
86 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
87 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
88 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
89 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
90 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
91 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
92 | 92 | ); |
93 | 93 | |
94 | 94 | return $messages; |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * Post row actions. |
100 | 100 | */ |
101 | - public static function post_row_actions( $actions, $post ) { |
|
101 | + public static function post_row_actions($actions, $post) { |
|
102 | 102 | |
103 | - $post = get_post( $post ); |
|
103 | + $post = get_post($post); |
|
104 | 104 | |
105 | 105 | // We do not want to edit the default payment form. |
106 | - if ( 'wpi_payment_form' == $post->post_type ) { |
|
106 | + if ('wpi_payment_form' == $post->post_type) { |
|
107 | 107 | |
108 | - if ( wpinv_get_default_payment_form() === $post->ID ) { |
|
109 | - unset( $actions['trash'] ); |
|
110 | - unset( $actions['inline hide-if-no-js'] ); |
|
108 | + if (wpinv_get_default_payment_form() === $post->ID) { |
|
109 | + unset($actions['trash']); |
|
110 | + unset($actions['inline hide-if-no-js']); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | $actions['duplicate'] = sprintf( |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | 'getpaid-nonce' |
125 | 125 | ) |
126 | 126 | ), |
127 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
127 | + esc_html(__('Duplicate', 'invoicing')) |
|
128 | 128 | ); |
129 | 129 | |
130 | 130 | $actions['reset'] = sprintf( |
@@ -141,17 +141,17 @@ discard block |
||
141 | 141 | 'getpaid-nonce' |
142 | 142 | ) |
143 | 143 | ), |
144 | - esc_html( __( 'Reset Stats', 'invoicing' ) ) |
|
144 | + esc_html(__('Reset Stats', 'invoicing')) |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Link to item payment form. |
149 | - if ( 'wpi_item' == $post->post_type ) { |
|
150 | - if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) { |
|
149 | + if ('wpi_item' == $post->post_type) { |
|
150 | + if (getpaid_item_type_supports(get_post_meta($post->ID, '_wpinv_type', true), 'buy_now')) { |
|
151 | 151 | $actions['buy'] = sprintf( |
152 | 152 | '<a href="%1$s">%2$s</a>', |
153 | - esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ), |
|
154 | - esc_html( __( 'Buy', 'invoicing' ) ) |
|
153 | + esc_url(getpaid_embed_url(false, $post->ID . '|0')), |
|
154 | + esc_html(__('Buy', 'invoicing')) |
|
155 | 155 | ); |
156 | 156 | } |
157 | 157 | } |
@@ -167,28 +167,28 @@ discard block |
||
167 | 167 | * @param WP_Post $post |
168 | 168 | * @return array $actions actions without edit option |
169 | 169 | */ |
170 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
170 | + public static function filter_invoice_row_actions($actions, $post) { |
|
171 | 171 | |
172 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
172 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
173 | 173 | |
174 | 174 | $actions = array(); |
175 | - $invoice = new WPInv_Invoice( $post ); |
|
175 | + $invoice = new WPInv_Invoice($post); |
|
176 | 176 | |
177 | 177 | $actions['edit'] = sprintf( |
178 | 178 | '<a href="%1$s">%2$s</a>', |
179 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
180 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
179 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
180 | + esc_html(__('Edit', 'invoicing')) |
|
181 | 181 | ); |
182 | 182 | |
183 | - if ( ! $invoice->is_draft() ) { |
|
183 | + if (!$invoice->is_draft()) { |
|
184 | 184 | |
185 | 185 | $actions['view'] = sprintf( |
186 | 186 | '<a href="%1$s">%2$s</a>', |
187 | - esc_url( $invoice->get_view_url() ), |
|
187 | + esc_url($invoice->get_view_url()), |
|
188 | 188 | sprintf( |
189 | 189 | // translators: %s is the invoice type |
190 | - esc_html__( 'View %s', 'invoicing' ), |
|
191 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
190 | + esc_html__('View %s', 'invoicing'), |
|
191 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
192 | 192 | ) |
193 | 193 | ); |
194 | 194 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | 'getpaid-nonce' |
207 | 207 | ) |
208 | 208 | ), |
209 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
209 | + esc_html(__('Send to Customer', 'invoicing')) |
|
210 | 210 | ); |
211 | 211 | |
212 | 212 | } |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | 'getpaid-nonce' |
226 | 226 | ) |
227 | 227 | ), |
228 | - esc_html( __( 'Duplicate', 'invoicing' ) ) |
|
228 | + esc_html(__('Duplicate', 'invoicing')) |
|
229 | 229 | ); |
230 | 230 | |
231 | 231 | } |
@@ -236,59 +236,59 @@ discard block |
||
236 | 236 | /** |
237 | 237 | * Returns an array of invoice table columns. |
238 | 238 | */ |
239 | - public static function invoice_columns( $columns ) { |
|
239 | + public static function invoice_columns($columns) { |
|
240 | 240 | |
241 | 241 | $columns = array( |
242 | 242 | 'cb' => $columns['cb'], |
243 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
244 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
245 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
246 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
247 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
248 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
249 | - 'status' => __( 'Status', 'invoicing' ), |
|
243 | + 'number' => __('Invoice', 'invoicing'), |
|
244 | + 'customer' => __('Customer', 'invoicing'), |
|
245 | + 'invoice_date' => __('Created', 'invoicing'), |
|
246 | + 'payment_date' => __('Completed', 'invoicing'), |
|
247 | + 'amount' => __('Amount', 'invoicing'), |
|
248 | + 'recurring' => __('Recurring', 'invoicing'), |
|
249 | + 'status' => __('Status', 'invoicing'), |
|
250 | 250 | ); |
251 | 251 | |
252 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
252 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | /** |
256 | 256 | * Displays invoice table columns. |
257 | 257 | */ |
258 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
258 | + public static function display_invoice_columns($column_name, $post_id) { |
|
259 | 259 | |
260 | - $invoice = new WPInv_Invoice( $post_id ); |
|
260 | + $invoice = new WPInv_Invoice($post_id); |
|
261 | 261 | |
262 | - switch ( $column_name ) { |
|
262 | + switch ($column_name) { |
|
263 | 263 | |
264 | 264 | case 'invoice_date': |
265 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
266 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
267 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
265 | + $date_time = esc_attr($invoice->get_created_date()); |
|
266 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
267 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
268 | 268 | break; |
269 | 269 | |
270 | 270 | case 'payment_date': |
271 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
272 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
273 | - $date = esc_html( getpaid_format_date_value( $date_time, '—', true ) ); |
|
274 | - echo wp_kses_post( "<span title='$date_time'>$date</span>" ); |
|
271 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
272 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
273 | + $date = esc_html(getpaid_format_date_value($date_time, '—', true)); |
|
274 | + echo wp_kses_post("<span title='$date_time'>$date</span>"); |
|
275 | 275 | |
276 | - if ( $_gateway = $invoice->get_gateway() ) { |
|
277 | - $gateway_label = wpinv_get_gateway_admin_label( $_gateway ); |
|
276 | + if ($_gateway = $invoice->get_gateway()) { |
|
277 | + $gateway_label = wpinv_get_gateway_admin_label($_gateway); |
|
278 | 278 | |
279 | - if ( $transaction_url = $invoice->get_transaction_url() ) { |
|
280 | - $gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>'; |
|
279 | + if ($transaction_url = $invoice->get_transaction_url()) { |
|
280 | + $gateway_label = '<a href="' . esc_url($transaction_url) . '" target="_blank" title="' . esc_attr__('Open transaction link', 'invoicing') . '">' . $gateway_label . '</a>'; |
|
281 | 281 | } |
282 | 282 | |
283 | - $gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>'; |
|
283 | + $gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf(_x('Via %s', 'Paid via gateway', 'invoicing'), $gateway_label) . '</span></small>'; |
|
284 | 284 | } else { |
285 | 285 | $gateway = ''; |
286 | 286 | } |
287 | 287 | |
288 | - $gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice ); |
|
288 | + $gateway = apply_filters('getpaid_admin_invoices_list_table_gateway', $gateway, $invoice); |
|
289 | 289 | |
290 | - if ( $gateway ) { |
|
291 | - echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
290 | + if ($gateway) { |
|
291 | + echo wp_kses_post($gateway); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
|
292 | 292 | } |
293 | 293 | } else { |
294 | 294 | echo '—'; |
@@ -298,60 +298,60 @@ discard block |
||
298 | 298 | |
299 | 299 | case 'amount': |
300 | 300 | $amount = $invoice->get_total(); |
301 | - $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) ); |
|
301 | + $formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency())); |
|
302 | 302 | |
303 | - if ( $invoice->is_refunded() ) { |
|
304 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
305 | - echo wp_kses_post( "<del>$formated_amount</del> <ins>$refunded_amount</ins>" ); |
|
303 | + if ($invoice->is_refunded()) { |
|
304 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
305 | + echo wp_kses_post("<del>$formated_amount</del> <ins>$refunded_amount</ins>"); |
|
306 | 306 | } else { |
307 | 307 | |
308 | 308 | $discount = $invoice->get_total_discount(); |
309 | 309 | |
310 | - if ( ! empty( $discount ) ) { |
|
311 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
312 | - echo wp_kses_post( "<del>$new_amount</del> <ins>$formated_amount</ins>" ); |
|
310 | + if (!empty($discount)) { |
|
311 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
312 | + echo wp_kses_post("<del>$new_amount</del> <ins>$formated_amount</ins>"); |
|
313 | 313 | } else { |
314 | - echo wp_kses_post( $formated_amount ); |
|
314 | + echo wp_kses_post($formated_amount); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | |
318 | 318 | break; |
319 | 319 | |
320 | 320 | case 'status': |
321 | - $status = esc_html( $invoice->get_status() ); |
|
321 | + $status = esc_html($invoice->get_status()); |
|
322 | 322 | |
323 | 323 | // If it is paid, show the gateway title. |
324 | - if ( $invoice->is_paid() ) { |
|
325 | - $gateway = esc_html( $invoice->get_gateway_title() ); |
|
326 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) ); |
|
324 | + if ($invoice->is_paid()) { |
|
325 | + $gateway = esc_html($invoice->get_gateway_title()); |
|
326 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway)); |
|
327 | 327 | |
328 | - echo wp_kses_post( "<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" ); |
|
328 | + echo wp_kses_post("<span class='bsui wpi-help-tip getpaid-invoice-statuss $status' title='$gateway'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>"); |
|
329 | 329 | } else { |
330 | - echo wp_kses_post( "<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>" ); |
|
330 | + echo wp_kses_post("<span class='bsui getpaid-invoice-statuss $status'><span class='fs-base'>" . $invoice->get_status_label_html() . "</span></span>"); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | // If it is not paid, display the overdue and view status. |
334 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
334 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
335 | 335 | |
336 | 336 | // Invoice view status. |
337 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
338 | - echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
337 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
338 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
339 | 339 | } else { |
340 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>'; |
|
340 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | // Display the overview status. |
344 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
344 | + if (wpinv_get_option('overdue_active')) { |
|
345 | 345 | $due_date = $invoice->get_due_date(); |
346 | - $fomatted = getpaid_format_date( $due_date ); |
|
346 | + $fomatted = getpaid_format_date($due_date); |
|
347 | 347 | |
348 | - if ( ! empty( $fomatted ) ) { |
|
348 | + if (!empty($fomatted)) { |
|
349 | 349 | $date = wp_sprintf( |
350 | 350 | // translators: %s is the due date. |
351 | - __( 'Due %s', 'invoicing' ), |
|
351 | + __('Due %s', 'invoicing'), |
|
352 | 352 | $fomatted |
353 | 353 | ); |
354 | - echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" ); |
|
354 | + echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"); |
|
355 | 355 | } |
356 | 356 | } |
357 | 357 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | break; |
360 | 360 | |
361 | 361 | case 'recurring': |
362 | - if ( $invoice->is_recurring() ) { |
|
362 | + if ($invoice->is_recurring()) { |
|
363 | 363 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
364 | 364 | } else { |
365 | 365 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -367,26 +367,26 @@ discard block |
||
367 | 367 | break; |
368 | 368 | |
369 | 369 | case 'number': |
370 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
371 | - $invoice_number = esc_html( $invoice->get_number() ); |
|
372 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
370 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
371 | + $invoice_number = esc_html($invoice->get_number()); |
|
372 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
373 | 373 | |
374 | - echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" ); |
|
374 | + echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"); |
|
375 | 375 | |
376 | - do_action( 'getpaid_admin_table_invoice_number_column', $invoice ); |
|
376 | + do_action('getpaid_admin_table_invoice_number_column', $invoice); |
|
377 | 377 | break; |
378 | 378 | |
379 | 379 | case 'customer': |
380 | 380 | $customer_name = $invoice->get_user_full_name(); |
381 | 381 | |
382 | - if ( empty( $customer_name ) ) { |
|
382 | + if (empty($customer_name)) { |
|
383 | 383 | $customer_name = $invoice->get_email(); |
384 | 384 | } |
385 | 385 | |
386 | - if ( ! empty( $customer_name ) ) { |
|
387 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
388 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
389 | - echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" ); |
|
386 | + if (!empty($customer_name)) { |
|
387 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
388 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
389 | + echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"); |
|
390 | 390 | } else { |
391 | 391 | echo '<div>—</div>'; |
392 | 392 | } |
@@ -400,19 +400,19 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Displays invoice bulk actions. |
402 | 402 | */ |
403 | - public static function invoice_bulk_actions( $actions ) { |
|
404 | - $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' ); |
|
403 | + public static function invoice_bulk_actions($actions) { |
|
404 | + $actions['resend-invoice'] = __('Send to Customer', 'invoicing'); |
|
405 | 405 | return $actions; |
406 | 406 | } |
407 | 407 | |
408 | 408 | /** |
409 | 409 | * Processes invoice bulk actions. |
410 | 410 | */ |
411 | - public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) { |
|
411 | + public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) { |
|
412 | 412 | |
413 | - if ( 'resend-invoice' === $action ) { |
|
414 | - foreach ( $post_ids as $post_id ) { |
|
415 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true ); |
|
413 | + if ('resend-invoice' === $action) { |
|
414 | + foreach ($post_ids as $post_id) { |
|
415 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -423,49 +423,49 @@ discard block |
||
423 | 423 | /** |
424 | 424 | * Returns an array of payment forms table columns. |
425 | 425 | */ |
426 | - public static function payment_form_columns( $columns ) { |
|
426 | + public static function payment_form_columns($columns) { |
|
427 | 427 | |
428 | 428 | $columns = array( |
429 | 429 | 'cb' => $columns['cb'], |
430 | - 'title' => __( 'Name', 'invoicing' ), |
|
431 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
432 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
433 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
434 | - 'items' => __( 'Items', 'invoicing' ), |
|
435 | - 'date' => __( 'Date', 'invoicing' ), |
|
430 | + 'title' => __('Name', 'invoicing'), |
|
431 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
432 | + 'earnings' => __('Revenue', 'invoicing'), |
|
433 | + 'refunds' => __('Refunded', 'invoicing'), |
|
434 | + 'items' => __('Items', 'invoicing'), |
|
435 | + 'date' => __('Date', 'invoicing'), |
|
436 | 436 | ); |
437 | 437 | |
438 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
438 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
439 | 439 | |
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
443 | 443 | * Displays payment form table columns. |
444 | 444 | */ |
445 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
445 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
446 | 446 | |
447 | 447 | // Retrieve the payment form. |
448 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
448 | + $form = new GetPaid_Payment_Form($post_id); |
|
449 | 449 | |
450 | - switch ( $column_name ) { |
|
450 | + switch ($column_name) { |
|
451 | 451 | |
452 | 452 | case 'earnings': |
453 | - echo wp_kses_post( wpinv_price( $form->get_earned() ) ); |
|
453 | + echo wp_kses_post(wpinv_price($form->get_earned())); |
|
454 | 454 | break; |
455 | 455 | |
456 | 456 | case 'refunds': |
457 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
457 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
458 | 458 | break; |
459 | 459 | |
460 | 460 | case 'refunds': |
461 | - echo wp_kses_post( wpinv_price( $form->get_refunded() ) ); |
|
461 | + echo wp_kses_post(wpinv_price($form->get_refunded())); |
|
462 | 462 | break; |
463 | 463 | |
464 | 464 | case 'shortcode': |
465 | - if ( $form->is_default() ) { |
|
465 | + if ($form->is_default()) { |
|
466 | 466 | echo '—'; |
467 | 467 | } else { |
468 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
468 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
469 | 469 | } |
470 | 470 | |
471 | 471 | break; |
@@ -473,28 +473,28 @@ discard block |
||
473 | 473 | case 'items': |
474 | 474 | $items = $form->get_items(); |
475 | 475 | |
476 | - if ( $form->is_default() || empty( $items ) ) { |
|
476 | + if ($form->is_default() || empty($items)) { |
|
477 | 477 | echo '—'; |
478 | 478 | return; |
479 | 479 | } |
480 | 480 | |
481 | 481 | $_items = array(); |
482 | 482 | |
483 | - foreach ( $items as $item ) { |
|
483 | + foreach ($items as $item) { |
|
484 | 484 | $url = $item->get_edit_url(); |
485 | 485 | |
486 | - if ( empty( $url ) ) { |
|
487 | - $_items[] = esc_html( $item->get_name() ); |
|
486 | + if (empty($url)) { |
|
487 | + $_items[] = esc_html($item->get_name()); |
|
488 | 488 | } else { |
489 | 489 | $_items[] = sprintf( |
490 | 490 | '<a href="%s">%s</a>', |
491 | - esc_url( $url ), |
|
492 | - esc_html( $item->get_name() ) |
|
491 | + esc_url($url), |
|
492 | + esc_html($item->get_name()) |
|
493 | 493 | ); |
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | - echo wp_kses_post( implode( '<br>', $_items ) ); |
|
497 | + echo wp_kses_post(implode('<br>', $_items)); |
|
498 | 498 | |
499 | 499 | break; |
500 | 500 | |
@@ -505,10 +505,10 @@ discard block |
||
505 | 505 | /** |
506 | 506 | * Filters post states. |
507 | 507 | */ |
508 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
508 | + public static function filter_payment_form_state($post_states, $post) { |
|
509 | 509 | |
510 | - if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) { |
|
511 | - $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' ); |
|
510 | + if ('wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID) { |
|
511 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
512 | 512 | } |
513 | 513 | |
514 | 514 | return $post_states; |
@@ -518,35 +518,35 @@ discard block |
||
518 | 518 | /** |
519 | 519 | * Returns an array of coupon table columns. |
520 | 520 | */ |
521 | - public static function discount_columns( $columns ) { |
|
521 | + public static function discount_columns($columns) { |
|
522 | 522 | |
523 | 523 | $columns = array( |
524 | 524 | 'cb' => $columns['cb'], |
525 | - 'title' => __( 'Name', 'invoicing' ), |
|
526 | - 'code' => __( 'Code', 'invoicing' ), |
|
527 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
528 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
529 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
530 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
525 | + 'title' => __('Name', 'invoicing'), |
|
526 | + 'code' => __('Code', 'invoicing'), |
|
527 | + 'amount' => __('Amount', 'invoicing'), |
|
528 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
529 | + 'start_date' => __('Start Date', 'invoicing'), |
|
530 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
531 | 531 | ); |
532 | 532 | |
533 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
533 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
537 | 537 | * Filters post states. |
538 | 538 | */ |
539 | - public static function filter_discount_state( $post_states, $post ) { |
|
539 | + public static function filter_discount_state($post_states, $post) { |
|
540 | 540 | |
541 | - if ( 'wpi_discount' === $post->post_type ) { |
|
541 | + if ('wpi_discount' === $post->post_type) { |
|
542 | 542 | |
543 | - $discount = new WPInv_Discount( $post ); |
|
543 | + $discount = new WPInv_Discount($post); |
|
544 | 544 | |
545 | 545 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
546 | 546 | |
547 | - if ( 'publish' !== $status ) { |
|
547 | + if ('publish' !== $status) { |
|
548 | 548 | return array( |
549 | - 'discount_status' => wpinv_discount_status( $status ), |
|
549 | + 'discount_status' => wpinv_discount_status($status), |
|
550 | 550 | ); |
551 | 551 | } |
552 | 552 | |
@@ -561,30 +561,30 @@ discard block |
||
561 | 561 | /** |
562 | 562 | * Returns an array of items table columns. |
563 | 563 | */ |
564 | - public static function item_columns( $columns ) { |
|
564 | + public static function item_columns($columns) { |
|
565 | 565 | |
566 | 566 | $columns = array( |
567 | 567 | 'cb' => $columns['cb'], |
568 | - 'title' => __( 'Name', 'invoicing' ), |
|
569 | - 'price' => __( 'Price', 'invoicing' ), |
|
570 | - 'vat_rule' => __( 'Tax Rule', 'invoicing' ), |
|
571 | - 'vat_class' => __( 'Tax Class', 'invoicing' ), |
|
572 | - 'type' => __( 'Type', 'invoicing' ), |
|
573 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
568 | + 'title' => __('Name', 'invoicing'), |
|
569 | + 'price' => __('Price', 'invoicing'), |
|
570 | + 'vat_rule' => __('Tax Rule', 'invoicing'), |
|
571 | + 'vat_class' => __('Tax Class', 'invoicing'), |
|
572 | + 'type' => __('Type', 'invoicing'), |
|
573 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
574 | 574 | ); |
575 | 575 | |
576 | - if ( ! wpinv_use_taxes() ) { |
|
577 | - unset( $columns['vat_rule'] ); |
|
578 | - unset( $columns['vat_class'] ); |
|
576 | + if (!wpinv_use_taxes()) { |
|
577 | + unset($columns['vat_rule']); |
|
578 | + unset($columns['vat_class']); |
|
579 | 579 | } |
580 | 580 | |
581 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
581 | + return apply_filters('wpi_item_table_columns', $columns); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
585 | 585 | * Returns an array of sortable items table columns. |
586 | 586 | */ |
587 | - public static function sortable_item_columns( $columns ) { |
|
587 | + public static function sortable_item_columns($columns) { |
|
588 | 588 | |
589 | 589 | return array_merge( |
590 | 590 | $columns, |
@@ -601,45 +601,45 @@ discard block |
||
601 | 601 | /** |
602 | 602 | * Displays items table columns. |
603 | 603 | */ |
604 | - public static function display_item_columns( $column_name, $post_id ) { |
|
604 | + public static function display_item_columns($column_name, $post_id) { |
|
605 | 605 | |
606 | - $item = new WPInv_Item( $post_id ); |
|
606 | + $item = new WPInv_Item($post_id); |
|
607 | 607 | |
608 | - switch ( $column_name ) { |
|
608 | + switch ($column_name) { |
|
609 | 609 | |
610 | 610 | case 'price': |
611 | - if ( ! $item->is_recurring() ) { |
|
612 | - echo wp_kses_post( $item->get_the_price() ); |
|
611 | + if (!$item->is_recurring()) { |
|
612 | + echo wp_kses_post($item->get_the_price()); |
|
613 | 613 | break; |
614 | 614 | } |
615 | 615 | |
616 | 616 | $price = wp_sprintf( |
617 | - __( '%1$s / %2$s', 'invoicing' ), |
|
617 | + __('%1$s / %2$s', 'invoicing'), |
|
618 | 618 | $item->get_the_price(), |
619 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
619 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
620 | 620 | ); |
621 | 621 | |
622 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
623 | - echo wp_kses_post( $price ); |
|
622 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
623 | + echo wp_kses_post($price); |
|
624 | 624 | break; |
625 | 625 | } |
626 | 626 | |
627 | - echo wp_kses_post( $item->get_the_initial_price() ); |
|
627 | + echo wp_kses_post($item->get_the_initial_price()); |
|
628 | 628 | |
629 | - echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>'; |
|
629 | + echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>'; |
|
630 | 630 | break; |
631 | 631 | |
632 | 632 | case 'vat_rule': |
633 | - echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) ); |
|
633 | + echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule())); |
|
634 | 634 | break; |
635 | 635 | |
636 | 636 | case 'vat_class': |
637 | - echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) ); |
|
637 | + echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class())); |
|
638 | 638 | break; |
639 | 639 | |
640 | 640 | case 'shortcode': |
641 | - if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) { |
|
642 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
641 | + if ($item->is_type(array('', 'fee', 'custom'))) { |
|
642 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
643 | 643 | } else { |
644 | 644 | echo '—'; |
645 | 645 | } |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | break; |
648 | 648 | |
649 | 649 | case 'type': |
650 | - echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' ); |
|
650 | + echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'); |
|
651 | 651 | break; |
652 | 652 | |
653 | 653 | } |
@@ -657,21 +657,21 @@ discard block |
||
657 | 657 | /** |
658 | 658 | * Lets users filter items using taxes. |
659 | 659 | */ |
660 | - public static function add_item_filters( $post_type ) { |
|
660 | + public static function add_item_filters($post_type) { |
|
661 | 661 | |
662 | 662 | // Abort if we're not dealing with items. |
663 | - if ( 'wpi_item' !== $post_type ) { |
|
663 | + if ('wpi_item' !== $post_type) { |
|
664 | 664 | return; |
665 | 665 | } |
666 | 666 | |
667 | 667 | // Filter by vat rules. |
668 | - if ( wpinv_use_taxes() ) { |
|
668 | + if (wpinv_use_taxes()) { |
|
669 | 669 | |
670 | 670 | // Sanitize selected vat rule. |
671 | 671 | $vat_rule = ''; |
672 | 672 | $vat_rules = getpaid_get_tax_rules(); |
673 | - if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
674 | - $vat_rule = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
673 | + if (isset($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
674 | + $vat_rule = sanitize_text_field($_GET['vat_rule']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
675 | 675 | } |
676 | 676 | |
677 | 677 | // Filter by VAT rule. |
@@ -679,13 +679,13 @@ discard block |
||
679 | 679 | array( |
680 | 680 | 'options' => array_merge( |
681 | 681 | array( |
682 | - '' => __( 'All Tax Rules', 'invoicing' ), |
|
682 | + '' => __('All Tax Rules', 'invoicing'), |
|
683 | 683 | ), |
684 | 684 | $vat_rules |
685 | 685 | ), |
686 | 686 | 'name' => 'vat_rule', |
687 | 687 | 'id' => 'vat_rule', |
688 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '', |
|
688 | + 'selected' => in_array($vat_rule, array_keys($vat_rules), true) ? $vat_rule : '', |
|
689 | 689 | 'show_option_all' => false, |
690 | 690 | 'show_option_none' => false, |
691 | 691 | ) |
@@ -696,21 +696,21 @@ discard block |
||
696 | 696 | // Sanitize selected vat rule. |
697 | 697 | $vat_class = ''; |
698 | 698 | $vat_classes = getpaid_get_tax_classes(); |
699 | - if ( isset( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
700 | - $vat_class = sanitize_text_field( $_GET['vat_class'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
699 | + if (isset($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
700 | + $vat_class = sanitize_text_field($_GET['vat_class']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | wpinv_html_select( |
704 | 704 | array( |
705 | 705 | 'options' => array_merge( |
706 | 706 | array( |
707 | - '' => __( 'All Tax Classes', 'invoicing' ), |
|
707 | + '' => __('All Tax Classes', 'invoicing'), |
|
708 | 708 | ), |
709 | 709 | $vat_classes |
710 | 710 | ), |
711 | 711 | 'name' => 'vat_class', |
712 | 712 | 'id' => 'vat_class', |
713 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '', |
|
713 | + 'selected' => in_array($vat_class, array_keys($vat_classes), true) ? $vat_class : '', |
|
714 | 714 | 'show_option_all' => false, |
715 | 715 | 'show_option_none' => false, |
716 | 716 | ) |
@@ -719,22 +719,22 @@ discard block |
||
719 | 719 | } |
720 | 720 | |
721 | 721 | // Filter by item type. |
722 | - $type = ''; |
|
723 | - if ( isset( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
724 | - $type = sanitize_text_field( $_GET['type'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
722 | + $type = ''; |
|
723 | + if (isset($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
724 | + $type = sanitize_text_field($_GET['type']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | wpinv_html_select( |
728 | 728 | array( |
729 | 729 | 'options' => array_merge( |
730 | 730 | array( |
731 | - '' => __( 'All item types', 'invoicing' ), |
|
731 | + '' => __('All item types', 'invoicing'), |
|
732 | 732 | ), |
733 | 733 | wpinv_get_item_types() |
734 | 734 | ), |
735 | 735 | 'name' => 'type', |
736 | 736 | 'id' => 'type', |
737 | - 'selected' => in_array( $type, wpinv_item_types(), true ) ? $type : '', |
|
737 | + 'selected' => in_array($type, wpinv_item_types(), true) ? $type : '', |
|
738 | 738 | 'show_option_all' => false, |
739 | 739 | 'show_option_none' => false, |
740 | 740 | ) |
@@ -745,45 +745,45 @@ discard block |
||
745 | 745 | /** |
746 | 746 | * Filters the item query. |
747 | 747 | */ |
748 | - public static function filter_item_query( $query ) { |
|
748 | + public static function filter_item_query($query) { |
|
749 | 749 | |
750 | 750 | // modify the query only if it admin and main query. |
751 | - if ( ! ( is_admin() && $query->is_main_query() ) ) { |
|
751 | + if (!(is_admin() && $query->is_main_query())) { |
|
752 | 752 | return $query; |
753 | 753 | } |
754 | 754 | |
755 | 755 | // we want to modify the query for our items. |
756 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) { |
|
756 | + if (empty($query->query['post_type']) || 'wpi_item' !== $query->query['post_type']) { |
|
757 | 757 | return $query; |
758 | 758 | } |
759 | 759 | |
760 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
760 | + if (empty($query->query_vars['meta_query'])) { |
|
761 | 761 | $query->query_vars['meta_query'] = array(); |
762 | 762 | } |
763 | 763 | |
764 | 764 | // Filter vat rule type |
765 | - if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
765 | + if (!empty($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
766 | 766 | $query->query_vars['meta_query'][] = array( |
767 | 767 | 'key' => '_wpinv_vat_rule', |
768 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
768 | + 'value' => sanitize_text_field($_GET['vat_rule']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
769 | 769 | 'compare' => '=', |
770 | 770 | ); |
771 | 771 | } |
772 | 772 | |
773 | 773 | // Filter vat class |
774 | - if ( ! empty( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
774 | + if (!empty($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
775 | 775 | $query->query_vars['meta_query'][] = array( |
776 | 776 | 'key' => '_wpinv_vat_class', |
777 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
777 | + 'value' => sanitize_text_field($_GET['vat_class']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
778 | 778 | 'compare' => '=', |
779 | 779 | ); |
780 | 780 | } |
781 | 781 | |
782 | 782 | // Filter item type |
783 | - if ( ! empty( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
783 | + if (!empty($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
784 | 784 | $query->query_vars['meta_query'][] = array( |
785 | 785 | 'key' => '_wpinv_type', |
786 | - 'value' => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
786 | + 'value' => sanitize_text_field($_GET['type']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
787 | 787 | 'compare' => '=', |
788 | 788 | ); |
789 | 789 | } |
@@ -797,15 +797,15 @@ discard block |
||
797 | 797 | /** |
798 | 798 | * Reorders items. |
799 | 799 | */ |
800 | - public static function reorder_items( $vars ) { |
|
800 | + public static function reorder_items($vars) { |
|
801 | 801 | global $typenow; |
802 | 802 | |
803 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
803 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
804 | 804 | return $vars; |
805 | 805 | } |
806 | 806 | |
807 | 807 | // By item type. |
808 | - if ( 'type' === $vars['orderby'] ) { |
|
808 | + if ('type' === $vars['orderby']) { |
|
809 | 809 | return array_merge( |
810 | 810 | $vars, |
811 | 811 | array( |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | } |
817 | 817 | |
818 | 818 | // By vat class. |
819 | - if ( 'vat_class' === $vars['orderby'] ) { |
|
819 | + if ('vat_class' === $vars['orderby']) { |
|
820 | 820 | return array_merge( |
821 | 821 | $vars, |
822 | 822 | array( |
@@ -827,7 +827,7 @@ discard block |
||
827 | 827 | } |
828 | 828 | |
829 | 829 | // By vat rule. |
830 | - if ( 'vat_rule' === $vars['orderby'] ) { |
|
830 | + if ('vat_rule' === $vars['orderby']) { |
|
831 | 831 | return array_merge( |
832 | 832 | $vars, |
833 | 833 | array( |
@@ -838,7 +838,7 @@ discard block |
||
838 | 838 | } |
839 | 839 | |
840 | 840 | // By price. |
841 | - if ( 'price' === $vars['orderby'] ) { |
|
841 | + if ('price' === $vars['orderby']) { |
|
842 | 842 | return array_merge( |
843 | 843 | $vars, |
844 | 844 | array( |
@@ -855,27 +855,27 @@ discard block |
||
855 | 855 | /** |
856 | 856 | * Fired when deleting a post. |
857 | 857 | */ |
858 | - public static function delete_post( $post_id ) { |
|
858 | + public static function delete_post($post_id) { |
|
859 | 859 | |
860 | - switch ( get_post_type( $post_id ) ) { |
|
860 | + switch (get_post_type($post_id)) { |
|
861 | 861 | |
862 | 862 | case 'wpi_item': |
863 | - do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) ); |
|
863 | + do_action('getpaid_before_delete_item', new WPInv_Item($post_id)); |
|
864 | 864 | break; |
865 | 865 | |
866 | 866 | case 'wpi_payment_form': |
867 | - do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) ); |
|
867 | + do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id)); |
|
868 | 868 | break; |
869 | 869 | |
870 | 870 | case 'wpi_discount': |
871 | - do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) ); |
|
871 | + do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id)); |
|
872 | 872 | break; |
873 | 873 | |
874 | 874 | case 'wpi_invoice': |
875 | - $invoice = new WPInv_Invoice( $post_id ); |
|
876 | - do_action( 'getpaid_before_delete_invoice', $invoice ); |
|
877 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
878 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
875 | + $invoice = new WPInv_Invoice($post_id); |
|
876 | + do_action('getpaid_before_delete_invoice', $invoice); |
|
877 | + $invoice->get_data_store()->delete_items($invoice); |
|
878 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
879 | 879 | break; |
880 | 880 | } |
881 | 881 | } |
@@ -888,41 +888,41 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @return mixed |
890 | 890 | */ |
891 | - public static function add_display_post_states( $post_states, $post ) { |
|
892 | - if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) { |
|
893 | - $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' ); |
|
891 | + public static function add_display_post_states($post_states, $post) { |
|
892 | + if (wpinv_get_option('success_page', 0) == $post->ID) { |
|
893 | + $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing'); |
|
894 | 894 | } |
895 | 895 | |
896 | - foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) { |
|
897 | - $_post_type = str_replace( "wpi_", "", $post_type ); |
|
896 | + foreach (getpaid_get_invoice_post_types() as $post_type => $label) { |
|
897 | + $_post_type = str_replace("wpi_", "", $post_type); |
|
898 | 898 | |
899 | - if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) { |
|
900 | - $post_states[ "getpaid_{$post_type}_history_page" ] = wp_sprintf( |
|
901 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
899 | + if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) { |
|
900 | + $post_states["getpaid_{$post_type}_history_page"] = wp_sprintf( |
|
901 | + __('GetPaid %s History Page', 'invoicing'), |
|
902 | 902 | $label |
903 | 903 | ); |
904 | - } else if ( wpinv_get_option( "{$_post_type}_history_page", 0 ) == $post->ID ) { |
|
905 | - $post_states[ "getpaid_{$_post_type}_history_page" ] = wp_sprintf( |
|
906 | - __( 'GetPaid %s History Page', 'invoicing' ), |
|
904 | + } else if (wpinv_get_option("{$_post_type}_history_page", 0) == $post->ID) { |
|
905 | + $post_states["getpaid_{$_post_type}_history_page"] = wp_sprintf( |
|
906 | + __('GetPaid %s History Page', 'invoicing'), |
|
907 | 907 | $label |
908 | 908 | ); |
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | - if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) { |
|
913 | - $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscriptions Page', 'invoicing' ); |
|
912 | + if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) { |
|
913 | + $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscriptions Page', 'invoicing'); |
|
914 | 914 | } |
915 | 915 | |
916 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
917 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
916 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
917 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
918 | 918 | } |
919 | 919 | |
920 | - if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) { |
|
921 | - $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' ); |
|
920 | + if (wpinv_get_option('checkout_page', 0) == $post->ID) { |
|
921 | + $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing'); |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( wpinv_get_option( 'failure_page', 0 ) == $post->ID ) { |
|
925 | - $post_states['getpaid_failure_page'] = __( 'GetPaid Transaction Failed Page', 'invoicing' ); |
|
924 | + if (wpinv_get_option('failure_page', 0) == $post->ID) { |
|
925 | + $post_states['getpaid_failure_page'] = __('GetPaid Transaction Failed Page', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | return $post_states; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | 'block-keywords' => "['invoicing','checkout']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'wpinv_checkout', |
25 | - 'name' => __( 'GetPaid > Checkout', 'invoicing' ), |
|
25 | + 'name' => __('GetPaid > Checkout', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid-checkout bsui', |
28 | - 'description' => esc_html__( 'Displays a checkout form.', 'invoicing' ), |
|
28 | + 'description' => esc_html__('Displays a checkout form.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | 'title' => array( |
32 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
33 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
32 | + 'title' => __('Widget title', 'invoicing'), |
|
33 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
34 | 34 | 'type' => 'text', |
35 | 35 | 'desc_tip' => true, |
36 | 36 | 'default' => '', |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | |
41 | 41 | ); |
42 | 42 | |
43 | - parent::__construct( $options ); |
|
43 | + parent::__construct($options); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -52,21 +52,21 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @return mixed|string|bool |
54 | 54 | */ |
55 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
56 | - if ( $this->is_preview() ) { |
|
57 | - return $this->get_dummy_preview( $args ); |
|
55 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
56 | + if ($this->is_preview()) { |
|
57 | + return $this->get_dummy_preview($args); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return wpinv_checkout_form(); |
61 | 61 | } |
62 | 62 | |
63 | - public function get_dummy_preview( $args ) { |
|
63 | + public function get_dummy_preview($args) { |
|
64 | 64 | $output = '<form><div class="col-12">'; |
65 | 65 | |
66 | 66 | $output .= aui()->alert( |
67 | 67 | array( |
68 | 68 | 'type'=> 'info', |
69 | - 'content' => __( 'This is a simple preview for a checkout form.', 'invoicing' ) |
|
69 | + 'content' => __('This is a simple preview for a checkout form.', 'invoicing') |
|
70 | 70 | ) |
71 | 71 | ); |
72 | 72 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | array( |
75 | 75 | 'name' => 'mmdwqzpox', |
76 | 76 | 'required' => true, |
77 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
77 | + 'label' => __('Billing Email', 'invoicing'), |
|
78 | 78 | 'label_type' => 'vertical', |
79 | 79 | 'type' => 'text', |
80 | 80 | 'placeholder' => '[email protected]', |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | array( |
88 | 88 | 'name' => 'mmdwqzpoy', |
89 | 89 | 'required' => true, |
90 | - 'label' => __( 'First Name', 'invoicing' ), |
|
90 | + 'label' => __('First Name', 'invoicing'), |
|
91 | 91 | 'label_type' => 'vertical', |
92 | 92 | 'type' => 'text', |
93 | 93 | 'placeholder' => 'Jon', |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | array( |
101 | 101 | 'name' => 'mmdwqzpoz', |
102 | 102 | 'required' => true, |
103 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
103 | + 'label' => __('Last Name', 'invoicing'), |
|
104 | 104 | 'label_type' => 'vertical', |
105 | 105 | 'type' => 'text', |
106 | 106 | 'placeholder' => 'Snow', |
@@ -113,8 +113,8 @@ discard block |
||
113 | 113 | array( |
114 | 114 | 'type' => 'button', |
115 | 115 | 'class' => 'btn btn-primary w-100', |
116 | - 'content' => __( 'Pay Now »', 'invoicing' ), |
|
117 | - 'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ) |
|
116 | + 'content' => __('Pay Now »', 'invoicing'), |
|
117 | + 'description' => __('By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing') |
|
118 | 118 | ) |
119 | 119 | ); |
120 | 120 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -21,15 +21,15 @@ discard block |
||
21 | 21 | 'block-keywords' => "['invoicing','receipt']", |
22 | 22 | 'class_name' => __CLASS__, |
23 | 23 | 'base_id' => 'wpinv_receipt', |
24 | - 'name' => __( 'GetPaid > Invoice Receipt', 'invoicing' ), |
|
24 | + 'name' => __('GetPaid > Invoice Receipt', 'invoicing'), |
|
25 | 25 | 'widget_ops' => array( |
26 | 26 | 'classname' => 'wpinv-receipt-class bsui', |
27 | - 'description' => esc_html__( 'Displays invoice receipt after checkout.', 'invoicing' ), |
|
27 | + 'description' => esc_html__('Displays invoice receipt after checkout.', 'invoicing'), |
|
28 | 28 | ), |
29 | 29 | 'arguments' => array( |
30 | 30 | 'title' => array( |
31 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
32 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
31 | + 'title' => __('Widget title', 'invoicing'), |
|
32 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
33 | 33 | 'type' => 'text', |
34 | 34 | 'desc_tip' => true, |
35 | 35 | 'default' => '', |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | ); |
41 | 41 | |
42 | - parent::__construct( $options ); |
|
42 | + parent::__construct($options); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -51,42 +51,42 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @return mixed|string|bool |
53 | 53 | */ |
54 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
55 | - if ( $this->is_preview() ) { |
|
56 | - return $this->get_dummy_preview( $args ); |
|
54 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
55 | + if ($this->is_preview()) { |
|
56 | + return $this->get_dummy_preview($args); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return wpinv_payment_receipt(); |
60 | 60 | } |
61 | 61 | |
62 | - public function get_dummy_preview( $args ) { |
|
62 | + public function get_dummy_preview($args) { |
|
63 | 63 | global $wpdb; |
64 | 64 | |
65 | - $output = aui()->alert( array( |
|
65 | + $output = aui()->alert(array( |
|
66 | 66 | 'type'=> 'info', |
67 | - 'content' => __( 'This is a simple preview for a invoice receipt.', 'invoicing' ) |
|
67 | + 'content' => __('This is a simple preview for a invoice receipt.', 'invoicing') |
|
68 | 68 | ) |
69 | 69 | ); |
70 | 70 | |
71 | - if ( ! current_user_can( 'manage_options' ) ) { |
|
71 | + if (!current_user_can('manage_options')) { |
|
72 | 72 | return $output; |
73 | 73 | } |
74 | 74 | |
75 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = %s AND `post_status` IN( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold' ) ORDER BY `post_status` ASC, `ID` ASC LIMIT 1;", 'wpi_invoice' ) ); |
|
75 | + $invoice_id = $wpdb->get_var($wpdb->prepare("SELECT `ID` FROM `{$wpdb->posts}` WHERE `post_type` = %s AND `post_status` IN( 'wpi-pending', 'publish', 'wpi-processing', 'wpi-onhold' ) ORDER BY `post_status` ASC, `ID` ASC LIMIT 1;", 'wpi_invoice')); |
|
76 | 76 | |
77 | - if ( ! $invoice_id ) { |
|
77 | + if (!$invoice_id) { |
|
78 | 78 | return $output; |
79 | 79 | } |
80 | 80 | |
81 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
81 | + $invoice = new WPInv_Invoice($invoice_id); |
|
82 | 82 | |
83 | - if ( empty( $invoice ) ) { |
|
83 | + if (empty($invoice)) { |
|
84 | 84 | return $output; |
85 | 85 | } |
86 | 86 | |
87 | - $output .= wpinv_get_template_html( 'invoice-receipt.php', array( 'invoice' => $invoice ) ); |
|
87 | + $output .= wpinv_get_template_html('invoice-receipt.php', array('invoice' => $invoice)); |
|
88 | 88 | |
89 | - $output = preg_replace( '/<a([^>]*)href=(["\'])(.*?)\2([^>]*)>/is', '<a\\1href="javascript:void(0)"\\4>', $output ); |
|
89 | + $output = preg_replace('/<a([^>]*)href=(["\'])(.*?)\2([^>]*)>/is', '<a\\1href="javascript:void(0)"\\4>', $output); |
|
90 | 90 | |
91 | 91 | return $output; |
92 | 92 | } |
@@ -6,4 +6,4 @@ |
||
6 | 6 | * @since 2.8.32 |
7 | 7 | */ |
8 | 8 | |
9 | -__( 'My String', 'invoicing' ); |
|
9 | +__('My String', 'invoicing'); |
@@ -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 | * The main admin class. |
@@ -39,11 +39,11 @@ discard block |
||
39 | 39 | */ |
40 | 40 | public function __construct() { |
41 | 41 | |
42 | - $this->admin_path = plugin_dir_path( __FILE__ ); |
|
43 | - $this->admin_url = plugins_url( '/', __FILE__ ); |
|
42 | + $this->admin_path = plugin_dir_path(__FILE__); |
|
43 | + $this->admin_url = plugins_url('/', __FILE__); |
|
44 | 44 | $this->reports = new GetPaid_Reports(); |
45 | 45 | |
46 | - if ( is_admin() ) { |
|
46 | + if (is_admin()) { |
|
47 | 47 | $this->init_admin_hooks(); |
48 | 48 | } |
49 | 49 | |
@@ -54,37 +54,37 @@ discard block |
||
54 | 54 | * |
55 | 55 | */ |
56 | 56 | private function init_admin_hooks() { |
57 | - add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 ); |
|
58 | - add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) ); |
|
59 | - add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) ); |
|
60 | - add_action( 'admin_init', array( $this, 'activation_redirect' ) ); |
|
61 | - add_action( 'admin_init', array( $this, 'maybe_do_admin_action' ) ); |
|
62 | - add_action( 'admin_notices', array( $this, 'show_notices' ) ); |
|
63 | - add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) ); |
|
64 | - add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) ); |
|
65 | - add_action( 'getpaid_authenticated_admin_action_reset_form_stats', array( $this, 'reset_form_stats' ) ); |
|
66 | - add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) ); |
|
67 | - add_action( 'getpaid_authenticated_admin_action_refund_invoice', array( $this, 'refund_invoice' ) ); |
|
68 | - add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) ); |
|
69 | - add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) ); |
|
70 | - add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) ); |
|
71 | - add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) ); |
|
72 | - add_action( 'getpaid_authenticated_admin_action_refresh_permalinks', array( $this, 'admin_refresh_permalinks' ) ); |
|
73 | - add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) ); |
|
74 | - add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) ); |
|
75 | - add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) ); |
|
76 | - add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) ); |
|
77 | - add_action( 'getpaid_authenticated_admin_action_translate_db_texts', array( $this, 'tool_translate_db_texts' ) ); |
|
78 | - add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) ); |
|
79 | - add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) ); |
|
80 | - add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) ); |
|
81 | - do_action( 'getpaid_init_admin_hooks', $this ); |
|
57 | + add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9); |
|
58 | + add_filter('admin_body_class', array($this, 'admin_body_class')); |
|
59 | + add_action('admin_init', array($this, 'init_ayecode_connect_helper')); |
|
60 | + add_action('admin_init', array($this, 'activation_redirect')); |
|
61 | + add_action('admin_init', array($this, 'maybe_do_admin_action')); |
|
62 | + add_action('admin_notices', array($this, 'show_notices')); |
|
63 | + add_action('getpaid_authenticated_admin_action_rate_plugin', array($this, 'redirect_to_wordpress_rating_page')); |
|
64 | + add_action('getpaid_authenticated_admin_action_duplicate_form', array($this, 'duplicate_payment_form')); |
|
65 | + add_action('getpaid_authenticated_admin_action_reset_form_stats', array($this, 'reset_form_stats')); |
|
66 | + add_action('getpaid_authenticated_admin_action_duplicate_invoice', array($this, 'duplicate_invoice')); |
|
67 | + add_action('getpaid_authenticated_admin_action_refund_invoice', array($this, 'refund_invoice')); |
|
68 | + add_action('getpaid_authenticated_admin_action_send_invoice', array($this, 'send_customer_invoice')); |
|
69 | + add_action('getpaid_authenticated_admin_action_send_invoice_reminder', array($this, 'send_customer_payment_reminder')); |
|
70 | + add_action('getpaid_authenticated_admin_action_reset_tax_rates', array($this, 'admin_reset_tax_rates')); |
|
71 | + add_action('getpaid_authenticated_admin_action_create_missing_pages', array($this, 'admin_create_missing_pages')); |
|
72 | + add_action('getpaid_authenticated_admin_action_refresh_permalinks', array($this, 'admin_refresh_permalinks')); |
|
73 | + add_action('getpaid_authenticated_admin_action_create_missing_tables', array($this, 'admin_create_missing_tables')); |
|
74 | + add_action('getpaid_authenticated_admin_action_migrate_old_invoices', array($this, 'admin_migrate_old_invoices')); |
|
75 | + add_action('getpaid_authenticated_admin_action_download_customers', array($this, 'admin_download_customers')); |
|
76 | + add_action('getpaid_authenticated_admin_action_recalculate_discounts', array($this, 'admin_recalculate_discounts')); |
|
77 | + add_action('getpaid_authenticated_admin_action_translate_db_texts', array($this, 'tool_translate_db_texts')); |
|
78 | + add_action('getpaid_authenticated_admin_action_install_plugin', array($this, 'admin_install_plugin')); |
|
79 | + add_action('getpaid_authenticated_admin_action_connect_gateway', array($this, 'admin_connect_gateway')); |
|
80 | + add_filter('admin_footer_text', array($this, 'admin_footer_text')); |
|
81 | + do_action('getpaid_init_admin_hooks', $this); |
|
82 | 82 | |
83 | 83 | // Setup/welcome |
84 | - if ( ! empty( $_GET['page'] ) ) { |
|
85 | - switch ( sanitize_text_field( $_GET['page'] ) ) { |
|
84 | + if (!empty($_GET['page'])) { |
|
85 | + switch (sanitize_text_field($_GET['page'])) { |
|
86 | 86 | case 'gp-setup': |
87 | - include_once dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php'; |
|
87 | + include_once dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php'; |
|
88 | 88 | break; |
89 | 89 | } |
90 | 90 | } |
@@ -98,37 +98,37 @@ discard block |
||
98 | 98 | public function enqeue_scripts() { |
99 | 99 | global $current_screen, $pagenow; |
100 | 100 | |
101 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
101 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
102 | 102 | $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php'; |
103 | 103 | |
104 | - if ( ! empty( $current_screen->post_type ) ) { |
|
104 | + if (!empty($current_screen->post_type)) { |
|
105 | 105 | $page = $current_screen->post_type; |
106 | 106 | } |
107 | 107 | |
108 | 108 | // General styles. |
109 | - if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page || false !== stripos( $page, 'geodir-tickets' ) ) { |
|
109 | + if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page || false !== stripos($page, 'geodir-tickets')) { |
|
110 | 110 | |
111 | 111 | // Styles. |
112 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' ); |
|
113 | - wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version ); |
|
114 | - wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' ); |
|
112 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css'); |
|
113 | + wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version); |
|
114 | + wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all'); |
|
115 | 115 | |
116 | 116 | // Scripts. |
117 | - wp_enqueue_script( 'select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION ); |
|
117 | + wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION); |
|
118 | 118 | |
119 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' ); |
|
120 | - wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ), $version ); |
|
121 | - wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) ); |
|
119 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js'); |
|
120 | + wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version); |
|
121 | + wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18())); |
|
122 | 122 | |
123 | 123 | } |
124 | 124 | |
125 | 125 | // Payment form scripts. |
126 | - if ( 'wpi_payment_form' == $page && $editing ) { |
|
126 | + if ('wpi_payment_form' == $page && $editing) { |
|
127 | 127 | $this->load_payment_form_scripts(); |
128 | 128 | } |
129 | 129 | |
130 | - if ( $page == 'wpinv-subscriptions' ) { |
|
131 | - wp_enqueue_script( 'postbox' ); |
|
130 | + if ($page == 'wpinv-subscriptions') { |
|
131 | + wp_enqueue_script('postbox'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | } |
@@ -141,31 +141,31 @@ discard block |
||
141 | 141 | global $post; |
142 | 142 | |
143 | 143 | $date_range = array( |
144 | - 'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days', |
|
144 | + 'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days', |
|
145 | 145 | ); |
146 | 146 | |
147 | - if ( $date_range['period'] == 'custom' ) { |
|
147 | + if ($date_range['period'] == 'custom') { |
|
148 | 148 | |
149 | - if ( isset( $_GET['from'] ) ) { |
|
150 | - $date_range['after'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS ); |
|
149 | + if (isset($_GET['from'])) { |
|
150 | + $date_range['after'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['from']), current_time('timestamp')) - DAY_IN_SECONDS); |
|
151 | 151 | } |
152 | 152 | |
153 | - if ( isset( $_GET['to'] ) ) { |
|
154 | - $date_range['before'] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS ); |
|
153 | + if (isset($_GET['to'])) { |
|
154 | + $date_range['before'] = date('Y-m-d', strtotime(sanitize_text_field($_GET['to']), current_time('timestamp')) + DAY_IN_SECONDS); |
|
155 | 155 | } |
156 | 156 | } |
157 | 157 | |
158 | 158 | $i18n = array( |
159 | - 'ajax_url' => admin_url( 'admin-ajax.php' ), |
|
160 | - 'post_ID' => isset( $post->ID ) ? $post->ID : '', |
|
161 | - 'wpinv_nonce' => wp_create_nonce( 'wpinv-nonce' ), |
|
162 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), |
|
163 | - 'rest_root' => esc_url_raw( rest_url() ), |
|
159 | + 'ajax_url' => admin_url('admin-ajax.php'), |
|
160 | + 'post_ID' => isset($post->ID) ? $post->ID : '', |
|
161 | + 'wpinv_nonce' => wp_create_nonce('wpinv-nonce'), |
|
162 | + 'rest_nonce' => wp_create_nonce('wp_rest'), |
|
163 | + 'rest_root' => esc_url_raw(rest_url()), |
|
164 | 164 | 'date_range' => $date_range, |
165 | - 'add_invoice_note_nonce' => wp_create_nonce( 'add-invoice-note' ), |
|
166 | - 'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ), |
|
167 | - 'invoice_item_nonce' => wp_create_nonce( 'invoice-item' ), |
|
168 | - 'billing_details_nonce' => wp_create_nonce( 'get-billing-details' ), |
|
165 | + 'add_invoice_note_nonce' => wp_create_nonce('add-invoice-note'), |
|
166 | + 'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'), |
|
167 | + 'invoice_item_nonce' => wp_create_nonce('invoice-item'), |
|
168 | + 'billing_details_nonce' => wp_create_nonce('get-billing-details'), |
|
169 | 169 | 'tax' => wpinv_tax_amount(), |
170 | 170 | 'discount' => 0, |
171 | 171 | 'currency_symbol' => wpinv_currency_symbol(), |
@@ -174,39 +174,39 @@ discard block |
||
174 | 174 | 'thousand_sep' => wpinv_thousands_separator(), |
175 | 175 | 'decimal_sep' => wpinv_decimal_separator(), |
176 | 176 | 'decimals' => wpinv_decimals(), |
177 | - 'save_invoice' => __( 'Save Invoice', 'invoicing' ), |
|
178 | - 'status_publish' => wpinv_status_nicename( 'publish' ), |
|
179 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
180 | - 'delete_tax_rate' => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ), |
|
181 | - 'status_pending' => wpinv_status_nicename( 'wpi-pending' ), |
|
182 | - 'FillBillingDetails' => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ), |
|
183 | - 'confirmCalcTotals' => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ), |
|
184 | - 'AreYouSure' => __( 'Are you sure?', 'invoicing' ), |
|
185 | - 'errDeleteItem' => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ), |
|
186 | - 'delete_subscription' => __( 'Are you sure you want to delete this subscription?', 'invoicing' ), |
|
187 | - 'action_edit' => __( 'Edit', 'invoicing' ), |
|
188 | - 'action_cancel' => __( 'Cancel', 'invoicing' ), |
|
189 | - 'item_description' => __( 'Item Description', 'invoicing' ), |
|
190 | - 'invoice_description' => __( 'Invoice Description', 'invoicing' ), |
|
191 | - 'discount_description' => __( 'Discount Description', 'invoicing' ), |
|
192 | - 'searching' => __( 'Searching', 'invoicing' ), |
|
193 | - 'loading' => __( 'Loading...', 'invoicing' ), |
|
194 | - 'search_customers' => __( 'Enter customer name or email', 'invoicing' ), |
|
195 | - 'search_items' => __( 'Enter item name', 'invoicing' ), |
|
196 | - 'graphs' => array_merge( array( 'refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax' ), array_keys( wpinv_get_report_graphs() ) ), |
|
177 | + 'save_invoice' => __('Save Invoice', 'invoicing'), |
|
178 | + 'status_publish' => wpinv_status_nicename('publish'), |
|
179 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
180 | + 'delete_tax_rate' => __('Are you sure you wish to delete this tax rate?', 'invoicing'), |
|
181 | + 'status_pending' => wpinv_status_nicename('wpi-pending'), |
|
182 | + 'FillBillingDetails' => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'), |
|
183 | + 'confirmCalcTotals' => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'), |
|
184 | + 'AreYouSure' => __('Are you sure?', 'invoicing'), |
|
185 | + 'errDeleteItem' => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'), |
|
186 | + 'delete_subscription' => __('Are you sure you want to delete this subscription?', 'invoicing'), |
|
187 | + 'action_edit' => __('Edit', 'invoicing'), |
|
188 | + 'action_cancel' => __('Cancel', 'invoicing'), |
|
189 | + 'item_description' => __('Item Description', 'invoicing'), |
|
190 | + 'invoice_description' => __('Invoice Description', 'invoicing'), |
|
191 | + 'discount_description' => __('Discount Description', 'invoicing'), |
|
192 | + 'searching' => __('Searching', 'invoicing'), |
|
193 | + 'loading' => __('Loading...', 'invoicing'), |
|
194 | + 'search_customers' => __('Enter customer name or email', 'invoicing'), |
|
195 | + 'search_items' => __('Enter item name', 'invoicing'), |
|
196 | + 'graphs' => array_merge(array('refunded_fees', 'refunded_items', 'refunded_subtotal', 'refunded_tax'), array_keys(wpinv_get_report_graphs())), |
|
197 | 197 | ); |
198 | 198 | |
199 | - if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
199 | + if (!empty($post) && getpaid_is_invoice_post_type($post->post_type)) { |
|
200 | 200 | |
201 | - $invoice = new WPInv_Invoice( $post ); |
|
201 | + $invoice = new WPInv_Invoice($post); |
|
202 | 202 | $i18n['save_invoice'] = sprintf( |
203 | - __( 'Save %s', 'invoicing' ), |
|
204 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
203 | + __('Save %s', 'invoicing'), |
|
204 | + ucfirst($invoice->get_invoice_quote_type()) |
|
205 | 205 | ); |
206 | 206 | |
207 | 207 | $i18n['invoice_description'] = sprintf( |
208 | - __( '%s Description', 'invoicing' ), |
|
209 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
208 | + __('%s Description', 'invoicing'), |
|
209 | + ucfirst($invoice->get_invoice_quote_type()) |
|
210 | 210 | ); |
211 | 211 | |
212 | 212 | } |
@@ -220,24 +220,24 @@ discard block |
||
220 | 220 | * @param string $footer_text |
221 | 221 | * @return string |
222 | 222 | */ |
223 | - public function admin_footer_text( $footer_text ) { |
|
223 | + public function admin_footer_text($footer_text) { |
|
224 | 224 | global $current_screen; |
225 | 225 | |
226 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
226 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
227 | 227 | |
228 | - if ( ! empty( $current_screen->post_type ) ) { |
|
228 | + if (!empty($current_screen->post_type)) { |
|
229 | 229 | $page = $current_screen->post_type; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // General styles. |
233 | - if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) { |
|
233 | + if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) { |
|
234 | 234 | |
235 | 235 | // Change the footer text |
236 | - if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) { |
|
236 | + if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) { |
|
237 | 237 | |
238 | - $rating_url = esc_url( |
|
238 | + $rating_url = esc_url( |
|
239 | 239 | wp_nonce_url( |
240 | - admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ), |
|
240 | + admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'), |
|
241 | 241 | 'getpaid-nonce', |
242 | 242 | 'getpaid-nonce' |
243 | 243 | ) |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | |
246 | 246 | $footer_text = sprintf( |
247 | 247 | /* translators: %s: five stars */ |
248 | - __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ), |
|
248 | + __('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'), |
|
249 | 249 | "<a href='$rating_url'>★★★★★</a>" |
250 | 250 | ); |
251 | 251 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | |
254 | 254 | $footer_text = sprintf( |
255 | 255 | /* translators: %s: GetPaid */ |
256 | - __( 'Thank you for using %s!', 'invoicing' ), |
|
256 | + __('Thank you for using %s!', 'invoicing'), |
|
257 | 257 | "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>" |
258 | 258 | ); |
259 | 259 | |
@@ -269,8 +269,8 @@ discard block |
||
269 | 269 | * @since 2.0.0 |
270 | 270 | */ |
271 | 271 | public function redirect_to_wordpress_rating_page() { |
272 | - update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 ); |
|
273 | - wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' ); |
|
272 | + update_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', 1); |
|
273 | + wp_redirect('https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post'); |
|
274 | 274 | exit; |
275 | 275 | } |
276 | 276 | |
@@ -281,29 +281,29 @@ discard block |
||
281 | 281 | protected function load_payment_form_scripts() { |
282 | 282 | global $post; |
283 | 283 | |
284 | - wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION ); |
|
285 | - wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION ); |
|
286 | - wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION ); |
|
284 | + wp_enqueue_script('vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION); |
|
285 | + wp_enqueue_script('sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION); |
|
286 | + wp_enqueue_script('vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array('sortable', 'vue'), WPINV_VERSION); |
|
287 | 287 | |
288 | - wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ), WPINV_VERSION ); |
|
288 | + wp_register_script('wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.min.js', array('wpinv-admin-script', 'vue_draggable', 'wp-hooks'), WPINV_VERSION); |
|
289 | 289 | |
290 | 290 | wp_localize_script( |
291 | 291 | 'wpinv-admin-payment-form-script', |
292 | 292 | 'wpinvPaymentFormAdmin', |
293 | 293 | array( |
294 | - 'elements' => wpinv_get_data( 'payment-form-elements' ), |
|
295 | - 'form_elements' => getpaid_get_payment_form_elements( $post->ID ), |
|
294 | + 'elements' => wpinv_get_data('payment-form-elements'), |
|
295 | + 'form_elements' => getpaid_get_payment_form_elements($post->ID), |
|
296 | 296 | 'currency' => wpinv_currency_symbol(), |
297 | 297 | 'position' => wpinv_currency_position(), |
298 | 298 | 'decimals' => (int) wpinv_decimals(), |
299 | 299 | 'thousands_sep' => wpinv_thousands_separator(), |
300 | 300 | 'decimals_sep' => wpinv_decimal_separator(), |
301 | - 'form_items' => gepaid_get_form_items( $post->ID ), |
|
301 | + 'form_items' => gepaid_get_form_items($post->ID), |
|
302 | 302 | 'is_default' => $post->ID == wpinv_get_default_payment_form(), |
303 | 303 | ) |
304 | 304 | ); |
305 | 305 | |
306 | - wp_enqueue_script( 'wpinv-admin-payment-form-script' ); |
|
306 | + wp_enqueue_script('wpinv-admin-payment-form-script'); |
|
307 | 307 | |
308 | 308 | } |
309 | 309 | |
@@ -314,24 +314,24 @@ discard block |
||
314 | 314 | * @return string |
315 | 315 | * |
316 | 316 | */ |
317 | - public function admin_body_class( $classes ) { |
|
317 | + public function admin_body_class($classes) { |
|
318 | 318 | global $pagenow, $post, $current_screen; |
319 | 319 | |
320 | - $page = isset( $_GET['page'] ) ? sanitize_text_field( $_GET['page'] ) : ''; |
|
320 | + $page = isset($_GET['page']) ? sanitize_text_field($_GET['page']) : ''; |
|
321 | 321 | |
322 | - if ( ! empty( $current_screen->post_type ) ) { |
|
322 | + if (!empty($current_screen->post_type)) { |
|
323 | 323 | $page = $current_screen->post_type; |
324 | 324 | } |
325 | 325 | |
326 | - if ( false !== stripos( $page, 'wpi' ) ) { |
|
327 | - $classes .= ' wpi-' . sanitize_key( $page ); |
|
326 | + if (false !== stripos($page, 'wpi')) { |
|
327 | + $classes .= ' wpi-' . sanitize_key($page); |
|
328 | 328 | } |
329 | 329 | |
330 | - if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) { |
|
330 | + if (in_array($page, wpinv_parse_list('wpi_invoice wpi_payment_form wpi_quote'))) { |
|
331 | 331 | $classes .= ' wpinv-cpt wpinv'; |
332 | 332 | } |
333 | 333 | |
334 | - if ( getpaid_is_invoice_post_type( $page ) ) { |
|
334 | + if (getpaid_is_invoice_post_type($page)) { |
|
335 | 335 | $classes .= ' getpaid-is-invoice-cpt'; |
336 | 336 | } |
337 | 337 | |
@@ -350,21 +350,21 @@ discard block |
||
350 | 350 | 'version' => WPINV_VERSION, |
351 | 351 | 'support_url' => 'https://wpgetpaid.com/support/', |
352 | 352 | 'documentation_url' => 'https://docs.wpgetpaid.com/', |
353 | - 'activated' => (int) get_option( 'gepaid_installed_on' ), |
|
353 | + 'activated' => (int) get_option('gepaid_installed_on'), |
|
354 | 354 | ) |
355 | 355 | ); |
356 | 356 | |
357 | 357 | new AyeCode_Connect_Helper( |
358 | 358 | array( |
359 | - 'connect_title' => __( 'WP Invoicing - an AyeCode product!', 'invoicing' ), |
|
360 | - 'connect_external' => __( 'Please confirm you wish to connect your site?', 'invoicing' ), |
|
361 | - 'connect' => sprintf( __( '<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing' ), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>' ), |
|
362 | - 'connect_button' => __( 'Connect Site', 'invoicing' ), |
|
363 | - 'connecting_button' => __( 'Connecting...', 'invoicing' ), |
|
364 | - 'error_localhost' => __( 'This service will only work with a live domain, not a localhost.', 'invoicing' ), |
|
365 | - 'error' => __( 'Something went wrong, please refresh and try again.', 'invoicing' ), |
|
359 | + 'connect_title' => __('WP Invoicing - an AyeCode product!', 'invoicing'), |
|
360 | + 'connect_external' => __('Please confirm you wish to connect your site?', 'invoicing'), |
|
361 | + 'connect' => sprintf(__('<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %1$slearn more%2$s', 'invoicing'), "<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>", '</a>'), |
|
362 | + 'connect_button' => __('Connect Site', 'invoicing'), |
|
363 | + 'connecting_button' => __('Connecting...', 'invoicing'), |
|
364 | + 'error_localhost' => __('This service will only work with a live domain, not a localhost.', 'invoicing'), |
|
365 | + 'error' => __('Something went wrong, please refresh and try again.', 'invoicing'), |
|
366 | 366 | ), |
367 | - array( 'wpi-addons' ) |
|
367 | + array('wpi-addons') |
|
368 | 368 | ); |
369 | 369 | |
370 | 370 | } |
@@ -376,20 +376,20 @@ discard block |
||
376 | 376 | */ |
377 | 377 | public function activation_redirect() { |
378 | 378 | |
379 | - $redirected = get_option( 'wpinv_redirected_to_settings' ); |
|
379 | + $redirected = get_option('wpinv_redirected_to_settings'); |
|
380 | 380 | |
381 | - if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) { |
|
381 | + if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) { |
|
382 | 382 | return; |
383 | 383 | } |
384 | 384 | |
385 | 385 | // Bail if activating from network, or bulk |
386 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
386 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
387 | 387 | return; |
388 | 388 | } |
389 | 389 | |
390 | - update_option( 'wpinv_redirected_to_settings', 1 ); |
|
390 | + update_option('wpinv_redirected_to_settings', 1); |
|
391 | 391 | |
392 | - wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) ); |
|
392 | + wp_safe_redirect(admin_url('index.php?page=gp-setup')); |
|
393 | 393 | exit; |
394 | 394 | |
395 | 395 | } |
@@ -398,10 +398,10 @@ discard block |
||
398 | 398 | * Fires an admin action after verifying that a user can fire them. |
399 | 399 | */ |
400 | 400 | public function maybe_do_admin_action() { |
401 | - if ( isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) && wpinv_current_user_can( sanitize_text_field( $_REQUEST['getpaid-admin-action'] ), $_REQUEST ) ) { |
|
402 | - $key = sanitize_key( $_REQUEST['getpaid-admin-action'] ); |
|
401 | + if (isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce') && wpinv_current_user_can(sanitize_text_field($_REQUEST['getpaid-admin-action']), $_REQUEST)) { |
|
402 | + $key = sanitize_key($_REQUEST['getpaid-admin-action']); |
|
403 | 403 | |
404 | - do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST ); |
|
404 | + do_action("getpaid_authenticated_admin_action_$key", $_REQUEST); |
|
405 | 405 | } |
406 | 406 | } |
407 | 407 | |
@@ -410,24 +410,24 @@ discard block |
||
410 | 410 | * |
411 | 411 | * @param array $args |
412 | 412 | */ |
413 | - public function duplicate_invoice( $args ) { |
|
413 | + public function duplicate_invoice($args) { |
|
414 | 414 | |
415 | - if ( empty( $args['invoice_id'] ) ) { |
|
415 | + if (empty($args['invoice_id'])) { |
|
416 | 416 | return; |
417 | 417 | } |
418 | 418 | |
419 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
419 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
420 | 420 | |
421 | - if ( ! $invoice->exists() ) { |
|
421 | + if (!$invoice->exists()) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | |
425 | - $new_invoice = getpaid_duplicate_invoice( $invoice ); |
|
425 | + $new_invoice = getpaid_duplicate_invoice($invoice); |
|
426 | 426 | $new_invoice->save(); |
427 | 427 | |
428 | - if ( $new_invoice->exists() ) { |
|
428 | + if ($new_invoice->exists()) { |
|
429 | 429 | |
430 | - getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'invoicing' ) ); |
|
430 | + getpaid_admin()->show_success(__('Invoice duplicated successfully.', 'invoicing')); |
|
431 | 431 | |
432 | 432 | wp_safe_redirect( |
433 | 433 | add_query_arg( |
@@ -435,14 +435,14 @@ discard block |
||
435 | 435 | 'action' => 'edit', |
436 | 436 | 'post' => $new_invoice->get_id(), |
437 | 437 | ), |
438 | - admin_url( 'post.php' ) |
|
438 | + admin_url('post.php') |
|
439 | 439 | ) |
440 | 440 | ); |
441 | 441 | exit; |
442 | 442 | |
443 | 443 | } |
444 | 444 | |
445 | - getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'invoicing' ) ); |
|
445 | + getpaid_admin()->show_error(__('There was an error duplicating this invoice. Please try again.', 'invoicing')); |
|
446 | 446 | |
447 | 447 | } |
448 | 448 | |
@@ -451,40 +451,40 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @param array $args |
453 | 453 | */ |
454 | - public function refund_invoice( $args ) { |
|
454 | + public function refund_invoice($args) { |
|
455 | 455 | |
456 | - if ( empty( $args['invoice_id'] ) ) { |
|
456 | + if (empty($args['invoice_id'])) { |
|
457 | 457 | return; |
458 | 458 | } |
459 | 459 | |
460 | - $invoice = new WPInv_Invoice( (int) $args['invoice_id'] ); |
|
460 | + $invoice = new WPInv_Invoice((int) $args['invoice_id']); |
|
461 | 461 | |
462 | - if ( ! $invoice->exists() || $invoice->is_refunded() ) { |
|
462 | + if (!$invoice->exists() || $invoice->is_refunded()) { |
|
463 | 463 | return; |
464 | 464 | } |
465 | 465 | |
466 | 466 | $invoice->refund(); |
467 | 467 | |
468 | 468 | // Refund remotely. |
469 | - if ( getpaid_payment_gateway_supports( $invoice->get_gateway(), 'refunds' ) && ! empty( $args['getpaid_refund_remote'] ) ) { |
|
470 | - do_action( 'getpaid_refund_invoice_remotely', $invoice ); |
|
469 | + if (getpaid_payment_gateway_supports($invoice->get_gateway(), 'refunds') && !empty($args['getpaid_refund_remote'])) { |
|
470 | + do_action('getpaid_refund_invoice_remotely', $invoice); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Cancel subscriptions. |
474 | - if ( ! empty( $args['getpaid_cancel_subscription'] ) ) { |
|
475 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
474 | + if (!empty($args['getpaid_cancel_subscription'])) { |
|
475 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
476 | 476 | |
477 | - if ( ! empty( $subscriptions ) ) { |
|
478 | - if ( ! is_array( $subscriptions ) ) { |
|
479 | - $subscriptions = array( $subscriptions ); |
|
477 | + if (!empty($subscriptions)) { |
|
478 | + if (!is_array($subscriptions)) { |
|
479 | + $subscriptions = array($subscriptions); |
|
480 | 480 | } |
481 | 481 | |
482 | - foreach ( $subscriptions as $subscription ) { |
|
482 | + foreach ($subscriptions as $subscription) { |
|
483 | 483 | $subscription->cancel(); |
484 | 484 | $invoice->add_system_note( |
485 | 485 | sprintf( |
486 | 486 | // translators: %s: subscription ID. |
487 | - __( 'Subscription #%s cancelled', 'invoicing' ), |
|
487 | + __('Subscription #%s cancelled', 'invoicing'), |
|
488 | 488 | $subscription->get_id() |
489 | 489 | ) |
490 | 490 | ); |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | } |
494 | 494 | |
495 | 495 | // Add notice. |
496 | - $this->show_success( __( 'Invoice refunded successfully.', 'invoicing' ) ); |
|
496 | + $this->show_success(__('Invoice refunded successfully.', 'invoicing')); |
|
497 | 497 | |
498 | 498 | // Redirect. |
499 | 499 | wp_safe_redirect( |
500 | - remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote' ) ) |
|
500 | + remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id', 'getpaid_cancel_subscription', 'getpaid_refund_remote')) |
|
501 | 501 | ); |
502 | 502 | } |
503 | 503 | |
@@ -506,34 +506,34 @@ discard block |
||
506 | 506 | * |
507 | 507 | * @param array $args |
508 | 508 | */ |
509 | - public function duplicate_payment_form( $args ) { |
|
509 | + public function duplicate_payment_form($args) { |
|
510 | 510 | |
511 | - if ( empty( $args['form_id'] ) ) { |
|
511 | + if (empty($args['form_id'])) { |
|
512 | 512 | return; |
513 | 513 | } |
514 | 514 | |
515 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
515 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
516 | 516 | |
517 | - if ( ! $form->exists() ) { |
|
517 | + if (!$form->exists()) { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | $new_form = new GetPaid_Payment_Form(); |
522 | - $new_form->set_author( $form->get_author( 'edit' ) ); |
|
523 | - $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) ); |
|
524 | - $new_form->set_elements( $form->get_elements( 'edit' ) ); |
|
525 | - $new_form->set_items( $form->get_items( 'edit' ) ); |
|
522 | + $new_form->set_author($form->get_author('edit')); |
|
523 | + $new_form->set_name($form->get_name('edit') . __('(copy)', 'invoicing')); |
|
524 | + $new_form->set_elements($form->get_elements('edit')); |
|
525 | + $new_form->set_items($form->get_items('edit')); |
|
526 | 526 | $new_form->save(); |
527 | 527 | |
528 | - if ( $new_form->exists() ) { |
|
529 | - $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) ); |
|
530 | - $url = get_edit_post_link( $new_form->get_id(), 'edit' ); |
|
528 | + if ($new_form->exists()) { |
|
529 | + $this->show_success(__('Form duplicated successfully', 'invoicing')); |
|
530 | + $url = get_edit_post_link($new_form->get_id(), 'edit'); |
|
531 | 531 | } else { |
532 | - $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) ); |
|
533 | - $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ); |
|
532 | + $this->show_error(__('Unable to duplicate form', 'invoicing')); |
|
533 | + $url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce')); |
|
534 | 534 | } |
535 | 535 | |
536 | - wp_redirect( $url ); |
|
536 | + wp_redirect($url); |
|
537 | 537 | exit; |
538 | 538 | } |
539 | 539 | |
@@ -542,27 +542,27 @@ discard block |
||
542 | 542 | * |
543 | 543 | * @param array $args |
544 | 544 | */ |
545 | - public function reset_form_stats( $args ) { |
|
545 | + public function reset_form_stats($args) { |
|
546 | 546 | |
547 | - if ( empty( $args['form_id'] ) ) { |
|
547 | + if (empty($args['form_id'])) { |
|
548 | 548 | return; |
549 | 549 | } |
550 | 550 | |
551 | - $form = new GetPaid_Payment_Form( (int) $args['form_id'] ); |
|
551 | + $form = new GetPaid_Payment_Form((int) $args['form_id']); |
|
552 | 552 | |
553 | - if ( ! $form->exists() ) { |
|
553 | + if (!$form->exists()) { |
|
554 | 554 | return; |
555 | 555 | } |
556 | 556 | |
557 | - $form->set_earned( 0 ); |
|
558 | - $form->set_refunded( 0 ); |
|
559 | - $form->set_cancelled( 0 ); |
|
560 | - $form->set_failed( 0 ); |
|
557 | + $form->set_earned(0); |
|
558 | + $form->set_refunded(0); |
|
559 | + $form->set_cancelled(0); |
|
560 | + $form->set_failed(0); |
|
561 | 561 | $form->save(); |
562 | 562 | |
563 | - $this->show_success( __( 'Form stats reset successfully', 'invoicing' ) ); |
|
563 | + $this->show_success(__('Form stats reset successfully', 'invoicing')); |
|
564 | 564 | |
565 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) ) ); |
|
565 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'))); |
|
566 | 566 | exit; |
567 | 567 | } |
568 | 568 | |
@@ -571,9 +571,9 @@ discard block |
||
571 | 571 | * |
572 | 572 | * @param array $args |
573 | 573 | */ |
574 | - public function send_customer_invoice( $args ) { |
|
575 | - getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true ); |
|
576 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
574 | + public function send_customer_invoice($args) { |
|
575 | + getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($args['invoice_id']), true); |
|
576 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
577 | 577 | exit; |
578 | 578 | } |
579 | 579 | |
@@ -582,16 +582,16 @@ discard block |
||
582 | 582 | * |
583 | 583 | * @param array $args |
584 | 584 | */ |
585 | - public function send_customer_payment_reminder( $args ) { |
|
586 | - $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) ); |
|
585 | + public function send_customer_payment_reminder($args) { |
|
586 | + $sent = getpaid()->get('invoice_emails')->force_send_overdue_notice(new WPInv_Invoice($args['invoice_id'])); |
|
587 | 587 | |
588 | - if ( $sent ) { |
|
589 | - $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) ); |
|
588 | + if ($sent) { |
|
589 | + $this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing')); |
|
590 | 590 | } else { |
591 | - $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) ); |
|
591 | + $this->show_error(__('Could not sent payment reminder to the customer', 'invoicing')); |
|
592 | 592 | } |
593 | 593 | |
594 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) ); |
|
594 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id'))); |
|
595 | 595 | exit; |
596 | 596 | } |
597 | 597 | |
@@ -601,8 +601,8 @@ discard block |
||
601 | 601 | */ |
602 | 602 | public function admin_reset_tax_rates() { |
603 | 603 | |
604 | - update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) ); |
|
605 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
604 | + update_option('wpinv_tax_rates', wpinv_get_data('tax-rates')); |
|
605 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
606 | 606 | exit; |
607 | 607 | |
608 | 608 | } |
@@ -614,8 +614,8 @@ discard block |
||
614 | 614 | public function admin_create_missing_pages() { |
615 | 615 | $installer = new GetPaid_Installer(); |
616 | 616 | $installer->create_pages(); |
617 | - $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) ); |
|
618 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
617 | + $this->show_success(__('GetPaid pages updated.', 'invoicing')); |
|
618 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
619 | 619 | exit; |
620 | 620 | } |
621 | 621 | |
@@ -624,8 +624,8 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function admin_refresh_permalinks() { |
626 | 626 | flush_rewrite_rules(); |
627 | - $this->show_success( __( 'Permalinks refreshed.', 'invoicing' ) ); |
|
628 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
627 | + $this->show_success(__('Permalinks refreshed.', 'invoicing')); |
|
628 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
629 | 629 | exit; |
630 | 630 | } |
631 | 631 | |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | GetPaid_Installer::create_db_tables(); |
640 | 640 | GetPaid_Installer::migrate_old_customers(); |
641 | 641 | |
642 | - if ( '' !== $wpdb->last_error ) { |
|
643 | - $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error ); |
|
642 | + if ('' !== $wpdb->last_error) { |
|
643 | + $this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error); |
|
644 | 644 | } else { |
645 | - $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) ); |
|
645 | + $this->show_success(__('Your GetPaid tables have been updated.', 'invoicing')); |
|
646 | 646 | } |
647 | 647 | |
648 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
648 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
649 | 649 | exit; |
650 | 650 | } |
651 | 651 | |
@@ -660,10 +660,10 @@ discard block |
||
660 | 660 | $installer->migrate_old_invoices(); |
661 | 661 | |
662 | 662 | // Show an admin message. |
663 | - $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) ); |
|
663 | + $this->show_success(__('Your invoices have been migrated.', 'invoicing')); |
|
664 | 664 | |
665 | 665 | // Redirect the admin. |
666 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
666 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
667 | 667 | exit; |
668 | 668 | |
669 | 669 | } |
@@ -674,35 +674,35 @@ discard block |
||
674 | 674 | */ |
675 | 675 | public function admin_download_customers() { |
676 | 676 | |
677 | - $output = fopen( 'php://output', 'w' ); |
|
677 | + $output = fopen('php://output', 'w'); |
|
678 | 678 | |
679 | - if ( false === $output ) { |
|
680 | - wp_die( esc_html__( 'Unsupported server', 'invoicing' ), 500 ); |
|
679 | + if (false === $output) { |
|
680 | + wp_die(esc_html__('Unsupported server', 'invoicing'), 500); |
|
681 | 681 | } |
682 | 682 | |
683 | - header( 'Content-Type:text/csv' ); |
|
684 | - header( 'Content-Disposition:attachment;filename=customers.csv' ); |
|
683 | + header('Content-Type:text/csv'); |
|
684 | + header('Content-Disposition:attachment;filename=customers.csv'); |
|
685 | 685 | |
686 | 686 | /** @var GetPaid_Customer[] $customers */ |
687 | - $customers = getpaid_get_customers( array( 'number' => -1 ) ); |
|
688 | - $columns = array_keys( GetPaid_Customer_Data_Store::get_database_fields() ); |
|
687 | + $customers = getpaid_get_customers(array('number' => -1)); |
|
688 | + $columns = array_keys(GetPaid_Customer_Data_Store::get_database_fields()); |
|
689 | 689 | |
690 | 690 | // Output the csv column headers. |
691 | - fputcsv( $output, $columns ); |
|
691 | + fputcsv($output, $columns); |
|
692 | 692 | |
693 | 693 | // Loop through |
694 | - foreach ( $customers as $customer ) { |
|
694 | + foreach ($customers as $customer) { |
|
695 | 695 | |
696 | - $row = array(); |
|
696 | + $row = array(); |
|
697 | 697 | |
698 | - foreach ( $columns as $column ) { |
|
699 | - $row[] = (string) maybe_serialize( $customer->get( $column, 'edit' ) ); |
|
698 | + foreach ($columns as $column) { |
|
699 | + $row[] = (string) maybe_serialize($customer->get($column, 'edit')); |
|
700 | 700 | } |
701 | 701 | |
702 | - fputcsv( $output, $row ); |
|
702 | + fputcsv($output, $row); |
|
703 | 703 | } |
704 | 704 | |
705 | - fclose( $output ); |
|
705 | + fclose($output); |
|
706 | 706 | exit; |
707 | 707 | |
708 | 708 | } |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | * |
713 | 713 | * @param array $data |
714 | 714 | */ |
715 | - public function admin_install_plugin( $data ) { |
|
715 | + public function admin_install_plugin($data) { |
|
716 | 716 | |
717 | - if ( ! empty( $data['plugins'] ) ) { |
|
717 | + if (!empty($data['plugins'])) { |
|
718 | 718 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
719 | 719 | wp_cache_flush(); |
720 | 720 | |
721 | - foreach ( $data['plugins'] as $slug => $file ) { |
|
722 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' ); |
|
723 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
724 | - $installed = $upgrader->install( $plugin_zip ); |
|
721 | + foreach ($data['plugins'] as $slug => $file) { |
|
722 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip'); |
|
723 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
724 | + $installed = $upgrader->install($plugin_zip); |
|
725 | 725 | |
726 | - if ( ! is_wp_error( $installed ) && $installed ) { |
|
727 | - activate_plugin( $file, '', false, true ); |
|
726 | + if (!is_wp_error($installed) && $installed) { |
|
727 | + activate_plugin($file, '', false, true); |
|
728 | 728 | } else { |
729 | - wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false ); |
|
729 | + wpinv_error_log($upgrader->skin->get_upgrade_messages(), false); |
|
730 | 730 | } |
731 | 731 | } |
732 | 732 | } |
733 | 733 | |
734 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' ); |
|
735 | - wp_safe_redirect( $redirect ); |
|
734 | + $redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php'); |
|
735 | + wp_safe_redirect($redirect); |
|
736 | 736 | exit; |
737 | 737 | |
738 | 738 | } |
@@ -742,41 +742,41 @@ discard block |
||
742 | 742 | * |
743 | 743 | * @param array $data |
744 | 744 | */ |
745 | - public function admin_connect_gateway( $data ) { |
|
745 | + public function admin_connect_gateway($data) { |
|
746 | 746 | |
747 | - if ( ! empty( $data['plugin'] ) ) { |
|
747 | + if (!empty($data['plugin'])) { |
|
748 | 748 | |
749 | - $gateway = sanitize_key( $data['plugin'] ); |
|
750 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
749 | + $gateway = sanitize_key($data['plugin']); |
|
750 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
751 | 751 | |
752 | - if ( ! empty( $connect_url ) ) { |
|
753 | - wp_redirect( $connect_url ); |
|
752 | + if (!empty($connect_url)) { |
|
753 | + wp_redirect($connect_url); |
|
754 | 754 | exit; |
755 | 755 | } |
756 | 756 | |
757 | - if ( 'stripe' == $data['plugin'] ) { |
|
757 | + if ('stripe' == $data['plugin']) { |
|
758 | 758 | require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
759 | 759 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
760 | 760 | wp_cache_flush(); |
761 | 761 | |
762 | - if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) { |
|
763 | - $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' ); |
|
764 | - $upgrader = new Plugin_Upgrader( new Automatic_Upgrader_Skin() ); |
|
765 | - $upgrader->install( $plugin_zip ); |
|
762 | + if (!array_key_exists('getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins())) { |
|
763 | + $plugin_zip = esc_url('https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip'); |
|
764 | + $upgrader = new Plugin_Upgrader(new Automatic_Upgrader_Skin()); |
|
765 | + $upgrader->install($plugin_zip); |
|
766 | 766 | } |
767 | 767 | |
768 | - activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true ); |
|
768 | + activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true); |
|
769 | 769 | } |
770 | 770 | |
771 | - $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data ); |
|
772 | - if ( ! empty( $connect_url ) ) { |
|
773 | - wp_redirect( $connect_url ); |
|
771 | + $connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data); |
|
772 | + if (!empty($connect_url)) { |
|
773 | + wp_redirect($connect_url); |
|
774 | 774 | exit; |
775 | 775 | } |
776 | 776 | } |
777 | 777 | |
778 | - $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' ); |
|
779 | - wp_safe_redirect( $redirect ); |
|
778 | + $redirect = isset($data['redirect']) ? esc_url_raw(urldecode($data['redirect'])) : admin_url('admin.php?page=wpinv-settings&tab=gateways'); |
|
779 | + wp_safe_redirect($redirect); |
|
780 | 780 | exit; |
781 | 781 | |
782 | 782 | } |
@@ -790,35 +790,35 @@ discard block |
||
790 | 790 | |
791 | 791 | // Fetch all invoices that have discount codes. |
792 | 792 | $table = $wpdb->prefix . 'getpaid_invoices'; |
793 | - $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" ); |
|
793 | + $invoices = $wpdb->get_col("SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''"); |
|
794 | 794 | |
795 | - foreach ( $invoices as $invoice ) { |
|
795 | + foreach ($invoices as $invoice) { |
|
796 | 796 | |
797 | - $invoice = new WPInv_Invoice( $invoice ); |
|
797 | + $invoice = new WPInv_Invoice($invoice); |
|
798 | 798 | |
799 | - if ( ! $invoice->exists() ) { |
|
799 | + if (!$invoice->exists()) { |
|
800 | 800 | continue; |
801 | 801 | } |
802 | 802 | |
803 | 803 | // Abort if the discount does not exist or does not apply here. |
804 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
805 | - if ( ! $discount->exists() ) { |
|
804 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
805 | + if (!$discount->exists()) { |
|
806 | 806 | continue; |
807 | 807 | } |
808 | 808 | |
809 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
809 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
810 | 810 | $invoice->recalculate_total(); |
811 | 811 | |
812 | - if ( $invoice->get_total_discount() > 0 ) { |
|
812 | + if ($invoice->get_total_discount() > 0) { |
|
813 | 813 | $invoice->save(); |
814 | 814 | } |
815 | 815 | } |
816 | 816 | |
817 | 817 | // Show an admin message. |
818 | - $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) ); |
|
818 | + $this->show_success(__('Discounts have been recalculated.', 'invoicing')); |
|
819 | 819 | |
820 | 820 | // Redirect the admin. |
821 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
821 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
822 | 822 | exit; |
823 | 823 | |
824 | 824 | } |
@@ -833,18 +833,18 @@ discard block |
||
833 | 833 | * @return bool True if file created otherwise false |
834 | 834 | */ |
835 | 835 | public function tool_translate_db_texts() { |
836 | - $language_file = wp_normalize_path( WPINV_PLUGIN_DIR . 'db-language.php' ); |
|
836 | + $language_file = wp_normalize_path(WPINV_PLUGIN_DIR . 'db-language.php'); |
|
837 | 837 | |
838 | - if ( getpaid_sync_db_text_translation() ) { |
|
838 | + if (getpaid_sync_db_text_translation()) { |
|
839 | 839 | // Success |
840 | - $this->show_success( wp_sprintf( __( 'Strings are added in the file <b>%s</b> for translation.', 'invoicing' ), $language_file ) ); |
|
840 | + $this->show_success(wp_sprintf(__('Strings are added in the file <b>%s</b> for translation.', 'invoicing'), $language_file)); |
|
841 | 841 | } else { |
842 | 842 | // Failure |
843 | - $this->show_error( wp_sprintf( __( 'There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing' ), $language_file ) ); |
|
843 | + $this->show_error(wp_sprintf(__('There was a problem creating the file <b>%s</b>. Please check file permissions.', 'invoicing'), $language_file)); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | // Redirect the admin. |
847 | - wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) ); |
|
847 | + wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce'))); |
|
848 | 848 | |
849 | 849 | exit; |
850 | 850 | } |
@@ -856,8 +856,8 @@ discard block |
||
856 | 856 | * @return array |
857 | 857 | */ |
858 | 858 | public function get_notices() { |
859 | - $notices = get_option( 'wpinv_admin_notices' ); |
|
860 | - return is_array( $notices ) ? $notices : array(); |
|
859 | + $notices = get_option('wpinv_admin_notices'); |
|
860 | + return is_array($notices) ? $notices : array(); |
|
861 | 861 | } |
862 | 862 | |
863 | 863 | /** |
@@ -867,7 +867,7 @@ discard block |
||
867 | 867 | * @return array |
868 | 868 | */ |
869 | 869 | public function has_notices() { |
870 | - return count( $this->get_notices() ) > 0; |
|
870 | + return count($this->get_notices()) > 0; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
@@ -877,7 +877,7 @@ discard block |
||
877 | 877 | * @since 1.0.19 |
878 | 878 | */ |
879 | 879 | public function clear_notices() { |
880 | - delete_option( 'wpinv_admin_notices' ); |
|
880 | + delete_option('wpinv_admin_notices'); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -886,16 +886,16 @@ discard block |
||
886 | 886 | * @access public |
887 | 887 | * @since 1.0.19 |
888 | 888 | */ |
889 | - public function save_notice( $type, $message ) { |
|
889 | + public function save_notice($type, $message) { |
|
890 | 890 | $notices = $this->get_notices(); |
891 | 891 | |
892 | - if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ] ) ) { |
|
893 | - $notices[ $type ] = array(); |
|
892 | + if (empty($notices[$type]) || !is_array($notices[$type])) { |
|
893 | + $notices[$type] = array(); |
|
894 | 894 | } |
895 | 895 | |
896 | - $notices[ $type ][] = $message; |
|
896 | + $notices[$type][] = $message; |
|
897 | 897 | |
898 | - update_option( 'wpinv_admin_notices', $notices ); |
|
898 | + update_option('wpinv_admin_notices', $notices); |
|
899 | 899 | } |
900 | 900 | |
901 | 901 | /** |
@@ -905,8 +905,8 @@ discard block |
||
905 | 905 | * @access public |
906 | 906 | * @since 1.0.19 |
907 | 907 | */ |
908 | - public function show_success( $msg ) { |
|
909 | - $this->save_notice( 'success', $msg ); |
|
908 | + public function show_success($msg) { |
|
909 | + $this->save_notice('success', $msg); |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -916,8 +916,8 @@ discard block |
||
916 | 916 | * @param string $msg The message to qeue. |
917 | 917 | * @since 1.0.19 |
918 | 918 | */ |
919 | - public function show_error( $msg ) { |
|
920 | - $this->save_notice( 'error', $msg ); |
|
919 | + public function show_error($msg) { |
|
920 | + $this->save_notice('error', $msg); |
|
921 | 921 | } |
922 | 922 | |
923 | 923 | /** |
@@ -927,8 +927,8 @@ discard block |
||
927 | 927 | * @param string $msg The message to qeue. |
928 | 928 | * @since 1.0.19 |
929 | 929 | */ |
930 | - public function show_warning( $msg ) { |
|
931 | - $this->save_notice( 'warning', $msg ); |
|
930 | + public function show_warning($msg) { |
|
931 | + $this->save_notice('warning', $msg); |
|
932 | 932 | } |
933 | 933 | |
934 | 934 | /** |
@@ -938,8 +938,8 @@ discard block |
||
938 | 938 | * @param string $msg The message to qeue. |
939 | 939 | * @since 1.0.19 |
940 | 940 | */ |
941 | - public function show_info( $msg ) { |
|
942 | - $this->save_notice( 'info', $msg ); |
|
941 | + public function show_info($msg) { |
|
942 | + $this->save_notice('info', $msg); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | /** |
@@ -953,29 +953,29 @@ discard block |
||
953 | 953 | $notices = $this->get_notices(); |
954 | 954 | $this->clear_notices(); |
955 | 955 | |
956 | - foreach ( $notices as $type => $messages ) { |
|
956 | + foreach ($notices as $type => $messages) { |
|
957 | 957 | |
958 | - if ( ! is_array( $messages ) ) { |
|
958 | + if (!is_array($messages)) { |
|
959 | 959 | continue; |
960 | 960 | } |
961 | 961 | |
962 | - $type = esc_attr( $type ); |
|
963 | - foreach ( $messages as $message ) { |
|
964 | - echo wp_kses_post( "<div class='notice notice-$type is-dismissible'><p>$message</p></div>" ); |
|
962 | + $type = esc_attr($type); |
|
963 | + foreach ($messages as $message) { |
|
964 | + echo wp_kses_post("<div class='notice notice-$type is-dismissible'><p>$message</p></div>"); |
|
965 | 965 | } |
966 | 966 | } |
967 | 967 | |
968 | - foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) { |
|
968 | + foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) { |
|
969 | 969 | |
970 | - if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) { |
|
971 | - $url = wp_nonce_url( |
|
972 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
970 | + if (!is_numeric(wpinv_get_option($page, false))) { |
|
971 | + $url = wp_nonce_url( |
|
972 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
973 | 973 | 'getpaid-nonce', |
974 | 974 | 'getpaid-nonce' |
975 | 975 | ); |
976 | - $message = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' ); |
|
977 | - $message2 = __( 'Generate Pages', 'invoicing' ); |
|
978 | - echo wp_kses_post( "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>" ); |
|
976 | + $message = __('Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing'); |
|
977 | + $message2 = __('Generate Pages', 'invoicing'); |
|
978 | + echo wp_kses_post("<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>"); |
|
979 | 979 | break; |
980 | 980 | } |
981 | 981 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves all default settings. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | function wpinv_get_settings() { |
17 | 17 | $defaults = array(); |
18 | 18 | |
19 | - foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) { |
|
19 | + foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) { |
|
20 | 20 | |
21 | - foreach ( array_values( $tab_settings ) as $section_settings ) { |
|
21 | + foreach (array_values($tab_settings) as $section_settings) { |
|
22 | 22 | |
23 | - foreach ( $section_settings as $key => $setting ) { |
|
24 | - if ( isset( $setting['std'] ) ) { |
|
25 | - $defaults[ $key ] = $setting['std']; |
|
23 | + foreach ($section_settings as $key => $setting) { |
|
24 | + if (isset($setting['std'])) { |
|
25 | + $defaults[$key] = $setting['std']; |
|
26 | 26 | } |
27 | 27 | } |
28 | 28 | } |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | global $wpinv_options; |
42 | 42 | |
43 | 43 | // Try fetching the saved options. |
44 | - if ( empty( $wpinv_options ) ) { |
|
45 | - $wpinv_options = get_option( 'wpinv_settings' ); |
|
44 | + if (empty($wpinv_options)) { |
|
45 | + $wpinv_options = get_option('wpinv_settings'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // If that fails, don't fetch the default settings to prevent a loop. |
49 | - if ( ! is_array( $wpinv_options ) ) { |
|
49 | + if (!is_array($wpinv_options)) { |
|
50 | 50 | $wpinv_options = array(); |
51 | 51 | } |
52 | 52 | |
@@ -60,13 +60,13 @@ discard block |
||
60 | 60 | * @param mixed $default The default value to use if the setting has not been set. |
61 | 61 | * @return mixed |
62 | 62 | */ |
63 | -function wpinv_get_option( $key = '', $default = false ) { |
|
63 | +function wpinv_get_option($key = '', $default = false) { |
|
64 | 64 | |
65 | 65 | $options = wpinv_get_options(); |
66 | - $value = isset( $options[ $key ] ) ? $options[ $key ] : $default; |
|
67 | - $value = apply_filters( 'wpinv_get_option', $value, $key, $default ); |
|
66 | + $value = isset($options[$key]) ? $options[$key] : $default; |
|
67 | + $value = apply_filters('wpinv_get_option', $value, $key, $default); |
|
68 | 68 | |
69 | - return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default ); |
|
69 | + return apply_filters('wpinv_get_option_' . $key, $value, $key, $default); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * @param array $options the new options. |
76 | 76 | * @return bool |
77 | 77 | */ |
78 | -function wpinv_update_options( $options ) { |
|
78 | +function wpinv_update_options($options) { |
|
79 | 79 | global $wpinv_options; |
80 | 80 | |
81 | 81 | // update the option. |
82 | - if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) { |
|
82 | + if (is_array($options) && update_option('wpinv_settings', $options)) { |
|
83 | 83 | $wpinv_options = $options; |
84 | 84 | return true; |
85 | 85 | } |
@@ -94,24 +94,24 @@ discard block |
||
94 | 94 | * @param mixed $value The setting value. |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | -function wpinv_update_option( $key = '', $value = false ) { |
|
97 | +function wpinv_update_option($key = '', $value = false) { |
|
98 | 98 | |
99 | 99 | // If no key, exit. |
100 | - if ( empty( $key ) ) { |
|
100 | + if (empty($key)) { |
|
101 | 101 | return false; |
102 | 102 | } |
103 | 103 | |
104 | 104 | // Maybe delete the option instead. |
105 | - if ( is_null( $value ) ) { |
|
106 | - return wpinv_delete_option( $key ); |
|
105 | + if (is_null($value)) { |
|
106 | + return wpinv_delete_option($key); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Prepare the new options. |
110 | 110 | $options = wpinv_get_options(); |
111 | - $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key ); |
|
111 | + $options[$key] = apply_filters('wpinv_update_option', $value, $key); |
|
112 | 112 | |
113 | 113 | // Save the new options. |
114 | - return wpinv_update_options( $options ); |
|
114 | + return wpinv_update_options($options); |
|
115 | 115 | |
116 | 116 | } |
117 | 117 | |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * @param string $key the setting key. |
122 | 122 | * @return bool |
123 | 123 | */ |
124 | -function wpinv_delete_option( $key = '' ) { |
|
124 | +function wpinv_delete_option($key = '') { |
|
125 | 125 | |
126 | 126 | // If no key, exit |
127 | - if ( empty( $key ) ) { |
|
127 | + if (empty($key)) { |
|
128 | 128 | return false; |
129 | 129 | } |
130 | 130 | |
131 | 131 | $options = wpinv_get_options(); |
132 | 132 | |
133 | - if ( isset( $options[ $key ] ) ) { |
|
134 | - unset( $options[ $key ] ); |
|
135 | - return wpinv_update_options( $options ); |
|
133 | + if (isset($options[$key])) { |
|
134 | + unset($options[$key]); |
|
135 | + return wpinv_update_options($options); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | return true; |
@@ -144,22 +144,22 @@ discard block |
||
144 | 144 | * |
145 | 145 | */ |
146 | 146 | function wpinv_register_settings() { |
147 | - do_action( 'getpaid_before_register_settings' ); |
|
147 | + do_action('getpaid_before_register_settings'); |
|
148 | 148 | |
149 | 149 | // Loop through all tabs. |
150 | - foreach ( wpinv_get_registered_settings() as $tab => $sections ) { |
|
150 | + foreach (wpinv_get_registered_settings() as $tab => $sections) { |
|
151 | 151 | |
152 | 152 | // In each tab, loop through sections. |
153 | - foreach ( $sections as $section => $settings ) { |
|
153 | + foreach ($sections as $section => $settings) { |
|
154 | 154 | |
155 | 155 | // Check for backwards compatibility |
156 | - $section_tabs = wpinv_get_settings_tab_sections( $tab ); |
|
157 | - if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) { |
|
156 | + $section_tabs = wpinv_get_settings_tab_sections($tab); |
|
157 | + if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) { |
|
158 | 158 | $section = 'main'; |
159 | 159 | $settings = $sections; |
160 | 160 | } |
161 | 161 | |
162 | - do_action( "getpaid_register_{$tab}_{$section}" ); |
|
162 | + do_action("getpaid_register_{$tab}_{$section}"); |
|
163 | 163 | |
164 | 164 | // Register the setting section. |
165 | 165 | add_settings_section( |
@@ -169,20 +169,20 @@ discard block |
||
169 | 169 | 'wpinv_settings_' . $tab . '_' . $section |
170 | 170 | ); |
171 | 171 | |
172 | - foreach ( $settings as $option ) { |
|
173 | - if ( ! empty( $option['id'] ) ) { |
|
174 | - wpinv_register_settings_option( $tab, $section, $option ); |
|
172 | + foreach ($settings as $option) { |
|
173 | + if (!empty($option['id'])) { |
|
174 | + wpinv_register_settings_option($tab, $section, $option); |
|
175 | 175 | } |
176 | 176 | } |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | 180 | // Creates our settings in the options table. |
181 | - register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' ); |
|
181 | + register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize'); |
|
182 | 182 | |
183 | - do_action( 'getpaid_after_register_settings' ); |
|
183 | + do_action('getpaid_after_register_settings'); |
|
184 | 184 | } |
185 | -add_action( 'admin_init', 'wpinv_register_settings' ); |
|
185 | +add_action('admin_init', 'wpinv_register_settings'); |
|
186 | 186 | |
187 | 187 | /** |
188 | 188 | * Register a single settings option. |
@@ -192,49 +192,49 @@ discard block |
||
192 | 192 | * @param string $option |
193 | 193 | * |
194 | 194 | */ |
195 | -function wpinv_register_settings_option( $tab, $section, $option ) { |
|
195 | +function wpinv_register_settings_option($tab, $section, $option) { |
|
196 | 196 | |
197 | - $name = isset( $option['name'] ) ? $option['name'] : ''; |
|
197 | + $name = isset($option['name']) ? $option['name'] : ''; |
|
198 | 198 | $cb = "wpinv_{$option['type']}_callback"; |
199 | 199 | $section = "wpinv_settings_{$tab}_$section"; |
200 | - $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page']; |
|
200 | + $is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page']; |
|
201 | 201 | |
202 | - if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) { |
|
203 | - $tip = wpinv_clean( $option['desc'] ); |
|
202 | + if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) { |
|
203 | + $tip = wpinv_clean($option['desc']); |
|
204 | 204 | $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>"; |
205 | - unset( $option['desc'] ); |
|
205 | + unset($option['desc']); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | // Loop through all tabs. |
209 | 209 | add_settings_field( |
210 | 210 | 'wpinv_settings[' . $option['id'] . ']', |
211 | 211 | $name, |
212 | - function_exists( $cb ) ? $cb : 'wpinv_missing_callback', |
|
212 | + function_exists($cb) ? $cb : 'wpinv_missing_callback', |
|
213 | 213 | $section, |
214 | 214 | $section, |
215 | 215 | array( |
216 | 216 | 'section' => $section, |
217 | - 'id' => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ), |
|
218 | - 'desc' => isset( $option['desc'] ) ? $option['desc'] : '', |
|
217 | + 'id' => isset($option['id']) ? $option['id'] : uniqid('wpinv-'), |
|
218 | + 'desc' => isset($option['desc']) ? $option['desc'] : '', |
|
219 | 219 | 'name' => $name, |
220 | - 'size' => isset( $option['size'] ) ? $option['size'] : null, |
|
221 | - 'options' => isset( $option['options'] ) ? $option['options'] : '', |
|
222 | - 'selected' => isset( $option['selected'] ) ? $option['selected'] : null, |
|
223 | - 'std' => isset( $option['std'] ) ? $option['std'] : '', |
|
224 | - 'min' => isset( $option['min'] ) ? $option['min'] : 0, |
|
225 | - 'max' => isset( $option['max'] ) ? $option['max'] : 999999, |
|
226 | - 'step' => isset( $option['step'] ) ? $option['step'] : 1, |
|
227 | - 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null, |
|
228 | - 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true, |
|
229 | - 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false, |
|
230 | - 'faux' => isset( $option['faux'] ) ? $option['faux'] : false, |
|
231 | - 'onchange' => isset( $option['onchange'] ) ? $option['onchange'] : '', |
|
232 | - 'custom' => isset( $option['custom'] ) ? $option['custom'] : '', |
|
233 | - 'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '', |
|
234 | - 'class' => isset( $option['class'] ) ? $option['class'] : '', |
|
235 | - 'style' => isset( $option['style'] ) ? $option['style'] : '', |
|
236 | - 'cols' => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | - 'rows' => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
220 | + 'size' => isset($option['size']) ? $option['size'] : null, |
|
221 | + 'options' => isset($option['options']) ? $option['options'] : '', |
|
222 | + 'selected' => isset($option['selected']) ? $option['selected'] : null, |
|
223 | + 'std' => isset($option['std']) ? $option['std'] : '', |
|
224 | + 'min' => isset($option['min']) ? $option['min'] : 0, |
|
225 | + 'max' => isset($option['max']) ? $option['max'] : 999999, |
|
226 | + 'step' => isset($option['step']) ? $option['step'] : 1, |
|
227 | + 'placeholder' => isset($option['placeholder']) ? $option['placeholder'] : null, |
|
228 | + 'allow_blank' => isset($option['allow_blank']) ? $option['allow_blank'] : true, |
|
229 | + 'readonly' => isset($option['readonly']) ? $option['readonly'] : false, |
|
230 | + 'faux' => isset($option['faux']) ? $option['faux'] : false, |
|
231 | + 'onchange' => isset($option['onchange']) ? $option['onchange'] : '', |
|
232 | + 'custom' => isset($option['custom']) ? $option['custom'] : '', |
|
233 | + 'default_content' => isset($option['default_content']) ? $option['default_content'] : '', |
|
234 | + 'class' => isset($option['class']) ? $option['class'] : '', |
|
235 | + 'style' => isset($option['style']) ? $option['style'] : '', |
|
236 | + 'cols' => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50, |
|
237 | + 'rows' => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5, |
|
238 | 238 | ) |
239 | 239 | ); |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return array |
247 | 247 | */ |
248 | 248 | function wpinv_get_registered_settings() { |
249 | - return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) ); |
|
249 | + return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings'))); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return array |
256 | 256 | */ |
257 | 257 | function getpaid_get_integration_settings() { |
258 | - return apply_filters( 'getpaid_integration_settings', array() ); |
|
258 | + return apply_filters('getpaid_integration_settings', array()); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -263,153 +263,153 @@ discard block |
||
263 | 263 | * |
264 | 264 | * @return array |
265 | 265 | */ |
266 | -function wpinv_settings_sanitize( $input = array() ) { |
|
266 | +function wpinv_settings_sanitize($input = array()) { |
|
267 | 267 | |
268 | 268 | $wpinv_options = wpinv_get_options(); |
269 | 269 | $raw_referrer = wp_get_raw_referer(); |
270 | 270 | |
271 | - if ( empty( $raw_referrer ) ) { |
|
272 | - return array_merge( $wpinv_options, $input ); |
|
271 | + if (empty($raw_referrer)) { |
|
272 | + return array_merge($wpinv_options, $input); |
|
273 | 273 | } |
274 | 274 | |
275 | - wp_parse_str( $raw_referrer, $referrer ); |
|
275 | + wp_parse_str($raw_referrer, $referrer); |
|
276 | 276 | |
277 | - if ( in_array( 'gp-setup', $referrer ) ) { |
|
278 | - return array_merge( $wpinv_options, $input ); |
|
277 | + if (in_array('gp-setup', $referrer)) { |
|
278 | + return array_merge($wpinv_options, $input); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | $settings = wpinv_get_registered_settings(); |
282 | - $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general'; |
|
283 | - $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main'; |
|
282 | + $tab = isset($referrer['tab']) ? $referrer['tab'] : 'general'; |
|
283 | + $section = isset($referrer['section']) ? $referrer['section'] : 'main'; |
|
284 | 284 | |
285 | 285 | $input = $input ? $input : array(); |
286 | - $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input ); |
|
287 | - $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input ); |
|
286 | + $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input); |
|
287 | + $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input); |
|
288 | 288 | |
289 | 289 | // Loop through each setting being saved and pass it through a sanitization filter |
290 | - foreach ( $input as $key => $value ) { |
|
290 | + foreach ($input as $key => $value) { |
|
291 | 291 | |
292 | 292 | // Get the setting type (checkbox, select, etc) |
293 | - $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false; |
|
293 | + $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false; |
|
294 | 294 | |
295 | - if ( $type ) { |
|
295 | + if ($type) { |
|
296 | 296 | // Field type specific filter |
297 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key ); |
|
297 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | // General filter |
301 | - $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key ); |
|
301 | + $input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key); |
|
302 | 302 | |
303 | 303 | // Key specific filter. |
304 | - $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] ); |
|
304 | + $input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | // Loop through the whitelist and unset any that are empty for the tab being saved |
308 | - $main_settings = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections |
|
309 | - $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array(); |
|
308 | + $main_settings = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections |
|
309 | + $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array(); |
|
310 | 310 | |
311 | - $found_settings = array_merge( $main_settings, $section_settings ); |
|
311 | + $found_settings = array_merge($main_settings, $section_settings); |
|
312 | 312 | |
313 | - if ( ! empty( $found_settings ) ) { |
|
314 | - foreach ( $found_settings as $key => $value ) { |
|
313 | + if (!empty($found_settings)) { |
|
314 | + foreach ($found_settings as $key => $value) { |
|
315 | 315 | |
316 | 316 | // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work |
317 | - if ( is_numeric( $key ) ) { |
|
317 | + if (is_numeric($key)) { |
|
318 | 318 | $key = $value['id']; |
319 | 319 | } |
320 | 320 | |
321 | - if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) { |
|
322 | - unset( $wpinv_options[ $key ] ); |
|
321 | + if (!isset($input[$key]) && isset($wpinv_options[$key])) { |
|
322 | + unset($wpinv_options[$key]); |
|
323 | 323 | } |
324 | 324 | } |
325 | 325 | } |
326 | 326 | |
327 | 327 | // Merge our new settings with the existing |
328 | - $output = array_merge( $wpinv_options, $input ); |
|
328 | + $output = array_merge($wpinv_options, $input); |
|
329 | 329 | |
330 | - add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' ); |
|
330 | + add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated'); |
|
331 | 331 | |
332 | 332 | return $output; |
333 | 333 | } |
334 | -add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 ); |
|
335 | -add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' ); |
|
334 | +add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1); |
|
335 | +add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount'); |
|
336 | 336 | |
337 | -function wpinv_settings_sanitize_tax_rates( $input ) { |
|
338 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
337 | +function wpinv_settings_sanitize_tax_rates($input) { |
|
338 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
339 | 339 | return $input; |
340 | 340 | } |
341 | 341 | |
342 | - $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array(); |
|
342 | + $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array(); |
|
343 | 343 | $tax_rates = array(); |
344 | 344 | |
345 | - foreach ( $new_rates as $rate ) { |
|
345 | + foreach ($new_rates as $rate) { |
|
346 | 346 | |
347 | - $rate['rate'] = wpinv_sanitize_amount( $rate['rate'] ); |
|
348 | - $rate['name'] = sanitize_text_field( $rate['name'] ); |
|
349 | - $rate['state'] = sanitize_text_field( $rate['state'] ); |
|
350 | - $rate['country'] = sanitize_text_field( $rate['country'] ); |
|
351 | - $rate['global'] = empty( $rate['state'] ); |
|
347 | + $rate['rate'] = wpinv_sanitize_amount($rate['rate']); |
|
348 | + $rate['name'] = sanitize_text_field($rate['name']); |
|
349 | + $rate['state'] = sanitize_text_field($rate['state']); |
|
350 | + $rate['country'] = sanitize_text_field($rate['country']); |
|
351 | + $rate['global'] = empty($rate['state']); |
|
352 | 352 | $tax_rates[] = $rate; |
353 | 353 | |
354 | 354 | } |
355 | 355 | |
356 | - update_option( 'wpinv_tax_rates', $tax_rates ); |
|
356 | + update_option('wpinv_tax_rates', $tax_rates); |
|
357 | 357 | |
358 | 358 | return $input; |
359 | 359 | } |
360 | -add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' ); |
|
360 | +add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates'); |
|
361 | 361 | |
362 | -function wpinv_settings_sanitize_tax_rules( $input ) { |
|
363 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
362 | +function wpinv_settings_sanitize_tax_rules($input) { |
|
363 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
364 | 364 | return $input; |
365 | 365 | } |
366 | 366 | |
367 | - if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) { |
|
367 | + if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) { |
|
368 | 368 | return $input; |
369 | 369 | } |
370 | 370 | |
371 | - $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array(); |
|
371 | + $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array(); |
|
372 | 372 | $tax_rules = array(); |
373 | 373 | |
374 | - foreach ( $new_rules as $rule ) { |
|
374 | + foreach ($new_rules as $rule) { |
|
375 | 375 | |
376 | - $rule['key'] = sanitize_title_with_dashes( $rule['key'] ); |
|
377 | - $rule['label'] = sanitize_text_field( $rule['label'] ); |
|
378 | - $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] ); |
|
376 | + $rule['key'] = sanitize_title_with_dashes($rule['key']); |
|
377 | + $rule['label'] = sanitize_text_field($rule['label']); |
|
378 | + $rule['tax_base'] = sanitize_text_field($rule['tax_base']); |
|
379 | 379 | $tax_rules[] = $rule; |
380 | 380 | |
381 | 381 | } |
382 | 382 | |
383 | - update_option( 'wpinv_tax_rules', $tax_rules ); |
|
383 | + update_option('wpinv_tax_rules', $tax_rules); |
|
384 | 384 | |
385 | 385 | return $input; |
386 | 386 | } |
387 | -add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' ); |
|
387 | +add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules'); |
|
388 | 388 | |
389 | 389 | function wpinv_get_settings_tabs() { |
390 | 390 | $tabs = array(); |
391 | - $tabs['general'] = __( 'General', 'invoicing' ); |
|
392 | - $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' ); |
|
393 | - $tabs['taxes'] = __( 'Taxes', 'invoicing' ); |
|
394 | - $tabs['emails'] = __( 'Emails', 'invoicing' ); |
|
391 | + $tabs['general'] = __('General', 'invoicing'); |
|
392 | + $tabs['gateways'] = __('Payment Gateways', 'invoicing'); |
|
393 | + $tabs['taxes'] = __('Taxes', 'invoicing'); |
|
394 | + $tabs['emails'] = __('Emails', 'invoicing'); |
|
395 | 395 | |
396 | - if ( count( getpaid_get_integration_settings() ) > 0 ) { |
|
397 | - $tabs['integrations'] = __( 'Integrations', 'invoicing' ); |
|
396 | + if (count(getpaid_get_integration_settings()) > 0) { |
|
397 | + $tabs['integrations'] = __('Integrations', 'invoicing'); |
|
398 | 398 | } |
399 | 399 | |
400 | - $tabs['privacy'] = __( 'Privacy', 'invoicing' ); |
|
401 | - $tabs['misc'] = __( 'Misc', 'invoicing' ); |
|
402 | - $tabs['tools'] = __( 'Tools', 'invoicing' ); |
|
400 | + $tabs['privacy'] = __('Privacy', 'invoicing'); |
|
401 | + $tabs['misc'] = __('Misc', 'invoicing'); |
|
402 | + $tabs['tools'] = __('Tools', 'invoicing'); |
|
403 | 403 | |
404 | - return apply_filters( 'wpinv_settings_tabs', $tabs ); |
|
404 | + return apply_filters('wpinv_settings_tabs', $tabs); |
|
405 | 405 | } |
406 | 406 | |
407 | -function wpinv_get_settings_tab_sections( $tab = false ) { |
|
407 | +function wpinv_get_settings_tab_sections($tab = false) { |
|
408 | 408 | $tabs = false; |
409 | 409 | $sections = wpinv_get_registered_settings_sections(); |
410 | 410 | |
411 | - if ( $tab && ! empty( $sections[ $tab ] ) ) { |
|
412 | - $tabs = $sections[ $tab ]; |
|
411 | + if ($tab && !empty($sections[$tab])) { |
|
412 | + $tabs = $sections[$tab]; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | return $tabs; |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | function wpinv_get_registered_settings_sections() { |
419 | 419 | static $sections = false; |
420 | 420 | |
421 | - if ( false !== $sections ) { |
|
421 | + if (false !== $sections) { |
|
422 | 422 | return $sections; |
423 | 423 | } |
424 | 424 | |
@@ -426,90 +426,90 @@ discard block |
||
426 | 426 | 'general' => apply_filters( |
427 | 427 | 'wpinv_settings_sections_general', |
428 | 428 | array( |
429 | - 'main' => __( 'General Settings', 'invoicing' ), |
|
430 | - 'page_section' => __( 'Page Settings', 'invoicing' ), |
|
431 | - 'currency_section' => __( 'Currency Settings', 'invoicing' ), |
|
432 | - 'labels' => __( 'Label Texts', 'invoicing' ), |
|
429 | + 'main' => __('General Settings', 'invoicing'), |
|
430 | + 'page_section' => __('Page Settings', 'invoicing'), |
|
431 | + 'currency_section' => __('Currency Settings', 'invoicing'), |
|
432 | + 'labels' => __('Label Texts', 'invoicing'), |
|
433 | 433 | ) |
434 | 434 | ), |
435 | 435 | 'gateways' => apply_filters( |
436 | 436 | 'wpinv_settings_sections_gateways', |
437 | 437 | array( |
438 | - 'main' => __( 'Gateway Settings', 'invoicing' ), |
|
438 | + 'main' => __('Gateway Settings', 'invoicing'), |
|
439 | 439 | ) |
440 | 440 | ), |
441 | 441 | 'taxes' => apply_filters( |
442 | 442 | 'wpinv_settings_sections_taxes', |
443 | 443 | array( |
444 | - 'main' => __( 'Tax Settings', 'invoicing' ), |
|
445 | - 'rules' => __( 'Tax Rules', 'invoicing' ), |
|
446 | - 'rates' => __( 'Tax Rates', 'invoicing' ), |
|
447 | - 'vat' => __( 'EU VAT Settings', 'invoicing' ), |
|
444 | + 'main' => __('Tax Settings', 'invoicing'), |
|
445 | + 'rules' => __('Tax Rules', 'invoicing'), |
|
446 | + 'rates' => __('Tax Rates', 'invoicing'), |
|
447 | + 'vat' => __('EU VAT Settings', 'invoicing'), |
|
448 | 448 | ) |
449 | 449 | ), |
450 | 450 | 'emails' => apply_filters( |
451 | 451 | 'wpinv_settings_sections_emails', |
452 | 452 | array( |
453 | - 'main' => __( 'Email Settings', 'invoicing' ), |
|
453 | + 'main' => __('Email Settings', 'invoicing'), |
|
454 | 454 | ) |
455 | 455 | ), |
456 | 456 | |
457 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ), |
|
457 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'), |
|
458 | 458 | |
459 | 459 | 'privacy' => apply_filters( |
460 | 460 | 'wpinv_settings_sections_privacy', |
461 | 461 | array( |
462 | - 'main' => __( 'Privacy policy', 'invoicing' ), |
|
462 | + 'main' => __('Privacy policy', 'invoicing'), |
|
463 | 463 | ) |
464 | 464 | ), |
465 | 465 | 'misc' => apply_filters( |
466 | 466 | 'wpinv_settings_sections_misc', |
467 | 467 | array( |
468 | - 'main' => __( 'Miscellaneous', 'invoicing' ), |
|
469 | - 'custom-css' => __( 'Custom CSS', 'invoicing' ), |
|
468 | + 'main' => __('Miscellaneous', 'invoicing'), |
|
469 | + 'custom-css' => __('Custom CSS', 'invoicing'), |
|
470 | 470 | ) |
471 | 471 | ), |
472 | 472 | 'tools' => apply_filters( |
473 | 473 | 'wpinv_settings_sections_tools', |
474 | 474 | array( |
475 | - 'main' => __( 'Diagnostic Tools', 'invoicing' ), |
|
475 | + 'main' => __('Diagnostic Tools', 'invoicing'), |
|
476 | 476 | ) |
477 | 477 | ), |
478 | 478 | ); |
479 | 479 | |
480 | - $sections = apply_filters( 'wpinv_settings_sections', $sections ); |
|
480 | + $sections = apply_filters('wpinv_settings_sections', $sections); |
|
481 | 481 | |
482 | 482 | return $sections; |
483 | 483 | } |
484 | 484 | |
485 | -function wpinv_get_pages( $with_slug = false, $default_label = null ) { |
|
485 | +function wpinv_get_pages($with_slug = false, $default_label = null) { |
|
486 | 486 | global $wpdb, $gp_tmpl_page_options; |
487 | 487 | |
488 | 488 | // Same function, lets not call it twice if we don't need to. |
489 | - if ( function_exists( 'sd_template_page_options' ) ) { |
|
489 | + if (function_exists('sd_template_page_options')) { |
|
490 | 490 | $args = array( |
491 | 491 | 'with_slug' => $with_slug, |
492 | 492 | 'default_label' => $default_label |
493 | 493 | ); |
494 | 494 | |
495 | - return sd_template_page_options( $args ); |
|
495 | + return sd_template_page_options($args); |
|
496 | 496 | } |
497 | 497 | |
498 | - if ( ! empty( $gp_tmpl_page_options ) ) { |
|
498 | + if (!empty($gp_tmpl_page_options)) { |
|
499 | 499 | return $gp_tmpl_page_options; |
500 | 500 | } |
501 | 501 | |
502 | 502 | $exclude_pages = array(); |
503 | - if ( $page_on_front = get_option( 'page_on_front' ) ) { |
|
503 | + if ($page_on_front = get_option('page_on_front')) { |
|
504 | 504 | $exclude_pages[] = $page_on_front; |
505 | 505 | } |
506 | 506 | |
507 | - if ( $page_for_posts = get_option( 'page_for_posts' ) ) { |
|
507 | + if ($page_for_posts = get_option('page_for_posts')) { |
|
508 | 508 | $exclude_pages[] = $page_for_posts; |
509 | 509 | } |
510 | 510 | |
511 | 511 | $exclude_pages_placeholders = ''; |
512 | - if ( ! empty( $exclude_pages ) ) { |
|
512 | + if (!empty($exclude_pages)) { |
|
513 | 513 | // Sanitize the array of excluded pages and implode it for the SQL query |
514 | 514 | $exclude_pages_placeholders = implode(',', array_fill(0, count($exclude_pages), '%d')); |
515 | 515 | } |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | "; |
524 | 524 | |
525 | 525 | // Add the exclusion if there are pages to exclude |
526 | - if ( ! empty( $exclude_pages ) ) { |
|
526 | + if (!empty($exclude_pages)) { |
|
527 | 527 | $sql .= " AND ID NOT IN ($exclude_pages_placeholders)"; |
528 | 528 | } |
529 | 529 | |
@@ -531,18 +531,18 @@ discard block |
||
531 | 531 | $sql .= " ORDER BY post_title ASC"; |
532 | 532 | |
533 | 533 | // Add a sanity limit |
534 | - $limit = absint( apply_filters('wpinv_get_pages_limit',500) ); |
|
534 | + $limit = absint(apply_filters('wpinv_get_pages_limit', 500)); |
|
535 | 535 | $sql .= " LIMIT " . absint($limit); |
536 | 536 | |
537 | 537 | // Prepare the SQL query to include the excluded pages only if we have placeholders |
538 | - $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql ); |
|
538 | + $pages = $exclude_pages_placeholders ? $wpdb->get_results($wpdb->prepare($sql, ...$exclude_pages)) : $wpdb->get_results($sql); |
|
539 | 539 | |
540 | 540 | $pages_options = array(); |
541 | 541 | |
542 | - if ( $pages ) { |
|
543 | - foreach ( $pages as $page ) { |
|
542 | + if ($pages) { |
|
543 | + foreach ($pages as $page) { |
|
544 | 544 | $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
545 | - $pages_options[ $page->ID ] = $title; |
|
545 | + $pages_options[$page->ID] = $title; |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | |
@@ -550,162 +550,162 @@ discard block |
||
550 | 550 | |
551 | 551 | $gp_tmpl_page_options = $pages_options; |
552 | 552 | |
553 | - if ( $default_label !== null && $default_label !== false ) { |
|
554 | - $pages_options = array( '' => $default_label ) + $pages_options; // Blank option |
|
553 | + if ($default_label !== null && $default_label !== false) { |
|
554 | + $pages_options = array('' => $default_label) + $pages_options; // Blank option |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | return $pages_options; |
558 | 558 | } |
559 | 559 | |
560 | -function wpinv_header_callback( $args ) { |
|
561 | - if ( ! empty( $args['desc'] ) ) { |
|
562 | - echo wp_kses_post( $args['desc'] ); |
|
560 | +function wpinv_header_callback($args) { |
|
561 | + if (!empty($args['desc'])) { |
|
562 | + echo wp_kses_post($args['desc']); |
|
563 | 563 | } |
564 | 564 | } |
565 | 565 | |
566 | -function wpinv_hidden_callback( $args ) { |
|
566 | +function wpinv_hidden_callback($args) { |
|
567 | 567 | |
568 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
569 | - $value = wpinv_get_option( $args['id'], $std ); |
|
568 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
569 | + $value = wpinv_get_option($args['id'], $std); |
|
570 | 570 | |
571 | - if ( isset( $args['set_value'] ) ) { |
|
571 | + if (isset($args['set_value'])) { |
|
572 | 572 | $value = $args['set_value']; |
573 | 573 | } |
574 | 574 | |
575 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
575 | + if (isset($args['faux']) && true === $args['faux']) { |
|
576 | 576 | $args['readonly'] = true; |
577 | - $name = ''; |
|
577 | + $name = ''; |
|
578 | 578 | } else { |
579 | - $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']'; |
|
579 | + $name = 'wpinv_settings[' . esc_attr($args['id']) . ']'; |
|
580 | 580 | } |
581 | 581 | |
582 | - echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
582 | + echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />'; |
|
583 | 583 | |
584 | 584 | } |
585 | 585 | |
586 | 586 | /** |
587 | 587 | * Displays a checkbox settings callback. |
588 | 588 | */ |
589 | -function wpinv_checkbox_callback( $args ) { |
|
589 | +function wpinv_checkbox_callback($args) { |
|
590 | 590 | |
591 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
592 | - $std = wpinv_get_option( $args['id'], $std ); |
|
593 | - $id = esc_attr( $args['id'] ); |
|
591 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
592 | + $std = wpinv_get_option($args['id'], $std); |
|
593 | + $id = esc_attr($args['id']); |
|
594 | 594 | |
595 | - getpaid_hidden_field( "wpinv_settings[$id]", '0' ); |
|
595 | + getpaid_hidden_field("wpinv_settings[$id]", '0'); |
|
596 | 596 | ?> |
597 | 597 | <label> |
598 | - <input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" /> |
|
599 | - <?php echo wp_kses_post( $args['desc'] ); ?> |
|
598 | + <input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" /> |
|
599 | + <?php echo wp_kses_post($args['desc']); ?> |
|
600 | 600 | </label> |
601 | 601 | <?php |
602 | 602 | } |
603 | 603 | |
604 | -function wpinv_multicheck_callback( $args ) { |
|
604 | +function wpinv_multicheck_callback($args) { |
|
605 | 605 | |
606 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
607 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
606 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
607 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
608 | 608 | |
609 | - if ( ! empty( $args['options'] ) ) { |
|
609 | + if (!empty($args['options'])) { |
|
610 | 610 | |
611 | - $std = isset( $args['std'] ) ? $args['std'] : array(); |
|
612 | - $value = wpinv_get_option( $args['id'], $std ); |
|
611 | + $std = isset($args['std']) ? $args['std'] : array(); |
|
612 | + $value = wpinv_get_option($args['id'], $std); |
|
613 | 613 | |
614 | - echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">'; |
|
615 | - foreach ( $args['options'] as $key => $option ) : |
|
616 | - $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) ); |
|
617 | - if ( in_array( $sanitize_key, $value ) ) { |
|
614 | + echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">'; |
|
615 | + foreach ($args['options'] as $key => $option) : |
|
616 | + $sanitize_key = esc_attr(wpinv_sanitize_key($key)); |
|
617 | + if (in_array($sanitize_key, $value)) { |
|
618 | 618 | $enabled = $sanitize_key; |
619 | 619 | } else { |
620 | 620 | $enabled = null; |
621 | 621 | } |
622 | - echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
623 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>'; |
|
622 | + echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/> '; |
|
623 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>'; |
|
624 | 624 | endforeach; |
625 | 625 | echo '</div>'; |
626 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
626 | + echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>'; |
|
627 | 627 | } |
628 | 628 | } |
629 | 629 | |
630 | -function wpinv_payment_icons_callback( $args ) { |
|
630 | +function wpinv_payment_icons_callback($args) { |
|
631 | 631 | |
632 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
633 | - $value = wpinv_get_option( $args['id'], false ); |
|
632 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
633 | + $value = wpinv_get_option($args['id'], false); |
|
634 | 634 | |
635 | - if ( ! empty( $args['options'] ) ) { |
|
636 | - foreach ( $args['options'] as $key => $option ) { |
|
637 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
635 | + if (!empty($args['options'])) { |
|
636 | + foreach ($args['options'] as $key => $option) { |
|
637 | + $sanitize_key = wpinv_sanitize_key($key); |
|
638 | 638 | |
639 | - if ( empty( $value ) ) { |
|
639 | + if (empty($value)) { |
|
640 | 640 | $enabled = $option; |
641 | 641 | } else { |
642 | 642 | $enabled = null; |
643 | 643 | } |
644 | 644 | |
645 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
645 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
646 | 646 | |
647 | - echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
647 | + echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/> '; |
|
648 | 648 | |
649 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
650 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
649 | + if (wpinv_string_is_image_url($key)) { |
|
650 | + echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
651 | 651 | } else { |
652 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
652 | + $card = strtolower(str_replace(' ', '', $option)); |
|
653 | 653 | |
654 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
655 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
654 | + if (has_filter('wpinv_accepted_payment_' . $card . '_image')) { |
|
655 | + $image = apply_filters('wpinv_accepted_payment_' . $card . '_image', ''); |
|
656 | 656 | } else { |
657 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
657 | + $image = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false); |
|
658 | 658 | $content_dir = WP_CONTENT_DIR; |
659 | 659 | |
660 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
660 | + if (function_exists('wp_normalize_path')) { |
|
661 | 661 | // Replaces backslashes with forward slashes for Windows systems |
662 | - $image = wp_normalize_path( $image ); |
|
663 | - $content_dir = wp_normalize_path( $content_dir ); |
|
662 | + $image = wp_normalize_path($image); |
|
663 | + $content_dir = wp_normalize_path($content_dir); |
|
664 | 664 | } |
665 | 665 | |
666 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
666 | + $image = str_replace($content_dir, content_url(), $image); |
|
667 | 667 | } |
668 | 668 | |
669 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
669 | + echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
670 | 670 | } |
671 | - echo wp_kses_post( $option ) . '</label>'; |
|
671 | + echo wp_kses_post($option) . '</label>'; |
|
672 | 672 | } |
673 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
673 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>'; |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
678 | 678 | * Displays a radio settings field. |
679 | 679 | */ |
680 | -function wpinv_radio_callback( $args ) { |
|
680 | +function wpinv_radio_callback($args) { |
|
681 | 681 | |
682 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
683 | - $std = wpinv_get_option( $args['id'], $std ); |
|
682 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
683 | + $std = wpinv_get_option($args['id'], $std); |
|
684 | 684 | ?> |
685 | 685 | <fieldset> |
686 | - <ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;"> |
|
687 | - <?php foreach ( $args['options'] as $key => $option ) : ?> |
|
686 | + <ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;"> |
|
687 | + <?php foreach ($args['options'] as $key => $option) : ?> |
|
688 | 688 | <li> |
689 | 689 | <label> |
690 | - <input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio"> |
|
691 | - <?php echo wp_kses_post( $option ); ?> |
|
690 | + <input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio"> |
|
691 | + <?php echo wp_kses_post($option); ?> |
|
692 | 692 | </label> |
693 | 693 | </li> |
694 | 694 | <?php endforeach; ?> |
695 | 695 | </ul> |
696 | 696 | </fieldset> |
697 | 697 | <?php |
698 | - getpaid_settings_description_callback( $args ); |
|
698 | + getpaid_settings_description_callback($args); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Displays a description if available. |
703 | 703 | */ |
704 | -function getpaid_settings_description_callback( $args ) { |
|
704 | +function getpaid_settings_description_callback($args) { |
|
705 | 705 | |
706 | - if ( ! empty( $args['desc'] ) ) { |
|
706 | + if (!empty($args['desc'])) { |
|
707 | 707 | $description = $args['desc']; |
708 | - echo wp_kses_post( "<p class='description'>$description</p>" ); |
|
708 | + echo wp_kses_post("<p class='description'>$description</p>"); |
|
709 | 709 | } |
710 | 710 | |
711 | 711 | } |
@@ -720,35 +720,35 @@ discard block |
||
720 | 720 | </tr> |
721 | 721 | <tr class="bsui"> |
722 | 722 | <td colspan="2" class="p-0"> |
723 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?> |
|
723 | + <?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?> |
|
724 | 724 | |
725 | 725 | <?php |
726 | 726 | } |
727 | 727 | |
728 | -function wpinv_gateway_select_callback( $args ) { |
|
728 | +function wpinv_gateway_select_callback($args) { |
|
729 | 729 | |
730 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
731 | - $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : ''; |
|
732 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
733 | - $value = wpinv_get_option( $args['id'], $std ); |
|
730 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
731 | + $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : ''; |
|
732 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
733 | + $value = wpinv_get_option($args['id'], $std); |
|
734 | 734 | |
735 | - echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >'; |
|
735 | + echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >'; |
|
736 | 736 | |
737 | - foreach ( $args['options'] as $key => $option ) : |
|
737 | + foreach ($args['options'] as $key => $option) : |
|
738 | 738 | |
739 | - echo '<option value="' . esc_attr( $key ) . '" '; |
|
739 | + echo '<option value="' . esc_attr($key) . '" '; |
|
740 | 740 | |
741 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
742 | - selected( $key, $args['selected'] ); |
|
741 | + if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) { |
|
742 | + selected($key, $args['selected']); |
|
743 | 743 | } else { |
744 | - selected( $key, $value ); |
|
744 | + selected($key, $value); |
|
745 | 745 | } |
746 | 746 | |
747 | - echo '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
747 | + echo '>' . esc_html($option['admin_label']) . '</option>'; |
|
748 | 748 | endforeach; |
749 | 749 | |
750 | 750 | echo '</select>'; |
751 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
751 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
752 | 752 | } |
753 | 753 | |
754 | 754 | /** |
@@ -757,16 +757,16 @@ discard block |
||
757 | 757 | * @param array $args |
758 | 758 | * @return string |
759 | 759 | */ |
760 | -function wpinv_settings_attrs_helper( $args ) { |
|
760 | +function wpinv_settings_attrs_helper($args) { |
|
761 | 761 | |
762 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
763 | - $id = esc_attr( $args['id'] ); |
|
764 | - $value = is_scalar( $value ) ? $value : ''; |
|
762 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
763 | + $id = esc_attr($args['id']); |
|
764 | + $value = is_scalar($value) ? $value : ''; |
|
765 | 765 | |
766 | 766 | $attrs = array( |
767 | - 'name' => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]", |
|
768 | - 'readonly' => ! empty( $args['faux'] ), |
|
769 | - 'value' => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ), |
|
767 | + 'name' => !empty($args['faux']) ? false : "wpinv_settings[$id]", |
|
768 | + 'readonly' => !empty($args['faux']), |
|
769 | + 'value' => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value), |
|
770 | 770 | 'id' => 'wpinv-settings-' . $args['id'], |
771 | 771 | 'style' => $args['style'], |
772 | 772 | 'class' => $args['class'], |
@@ -774,20 +774,20 @@ discard block |
||
774 | 774 | 'data-placeholder' => $args['placeholder'], |
775 | 775 | ); |
776 | 776 | |
777 | - if ( ! empty( $args['onchange'] ) ) { |
|
777 | + if (!empty($args['onchange'])) { |
|
778 | 778 | $attrs['onchange'] = $args['onchange']; |
779 | 779 | } |
780 | 780 | |
781 | - foreach ( $attrs as $key => $value ) { |
|
781 | + foreach ($attrs as $key => $value) { |
|
782 | 782 | |
783 | - if ( false === $value ) { |
|
783 | + if (false === $value) { |
|
784 | 784 | continue; |
785 | 785 | } |
786 | 786 | |
787 | - if ( true === $value ) { |
|
788 | - echo ' ' . esc_attr( $key ); |
|
787 | + if (true === $value) { |
|
788 | + echo ' ' . esc_attr($key); |
|
789 | 789 | } else { |
790 | - echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"'; |
|
790 | + echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"'; |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | } |
@@ -797,12 +797,12 @@ discard block |
||
797 | 797 | /** |
798 | 798 | * Displays a text input settings callback. |
799 | 799 | */ |
800 | -function wpinv_text_callback( $args ) { |
|
800 | +function wpinv_text_callback($args) { |
|
801 | 801 | |
802 | 802 | ?> |
803 | 803 | <label style="width: 100%;"> |
804 | - <input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
805 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
804 | + <input type="text" <?php wpinv_settings_attrs_helper($args); ?>> |
|
805 | + <?php getpaid_settings_description_callback($args); ?> |
|
806 | 806 | </label> |
807 | 807 | <?php |
808 | 808 | |
@@ -811,174 +811,174 @@ discard block |
||
811 | 811 | /** |
812 | 812 | * Displays a number input settings callback. |
813 | 813 | */ |
814 | -function wpinv_number_callback( $args ) { |
|
814 | +function wpinv_number_callback($args) { |
|
815 | 815 | |
816 | 816 | ?> |
817 | 817 | <label style="width: 100%;"> |
818 | - <input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>> |
|
819 | - <?php getpaid_settings_description_callback( $args ); ?> |
|
818 | + <input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>> |
|
819 | + <?php getpaid_settings_description_callback($args); ?> |
|
820 | 820 | </label> |
821 | 821 | <?php |
822 | 822 | |
823 | 823 | } |
824 | 824 | |
825 | -function wpinv_textarea_callback( $args ) { |
|
825 | +function wpinv_textarea_callback($args) { |
|
826 | 826 | |
827 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
828 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
829 | - $value = wpinv_get_option( $args['id'], $std ); |
|
827 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
828 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
829 | + $value = wpinv_get_option($args['id'], $std); |
|
830 | 830 | |
831 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
832 | - $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
|
831 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
832 | + $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text'; |
|
833 | 833 | |
834 | - echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
835 | - echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
834 | + echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
835 | + echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
836 | 836 | |
837 | 837 | } |
838 | 838 | |
839 | -function wpinv_password_callback( $args ) { |
|
839 | +function wpinv_password_callback($args) { |
|
840 | 840 | |
841 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
842 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
843 | - $value = wpinv_get_option( $args['id'], $std ); |
|
841 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
842 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
843 | + $value = wpinv_get_option($args['id'], $std); |
|
844 | 844 | |
845 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
846 | - echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
847 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
845 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
846 | + echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>'; |
|
847 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
848 | 848 | |
849 | 849 | } |
850 | 850 | |
851 | -function wpinv_missing_callback( $args ) { |
|
851 | +function wpinv_missing_callback($args) { |
|
852 | 852 | printf( |
853 | - esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
854 | - '<strong>' . esc_html( $args['id'] ) . '</strong>' |
|
853 | + esc_html__('The callback function used for the %s setting is missing.', 'invoicing'), |
|
854 | + '<strong>' . esc_html($args['id']) . '</strong>' |
|
855 | 855 | ); |
856 | 856 | } |
857 | 857 | |
858 | 858 | /** |
859 | 859 | * Displays a number input settings callback. |
860 | 860 | */ |
861 | -function wpinv_select_callback( $args ) { |
|
861 | +function wpinv_select_callback($args) { |
|
862 | 862 | |
863 | - $desc = wp_kses_post( $args['desc'] ); |
|
864 | - $desc = empty( $desc ) ? '' : "<p class='description'>$desc</p>"; |
|
865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
866 | - $value = wpinv_get_option( $args['id'], $value ); |
|
867 | - $rand = uniqid( 'random_id' ); |
|
863 | + $desc = wp_kses_post($args['desc']); |
|
864 | + $desc = empty($desc) ? '' : "<p class='description'>$desc</p>"; |
|
865 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
866 | + $value = wpinv_get_option($args['id'], $value); |
|
867 | + $rand = uniqid('random_id'); |
|
868 | 868 | |
869 | 869 | ?> |
870 | 870 | <label style="width: 100%;"> |
871 | - <select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true"> |
|
872 | - <?php foreach ( $args['options'] as $option => $name ) : ?> |
|
873 | - <option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option> |
|
871 | + <select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true"> |
|
872 | + <?php foreach ($args['options'] as $option => $name) : ?> |
|
873 | + <option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option> |
|
874 | 874 | <?php endforeach; ?> |
875 | 875 | </select> |
876 | 876 | |
877 | - <?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?> |
|
878 | - <a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a> |
|
877 | + <?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?> |
|
878 | + <a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a> |
|
879 | 879 | <?php endif; ?> |
880 | 880 | |
881 | - <?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?> |
|
882 | - <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a> |
|
883 | - <div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'> |
|
881 | + <?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?> |
|
882 | + <a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a> |
|
883 | + <div id='<?php echo esc_attr($rand); ?>' style='display:none;'> |
|
884 | 884 | <div> |
885 | - <h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3> |
|
886 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea> |
|
887 | - <h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3> |
|
888 | - <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea> |
|
885 | + <h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3> |
|
886 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea> |
|
887 | + <h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3> |
|
888 | + <textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea> |
|
889 | 889 | </div> |
890 | 890 | </div> |
891 | 891 | <?php endif; ?> |
892 | 892 | |
893 | - <?php echo wp_kses_post( $desc ); ?> |
|
893 | + <?php echo wp_kses_post($desc); ?> |
|
894 | 894 | </label> |
895 | 895 | <?php |
896 | 896 | |
897 | 897 | } |
898 | 898 | |
899 | -function wpinv_color_select_callback( $args ) { |
|
899 | +function wpinv_color_select_callback($args) { |
|
900 | 900 | |
901 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
902 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
903 | - $value = wpinv_get_option( $args['id'], $std ); |
|
901 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
902 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
903 | + $value = wpinv_get_option($args['id'], $std); |
|
904 | 904 | |
905 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
905 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>'; |
|
906 | 906 | |
907 | - foreach ( $args['options'] as $option => $color ) { |
|
908 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>'; |
|
907 | + foreach ($args['options'] as $option => $color) { |
|
908 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>'; |
|
909 | 909 | } |
910 | 910 | |
911 | 911 | echo '</select>'; |
912 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
912 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | -function wpinv_rich_editor_callback( $args ) { |
|
916 | +function wpinv_rich_editor_callback($args) { |
|
917 | 917 | global $wp_version; |
918 | 918 | |
919 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
919 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
920 | 920 | |
921 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
922 | - $value = wpinv_get_option( $args['id'], $std ); |
|
921 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
922 | + $value = wpinv_get_option($args['id'], $std); |
|
923 | 923 | |
924 | - if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
924 | + if (!empty($args['allow_blank']) && empty($value)) { |
|
925 | 925 | $value = $std; |
926 | 926 | } |
927 | 927 | |
928 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
928 | + $rows = isset($args['size']) ? $args['size'] : 20; |
|
929 | 929 | |
930 | 930 | echo '<div class="getpaid-settings-editor-input">'; |
931 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
931 | + if ($wp_version >= 3.3 && function_exists('wp_editor')) { |
|
932 | 932 | wp_editor( |
933 | - stripslashes( $value ), |
|
934 | - 'wpinv_settings_' . esc_attr( $args['id'] ), |
|
933 | + stripslashes($value), |
|
934 | + 'wpinv_settings_' . esc_attr($args['id']), |
|
935 | 935 | array( |
936 | - 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', |
|
937 | - 'textarea_rows' => absint( $rows ), |
|
936 | + 'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']', |
|
937 | + 'textarea_rows' => absint($rows), |
|
938 | 938 | 'media_buttons' => false, |
939 | 939 | ) |
940 | 940 | ); |
941 | 941 | } else { |
942 | - echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
942 | + echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>'; |
|
943 | 943 | } |
944 | 944 | |
945 | - echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
945 | + echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
946 | 946 | |
947 | 947 | } |
948 | 948 | |
949 | -function wpinv_upload_callback( $args ) { |
|
949 | +function wpinv_upload_callback($args) { |
|
950 | 950 | |
951 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
951 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
952 | 952 | |
953 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
954 | - $value = wpinv_get_option( $args['id'], $std ); |
|
953 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
954 | + $value = wpinv_get_option($args['id'], $std); |
|
955 | 955 | |
956 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
957 | - echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
958 | - echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
959 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
956 | + $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular'; |
|
957 | + echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>'; |
|
958 | + echo '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>'; |
|
959 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
960 | 960 | |
961 | 961 | } |
962 | 962 | |
963 | -function wpinv_color_callback( $args ) { |
|
963 | +function wpinv_color_callback($args) { |
|
964 | 964 | |
965 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
966 | - $value = wpinv_get_option( $args['id'], $std ); |
|
967 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
965 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
966 | + $value = wpinv_get_option($args['id'], $std); |
|
967 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
968 | 968 | |
969 | - echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />'; |
|
970 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
969 | + echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />'; |
|
970 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
971 | 971 | |
972 | 972 | } |
973 | 973 | |
974 | -function wpinv_country_states_callback( $args ) { |
|
974 | +function wpinv_country_states_callback($args) { |
|
975 | 975 | |
976 | - $std = isset( $args['std'] ) ? $args['std'] : ''; |
|
977 | - $value = wpinv_get_option( $args['id'], $std ); |
|
976 | + $std = isset($args['std']) ? $args['std'] : ''; |
|
977 | + $value = wpinv_get_option($args['id'], $std); |
|
978 | 978 | |
979 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
979 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
980 | 980 | |
981 | - if ( isset( $args['placeholder'] ) ) { |
|
981 | + if (isset($args['placeholder'])) { |
|
982 | 982 | $placeholder = $args['placeholder']; |
983 | 983 | } else { |
984 | 984 | $placeholder = ''; |
@@ -986,15 +986,15 @@ discard block |
||
986 | 986 | |
987 | 987 | $states = wpinv_get_country_states(); |
988 | 988 | |
989 | - $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | - echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
989 | + $class = empty($states) ? 'wpinv-no-states' : 'wpi_select2'; |
|
990 | + echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>'; |
|
991 | 991 | |
992 | - foreach ( $states as $option => $name ) { |
|
993 | - echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>'; |
|
992 | + foreach ($states as $option => $name) { |
|
993 | + echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>'; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | echo '</select>'; |
997 | - echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
997 | + echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>'; |
|
998 | 998 | |
999 | 999 | } |
1000 | 1000 | |
@@ -1008,7 +1008,7 @@ discard block |
||
1008 | 1008 | </tr> |
1009 | 1009 | <tr class="bsui"> |
1010 | 1010 | <td colspan="2" class="p-0"> |
1011 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?> |
|
1011 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?> |
|
1012 | 1012 | |
1013 | 1013 | <?php |
1014 | 1014 | |
@@ -1017,11 +1017,11 @@ discard block |
||
1017 | 1017 | /** |
1018 | 1018 | * Displays a tax rate' edit row. |
1019 | 1019 | */ |
1020 | -function wpinv_tax_rate_callback( $tax_rate, $key ) { |
|
1020 | +function wpinv_tax_rate_callback($tax_rate, $key) { |
|
1021 | 1021 | |
1022 | - $key = sanitize_key( $key ); |
|
1023 | - $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | - include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php'; |
|
1022 | + $key = sanitize_key($key); |
|
1023 | + $tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate']; |
|
1024 | + include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php'; |
|
1025 | 1025 | |
1026 | 1026 | } |
1027 | 1027 | |
@@ -1035,187 +1035,187 @@ discard block |
||
1035 | 1035 | </tr> |
1036 | 1036 | <tr class="bsui"> |
1037 | 1037 | <td colspan="2" class="p-0"> |
1038 | - <?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?> |
|
1038 | + <?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?> |
|
1039 | 1039 | |
1040 | 1040 | <?php |
1041 | 1041 | |
1042 | 1042 | } |
1043 | 1043 | |
1044 | -function wpinv_tools_callback( $args ) { |
|
1044 | +function wpinv_tools_callback($args) { |
|
1045 | 1045 | ?> |
1046 | 1046 | </td><tr> |
1047 | 1047 | <td colspan="2" class="wpinv_tools_tdbox"> |
1048 | 1048 | <?php |
1049 | - if ( $args['desc'] ) { |
|
1049 | + if ($args['desc']) { |
|
1050 | 1050 | ?> |
1051 | -<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?> |
|
1052 | - <?php do_action( 'wpinv_tools_before' ); ?> |
|
1051 | +<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?> |
|
1052 | + <?php do_action('wpinv_tools_before'); ?> |
|
1053 | 1053 | <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts"> |
1054 | 1054 | <thead> |
1055 | 1055 | <tr> |
1056 | - <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th> |
|
1057 | - <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th> |
|
1058 | - <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th> |
|
1056 | + <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th> |
|
1057 | + <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th> |
|
1058 | + <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th> |
|
1059 | 1059 | </tr> |
1060 | 1060 | </thead> |
1061 | 1061 | |
1062 | 1062 | <tbody> |
1063 | 1063 | <tr> |
1064 | - <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td> |
|
1064 | + <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td> |
|
1065 | 1065 | <td> |
1066 | - <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small> |
|
1066 | + <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small> |
|
1067 | 1067 | </td> |
1068 | 1068 | <td> |
1069 | 1069 | <a href=" |
1070 | 1070 | <?php |
1071 | 1071 | echo esc_url( |
1072 | 1072 | wp_nonce_url( |
1073 | - add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ), |
|
1073 | + add_query_arg('getpaid-admin-action', 'create_missing_pages'), |
|
1074 | 1074 | 'getpaid-nonce', |
1075 | 1075 | 'getpaid-nonce' |
1076 | 1076 | ) |
1077 | 1077 | ); |
1078 | 1078 | ?> |
1079 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1079 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1080 | 1080 | </td> |
1081 | 1081 | </tr> |
1082 | 1082 | <tr> |
1083 | - <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td> |
|
1083 | + <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td> |
|
1084 | 1084 | <td> |
1085 | - <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small> |
|
1085 | + <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small> |
|
1086 | 1086 | </td> |
1087 | 1087 | <td> |
1088 | 1088 | <a href=" |
1089 | 1089 | <?php |
1090 | 1090 | echo esc_url( |
1091 | 1091 | wp_nonce_url( |
1092 | - add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ), |
|
1092 | + add_query_arg('getpaid-admin-action', 'refresh_permalinks'), |
|
1093 | 1093 | 'getpaid-nonce', |
1094 | 1094 | 'getpaid-nonce' |
1095 | 1095 | ) |
1096 | 1096 | ); |
1097 | 1097 | ?> |
1098 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1098 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1099 | 1099 | </td> |
1100 | 1100 | </tr> |
1101 | 1101 | <tr> |
1102 | - <td><?php esc_html_e( 'Repair Database Tables', 'invoicing' ); ?></td> |
|
1102 | + <td><?php esc_html_e('Repair Database Tables', 'invoicing'); ?></td> |
|
1103 | 1103 | <td> |
1104 | - <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small> |
|
1104 | + <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small> |
|
1105 | 1105 | </td> |
1106 | 1106 | <td> |
1107 | 1107 | <a href=" |
1108 | 1108 | <?php |
1109 | 1109 | echo esc_url( |
1110 | 1110 | wp_nonce_url( |
1111 | - add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ), |
|
1111 | + add_query_arg('getpaid-admin-action', 'create_missing_tables'), |
|
1112 | 1112 | 'getpaid-nonce', |
1113 | 1113 | 'getpaid-nonce' |
1114 | 1114 | ) |
1115 | 1115 | ); |
1116 | 1116 | ?> |
1117 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1117 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1118 | 1118 | </td> |
1119 | 1119 | </tr> |
1120 | 1120 | <tr> |
1121 | - <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td> |
|
1121 | + <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td> |
|
1122 | 1122 | <td> |
1123 | - <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small> |
|
1123 | + <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small> |
|
1124 | 1124 | </td> |
1125 | 1125 | <td> |
1126 | 1126 | <a href=" |
1127 | 1127 | <?php |
1128 | 1128 | echo esc_url( |
1129 | 1129 | wp_nonce_url( |
1130 | - add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ), |
|
1130 | + add_query_arg('getpaid-admin-action', 'migrate_old_invoices'), |
|
1131 | 1131 | 'getpaid-nonce', |
1132 | 1132 | 'getpaid-nonce' |
1133 | 1133 | ) |
1134 | 1134 | ); |
1135 | 1135 | ?> |
1136 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1136 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1137 | 1137 | </td> |
1138 | 1138 | </tr> |
1139 | 1139 | |
1140 | 1140 | <tr> |
1141 | - <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td> |
|
1141 | + <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td> |
|
1142 | 1142 | <td> |
1143 | - <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small> |
|
1143 | + <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small> |
|
1144 | 1144 | </td> |
1145 | 1145 | <td> |
1146 | 1146 | <a href=" |
1147 | 1147 | <?php |
1148 | 1148 | echo esc_url( |
1149 | 1149 | wp_nonce_url( |
1150 | - add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ), |
|
1150 | + add_query_arg('getpaid-admin-action', 'recalculate_discounts'), |
|
1151 | 1151 | 'getpaid-nonce', |
1152 | 1152 | 'getpaid-nonce' |
1153 | 1153 | ) |
1154 | 1154 | ); |
1155 | 1155 | ?> |
1156 | - " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1156 | + " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1157 | 1157 | </td> |
1158 | 1158 | </tr> |
1159 | 1159 | |
1160 | 1160 | <tr> |
1161 | - <td><?php esc_html_e( 'Database Text Translation', 'invoicing' ); ?></td> |
|
1161 | + <td><?php esc_html_e('Database Text Translation', 'invoicing'); ?></td> |
|
1162 | 1162 | <td> |
1163 | - <small><?php esc_html_e( 'This tool will collect any strings stored in the database and put them in the file db-language.php, so those strings can be used to translate by translation tools.', 'invoicing' ); ?></small> |
|
1163 | + <small><?php esc_html_e('This tool will collect any strings stored in the database and put them in the file db-language.php, so those strings can be used to translate by translation tools.', 'invoicing'); ?></small> |
|
1164 | 1164 | </td> |
1165 | 1165 | <td> |
1166 | - <a href=" <?php echo esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'translate_db_texts' ), 'getpaid-nonce', 'getpaid-nonce' ) ); ?>" class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a> |
|
1166 | + <a href=" <?php echo esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'translate_db_texts'), 'getpaid-nonce', 'getpaid-nonce')); ?>" class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a> |
|
1167 | 1167 | </td> |
1168 | 1168 | </tr> |
1169 | 1169 | |
1170 | 1170 | <tr> |
1171 | - <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td> |
|
1171 | + <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td> |
|
1172 | 1172 | <td> |
1173 | - <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small> |
|
1173 | + <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small> |
|
1174 | 1174 | </td> |
1175 | 1175 | <td> |
1176 | 1176 | <a href=" |
1177 | 1177 | <?php |
1178 | - echo esc_url( admin_url( 'index.php?page=gp-setup' ) ); |
|
1178 | + echo esc_url(admin_url('index.php?page=gp-setup')); |
|
1179 | 1179 | ?> |
1180 | - " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a> |
|
1180 | + " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a> |
|
1181 | 1181 | </td> |
1182 | 1182 | </tr> |
1183 | 1183 | |
1184 | - <?php do_action( 'wpinv_tools_row' ); ?> |
|
1184 | + <?php do_action('wpinv_tools_row'); ?> |
|
1185 | 1185 | </tbody> |
1186 | 1186 | </table> |
1187 | - <?php do_action( 'wpinv_tools_after' ); ?> |
|
1187 | + <?php do_action('wpinv_tools_after'); ?> |
|
1188 | 1188 | <?php |
1189 | 1189 | } |
1190 | 1190 | |
1191 | 1191 | |
1192 | -function wpinv_descriptive_text_callback( $args ) { |
|
1193 | - echo wp_kses_post( $args['desc'] ); |
|
1192 | +function wpinv_descriptive_text_callback($args) { |
|
1193 | + echo wp_kses_post($args['desc']); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | -function wpinv_raw_html_callback( $args ) { |
|
1197 | - echo wp_kses( $args['desc'], getpaid_allowed_html() ); |
|
1196 | +function wpinv_raw_html_callback($args) { |
|
1197 | + echo wp_kses($args['desc'], getpaid_allowed_html()); |
|
1198 | 1198 | } |
1199 | 1199 | |
1200 | -function wpinv_hook_callback( $args ) { |
|
1201 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
1200 | +function wpinv_hook_callback($args) { |
|
1201 | + do_action('wpinv_' . $args['id'], $args); |
|
1202 | 1202 | } |
1203 | 1203 | |
1204 | 1204 | function wpinv_set_settings_cap() { |
1205 | 1205 | return wpinv_get_capability(); |
1206 | 1206 | } |
1207 | -add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
|
1207 | +add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap'); |
|
1208 | 1208 | |
1209 | 1209 | |
1210 | -function wpinv_on_update_settings( $old_value, $value, $option ) { |
|
1211 | - $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1212 | - $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : ''; |
|
1210 | +function wpinv_on_update_settings($old_value, $value, $option) { |
|
1211 | + $old = !empty($old_value['remove_data_on_unistall']) ? 1 : ''; |
|
1212 | + $new = !empty($value['remove_data_on_unistall']) ? 1 : ''; |
|
1213 | 1213 | |
1214 | - if ( $old != $new ) { |
|
1215 | - update_option( 'wpinv_remove_data_on_invoice_unistall', $new ); |
|
1214 | + if ($old != $new) { |
|
1215 | + update_option('wpinv_remove_data_on_invoice_unistall', $new); |
|
1216 | 1216 | } |
1217 | 1217 | } |
1218 | -add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 ); |
|
1218 | +add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3); |
|
1219 | 1219 | |
1220 | 1220 | |
1221 | 1221 | /** |
@@ -1227,43 +1227,43 @@ discard block |
||
1227 | 1227 | * |
1228 | 1228 | * @return array |
1229 | 1229 | */ |
1230 | -function wpinv_get_email_merge_tags( $subscription = false ) { |
|
1230 | +function wpinv_get_email_merge_tags($subscription = false) { |
|
1231 | 1231 | $merge_tags = array( |
1232 | - '{site_title}' => __( 'Site Title', 'invoicing' ), |
|
1233 | - '{name}' => __( "Customer's full name", 'invoicing' ), |
|
1234 | - '{first_name}' => __( "Customer's first name", 'invoicing' ), |
|
1235 | - '{last_name}' => __( "Customer's last name", 'invoicing' ), |
|
1236 | - '{email}' => __( "Customer's email address", 'invoicing' ), |
|
1237 | - '{invoice_number}' => __( 'The invoice number', 'invoicing' ), |
|
1238 | - '{invoice_currency}' => __( 'The invoice currency', 'invoicing' ), |
|
1239 | - '{invoice_total}' => __( 'The invoice total', 'invoicing' ), |
|
1240 | - '{invoice_link}' => __( 'The invoice link', 'invoicing' ), |
|
1241 | - '{invoice_pay_link}' => __( 'The payment link', 'invoicing' ), |
|
1242 | - '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ), |
|
1243 | - '{invoice_date}' => __( 'The date the invoice was created', 'invoicing' ), |
|
1244 | - '{invoice_due_date}' => __( 'The date the invoice is due', 'invoicing' ), |
|
1245 | - '{date}' => __( "Today's date", 'invoicing' ), |
|
1246 | - '{is_was}' => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ), |
|
1247 | - '{invoice_label}' => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ), |
|
1248 | - '{invoice_quote}' => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ), |
|
1249 | - '{invoice_description}' => __( 'The description of the invoice', 'invoicing' ), |
|
1232 | + '{site_title}' => __('Site Title', 'invoicing'), |
|
1233 | + '{name}' => __("Customer's full name", 'invoicing'), |
|
1234 | + '{first_name}' => __("Customer's first name", 'invoicing'), |
|
1235 | + '{last_name}' => __("Customer's last name", 'invoicing'), |
|
1236 | + '{email}' => __("Customer's email address", 'invoicing'), |
|
1237 | + '{invoice_number}' => __('The invoice number', 'invoicing'), |
|
1238 | + '{invoice_currency}' => __('The invoice currency', 'invoicing'), |
|
1239 | + '{invoice_total}' => __('The invoice total', 'invoicing'), |
|
1240 | + '{invoice_link}' => __('The invoice link', 'invoicing'), |
|
1241 | + '{invoice_pay_link}' => __('The payment link', 'invoicing'), |
|
1242 | + '{invoice_receipt_link}' => __('The receipt link', 'invoicing'), |
|
1243 | + '{invoice_date}' => __('The date the invoice was created', 'invoicing'), |
|
1244 | + '{invoice_due_date}' => __('The date the invoice is due', 'invoicing'), |
|
1245 | + '{date}' => __("Today's date", 'invoicing'), |
|
1246 | + '{is_was}' => __('If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing'), |
|
1247 | + '{invoice_label}' => __('Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing'), |
|
1248 | + '{invoice_quote}' => __('Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing'), |
|
1249 | + '{invoice_description}' => __('The description of the invoice', 'invoicing'), |
|
1250 | 1250 | ); |
1251 | 1251 | |
1252 | - if ( $subscription ) { |
|
1252 | + if ($subscription) { |
|
1253 | 1253 | $merge_tags = array_merge( |
1254 | 1254 | $merge_tags, |
1255 | 1255 | array( |
1256 | - '{subscription_renewal_date}' => __( 'The next renewal date of the subscription', 'invoicing' ), |
|
1257 | - '{subscription_created}' => __( "The subscription's creation date", 'invoicing' ), |
|
1258 | - '{subscription_status}' => __( "The subscription's status", 'invoicing' ), |
|
1259 | - '{subscription_profile_id}' => __( "The subscription's remote profile id", 'invoicing' ), |
|
1260 | - '{subscription_id}' => __( "The subscription's id", 'invoicing' ), |
|
1261 | - '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ), |
|
1262 | - '{subscription_initial_amount}' => __( 'The initial amount of the subscription', 'invoicing' ), |
|
1263 | - '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ), |
|
1264 | - '{subscription_bill_times}' => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ), |
|
1265 | - '{subscription_url}' => __( 'The URL to manage a subscription', 'invoicing' ), |
|
1266 | - '{subscription_name}' => __( 'The name of the recurring item', 'invoicing' ), |
|
1256 | + '{subscription_renewal_date}' => __('The next renewal date of the subscription', 'invoicing'), |
|
1257 | + '{subscription_created}' => __("The subscription's creation date", 'invoicing'), |
|
1258 | + '{subscription_status}' => __("The subscription's status", 'invoicing'), |
|
1259 | + '{subscription_profile_id}' => __("The subscription's remote profile id", 'invoicing'), |
|
1260 | + '{subscription_id}' => __("The subscription's id", 'invoicing'), |
|
1261 | + '{subscription_recurring_amount}' => __('The renewal amount of the subscription', 'invoicing'), |
|
1262 | + '{subscription_initial_amount}' => __('The initial amount of the subscription', 'invoicing'), |
|
1263 | + '{subscription_recurring_period}' => __('The recurring period of the subscription (e.g 1 year)', 'invoicing'), |
|
1264 | + '{subscription_bill_times}' => __('The maximum number of times the subscription can be renewed', 'invoicing'), |
|
1265 | + '{subscription_url}' => __('The URL to manage a subscription', 'invoicing'), |
|
1266 | + '{subscription_name}' => __('The name of the recurring item', 'invoicing'), |
|
1267 | 1267 | ) |
1268 | 1268 | ); |
1269 | 1269 | } |
@@ -1279,25 +1279,25 @@ discard block |
||
1279 | 1279 | * |
1280 | 1280 | * @return string |
1281 | 1281 | */ |
1282 | -function wpinv_get_merge_tags_help_text( $subscription = false ) { |
|
1283 | - $merge_tags = wpinv_get_email_merge_tags( $subscription ); |
|
1282 | +function wpinv_get_merge_tags_help_text($subscription = false) { |
|
1283 | + $merge_tags = wpinv_get_email_merge_tags($subscription); |
|
1284 | 1284 | |
1285 | 1285 | $output = '<div class="bsui">'; |
1286 | 1286 | |
1287 | 1287 | $link = sprintf( |
1288 | 1288 | '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>', |
1289 | - esc_html__( 'View available merge tags.', 'invoicing' ) |
|
1289 | + esc_html__('View available merge tags.', 'invoicing') |
|
1290 | 1290 | ); |
1291 | 1291 | |
1292 | - $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' ); |
|
1292 | + $description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing'); |
|
1293 | 1293 | |
1294 | 1294 | $output .= "$description $link"; |
1295 | 1295 | |
1296 | 1296 | $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">'; |
1297 | - $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>'; |
|
1297 | + $output .= '<p class="mb-2">' . esc_html__('The following wildcards can be used in email subjects, heading and content:', 'invoicing') . '</p>'; |
|
1298 | 1298 | |
1299 | 1299 | $output .= '<ul class="p-0 m-0">'; |
1300 | - foreach($merge_tags as $tag => $tag_description) { |
|
1300 | + foreach ($merge_tags as $tag => $tag_description) { |
|
1301 | 1301 | $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> — $tag_description</li>"; |
1302 | 1302 | } |
1303 | 1303 |
@@ -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 | * Bank transfer Payment Gateway class. |
@@ -56,21 +56,21 @@ discard block |
||
56 | 56 | public function __construct() { |
57 | 57 | parent::__construct(); |
58 | 58 | |
59 | - $this->title = __( 'Direct bank transfer', 'invoicing' ); |
|
60 | - $this->method_title = __( 'Bank transfer', 'invoicing' ); |
|
61 | - $this->checkout_button_text = __( 'Proceed', 'invoicing' ); |
|
62 | - $this->instructions = apply_filters( 'wpinv_bank_instructions', $this->get_option( 'info' ) ); |
|
63 | - |
|
64 | - add_action( 'wpinv_receipt_end', array( $this, 'thankyou_page' ) ); |
|
65 | - add_action( 'getpaid_invoice_line_items', array( $this, 'thankyou_page' ), 40 ); |
|
66 | - add_action( 'wpinv_pdf_content_billing', array( $this, 'thankyou_page' ), 11 ); |
|
67 | - add_action( 'wpinv_email_invoice_details', array( $this, 'email_instructions' ), 10, 3 ); |
|
68 | - add_action( 'getpaid_should_renew_subscription', array( $this, 'maybe_renew_subscription' ), 12, 2 ); |
|
69 | - add_action( 'getpaid_invoice_status_publish', array( $this, 'invoice_paid' ), 20 ); |
|
70 | - |
|
71 | - add_filter( 'wpinv_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
72 | - add_filter( 'getpaid_' . $this->id . '_support_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
73 | - add_filter( 'getpaid_' . $this->id . '_supports_subscription', array( $this, 'supports_subscription' ), 20, 1 ); |
|
59 | + $this->title = __('Direct bank transfer', 'invoicing'); |
|
60 | + $this->method_title = __('Bank transfer', 'invoicing'); |
|
61 | + $this->checkout_button_text = __('Proceed', 'invoicing'); |
|
62 | + $this->instructions = apply_filters('wpinv_bank_instructions', $this->get_option('info')); |
|
63 | + |
|
64 | + add_action('wpinv_receipt_end', array($this, 'thankyou_page')); |
|
65 | + add_action('getpaid_invoice_line_items', array($this, 'thankyou_page'), 40); |
|
66 | + add_action('wpinv_pdf_content_billing', array($this, 'thankyou_page'), 11); |
|
67 | + add_action('wpinv_email_invoice_details', array($this, 'email_instructions'), 10, 3); |
|
68 | + add_action('getpaid_should_renew_subscription', array($this, 'maybe_renew_subscription'), 12, 2); |
|
69 | + add_action('getpaid_invoice_status_publish', array($this, 'invoice_paid'), 20); |
|
70 | + |
|
71 | + add_filter('wpinv_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1); |
|
72 | + add_filter('getpaid_' . $this->id . '_support_subscription', array($this, 'supports_subscription'), 20, 1); |
|
73 | + add_filter('getpaid_' . $this->id . '_supports_subscription', array($this, 'supports_subscription'), 20, 1); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | /** |
@@ -81,8 +81,8 @@ discard block |
||
81 | 81 | * @param bool $supports True if supports else False. |
82 | 82 | * @return bool True if supports else False. |
83 | 83 | */ |
84 | - public function supports_subscription( $supports ) { |
|
85 | - if ( $supports && (int) $this->get_option( 'no_subscription' ) ) { |
|
84 | + public function supports_subscription($supports) { |
|
85 | + if ($supports && (int) $this->get_option('no_subscription')) { |
|
86 | 86 | $supports = false; |
87 | 87 | } |
88 | 88 | |
@@ -97,23 +97,23 @@ discard block |
||
97 | 97 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
98 | 98 | * @return array |
99 | 99 | */ |
100 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
100 | + public function process_payment($invoice, $submission_data, $submission) { |
|
101 | 101 | |
102 | 102 | // Add a transaction id. |
103 | - $invoice->set_transaction_id( $invoice->generate_key( 'bt_' ) ); |
|
103 | + $invoice->set_transaction_id($invoice->generate_key('bt_')); |
|
104 | 104 | |
105 | 105 | // Set it as pending payment. |
106 | - if ( ! $invoice->needs_payment() ) { |
|
106 | + if (!$invoice->needs_payment()) { |
|
107 | 107 | $invoice->mark_paid(); |
108 | - } elseif ( ! $invoice->is_paid() ) { |
|
109 | - $invoice->set_status( 'wpi-onhold' ); |
|
108 | + } elseif (!$invoice->is_paid()) { |
|
109 | + $invoice->set_status('wpi-onhold'); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Save it. |
113 | 113 | $invoice->save(); |
114 | 114 | |
115 | 115 | // Send to the success page. |
116 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
116 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
117 | 117 | |
118 | 118 | } |
119 | 119 | |
@@ -122,17 +122,17 @@ discard block |
||
122 | 122 | * |
123 | 123 | * @param WPInv_Invoice $invoice Invoice. |
124 | 124 | */ |
125 | - public function thankyou_page( $invoice ) { |
|
125 | + public function thankyou_page($invoice) { |
|
126 | 126 | |
127 | - if ( 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
127 | + if ('bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
128 | 128 | |
129 | 129 | echo '<div class="mt-4 mb-2 getpaid-bank-transfer-details">' . PHP_EOL; |
130 | 130 | |
131 | - if ( ! empty( $this->instructions ) ) { |
|
132 | - echo wp_kses_post( wpautop( wptexturize( __( wp_unslash( $this->instructions ), 'invoicing' ) ) ) ); |
|
131 | + if (!empty($this->instructions)) { |
|
132 | + echo wp_kses_post(wpautop(wptexturize(__(wp_unslash($this->instructions), 'invoicing')))); |
|
133 | 133 | } |
134 | 134 | |
135 | - $this->bank_details( $invoice ); |
|
135 | + $this->bank_details($invoice); |
|
136 | 136 | |
137 | 137 | echo '</div>'; |
138 | 138 | |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * @param string $email_type Email format: plain text or HTML. |
148 | 148 | * @param bool $sent_to_admin Sent to admin. |
149 | 149 | */ |
150 | - public function email_instructions( $invoice, $email_type, $sent_to_admin ) { |
|
150 | + public function email_instructions($invoice, $email_type, $sent_to_admin) { |
|
151 | 151 | |
152 | - if ( ! $sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment() ) { |
|
152 | + if (!$sent_to_admin && 'bank_transfer' === $invoice->get_gateway() && $invoice->needs_payment()) { |
|
153 | 153 | |
154 | 154 | echo '<div class="wpi-email-row getpaid-bank-transfer-details">'; |
155 | 155 | |
156 | - if ( $this->instructions ) { |
|
157 | - echo wp_kses_post( wpautop( wptexturize( $this->instructions ) ) . PHP_EOL ); |
|
156 | + if ($this->instructions) { |
|
157 | + echo wp_kses_post(wpautop(wptexturize($this->instructions)) . PHP_EOL); |
|
158 | 158 | } |
159 | 159 | |
160 | - $this->bank_details( $invoice ); |
|
160 | + $this->bank_details($invoice); |
|
161 | 161 | |
162 | 162 | echo '</div>'; |
163 | 163 | |
@@ -170,50 +170,50 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param WPInv_Invoice $invoice Invoice. |
172 | 172 | */ |
173 | - protected function bank_details( $invoice ) { |
|
173 | + protected function bank_details($invoice) { |
|
174 | 174 | |
175 | 175 | // Get the invoice country and country $locale. |
176 | 176 | $country = $invoice->get_country(); |
177 | 177 | $locale = $this->get_country_locale(); |
178 | 178 | |
179 | 179 | // Get shortcode label in the $locale array and use appropriate one. |
180 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
180 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
181 | 181 | |
182 | 182 | $bank_fields = array( |
183 | - 'ac_name' => __( 'Account Name', 'invoicing' ), |
|
184 | - 'ac_no' => __( 'Account Number', 'invoicing' ), |
|
185 | - 'bank_name' => __( 'Bank Name', 'invoicing' ), |
|
186 | - 'ifsc' => __( 'IFSC code', 'invoicing' ), |
|
187 | - 'iban' => __( 'IBAN', 'invoicing' ), |
|
188 | - 'bic' => __( 'BIC/Swift code', 'invoicing' ), |
|
183 | + 'ac_name' => __('Account Name', 'invoicing'), |
|
184 | + 'ac_no' => __('Account Number', 'invoicing'), |
|
185 | + 'bank_name' => __('Bank Name', 'invoicing'), |
|
186 | + 'ifsc' => __('IFSC code', 'invoicing'), |
|
187 | + 'iban' => __('IBAN', 'invoicing'), |
|
188 | + 'bic' => __('BIC/Swift code', 'invoicing'), |
|
189 | 189 | 'sort_code' => $sortcode, |
190 | 190 | ); |
191 | 191 | |
192 | 192 | $bank_info = array(); |
193 | 193 | |
194 | - foreach ( $bank_fields as $field => $label ) { |
|
195 | - $value = $this->get_option( $field ); |
|
194 | + foreach ($bank_fields as $field => $label) { |
|
195 | + $value = $this->get_option($field); |
|
196 | 196 | |
197 | - if ( ! empty( $value ) ) { |
|
198 | - $bank_info[ $field ] = array( |
|
197 | + if (!empty($value)) { |
|
198 | + $bank_info[$field] = array( |
|
199 | 199 | 'label' => $label, |
200 | 200 | 'value' => $value, |
201 | 201 | ); |
202 | 202 | } |
203 | 203 | } |
204 | 204 | |
205 | - $bank_info = apply_filters( 'wpinv_bank_info', $bank_info, $invoice ); |
|
205 | + $bank_info = apply_filters('wpinv_bank_info', $bank_info, $invoice); |
|
206 | 206 | |
207 | - if ( empty( $bank_info ) ) { |
|
207 | + if (empty($bank_info)) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html( apply_filters( 'wpinv_receipt_bank_details_title', __( 'Bank Details', 'invoicing' ), $invoice ) ) . '</h3>' . PHP_EOL; |
|
211 | + echo '<h3 class="getpaid-bank-transfer-title"> ' . esc_html(apply_filters('wpinv_receipt_bank_details_title', __('Bank Details', 'invoicing'), $invoice)) . '</h3>' . PHP_EOL; |
|
212 | 212 | |
213 | 213 | echo '<table class="table table-bordered getpaid-bank-transfer-details">' . PHP_EOL; |
214 | 214 | |
215 | - foreach ( $bank_info as $key => $data ) { |
|
216 | - echo "<tr class='getpaid-bank-transfer-" . esc_attr( $key ) . "'><th class='font-weight-bold'>" . wp_kses_post( $data['label'] ) . "</th><td class='w-75'>" . wp_kses_post( wptexturize( $data['value'] ) ) . '</td></tr>' . PHP_EOL; |
|
215 | + foreach ($bank_info as $key => $data) { |
|
216 | + echo "<tr class='getpaid-bank-transfer-" . esc_attr($key) . "'><th class='font-weight-bold'>" . wp_kses_post($data['label']) . "</th><td class='w-75'>" . wp_kses_post(wptexturize($data['value'])) . '</td></tr>' . PHP_EOL; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | echo '</table>'; |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function get_country_locale() { |
229 | 229 | |
230 | - if ( empty( $this->locale ) ) { |
|
230 | + if (empty($this->locale)) { |
|
231 | 231 | |
232 | 232 | // Locale information to be used - only those that are not 'Sort Code'. |
233 | 233 | $this->locale = apply_filters( |
@@ -235,42 +235,42 @@ discard block |
||
235 | 235 | array( |
236 | 236 | 'AU' => array( |
237 | 237 | 'sortcode' => array( |
238 | - 'label' => __( 'BSB', 'invoicing' ), |
|
238 | + 'label' => __('BSB', 'invoicing'), |
|
239 | 239 | ), |
240 | 240 | ), |
241 | 241 | 'CA' => array( |
242 | 242 | 'sortcode' => array( |
243 | - 'label' => __( 'Bank transit number', 'invoicing' ), |
|
243 | + 'label' => __('Bank transit number', 'invoicing'), |
|
244 | 244 | ), |
245 | 245 | ), |
246 | 246 | 'IN' => array( |
247 | 247 | 'sortcode' => array( |
248 | - 'label' => __( 'IFSC', 'invoicing' ), |
|
248 | + 'label' => __('IFSC', 'invoicing'), |
|
249 | 249 | ), |
250 | 250 | ), |
251 | 251 | 'IT' => array( |
252 | 252 | 'sortcode' => array( |
253 | - 'label' => __( 'Branch sort', 'invoicing' ), |
|
253 | + 'label' => __('Branch sort', 'invoicing'), |
|
254 | 254 | ), |
255 | 255 | ), |
256 | 256 | 'NZ' => array( |
257 | 257 | 'sortcode' => array( |
258 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
258 | + 'label' => __('Bank code', 'invoicing'), |
|
259 | 259 | ), |
260 | 260 | ), |
261 | 261 | 'SE' => array( |
262 | 262 | 'sortcode' => array( |
263 | - 'label' => __( 'Bank code', 'invoicing' ), |
|
263 | + 'label' => __('Bank code', 'invoicing'), |
|
264 | 264 | ), |
265 | 265 | ), |
266 | 266 | 'US' => array( |
267 | 267 | 'sortcode' => array( |
268 | - 'label' => __( 'Routing number', 'invoicing' ), |
|
268 | + 'label' => __('Routing number', 'invoicing'), |
|
269 | 269 | ), |
270 | 270 | ), |
271 | 271 | 'ZA' => array( |
272 | 272 | 'sortcode' => array( |
273 | - 'label' => __( 'Branch code', 'invoicing' ), |
|
273 | + 'label' => __('Branch code', 'invoicing'), |
|
274 | 274 | ), |
275 | 275 | ), |
276 | 276 | ) |
@@ -287,22 +287,22 @@ discard block |
||
287 | 287 | * |
288 | 288 | * @param array $admin_settings |
289 | 289 | */ |
290 | - public function admin_settings( $admin_settings ) { |
|
291 | - $admin_settings['bank_transfer_desc']['std'] = __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ); |
|
292 | - $admin_settings['bank_transfer_active']['desc'] = __( 'Enable bank transfer', 'invoicing' ); |
|
290 | + public function admin_settings($admin_settings) { |
|
291 | + $admin_settings['bank_transfer_desc']['std'] = __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'); |
|
292 | + $admin_settings['bank_transfer_active']['desc'] = __('Enable bank transfer', 'invoicing'); |
|
293 | 293 | |
294 | 294 | $_settings = array(); |
295 | 295 | |
296 | - foreach ( $admin_settings as $key => $setting ) { |
|
297 | - $_settings[ $key ] = $setting; |
|
296 | + foreach ($admin_settings as $key => $setting) { |
|
297 | + $_settings[$key] = $setting; |
|
298 | 298 | |
299 | - if ( $key == 'bank_transfer_active' ) { |
|
299 | + if ($key == 'bank_transfer_active') { |
|
300 | 300 | // Enable/disable subscriptions setting. |
301 | 301 | $_settings['bank_transfer_no_subscription'] = array( |
302 | 302 | 'id' => 'bank_transfer_no_subscription', |
303 | 303 | 'type' => 'checkbox', |
304 | - 'name' => __( 'Disable Subscriptions', 'invoicing' ), |
|
305 | - 'desc' => __( 'Tick to disable support for recurring items.', 'invoicing' ), |
|
304 | + 'name' => __('Disable Subscriptions', 'invoicing'), |
|
305 | + 'desc' => __('Tick to disable support for recurring items.', 'invoicing'), |
|
306 | 306 | 'std' => 0 |
307 | 307 | ); |
308 | 308 | } |
@@ -310,46 +310,46 @@ discard block |
||
310 | 310 | |
311 | 311 | $admin_settings = $_settings; |
312 | 312 | |
313 | - $locale = $this->get_country_locale(); |
|
313 | + $locale = $this->get_country_locale(); |
|
314 | 314 | |
315 | 315 | // Get sortcode label in the $locale array and use appropriate one. |
316 | 316 | $country = wpinv_default_billing_country(); |
317 | - $sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'invoicing' ); |
|
317 | + $sortcode = isset($locale[$country]['sortcode']['label']) ? $locale[$country]['sortcode']['label'] : __('Sort code', 'invoicing'); |
|
318 | 318 | |
319 | 319 | $admin_settings['bank_transfer_ac_name'] = array( |
320 | 320 | 'type' => 'text', |
321 | 321 | 'id' => 'bank_transfer_ac_name', |
322 | - 'name' => __( 'Account Name', 'invoicing' ), |
|
322 | + 'name' => __('Account Name', 'invoicing'), |
|
323 | 323 | ); |
324 | 324 | |
325 | 325 | $admin_settings['bank_transfer_ac_no'] = array( |
326 | 326 | 'type' => 'text', |
327 | 327 | 'id' => 'bank_transfer_ac_no', |
328 | - 'name' => __( 'Account Number', 'invoicing' ), |
|
328 | + 'name' => __('Account Number', 'invoicing'), |
|
329 | 329 | ); |
330 | 330 | |
331 | 331 | $admin_settings['bank_transfer_bank_name'] = array( |
332 | 332 | 'type' => 'text', |
333 | 333 | 'id' => 'bank_transfer_bank_name', |
334 | - 'name' => __( 'Bank Name', 'invoicing' ), |
|
334 | + 'name' => __('Bank Name', 'invoicing'), |
|
335 | 335 | ); |
336 | 336 | |
337 | 337 | $admin_settings['bank_transfer_ifsc'] = array( |
338 | 338 | 'type' => 'text', |
339 | 339 | 'id' => 'bank_transfer_ifsc', |
340 | - 'name' => __( 'IFSC Code', 'invoicing' ), |
|
340 | + 'name' => __('IFSC Code', 'invoicing'), |
|
341 | 341 | ); |
342 | 342 | |
343 | 343 | $admin_settings['bank_transfer_iban'] = array( |
344 | 344 | 'type' => 'text', |
345 | 345 | 'id' => 'bank_transfer_iban', |
346 | - 'name' => __( 'IBAN', 'invoicing' ), |
|
346 | + 'name' => __('IBAN', 'invoicing'), |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | $admin_settings['bank_transfer_bic'] = array( |
350 | 350 | 'type' => 'text', |
351 | 351 | 'id' => 'bank_transfer_bic', |
352 | - 'name' => __( 'BIC/Swift Code', 'invoicing' ), |
|
352 | + 'name' => __('BIC/Swift Code', 'invoicing'), |
|
353 | 353 | ); |
354 | 354 | |
355 | 355 | $admin_settings['bank_transfer_sort_code'] = array( |
@@ -360,10 +360,10 @@ discard block |
||
360 | 360 | |
361 | 361 | $admin_settings['bank_transfer_info'] = array( |
362 | 362 | 'id' => 'bank_transfer_info', |
363 | - 'name' => __( 'Instructions', 'invoicing' ), |
|
364 | - 'desc' => __( 'Instructions that will be added to the thank you page and emails.', 'invoicing' ), |
|
363 | + 'name' => __('Instructions', 'invoicing'), |
|
364 | + 'desc' => __('Instructions that will be added to the thank you page and emails.', 'invoicing'), |
|
365 | 365 | 'type' => 'textarea', |
366 | - 'std' => __( "Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing' ), |
|
366 | + 'std' => __("Make your payment directly into our bank account. Please use your Invoice Number as the payment reference. Your invoice won't be processed until the funds have cleared in our account.", 'invoicing'), |
|
367 | 367 | 'cols' => 50, |
368 | 368 | 'rows' => 5, |
369 | 369 | ); |
@@ -378,10 +378,10 @@ discard block |
||
378 | 378 | * @param GetPaid_Form_Item[] $items |
379 | 379 | * @return WPInv_Invoice |
380 | 380 | */ |
381 | - public function process_addons( $invoice, $items ) { |
|
381 | + public function process_addons($invoice, $items) { |
|
382 | 382 | |
383 | - foreach ( $items as $item ) { |
|
384 | - $invoice->add_item( $item ); |
|
383 | + foreach ($items as $item) { |
|
384 | + $invoice->add_item($item); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | $invoice->recalculate_total(); |
@@ -394,25 +394,25 @@ discard block |
||
394 | 394 | * |
395 | 395 | * @param WPInv_Subscription $subscription |
396 | 396 | */ |
397 | - public function maybe_renew_subscription( $subscription, $parent_invoice ) { |
|
397 | + public function maybe_renew_subscription($subscription, $parent_invoice) { |
|
398 | 398 | // Ensure its our subscription && it's active. |
399 | - if ( ! empty( $parent_invoice ) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status( 'active trialling' ) ) { |
|
400 | - add_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
399 | + if (!empty($parent_invoice) && $this->id === $parent_invoice->get_gateway() && $subscription->has_status('active trialling')) { |
|
400 | + add_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2); |
|
401 | 401 | |
402 | 402 | $invoice = $subscription->create_payment(); |
403 | 403 | |
404 | - if ( ! empty( $invoice ) ) { |
|
404 | + if (!empty($invoice)) { |
|
405 | 405 | $is_logged_in = is_user_logged_in(); |
406 | 406 | |
407 | 407 | // Cron run. |
408 | - if ( ! $is_logged_in ) { |
|
409 | - $note = wp_sprintf( __( 'Renewal %1$s created with the status "%2$s".', 'invoicing' ), $invoice->get_invoice_quote_type(), wpinv_status_nicename( $invoice->get_status(), $invoice ) ); |
|
408 | + if (!$is_logged_in) { |
|
409 | + $note = wp_sprintf(__('Renewal %1$s created with the status "%2$s".', 'invoicing'), $invoice->get_invoice_quote_type(), wpinv_status_nicename($invoice->get_status(), $invoice)); |
|
410 | 410 | |
411 | - $invoice->add_note( $note, false, $is_logged_in, ! $is_logged_in ); |
|
411 | + $invoice->add_note($note, false, $is_logged_in, !$is_logged_in); |
|
412 | 412 | } |
413 | 413 | } |
414 | 414 | |
415 | - remove_filter( 'getpaid_invoice_notifications_is_payment_form_invoice', array( $this, 'force_is_payment_form_invoice' ), 10, 2 ); |
|
415 | + remove_filter('getpaid_invoice_notifications_is_payment_form_invoice', array($this, 'force_is_payment_form_invoice'), 10, 2); |
|
416 | 416 | } |
417 | 417 | } |
418 | 418 | |
@@ -422,42 +422,42 @@ discard block |
||
422 | 422 | * |
423 | 423 | * @param WPInv_Invoice $invoice |
424 | 424 | */ |
425 | - public function invoice_paid( $invoice ) { |
|
425 | + public function invoice_paid($invoice) { |
|
426 | 426 | |
427 | 427 | // Abort if not paid by bank transfer. |
428 | - if ( $this->id !== $invoice->get_gateway() || ! $invoice->is_recurring() ) { |
|
428 | + if ($this->id !== $invoice->get_gateway() || !$invoice->is_recurring()) { |
|
429 | 429 | return; |
430 | 430 | } |
431 | 431 | |
432 | 432 | // Is it a parent payment? |
433 | - if ( 0 == $invoice->get_parent_id() ) { |
|
433 | + if (0 == $invoice->get_parent_id()) { |
|
434 | 434 | |
435 | 435 | // (Maybe) activate subscriptions. |
436 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
436 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
437 | 437 | |
438 | - if ( ! empty( $subscriptions ) ) { |
|
439 | - $subscriptions = is_array( $subscriptions ) ? $subscriptions : array( $subscriptions ); |
|
438 | + if (!empty($subscriptions)) { |
|
439 | + $subscriptions = is_array($subscriptions) ? $subscriptions : array($subscriptions); |
|
440 | 440 | |
441 | - foreach ( $subscriptions as $subscription ) { |
|
442 | - if ( $subscription->exists() ) { |
|
443 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
444 | - $expiry = gmdate( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
441 | + foreach ($subscriptions as $subscription) { |
|
442 | + if ($subscription->exists()) { |
|
443 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
444 | + $expiry = gmdate('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
445 | 445 | |
446 | - $subscription->set_next_renewal_date( $expiry ); |
|
447 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
448 | - $subscription->set_profile_id( 'bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id() ); |
|
446 | + $subscription->set_next_renewal_date($expiry); |
|
447 | + $subscription->set_date_created(current_time('mysql')); |
|
448 | + $subscription->set_profile_id('bt_sub_' . $invoice->get_id() . '_' . $subscription->get_id()); |
|
449 | 449 | $subscription->activate(); |
450 | 450 | } |
451 | 451 | } |
452 | 452 | } |
453 | 453 | } else { |
454 | 454 | |
455 | - $subscription = getpaid_get_subscription( $invoice->get_subscription_id() ); |
|
455 | + $subscription = getpaid_get_subscription($invoice->get_subscription_id()); |
|
456 | 456 | |
457 | 457 | // Renew the subscription. |
458 | - if ( $subscription && $subscription->exists() ) { |
|
459 | - $subscription->add_payment( array(), $invoice ); |
|
460 | - $subscription->renew( strtotime( $invoice->get_date_created() ) ); |
|
458 | + if ($subscription && $subscription->exists()) { |
|
459 | + $subscription->add_payment(array(), $invoice); |
|
460 | + $subscription->renew(strtotime($invoice->get_date_created())); |
|
461 | 461 | } |
462 | 462 | } |
463 | 463 | |
@@ -472,8 +472,8 @@ discard block |
||
472 | 472 | * @param int $invoice Invoice ID. |
473 | 473 | * @return bool True when invoice created via payment form else false. |
474 | 474 | */ |
475 | - public function force_is_payment_form_invoice( $is_payment_form_invoice, $invoice ) { |
|
476 | - if ( $is_payment_form_invoice ) { |
|
475 | + public function force_is_payment_form_invoice($is_payment_form_invoice, $invoice) { |
|
476 | + if ($is_payment_form_invoice) { |
|
477 | 477 | $is_payment_form_invoice = false; |
478 | 478 | } |
479 | 479 |
@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( ! $is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( ! $is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,156 +49,156 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | |
83 | - $args = wp_parse_args( $args ); |
|
83 | + $args = wp_parse_args($args); |
|
84 | 84 | |
85 | - if ( ! empty( $args['invoice_key'] ) ) { |
|
86 | - $invoice = wpinv_get_invoice( $args['invoice_key'] ); |
|
85 | + if (!empty($args['invoice_key'])) { |
|
86 | + $invoice = wpinv_get_invoice($args['invoice_key']); |
|
87 | 87 | |
88 | - if ( $invoice && $invoice->exists() ) { |
|
88 | + if ($invoice && $invoice->exists()) { |
|
89 | 89 | $success_page = $invoice->get_receipt_url(); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - if ( empty( $success_page ) ) { |
|
93 | + if (empty($success_page)) { |
|
94 | 94 | $success_page = wpinv_get_success_page_uri(); |
95 | 95 | } |
96 | 96 | |
97 | - $args['wpinv-notice'] = current( array_keys( wpinv_get_errors() ) ); |
|
97 | + $args['wpinv-notice'] = current(array_keys(wpinv_get_errors())); |
|
98 | 98 | |
99 | - $redirect = add_query_arg( $args, $success_page ); |
|
99 | + $redirect = add_query_arg($args, $success_page); |
|
100 | 100 | |
101 | - $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args, $success_page ); |
|
101 | + $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args, $success_page); |
|
102 | 102 | |
103 | - wp_redirect( $redirect ); |
|
103 | + wp_redirect($redirect); |
|
104 | 104 | exit; |
105 | 105 | } |
106 | 106 | |
107 | -function wpinv_send_to_failed_page( $args = null ) { |
|
107 | +function wpinv_send_to_failed_page($args = null) { |
|
108 | 108 | $redirect = wpinv_get_failed_transaction_uri(); |
109 | 109 | |
110 | - if ( ! empty( $args ) ) { |
|
110 | + if (!empty($args)) { |
|
111 | 111 | // Check for backward compatibility |
112 | - if ( is_string( $args ) ) { |
|
113 | - $args = str_replace( '?', '', $args ); |
|
112 | + if (is_string($args)) { |
|
113 | + $args = str_replace('?', '', $args); |
|
114 | 114 | } |
115 | 115 | |
116 | - $args = wp_parse_args( $args ); |
|
116 | + $args = wp_parse_args($args); |
|
117 | 117 | |
118 | - $redirect = add_query_arg( $args, $redirect ); |
|
118 | + $redirect = add_query_arg($args, $redirect); |
|
119 | 119 | } |
120 | 120 | |
121 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
121 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
122 | 122 | |
123 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
124 | - wp_redirect( $redirect ); |
|
123 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
124 | + wp_redirect($redirect); |
|
125 | 125 | exit; |
126 | 126 | } |
127 | 127 | |
128 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
129 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
130 | - $uri = isset( $uri ) ? get_permalink( $uri ) : null; |
|
128 | +function wpinv_get_checkout_uri($args = array()) { |
|
129 | + $uri = wpinv_get_option('checkout_page', false); |
|
130 | + $uri = isset($uri) ? get_permalink($uri) : null; |
|
131 | 131 | |
132 | - if ( ! empty( $args ) ) { |
|
132 | + if (!empty($args)) { |
|
133 | 133 | // Check for backward compatibility |
134 | - if ( is_string( $args ) ) { |
|
135 | - $args = str_replace( '?', '', $args ); |
|
134 | + if (is_string($args)) { |
|
135 | + $args = str_replace('?', '', $args); |
|
136 | 136 | } |
137 | 137 | |
138 | - $args = wp_parse_args( $args ); |
|
138 | + $args = wp_parse_args($args); |
|
139 | 139 | |
140 | - $uri = add_query_arg( $args, $uri ); |
|
140 | + $uri = add_query_arg($args, $uri); |
|
141 | 141 | } |
142 | 142 | |
143 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
143 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
144 | 144 | |
145 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
145 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
146 | 146 | |
147 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
148 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
147 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
148 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
149 | 149 | } |
150 | 150 | |
151 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
151 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
152 | 152 | } |
153 | 153 | |
154 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
155 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
156 | - $success_page = get_permalink( $success_page ); |
|
154 | +function wpinv_get_success_page_url($query_string = null) { |
|
155 | + $success_page = wpinv_get_option('success_page', 0); |
|
156 | + $success_page = get_permalink($success_page); |
|
157 | 157 | |
158 | - if ( $query_string ) { |
|
158 | + if ($query_string) { |
|
159 | 159 | $success_page .= $query_string; |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
162 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
163 | 163 | } |
164 | 164 | |
165 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
166 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
167 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
165 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
166 | + $uri = wpinv_get_option('failure_page', ''); |
|
167 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
168 | 168 | |
169 | - if ( $extras ) { |
|
169 | + if ($extras) { |
|
170 | 170 | $uri .= $extras; |
171 | 171 | } |
172 | 172 | |
173 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
173 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | function wpinv_is_failed_transaction_page() { |
177 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
178 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
177 | + $ret = wpinv_get_option('failure_page', false); |
|
178 | + $ret = isset($ret) ? is_page($ret) : false; |
|
179 | 179 | |
180 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
180 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
181 | 181 | } |
182 | 182 | |
183 | -function wpinv_transaction_query( $type = 'start' ) { |
|
183 | +function wpinv_transaction_query($type = 'start') { |
|
184 | 184 | global $wpdb; |
185 | 185 | |
186 | 186 | $wpdb->hide_errors(); |
187 | 187 | |
188 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
189 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
188 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
189 | + define('WPINV_USE_TRANSACTIONS', true); |
|
190 | 190 | } |
191 | 191 | |
192 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
193 | - switch ( $type ) { |
|
192 | + if (WPINV_USE_TRANSACTIONS) { |
|
193 | + switch ($type) { |
|
194 | 194 | case 'commit': |
195 | - $wpdb->query( 'COMMIT' ); |
|
195 | + $wpdb->query('COMMIT'); |
|
196 | 196 | break; |
197 | 197 | case 'rollback': |
198 | - $wpdb->query( 'ROLLBACK' ); |
|
198 | + $wpdb->query('ROLLBACK'); |
|
199 | 199 | break; |
200 | 200 | default: |
201 | - $wpdb->query( 'START TRANSACTION' ); |
|
201 | + $wpdb->query('START TRANSACTION'); |
|
202 | 202 | break; |
203 | 203 | } |
204 | 204 | } |
@@ -207,146 +207,146 @@ discard block |
||
207 | 207 | function wpinv_get_prefix() { |
208 | 208 | $invoice_prefix = 'INV-'; |
209 | 209 | |
210 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
210 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | function wpinv_get_business_logo() { |
214 | - $business_logo = wpinv_get_option( 'logo' ); |
|
215 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
214 | + $business_logo = wpinv_get_option('logo'); |
|
215 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | function wpinv_get_business_name() { |
219 | - $name = wpinv_get_option( 'store_name', wpinv_get_blogname() ); |
|
219 | + $name = wpinv_get_option('store_name', wpinv_get_blogname()); |
|
220 | 220 | |
221 | - if ( empty( $name ) ) { |
|
221 | + if (empty($name)) { |
|
222 | 222 | $name = wpinv_get_blogname(); |
223 | 223 | } |
224 | 224 | |
225 | - return apply_filters( 'wpinv_get_business_name', $name ); |
|
225 | + return apply_filters('wpinv_get_business_name', $name); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | function wpinv_get_blogname() { |
229 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
229 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | function wpinv_get_admin_email() { |
233 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
234 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
233 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
234 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | function wpinv_get_business_website() { |
238 | - $business_website = home_url( '/' ); |
|
239 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
238 | + $business_website = home_url('/'); |
|
239 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
240 | 240 | } |
241 | 241 | |
242 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
242 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
243 | 243 | $terms_text = ''; |
244 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
244 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_get_business_footer() { |
248 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
249 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
250 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
248 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
249 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
250 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
251 | 251 | } |
252 | 252 | |
253 | 253 | function wpinv_checkout_required_fields() { |
254 | 254 | $required_fields = array(); |
255 | 255 | |
256 | 256 | // Let payment gateways and other extensions determine if address fields should be required |
257 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
257 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
258 | 258 | |
259 | - if ( $require_billing_details ) { |
|
260 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
259 | + if ($require_billing_details) { |
|
260 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
261 | 261 | $required_fields['first_name'] = array( |
262 | 262 | 'error_id' => 'invalid_first_name', |
263 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ), |
|
263 | + 'error_message' => __('Please enter your first name', 'invoicing'), |
|
264 | 264 | ); |
265 | 265 | } |
266 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
266 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
267 | 267 | $required_fields['address'] = array( |
268 | 268 | 'error_id' => 'invalid_address', |
269 | - 'error_message' => __( 'Please enter your address', 'invoicing' ), |
|
269 | + 'error_message' => __('Please enter your address', 'invoicing'), |
|
270 | 270 | ); |
271 | 271 | } |
272 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
272 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
273 | 273 | $required_fields['city'] = array( |
274 | 274 | 'error_id' => 'invalid_city', |
275 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ), |
|
275 | + 'error_message' => __('Please enter your billing city', 'invoicing'), |
|
276 | 276 | ); |
277 | 277 | } |
278 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
278 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
279 | 279 | $required_fields['state'] = array( |
280 | 280 | 'error_id' => 'invalid_state', |
281 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ), |
|
281 | + 'error_message' => __('Please enter billing state / province', 'invoicing'), |
|
282 | 282 | ); |
283 | 283 | } |
284 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
284 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
285 | 285 | $required_fields['country'] = array( |
286 | 286 | 'error_id' => 'invalid_country', |
287 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ), |
|
287 | + 'error_message' => __('Please select your billing country', 'invoicing'), |
|
288 | 288 | ); |
289 | 289 | } |
290 | 290 | } |
291 | 291 | |
292 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
292 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | function wpinv_is_ssl_enforced() { |
296 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
297 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
296 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
297 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | function wpinv_schedule_event_twicedaily() { |
301 | 301 | wpinv_email_payment_reminders(); |
302 | 302 | } |
303 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
303 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
304 | 304 | |
305 | 305 | function wpinv_require_login_to_checkout() { |
306 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
307 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
306 | + $return = wpinv_get_option('login_to_checkout', false); |
|
307 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
308 | 308 | } |
309 | 309 | |
310 | -function wpinv_sequential_number_active( $type = '' ) { |
|
311 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
312 | - if ( null !== $check ) { |
|
310 | +function wpinv_sequential_number_active($type = '') { |
|
311 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
312 | + if (null !== $check) { |
|
313 | 313 | return $check; |
314 | 314 | } |
315 | 315 | |
316 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
316 | + return wpinv_get_option('sequential_invoice_number'); |
|
317 | 317 | } |
318 | 318 | |
319 | -function wpinv_switch_to_locale( $locale = null ) { |
|
319 | +function wpinv_switch_to_locale($locale = null) { |
|
320 | 320 | global $invoicing, $wpi_switch_locale; |
321 | 321 | |
322 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
323 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
322 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
323 | + $locale = empty($locale) ? get_locale() : $locale; |
|
324 | 324 | |
325 | - switch_to_locale( $locale ); |
|
325 | + switch_to_locale($locale); |
|
326 | 326 | |
327 | 327 | $wpi_switch_locale = $locale; |
328 | 328 | |
329 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
329 | + add_filter('plugin_locale', 'get_locale'); |
|
330 | 330 | |
331 | 331 | $invoicing->load_textdomain(); |
332 | 332 | |
333 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
333 | + do_action('wpinv_switch_to_locale', $locale); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_restore_locale() { |
338 | 338 | global $invoicing, $wpi_switch_locale; |
339 | 339 | |
340 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
340 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
341 | 341 | restore_previous_locale(); |
342 | 342 | |
343 | 343 | $wpi_switch_locale = null; |
344 | 344 | |
345 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
345 | + remove_filter('plugin_locale', 'get_locale'); |
|
346 | 346 | |
347 | 347 | $invoicing->load_textdomain(); |
348 | 348 | |
349 | - do_action( 'wpinv_restore_locale' ); |
|
349 | + do_action('wpinv_restore_locale'); |
|
350 | 350 | } |
351 | 351 | } |
352 | 352 | |
@@ -354,26 +354,26 @@ discard block |
||
354 | 354 | * Returns the default form's id. |
355 | 355 | */ |
356 | 356 | function wpinv_get_default_payment_form() { |
357 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
357 | + $form = get_option('wpinv_default_payment_form'); |
|
358 | 358 | |
359 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
359 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
360 | 360 | $form = wp_insert_post( |
361 | 361 | array( |
362 | 362 | 'post_type' => 'wpi_payment_form', |
363 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
363 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
364 | 364 | 'post_status' => 'publish', |
365 | 365 | 'meta_input' => array( |
366 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
366 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
367 | 367 | 'wpinv_form_items' => array(), |
368 | 368 | ), |
369 | 369 | ) |
370 | 370 | ); |
371 | 371 | |
372 | - update_option( 'wpinv_default_payment_form', $form ); |
|
372 | + update_option('wpinv_default_payment_form', $form); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | // WPML support. |
376 | - return (int) wpinv_translate_post_id( $form ); |
|
376 | + return (int) wpinv_translate_post_id($form); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -381,21 +381,21 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @param int $post_id |
383 | 383 | */ |
384 | -function wpinv_translate_post_id( $post_id ) { |
|
384 | +function wpinv_translate_post_id($post_id) { |
|
385 | 385 | |
386 | 386 | // Abort if no post id is given. |
387 | - if ( empty( $post_id ) ) { |
|
387 | + if (empty($post_id)) { |
|
388 | 388 | return $post_id; |
389 | 389 | } |
390 | 390 | |
391 | 391 | // WPML. |
392 | - $post_id = apply_filters( 'wpml_object_id', $post_id, 'wpi_payment_form', true ); |
|
392 | + $post_id = apply_filters('wpml_object_id', $post_id, 'wpi_payment_form', true); |
|
393 | 393 | |
394 | 394 | // Polylang. |
395 | - if ( function_exists( 'pll_get_post' ) ) { |
|
396 | - $translated = pll_get_post( $post_id ); |
|
395 | + if (function_exists('pll_get_post')) { |
|
396 | + $translated = pll_get_post($post_id); |
|
397 | 397 | |
398 | - if ( ! empty( $translated ) ) { |
|
398 | + if (!empty($translated)) { |
|
399 | 399 | $post_id = $translated; |
400 | 400 | } |
401 | 401 | } |
@@ -408,19 +408,19 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param int $payment_form |
410 | 410 | */ |
411 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
411 | +function getpaid_get_payment_form_elements($payment_form) { |
|
412 | 412 | |
413 | - if ( empty( $payment_form ) ) { |
|
414 | - return wpinv_get_data( 'sample-payment-form' ); |
|
413 | + if (empty($payment_form)) { |
|
414 | + return wpinv_get_data('sample-payment-form'); |
|
415 | 415 | } |
416 | 416 | |
417 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
417 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
418 | 418 | |
419 | - if ( is_array( $form_elements ) ) { |
|
419 | + if (is_array($form_elements)) { |
|
420 | 420 | return $form_elements; |
421 | 421 | } |
422 | 422 | |
423 | - return wpinv_get_data( 'sample-payment-form' ); |
|
423 | + return wpinv_get_data('sample-payment-form'); |
|
424 | 424 | |
425 | 425 | } |
426 | 426 | |
@@ -429,65 +429,65 @@ discard block |
||
429 | 429 | * |
430 | 430 | * @param int $payment_form |
431 | 431 | */ |
432 | -function gepaid_get_form_items( $id ) { |
|
433 | - $form = new GetPaid_Payment_Form( $id ); |
|
432 | +function gepaid_get_form_items($id) { |
|
433 | + $form = new GetPaid_Payment_Form($id); |
|
434 | 434 | |
435 | 435 | // Is this a default form? |
436 | - if ( $form->is_default() ) { |
|
436 | + if ($form->is_default()) { |
|
437 | 437 | return array(); |
438 | 438 | } |
439 | 439 | |
440 | - return $form->get_items( 'view', 'arrays' ); |
|
440 | + return $form->get_items('view', 'arrays'); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
444 | 444 | * Trims each line in a paragraph. |
445 | 445 | * |
446 | 446 | */ |
447 | -function gepaid_trim_lines( $content ) { |
|
448 | - return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) ); |
|
447 | +function gepaid_trim_lines($content) { |
|
448 | + return implode("\n", array_map('trim', explode("\n", $content))); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | |
452 | -function wpinv_add_elementor_widget_categories( $elements_manager ) { |
|
452 | +function wpinv_add_elementor_widget_categories($elements_manager) { |
|
453 | 453 | $elements_manager->add_category( |
454 | 454 | 'getpaid', |
455 | 455 | array( |
456 | - 'title' => esc_html__( 'GetPaid', 'invoicing' ), |
|
456 | + 'title' => esc_html__('GetPaid', 'invoicing'), |
|
457 | 457 | 'icon' => 'fa fa-plug', |
458 | 458 | ) |
459 | 459 | ); |
460 | 460 | } |
461 | -add_filter( 'elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories' ); |
|
461 | +add_filter('elementor/elements/categories_registered', 'wpinv_add_elementor_widget_categories'); |
|
462 | 462 | |
463 | -function wpinv_alter_elementor_widget_config( $config ) { |
|
463 | +function wpinv_alter_elementor_widget_config($config) { |
|
464 | 464 | |
465 | - if ( ! empty( $config['initial_document']['widgets'] ) ) { |
|
466 | - foreach ( $config['initial_document']['widgets'] as $key => $widget ) { |
|
467 | - if ( substr( $key, 0, 16 ) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid' ) { |
|
468 | - $config['initial_document']['widgets'][ $key ]['categories'][] = 'getpaid'; |
|
469 | - $config['initial_document']['widgets'][ $key ]['hide_on_search'] = false; |
|
470 | - $config['initial_document']['widgets'][ $key ]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i> |
|
465 | + if (!empty($config['initial_document']['widgets'])) { |
|
466 | + foreach ($config['initial_document']['widgets'] as $key => $widget) { |
|
467 | + if (substr($key, 0, 16) === 'wp-widget-wpinv_' || $key === 'wp-widget-getpaid') { |
|
468 | + $config['initial_document']['widgets'][$key]['categories'][] = 'getpaid'; |
|
469 | + $config['initial_document']['widgets'][$key]['hide_on_search'] = false; |
|
470 | + $config['initial_document']['widgets'][$key]['icon'] = 'eicon-globe'; //@todo if no icons use on page then font-awesome is not loaded, wif we can fifure out how to force load we can use icons. <i class="fas fa-globe-americas"></i><i class="fa-solid fa-earth-americas"></i> |
|
471 | 471 | } |
472 | 472 | } |
473 | 473 | } |
474 | 474 | |
475 | 475 | return $config; |
476 | 476 | } |
477 | -add_filter( 'elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config' ); |
|
477 | +add_filter('elementor/editor/localize_settings', 'wpinv_alter_elementor_widget_config'); |
|
478 | 478 | |
479 | 479 | function wpinv_get_report_graphs() { |
480 | 480 | |
481 | 481 | return apply_filters( |
482 | 482 | 'getpaid_report_graphs', |
483 | 483 | array( |
484 | - 'sales' => __( 'Earnings', 'invoicing' ), |
|
485 | - 'refunds' => __( 'Refunds', 'invoicing' ), |
|
486 | - 'tax' => __( 'Taxes', 'invoicing' ), |
|
487 | - 'fees' => __( 'Fees', 'invoicing' ), |
|
488 | - 'discount' => __( 'Discounts', 'invoicing' ), |
|
489 | - 'invoices' => __( 'Invoices', 'invoicing' ), |
|
490 | - 'items' => __( 'Purchased Items', 'invoicing' ), |
|
484 | + 'sales' => __('Earnings', 'invoicing'), |
|
485 | + 'refunds' => __('Refunds', 'invoicing'), |
|
486 | + 'tax' => __('Taxes', 'invoicing'), |
|
487 | + 'fees' => __('Fees', 'invoicing'), |
|
488 | + 'discount' => __('Discounts', 'invoicing'), |
|
489 | + 'invoices' => __('Invoices', 'invoicing'), |
|
490 | + 'items' => __('Purchased Items', 'invoicing'), |
|
491 | 491 | ) |
492 | 492 | ); |
493 | 493 | |
@@ -501,18 +501,18 @@ discard block |
||
501 | 501 | * @return bool|WP_Filesystem The WP Filesystem object or false on failure. |
502 | 502 | */ |
503 | 503 | function getpaid_wp_filesystem() { |
504 | - if ( ! function_exists( 'get_filesystem_method' ) ) { |
|
505 | - require_once( ABSPATH . "/wp-admin/includes/file.php" ); |
|
504 | + if (!function_exists('get_filesystem_method')) { |
|
505 | + require_once(ABSPATH . "/wp-admin/includes/file.php"); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | $access_type = get_filesystem_method(); |
509 | 509 | |
510 | - if ( $access_type === 'direct' ) { |
|
510 | + if ($access_type === 'direct') { |
|
511 | 511 | /* You can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
512 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
512 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
513 | 513 | |
514 | 514 | /* Initialize the API */ |
515 | - if ( ! WP_Filesystem( $creds ) ) { |
|
515 | + if (!WP_Filesystem($creds)) { |
|
516 | 516 | /* Any problems and we exit */ |
517 | 517 | return false; |
518 | 518 | } |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | |
522 | 522 | return $wp_filesystem; |
523 | 523 | /* Do our file manipulations below */ |
524 | - } else if ( defined( 'FTP_USER' ) ) { |
|
525 | - $creds = request_filesystem_credentials( trailingslashit( site_url() ) . 'wp-admin/', '', false, false, array() ); |
|
524 | + } else if (defined('FTP_USER')) { |
|
525 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
526 | 526 | |
527 | 527 | /* Initialize the API */ |
528 | - if ( ! WP_Filesystem( $creds ) ) { |
|
528 | + if (!WP_Filesystem($creds)) { |
|
529 | 529 | /* Any problems and we exit */ |
530 | 530 | return false; |
531 | 531 | } |
@@ -551,11 +551,11 @@ discard block |
||
551 | 551 | |
552 | 552 | $language_file = WPINV_PLUGIN_DIR . 'db-language.php'; |
553 | 553 | |
554 | - if ( is_file( $language_file ) && ! is_writable( $language_file ) ) { |
|
554 | + if (is_file($language_file) && !is_writable($language_file)) { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | |
558 | - if ( ! is_file( $language_file ) && ! is_writable( dirname( $language_file ) ) ) { |
|
558 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) { |
|
559 | 559 | return false; |
560 | 560 | } |
561 | 561 | |
@@ -573,35 +573,35 @@ discard block |
||
573 | 573 | $footer = array(); |
574 | 574 | $footer[] = ""; |
575 | 575 | $footer[] = ""; |
576 | - $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate( 'Y-m-d H:i:s' ) . " ***/"; |
|
576 | + $footer[] = "/*** GetPaid " . WPINV_VERSION . " @ " . gmdate('Y-m-d H:i:s') . " ***/"; |
|
577 | 577 | $footer[] = ""; |
578 | 578 | |
579 | - $contents = implode( PHP_EOL, $head ); |
|
579 | + $contents = implode(PHP_EOL, $head); |
|
580 | 580 | |
581 | 581 | $strings = getpaid_get_db_language_strings(); |
582 | 582 | |
583 | - if ( ! empty( $strings ) ) { |
|
583 | + if (!empty($strings)) { |
|
584 | 584 | $is_wpml = getpaid_is_wpml(); |
585 | 585 | |
586 | - foreach ( $strings as $string ) { |
|
587 | - if ( is_scalar( $string ) && $string != '' ) { |
|
588 | - do_action( 'getpaid_db_language_add_string', $string ); |
|
586 | + foreach ($strings as $string) { |
|
587 | + if (is_scalar($string) && $string != '') { |
|
588 | + do_action('getpaid_db_language_add_string', $string); |
|
589 | 589 | |
590 | - if ( $is_wpml ) { |
|
590 | + if ($is_wpml) { |
|
591 | 591 | // Registers a individual text string for WPML translation. |
592 | - do_action( 'wpml_register_single_string', 'invoicing', '', $string ); |
|
592 | + do_action('wpml_register_single_string', 'invoicing', '', $string); |
|
593 | 593 | } |
594 | 594 | |
595 | - $string = str_replace( "'", "\'", $string ); |
|
595 | + $string = str_replace("'", "\'", $string); |
|
596 | 596 | |
597 | 597 | $contents .= PHP_EOL . "__( '" . $string . "', 'invoicing' );"; |
598 | 598 | } |
599 | 599 | } |
600 | 600 | } |
601 | 601 | |
602 | - $contents .= implode( PHP_EOL, $footer ); |
|
602 | + $contents .= implode(PHP_EOL, $footer); |
|
603 | 603 | |
604 | - if ( $wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE ) ) { |
|
604 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) { |
|
605 | 605 | return true; |
606 | 606 | } else { |
607 | 607 | return false; |
@@ -637,62 +637,62 @@ discard block |
||
637 | 637 | * |
638 | 638 | * @param array $setting_keys Array of setting keys. |
639 | 639 | */ |
640 | - $setting_keys = apply_filters( 'getpaid_options_to_db_language_strings', $setting_keys ); |
|
640 | + $setting_keys = apply_filters('getpaid_options_to_db_language_strings', $setting_keys); |
|
641 | 641 | |
642 | - $setting_keys = array_unique( $setting_keys ); |
|
642 | + $setting_keys = array_unique($setting_keys); |
|
643 | 643 | |
644 | - if ( ! empty( $settings ) && ! empty( $setting_keys ) ) { |
|
645 | - foreach ( $setting_keys as $setting_key ) { |
|
646 | - if ( ! empty( $settings[ $setting_key ] ) && is_string( $settings[ $setting_key ] ) ) { |
|
647 | - $strings[] = wp_unslash( $settings[ $setting_key ] ); |
|
644 | + if (!empty($settings) && !empty($setting_keys)) { |
|
645 | + foreach ($setting_keys as $setting_key) { |
|
646 | + if (!empty($settings[$setting_key]) && is_string($settings[$setting_key])) { |
|
647 | + $strings[] = wp_unslash($settings[$setting_key]); |
|
648 | 648 | } |
649 | 649 | } |
650 | 650 | } |
651 | 651 | |
652 | 652 | // Payment forms |
653 | - $results = $wpdb->get_col( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
653 | + $results = $wpdb->get_col("SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'"); |
|
654 | 654 | |
655 | - if ( ! empty( $results ) ) { |
|
656 | - $string_keys = array( 'label', 'placeholder', 'description', 'text', 'input_label', 'button_label' ); |
|
655 | + if (!empty($results)) { |
|
656 | + $string_keys = array('label', 'placeholder', 'description', 'text', 'input_label', 'button_label'); |
|
657 | 657 | |
658 | - foreach ( $results as $meta_value ) { |
|
659 | - $fields = maybe_unserialize( $meta_value ); |
|
658 | + foreach ($results as $meta_value) { |
|
659 | + $fields = maybe_unserialize($meta_value); |
|
660 | 660 | |
661 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
662 | - foreach ( $fields as $field ) { |
|
661 | + if (!empty($fields) && is_array($fields)) { |
|
662 | + foreach ($fields as $field) { |
|
663 | 663 | // Labels |
664 | - foreach ( $string_keys as $string_key ) { |
|
665 | - if ( ! empty( $field[ $string_key ] ) && is_string( $field[ $string_key ] ) ) { |
|
666 | - $strings[] = wp_unslash( $field[ $string_key ] ); |
|
664 | + foreach ($string_keys as $string_key) { |
|
665 | + if (!empty($field[$string_key]) && is_string($field[$string_key])) { |
|
666 | + $strings[] = wp_unslash($field[$string_key]); |
|
667 | 667 | } |
668 | 668 | } |
669 | 669 | |
670 | 670 | // Address fields |
671 | - if ( ! empty( $field['fields'] ) && ! empty( $field['fields'] ) ) { |
|
672 | - foreach ( $field['fields'] as $sub_field ) { |
|
673 | - foreach ( $string_keys as $string_key ) { |
|
674 | - if ( ! empty( $sub_field[ $string_key ] ) && is_string( $sub_field[ $string_key ] ) ) { |
|
675 | - $strings[] = wp_unslash( $sub_field[ $string_key ] ); |
|
671 | + if (!empty($field['fields']) && !empty($field['fields'])) { |
|
672 | + foreach ($field['fields'] as $sub_field) { |
|
673 | + foreach ($string_keys as $string_key) { |
|
674 | + if (!empty($sub_field[$string_key]) && is_string($sub_field[$string_key])) { |
|
675 | + $strings[] = wp_unslash($sub_field[$string_key]); |
|
676 | 676 | } |
677 | 677 | } |
678 | 678 | } |
679 | 679 | } |
680 | 680 | |
681 | 681 | // Options |
682 | - if ( ! empty( $field['options'] ) ) { |
|
682 | + if (!empty($field['options'])) { |
|
683 | 683 | $options = array(); |
684 | 684 | |
685 | - if ( is_array( $field['options'] ) ) { |
|
685 | + if (is_array($field['options'])) { |
|
686 | 686 | $options = $field['options']; |
687 | - } else if ( is_string( $field['options'] ) ) { |
|
688 | - $options = getpaid_convert_price_string_to_options( $field['options'], false ); |
|
689 | - $options = ! empty( $options ) ? array_values( $options ) : array(); |
|
687 | + } else if (is_string($field['options'])) { |
|
688 | + $options = getpaid_convert_price_string_to_options($field['options'], false); |
|
689 | + $options = !empty($options) ? array_values($options) : array(); |
|
690 | 690 | } |
691 | 691 | |
692 | - if ( ! empty( $options ) ) { |
|
693 | - foreach( $options as $option ) { |
|
694 | - if ( ! empty( $option ) && is_string( $option ) ) { |
|
695 | - $strings[] = wp_unslash( $option ); |
|
692 | + if (!empty($options)) { |
|
693 | + foreach ($options as $option) { |
|
694 | + if (!empty($option) && is_string($option)) { |
|
695 | + $strings[] = wp_unslash($option); |
|
696 | 696 | } |
697 | 697 | } |
698 | 698 | } |
@@ -709,9 +709,9 @@ discard block |
||
709 | 709 | * |
710 | 710 | * @param array $strings Array of strings. |
711 | 711 | */ |
712 | - $strings = apply_filters( 'getpaid_db_language_strings', $strings ); |
|
712 | + $strings = apply_filters('getpaid_db_language_strings', $strings); |
|
713 | 713 | |
714 | - $strings = array_unique( $strings ); |
|
714 | + $strings = array_unique($strings); |
|
715 | 715 | |
716 | 716 | return $strings; |
717 | 717 | } |
@@ -724,7 +724,7 @@ discard block |
||
724 | 724 | * @return bool True if active else false. |
725 | 725 | */ |
726 | 726 | function getpaid_is_wpml() { |
727 | - if ( defined( 'ICL_SITEPRESS_VERSION' ) && ! ICL_PLUGIN_INACTIVE && class_exists( 'SitePress', false ) && function_exists( 'icl_object_id' ) ) { |
|
727 | + if (defined('ICL_SITEPRESS_VERSION') && !ICL_PLUGIN_INACTIVE && class_exists('SitePress', false) && function_exists('icl_object_id')) { |
|
728 | 728 | return true; |
729 | 729 | } |
730 | 730 |
@@ -4,99 +4,99 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Displays an invoice. |
11 | 11 | * |
12 | 12 | * @param WPInv_Invoice $invoice. |
13 | 13 | */ |
14 | -function getpaid_invoice( $invoice ) { |
|
15 | - if ( ! empty( $invoice ) ) { |
|
16 | - wpinv_get_template( 'invoice/invoice.php', compact( 'invoice' ) ); |
|
14 | +function getpaid_invoice($invoice) { |
|
15 | + if (!empty($invoice)) { |
|
16 | + wpinv_get_template('invoice/invoice.php', compact('invoice')); |
|
17 | 17 | } |
18 | 18 | } |
19 | -add_action( 'getpaid_invoice', 'getpaid_invoice', 10 ); |
|
19 | +add_action('getpaid_invoice', 'getpaid_invoice', 10); |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * Displays the invoice footer. |
23 | 23 | */ |
24 | -function getpaid_invoice_footer( $invoice ) { |
|
25 | - if ( ! empty( $invoice ) ) { |
|
26 | - wpinv_get_template( 'invoice/footer.php', compact( 'invoice' ) ); |
|
24 | +function getpaid_invoice_footer($invoice) { |
|
25 | + if (!empty($invoice)) { |
|
26 | + wpinv_get_template('invoice/footer.php', compact('invoice')); |
|
27 | 27 | } |
28 | 28 | } |
29 | -add_action( 'getpaid_invoice_footer', 'getpaid_invoice_footer', 10 ); |
|
29 | +add_action('getpaid_invoice_footer', 'getpaid_invoice_footer', 10); |
|
30 | 30 | |
31 | 31 | /** |
32 | 32 | * Displays the invoice top bar. |
33 | 33 | */ |
34 | -function getpaid_invoice_header( $invoice ) { |
|
35 | - if ( ! empty( $invoice ) ) { |
|
36 | - wpinv_get_template( 'invoice/header.php', compact( 'invoice' ) ); |
|
34 | +function getpaid_invoice_header($invoice) { |
|
35 | + if (!empty($invoice)) { |
|
36 | + wpinv_get_template('invoice/header.php', compact('invoice')); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'getpaid_invoice_header', 'getpaid_invoice_header', 10 ); |
|
39 | +add_action('getpaid_invoice_header', 'getpaid_invoice_header', 10); |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Displays actions on the left side of the header. |
43 | 43 | */ |
44 | -function getpaid_invoice_header_left_actions( $invoice ) { |
|
45 | - if ( ! empty( $invoice ) ) { |
|
46 | - wpinv_get_template( 'invoice/header-left-actions.php', compact( 'invoice' ) ); |
|
44 | +function getpaid_invoice_header_left_actions($invoice) { |
|
45 | + if (!empty($invoice)) { |
|
46 | + wpinv_get_template('invoice/header-left-actions.php', compact('invoice')); |
|
47 | 47 | } |
48 | 48 | } |
49 | -add_action( 'getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10 ); |
|
49 | +add_action('getpaid_invoice_header_left', 'getpaid_invoice_header_left_actions', 10); |
|
50 | 50 | |
51 | 51 | /** |
52 | 52 | * Displays actions on the right side of the invoice top bar. |
53 | 53 | */ |
54 | -function getpaid_invoice_header_right_actions( $invoice ) { |
|
55 | - if ( ! empty( $invoice ) ) { |
|
56 | - wpinv_get_template( 'invoice/header-right-actions.php', compact( 'invoice' ) ); |
|
54 | +function getpaid_invoice_header_right_actions($invoice) { |
|
55 | + if (!empty($invoice)) { |
|
56 | + wpinv_get_template('invoice/header-right-actions.php', compact('invoice')); |
|
57 | 57 | } |
58 | 58 | } |
59 | -add_action( 'getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10 ); |
|
59 | +add_action('getpaid_invoice_header_right', 'getpaid_invoice_header_right_actions', 10); |
|
60 | 60 | |
61 | 61 | /** |
62 | 62 | * Displays the invoice title, logo etc. |
63 | 63 | */ |
64 | -function getpaid_invoice_details_top( $invoice ) { |
|
65 | - if ( ! empty( $invoice ) ) { |
|
66 | - wpinv_get_template( 'invoice/details-top.php', compact( 'invoice' ) ); |
|
64 | +function getpaid_invoice_details_top($invoice) { |
|
65 | + if (!empty($invoice)) { |
|
66 | + wpinv_get_template('invoice/details-top.php', compact('invoice')); |
|
67 | 67 | } |
68 | 68 | } |
69 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_top', 10 ); |
|
69 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_top', 10); |
|
70 | 70 | |
71 | 71 | /** |
72 | 72 | * Displays the company logo. |
73 | 73 | */ |
74 | -function getpaid_invoice_logo( $invoice ) { |
|
75 | - if ( ! empty( $invoice ) ) { |
|
76 | - wpinv_get_template( 'invoice/invoice-logo.php', compact( 'invoice' ) ); |
|
74 | +function getpaid_invoice_logo($invoice) { |
|
75 | + if (!empty($invoice)) { |
|
76 | + wpinv_get_template('invoice/invoice-logo.php', compact('invoice')); |
|
77 | 77 | } |
78 | 78 | } |
79 | -add_action( 'getpaid_invoice_details_top_left', 'getpaid_invoice_logo' ); |
|
79 | +add_action('getpaid_invoice_details_top_left', 'getpaid_invoice_logo'); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Displays the type of invoice. |
83 | 83 | */ |
84 | -function getpaid_invoice_type( $invoice ) { |
|
85 | - if ( ! empty( $invoice ) ) { |
|
86 | - wpinv_get_template( 'invoice/invoice-type.php', compact( 'invoice' ) ); |
|
84 | +function getpaid_invoice_type($invoice) { |
|
85 | + if (!empty($invoice)) { |
|
86 | + wpinv_get_template('invoice/invoice-type.php', compact('invoice')); |
|
87 | 87 | } |
88 | 88 | } |
89 | -add_action( 'getpaid_invoice_details_top_right', 'getpaid_invoice_type' ); |
|
89 | +add_action('getpaid_invoice_details_top_right', 'getpaid_invoice_type'); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * Displays the invoice details. |
93 | 93 | */ |
94 | -function getpaid_invoice_details_main( $invoice ) { |
|
95 | - if ( ! empty( $invoice ) ) { |
|
96 | - wpinv_get_template( 'invoice/details.php', compact( 'invoice' ) ); |
|
94 | +function getpaid_invoice_details_main($invoice) { |
|
95 | + if (!empty($invoice)) { |
|
96 | + wpinv_get_template('invoice/details.php', compact('invoice')); |
|
97 | 97 | } |
98 | 98 | } |
99 | -add_action( 'getpaid_invoice_details', 'getpaid_invoice_details_main', 50 ); |
|
99 | +add_action('getpaid_invoice_details', 'getpaid_invoice_details_main', 50); |
|
100 | 100 | |
101 | 101 | /** |
102 | 102 | * Returns a path to the templates directory. |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
126 | 126 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
127 | 127 | */ |
128 | -function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
129 | - getpaid_template()->display_template( $template_name, $args, $template_path, $default_path ); |
|
128 | +function wpinv_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
129 | + getpaid_template()->display_template($template_name, $args, $template_path, $default_path); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -139,8 +139,8 @@ discard block |
||
139 | 139 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
140 | 140 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
141 | 141 | */ |
142 | -function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
143 | - return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path ); |
|
142 | +function wpinv_get_template_html($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
143 | + return getpaid_template()->get_template($template_name, $args, $template_path, $default_path); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | * @return string |
150 | 150 | */ |
151 | 151 | function wpinv_template_path() { |
152 | - return apply_filters( 'wpinv_template_path', wpinv_get_theme_template_dir_name() ); |
|
152 | + return apply_filters('wpinv_template_path', wpinv_get_theme_template_dir_name()); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | function wpinv_get_theme_template_dir_name() { |
161 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
161 | + return trailingslashit(apply_filters('wpinv_templates_dir', 'invoicing')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -170,58 +170,58 @@ discard block |
||
170 | 170 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
171 | 171 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
172 | 172 | */ |
173 | -function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
174 | - return getpaid_template()->locate_template( $template_name, $template_path, $default_path ); |
|
173 | +function wpinv_locate_template($template_name, $template_path = '', $default_path = '') { |
|
174 | + return getpaid_template()->locate_template($template_name, $template_path, $default_path); |
|
175 | 175 | } |
176 | 176 | |
177 | -function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
|
178 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
177 | +function wpinv_get_template_part($slug, $name = null, $load = true) { |
|
178 | + do_action('get_template_part_' . $slug, $slug, $name); |
|
179 | 179 | |
180 | 180 | // Setup possible parts |
181 | 181 | $templates = array(); |
182 | - if ( isset( $name ) ) { |
|
182 | + if (isset($name)) { |
|
183 | 183 | $templates[] = $slug . '-' . $name . '.php'; |
184 | 184 | } |
185 | 185 | $templates[] = $slug . '.php'; |
186 | 186 | |
187 | 187 | // Allow template parts to be filtered |
188 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
188 | + $templates = apply_filters('wpinv_get_template_part', $templates, $slug, $name); |
|
189 | 189 | |
190 | 190 | // Return the part that is found |
191 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
191 | + return wpinv_locate_tmpl($templates, $load, false); |
|
192 | 192 | } |
193 | 193 | |
194 | -function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
|
194 | +function wpinv_locate_tmpl($template_names, $load = false, $require_once = true) { |
|
195 | 195 | // No file found yet |
196 | 196 | $located = false; |
197 | 197 | |
198 | 198 | // Try to find a template file |
199 | - foreach ( (array)$template_names as $template_name ) { |
|
199 | + foreach ((array) $template_names as $template_name) { |
|
200 | 200 | |
201 | 201 | // Continue if template is empty |
202 | - if ( empty( $template_name ) ) { |
|
202 | + if (empty($template_name)) { |
|
203 | 203 | continue; |
204 | 204 | } |
205 | 205 | |
206 | 206 | // Trim off any slashes from the template name |
207 | - $template_name = ltrim( $template_name, '/' ); |
|
207 | + $template_name = ltrim($template_name, '/'); |
|
208 | 208 | |
209 | 209 | // try locating this template file by looping through the template paths |
210 | - foreach ( wpinv_get_theme_template_paths() as $template_path ) { |
|
210 | + foreach (wpinv_get_theme_template_paths() as $template_path) { |
|
211 | 211 | |
212 | - if ( file_exists( $template_path . $template_name ) ) { |
|
212 | + if (file_exists($template_path . $template_name)) { |
|
213 | 213 | $located = $template_path . $template_name; |
214 | 214 | break; |
215 | 215 | } |
216 | 216 | } |
217 | 217 | |
218 | - if ( ! empty( $located ) ) { |
|
218 | + if (!empty($located)) { |
|
219 | 219 | break; |
220 | 220 | } |
221 | 221 | } |
222 | 222 | |
223 | - if ( ( true == $load ) && ! empty( $located ) ) { |
|
224 | - load_template( $located, $require_once ); |
|
223 | + if ((true == $load) && !empty($located)) { |
|
224 | + load_template($located, $require_once); |
|
225 | 225 | } |
226 | 226 | |
227 | 227 | return $located; |
@@ -231,73 +231,73 @@ discard block |
||
231 | 231 | $template_dir = wpinv_get_theme_template_dir_name(); |
232 | 232 | |
233 | 233 | $file_paths = array( |
234 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
235 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
234 | + 1 => trailingslashit(get_stylesheet_directory()) . $template_dir, |
|
235 | + 10 => trailingslashit(get_template_directory()) . $template_dir, |
|
236 | 236 | 100 => wpinv_get_templates_dir(), |
237 | 237 | ); |
238 | 238 | |
239 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
239 | + $file_paths = apply_filters('wpinv_template_paths', $file_paths); |
|
240 | 240 | |
241 | 241 | // sort the file paths based on priority |
242 | - ksort( $file_paths, SORT_NUMERIC ); |
|
242 | + ksort($file_paths, SORT_NUMERIC); |
|
243 | 243 | |
244 | - return array_map( 'trailingslashit', $file_paths ); |
|
244 | + return array_map('trailingslashit', $file_paths); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | function wpinv_checkout_meta_tags() { |
248 | 248 | |
249 | 249 | $pages = array(); |
250 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
251 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
252 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
253 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
250 | + $pages[] = wpinv_get_option('success_page'); |
|
251 | + $pages[] = wpinv_get_option('failure_page'); |
|
252 | + $pages[] = wpinv_get_option('invoice_history_page'); |
|
253 | + $pages[] = wpinv_get_option('invoice_subscription_page'); |
|
254 | 254 | |
255 | - if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) { |
|
255 | + if (!wpinv_is_checkout() && !is_page($pages)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
260 | 260 | } |
261 | -add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
|
261 | +add_action('wp_head', 'wpinv_checkout_meta_tags'); |
|
262 | 262 | |
263 | -function wpinv_add_body_classes( $class ) { |
|
264 | - $classes = (array)$class; |
|
263 | +function wpinv_add_body_classes($class) { |
|
264 | + $classes = (array) $class; |
|
265 | 265 | |
266 | - if ( wpinv_is_checkout() ) { |
|
266 | + if (wpinv_is_checkout()) { |
|
267 | 267 | $classes[] = 'wpinv-checkout'; |
268 | 268 | $classes[] = 'wpinv-page'; |
269 | 269 | } |
270 | 270 | |
271 | - if ( wpinv_is_success_page() ) { |
|
271 | + if (wpinv_is_success_page()) { |
|
272 | 272 | $classes[] = 'wpinv-success'; |
273 | 273 | $classes[] = 'wpinv-page'; |
274 | 274 | } |
275 | 275 | |
276 | - if ( wpinv_is_failed_transaction_page() ) { |
|
276 | + if (wpinv_is_failed_transaction_page()) { |
|
277 | 277 | $classes[] = 'wpinv-failed-transaction'; |
278 | 278 | $classes[] = 'wpinv-page'; |
279 | 279 | } |
280 | 280 | |
281 | - if ( wpinv_is_invoice_history_page() ) { |
|
281 | + if (wpinv_is_invoice_history_page()) { |
|
282 | 282 | $classes[] = 'wpinv-history'; |
283 | 283 | $classes[] = 'wpinv-page'; |
284 | 284 | } |
285 | 285 | |
286 | - if ( wpinv_is_subscriptions_history_page() ) { |
|
286 | + if (wpinv_is_subscriptions_history_page()) { |
|
287 | 287 | $classes[] = 'wpinv-subscription'; |
288 | 288 | $classes[] = 'wpinv-page'; |
289 | 289 | } |
290 | 290 | |
291 | - if ( wpinv_is_test_mode() ) { |
|
291 | + if (wpinv_is_test_mode()) { |
|
292 | 292 | $classes[] = 'wpinv-test-mode'; |
293 | 293 | $classes[] = 'wpinv-page'; |
294 | 294 | } |
295 | 295 | |
296 | - return array_unique( $classes ); |
|
296 | + return array_unique($classes); |
|
297 | 297 | } |
298 | -add_filter( 'body_class', 'wpinv_add_body_classes' ); |
|
298 | +add_filter('body_class', 'wpinv_add_body_classes'); |
|
299 | 299 | |
300 | -function wpinv_html_select( $args = array() ) { |
|
300 | +function wpinv_html_select($args = array()) { |
|
301 | 301 | $defaults = array( |
302 | 302 | 'options' => array(), |
303 | 303 | 'name' => null, |
@@ -306,8 +306,8 @@ discard block |
||
306 | 306 | 'selected' => 0, |
307 | 307 | 'placeholder' => null, |
308 | 308 | 'multiple' => false, |
309 | - 'show_option_all' => _x( 'All', 'all dropdown items', 'invoicing' ), |
|
310 | - 'show_option_none' => _x( 'None', 'no dropdown items', 'invoicing' ), |
|
309 | + 'show_option_all' => _x('All', 'all dropdown items', 'invoicing'), |
|
310 | + 'show_option_none' => _x('None', 'no dropdown items', 'invoicing'), |
|
311 | 311 | 'data' => array(), |
312 | 312 | 'onchange' => null, |
313 | 313 | 'required' => false, |
@@ -315,79 +315,79 @@ discard block |
||
315 | 315 | 'readonly' => false, |
316 | 316 | ); |
317 | 317 | |
318 | - $args = wp_parse_args( $args, $defaults ); |
|
318 | + $args = wp_parse_args($args, $defaults); |
|
319 | 319 | |
320 | 320 | $attrs = array( |
321 | 321 | 'name' => $args['name'], |
322 | 322 | 'id' => $args['id'], |
323 | - 'class' => 'wpinv-select ' . implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ), |
|
324 | - 'multiple' => ! empty( $args['multiple'] ), |
|
325 | - 'readonly' => ! empty( $args['readonly'] ), |
|
326 | - 'disabled' => ! empty( $args['disabled'] ), |
|
327 | - 'required' => ! empty( $args['required'] ), |
|
328 | - 'onchange' => ! empty( $args['onchange'] ), |
|
323 | + 'class' => 'wpinv-select ' . implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))), |
|
324 | + 'multiple' => !empty($args['multiple']), |
|
325 | + 'readonly' => !empty($args['readonly']), |
|
326 | + 'disabled' => !empty($args['disabled']), |
|
327 | + 'required' => !empty($args['required']), |
|
328 | + 'onchange' => !empty($args['onchange']), |
|
329 | 329 | ); |
330 | 330 | |
331 | - if ( $args['placeholder'] ) { |
|
331 | + if ($args['placeholder']) { |
|
332 | 332 | $attrs['data-placeholder'] = $args['placeholder']; |
333 | 333 | } |
334 | 334 | |
335 | - if ( $args['onchange'] ) { |
|
335 | + if ($args['onchange']) { |
|
336 | 336 | $attrs['onchange'] = $args['onchange']; |
337 | 337 | } |
338 | 338 | |
339 | - foreach ( $args['data'] as $key => $value ) { |
|
339 | + foreach ($args['data'] as $key => $value) { |
|
340 | 340 | $attrs["data-$key"] = $value; |
341 | 341 | } |
342 | 342 | |
343 | 343 | echo '<select '; |
344 | 344 | |
345 | - foreach ( $attrs as $attr => $value ) { |
|
345 | + foreach ($attrs as $attr => $value) { |
|
346 | 346 | |
347 | - if ( false === $value ) { |
|
347 | + if (false === $value) { |
|
348 | 348 | continue; |
349 | 349 | } |
350 | 350 | |
351 | - if ( true === $value ) { |
|
352 | - echo ' ' . esc_attr( $attr ); |
|
351 | + if (true === $value) { |
|
352 | + echo ' ' . esc_attr($attr); |
|
353 | 353 | } else { |
354 | - echo ' ' . esc_attr( $attr ) . '="' . esc_attr( $value ) . '"'; |
|
354 | + echo ' ' . esc_attr($attr) . '="' . esc_attr($value) . '"'; |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | } |
358 | 358 | |
359 | 359 | echo '>'; |
360 | 360 | |
361 | - if ( $args['show_option_all'] ) { |
|
362 | - if ( $args['multiple'] ) { |
|
363 | - $selected = in_array( 0, $args['selected'] ); |
|
361 | + if ($args['show_option_all']) { |
|
362 | + if ($args['multiple']) { |
|
363 | + $selected = in_array(0, $args['selected']); |
|
364 | 364 | } else { |
365 | - $selected = empty( $args['selected'] ); |
|
365 | + $selected = empty($args['selected']); |
|
366 | 366 | } |
367 | - echo '<option value="all"' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_all'] ) . '</option>'; |
|
367 | + echo '<option value="all"' . selected($selected, true, false) . '>' . esc_html($args['show_option_all']) . '</option>'; |
|
368 | 368 | } |
369 | 369 | |
370 | - if ( ! empty( $args['options'] ) ) { |
|
370 | + if (!empty($args['options'])) { |
|
371 | 371 | |
372 | - if ( $args['show_option_none'] ) { |
|
373 | - if ( $args['multiple'] ) { |
|
374 | - $selected = in_array( '', $args['selected'], true ); |
|
372 | + if ($args['show_option_none']) { |
|
373 | + if ($args['multiple']) { |
|
374 | + $selected = in_array('', $args['selected'], true); |
|
375 | 375 | } else { |
376 | 376 | $selected = $args['selected'] === ''; |
377 | 377 | } |
378 | 378 | |
379 | - echo '<option value=""' . selected( $selected, true, false ) . '>' . esc_html( $args['show_option_none'] ) . '</option>'; |
|
379 | + echo '<option value=""' . selected($selected, true, false) . '>' . esc_html($args['show_option_none']) . '</option>'; |
|
380 | 380 | } |
381 | 381 | |
382 | - foreach ( $args['options'] as $key => $option ) { |
|
382 | + foreach ($args['options'] as $key => $option) { |
|
383 | 383 | |
384 | - if ( $args['multiple'] && is_array( $args['selected'] ) ) { |
|
385 | - $selected = in_array( $key, $args['selected'], true ); |
|
384 | + if ($args['multiple'] && is_array($args['selected'])) { |
|
385 | + $selected = in_array($key, $args['selected'], true); |
|
386 | 386 | } else { |
387 | 387 | $selected = $args['selected'] === $key; |
388 | 388 | } |
389 | 389 | |
390 | - echo '<option value="' . esc_attr( $key ) . '"' . selected( $selected, true, false ) . '>' . esc_html( $option ) . '</option>'; |
|
390 | + echo '<option value="' . esc_attr($key) . '"' . selected($selected, true, false) . '>' . esc_html($option) . '</option>'; |
|
391 | 391 | } |
392 | 392 | } |
393 | 393 | |
@@ -395,7 +395,7 @@ discard block |
||
395 | 395 | |
396 | 396 | } |
397 | 397 | |
398 | -function wpinv_item_dropdown( $args = array() ) { |
|
398 | +function wpinv_item_dropdown($args = array()) { |
|
399 | 399 | $defaults = array( |
400 | 400 | 'name' => 'wpi_item', |
401 | 401 | 'id' => 'wpi_item', |
@@ -403,14 +403,14 @@ discard block |
||
403 | 403 | 'multiple' => false, |
404 | 404 | 'selected' => 0, |
405 | 405 | 'number' => -1, |
406 | - 'placeholder' => __( 'Choose a item', 'invoicing' ), |
|
407 | - 'data' => array( 'search-type' => 'item' ), |
|
406 | + 'placeholder' => __('Choose a item', 'invoicing'), |
|
407 | + 'data' => array('search-type' => 'item'), |
|
408 | 408 | 'show_option_all' => false, |
409 | 409 | 'show_option_none' => false, |
410 | 410 | 'show_recurring' => false, |
411 | 411 | ); |
412 | 412 | |
413 | - $args = wp_parse_args( $args, $defaults ); |
|
413 | + $args = wp_parse_args($args, $defaults); |
|
414 | 414 | |
415 | 415 | $item_args = array( |
416 | 416 | 'post_type' => 'wpi_item', |
@@ -428,40 +428,40 @@ discard block |
||
428 | 428 | ), |
429 | 429 | ); |
430 | 430 | |
431 | - $item_args = apply_filters( 'wpinv_item_dropdown_query_args', $item_args, $args, $defaults ); |
|
431 | + $item_args = apply_filters('wpinv_item_dropdown_query_args', $item_args, $args, $defaults); |
|
432 | 432 | |
433 | - $items = get_posts( $item_args ); |
|
433 | + $items = get_posts($item_args); |
|
434 | 434 | $options = array(); |
435 | - if ( $items ) { |
|
436 | - foreach ( $items as $item ) { |
|
437 | - $title = esc_html( $item->post_title ); |
|
435 | + if ($items) { |
|
436 | + foreach ($items as $item) { |
|
437 | + $title = esc_html($item->post_title); |
|
438 | 438 | |
439 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
440 | - $title .= wpinv_get_item_suffix( $item->ID, false ); |
|
439 | + if (!empty($args['show_recurring'])) { |
|
440 | + $title .= wpinv_get_item_suffix($item->ID, false); |
|
441 | 441 | } |
442 | 442 | |
443 | - $options[ absint( $item->ID ) ] = $title; |
|
443 | + $options[absint($item->ID)] = $title; |
|
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | 447 | // This ensures that any selected items are included in the drop down |
448 | - if ( is_array( $args['selected'] ) ) { |
|
449 | - foreach ( $args['selected'] as $item ) { |
|
450 | - if ( ! in_array( $item, $options ) ) { |
|
451 | - $title = get_the_title( $item ); |
|
452 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
453 | - $title .= wpinv_get_item_suffix( $item, false ); |
|
448 | + if (is_array($args['selected'])) { |
|
449 | + foreach ($args['selected'] as $item) { |
|
450 | + if (!in_array($item, $options)) { |
|
451 | + $title = get_the_title($item); |
|
452 | + if (!empty($args['show_recurring'])) { |
|
453 | + $title .= wpinv_get_item_suffix($item, false); |
|
454 | 454 | } |
455 | - $options[ $item ] = $title; |
|
455 | + $options[$item] = $title; |
|
456 | 456 | } |
457 | 457 | } |
458 | - } elseif ( is_numeric( $args['selected'] ) && $args['selected'] !== 0 ) { |
|
459 | - if ( ! in_array( $args['selected'], $options ) ) { |
|
460 | - $title = get_the_title( $args['selected'] ); |
|
461 | - if ( ! empty( $args['show_recurring'] ) ) { |
|
462 | - $title .= wpinv_get_item_suffix( $args['selected'], false ); |
|
458 | + } elseif (is_numeric($args['selected']) && $args['selected'] !== 0) { |
|
459 | + if (!in_array($args['selected'], $options)) { |
|
460 | + $title = get_the_title($args['selected']); |
|
461 | + if (!empty($args['show_recurring'])) { |
|
462 | + $title .= wpinv_get_item_suffix($args['selected'], false); |
|
463 | 463 | } |
464 | - $options[ $args['selected'] ] = get_the_title( $args['selected'] ); |
|
464 | + $options[$args['selected']] = get_the_title($args['selected']); |
|
465 | 465 | } |
466 | 466 | } |
467 | 467 | |
@@ -497,16 +497,16 @@ discard block |
||
497 | 497 | ); |
498 | 498 | |
499 | 499 | $options = array(); |
500 | - if ( $items ) { |
|
501 | - foreach ( $items as $item ) { |
|
502 | - $options[ $item->ID ] = esc_html( $item->post_title ) . wpinv_get_item_suffix( $item->ID, false ); |
|
500 | + if ($items) { |
|
501 | + foreach ($items as $item) { |
|
502 | + $options[$item->ID] = esc_html($item->post_title) . wpinv_get_item_suffix($item->ID, false); |
|
503 | 503 | } |
504 | 504 | } |
505 | 505 | |
506 | 506 | return $options; |
507 | 507 | } |
508 | 508 | |
509 | -function wpinv_html_checkbox( $args = array() ) { |
|
509 | +function wpinv_html_checkbox($args = array()) { |
|
510 | 510 | $defaults = array( |
511 | 511 | 'name' => null, |
512 | 512 | 'current' => null, |
@@ -517,17 +517,17 @@ discard block |
||
517 | 517 | ), |
518 | 518 | ); |
519 | 519 | |
520 | - $args = wp_parse_args( $args, $defaults ); |
|
520 | + $args = wp_parse_args($args, $defaults); |
|
521 | 521 | |
522 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
522 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
523 | 523 | $attr = ''; |
524 | - if ( ! empty( $args['options']['disabled'] ) ) { |
|
524 | + if (!empty($args['options']['disabled'])) { |
|
525 | 525 | $attr .= ' disabled="disabled"'; |
526 | - } elseif ( ! empty( $args['options']['readonly'] ) ) { |
|
526 | + } elseif (!empty($args['options']['readonly'])) { |
|
527 | 527 | $attr .= ' readonly'; |
528 | 528 | } |
529 | 529 | |
530 | - $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . esc_attr( $class ) . ' ' . esc_attr( $args['name'] ) . '" ' . checked( 1, $args['current'], false ) . ' />'; |
|
530 | + $output = '<input type="checkbox"' . $attr . ' name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['name']) . '" class="' . esc_attr($class) . ' ' . esc_attr($args['name']) . '" ' . checked(1, $args['current'], false) . ' />'; |
|
531 | 531 | |
532 | 532 | return $output; |
533 | 533 | } |
@@ -535,34 +535,34 @@ discard block |
||
535 | 535 | /** |
536 | 536 | * Displays a hidden field. |
537 | 537 | */ |
538 | -function getpaid_hidden_field( $name, $value ) { |
|
539 | - echo "<input type='hidden' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
538 | +function getpaid_hidden_field($name, $value) { |
|
539 | + echo "<input type='hidden' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | /** |
543 | 543 | * Displays a submit field. |
544 | 544 | */ |
545 | -function getpaid_submit_field( $value, $name = 'submit', $class = 'btn-primary' ) { |
|
546 | - echo "<input type='submit' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' class='btn " . esc_attr( $class ) . "' />"; |
|
545 | +function getpaid_submit_field($value, $name = 'submit', $class = 'btn-primary') { |
|
546 | + echo "<input type='submit' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' class='btn " . esc_attr($class) . "' />"; |
|
547 | 547 | } |
548 | 548 | |
549 | -function wpinv_html_text( $args = array() ) { |
|
549 | +function wpinv_html_text($args = array()) { |
|
550 | 550 | // Backwards compatibility |
551 | - if ( func_num_args() > 1 ) { |
|
551 | + if (func_num_args() > 1) { |
|
552 | 552 | $args = func_get_args(); |
553 | 553 | |
554 | 554 | $name = $args[0]; |
555 | - $value = isset( $args[1] ) ? $args[1] : ''; |
|
556 | - $label = isset( $args[2] ) ? $args[2] : ''; |
|
557 | - $desc = isset( $args[3] ) ? $args[3] : ''; |
|
555 | + $value = isset($args[1]) ? $args[1] : ''; |
|
556 | + $label = isset($args[2]) ? $args[2] : ''; |
|
557 | + $desc = isset($args[3]) ? $args[3] : ''; |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | $defaults = array( |
561 | 561 | 'id' => '', |
562 | - 'name' => isset( $name ) ? $name : 'text', |
|
563 | - 'value' => isset( $value ) ? $value : null, |
|
564 | - 'label' => isset( $label ) ? $label : null, |
|
565 | - 'desc' => isset( $desc ) ? $desc : null, |
|
562 | + 'name' => isset($name) ? $name : 'text', |
|
563 | + 'value' => isset($value) ? $value : null, |
|
564 | + 'label' => isset($label) ? $label : null, |
|
565 | + 'desc' => isset($desc) ? $desc : null, |
|
566 | 566 | 'placeholder' => '', |
567 | 567 | 'class' => 'regular-text', |
568 | 568 | 'disabled' => false, |
@@ -572,41 +572,41 @@ discard block |
||
572 | 572 | 'data' => false, |
573 | 573 | ); |
574 | 574 | |
575 | - $args = wp_parse_args( $args, $defaults ); |
|
575 | + $args = wp_parse_args($args, $defaults); |
|
576 | 576 | |
577 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
577 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
578 | 578 | $options = ''; |
579 | - if ( $args['required'] ) { |
|
579 | + if ($args['required']) { |
|
580 | 580 | $options .= ' required="required"'; |
581 | 581 | } |
582 | - if ( $args['readonly'] ) { |
|
582 | + if ($args['readonly']) { |
|
583 | 583 | $options .= ' readonly'; |
584 | 584 | } |
585 | - if ( $args['readonly'] ) { |
|
585 | + if ($args['readonly']) { |
|
586 | 586 | $options .= ' readonly'; |
587 | 587 | } |
588 | 588 | |
589 | 589 | $data = ''; |
590 | - if ( ! empty( $args['data'] ) ) { |
|
591 | - foreach ( $args['data'] as $key => $value ) { |
|
592 | - $data .= 'data-' . wpinv_sanitize_key( $key ) . '="' . esc_attr( $value ) . '" '; |
|
590 | + if (!empty($args['data'])) { |
|
591 | + foreach ($args['data'] as $key => $value) { |
|
592 | + $data .= 'data-' . wpinv_sanitize_key($key) . '="' . esc_attr($value) . '" '; |
|
593 | 593 | } |
594 | 594 | } |
595 | 595 | |
596 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
597 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
598 | - if ( ! empty( $args['desc'] ) ) { |
|
599 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
596 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
597 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['id']) . '">' . esc_html($args['label']) . '</label>'; |
|
598 | + if (!empty($args['desc'])) { |
|
599 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
600 | 600 | } |
601 | 601 | |
602 | - $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $class . '" ' . $data . ' ' . trim( $options ) . '/>'; |
|
602 | + $output .= '<input type="text" name="' . esc_attr($args['name']) . '" id="' . esc_attr($args['id']) . '" autocomplete="' . esc_attr($args['autocomplete']) . '" value="' . esc_attr($args['value']) . '" placeholder="' . esc_attr($args['placeholder']) . '" class="' . $class . '" ' . $data . ' ' . trim($options) . '/>'; |
|
603 | 603 | |
604 | 604 | $output .= '</span>'; |
605 | 605 | |
606 | 606 | return $output; |
607 | 607 | } |
608 | 608 | |
609 | -function wpinv_html_textarea( $args = array() ) { |
|
609 | +function wpinv_html_textarea($args = array()) { |
|
610 | 610 | $defaults = array( |
611 | 611 | 'name' => 'textarea', |
612 | 612 | 'value' => null, |
@@ -617,31 +617,31 @@ discard block |
||
617 | 617 | 'placeholder' => '', |
618 | 618 | ); |
619 | 619 | |
620 | - $args = wp_parse_args( $args, $defaults ); |
|
620 | + $args = wp_parse_args($args, $defaults); |
|
621 | 621 | |
622 | - $class = implode( ' ', array_map( 'sanitize_html_class', explode( ' ', $args['class'] ) ) ); |
|
622 | + $class = implode(' ', array_map('sanitize_html_class', explode(' ', $args['class']))); |
|
623 | 623 | $disabled = ''; |
624 | - if ( $args['disabled'] ) { |
|
624 | + if ($args['disabled']) { |
|
625 | 625 | $disabled = ' disabled="disabled"'; |
626 | 626 | } |
627 | 627 | |
628 | - $output = '<span id="wpinv-' . wpinv_sanitize_key( $args['name'] ) . '-wrap">'; |
|
629 | - $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>'; |
|
630 | - $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" id="' . wpinv_sanitize_key( $args['name'] ) . '" class="' . $class . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>'; |
|
628 | + $output = '<span id="wpinv-' . wpinv_sanitize_key($args['name']) . '-wrap">'; |
|
629 | + $output .= '<label class="wpinv-label" for="' . wpinv_sanitize_key($args['name']) . '">' . esc_html($args['label']) . '</label>'; |
|
630 | + $output .= '<textarea name="' . esc_attr($args['name']) . '" placeholder="' . esc_attr($args['placeholder']) . '" id="' . wpinv_sanitize_key($args['name']) . '" class="' . $class . '"' . $disabled . '>' . esc_attr($args['value']) . '</textarea>'; |
|
631 | 631 | |
632 | - if ( ! empty( $args['desc'] ) ) { |
|
633 | - $output .= '<span class="wpinv-description">' . esc_html( $args['desc'] ) . '</span>'; |
|
632 | + if (!empty($args['desc'])) { |
|
633 | + $output .= '<span class="wpinv-description">' . esc_html($args['desc']) . '</span>'; |
|
634 | 634 | } |
635 | 635 | $output .= '</span>'; |
636 | 636 | |
637 | 637 | return $output; |
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_html_ajax_user_search( $args = array() ) { |
|
640 | +function wpinv_html_ajax_user_search($args = array()) { |
|
641 | 641 | $defaults = array( |
642 | 642 | 'name' => 'user_id', |
643 | 643 | 'value' => null, |
644 | - 'placeholder' => __( 'Enter username', 'invoicing' ), |
|
644 | + 'placeholder' => __('Enter username', 'invoicing'), |
|
645 | 645 | 'label' => null, |
646 | 646 | 'desc' => null, |
647 | 647 | 'class' => '', |
@@ -650,13 +650,13 @@ discard block |
||
650 | 650 | 'data' => false, |
651 | 651 | ); |
652 | 652 | |
653 | - $args = wp_parse_args( $args, $defaults ); |
|
653 | + $args = wp_parse_args($args, $defaults); |
|
654 | 654 | |
655 | 655 | $args['class'] = 'wpinv-ajax-user-search ' . $args['class']; |
656 | 656 | |
657 | 657 | $output = '<span class="wpinv_user_search_wrap">'; |
658 | - $output .= wpinv_html_text( $args ); |
|
659 | - $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __( 'Cancel', 'invoicing' ) . '" aria-label="' . __( 'Cancel', 'invoicing' ) . '" href="#">x</a><span></span></span>'; |
|
658 | + $output .= wpinv_html_text($args); |
|
659 | + $output .= '<span class="wpinv_user_search_results hidden"><a class="wpinv-ajax-user-cancel" title="' . __('Cancel', 'invoicing') . '" aria-label="' . __('Cancel', 'invoicing') . '" href="#">x</a><span></span></span>'; |
|
660 | 660 | $output .= '</span>'; |
661 | 661 | |
662 | 662 | return $output; |
@@ -667,44 +667,44 @@ discard block |
||
667 | 667 | * |
668 | 668 | * @param string $template the template that is currently being used. |
669 | 669 | */ |
670 | -function wpinv_template( $template ) { |
|
670 | +function wpinv_template($template) { |
|
671 | 671 | global $post; |
672 | 672 | |
673 | - if ( ! is_admin() && ( is_single() || is_404() ) && ! empty( $post->ID ) && getpaid_is_invoice_post_type( get_post_type( $post->ID ) ) ) { |
|
673 | + if (!is_admin() && (is_single() || is_404()) && !empty($post->ID) && getpaid_is_invoice_post_type(get_post_type($post->ID))) { |
|
674 | 674 | |
675 | 675 | // If the user can view this invoice, display it. |
676 | - if ( wpinv_user_can_view_invoice( $post->ID ) ) { |
|
676 | + if (wpinv_user_can_view_invoice($post->ID)) { |
|
677 | 677 | |
678 | - return wpinv_get_template_part( 'wpinv-invoice-print', false, false ); |
|
678 | + return wpinv_get_template_part('wpinv-invoice-print', false, false); |
|
679 | 679 | |
680 | 680 | // Else display an error message. |
681 | 681 | } else { |
682 | 682 | |
683 | - return wpinv_get_template_part( 'wpinv-invalid-access', false, false ); |
|
683 | + return wpinv_get_template_part('wpinv-invalid-access', false, false); |
|
684 | 684 | |
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
688 | 688 | return $template; |
689 | 689 | } |
690 | -add_filter( 'template_include', 'wpinv_template', 1000, 1 ); |
|
690 | +add_filter('template_include', 'wpinv_template', 1000, 1); |
|
691 | 691 | |
692 | 692 | function wpinv_get_business_address() { |
693 | 693 | $business_address = wpinv_store_address(); |
694 | - $business_address = ! empty( $business_address ) ? wp_kses_post( wpautop( $business_address ) ) : ''; |
|
694 | + $business_address = !empty($business_address) ? wp_kses_post(wpautop($business_address)) : ''; |
|
695 | 695 | |
696 | 696 | $business_address = $business_address ? '<div class="address">' . $business_address . '</div>' : ''; |
697 | 697 | |
698 | - return apply_filters( 'wpinv_get_business_address', $business_address ); |
|
698 | + return apply_filters('wpinv_get_business_address', $business_address); |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | /** |
702 | 702 | * Displays the company address. |
703 | 703 | */ |
704 | 704 | function wpinv_display_from_address() { |
705 | - wpinv_get_template( 'invoice/company-address.php' ); |
|
705 | + wpinv_get_template('invoice/company-address.php'); |
|
706 | 706 | } |
707 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_from_address', 10 ); |
|
707 | +add_action('getpaid_invoice_details_left', 'wpinv_display_from_address', 10); |
|
708 | 708 | |
709 | 709 | /** |
710 | 710 | * Generates a watermark text for an invoice. |
@@ -712,9 +712,9 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice $invoice |
713 | 713 | * @return string |
714 | 714 | */ |
715 | -function wpinv_watermark( $invoice ) { |
|
716 | - $watermark = wpinv_get_watermark( $invoice ); |
|
717 | - return apply_filters( 'wpinv_get_watermark', $watermark, $invoice ); |
|
715 | +function wpinv_watermark($invoice) { |
|
716 | + $watermark = wpinv_get_watermark($invoice); |
|
717 | + return apply_filters('wpinv_get_watermark', $watermark, $invoice); |
|
718 | 718 | } |
719 | 719 | |
720 | 720 | /** |
@@ -723,37 +723,37 @@ discard block |
||
723 | 723 | * @param WPInv_Invoice $invoice |
724 | 724 | * @return string |
725 | 725 | */ |
726 | -function wpinv_get_watermark( $invoice ) { |
|
726 | +function wpinv_get_watermark($invoice) { |
|
727 | 727 | return $invoice->get_status_nicename(); |
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | 731 | * @deprecated |
732 | 732 | */ |
733 | -function wpinv_display_invoice_details( $invoice ) { |
|
734 | - return getpaid_invoice_meta( $invoice ); |
|
733 | +function wpinv_display_invoice_details($invoice) { |
|
734 | + return getpaid_invoice_meta($invoice); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
738 | 738 | * Displays invoice meta. |
739 | 739 | */ |
740 | -function getpaid_invoice_meta( $invoice ) { |
|
740 | +function getpaid_invoice_meta($invoice) { |
|
741 | 741 | |
742 | - $invoice = new WPInv_Invoice( $invoice ); |
|
742 | + $invoice = new WPInv_Invoice($invoice); |
|
743 | 743 | |
744 | 744 | // Ensure that we have an invoice. |
745 | - if ( 0 == $invoice->get_id() ) { |
|
745 | + if (0 == $invoice->get_id()) { |
|
746 | 746 | return; |
747 | 747 | } |
748 | 748 | |
749 | 749 | // Get the invoice meta. |
750 | - $meta = getpaid_get_invoice_meta( $invoice ); |
|
750 | + $meta = getpaid_get_invoice_meta($invoice); |
|
751 | 751 | |
752 | 752 | // Display the meta. |
753 | - wpinv_get_template( 'invoice/invoice-meta.php', compact( 'invoice', 'meta' ) ); |
|
753 | + wpinv_get_template('invoice/invoice-meta.php', compact('invoice', 'meta')); |
|
754 | 754 | |
755 | 755 | } |
756 | -add_action( 'getpaid_invoice_details_right', 'getpaid_invoice_meta', 10 ); |
|
756 | +add_action('getpaid_invoice_details_right', 'getpaid_invoice_meta', 10); |
|
757 | 757 | |
758 | 758 | /** |
759 | 759 | * Retrieves the address markup to use on Invoices. |
@@ -765,29 +765,29 @@ discard block |
||
765 | 765 | * @param string $separator How to separate address lines. |
766 | 766 | * @return string |
767 | 767 | */ |
768 | -function wpinv_get_invoice_address_markup( $billing_details, $separator = '<br/>' ) { |
|
768 | +function wpinv_get_invoice_address_markup($billing_details, $separator = '<br/>') { |
|
769 | 769 | |
770 | 770 | // Retrieve the address markup... |
771 | - $country = empty( $billing_details['country'] ) ? '' : $billing_details['country']; |
|
772 | - $format = wpinv_get_full_address_format( $country ); |
|
771 | + $country = empty($billing_details['country']) ? '' : $billing_details['country']; |
|
772 | + $format = wpinv_get_full_address_format($country); |
|
773 | 773 | |
774 | 774 | // ... and the replacements. |
775 | - $replacements = wpinv_get_invoice_address_replacements( $billing_details ); |
|
775 | + $replacements = wpinv_get_invoice_address_replacements($billing_details); |
|
776 | 776 | |
777 | - $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
|
777 | + $formatted_address = str_ireplace(array_keys($replacements), $replacements, $format); |
|
778 | 778 | |
779 | 779 | // Remove unavailable tags. |
780 | - $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address ); |
|
780 | + $formatted_address = preg_replace('/\{\{\w+\}\}/', '', $formatted_address); |
|
781 | 781 | |
782 | 782 | // Clean up white space. |
783 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
784 | - $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
|
783 | + $formatted_address = preg_replace('/ +/', ' ', trim($formatted_address)); |
|
784 | + $formatted_address = preg_replace('/\n\n+/', "\n", $formatted_address); |
|
785 | 785 | |
786 | 786 | // Break newlines apart and remove empty lines/trim commas and white space. |
787 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
787 | + $formatted_address = array_filter(array_map('wpinv_trim_formatted_address_line', explode("\n", $formatted_address))); |
|
788 | 788 | |
789 | 789 | // Add html breaks. |
790 | - $formatted_address = implode( $separator, $formatted_address ); |
|
790 | + $formatted_address = implode($separator, $formatted_address); |
|
791 | 791 | |
792 | 792 | // We're done! |
793 | 793 | return $formatted_address; |
@@ -799,118 +799,118 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @param WPInv_Invoice $invoice |
801 | 801 | */ |
802 | -function wpinv_display_to_address( $invoice = 0 ) { |
|
803 | - if ( ! empty( $invoice ) ) { |
|
804 | - wpinv_get_template( 'invoice/billing-address.php', compact( 'invoice' ) ); |
|
802 | +function wpinv_display_to_address($invoice = 0) { |
|
803 | + if (!empty($invoice)) { |
|
804 | + wpinv_get_template('invoice/billing-address.php', compact('invoice')); |
|
805 | 805 | } |
806 | 806 | } |
807 | -add_action( 'getpaid_invoice_details_left', 'wpinv_display_to_address', 40 ); |
|
807 | +add_action('getpaid_invoice_details_left', 'wpinv_display_to_address', 40); |
|
808 | 808 | |
809 | 809 | |
810 | 810 | /** |
811 | 811 | * Displays invoice line items. |
812 | 812 | */ |
813 | -function wpinv_display_line_items( $invoice_id = 0 ) { |
|
813 | +function wpinv_display_line_items($invoice_id = 0) { |
|
814 | 814 | |
815 | 815 | // Prepare the invoice. |
816 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
816 | + $invoice = new WPInv_Invoice($invoice_id); |
|
817 | 817 | |
818 | 818 | // Abort if there is no invoice. |
819 | - if ( 0 == $invoice->get_id() ) { |
|
819 | + if (0 == $invoice->get_id()) { |
|
820 | 820 | return; |
821 | 821 | } |
822 | 822 | |
823 | 823 | // Line item columns. |
824 | - $columns = getpaid_invoice_item_columns( $invoice ); |
|
825 | - $columns = apply_filters( 'getpaid_invoice_line_items_table_columns', $columns, $invoice ); |
|
824 | + $columns = getpaid_invoice_item_columns($invoice); |
|
825 | + $columns = apply_filters('getpaid_invoice_line_items_table_columns', $columns, $invoice); |
|
826 | 826 | |
827 | - wpinv_get_template( 'invoice/line-items.php', compact( 'invoice', 'columns' ) ); |
|
827 | + wpinv_get_template('invoice/line-items.php', compact('invoice', 'columns')); |
|
828 | 828 | } |
829 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_line_items', 10 ); |
|
829 | +add_action('getpaid_invoice_line_items', 'wpinv_display_line_items', 10); |
|
830 | 830 | |
831 | 831 | /** |
832 | 832 | * Displays invoice subscriptions. |
833 | 833 | * |
834 | 834 | * @param WPInv_Invoice $invoice |
835 | 835 | */ |
836 | -function getpaid_display_invoice_subscriptions( $invoice ) { |
|
836 | +function getpaid_display_invoice_subscriptions($invoice) { |
|
837 | 837 | |
838 | 838 | // Subscriptions. |
839 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
839 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
840 | 840 | |
841 | - if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) { |
|
841 | + if (empty($subscriptions) || !$invoice->is_recurring()) { |
|
842 | 842 | return; |
843 | 843 | } |
844 | 844 | |
845 | - $main_subscription = getpaid_get_invoice_subscription( $invoice ); |
|
845 | + $main_subscription = getpaid_get_invoice_subscription($invoice); |
|
846 | 846 | |
847 | 847 | // Display related subscriptions. |
848 | - if ( is_array( $subscriptions ) ) { |
|
849 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Subscriptions', 'invoicing' ) ); |
|
850 | - getpaid_admin_subscription_related_subscriptions_metabox( $main_subscription, false ); |
|
848 | + if (is_array($subscriptions)) { |
|
849 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Subscriptions', 'invoicing')); |
|
850 | + getpaid_admin_subscription_related_subscriptions_metabox($main_subscription, false); |
|
851 | 851 | } |
852 | 852 | |
853 | - if ( $main_subscription->get_total_payments() > 1 ) { |
|
854 | - printf( '<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__( 'Related Invoices', 'invoicing' ) ); |
|
855 | - getpaid_admin_subscription_invoice_details_metabox( $main_subscription, false ); |
|
853 | + if ($main_subscription->get_total_payments() > 1) { |
|
854 | + printf('<h2 class="mt-5 mb-1 h4">%s</h2>', esc_html__('Related Invoices', 'invoicing')); |
|
855 | + getpaid_admin_subscription_invoice_details_metabox($main_subscription, false); |
|
856 | 856 | } |
857 | 857 | |
858 | 858 | } |
859 | -add_action( 'getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55 ); |
|
860 | -add_action( 'wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11 ); |
|
859 | +add_action('getpaid_invoice_line_items', 'getpaid_display_invoice_subscriptions', 55); |
|
860 | +add_action('wpinv_receipt_end', 'getpaid_display_invoice_subscriptions', 11); |
|
861 | 861 | |
862 | 862 | /** |
863 | 863 | * Displays invoice notices on invoices. |
864 | 864 | */ |
865 | 865 | function wpinv_display_invoice_notice() { |
866 | 866 | |
867 | - $label = wpinv_get_option( 'vat_invoice_notice_label' ); |
|
868 | - $notice = wpinv_get_option( 'vat_invoice_notice' ); |
|
867 | + $label = wpinv_get_option('vat_invoice_notice_label'); |
|
868 | + $notice = wpinv_get_option('vat_invoice_notice'); |
|
869 | 869 | |
870 | - if ( empty( $label ) && empty( $notice ) ) { |
|
870 | + if (empty($label) && empty($notice)) { |
|
871 | 871 | return; |
872 | 872 | } |
873 | 873 | |
874 | 874 | echo '<div class="mt-4 mb-4 wpinv-vat-notice">'; |
875 | 875 | |
876 | - if ( ! empty( $label ) ) { |
|
877 | - echo "<h5>" . esc_html( __( wp_unslash( $label ), 'invoicing' ) ) . "</h5>"; |
|
876 | + if (!empty($label)) { |
|
877 | + echo "<h5>" . esc_html(__(wp_unslash($label), 'invoicing')) . "</h5>"; |
|
878 | 878 | } |
879 | 879 | |
880 | - if ( ! empty( $notice ) ) { |
|
881 | - echo '<small class="form-text text-muted">' . wp_kses_post( wpautop( wptexturize( __( wp_unslash( $notice ), 'invoicing' ) ) ) ) . '</small>'; |
|
880 | + if (!empty($notice)) { |
|
881 | + echo '<small class="form-text text-muted">' . wp_kses_post(wpautop(wptexturize(__(wp_unslash($notice), 'invoicing')))) . '</small>'; |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | echo '</div>'; |
885 | 885 | } |
886 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100 ); |
|
886 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notice', 100); |
|
887 | 887 | |
888 | 888 | /** |
889 | 889 | * @param WPInv_Invoice $invoice |
890 | 890 | */ |
891 | -function wpinv_display_invoice_notes( $invoice ) { |
|
891 | +function wpinv_display_invoice_notes($invoice) { |
|
892 | 892 | |
893 | 893 | // Retrieve the notes. |
894 | - $notes = wpinv_get_invoice_notes( $invoice->get_id(), 'customer' ); |
|
894 | + $notes = wpinv_get_invoice_notes($invoice->get_id(), 'customer'); |
|
895 | 895 | |
896 | 896 | // Abort if we have non. |
897 | - if ( empty( $notes ) ) { |
|
897 | + if (empty($notes)) { |
|
898 | 898 | return; |
899 | 899 | } |
900 | 900 | |
901 | 901 | // Echo the note. |
902 | 902 | echo '<div class="getpaid-invoice-notes-wrapper position-relative my-4">'; |
903 | - echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__( 'Notes', 'invoicing' ) . '</h2>'; |
|
903 | + echo '<h2 class="getpaid-invoice-notes-title mb-1 p-0 h4">' . esc_html__('Notes', 'invoicing') . '</h2>'; |
|
904 | 904 | echo '<ul class="getpaid-invoice-notes text-break overflow-auto list-unstyled p-0 m-0">'; |
905 | 905 | |
906 | - foreach ( $notes as $note ) { |
|
907 | - wpinv_get_invoice_note_line_item( $note ); |
|
906 | + foreach ($notes as $note) { |
|
907 | + wpinv_get_invoice_note_line_item($note); |
|
908 | 908 | } |
909 | 909 | |
910 | 910 | echo '</ul>'; |
911 | 911 | echo '</div>'; |
912 | 912 | } |
913 | -add_action( 'getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60 ); |
|
913 | +add_action('getpaid_invoice_line_items', 'wpinv_display_invoice_notes', 60); |
|
914 | 914 | |
915 | 915 | /** |
916 | 916 | * Loads scripts on our invoice templates. |
@@ -918,37 +918,37 @@ discard block |
||
918 | 918 | function wpinv_display_style() { |
919 | 919 | |
920 | 920 | // Make sure that all scripts have been loaded. |
921 | - if ( ! did_action( 'wp_enqueue_scripts' ) ) { |
|
922 | - do_action( 'wp_enqueue_scripts' ); |
|
921 | + if (!did_action('wp_enqueue_scripts')) { |
|
922 | + do_action('wp_enqueue_scripts'); |
|
923 | 923 | } |
924 | 924 | |
925 | 925 | // Add global styles. |
926 | - if ( wp_is_block_theme() ) { |
|
927 | - wp_print_styles( 'global-styles' ); |
|
926 | + if (wp_is_block_theme()) { |
|
927 | + wp_print_styles('global-styles'); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | // Register the invoices style. |
931 | - wp_register_style( 'wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime( WPINV_PLUGIN_DIR . 'assets/css/invoice.css' ) ); |
|
931 | + wp_register_style('wpinv-single-style', WPINV_PLUGIN_URL . 'assets/css/invoice.css', array(), filemtime(WPINV_PLUGIN_DIR . 'assets/css/invoice.css')); |
|
932 | 932 | |
933 | 933 | // Load required styles |
934 | - wp_print_styles( 'wpinv-single-style' ); |
|
935 | - wp_print_styles( 'ayecode-ui' ); |
|
934 | + wp_print_styles('wpinv-single-style'); |
|
935 | + wp_print_styles('ayecode-ui'); |
|
936 | 936 | |
937 | 937 | // Maybe load custom css. |
938 | - $custom_css = wpinv_get_option( 'template_custom_css' ); |
|
938 | + $custom_css = wpinv_get_option('template_custom_css'); |
|
939 | 939 | |
940 | - if ( isset( $custom_css ) && ! empty( $custom_css ) ) { |
|
941 | - $custom_css = wp_kses( $custom_css, array( '\'', '\"' ) ); |
|
942 | - $custom_css = str_replace( '>', '>', $custom_css ); |
|
940 | + if (isset($custom_css) && !empty($custom_css)) { |
|
941 | + $custom_css = wp_kses($custom_css, array('\'', '\"')); |
|
942 | + $custom_css = str_replace('>', '>', $custom_css); |
|
943 | 943 | echo '<style type="text/css">'; |
944 | - echo wp_kses_post( $custom_css ); |
|
944 | + echo wp_kses_post($custom_css); |
|
945 | 945 | echo '</style>'; |
946 | 946 | } |
947 | 947 | |
948 | 948 | wp_site_icon(); |
949 | 949 | } |
950 | -add_action( 'wpinv_invoice_print_head', 'wpinv_display_style' ); |
|
951 | -add_action( 'wpinv_invalid_invoice_head', 'wpinv_display_style' ); |
|
950 | +add_action('wpinv_invoice_print_head', 'wpinv_display_style'); |
|
951 | +add_action('wpinv_invalid_invoice_head', 'wpinv_display_style'); |
|
952 | 952 | |
953 | 953 | |
954 | 954 | /** |
@@ -960,41 +960,41 @@ discard block |
||
960 | 960 | // Retrieve the current invoice. |
961 | 961 | $invoice_id = getpaid_get_current_invoice_id(); |
962 | 962 | |
963 | - if ( empty( $invoice_id ) ) { |
|
963 | + if (empty($invoice_id)) { |
|
964 | 964 | |
965 | 965 | return aui()->alert( |
966 | 966 | array( |
967 | 967 | 'type' => 'warning', |
968 | - 'content' => __( 'Invalid invoice', 'invoicing' ), |
|
968 | + 'content' => __('Invalid invoice', 'invoicing'), |
|
969 | 969 | ) |
970 | 970 | ); |
971 | 971 | |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Can the user view this invoice? |
975 | - if ( ! wpinv_user_can_view_invoice( $invoice_id ) ) { |
|
975 | + if (!wpinv_user_can_view_invoice($invoice_id)) { |
|
976 | 976 | |
977 | 977 | return aui()->alert( |
978 | 978 | array( |
979 | 979 | 'type' => 'warning', |
980 | - 'content' => __( 'You are not allowed to view this invoice', 'invoicing' ), |
|
980 | + 'content' => __('You are not allowed to view this invoice', 'invoicing'), |
|
981 | 981 | ) |
982 | 982 | ); |
983 | 983 | |
984 | 984 | } |
985 | 985 | |
986 | 986 | // Ensure that it is not yet paid for. |
987 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
987 | + $invoice = new WPInv_Invoice($invoice_id); |
|
988 | 988 | |
989 | 989 | // Maybe mark it as viewed. |
990 | - getpaid_maybe_mark_invoice_as_viewed( $invoice ); |
|
990 | + getpaid_maybe_mark_invoice_as_viewed($invoice); |
|
991 | 991 | |
992 | - if ( $invoice->is_paid() ) { |
|
992 | + if ($invoice->is_paid()) { |
|
993 | 993 | |
994 | 994 | return aui()->alert( |
995 | 995 | array( |
996 | 996 | 'type' => 'success', |
997 | - 'content' => __( 'This invoice has already been paid.', 'invoicing' ), |
|
997 | + 'content' => __('This invoice has already been paid.', 'invoicing'), |
|
998 | 998 | ) |
999 | 999 | ); |
1000 | 1000 | |
@@ -1004,15 +1004,15 @@ discard block |
||
1004 | 1004 | $wpi_checkout_id = $invoice_id; |
1005 | 1005 | |
1006 | 1006 | // Retrieve appropriate payment form. |
1007 | - $payment_form = new GetPaid_Payment_Form( wpinv_translate_post_id( $invoice->get_meta( 'force_payment_form' ) ) ); |
|
1008 | - $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1007 | + $payment_form = new GetPaid_Payment_Form(wpinv_translate_post_id($invoice->get_meta('force_payment_form'))); |
|
1008 | + $payment_form = $payment_form->exists() ? $payment_form : new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1009 | 1009 | |
1010 | - if ( ! $payment_form->exists() ) { |
|
1010 | + if (!$payment_form->exists()) { |
|
1011 | 1011 | |
1012 | 1012 | return aui()->alert( |
1013 | 1013 | array( |
1014 | 1014 | 'type' => 'warning', |
1015 | - 'content' => __( 'Error loading the payment form', 'invoicing' ), |
|
1015 | + 'content' => __('Error loading the payment form', 'invoicing'), |
|
1016 | 1016 | ) |
1017 | 1017 | ); |
1018 | 1018 | |
@@ -1021,29 +1021,29 @@ discard block |
||
1021 | 1021 | // Set the invoice. |
1022 | 1022 | $payment_form->invoice = $invoice; |
1023 | 1023 | |
1024 | - if ( ! $payment_form->is_default() ) { |
|
1024 | + if (!$payment_form->is_default()) { |
|
1025 | 1025 | |
1026 | 1026 | $items = array(); |
1027 | 1027 | $item_ids = array(); |
1028 | 1028 | |
1029 | - foreach ( $invoice->get_items() as $item ) { |
|
1030 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1029 | + foreach ($invoice->get_items() as $item) { |
|
1030 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1031 | 1031 | $item_ids[] = $item->get_id(); |
1032 | 1032 | $items[] = $item; |
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | |
1036 | - foreach ( $payment_form->get_items() as $item ) { |
|
1037 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
1036 | + foreach ($payment_form->get_items() as $item) { |
|
1037 | + if (!in_array($item->get_id(), $item_ids)) { |
|
1038 | 1038 | $item_ids[] = $item->get_id(); |
1039 | 1039 | $items[] = $item; |
1040 | 1040 | } |
1041 | 1041 | } |
1042 | 1042 | |
1043 | - $payment_form->set_items( $items ); |
|
1043 | + $payment_form->set_items($items); |
|
1044 | 1044 | |
1045 | 1045 | } else { |
1046 | - $payment_form->set_items( $invoice->get_items() ); |
|
1046 | + $payment_form->set_items($invoice->get_items()); |
|
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | // Generate the html. |
@@ -1052,7 +1052,7 @@ discard block |
||
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | function wpinv_empty_cart_message() { |
1055 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1055 | + return apply_filters('wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __('Your cart is empty.', 'invoicing') . '</span>'); |
|
1056 | 1056 | } |
1057 | 1057 | |
1058 | 1058 | /** |
@@ -1070,76 +1070,76 @@ discard block |
||
1070 | 1070 | true |
1071 | 1071 | ); |
1072 | 1072 | } |
1073 | -add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
|
1073 | +add_action('wpinv_cart_empty', 'wpinv_empty_checkout_cart'); |
|
1074 | 1074 | |
1075 | 1075 | /** |
1076 | 1076 | * Filters the receipt page. |
1077 | 1077 | */ |
1078 | -function wpinv_filter_success_page_content( $content ) { |
|
1078 | +function wpinv_filter_success_page_content($content) { |
|
1079 | 1079 | |
1080 | 1080 | // Maybe abort early. |
1081 | - if ( is_admin() || ! is_singular() || ! in_the_loop() || ! is_main_query() || is_preview() ) { |
|
1081 | + if (is_admin() || !is_singular() || !in_the_loop() || !is_main_query() || is_preview()) { |
|
1082 | 1082 | return $content; |
1083 | 1083 | } |
1084 | 1084 | |
1085 | 1085 | // Ensure this is our page. |
1086 | - if ( isset( $_GET['payment-confirm'] ) && wpinv_is_success_page() ) { |
|
1086 | + if (isset($_GET['payment-confirm']) && wpinv_is_success_page()) { |
|
1087 | 1087 | |
1088 | - $gateway = sanitize_text_field( $_GET['payment-confirm'] ); |
|
1089 | - return apply_filters( "wpinv_payment_confirm_$gateway", $content ); |
|
1088 | + $gateway = sanitize_text_field($_GET['payment-confirm']); |
|
1089 | + return apply_filters("wpinv_payment_confirm_$gateway", $content); |
|
1090 | 1090 | |
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | return $content; |
1094 | 1094 | } |
1095 | -add_filter( 'the_content', 'wpinv_filter_success_page_content', 99999 ); |
|
1095 | +add_filter('the_content', 'wpinv_filter_success_page_content', 99999); |
|
1096 | 1096 | |
1097 | -function wpinv_invoice_link( $invoice_id ) { |
|
1098 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1097 | +function wpinv_invoice_link($invoice_id) { |
|
1098 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1099 | 1099 | |
1100 | - if ( empty( $invoice ) ) { |
|
1100 | + if (empty($invoice)) { |
|
1101 | 1101 | return null; |
1102 | 1102 | } |
1103 | 1103 | |
1104 | - $invoice_link = '<a href="' . esc_url( $invoice->get_view_url() ) . '">' . $invoice->get_number() . '</a>'; |
|
1104 | + $invoice_link = '<a href="' . esc_url($invoice->get_view_url()) . '">' . $invoice->get_number() . '</a>'; |
|
1105 | 1105 | |
1106 | - return apply_filters( 'wpinv_get_invoice_link', $invoice_link, $invoice ); |
|
1106 | + return apply_filters('wpinv_get_invoice_link', $invoice_link, $invoice); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | -function wpinv_get_invoice_note_line_item( $note, $echo = true ) { |
|
1110 | - if ( empty( $note ) ) { |
|
1109 | +function wpinv_get_invoice_note_line_item($note, $echo = true) { |
|
1110 | + if (empty($note)) { |
|
1111 | 1111 | return null; |
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if ( is_int( $note ) ) { |
|
1115 | - $note = get_comment( $note ); |
|
1114 | + if (is_int($note)) { |
|
1115 | + $note = get_comment($note); |
|
1116 | 1116 | } |
1117 | 1117 | |
1118 | - if ( ! ( is_object( $note ) && is_a( $note, 'WP_Comment' ) ) ) { |
|
1118 | + if (!(is_object($note) && is_a($note, 'WP_Comment'))) { |
|
1119 | 1119 | return null; |
1120 | 1120 | } |
1121 | 1121 | |
1122 | - $note_classes = array( 'note' ); |
|
1123 | - $note_classes[] = get_comment_meta( $note->comment_ID, '_wpi_customer_note', true ) ? 'customer-note' : ''; |
|
1122 | + $note_classes = array('note'); |
|
1123 | + $note_classes[] = get_comment_meta($note->comment_ID, '_wpi_customer_note', true) ? 'customer-note' : ''; |
|
1124 | 1124 | $note_classes[] = $note->comment_author === 'System' ? 'system-note' : ''; |
1125 | - $note_classes = apply_filters( 'wpinv_invoice_note_class', array_filter( $note_classes ), $note ); |
|
1126 | - $note_classes = ! empty( $note_classes ) ? implode( ' ', $note_classes ) : ''; |
|
1125 | + $note_classes = apply_filters('wpinv_invoice_note_class', array_filter($note_classes), $note); |
|
1126 | + $note_classes = !empty($note_classes) ? implode(' ', $note_classes) : ''; |
|
1127 | 1127 | |
1128 | 1128 | ob_start(); |
1129 | 1129 | ?> |
1130 | - <li rel="<?php echo absint( $note->comment_ID ); ?>" class="<?php echo esc_attr( $note_classes ); ?> mb-2"> |
|
1130 | + <li rel="<?php echo absint($note->comment_ID); ?>" class="<?php echo esc_attr($note_classes); ?> mb-2"> |
|
1131 | 1131 | <div class="note_content"> |
1132 | 1132 | |
1133 | - <?php echo wp_kses_post( wptexturize( $note->comment_content ) ); ?> |
|
1133 | + <?php echo wp_kses_post(wptexturize($note->comment_content)); ?> |
|
1134 | 1134 | |
1135 | - <?php if ( ! is_admin() ) : ?> |
|
1135 | + <?php if (!is_admin()) : ?> |
|
1136 | 1136 | <em class="small form-text text-muted mt-0"> |
1137 | 1137 | <?php |
1138 | 1138 | printf( |
1139 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1140 | - esc_html( $note->comment_author ), |
|
1141 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1142 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1139 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1140 | + esc_html($note->comment_author), |
|
1141 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1142 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1143 | 1143 | ); |
1144 | 1144 | ?> |
1145 | 1145 | </em> |
@@ -1147,21 +1147,21 @@ discard block |
||
1147 | 1147 | |
1148 | 1148 | </div> |
1149 | 1149 | |
1150 | - <?php if ( is_admin() ) : ?> |
|
1150 | + <?php if (is_admin()) : ?> |
|
1151 | 1151 | |
1152 | 1152 | <p class="meta px-4 py-2"> |
1153 | - <abbr class="exact-date" title="<?php echo esc_attr( $note->comment_date ); ?>"> |
|
1153 | + <abbr class="exact-date" title="<?php echo esc_attr($note->comment_date); ?>"> |
|
1154 | 1154 | <?php |
1155 | 1155 | printf( |
1156 | - esc_html__( '%1$s - %2$s at %3$s', 'invoicing' ), |
|
1157 | - esc_html( $note->comment_author ), |
|
1158 | - esc_html( getpaid_format_date_value( $note->comment_date ) ), |
|
1159 | - esc_html( date_i18n( get_option( 'time_format' ), strtotime( $note->comment_date ) ) ) |
|
1156 | + esc_html__('%1$s - %2$s at %3$s', 'invoicing'), |
|
1157 | + esc_html($note->comment_author), |
|
1158 | + esc_html(getpaid_format_date_value($note->comment_date)), |
|
1159 | + esc_html(date_i18n(get_option('time_format'), strtotime($note->comment_date))) |
|
1160 | 1160 | ); |
1161 | 1161 | ?> |
1162 | 1162 | </abbr> |
1163 | - <?php if ( $note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing() ) { ?> |
|
1164 | - <a href="#" class="delete_note" data-id="<?php echo esc_attr( $note->comment_ID ); ?>"><?php esc_html_e( 'Delete note', 'invoicing' ); ?></a> |
|
1163 | + <?php if ($note->comment_author !== 'System' && wpinv_current_user_can_manage_invoicing()) { ?> |
|
1164 | + <a href="#" class="delete_note" data-id="<?php echo esc_attr($note->comment_ID); ?>"><?php esc_html_e('Delete note', 'invoicing'); ?></a> |
|
1165 | 1165 | <?php } ?> |
1166 | 1166 | </p> |
1167 | 1167 | |
@@ -1170,10 +1170,10 @@ discard block |
||
1170 | 1170 | </li> |
1171 | 1171 | <?php |
1172 | 1172 | $note_content = ob_get_clean(); |
1173 | - $note_content = apply_filters( 'wpinv_get_invoice_note_line_item', $note_content, $note, $echo ); |
|
1173 | + $note_content = apply_filters('wpinv_get_invoice_note_line_item', $note_content, $note, $echo); |
|
1174 | 1174 | |
1175 | - if ( $echo ) { |
|
1176 | - echo wp_kses_post( $note_content ); |
|
1175 | + if ($echo) { |
|
1176 | + echo wp_kses_post($note_content); |
|
1177 | 1177 | } else { |
1178 | 1178 | return $note_content; |
1179 | 1179 | } |
@@ -1186,43 +1186,43 @@ discard block |
||
1186 | 1186 | * @return string |
1187 | 1187 | */ |
1188 | 1188 | function wpinv_get_policy_text() { |
1189 | - $privacy_page_id = get_option( 'wp_page_for_privacy_policy', 0 ); |
|
1189 | + $privacy_page_id = get_option('wp_page_for_privacy_policy', 0); |
|
1190 | 1190 | |
1191 | - $text = wpinv_get_option( 'invoicing_privacy_checkout_message', sprintf( __( 'Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing' ), '[wpinv_privacy_policy]' ) ); |
|
1191 | + $text = wpinv_get_option('invoicing_privacy_checkout_message', sprintf(__('Your personal data will be used to process your invoice, payment and for other purposes described in our %s.', 'invoicing'), '[wpinv_privacy_policy]')); |
|
1192 | 1192 | |
1193 | - if ( ! $privacy_page_id ) { |
|
1194 | - $privacy_page_id = wpinv_get_option( 'privacy_page', 0 ); |
|
1193 | + if (!$privacy_page_id) { |
|
1194 | + $privacy_page_id = wpinv_get_option('privacy_page', 0); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | - $privacy_link = $privacy_page_id ? '<a href="' . esc_url( get_permalink( $privacy_page_id ) ) . '" class="wpinv-privacy-policy-link" target="_blank">' . __( 'privacy policy', 'invoicing' ) . '</a>' : __( 'privacy policy', 'invoicing' ); |
|
1197 | + $privacy_link = $privacy_page_id ? '<a href="' . esc_url(get_permalink($privacy_page_id)) . '" class="wpinv-privacy-policy-link" target="_blank">' . __('privacy policy', 'invoicing') . '</a>' : __('privacy policy', 'invoicing'); |
|
1198 | 1198 | |
1199 | 1199 | $find_replace = array( |
1200 | 1200 | '[wpinv_privacy_policy]' => $privacy_link, |
1201 | 1201 | ); |
1202 | 1202 | |
1203 | - $privacy_text = str_replace( array_keys( $find_replace ), array_values( $find_replace ), $text ); |
|
1203 | + $privacy_text = str_replace(array_keys($find_replace), array_values($find_replace), $text); |
|
1204 | 1204 | |
1205 | - return wp_kses_post( wpautop( $privacy_text ) ); |
|
1205 | + return wp_kses_post(wpautop($privacy_text)); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | function wpinv_oxygen_fix_conflict() { |
1209 | 1209 | global $ct_ignore_post_types; |
1210 | 1210 | |
1211 | - if ( ! is_array( $ct_ignore_post_types ) ) { |
|
1211 | + if (!is_array($ct_ignore_post_types)) { |
|
1212 | 1212 | $ct_ignore_post_types = array(); |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $post_types = array( 'wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form' ); |
|
1215 | + $post_types = array('wpi_discount', 'wpi_invoice', 'wpi_item', 'wpi_payment_form'); |
|
1216 | 1216 | |
1217 | - foreach ( $post_types as $post_type ) { |
|
1217 | + foreach ($post_types as $post_type) { |
|
1218 | 1218 | $ct_ignore_post_types[] = $post_type; |
1219 | 1219 | |
1220 | 1220 | // Ignore post type |
1221 | - add_filter( 'pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999 ); |
|
1221 | + add_filter('pre_option_oxygen_vsb_ignore_post_type_' . $post_type, '__return_true', 999); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | - remove_filter( 'template_include', 'wpinv_template', 10, 1 ); |
|
1225 | - add_filter( 'template_include', 'wpinv_template', 999, 1 ); |
|
1224 | + remove_filter('template_include', 'wpinv_template', 10, 1); |
|
1225 | + add_filter('template_include', 'wpinv_template', 999, 1); |
|
1226 | 1226 | } |
1227 | 1227 | |
1228 | 1228 | /** |
@@ -1230,10 +1230,10 @@ discard block |
||
1230 | 1230 | * |
1231 | 1231 | * @param GetPaid_Payment_Form $form |
1232 | 1232 | */ |
1233 | -function getpaid_display_payment_form( $form ) { |
|
1233 | +function getpaid_display_payment_form($form) { |
|
1234 | 1234 | |
1235 | - if ( is_numeric( $form ) ) { |
|
1236 | - $form = new GetPaid_Payment_Form( wpinv_translate_post_id( $form ) ); |
|
1235 | + if (is_numeric($form)) { |
|
1236 | + $form = new GetPaid_Payment_Form(wpinv_translate_post_id($form)); |
|
1237 | 1237 | } |
1238 | 1238 | |
1239 | 1239 | $form->display(); |
@@ -1243,61 +1243,61 @@ discard block |
||
1243 | 1243 | /** |
1244 | 1244 | * Helper function to display a item payment form on the frontend. |
1245 | 1245 | */ |
1246 | -function getpaid_display_item_payment_form( $items ) { |
|
1246 | +function getpaid_display_item_payment_form($items) { |
|
1247 | 1247 | |
1248 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1249 | - $form->set_items( $items ); |
|
1248 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1249 | + $form->set_items($items); |
|
1250 | 1250 | |
1251 | - if ( 0 == count( $form->get_items() ) ) { |
|
1251 | + if (0 == count($form->get_items())) { |
|
1252 | 1252 | aui()->alert( |
1253 | 1253 | array( |
1254 | 1254 | 'type' => 'warning', |
1255 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
1255 | + 'content' => __('No published items found', 'invoicing'), |
|
1256 | 1256 | ), |
1257 | 1257 | true |
1258 | 1258 | ); |
1259 | 1259 | return; |
1260 | 1260 | } |
1261 | 1261 | |
1262 | - $extra_items = esc_attr( getpaid_convert_items_to_string( $items ) ); |
|
1263 | - $extra_items_key = md5( NONCE_KEY . AUTH_KEY . $extra_items ); |
|
1262 | + $extra_items = esc_attr(getpaid_convert_items_to_string($items)); |
|
1263 | + $extra_items_key = md5(NONCE_KEY . AUTH_KEY . $extra_items); |
|
1264 | 1264 | $extra_items = "<input type='hidden' name='getpaid-form-items' value='$extra_items' />"; |
1265 | 1265 | $extra_items .= "<input type='hidden' name='getpaid-form-items-key' value='$extra_items_key' />"; |
1266 | 1266 | |
1267 | - $form->display( $extra_items ); |
|
1267 | + $form->display($extra_items); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | /** |
1271 | 1271 | * Helper function to display an invoice payment form on the frontend. |
1272 | 1272 | */ |
1273 | -function getpaid_display_invoice_payment_form( $invoice_id ) { |
|
1273 | +function getpaid_display_invoice_payment_form($invoice_id) { |
|
1274 | 1274 | |
1275 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1275 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1276 | 1276 | |
1277 | - if ( empty( $invoice ) ) { |
|
1277 | + if (empty($invoice)) { |
|
1278 | 1278 | aui()->alert( |
1279 | 1279 | array( |
1280 | 1280 | 'type' => 'warning', |
1281 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
1281 | + 'content' => __('Invoice not found', 'invoicing'), |
|
1282 | 1282 | ), |
1283 | 1283 | true |
1284 | 1284 | ); |
1285 | 1285 | return; |
1286 | 1286 | } |
1287 | 1287 | |
1288 | - if ( $invoice->is_paid() ) { |
|
1288 | + if ($invoice->is_paid()) { |
|
1289 | 1289 | aui()->alert( |
1290 | 1290 | array( |
1291 | 1291 | 'type' => 'warning', |
1292 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
1292 | + 'content' => __('Invoice has already been paid', 'invoicing'), |
|
1293 | 1293 | ), |
1294 | 1294 | true |
1295 | 1295 | ); |
1296 | 1296 | return; |
1297 | 1297 | } |
1298 | 1298 | |
1299 | - $form = new GetPaid_Payment_Form( wpinv_get_default_payment_form() ); |
|
1300 | - $form->set_items( $invoice->get_items() ); |
|
1299 | + $form = new GetPaid_Payment_Form(wpinv_get_default_payment_form()); |
|
1300 | + $form->set_items($invoice->get_items()); |
|
1301 | 1301 | |
1302 | 1302 | $form->display(); |
1303 | 1303 | } |
@@ -1305,24 +1305,24 @@ discard block |
||
1305 | 1305 | /** |
1306 | 1306 | * Helper function to convert item string to array. |
1307 | 1307 | */ |
1308 | -function getpaid_convert_items_to_array( $items ) { |
|
1309 | - $items = array_filter( array_map( 'trim', explode( ',', $items ) ) ); |
|
1308 | +function getpaid_convert_items_to_array($items) { |
|
1309 | + $items = array_filter(array_map('trim', explode(',', $items))); |
|
1310 | 1310 | $prepared = array(); |
1311 | 1311 | |
1312 | - foreach ( $items as $item ) { |
|
1313 | - $data = array_map( 'trim', explode( '|', $item ) ); |
|
1312 | + foreach ($items as $item) { |
|
1313 | + $data = array_map('trim', explode('|', $item)); |
|
1314 | 1314 | |
1315 | - if ( empty( $data[0] ) || ! is_numeric( $data[0] ) ) { |
|
1315 | + if (empty($data[0]) || !is_numeric($data[0])) { |
|
1316 | 1316 | continue; |
1317 | 1317 | } |
1318 | 1318 | |
1319 | 1319 | $quantity = 1; |
1320 | - if ( isset( $data[1] ) && is_numeric( $data[1] ) ) { |
|
1320 | + if (isset($data[1]) && is_numeric($data[1])) { |
|
1321 | 1321 | $quantity = (float) $data[1]; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | 1324 | // WPML support. |
1325 | - $prepared[ wpinv_translate_post_id( $data[0] ) ] = $quantity; |
|
1325 | + $prepared[wpinv_translate_post_id($data[0])] = $quantity; |
|
1326 | 1326 | |
1327 | 1327 | } |
1328 | 1328 | |
@@ -1332,13 +1332,13 @@ discard block |
||
1332 | 1332 | /** |
1333 | 1333 | * Helper function to convert item array to string. |
1334 | 1334 | */ |
1335 | -function getpaid_convert_items_to_string( $items ) { |
|
1335 | +function getpaid_convert_items_to_string($items) { |
|
1336 | 1336 | $prepared = array(); |
1337 | 1337 | |
1338 | - foreach ( $items as $item => $quantity ) { |
|
1338 | + foreach ($items as $item => $quantity) { |
|
1339 | 1339 | $prepared[] = "$item|$quantity"; |
1340 | 1340 | } |
1341 | - return implode( ',', $prepared ); |
|
1341 | + return implode(',', $prepared); |
|
1342 | 1342 | } |
1343 | 1343 | |
1344 | 1344 | /** |
@@ -1346,21 +1346,21 @@ discard block |
||
1346 | 1346 | * |
1347 | 1347 | * Provide a label and one of $form, $items or $invoice. |
1348 | 1348 | */ |
1349 | -function getpaid_get_payment_button( $label, $form = null, $items = null, $invoice = null ) { |
|
1350 | - $label = sanitize_text_field( $label ); |
|
1349 | +function getpaid_get_payment_button($label, $form = null, $items = null, $invoice = null) { |
|
1350 | + $label = sanitize_text_field($label); |
|
1351 | 1351 | |
1352 | - if ( ! empty( $form ) ) { |
|
1353 | - $form = esc_attr( $form ); |
|
1352 | + if (!empty($form)) { |
|
1353 | + $form = esc_attr($form); |
|
1354 | 1354 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>"; |
1355 | 1355 | } |
1356 | 1356 | |
1357 | - if ( ! empty( $items ) ) { |
|
1358 | - $items = esc_attr( $items ); |
|
1357 | + if (!empty($items)) { |
|
1358 | + $items = esc_attr($items); |
|
1359 | 1359 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>"; |
1360 | 1360 | } |
1361 | 1361 | |
1362 | - if ( ! empty( $invoice ) ) { |
|
1363 | - $invoice = esc_attr( $invoice ); |
|
1362 | + if (!empty($invoice)) { |
|
1363 | + $invoice = esc_attr($invoice); |
|
1364 | 1364 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-invoice='$invoice'>$label</button>"; |
1365 | 1365 | } |
1366 | 1366 | |
@@ -1371,17 +1371,17 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @param WPInv_Invoice $invoice |
1373 | 1373 | */ |
1374 | -function getpaid_the_invoice_description( $invoice ) { |
|
1374 | +function getpaid_the_invoice_description($invoice) { |
|
1375 | 1375 | $description = $invoice->get_description(); |
1376 | 1376 | |
1377 | - if ( empty( $description ) ) { |
|
1377 | + if (empty($description)) { |
|
1378 | 1378 | return; |
1379 | 1379 | } |
1380 | 1380 | |
1381 | - echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post( wpautop( $description ) ) . "</em></small>"; |
|
1381 | + echo "<small class='getpaid-invoice-description text-dark pl-2 ps-2 form-text' style='margin-bottom:20px;border-left:2px solid #2196F3;display:block;padding-left:.5rem'><em>" . wp_kses_post(wpautop($description)) . "</em></small>"; |
|
1382 | 1382 | } |
1383 | -add_action( 'getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100 ); |
|
1384 | -add_action( 'wpinv_email_billing_details', 'getpaid_the_invoice_description', 100 ); |
|
1383 | +add_action('getpaid_invoice_line_items', 'getpaid_the_invoice_description', 100); |
|
1384 | +add_action('wpinv_email_billing_details', 'getpaid_the_invoice_description', 100); |
|
1385 | 1385 | |
1386 | 1386 | /** |
1387 | 1387 | * Render element on a form. |
@@ -1389,86 +1389,86 @@ discard block |
||
1389 | 1389 | * @param array $element |
1390 | 1390 | * @param GetPaid_Payment_Form $form |
1391 | 1391 | */ |
1392 | -function getpaid_payment_form_element( $element, $form ) { |
|
1393 | - $translatable = array( 'text', 'label', 'placeholder', 'input_label', 'button_label', 'description' ); |
|
1392 | +function getpaid_payment_form_element($element, $form) { |
|
1393 | + $translatable = array('text', 'label', 'placeholder', 'input_label', 'button_label', 'description'); |
|
1394 | 1394 | |
1395 | - foreach ( $translatable as $string ) { |
|
1396 | - if ( ! empty( $element[ $string ] ) && is_scalar( $element[ $string ] ) ) { |
|
1397 | - $element[ $string ] = __( $element[ $string ], 'invoicing' ); |
|
1395 | + foreach ($translatable as $string) { |
|
1396 | + if (!empty($element[$string]) && is_scalar($element[$string])) { |
|
1397 | + $element[$string] = __($element[$string], 'invoicing'); |
|
1398 | 1398 | } |
1399 | 1399 | } |
1400 | 1400 | |
1401 | 1401 | // Set up the args. |
1402 | - $element_type = trim( $element['type'] ); |
|
1402 | + $element_type = trim($element['type']); |
|
1403 | 1403 | $element['form'] = $form; |
1404 | - extract( $element ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1404 | + extract($element); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract |
|
1405 | 1405 | |
1406 | 1406 | // Try to locate the appropriate template. |
1407 | - $located = wpinv_locate_template( "payment-forms/elements/$element_type.php" ); |
|
1407 | + $located = wpinv_locate_template("payment-forms/elements/$element_type.php"); |
|
1408 | 1408 | |
1409 | 1409 | // Abort if this is not our element. |
1410 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1410 | + if (empty($located) || !file_exists($located)) { |
|
1411 | 1411 | return; |
1412 | 1412 | } |
1413 | 1413 | |
1414 | 1414 | // Generate the class and id of the element. |
1415 | - $wrapper_class = 'getpaid-payment-form-element-' . trim( esc_attr( $element_type ) ); |
|
1416 | - $id = isset( $id ) ? $id : uniqid( 'gp' ); |
|
1415 | + $wrapper_class = 'getpaid-payment-form-element-' . trim(esc_attr($element_type)); |
|
1416 | + $id = isset($id) ? $id : uniqid('gp'); |
|
1417 | 1417 | |
1418 | - $element_id = ! empty( $element['label'] ) ? sanitize_title( $element['label'] ) : $id; |
|
1419 | - $query_value = isset( $_GET[ $element_id ] ) ? wpinv_clean( urldecode_deep( $_GET[ $element_id ] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1418 | + $element_id = !empty($element['label']) ? sanitize_title($element['label']) : $id; |
|
1419 | + $query_value = isset($_GET[$element_id]) ? wpinv_clean(urldecode_deep($_GET[$element_id])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
|
1420 | 1420 | |
1421 | 1421 | $element_id = 'getpaid-' . $element_id; |
1422 | - if ( ! empty( $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ] ) ) { |
|
1423 | - $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][ $form->get_id() ]; |
|
1422 | + if (!empty($GLOBALS['rendered_getpaid_forms'][$form->get_id()])) { |
|
1423 | + $element_id = $element_id . '-' . $GLOBALS['rendered_getpaid_forms'][$form->get_id()]; |
|
1424 | 1424 | } |
1425 | 1425 | |
1426 | 1426 | // Echo the opening wrapper. |
1427 | - echo "<div class='getpaid-payment-form-element " . esc_attr( $wrapper_class ) . "'>"; |
|
1427 | + echo "<div class='getpaid-payment-form-element " . esc_attr($wrapper_class) . "'>"; |
|
1428 | 1428 | |
1429 | 1429 | // Fires before displaying a given element type's content. |
1430 | - do_action( "getpaid_before_payment_form_{$element_type}_element", $element, $form ); |
|
1430 | + do_action("getpaid_before_payment_form_{$element_type}_element", $element, $form); |
|
1431 | 1431 | |
1432 | 1432 | // Include the template for the element. |
1433 | 1433 | include $located; |
1434 | 1434 | |
1435 | 1435 | // Fires after displaying a given element type's content. |
1436 | - do_action( "getpaid_payment_form_{$element_type}_element", $element, $form ); |
|
1436 | + do_action("getpaid_payment_form_{$element_type}_element", $element, $form); |
|
1437 | 1437 | |
1438 | 1438 | // Echo the closing wrapper. |
1439 | 1439 | echo '</div>'; |
1440 | 1440 | } |
1441 | -add_action( 'getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2 ); |
|
1441 | +add_action('getpaid_payment_form_element', 'getpaid_payment_form_element', 10, 2); |
|
1442 | 1442 | |
1443 | 1443 | /** |
1444 | 1444 | * Render an element's edit page. |
1445 | 1445 | * |
1446 | 1446 | * @param WP_Post $post |
1447 | 1447 | */ |
1448 | -function getpaid_payment_form_edit_element_template( $post ) { |
|
1448 | +function getpaid_payment_form_edit_element_template($post) { |
|
1449 | 1449 | |
1450 | 1450 | // Retrieve all elements. |
1451 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1451 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1452 | 1452 | |
1453 | - foreach ( $all_elements as $element ) { |
|
1453 | + foreach ($all_elements as $element) { |
|
1454 | 1454 | |
1455 | 1455 | // Try to locate the appropriate template. |
1456 | - $element = esc_attr( sanitize_key( $element ) ); |
|
1457 | - $located = wpinv_locate_template( "payment-forms-admin/edit/$element.php" ); |
|
1456 | + $element = esc_attr(sanitize_key($element)); |
|
1457 | + $located = wpinv_locate_template("payment-forms-admin/edit/$element.php"); |
|
1458 | 1458 | |
1459 | 1459 | // Continue if this is not our element. |
1460 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1460 | + if (empty($located) || !file_exists($located)) { |
|
1461 | 1461 | continue; |
1462 | 1462 | } |
1463 | 1463 | |
1464 | 1464 | // Include the template for the element. |
1465 | - echo "<div v-if=\"active_form_element.type=='" . esc_attr( $element ) . "'\">"; |
|
1465 | + echo "<div v-if=\"active_form_element.type=='" . esc_attr($element) . "'\">"; |
|
1466 | 1466 | include $located; |
1467 | 1467 | echo '</div>'; |
1468 | 1468 | } |
1469 | 1469 | |
1470 | 1470 | } |
1471 | -add_action( 'getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template' ); |
|
1471 | +add_action('getpaid_payment_form_edit_element_template', 'getpaid_payment_form_edit_element_template'); |
|
1472 | 1472 | |
1473 | 1473 | /** |
1474 | 1474 | * Render an element's preview. |
@@ -1477,27 +1477,27 @@ discard block |
||
1477 | 1477 | function getpaid_payment_form_render_element_preview_template() { |
1478 | 1478 | |
1479 | 1479 | // Retrieve all elements. |
1480 | - $all_elements = wp_list_pluck( wpinv_get_data( 'payment-form-elements' ), 'type' ); |
|
1480 | + $all_elements = wp_list_pluck(wpinv_get_data('payment-form-elements'), 'type'); |
|
1481 | 1481 | |
1482 | - foreach ( $all_elements as $element ) { |
|
1482 | + foreach ($all_elements as $element) { |
|
1483 | 1483 | |
1484 | 1484 | // Try to locate the appropriate template. |
1485 | - $element = sanitize_key( $element ); |
|
1486 | - $located = wpinv_locate_template( "payment-forms-admin/previews/$element.php" ); |
|
1485 | + $element = sanitize_key($element); |
|
1486 | + $located = wpinv_locate_template("payment-forms-admin/previews/$element.php"); |
|
1487 | 1487 | |
1488 | 1488 | // Continue if this is not our element. |
1489 | - if ( empty( $located ) || ! file_exists( $located ) ) { |
|
1489 | + if (empty($located) || !file_exists($located)) { |
|
1490 | 1490 | continue; |
1491 | 1491 | } |
1492 | 1492 | |
1493 | 1493 | // Include the template for the element. |
1494 | - echo "<div v-if=\"form_element.type=='" . esc_html( $element ) . "'\">"; |
|
1494 | + echo "<div v-if=\"form_element.type=='" . esc_html($element) . "'\">"; |
|
1495 | 1495 | include $located; |
1496 | 1496 | echo '</div>'; |
1497 | 1497 | } |
1498 | 1498 | |
1499 | 1499 | } |
1500 | -add_action( 'wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template' ); |
|
1500 | +add_action('wpinv_payment_form_render_element_template', 'getpaid_payment_form_render_element_preview_template'); |
|
1501 | 1501 | |
1502 | 1502 | /** |
1503 | 1503 | * Shows a list of gateways that support recurring payments. |
@@ -1505,17 +1505,17 @@ discard block |
||
1505 | 1505 | function wpinv_get_recurring_gateways_text() { |
1506 | 1506 | $gateways = array(); |
1507 | 1507 | |
1508 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
1509 | - if ( wpinv_gateway_support_subscription( $key ) ) { |
|
1510 | - $gateways[] = sanitize_text_field( $gateway['admin_label'] ); |
|
1508 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
1509 | + if (wpinv_gateway_support_subscription($key)) { |
|
1510 | + $gateways[] = sanitize_text_field($gateway['admin_label']); |
|
1511 | 1511 | } |
1512 | 1512 | } |
1513 | 1513 | |
1514 | - if ( empty( $gateways ) ) { |
|
1515 | - return "<span class='form-text text-danger'>" . __( 'No active gateways support subscription payments.', 'invoicing' ) . '</span>'; |
|
1514 | + if (empty($gateways)) { |
|
1515 | + return "<span class='form-text text-danger'>" . __('No active gateways support subscription payments.', 'invoicing') . '</span>'; |
|
1516 | 1516 | } |
1517 | 1517 | |
1518 | - return "<span class='form-text text-muted'>" . wp_sprintf( __( 'Subscription payments only supported by: %s', 'invoicing' ), implode( ', ', $gateways ) ) . '</span>'; |
|
1518 | + return "<span class='form-text text-muted'>" . wp_sprintf(__('Subscription payments only supported by: %s', 'invoicing'), implode(', ', $gateways)) . '</span>'; |
|
1519 | 1519 | |
1520 | 1520 | } |
1521 | 1521 | |
@@ -1525,7 +1525,7 @@ discard block |
||
1525 | 1525 | * @return GetPaid_Template |
1526 | 1526 | */ |
1527 | 1527 | function getpaid_template() { |
1528 | - return getpaid()->get( 'template' ); |
|
1528 | + return getpaid()->get('template'); |
|
1529 | 1529 | } |
1530 | 1530 | |
1531 | 1531 | /** |
@@ -1534,8 +1534,8 @@ discard block |
||
1534 | 1534 | * @param array args |
1535 | 1535 | * @return string |
1536 | 1536 | */ |
1537 | -function getpaid_paginate_links( $args ) { |
|
1538 | - return str_replace( 'page-link dots', 'page-link text-dark', aui()->pagination( $args ) ); |
|
1537 | +function getpaid_paginate_links($args) { |
|
1538 | + return str_replace('page-link dots', 'page-link text-dark', aui()->pagination($args)); |
|
1539 | 1539 | } |
1540 | 1540 | |
1541 | 1541 | /** |
@@ -1545,22 +1545,22 @@ discard block |
||
1545 | 1545 | * @param string state |
1546 | 1546 | * @return string |
1547 | 1547 | */ |
1548 | -function getpaid_get_states_select_markup( $country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false ) { |
|
1548 | +function getpaid_get_states_select_markup($country, $state, $placeholder, $label, $help_text, $required = false, $wrapper_class = 'col-12', $field_name = 'wpinv_state', $echo = false) { |
|
1549 | 1549 | |
1550 | - $states = wpinv_get_country_states( $country ); |
|
1551 | - $uniqid = uniqid( '_' ); |
|
1550 | + $states = wpinv_get_country_states($country); |
|
1551 | + $uniqid = uniqid('_'); |
|
1552 | 1552 | |
1553 | - if ( ! empty( $states ) ) { |
|
1553 | + if (!empty($states)) { |
|
1554 | 1554 | |
1555 | 1555 | return aui()->select( |
1556 | 1556 | array( |
1557 | 1557 | 'options' => $states, |
1558 | - 'name' => esc_attr( $field_name ), |
|
1559 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1560 | - 'value' => sanitize_text_field( $state ), |
|
1558 | + 'name' => esc_attr($field_name), |
|
1559 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1560 | + 'value' => sanitize_text_field($state), |
|
1561 | 1561 | 'placeholder' => $placeholder, |
1562 | 1562 | 'required' => $required, |
1563 | - 'label' => wp_kses_post( $label ), |
|
1563 | + 'label' => wp_kses_post($label), |
|
1564 | 1564 | 'label_type' => 'vertical', |
1565 | 1565 | 'help_text' => $help_text, |
1566 | 1566 | 'class' => 'getpaid-address-field wpinv_state', |
@@ -1577,14 +1577,14 @@ discard block |
||
1577 | 1577 | |
1578 | 1578 | return aui()->input( |
1579 | 1579 | array( |
1580 | - 'name' => esc_attr( $field_name ), |
|
1581 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
1580 | + 'name' => esc_attr($field_name), |
|
1581 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
1582 | 1582 | 'placeholder' => $placeholder, |
1583 | 1583 | 'required' => $required, |
1584 | - 'label' => wp_kses_post( $label ), |
|
1584 | + 'label' => wp_kses_post($label), |
|
1585 | 1585 | 'label_type' => 'vertical', |
1586 | 1586 | 'help_text' => $help_text, |
1587 | - 'value' => sanitize_text_field( $state ), |
|
1587 | + 'value' => sanitize_text_field($state), |
|
1588 | 1588 | 'class' => 'getpaid-address-field wpinv_state', |
1589 | 1589 | 'wrap_class' => "$wrapper_class getpaid-address-field-wrapper__state", |
1590 | 1590 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__state', |
@@ -1603,16 +1603,16 @@ discard block |
||
1603 | 1603 | * @param array $element |
1604 | 1604 | * @return string |
1605 | 1605 | */ |
1606 | -function getpaid_get_form_element_grid_class( $element ) { |
|
1606 | +function getpaid_get_form_element_grid_class($element) { |
|
1607 | 1607 | |
1608 | 1608 | $class = 'col-12'; |
1609 | - $width = empty( $element['grid_width'] ) ? 'full' : $element['grid_width']; |
|
1609 | + $width = empty($element['grid_width']) ? 'full' : $element['grid_width']; |
|
1610 | 1610 | |
1611 | - if ( $width == 'half' ) { |
|
1611 | + if ($width == 'half') { |
|
1612 | 1612 | $class .= ' col-md-6'; |
1613 | 1613 | } |
1614 | 1614 | |
1615 | - if ( $width == 'third' ) { |
|
1615 | + if ($width == 'third') { |
|
1616 | 1616 | $class .= ' col-md-4'; |
1617 | 1617 | } |
1618 | 1618 | |
@@ -1627,15 +1627,15 @@ discard block |
||
1627 | 1627 | * |
1628 | 1628 | * @return string |
1629 | 1629 | */ |
1630 | -function getpaid_embed_url( $payment_form = false, $items = false ) { |
|
1630 | +function getpaid_embed_url($payment_form = false, $items = false) { |
|
1631 | 1631 | |
1632 | 1632 | return add_query_arg( |
1633 | 1633 | array( |
1634 | 1634 | 'getpaid_embed' => 1, |
1635 | - 'form' => $payment_form ? absint( $payment_form ) : false, |
|
1636 | - 'item' => $items ? urlencode( $items ) : false, |
|
1635 | + 'form' => $payment_form ? absint($payment_form) : false, |
|
1636 | + 'item' => $items ? urlencode($items) : false, |
|
1637 | 1637 | ), |
1638 | - home_url( 'index.php' ) |
|
1638 | + home_url('index.php') |
|
1639 | 1639 | ); |
1640 | 1640 | |
1641 | 1641 | } |
@@ -1645,16 +1645,16 @@ discard block |
||
1645 | 1645 | * |
1646 | 1646 | * @return string |
1647 | 1647 | */ |
1648 | -function getpaid_filter_embed_template( $template ) { |
|
1648 | +function getpaid_filter_embed_template($template) { |
|
1649 | 1649 | |
1650 | - if ( isset( $_GET['getpaid_embed'] ) ) { |
|
1651 | - wpinv_get_template( 'payment-forms/embed.php' ); |
|
1650 | + if (isset($_GET['getpaid_embed'])) { |
|
1651 | + wpinv_get_template('payment-forms/embed.php'); |
|
1652 | 1652 | exit; |
1653 | 1653 | } |
1654 | 1654 | |
1655 | 1655 | return $template; |
1656 | 1656 | } |
1657 | -add_filter( 'template_include', 'getpaid_filter_embed_template' ); |
|
1657 | +add_filter('template_include', 'getpaid_filter_embed_template'); |
|
1658 | 1658 | |
1659 | 1659 | /** |
1660 | 1660 | * Get the payment forms custom fields. |
@@ -1666,25 +1666,25 @@ discard block |
||
1666 | 1666 | function getpaid_get_payment_form_custom_fields() { |
1667 | 1667 | global $wpdb, $payment_form_meta_fields; |
1668 | 1668 | |
1669 | - if ( ! empty( $payment_form_meta_fields ) ) { |
|
1669 | + if (!empty($payment_form_meta_fields)) { |
|
1670 | 1670 | return $payment_form_meta_fields; |
1671 | 1671 | } |
1672 | 1672 | |
1673 | - $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" ); |
|
1673 | + $results = $wpdb->get_results("SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'"); |
|
1674 | 1674 | |
1675 | 1675 | $meta_fields = array(); |
1676 | 1676 | |
1677 | - if ( ! empty( $results ) ) { |
|
1678 | - foreach ( $results as $row ) { |
|
1679 | - $fields = maybe_unserialize( $row->meta_value ); |
|
1677 | + if (!empty($results)) { |
|
1678 | + foreach ($results as $row) { |
|
1679 | + $fields = maybe_unserialize($row->meta_value); |
|
1680 | 1680 | |
1681 | - if ( ! empty( $fields ) && is_array( $fields ) ) { |
|
1682 | - foreach ( $fields as $field ) { |
|
1683 | - $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : ''; |
|
1681 | + if (!empty($fields) && is_array($fields)) { |
|
1682 | + foreach ($fields as $field) { |
|
1683 | + $label = !empty($field['add_meta']) && !empty($field['label']) ? wpinv_clean(wp_unslash($field['label'])) : ''; |
|
1684 | 1684 | |
1685 | - if ( $label ) { |
|
1686 | - $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) ); |
|
1687 | - $meta_fields[ $field_key ] = $label; |
|
1685 | + if ($label) { |
|
1686 | + $field_key = '_' . str_replace(array(' ', "'", '"', ','), array('_', '', '', '_'), getpaid_strtolower($label)); |
|
1687 | + $meta_fields[$field_key] = $label; |
|
1688 | 1688 | } |
1689 | 1689 | } |
1690 | 1690 | } |
@@ -1709,13 +1709,13 @@ discard block |
||
1709 | 1709 | $is_gutenberg = true; |
1710 | 1710 | |
1711 | 1711 | // If less than v5. |
1712 | - if ( version_compare( $wp_version, '5.0.0', '<' ) ) { |
|
1712 | + if (version_compare($wp_version, '5.0.0', '<')) { |
|
1713 | 1713 | $is_gutenberg = false; |
1714 | 1714 | } |
1715 | 1715 | |
1716 | - if ( class_exists( 'Classic_Editor' ) ) { |
|
1716 | + if (class_exists('Classic_Editor')) { |
|
1717 | 1717 | $is_gutenberg = false; // Classic Editor plugin is active. |
1718 | - } else if ( getpaid_is_classicpress() ) { |
|
1718 | + } else if (getpaid_is_classicpress()) { |
|
1719 | 1719 | $is_gutenberg = false; // Site is using ClassicPress. |
1720 | 1720 | } |
1721 | 1721 | |
@@ -1730,7 +1730,7 @@ discard block |
||
1730 | 1730 | * @return bool True if site uses ClassicPress else False. |
1731 | 1731 | */ |
1732 | 1732 | function getpaid_is_classicpress() { |
1733 | - if ( function_exists( 'classicpress_version' ) ) { |
|
1733 | + if (function_exists('classicpress_version')) { |
|
1734 | 1734 | $is_classicpress = true; |
1735 | 1735 | } else { |
1736 | 1736 | $is_classicpress = false; |
@@ -1748,8 +1748,8 @@ discard block |
||
1748 | 1748 | * @param @bool $blocks True to use blocks. |
1749 | 1749 | * @return string Page content. |
1750 | 1750 | */ |
1751 | - function getpaid_page_content_checkout( $filtered = false, $blocks = false ) { |
|
1752 | - if ( $blocks ) { |
|
1751 | + function getpaid_page_content_checkout($filtered = false, $blocks = false) { |
|
1752 | + if ($blocks) { |
|
1753 | 1753 | $content = "<!-- wp:invoicing/wpinv-checkout-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_checkout title='' ]\"} --> |
1754 | 1754 | <div class=\"wp-block-invoicing-wpinv-checkout-widget\"></div> |
1755 | 1755 | <!-- /wp:invoicing/wpinv-checkout-widget -->"; |
@@ -1757,8 +1757,8 @@ discard block |
||
1757 | 1757 | $content = "[wpinv_checkout]"; |
1758 | 1758 | } |
1759 | 1759 | |
1760 | - if ( $filtered ) { |
|
1761 | - $content = apply_filters( 'getpaid_page_default_content_checkout', $content, $blocks ); |
|
1760 | + if ($filtered) { |
|
1761 | + $content = apply_filters('getpaid_page_default_content_checkout', $content, $blocks); |
|
1762 | 1762 | } |
1763 | 1763 | |
1764 | 1764 | return $content; |
@@ -1773,8 +1773,8 @@ discard block |
||
1773 | 1773 | * @param @bool $blocks True to use blocks. |
1774 | 1774 | * @return string Page content. |
1775 | 1775 | */ |
1776 | - function getpaid_page_content_invoice_history( $filtered = false, $blocks = false ) { |
|
1777 | - if ( $blocks ) { |
|
1776 | + function getpaid_page_content_invoice_history($filtered = false, $blocks = false) { |
|
1777 | + if ($blocks) { |
|
1778 | 1778 | $content = "<!-- wp:invoicing/wpinv-history-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_history title='' ]\"} --> |
1779 | 1779 | <div class=\"wp-block-invoicing-wpinv-history-widget\"></div> |
1780 | 1780 | <!-- /wp:invoicing/wpinv-history-widget -->"; |
@@ -1782,8 +1782,8 @@ discard block |
||
1782 | 1782 | $content = "[wpinv_history]"; |
1783 | 1783 | } |
1784 | 1784 | |
1785 | - if ( $filtered ) { |
|
1786 | - $content = apply_filters( 'getpaid_page_default_content_invoice_history', $content, $blocks ); |
|
1785 | + if ($filtered) { |
|
1786 | + $content = apply_filters('getpaid_page_default_content_invoice_history', $content, $blocks); |
|
1787 | 1787 | } |
1788 | 1788 | |
1789 | 1789 | return $content; |
@@ -1798,8 +1798,8 @@ discard block |
||
1798 | 1798 | * @param @bool $blocks True to use blocks. |
1799 | 1799 | * @return string Page content. |
1800 | 1800 | */ |
1801 | - function getpaid_page_content_receipt( $filtered = false, $blocks = false ) { |
|
1802 | - if ( $blocks ) { |
|
1801 | + function getpaid_page_content_receipt($filtered = false, $blocks = false) { |
|
1802 | + if ($blocks) { |
|
1803 | 1803 | $content = "<!-- wp:invoicing/wpinv-receipt-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_receipt title='' ]\"} --> |
1804 | 1804 | <div class=\"wp-block-invoicing-wpinv-receipt-widget\"></div> |
1805 | 1805 | <!-- /wp:invoicing/wpinv-receipt-widget -->"; |
@@ -1807,8 +1807,8 @@ discard block |
||
1807 | 1807 | $content = "[wpinv_receipt]"; |
1808 | 1808 | } |
1809 | 1809 | |
1810 | - if ( $filtered ) { |
|
1811 | - $content = apply_filters( 'getpaid_page_default_content_receipt', $content, $blocks ); |
|
1810 | + if ($filtered) { |
|
1811 | + $content = apply_filters('getpaid_page_default_content_receipt', $content, $blocks); |
|
1812 | 1812 | } |
1813 | 1813 | |
1814 | 1814 | return $content; |
@@ -1823,17 +1823,17 @@ discard block |
||
1823 | 1823 | * @param @bool $blocks True to use blocks. |
1824 | 1824 | * @return string Page content. |
1825 | 1825 | */ |
1826 | - function getpaid_page_content_failure( $filtered = false, $blocks = false ) { |
|
1827 | - if ( $blocks ) { |
|
1826 | + function getpaid_page_content_failure($filtered = false, $blocks = false) { |
|
1827 | + if ($blocks) { |
|
1828 | 1828 | $content = "<!-- wp:html --> |
1829 | -" . __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ) . " |
|
1829 | +" . __('Your transaction failed, please try again or contact site support.', 'invoicing') . " |
|
1830 | 1830 | <!-- /wp:html -->"; |
1831 | 1831 | } else { |
1832 | - $content = __( 'Your transaction failed, please try again or contact site support.', 'invoicing' ); |
|
1832 | + $content = __('Your transaction failed, please try again or contact site support.', 'invoicing'); |
|
1833 | 1833 | } |
1834 | 1834 | |
1835 | - if ( $filtered ) { |
|
1836 | - $content = apply_filters( 'getpaid_page_default_content_failure', $content, $blocks ); |
|
1835 | + if ($filtered) { |
|
1836 | + $content = apply_filters('getpaid_page_default_content_failure', $content, $blocks); |
|
1837 | 1837 | } |
1838 | 1838 | |
1839 | 1839 | return $content; |
@@ -1848,8 +1848,8 @@ discard block |
||
1848 | 1848 | * @param @bool $blocks True to use blocks. |
1849 | 1849 | * @return string Page content. |
1850 | 1850 | */ |
1851 | - function getpaid_page_content_subscriptions( $filtered = false, $blocks = false ) { |
|
1852 | - if ( $blocks ) { |
|
1851 | + function getpaid_page_content_subscriptions($filtered = false, $blocks = false) { |
|
1852 | + if ($blocks) { |
|
1853 | 1853 | $content = "<!-- wp:invoicing/wpinv-subscriptions-widget {\"content\":\"\",\"sd_shortcode\":\"[wpinv_subscriptions title='' ]\"} --> |
1854 | 1854 | <div class=\"wp-block-invoicing-wpinv-subscriptions-widget\"></div> |
1855 | 1855 | <!-- /wp:invoicing/wpinv-subscriptions-widget -->"; |
@@ -1857,8 +1857,8 @@ discard block |
||
1857 | 1857 | $content = "[wpinv_subscriptions]"; |
1858 | 1858 | } |
1859 | 1859 | |
1860 | - if ( $filtered ) { |
|
1861 | - $content = apply_filters( 'getpaid_page_default_content_subscriptions', $content, $blocks ); |
|
1860 | + if ($filtered) { |
|
1861 | + $content = apply_filters('getpaid_page_default_content_subscriptions', $content, $blocks); |
|
1862 | 1862 | } |
1863 | 1863 | |
1864 | 1864 | return $content; |
@@ -1873,22 +1873,22 @@ discard block |
||
1873 | 1873 | * @param bool $translated True if label needs to be translated. |
1874 | 1874 | * @return array Returns options array. |
1875 | 1875 | */ |
1876 | -function getpaid_parse_field_options( $options, $translated = true ) { |
|
1876 | +function getpaid_parse_field_options($options, $translated = true) { |
|
1877 | 1877 | $orig_options = $options; |
1878 | 1878 | |
1879 | 1879 | $options = array(); |
1880 | 1880 | |
1881 | - if ( ! empty( $orig_options ) ) { |
|
1882 | - foreach ( $orig_options as $key => $value ) { |
|
1883 | - if ( $value && is_string( $value ) ) { |
|
1884 | - $label = $translated ? __( wp_unslash( $value ), 'invoicing' ) : $value; |
|
1881 | + if (!empty($orig_options)) { |
|
1882 | + foreach ($orig_options as $key => $value) { |
|
1883 | + if ($value && is_string($value)) { |
|
1884 | + $label = $translated ? __(wp_unslash($value), 'invoicing') : $value; |
|
1885 | 1885 | } else { |
1886 | 1886 | $label = $value; |
1887 | 1887 | } |
1888 | 1888 | |
1889 | - $options[ $value ] = $label; |
|
1889 | + $options[$value] = $label; |
|
1890 | 1890 | } |
1891 | 1891 | } |
1892 | 1892 | |
1893 | - return apply_filters( 'getpaid_parse_field_options', $options, $orig_options, $translated ); |
|
1893 | + return apply_filters('getpaid_parse_field_options', $options, $orig_options, $translated); |
|
1894 | 1894 | } |