@@ -42,94 +42,94 @@ discard block |
||
42 | 42 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
43 | 43 | <?php |
44 | 44 | |
45 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
45 | + foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
46 | 46 | |
47 | - $column_id = sanitize_html_class( $column_id ); |
|
48 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
47 | + $column_id = sanitize_html_class( $column_id ); |
|
48 | + $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
49 | 49 | |
50 | - echo "<td class='$column_id $class'>"; |
|
51 | - switch ( $column_id ) { |
|
50 | + echo "<td class='$column_id $class'>"; |
|
51 | + switch ( $column_id ) { |
|
52 | 52 | |
53 | - case 'invoice-number': |
|
54 | - echo wpinv_invoice_link( $invoice ); |
|
55 | - break; |
|
53 | + case 'invoice-number': |
|
54 | + echo wpinv_invoice_link( $invoice ); |
|
55 | + break; |
|
56 | 56 | |
57 | - case 'created-date': |
|
58 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
59 | - break; |
|
57 | + case 'created-date': |
|
58 | + echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
59 | + break; |
|
60 | 60 | |
61 | - case 'payment-date': |
|
61 | + case 'payment-date': |
|
62 | 62 | |
63 | - if ( $invoice->needs_payment() ) { |
|
64 | - echo "—"; |
|
65 | - } else { |
|
66 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
67 | - } |
|
63 | + if ( $invoice->needs_payment() ) { |
|
64 | + echo "—"; |
|
65 | + } else { |
|
66 | + echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
67 | + } |
|
68 | 68 | |
69 | - break; |
|
69 | + break; |
|
70 | 70 | |
71 | - case 'invoice-status': |
|
72 | - echo $invoice->get_status_label_html(); |
|
71 | + case 'invoice-status': |
|
72 | + echo $invoice->get_status_label_html(); |
|
73 | 73 | |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - case 'invoice-total': |
|
77 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
76 | + case 'invoice-total': |
|
77 | + echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
78 | 78 | |
79 | - break; |
|
79 | + break; |
|
80 | 80 | |
81 | - case 'invoice-actions': |
|
81 | + case 'invoice-actions': |
|
82 | 82 | |
83 | - $actions = array( |
|
83 | + $actions = array( |
|
84 | 84 | |
85 | - 'pay' => array( |
|
86 | - 'url' => $invoice->get_checkout_payment_url(), |
|
87 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
88 | - 'class' => 'btn-success' |
|
89 | - ), |
|
85 | + 'pay' => array( |
|
86 | + 'url' => $invoice->get_checkout_payment_url(), |
|
87 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
88 | + 'class' => 'btn-success' |
|
89 | + ), |
|
90 | 90 | |
91 | - 'print' => array( |
|
92 | - 'url' => $invoice->get_view_url(), |
|
93 | - 'name' => __( 'View', 'invoicing' ), |
|
94 | - 'class' => 'btn-secondary', |
|
95 | - 'attrs' => 'target="_blank"' |
|
96 | - ) |
|
97 | - ); |
|
91 | + 'print' => array( |
|
92 | + 'url' => $invoice->get_view_url(), |
|
93 | + 'name' => __( 'View', 'invoicing' ), |
|
94 | + 'class' => 'btn-secondary', |
|
95 | + 'attrs' => 'target="_blank"' |
|
96 | + ) |
|
97 | + ); |
|
98 | 98 | |
99 | - if ( ! $invoice->needs_payment() ) { |
|
100 | - unset( $actions['pay'] ); |
|
101 | - } |
|
99 | + if ( ! $invoice->needs_payment() ) { |
|
100 | + unset( $actions['pay'] ); |
|
101 | + } |
|
102 | 102 | |
103 | - if ( $invoice->needs_payment() ) { |
|
104 | - $actions['delete'] = array( |
|
105 | - 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
106 | - 'name' => __( 'Delete', 'invoicing' ), |
|
107 | - 'class' => 'btn-danger' |
|
108 | - ); |
|
109 | - } |
|
103 | + if ( $invoice->needs_payment() ) { |
|
104 | + $actions['delete'] = array( |
|
105 | + 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
106 | + 'name' => __( 'Delete', 'invoicing' ), |
|
107 | + 'class' => 'btn-danger' |
|
108 | + ); |
|
109 | + } |
|
110 | 110 | |
111 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
111 | + $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
112 | 112 | |
113 | - foreach ( $actions as $key => $action ) { |
|
114 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
115 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
116 | - } |
|
113 | + foreach ( $actions as $key => $action ) { |
|
114 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
115 | + echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
116 | + } |
|
117 | 117 | |
118 | - break; |
|
118 | + break; |
|
119 | 119 | |
120 | - default: |
|
121 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
122 | - break; |
|
120 | + default: |
|
121 | + do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
122 | + break; |
|
123 | 123 | |
124 | 124 | |
125 | - } |
|
125 | + } |
|
126 | 126 | |
127 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
127 | + do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
128 | 128 | |
129 | - echo '</td>'; |
|
129 | + echo '</td>'; |
|
130 | 130 | |
131 | - endforeach; |
|
132 | - ?> |
|
131 | + endforeach; |
|
132 | + ?> |
|
133 | 133 | </tr> |
134 | 134 | |
135 | 135 | <?php endforeach; ?> |
@@ -143,14 +143,14 @@ discard block |
||
143 | 143 | <?php if ( 1 < $invoices->max_num_pages ) : ?> |
144 | 144 | <div class="invoicing-Pagination"> |
145 | 145 | <?php |
146 | - $big = 999999; |
|
147 | - |
|
148 | - echo paginate_links( array( |
|
149 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
150 | - 'format' => '?paged=%#%', |
|
151 | - 'total' => $invoices->max_num_pages, |
|
152 | - ) ); |
|
153 | - ?> |
|
146 | + $big = 999999; |
|
147 | + |
|
148 | + echo paginate_links( array( |
|
149 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
150 | + 'format' => '?paged=%#%', |
|
151 | + 'total' => $invoices->max_num_pages, |
|
152 | + ) ); |
|
153 | + ?> |
|
154 | 154 | </div> |
155 | 155 | <?php endif; ?> |
156 | 156 |
@@ -7,27 +7,27 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Current page. |
13 | -$current_page = empty( $_GET[ 'page' ] ) ? 1 : absint( $_GET[ 'page' ] ); |
|
13 | +$current_page = empty($_GET['page']) ? 1 : absint($_GET['page']); |
|
14 | 14 | |
15 | 15 | // Fires before displaying user invoices. |
16 | -do_action( 'wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); |
|
16 | +do_action('wpinv_before_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); |
|
17 | 17 | |
18 | 18 | ?> |
19 | 19 | |
20 | 20 | |
21 | 21 | <div class="table-responsive"> |
22 | - <table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class( $post_type ); ?>"> |
|
22 | + <table class="table table-bordered table-hover getpaid-user-invoices <?php echo sanitize_html_class($post_type); ?>"> |
|
23 | 23 | |
24 | 24 | |
25 | 25 | <thead> |
26 | 26 | <tr> |
27 | 27 | |
28 | - <?php foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : ?> |
|
29 | - <th class="<?php echo sanitize_html_class( $column_id ); ?> <?php echo ( ! empty( $column_name['class'] ) ? sanitize_html_class( $column_name['class'] ) : '');?> border-bottom-0"> |
|
30 | - <span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span> |
|
28 | + <?php foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : ?> |
|
29 | + <th class="<?php echo sanitize_html_class($column_id); ?> <?php echo (!empty($column_name['class']) ? sanitize_html_class($column_name['class']) : ''); ?> border-bottom-0"> |
|
30 | + <span class="nobr"><?php echo esc_html($column_name['title']); ?></span> |
|
31 | 31 | </th> |
32 | 32 | <?php endforeach; ?> |
33 | 33 | |
@@ -37,33 +37,33 @@ discard block |
||
37 | 37 | |
38 | 38 | |
39 | 39 | <tbody> |
40 | - <?php foreach ( $invoices->invoices as $invoice ) : ?> |
|
40 | + <?php foreach ($invoices->invoices as $invoice) : ?> |
|
41 | 41 | |
42 | 42 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
43 | 43 | <?php |
44 | 44 | |
45 | - foreach ( wpinv_get_user_invoices_columns( $post_type ) as $column_id => $column_name ) : |
|
45 | + foreach (wpinv_get_user_invoices_columns($post_type) as $column_id => $column_name) : |
|
46 | 46 | |
47 | - $column_id = sanitize_html_class( $column_id ); |
|
48 | - $class = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] ); |
|
47 | + $column_id = sanitize_html_class($column_id); |
|
48 | + $class = empty($column_name['class']) ? '' : sanitize_html_class($column_name['class']); |
|
49 | 49 | |
50 | 50 | echo "<td class='$column_id $class'>"; |
51 | - switch ( $column_id ) { |
|
51 | + switch ($column_id) { |
|
52 | 52 | |
53 | 53 | case 'invoice-number': |
54 | - echo wpinv_invoice_link( $invoice ); |
|
54 | + echo wpinv_invoice_link($invoice); |
|
55 | 55 | break; |
56 | 56 | |
57 | 57 | case 'created-date': |
58 | - echo getpaid_format_date_value( $invoice->get_date_created() ); |
|
58 | + echo getpaid_format_date_value($invoice->get_date_created()); |
|
59 | 59 | break; |
60 | 60 | |
61 | 61 | case 'payment-date': |
62 | 62 | |
63 | - if ( $invoice->needs_payment() ) { |
|
63 | + if ($invoice->needs_payment()) { |
|
64 | 64 | echo "—"; |
65 | 65 | } else { |
66 | - echo getpaid_format_date_value( $invoice->get_date_completed() ); |
|
66 | + echo getpaid_format_date_value($invoice->get_date_completed()); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | break; |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | break; |
75 | 75 | |
76 | 76 | case 'invoice-total': |
77 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
77 | + echo wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
78 | 78 | |
79 | 79 | break; |
80 | 80 | |
@@ -84,47 +84,47 @@ discard block |
||
84 | 84 | |
85 | 85 | 'pay' => array( |
86 | 86 | 'url' => $invoice->get_checkout_payment_url(), |
87 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
87 | + 'name' => __('Pay Now', 'invoicing'), |
|
88 | 88 | 'class' => 'btn-success' |
89 | 89 | ), |
90 | 90 | |
91 | 91 | 'print' => array( |
92 | 92 | 'url' => $invoice->get_view_url(), |
93 | - 'name' => __( 'View', 'invoicing' ), |
|
93 | + 'name' => __('View', 'invoicing'), |
|
94 | 94 | 'class' => 'btn-secondary', |
95 | 95 | 'attrs' => 'target="_blank"' |
96 | 96 | ) |
97 | 97 | ); |
98 | 98 | |
99 | - if ( ! $invoice->needs_payment() ) { |
|
100 | - unset( $actions['pay'] ); |
|
99 | + if (!$invoice->needs_payment()) { |
|
100 | + unset($actions['pay']); |
|
101 | 101 | } |
102 | 102 | |
103 | - if ( $invoice->needs_payment() ) { |
|
103 | + if ($invoice->needs_payment()) { |
|
104 | 104 | $actions['delete'] = array( |
105 | - 'url' => getpaid_get_authenticated_action_url( 'delete_invoice', add_query_arg( 'invoice_id', $invoice->get_id() ) ), |
|
106 | - 'name' => __( 'Delete', 'invoicing' ), |
|
105 | + 'url' => getpaid_get_authenticated_action_url('delete_invoice', add_query_arg('invoice_id', $invoice->get_id())), |
|
106 | + 'name' => __('Delete', 'invoicing'), |
|
107 | 107 | 'class' => 'btn-danger' |
108 | 108 | ); |
109 | 109 | } |
110 | 110 | |
111 | - $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice, $post_type ); |
|
111 | + $actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice, $post_type); |
|
112 | 112 | |
113 | - foreach ( $actions as $key => $action ) { |
|
113 | + foreach ($actions as $key => $action) { |
|
114 | 114 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
115 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
115 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | break; |
119 | 119 | |
120 | 120 | default: |
121 | - do_action( "wpinv_user_invoices_column_$column_id", $invoice ); |
|
121 | + do_action("wpinv_user_invoices_column_$column_id", $invoice); |
|
122 | 122 | break; |
123 | 123 | |
124 | 124 | |
125 | 125 | } |
126 | 126 | |
127 | - do_action( "wpinv_user_invoices_column_after_$column_id", $invoice ); |
|
127 | + do_action("wpinv_user_invoices_column_after_$column_id", $invoice); |
|
128 | 128 | |
129 | 129 | echo '</td>'; |
130 | 130 | |
@@ -138,20 +138,20 @@ discard block |
||
138 | 138 | </table> |
139 | 139 | </div> |
140 | 140 | |
141 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
141 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
142 | 142 | |
143 | - <?php if ( 1 < $invoices->max_num_pages ) : ?> |
|
143 | + <?php if (1 < $invoices->max_num_pages) : ?> |
|
144 | 144 | <div class="invoicing-Pagination"> |
145 | 145 | <?php |
146 | 146 | $big = 999999; |
147 | 147 | |
148 | - echo paginate_links( array( |
|
149 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
148 | + echo paginate_links(array( |
|
149 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
150 | 150 | 'format' => '?paged=%#%', |
151 | 151 | 'total' => $invoices->max_num_pages, |
152 | - ) ); |
|
152 | + )); |
|
153 | 153 | ?> |
154 | 154 | </div> |
155 | 155 | <?php endif; ?> |
156 | 156 | |
157 | -<?php do_action( 'wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type ); ?> |
|
157 | +<?php do_action('wpinv_after_user_invoices', $invoices->invoices, $invoices->total, $invoices->max_num_pages, $post_type); ?> |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -20,35 +20,35 @@ discard block |
||
20 | 20 | */ |
21 | 21 | function wpinv_get_ip() { |
22 | 22 | |
23 | - if ( isset( $_SERVER['HTTP_X_REAL_IP'] ) ) { |
|
24 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_REAL_IP'] ) ); |
|
23 | + if (isset($_SERVER['HTTP_X_REAL_IP'])) { |
|
24 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_X_REAL_IP'])); |
|
25 | 25 | } |
26 | 26 | |
27 | - if ( isset( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | // Proxy servers can send through this header like this: X-Forwarded-For: client1, proxy1, proxy2 |
29 | 29 | // Make sure we always only send through the first IP in the list which should always be the client IP. |
30 | - return (string) rest_is_ip_address( trim( current( preg_split( '/,/', sanitize_text_field( wp_unslash( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) ) ) ) ); |
|
30 | + return (string) rest_is_ip_address(trim(current(preg_split('/,/', sanitize_text_field(wp_unslash($_SERVER['HTTP_X_FORWARDED_FOR'])))))); |
|
31 | 31 | } |
32 | 32 | |
33 | - if ( isset( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
34 | - return sanitize_text_field( wp_unslash( $_SERVER['HTTP_CLIENT_IP'] ) ); |
|
33 | + if (isset($_SERVER['HTTP_CLIENT_IP'])) { |
|
34 | + return sanitize_text_field(wp_unslash($_SERVER['HTTP_CLIENT_IP'])); |
|
35 | 35 | } |
36 | 36 | |
37 | - if ( isset( $_SERVER['REMOTE_ADDR'] ) ) { |
|
38 | - return sanitize_text_field( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ); |
|
37 | + if (isset($_SERVER['REMOTE_ADDR'])) { |
|
38 | + return sanitize_text_field(wp_unslash($_SERVER['REMOTE_ADDR'])); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | return ''; |
42 | 42 | } |
43 | 43 | |
44 | 44 | function wpinv_get_user_agent() { |
45 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
46 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
45 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
46 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
47 | 47 | } else { |
48 | 48 | $user_agent = ''; |
49 | 49 | } |
50 | 50 | |
51 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
51 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,16 +57,16 @@ discard block |
||
57 | 57 | * @param string $amount The amount to sanitize. |
58 | 58 | * @return float |
59 | 59 | */ |
60 | -function getpaid_standardize_amount( $amount ) { |
|
60 | +function getpaid_standardize_amount($amount) { |
|
61 | 61 | |
62 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
63 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
64 | - if ( is_numeric( $amount ) ) { |
|
65 | - return floatval( $amount ); |
|
62 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
63 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
64 | + if (is_numeric($amount)) { |
|
65 | + return floatval($amount); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | // Cast the remaining to a float. |
69 | - return wpinv_round_amount( preg_replace( '/[^0-9\.\-]/', '', $amount ) ); |
|
69 | + return wpinv_round_amount(preg_replace('/[^0-9\.\-]/', '', $amount)); |
|
70 | 70 | |
71 | 71 | } |
72 | 72 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * |
76 | 76 | * @param string $amount The amount to sanitize. |
77 | 77 | */ |
78 | -function getpaid_unstandardize_amount( $amount ) { |
|
79 | - return str_replace( '.', wpinv_decimal_separator(), $amount ); |
|
78 | +function getpaid_unstandardize_amount($amount) { |
|
79 | + return str_replace('.', wpinv_decimal_separator(), $amount); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @param string $amount The amount to sanitize. |
86 | 86 | */ |
87 | -function wpinv_sanitize_amount( $amount ) { |
|
87 | +function wpinv_sanitize_amount($amount) { |
|
88 | 88 | |
89 | - if ( is_numeric( $amount ) ) { |
|
90 | - return floatval( $amount ); |
|
89 | + if (is_numeric($amount)) { |
|
90 | + return floatval($amount); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Separate the decimals and thousands. |
94 | - $amount = explode( wpinv_decimal_separator(), $amount ); |
|
94 | + $amount = explode(wpinv_decimal_separator(), $amount); |
|
95 | 95 | |
96 | 96 | // Remove thousands. |
97 | - $amount[0] = str_replace( wpinv_thousands_separator(), '', $amount[0] ); |
|
97 | + $amount[0] = str_replace(wpinv_thousands_separator(), '', $amount[0]); |
|
98 | 98 | |
99 | 99 | // Convert back to string. |
100 | - $amount = count( $amount ) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
100 | + $amount = count($amount) > 1 ? "{$amount[0]}.{$amount[1]}" : $amount[0]; |
|
101 | 101 | |
102 | 102 | // Cast the remaining to a float. |
103 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
103 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
104 | 104 | |
105 | 105 | } |
106 | 106 | |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | * @param float $amount |
111 | 111 | * @param float|string|int|null $decimals |
112 | 112 | */ |
113 | -function wpinv_round_amount( $amount, $decimals = null, $use_sprintf = false ) { |
|
113 | +function wpinv_round_amount($amount, $decimals = null, $use_sprintf = false) { |
|
114 | 114 | |
115 | - if ( $decimals === null ) { |
|
115 | + if ($decimals === null) { |
|
116 | 116 | $decimals = wpinv_decimals(); |
117 | 117 | } |
118 | 118 | |
119 | - if ( $use_sprintf ) { |
|
120 | - $amount = sprintf( "%.{$decimals}f", (float) $amount ); |
|
119 | + if ($use_sprintf) { |
|
120 | + $amount = sprintf("%.{$decimals}f", (float) $amount); |
|
121 | 121 | } else { |
122 | - $amount = round( (float) $amount, absint( $decimals ) ); |
|
122 | + $amount = round((float) $amount, absint($decimals)); |
|
123 | 123 | } |
124 | 124 | |
125 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
125 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -134,32 +134,32 @@ discard block |
||
134 | 134 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
135 | 135 | * @return array |
136 | 136 | */ |
137 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
137 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
138 | 138 | |
139 | 139 | $invoice_statuses = array( |
140 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
141 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
142 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
143 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
144 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
145 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
146 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
147 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
140 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
141 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
142 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
143 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
144 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
145 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
146 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
147 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - if ( $draft ) { |
|
151 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
150 | + if ($draft) { |
|
151 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
152 | 152 | } |
153 | 153 | |
154 | - if ( $trashed ) { |
|
155 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
154 | + if ($trashed) { |
|
155 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $invoice instanceof WPInv_Invoice ) { |
|
158 | + if ($invoice instanceof WPInv_Invoice) { |
|
159 | 159 | $invoice = $invoice->get_post_type(); |
160 | 160 | } |
161 | 161 | |
162 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
162 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,11 +168,11 @@ discard block |
||
168 | 168 | * @param string $status The raw status |
169 | 169 | * @param string|WPInv_Invoice $invoice The invoice object|post type|type |
170 | 170 | */ |
171 | -function wpinv_status_nicename( $status, $invoice = false ) { |
|
172 | - $statuses = wpinv_get_invoice_statuses( true, true, $invoice ); |
|
173 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : $status; |
|
171 | +function wpinv_status_nicename($status, $invoice = false) { |
|
172 | + $statuses = wpinv_get_invoice_statuses(true, true, $invoice); |
|
173 | + $status = isset($statuses[$status]) ? $statuses[$status] : $status; |
|
174 | 174 | |
175 | - return sanitize_text_field( $status ); |
|
175 | + return sanitize_text_field($status); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @param string $current |
182 | 182 | */ |
183 | -function wpinv_get_currency( $current = '' ) { |
|
183 | +function wpinv_get_currency($current = '') { |
|
184 | 184 | |
185 | - if ( empty( $current ) ) { |
|
186 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
185 | + if (empty($current)) { |
|
186 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
187 | 187 | } |
188 | 188 | |
189 | - return trim( strtoupper( $current ) ); |
|
189 | + return trim(strtoupper($current)); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -194,25 +194,25 @@ discard block |
||
194 | 194 | * |
195 | 195 | * @param string|null $currency The currency code. Defaults to the default currency. |
196 | 196 | */ |
197 | -function wpinv_currency_symbol( $currency = null ) { |
|
197 | +function wpinv_currency_symbol($currency = null) { |
|
198 | 198 | |
199 | 199 | // Prepare the currency. |
200 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
200 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
201 | 201 | |
202 | 202 | // Fetch all symbols. |
203 | 203 | $symbols = wpinv_get_currency_symbols(); |
204 | 204 | |
205 | 205 | // Fetch this currencies symbol. |
206 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
206 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
207 | 207 | |
208 | 208 | // Filter the symbol. |
209 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
209 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | function wpinv_currency_position() { |
213 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
213 | + $position = wpinv_get_option('currency_position', 'left'); |
|
214 | 214 | |
215 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
215 | + return apply_filters('wpinv_currency_position', $position); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,13 +220,13 @@ discard block |
||
220 | 220 | * |
221 | 221 | * @param $string|null $current |
222 | 222 | */ |
223 | -function wpinv_thousands_separator( $current = null ) { |
|
223 | +function wpinv_thousands_separator($current = null) { |
|
224 | 224 | |
225 | - if ( null == $current ) { |
|
226 | - $current = wpinv_get_option( 'thousands_separator', ',' ); |
|
225 | + if (null == $current) { |
|
226 | + $current = wpinv_get_option('thousands_separator', ','); |
|
227 | 227 | } |
228 | 228 | |
229 | - return trim( $current ); |
|
229 | + return trim($current); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -234,13 +234,13 @@ discard block |
||
234 | 234 | * |
235 | 235 | * @param $string|null $current |
236 | 236 | */ |
237 | -function wpinv_decimal_separator( $current = null ) { |
|
237 | +function wpinv_decimal_separator($current = null) { |
|
238 | 238 | |
239 | - if ( null == $current ) { |
|
240 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
239 | + if (null == $current) { |
|
240 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
241 | 241 | } |
242 | 242 | |
243 | - return trim( $current ); |
|
243 | + return trim($current); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -248,27 +248,27 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @param $string|null $current |
250 | 250 | */ |
251 | -function wpinv_decimals( $current = null ) { |
|
251 | +function wpinv_decimals($current = null) { |
|
252 | 252 | |
253 | - if ( null == $current ) { |
|
254 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
253 | + if (null == $current) { |
|
254 | + $current = wpinv_get_option('decimals', 2); |
|
255 | 255 | } |
256 | 256 | |
257 | - return absint( $current ); |
|
257 | + return absint($current); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
261 | 261 | * Retrieves a list of all supported currencies. |
262 | 262 | */ |
263 | 263 | function wpinv_get_currencies() { |
264 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
264 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | /** |
268 | 268 | * Retrieves a list of all currency symbols. |
269 | 269 | */ |
270 | 270 | function wpinv_get_currency_symbols() { |
271 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
271 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | $currency_pos = wpinv_currency_position(); |
281 | 281 | $format = '%1$s%2$s'; |
282 | 282 | |
283 | - switch ( $currency_pos ) { |
|
283 | + switch ($currency_pos) { |
|
284 | 284 | case 'left': |
285 | 285 | $format = '%1$s%2$s'; |
286 | 286 | break; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | break; |
296 | 296 | } |
297 | 297 | |
298 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
298 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
@@ -305,25 +305,25 @@ discard block |
||
305 | 305 | * @param string $currency Currency. |
306 | 306 | * @return string |
307 | 307 | */ |
308 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
308 | +function wpinv_price($amount = 0, $currency = '') { |
|
309 | 309 | |
310 | 310 | // Backwards compatibility. |
311 | - $amount = wpinv_sanitize_amount( $amount ); |
|
311 | + $amount = wpinv_sanitize_amount($amount); |
|
312 | 312 | |
313 | 313 | // Prepare variables. |
314 | - $currency = wpinv_get_currency( $currency ); |
|
314 | + $currency = wpinv_get_currency($currency); |
|
315 | 315 | $amount = (float) $amount; |
316 | 316 | $unformatted_amount = $amount; |
317 | 317 | $negative = $amount < 0; |
318 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
319 | - $amount = wpinv_format_amount( $amount ); |
|
318 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
319 | + $amount = wpinv_format_amount($amount); |
|
320 | 320 | |
321 | 321 | // Format the amount. |
322 | 322 | $format = getpaid_get_price_format(); |
323 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
323 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
324 | 324 | |
325 | 325 | // Filter the formatting. |
326 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
326 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,25 +334,25 @@ discard block |
||
334 | 334 | * @param bool $calculate Whether or not to apply separators. |
335 | 335 | * @return string |
336 | 336 | */ |
337 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
337 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
338 | 338 | $thousands_sep = wpinv_thousands_separator(); |
339 | 339 | $decimal_sep = wpinv_decimal_separator(); |
340 | - $decimals = wpinv_decimals( $decimals ); |
|
341 | - $amount = wpinv_sanitize_amount( $amount ); |
|
340 | + $decimals = wpinv_decimals($decimals); |
|
341 | + $amount = wpinv_sanitize_amount($amount); |
|
342 | 342 | |
343 | - if ( $calculate ) { |
|
343 | + if ($calculate) { |
|
344 | 344 | return $amount; |
345 | 345 | } |
346 | 346 | |
347 | 347 | // Fomart the amount. |
348 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
348 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
349 | 349 | } |
350 | 350 | |
351 | -function wpinv_sanitize_key( $key ) { |
|
351 | +function wpinv_sanitize_key($key) { |
|
352 | 352 | $raw_key = $key; |
353 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
353 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
354 | 354 | |
355 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
355 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -360,8 +360,8 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @param $str the file whose extension should be retrieved. |
362 | 362 | */ |
363 | -function wpinv_get_file_extension( $str ) { |
|
364 | - $filetype = wp_check_filetype( $str ); |
|
363 | +function wpinv_get_file_extension($str) { |
|
364 | + $filetype = wp_check_filetype($str); |
|
365 | 365 | return $filetype['ext']; |
366 | 366 | } |
367 | 367 | |
@@ -370,16 +370,16 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param string $string |
372 | 372 | */ |
373 | -function wpinv_string_is_image_url( $string ) { |
|
374 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
375 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
373 | +function wpinv_string_is_image_url($string) { |
|
374 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
375 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
379 | 379 | * Returns the current URL. |
380 | 380 | */ |
381 | 381 | function wpinv_get_current_page_url() { |
382 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
382 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -389,46 +389,46 @@ discard block |
||
389 | 389 | * @param string $name Constant name. |
390 | 390 | * @param mixed $value Value. |
391 | 391 | */ |
392 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
393 | - if ( ! defined( $name ) ) { |
|
394 | - define( $name, $value ); |
|
392 | +function getpaid_maybe_define_constant($name, $value) { |
|
393 | + if (!defined($name)) { |
|
394 | + define($name, $value); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
398 | 398 | function wpinv_get_php_arg_separator_output() { |
399 | - return ini_get( 'arg_separator.output' ); |
|
399 | + return ini_get('arg_separator.output'); |
|
400 | 400 | } |
401 | 401 | |
402 | -function wpinv_rgb_from_hex( $color ) { |
|
403 | - $color = str_replace( '#', '', $color ); |
|
402 | +function wpinv_rgb_from_hex($color) { |
|
403 | + $color = str_replace('#', '', $color); |
|
404 | 404 | |
405 | 405 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
406 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
407 | - if ( empty( $color ) ) { |
|
406 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
407 | + if (empty($color)) { |
|
408 | 408 | return NULL; |
409 | 409 | } |
410 | 410 | |
411 | - $color = str_split( $color ); |
|
411 | + $color = str_split($color); |
|
412 | 412 | |
413 | 413 | $rgb = array(); |
414 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
415 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
416 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
414 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
415 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
416 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
417 | 417 | |
418 | 418 | return $rgb; |
419 | 419 | } |
420 | 420 | |
421 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
422 | - $base = wpinv_rgb_from_hex( $color ); |
|
421 | +function wpinv_hex_darker($color, $factor = 30) { |
|
422 | + $base = wpinv_rgb_from_hex($color); |
|
423 | 423 | $color = '#'; |
424 | 424 | |
425 | - foreach ( $base as $k => $v ) { |
|
425 | + foreach ($base as $k => $v) { |
|
426 | 426 | $amount = $v / 100; |
427 | - $amount = round( $amount * $factor ); |
|
427 | + $amount = round($amount * $factor); |
|
428 | 428 | $new_decimal = $v - $amount; |
429 | 429 | |
430 | - $new_hex_component = dechex( $new_decimal ); |
|
431 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
430 | + $new_hex_component = dechex($new_decimal); |
|
431 | + if (strlen($new_hex_component) < 2) { |
|
432 | 432 | $new_hex_component = "0" . $new_hex_component; |
433 | 433 | } |
434 | 434 | $color .= $new_hex_component; |
@@ -437,18 +437,18 @@ discard block |
||
437 | 437 | return $color; |
438 | 438 | } |
439 | 439 | |
440 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
441 | - $base = wpinv_rgb_from_hex( $color ); |
|
440 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
441 | + $base = wpinv_rgb_from_hex($color); |
|
442 | 442 | $color = '#'; |
443 | 443 | |
444 | - foreach ( $base as $k => $v ) { |
|
444 | + foreach ($base as $k => $v) { |
|
445 | 445 | $amount = 255 - $v; |
446 | 446 | $amount = $amount / 100; |
447 | - $amount = round( $amount * $factor ); |
|
447 | + $amount = round($amount * $factor); |
|
448 | 448 | $new_decimal = $v + $amount; |
449 | 449 | |
450 | - $new_hex_component = dechex( $new_decimal ); |
|
451 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
450 | + $new_hex_component = dechex($new_decimal); |
|
451 | + if (strlen($new_hex_component) < 2) { |
|
452 | 452 | $new_hex_component = "0" . $new_hex_component; |
453 | 453 | } |
454 | 454 | $color .= $new_hex_component; |
@@ -457,22 +457,22 @@ discard block |
||
457 | 457 | return $color; |
458 | 458 | } |
459 | 459 | |
460 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
461 | - $hex = str_replace( '#', '', $color ); |
|
460 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
461 | + $hex = str_replace('#', '', $color); |
|
462 | 462 | |
463 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
464 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
465 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
463 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
464 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
465 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
466 | 466 | |
467 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
467 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
468 | 468 | |
469 | 469 | return $brightness > 155 ? $dark : $light; |
470 | 470 | } |
471 | 471 | |
472 | -function wpinv_format_hex( $hex ) { |
|
473 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
472 | +function wpinv_format_hex($hex) { |
|
473 | + $hex = trim(str_replace('#', '', $hex)); |
|
474 | 474 | |
475 | - if ( strlen( $hex ) == 3 ) { |
|
475 | + if (strlen($hex) == 3) { |
|
476 | 476 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
477 | 477 | } |
478 | 478 | |
@@ -492,12 +492,12 @@ discard block |
||
492 | 492 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
493 | 493 | * @return string |
494 | 494 | */ |
495 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
496 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
497 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
495 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
496 | + if (function_exists('mb_strimwidth')) { |
|
497 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
498 | 498 | } |
499 | 499 | |
500 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
500 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -509,28 +509,28 @@ discard block |
||
509 | 509 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
510 | 510 | * @return int Returns the number of characters in string. |
511 | 511 | */ |
512 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
513 | - if ( function_exists( 'mb_strlen' ) ) { |
|
514 | - return mb_strlen( $str, $encoding ); |
|
512 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
513 | + if (function_exists('mb_strlen')) { |
|
514 | + return mb_strlen($str, $encoding); |
|
515 | 515 | } |
516 | 516 | |
517 | - return strlen( $str ); |
|
517 | + return strlen($str); |
|
518 | 518 | } |
519 | 519 | |
520 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
521 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
522 | - return mb_strtolower( $str, $encoding ); |
|
520 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
521 | + if (function_exists('mb_strtolower')) { |
|
522 | + return mb_strtolower($str, $encoding); |
|
523 | 523 | } |
524 | 524 | |
525 | - return strtolower( $str ); |
|
525 | + return strtolower($str); |
|
526 | 526 | } |
527 | 527 | |
528 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
529 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
530 | - return mb_strtoupper( $str, $encoding ); |
|
528 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
529 | + if (function_exists('mb_strtoupper')) { |
|
530 | + return mb_strtoupper($str, $encoding); |
|
531 | 531 | } |
532 | 532 | |
533 | - return strtoupper( $str ); |
|
533 | + return strtoupper($str); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
545 | 545 | * @return int Returns the position of the first occurrence of search in the string. |
546 | 546 | */ |
547 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
548 | - if ( function_exists( 'mb_strpos' ) ) { |
|
549 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
547 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
548 | + if (function_exists('mb_strpos')) { |
|
549 | + return mb_strpos($str, $find, $offset, $encoding); |
|
550 | 550 | } |
551 | 551 | |
552 | - return strpos( $str, $find, $offset ); |
|
552 | + return strpos($str, $find, $offset); |
|
553 | 553 | } |
554 | 554 | |
555 | 555 | /** |
@@ -563,12 +563,12 @@ discard block |
||
563 | 563 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
564 | 564 | * @return int Returns the position of the last occurrence of search. |
565 | 565 | */ |
566 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
567 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
568 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
566 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
567 | + if (function_exists('mb_strrpos')) { |
|
568 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
569 | 569 | } |
570 | 570 | |
571 | - return strrpos( $str, $find, $offset ); |
|
571 | + return strrpos($str, $find, $offset); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | /** |
@@ -583,16 +583,16 @@ discard block |
||
583 | 583 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
584 | 584 | * @return string |
585 | 585 | */ |
586 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
587 | - if ( function_exists( 'mb_substr' ) ) { |
|
588 | - if ( $length === null ) { |
|
589 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
586 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
587 | + if (function_exists('mb_substr')) { |
|
588 | + if ($length === null) { |
|
589 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
590 | 590 | } else { |
591 | - return mb_substr( $str, $start, $length, $encoding ); |
|
591 | + return mb_substr($str, $start, $length, $encoding); |
|
592 | 592 | } |
593 | 593 | } |
594 | 594 | |
595 | - return substr( $str, $start, $length ); |
|
595 | + return substr($str, $start, $length); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | /** |
@@ -604,48 +604,48 @@ discard block |
||
604 | 604 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
605 | 605 | * @return string The width of string. |
606 | 606 | */ |
607 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
608 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
609 | - return mb_strwidth( $str, $encoding ); |
|
607 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
608 | + if (function_exists('mb_strwidth')) { |
|
609 | + return mb_strwidth($str, $encoding); |
|
610 | 610 | } |
611 | 611 | |
612 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
612 | + return wpinv_utf8_strlen($str, $encoding); |
|
613 | 613 | } |
614 | 614 | |
615 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
616 | - if ( function_exists( 'mb_strlen' ) ) { |
|
617 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
615 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
616 | + if (function_exists('mb_strlen')) { |
|
617 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
618 | 618 | $str_end = ""; |
619 | 619 | |
620 | - if ( $lower_str_end ) { |
|
621 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
620 | + if ($lower_str_end) { |
|
621 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
622 | 622 | } else { |
623 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
623 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
624 | 624 | } |
625 | 625 | |
626 | 626 | return $first_letter . $str_end; |
627 | 627 | } |
628 | 628 | |
629 | - return ucfirst( $str ); |
|
629 | + return ucfirst($str); |
|
630 | 630 | } |
631 | 631 | |
632 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
633 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
634 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
632 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
633 | + if (function_exists('mb_convert_case')) { |
|
634 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
635 | 635 | } |
636 | 636 | |
637 | - return ucwords( $str ); |
|
637 | + return ucwords($str); |
|
638 | 638 | } |
639 | 639 | |
640 | -function wpinv_period_in_days( $period, $unit ) { |
|
641 | - $period = absint( $period ); |
|
640 | +function wpinv_period_in_days($period, $unit) { |
|
641 | + $period = absint($period); |
|
642 | 642 | |
643 | - if ( $period > 0 ) { |
|
644 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
643 | + if ($period > 0) { |
|
644 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
645 | 645 | $period = $period * 7; |
646 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
646 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
647 | 647 | $period = $period * 30; |
648 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
648 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
649 | 649 | $period = $period * 365; |
650 | 650 | } |
651 | 651 | } |
@@ -653,14 +653,14 @@ discard block |
||
653 | 653 | return $period; |
654 | 654 | } |
655 | 655 | |
656 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
657 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
658 | - return cal_days_in_month( $calendar, $month, $year ); |
|
656 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
657 | + if (function_exists('cal_days_in_month')) { |
|
658 | + return cal_days_in_month($calendar, $month, $year); |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | // Fallback in case the calendar extension is not loaded in PHP |
662 | 662 | // Only supports Gregorian calendar |
663 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
663 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | /** |
@@ -671,15 +671,15 @@ discard block |
||
671 | 671 | * |
672 | 672 | * @return string |
673 | 673 | */ |
674 | -function wpi_help_tip( $tip, $allow_html = false, $is_vue = false ) { |
|
674 | +function wpi_help_tip($tip, $allow_html = false, $is_vue = false) { |
|
675 | 675 | |
676 | - if ( $allow_html ) { |
|
677 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
676 | + if ($allow_html) { |
|
677 | + $tip = wpi_sanitize_tooltip($tip); |
|
678 | 678 | } else { |
679 | - $tip = esc_attr( $tip ); |
|
679 | + $tip = esc_attr($tip); |
|
680 | 680 | } |
681 | 681 | |
682 | - if ( $is_vue ) { |
|
682 | + if ($is_vue) { |
|
683 | 683 | return '<span class="dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
684 | 684 | } |
685 | 685 | |
@@ -694,8 +694,8 @@ discard block |
||
694 | 694 | * @param string $var |
695 | 695 | * @return string |
696 | 696 | */ |
697 | -function wpi_sanitize_tooltip( $var ) { |
|
698 | - return wp_kses( html_entity_decode( $var ), array( |
|
697 | +function wpi_sanitize_tooltip($var) { |
|
698 | + return wp_kses(html_entity_decode($var), array( |
|
699 | 699 | 'br' => array(), |
700 | 700 | 'em' => array(), |
701 | 701 | 'strong' => array(), |
@@ -706,7 +706,7 @@ discard block |
||
706 | 706 | 'li' => array(), |
707 | 707 | 'ol' => array(), |
708 | 708 | 'p' => array(), |
709 | - ) ); |
|
709 | + )); |
|
710 | 710 | } |
711 | 711 | |
712 | 712 | /** |
@@ -716,7 +716,7 @@ discard block |
||
716 | 716 | */ |
717 | 717 | function wpinv_get_screen_ids() { |
718 | 718 | |
719 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
719 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
720 | 720 | |
721 | 721 | $screen_ids = array( |
722 | 722 | 'toplevel_page_' . $screen_id, |
@@ -735,10 +735,10 @@ discard block |
||
735 | 735 | 'getpaid_page_wpinv-reports', |
736 | 736 | 'getpaid_page_wpi-addons', |
737 | 737 | 'getpaid_page_wpinv-customers', |
738 | - 'gp-setup',// setup wizard |
|
738 | + 'gp-setup', // setup wizard |
|
739 | 739 | ); |
740 | 740 | |
741 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
741 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -749,14 +749,14 @@ discard block |
||
749 | 749 | * @param array|string $list List of values. |
750 | 750 | * @return array Sanitized array of values. |
751 | 751 | */ |
752 | -function wpinv_parse_list( $list ) { |
|
752 | +function wpinv_parse_list($list) { |
|
753 | 753 | |
754 | - if ( empty( $list ) ) { |
|
754 | + if (empty($list)) { |
|
755 | 755 | $list = array(); |
756 | 756 | } |
757 | 757 | |
758 | - if ( ! is_array( $list ) ) { |
|
759 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
758 | + if (!is_array($list)) { |
|
759 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
760 | 760 | } |
761 | 761 | |
762 | 762 | return $list; |
@@ -770,16 +770,16 @@ discard block |
||
770 | 770 | * @param string $key Type of data to fetch. |
771 | 771 | * @return mixed Fetched data. |
772 | 772 | */ |
773 | -function wpinv_get_data( $key ) { |
|
773 | +function wpinv_get_data($key) { |
|
774 | 774 | |
775 | 775 | // Try fetching it from the cache. |
776 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
777 | - if( $data ) { |
|
776 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
777 | + if ($data) { |
|
778 | 778 | return $data; |
779 | 779 | } |
780 | 780 | |
781 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
782 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
781 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
782 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
783 | 783 | |
784 | 784 | return $data; |
785 | 785 | } |
@@ -793,10 +793,10 @@ discard block |
||
793 | 793 | * @param bool $first_empty Whether or not the first item in the list should be empty |
794 | 794 | * @return mixed Fetched data. |
795 | 795 | */ |
796 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
796 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
797 | 797 | |
798 | - if ( ! empty( $options ) && $first_empty ) { |
|
799 | - return array_merge( array( '' => '' ), $options ); |
|
798 | + if (!empty($options) && $first_empty) { |
|
799 | + return array_merge(array('' => ''), $options); |
|
800 | 800 | } |
801 | 801 | return $options; |
802 | 802 | |
@@ -808,21 +808,21 @@ discard block |
||
808 | 808 | * @param mixed $var Data to sanitize. |
809 | 809 | * @return string|array |
810 | 810 | */ |
811 | -function wpinv_clean( $var ) { |
|
811 | +function wpinv_clean($var) { |
|
812 | 812 | |
813 | - if ( is_array( $var ) ) { |
|
814 | - return array_map( 'wpinv_clean', $var ); |
|
813 | + if (is_array($var)) { |
|
814 | + return array_map('wpinv_clean', $var); |
|
815 | 815 | } |
816 | 816 | |
817 | - if ( is_object( $var ) ) { |
|
818 | - $object_vars = get_object_vars( $var ); |
|
819 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
820 | - $var->$property_name = wpinv_clean( $property_value ); |
|
817 | + if (is_object($var)) { |
|
818 | + $object_vars = get_object_vars($var); |
|
819 | + foreach ($object_vars as $property_name => $property_value) { |
|
820 | + $var->$property_name = wpinv_clean($property_value); |
|
821 | 821 | } |
822 | 822 | return $var; |
823 | 823 | } |
824 | 824 | |
825 | - return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var; |
|
825 | + return is_string($var) ? sanitize_text_field(stripslashes($var)) : $var; |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -831,43 +831,43 @@ discard block |
||
831 | 831 | * @param string $str Data to convert. |
832 | 832 | * @return string|array |
833 | 833 | */ |
834 | -function getpaid_convert_price_string_to_options( $str ) { |
|
834 | +function getpaid_convert_price_string_to_options($str) { |
|
835 | 835 | |
836 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
837 | - $options = array(); |
|
836 | + $raw_options = array_map('trim', explode(',', $str)); |
|
837 | + $options = array(); |
|
838 | 838 | |
839 | - foreach ( $raw_options as $option ) { |
|
839 | + foreach ($raw_options as $option) { |
|
840 | 840 | |
841 | - if ( '' == $option ) { |
|
841 | + if ('' == $option) { |
|
842 | 842 | continue; |
843 | 843 | } |
844 | 844 | |
845 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
845 | + $option = array_map('trim', explode('|', $option)); |
|
846 | 846 | |
847 | 847 | $price = null; |
848 | 848 | $label = null; |
849 | 849 | |
850 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
851 | - $label = $option[0]; |
|
850 | + if (isset($option[0]) && '' != $option[0]) { |
|
851 | + $label = $option[0]; |
|
852 | 852 | } |
853 | 853 | |
854 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
854 | + if (isset($option[1]) && '' != $option[1]) { |
|
855 | 855 | $price = $option[1]; |
856 | 856 | } |
857 | 857 | |
858 | - if ( ! isset( $price ) ) { |
|
858 | + if (!isset($price)) { |
|
859 | 859 | $price = $label; |
860 | 860 | } |
861 | 861 | |
862 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
862 | + if (!isset($price) || !is_numeric($price)) { |
|
863 | 863 | continue; |
864 | 864 | } |
865 | 865 | |
866 | - if ( ! isset( $label ) ) { |
|
866 | + if (!isset($label)) { |
|
867 | 867 | $label = $price; |
868 | 868 | } |
869 | 869 | |
870 | - $options[ "$label|$price" ] = $label; |
|
870 | + $options["$label|$price"] = $label; |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | return $options; |
@@ -876,27 +876,27 @@ discard block |
||
876 | 876 | /** |
877 | 877 | * Returns the help tip. |
878 | 878 | */ |
879 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
880 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
881 | - $tip = esc_attr__( $tip ); |
|
879 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
880 | + $additional_classes = sanitize_html_class($additional_classes); |
|
881 | + $tip = esc_attr__($tip); |
|
882 | 882 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
883 | 883 | } |
884 | 884 | |
885 | 885 | /** |
886 | 886 | * Formats a date |
887 | 887 | */ |
888 | -function getpaid_format_date( $date, $with_time = false ) { |
|
888 | +function getpaid_format_date($date, $with_time = false) { |
|
889 | 889 | |
890 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
890 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
891 | 891 | return ''; |
892 | 892 | } |
893 | 893 | |
894 | 894 | $format = getpaid_date_format(); |
895 | 895 | |
896 | - if ( $with_time ) { |
|
896 | + if ($with_time) { |
|
897 | 897 | $format .= ' ' . getpaid_time_format(); |
898 | 898 | } |
899 | - return date_i18n( $format, strtotime( $date ) ); |
|
899 | + return date_i18n($format, strtotime($date)); |
|
900 | 900 | |
901 | 901 | } |
902 | 902 | |
@@ -905,9 +905,9 @@ discard block |
||
905 | 905 | * |
906 | 906 | * @return string |
907 | 907 | */ |
908 | -function getpaid_format_date_value( $date, $default = "—", $with_time = false ) { |
|
909 | - $date = getpaid_format_date( $date, $with_time ); |
|
910 | - return empty( $date ) ? $default : $date; |
|
908 | +function getpaid_format_date_value($date, $default = "—", $with_time = false) { |
|
909 | + $date = getpaid_format_date($date, $with_time); |
|
910 | + return empty($date) ? $default : $date; |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | /** |
@@ -916,7 +916,7 @@ discard block |
||
916 | 916 | * @return string |
917 | 917 | */ |
918 | 918 | function getpaid_date_format() { |
919 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
919 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
920 | 920 | } |
921 | 921 | |
922 | 922 | /** |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | * @return string |
926 | 926 | */ |
927 | 927 | function getpaid_time_format() { |
928 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
928 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -935,16 +935,16 @@ discard block |
||
935 | 935 | * @param integer $limit Limit size in characters. |
936 | 936 | * @return string |
937 | 937 | */ |
938 | -function getpaid_limit_length( $string, $limit ) { |
|
938 | +function getpaid_limit_length($string, $limit) { |
|
939 | 939 | $str_limit = $limit - 3; |
940 | 940 | |
941 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
942 | - if ( mb_strlen( $string ) > $limit ) { |
|
943 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
941 | + if (function_exists('mb_strimwidth')) { |
|
942 | + if (mb_strlen($string) > $limit) { |
|
943 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
944 | 944 | } |
945 | 945 | } else { |
946 | - if ( strlen( $string ) > $limit ) { |
|
947 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
946 | + if (strlen($string) > $limit) { |
|
947 | + $string = substr($string, 0, $str_limit) . '...'; |
|
948 | 948 | } |
949 | 949 | } |
950 | 950 | return $string; |
@@ -958,7 +958,7 @@ discard block |
||
958 | 958 | * @since 1.0.19 |
959 | 959 | */ |
960 | 960 | function getpaid_api() { |
961 | - return getpaid()->get( 'api' ); |
|
961 | + return getpaid()->get('api'); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -968,7 +968,7 @@ discard block |
||
968 | 968 | * @since 1.0.19 |
969 | 969 | */ |
970 | 970 | function getpaid_post_types() { |
971 | - return getpaid()->get( 'post_types' ); |
|
971 | + return getpaid()->get('post_types'); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
@@ -978,7 +978,7 @@ discard block |
||
978 | 978 | * @since 1.0.19 |
979 | 979 | */ |
980 | 980 | function getpaid_session() { |
981 | - return getpaid()->get( 'session' ); |
|
981 | + return getpaid()->get('session'); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
@@ -988,7 +988,7 @@ discard block |
||
988 | 988 | * @since 1.0.19 |
989 | 989 | */ |
990 | 990 | function getpaid_notes() { |
991 | - return getpaid()->get( 'notes' ); |
|
991 | + return getpaid()->get('notes'); |
|
992 | 992 | } |
993 | 993 | |
994 | 994 | /** |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | * @return GetPaid_Admin |
998 | 998 | */ |
999 | 999 | function getpaid_admin() { |
1000 | - return getpaid()->get( 'admin' ); |
|
1000 | + return getpaid()->get('admin'); |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | /** |
@@ -1007,8 +1007,8 @@ discard block |
||
1007 | 1007 | * @param string $base the base url |
1008 | 1008 | * @return string |
1009 | 1009 | */ |
1010 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
1011 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
1010 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
1011 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
1012 | 1012 | } |
1013 | 1013 | |
1014 | 1014 | /** |
@@ -1016,11 +1016,11 @@ discard block |
||
1016 | 1016 | * |
1017 | 1017 | * @return string |
1018 | 1018 | */ |
1019 | -function getpaid_get_post_type_label( $post_type, $plural = true ) { |
|
1019 | +function getpaid_get_post_type_label($post_type, $plural = true) { |
|
1020 | 1020 | |
1021 | - $post_type = get_post_type_object( $post_type ); |
|
1021 | + $post_type = get_post_type_object($post_type); |
|
1022 | 1022 | |
1023 | - if ( ! is_object( $post_type ) ) { |
|
1023 | + if (!is_object($post_type)) { |
|
1024 | 1024 | return null; |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1033,18 +1033,18 @@ discard block |
||
1033 | 1033 | * |
1034 | 1034 | * @return mixed|null |
1035 | 1035 | */ |
1036 | -function getpaid_get_array_field( $array, $key, $secondary_key = null ) { |
|
1036 | +function getpaid_get_array_field($array, $key, $secondary_key = null) { |
|
1037 | 1037 | |
1038 | - if ( ! is_array( $array ) ) { |
|
1038 | + if (!is_array($array)) { |
|
1039 | 1039 | return null; |
1040 | 1040 | } |
1041 | 1041 | |
1042 | - if ( ! empty( $secondary_key ) ) { |
|
1043 | - $array = isset( $array[ $secondary_key ] ) ? $array[ $secondary_key ] : array(); |
|
1044 | - return getpaid_get_array_field( $array, $key ); |
|
1042 | + if (!empty($secondary_key)) { |
|
1043 | + $array = isset($array[$secondary_key]) ? $array[$secondary_key] : array(); |
|
1044 | + return getpaid_get_array_field($array, $key); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | - return isset( $array[ $key ] ) ? $array[ $key ] : null; |
|
1047 | + return isset($array[$key]) ? $array[$key] : null; |
|
1048 | 1048 | |
1049 | 1049 | } |
1050 | 1050 | |
@@ -1053,12 +1053,12 @@ discard block |
||
1053 | 1053 | * |
1054 | 1054 | * @return array |
1055 | 1055 | */ |
1056 | -function getpaid_array_merge_if_empty( $args, $defaults ) { |
|
1056 | +function getpaid_array_merge_if_empty($args, $defaults) { |
|
1057 | 1057 | |
1058 | - foreach ( $defaults as $key => $value ) { |
|
1058 | + foreach ($defaults as $key => $value) { |
|
1059 | 1059 | |
1060 | - if ( array_key_exists( $key, $args ) && empty( $args[ $key ] ) ) { |
|
1061 | - $args[ $key ] = $value; |
|
1060 | + if (array_key_exists($key, $args) && empty($args[$key])) { |
|
1061 | + $args[$key] = $value; |
|
1062 | 1062 | } |
1063 | 1063 | |
1064 | 1064 | } |
@@ -1076,12 +1076,12 @@ discard block |
||
1076 | 1076 | |
1077 | 1077 | $types = get_allowed_mime_types(); |
1078 | 1078 | |
1079 | - if ( isset( $types['htm|html'] ) ) { |
|
1080 | - unset( $types['htm|html'] ); |
|
1079 | + if (isset($types['htm|html'])) { |
|
1080 | + unset($types['htm|html']); |
|
1081 | 1081 | } |
1082 | 1082 | |
1083 | - if ( isset( $types['js'] ) ) { |
|
1084 | - unset( $types['js'] ); |
|
1083 | + if (isset($types['js'])) { |
|
1084 | + unset($types['js']); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | return $types; |
@@ -1089,34 +1089,34 @@ discard block |
||
1089 | 1089 | } |
1090 | 1090 | |
1091 | 1091 | |
1092 | -function getpaid_user_delete_invoice( $data ) { |
|
1092 | +function getpaid_user_delete_invoice($data) { |
|
1093 | 1093 | |
1094 | 1094 | // Ensure there is an invoice to delete. |
1095 | - if ( empty( $data['invoice_id'] ) ) { |
|
1095 | + if (empty($data['invoice_id'])) { |
|
1096 | 1096 | return; |
1097 | 1097 | } |
1098 | 1098 | |
1099 | - $invoice = new WPInv_Invoice( (int) $data['invoice_id'] ); |
|
1099 | + $invoice = new WPInv_Invoice((int) $data['invoice_id']); |
|
1100 | 1100 | |
1101 | 1101 | // Ensure that it exists and that it belongs to the current user. |
1102 | - if ( ! $invoice->exists() || $invoice->get_customer_id() != get_current_user_id() ) { |
|
1103 | - wpinv_set_error( 'invalid_invoice', __( 'You do not have permission to delete this invoice', 'invoicing' ) ); |
|
1102 | + if (!$invoice->exists() || $invoice->get_customer_id() != get_current_user_id()) { |
|
1103 | + wpinv_set_error('invalid_invoice', __('You do not have permission to delete this invoice', 'invoicing')); |
|
1104 | 1104 | |
1105 | 1105 | // Can it be deleted? |
1106 | - } else if ( ! $invoice->needs_payment() ) { |
|
1107 | - wpinv_set_error( 'cannot_delete', __( 'This invoice cannot be deleted as it has already been paid.', 'invoicing' ) ); |
|
1106 | + } else if (!$invoice->needs_payment()) { |
|
1107 | + wpinv_set_error('cannot_delete', __('This invoice cannot be deleted as it has already been paid.', 'invoicing')); |
|
1108 | 1108 | |
1109 | 1109 | // Delete it. |
1110 | 1110 | } else { |
1111 | 1111 | |
1112 | 1112 | $invoice->delete(); |
1113 | - wpinv_set_error( 'delete', __( 'The invoice has been deleted.', 'invoicing' ), 'info' ); |
|
1113 | + wpinv_set_error('delete', __('The invoice has been deleted.', 'invoicing'), 'info'); |
|
1114 | 1114 | } |
1115 | 1115 | |
1116 | - $redirect = remove_query_arg( array( 'getpaid-action', 'getpaid-nonce', 'invoice_id' ) ); |
|
1116 | + $redirect = remove_query_arg(array('getpaid-action', 'getpaid-nonce', 'invoice_id')); |
|
1117 | 1117 | |
1118 | - wp_safe_redirect( $redirect ); |
|
1118 | + wp_safe_redirect($redirect); |
|
1119 | 1119 | exit; |
1120 | 1120 | |
1121 | 1121 | } |
1122 | -add_action( 'getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice' ); |
|
1123 | 1122 | \ No newline at end of file |
1123 | +add_action('getpaid_authenticated_action_delete_invoice', 'getpaid_user_delete_invoice'); |
|
1124 | 1124 | \ No newline at end of file |