@@ -7,33 +7,33 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Alert Text', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Alert Text', 'invoicing'); ?></span> |
|
17 | 17 | <textarea v-model='active_form_element.text' class='form-control' rows='3'></textarea> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group form-check'> |
22 | 22 | <input :id="active_form_element.id + '_edit_dismissible'" v-model='active_form_element.dismissible' type='checkbox' class='form-check-input' /> |
23 | - <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e( 'Is Dismissible?', 'invoicing' ); ?></label> |
|
23 | + <label class='form-check-label' :for="active_form_element.id + '_edit_dismissible'"><?php esc_html_e('Is Dismissible?', 'invoicing'); ?></label> |
|
24 | 24 | </div> |
25 | 25 | |
26 | 26 | <div class='form-group'> |
27 | - <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Alert Type', 'invoicing' ) ?></label> |
|
27 | + <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Alert Type', 'invoicing') ?></label> |
|
28 | 28 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'> |
29 | - <option value='alert-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option> |
|
30 | - <option value='alert-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option> |
|
31 | - <option value='alert-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option> |
|
32 | - <option value='alert-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option> |
|
33 | - <option value='alert-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option> |
|
34 | - <option value='alert-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option> |
|
35 | - <option value='alert-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option> |
|
36 | - <option value='alert-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option> |
|
37 | - <option value='alert-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option> |
|
29 | + <option value='alert-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option> |
|
30 | + <option value='alert-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option> |
|
31 | + <option value='alert-success'><?php esc_html_e('Success', 'invoicing'); ?></option> |
|
32 | + <option value='alert-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option> |
|
33 | + <option value='alert-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option> |
|
34 | + <option value='alert-info'><?php esc_html_e('Info', 'invoicing'); ?></option> |
|
35 | + <option value='alert-light'><?php esc_html_e('Light', 'invoicing'); ?></option> |
|
36 | + <option value='alert-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option> |
|
37 | + <option value='alert-link'><?php esc_html_e('Link', 'invoicing'); ?></option> |
|
38 | 38 | </select> |
39 | 39 | </div> |
@@ -7,30 +7,30 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Set the currency position. |
13 | 13 | $position = wpinv_currency_position(); |
14 | 14 | |
15 | -if ( $position == 'left_space' ) { |
|
15 | +if ($position == 'left_space') { |
|
16 | 16 | $position = 'left'; |
17 | 17 | } |
18 | 18 | |
19 | -if ( $position == 'right_space' ) { |
|
19 | +if ($position == 'right_space') { |
|
20 | 20 | $position = 'right'; |
21 | 21 | } |
22 | 22 | |
23 | 23 | echo aui()->input( |
24 | 24 | array( |
25 | - 'name' => esc_attr( $id ), |
|
26 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
27 | - 'placeholder' => empty( $placeholder ) ? wpinv_format_amount(0) : wpinv_format_amount( $placeholder ), |
|
28 | - 'value' => empty( $value ) ? wpinv_format_amount(0) : wpinv_format_amount( $value ), |
|
29 | - 'label' => empty( $label ) ? '' : wp_kses_post( $label ), |
|
25 | + 'name' => esc_attr($id), |
|
26 | + 'id' => esc_attr($id) . uniqid('_'), |
|
27 | + 'placeholder' => empty($placeholder) ? wpinv_format_amount(0) : wpinv_format_amount($placeholder), |
|
28 | + 'value' => empty($value) ? wpinv_format_amount(0) : wpinv_format_amount($value), |
|
29 | + 'label' => empty($label) ? '' : wp_kses_post($label), |
|
30 | 30 | 'label_type' => 'vertical', |
31 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
32 | - 'input_group_right' => $position == 'right' ? wpinv_currency_symbol( $form->get_currency() ) : '', |
|
33 | - 'input_group_left' => $position == 'left' ? wpinv_currency_symbol( $form->get_currency() ) : '', |
|
31 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
32 | + 'input_group_right' => $position == 'right' ? wpinv_currency_symbol($form->get_currency()) : '', |
|
33 | + 'input_group_left' => $position == 'left' ? wpinv_currency_symbol($form->get_currency()) : '', |
|
34 | 34 | 'class' => 'getpaid-refresh-on-change', |
35 | 35 | ) |
36 | 36 | ); |
@@ -7,32 +7,32 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Ensure that we have options. |
13 | -if ( empty( $options ) ) { |
|
13 | +if (empty($options)) { |
|
14 | 14 | return; |
15 | 15 | } |
16 | 16 | |
17 | 17 | // Prepare price options. |
18 | -$options = getpaid_convert_price_string_to_options( $options ); |
|
18 | +$options = getpaid_convert_price_string_to_options($options); |
|
19 | 19 | |
20 | 20 | // Prepare id. |
21 | -$id = esc_attr( $id ); |
|
21 | +$id = esc_attr($id); |
|
22 | 22 | |
23 | -$select_type = empty( $select_type ) ? 'select' : $select_type; |
|
23 | +$select_type = empty($select_type) ? 'select' : $select_type; |
|
24 | 24 | |
25 | 25 | // Item select; |
26 | -if ( $select_type == 'select' ) { |
|
26 | +if ($select_type == 'select') { |
|
27 | 27 | echo aui()->select( |
28 | 28 | array( |
29 | 29 | 'name' => $id, |
30 | - 'id' => $id . uniqid( '_' ), |
|
31 | - 'placeholder'=> empty( $placeholder ) ? '' : esc_attr( $placeholder ), |
|
32 | - 'label' => empty( $label ) ? '' : sanitize_text_field( $label ), |
|
30 | + 'id' => $id . uniqid('_'), |
|
31 | + 'placeholder'=> empty($placeholder) ? '' : esc_attr($placeholder), |
|
32 | + 'label' => empty($label) ? '' : sanitize_text_field($label), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'class' => 'getpaid-price-select-dropdown getpaid-refresh-on-change', |
35 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
35 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
36 | 36 | 'options' => $options, |
37 | 37 | ) |
38 | 38 | ); |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item radios; |
43 | -if ( $select_type == 'radios' ) { |
|
43 | +if ($select_type == 'radios') { |
|
44 | 44 | echo aui()->radio( |
45 | 45 | array( |
46 | - 'name' => esc_attr( $id ), |
|
47 | - 'id' => esc_attr( $id ) . uniqid( '_' ), |
|
48 | - 'label' => empty( $label ) ? '' : sanitize_text_field( $label ), |
|
46 | + 'name' => esc_attr($id), |
|
47 | + 'id' => esc_attr($id) . uniqid('_'), |
|
48 | + 'label' => empty($label) ? '' : sanitize_text_field($label), |
|
49 | 49 | 'label_type' => 'vertical', |
50 | 50 | 'class' => 'getpaid-price-select-radio getpaid-refresh-on-change', |
51 | 51 | 'inline' => false, |
52 | 52 | 'options' => $options, |
53 | - 'help_text' => empty( $description ) ? '' : wp_kses_post( $description ), |
|
53 | + 'help_text' => empty($description) ? '' : wp_kses_post($description), |
|
54 | 54 | ) |
55 | 55 | ); |
56 | 56 | return; |
@@ -58,32 +58,32 @@ discard block |
||
58 | 58 | |
59 | 59 | |
60 | 60 | // Display the label. |
61 | -if ( ! empty( $label ) && $select_type != 'select' ) { |
|
62 | - $label = sanitize_text_field( $label ); |
|
61 | +if (!empty($label) && $select_type != 'select') { |
|
62 | + $label = sanitize_text_field($label); |
|
63 | 63 | echo "<label>$label</label>"; |
64 | 64 | } |
65 | 65 | |
66 | 66 | // Item buttons; |
67 | -if ( $select_type == 'buttons' || $select_type == 'circles' ) { |
|
67 | +if ($select_type == 'buttons' || $select_type == 'circles') { |
|
68 | 68 | |
69 | 69 | $class = 'getpaid-price-buttons'; |
70 | 70 | |
71 | - if ( $select_type == 'circles' ) { |
|
71 | + if ($select_type == 'circles') { |
|
72 | 72 | $class .= ' getpaid-price-circles'; |
73 | 73 | } |
74 | 74 | echo "<div class='$class'>"; |
75 | 75 | |
76 | 76 | $processed = 0; |
77 | - foreach ( $options as $price => $label ) { |
|
78 | - $label = sanitize_text_field( $label ); |
|
79 | - $price = esc_attr( $price ); |
|
80 | - $_id = $id . uniqid( '_' ); |
|
81 | - $checked = checked( $processed, 0, false ); |
|
82 | - $processed ++; |
|
77 | + foreach ($options as $price => $label) { |
|
78 | + $label = sanitize_text_field($label); |
|
79 | + $price = esc_attr($price); |
|
80 | + $_id = $id . uniqid('_'); |
|
81 | + $checked = checked($processed, 0, false); |
|
82 | + $processed++; |
|
83 | 83 | |
84 | 84 | $class = 'rounded'; |
85 | 85 | |
86 | - if ( $select_type == 'circles' ) { |
|
86 | + if ($select_type == 'circles') { |
|
87 | 87 | $class = ''; |
88 | 88 | } |
89 | 89 | echo " |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | } |
100 | 100 | |
101 | 101 | // Item checkboxes; |
102 | -if ( $select_type == 'checkboxes' ) { |
|
102 | +if ($select_type == 'checkboxes') { |
|
103 | 103 | echo '<div class="form-group">'; |
104 | 104 | |
105 | 105 | $processed = 0; |
106 | - foreach ( $options as $price => $label ) { |
|
107 | - $label = sanitize_text_field( $label ); |
|
108 | - $price = esc_attr( $price ); |
|
109 | - $checked = checked( $processed, 0, false ); |
|
110 | - $processed ++; |
|
106 | + foreach ($options as $price => $label) { |
|
107 | + $label = sanitize_text_field($label); |
|
108 | + $price = esc_attr($price); |
|
109 | + $checked = checked($processed, 0, false); |
|
110 | + $processed++; |
|
111 | 111 | echo " |
112 | 112 | <label class='d-block'> |
113 | 113 | <input type='checkbox' class='getpaid-price-select-checkbox getpaid-refresh-on-change' name='{$id}[]' value='$price' $checked /> |
@@ -120,6 +120,6 @@ discard block |
||
120 | 120 | |
121 | 121 | } |
122 | 122 | |
123 | -if ( ! empty( $description ) ) { |
|
123 | +if (!empty($description)) { |
|
124 | 124 | echo "<small class='form-text text-muted'>$description</small>"; |
125 | 125 | } |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | * Displays a list of all subscriptions rules |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
6 | +if (!defined('ABSPATH')) exit; |
|
7 | 7 | |
8 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
8 | +if (!class_exists('WP_List_Table')) { |
|
9 | 9 | include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
10 | 10 | } |
11 | 11 | |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | |
79 | 79 | $this->prepare_query(); |
80 | 80 | |
81 | - $this->base_url = remove_query_arg( 'status' ); |
|
81 | + $this->base_url = remove_query_arg('status'); |
|
82 | 82 | |
83 | 83 | } |
84 | 84 | |
@@ -91,21 +91,21 @@ discard block |
||
91 | 91 | $query = array( |
92 | 92 | 'number' => $this->per_page, |
93 | 93 | 'paged' => $this->get_paged(), |
94 | - 'status' => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all', |
|
95 | - 'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id', |
|
96 | - 'order' => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC', |
|
94 | + 'status' => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all', |
|
95 | + 'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id', |
|
96 | + 'order' => (isset($_GET['order'])) ? $_GET['order'] : 'DESC', |
|
97 | 97 | ); |
98 | 98 | |
99 | 99 | // Prepare class properties. |
100 | - $this->query = new GetPaid_Subscriptions_Query( $query ); |
|
100 | + $this->query = new GetPaid_Subscriptions_Query($query); |
|
101 | 101 | $this->total_count = $this->query->get_total(); |
102 | 102 | $this->current_total_count = $this->query->get_total(); |
103 | 103 | $this->items = $this->query->get_results(); |
104 | - $this->status_counts = getpaid_get_subscription_status_counts( $query ); |
|
104 | + $this->status_counts = getpaid_get_subscription_status_counts($query); |
|
105 | 105 | |
106 | - if ( 'all' != $query['status'] ) { |
|
107 | - unset( $query['status'] ); |
|
108 | - $this->total_count = getpaid_get_subscriptions( $query, 'count' ); |
|
106 | + if ('all' != $query['status']) { |
|
107 | + unset($query['status']); |
|
108 | + $this->total_count = getpaid_get_subscriptions($query, 'count'); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | } |
@@ -122,26 +122,26 @@ discard block |
||
122 | 122 | */ |
123 | 123 | public function get_views() { |
124 | 124 | |
125 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : 'all'; |
|
125 | + $current = isset($_GET['status']) ? $_GET['status'] : 'all'; |
|
126 | 126 | $views = array( |
127 | 127 | |
128 | 128 | 'all' => sprintf( |
129 | 129 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
130 | - esc_url( add_query_arg( 'status', false, $this->base_url ) ), |
|
130 | + esc_url(add_query_arg('status', false, $this->base_url)), |
|
131 | 131 | $current === 'all' ? ' class="current"' : '', |
132 | - __('All','invoicing' ), |
|
132 | + __('All', 'invoicing'), |
|
133 | 133 | $this->total_count |
134 | 134 | ) |
135 | 135 | |
136 | 136 | ); |
137 | 137 | |
138 | - foreach ( array_filter( $this->status_counts ) as $status => $count ) { |
|
138 | + foreach (array_filter($this->status_counts) as $status => $count) { |
|
139 | 139 | |
140 | - $views[ $status ] = sprintf( |
|
140 | + $views[$status] = sprintf( |
|
141 | 141 | '<a href="%s" %s>%s <span class="count">(%d)</span></a>', |
142 | - esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ), |
|
142 | + esc_url(add_query_arg('status', urlencode($status), $this->base_url)), |
|
143 | 143 | $current === $status ? ' class="current"' : '', |
144 | - sanitize_text_field( getpaid_get_subscription_status_label( $status ) ), |
|
144 | + sanitize_text_field(getpaid_get_subscription_status_label($status)), |
|
145 | 145 | $count |
146 | 146 | ); |
147 | 147 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function column_default( $item, $column_name ) { |
|
162 | - return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name ); |
|
161 | + public function column_default($item, $column_name) { |
|
162 | + return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -168,8 +168,8 @@ discard block |
||
168 | 168 | * @param WPInv_Subscription $item |
169 | 169 | * @return string |
170 | 170 | */ |
171 | - public function column_cb( $item ) { |
|
172 | - return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) ); |
|
171 | + public function column_cb($item) { |
|
172 | + return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id())); |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @since 1.0.0 |
180 | 180 | * @return string |
181 | 181 | */ |
182 | - public function column_status( $item ) { |
|
182 | + public function column_status($item) { |
|
183 | 183 | return $item->get_status_label_html(); |
184 | 184 | } |
185 | 185 | |
@@ -190,46 +190,46 @@ discard block |
||
190 | 190 | * @since 1.0.0 |
191 | 191 | * @return string |
192 | 192 | */ |
193 | - public function column_subscription( $item ) { |
|
193 | + public function column_subscription($item) { |
|
194 | 194 | |
195 | - $username = __( '(Missing User)', 'invoicing' ); |
|
195 | + $username = __('(Missing User)', 'invoicing'); |
|
196 | 196 | |
197 | - $user = get_userdata( $item->get_customer_id() ); |
|
198 | - if ( $user ) { |
|
197 | + $user = get_userdata($item->get_customer_id()); |
|
198 | + if ($user) { |
|
199 | 199 | |
200 | 200 | $username = sprintf( |
201 | 201 | '<a href="user-edit.php?user_id=%s">%s</a>', |
202 | - absint( $user->ID ), |
|
203 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
202 | + absint($user->ID), |
|
203 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
204 | 204 | ); |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | 208 | // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name |
209 | 209 | $column_content = sprintf( |
210 | - _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ), |
|
211 | - '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">', |
|
212 | - '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>', |
|
210 | + _x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'), |
|
211 | + '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">', |
|
212 | + '<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>', |
|
213 | 213 | $username |
214 | 214 | ); |
215 | 215 | |
216 | 216 | $row_actions = array(); |
217 | 217 | |
218 | 218 | // View subscription. |
219 | - $view_url = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) )); |
|
220 | - $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>'; |
|
219 | + $view_url = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions'))); |
|
220 | + $row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>'; |
|
221 | 221 | |
222 | 222 | // View invoice. |
223 | - $invoice = get_post( $item->get_parent_invoice_id() ); |
|
223 | + $invoice = get_post($item->get_parent_invoice_id()); |
|
224 | 224 | |
225 | - if ( ! empty( $invoice ) ) { |
|
226 | - $view_url = get_edit_post_link( $invoice ); |
|
227 | - $row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>'; |
|
225 | + if (!empty($invoice)) { |
|
226 | + $view_url = get_edit_post_link($invoice); |
|
227 | + $row_actions['invoice'] = '<a href="' . $view_url . '">' . __('View Invoice', 'invoicing') . '</a>'; |
|
228 | 228 | } |
229 | 229 | |
230 | - $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) ); |
|
230 | + $row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item)); |
|
231 | 231 | |
232 | - return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions; |
|
232 | + return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | /** |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | * @since 1.0.0 |
240 | 240 | * @return string |
241 | 241 | */ |
242 | - public function column_renewal_date( $item ) { |
|
243 | - return getpaid_format_date_value( $item->get_expiration() ); |
|
242 | + public function column_renewal_date($item) { |
|
243 | + return getpaid_format_date_value($item->get_expiration()); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | /** |
@@ -250,8 +250,8 @@ discard block |
||
250 | 250 | * @since 1.0.0 |
251 | 251 | * @return string |
252 | 252 | */ |
253 | - public function column_start_date( $item ) { |
|
254 | - return getpaid_format_date_value( $item->get_date_created() ); |
|
253 | + public function column_start_date($item) { |
|
254 | + return getpaid_format_date_value($item->get_date_created()); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @since 1.0.19 |
262 | 262 | * @return string |
263 | 263 | */ |
264 | - public function column_amount( $item ) { |
|
265 | - $amount = getpaid_get_formatted_subscription_amount( $item ); |
|
264 | + public function column_amount($item) { |
|
265 | + $amount = getpaid_get_formatted_subscription_amount($item); |
|
266 | 266 | return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>"; |
267 | 267 | } |
268 | 268 | |
@@ -273,9 +273,9 @@ discard block |
||
273 | 273 | * @since 1.0.0 |
274 | 274 | * @return string |
275 | 275 | */ |
276 | - public function column_renewals( $item ) { |
|
276 | + public function column_renewals($item) { |
|
277 | 277 | $max_bills = $item->get_bill_times(); |
278 | - return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
278 | + return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | /** |
@@ -285,16 +285,16 @@ discard block |
||
285 | 285 | * @since 1.0.0 |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function column_item( $item ) { |
|
289 | - $_item = get_post( $item->get_product_id() ); |
|
288 | + public function column_item($item) { |
|
289 | + $_item = get_post($item->get_product_id()); |
|
290 | 290 | |
291 | - if ( ! empty( $_item ) ) { |
|
292 | - $link = get_edit_post_link( $_item ); |
|
293 | - $link = esc_url( $link ); |
|
294 | - $name = esc_html( get_the_title( $_item ) ); |
|
291 | + if (!empty($_item)) { |
|
292 | + $link = get_edit_post_link($_item); |
|
293 | + $link = esc_url($link); |
|
294 | + $name = esc_html(get_the_title($_item)); |
|
295 | 295 | return "<a href='$link'>$name</a>"; |
296 | 296 | } else { |
297 | - return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() ); |
|
297 | + return sprintf(__('Item #%s', 'invoicing'), $item->get_product_id()); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | } |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | * @return int |
306 | 306 | */ |
307 | 307 | public function get_paged() { |
308 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
308 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
309 | 309 | } |
310 | 310 | |
311 | 311 | /** |
@@ -318,13 +318,13 @@ discard block |
||
318 | 318 | $hidden = array(); |
319 | 319 | $sortable = $this->get_sortable_columns(); |
320 | 320 | |
321 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
321 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
322 | 322 | |
323 | 323 | $this->set_pagination_args( |
324 | 324 | array( |
325 | 325 | 'total_items' => $this->current_total_count, |
326 | 326 | 'per_page' => $this->per_page, |
327 | - 'total_pages' => ceil( $this->current_total_count / $this->per_page ) |
|
327 | + 'total_pages' => ceil($this->current_total_count / $this->per_page) |
|
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | } |
@@ -334,18 +334,18 @@ discard block |
||
334 | 334 | * |
335 | 335 | * @return array |
336 | 336 | */ |
337 | - public function get_columns(){ |
|
337 | + public function get_columns() { |
|
338 | 338 | $columns = array( |
339 | 339 | 'cb' => '<input type="checkbox" />', |
340 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
341 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
342 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
343 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
344 | - 'item' => __( 'Item', 'invoicing' ), |
|
345 | - 'status' => __( 'Status', 'invoicing' ), |
|
340 | + 'subscription' => __('Subscription', 'invoicing'), |
|
341 | + 'start_date' => __('Start Date', 'invoicing'), |
|
342 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
343 | + 'renewals' => __('Payments', 'invoicing'), |
|
344 | + 'item' => __('Item', 'invoicing'), |
|
345 | + 'status' => __('Status', 'invoicing'), |
|
346 | 346 | ); |
347 | 347 | |
348 | - return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns ); |
|
348 | + return apply_filters('manage_getpaid_subscriptions_table_columns', $columns); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | /** |
@@ -355,15 +355,15 @@ discard block |
||
355 | 355 | */ |
356 | 356 | public function get_sortable_columns() { |
357 | 357 | $sortable = array( |
358 | - 'subscription' => array( 'id', true ), |
|
359 | - 'start_date' => array( 'created', true ), |
|
360 | - 'renewal_date' => array( 'expiration', true ), |
|
361 | - 'renewals' => array( 'bill_times', true ), |
|
362 | - 'item' => array( 'product_id', true ), |
|
363 | - 'status' => array( 'status', true ), |
|
358 | + 'subscription' => array('id', true), |
|
359 | + 'start_date' => array('created', true), |
|
360 | + 'renewal_date' => array('expiration', true), |
|
361 | + 'renewals' => array('bill_times', true), |
|
362 | + 'item' => array('product_id', true), |
|
363 | + 'status' => array('status', true), |
|
364 | 364 | ); |
365 | 365 | |
366 | - return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable ); |
|
366 | + return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | * @return bool |
373 | 373 | */ |
374 | 374 | public function has_items() { |
375 | - return ! empty( $this->current_total_count ); |
|
375 | + return !empty($this->current_total_count); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | /** |
@@ -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,68 +21,68 @@ 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 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | 28 | |
29 | 29 | // Invoice table columns. |
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
30 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
31 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
32 | 32 | |
33 | 33 | // Items table columns. |
34 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
34 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
35 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
36 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
37 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
38 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
39 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
40 | 40 | |
41 | 41 | // Payment forms columns. |
42 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
42 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
43 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
44 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
45 | 45 | |
46 | 46 | // Discount table columns. |
47 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
47 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
48 | 48 | |
49 | 49 | // Deleting posts. |
50 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
50 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
51 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Post updated messages. |
56 | 56 | */ |
57 | - public static function post_updated_messages( $messages ) { |
|
57 | + public static function post_updated_messages($messages) { |
|
58 | 58 | global $post; |
59 | 59 | |
60 | 60 | $messages['wpi_discount'] = array( |
61 | 61 | 0 => '', |
62 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
62 | + 1 => __('Discount updated.', 'invoicing'), |
|
63 | + 2 => __('Custom field updated.', 'invoicing'), |
|
64 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
65 | + 4 => __('Discount updated.', 'invoicing'), |
|
66 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
67 | + 6 => __('Discount updated.', 'invoicing'), |
|
68 | + 7 => __('Discount saved.', 'invoicing'), |
|
69 | + 8 => __('Discount submitted.', 'invoicing'), |
|
70 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
71 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | $messages['wpi_payment_form'] = array( |
75 | 75 | 0 => '', |
76 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
76 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
77 | + 2 => __('Custom field updated.', 'invoicing'), |
|
78 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
79 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
80 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
81 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
83 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
84 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
85 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | return $messages; |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Post row actions. |
94 | 94 | */ |
95 | - public static function post_row_actions( $actions, $post ) { |
|
95 | + public static function post_row_actions($actions, $post) { |
|
96 | 96 | |
97 | - $post = get_post( $post ); |
|
97 | + $post = get_post($post); |
|
98 | 98 | |
99 | 99 | // We do not want to edit the default payment form. |
100 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | - unset( $actions['trash'] ); |
|
102 | - unset( $actions['inline hide-if-no-js'] ); |
|
100 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
101 | + unset($actions['trash']); |
|
102 | + unset($actions['inline hide-if-no-js']); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $actions; |
@@ -108,51 +108,51 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Returns an array of invoice table columns. |
110 | 110 | */ |
111 | - public static function invoice_columns( $columns ) { |
|
111 | + public static function invoice_columns($columns) { |
|
112 | 112 | |
113 | 113 | $columns = array( |
114 | 114 | 'cb' => $columns['cb'], |
115 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | - 'status' => __( 'Status', 'invoicing' ), |
|
121 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
115 | + 'number' => __('Invoice', 'invoicing'), |
|
116 | + 'customer' => __('Customer', 'invoicing'), |
|
117 | + 'invoice_date' => __('Date', 'invoicing'), |
|
118 | + 'amount' => __('Amount', 'invoicing'), |
|
119 | + 'recurring' => __('Recurring', 'invoicing'), |
|
120 | + 'status' => __('Status', 'invoicing'), |
|
121 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
122 | 122 | ); |
123 | 123 | |
124 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
124 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Displays invoice table columns. |
129 | 129 | */ |
130 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
130 | + public static function display_invoice_columns($column_name, $post_id) { |
|
131 | 131 | |
132 | - $invoice = new WPInv_Invoice( $post_id ); |
|
132 | + $invoice = new WPInv_Invoice($post_id); |
|
133 | 133 | |
134 | - switch ( $column_name ) { |
|
134 | + switch ($column_name) { |
|
135 | 135 | |
136 | 136 | case 'invoice_date' : |
137 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | - $date = getpaid_format_date_value( $date_time ); |
|
137 | + $date_time = esc_attr($invoice->get_created_date()); |
|
138 | + $date = getpaid_format_date_value($date_time); |
|
139 | 139 | echo "<span title='$date_time'>$date</span>"; |
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'amount' : |
143 | 143 | |
144 | 144 | $amount = $invoice->get_total(); |
145 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
145 | + $formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency()); |
|
146 | 146 | |
147 | - if ( $invoice->is_refunded() ) { |
|
148 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
147 | + if ($invoice->is_refunded()) { |
|
148 | + $refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency()); |
|
149 | 149 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
150 | 150 | } else { |
151 | 151 | |
152 | 152 | $discount = $invoice->get_total_discount(); |
153 | 153 | |
154 | - if ( ! empty( $discount ) ) { |
|
155 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
154 | + if (!empty($discount)) { |
|
155 | + $new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency()); |
|
156 | 156 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
157 | 157 | } else { |
158 | 158 | echo $formated_amount; |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | break; |
164 | 164 | |
165 | 165 | case 'status' : |
166 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
166 | + $status = sanitize_text_field($invoice->get_status()); |
|
167 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
168 | 168 | |
169 | 169 | // If it is paid, show the gateway title. |
170 | - if ( $invoice->is_paid() ) { |
|
171 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
170 | + if ($invoice->is_paid()) { |
|
171 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
172 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
173 | 173 | |
174 | 174 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
175 | 175 | } else { |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | // If it is not paid, display the overdue and view status. |
180 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
180 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
181 | 181 | |
182 | 182 | // Invoice view status. |
183 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
183 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
184 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
185 | 185 | } else { |
186 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
186 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Display the overview status. |
190 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
190 | + if (wpinv_get_option('overdue_active')) { |
|
191 | 191 | $due_date = $invoice->get_due_date(); |
192 | - $fomatted = getpaid_format_date( $due_date ); |
|
192 | + $fomatted = getpaid_format_date($due_date); |
|
193 | 193 | |
194 | - if ( ! empty( $fomatted ) ) { |
|
195 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
194 | + if (!empty($fomatted)) { |
|
195 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
196 | 196 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
197 | 197 | } |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | case 'recurring': |
205 | 205 | |
206 | - if ( $invoice->is_recurring() ) { |
|
206 | + if ($invoice->is_recurring()) { |
|
207 | 207 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
208 | 208 | } else { |
209 | 209 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'number' : |
214 | 214 | |
215 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
215 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
216 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
217 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
218 | 218 | |
219 | 219 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
220 | 220 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | |
225 | 225 | $customer_name = $invoice->get_user_full_name(); |
226 | 226 | |
227 | - if ( empty( $customer_name ) ) { |
|
227 | + if (empty($customer_name)) { |
|
228 | 228 | $customer_name = $invoice->get_email(); |
229 | 229 | } |
230 | 230 | |
231 | - if ( ! empty( $customer_name ) ) { |
|
232 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
231 | + if (!empty($customer_name)) { |
|
232 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
233 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
234 | 234 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
235 | 235 | } else { |
236 | 236 | echo '<div>—</div>'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | |
241 | 241 | case 'wpi_actions' : |
242 | 242 | |
243 | - if ( $invoice->is_draft() ) { |
|
243 | + if ($invoice->is_draft()) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - $url = esc_url( $invoice->get_view_url() ); |
|
248 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
247 | + $url = esc_url($invoice->get_view_url()); |
|
248 | + $print = esc_attr__('Print invoice', 'invoicing'); |
|
249 | 249 | echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
250 | 250 | |
251 | 251 | $url = esc_url( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ) |
262 | 262 | ); |
263 | 263 | |
264 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
264 | + $send = esc_attr__('Send invoice to customer', 'invoicing'); |
|
265 | 265 | echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
266 | 266 | |
267 | 267 | break; |
@@ -272,50 +272,50 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * Returns an array of payment forms table columns. |
274 | 274 | */ |
275 | - public static function payment_form_columns( $columns ) { |
|
275 | + public static function payment_form_columns($columns) { |
|
276 | 276 | |
277 | 277 | $columns = array( |
278 | 278 | 'cb' => $columns['cb'], |
279 | - 'title' => __( 'Name', 'invoicing' ), |
|
280 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | - 'items' => __( 'Items', 'invoicing' ), |
|
284 | - 'date' => __( 'Date', 'invoicing' ), |
|
279 | + 'title' => __('Name', 'invoicing'), |
|
280 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
281 | + 'earnings' => __('Revenue', 'invoicing'), |
|
282 | + 'refunds' => __('Refunded', 'invoicing'), |
|
283 | + 'items' => __('Items', 'invoicing'), |
|
284 | + 'date' => __('Date', 'invoicing'), |
|
285 | 285 | ); |
286 | 286 | |
287 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
287 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Displays payment form table columns. |
293 | 293 | */ |
294 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
294 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
295 | 295 | |
296 | 296 | // Retrieve the payment form. |
297 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
297 | + $form = new GetPaid_Payment_Form($post_id); |
|
298 | 298 | |
299 | - switch ( $column_name ) { |
|
299 | + switch ($column_name) { |
|
300 | 300 | |
301 | 301 | case 'earnings' : |
302 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
302 | + echo wpinv_price(wpinv_format_amount($form->get_earned())); |
|
303 | 303 | break; |
304 | 304 | |
305 | 305 | case 'refunds' : |
306 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
306 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
307 | 307 | break; |
308 | 308 | |
309 | 309 | case 'refunds' : |
310 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
310 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
311 | 311 | break; |
312 | 312 | |
313 | 313 | case 'shortcode' : |
314 | 314 | |
315 | - if ( $form->is_default() ) { |
|
315 | + if ($form->is_default()) { |
|
316 | 316 | echo '—'; |
317 | 317 | } else { |
318 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
318 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | break; |
@@ -324,29 +324,29 @@ discard block |
||
324 | 324 | |
325 | 325 | $items = $form->get_items(); |
326 | 326 | |
327 | - if ( $form->is_default() || empty( $items ) ) { |
|
327 | + if ($form->is_default() || empty($items)) { |
|
328 | 328 | echo '—'; |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | $_items = array(); |
333 | 333 | |
334 | - foreach ( $items as $item ) { |
|
334 | + foreach ($items as $item) { |
|
335 | 335 | $url = $item->get_edit_url(); |
336 | 336 | |
337 | - if ( empty( $url ) ) { |
|
338 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
337 | + if (empty($url)) { |
|
338 | + $_items[] = sanitize_text_field($item->get_name()); |
|
339 | 339 | } else { |
340 | 340 | $_items[] = sprintf( |
341 | 341 | '<a href="%s">%s</a>', |
342 | - esc_url( $url ), |
|
343 | - sanitize_text_field( $item->get_name() ) |
|
342 | + esc_url($url), |
|
343 | + sanitize_text_field($item->get_name()) |
|
344 | 344 | ); |
345 | 345 | } |
346 | 346 | |
347 | 347 | } |
348 | 348 | |
349 | - echo implode( '<br>', $_items ); |
|
349 | + echo implode('<br>', $_items); |
|
350 | 350 | |
351 | 351 | break; |
352 | 352 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * Filters post states. |
359 | 359 | */ |
360 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
360 | + public static function filter_payment_form_state($post_states, $post) { |
|
361 | 361 | |
362 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
362 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
363 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $post_states; |
@@ -370,35 +370,35 @@ discard block |
||
370 | 370 | /** |
371 | 371 | * Returns an array of coupon table columns. |
372 | 372 | */ |
373 | - public static function discount_columns( $columns ) { |
|
373 | + public static function discount_columns($columns) { |
|
374 | 374 | |
375 | 375 | $columns = array( |
376 | 376 | 'cb' => $columns['cb'], |
377 | - 'title' => __( 'Name', 'invoicing' ), |
|
378 | - 'code' => __( 'Code', 'invoicing' ), |
|
379 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
377 | + 'title' => __('Name', 'invoicing'), |
|
378 | + 'code' => __('Code', 'invoicing'), |
|
379 | + 'amount' => __('Amount', 'invoicing'), |
|
380 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
381 | + 'start_date' => __('Start Date', 'invoicing'), |
|
382 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
383 | 383 | ); |
384 | 384 | |
385 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
385 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Filters post states. |
390 | 390 | */ |
391 | - public static function filter_discount_state( $post_states, $post ) { |
|
391 | + public static function filter_discount_state($post_states, $post) { |
|
392 | 392 | |
393 | - if ( 'wpi_discount' == $post->post_type ) { |
|
393 | + if ('wpi_discount' == $post->post_type) { |
|
394 | 394 | |
395 | - $discount = new WPInv_Discount( $post ); |
|
395 | + $discount = new WPInv_Discount($post); |
|
396 | 396 | |
397 | 397 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
398 | 398 | |
399 | - if ( $status != 'publish' ) { |
|
399 | + if ($status != 'publish') { |
|
400 | 400 | return array( |
401 | - 'discount_status' => wpinv_discount_status( $status ), |
|
401 | + 'discount_status' => wpinv_discount_status($status), |
|
402 | 402 | ); |
403 | 403 | } |
404 | 404 | |
@@ -413,34 +413,34 @@ discard block |
||
413 | 413 | /** |
414 | 414 | * Returns an array of items table columns. |
415 | 415 | */ |
416 | - public static function item_columns( $columns ) { |
|
416 | + public static function item_columns($columns) { |
|
417 | 417 | global $wpinv_euvat; |
418 | 418 | |
419 | 419 | $columns = array( |
420 | 420 | 'cb' => $columns['cb'], |
421 | - 'title' => __( 'Name', 'invoicing' ), |
|
422 | - 'price' => __( 'Price', 'invoicing' ), |
|
423 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | - 'type' => __( 'Type', 'invoicing' ), |
|
426 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
421 | + 'title' => __('Name', 'invoicing'), |
|
422 | + 'price' => __('Price', 'invoicing'), |
|
423 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
424 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
425 | + 'type' => __('Type', 'invoicing'), |
|
426 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
427 | 427 | ); |
428 | 428 | |
429 | - if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | - unset( $columns['vat_rule'] ); |
|
429 | + if (!$wpinv_euvat->allow_vat_rules()) { |
|
430 | + unset($columns['vat_rule']); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | - unset( $columns['vat_class'] ); |
|
433 | + if (!$wpinv_euvat->allow_vat_classes()) { |
|
434 | + unset($columns['vat_class']); |
|
435 | 435 | } |
436 | 436 | |
437 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
437 | + return apply_filters('wpi_item_table_columns', $columns); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
441 | 441 | * Returns an array of sortable items table columns. |
442 | 442 | */ |
443 | - public static function sortable_item_columns( $columns ) { |
|
443 | + public static function sortable_item_columns($columns) { |
|
444 | 444 | |
445 | 445 | return array_merge( |
446 | 446 | $columns, |
@@ -457,50 +457,50 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Displays items table columns. |
459 | 459 | */ |
460 | - public static function display_item_columns( $column_name, $post_id ) { |
|
460 | + public static function display_item_columns($column_name, $post_id) { |
|
461 | 461 | global $wpinv_euvat; |
462 | 462 | |
463 | - $item = new WPInv_Item( $post_id ); |
|
463 | + $item = new WPInv_Item($post_id); |
|
464 | 464 | |
465 | - switch ( $column_name ) { |
|
465 | + switch ($column_name) { |
|
466 | 466 | |
467 | 467 | case 'price' : |
468 | 468 | |
469 | - if ( ! $item->is_recurring() ) { |
|
469 | + if (!$item->is_recurring()) { |
|
470 | 470 | echo $item->get_the_price(); |
471 | 471 | break; |
472 | 472 | } |
473 | 473 | |
474 | 474 | $price = wp_sprintf( |
475 | - __( '%s / %s', 'invoicing' ), |
|
475 | + __('%s / %s', 'invoicing'), |
|
476 | 476 | $item->get_the_price(), |
477 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
477 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
478 | 478 | ); |
479 | 479 | |
480 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
480 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
481 | 481 | echo $price; |
482 | 482 | break; |
483 | 483 | } |
484 | 484 | |
485 | 485 | echo $item->get_the_initial_price(); |
486 | 486 | |
487 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
487 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
488 | 488 | break; |
489 | 489 | |
490 | 490 | case 'vat_rule' : |
491 | - echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
491 | + echo $wpinv_euvat->item_rule_label($item->get_id()); |
|
492 | 492 | break; |
493 | 493 | |
494 | 494 | case 'vat_class' : |
495 | - echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
495 | + echo $wpinv_euvat->item_class_label($item->get_id()); |
|
496 | 496 | break; |
497 | 497 | |
498 | 498 | case 'shortcode' : |
499 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
499 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | 500 | break; |
501 | 501 | |
502 | 502 | case 'type' : |
503 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
503 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | 504 | break; |
505 | 505 | |
506 | 506 | } |
@@ -510,22 +510,22 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * Lets users filter items using taxes. |
512 | 512 | */ |
513 | - public static function add_item_filters( $post_type ) { |
|
513 | + public static function add_item_filters($post_type) { |
|
514 | 514 | $wpinv_euvat = getpaid_tax(); |
515 | 515 | |
516 | 516 | // Abort if we're not dealing with items. |
517 | - if ( $post_type != 'wpi_item' ) { |
|
517 | + if ($post_type != 'wpi_item') { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | // Filter by vat rules. |
522 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
522 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
523 | 523 | |
524 | 524 | // Sanitize selected vat rule. |
525 | 525 | $vat_rule = ''; |
526 | 526 | $vat_rules = $wpinv_euvat->get_rules(); |
527 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | - $vat_rule = $_GET['vat_rule']; |
|
527 | + if (isset($_GET['vat_rule'])) { |
|
528 | + $vat_rule = $_GET['vat_rule']; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Filter by VAT rule. |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | array( |
534 | 534 | 'options' => array_merge( |
535 | 535 | array( |
536 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
536 | + '' => __('All VAT rules', 'invoicing') |
|
537 | 537 | ), |
538 | 538 | $vat_rules |
539 | 539 | ), |
540 | 540 | 'name' => 'vat_rule', |
541 | 541 | 'id' => 'vat_rule', |
542 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
542 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
543 | 543 | 'show_option_all' => false, |
544 | 544 | 'show_option_none' => false, |
545 | 545 | 'class' => 'gdmbx2-text-medium', |
@@ -550,26 +550,26 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // Filter by vat class. |
553 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
553 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
554 | 554 | |
555 | 555 | // Sanitize selected vat rule. |
556 | 556 | $vat_class = ''; |
557 | 557 | $vat_classes = $wpinv_euvat->get_all_classes(); |
558 | - if ( isset( $_GET['vat_class'] ) ) { |
|
559 | - $vat_class = $_GET['vat_class']; |
|
558 | + if (isset($_GET['vat_class'])) { |
|
559 | + $vat_class = $_GET['vat_class']; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | echo wpinv_html_select( |
563 | 563 | array( |
564 | 564 | 'options' => array_merge( |
565 | 565 | array( |
566 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
566 | + '' => __('All VAT classes', 'invoicing') |
|
567 | 567 | ), |
568 | 568 | $vat_classes |
569 | 569 | ), |
570 | 570 | 'name' => 'vat_class', |
571 | 571 | 'id' => 'vat_class', |
572 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
572 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
573 | 573 | 'show_option_all' => false, |
574 | 574 | 'show_option_none' => false, |
575 | 575 | 'class' => 'gdmbx2-text-medium', |
@@ -579,22 +579,22 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | // Filter by item type. |
582 | - $type = ''; |
|
583 | - if ( isset( $_GET['type'] ) ) { |
|
584 | - $type = $_GET['type']; |
|
582 | + $type = ''; |
|
583 | + if (isset($_GET['type'])) { |
|
584 | + $type = $_GET['type']; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | echo wpinv_html_select( |
588 | 588 | array( |
589 | 589 | 'options' => array_merge( |
590 | 590 | array( |
591 | - '' => __( 'All item types', 'invoicing' ) |
|
591 | + '' => __('All item types', 'invoicing') |
|
592 | 592 | ), |
593 | 593 | wpinv_get_item_types() |
594 | 594 | ), |
595 | 595 | 'name' => 'type', |
596 | 596 | 'id' => 'type', |
597 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
597 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
598 | 598 | 'show_option_all' => false, |
599 | 599 | 'show_option_none' => false, |
600 | 600 | 'class' => 'gdmbx2-text-medium', |
@@ -606,45 +606,45 @@ discard block |
||
606 | 606 | /** |
607 | 607 | * Filters the item query. |
608 | 608 | */ |
609 | - public static function filter_item_query( $query ) { |
|
609 | + public static function filter_item_query($query) { |
|
610 | 610 | |
611 | 611 | // modify the query only if it admin and main query. |
612 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
612 | + if (!(is_admin() && $query->is_main_query())) { |
|
613 | 613 | return $query; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // we want to modify the query for our items. |
617 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
617 | + if ('wpi_item' != $query->query['post_type']) { |
|
618 | 618 | return $query; |
619 | 619 | } |
620 | 620 | |
621 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
621 | + if (empty($query->query_vars['meta_query'])) { |
|
622 | 622 | $query->query_vars['meta_query'] = array(); |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Filter vat rule type |
626 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
626 | + if (!empty($_GET['vat_rule'])) { |
|
627 | 627 | $query->query_vars['meta_query'][] = array( |
628 | 628 | 'key' => '_wpinv_vat_rule', |
629 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
629 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
630 | 630 | 'compare' => '=' |
631 | 631 | ); |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Filter vat class |
635 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
635 | + if (!empty($_GET['vat_class'])) { |
|
636 | 636 | $query->query_vars['meta_query'][] = array( |
637 | 637 | 'key' => '_wpinv_vat_class', |
638 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
638 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
639 | 639 | 'compare' => '=' |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Filter item type |
644 | - if ( ! empty( $_GET['type'] ) ) { |
|
644 | + if (!empty($_GET['type'])) { |
|
645 | 645 | $query->query_vars['meta_query'][] = array( |
646 | 646 | 'key' => '_wpinv_type', |
647 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
647 | + 'value' => sanitize_text_field($_GET['type']), |
|
648 | 648 | 'compare' => '=' |
649 | 649 | ); |
650 | 650 | } |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | /** |
655 | 655 | * Reorders items. |
656 | 656 | */ |
657 | - public static function reorder_items( $vars ) { |
|
657 | + public static function reorder_items($vars) { |
|
658 | 658 | global $typenow; |
659 | 659 | |
660 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
660 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
661 | 661 | return $vars; |
662 | 662 | } |
663 | 663 | |
664 | 664 | // By item type. |
665 | - if ( 'type' == $vars['orderby'] ) { |
|
665 | + if ('type' == $vars['orderby']) { |
|
666 | 666 | return array_merge( |
667 | 667 | $vars, |
668 | 668 | array( |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | // By vat class. |
676 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
676 | + if ('vat_class' == $vars['orderby']) { |
|
677 | 677 | return array_merge( |
678 | 678 | $vars, |
679 | 679 | array( |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | // By vat rule. |
687 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
687 | + if ('vat_rule' == $vars['orderby']) { |
|
688 | 688 | return array_merge( |
689 | 689 | $vars, |
690 | 690 | array( |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | // By price. |
698 | - if ( 'price' == $vars['orderby'] ) { |
|
698 | + if ('price' == $vars['orderby']) { |
|
699 | 699 | return array_merge( |
700 | 700 | $vars, |
701 | 701 | array( |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Fired when deleting a post. |
714 | 714 | */ |
715 | - public static function delete_post( $post_id ) { |
|
715 | + public static function delete_post($post_id) { |
|
716 | 716 | |
717 | - switch ( get_post_type( $post_id ) ) { |
|
717 | + switch (get_post_type($post_id)) { |
|
718 | 718 | |
719 | 719 | case 'wpi_item' : |
720 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
720 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'wpi_payment_form' : |
724 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
724 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
725 | 725 | break; |
726 | 726 | |
727 | 727 | case 'wpi_discount' : |
728 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
728 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'wpi_invoice' : |
732 | - $invoice = new WPInv_Invoice( $post_id ); |
|
733 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
732 | + $invoice = new WPInv_Invoice($post_id); |
|
733 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
734 | + $invoice->get_data_store()->delete_items($invoice); |
|
735 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
736 | 736 | break; |
737 | 737 | } |
738 | 738 | } |
@@ -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? |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | function wpinv_get_ip() { |
22 | 22 | $ip = $_SERVER['REMOTE_ADDR']; |
23 | 23 | |
24 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
25 | 25 | //Check ip from share internet. |
26 | 26 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
27 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | //Check ip is pass from proxy. |
29 | 29 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
30 | 30 | } |
31 | 31 | |
32 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
32 | + return apply_filters('wpinv_get_ip', $ip); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function wpinv_get_user_agent() { |
36 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
37 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
36 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
37 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
38 | 38 | } else { |
39 | 39 | $user_agent = ''; |
40 | 40 | } |
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
42 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,27 +47,27 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $amount The amount to sanitize. |
49 | 49 | */ |
50 | -function wpinv_sanitize_amount( $amount ) { |
|
50 | +function wpinv_sanitize_amount($amount) { |
|
51 | 51 | |
52 | 52 | // Format decimals. |
53 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
53 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
54 | 54 | |
55 | 55 | // Remove thousands. |
56 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
56 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
57 | 57 | |
58 | 58 | // Cast the remaining to a float. |
59 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
59 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
64 | - if ( $decimals === NULL ) { |
|
63 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
64 | + if ($decimals === NULL) { |
|
65 | 65 | $decimals = wpinv_decimals(); |
66 | 66 | } |
67 | 67 | |
68 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
68 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
69 | 69 | |
70 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
70 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | * @since 1.0.19 |
77 | 77 | * @return array |
78 | 78 | */ |
79 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
79 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
80 | 80 | $invoice_statuses = array( |
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
83 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
88 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
81 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
82 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
83 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
84 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
85 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
86 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
87 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
88 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
89 | 89 | ); |
90 | 90 | |
91 | - if ( $draft ) { |
|
92 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
91 | + if ($draft) { |
|
92 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( $trashed ) { |
|
96 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
95 | + if ($trashed) { |
|
96 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
100 | 100 | } |
101 | 101 | |
102 | -function wpinv_status_nicename( $status ) { |
|
103 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
104 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
102 | +function wpinv_status_nicename($status) { |
|
103 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
104 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
105 | 105 | |
106 | 106 | return $status; |
107 | 107 | } |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param string $current |
113 | 113 | */ |
114 | -function wpinv_get_currency( $current = '' ) { |
|
114 | +function wpinv_get_currency($current = '') { |
|
115 | 115 | |
116 | - if ( empty( $current ) ) { |
|
117 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
116 | + if (empty($current)) { |
|
117 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
118 | 118 | } |
119 | 119 | |
120 | - return trim( strtoupper( $current ) ); |
|
120 | + return trim(strtoupper($current)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,25 +125,25 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string|null $currency The currency code. Defaults to the default currency. |
127 | 127 | */ |
128 | -function wpinv_currency_symbol( $currency = null ) { |
|
128 | +function wpinv_currency_symbol($currency = null) { |
|
129 | 129 | |
130 | 130 | // Prepare the currency. |
131 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
131 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
132 | 132 | |
133 | 133 | // Fetch all symbols. |
134 | 134 | $symbols = wpinv_get_currency_symbols(); |
135 | 135 | |
136 | 136 | // Fetch this currencies symbol. |
137 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
137 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
138 | 138 | |
139 | 139 | // Filter the symbol. |
140 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
140 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_currency_position() { |
144 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
144 | + $position = wpinv_get_option('currency_position', 'left'); |
|
145 | 145 | |
146 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
146 | + return apply_filters('wpinv_currency_position', $position); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param $string|null $current |
153 | 153 | */ |
154 | -function wpinv_thousands_separator( $current = null ) { |
|
154 | +function wpinv_thousands_separator($current = null) { |
|
155 | 155 | |
156 | - if ( null == $current ) { |
|
157 | - $current = wpinv_get_option( 'thousands_separator', '.' ); |
|
156 | + if (null == $current) { |
|
157 | + $current = wpinv_get_option('thousands_separator', '.'); |
|
158 | 158 | } |
159 | 159 | |
160 | - return trim( $current ); |
|
160 | + return trim($current); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param $string|null $current |
167 | 167 | */ |
168 | -function wpinv_decimal_separator( $current = null ) { |
|
168 | +function wpinv_decimal_separator($current = null) { |
|
169 | 169 | |
170 | - if ( null == $current ) { |
|
171 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
170 | + if (null == $current) { |
|
171 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
172 | 172 | } |
173 | 173 | |
174 | - return trim( $current ); |
|
174 | + return trim($current); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param $string|null $current |
181 | 181 | */ |
182 | -function wpinv_decimals( $current = null ) { |
|
182 | +function wpinv_decimals($current = null) { |
|
183 | 183 | |
184 | - if ( null == $current ) { |
|
185 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
184 | + if (null == $current) { |
|
185 | + $current = wpinv_get_option('decimals', 2); |
|
186 | 186 | } |
187 | 187 | |
188 | - return absint( $current ); |
|
188 | + return absint($current); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Retrieves a list of all supported currencies. |
193 | 193 | */ |
194 | 194 | function wpinv_get_currencies() { |
195 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
195 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Retrieves a list of all currency symbols. |
200 | 200 | */ |
201 | 201 | function wpinv_get_currency_symbols() { |
202 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
202 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $currency_pos = wpinv_currency_position(); |
212 | 212 | $format = '%1$s%2$s'; |
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
214 | + switch ($currency_pos) { |
|
215 | 215 | case 'left': |
216 | 216 | $format = '%1$s%2$s'; |
217 | 217 | break; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | break; |
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -236,25 +236,25 @@ discard block |
||
236 | 236 | * @param string $currency Currency. |
237 | 237 | * @return string |
238 | 238 | */ |
239 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
239 | +function wpinv_price($amount = 0, $currency = '') { |
|
240 | 240 | |
241 | 241 | // Backwards compatibility. |
242 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
242 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
243 | 243 | |
244 | 244 | // Prepare variables. |
245 | - $currency = wpinv_get_currency( $currency ); |
|
245 | + $currency = wpinv_get_currency($currency); |
|
246 | 246 | $amount = (float) $amount; |
247 | 247 | $unformatted_amount = $amount; |
248 | 248 | $negative = $amount < 0; |
249 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
250 | - $amount = wpinv_format_amount( $amount ); |
|
249 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
250 | + $amount = wpinv_format_amount($amount); |
|
251 | 251 | |
252 | 252 | // Format the amount. |
253 | 253 | $format = getpaid_get_price_format(); |
254 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
254 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
255 | 255 | |
256 | 256 | // Filter the formatting. |
257 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
257 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | * @param bool $calculate Whether or not to apply separators. |
266 | 266 | * @return string |
267 | 267 | */ |
268 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
268 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
269 | 269 | $thousands_sep = wpinv_thousands_separator(); |
270 | 270 | $decimal_sep = wpinv_decimal_separator(); |
271 | - $decimals = wpinv_decimals( $decimals ); |
|
271 | + $decimals = wpinv_decimals($decimals); |
|
272 | 272 | |
273 | 273 | // Format decimals. |
274 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
274 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
275 | 275 | |
276 | 276 | // Remove thousands. |
277 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
277 | + $amount = str_replace($thousands_sep, '', $amount); |
|
278 | 278 | |
279 | 279 | // Cast the remaining to a float. |
280 | - $amount = floatval( $amount ); |
|
280 | + $amount = floatval($amount); |
|
281 | 281 | |
282 | - if ( $calculate ) { |
|
282 | + if ($calculate) { |
|
283 | 283 | return $amount; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Fomart the amount. |
287 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
287 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
288 | 288 | } |
289 | 289 | |
290 | -function wpinv_sanitize_key( $key ) { |
|
290 | +function wpinv_sanitize_key($key) { |
|
291 | 291 | $raw_key = $key; |
292 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
292 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
294 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param $str the file whose extension should be retrieved. |
301 | 301 | */ |
302 | -function wpinv_get_file_extension( $str ) { |
|
303 | - $filetype = wp_check_filetype( $str ); |
|
302 | +function wpinv_get_file_extension($str) { |
|
303 | + $filetype = wp_check_filetype($str); |
|
304 | 304 | return $filetype['ext']; |
305 | 305 | } |
306 | 306 | |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param string $string |
311 | 311 | */ |
312 | -function wpinv_string_is_image_url( $string ) { |
|
313 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
314 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
312 | +function wpinv_string_is_image_url($string) { |
|
313 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
314 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Returns the current URL. |
319 | 319 | */ |
320 | 320 | function wpinv_get_current_page_url() { |
321 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
321 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -328,46 +328,46 @@ discard block |
||
328 | 328 | * @param string $name Constant name. |
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
331 | +function getpaid_maybe_define_constant($name, $value) { |
|
332 | + if (!defined($name)) { |
|
333 | + define($name, $value); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get('arg_separator.output'); |
|
339 | 339 | } |
340 | 340 | |
341 | -function wpinv_rgb_from_hex( $color ) { |
|
342 | - $color = str_replace( '#', '', $color ); |
|
341 | +function wpinv_rgb_from_hex($color) { |
|
342 | + $color = str_replace('#', '', $color); |
|
343 | 343 | |
344 | 344 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
345 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
346 | - if ( empty( $color ) ) { |
|
345 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
346 | + if (empty($color)) { |
|
347 | 347 | return NULL; |
348 | 348 | } |
349 | 349 | |
350 | - $color = str_split( $color ); |
|
350 | + $color = str_split($color); |
|
351 | 351 | |
352 | 352 | $rgb = array(); |
353 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
354 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
355 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
353 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
354 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
355 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
356 | 356 | |
357 | 357 | return $rgb; |
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
361 | - $base = wpinv_rgb_from_hex( $color ); |
|
360 | +function wpinv_hex_darker($color, $factor = 30) { |
|
361 | + $base = wpinv_rgb_from_hex($color); |
|
362 | 362 | $color = '#'; |
363 | 363 | |
364 | - foreach ( $base as $k => $v ) { |
|
364 | + foreach ($base as $k => $v) { |
|
365 | 365 | $amount = $v / 100; |
366 | - $amount = round( $amount * $factor ); |
|
366 | + $amount = round($amount * $factor); |
|
367 | 367 | $new_decimal = $v - $amount; |
368 | 368 | |
369 | - $new_hex_component = dechex( $new_decimal ); |
|
370 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
369 | + $new_hex_component = dechex($new_decimal); |
|
370 | + if (strlen($new_hex_component) < 2) { |
|
371 | 371 | $new_hex_component = "0" . $new_hex_component; |
372 | 372 | } |
373 | 373 | $color .= $new_hex_component; |
@@ -376,18 +376,18 @@ discard block |
||
376 | 376 | return $color; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
380 | - $base = wpinv_rgb_from_hex( $color ); |
|
379 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
380 | + $base = wpinv_rgb_from_hex($color); |
|
381 | 381 | $color = '#'; |
382 | 382 | |
383 | - foreach ( $base as $k => $v ) { |
|
383 | + foreach ($base as $k => $v) { |
|
384 | 384 | $amount = 255 - $v; |
385 | 385 | $amount = $amount / 100; |
386 | - $amount = round( $amount * $factor ); |
|
386 | + $amount = round($amount * $factor); |
|
387 | 387 | $new_decimal = $v + $amount; |
388 | 388 | |
389 | - $new_hex_component = dechex( $new_decimal ); |
|
390 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
389 | + $new_hex_component = dechex($new_decimal); |
|
390 | + if (strlen($new_hex_component) < 2) { |
|
391 | 391 | $new_hex_component = "0" . $new_hex_component; |
392 | 392 | } |
393 | 393 | $color .= $new_hex_component; |
@@ -396,22 +396,22 @@ discard block |
||
396 | 396 | return $color; |
397 | 397 | } |
398 | 398 | |
399 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
400 | - $hex = str_replace( '#', '', $color ); |
|
399 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
400 | + $hex = str_replace('#', '', $color); |
|
401 | 401 | |
402 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
403 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
404 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
402 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
403 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
404 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
405 | 405 | |
406 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
406 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
407 | 407 | |
408 | 408 | return $brightness > 155 ? $dark : $light; |
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_format_hex( $hex ) { |
|
412 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
411 | +function wpinv_format_hex($hex) { |
|
412 | + $hex = trim(str_replace('#', '', $hex)); |
|
413 | 413 | |
414 | - if ( strlen( $hex ) == 3 ) { |
|
414 | + if (strlen($hex) == 3) { |
|
415 | 415 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
416 | 416 | } |
417 | 417 | |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
432 | 432 | * @return string |
433 | 433 | */ |
434 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
435 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
436 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
434 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
435 | + if (function_exists('mb_strimwidth')) { |
|
436 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
437 | 437 | } |
438 | 438 | |
439 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
439 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -448,28 +448,28 @@ discard block |
||
448 | 448 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
449 | 449 | * @return int Returns the number of characters in string. |
450 | 450 | */ |
451 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
452 | - if ( function_exists( 'mb_strlen' ) ) { |
|
453 | - return mb_strlen( $str, $encoding ); |
|
451 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
452 | + if (function_exists('mb_strlen')) { |
|
453 | + return mb_strlen($str, $encoding); |
|
454 | 454 | } |
455 | 455 | |
456 | - return strlen( $str ); |
|
456 | + return strlen($str); |
|
457 | 457 | } |
458 | 458 | |
459 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
460 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
461 | - return mb_strtolower( $str, $encoding ); |
|
459 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
460 | + if (function_exists('mb_strtolower')) { |
|
461 | + return mb_strtolower($str, $encoding); |
|
462 | 462 | } |
463 | 463 | |
464 | - return strtolower( $str ); |
|
464 | + return strtolower($str); |
|
465 | 465 | } |
466 | 466 | |
467 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
468 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
469 | - return mb_strtoupper( $str, $encoding ); |
|
467 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
468 | + if (function_exists('mb_strtoupper')) { |
|
469 | + return mb_strtoupper($str, $encoding); |
|
470 | 470 | } |
471 | 471 | |
472 | - return strtoupper( $str ); |
|
472 | + return strtoupper($str); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
484 | 484 | * @return int Returns the position of the first occurrence of search in the string. |
485 | 485 | */ |
486 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
487 | - if ( function_exists( 'mb_strpos' ) ) { |
|
488 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
486 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
487 | + if (function_exists('mb_strpos')) { |
|
488 | + return mb_strpos($str, $find, $offset, $encoding); |
|
489 | 489 | } |
490 | 490 | |
491 | - return strpos( $str, $find, $offset ); |
|
491 | + return strpos($str, $find, $offset); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
503 | 503 | * @return int Returns the position of the last occurrence of search. |
504 | 504 | */ |
505 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
506 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
507 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
505 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
506 | + if (function_exists('mb_strrpos')) { |
|
507 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
508 | 508 | } |
509 | 509 | |
510 | - return strrpos( $str, $find, $offset ); |
|
510 | + return strrpos($str, $find, $offset); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -522,16 +522,16 @@ discard block |
||
522 | 522 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
523 | 523 | * @return string |
524 | 524 | */ |
525 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
526 | - if ( function_exists( 'mb_substr' ) ) { |
|
527 | - if ( $length === null ) { |
|
528 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
525 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
526 | + if (function_exists('mb_substr')) { |
|
527 | + if ($length === null) { |
|
528 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
529 | 529 | } else { |
530 | - return mb_substr( $str, $start, $length, $encoding ); |
|
530 | + return mb_substr($str, $start, $length, $encoding); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - return substr( $str, $start, $length ); |
|
534 | + return substr($str, $start, $length); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -543,48 +543,48 @@ discard block |
||
543 | 543 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
544 | 544 | * @return string The width of string. |
545 | 545 | */ |
546 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
547 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
548 | - return mb_strwidth( $str, $encoding ); |
|
546 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
547 | + if (function_exists('mb_strwidth')) { |
|
548 | + return mb_strwidth($str, $encoding); |
|
549 | 549 | } |
550 | 550 | |
551 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
551 | + return wpinv_utf8_strlen($str, $encoding); |
|
552 | 552 | } |
553 | 553 | |
554 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
555 | - if ( function_exists( 'mb_strlen' ) ) { |
|
556 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
554 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
555 | + if (function_exists('mb_strlen')) { |
|
556 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
557 | 557 | $str_end = ""; |
558 | 558 | |
559 | - if ( $lower_str_end ) { |
|
560 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
559 | + if ($lower_str_end) { |
|
560 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
561 | 561 | } else { |
562 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
562 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | return $first_letter . $str_end; |
566 | 566 | } |
567 | 567 | |
568 | - return ucfirst( $str ); |
|
568 | + return ucfirst($str); |
|
569 | 569 | } |
570 | 570 | |
571 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
572 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
573 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
571 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
572 | + if (function_exists('mb_convert_case')) { |
|
573 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
574 | 574 | } |
575 | 575 | |
576 | - return ucwords( $str ); |
|
576 | + return ucwords($str); |
|
577 | 577 | } |
578 | 578 | |
579 | -function wpinv_period_in_days( $period, $unit ) { |
|
580 | - $period = absint( $period ); |
|
579 | +function wpinv_period_in_days($period, $unit) { |
|
580 | + $period = absint($period); |
|
581 | 581 | |
582 | - if ( $period > 0 ) { |
|
583 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
582 | + if ($period > 0) { |
|
583 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
584 | 584 | $period = $period * 7; |
585 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
585 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
586 | 586 | $period = $period * 30; |
587 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
587 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
588 | 588 | $period = $period * 365; |
589 | 589 | } |
590 | 590 | } |
@@ -592,14 +592,14 @@ discard block |
||
592 | 592 | return $period; |
593 | 593 | } |
594 | 594 | |
595 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
596 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
597 | - return cal_days_in_month( $calendar, $month, $year ); |
|
595 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
596 | + if (function_exists('cal_days_in_month')) { |
|
597 | + return cal_days_in_month($calendar, $month, $year); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | // Fallback in case the calendar extension is not loaded in PHP |
601 | 601 | // Only supports Gregorian calendar |
602 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
602 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string |
612 | 612 | */ |
613 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
614 | - if ( $allow_html ) { |
|
615 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
613 | +function wpi_help_tip($tip, $allow_html = false) { |
|
614 | + if ($allow_html) { |
|
615 | + $tip = wpi_sanitize_tooltip($tip); |
|
616 | 616 | } else { |
617 | - $tip = esc_attr( $tip ); |
|
617 | + $tip = esc_attr($tip); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param string $var |
629 | 629 | * @return string |
630 | 630 | */ |
631 | -function wpi_sanitize_tooltip( $var ) { |
|
632 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
631 | +function wpi_sanitize_tooltip($var) { |
|
632 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
633 | 633 | 'br' => array(), |
634 | 634 | 'em' => array(), |
635 | 635 | 'strong' => array(), |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | 'li' => array(), |
640 | 640 | 'ol' => array(), |
641 | 641 | 'p' => array(), |
642 | - ) ) ); |
|
642 | + ))); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function wpinv_get_screen_ids() { |
651 | 651 | |
652 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
652 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
653 | 653 | |
654 | 654 | $screen_ids = array( |
655 | 655 | 'toplevel_page_' . $screen_id, |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | 'invoicing_page_wpi-addons', |
668 | 668 | ); |
669 | 669 | |
670 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
670 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * @param array|string $list List of values. |
679 | 679 | * @return array Sanitized array of values. |
680 | 680 | */ |
681 | -function wpinv_parse_list( $list ) { |
|
681 | +function wpinv_parse_list($list) { |
|
682 | 682 | |
683 | - if ( empty( $list ) ) { |
|
683 | + if (empty($list)) { |
|
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
687 | + if (!is_array($list)) { |
|
688 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | return $list; |
@@ -699,16 +699,16 @@ discard block |
||
699 | 699 | * @param string $key Type of data to fetch. |
700 | 700 | * @return mixed Fetched data. |
701 | 701 | */ |
702 | -function wpinv_get_data( $key ) { |
|
702 | +function wpinv_get_data($key) { |
|
703 | 703 | |
704 | 704 | // Try fetching it from the cache. |
705 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
706 | - if( $data ) { |
|
705 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
706 | + if ($data) { |
|
707 | 707 | return $data; |
708 | 708 | } |
709 | 709 | |
710 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
710 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
711 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
712 | 712 | |
713 | 713 | return $data; |
714 | 714 | } |
@@ -722,10 +722,10 @@ discard block |
||
722 | 722 | * @param bool $first_empty Whether or not the first item in the list should be empty |
723 | 723 | * @return mixed Fetched data. |
724 | 724 | */ |
725 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
725 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
726 | 726 | |
727 | - if ( ! empty( $options ) && $first_empty ) { |
|
728 | - return array_merge( array( '' => '' ), $options ); |
|
727 | + if (!empty($options) && $first_empty) { |
|
728 | + return array_merge(array('' => ''), $options); |
|
729 | 729 | } |
730 | 730 | return $options; |
731 | 731 | |
@@ -737,21 +737,21 @@ discard block |
||
737 | 737 | * @param mixed $var Data to sanitize. |
738 | 738 | * @return string|array |
739 | 739 | */ |
740 | -function wpinv_clean( $var ) { |
|
740 | +function wpinv_clean($var) { |
|
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if (is_array($var)) { |
|
743 | + return array_map('wpinv_clean', $var); |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( is_object( $var ) ) { |
|
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
746 | + if (is_object($var)) { |
|
747 | + $object_vars = get_object_vars($var); |
|
748 | + foreach ($object_vars as $property_name => $property_value) { |
|
749 | + $var->$property_name = wpinv_clean($property_value); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | 752 | } |
753 | 753 | |
754 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
754 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -760,43 +760,43 @@ discard block |
||
760 | 760 | * @param string $str Data to convert. |
761 | 761 | * @return string|array |
762 | 762 | */ |
763 | -function getpaid_convert_price_string_to_options( $str ) { |
|
763 | +function getpaid_convert_price_string_to_options($str) { |
|
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | - $options = array(); |
|
765 | + $raw_options = array_map('trim', explode(',', $str)); |
|
766 | + $options = array(); |
|
767 | 767 | |
768 | - foreach ( $raw_options as $option ) { |
|
768 | + foreach ($raw_options as $option) { |
|
769 | 769 | |
770 | - if ( '' == $option ) { |
|
770 | + if ('' == $option) { |
|
771 | 771 | continue; |
772 | 772 | } |
773 | 773 | |
774 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
774 | + $option = array_map('trim', explode('|', $option)); |
|
775 | 775 | |
776 | 776 | $price = null; |
777 | 777 | $label = null; |
778 | 778 | |
779 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
780 | - $label = $option[0]; |
|
779 | + if (isset($option[0]) && '' != $option[0]) { |
|
780 | + $label = $option[0]; |
|
781 | 781 | } |
782 | 782 | |
783 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
783 | + if (isset($option[1]) && '' != $option[1]) { |
|
784 | 784 | $price = $option[1]; |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! isset( $price ) ) { |
|
787 | + if (!isset($price)) { |
|
788 | 788 | $price = $label; |
789 | 789 | } |
790 | 790 | |
791 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
791 | + if (!isset($price) || !is_numeric($price)) { |
|
792 | 792 | continue; |
793 | 793 | } |
794 | 794 | |
795 | - if ( ! isset( $label ) ) { |
|
795 | + if (!isset($label)) { |
|
796 | 796 | $label = $price; |
797 | 797 | } |
798 | 798 | |
799 | - $options[ $price ] = $label; |
|
799 | + $options[$price] = $label; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | return $options; |
@@ -805,22 +805,22 @@ discard block |
||
805 | 805 | /** |
806 | 806 | * Returns the help tip. |
807 | 807 | */ |
808 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
809 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
810 | - $tip = esc_attr__( $tip ); |
|
808 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
809 | + $additional_classes = sanitize_html_class($additional_classes); |
|
810 | + $tip = esc_attr__($tip); |
|
811 | 811 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
815 | 815 | * Formats a date |
816 | 816 | */ |
817 | -function getpaid_format_date( $date ) { |
|
817 | +function getpaid_format_date($date) { |
|
818 | 818 | |
819 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
819 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
820 | 820 | return ''; |
821 | 821 | } |
822 | 822 | |
823 | - return date_i18n( getpaid_date_format(), strtotime( $date ) ); |
|
823 | + return date_i18n(getpaid_date_format(), strtotime($date)); |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @return string |
831 | 831 | */ |
832 | -function getpaid_format_date_value( $date, $default = "—" ) { |
|
833 | - $date = getpaid_format_date( $date ); |
|
834 | - return empty( $date ) ? $default : $date; |
|
832 | +function getpaid_format_date_value($date, $default = "—") { |
|
833 | + $date = getpaid_format_date($date); |
|
834 | + return empty($date) ? $default : $date; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -859,16 +859,16 @@ discard block |
||
859 | 859 | * @param integer $limit Limit size in characters. |
860 | 860 | * @return string |
861 | 861 | */ |
862 | -function getpaid_limit_length( $string, $limit ) { |
|
862 | +function getpaid_limit_length($string, $limit) { |
|
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
865 | + if (function_exists('mb_strimwidth')) { |
|
866 | + if (mb_strlen($string) > $limit) { |
|
867 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
868 | 868 | } |
869 | 869 | } else { |
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
870 | + if (strlen($string) > $limit) { |
|
871 | + $string = substr($string, 0, $str_limit) . '...'; |
|
872 | 872 | } |
873 | 873 | } |
874 | 874 | return $string; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * @since 1.0.19 |
883 | 883 | */ |
884 | 884 | function getpaid_api() { |
885 | - return getpaid()->get( 'api' ); |
|
885 | + return getpaid()->get('api'); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @since 1.0.19 |
893 | 893 | */ |
894 | 894 | function getpaid_post_types() { |
895 | - return getpaid()->get( 'post_types' ); |
|
895 | + return getpaid()->get('post_types'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @since 1.0.19 |
903 | 903 | */ |
904 | 904 | function getpaid_session() { |
905 | - return getpaid()->get( 'session' ); |
|
905 | + return getpaid()->get('session'); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @since 1.0.19 |
913 | 913 | */ |
914 | 914 | function getpaid_notes() { |
915 | - return getpaid()->get( 'notes' ); |
|
915 | + return getpaid()->get('notes'); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * @return GetPaid_Admin |
922 | 922 | */ |
923 | 923 | function getpaid_admin() { |
924 | - return getpaid()->get( 'admin' ); |
|
924 | + return getpaid()->get('admin'); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -931,6 +931,6 @@ discard block |
||
931 | 931 | * @param string $base the base url |
932 | 932 | * @return string |
933 | 933 | */ |
934 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
935 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
934 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
935 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
936 | 936 | } |
@@ -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 | * Payment form submission refresh prices class |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
32 | 32 | ); |
33 | 33 | |
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
34 | + $this->add_totals($submission); |
|
35 | + $this->add_texts($submission); |
|
36 | + $this->add_items($submission); |
|
37 | + $this->add_fees($submission); |
|
38 | + $this->add_discounts($submission); |
|
39 | + $this->add_taxes($submission); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
@@ -45,26 +45,26 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @param GetPaid_Payment_Form_Submission $submission |
47 | 47 | */ |
48 | - public function add_totals( $submission ) { |
|
48 | + public function add_totals($submission) { |
|
49 | 49 | |
50 | 50 | $this->response = array_merge( |
51 | 51 | $this->response, |
52 | 52 | array( |
53 | 53 | |
54 | 54 | 'totals' => array( |
55 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
56 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
57 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
58 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
59 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
55 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
56 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
57 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
58 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
59 | + 'total' => $submission->format_amount($submission->get_total()), |
|
60 | 60 | ), |
61 | 61 | |
62 | 62 | 'recurring' => array( |
63 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
64 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
65 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
66 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
67 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
63 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
64 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
65 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
66 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
67 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
68 | 68 | ), |
69 | 69 | |
70 | 70 | ) |
@@ -77,22 +77,22 @@ discard block |
||
77 | 77 | * |
78 | 78 | * @param GetPaid_Payment_Form_Submission $submission |
79 | 79 | */ |
80 | - public function add_texts( $submission ) { |
|
80 | + public function add_texts($submission) { |
|
81 | 81 | |
82 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
82 | + $payable = $submission->format_amount($submission->get_total()); |
|
83 | 83 | |
84 | - if ( $submission->has_recurring != 0 ) { |
|
84 | + if ($submission->has_recurring != 0) { |
|
85 | 85 | |
86 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
87 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
86 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
87 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
88 | 88 | |
89 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
89 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
90 | 90 | $payable = "$payable / $period"; |
91 | 91 | } else { |
92 | 92 | $payable = sprintf( |
93 | - __( '%1$s (renews at %2$s / %3$s)'), |
|
94 | - $submission->format_amount( $submission->get_total() ), |
|
95 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
93 | + __('%1$s (renews at %2$s / %3$s)'), |
|
94 | + $submission->format_amount($submission->get_total()), |
|
95 | + $submission->format_amount($submission->get_recurring_total()), |
|
96 | 96 | $period |
97 | 97 | ); |
98 | 98 | } |
@@ -103,12 +103,12 @@ discard block |
||
103 | 103 | '.getpaid-checkout-total-payable' => $payable, |
104 | 104 | ); |
105 | 105 | |
106 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
107 | - $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount( $item->get_sub_total() ); |
|
108 | - $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount( $item->get_recurring_sub_total() ); |
|
106 | + foreach ($submission->get_items() as $item_id => $item) { |
|
107 | + $texts[".item-$item_id .getpaid-item-initial-price"] = $submission->format_amount($item->get_sub_total()); |
|
108 | + $texts[".item-$item_id .getpaid-item-recurring-price"] = $submission->format_amount($item->get_recurring_sub_total()); |
|
109 | 109 | } |
110 | 110 | |
111 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
111 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
112 | 112 | |
113 | 113 | } |
114 | 114 | |
@@ -117,18 +117,18 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param GetPaid_Payment_Form_Submission $submission |
119 | 119 | */ |
120 | - public function add_items( $submission ) { |
|
120 | + public function add_items($submission) { |
|
121 | 121 | |
122 | 122 | // Add items. |
123 | 123 | $items = array(); |
124 | 124 | |
125 | - foreach ( $submission->get_items() as $item_id => $item ) { |
|
126 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
125 | + foreach ($submission->get_items() as $item_id => $item) { |
|
126 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | $this->response = array_merge( |
130 | 130 | $this->response, |
131 | - array( 'items' => $items ) |
|
131 | + array('items' => $items) |
|
132 | 132 | ); |
133 | 133 | |
134 | 134 | } |
@@ -138,17 +138,17 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param GetPaid_Payment_Form_Submission $submission |
140 | 140 | */ |
141 | - public function add_fees( $submission ) { |
|
141 | + public function add_fees($submission) { |
|
142 | 142 | |
143 | 143 | $fees = array(); |
144 | 144 | |
145 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
146 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
145 | + foreach ($submission->get_fees() as $name => $data) { |
|
146 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $this->response = array_merge( |
150 | 150 | $this->response, |
151 | - array( 'fees' => $fees ) |
|
151 | + array('fees' => $fees) |
|
152 | 152 | ); |
153 | 153 | |
154 | 154 | } |
@@ -158,17 +158,17 @@ discard block |
||
158 | 158 | * |
159 | 159 | * @param GetPaid_Payment_Form_Submission $submission |
160 | 160 | */ |
161 | - public function add_discounts( $submission ) { |
|
161 | + public function add_discounts($submission) { |
|
162 | 162 | |
163 | 163 | $discounts = array(); |
164 | 164 | |
165 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
166 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
165 | + foreach ($submission->get_discounts() as $name => $data) { |
|
166 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $this->response = array_merge( |
170 | 170 | $this->response, |
171 | - array( 'discounts' => $discounts ) |
|
171 | + array('discounts' => $discounts) |
|
172 | 172 | ); |
173 | 173 | |
174 | 174 | } |
@@ -178,17 +178,17 @@ discard block |
||
178 | 178 | * |
179 | 179 | * @param GetPaid_Payment_Form_Submission $submission |
180 | 180 | */ |
181 | - public function add_taxes( $submission ) { |
|
181 | + public function add_taxes($submission) { |
|
182 | 182 | |
183 | 183 | $taxes = array(); |
184 | 184 | |
185 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
186 | - $taxes[$name] = $submission->format_amount( $data['initial_tax'] ); |
|
185 | + foreach ($submission->get_taxes() as $name => $data) { |
|
186 | + $taxes[$name] = $submission->format_amount($data['initial_tax']); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | $this->response = array_merge( |
190 | 190 | $this->response, |
191 | - array( 'taxes' => $taxes ) |
|
191 | + array('taxes' => $taxes) |
|
192 | 192 | ); |
193 | 193 | |
194 | 194 | } |
@@ -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 | * Main Checkout Class. |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * |
23 | 23 | * @param GetPaid_Payment_Form_Submission $submission |
24 | 24 | */ |
25 | - public function __construct( $submission ) { |
|
25 | + public function __construct($submission) { |
|
26 | 26 | $this->payment_form_submission = $submission; |
27 | 27 | } |
28 | 28 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | // Prepare the invoice. |
39 | 39 | $items = $this->get_submission_items(); |
40 | 40 | $invoice = $this->get_submission_invoice(); |
41 | - $invoice = $this->process_submission_invoice( $invoice, $items ); |
|
42 | - $prepared = $this->prepare_submission_data_for_saving( $invoice ); |
|
41 | + $invoice = $this->process_submission_invoice($invoice, $items); |
|
42 | + $prepared = $this->prepare_submission_data_for_saving($invoice); |
|
43 | 43 | |
44 | 44 | // Save the invoice. |
45 | 45 | $invoice->recalculate_total(); |
46 | 46 | $invoice->save(); |
47 | 47 | |
48 | 48 | // Send to the gateway. |
49 | - $this->post_process_submission( $invoice, $prepared ); |
|
49 | + $this->post_process_submission($invoice, $prepared); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -59,34 +59,34 @@ discard block |
||
59 | 59 | $data = $submission->get_data(); |
60 | 60 | |
61 | 61 | // Do we have an error? |
62 | - if ( ! empty( $submission->last_error ) ) { |
|
63 | - wp_send_json_error( $submission->last_error ); |
|
62 | + if (!empty($submission->last_error)) { |
|
63 | + wp_send_json_error($submission->last_error); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | // We need a billing email. |
67 | - if ( ! $submission->has_billing_email() ) { |
|
68 | - wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) ); |
|
67 | + if (!$submission->has_billing_email()) { |
|
68 | + wp_send_json_error(__('Provide a valid billing email.', 'invoicing')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Non-recurring gateways should not be allowed to process recurring invoices. |
72 | - if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) { |
|
73 | - wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) ); |
|
72 | + if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) { |
|
73 | + wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing')); |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | // Ensure the gateway is active. |
77 | - if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) { |
|
78 | - wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) ); |
|
77 | + if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) { |
|
78 | + wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing')); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Clear any existing errors. |
82 | 82 | wpinv_clear_errors(); |
83 | 83 | |
84 | 84 | // Allow themes and plugins to hook to errors |
85 | - do_action( 'getpaid_checkout_error_checks', $submission ); |
|
85 | + do_action('getpaid_checkout_error_checks', $submission); |
|
86 | 86 | |
87 | 87 | // Do we have any errors? |
88 | - if ( wpinv_get_errors() ) { |
|
89 | - wp_send_json_error( getpaid_get_errors_html() ); |
|
88 | + if (wpinv_get_errors()) { |
|
89 | + wp_send_json_error(getpaid_get_errors_html()); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | } |
@@ -101,8 +101,8 @@ discard block |
||
101 | 101 | $items = $this->payment_form_submission->get_items(); |
102 | 102 | |
103 | 103 | // Ensure that we have items. |
104 | - if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) { |
|
105 | - wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) ); |
|
104 | + if (empty($items) && !$this->payment_form_submission->has_fees()) { |
|
105 | + wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing')); |
|
106 | 106 | } |
107 | 107 | |
108 | 108 | return $items; |
@@ -116,17 +116,17 @@ discard block |
||
116 | 116 | protected function get_submission_invoice() { |
117 | 117 | $submission = $this->payment_form_submission; |
118 | 118 | |
119 | - if ( ! $submission->has_invoice() ) { |
|
119 | + if (!$submission->has_invoice()) { |
|
120 | 120 | $invoice = new WPInv_Invoice(); |
121 | - $invoice->created_via( 'payment_form' ); |
|
121 | + $invoice->created_via('payment_form'); |
|
122 | 122 | return $invoice; |
123 | 123 | } |
124 | 124 | |
125 | 125 | $invoice = $submission->get_invoice(); |
126 | 126 | |
127 | 127 | // Make sure that it is neither paid or refunded. |
128 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
129 | - wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) ); |
|
128 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
129 | + wp_send_json_error(__('This invoice has already been paid for.', 'invoicing')); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | return $invoice; |
@@ -139,26 +139,26 @@ discard block |
||
139 | 139 | * @param GetPaid_Form_Item[] $items |
140 | 140 | * @return WPInv_Invoice |
141 | 141 | */ |
142 | - protected function process_submission_invoice( $invoice, $items ) { |
|
142 | + protected function process_submission_invoice($invoice, $items) { |
|
143 | 143 | |
144 | 144 | $submission = $this->payment_form_submission; |
145 | 145 | $data = $submission->get_data(); |
146 | 146 | |
147 | 147 | // Set-up the invoice details. |
148 | - $invoice->set_email( sanitize_email( $submission->get_billing_email() ) ); |
|
149 | - $invoice->set_user_id( $this->get_submission_customer() ); |
|
150 | - $invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) ); |
|
151 | - $invoice->set_items( $items ); |
|
152 | - $invoice->set_fees( $submission->get_fees() ); |
|
153 | - $invoice->set_taxes( $submission->get_taxes() ); |
|
154 | - $invoice->set_discounts( $submission->get_discounts() ); |
|
155 | - $invoice->set_gateway( $data['wpi-gateway'] ); |
|
156 | - |
|
157 | - if ( $submission->has_discount_code() ) { |
|
158 | - $invoice->set_discount_code( $submission->get_discount_code() ); |
|
148 | + $invoice->set_email(sanitize_email($submission->get_billing_email())); |
|
149 | + $invoice->set_user_id($this->get_submission_customer()); |
|
150 | + $invoice->set_payment_form(absint($submission->get_payment_form()->get_id())); |
|
151 | + $invoice->set_items($items); |
|
152 | + $invoice->set_fees($submission->get_fees()); |
|
153 | + $invoice->set_taxes($submission->get_taxes()); |
|
154 | + $invoice->set_discounts($submission->get_discounts()); |
|
155 | + $invoice->set_gateway($data['wpi-gateway']); |
|
156 | + |
|
157 | + if ($submission->has_discount_code()) { |
|
158 | + $invoice->set_discount_code($submission->get_discount_code()); |
|
159 | 159 | } |
160 | 160 | |
161 | - getpaid_maybe_add_default_address( $invoice ); |
|
161 | + getpaid_maybe_add_default_address($invoice); |
|
162 | 162 | return $invoice; |
163 | 163 | } |
164 | 164 | |
@@ -171,26 +171,26 @@ discard block |
||
171 | 171 | $submission = $this->payment_form_submission; |
172 | 172 | |
173 | 173 | // If this is an existing invoice... |
174 | - if ( $submission->has_invoice() ) { |
|
174 | + if ($submission->has_invoice()) { |
|
175 | 175 | return $submission->get_invoice()->get_user_id(); |
176 | 176 | } |
177 | 177 | |
178 | 178 | // (Maybe) create the user. |
179 | 179 | $user = get_current_user_id(); |
180 | 180 | |
181 | - if ( empty( $user ) ) { |
|
182 | - $user = get_user_by( 'email', $submission->get_billing_email() ); |
|
181 | + if (empty($user)) { |
|
182 | + $user = get_user_by('email', $submission->get_billing_email()); |
|
183 | 183 | } |
184 | 184 | |
185 | - if ( empty( $user ) ) { |
|
186 | - $user = wpinv_create_user( $submission->get_billing_email() ); |
|
185 | + if (empty($user)) { |
|
186 | + $user = wpinv_create_user($submission->get_billing_email()); |
|
187 | 187 | } |
188 | 188 | |
189 | - if ( is_wp_error( $user ) ) { |
|
190 | - wp_send_json_error( $user->get_error_message() ); |
|
189 | + if (is_wp_error($user)) { |
|
190 | + wp_send_json_error($user->get_error_message()); |
|
191 | 191 | } |
192 | 192 | |
193 | - if ( is_numeric( $user ) ) { |
|
193 | + if (is_numeric($user)) { |
|
194 | 194 | return $user; |
195 | 195 | } |
196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | * |
204 | 204 | * @param WPInv_Invoice $invoice |
205 | 205 | */ |
206 | - public function prepare_submission_data_for_saving( &$invoice ) { |
|
206 | + public function prepare_submission_data_for_saving(&$invoice) { |
|
207 | 207 | |
208 | 208 | $submission = $this->payment_form_submission; |
209 | 209 | |
@@ -214,49 +214,49 @@ discard block |
||
214 | 214 | $data = $submission->get_data(); |
215 | 215 | |
216 | 216 | // Loop throught the submitted details. |
217 | - foreach ( $submission->get_payment_form()->get_elements() as $field ) { |
|
217 | + foreach ($submission->get_payment_form()->get_elements() as $field) { |
|
218 | 218 | |
219 | 219 | // Skip premade fields. |
220 | - if ( ! empty( $field['premade'] ) ) { |
|
220 | + if (!empty($field['premade'])) { |
|
221 | 221 | continue; |
222 | 222 | } |
223 | 223 | |
224 | 224 | // If it is required and not set, abort. |
225 | - if ( ! $submission->is_required_field_set( $field ) ) { |
|
226 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
225 | + if (!$submission->is_required_field_set($field)) { |
|
226 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | // Handle address fields. |
230 | - if ( $field['type'] == 'address' ) { |
|
230 | + if ($field['type'] == 'address') { |
|
231 | 231 | |
232 | - foreach ( $field['fields'] as $address_field ) { |
|
232 | + foreach ($field['fields'] as $address_field) { |
|
233 | 233 | |
234 | 234 | // skip if it is not visible. |
235 | - if ( empty( $address_field['visible'] ) ) { |
|
235 | + if (empty($address_field['visible'])) { |
|
236 | 236 | continue; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // If it is required and not set, abort |
240 | - if ( ! empty( $address_field['required'] ) && empty( $data[ $address_field['name'] ] ) ) { |
|
241 | - wp_send_json_error( __( 'Some required fields are not set.', 'invoicing' ) ); |
|
240 | + if (!empty($address_field['required']) && empty($data[$address_field['name']])) { |
|
241 | + wp_send_json_error(__('Some required fields are not set.', 'invoicing')); |
|
242 | 242 | } |
243 | 243 | |
244 | - if ( isset( $data[ $address_field['name'] ] ) ) { |
|
245 | - $name = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
244 | + if (isset($data[$address_field['name']])) { |
|
245 | + $name = str_replace('wpinv_', '', $address_field['name']); |
|
246 | 246 | $method = "set_$name"; |
247 | - $invoice->$method( wpinv_clean( $data[ $address_field['name'] ] ) ); |
|
247 | + $invoice->$method(wpinv_clean($data[$address_field['name']])); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | } |
251 | 251 | |
252 | - } else if ( isset( $data[ $field['id'] ] ) ) { |
|
252 | + } else if (isset($data[$field['id']])) { |
|
253 | 253 | $label = $field['id']; |
254 | 254 | |
255 | - if ( isset( $field['label'] ) ) { |
|
255 | + if (isset($field['label'])) { |
|
256 | 256 | $label = $field['label']; |
257 | 257 | } |
258 | 258 | |
259 | - $prepared[ wpinv_clean( $label ) ] = wpinv_clean( $data[ $field['id'] ] ); |
|
259 | + $prepared[wpinv_clean($label)] = wpinv_clean($data[$field['id']]); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | } |
@@ -271,22 +271,22 @@ discard block |
||
271 | 271 | * @param WPInv_Invoice $invoice |
272 | 272 | * @param array $prepared_payment_form_data |
273 | 273 | */ |
274 | - protected function post_process_submission( $invoice, $prepared_payment_form_data ) { |
|
274 | + protected function post_process_submission($invoice, $prepared_payment_form_data) { |
|
275 | 275 | |
276 | 276 | // Ensure the invoice exists. |
277 | - if ( ! $invoice->exists() ) { |
|
278 | - wp_send_json_error( __( 'An error occured while saving your invoice.', 'invoicing' ) ); |
|
277 | + if (!$invoice->exists()) { |
|
278 | + wp_send_json_error(__('An error occured while saving your invoice.', 'invoicing')); |
|
279 | 279 | } |
280 | 280 | |
281 | 281 | // Save payment form data. |
282 | - if ( ! empty( $prepared_payment_form_data ) ) { |
|
283 | - update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data ); |
|
282 | + if (!empty($prepared_payment_form_data)) { |
|
283 | + update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | // Backwards compatibility. |
287 | - add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) ); |
|
287 | + add_filter('wp_redirect', array($this, 'send_redirect_response')); |
|
288 | 288 | |
289 | - $this->process_payment( $invoice ); |
|
289 | + $this->process_payment($invoice); |
|
290 | 290 | |
291 | 291 | // If we are here, there was an error. |
292 | 292 | wpinv_send_back_to_checkout(); |
@@ -298,44 +298,44 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @param WPInv_Invoice $invoice |
300 | 300 | */ |
301 | - protected function process_payment( $invoice ) { |
|
301 | + protected function process_payment($invoice) { |
|
302 | 302 | |
303 | 303 | $submission = $this->payment_form_submission; |
304 | 304 | |
305 | 305 | // No need to send free invoices to the gateway. |
306 | - if ( $invoice->is_free() ) { |
|
307 | - $invoice->set_gateway( 'none' ); |
|
308 | - $invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true ); |
|
306 | + if ($invoice->is_free()) { |
|
307 | + $invoice->set_gateway('none'); |
|
308 | + $invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true); |
|
309 | 309 | $invoice->mark_paid(); |
310 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
310 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | // Clear any checkout errors. |
314 | 314 | wpinv_clear_errors(); |
315 | 315 | |
316 | 316 | // Fires before sending to the gateway. |
317 | - do_action( 'getpaid_checkout_before_gateway', $invoice, $submission ); |
|
317 | + do_action('getpaid_checkout_before_gateway', $invoice, $submission); |
|
318 | 318 | |
319 | 319 | // Allow the sumission data to be modified before it is sent to the gateway. |
320 | 320 | $submission_data = $submission->get_data(); |
321 | - $submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice ); |
|
322 | - $submission_data = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice ); |
|
321 | + $submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice); |
|
322 | + $submission_data = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice); |
|
323 | 323 | |
324 | 324 | // Validate the currency. |
325 | - if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) { |
|
326 | - wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support the invoice currency', 'invoicing' ) ); |
|
325 | + if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) { |
|
326 | + wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support the invoice currency', 'invoicing')); |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | // Check to see if we have any errors. |
330 | - if ( wpinv_get_errors() ) { |
|
330 | + if (wpinv_get_errors()) { |
|
331 | 331 | wpinv_send_back_to_checkout(); |
332 | 332 | } |
333 | 333 | |
334 | 334 | // Send info to the gateway for payment processing |
335 | - do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission ); |
|
335 | + do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission); |
|
336 | 336 | |
337 | 337 | // Backwards compatibility. |
338 | - wpinv_send_to_gateway( $submission_gateway, $invoice ); |
|
338 | + wpinv_send_to_gateway($submission_gateway, $invoice); |
|
339 | 339 | |
340 | 340 | } |
341 | 341 | |
@@ -343,9 +343,9 @@ discard block |
||
343 | 343 | * Sends a redrect response to payment details. |
344 | 344 | * |
345 | 345 | */ |
346 | - public function send_redirect_response( $url ) { |
|
347 | - $url = urlencode( $url ); |
|
348 | - wp_send_json_success( $url ); |
|
346 | + public function send_redirect_response($url) { |
|
347 | + $url = urlencode($url); |
|
348 | + wp_send_json_success($url); |
|
349 | 349 | } |
350 | 350 | |
351 | 351 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $this->state = wpinv_get_default_state(); |
135 | 135 | |
136 | 136 | // Do we have an actual submission? |
137 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | - $this->load_data( $_POST ); |
|
137 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
138 | + $this->load_data($_POST); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $data |
147 | 147 | */ |
148 | - public function load_data( $data ) { |
|
148 | + public function load_data($data) { |
|
149 | 149 | |
150 | 150 | // Remove slashes from the submitted data... |
151 | - $data = wp_unslash( $data ); |
|
151 | + $data = wp_unslash($data); |
|
152 | 152 | |
153 | 153 | // Allow plugins to filter the data. |
154 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
154 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
155 | 155 | |
156 | 156 | // Cache it... |
157 | 157 | $this->data = $data; |
158 | 158 | |
159 | 159 | // Then generate a unique id from the data. |
160 | - $this->id = md5( wp_json_encode( $data ) ); |
|
160 | + $this->id = md5(wp_json_encode($data)); |
|
161 | 161 | |
162 | 162 | // Finally, process the submission. |
163 | 163 | try { |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | $processors = apply_filters( |
168 | 168 | 'getpaid_payment_form_submission_processors', |
169 | 169 | array( |
170 | - array( $this, 'process_payment_form' ), |
|
171 | - array( $this, 'process_invoice' ), |
|
172 | - array( $this, 'process_fees' ), |
|
173 | - array( $this, 'process_items' ), |
|
174 | - array( $this, 'process_taxes' ), |
|
175 | - array( $this, 'process_discount' ), |
|
170 | + array($this, 'process_payment_form'), |
|
171 | + array($this, 'process_invoice'), |
|
172 | + array($this, 'process_fees'), |
|
173 | + array($this, 'process_items'), |
|
174 | + array($this, 'process_taxes'), |
|
175 | + array($this, 'process_discount'), |
|
176 | 176 | ), |
177 | 177 | $this |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $processors as $processor ) { |
|
181 | - call_user_func_array( $processor, array( &$this ) ); |
|
180 | + foreach ($processors as $processor) { |
|
181 | + call_user_func_array($processor, array(&$this)); |
|
182 | 182 | } |
183 | 183 | |
184 | - } catch ( Exception $e ) { |
|
184 | + } catch (Exception $e) { |
|
185 | 185 | $this->last_error = $e->getMessage(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Fired when we are done processing a submission. |
189 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
189 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | public function process_payment_form() { |
208 | 208 | |
209 | 209 | // Every submission needs an active payment form. |
210 | - if ( empty( $this->data['form_id'] ) ) { |
|
211 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
210 | + if (empty($this->data['form_id'])) { |
|
211 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Fetch the payment form. |
215 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
215 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
216 | 216 | |
217 | - if ( ! $this->payment_form->is_active() ) { |
|
218 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
217 | + if (!$this->payment_form->is_active()) { |
|
218 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
219 | 219 | } |
220 | 220 | |
221 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
221 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | public function process_invoice() { |
249 | 249 | |
250 | 250 | // Abort if there is no invoice. |
251 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
251 | + if (empty($this->data['invoice_id'])) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // If the submission is for an existing invoice, ensure that it exists |
256 | 256 | // and that it is not paid for. |
257 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
257 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
258 | 258 | |
259 | - if ( empty( $invoice ) ) { |
|
260 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
259 | + if (empty($invoice)) { |
|
260 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( $invoice->is_paid() ) { |
|
264 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
263 | + if ($invoice->is_paid()) { |
|
264 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
265 | 265 | } |
266 | 266 | |
267 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
267 | + $this->payment_form->set_items($invoice->get_items()); |
|
268 | 268 | $this->payment_form->invoice = $invoice; |
269 | 269 | |
270 | 270 | $this->country = $invoice->get_country(); |
271 | 271 | $this->state = $invoice->get_state(); |
272 | 272 | $this->invoice = $invoice; |
273 | 273 | |
274 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
274 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | public function has_invoice() { |
294 | - return ! empty( $this->invoice ); |
|
294 | + return !empty($this->invoice); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /* |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function process_items() { |
312 | 312 | |
313 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
313 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
314 | 314 | |
315 | - foreach ( $processor->items as $item ) { |
|
316 | - $this->add_item( $item ); |
|
315 | + foreach ($processor->items as $item) { |
|
316 | + $this->add_item($item); |
|
317 | 317 | } |
318 | 318 | |
319 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
319 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | * @since 1.0.19 |
326 | 326 | * @param GetPaid_Form_Item $item |
327 | 327 | */ |
328 | - public function add_item( $item ) { |
|
328 | + public function add_item($item) { |
|
329 | 329 | |
330 | 330 | // Make sure that it is available for purchase. |
331 | - if ( ! $item->can_purchase() ) { |
|
331 | + if (!$item->can_purchase()) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Each submission can only contain one recurring item. |
336 | - if ( $item->is_recurring() ) { |
|
336 | + if ($item->is_recurring()) { |
|
337 | 337 | |
338 | - if ( $this->has_recurring != 0 ) { |
|
339 | - throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
338 | + if ($this->has_recurring != 0) { |
|
339 | + throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing')); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | $this->has_recurring = $item->get_id(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Update the items and totals. |
347 | - $this->items[ $item->get_id() ] = $item; |
|
347 | + $this->items[$item->get_id()] = $item; |
|
348 | 348 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
349 | 349 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
350 | 350 | |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.0.19 |
360 | 360 | */ |
361 | - public function remove_item( $item_id ) { |
|
361 | + public function remove_item($item_id) { |
|
362 | 362 | |
363 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
363 | + if (isset($this->items[$item_id])) { |
|
364 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
365 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
366 | 366 | |
367 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
367 | + if ($this->items[$item_id]->is_recurring()) { |
|
368 | 368 | $this->has_recurring = 0; |
369 | 369 | } |
370 | 370 | |
371 | - unset( $this->items[ $item_id ] ); |
|
371 | + unset($this->items[$item_id]); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -418,26 +418,26 @@ discard block |
||
418 | 418 | public function process_taxes() { |
419 | 419 | |
420 | 420 | // Abort if we're not using taxes. |
421 | - if ( ! $this->use_taxes() ) { |
|
421 | + if (!$this->use_taxes()) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | |
425 | 425 | // If a custom country && state has been passed in, use it to calculate taxes. |
426 | - if ( ! empty( $this->data['wpinv_country'] ) ) { |
|
426 | + if (!empty($this->data['wpinv_country'])) { |
|
427 | 427 | $this->country = $this->data['wpinv_country']; |
428 | 428 | } |
429 | 429 | |
430 | - if ( ! empty( $this->data['wpinv_state'] ) ) { |
|
430 | + if (!empty($this->data['wpinv_state'])) { |
|
431 | 431 | $this->country = $this->data['wpinv_state']; |
432 | 432 | } |
433 | 433 | |
434 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
434 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
435 | 435 | |
436 | - foreach ( $processor->taxes as $tax ) { |
|
437 | - $this->add_tax( $tax ); |
|
436 | + foreach ($processor->taxes as $tax) { |
|
437 | + $this->add_tax($tax); |
|
438 | 438 | } |
439 | 439 | |
440 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
440 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | /** |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
447 | 447 | * @since 1.0.19 |
448 | 448 | */ |
449 | - public function add_tax( $tax ) { |
|
450 | - $this->taxes[ $tax['name'] ] = $tax; |
|
451 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
452 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
449 | + public function add_tax($tax) { |
|
450 | + $this->taxes[$tax['name']] = $tax; |
|
451 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
452 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -457,12 +457,12 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function remove_tax( $tax_name ) { |
|
460 | + public function remove_tax($tax_name) { |
|
461 | 461 | |
462 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
463 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
464 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
465 | - unset( $this->taxes[ $tax_name ] ); |
|
462 | + if (isset($this->taxes[$tax_name])) { |
|
463 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
464 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
465 | + unset($this->taxes[$tax_name]); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | } |
@@ -476,11 +476,11 @@ discard block |
||
476 | 476 | |
477 | 477 | $use_taxes = wpinv_use_taxes(); |
478 | 478 | |
479 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
479 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
480 | 480 | $use_taxes = false; |
481 | 481 | } |
482 | 482 | |
483 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
483 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
484 | 484 | |
485 | 485 | } |
486 | 486 | |
@@ -529,13 +529,13 @@ discard block |
||
529 | 529 | |
530 | 530 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
531 | 531 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
532 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
532 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
533 | 533 | |
534 | - foreach ( $processor->discounts as $discount ) { |
|
535 | - $this->add_discount( $discount ); |
|
534 | + foreach ($processor->discounts as $discount) { |
|
535 | + $this->add_discount($discount); |
|
536 | 536 | } |
537 | 537 | |
538 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
538 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
545 | 545 | * @since 1.0.19 |
546 | 546 | */ |
547 | - public function add_discount( $discount ) { |
|
548 | - $this->discounts[ $discount['name'] ] = $discount; |
|
549 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
550 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
547 | + public function add_discount($discount) { |
|
548 | + $this->discounts[$discount['name']] = $discount; |
|
549 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
550 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -555,12 +555,12 @@ discard block |
||
555 | 555 | * |
556 | 556 | * @since 1.0.19 |
557 | 557 | */ |
558 | - public function remove_discount( $name ) { |
|
558 | + public function remove_discount($name) { |
|
559 | 559 | |
560 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
561 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
562 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
563 | - unset( $this->discounts[ $name ] ); |
|
560 | + if (isset($this->discounts[$name])) { |
|
561 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
562 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
563 | + unset($this->discounts[$name]); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | } |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @return bool |
573 | 573 | */ |
574 | 574 | public function has_discount_code() { |
575 | - return ! empty( $this->discounts['discount_code'] ); |
|
575 | + return !empty($this->discounts['discount_code']); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | */ |
630 | 630 | public function process_fees() { |
631 | 631 | |
632 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
632 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
633 | 633 | |
634 | - foreach ( $fees_processor->fees as $fee ) { |
|
635 | - $this->add_fee( $fee ); |
|
634 | + foreach ($fees_processor->fees as $fee) { |
|
635 | + $this->add_fee($fee); |
|
636 | 636 | } |
637 | 637 | |
638 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
638 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
639 | 639 | } |
640 | 640 | |
641 | 641 | /** |
@@ -644,11 +644,11 @@ discard block |
||
644 | 644 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
645 | 645 | * @since 1.0.19 |
646 | 646 | */ |
647 | - public function add_fee( $fee ) { |
|
647 | + public function add_fee($fee) { |
|
648 | 648 | |
649 | - $this->fees[ $fee['name'] ] = $fee; |
|
650 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
651 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
649 | + $this->fees[$fee['name']] = $fee; |
|
650 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
651 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
652 | 652 | |
653 | 653 | } |
654 | 654 | |
@@ -657,12 +657,12 @@ discard block |
||
657 | 657 | * |
658 | 658 | * @since 1.0.19 |
659 | 659 | */ |
660 | - public function remove_fee( $name ) { |
|
660 | + public function remove_fee($name) { |
|
661 | 661 | |
662 | - if ( isset( $this->fees[ $name ] ) ) { |
|
663 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
664 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
665 | - unset( $this->fees[ $name ] ); |
|
662 | + if (isset($this->fees[$name])) { |
|
663 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
664 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
665 | + unset($this->fees[$name]); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | } |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @since 1.0.19 |
702 | 702 | */ |
703 | 703 | public function has_fees() { |
704 | - return count( $this->fees ) !== 0; |
|
704 | + return count($this->fees) !== 0; |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /* |
@@ -719,7 +719,7 @@ discard block |
||
719 | 719 | */ |
720 | 720 | public function get_total() { |
721 | 721 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
722 | - return max( $total, 0 ); |
|
722 | + return max($total, 0); |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | /** |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | */ |
730 | 730 | public function get_recurring_total() { |
731 | 731 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
732 | - return max( $total, 0 ); |
|
732 | + return max($total, 0); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | /** |
@@ -741,12 +741,12 @@ discard block |
||
741 | 741 | $initial = $this->get_total(); |
742 | 742 | $recurring = $this->get_recurring_total(); |
743 | 743 | |
744 | - if ( $this->has_recurring == 0 ) { |
|
744 | + if ($this->has_recurring == 0) { |
|
745 | 745 | $recurring = 0; |
746 | 746 | } |
747 | 747 | |
748 | 748 | $collect = $initial > 0 || $recurring > 0; |
749 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
749 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
750 | 750 | } |
751 | 751 | |
752 | 752 | /** |
@@ -755,7 +755,7 @@ discard block |
||
755 | 755 | * @since 1.0.19 |
756 | 756 | */ |
757 | 757 | public function get_billing_email() { |
758 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
758 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
759 | 759 | } |
760 | 760 | |
761 | 761 | /** |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | */ |
766 | 766 | public function has_billing_email() { |
767 | 767 | $billing_email = $this->get_billing_email(); |
768 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
768 | + return !empty($billing_email) && is_email($billing_email); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -795,8 +795,8 @@ discard block |
||
795 | 795 | * @since 1.0.19 |
796 | 796 | * @return mixed |
797 | 797 | */ |
798 | - public function get_field( $field ) { |
|
799 | - return isset( $this->data[ $field ] ) ? $this->data[ $field ] : ''; |
|
798 | + public function get_field($field) { |
|
799 | + return isset($this->data[$field]) ? $this->data[$field] : ''; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -804,8 +804,8 @@ discard block |
||
804 | 804 | * |
805 | 805 | * @since 1.0.19 |
806 | 806 | */ |
807 | - public function is_required_field_set( $field ) { |
|
808 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
807 | + public function is_required_field_set($field) { |
|
808 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -813,8 +813,8 @@ discard block |
||
813 | 813 | * |
814 | 814 | * @since 1.0.19 |
815 | 815 | */ |
816 | - public function format_amount( $amount ) { |
|
817 | - return wpinv_price( $amount, $this->get_currency() ); |
|
816 | + public function format_amount($amount) { |
|
817 | + return wpinv_price($amount, $this->get_currency()); |
|
818 | 818 | } |
819 | 819 | |
820 | 820 | } |