@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,139 +49,139 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | |
83 | 83 | $redirect = add_query_arg( |
84 | - wp_parse_args( $args ), |
|
84 | + wp_parse_args($args), |
|
85 | 85 | wpinv_get_success_page_uri() |
86 | 86 | ); |
87 | 87 | |
88 | - $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args ); |
|
88 | + $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args); |
|
89 | 89 | |
90 | - wp_redirect( $redirect ); |
|
90 | + wp_redirect($redirect); |
|
91 | 91 | exit; |
92 | 92 | } |
93 | 93 | |
94 | -function wpinv_send_to_failed_page( $args = null ) { |
|
94 | +function wpinv_send_to_failed_page($args = null) { |
|
95 | 95 | $redirect = wpinv_get_failed_transaction_uri(); |
96 | 96 | |
97 | - if ( !empty( $args ) ) { |
|
97 | + if (!empty($args)) { |
|
98 | 98 | // Check for backward compatibility |
99 | - if ( is_string( $args ) ) |
|
100 | - $args = str_replace( '?', '', $args ); |
|
99 | + if (is_string($args)) |
|
100 | + $args = str_replace('?', '', $args); |
|
101 | 101 | |
102 | - $args = wp_parse_args( $args ); |
|
102 | + $args = wp_parse_args($args); |
|
103 | 103 | |
104 | - $redirect = add_query_arg( $args, $redirect ); |
|
104 | + $redirect = add_query_arg($args, $redirect); |
|
105 | 105 | } |
106 | 106 | |
107 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
107 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
108 | 108 | |
109 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
110 | - wp_redirect( $redirect ); |
|
109 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
110 | + wp_redirect($redirect); |
|
111 | 111 | exit; |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
115 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
116 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | +function wpinv_get_checkout_uri($args = array()) { |
|
115 | + $uri = wpinv_get_option('checkout_page', false); |
|
116 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
117 | 117 | |
118 | - if ( !empty( $args ) ) { |
|
118 | + if (!empty($args)) { |
|
119 | 119 | // Check for backward compatibility |
120 | - if ( is_string( $args ) ) |
|
121 | - $args = str_replace( '?', '', $args ); |
|
120 | + if (is_string($args)) |
|
121 | + $args = str_replace('?', '', $args); |
|
122 | 122 | |
123 | - $args = wp_parse_args( $args ); |
|
123 | + $args = wp_parse_args($args); |
|
124 | 124 | |
125 | - $uri = add_query_arg( $args, $uri ); |
|
125 | + $uri = add_query_arg($args, $uri); |
|
126 | 126 | } |
127 | 127 | |
128 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
128 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
129 | 129 | |
130 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
130 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
131 | 131 | |
132 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
133 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
132 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
133 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
136 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
140 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
141 | - $success_page = get_permalink( $success_page ); |
|
139 | +function wpinv_get_success_page_url($query_string = null) { |
|
140 | + $success_page = wpinv_get_option('success_page', 0); |
|
141 | + $success_page = get_permalink($success_page); |
|
142 | 142 | |
143 | - if ( $query_string ) |
|
143 | + if ($query_string) |
|
144 | 144 | $success_page .= $query_string; |
145 | 145 | |
146 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
146 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
150 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
151 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
149 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
150 | + $uri = wpinv_get_option('failure_page', ''); |
|
151 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
152 | 152 | |
153 | - if ( $extras ) |
|
153 | + if ($extras) |
|
154 | 154 | $uri .= $extras; |
155 | 155 | |
156 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
156 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | function wpinv_is_failed_transaction_page() { |
160 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
161 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
160 | + $ret = wpinv_get_option('failure_page', false); |
|
161 | + $ret = isset($ret) ? is_page($ret) : false; |
|
162 | 162 | |
163 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
163 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_transaction_query( $type = 'start' ) { |
|
166 | +function wpinv_transaction_query($type = 'start') { |
|
167 | 167 | global $wpdb; |
168 | 168 | |
169 | 169 | $wpdb->hide_errors(); |
170 | 170 | |
171 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
172 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
171 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
172 | + define('WPINV_USE_TRANSACTIONS', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
176 | - switch ( $type ) { |
|
175 | + if (WPINV_USE_TRANSACTIONS) { |
|
176 | + switch ($type) { |
|
177 | 177 | case 'commit' : |
178 | - $wpdb->query( 'COMMIT' ); |
|
178 | + $wpdb->query('COMMIT'); |
|
179 | 179 | break; |
180 | 180 | case 'rollback' : |
181 | - $wpdb->query( 'ROLLBACK' ); |
|
181 | + $wpdb->query('ROLLBACK'); |
|
182 | 182 | break; |
183 | 183 | default : |
184 | - $wpdb->query( 'START TRANSACTION' ); |
|
184 | + $wpdb->query('START TRANSACTION'); |
|
185 | 185 | break; |
186 | 186 | } |
187 | 187 | } |
@@ -190,146 +190,146 @@ discard block |
||
190 | 190 | function wpinv_get_prefix() { |
191 | 191 | $invoice_prefix = 'INV-'; |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
193 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | function wpinv_get_business_logo() { |
197 | - $business_logo = wpinv_get_option( 'logo' ); |
|
198 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
197 | + $business_logo = wpinv_get_option('logo'); |
|
198 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_business_name() { |
202 | - $name = wpinv_get_option( 'store_name', wpinv_get_blogname() ); |
|
202 | + $name = wpinv_get_option('store_name', wpinv_get_blogname()); |
|
203 | 203 | |
204 | - if ( empty( $name ) ) { |
|
204 | + if (empty($name)) { |
|
205 | 205 | $name = wpinv_get_blogname(); |
206 | 206 | } |
207 | 207 | |
208 | - return apply_filters( 'wpinv_get_business_name', $name ); |
|
208 | + return apply_filters('wpinv_get_business_name', $name); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | function wpinv_get_blogname() { |
212 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
212 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_get_admin_email() { |
216 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
217 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
216 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
217 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | function wpinv_get_business_website() { |
221 | - $business_website = home_url( '/' ); |
|
222 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
221 | + $business_website = home_url('/'); |
|
222 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
223 | 223 | } |
224 | 224 | |
225 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
225 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
226 | 226 | $terms_text = ''; |
227 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
227 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | function wpinv_get_business_footer() { |
231 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
232 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
233 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
231 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
232 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
233 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | function wpinv_checkout_required_fields() { |
237 | 237 | $required_fields = array(); |
238 | 238 | |
239 | 239 | // Let payment gateways and other extensions determine if address fields should be required |
240 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
240 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
241 | 241 | |
242 | - if ( $require_billing_details ) { |
|
243 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
242 | + if ($require_billing_details) { |
|
243 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
244 | 244 | $required_fields['first_name'] = array( |
245 | 245 | 'error_id' => 'invalid_first_name', |
246 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
246 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
247 | 247 | ); |
248 | 248 | } |
249 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
249 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
250 | 250 | $required_fields['address'] = array( |
251 | 251 | 'error_id' => 'invalid_address', |
252 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
252 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
253 | 253 | ); |
254 | 254 | } |
255 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
255 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
256 | 256 | $required_fields['city'] = array( |
257 | 257 | 'error_id' => 'invalid_city', |
258 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
258 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
259 | 259 | ); |
260 | 260 | } |
261 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
261 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
262 | 262 | $required_fields['state'] = array( |
263 | 263 | 'error_id' => 'invalid_state', |
264 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
264 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
265 | 265 | ); |
266 | 266 | } |
267 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
267 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
268 | 268 | $required_fields['country'] = array( |
269 | 269 | 'error_id' => 'invalid_country', |
270 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
270 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | } |
274 | 274 | |
275 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
275 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_is_ssl_enforced() { |
279 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
280 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
279 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
280 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | function wpinv_schedule_event_twicedaily() { |
284 | 284 | wpinv_email_payment_reminders(); |
285 | 285 | } |
286 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
286 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
287 | 287 | |
288 | 288 | function wpinv_require_login_to_checkout() { |
289 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
290 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
289 | + $return = wpinv_get_option('login_to_checkout', false); |
|
290 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
291 | 291 | } |
292 | 292 | |
293 | -function wpinv_sequential_number_active( $type = '' ) { |
|
294 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
295 | - if ( null !== $check ) { |
|
293 | +function wpinv_sequential_number_active($type = '') { |
|
294 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
295 | + if (null !== $check) { |
|
296 | 296 | return $check; |
297 | 297 | } |
298 | 298 | |
299 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
299 | + return wpinv_get_option('sequential_invoice_number'); |
|
300 | 300 | } |
301 | 301 | |
302 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
302 | +function wpinv_switch_to_locale($locale = NULL) { |
|
303 | 303 | global $invoicing, $wpi_switch_locale; |
304 | 304 | |
305 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
306 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
305 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
306 | + $locale = empty($locale) ? get_locale() : $locale; |
|
307 | 307 | |
308 | - switch_to_locale( $locale ); |
|
308 | + switch_to_locale($locale); |
|
309 | 309 | |
310 | 310 | $wpi_switch_locale = $locale; |
311 | 311 | |
312 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
312 | + add_filter('plugin_locale', 'get_locale'); |
|
313 | 313 | |
314 | 314 | $invoicing->load_textdomain(); |
315 | 315 | |
316 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
316 | + do_action('wpinv_switch_to_locale', $locale); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
320 | 320 | function wpinv_restore_locale() { |
321 | 321 | global $invoicing, $wpi_switch_locale; |
322 | 322 | |
323 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
323 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
324 | 324 | restore_previous_locale(); |
325 | 325 | |
326 | 326 | $wpi_switch_locale = NULL; |
327 | 327 | |
328 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
328 | + remove_filter('plugin_locale', 'get_locale'); |
|
329 | 329 | |
330 | 330 | $invoicing->load_textdomain(); |
331 | 331 | |
332 | - do_action( 'wpinv_restore_locale' ); |
|
332 | + do_action('wpinv_restore_locale'); |
|
333 | 333 | } |
334 | 334 | } |
335 | 335 | |
@@ -337,26 +337,26 @@ discard block |
||
337 | 337 | * Returns the default form's id. |
338 | 338 | */ |
339 | 339 | function wpinv_get_default_payment_form() { |
340 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
340 | + $form = get_option('wpinv_default_payment_form'); |
|
341 | 341 | |
342 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
342 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
343 | 343 | $form = wp_insert_post( |
344 | 344 | array( |
345 | 345 | 'post_type' => 'wpi_payment_form', |
346 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
346 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
347 | 347 | 'post_status' => 'publish', |
348 | 348 | 'meta_input' => array( |
349 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
349 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
350 | 350 | 'wpinv_form_items' => array(), |
351 | 351 | ) |
352 | 352 | ) |
353 | 353 | ); |
354 | 354 | |
355 | - update_option( 'wpinv_default_payment_form', $form ); |
|
355 | + update_option('wpinv_default_payment_form', $form); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // WPML support. |
359 | - $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', TRUE ); |
|
359 | + $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', TRUE); |
|
360 | 360 | return $form; |
361 | 361 | } |
362 | 362 | |
@@ -365,19 +365,19 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param int $payment_form |
367 | 367 | */ |
368 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
368 | +function getpaid_get_payment_form_elements($payment_form) { |
|
369 | 369 | |
370 | - if ( empty( $payment_form ) ) { |
|
371 | - return wpinv_get_data( 'sample-payment-form' ); |
|
370 | + if (empty($payment_form)) { |
|
371 | + return wpinv_get_data('sample-payment-form'); |
|
372 | 372 | } |
373 | 373 | |
374 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
374 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
375 | 375 | |
376 | - if ( is_array( $form_elements ) ) { |
|
376 | + if (is_array($form_elements)) { |
|
377 | 377 | return $form_elements; |
378 | 378 | } |
379 | 379 | |
380 | - return wpinv_get_data( 'sample-payment-form' ); |
|
380 | + return wpinv_get_data('sample-payment-form'); |
|
381 | 381 | |
382 | 382 | } |
383 | 383 | |
@@ -386,21 +386,21 @@ discard block |
||
386 | 386 | * |
387 | 387 | * @param int $payment_form |
388 | 388 | */ |
389 | -function gepaid_get_form_items( $id ) { |
|
390 | - $form = new GetPaid_Payment_Form( $id ); |
|
389 | +function gepaid_get_form_items($id) { |
|
390 | + $form = new GetPaid_Payment_Form($id); |
|
391 | 391 | |
392 | 392 | // Is this a default form? |
393 | - if ( $form->is_default() ) { |
|
393 | + if ($form->is_default()) { |
|
394 | 394 | return array(); |
395 | 395 | } |
396 | 396 | |
397 | - return $form->get_items( 'view', 'arrays' ); |
|
397 | + return $form->get_items('view', 'arrays'); |
|
398 | 398 | } |
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Trims each line in a paragraph. |
402 | 402 | * |
403 | 403 | */ |
404 | -function gepaid_trim_lines( $content ) { |
|
405 | - return implode( "\n", array_map( 'trim', explode( "\n", $content ) ) ); |
|
404 | +function gepaid_trim_lines($content) { |
|
405 | + return implode("\n", array_map('trim', explode("\n", $content))); |
|
406 | 406 | } |
@@ -4,29 +4,29 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | $gateways = wpinv_get_payment_gateways(); |
10 | -ksort( $gateways ); |
|
10 | +ksort($gateways); |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <div class="table-responsive"> |
14 | 14 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
15 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
15 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
16 | 16 | |
17 | 17 | <thead> |
18 | 18 | <tr class="table-light"> |
19 | 19 | |
20 | 20 | <th scope="col" class="border-bottom border-top text-left"> |
21 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
21 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
22 | 22 | </th> |
23 | 23 | |
24 | 24 | <th scope="col" class="border-bottom border-top text-center"> |
25 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
25 | + <?php _e('Enabled', 'invoicing'); ?> |
|
26 | 26 | </th> |
27 | 27 | |
28 | 28 | <th scope="col" class="border-bottom border-top text-center"> |
29 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
29 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
30 | 30 | </th> |
31 | 31 | |
32 | 32 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -35,15 +35,15 @@ discard block |
||
35 | 35 | </thead> |
36 | 36 | |
37 | 37 | <tbody> |
38 | - <?php foreach ( $gateways as $id => $gateway ) : ?> |
|
38 | + <?php foreach ($gateways as $id => $gateway) : ?> |
|
39 | 39 | <tr> |
40 | 40 | <td class="getpaid-payment-method text-left"> |
41 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
41 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
42 | 42 | </td> |
43 | 43 | <td class="getpaid-payment-method-enabled text-center"> |
44 | 44 | <?php |
45 | 45 | |
46 | - if ( wpinv_is_gateway_active( $id ) ) { |
|
46 | + if (wpinv_is_gateway_active($id)) { |
|
47 | 47 | echo "<i class='text-success fa fa-check'></i>"; |
48 | 48 | } else { |
49 | 49 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -54,10 +54,10 @@ discard block |
||
54 | 54 | <td class="getpaid-payment-method-subscription text-center"> |
55 | 55 | <?php |
56 | 56 | |
57 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
58 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
57 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
58 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
59 | 59 | |
60 | - if ( $supports ) { |
|
60 | + if ($supports) { |
|
61 | 61 | echo "<i class='text-success fa fa-check'></i>"; |
62 | 62 | } else { |
63 | 63 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | </td> |
68 | 68 | |
69 | 69 | <td class="getpaid-payment-method-action text-right"> |
70 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
70 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
71 | 71 | </td> |
72 | 72 | |
73 | 73 | </tr> |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | <tfoot> |
78 | 78 | <tr class="table-light"> |
79 | 79 | <td colspan="4" class="border-top"> |
80 | - <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url( admin_url( 'admin.php?page=wpi-addons&tab=gateways' ) ); ?>"> |
|
81 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
80 | + <a class="button button-secondary getpaid-install-gateways" href="<?php echo esc_url(admin_url('admin.php?page=wpi-addons&tab=gateways')); ?>"> |
|
81 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
82 | 82 | </a> |
83 | 83 | </td> |
84 | 84 | </tr> |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,51 +139,51 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | |
162 | 162 | // Gateway checkout fiellds. |
163 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
164 | 164 | |
165 | 165 | // Process payment. |
166 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
167 | 167 | |
168 | 168 | // Change the checkout button text. |
169 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
170 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
169 | + if (!empty($this->checkout_button_text)) { |
|
170 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Check if a gateway is valid for a given currency. |
174 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
175 | 175 | |
176 | 176 | // Generate the transaction url. |
177 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
178 | 178 | |
179 | 179 | // Generate the subscription url. |
180 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
181 | 181 | |
182 | 182 | // Confirm payments. |
183 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
184 | 184 | |
185 | 185 | // Verify IPNs. |
186 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
187 | 187 | |
188 | 188 | } |
189 | 189 | |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | * @since 1.0.19 |
194 | 194 | * @return bool |
195 | 195 | */ |
196 | - public function is( $gateway ) { |
|
196 | + public function is($gateway) { |
|
197 | 197 | return $gateway == $this->id; |
198 | 198 | } |
199 | 199 | |
@@ -203,24 +203,24 @@ discard block |
||
203 | 203 | * @since 1.0.19 |
204 | 204 | * @return array |
205 | 205 | */ |
206 | - public function get_tokens( $sandbox = null ) { |
|
206 | + public function get_tokens($sandbox = null) { |
|
207 | 207 | |
208 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
209 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
208 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
209 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
210 | 210 | |
211 | - if ( is_array( $tokens ) ) { |
|
211 | + if (is_array($tokens)) { |
|
212 | 212 | $this->tokens = $tokens; |
213 | 213 | } |
214 | 214 | |
215 | 215 | } |
216 | 216 | |
217 | - if ( ! is_bool( $sandbox ) ) { |
|
217 | + if (!is_bool($sandbox)) { |
|
218 | 218 | return $this->tokens; |
219 | 219 | } |
220 | 220 | |
221 | 221 | // Filter tokens. |
222 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
223 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
223 | + return wp_list_filter($this->tokens, $args); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,12 +229,12 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @since 1.0.19 |
231 | 231 | */ |
232 | - public function save_token( $token ) { |
|
232 | + public function save_token($token) { |
|
233 | 233 | |
234 | 234 | $tokens = $this->get_tokens(); |
235 | 235 | $tokens[] = $token; |
236 | 236 | |
237 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
237 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
238 | 238 | |
239 | 239 | $this->tokens = $tokens; |
240 | 240 | |
@@ -246,7 +246,7 @@ discard block |
||
246 | 246 | * @return string |
247 | 247 | */ |
248 | 248 | public function get_method_title() { |
249 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
249 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
@@ -255,7 +255,7 @@ discard block |
||
255 | 255 | * @return string |
256 | 256 | */ |
257 | 257 | public function get_method_description() { |
258 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
258 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | * @param WPInv_Invoice $invoice Invoice object. |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function get_return_url( $invoice ) { |
|
267 | + public function get_return_url($invoice) { |
|
268 | 268 | |
269 | 269 | // Payment success url |
270 | 270 | $return_url = add_query_arg( |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | wpinv_get_success_page_uri() |
277 | 277 | ); |
278 | 278 | |
279 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
279 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -285,24 +285,24 @@ discard block |
||
285 | 285 | * @param string $content Success page content. |
286 | 286 | * @return string |
287 | 287 | */ |
288 | - public function confirm_payment( $content ) { |
|
288 | + public function confirm_payment($content) { |
|
289 | 289 | |
290 | 290 | // Retrieve the invoice. |
291 | 291 | $invoice_id = getpaid_get_current_invoice_id(); |
292 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
292 | + $invoice = wpinv_get_invoice($invoice_id); |
|
293 | 293 | |
294 | 294 | // Ensure that it exists and that it is pending payment. |
295 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
295 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
296 | 296 | return $content; |
297 | 297 | } |
298 | 298 | |
299 | 299 | // Can the user view this invoice?? |
300 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
300 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
301 | 301 | return $content; |
302 | 302 | } |
303 | 303 | |
304 | 304 | // Show payment processing indicator. |
305 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
305 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | * @param GetPaid_Form_Item[] $items |
320 | 320 | * @return WPInv_Invoice |
321 | 321 | */ |
322 | - public function process_addons( $invoice, $items ) { |
|
322 | + public function process_addons($invoice, $items) { |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | |
@@ -330,14 +330,14 @@ discard block |
||
330 | 330 | * @param WPInv_Invoice $invoice Invoice object. |
331 | 331 | * @return string transaction URL, or empty string. |
332 | 332 | */ |
333 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
333 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
334 | 334 | |
335 | - $transaction_id = $invoice->get_transaction_id(); |
|
335 | + $transaction_id = $invoice->get_transaction_id(); |
|
336 | 336 | |
337 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
338 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
339 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
340 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
337 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
338 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
339 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
340 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
341 | 341 | } |
342 | 342 | |
343 | 343 | return $transaction_url; |
@@ -350,15 +350,15 @@ discard block |
||
350 | 350 | * @param WPInv_Subscription $subscription Subscription objectt. |
351 | 351 | * @return string subscription URL, or empty string. |
352 | 352 | */ |
353 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
353 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
354 | 354 | |
355 | - $profile_id = $subscription->get_profile_id(); |
|
355 | + $profile_id = $subscription->get_profile_id(); |
|
356 | 356 | |
357 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
357 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
358 | 358 | |
359 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
360 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
361 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
359 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
360 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
361 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
362 | 362 | |
363 | 363 | } |
364 | 364 | |
@@ -371,7 +371,7 @@ discard block |
||
371 | 371 | * @return bool |
372 | 372 | */ |
373 | 373 | public function is_available() { |
374 | - return ! empty( $this->enabled ); |
|
374 | + return !empty($this->enabled); |
|
375 | 375 | } |
376 | 376 | |
377 | 377 | /** |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | * @return string |
381 | 381 | */ |
382 | 382 | public function get_title() { |
383 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
383 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | /** |
@@ -389,7 +389,7 @@ discard block |
||
389 | 389 | * @return string |
390 | 390 | */ |
391 | 391 | public function get_description() { |
392 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
392 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | /** |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
402 | 402 | * @return void |
403 | 403 | */ |
404 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
404 | + public function process_payment($invoice, $submission_data, $submission) { |
|
405 | 405 | // Process the payment then either redirect to the success page or the gateway. |
406 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
406 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -417,8 +417,8 @@ discard block |
||
417 | 417 | * @param string $reason Refund reason. |
418 | 418 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
419 | 419 | */ |
420 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
421 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
421 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param int $invoice_id 0 or invoice id. |
428 | 428 | * @param GetPaid_Payment_Form $form Current payment form. |
429 | 429 | */ |
430 | - public function payment_fields( $invoice_id, $form ) { |
|
431 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + public function payment_fields($invoice_id, $form) { |
|
431 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -436,7 +436,7 @@ discard block |
||
436 | 436 | * |
437 | 437 | * @param array $admin_settings |
438 | 438 | */ |
439 | - public function admin_settings( $admin_settings ) { |
|
439 | + public function admin_settings($admin_settings) { |
|
440 | 440 | return $admin_settings; |
441 | 441 | } |
442 | 442 | |
@@ -445,8 +445,8 @@ discard block |
||
445 | 445 | * |
446 | 446 | * @param string $option |
447 | 447 | */ |
448 | - public function get_option( $option, $default = false ) { |
|
449 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + public function get_option($option, $default = false) { |
|
449 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -459,8 +459,8 @@ discard block |
||
459 | 459 | * @return bool True if the gateway supports the feature, false otherwise. |
460 | 460 | * @since 1.0.19 |
461 | 461 | */ |
462 | - public function supports( $feature ) { |
|
463 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + public function supports($feature) { |
|
463 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -468,36 +468,36 @@ discard block |
||
468 | 468 | * |
469 | 469 | * @param bool $save whether or not to display the save button. |
470 | 470 | */ |
471 | - public function get_cc_form( $save = false ) { |
|
471 | + public function get_cc_form($save = false) { |
|
472 | 472 | |
473 | 473 | ob_start(); |
474 | 474 | |
475 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
475 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
476 | 476 | |
477 | 477 | $months = array( |
478 | - '01' => __( 'January', 'invoicing' ), |
|
479 | - '02' => __( 'February', 'invoicing' ), |
|
480 | - '03' => __( 'March', 'invoicing' ), |
|
481 | - '04' => __( 'April', 'invoicing' ), |
|
482 | - '05' => __( 'May', 'invoicing' ), |
|
483 | - '06' => __( 'June', 'invoicing' ), |
|
484 | - '07' => __( 'July', 'invoicing' ), |
|
485 | - '08' => __( 'August', 'invoicing' ), |
|
486 | - '09' => __( 'September', 'invoicing' ), |
|
487 | - '10' => __( 'October', 'invoicing' ), |
|
488 | - '11' => __( 'November', 'invoicing' ), |
|
489 | - '12' => __( 'December', 'invoicing' ), |
|
478 | + '01' => __('January', 'invoicing'), |
|
479 | + '02' => __('February', 'invoicing'), |
|
480 | + '03' => __('March', 'invoicing'), |
|
481 | + '04' => __('April', 'invoicing'), |
|
482 | + '05' => __('May', 'invoicing'), |
|
483 | + '06' => __('June', 'invoicing'), |
|
484 | + '07' => __('July', 'invoicing'), |
|
485 | + '08' => __('August', 'invoicing'), |
|
486 | + '09' => __('September', 'invoicing'), |
|
487 | + '10' => __('October', 'invoicing'), |
|
488 | + '11' => __('November', 'invoicing'), |
|
489 | + '12' => __('December', 'invoicing'), |
|
490 | 490 | ); |
491 | 491 | |
492 | - $year = (int) date( 'Y', current_time( 'timestamp' ) ); |
|
492 | + $year = (int) date('Y', current_time('timestamp')); |
|
493 | 493 | $years = array(); |
494 | 494 | |
495 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
496 | - $years[ $year + $i ] = $year + $i; |
|
495 | + for ($i = 0; $i <= 10; $i++) { |
|
496 | + $years[$year + $i] = $year + $i; |
|
497 | 497 | } |
498 | 498 | |
499 | 499 | ?> |
500 | - <div class="<?php echo esc_attr( $this->id );?>-cc-form getpaid-cc-form mt-1"> |
|
500 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
501 | 501 | |
502 | 502 | |
503 | 503 | <div class="getpaid-cc-card-inner"> |
@@ -506,14 +506,14 @@ discard block |
||
506 | 506 | <div class="col-12"> |
507 | 507 | |
508 | 508 | <div class="form-group"> |
509 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>"><?php _e( 'Card number', 'invoicing' ); ?></label> |
|
509 | + <label for="<?php echo esc_attr("$id_prefix-cc-number") ?>"><?php _e('Card number', 'invoicing'); ?></label> |
|
510 | 510 | <div class="input-group input-group-sm"> |
511 | 511 | <div class="input-group-prepend "> |
512 | 512 | <span class="input-group-text"> |
513 | 513 | <i class="fa fa-credit-card"></i> |
514 | 514 | </span> |
515 | 515 | </div> |
516 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ) ?>authorizenet[cc_number]" id="<?php echo esc_attr( "$id_prefix-cc-number" ) ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
516 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]') ?>authorizenet[cc_number]" id="<?php echo esc_attr("$id_prefix-cc-number") ?>" class="form-control form-control-sm" autocomplete="cc-number"> |
|
517 | 517 | </div> |
518 | 518 | </div> |
519 | 519 | |
@@ -521,17 +521,17 @@ discard block |
||
521 | 521 | |
522 | 522 | <div class="col-12"> |
523 | 523 | <div class="form-group"> |
524 | - <label><?php _e( 'Expiration', 'invoicing' ); ?></label> |
|
524 | + <label><?php _e('Expiration', 'invoicing'); ?></label> |
|
525 | 525 | <div class="form-row"> |
526 | 526 | |
527 | 527 | <div class="col"> |
528 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id );?>[cc_expire_month]"> |
|
529 | - <option disabled selected="selected"><?php _e( 'MM', 'invoicing' ); ?></option> |
|
528 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
529 | + <option disabled selected="selected"><?php _e('MM', 'invoicing'); ?></option> |
|
530 | 530 | |
531 | 531 | <?php |
532 | - foreach ( $months as $key => $month ) { |
|
533 | - $key = esc_attr( $key ); |
|
534 | - $month = wpinv_clean( $month ); |
|
532 | + foreach ($months as $key => $month) { |
|
533 | + $key = esc_attr($key); |
|
534 | + $month = wpinv_clean($month); |
|
535 | 535 | echo "<option value='$key'>$month</option>" . PHP_EOL; |
536 | 536 | } |
537 | 537 | ?> |
@@ -540,13 +540,13 @@ discard block |
||
540 | 540 | </div> |
541 | 541 | |
542 | 542 | <div class="col"> |
543 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id );?>[cc_expire_year]"> |
|
544 | - <option disabled selected="selected"><?php _e( 'YY', 'invoicing' ); ?></option> |
|
543 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
544 | + <option disabled selected="selected"><?php _e('YY', 'invoicing'); ?></option> |
|
545 | 545 | |
546 | 546 | <?php |
547 | - foreach ( $years as $key => $year ) { |
|
548 | - $key = esc_attr( $key ); |
|
549 | - $year = wpinv_clean( $year ); |
|
547 | + foreach ($years as $key => $year) { |
|
548 | + $key = esc_attr($key); |
|
549 | + $year = wpinv_clean($year); |
|
550 | 550 | echo "<option value='$key'>$year</option>" . PHP_EOL; |
551 | 551 | } |
552 | 552 | ?> |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | array( |
565 | 565 | 'name' => $this->id . '[cc_cvv2]', |
566 | 566 | 'id' => "$id_prefix-cc-cvv2", |
567 | - 'label' => __( 'CCV', 'invoicing' ), |
|
567 | + 'label' => __('CCV', 'invoicing'), |
|
568 | 568 | 'label_type' => 'vertical', |
569 | 569 | 'class' => 'form-control-sm', |
570 | 570 | 'extra_attributes' => array( |
@@ -579,7 +579,7 @@ discard block |
||
579 | 579 | |
580 | 580 | <?php |
581 | 581 | |
582 | - if ( $save ) { |
|
582 | + if ($save) { |
|
583 | 583 | echo $this->save_payment_method_checkbox(); |
584 | 584 | } |
585 | 585 | |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * |
599 | 599 | * @since 1.0.19 |
600 | 600 | */ |
601 | - public function new_payment_method_entry( $form ) { |
|
601 | + public function new_payment_method_entry($form) { |
|
602 | 602 | echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>"; |
603 | 603 | } |
604 | 604 | |
@@ -608,16 +608,16 @@ discard block |
||
608 | 608 | * @since 1.0.19 |
609 | 609 | */ |
610 | 610 | public function saved_payment_methods() { |
611 | - $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
611 | + $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
612 | 612 | |
613 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
614 | - $html .= $this->get_saved_payment_method_option_html( $token ); |
|
613 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
614 | + $html .= $this->get_saved_payment_method_option_html($token); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | $html .= $this->get_new_payment_method_option_html(); |
618 | 618 | $html .= '</ul>'; |
619 | 619 | |
620 | - echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this ); |
|
620 | + echo apply_filters('getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this); |
|
621 | 621 | } |
622 | 622 | |
623 | 623 | /** |
@@ -627,7 +627,7 @@ discard block |
||
627 | 627 | * @param array $token Payment Token. |
628 | 628 | * @return string Generated payment method HTML |
629 | 629 | */ |
630 | - public function get_saved_payment_method_option_html( $token ) { |
|
630 | + public function get_saved_payment_method_option_html($token) { |
|
631 | 631 | |
632 | 632 | return sprintf( |
633 | 633 | '<li class="getpaid-payment-method form-group"> |
@@ -636,11 +636,11 @@ discard block |
||
636 | 636 | <span>%3$s</span> |
637 | 637 | </label> |
638 | 638 | </li>', |
639 | - esc_attr( $this->id ), |
|
640 | - esc_attr( $token['id'] ), |
|
641 | - esc_html( $token['name'] ), |
|
642 | - checked( empty( $token['default'] ), false, false ), |
|
643 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
639 | + esc_attr($this->id), |
|
640 | + esc_attr($token['id']), |
|
641 | + esc_html($token['name']), |
|
642 | + checked(empty($token['default']), false, false), |
|
643 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
644 | 644 | ); |
645 | 645 | |
646 | 646 | } |
@@ -652,7 +652,7 @@ discard block |
||
652 | 652 | */ |
653 | 653 | public function get_new_payment_method_option_html() { |
654 | 654 | |
655 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
655 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
656 | 656 | |
657 | 657 | return sprintf( |
658 | 658 | '<li class="getpaid-new-payment-method"> |
@@ -661,8 +661,8 @@ discard block |
||
661 | 661 | <span>%2$s</span> |
662 | 662 | </label> |
663 | 663 | </li>', |
664 | - esc_attr( $this->id ), |
|
665 | - esc_html( $label ) |
|
664 | + esc_attr($this->id), |
|
665 | + esc_html($label) |
|
666 | 666 | ); |
667 | 667 | |
668 | 668 | } |
@@ -677,10 +677,10 @@ discard block |
||
677 | 677 | return aui()->input( |
678 | 678 | array( |
679 | 679 | 'type' => 'checkbox', |
680 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
681 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
680 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
681 | + 'id' => esc_attr(uniqid($this->id)), |
|
682 | 682 | 'required' => false, |
683 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
683 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
684 | 684 | 'value' => 'true', |
685 | 685 | 'checked' => true, |
686 | 686 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -694,9 +694,9 @@ discard block |
||
694 | 694 | * |
695 | 695 | * @return array |
696 | 696 | */ |
697 | - public function register_gateway( $gateways ) { |
|
697 | + public function register_gateway($gateways) { |
|
698 | 698 | |
699 | - $gateways[ $this->id ] = array( |
|
699 | + $gateways[$this->id] = array( |
|
700 | 700 | |
701 | 701 | 'admin_label' => $this->method_title, |
702 | 702 | 'checkout_label' => $this->title, |
@@ -714,13 +714,13 @@ discard block |
||
714 | 714 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
715 | 715 | * @return bool |
716 | 716 | */ |
717 | - public function is_sandbox( $invoice = null ) { |
|
717 | + public function is_sandbox($invoice = null) { |
|
718 | 718 | |
719 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
719 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
720 | 720 | return $invoice->get_mode() == 'test'; |
721 | 721 | } |
722 | 722 | |
723 | - return wpinv_is_test_mode( $this->id ); |
|
723 | + return wpinv_is_test_mode($this->id); |
|
724 | 724 | |
725 | 725 | } |
726 | 726 | |
@@ -738,15 +738,15 @@ discard block |
||
738 | 738 | * |
739 | 739 | * @return bool |
740 | 740 | */ |
741 | - public function validate_currency( $validation, $currency ) { |
|
741 | + public function validate_currency($validation, $currency) { |
|
742 | 742 | |
743 | 743 | // Required currencies. |
744 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
744 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
745 | 745 | return false; |
746 | 746 | } |
747 | 747 | |
748 | 748 | // Excluded currencies. |
749 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
749 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
750 | 750 | return false; |
751 | 751 | } |
752 | 752 | |
@@ -757,13 +757,13 @@ discard block |
||
757 | 757 | * Displays an error |
758 | 758 | * |
759 | 759 | */ |
760 | - public function show_error( $code, $message, $type ) { |
|
760 | + public function show_error($code, $message, $type) { |
|
761 | 761 | |
762 | - if ( is_admin() ) { |
|
763 | - getpaid_admin()->{"show_$type"}( $message ); |
|
762 | + if (is_admin()) { |
|
763 | + getpaid_admin()->{"show_$type"}($message); |
|
764 | 764 | } |
765 | 765 | |
766 | - wpinv_set_error( $code, $message, $type ); |
|
766 | + wpinv_set_error($code, $message, $type); |
|
767 | 767 | |
768 | 768 | } |
769 | 769 |
@@ -10,66 +10,66 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_line_item', $invoice, $item ); ?> |
|
17 | +<?php do_action('getpaid_before_email_line_item', $invoice, $item); ?> |
|
18 | 18 | |
19 | -<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class( $item->get_type() ); ?>"> |
|
19 | +<tr class="wpinv_cart_item item-type-<?php echo sanitize_html_class($item->get_type()); ?>"> |
|
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_email_line_item_before_$column", $item, $invoice ); |
|
28 | + do_action("getpaid_email_line_item_before_$column", $item, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<p class='small'>$description</p>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Item price. |
47 | - if ( 'price' == $column ) { |
|
47 | + if ('price' == $column) { |
|
48 | 48 | |
49 | 49 | // Display the item price (or recurring price if this is a renewal invoice) |
50 | 50 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
51 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
51 | + echo wpinv_price($price, $invoice->get_currency()); |
|
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo (float) $item->get_quantity(); |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Tax rate. |
61 | - if ( 'tax_rate' == $column ) { |
|
62 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
61 | + if ('tax_rate' == $column) { |
|
62 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
68 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
68 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Fires when printing a line item column. |
72 | - do_action( "getpaid_email_line_item_$column", $item, $invoice ); |
|
72 | + do_action("getpaid_email_line_item_$column", $item, $invoice); |
|
73 | 73 | |
74 | 74 | ?> |
75 | 75 | |
@@ -79,4 +79,4 @@ discard block |
||
79 | 79 | |
80 | 80 | </tr> |
81 | 81 | |
82 | -<?php do_action( 'getpaid_after_email_line_item', $invoice, $item ); ?> |
|
82 | +<?php do_action('getpaid_after_email_line_item', $invoice, $item); ?> |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | -do_action( 'getpaid_before_invoice_line_item', $invoice, $item ); |
|
15 | +do_action('getpaid_before_invoice_line_item', $invoice, $item); |
|
16 | 16 | |
17 | 17 | ?> |
18 | 18 | |
19 | -<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class( $item->get_type() ); ?> border-bottom'> |
|
19 | +<div class='getpaid-invoice-item item-<?php echo (int) $item->get_id(); ?> item-type-<?php echo sanitize_html_class($item->get_type()); ?> border-bottom'> |
|
20 | 20 | |
21 | 21 | <div class="form-row"> |
22 | 22 | |
23 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
23 | + <?php foreach (array_keys($columns) as $column): ?> |
|
24 | 24 | |
25 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
25 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
26 | 26 | |
27 | 27 | <?php |
28 | 28 | |
29 | 29 | // Fires before printing a line item column. |
30 | - do_action( "getpaid_invoice_line_item_before_$column", $item, $invoice ); |
|
30 | + do_action("getpaid_invoice_line_item_before_$column", $item, $invoice); |
|
31 | 31 | |
32 | 32 | // Item name. |
33 | - if ( 'name' == $column ) { |
|
33 | + if ('name' == $column) { |
|
34 | 34 | |
35 | 35 | // Display the name. |
36 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
36 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
37 | 37 | |
38 | 38 | // And an optional description. |
39 | 39 | $description = $item->get_description(); |
40 | 40 | |
41 | - if ( ! empty( $description ) ) { |
|
42 | - $description = wp_kses_post( $description ); |
|
41 | + if (!empty($description)) { |
|
42 | + $description = wp_kses_post($description); |
|
43 | 43 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // Fires before printing the line item actions. |
47 | - do_action( "getpaid_before_invoice_line_item_actions", $item, $invoice ); |
|
47 | + do_action("getpaid_before_invoice_line_item_actions", $item, $invoice); |
|
48 | 48 | |
49 | - $actions = apply_filters( 'getpaid-invoice-page-line-item-actions', array(), $item, $invoice ); |
|
49 | + $actions = apply_filters('getpaid-invoice-page-line-item-actions', array(), $item, $invoice); |
|
50 | 50 | |
51 | - if ( ! empty( $actions ) ) { |
|
51 | + if (!empty($actions)) { |
|
52 | 52 | |
53 | - $sanitized = array(); |
|
54 | - foreach ( $actions as $key => $action ) { |
|
55 | - $key = sanitize_html_class( $key ); |
|
56 | - $action = wp_kses_post( $action ); |
|
53 | + $sanitized = array(); |
|
54 | + foreach ($actions as $key => $action) { |
|
55 | + $key = sanitize_html_class($key); |
|
56 | + $action = wp_kses_post($action); |
|
57 | 57 | $sanitized[] = "<span class='$key'>$action</span>"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | echo "<small class='form-text getpaid-line-item-actions'>"; |
61 | - echo implode( ' | ', $sanitized ); |
|
61 | + echo implode(' | ', $sanitized); |
|
62 | 62 | echo '</small>'; |
63 | 63 | |
64 | 64 | } |
@@ -66,35 +66,35 @@ discard block |
||
66 | 66 | } |
67 | 67 | |
68 | 68 | // Item price. |
69 | - if ( 'price' == $column ) { |
|
69 | + if ('price' == $column) { |
|
70 | 70 | |
71 | 71 | // Display the item price (or recurring price if this is a renewal invoice) |
72 | 72 | $price = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
73 | - echo wpinv_price( $price, $invoice->get_currency() ); |
|
73 | + echo wpinv_price($price, $invoice->get_currency()); |
|
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Tax rate. |
78 | - if ( 'tax_rate' == $column ) { |
|
79 | - echo round( getpaid_get_invoice_tax_rate( $invoice, $item ), 2 ) . '%'; |
|
78 | + if ('tax_rate' == $column) { |
|
79 | + echo round(getpaid_get_invoice_tax_rate($invoice, $item), 2) . '%'; |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | // Item quantity. |
83 | - if ( 'quantity' == $column ) { |
|
83 | + if ('quantity' == $column) { |
|
84 | 84 | echo (float) $item->get_quantity(); |
85 | 85 | } |
86 | 86 | |
87 | 87 | // Item sub total. |
88 | - if ( 'subtotal' == $column ) { |
|
88 | + if ('subtotal' == $column) { |
|
89 | 89 | $subtotal = $invoice->is_renewal() ? $item->get_recurring_sub_total() : $item->get_sub_total(); |
90 | - echo wpinv_price( $subtotal, $invoice->get_currency() ); |
|
90 | + echo wpinv_price($subtotal, $invoice->get_currency()); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | // Fires when printing a line item column. |
94 | - do_action( "getpaid_invoice_line_item_$column", $item, $invoice ); |
|
94 | + do_action("getpaid_invoice_line_item_$column", $item, $invoice); |
|
95 | 95 | |
96 | 96 | // Fires after printing a line item column. |
97 | - do_action( "getpaid_invoice_line_item_after_$column", $item, $invoice ); |
|
97 | + do_action("getpaid_invoice_line_item_after_$column", $item, $invoice); |
|
98 | 98 | |
99 | 99 | ?> |
100 | 100 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | // Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity (buy buttons) |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
287 | + if ($item->can_purchase()) { |
|
288 | 288 | |
289 | 289 | $value = (float) $value; |
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
290 | + $item->set_quantity($value); |
|
291 | + if (0 == $value) { |
|
292 | + $item->set_quantity(1); |
|
293 | + $item->set_allow_quantities(true); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Items saved via payment forms editor. |
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
303 | + if (is_array($value) && isset($value['id'])) { |
|
304 | 304 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
305 | + $item = new GetPaid_Form_Item($value['id']); |
|
306 | 306 | |
307 | - if ( ! $item->can_purchase() ) { |
|
307 | + if (!$item->can_purchase()) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Sub-total (Cart items). |
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
312 | + if (isset($value['subtotal'])) { |
|
313 | + $item->set_price($value['subtotal']); |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
316 | + if (isset($value['quantity'])) { |
|
317 | + $item->set_quantity($value['quantity']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
320 | + if (isset($value['allow_quantities'])) { |
|
321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
324 | + if (isset($value['required'])) { |
|
325 | + $item->set_is_required($value['required']); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
328 | + if (isset($value['description'])) { |
|
329 | + $item->set_custom_description($value['description']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
338 | + if (is_numeric($key) && is_array($value)) { |
|
339 | + $item = new GetPaid_Form_Item($key); |
|
340 | 340 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
342 | + $item->set_price($value['price']); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $item->can_purchase() ) { |
|
345 | + if ($item->can_purchase()) { |
|
346 | 346 | $prepared[] = $item; |
347 | 347 | } |
348 | 348 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
354 | + if ('objects' == $return && 'view' == $context) { |
|
355 | 355 | return $prepared; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $items = array(); |
359 | - foreach ( $prepared as $item ) { |
|
359 | + foreach ($prepared as $item) { |
|
360 | 360 | $items[] = $item->prepare_data_for_use(); |
361 | 361 | } |
362 | 362 | |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | * @param int $item_id The item id to return. |
371 | 371 | * @return GetPaid_Form_Item|bool |
372 | 372 | */ |
373 | - public function get_item( $item_id ) { |
|
373 | + public function get_item($item_id) { |
|
374 | 374 | |
375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
375 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
376 | 376 | return false; |
377 | 377 | } |
378 | 378 | |
379 | - foreach( $this->get_items() as $item ) { |
|
380 | - if ( $item->get_id() == (int) $item_id ) { |
|
379 | + foreach ($this->get_items() as $item) { |
|
380 | + if ($item->get_id() == (int) $item_id) { |
|
381 | 381 | return $item; |
382 | 382 | } |
383 | 383 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | * @param string $element_type The element type to return. |
394 | 394 | * @return array|bool |
395 | 395 | */ |
396 | - public function get_element_type( $element_type ) { |
|
396 | + public function get_element_type($element_type) { |
|
397 | 397 | |
398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
398 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
399 | 399 | return false; |
400 | 400 | } |
401 | 401 | |
402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
402 | + foreach ($this->get_prop('elements') as $element) { |
|
403 | 403 | |
404 | - if ( $element['type'] == $element_type ) { |
|
404 | + if ($element['type'] == $element_type) { |
|
405 | 405 | return $element; |
406 | 406 | } |
407 | 407 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $context View or edit context. |
419 | 419 | * @return float |
420 | 420 | */ |
421 | - public function get_earned( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'earned', $context ); |
|
421 | + public function get_earned($context = 'view') { |
|
422 | + return $this->get_prop('earned', $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $context View or edit context. |
430 | 430 | * @return float |
431 | 431 | */ |
432 | - public function get_refunded( $context = 'view' ) { |
|
433 | - return $this->get_prop( 'refunded', $context ); |
|
432 | + public function get_refunded($context = 'view') { |
|
433 | + return $this->get_prop('refunded', $context); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $context View or edit context. |
441 | 441 | * @return float |
442 | 442 | */ |
443 | - public function get_cancelled( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'cancelled', $context ); |
|
443 | + public function get_cancelled($context = 'view') { |
|
444 | + return $this->get_prop('cancelled', $context); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return float |
453 | 453 | */ |
454 | - public function get_failed( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'failed', $context ); |
|
454 | + public function get_failed($context = 'view') { |
|
455 | + return $this->get_prop('failed', $context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @return string |
464 | 464 | */ |
465 | 465 | public function get_currency() { |
466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
466 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /* |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @since 1.0.19 |
484 | 484 | */ |
485 | - public function set_version( $value ) { |
|
486 | - $this->set_prop( 'version', $value ); |
|
485 | + public function set_version($value) { |
|
486 | + $this->set_prop('version', $value); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @param string $value Value to set. |
494 | 494 | * @return bool Whether or not the date was set. |
495 | 495 | */ |
496 | - public function set_date_created( $value ) { |
|
497 | - $date = strtotime( $value ); |
|
496 | + public function set_date_created($value) { |
|
497 | + $date = strtotime($value); |
|
498 | 498 | |
499 | - if ( $date ) { |
|
500 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
499 | + if ($date) { |
|
500 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
501 | 501 | return true; |
502 | 502 | } |
503 | 503 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @param string $value Value to set. |
513 | 513 | * @return bool Whether or not the date was set. |
514 | 514 | */ |
515 | - public function set_date_modified( $value ) { |
|
516 | - $date = strtotime( $value ); |
|
515 | + public function set_date_modified($value) { |
|
516 | + $date = strtotime($value); |
|
517 | 517 | |
518 | - if ( $date ) { |
|
519 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
518 | + if ($date) { |
|
519 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
520 | 520 | return true; |
521 | 521 | } |
522 | 522 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @since 1.0.19 |
531 | 531 | * @param string $value New name. |
532 | 532 | */ |
533 | - public function set_name( $value ) { |
|
534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
533 | + public function set_name($value) { |
|
534 | + $this->set_prop('name', sanitize_text_field($value)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * @since 1.0.19 |
541 | 541 | * @param string $value New name. |
542 | 542 | */ |
543 | - public function set_title( $value ) { |
|
544 | - $this->set_name( $value ); |
|
543 | + public function set_title($value) { |
|
544 | + $this->set_name($value); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @since 1.0.19 |
551 | 551 | * @param int $value New author. |
552 | 552 | */ |
553 | - public function set_author( $value ) { |
|
554 | - $this->set_prop( 'author', (int) $value ); |
|
553 | + public function set_author($value) { |
|
554 | + $this->set_prop('author', (int) $value); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -561,13 +561,13 @@ discard block |
||
561 | 561 | * @sinve 2.3.4 Array values sanitized. |
562 | 562 | * @param array $value Form elements. |
563 | 563 | */ |
564 | - public function set_elements( $value ) { |
|
565 | - if ( is_array( $value ) ) { |
|
564 | + public function set_elements($value) { |
|
565 | + if (is_array($value)) { |
|
566 | 566 | |
567 | 567 | // sanitize |
568 | - $value = $this->sanitize_array_values( $value ); |
|
568 | + $value = $this->sanitize_array_values($value); |
|
569 | 569 | |
570 | - $this->set_prop( 'elements', $value ); |
|
570 | + $this->set_prop('elements', $value); |
|
571 | 571 | } |
572 | 572 | } |
573 | 573 | |
@@ -578,18 +578,18 @@ discard block |
||
578 | 578 | * |
579 | 579 | * @return mixed |
580 | 580 | */ |
581 | - public function sanitize_array_values($value){ |
|
581 | + public function sanitize_array_values($value) { |
|
582 | 582 | |
583 | 583 | // sanitize |
584 | - if(!empty($value )){ |
|
584 | + if (!empty($value)) { |
|
585 | 585 | |
586 | - foreach($value as $key => $val_arr){ |
|
586 | + foreach ($value as $key => $val_arr) { |
|
587 | 587 | |
588 | - if(is_array($val_arr)){ |
|
588 | + if (is_array($val_arr)) { |
|
589 | 589 | // check if we have sub array items. |
590 | 590 | $sub_arr = array(); |
591 | - foreach($val_arr as $key2 => $val2){ |
|
592 | - if(is_array($val2)){ |
|
591 | + foreach ($val_arr as $key2 => $val2) { |
|
592 | + if (is_array($val2)) { |
|
593 | 593 | $sub_arr[$key2] = $this->sanitize_array_values($val2); |
594 | 594 | unset($val_arr[$key][$key2]); |
595 | 595 | } |
@@ -599,14 +599,14 @@ discard block |
||
599 | 599 | $help_text = !empty($val_arr['description']) ? wp_kses_post($val_arr['description']) : ''; |
600 | 600 | |
601 | 601 | // sanitize array elements |
602 | - $value[$key] = array_map( 'sanitize_text_field', $val_arr ); |
|
602 | + $value[$key] = array_map('sanitize_text_field', $val_arr); |
|
603 | 603 | |
604 | 604 | // add back the description if set |
605 | - if(isset($val_arr['description'])){ $value[$key]['description'] = $help_text;} |
|
605 | + if (isset($val_arr['description'])) { $value[$key]['description'] = $help_text; } |
|
606 | 606 | |
607 | 607 | // add back sub array items after its been sanitized. |
608 | - if ( ! empty( $sub_arr ) ) { |
|
609 | - $value[$key] = array_merge($value[$key],$sub_arr); |
|
608 | + if (!empty($sub_arr)) { |
|
609 | + $value[$key] = array_merge($value[$key], $sub_arr); |
|
610 | 610 | } |
611 | 611 | } |
612 | 612 | |
@@ -623,9 +623,9 @@ discard block |
||
623 | 623 | * @since 1.0.19 |
624 | 624 | * @param array $value Form elements. |
625 | 625 | */ |
626 | - public function set_items( $value ) { |
|
627 | - if ( is_array( $value ) ) { |
|
628 | - $this->set_prop( 'items', $value ); |
|
626 | + public function set_items($value) { |
|
627 | + if (is_array($value)) { |
|
628 | + $this->set_prop('items', $value); |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
@@ -635,9 +635,9 @@ discard block |
||
635 | 635 | * @since 1.0.19 |
636 | 636 | * @param float $value Amount earned. |
637 | 637 | */ |
638 | - public function set_earned( $value ) { |
|
639 | - $value = max( (float) $value, 0 ); |
|
640 | - $this->set_prop( 'earned', $value ); |
|
638 | + public function set_earned($value) { |
|
639 | + $value = max((float) $value, 0); |
|
640 | + $this->set_prop('earned', $value); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | /** |
@@ -646,9 +646,9 @@ discard block |
||
646 | 646 | * @since 1.0.19 |
647 | 647 | * @param float $value Amount refunded. |
648 | 648 | */ |
649 | - public function set_refunded( $value ) { |
|
650 | - $value = max( (float) $value, 0 ); |
|
651 | - $this->set_prop( 'refunded', $value ); |
|
649 | + public function set_refunded($value) { |
|
650 | + $value = max((float) $value, 0); |
|
651 | + $this->set_prop('refunded', $value); |
|
652 | 652 | } |
653 | 653 | |
654 | 654 | /** |
@@ -657,9 +657,9 @@ discard block |
||
657 | 657 | * @since 1.0.19 |
658 | 658 | * @param float $value Amount cancelled. |
659 | 659 | */ |
660 | - public function set_cancelled( $value ) { |
|
661 | - $value = max( (float) $value, 0 ); |
|
662 | - $this->set_prop( 'cancelled', $value ); |
|
660 | + public function set_cancelled($value) { |
|
661 | + $value = max((float) $value, 0); |
|
662 | + $this->set_prop('cancelled', $value); |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | /** |
@@ -668,9 +668,9 @@ discard block |
||
668 | 668 | * @since 1.0.19 |
669 | 669 | * @param float $value Amount cancelled. |
670 | 670 | */ |
671 | - public function set_failed( $value ) { |
|
672 | - $value = max( (float) $value, 0 ); |
|
673 | - $this->set_prop( 'failed', $value ); |
|
671 | + public function set_failed($value) { |
|
672 | + $value = max((float) $value, 0); |
|
673 | + $this->set_prop('failed', $value); |
|
674 | 674 | } |
675 | 675 | |
676 | 676 | /** |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | * @deprecated |
680 | 680 | * @return int item id |
681 | 681 | */ |
682 | - public function create( $data = array() ) { |
|
682 | + public function create($data = array()) { |
|
683 | 683 | |
684 | 684 | // Set the properties. |
685 | - if ( is_array( $data ) ) { |
|
686 | - $this->set_props( $data ); |
|
685 | + if (is_array($data)) { |
|
686 | + $this->set_props($data); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | // Save the item. |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | * @deprecated |
698 | 698 | * @return int item id |
699 | 699 | */ |
700 | - public function update( $data = array() ) { |
|
701 | - return $this->create( $data ); |
|
700 | + public function update($data = array()) { |
|
701 | + return $this->create($data); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /* |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | */ |
719 | 719 | public function is_default() { |
720 | 720 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
721 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
721 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
722 | 722 | } |
723 | 723 | |
724 | 724 | /** |
@@ -730,11 +730,11 @@ discard block |
||
730 | 730 | public function is_active() { |
731 | 731 | $is_active = 0 !== (int) $this->get_id(); |
732 | 732 | |
733 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
733 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
734 | 734 | $is_active = false; |
735 | 735 | } |
736 | 736 | |
737 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
737 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
738 | 738 | } |
739 | 739 | |
740 | 740 | /** |
@@ -743,8 +743,8 @@ discard block |
||
743 | 743 | * @since 1.0.19 |
744 | 744 | * @return bool |
745 | 745 | */ |
746 | - public function has_item( $item_id ) { |
|
747 | - return false !== $this->get_item( $item_id ); |
|
746 | + public function has_item($item_id) { |
|
747 | + return false !== $this->get_item($item_id); |
|
748 | 748 | } |
749 | 749 | |
750 | 750 | /** |
@@ -753,8 +753,8 @@ discard block |
||
753 | 753 | * @since 1.0.19 |
754 | 754 | * @return bool |
755 | 755 | */ |
756 | - public function has_element_type( $element_type ) { |
|
757 | - return false !== $this->get_element_type( $element_type ); |
|
756 | + public function has_element_type($element_type) { |
|
757 | + return false !== $this->get_element_type($element_type); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | /** |
@@ -765,13 +765,13 @@ discard block |
||
765 | 765 | */ |
766 | 766 | public function is_recurring() { |
767 | 767 | |
768 | - if ( ! empty( $this->invoice ) ) { |
|
768 | + if (!empty($this->invoice)) { |
|
769 | 769 | return $this->invoice->is_recurring(); |
770 | 770 | } |
771 | 771 | |
772 | - foreach ( $this->get_items() as $item ) { |
|
772 | + foreach ($this->get_items() as $item) { |
|
773 | 773 | |
774 | - if ( $item->is_recurring() ) { |
|
774 | + if ($item->is_recurring()) { |
|
775 | 775 | return true; |
776 | 776 | } |
777 | 777 | |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | * |
786 | 786 | * @since 1.0.19 |
787 | 787 | */ |
788 | - public function get_html( $extra_markup = '' ) { |
|
788 | + public function get_html($extra_markup = '') { |
|
789 | 789 | |
790 | 790 | // Return the HTML. |
791 | 791 | return wpinv_get_template_html( |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | * |
804 | 804 | * @since 1.0.19 |
805 | 805 | */ |
806 | - public function display( $extra_markup = '' ) { |
|
807 | - echo $this->get_html( $extra_markup ); |
|
806 | + public function display($extra_markup = '') { |
|
807 | + echo $this->get_html($extra_markup); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | } |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @var array $fee |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
@@ -19,66 +19,66 @@ discard block |
||
19 | 19 | |
20 | 20 | <div class="form-row"> |
21 | 21 | |
22 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
22 | + <?php foreach (array_keys($columns) as $column): ?> |
|
23 | 23 | |
24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
25 | 25 | |
26 | 26 | <?php |
27 | 27 | |
28 | 28 | // Fires before printing a fee item column. |
29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
30 | 30 | |
31 | 31 | // Item name. |
32 | - if ( 'name' == $column ) { |
|
32 | + if ('name' == $column) { |
|
33 | 33 | |
34 | 34 | // Display the name. |
35 | - echo '<div class="mb-1">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
35 | + echo '<div class="mb-1">' . sanitize_text_field($fee['name']) . '</div>'; |
|
36 | 36 | |
37 | 37 | // And an optional description. |
38 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
38 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
39 | 39 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
50 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo "—"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Item tax. |
61 | - if ( 'tax_rate' == $column ) { |
|
61 | + if ('tax_rate' == $column) { |
|
62 | 62 | echo "—"; |
63 | 63 | } |
64 | 64 | |
65 | 65 | // Item sub total. |
66 | - if ( 'subtotal' == $column ) { |
|
66 | + if ('subtotal' == $column) { |
|
67 | 67 | |
68 | 68 | // Display the item price (or recurring price if this is a renewal invoice) |
69 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
70 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
69 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
70 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
71 | 71 | } else { |
72 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
72 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | } |
76 | 76 | |
77 | 77 | // Fires when printing a fee item column. |
78 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
78 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
79 | 79 | |
80 | 80 | // Fires after printing a fee item column. |
81 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
81 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
82 | 82 | |
83 | 83 | ?> |
84 | 84 |
@@ -10,68 +10,68 @@ discard block |
||
10 | 10 | * @var array $columns |
11 | 11 | */ |
12 | 12 | |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php do_action( 'getpaid_before_email_fee_item', $invoice, $fee ); ?> |
|
17 | +<?php do_action('getpaid_before_email_fee_item', $invoice, $fee); ?> |
|
18 | 18 | |
19 | 19 | <tr class="wpinv_cart_item item-fee"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
21 | + <?php foreach (array_keys($columns) as $column): ?> |
|
22 | 22 | |
23 | - <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class( $column ); ?>"> |
|
23 | + <td class="<?php echo 'name' == $column ? 'text-left' : 'text-right' ?> wpinv_cart_item_<?php echo sanitize_html_class($column); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a fee item column. |
28 | - do_action( "getpaid_email_fee_item_before_$column", $fee, $invoice ); |
|
28 | + do_action("getpaid_email_fee_item_before_$column", $fee, $invoice); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $column ) { |
|
31 | + if ('name' == $column) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
34 | + echo '<div class="wpinv_email_cart_item_title">' . sanitize_text_field($fee['name']) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | - $description = empty( $fee['description'] ) ? esc_html__( 'Fee', 'invoicing' ) : esc_html( $fee['description'] ); |
|
37 | + $description = empty($fee['description']) ? esc_html__('Fee', 'invoicing') : esc_html($fee['description']); |
|
38 | 38 | echo "<p class='small'>$description</p>"; |
39 | 39 | |
40 | 40 | } |
41 | 41 | |
42 | 42 | // Item price. |
43 | - if ( 'price' == $column ) { |
|
43 | + if ('price' == $column) { |
|
44 | 44 | |
45 | 45 | // Display the item price (or recurring price if this is a renewal invoice) |
46 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
47 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
46 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
47 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
48 | 48 | } else { |
49 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
49 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
53 | 53 | |
54 | 54 | // Item quantity. |
55 | - if ( 'quantity' == $column ) { |
|
55 | + if ('quantity' == $column) { |
|
56 | 56 | echo "—"; |
57 | 57 | } |
58 | 58 | |
59 | 59 | // Item tax. |
60 | - if ( 'tax_rate' == $column ) { |
|
60 | + if ('tax_rate' == $column) { |
|
61 | 61 | echo "—"; |
62 | 62 | } |
63 | 63 | |
64 | 64 | // Item sub total. |
65 | - if ( 'subtotal' == $column ) { |
|
66 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
67 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
65 | + if ('subtotal' == $column) { |
|
66 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
67 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
68 | 68 | } else { |
69 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
69 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | 73 | // Fires when printing a line item column. |
74 | - do_action( "getpaid_email_fee_item_$column", $fee, $invoice ); |
|
74 | + do_action("getpaid_email_fee_item_$column", $fee, $invoice); |
|
75 | 75 | |
76 | 76 | ?> |
77 | 77 | |
@@ -81,4 +81,4 @@ discard block |
||
81 | 81 | |
82 | 82 | </tr> |
83 | 83 | |
84 | -<?php do_action( 'getpaid_after_email_fee_item', $invoice, $fee ); ?> |
|
84 | +<?php do_action('getpaid_after_email_fee_item', $invoice, $fee); ?> |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Contains gateway functions. |
4 | 4 | * |
5 | 5 | */ |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * Returns an array of payment gateways. |
@@ -11,30 +11,30 @@ discard block |
||
11 | 11 | * @return array |
12 | 12 | */ |
13 | 13 | function wpinv_get_payment_gateways() { |
14 | - return apply_filters( 'wpinv_payment_gateways', array() ); |
|
14 | + return apply_filters('wpinv_payment_gateways', array()); |
|
15 | 15 | } |
16 | 16 | |
17 | -function wpinv_payment_gateway_titles( $all_gateways ) { |
|
17 | +function wpinv_payment_gateway_titles($all_gateways) { |
|
18 | 18 | |
19 | 19 | $options = wpinv_get_options(); |
20 | 20 | $gateways = array(); |
21 | - foreach ( $all_gateways as $key => $gateway ) { |
|
22 | - if ( !empty( $options[$key . '_title'] ) ) { |
|
23 | - $all_gateways[$key]['checkout_label'] = __( $options[$key . '_title'], 'invoicing' ); |
|
21 | + foreach ($all_gateways as $key => $gateway) { |
|
22 | + if (!empty($options[$key . '_title'])) { |
|
23 | + $all_gateways[$key]['checkout_label'] = __($options[$key . '_title'], 'invoicing'); |
|
24 | 24 | } |
25 | 25 | |
26 | - $gateways[$key] = isset( $options[$key . '_ordering'] ) ? $options[$key . '_ordering'] : ( isset( $gateway['ordering'] ) ? $gateway['ordering'] : '' ); |
|
26 | + $gateways[$key] = isset($options[$key . '_ordering']) ? $options[$key . '_ordering'] : (isset($gateway['ordering']) ? $gateway['ordering'] : ''); |
|
27 | 27 | } |
28 | 28 | |
29 | - asort( $gateways ); |
|
29 | + asort($gateways); |
|
30 | 30 | |
31 | - foreach ( $gateways as $gateway => $key ) { |
|
31 | + foreach ($gateways as $gateway => $key) { |
|
32 | 32 | $gateways[$gateway] = $all_gateways[$gateway]; |
33 | 33 | } |
34 | 34 | |
35 | 35 | return $gateways; |
36 | 36 | } |
37 | -add_filter( 'wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1 ); |
|
37 | +add_filter('wpinv_payment_gateways', 'wpinv_payment_gateway_titles', 1000, 1); |
|
38 | 38 | |
39 | 39 | /** |
40 | 40 | * Returns an array of enabled gateways. |
@@ -42,38 +42,38 @@ discard block |
||
42 | 42 | * @param bool $sort |
43 | 43 | * @return array |
44 | 44 | */ |
45 | -function wpinv_get_enabled_payment_gateways( $sort = false ) { |
|
45 | +function wpinv_get_enabled_payment_gateways($sort = false) { |
|
46 | 46 | |
47 | 47 | $enabled = array(); |
48 | 48 | |
49 | - foreach ( wpinv_get_payment_gateways() as $gateway => $data ) { |
|
49 | + foreach (wpinv_get_payment_gateways() as $gateway => $data) { |
|
50 | 50 | |
51 | - if ( (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ) { |
|
52 | - $enabled[ $gateway ] = $data; |
|
51 | + if ((int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1) { |
|
52 | + $enabled[$gateway] = $data; |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | } |
56 | 56 | |
57 | - if ( true === $sort ) { |
|
58 | - uasort( $enabled, 'wpinv_sort_gateway_order' ); |
|
57 | + if (true === $sort) { |
|
58 | + uasort($enabled, 'wpinv_sort_gateway_order'); |
|
59 | 59 | |
60 | 60 | // Reorder our gateways so the default is first |
61 | 61 | $default_gateway_id = wpinv_get_default_gateway(); |
62 | - if ( isset( $enabled[ $default_gateway_id ] ) ) { |
|
62 | + if (isset($enabled[$default_gateway_id])) { |
|
63 | 63 | $default_gateway = array( |
64 | - $default_gateway_id => $enabled[ $default_gateway_id ] |
|
64 | + $default_gateway_id => $enabled[$default_gateway_id] |
|
65 | 65 | ); |
66 | 66 | |
67 | - unset( $enabled[ $default_gateway_id ] ); |
|
68 | - $enabled = array_merge( $default_gateway, $enabled ); |
|
67 | + unset($enabled[$default_gateway_id]); |
|
68 | + $enabled = array_merge($default_gateway, $enabled); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | } |
72 | 72 | |
73 | - return apply_filters( 'wpinv_enabled_payment_gateways', $enabled ); |
|
73 | + return apply_filters('wpinv_enabled_payment_gateways', $enabled); |
|
74 | 74 | } |
75 | 75 | |
76 | -function wpinv_sort_gateway_order( $a, $b ) { |
|
76 | +function wpinv_sort_gateway_order($a, $b) { |
|
77 | 77 | return $a['ordering'] - $b['ordering']; |
78 | 78 | } |
79 | 79 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param string $gateway |
84 | 84 | * @return bool |
85 | 85 | */ |
86 | -function wpinv_is_gateway_active( $gateway ) { |
|
87 | - $is_active = (int) wpinv_get_option( "{$gateway}_active", $gateway === 'manual' ) === 1 ; |
|
88 | - return apply_filters( 'wpinv_is_gateway_active', $is_active, $gateway ); |
|
86 | +function wpinv_is_gateway_active($gateway) { |
|
87 | + $is_active = (int) wpinv_get_option("{$gateway}_active", $gateway === 'manual') === 1; |
|
88 | + return apply_filters('wpinv_is_gateway_active', $is_active, $gateway); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | * @return string|false |
95 | 95 | */ |
96 | 96 | function wpinv_get_default_gateway() { |
97 | - $default = wpinv_get_option( 'default_gateway' ); |
|
97 | + $default = wpinv_get_option('default_gateway'); |
|
98 | 98 | $gateways = wpinv_get_enabled_payment_gateways(); |
99 | - $default = ! empty( $default ) && isset( $gateways[ $default ] ) ? $default : false; |
|
99 | + $default = !empty($default) && isset($gateways[$default]) ? $default : false; |
|
100 | 100 | |
101 | - return apply_filters( 'wpinv_default_gateway', $default ); |
|
101 | + return apply_filters('wpinv_default_gateway', $default); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,17 +107,17 @@ discard block |
||
107 | 107 | * @param string $gateway The gateway to key. |
108 | 108 | * @return string |
109 | 109 | */ |
110 | -function wpinv_get_gateway_admin_label( $gateway ) { |
|
110 | +function wpinv_get_gateway_admin_label($gateway) { |
|
111 | 111 | |
112 | - if ( empty( $gateway ) || 'none' == $gateway ) { |
|
113 | - return esc_html__( 'No Gateway', 'invoicing' ); |
|
112 | + if (empty($gateway) || 'none' == $gateway) { |
|
113 | + return esc_html__('No Gateway', 'invoicing'); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $gateways = wpinv_get_payment_gateways(); |
117 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['admin_label'] : $gateway; |
|
118 | - $gateway = apply_filters( 'wpinv_gateway_admin_label', $label, $gateway ); |
|
117 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['admin_label'] : $gateway; |
|
118 | + $gateway = apply_filters('wpinv_gateway_admin_label', $label, $gateway); |
|
119 | 119 | |
120 | - return wpinv_clean( $gateway ); |
|
120 | + return wpinv_clean($gateway); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,48 +125,48 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string $gateway |
127 | 127 | */ |
128 | -function wpinv_get_gateway_description( $gateway ) { |
|
128 | +function wpinv_get_gateway_description($gateway) { |
|
129 | 129 | |
130 | 130 | $options = wpinv_get_options(); |
131 | - $description = ! empty( $options[$gateway . '_desc'] ) ? $options[$gateway . '_desc'] : ''; |
|
131 | + $description = !empty($options[$gateway . '_desc']) ? $options[$gateway . '_desc'] : ''; |
|
132 | 132 | |
133 | - return apply_filters( 'wpinv_gateway_description', $description, $gateway ); |
|
133 | + return apply_filters('wpinv_gateway_description', $description, $gateway); |
|
134 | 134 | } |
135 | 135 | |
136 | -function wpinv_get_gateway_button_label( $gateway ) { |
|
137 | - return apply_filters( 'wpinv_gateway_' . $gateway . '_button_label', '' ); |
|
136 | +function wpinv_get_gateway_button_label($gateway) { |
|
137 | + return apply_filters('wpinv_gateway_' . $gateway . '_button_label', ''); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_gateway_checkout_label( $gateway ) { |
|
140 | +function wpinv_get_gateway_checkout_label($gateway) { |
|
141 | 141 | $gateways = wpinv_get_payment_gateways(); |
142 | - $label = isset( $gateways[ $gateway ] ) ? $gateways[ $gateway ]['checkout_label'] : $gateway; |
|
142 | + $label = isset($gateways[$gateway]) ? $gateways[$gateway]['checkout_label'] : $gateway; |
|
143 | 143 | |
144 | - if ( $gateway == 'none' ) { |
|
145 | - $label = __( 'None', 'invoicing' ); |
|
144 | + if ($gateway == 'none') { |
|
145 | + $label = __('None', 'invoicing'); |
|
146 | 146 | } |
147 | 147 | |
148 | - return apply_filters( 'wpinv_gateway_checkout_label', ucfirst( $label ), $gateway ); |
|
148 | + return apply_filters('wpinv_gateway_checkout_label', ucfirst($label), $gateway); |
|
149 | 149 | } |
150 | 150 | |
151 | -function wpinv_settings_sections_gateways( $settings ) { |
|
151 | +function wpinv_settings_sections_gateways($settings) { |
|
152 | 152 | $gateways = wpinv_get_payment_gateways(); |
153 | - ksort( $gateways ); |
|
153 | + ksort($gateways); |
|
154 | 154 | |
155 | - foreach ( $gateways as $key => $gateway ) { |
|
156 | - $settings[ $key ] = $gateway['admin_label']; |
|
155 | + foreach ($gateways as $key => $gateway) { |
|
156 | + $settings[$key] = $gateway['admin_label']; |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | return $settings; |
160 | 160 | } |
161 | -add_filter( 'wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1 ); |
|
161 | +add_filter('wpinv_settings_sections_gateways', 'wpinv_settings_sections_gateways', 10, 1); |
|
162 | 162 | |
163 | 163 | /** |
164 | 164 | * Adds GateWay settings. |
165 | 165 | */ |
166 | -function wpinv_settings_gateways( $settings ) { |
|
166 | +function wpinv_settings_gateways($settings) { |
|
167 | 167 | |
168 | 168 | // Loop through each gateway. |
169 | - foreach ( wpinv_get_payment_gateways() as $key => $gateway ) { |
|
169 | + foreach (wpinv_get_payment_gateways() as $key => $gateway) { |
|
170 | 170 | |
171 | 171 | $gateway_settings = array( |
172 | 172 | |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | "{$key}_header" => array( |
175 | 175 | |
176 | 176 | 'id' => "{$key}_gateway_header", |
177 | - 'name' => '<h3>' . wp_sprintf( __( '%s Settings', 'invoicing' ), $gateway['admin_label'] ) . '</h3>', |
|
177 | + 'name' => '<h3>' . wp_sprintf(__('%s Settings', 'invoicing'), $gateway['admin_label']) . '</h3>', |
|
178 | 178 | 'custom' => $key, |
179 | 179 | 'type' => 'gateway_header', |
180 | 180 | |
@@ -183,8 +183,8 @@ discard block |
||
183 | 183 | // Activate/Deactivate a gateway. |
184 | 184 | "{$key}_active" => array( |
185 | 185 | 'id' => $key . '_active', |
186 | - 'name' => __( 'Activate', 'invoicing' ), |
|
187 | - 'desc' => wp_sprintf( __( 'Enable %s', 'invoicing' ), $gateway['admin_label'] ), |
|
186 | + 'name' => __('Activate', 'invoicing'), |
|
187 | + 'desc' => wp_sprintf(__('Enable %s', 'invoicing'), $gateway['admin_label']), |
|
188 | 188 | 'type' => 'checkbox', |
189 | 189 | 'std' => $key === 'manual' ? '1' : '0', |
190 | 190 | ), |
@@ -192,8 +192,8 @@ discard block |
||
192 | 192 | // Activate/Deactivate sandbox. |
193 | 193 | "{$key}_sandbox" => array( |
194 | 194 | 'id' => $key . '_sandbox', |
195 | - 'name' => __( 'Sandbox', 'invoicing' ), |
|
196 | - 'desc' => __( 'Enable sandbox to test payments', 'invoicing' ), |
|
195 | + 'name' => __('Sandbox', 'invoicing'), |
|
196 | + 'desc' => __('Enable sandbox to test payments', 'invoicing'), |
|
197 | 197 | 'type' => 'checkbox', |
198 | 198 | 'std' => '1', |
199 | 199 | ), |
@@ -201,40 +201,40 @@ discard block |
||
201 | 201 | // Checkout title. |
202 | 202 | "{$key}_title" => array( |
203 | 203 | 'id' => $key . '_title', |
204 | - 'name' => __( 'Checkout Title', 'invoicing' ), |
|
205 | - 'std' => isset( $gateway['checkout_label'] ) ? $gateway['checkout_label'] : '', |
|
204 | + 'name' => __('Checkout Title', 'invoicing'), |
|
205 | + 'std' => isset($gateway['checkout_label']) ? $gateway['checkout_label'] : '', |
|
206 | 206 | 'type' => 'text', |
207 | 207 | ), |
208 | 208 | |
209 | 209 | // Checkout description. |
210 | 210 | "{$key}_desc" => array( |
211 | 211 | 'id' => $key . '_desc', |
212 | - 'name' => __( 'Checkout Description', 'invoicing' ), |
|
213 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
212 | + 'name' => __('Checkout Description', 'invoicing'), |
|
213 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
214 | 214 | 'type' => 'text', |
215 | 215 | ), |
216 | 216 | |
217 | 217 | // Checkout order. |
218 | 218 | "{$key}_ordering" => array( |
219 | 219 | 'id' => $key . '_ordering', |
220 | - 'name' => __( 'Priority', 'invoicing' ), |
|
221 | - 'std' => apply_filters( "getpaid_default_{$key}_checkout_description", '' ), |
|
220 | + 'name' => __('Priority', 'invoicing'), |
|
221 | + 'std' => apply_filters("getpaid_default_{$key}_checkout_description", ''), |
|
222 | 222 | 'type' => 'number', |
223 | 223 | 'step' => '1', |
224 | 224 | 'min' => '0', |
225 | 225 | 'max' => '100000', |
226 | - 'std' => isset( $gateway['ordering'] ) ? $gateway['ordering'] : '10', |
|
226 | + 'std' => isset($gateway['ordering']) ? $gateway['ordering'] : '10', |
|
227 | 227 | ), |
228 | 228 | |
229 | 229 | ); |
230 | 230 | |
231 | 231 | // Maybe remove the sandbox. |
232 | - if ( ! getpaid_payment_gateway_supports( $key, 'sandbox' ) ) { |
|
233 | - unset( $gateway_settings["{$key}_sandbox"] ); |
|
232 | + if (!getpaid_payment_gateway_supports($key, 'sandbox')) { |
|
233 | + unset($gateway_settings["{$key}_sandbox"]); |
|
234 | 234 | } |
235 | 235 | |
236 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings', $gateway_settings, $key, $gateway ); |
|
237 | - $gateway_settings = apply_filters( 'wpinv_gateway_settings_' . $key, $gateway_settings, $gateway ); |
|
236 | + $gateway_settings = apply_filters('wpinv_gateway_settings', $gateway_settings, $key, $gateway); |
|
237 | + $gateway_settings = apply_filters('wpinv_gateway_settings_' . $key, $gateway_settings, $gateway); |
|
238 | 238 | |
239 | 239 | $settings[$key] = $gateway_settings; |
240 | 240 | } |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | return $settings; |
243 | 243 | |
244 | 244 | } |
245 | -add_filter( 'wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1 ); |
|
245 | +add_filter('wpinv_settings_gateways', 'wpinv_settings_gateways', 10, 1); |
|
246 | 246 | |
247 | -function wpinv_gateway_header_callback( $args ) { |
|
248 | - echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr( $args['custom'] ) . '" />'; |
|
247 | +function wpinv_gateway_header_callback($args) { |
|
248 | + echo '<input type="hidden" id="wpinv_settings[save_gateway]" name="wpinv_settings[save_gateway]" value="' . esc_attr($args['custom']) . '" />'; |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -256,61 +256,61 @@ discard block |
||
256 | 256 | * @return bool |
257 | 257 | * @since 2.3.0 |
258 | 258 | */ |
259 | -function getpaid_payment_gateway_supports( $gateway, $feature ) { |
|
259 | +function getpaid_payment_gateway_supports($gateway, $feature) { |
|
260 | 260 | |
261 | 261 | $supports = false; |
262 | 262 | |
263 | - $supports = apply_filters( "getpaid_{$gateway}_supports_{$feature}", false ); |
|
263 | + $supports = apply_filters("getpaid_{$gateway}_supports_{$feature}", false); |
|
264 | 264 | |
265 | 265 | // Backwards compatibility. |
266 | - $supports = apply_filters( "wpinv_{$gateway}_supports_{$feature}", $supports ); |
|
267 | - $supports = apply_filters( "wpinv_{$gateway}_support_{$feature}", $supports ); |
|
266 | + $supports = apply_filters("wpinv_{$gateway}_supports_{$feature}", $supports); |
|
267 | + $supports = apply_filters("wpinv_{$gateway}_support_{$feature}", $supports); |
|
268 | 268 | |
269 | - $supports = apply_filters( "getpaid_gateway_supports_{$feature}", $supports, $gateway ); |
|
270 | - $supports = apply_filters( 'getpaid_payment_gateway_supports', $supports, $feature, $gateway ); |
|
269 | + $supports = apply_filters("getpaid_gateway_supports_{$feature}", $supports, $gateway); |
|
270 | + $supports = apply_filters('getpaid_payment_gateway_supports', $supports, $feature, $gateway); |
|
271 | 271 | |
272 | 272 | return $supports; |
273 | 273 | } |
274 | 274 | |
275 | -function wpinv_get_chosen_gateway( $invoice_id = 0 ) { |
|
276 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
275 | +function wpinv_get_chosen_gateway($invoice_id = 0) { |
|
276 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
277 | 277 | |
278 | 278 | $chosen = false; |
279 | - if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) { |
|
279 | + if ($invoice_id > 0 && $invoice = wpinv_get_invoice($invoice_id)) { |
|
280 | 280 | $chosen = $invoice->get_gateway(); |
281 | 281 | } |
282 | 282 | |
283 | - $chosen = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen; |
|
283 | + $chosen = isset($_REQUEST['payment-mode']) ? sanitize_text_field($_REQUEST['payment-mode']) : $chosen; |
|
284 | 284 | |
285 | - if ( false !== $chosen ) { |
|
286 | - $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen ); |
|
285 | + if (false !== $chosen) { |
|
286 | + $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen); |
|
287 | 287 | } |
288 | 288 | |
289 | - if ( ! empty ( $chosen ) ) { |
|
290 | - $enabled_gateway = urldecode( $chosen ); |
|
291 | - } else if ( !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) { |
|
289 | + if (!empty ($chosen)) { |
|
290 | + $enabled_gateway = urldecode($chosen); |
|
291 | + } else if (!empty($invoice) && (float) $invoice->get_subtotal() <= 0) { |
|
292 | 292 | $enabled_gateway = 'manual'; |
293 | 293 | } else { |
294 | 294 | $enabled_gateway = wpinv_get_default_gateway(); |
295 | 295 | } |
296 | 296 | |
297 | - if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) { |
|
298 | - if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){ |
|
297 | + if (!wpinv_is_gateway_active($enabled_gateway) && !empty($gateways)) { |
|
298 | + if (wpinv_is_gateway_active(wpinv_get_default_gateway())) { |
|
299 | 299 | $enabled_gateway = wpinv_get_default_gateway(); |
300 | - }else{ |
|
300 | + } else { |
|
301 | 301 | $enabled_gateway = $gateways[0]; |
302 | 302 | } |
303 | 303 | |
304 | 304 | } |
305 | 305 | |
306 | - return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway ); |
|
306 | + return apply_filters('wpinv_chosen_gateway', $enabled_gateway); |
|
307 | 307 | } |
308 | 308 | |
309 | -function wpinv_record_gateway_error( $title = '', $message = '' ) { |
|
310 | - return wpinv_error_log( $message, $title ); |
|
309 | +function wpinv_record_gateway_error($title = '', $message = '') { |
|
310 | + return wpinv_error_log($message, $title); |
|
311 | 311 | } |
312 | 312 | |
313 | -function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) { |
|
313 | +function wpinv_count_sales_by_gateway($gateway_id = 'paypal', $status = 'publish') { |
|
314 | 314 | $ret = 0; |
315 | 315 | $args = array( |
316 | 316 | 'meta_key' => '_wpinv_gateway', |
@@ -321,9 +321,9 @@ discard block |
||
321 | 321 | 'fields' => 'ids' |
322 | 322 | ); |
323 | 323 | |
324 | - $payments = new WP_Query( $args ); |
|
324 | + $payments = new WP_Query($args); |
|
325 | 325 | |
326 | - if( $payments ) |
|
326 | + if ($payments) |
|
327 | 327 | $ret = $payments->post_count; |
328 | 328 | return $ret; |
329 | 329 | } |
@@ -331,13 +331,13 @@ discard block |
||
331 | 331 | /** |
332 | 332 | * Displays the ipn url field. |
333 | 333 | */ |
334 | -function wpinv_ipn_url_callback( $args ) { |
|
335 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
334 | +function wpinv_ipn_url_callback($args) { |
|
335 | + $sanitize_id = wpinv_sanitize_key($args['id']); |
|
336 | 336 | |
337 | 337 | $attrs = $args['readonly'] ? ' readonly' : ''; |
338 | 338 | |
339 | - $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr( $args['std'] ) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
340 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
339 | + $html = '<input class="regular-text" type="text" ' . $attrs . ' value="' . esc_attr($args['std']) . '" name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . ']" onClick="this.select()">'; |
|
340 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']">' . $args['desc'] . '</label>'; |
|
341 | 341 | |
342 | 342 | echo $html; |
343 | 343 | } |
@@ -349,10 +349,10 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @return bool |
351 | 351 | */ |
352 | -function wpinv_is_test_mode( $gateway = '' ) { |
|
353 | - $sandbox = empty( $gateway ) ? false : wpinv_get_option( "{$gateway}_sandbox", true ); |
|
354 | - $supports = getpaid_payment_gateway_supports( $gateway, 'sandbox' ); |
|
355 | - return apply_filters( 'wpinv_is_test_mode', $sandbox && $supports, $gateway ); |
|
352 | +function wpinv_is_test_mode($gateway = '') { |
|
353 | + $sandbox = empty($gateway) ? false : wpinv_get_option("{$gateway}_sandbox", true); |
|
354 | + $supports = getpaid_payment_gateway_supports($gateway, 'sandbox'); |
|
355 | + return apply_filters('wpinv_is_test_mode', $sandbox && $supports, $gateway); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | * |
364 | 364 | * @return string |
365 | 365 | */ |
366 | -function wpinv_get_ipn_url( $gateway = false, $args = array() ) { |
|
366 | +function wpinv_get_ipn_url($gateway = false, $args = array()) { |
|
367 | 367 | $args = wp_parse_args( |
368 | 368 | array( |
369 | 369 | 'wpi-listener' => 'IPN', |
@@ -372,7 +372,7 @@ discard block |
||
372 | 372 | $args |
373 | 373 | ); |
374 | 374 | |
375 | - return apply_filters( 'wpinv_ipn_url', add_query_arg( $args, home_url( 'index.php' ) ), $gateway, $args ); |
|
375 | + return apply_filters('wpinv_ipn_url', add_query_arg($args, home_url('index.php')), $gateway, $args); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -383,34 +383,34 @@ discard block |
||
383 | 383 | * |
384 | 384 | * @return string |
385 | 385 | */ |
386 | -function getpaid_get_non_query_string_ipn_url( $gateway ) { |
|
387 | - $gateway = wpinv_sanitize_key( $gateway ); |
|
388 | - return home_url( "getpaid-ipn/$gateway" ); |
|
386 | +function getpaid_get_non_query_string_ipn_url($gateway) { |
|
387 | + $gateway = wpinv_sanitize_key($gateway); |
|
388 | + return home_url("getpaid-ipn/$gateway"); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
392 | 392 | /** |
393 | 393 | * Retrieves request data with slashes removed slashes. |
394 | 394 | */ |
395 | -function wpinv_get_post_data( $method = 'request' ) { |
|
395 | +function wpinv_get_post_data($method = 'request') { |
|
396 | 396 | |
397 | - if ( $method == 'post' ) { |
|
398 | - return wp_unslash( $_POST ); |
|
397 | + if ($method == 'post') { |
|
398 | + return wp_unslash($_POST); |
|
399 | 399 | } |
400 | 400 | |
401 | - if ( $method == 'get' ) { |
|
402 | - return wp_unslash( $_GET ); |
|
401 | + if ($method == 'get') { |
|
402 | + return wp_unslash($_GET); |
|
403 | 403 | } |
404 | 404 | |
405 | - return wp_unslash( $_REQUEST ); |
|
405 | + return wp_unslash($_REQUEST); |
|
406 | 406 | |
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
410 | 410 | * Checks if a given gateway supports subscription payments. |
411 | 411 | */ |
412 | -function wpinv_gateway_support_subscription( $gateway ) { |
|
413 | - return getpaid_payment_gateway_supports( $gateway, 'subscription' ); |
|
412 | +function wpinv_gateway_support_subscription($gateway) { |
|
413 | + return getpaid_payment_gateway_supports($gateway, 'subscription'); |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | /** |
@@ -419,14 +419,14 @@ discard block |
||
419 | 419 | * @param array $gateways an array of gateways. |
420 | 420 | * @param GetPaid_Payment_Form $form payment form. |
421 | 421 | */ |
422 | -function wpinv_payment_gateways_on_cart( $gateways, $form ) { |
|
422 | +function wpinv_payment_gateways_on_cart($gateways, $form) { |
|
423 | 423 | |
424 | - if ( $form->is_recurring() ) { |
|
424 | + if ($form->is_recurring()) { |
|
425 | 425 | |
426 | - foreach ( array_keys( $gateways ) as $gateway ) { |
|
426 | + foreach (array_keys($gateways) as $gateway) { |
|
427 | 427 | |
428 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
429 | - unset( $gateways[$gateway] ); |
|
428 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
429 | + unset($gateways[$gateway]); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | } |
@@ -435,4 +435,4 @@ discard block |
||
435 | 435 | |
436 | 436 | return $gateways; |
437 | 437 | } |
438 | -add_filter( 'getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2 ); |
|
438 | +add_filter('getpaid_payment_form_gateways', 'wpinv_payment_gateways_on_cart', 10, 2); |