@@ -31,36 +31,36 @@ discard block |
||
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | - $can_checkout = true; // Always true for now |
|
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 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | + $page_id = absint( $page_id ); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | + $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | + $ret = $ret ? is_page( $ret ) : false; |
|
63 | + return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | |
85 | 85 | function wpinv_send_to_failed_page( $args = null ) { |
86 | - $redirect = wpinv_get_failed_transaction_uri(); |
|
86 | + $redirect = wpinv_get_failed_transaction_uri(); |
|
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
@@ -103,55 +103,55 @@ discard block |
||
103 | 103 | } |
104 | 104 | |
105 | 105 | function wpinv_get_checkout_uri( $args = array() ) { |
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
106 | + $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | + $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
110 | - // Check for backward compatibility |
|
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
109 | + if ( !empty( $args ) ) { |
|
110 | + // Check for backward compatibility |
|
111 | + if ( is_string( $args ) ) |
|
112 | + $args = str_replace( '?', '', $args ); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args( $args ); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
117 | - } |
|
116 | + $uri = add_query_arg( $args, $uri ); |
|
117 | + } |
|
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | - } |
|
123 | + if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | + $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
125 | + } |
|
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | function wpinv_get_success_page_url( $query_string = null ) { |
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
131 | + $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | + $success_page = get_permalink( $success_page ); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
135 | - $success_page .= $query_string; |
|
134 | + if ( $query_string ) |
|
135 | + $success_page .= $query_string; |
|
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | function wpinv_get_failed_transaction_uri( $extras = false ) { |
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
141 | + $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | + $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
145 | - $uri .= $extras; |
|
144 | + if ( $extras ) |
|
145 | + $uri .= $extras; |
|
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | + $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | function wpinv_transaction_query( $type = 'start' ) { |
@@ -226,36 +226,36 @@ discard block |
||
226 | 226 | $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
227 | 227 | |
228 | 228 | if ( $require_billing_details ) { |
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | - $required_fields['first_name'] = array( |
|
231 | - 'error_id' => 'invalid_first_name', |
|
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | - ); |
|
234 | - } |
|
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | - $required_fields['address'] = array( |
|
237 | - 'error_id' => 'invalid_address', |
|
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | - ); |
|
240 | - } |
|
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | - $required_fields['city'] = array( |
|
243 | - 'error_id' => 'invalid_city', |
|
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | - ); |
|
246 | - } |
|
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | - $required_fields['state'] = array( |
|
249 | - 'error_id' => 'invalid_state', |
|
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | - ); |
|
252 | - } |
|
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | - $required_fields['country'] = array( |
|
255 | - 'error_id' => 'invalid_country', |
|
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | - ); |
|
258 | - } |
|
229 | + if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
230 | + $required_fields['first_name'] = array( |
|
231 | + 'error_id' => 'invalid_first_name', |
|
232 | + 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
233 | + ); |
|
234 | + } |
|
235 | + if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
236 | + $required_fields['address'] = array( |
|
237 | + 'error_id' => 'invalid_address', |
|
238 | + 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
239 | + ); |
|
240 | + } |
|
241 | + if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
242 | + $required_fields['city'] = array( |
|
243 | + 'error_id' => 'invalid_city', |
|
244 | + 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
245 | + ); |
|
246 | + } |
|
247 | + if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
248 | + $required_fields['state'] = array( |
|
249 | + 'error_id' => 'invalid_state', |
|
250 | + 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
251 | + ); |
|
252 | + } |
|
253 | + if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
254 | + $required_fields['country'] = array( |
|
255 | + 'error_id' => 'invalid_country', |
|
256 | + 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
257 | + ); |
|
258 | + } |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
@@ -87,8 +87,9 @@ discard block |
||
87 | 87 | |
88 | 88 | if ( !empty( $args ) ) { |
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if ( is_string( $args ) ) { |
|
91 | + $args = str_replace( '?', '', $args ); |
|
92 | + } |
|
92 | 93 | |
93 | 94 | $args = wp_parse_args( $args ); |
94 | 95 | |
@@ -108,8 +109,9 @@ discard block |
||
108 | 109 | |
109 | 110 | if ( !empty( $args ) ) { |
110 | 111 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
112 | + if ( is_string( $args ) ) { |
|
113 | + $args = str_replace( '?', '', $args ); |
|
114 | + } |
|
113 | 115 | |
114 | 116 | $args = wp_parse_args( $args ); |
115 | 117 | |
@@ -131,8 +133,9 @@ discard block |
||
131 | 133 | $success_page = wpinv_get_option( 'success_page', 0 ); |
132 | 134 | $success_page = get_permalink( $success_page ); |
133 | 135 | |
134 | - if ( $query_string ) |
|
135 | - $success_page .= $query_string; |
|
136 | + if ( $query_string ) { |
|
137 | + $success_page .= $query_string; |
|
138 | + } |
|
136 | 139 | |
137 | 140 | return apply_filters( 'wpinv_success_page_url', $success_page ); |
138 | 141 | } |
@@ -141,8 +144,9 @@ discard block |
||
141 | 144 | $uri = wpinv_get_option( 'failure_page', '' ); |
142 | 145 | $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
143 | 146 | |
144 | - if ( $extras ) |
|
145 | - $uri .= $extras; |
|
147 | + if ( $extras ) { |
|
148 | + $uri .= $extras; |
|
149 | + } |
|
146 | 150 | |
147 | 151 | return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
148 | 152 | } |
@@ -7,172 +7,172 @@ 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 | function wpinv_get_history_page_uri() { |
47 | - $page_id = wpinv_get_option( 'invoice_history_page', 0 ); |
|
48 | - $page_id = absint( $page_id ); |
|
47 | + $page_id = wpinv_get_option('invoice_history_page', 0); |
|
48 | + $page_id = absint($page_id); |
|
49 | 49 | |
50 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) ); |
|
50 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id)); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | function wpinv_is_success_page() { |
54 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
55 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
54 | + $is_success_page = wpinv_get_option('success_page', false); |
|
55 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
56 | 56 | |
57 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
57 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | function wpinv_is_invoice_history_page() { |
61 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
62 | - $ret = $ret ? is_page( $ret ) : false; |
|
63 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
61 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
62 | + $ret = $ret ? is_page($ret) : false; |
|
63 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_subscriptions_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Redirects a user the success page. |
74 | 74 | */ |
75 | -function wpinv_send_to_success_page( $args = array() ) { |
|
75 | +function wpinv_send_to_success_page($args = array()) { |
|
76 | 76 | $redirect = add_query_arg( |
77 | - wp_parse_args( $args ), |
|
77 | + wp_parse_args($args), |
|
78 | 78 | wpinv_get_success_page_uri() |
79 | 79 | ); |
80 | 80 | |
81 | - wp_redirect( $redirect ); |
|
81 | + wp_redirect($redirect); |
|
82 | 82 | exit; |
83 | 83 | } |
84 | 84 | |
85 | -function wpinv_send_to_failed_page( $args = null ) { |
|
85 | +function wpinv_send_to_failed_page($args = null) { |
|
86 | 86 | $redirect = wpinv_get_failed_transaction_uri(); |
87 | 87 | |
88 | - if ( !empty( $args ) ) { |
|
88 | + if (!empty($args)) { |
|
89 | 89 | // Check for backward compatibility |
90 | - if ( is_string( $args ) ) |
|
91 | - $args = str_replace( '?', '', $args ); |
|
90 | + if (is_string($args)) |
|
91 | + $args = str_replace('?', '', $args); |
|
92 | 92 | |
93 | - $args = wp_parse_args( $args ); |
|
93 | + $args = wp_parse_args($args); |
|
94 | 94 | |
95 | - $redirect = add_query_arg( $args, $redirect ); |
|
95 | + $redirect = add_query_arg($args, $redirect); |
|
96 | 96 | } |
97 | 97 | |
98 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
98 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
99 | 99 | |
100 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
101 | - wp_redirect( $redirect ); |
|
100 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
101 | + wp_redirect($redirect); |
|
102 | 102 | exit; |
103 | 103 | } |
104 | 104 | |
105 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
106 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
107 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
105 | +function wpinv_get_checkout_uri($args = array()) { |
|
106 | + $uri = wpinv_get_option('checkout_page', false); |
|
107 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
108 | 108 | |
109 | - if ( !empty( $args ) ) { |
|
109 | + if (!empty($args)) { |
|
110 | 110 | // Check for backward compatibility |
111 | - if ( is_string( $args ) ) |
|
112 | - $args = str_replace( '?', '', $args ); |
|
111 | + if (is_string($args)) |
|
112 | + $args = str_replace('?', '', $args); |
|
113 | 113 | |
114 | - $args = wp_parse_args( $args ); |
|
114 | + $args = wp_parse_args($args); |
|
115 | 115 | |
116 | - $uri = add_query_arg( $args, $uri ); |
|
116 | + $uri = add_query_arg($args, $uri); |
|
117 | 117 | } |
118 | 118 | |
119 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
119 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
120 | 120 | |
121 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
121 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
122 | 122 | |
123 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
124 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
123 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
124 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
125 | 125 | } |
126 | 126 | |
127 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
127 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
128 | 128 | } |
129 | 129 | |
130 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
131 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
132 | - $success_page = get_permalink( $success_page ); |
|
130 | +function wpinv_get_success_page_url($query_string = null) { |
|
131 | + $success_page = wpinv_get_option('success_page', 0); |
|
132 | + $success_page = get_permalink($success_page); |
|
133 | 133 | |
134 | - if ( $query_string ) |
|
134 | + if ($query_string) |
|
135 | 135 | $success_page .= $query_string; |
136 | 136 | |
137 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
137 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
138 | 138 | } |
139 | 139 | |
140 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
141 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
142 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
140 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
141 | + $uri = wpinv_get_option('failure_page', ''); |
|
142 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
143 | 143 | |
144 | - if ( $extras ) |
|
144 | + if ($extras) |
|
145 | 145 | $uri .= $extras; |
146 | 146 | |
147 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
147 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | function wpinv_is_failed_transaction_page() { |
151 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
152 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
151 | + $ret = wpinv_get_option('failure_page', false); |
|
152 | + $ret = isset($ret) ? is_page($ret) : false; |
|
153 | 153 | |
154 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
154 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
155 | 155 | } |
156 | 156 | |
157 | -function wpinv_transaction_query( $type = 'start' ) { |
|
157 | +function wpinv_transaction_query($type = 'start') { |
|
158 | 158 | global $wpdb; |
159 | 159 | |
160 | 160 | $wpdb->hide_errors(); |
161 | 161 | |
162 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
163 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
162 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
163 | + define('WPINV_USE_TRANSACTIONS', true); |
|
164 | 164 | } |
165 | 165 | |
166 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
167 | - switch ( $type ) { |
|
166 | + if (WPINV_USE_TRANSACTIONS) { |
|
167 | + switch ($type) { |
|
168 | 168 | case 'commit' : |
169 | - $wpdb->query( 'COMMIT' ); |
|
169 | + $wpdb->query('COMMIT'); |
|
170 | 170 | break; |
171 | 171 | case 'rollback' : |
172 | - $wpdb->query( 'ROLLBACK' ); |
|
172 | + $wpdb->query('ROLLBACK'); |
|
173 | 173 | break; |
174 | 174 | default : |
175 | - $wpdb->query( 'START TRANSACTION' ); |
|
175 | + $wpdb->query('START TRANSACTION'); |
|
176 | 176 | break; |
177 | 177 | } |
178 | 178 | } |
@@ -181,141 +181,141 @@ discard block |
||
181 | 181 | function wpinv_get_prefix() { |
182 | 182 | $invoice_prefix = 'INV-'; |
183 | 183 | |
184 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
184 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | function wpinv_get_business_logo() { |
188 | - $business_logo = wpinv_get_option( 'logo' ); |
|
189 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
188 | + $business_logo = wpinv_get_option('logo'); |
|
189 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | function wpinv_get_business_name() { |
193 | 193 | $business_name = wpinv_get_option('store_name'); |
194 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
194 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | function wpinv_get_blogname() { |
198 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
198 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_admin_email() { |
202 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
203 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
202 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
203 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function wpinv_get_business_website() { |
207 | - $business_website = home_url( '/' ); |
|
208 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
207 | + $business_website = home_url('/'); |
|
208 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
209 | 209 | } |
210 | 210 | |
211 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
211 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
212 | 212 | $terms_text = ''; |
213 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
213 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | function wpinv_get_business_footer() { |
217 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
218 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
219 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
217 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
218 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
219 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | function wpinv_checkout_required_fields() { |
223 | 223 | $required_fields = array(); |
224 | 224 | |
225 | 225 | // Let payment gateways and other extensions determine if address fields should be required |
226 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
226 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
227 | 227 | |
228 | - if ( $require_billing_details ) { |
|
229 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
228 | + if ($require_billing_details) { |
|
229 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
230 | 230 | $required_fields['first_name'] = array( |
231 | 231 | 'error_id' => 'invalid_first_name', |
232 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
232 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
233 | 233 | ); |
234 | 234 | } |
235 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
235 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
236 | 236 | $required_fields['address'] = array( |
237 | 237 | 'error_id' => 'invalid_address', |
238 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
238 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
239 | 239 | ); |
240 | 240 | } |
241 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
241 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
242 | 242 | $required_fields['city'] = array( |
243 | 243 | 'error_id' => 'invalid_city', |
244 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
244 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
245 | 245 | ); |
246 | 246 | } |
247 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
247 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
248 | 248 | $required_fields['state'] = array( |
249 | 249 | 'error_id' => 'invalid_state', |
250 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
250 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
251 | 251 | ); |
252 | 252 | } |
253 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
253 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
254 | 254 | $required_fields['country'] = array( |
255 | 255 | 'error_id' => 'invalid_country', |
256 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
256 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
257 | 257 | ); |
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
261 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | function wpinv_is_ssl_enforced() { |
265 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
266 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
265 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
266 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | function wpinv_schedule_event_twicedaily() { |
270 | 270 | wpinv_email_payment_reminders(); |
271 | 271 | } |
272 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
272 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
273 | 273 | |
274 | 274 | function wpinv_require_login_to_checkout() { |
275 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
276 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
275 | + $return = wpinv_get_option('login_to_checkout', false); |
|
276 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
277 | 277 | } |
278 | 278 | |
279 | -function wpinv_sequential_number_active( $type = '' ) { |
|
280 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
281 | - if ( null !== $check ) { |
|
279 | +function wpinv_sequential_number_active($type = '') { |
|
280 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
281 | + if (null !== $check) { |
|
282 | 282 | return $check; |
283 | 283 | } |
284 | 284 | |
285 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
285 | + return wpinv_get_option('sequential_invoice_number'); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
288 | +function wpinv_switch_to_locale($locale = NULL) { |
|
289 | 289 | global $invoicing, $wpi_switch_locale; |
290 | 290 | |
291 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
292 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
291 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
292 | + $locale = empty($locale) ? get_locale() : $locale; |
|
293 | 293 | |
294 | - switch_to_locale( $locale ); |
|
294 | + switch_to_locale($locale); |
|
295 | 295 | |
296 | 296 | $wpi_switch_locale = $locale; |
297 | 297 | |
298 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
298 | + add_filter('plugin_locale', 'get_locale'); |
|
299 | 299 | |
300 | 300 | $invoicing->load_textdomain(); |
301 | 301 | |
302 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
302 | + do_action('wpinv_switch_to_locale', $locale); |
|
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | 306 | function wpinv_restore_locale() { |
307 | 307 | global $invoicing, $wpi_switch_locale; |
308 | 308 | |
309 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
309 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
310 | 310 | restore_previous_locale(); |
311 | 311 | |
312 | 312 | $wpi_switch_locale = NULL; |
313 | 313 | |
314 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
314 | + remove_filter('plugin_locale', 'get_locale'); |
|
315 | 315 | |
316 | 316 | $invoicing->load_textdomain(); |
317 | 317 | |
318 | - do_action( 'wpinv_restore_locale' ); |
|
318 | + do_action('wpinv_restore_locale'); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | |
@@ -323,22 +323,22 @@ discard block |
||
323 | 323 | * Returns the default form's id. |
324 | 324 | */ |
325 | 325 | function wpinv_get_default_payment_form() { |
326 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
326 | + $form = get_option('wpinv_default_payment_form'); |
|
327 | 327 | |
328 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
328 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
329 | 329 | $form = wp_insert_post( |
330 | 330 | array( |
331 | 331 | 'post_type' => 'wpi_payment_form', |
332 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
332 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
333 | 333 | 'post_status' => 'publish', |
334 | 334 | 'meta_input' => array( |
335 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
335 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
336 | 336 | 'wpinv_form_items' => array(), |
337 | 337 | ) |
338 | 338 | ) |
339 | 339 | ); |
340 | 340 | |
341 | - update_option( 'wpinv_default_payment_form', $form ); |
|
341 | + update_option('wpinv_default_payment_form', $form); |
|
342 | 342 | } |
343 | 343 | |
344 | 344 | return $form; |
@@ -349,19 +349,19 @@ discard block |
||
349 | 349 | * |
350 | 350 | * @param int $payment_form |
351 | 351 | */ |
352 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
352 | +function getpaid_get_payment_form_elements($payment_form) { |
|
353 | 353 | |
354 | - if ( empty( $payment_form ) ) { |
|
355 | - return wpinv_get_data( 'sample-payment-form' ); |
|
354 | + if (empty($payment_form)) { |
|
355 | + return wpinv_get_data('sample-payment-form'); |
|
356 | 356 | } |
357 | 357 | |
358 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
358 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
359 | 359 | |
360 | - if ( is_array( $form_elements ) ) { |
|
360 | + if (is_array($form_elements)) { |
|
361 | 361 | return $form_elements; |
362 | 362 | } |
363 | 363 | |
364 | - return wpinv_get_data( 'sample-payment-form' ); |
|
364 | + return wpinv_get_data('sample-payment-form'); |
|
365 | 365 | |
366 | 366 | } |
367 | 367 | |
@@ -370,13 +370,13 @@ discard block |
||
370 | 370 | * |
371 | 371 | * @param int $payment_form |
372 | 372 | */ |
373 | -function gepaid_get_form_items( $id ) { |
|
374 | - $form = new GetPaid_Payment_Form( $id ); |
|
373 | +function gepaid_get_form_items($id) { |
|
374 | + $form = new GetPaid_Payment_Form($id); |
|
375 | 375 | |
376 | 376 | // Is this a default form? |
377 | - if ( $form->is_default() ) { |
|
377 | + if ($form->is_default()) { |
|
378 | 378 | return array(); |
379 | 379 | } |
380 | 380 | |
381 | - return $form->get_items( 'view', 'arrays' ); |
|
381 | + return $form->get_items('view', 'arrays'); |
|
382 | 382 | } |
@@ -77,13 +77,13 @@ discard block |
||
77 | 77 | * @return array |
78 | 78 | */ |
79 | 79 | function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
80 | - $invoice_statuses = array( |
|
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
80 | + $invoice_statuses = array( |
|
81 | + 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | 82 | 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
83 | 83 | 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
84 | + 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | + 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | + 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | 87 | 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
88 | 88 | 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
89 | 89 | ); |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | function wpinv_status_nicename( $status ) { |
@@ -208,25 +208,25 @@ discard block |
||
208 | 208 | * @return string |
209 | 209 | */ |
210 | 210 | function getpaid_get_price_format() { |
211 | - $currency_pos = wpinv_currency_position(); |
|
212 | - $format = '%1$s%2$s'; |
|
211 | + $currency_pos = wpinv_currency_position(); |
|
212 | + $format = '%1$s%2$s'; |
|
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
215 | - case 'left': |
|
216 | - $format = '%1$s%2$s'; |
|
217 | - break; |
|
218 | - case 'right': |
|
219 | - $format = '%2$s%1$s'; |
|
220 | - break; |
|
221 | - case 'left_space': |
|
222 | - $format = '%1$s %2$s'; |
|
223 | - break; |
|
224 | - case 'right_space': |
|
225 | - $format = '%2$s %1$s'; |
|
226 | - break; |
|
227 | - } |
|
214 | + switch ( $currency_pos ) { |
|
215 | + case 'left': |
|
216 | + $format = '%1$s%2$s'; |
|
217 | + break; |
|
218 | + case 'right': |
|
219 | + $format = '%2$s%1$s'; |
|
220 | + break; |
|
221 | + case 'left_space': |
|
222 | + $format = '%1$s %2$s'; |
|
223 | + break; |
|
224 | + case 'right_space': |
|
225 | + $format = '%2$s %1$s'; |
|
226 | + break; |
|
227 | + } |
|
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -329,13 +329,13 @@ discard block |
||
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | 331 | function getpaid_maybe_define_constant( $name, $value ) { |
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
334 | - } |
|
332 | + if ( ! defined( $name ) ) { |
|
333 | + define( $name, $value ); |
|
334 | + } |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get( 'arg_separator.output' ); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | function wpinv_rgb_from_hex( $color ) { |
@@ -684,11 +684,11 @@ discard block |
||
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | - } |
|
687 | + if ( ! is_array( $list ) ) { |
|
688 | + return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
689 | + } |
|
690 | 690 | |
691 | - return $list; |
|
691 | + return $list; |
|
692 | 692 | } |
693 | 693 | |
694 | 694 | /** |
@@ -708,9 +708,9 @@ discard block |
||
708 | 708 | } |
709 | 709 | |
710 | 710 | $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
711 | + wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
712 | 712 | |
713 | - return $data; |
|
713 | + return $data; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -739,17 +739,17 @@ discard block |
||
739 | 739 | */ |
740 | 740 | function wpinv_clean( $var ) { |
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if ( is_array( $var ) ) { |
|
743 | + return array_map( 'wpinv_clean', $var ); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | if ( is_object( $var ) ) { |
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
747 | + $object_vars = get_object_vars( $var ); |
|
748 | + foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | + $var->$property_name = wpinv_clean( $property_value ); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | - } |
|
752 | + } |
|
753 | 753 | |
754 | 754 | return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
755 | 755 | } |
@@ -762,7 +762,7 @@ discard block |
||
762 | 762 | */ |
763 | 763 | function getpaid_convert_price_string_to_options( $str ) { |
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
765 | + $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | 766 | $options = array(); |
767 | 767 | |
768 | 768 | foreach ( $raw_options as $option ) { |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -862,15 +862,15 @@ discard block |
||
862 | 862 | function getpaid_limit_length( $string, $limit ) { |
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | - } |
|
869 | - } else { |
|
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | - } |
|
873 | - } |
|
865 | + if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | + if ( mb_strlen( $string ) > $limit ) { |
|
867 | + $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
868 | + } |
|
869 | + } else { |
|
870 | + if ( strlen( $string ) > $limit ) { |
|
871 | + $string = substr( $string, 0, $str_limit ) . '...'; |
|
872 | + } |
|
873 | + } |
|
874 | 874 | return $string; |
875 | 875 | |
876 | 876 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Are we supporting item quantities? |
@@ -21,25 +21,25 @@ discard block |
||
21 | 21 | function wpinv_get_ip() { |
22 | 22 | $ip = $_SERVER['REMOTE_ADDR']; |
23 | 23 | |
24 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
24 | + if (!empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
25 | 25 | //Check ip from share internet. |
26 | 26 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
27 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
27 | + } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
28 | 28 | //Check ip is pass from proxy. |
29 | 29 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
30 | 30 | } |
31 | 31 | |
32 | - return apply_filters( 'wpinv_get_ip', $ip ); |
|
32 | + return apply_filters('wpinv_get_ip', $ip); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | function wpinv_get_user_agent() { |
36 | - if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
37 | - $user_agent = sanitize_text_field( $_SERVER['HTTP_USER_AGENT'] ); |
|
36 | + if (!empty($_SERVER['HTTP_USER_AGENT'])) { |
|
37 | + $user_agent = sanitize_text_field($_SERVER['HTTP_USER_AGENT']); |
|
38 | 38 | } else { |
39 | 39 | $user_agent = ''; |
40 | 40 | } |
41 | 41 | |
42 | - return apply_filters( 'wpinv_get_user_agent', $user_agent ); |
|
42 | + return apply_filters('wpinv_get_user_agent', $user_agent); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -47,27 +47,27 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param string $amount The amount to sanitize. |
49 | 49 | */ |
50 | -function wpinv_sanitize_amount( $amount ) { |
|
50 | +function wpinv_sanitize_amount($amount) { |
|
51 | 51 | |
52 | 52 | // Format decimals. |
53 | - $amount = str_replace( wpinv_decimal_separator(), '.', $amount ); |
|
53 | + $amount = str_replace(wpinv_decimal_separator(), '.', $amount); |
|
54 | 54 | |
55 | 55 | // Remove thousands. |
56 | - $amount = str_replace( wpinv_thousands_separator(), '', $amount ); |
|
56 | + $amount = str_replace(wpinv_thousands_separator(), '', $amount); |
|
57 | 57 | |
58 | 58 | // Cast the remaining to a float. |
59 | - return (float) preg_replace( '/[^0-9\.\-]/', '', $amount ); |
|
59 | + return (float) preg_replace('/[^0-9\.\-]/', '', $amount); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
63 | -function wpinv_round_amount( $amount, $decimals = NULL ) { |
|
64 | - if ( $decimals === NULL ) { |
|
63 | +function wpinv_round_amount($amount, $decimals = NULL) { |
|
64 | + if ($decimals === NULL) { |
|
65 | 65 | $decimals = wpinv_decimals(); |
66 | 66 | } |
67 | 67 | |
68 | - $amount = round( (double)$amount, wpinv_currency_decimal_filter( absint( $decimals ) ) ); |
|
68 | + $amount = round((double) $amount, wpinv_currency_decimal_filter(absint($decimals))); |
|
69 | 69 | |
70 | - return apply_filters( 'wpinv_round_amount', $amount, $decimals ); |
|
70 | + return apply_filters('wpinv_round_amount', $amount, $decimals); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | * @since 1.0.19 |
77 | 77 | * @return array |
78 | 78 | */ |
79 | -function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) { |
|
79 | +function wpinv_get_invoice_statuses($draft = false, $trashed = false, $invoice = false) { |
|
80 | 80 | $invoice_statuses = array( |
81 | - 'wpi-pending' => _x( 'Pending payment', 'Invoice status', 'invoicing' ), |
|
82 | - 'publish' => _x( 'Paid', 'Invoice status', 'invoicing' ), |
|
83 | - 'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ), |
|
84 | - 'wpi-onhold' => _x( 'On hold', 'Invoice status', 'invoicing' ), |
|
85 | - 'wpi-cancelled' => _x( 'Cancelled', 'Invoice status', 'invoicing' ), |
|
86 | - 'wpi-refunded' => _x( 'Refunded', 'Invoice status', 'invoicing' ), |
|
87 | - 'wpi-failed' => _x( 'Failed', 'Invoice status', 'invoicing' ), |
|
88 | - 'wpi-renewal' => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ), |
|
81 | + 'wpi-pending' => _x('Pending payment', 'Invoice status', 'invoicing'), |
|
82 | + 'publish' => _x('Paid', 'Invoice status', 'invoicing'), |
|
83 | + 'wpi-processing' => _x('Processing', 'Invoice status', 'invoicing'), |
|
84 | + 'wpi-onhold' => _x('On hold', 'Invoice status', 'invoicing'), |
|
85 | + 'wpi-cancelled' => _x('Cancelled', 'Invoice status', 'invoicing'), |
|
86 | + 'wpi-refunded' => _x('Refunded', 'Invoice status', 'invoicing'), |
|
87 | + 'wpi-failed' => _x('Failed', 'Invoice status', 'invoicing'), |
|
88 | + 'wpi-renewal' => _x('Renewal Payment', 'Invoice status', 'invoicing'), |
|
89 | 89 | ); |
90 | 90 | |
91 | - if ( $draft ) { |
|
92 | - $invoice_statuses['draft'] = __( 'Draft', 'invoicing' ); |
|
91 | + if ($draft) { |
|
92 | + $invoice_statuses['draft'] = __('Draft', 'invoicing'); |
|
93 | 93 | } |
94 | 94 | |
95 | - if ( $trashed ) { |
|
96 | - $invoice_statuses['trash'] = __( 'Trash', 'invoicing' ); |
|
95 | + if ($trashed) { |
|
96 | + $invoice_statuses['trash'] = __('Trash', 'invoicing'); |
|
97 | 97 | } |
98 | 98 | |
99 | - return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice ); |
|
99 | + return apply_filters('wpinv_statuses', $invoice_statuses, $invoice); |
|
100 | 100 | } |
101 | 101 | |
102 | -function wpinv_status_nicename( $status ) { |
|
103 | - $statuses = wpinv_get_invoice_statuses( true, true ); |
|
104 | - $status = isset( $statuses[$status] ) ? $statuses[$status] : __( $status, 'invoicing' ); |
|
102 | +function wpinv_status_nicename($status) { |
|
103 | + $statuses = wpinv_get_invoice_statuses(true, true); |
|
104 | + $status = isset($statuses[$status]) ? $statuses[$status] : __($status, 'invoicing'); |
|
105 | 105 | |
106 | 106 | return $status; |
107 | 107 | } |
@@ -111,13 +111,13 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param string $current |
113 | 113 | */ |
114 | -function wpinv_get_currency( $current = '' ) { |
|
114 | +function wpinv_get_currency($current = '') { |
|
115 | 115 | |
116 | - if ( empty( $current ) ) { |
|
117 | - $current = apply_filters( 'wpinv_currency', wpinv_get_option( 'currency', 'USD' ) ); |
|
116 | + if (empty($current)) { |
|
117 | + $current = apply_filters('wpinv_currency', wpinv_get_option('currency', 'USD')); |
|
118 | 118 | } |
119 | 119 | |
120 | - return trim( strtoupper( $current ) ); |
|
120 | + return trim(strtoupper($current)); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -125,25 +125,25 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param string|null $currency The currency code. Defaults to the default currency. |
127 | 127 | */ |
128 | -function wpinv_currency_symbol( $currency = null ) { |
|
128 | +function wpinv_currency_symbol($currency = null) { |
|
129 | 129 | |
130 | 130 | // Prepare the currency. |
131 | - $currency = empty( $currency ) ? wpinv_get_currency() : wpinv_clean( $currency ); |
|
131 | + $currency = empty($currency) ? wpinv_get_currency() : wpinv_clean($currency); |
|
132 | 132 | |
133 | 133 | // Fetch all symbols. |
134 | 134 | $symbols = wpinv_get_currency_symbols(); |
135 | 135 | |
136 | 136 | // Fetch this currencies symbol. |
137 | - $currency_symbol = isset( $symbols[$currency] ) ? $symbols[$currency] : $currency; |
|
137 | + $currency_symbol = isset($symbols[$currency]) ? $symbols[$currency] : $currency; |
|
138 | 138 | |
139 | 139 | // Filter the symbol. |
140 | - return apply_filters( 'wpinv_currency_symbol', $currency_symbol, $currency ); |
|
140 | + return apply_filters('wpinv_currency_symbol', $currency_symbol, $currency); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | function wpinv_currency_position() { |
144 | - $position = wpinv_get_option( 'currency_position', 'left' ); |
|
144 | + $position = wpinv_get_option('currency_position', 'left'); |
|
145 | 145 | |
146 | - return apply_filters( 'wpinv_currency_position', $position ); |
|
146 | + return apply_filters('wpinv_currency_position', $position); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | /** |
@@ -151,13 +151,13 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @param $string|null $current |
153 | 153 | */ |
154 | -function wpinv_thousands_separator( $current = null ) { |
|
154 | +function wpinv_thousands_separator($current = null) { |
|
155 | 155 | |
156 | - if ( null == $current ) { |
|
157 | - $current = wpinv_get_option( 'thousands_separator', '.' ); |
|
156 | + if (null == $current) { |
|
157 | + $current = wpinv_get_option('thousands_separator', '.'); |
|
158 | 158 | } |
159 | 159 | |
160 | - return trim( $current ); |
|
160 | + return trim($current); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @param $string|null $current |
167 | 167 | */ |
168 | -function wpinv_decimal_separator( $current = null ) { |
|
168 | +function wpinv_decimal_separator($current = null) { |
|
169 | 169 | |
170 | - if ( null == $current ) { |
|
171 | - $current = wpinv_get_option( 'decimal_separator', '.' ); |
|
170 | + if (null == $current) { |
|
171 | + $current = wpinv_get_option('decimal_separator', '.'); |
|
172 | 172 | } |
173 | 173 | |
174 | - return trim( $current ); |
|
174 | + return trim($current); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -179,27 +179,27 @@ discard block |
||
179 | 179 | * |
180 | 180 | * @param $string|null $current |
181 | 181 | */ |
182 | -function wpinv_decimals( $current = null ) { |
|
182 | +function wpinv_decimals($current = null) { |
|
183 | 183 | |
184 | - if ( null == $current ) { |
|
185 | - $current = wpinv_get_option( 'decimals', 2 ); |
|
184 | + if (null == $current) { |
|
185 | + $current = wpinv_get_option('decimals', 2); |
|
186 | 186 | } |
187 | 187 | |
188 | - return absint( $current ); |
|
188 | + return absint($current); |
|
189 | 189 | } |
190 | 190 | |
191 | 191 | /** |
192 | 192 | * Retrieves a list of all supported currencies. |
193 | 193 | */ |
194 | 194 | function wpinv_get_currencies() { |
195 | - return apply_filters( 'wpinv_currencies', wpinv_get_data( 'currencies' ) ); |
|
195 | + return apply_filters('wpinv_currencies', wpinv_get_data('currencies')); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
199 | 199 | * Retrieves a list of all currency symbols. |
200 | 200 | */ |
201 | 201 | function wpinv_get_currency_symbols() { |
202 | - return apply_filters( 'wpinv_currency_symbols', wpinv_get_data( 'currency-symbols' ) ); |
|
202 | + return apply_filters('wpinv_currency_symbols', wpinv_get_data('currency-symbols')); |
|
203 | 203 | } |
204 | 204 | |
205 | 205 | /** |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | $currency_pos = wpinv_currency_position(); |
212 | 212 | $format = '%1$s%2$s'; |
213 | 213 | |
214 | - switch ( $currency_pos ) { |
|
214 | + switch ($currency_pos) { |
|
215 | 215 | case 'left': |
216 | 216 | $format = '%1$s%2$s'; |
217 | 217 | break; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | break; |
227 | 227 | } |
228 | 228 | |
229 | - return apply_filters( 'getpaid_price_format', $format, $currency_pos ); |
|
229 | + return apply_filters('getpaid_price_format', $format, $currency_pos); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -236,25 +236,25 @@ discard block |
||
236 | 236 | * @param string $currency Currency. |
237 | 237 | * @return string |
238 | 238 | */ |
239 | -function wpinv_price( $amount = 0, $currency = '' ) { |
|
239 | +function wpinv_price($amount = 0, $currency = '') { |
|
240 | 240 | |
241 | 241 | // Backwards compatibility. |
242 | - $amount = floatval( wpinv_sanitize_amount( $amount ) ); |
|
242 | + $amount = floatval(wpinv_sanitize_amount($amount)); |
|
243 | 243 | |
244 | 244 | // Prepare variables. |
245 | - $currency = wpinv_get_currency( $currency ); |
|
245 | + $currency = wpinv_get_currency($currency); |
|
246 | 246 | $amount = (float) $amount; |
247 | 247 | $unformatted_amount = $amount; |
248 | 248 | $negative = $amount < 0; |
249 | - $amount = apply_filters( 'getpaid_raw_amount', floatval( $negative ? $amount * -1 : $amount ) ); |
|
250 | - $amount = wpinv_format_amount( $amount ); |
|
249 | + $amount = apply_filters('getpaid_raw_amount', floatval($negative ? $amount * -1 : $amount)); |
|
250 | + $amount = wpinv_format_amount($amount); |
|
251 | 251 | |
252 | 252 | // Format the amount. |
253 | 253 | $format = getpaid_get_price_format(); |
254 | - $formatted_amount = ( $negative ? '-' : '' ) . sprintf( $format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol( $currency ) . '</span>', $amount ); |
|
254 | + $formatted_amount = ($negative ? '-' : '') . sprintf($format, '<span class="getpaid-currency__symbol">' . wpinv_currency_symbol($currency) . '</span>', $amount); |
|
255 | 255 | |
256 | 256 | // Filter the formatting. |
257 | - return apply_filters( 'wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount ); |
|
257 | + return apply_filters('wpinv_price', $formatted_amount, $amount, $currency, $unformatted_amount); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | /** |
@@ -265,33 +265,33 @@ discard block |
||
265 | 265 | * @param bool $calculate Whether or not to apply separators. |
266 | 266 | * @return string |
267 | 267 | */ |
268 | -function wpinv_format_amount( $amount, $decimals = null, $calculate = false ) { |
|
268 | +function wpinv_format_amount($amount, $decimals = null, $calculate = false) { |
|
269 | 269 | $thousands_sep = wpinv_thousands_separator(); |
270 | 270 | $decimal_sep = wpinv_decimal_separator(); |
271 | - $decimals = wpinv_decimals( $decimals ); |
|
271 | + $decimals = wpinv_decimals($decimals); |
|
272 | 272 | |
273 | 273 | // Format decimals. |
274 | - $amount = str_replace( $decimal_sep, '.', $amount ); |
|
274 | + $amount = str_replace($decimal_sep, '.', $amount); |
|
275 | 275 | |
276 | 276 | // Remove thousands. |
277 | - $amount = str_replace( $thousands_sep, '', $amount ); |
|
277 | + $amount = str_replace($thousands_sep, '', $amount); |
|
278 | 278 | |
279 | 279 | // Cast the remaining to a float. |
280 | - $amount = floatval( $amount ); |
|
280 | + $amount = floatval($amount); |
|
281 | 281 | |
282 | - if ( $calculate ) { |
|
282 | + if ($calculate) { |
|
283 | 283 | return $amount; |
284 | 284 | } |
285 | 285 | |
286 | 286 | // Fomart the amount. |
287 | - return number_format( $amount, $decimals, $decimal_sep, $thousands_sep ); |
|
287 | + return number_format($amount, $decimals, $decimal_sep, $thousands_sep); |
|
288 | 288 | } |
289 | 289 | |
290 | -function wpinv_sanitize_key( $key ) { |
|
290 | +function wpinv_sanitize_key($key) { |
|
291 | 291 | $raw_key = $key; |
292 | - $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key ); |
|
292 | + $key = preg_replace('/[^a-zA-Z0-9_\-\.\:\/]/', '', $key); |
|
293 | 293 | |
294 | - return apply_filters( 'wpinv_sanitize_key', $key, $raw_key ); |
|
294 | + return apply_filters('wpinv_sanitize_key', $key, $raw_key); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -299,8 +299,8 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @param $str the file whose extension should be retrieved. |
301 | 301 | */ |
302 | -function wpinv_get_file_extension( $str ) { |
|
303 | - $filetype = wp_check_filetype( $str ); |
|
302 | +function wpinv_get_file_extension($str) { |
|
303 | + $filetype = wp_check_filetype($str); |
|
304 | 304 | return $filetype['ext']; |
305 | 305 | } |
306 | 306 | |
@@ -309,16 +309,16 @@ discard block |
||
309 | 309 | * |
310 | 310 | * @param string $string |
311 | 311 | */ |
312 | -function wpinv_string_is_image_url( $string ) { |
|
313 | - $extension = strtolower( wpinv_get_file_extension( $string ) ); |
|
314 | - return in_array( $extension, array( 'jpeg', 'jpg', 'png', 'gif', 'ico' ), true ); |
|
312 | +function wpinv_string_is_image_url($string) { |
|
313 | + $extension = strtolower(wpinv_get_file_extension($string)); |
|
314 | + return in_array($extension, array('jpeg', 'jpg', 'png', 'gif', 'ico'), true); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
318 | 318 | * Returns the current URL. |
319 | 319 | */ |
320 | 320 | function wpinv_get_current_page_url() { |
321 | - return ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
321 | + return (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
@@ -328,46 +328,46 @@ discard block |
||
328 | 328 | * @param string $name Constant name. |
329 | 329 | * @param mixed $value Value. |
330 | 330 | */ |
331 | -function getpaid_maybe_define_constant( $name, $value ) { |
|
332 | - if ( ! defined( $name ) ) { |
|
333 | - define( $name, $value ); |
|
331 | +function getpaid_maybe_define_constant($name, $value) { |
|
332 | + if (!defined($name)) { |
|
333 | + define($name, $value); |
|
334 | 334 | } |
335 | 335 | } |
336 | 336 | |
337 | 337 | function wpinv_get_php_arg_separator_output() { |
338 | - return ini_get( 'arg_separator.output' ); |
|
338 | + return ini_get('arg_separator.output'); |
|
339 | 339 | } |
340 | 340 | |
341 | -function wpinv_rgb_from_hex( $color ) { |
|
342 | - $color = str_replace( '#', '', $color ); |
|
341 | +function wpinv_rgb_from_hex($color) { |
|
342 | + $color = str_replace('#', '', $color); |
|
343 | 343 | |
344 | 344 | // Convert shorthand colors to full format, e.g. "FFF" -> "FFFFFF" |
345 | - $color = preg_replace( '~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color ); |
|
346 | - if ( empty( $color ) ) { |
|
345 | + $color = preg_replace('~^(.)(.)(.)$~', '$1$1$2$2$3$3', $color); |
|
346 | + if (empty($color)) { |
|
347 | 347 | return NULL; |
348 | 348 | } |
349 | 349 | |
350 | - $color = str_split( $color ); |
|
350 | + $color = str_split($color); |
|
351 | 351 | |
352 | 352 | $rgb = array(); |
353 | - $rgb['R'] = hexdec( $color[0] . $color[1] ); |
|
354 | - $rgb['G'] = hexdec( $color[2] . $color[3] ); |
|
355 | - $rgb['B'] = hexdec( $color[4] . $color[5] ); |
|
353 | + $rgb['R'] = hexdec($color[0] . $color[1]); |
|
354 | + $rgb['G'] = hexdec($color[2] . $color[3]); |
|
355 | + $rgb['B'] = hexdec($color[4] . $color[5]); |
|
356 | 356 | |
357 | 357 | return $rgb; |
358 | 358 | } |
359 | 359 | |
360 | -function wpinv_hex_darker( $color, $factor = 30 ) { |
|
361 | - $base = wpinv_rgb_from_hex( $color ); |
|
360 | +function wpinv_hex_darker($color, $factor = 30) { |
|
361 | + $base = wpinv_rgb_from_hex($color); |
|
362 | 362 | $color = '#'; |
363 | 363 | |
364 | - foreach ( $base as $k => $v ) { |
|
364 | + foreach ($base as $k => $v) { |
|
365 | 365 | $amount = $v / 100; |
366 | - $amount = round( $amount * $factor ); |
|
366 | + $amount = round($amount * $factor); |
|
367 | 367 | $new_decimal = $v - $amount; |
368 | 368 | |
369 | - $new_hex_component = dechex( $new_decimal ); |
|
370 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
369 | + $new_hex_component = dechex($new_decimal); |
|
370 | + if (strlen($new_hex_component) < 2) { |
|
371 | 371 | $new_hex_component = "0" . $new_hex_component; |
372 | 372 | } |
373 | 373 | $color .= $new_hex_component; |
@@ -376,18 +376,18 @@ discard block |
||
376 | 376 | return $color; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_hex_lighter( $color, $factor = 30 ) { |
|
380 | - $base = wpinv_rgb_from_hex( $color ); |
|
379 | +function wpinv_hex_lighter($color, $factor = 30) { |
|
380 | + $base = wpinv_rgb_from_hex($color); |
|
381 | 381 | $color = '#'; |
382 | 382 | |
383 | - foreach ( $base as $k => $v ) { |
|
383 | + foreach ($base as $k => $v) { |
|
384 | 384 | $amount = 255 - $v; |
385 | 385 | $amount = $amount / 100; |
386 | - $amount = round( $amount * $factor ); |
|
386 | + $amount = round($amount * $factor); |
|
387 | 387 | $new_decimal = $v + $amount; |
388 | 388 | |
389 | - $new_hex_component = dechex( $new_decimal ); |
|
390 | - if ( strlen( $new_hex_component ) < 2 ) { |
|
389 | + $new_hex_component = dechex($new_decimal); |
|
390 | + if (strlen($new_hex_component) < 2) { |
|
391 | 391 | $new_hex_component = "0" . $new_hex_component; |
392 | 392 | } |
393 | 393 | $color .= $new_hex_component; |
@@ -396,22 +396,22 @@ discard block |
||
396 | 396 | return $color; |
397 | 397 | } |
398 | 398 | |
399 | -function wpinv_light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) { |
|
400 | - $hex = str_replace( '#', '', $color ); |
|
399 | +function wpinv_light_or_dark($color, $dark = '#000000', $light = '#FFFFFF') { |
|
400 | + $hex = str_replace('#', '', $color); |
|
401 | 401 | |
402 | - $c_r = hexdec( substr( $hex, 0, 2 ) ); |
|
403 | - $c_g = hexdec( substr( $hex, 2, 2 ) ); |
|
404 | - $c_b = hexdec( substr( $hex, 4, 2 ) ); |
|
402 | + $c_r = hexdec(substr($hex, 0, 2)); |
|
403 | + $c_g = hexdec(substr($hex, 2, 2)); |
|
404 | + $c_b = hexdec(substr($hex, 4, 2)); |
|
405 | 405 | |
406 | - $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000; |
|
406 | + $brightness = (($c_r * 299) + ($c_g * 587) + ($c_b * 114)) / 1000; |
|
407 | 407 | |
408 | 408 | return $brightness > 155 ? $dark : $light; |
409 | 409 | } |
410 | 410 | |
411 | -function wpinv_format_hex( $hex ) { |
|
412 | - $hex = trim( str_replace( '#', '', $hex ) ); |
|
411 | +function wpinv_format_hex($hex) { |
|
412 | + $hex = trim(str_replace('#', '', $hex)); |
|
413 | 413 | |
414 | - if ( strlen( $hex ) == 3 ) { |
|
414 | + if (strlen($hex) == 3) { |
|
415 | 415 | $hex = $hex[0] . $hex[0] . $hex[1] . $hex[1] . $hex[2] . $hex[2]; |
416 | 416 | } |
417 | 417 | |
@@ -431,12 +431,12 @@ discard block |
||
431 | 431 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
432 | 432 | * @return string |
433 | 433 | */ |
434 | -function wpinv_utf8_strimwidth( $str, $start, $width, $trimmaker = '', $encoding = 'UTF-8' ) { |
|
435 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
436 | - return mb_strimwidth( $str, $start, $width, $trimmaker, $encoding ); |
|
434 | +function wpinv_utf8_strimwidth($str, $start, $width, $trimmaker = '', $encoding = 'UTF-8') { |
|
435 | + if (function_exists('mb_strimwidth')) { |
|
436 | + return mb_strimwidth($str, $start, $width, $trimmaker, $encoding); |
|
437 | 437 | } |
438 | 438 | |
439 | - return wpinv_utf8_substr( $str, $start, $width, $encoding ) . $trimmaker; |
|
439 | + return wpinv_utf8_substr($str, $start, $width, $encoding) . $trimmaker; |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | /** |
@@ -448,28 +448,28 @@ discard block |
||
448 | 448 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
449 | 449 | * @return int Returns the number of characters in string. |
450 | 450 | */ |
451 | -function wpinv_utf8_strlen( $str, $encoding = 'UTF-8' ) { |
|
452 | - if ( function_exists( 'mb_strlen' ) ) { |
|
453 | - return mb_strlen( $str, $encoding ); |
|
451 | +function wpinv_utf8_strlen($str, $encoding = 'UTF-8') { |
|
452 | + if (function_exists('mb_strlen')) { |
|
453 | + return mb_strlen($str, $encoding); |
|
454 | 454 | } |
455 | 455 | |
456 | - return strlen( $str ); |
|
456 | + return strlen($str); |
|
457 | 457 | } |
458 | 458 | |
459 | -function wpinv_utf8_strtolower( $str, $encoding = 'UTF-8' ) { |
|
460 | - if ( function_exists( 'mb_strtolower' ) ) { |
|
461 | - return mb_strtolower( $str, $encoding ); |
|
459 | +function wpinv_utf8_strtolower($str, $encoding = 'UTF-8') { |
|
460 | + if (function_exists('mb_strtolower')) { |
|
461 | + return mb_strtolower($str, $encoding); |
|
462 | 462 | } |
463 | 463 | |
464 | - return strtolower( $str ); |
|
464 | + return strtolower($str); |
|
465 | 465 | } |
466 | 466 | |
467 | -function wpinv_utf8_strtoupper( $str, $encoding = 'UTF-8' ) { |
|
468 | - if ( function_exists( 'mb_strtoupper' ) ) { |
|
469 | - return mb_strtoupper( $str, $encoding ); |
|
467 | +function wpinv_utf8_strtoupper($str, $encoding = 'UTF-8') { |
|
468 | + if (function_exists('mb_strtoupper')) { |
|
469 | + return mb_strtoupper($str, $encoding); |
|
470 | 470 | } |
471 | 471 | |
472 | - return strtoupper( $str ); |
|
472 | + return strtoupper($str); |
|
473 | 473 | } |
474 | 474 | |
475 | 475 | /** |
@@ -483,12 +483,12 @@ discard block |
||
483 | 483 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
484 | 484 | * @return int Returns the position of the first occurrence of search in the string. |
485 | 485 | */ |
486 | -function wpinv_utf8_strpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
487 | - if ( function_exists( 'mb_strpos' ) ) { |
|
488 | - return mb_strpos( $str, $find, $offset, $encoding ); |
|
486 | +function wpinv_utf8_strpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
487 | + if (function_exists('mb_strpos')) { |
|
488 | + return mb_strpos($str, $find, $offset, $encoding); |
|
489 | 489 | } |
490 | 490 | |
491 | - return strpos( $str, $find, $offset ); |
|
491 | + return strpos($str, $find, $offset); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -502,12 +502,12 @@ discard block |
||
502 | 502 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
503 | 503 | * @return int Returns the position of the last occurrence of search. |
504 | 504 | */ |
505 | -function wpinv_utf8_strrpos( $str, $find, $offset = 0, $encoding = 'UTF-8' ) { |
|
506 | - if ( function_exists( 'mb_strrpos' ) ) { |
|
507 | - return mb_strrpos( $str, $find, $offset, $encoding ); |
|
505 | +function wpinv_utf8_strrpos($str, $find, $offset = 0, $encoding = 'UTF-8') { |
|
506 | + if (function_exists('mb_strrpos')) { |
|
507 | + return mb_strrpos($str, $find, $offset, $encoding); |
|
508 | 508 | } |
509 | 509 | |
510 | - return strrpos( $str, $find, $offset ); |
|
510 | + return strrpos($str, $find, $offset); |
|
511 | 511 | } |
512 | 512 | |
513 | 513 | /** |
@@ -522,16 +522,16 @@ discard block |
||
522 | 522 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
523 | 523 | * @return string |
524 | 524 | */ |
525 | -function wpinv_utf8_substr( $str, $start, $length = null, $encoding = 'UTF-8' ) { |
|
526 | - if ( function_exists( 'mb_substr' ) ) { |
|
527 | - if ( $length === null ) { |
|
528 | - return mb_substr( $str, $start, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
525 | +function wpinv_utf8_substr($str, $start, $length = null, $encoding = 'UTF-8') { |
|
526 | + if (function_exists('mb_substr')) { |
|
527 | + if ($length === null) { |
|
528 | + return mb_substr($str, $start, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
529 | 529 | } else { |
530 | - return mb_substr( $str, $start, $length, $encoding ); |
|
530 | + return mb_substr($str, $start, $length, $encoding); |
|
531 | 531 | } |
532 | 532 | } |
533 | 533 | |
534 | - return substr( $str, $start, $length ); |
|
534 | + return substr($str, $start, $length); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -543,48 +543,48 @@ discard block |
||
543 | 543 | * @param string $encoding The encoding parameter is the character encoding. Default "UTF-8". |
544 | 544 | * @return string The width of string. |
545 | 545 | */ |
546 | -function wpinv_utf8_strwidth( $str, $encoding = 'UTF-8' ) { |
|
547 | - if ( function_exists( 'mb_strwidth' ) ) { |
|
548 | - return mb_strwidth( $str, $encoding ); |
|
546 | +function wpinv_utf8_strwidth($str, $encoding = 'UTF-8') { |
|
547 | + if (function_exists('mb_strwidth')) { |
|
548 | + return mb_strwidth($str, $encoding); |
|
549 | 549 | } |
550 | 550 | |
551 | - return wpinv_utf8_strlen( $str, $encoding ); |
|
551 | + return wpinv_utf8_strlen($str, $encoding); |
|
552 | 552 | } |
553 | 553 | |
554 | -function wpinv_utf8_ucfirst( $str, $lower_str_end = false, $encoding = 'UTF-8' ) { |
|
555 | - if ( function_exists( 'mb_strlen' ) ) { |
|
556 | - $first_letter = wpinv_utf8_strtoupper( wpinv_utf8_substr( $str, 0, 1, $encoding ), $encoding ); |
|
554 | +function wpinv_utf8_ucfirst($str, $lower_str_end = false, $encoding = 'UTF-8') { |
|
555 | + if (function_exists('mb_strlen')) { |
|
556 | + $first_letter = wpinv_utf8_strtoupper(wpinv_utf8_substr($str, 0, 1, $encoding), $encoding); |
|
557 | 557 | $str_end = ""; |
558 | 558 | |
559 | - if ( $lower_str_end ) { |
|
560 | - $str_end = wpinv_utf8_strtolower( wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ), $encoding ); |
|
559 | + if ($lower_str_end) { |
|
560 | + $str_end = wpinv_utf8_strtolower(wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding), $encoding); |
|
561 | 561 | } else { |
562 | - $str_end = wpinv_utf8_substr( $str, 1, wpinv_utf8_strlen( $str, $encoding ), $encoding ); |
|
562 | + $str_end = wpinv_utf8_substr($str, 1, wpinv_utf8_strlen($str, $encoding), $encoding); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | return $first_letter . $str_end; |
566 | 566 | } |
567 | 567 | |
568 | - return ucfirst( $str ); |
|
568 | + return ucfirst($str); |
|
569 | 569 | } |
570 | 570 | |
571 | -function wpinv_utf8_ucwords( $str, $encoding = 'UTF-8' ) { |
|
572 | - if ( function_exists( 'mb_convert_case' ) ) { |
|
573 | - return mb_convert_case( $str, MB_CASE_TITLE, $encoding ); |
|
571 | +function wpinv_utf8_ucwords($str, $encoding = 'UTF-8') { |
|
572 | + if (function_exists('mb_convert_case')) { |
|
573 | + return mb_convert_case($str, MB_CASE_TITLE, $encoding); |
|
574 | 574 | } |
575 | 575 | |
576 | - return ucwords( $str ); |
|
576 | + return ucwords($str); |
|
577 | 577 | } |
578 | 578 | |
579 | -function wpinv_period_in_days( $period, $unit ) { |
|
580 | - $period = absint( $period ); |
|
579 | +function wpinv_period_in_days($period, $unit) { |
|
580 | + $period = absint($period); |
|
581 | 581 | |
582 | - if ( $period > 0 ) { |
|
583 | - if ( in_array( strtolower( $unit ), array( 'w', 'week', 'weeks' ) ) ) { |
|
582 | + if ($period > 0) { |
|
583 | + if (in_array(strtolower($unit), array('w', 'week', 'weeks'))) { |
|
584 | 584 | $period = $period * 7; |
585 | - } else if ( in_array( strtolower( $unit ), array( 'm', 'month', 'months' ) ) ) { |
|
585 | + } else if (in_array(strtolower($unit), array('m', 'month', 'months'))) { |
|
586 | 586 | $period = $period * 30; |
587 | - } else if ( in_array( strtolower( $unit ), array( 'y', 'year', 'years' ) ) ) { |
|
587 | + } else if (in_array(strtolower($unit), array('y', 'year', 'years'))) { |
|
588 | 588 | $period = $period * 365; |
589 | 589 | } |
590 | 590 | } |
@@ -592,14 +592,14 @@ discard block |
||
592 | 592 | return $period; |
593 | 593 | } |
594 | 594 | |
595 | -function wpinv_cal_days_in_month( $calendar, $month, $year ) { |
|
596 | - if ( function_exists( 'cal_days_in_month' ) ) { |
|
597 | - return cal_days_in_month( $calendar, $month, $year ); |
|
595 | +function wpinv_cal_days_in_month($calendar, $month, $year) { |
|
596 | + if (function_exists('cal_days_in_month')) { |
|
597 | + return cal_days_in_month($calendar, $month, $year); |
|
598 | 598 | } |
599 | 599 | |
600 | 600 | // Fallback in case the calendar extension is not loaded in PHP |
601 | 601 | // Only supports Gregorian calendar |
602 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
602 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
603 | 603 | } |
604 | 604 | |
605 | 605 | /** |
@@ -610,11 +610,11 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return string |
612 | 612 | */ |
613 | -function wpi_help_tip( $tip, $allow_html = false ) { |
|
614 | - if ( $allow_html ) { |
|
615 | - $tip = wpi_sanitize_tooltip( $tip ); |
|
613 | +function wpi_help_tip($tip, $allow_html = false) { |
|
614 | + if ($allow_html) { |
|
615 | + $tip = wpi_sanitize_tooltip($tip); |
|
616 | 616 | } else { |
617 | - $tip = esc_attr( $tip ); |
|
617 | + $tip = esc_attr($tip); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | return '<span class="wpi-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>'; |
@@ -628,8 +628,8 @@ discard block |
||
628 | 628 | * @param string $var |
629 | 629 | * @return string |
630 | 630 | */ |
631 | -function wpi_sanitize_tooltip( $var ) { |
|
632 | - return htmlspecialchars( wp_kses( html_entity_decode( $var ), array( |
|
631 | +function wpi_sanitize_tooltip($var) { |
|
632 | + return htmlspecialchars(wp_kses(html_entity_decode($var), array( |
|
633 | 633 | 'br' => array(), |
634 | 634 | 'em' => array(), |
635 | 635 | 'strong' => array(), |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | 'li' => array(), |
640 | 640 | 'ol' => array(), |
641 | 641 | 'p' => array(), |
642 | - ) ) ); |
|
642 | + ))); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | function wpinv_get_screen_ids() { |
651 | 651 | |
652 | - $screen_id = sanitize_title( __( 'Invoicing', 'invoicing' ) ); |
|
652 | + $screen_id = sanitize_title(__('Invoicing', 'invoicing')); |
|
653 | 653 | |
654 | 654 | $screen_ids = array( |
655 | 655 | 'toplevel_page_' . $screen_id, |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | 'invoicing_page_wpi-addons', |
668 | 668 | ); |
669 | 669 | |
670 | - return apply_filters( 'wpinv_screen_ids', $screen_ids ); |
|
670 | + return apply_filters('wpinv_screen_ids', $screen_ids); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -678,14 +678,14 @@ discard block |
||
678 | 678 | * @param array|string $list List of values. |
679 | 679 | * @return array Sanitized array of values. |
680 | 680 | */ |
681 | -function wpinv_parse_list( $list ) { |
|
681 | +function wpinv_parse_list($list) { |
|
682 | 682 | |
683 | - if ( empty( $list ) ) { |
|
683 | + if (empty($list)) { |
|
684 | 684 | $list = array(); |
685 | 685 | } |
686 | 686 | |
687 | - if ( ! is_array( $list ) ) { |
|
688 | - return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY ); |
|
687 | + if (!is_array($list)) { |
|
688 | + return preg_split('/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY); |
|
689 | 689 | } |
690 | 690 | |
691 | 691 | return $list; |
@@ -699,16 +699,16 @@ discard block |
||
699 | 699 | * @param string $key Type of data to fetch. |
700 | 700 | * @return mixed Fetched data. |
701 | 701 | */ |
702 | -function wpinv_get_data( $key ) { |
|
702 | +function wpinv_get_data($key) { |
|
703 | 703 | |
704 | 704 | // Try fetching it from the cache. |
705 | - $data = wp_cache_get( "wpinv-data-$key", 'wpinv' ); |
|
706 | - if( $data ) { |
|
705 | + $data = wp_cache_get("wpinv-data-$key", 'wpinv'); |
|
706 | + if ($data) { |
|
707 | 707 | return $data; |
708 | 708 | } |
709 | 709 | |
710 | - $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" ); |
|
711 | - wp_cache_set( "wpinv-data-$key", $data, 'wpinv' ); |
|
710 | + $data = apply_filters("wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php"); |
|
711 | + wp_cache_set("wpinv-data-$key", $data, 'wpinv'); |
|
712 | 712 | |
713 | 713 | return $data; |
714 | 714 | } |
@@ -722,10 +722,10 @@ discard block |
||
722 | 722 | * @param bool $first_empty Whether or not the first item in the list should be empty |
723 | 723 | * @return mixed Fetched data. |
724 | 724 | */ |
725 | -function wpinv_maybe_add_empty_option( $options, $first_empty ) { |
|
725 | +function wpinv_maybe_add_empty_option($options, $first_empty) { |
|
726 | 726 | |
727 | - if ( ! empty( $options ) && $first_empty ) { |
|
728 | - return array_merge( array( '' => '' ), $options ); |
|
727 | + if (!empty($options) && $first_empty) { |
|
728 | + return array_merge(array('' => ''), $options); |
|
729 | 729 | } |
730 | 730 | return $options; |
731 | 731 | |
@@ -737,21 +737,21 @@ discard block |
||
737 | 737 | * @param mixed $var Data to sanitize. |
738 | 738 | * @return string|array |
739 | 739 | */ |
740 | -function wpinv_clean( $var ) { |
|
740 | +function wpinv_clean($var) { |
|
741 | 741 | |
742 | - if ( is_array( $var ) ) { |
|
743 | - return array_map( 'wpinv_clean', $var ); |
|
742 | + if (is_array($var)) { |
|
743 | + return array_map('wpinv_clean', $var); |
|
744 | 744 | } |
745 | 745 | |
746 | - if ( is_object( $var ) ) { |
|
747 | - $object_vars = get_object_vars( $var ); |
|
748 | - foreach ( $object_vars as $property_name => $property_value ) { |
|
749 | - $var->$property_name = wpinv_clean( $property_value ); |
|
746 | + if (is_object($var)) { |
|
747 | + $object_vars = get_object_vars($var); |
|
748 | + foreach ($object_vars as $property_name => $property_value) { |
|
749 | + $var->$property_name = wpinv_clean($property_value); |
|
750 | 750 | } |
751 | 751 | return $var; |
752 | 752 | } |
753 | 753 | |
754 | - return is_string( $var ) ? sanitize_text_field( $var ) : $var; |
|
754 | + return is_string($var) ? sanitize_text_field($var) : $var; |
|
755 | 755 | } |
756 | 756 | |
757 | 757 | /** |
@@ -760,43 +760,43 @@ discard block |
||
760 | 760 | * @param string $str Data to convert. |
761 | 761 | * @return string|array |
762 | 762 | */ |
763 | -function getpaid_convert_price_string_to_options( $str ) { |
|
763 | +function getpaid_convert_price_string_to_options($str) { |
|
764 | 764 | |
765 | - $raw_options = array_map( 'trim', explode( ',', $str ) ); |
|
766 | - $options = array(); |
|
765 | + $raw_options = array_map('trim', explode(',', $str)); |
|
766 | + $options = array(); |
|
767 | 767 | |
768 | - foreach ( $raw_options as $option ) { |
|
768 | + foreach ($raw_options as $option) { |
|
769 | 769 | |
770 | - if ( '' == $option ) { |
|
770 | + if ('' == $option) { |
|
771 | 771 | continue; |
772 | 772 | } |
773 | 773 | |
774 | - $option = array_map( 'trim', explode( '|', $option ) ); |
|
774 | + $option = array_map('trim', explode('|', $option)); |
|
775 | 775 | |
776 | 776 | $price = null; |
777 | 777 | $label = null; |
778 | 778 | |
779 | - if ( isset( $option[0] ) && '' != $option[0] ) { |
|
780 | - $label = $option[0]; |
|
779 | + if (isset($option[0]) && '' != $option[0]) { |
|
780 | + $label = $option[0]; |
|
781 | 781 | } |
782 | 782 | |
783 | - if ( isset( $option[1] ) && '' != $option[1] ) { |
|
783 | + if (isset($option[1]) && '' != $option[1]) { |
|
784 | 784 | $price = $option[1]; |
785 | 785 | } |
786 | 786 | |
787 | - if ( ! isset( $price ) ) { |
|
787 | + if (!isset($price)) { |
|
788 | 788 | $price = $label; |
789 | 789 | } |
790 | 790 | |
791 | - if ( ! isset( $price ) || ! is_numeric( $price ) ) { |
|
791 | + if (!isset($price) || !is_numeric($price)) { |
|
792 | 792 | continue; |
793 | 793 | } |
794 | 794 | |
795 | - if ( ! isset( $label ) ) { |
|
795 | + if (!isset($label)) { |
|
796 | 796 | $label = $price; |
797 | 797 | } |
798 | 798 | |
799 | - $options[ $price ] = $label; |
|
799 | + $options[$price] = $label; |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | return $options; |
@@ -805,22 +805,22 @@ discard block |
||
805 | 805 | /** |
806 | 806 | * Returns the help tip. |
807 | 807 | */ |
808 | -function getpaid_get_help_tip( $tip, $additional_classes = '' ) { |
|
809 | - $additional_classes = sanitize_html_class( $additional_classes ); |
|
810 | - $tip = esc_attr__( $tip ); |
|
808 | +function getpaid_get_help_tip($tip, $additional_classes = '') { |
|
809 | + $additional_classes = sanitize_html_class($additional_classes); |
|
810 | + $tip = esc_attr__($tip); |
|
811 | 811 | return "<span class='wpi-help-tip dashicons dashicons-editor-help $additional_classes' title='$tip'></span>"; |
812 | 812 | } |
813 | 813 | |
814 | 814 | /** |
815 | 815 | * Formats a date |
816 | 816 | */ |
817 | -function getpaid_format_date( $date ) { |
|
817 | +function getpaid_format_date($date) { |
|
818 | 818 | |
819 | - if ( empty( $date ) || $date == '0000-00-00 00:00:00' ) { |
|
819 | + if (empty($date) || $date == '0000-00-00 00:00:00') { |
|
820 | 820 | return ''; |
821 | 821 | } |
822 | 822 | |
823 | - return date_i18n( getpaid_date_format(), strtotime( $date ) ); |
|
823 | + return date_i18n(getpaid_date_format(), strtotime($date)); |
|
824 | 824 | |
825 | 825 | } |
826 | 826 | |
@@ -829,9 +829,9 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @return string |
831 | 831 | */ |
832 | -function getpaid_format_date_value( $date, $default = "—" ) { |
|
833 | - $date = getpaid_format_date( $date ); |
|
834 | - return empty( $date ) ? $default : $date; |
|
832 | +function getpaid_format_date_value($date, $default = "—") { |
|
833 | + $date = getpaid_format_date($date); |
|
834 | + return empty($date) ? $default : $date; |
|
835 | 835 | } |
836 | 836 | |
837 | 837 | /** |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | * @return string |
841 | 841 | */ |
842 | 842 | function getpaid_date_format() { |
843 | - return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) ); |
|
843 | + return apply_filters('getpaid_date_format', get_option('date_format')); |
|
844 | 844 | } |
845 | 845 | |
846 | 846 | /** |
@@ -849,7 +849,7 @@ discard block |
||
849 | 849 | * @return string |
850 | 850 | */ |
851 | 851 | function getpaid_time_format() { |
852 | - return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) ); |
|
852 | + return apply_filters('getpaid_time_format', get_option('time_format')); |
|
853 | 853 | } |
854 | 854 | |
855 | 855 | /** |
@@ -859,16 +859,16 @@ discard block |
||
859 | 859 | * @param integer $limit Limit size in characters. |
860 | 860 | * @return string |
861 | 861 | */ |
862 | -function getpaid_limit_length( $string, $limit ) { |
|
862 | +function getpaid_limit_length($string, $limit) { |
|
863 | 863 | $str_limit = $limit - 3; |
864 | 864 | |
865 | - if ( function_exists( 'mb_strimwidth' ) ) { |
|
866 | - if ( mb_strlen( $string ) > $limit ) { |
|
867 | - $string = mb_strimwidth( $string, 0, $str_limit ) . '...'; |
|
865 | + if (function_exists('mb_strimwidth')) { |
|
866 | + if (mb_strlen($string) > $limit) { |
|
867 | + $string = mb_strimwidth($string, 0, $str_limit) . '...'; |
|
868 | 868 | } |
869 | 869 | } else { |
870 | - if ( strlen( $string ) > $limit ) { |
|
871 | - $string = substr( $string, 0, $str_limit ) . '...'; |
|
870 | + if (strlen($string) > $limit) { |
|
871 | + $string = substr($string, 0, $str_limit) . '...'; |
|
872 | 872 | } |
873 | 873 | } |
874 | 874 | return $string; |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * @since 1.0.19 |
883 | 883 | */ |
884 | 884 | function getpaid_api() { |
885 | - return getpaid()->get( 'api' ); |
|
885 | + return getpaid()->get('api'); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -892,7 +892,7 @@ discard block |
||
892 | 892 | * @since 1.0.19 |
893 | 893 | */ |
894 | 894 | function getpaid_post_types() { |
895 | - return getpaid()->get( 'post_types' ); |
|
895 | + return getpaid()->get('post_types'); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @since 1.0.19 |
903 | 903 | */ |
904 | 904 | function getpaid_session() { |
905 | - return getpaid()->get( 'session' ); |
|
905 | + return getpaid()->get('session'); |
|
906 | 906 | } |
907 | 907 | |
908 | 908 | /** |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | * @since 1.0.19 |
913 | 913 | */ |
914 | 914 | function getpaid_notes() { |
915 | - return getpaid()->get( 'notes' ); |
|
915 | + return getpaid()->get('notes'); |
|
916 | 916 | } |
917 | 917 | |
918 | 918 | /** |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * @return GetPaid_Admin |
922 | 922 | */ |
923 | 923 | function getpaid_admin() { |
924 | - return getpaid()->get( 'admin' ); |
|
924 | + return getpaid()->get('admin'); |
|
925 | 925 | } |
926 | 926 | |
927 | 927 | /** |
@@ -931,6 +931,6 @@ discard block |
||
931 | 931 | * @param string $base the base url |
932 | 932 | * @return string |
933 | 933 | */ |
934 | -function getpaid_get_authenticated_action_url( $action, $base = false ) { |
|
935 | - return wp_nonce_url( add_query_arg( 'getpaid-action', $action, $base ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
934 | +function getpaid_get_authenticated_action_url($action, $base = false) { |
|
935 | + return wp_nonce_url(add_query_arg('getpaid-action', $action, $base), 'getpaid-nonce', 'getpaid-nonce'); |
|
936 | 936 | } |
@@ -117,14 +117,14 @@ |
||
117 | 117 | */ |
118 | 118 | function getpaid_doing_it_wrong( $function, $message, $version ) { |
119 | 119 | |
120 | - $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | - |
|
122 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | - } else { |
|
126 | - _doing_it_wrong( $function, $message, $version ); |
|
127 | - } |
|
120 | + $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
|
121 | + |
|
122 | + if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
123 | + do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
124 | + error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
125 | + } else { |
|
126 | + _doing_it_wrong( $function, $message, $version ); |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns the errors as html |
@@ -15,36 +15,36 @@ discard block |
||
15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
16 | 16 | * @since 1.0.19 |
17 | 17 | */ |
18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
19 | 19 | |
20 | 20 | $errors = ''; |
21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
22 | - $type = 'error'; |
|
21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
22 | + $type = 'error'; |
|
23 | 23 | |
24 | - if ( is_array( $error ) ) { |
|
24 | + if (is_array($error)) { |
|
25 | 25 | $type = $error['type']; |
26 | 26 | $error = $error['text']; |
27 | 27 | } |
28 | 28 | |
29 | - if ( $wrap ) { |
|
29 | + if ($wrap) { |
|
30 | 30 | |
31 | 31 | $errors .= aui()->alert( |
32 | 32 | array( |
33 | - 'content' => wp_kses_post( $error ), |
|
33 | + 'content' => wp_kses_post($error), |
|
34 | 34 | 'type' => $type, |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - $id = esc_attr( $id ); |
|
41 | - $error = wp_kses_post( $error ); |
|
40 | + $id = esc_attr($id); |
|
41 | + $error = wp_kses_post($error); |
|
42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
43 | 43 | } |
44 | 44 | |
45 | 45 | } |
46 | 46 | |
47 | - if ( $clear ){ |
|
47 | + if ($clear) { |
|
48 | 48 | wpinv_clear_errors(); |
49 | 49 | } |
50 | 50 | |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @return array |
66 | 66 | */ |
67 | 67 | function wpinv_get_errors() { |
68 | - $errors = getpaid_session()->get( 'wpinv_errors' ); |
|
69 | - return is_array( $errors ) ? $errors : array(); |
|
68 | + $errors = getpaid_session()->get('wpinv_errors'); |
|
69 | + return is_array($errors) ? $errors : array(); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | * @param string $error_message The error message. |
77 | 77 | * @param string $type Either error, info, warning, primary, dark, light or success. |
78 | 78 | */ |
79 | -function wpinv_set_error( $error_id, $error_message, $type = 'error' ) { |
|
79 | +function wpinv_set_error($error_id, $error_message, $type = 'error') { |
|
80 | 80 | |
81 | 81 | $errors = wpinv_get_errors(); |
82 | - $errors[ $error_id ] = array( |
|
82 | + $errors[$error_id] = array( |
|
83 | 83 | 'type' => $type, |
84 | 84 | 'text' => $error_message, |
85 | 85 | ); |
86 | 86 | |
87 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
87 | + getpaid_session()->set('wpinv_errors', $errors); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | * |
93 | 93 | */ |
94 | 94 | function wpinv_has_errors() { |
95 | - return count( wpinv_get_errors() ) > 0; |
|
95 | + return count(wpinv_get_errors()) > 0; |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
@@ -100,21 +100,21 @@ discard block |
||
100 | 100 | * |
101 | 101 | */ |
102 | 102 | function wpinv_clear_errors() { |
103 | - getpaid_session()->set( 'wpinv_errors', null ); |
|
103 | + getpaid_session()->set('wpinv_errors', null); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * Clears a single error. |
108 | 108 | * |
109 | 109 | */ |
110 | -function wpinv_unset_error( $error_id ) { |
|
110 | +function wpinv_unset_error($error_id) { |
|
111 | 111 | $errors = wpinv_get_errors(); |
112 | 112 | |
113 | - if ( isset( $errors[ $error_id ] ) ) { |
|
114 | - unset( $errors[ $error_id ] ); |
|
113 | + if (isset($errors[$error_id])) { |
|
114 | + unset($errors[$error_id]); |
|
115 | 115 | } |
116 | 116 | |
117 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
117 | + getpaid_session()->set('wpinv_errors', $errors); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | /** |
@@ -125,15 +125,15 @@ discard block |
||
125 | 125 | * @param string $message Message to log. |
126 | 126 | * @param string $version Version the message was added in. |
127 | 127 | */ |
128 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
128 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
129 | 129 | |
130 | 130 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
131 | 131 | |
132 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
133 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
134 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
132 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
133 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
134 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
135 | 135 | } else { |
136 | - _doing_it_wrong( $function, $message, $version ); |
|
136 | + _doing_it_wrong($function, $message, $version); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | } |
@@ -147,40 +147,40 @@ discard block |
||
147 | 147 | * @param string $line The line that contains the error. |
148 | 148 | * @param bool $exit Whether or not to exit function execution. |
149 | 149 | */ |
150 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
150 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
151 | 151 | |
152 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
152 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
153 | 153 | |
154 | 154 | // Ensure the log is a scalar. |
155 | - if ( ! is_scalar( $log ) ) { |
|
156 | - $log = print_r( $log, true ); |
|
155 | + if (!is_scalar($log)) { |
|
156 | + $log = print_r($log, true); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | // Add title. |
160 | - if ( ! empty( $title ) ) { |
|
161 | - $log = $title . ' ' . trim( $log ); |
|
160 | + if (!empty($title)) { |
|
161 | + $log = $title . ' ' . trim($log); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Add the file to the label. |
165 | - if ( ! empty( $file ) ) { |
|
165 | + if (!empty($file)) { |
|
166 | 166 | $log .= ' in ' . $file; |
167 | 167 | } |
168 | 168 | |
169 | 169 | // Add the line number to the label. |
170 | - if ( ! empty( $line ) ) { |
|
170 | + if (!empty($line)) { |
|
171 | 171 | $log .= ' on line ' . $line; |
172 | 172 | } |
173 | 173 | |
174 | 174 | // Log the message. |
175 | - error_log( trim ( $log ) ); |
|
175 | + error_log(trim($log)); |
|
176 | 176 | |
177 | 177 | // ... and a backtrace. |
178 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
178 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
179 | 179 | |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Maybe exit. |
183 | - if ( $exit ) { |
|
183 | + if ($exit) { |
|
184 | 184 | exit; |
185 | 185 | } |
186 | 186 |
@@ -36,36 +36,36 @@ discard block |
||
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
38 | 38 | 'advanced' => false |
39 | - ), |
|
39 | + ), |
|
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | - 'type' => 'text', |
|
45 | - 'desc_tip' => true, |
|
46 | - 'default' => '', |
|
47 | - 'placeholder' => __('1','invoicing'), |
|
48 | - 'advanced' => false |
|
49 | - ), |
|
50 | - |
|
51 | - 'item' => array( |
|
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | - 'type' => 'text', |
|
55 | - 'desc_tip' => true, |
|
56 | - 'default' => '', |
|
57 | - 'placeholder' => __('1','invoicing'), |
|
58 | - 'advanced' => false |
|
59 | - ), |
|
42 | + 'title' => __( 'Form', 'invoicing' ), |
|
43 | + 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
44 | + 'type' => 'text', |
|
45 | + 'desc_tip' => true, |
|
46 | + 'default' => '', |
|
47 | + 'placeholder' => __('1','invoicing'), |
|
48 | + 'advanced' => false |
|
49 | + ), |
|
50 | + |
|
51 | + 'item' => array( |
|
52 | + 'title' => __( 'Items', 'invoicing' ), |
|
53 | + 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
54 | + 'type' => 'text', |
|
55 | + 'desc_tip' => true, |
|
56 | + 'default' => '', |
|
57 | + 'placeholder' => __('1','invoicing'), |
|
58 | + 'advanced' => false |
|
59 | + ), |
|
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | - 'type' => 'text', |
|
65 | - 'desc_tip' => true, |
|
66 | - 'default' => '', |
|
67 | - 'advanced' => false |
|
68 | - ) |
|
62 | + 'title' => __( 'Button', 'invoicing' ), |
|
63 | + 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
64 | + 'type' => 'text', |
|
65 | + 'desc_tip' => true, |
|
66 | + 'default' => '', |
|
67 | + 'advanced' => false |
|
68 | + ) |
|
69 | 69 | |
70 | 70 | ) |
71 | 71 | |
@@ -75,95 +75,95 @@ discard block |
||
75 | 75 | parent::__construct( $options ); |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * The Super block output function. |
|
80 | - * |
|
81 | - * @param array $args |
|
82 | - * @param array $widget_args |
|
83 | - * @param string $content |
|
84 | - * |
|
85 | - * @return string |
|
86 | - */ |
|
78 | + /** |
|
79 | + * The Super block output function. |
|
80 | + * |
|
81 | + * @param array $args |
|
82 | + * @param array $widget_args |
|
83 | + * @param string $content |
|
84 | + * |
|
85 | + * @return string |
|
86 | + */ |
|
87 | 87 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
88 | 88 | |
89 | - // Is the shortcode set up correctly? |
|
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | - return aui()->alert( |
|
92 | - array( |
|
93 | - 'type' => 'warning', |
|
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | - ) |
|
96 | - ); |
|
97 | - } |
|
98 | - |
|
99 | - // Payment form or button? |
|
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
102 | - } else { |
|
103 | - return $this->handle_buy_item( $args ); |
|
104 | - } |
|
105 | - |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Displaying a payment form |
|
110 | - * |
|
111 | - * @return string |
|
112 | - */ |
|
89 | + // Is the shortcode set up correctly? |
|
90 | + if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
91 | + return aui()->alert( |
|
92 | + array( |
|
93 | + 'type' => 'warning', |
|
94 | + 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
95 | + ) |
|
96 | + ); |
|
97 | + } |
|
98 | + |
|
99 | + // Payment form or button? |
|
100 | + if ( ! empty( $args['form'] ) ) { |
|
101 | + return $this->handle_payment_form( $args ); |
|
102 | + } else { |
|
103 | + return $this->handle_buy_item( $args ); |
|
104 | + } |
|
105 | + |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Displaying a payment form |
|
110 | + * |
|
111 | + * @return string |
|
112 | + */ |
|
113 | 113 | protected function handle_payment_form( $args = array() ) { |
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
116 | - ob_start(); |
|
117 | - getpaid_display_payment_form( $args['form'] ); |
|
118 | - return ob_get_clean(); |
|
119 | - } |
|
115 | + if ( empty( $args['button'] ) ) { |
|
116 | + ob_start(); |
|
117 | + getpaid_display_payment_form( $args['form'] ); |
|
118 | + return ob_get_clean(); |
|
119 | + } |
|
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | - } |
|
121 | + return $this->payment_form_button( $args['form'], $args['button'] ); |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Displays a payment form button. |
|
126 | - * |
|
127 | - * @return string |
|
128 | - */ |
|
124 | + /** |
|
125 | + * Displays a payment form button. |
|
126 | + * |
|
127 | + * @return string |
|
128 | + */ |
|
129 | 129 | protected function payment_form_button( $form, $button ) { |
130 | - return getpaid_get_payment_button( $button, $form ); |
|
131 | - } |
|
132 | - |
|
133 | - /** |
|
134 | - * Selling an item |
|
135 | - * |
|
136 | - * @return string |
|
137 | - */ |
|
130 | + return getpaid_get_payment_button( $button, $form ); |
|
131 | + } |
|
132 | + |
|
133 | + /** |
|
134 | + * Selling an item |
|
135 | + * |
|
136 | + * @return string |
|
137 | + */ |
|
138 | 138 | protected function handle_buy_item( $args = array() ) { |
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
142 | - } |
|
140 | + if ( empty( $args['button'] ) ) { |
|
141 | + return $this->buy_item_form( $args['item'] ); |
|
142 | + } |
|
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button( $args['item'], $args['button'] ); |
|
145 | 145 | |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
149 | - * Displays a buy item form. |
|
150 | - * |
|
151 | - * @return string |
|
152 | - */ |
|
148 | + /** |
|
149 | + * Displays a buy item form. |
|
150 | + * |
|
151 | + * @return string |
|
152 | + */ |
|
153 | 153 | protected function buy_item_form( $item ) { |
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
155 | - ob_start(); |
|
156 | - getpaid_display_item_payment_form( $items ); |
|
157 | - return ob_get_clean(); |
|
158 | - } |
|
159 | - |
|
160 | - /** |
|
161 | - * Displays a buy item button. |
|
162 | - * |
|
163 | - * @return string |
|
164 | - */ |
|
154 | + $items = getpaid_convert_items_to_array( $item ); |
|
155 | + ob_start(); |
|
156 | + getpaid_display_item_payment_form( $items ); |
|
157 | + return ob_get_clean(); |
|
158 | + } |
|
159 | + |
|
160 | + /** |
|
161 | + * Displays a buy item button. |
|
162 | + * |
|
163 | + * @return string |
|
164 | + */ |
|
165 | 165 | protected function buy_item_button( $item, $button ) { |
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
166 | + return getpaid_get_payment_button( $button, null, $item ); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -22,16 +22,16 @@ discard block |
||
22 | 22 | 'block-keywords'=> "['invoicing','buy', 'buy item', 'form']", |
23 | 23 | 'class_name' => __CLASS__, |
24 | 24 | 'base_id' => 'getpaid', |
25 | - 'name' => __('GetPaid','invoicing'), |
|
25 | + 'name' => __('GetPaid', 'invoicing'), |
|
26 | 26 | 'widget_ops' => array( |
27 | 27 | 'classname' => 'getpaid bsui', |
28 | - 'description' => esc_html__('Show payment forms or buttons.','invoicing'), |
|
28 | + 'description' => esc_html__('Show payment forms or buttons.', 'invoicing'), |
|
29 | 29 | ), |
30 | 30 | 'arguments' => array( |
31 | 31 | |
32 | 32 | 'title' => array( |
33 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
34 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
33 | + 'title' => __('Widget title', 'invoicing'), |
|
34 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
35 | 35 | 'type' => 'text', |
36 | 36 | 'desc_tip' => true, |
37 | 37 | 'default' => '', |
@@ -39,28 +39,28 @@ discard block |
||
39 | 39 | ), |
40 | 40 | |
41 | 41 | 'form' => array( |
42 | - 'title' => __( 'Form', 'invoicing' ), |
|
43 | - 'desc' => __( 'Enter a form id in case you want to display a specific payment form', 'invoicing' ), |
|
42 | + 'title' => __('Form', 'invoicing'), |
|
43 | + 'desc' => __('Enter a form id in case you want to display a specific payment form', 'invoicing'), |
|
44 | 44 | 'type' => 'text', |
45 | 45 | 'desc_tip' => true, |
46 | 46 | 'default' => '', |
47 | - 'placeholder' => __('1','invoicing'), |
|
47 | + 'placeholder' => __('1', 'invoicing'), |
|
48 | 48 | 'advanced' => false |
49 | 49 | ), |
50 | 50 | |
51 | 51 | 'item' => array( |
52 | - 'title' => __( 'Items', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing' ), |
|
52 | + 'title' => __('Items', 'invoicing'), |
|
53 | + 'desc' => __('Enter comma separated list of invoicing item id and quantity (item_id|quantity). Ex. 101|2. This will be ignored in case you specify a form above. Enter 0 as the quantity to let users select their own quantities', 'invoicing'), |
|
54 | 54 | 'type' => 'text', |
55 | 55 | 'desc_tip' => true, |
56 | 56 | 'default' => '', |
57 | - 'placeholder' => __('1','invoicing'), |
|
57 | + 'placeholder' => __('1', 'invoicing'), |
|
58 | 58 | 'advanced' => false |
59 | 59 | ), |
60 | 60 | |
61 | 61 | 'button' => array( |
62 | - 'title' => __( 'Button', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter button label in case you would like to display the forms in a popup.', 'invoicing' ), |
|
62 | + 'title' => __('Button', 'invoicing'), |
|
63 | + 'desc' => __('Enter button label in case you would like to display the forms in a popup.', 'invoicing'), |
|
64 | 64 | 'type' => 'text', |
65 | 65 | 'desc_tip' => true, |
66 | 66 | 'default' => '', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | ); |
73 | 73 | |
74 | 74 | |
75 | - parent::__construct( $options ); |
|
75 | + parent::__construct($options); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
@@ -84,23 +84,23 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return string |
86 | 86 | */ |
87 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
87 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
88 | 88 | |
89 | 89 | // Is the shortcode set up correctly? |
90 | - if ( empty( $args['form'] ) && empty( $args['item'] ) ) { |
|
90 | + if (empty($args['form']) && empty($args['item'])) { |
|
91 | 91 | return aui()->alert( |
92 | 92 | array( |
93 | 93 | 'type' => 'warning', |
94 | - 'content' => __( 'No payment form or item selected', 'invoicing' ), |
|
94 | + 'content' => __('No payment form or item selected', 'invoicing'), |
|
95 | 95 | ) |
96 | 96 | ); |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Payment form or button? |
100 | - if ( ! empty( $args['form'] ) ) { |
|
101 | - return $this->handle_payment_form( $args ); |
|
100 | + if (!empty($args['form'])) { |
|
101 | + return $this->handle_payment_form($args); |
|
102 | 102 | } else { |
103 | - return $this->handle_buy_item( $args ); |
|
103 | + return $this->handle_buy_item($args); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | } |
@@ -110,15 +110,15 @@ discard block |
||
110 | 110 | * |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - protected function handle_payment_form( $args = array() ) { |
|
113 | + protected function handle_payment_form($args = array()) { |
|
114 | 114 | |
115 | - if ( empty( $args['button'] ) ) { |
|
115 | + if (empty($args['button'])) { |
|
116 | 116 | ob_start(); |
117 | - getpaid_display_payment_form( $args['form'] ); |
|
117 | + getpaid_display_payment_form($args['form']); |
|
118 | 118 | return ob_get_clean(); |
119 | 119 | } |
120 | 120 | |
121 | - return $this->payment_form_button( $args['form'], $args['button'] ); |
|
121 | + return $this->payment_form_button($args['form'], $args['button']); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * |
127 | 127 | * @return string |
128 | 128 | */ |
129 | - protected function payment_form_button( $form, $button ) { |
|
130 | - return getpaid_get_payment_button( $button, $form ); |
|
129 | + protected function payment_form_button($form, $button) { |
|
130 | + return getpaid_get_payment_button($button, $form); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -135,13 +135,13 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return string |
137 | 137 | */ |
138 | - protected function handle_buy_item( $args = array() ) { |
|
138 | + protected function handle_buy_item($args = array()) { |
|
139 | 139 | |
140 | - if ( empty( $args['button'] ) ) { |
|
141 | - return $this->buy_item_form( $args['item'] ); |
|
140 | + if (empty($args['button'])) { |
|
141 | + return $this->buy_item_form($args['item']); |
|
142 | 142 | } |
143 | 143 | |
144 | - return $this->buy_item_button( $args['item'], $args['button'] ); |
|
144 | + return $this->buy_item_button($args['item'], $args['button']); |
|
145 | 145 | |
146 | 146 | } |
147 | 147 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - protected function buy_item_form( $item ) { |
|
154 | - $items = getpaid_convert_items_to_array( $item ); |
|
153 | + protected function buy_item_form($item) { |
|
154 | + $items = getpaid_convert_items_to_array($item); |
|
155 | 155 | ob_start(); |
156 | - getpaid_display_item_payment_form( $items ); |
|
156 | + getpaid_display_item_payment_form($items); |
|
157 | 157 | return ob_get_clean(); |
158 | 158 | } |
159 | 159 | |
@@ -162,8 +162,8 @@ discard block |
||
162 | 162 | * |
163 | 163 | * @return string |
164 | 164 | */ |
165 | - protected function buy_item_button( $item, $button ) { |
|
166 | - return getpaid_get_payment_button( $button, null, $item ); |
|
165 | + protected function buy_item_button($item, $button) { |
|
166 | + return getpaid_get_payment_button($button, null, $item); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -7,52 +7,52 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <small class='form-text text-muted mb-2'> |
15 | - <?php esc_html_e( 'This amount will be added to the total amount for this form', 'invoicing' ); ?> |
|
15 | + <?php esc_html_e('This amount will be added to the total amount for this form', 'invoicing'); ?> |
|
16 | 16 | </small> |
17 | 17 | |
18 | 18 | <div class='form-group'> |
19 | 19 | <label class="d-block"> |
20 | - <span><?php esc_html_e( 'Field Label', 'invoicing' ); ?></span> |
|
20 | + <span><?php esc_html_e('Field Label', 'invoicing'); ?></span> |
|
21 | 21 | <input v-model='active_form_element.label' class='form-control' /> |
22 | 22 | </label> |
23 | 23 | </div> |
24 | 24 | |
25 | 25 | <div class='form-group' v-if="active_form_element.select_type=='select'"> |
26 | 26 | <label class="d-block"> |
27 | - <span><?php esc_html_e( 'Placeholder text', 'invoicing' ); ?></span> |
|
27 | + <span><?php esc_html_e('Placeholder text', 'invoicing'); ?></span> |
|
28 | 28 | <input v-model='active_form_element.placeholder' class='form-control' /> |
29 | 29 | </label> |
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class='form-group'> |
33 | 33 | <label class="d-block"> |
34 | - <span><?php esc_html_e( 'Select Type', 'invoicing' ); ?></span> |
|
34 | + <span><?php esc_html_e('Select Type', 'invoicing'); ?></span> |
|
35 | 35 | <select class='form-control custom-select' v-model='active_form_element.select_type'> |
36 | - <option value='select'><?php esc_html_e( 'Dropdown', 'invoicing' ) ?></option> |
|
37 | - <option value='checkboxes'><?php esc_html_e( 'Checkboxes', 'invoicing' ) ?></option> |
|
38 | - <option value='radios'><?php esc_html_e( 'Radio Buttons', 'invoicing' ) ?></option> |
|
39 | - <option value='buttons'><?php esc_html_e( 'Buttons', 'invoicing' ) ?></option> |
|
40 | - <option value='circles'><?php esc_html_e( 'Circles', 'invoicing' ) ?></option> |
|
36 | + <option value='select'><?php esc_html_e('Dropdown', 'invoicing') ?></option> |
|
37 | + <option value='checkboxes'><?php esc_html_e('Checkboxes', 'invoicing') ?></option> |
|
38 | + <option value='radios'><?php esc_html_e('Radio Buttons', 'invoicing') ?></option> |
|
39 | + <option value='buttons'><?php esc_html_e('Buttons', 'invoicing') ?></option> |
|
40 | + <option value='circles'><?php esc_html_e('Circles', 'invoicing') ?></option> |
|
41 | 41 | </select> |
42 | 42 | </label> |
43 | 43 | </div> |
44 | 44 | |
45 | 45 | <div class='form-group'> |
46 | 46 | <label class="d-block"> |
47 | - <span><?php esc_html_e( 'Options', 'invoicing' ); ?></span> |
|
47 | + <span><?php esc_html_e('Options', 'invoicing'); ?></span> |
|
48 | 48 | <textarea placeholder='Basic|10,Pro|99,Business|199' v-model='active_form_element.options' class='form-control' rows='3'></textarea> |
49 | - <small class='form-text text-muted mb-2'><?php esc_html_e( 'Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing' ); ?></small> |
|
49 | + <small class='form-text text-muted mb-2'><?php esc_html_e('Use commas to separate options and pipes to separate a label and its price. Do not include a currency symbol in the price.', 'invoicing'); ?></small> |
|
50 | 50 | </label> |
51 | 51 | </div> |
52 | 52 | |
53 | 53 | <div class='form-group'> |
54 | 54 | <label class="d-block"> |
55 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
56 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
55 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
56 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
57 | 57 | </label> |
58 | 58 | </div> |
@@ -8,24 +8,24 @@ |
||
8 | 8 | */ |
9 | 9 | |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | 15 | <div class='form-group'> |
16 | - <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e( 'Heading', 'invoicing' ) ?></label> |
|
16 | + <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e('Heading', 'invoicing') ?></label> |
|
17 | 17 | <input :id="active_form_element.id + '_edit_heading'" v-model='active_form_element.text' class='form-control' type='text' /> |
18 | 18 | </div> |
19 | 19 | |
20 | 20 | <div class='form-group'> |
21 | - <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e( 'Select Heading Level', 'invoicing' ) ?></label> |
|
21 | + <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e('Select Heading Level', 'invoicing') ?></label> |
|
22 | 22 | <select class='form-control custom-select' :id="active_form_element.id + '_edit_level'" v-model='active_form_element.level'> |
23 | - <option value='h1'><?php esc_html_e( 'H1', 'invoicing' ); ?></option> |
|
24 | - <option value='h2'><?php esc_html_e( 'H2', 'invoicing' ); ?></option> |
|
25 | - <option value='h3'><?php esc_html_e( 'H3', 'invoicing' ); ?></option> |
|
26 | - <option value='h4'><?php esc_html_e( 'H4', 'invoicing' ); ?></option> |
|
27 | - <option value='h5'><?php esc_html_e( 'H5', 'invoicing' ); ?></option> |
|
28 | - <option value='h6'><?php esc_html_e( 'H6', 'invoicing' ); ?></option> |
|
29 | - <option value='h7'><?php esc_html_e( 'H7', 'invoicing' ); ?></option> |
|
23 | + <option value='h1'><?php esc_html_e('H1', 'invoicing'); ?></option> |
|
24 | + <option value='h2'><?php esc_html_e('H2', 'invoicing'); ?></option> |
|
25 | + <option value='h3'><?php esc_html_e('H3', 'invoicing'); ?></option> |
|
26 | + <option value='h4'><?php esc_html_e('H4', 'invoicing'); ?></option> |
|
27 | + <option value='h5'><?php esc_html_e('H5', 'invoicing'); ?></option> |
|
28 | + <option value='h6'><?php esc_html_e('H6', 'invoicing'); ?></option> |
|
29 | + <option value='h7'><?php esc_html_e('H7', 'invoicing'); ?></option> |
|
30 | 30 | </select> |
31 | 31 | </div> |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | - <label :for="active_form_element.id + '_edit'"><?php esc_html_e( 'The total payable text', 'invoicing' ) ?></label> |
|
15 | + <label :for="active_form_element.id + '_edit'"><?php esc_html_e('The total payable text', 'invoicing') ?></label> |
|
16 | 16 | <textarea :id="active_form_element.id + '_edit'" v-model='active_form_element.text' class='form-control' rows='3'></textarea> |
17 | 17 | </div> |
@@ -7,27 +7,27 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | 15 | <label class="d-block"> |
16 | - <span><?php esc_html_e( 'Input Label', 'invoicing' ); ?></span> |
|
16 | + <span><?php esc_html_e('Input Label', 'invoicing'); ?></span> |
|
17 | 17 | <input v-model='active_form_element.input_label' class='form-control' type="text"/> |
18 | 18 | </label> |
19 | 19 | </div> |
20 | 20 | |
21 | 21 | <div class='form-group'> |
22 | 22 | <label class="d-block"> |
23 | - <span><?php esc_html_e( 'Button Label', 'invoicing' ); ?></span> |
|
23 | + <span><?php esc_html_e('Button Label', 'invoicing'); ?></span> |
|
24 | 24 | <input v-model='active_form_element.button_label' class='form-control' type="text"/> |
25 | 25 | </label> |
26 | 26 | </div> |
27 | 27 | |
28 | 28 | <div class='form-group'> |
29 | 29 | <label class="d-block"> |
30 | - <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span> |
|
31 | - <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
30 | + <span><?php esc_html_e('Help Text', 'invoicing'); ?></span> |
|
31 | + <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea> |
|
32 | 32 | </label> |
33 | 33 | </div> |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class='form-group'> |
15 | - <label :for="active_form_element.id + '_edit'"><?php esc_html_e( 'Enter your text', 'invoicing' ) ?></label> |
|
15 | + <label :for="active_form_element.id + '_edit'"><?php esc_html_e('Enter your text', 'invoicing') ?></label> |
|
16 | 16 | <textarea :id="active_form_element.id + '_edit'" v-model='active_form_element.text' class='form-control' rows='3'></textarea> |
17 | 17 | </div> |