@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Manual Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'addons' ); |
|
27 | + protected $supports = array('subscription', 'addons'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | - $this->title = __( 'Test Gateway', 'invoicing' ); |
|
43 | - $this->method_title = __( 'Test Gateway', 'invoicing' ); |
|
42 | + $this->title = __('Test Gateway', 'invoicing'); |
|
43 | + $this->method_title = __('Test Gateway', 'invoicing'); |
|
44 | 44 | |
45 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
45 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
57 | + public function process_payment($invoice, $submission_data, $submission) { |
|
58 | 58 | |
59 | 59 | // Mark it as paid. |
60 | 60 | $invoice->mark_paid(); |
61 | 61 | |
62 | 62 | // (Maybe) activate subscription. |
63 | - getpaid_activate_invoice_subscription( $invoice ); |
|
63 | + getpaid_activate_invoice_subscription($invoice); |
|
64 | 64 | |
65 | 65 | // Send to the success page. |
66 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
66 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @param bool $should_expire |
75 | 75 | * @param WPInv_Subscription $subscription |
76 | 76 | */ |
77 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
77 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
78 | 78 | |
79 | 79 | // Ensure its our subscription && it's active. |
80 | - if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
80 | + if ('manual' != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
81 | 81 | return $should_expire; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // If this is the last renewal, complete the subscription. |
85 | - if ( $subscription->is_last_renewal() ) { |
|
85 | + if ($subscription->is_last_renewal()) { |
|
86 | 86 | $subscription->complete(); |
87 | 87 | return false; |
88 | 88 | } |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | * @param GetPaid_Form_Item[] $items |
109 | 109 | * @return WPInv_Invoice |
110 | 110 | */ |
111 | - public function process_addons( $invoice, $items ) { |
|
111 | + public function process_addons($invoice, $items) { |
|
112 | 112 | |
113 | - foreach ( $items as $item ) { |
|
114 | - $invoice->add_item( $item ); |
|
113 | + foreach ($items as $item) { |
|
114 | + $invoice->add_item($item); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | $invoice->recalculate_total(); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,17 +57,17 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email ) { |
|
60 | +function wpinv_create_user($email) { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | 63 | $args = array( |
64 | - 'user_login' => wpinv_generate_user_name( $email ), |
|
64 | + 'user_login' => wpinv_generate_user_name($email), |
|
65 | 65 | 'user_pass' => wp_generate_password(), |
66 | 66 | 'user_email' => $email, |
67 | 67 | 'role' => 'subscriber', |
68 | 68 | ); |
69 | 69 | |
70 | - return wp_insert_user( $args ); |
|
70 | + return wp_insert_user($args); |
|
71 | 71 | |
72 | 72 | } |
73 | 73 | |
@@ -77,22 +77,22 @@ discard block |
||
77 | 77 | * @since 1.0.19 |
78 | 78 | * @return bool|WP_User |
79 | 79 | */ |
80 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
80 | +function wpinv_generate_user_name($prefix = '') { |
|
81 | 81 | |
82 | 82 | // If prefix is an email, retrieve the part before the email. |
83 | - $prefix = strtok( $prefix, '@' ); |
|
83 | + $prefix = strtok($prefix, '@'); |
|
84 | 84 | |
85 | 85 | // Trim to 4 characters max. |
86 | - $prefix = sanitize_user( $prefix ); |
|
86 | + $prefix = sanitize_user($prefix); |
|
87 | 87 | |
88 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
89 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
88 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
89 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
90 | 90 | $prefix = 'gtp'; |
91 | 91 | } |
92 | 92 | |
93 | - $username = $prefix . '_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | - if ( username_exists( $username ) ) { |
|
95 | - return wpinv_generate_user_name( $username ); |
|
93 | + $username = $prefix . '_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | + if (username_exists($username)) { |
|
95 | + return wpinv_generate_user_name($username); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | return $username; |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | |
111 | 111 | // Slug - invoices. |
112 | 112 | 'gp-invoices' => array( |
113 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
113 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
114 | 114 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
115 | 115 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'gp-subscriptions' => array( |
119 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
119 | + 'label' => __('Subscriptions', 'invoicing'), |
|
120 | 120 | 'content' => '[wpinv_subscriptions]', |
121 | 121 | 'icon' => 'fas fa-redo', |
122 | 122 | ) |
123 | 123 | ); |
124 | 124 | |
125 | - return apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
125 | + return apply_filters('getpaid_user_content_tabs', $tabs); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -132,19 +132,19 @@ discard block |
||
132 | 132 | * @param array $tab |
133 | 133 | * @return array |
134 | 134 | */ |
135 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
135 | +function getpaid_prepare_user_content_tab($tab) { |
|
136 | 136 | |
137 | - if ( ! empty( $tab['callback'] ) ) { |
|
138 | - return call_user_func( $tab['callback'] ); |
|
137 | + if (!empty($tab['callback'])) { |
|
138 | + return call_user_func($tab['callback']); |
|
139 | 139 | } |
140 | 140 | |
141 | - if ( ! empty( $tab['content'] ) ) { |
|
142 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
141 | + if (!empty($tab['content'])) { |
|
142 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | $notice = aui()->alert( |
146 | 146 | array( |
147 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
147 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
148 | 148 | 'type' => 'error', |
149 | 149 | ) |
150 | 150 | ); |
@@ -160,14 +160,14 @@ discard block |
||
160 | 160 | * @param string $default |
161 | 161 | * @return array |
162 | 162 | */ |
163 | -function getpaid_get_tab_url( $tab, $default ) { |
|
163 | +function getpaid_get_tab_url($tab, $default) { |
|
164 | 164 | global $getpaid_tab_url; |
165 | 165 | |
166 | - if ( empty( $getpaid_tab_url ) ) { |
|
166 | + if (empty($getpaid_tab_url)) { |
|
167 | 167 | return $default; |
168 | 168 | } |
169 | 169 | |
170 | - return sprintf( $getpaid_tab_url, $tab ); |
|
170 | + return sprintf($getpaid_tab_url, $tab); |
|
171 | 171 | |
172 | 172 | } |
173 | 173 | |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | * @param array $tabs |
187 | 187 | * @return array |
188 | 188 | */ |
189 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
189 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
190 | 190 | |
191 | 191 | // Abort if the integration is inactive. |
192 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
192 | + if (!getpaid_is_userswp_integration_active()) { |
|
193 | 193 | return $tabs; |
194 | 194 | } |
195 | 195 | |
196 | - $new_tabs = array(); |
|
196 | + $new_tabs = array(); |
|
197 | 197 | |
198 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
198 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
199 | 199 | |
200 | - $new_tabs[ $slug ] = array( |
|
201 | - 'title' => $tab[ 'label'], |
|
202 | - 'icon' => $tab[ 'icon'], |
|
200 | + $new_tabs[$slug] = array( |
|
201 | + 'title' => $tab['label'], |
|
202 | + 'icon' => $tab['icon'], |
|
203 | 203 | ); |
204 | 204 | |
205 | 205 | } |
206 | 206 | |
207 | - return array_merge( $tabs, $new_tabs ); |
|
207 | + return array_merge($tabs, $new_tabs); |
|
208 | 208 | } |
209 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
209 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
210 | 210 | |
211 | 211 | /** |
212 | 212 | * Display our UsersWP account tabs. |
@@ -215,18 +215,18 @@ discard block |
||
215 | 215 | * @param array $tabs |
216 | 216 | * @return array |
217 | 217 | */ |
218 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
218 | +function getpaid_display_userswp_account_tabs($tab) { |
|
219 | 219 | global $getpaid_tab_url; |
220 | 220 | |
221 | 221 | $our_tabs = getpaid_get_user_content_tabs(); |
222 | 222 | |
223 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
224 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
225 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
223 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
224 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
225 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | } |
229 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
229 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * @param string $tab Current tab. |
238 | 238 | * @return string Title. |
239 | 239 | */ |
240 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
240 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
241 | 241 | |
242 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
242 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
243 | 243 | |
244 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
245 | - return $our_tabs[ $tab ]['label']; |
|
244 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
245 | + return $our_tabs[$tab]['label']; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | return $title; |
249 | 249 | } |
250 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
250 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
251 | 251 | |
252 | 252 | /** |
253 | 253 | * Registers the UsersWP integration settings. |
@@ -256,26 +256,26 @@ discard block |
||
256 | 256 | * @param array $settings An array of integration settings. |
257 | 257 | * @return array |
258 | 258 | */ |
259 | -function getpaid_register_userswp_settings( $settings ) { |
|
259 | +function getpaid_register_userswp_settings($settings) { |
|
260 | 260 | |
261 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
261 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
262 | 262 | |
263 | 263 | $settings[] = array( |
264 | 264 | |
265 | 265 | 'id' => 'userswp', |
266 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
266 | + 'label' => __('UsersWP', 'invoicing'), |
|
267 | 267 | 'settings' => array( |
268 | 268 | |
269 | 269 | 'userswp_settings' => array( |
270 | 270 | 'id' => 'userswp_settings', |
271 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
271 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
272 | 272 | 'type' => 'header', |
273 | 273 | ), |
274 | 274 | |
275 | 275 | 'enable_userswp' => array( |
276 | 276 | 'id' => 'enable_userswp', |
277 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
278 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
277 | + 'name' => __('Enable Integration', 'invoicing'), |
|
278 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
279 | 279 | 'type' => 'checkbox', |
280 | 280 | 'std' => 1, |
281 | 281 | ) |
@@ -288,7 +288,7 @@ discard block |
||
288 | 288 | |
289 | 289 | return $settings; |
290 | 290 | } |
291 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
291 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
292 | 292 | |
293 | 293 | /** |
294 | 294 | * Checks if the integration is enabled. |
@@ -297,6 +297,6 @@ discard block |
||
297 | 297 | * @return bool |
298 | 298 | */ |
299 | 299 | function getpaid_is_userswp_integration_active() { |
300 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
301 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
300 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
301 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
302 | 302 | } |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | return array( |
14 | 14 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | |
17 | 17 | 'placeholder' => '[email protected]', |
18 | 18 | 'value' => '', |
19 | - 'label' => __( 'Billing Email', 'invoicing' ), |
|
19 | + 'label' => __('Billing Email', 'invoicing'), |
|
20 | 20 | 'description' => '', |
21 | 21 | 'required' => true, |
22 | 22 | 'id' => 'mmdwqzpox', |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | array( |
35 | 35 | 'placeholder' => 'Jon', |
36 | 36 | 'value' => '', |
37 | - 'label' => __( 'First Name', 'invoicing' ), |
|
37 | + 'label' => __('First Name', 'invoicing'), |
|
38 | 38 | 'description' => '', |
39 | 39 | 'required' => false, |
40 | 40 | 'visible' => true, |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'placeholder' => 'Snow', |
46 | 46 | 'value' => '', |
47 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
47 | + 'label' => __('Last Name', 'invoicing'), |
|
48 | 48 | 'description' => '', |
49 | 49 | 'required' => false, |
50 | 50 | 'visible' => true, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | array( |
55 | 55 | 'placeholder' => '', |
56 | 56 | 'value' => '', |
57 | - 'label' => __( 'Address', 'invoicing' ), |
|
57 | + 'label' => __('Address', 'invoicing'), |
|
58 | 58 | 'description' => '', |
59 | 59 | 'required' => false, |
60 | 60 | 'visible' => true, |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | array( |
65 | 65 | 'placeholder' => '', |
66 | 66 | 'value' => '', |
67 | - 'label' => __( 'City', 'invoicing' ), |
|
67 | + 'label' => __('City', 'invoicing'), |
|
68 | 68 | 'description' => '', |
69 | 69 | 'required' => false, |
70 | 70 | 'visible' => true, |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | ), |
73 | 73 | |
74 | 74 | array( |
75 | - 'placeholder' => __( 'Select your country' ), |
|
75 | + 'placeholder' => __('Select your country'), |
|
76 | 76 | 'value' => '', |
77 | - 'label' => __( 'Country', 'invoicing' ), |
|
77 | + 'label' => __('Country', 'invoicing'), |
|
78 | 78 | 'description' => '', |
79 | 79 | 'required' => false, |
80 | 80 | 'visible' => true, |
@@ -82,9 +82,9 @@ discard block |
||
82 | 82 | ), |
83 | 83 | |
84 | 84 | array( |
85 | - 'placeholder' => __( 'Choose a state', 'invoicing' ), |
|
85 | + 'placeholder' => __('Choose a state', 'invoicing'), |
|
86 | 86 | 'value' => '', |
87 | - 'label' => __( 'State / Province', 'invoicing' ), |
|
87 | + 'label' => __('State / Province', 'invoicing'), |
|
88 | 88 | 'description' => '', |
89 | 89 | 'required' => false, |
90 | 90 | 'visible' => true, |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | array( |
95 | 95 | 'placeholder' => '', |
96 | 96 | 'value' => '', |
97 | - 'label' => __( 'ZIP / Postcode', 'invoicing' ), |
|
97 | + 'label' => __('ZIP / Postcode', 'invoicing'), |
|
98 | 98 | 'description' => '', |
99 | 99 | 'required' => false, |
100 | 100 | 'visible' => true, |
@@ -104,7 +104,7 @@ discard block |
||
104 | 104 | array( |
105 | 105 | 'placeholder' => '', |
106 | 106 | 'value' => '', |
107 | - 'label' => __( 'Phone', 'invoicing' ), |
|
107 | + 'label' => __('Phone', 'invoicing'), |
|
108 | 108 | 'description' => '', |
109 | 109 | 'required' => false, |
110 | 110 | 'visible' => true, |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | array( |
115 | 115 | 'placeholder' => '', |
116 | 116 | 'value' => '', |
117 | - 'label' => __( 'Company', 'invoicing' ), |
|
117 | + 'label' => __('Company', 'invoicing'), |
|
118 | 118 | 'description' => '', |
119 | 119 | 'required' => false, |
120 | 120 | 'visible' => true, |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | array( |
125 | 125 | 'placeholder' => '', |
126 | 126 | 'value' => '', |
127 | - 'label' => __( 'VAT Number', 'invoicing' ), |
|
127 | + 'label' => __('VAT Number', 'invoicing'), |
|
128 | 128 | 'description' => '', |
129 | 129 | 'required' => false, |
130 | 130 | 'visible' => true, |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | ), |
147 | 147 | |
148 | 148 | array( |
149 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
149 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
150 | 150 | 'id' => 'gtscicd', |
151 | 151 | 'name' => 'gtscicd', |
152 | 152 | 'type' => 'gateway_select', |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | |
159 | 159 | 'value' =>'', |
160 | 160 | 'class' => 'btn-primary', |
161 | - 'label' => __( 'Pay Now »', 'invoicing' ), |
|
162 | - 'description' => __( 'By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing' ), |
|
161 | + 'label' => __('Pay Now »', 'invoicing'), |
|
162 | + 'description' => __('By continuing with your payment, you are agreeing to our privacy policy and terms of service.', 'invoicing'), |
|
163 | 163 | 'id' => 'rtqljyy', |
164 | 164 | 'name' => 'rtqljyy', |
165 | 165 | 'type' => 'pay_button', |
@@ -7,57 +7,57 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $fields ) ) { |
|
12 | +if (empty($fields)) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | 16 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
17 | -$uniqid = uniqid( '_' ); |
|
17 | +$uniqid = uniqid('_'); |
|
18 | 18 | |
19 | 19 | // Prepare the user's country. |
20 | -if ( ! empty( $form->invoice ) ) { |
|
20 | +if (!empty($form->invoice)) { |
|
21 | 21 | $country = $form->invoice->get_country(); |
22 | 22 | } |
23 | 23 | |
24 | -if ( empty( $country ) ) { |
|
25 | - $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
26 | - $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
24 | +if (empty($country)) { |
|
25 | + $country = empty($country) ? getpaid_get_ip_country() : $country; |
|
26 | + $country = empty($country) ? wpinv_get_default_country() : $country; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
30 | -$uniqid = uniqid( '_' ); |
|
30 | +$uniqid = uniqid('_'); |
|
31 | 31 | |
32 | -$address_type = empty( $address_type ) ? 'billing' : $address_type; |
|
32 | +$address_type = empty($address_type) ? 'billing' : $address_type; |
|
33 | 33 | |
34 | 34 | ?> |
35 | 35 | |
36 | -<?php if ( 'both' === $address_type ) : ?> |
|
36 | +<?php if ('both' === $address_type) : ?> |
|
37 | 37 | |
38 | 38 | <!-- Start Billing/Shipping Address Title --> |
39 | 39 | <h4 class="mb-3 getpaid-shipping-billing-address-title"> |
40 | - <?php _e( 'Billing / Shipping Address', 'invoicing' ); ?> |
|
40 | + <?php _e('Billing / Shipping Address', 'invoicing'); ?> |
|
41 | 41 | </h4> |
42 | 42 | <!-- End Billing Address Title --> |
43 | 43 | |
44 | 44 | <!-- Start Billing Address Title --> |
45 | 45 | <h4 class="mb-3 getpaid-billing-address-title"> |
46 | - <?php _e( 'Billing Address', 'invoicing' ); ?> |
|
46 | + <?php _e('Billing Address', 'invoicing'); ?> |
|
47 | 47 | </h4> |
48 | 48 | <!-- End Billing Address Title --> |
49 | 49 | |
50 | 50 | <?php endif; ?> |
51 | 51 | |
52 | 52 | |
53 | -<?php if ( 'both' === $address_type || 'billing' === $address_type ) : ?> |
|
53 | +<?php if ('both' === $address_type || 'billing' === $address_type) : ?> |
|
54 | 54 | |
55 | 55 | <!-- Start Billing Address --> |
56 | 56 | <div class="getpaid-billing-address-wrapper"> |
57 | 57 | <?php |
58 | 58 | $field_type = 'billing'; |
59 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
60 | - do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
59 | + include plugin_dir_path(__FILE__) . 'address-fields.php'; |
|
60 | + do_action('getpaid_after_payment_form_billing_fields', $form); |
|
61 | 61 | ?> |
62 | 62 | </div> |
63 | 63 | <!-- End Billing Address --> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php endif; ?> |
66 | 66 | |
67 | 67 | |
68 | -<?php if ( 'both' === $address_type ) : ?> |
|
68 | +<?php if ('both' === $address_type) : ?> |
|
69 | 69 | |
70 | 70 | |
71 | 71 | <?php |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | 'name' => 'same-shipping-address', |
77 | 77 | 'id' => "shipping-toggle$uniqid", |
78 | 78 | 'required' => false, |
79 | - 'label' => wp_kses_post( $shipping_address_toggle ), |
|
79 | + 'label' => wp_kses_post($shipping_address_toggle), |
|
80 | 80 | 'value' => 1, |
81 | 81 | 'checked' => true, |
82 | 82 | ) |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | <!-- Start Shipping Address Title --> |
89 | 89 | <h4 class="mb-3 getpaid-shipping-address-title"> |
90 | - <?php _e( 'Shipping Address', 'invoicing' ); ?> |
|
90 | + <?php _e('Shipping Address', 'invoicing'); ?> |
|
91 | 91 | </h4> |
92 | 92 | <!-- End Shipping Address Title --> |
93 | 93 | |
@@ -96,14 +96,14 @@ discard block |
||
96 | 96 | |
97 | 97 | |
98 | 98 | |
99 | -<?php if ( 'both' === $address_type || 'shipping' === $address_type ) : ?> |
|
99 | +<?php if ('both' === $address_type || 'shipping' === $address_type) : ?> |
|
100 | 100 | |
101 | 101 | <!-- Start Shipping Address --> |
102 | 102 | <div class="getpaid-shipping-address-wrapper"> |
103 | 103 | <?php |
104 | 104 | $field_type = 'shipping'; |
105 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
106 | - do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
105 | + include plugin_dir_path(__FILE__) . 'address-fields.php'; |
|
106 | + do_action('getpaid_after_payment_form_shipping_fields', $form); |
|
107 | 107 | ?> |
108 | 108 | </div> |
109 | 109 | <!-- End Shipping Address --> |
@@ -11,58 +11,58 @@ discard block |
||
11 | 11 | * @var string $country The current user's country |
12 | 12 | */ |
13 | 13 | |
14 | -defined( 'ABSPATH' ) || exit; |
|
14 | +defined('ABSPATH') || exit; |
|
15 | 15 | |
16 | 16 | |
17 | -$field_type = sanitize_key( $field_type ); |
|
17 | +$field_type = sanitize_key($field_type); |
|
18 | 18 | |
19 | 19 | echo "<div class='row $field_type'>"; |
20 | 20 | |
21 | -foreach ( $fields as $address_field ) { |
|
21 | +foreach ($fields as $address_field) { |
|
22 | 22 | |
23 | 23 | // Skip if it is hidden. |
24 | - if ( empty( $address_field['visible'] ) ) { |
|
24 | + if (empty($address_field['visible'])) { |
|
25 | 25 | continue; |
26 | 26 | } |
27 | 27 | |
28 | - do_action( 'getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field ); |
|
28 | + do_action('getpaid_payment_form_address_field_before_' . $address_field['name'], $field_type, $address_field); |
|
29 | 29 | |
30 | 30 | // Prepare variables. |
31 | - if ( ! empty( $form->invoice ) ) { |
|
31 | + if (!empty($form->invoice)) { |
|
32 | 32 | $user_id = $form->invoice->get_user_id(); |
33 | 33 | } |
34 | 34 | |
35 | - if ( empty( $user_id ) && is_user_logged_in() ) { |
|
35 | + if (empty($user_id) && is_user_logged_in()) { |
|
36 | 36 | $user_id = get_current_user_id(); |
37 | 37 | } |
38 | 38 | |
39 | 39 | $field_name = $address_field['name']; |
40 | 40 | $field_name = "{$field_type}[$field_name]"; |
41 | - $wrap_class = getpaid_get_form_element_grid_class( $address_field ); |
|
42 | - $wrap_class = esc_attr( "$wrap_class getpaid-address-field-wrapper" ); |
|
43 | - $placeholder = empty( $address_field['placeholder'] ) ? '' : esc_attr( $address_field['placeholder'] ); |
|
44 | - $description = empty( $address_field['description'] ) ? '' : wp_kses_post( $address_field['description'] ); |
|
45 | - $value = ! empty( $user_id ) ? get_user_meta( $user_id, '_' . $address_field['name'], true ) : ''; |
|
46 | - $label = empty( $address_field['label'] ) ? '' : wp_kses_post( $address_field['label'] ); |
|
47 | - |
|
48 | - if ( ! empty( $address_field['required'] ) ) { |
|
41 | + $wrap_class = getpaid_get_form_element_grid_class($address_field); |
|
42 | + $wrap_class = esc_attr("$wrap_class getpaid-address-field-wrapper"); |
|
43 | + $placeholder = empty($address_field['placeholder']) ? '' : esc_attr($address_field['placeholder']); |
|
44 | + $description = empty($address_field['description']) ? '' : wp_kses_post($address_field['description']); |
|
45 | + $value = !empty($user_id) ? get_user_meta($user_id, '_' . $address_field['name'], true) : ''; |
|
46 | + $label = empty($address_field['label']) ? '' : wp_kses_post($address_field['label']); |
|
47 | + |
|
48 | + if (!empty($address_field['required'])) { |
|
49 | 49 | $label .= "<span class='text-danger'> *</span>"; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Display the country. |
53 | - if ( 'wpinv_country' == $address_field['name'] ) { |
|
53 | + if ('wpinv_country' == $address_field['name']) { |
|
54 | 54 | |
55 | 55 | echo "<div class='form-group $wrap_class getpaid-address-field-wrapper__country'"; |
56 | 56 | |
57 | 57 | echo aui()->select( |
58 | 58 | array( |
59 | 59 | 'options' => wpinv_get_country_list(), |
60 | - 'name' => esc_attr( $field_name ), |
|
61 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
62 | - 'value' => sanitize_text_field( $country ), |
|
60 | + 'name' => esc_attr($field_name), |
|
61 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
62 | + 'value' => sanitize_text_field($country), |
|
63 | 63 | 'placeholder' => $placeholder, |
64 | - 'required' => ! empty( $address_field['required'] ), |
|
65 | - 'label' => wp_kses_post( $label ), |
|
64 | + 'required' => !empty($address_field['required']), |
|
65 | + 'label' => wp_kses_post($label), |
|
66 | 66 | 'label_type' => 'vertical', |
67 | 67 | 'help_text' => $description, |
68 | 68 | 'class' => 'getpaid-address-field wpinv_country', |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | ) |
76 | 76 | ); |
77 | 77 | |
78 | - if ( wpinv_should_validate_vat_number() ) { |
|
78 | + if (wpinv_should_validate_vat_number()) { |
|
79 | 79 | |
80 | 80 | echo aui()->input( |
81 | 81 | array( |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | 'id' => "shipping-toggle$uniqid", |
85 | 85 | 'wrap_class' => "getpaid-address-field-wrapper__address-confirm mt-1 d-none", |
86 | 86 | 'required' => false, |
87 | - 'label' => __( 'I certify that I live in the country selected above', 'invoicing' ) . "<span class='text-danger'> *</span>", |
|
87 | + 'label' => __('I certify that I live in the country selected above', 'invoicing') . "<span class='text-danger'> *</span>", |
|
88 | 88 | 'value' => 1, |
89 | 89 | 'checked' => true, |
90 | 90 | ) |
@@ -97,27 +97,27 @@ discard block |
||
97 | 97 | } |
98 | 98 | |
99 | 99 | // Display the state. |
100 | - else if ( 'wpinv_state' == $address_field['name'] ) { |
|
100 | + else if ('wpinv_state' == $address_field['name']) { |
|
101 | 101 | |
102 | - if ( empty( $value ) ) { |
|
102 | + if (empty($value)) { |
|
103 | 103 | $value = wpinv_get_default_state(); |
104 | 104 | } |
105 | 105 | |
106 | - echo getpaid_get_states_select_markup ( |
|
106 | + echo getpaid_get_states_select_markup( |
|
107 | 107 | $country, |
108 | 108 | $value, |
109 | 109 | $placeholder, |
110 | 110 | $label, |
111 | 111 | $description, |
112 | - ! empty( $address_field['required'] ), |
|
112 | + !empty($address_field['required']), |
|
113 | 113 | $wrap_class, |
114 | 114 | $field_name |
115 | 115 | ); |
116 | 116 | |
117 | 117 | } else { |
118 | 118 | |
119 | - $key = str_replace( 'wpinv_', '', $address_field['name'] ); |
|
120 | - $key = esc_attr( str_replace( '_', '-', $key ) ); |
|
119 | + $key = str_replace('wpinv_', '', $address_field['name']); |
|
120 | + $key = esc_attr(str_replace('_', '-', $key)); |
|
121 | 121 | $autocomplete = ''; |
122 | 122 | $replacements = array( |
123 | 123 | 'zip' => 'postal-code', |
@@ -130,33 +130,33 @@ discard block |
||
130 | 130 | ); |
131 | 131 | |
132 | 132 | |
133 | - if ( isset( $replacements[ $key ] ) ) { |
|
133 | + if (isset($replacements[$key])) { |
|
134 | 134 | $autocomplete = array( |
135 | - 'autocomplete' => "$field_type {$replacements[ $key ]}", |
|
135 | + 'autocomplete' => "$field_type {$replacements[$key]}", |
|
136 | 136 | ); |
137 | 137 | } |
138 | 138 | |
139 | 139 | $append = ''; |
140 | 140 | |
141 | - if ( 'billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key ) { |
|
142 | - $valid = esc_attr__( 'Valid', 'invoicing' ); |
|
143 | - $invalid = esc_attr__( 'Invalid', 'invoicing' ); |
|
144 | - $validate = esc_attr__( 'Validate', 'invoicing' ); |
|
141 | + if ('billing' === $field_type && wpinv_should_validate_vat_number() && 'vat-number' === $key) { |
|
142 | + $valid = esc_attr__('Valid', 'invoicing'); |
|
143 | + $invalid = esc_attr__('Invalid', 'invoicing'); |
|
144 | + $validate = esc_attr__('Validate', 'invoicing'); |
|
145 | 145 | $append = "<span class='btn btn-secondary getpaid-vat-number-validate' data-valid='$valid' data-invalid='$invalid' data-validate='$validate'>$validate</span>"; |
146 | 146 | } |
147 | 147 | |
148 | 148 | echo aui()->input( |
149 | 149 | array( |
150 | - 'name' => esc_attr( $field_name ), |
|
151 | - 'id' => sanitize_html_class( $field_name ) . $uniqid, |
|
152 | - 'required' => ! empty( $address_field['required'] ), |
|
150 | + 'name' => esc_attr($field_name), |
|
151 | + 'id' => sanitize_html_class($field_name) . $uniqid, |
|
152 | + 'required' => !empty($address_field['required']), |
|
153 | 153 | 'placeholder' => $placeholder, |
154 | - 'label' => wp_kses_post( $label ), |
|
154 | + 'label' => wp_kses_post($label), |
|
155 | 155 | 'label_type' => 'vertical', |
156 | 156 | 'help_text' => $description, |
157 | 157 | 'type' => 'text', |
158 | - 'value' => sanitize_text_field( $value ), |
|
159 | - 'class' => 'getpaid-address-field ' . esc_attr( $address_field['name'] ), |
|
158 | + 'value' => sanitize_text_field($value), |
|
159 | + 'class' => 'getpaid-address-field ' . esc_attr($address_field['name']), |
|
160 | 160 | 'wrap_class' => "$wrap_class getpaid-address-field-wrapper__$key", |
161 | 161 | 'label_class' => 'getpaid-address-field-label getpaid-address-field-label__' . $key, |
162 | 162 | 'extra_attributes' => $autocomplete, |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | - do_action( 'getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field ); |
|
169 | + do_action('getpaid_payment_form_address_field_after_' . $address_field['name'], $field_type, $address_field); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | echo "</div>"; |
@@ -6,7 +6,7 @@ |
||
6 | 6 | * @package Invoicing/data |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | return array( |
12 | 12 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * GetPaid_Geolocation Class. |
@@ -64,31 +64,31 @@ discard block |
||
64 | 64 | |
65 | 65 | $transient_name = 'external_ip_address_0.0.0.0'; |
66 | 66 | |
67 | - if ( '' !== self::get_ip_address() ) { |
|
68 | - $transient_name = 'external_ip_address_' . self::get_ip_address(); |
|
67 | + if ('' !== self::get_ip_address()) { |
|
68 | + $transient_name = 'external_ip_address_' . self::get_ip_address(); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Try retrieving from cache. |
72 | - $external_ip_address = get_transient( $transient_name ); |
|
72 | + $external_ip_address = get_transient($transient_name); |
|
73 | 73 | |
74 | - if ( false === $external_ip_address ) { |
|
74 | + if (false === $external_ip_address) { |
|
75 | 75 | $external_ip_address = '0.0.0.0'; |
76 | - $ip_lookup_services = apply_filters( 'getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis ); |
|
77 | - $ip_lookup_services_keys = array_keys( $ip_lookup_services ); |
|
78 | - shuffle( $ip_lookup_services_keys ); |
|
76 | + $ip_lookup_services = apply_filters('getpaid_geolocation_ip_lookup_apis', self::$ip_lookup_apis); |
|
77 | + $ip_lookup_services_keys = array_keys($ip_lookup_services); |
|
78 | + shuffle($ip_lookup_services_keys); |
|
79 | 79 | |
80 | - foreach ( $ip_lookup_services_keys as $service_name ) { |
|
81 | - $service_endpoint = $ip_lookup_services[ $service_name ]; |
|
82 | - $response = wp_safe_remote_get( $service_endpoint, array( 'timeout' => 2 ) ); |
|
80 | + foreach ($ip_lookup_services_keys as $service_name) { |
|
81 | + $service_endpoint = $ip_lookup_services[$service_name]; |
|
82 | + $response = wp_safe_remote_get($service_endpoint, array('timeout' => 2)); |
|
83 | 83 | |
84 | - if ( ! is_wp_error( $response ) && rest_is_ip_address( $response['body'] ) ) { |
|
85 | - $external_ip_address = apply_filters( 'getpaid_geolocation_ip_lookup_api_response', wpinv_clean( $response['body'] ), $service_name ); |
|
84 | + if (!is_wp_error($response) && rest_is_ip_address($response['body'])) { |
|
85 | + $external_ip_address = apply_filters('getpaid_geolocation_ip_lookup_api_response', wpinv_clean($response['body']), $service_name); |
|
86 | 86 | break; |
87 | 87 | } |
88 | 88 | |
89 | 89 | } |
90 | 90 | |
91 | - set_transient( $transient_name, $external_ip_address, WEEK_IN_SECONDS ); |
|
91 | + set_transient($transient_name, $external_ip_address, WEEK_IN_SECONDS); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | return $external_ip_address; |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param bool $api_fallback If true, uses geolocation APIs if the database file doesn't exist (can be slower). |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public static function geolocate_ip( $ip_address = '', $fallback = false, $api_fallback = true ) { |
|
105 | + public static function geolocate_ip($ip_address = '', $fallback = false, $api_fallback = true) { |
|
106 | 106 | |
107 | - if ( empty( $ip_address ) ) { |
|
107 | + if (empty($ip_address)) { |
|
108 | 108 | $ip_address = self::get_ip_address(); |
109 | 109 | } |
110 | 110 | |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | self::$current_user_ip = $ip_address; |
113 | 113 | |
114 | 114 | // Filter to allow custom geolocation of the IP address. |
115 | - $country_code = apply_filters( 'getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback ); |
|
115 | + $country_code = apply_filters('getpaid_geolocate_ip', false, $ip_address, $fallback, $api_fallback); |
|
116 | 116 | |
117 | - if ( false !== $country_code ) { |
|
117 | + if (false !== $country_code) { |
|
118 | 118 | |
119 | 119 | return array( |
120 | 120 | 'country' => $country_code, |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * @param array $geolocation Geolocation data, including country, state, city, and postcode. |
135 | 135 | * @param string $ip_address IP Address. |
136 | 136 | */ |
137 | - $geolocation = apply_filters( |
|
137 | + $geolocation = apply_filters( |
|
138 | 138 | 'getpaid_get_geolocation', |
139 | 139 | array( |
140 | 140 | 'country' => $country_code, |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | ); |
147 | 147 | |
148 | 148 | // If we still haven't found a country code, let's consider doing an API lookup. |
149 | - if ( '' === $geolocation['country'] && $api_fallback ) { |
|
150 | - $geolocation['country'] = self::geolocate_via_api( $ip_address ); |
|
149 | + if ('' === $geolocation['country'] && $api_fallback) { |
|
150 | + $geolocation['country'] = self::geolocate_via_api($ip_address); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // It's possible that we're in a local environment, in which case the geolocation needs to be done from the |
154 | 154 | // external address. |
155 | - if ( '' === $geolocation['country'] && $fallback ) { |
|
155 | + if ('' === $geolocation['country'] && $fallback) { |
|
156 | 156 | $external_ip_address = self::get_external_ip_address(); |
157 | 157 | |
158 | 158 | // Only bother with this if the external IP differs. |
159 | - if ( '0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address ) { |
|
160 | - return self::geolocate_ip( $external_ip_address, false, $api_fallback ); |
|
159 | + if ('0.0.0.0' !== $external_ip_address && $external_ip_address !== $ip_address) { |
|
160 | + return self::geolocate_ip($external_ip_address, false, $api_fallback); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
@@ -187,12 +187,12 @@ discard block |
||
187 | 187 | 'HTTP_X_COUNTRY_CODE', |
188 | 188 | ); |
189 | 189 | |
190 | - foreach ( $headers as $header ) { |
|
191 | - if ( empty( $_SERVER[ $header ] ) ) { |
|
190 | + foreach ($headers as $header) { |
|
191 | + if (empty($_SERVER[$header])) { |
|
192 | 192 | continue; |
193 | 193 | } |
194 | 194 | |
195 | - $country_code = strtoupper( sanitize_text_field( wp_unslash( $_SERVER[ $header ] ) ) ); |
|
195 | + $country_code = strtoupper(sanitize_text_field(wp_unslash($_SERVER[$header]))); |
|
196 | 196 | break; |
197 | 197 | } |
198 | 198 | |
@@ -211,36 +211,36 @@ discard block |
||
211 | 211 | * @param string $ip_address IP address. |
212 | 212 | * @return string |
213 | 213 | */ |
214 | - protected static function geolocate_via_api( $ip_address ) { |
|
214 | + protected static function geolocate_via_api($ip_address) { |
|
215 | 215 | |
216 | 216 | // Retrieve from cache... |
217 | - $country_code = get_transient( 'geoip_' . $ip_address ); |
|
217 | + $country_code = get_transient('geoip_' . $ip_address); |
|
218 | 218 | |
219 | 219 | // If missing, retrieve from the API. |
220 | - if ( false === $country_code ) { |
|
221 | - $geoip_services = apply_filters( 'getpaid_geolocation_geoip_apis', self::$geoip_apis ); |
|
220 | + if (false === $country_code) { |
|
221 | + $geoip_services = apply_filters('getpaid_geolocation_geoip_apis', self::$geoip_apis); |
|
222 | 222 | |
223 | - if ( empty( $geoip_services ) ) { |
|
223 | + if (empty($geoip_services)) { |
|
224 | 224 | return ''; |
225 | 225 | } |
226 | 226 | |
227 | - $geoip_services_keys = array_keys( $geoip_services ); |
|
227 | + $geoip_services_keys = array_keys($geoip_services); |
|
228 | 228 | |
229 | - shuffle( $geoip_services_keys ); |
|
229 | + shuffle($geoip_services_keys); |
|
230 | 230 | |
231 | - foreach ( $geoip_services_keys as $service_name ) { |
|
231 | + foreach ($geoip_services_keys as $service_name) { |
|
232 | 232 | |
233 | - $service_endpoint = $geoip_services[ $service_name ]; |
|
234 | - $response = wp_safe_remote_get( sprintf( $service_endpoint, $ip_address ), array( 'timeout' => 2 ) ); |
|
235 | - $country_code = sanitize_text_field( strtoupper( self::handle_geolocation_response( $response, $service_name ) ) ); |
|
233 | + $service_endpoint = $geoip_services[$service_name]; |
|
234 | + $response = wp_safe_remote_get(sprintf($service_endpoint, $ip_address), array('timeout' => 2)); |
|
235 | + $country_code = sanitize_text_field(strtoupper(self::handle_geolocation_response($response, $service_name))); |
|
236 | 236 | |
237 | - if ( ! empty( $country_code ) ) { |
|
237 | + if (!empty($country_code)) { |
|
238 | 238 | break; |
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
242 | 242 | |
243 | - set_transient( 'geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS ); |
|
243 | + set_transient('geoip_' . $ip_address, $country_code, WEEK_IN_SECONDS); |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | return $country_code; |
@@ -253,23 +253,23 @@ discard block |
||
253 | 253 | * @param String $geolocation_service |
254 | 254 | * @return string Country code |
255 | 255 | */ |
256 | - protected static function handle_geolocation_response( $geolocation_response, $geolocation_service ) { |
|
256 | + protected static function handle_geolocation_response($geolocation_response, $geolocation_service) { |
|
257 | 257 | |
258 | - if ( is_wp_error( $geolocation_response ) || empty( $geolocation_response['body'] ) ) { |
|
258 | + if (is_wp_error($geolocation_response) || empty($geolocation_response['body'])) { |
|
259 | 259 | return ''; |
260 | 260 | } |
261 | 261 | |
262 | - if ( $geolocation_service === 'ipinfo.io' ) { |
|
263 | - $data = json_decode( $geolocation_response['body'] ); |
|
264 | - return empty( $data ) || empty( $data->country ) ? '' : $data->country; |
|
262 | + if ($geolocation_service === 'ipinfo.io') { |
|
263 | + $data = json_decode($geolocation_response['body']); |
|
264 | + return empty($data) || empty($data->country) ? '' : $data->country; |
|
265 | 265 | } |
266 | 266 | |
267 | - if ( $geolocation_service === 'ip-api.com' ) { |
|
268 | - $data = json_decode( $geolocation_response['body'] ); |
|
269 | - return empty( $data ) || empty( $data->countryCode ) ? '' : $data->countryCode; |
|
267 | + if ($geolocation_service === 'ip-api.com') { |
|
268 | + $data = json_decode($geolocation_response['body']); |
|
269 | + return empty($data) || empty($data->countryCode) ? '' : $data->countryCode; |
|
270 | 270 | } |
271 | 271 | |
272 | - return apply_filters( 'getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body'] ); |
|
272 | + return apply_filters('getpaid_geolocation_geoip_response_' . $geolocation_service, '', $geolocation_response['body']); |
|
273 | 273 | |
274 | 274 | } |
275 | 275 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | * |
6 | 6 | */ |
7 | 7 | |
8 | -defined( 'ABSPATH' ) || exit; |
|
8 | +defined('ABSPATH') || exit; |
|
9 | 9 | |
10 | 10 | /** |
11 | 11 | * Session handler class. |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function __construct() { |
54 | 54 | |
55 | - $this->_cookie = apply_filters( 'wpinv_cookie', 'wpinv_session_' . COOKIEHASH ); |
|
56 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
57 | - add_action( 'wp_logout', array( $this, 'destroy_session' ) ); |
|
58 | - add_action( 'wp', array( $this, 'set_customer_session_cookie' ), 10 ); |
|
59 | - add_action( 'shutdown', array( $this, 'save_data' ), 20 ); |
|
55 | + $this->_cookie = apply_filters('wpinv_cookie', 'wpinv_session_' . COOKIEHASH); |
|
56 | + add_action('init', array($this, 'init'), -1); |
|
57 | + add_action('wp_logout', array($this, 'destroy_session')); |
|
58 | + add_action('wp', array($this, 'set_customer_session_cookie'), 10); |
|
59 | + add_action('shutdown', array($this, 'save_data'), 20); |
|
60 | 60 | |
61 | 61 | } |
62 | 62 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | public function init() { |
69 | 69 | $this->init_session_cookie(); |
70 | 70 | |
71 | - if ( ! is_user_logged_in() ) { |
|
72 | - add_filter( 'nonce_user_logged_out', array( $this, 'nonce_user_logged_out' ), 10, 2 ); |
|
71 | + if (!is_user_logged_in()) { |
|
72 | + add_filter('nonce_user_logged_out', array($this, 'nonce_user_logged_out'), 10, 2); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | public function init_session_cookie() { |
82 | 82 | $cookie = $this->get_session_cookie(); |
83 | 83 | |
84 | - if ( $cookie ) { |
|
84 | + if ($cookie) { |
|
85 | 85 | $this->_customer_id = $cookie[0]; |
86 | 86 | $this->_session_expiration = $cookie[1]; |
87 | 87 | $this->_session_expiring = $cookie[2]; |
@@ -89,17 +89,17 @@ discard block |
||
89 | 89 | $this->_data = $this->get_session_data(); |
90 | 90 | |
91 | 91 | // If the user logs in, update session. |
92 | - if ( is_user_logged_in() && get_current_user_id() != $this->_customer_id ) { |
|
92 | + if (is_user_logged_in() && get_current_user_id() != $this->_customer_id) { |
|
93 | 93 | $this->_customer_id = get_current_user_id(); |
94 | 94 | $this->_dirty = true; |
95 | 95 | $this->save_data(); |
96 | - $this->set_customer_session_cookie( true ); |
|
96 | + $this->set_customer_session_cookie(true); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Update session if its close to expiring. |
100 | - if ( time() > $this->_session_expiring ) { |
|
100 | + if (time() > $this->_session_expiring) { |
|
101 | 101 | $this->set_session_expiration(); |
102 | - $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration ); |
|
102 | + $this->update_session_timestamp($this->_customer_id, $this->_session_expiration); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | 105 | $this->set_session_expiration(); |
@@ -117,25 +117,25 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param bool $set Should the session cookie be set. |
119 | 119 | */ |
120 | - public function set_customer_session_cookie( $set ) { |
|
121 | - if ( $set ) { |
|
120 | + public function set_customer_session_cookie($set) { |
|
121 | + if ($set) { |
|
122 | 122 | $to_hash = $this->_customer_id . '|' . $this->_session_expiration; |
123 | - $cookie_hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
123 | + $cookie_hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
124 | 124 | $cookie_value = $this->_customer_id . '||' . $this->_session_expiration . '||' . $this->_session_expiring . '||' . $cookie_hash; |
125 | 125 | $this->_has_cookie = true; |
126 | 126 | |
127 | - if ( ! isset( $_COOKIE[ $this->_cookie ] ) || $_COOKIE[ $this->_cookie ] !== $cookie_value ) { |
|
128 | - $this->setcookie( $this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true ); |
|
127 | + if (!isset($_COOKIE[$this->_cookie]) || $_COOKIE[$this->_cookie] !== $cookie_value) { |
|
128 | + $this->setcookie($this->_cookie, $cookie_value, $this->_session_expiration, $this->use_secure_cookie(), true); |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | } |
132 | 132 | |
133 | - public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false){ |
|
134 | - if ( ! headers_sent() ) { |
|
135 | - setcookie( $name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters( 'wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure ) ); |
|
136 | - } elseif ( defined( 'WP_DEBUG' ) && WP_DEBUG ) { |
|
137 | - headers_sent( $file, $line ); |
|
138 | - trigger_error( "{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE ); // @codingStandardsIgnoreLine |
|
133 | + public function setcookie($name, $value, $expire = 0, $secure = false, $httponly = false) { |
|
134 | + if (!headers_sent()) { |
|
135 | + setcookie($name, $value, $expire, COOKIEPATH ? COOKIEPATH : '/', COOKIE_DOMAIN, $secure, apply_filters('wpinv_cookie_httponly', $httponly, $name, $value, $expire, $secure)); |
|
136 | + } elseif (defined('WP_DEBUG') && WP_DEBUG) { |
|
137 | + headers_sent($file, $line); |
|
138 | + trigger_error("{$name} cookie cannot be set - headers already sent by {$file} on line {$line}", E_USER_NOTICE); // @codingStandardsIgnoreLine |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @return bool |
147 | 147 | */ |
148 | 148 | protected function use_secure_cookie() { |
149 | - $is_https = false !== strstr( get_option( 'home' ), 'https:' ); |
|
150 | - return apply_filters( 'wpinv_session_use_secure_cookie', $is_https && is_ssl() ); |
|
149 | + $is_https = false !== strstr(get_option('home'), 'https:'); |
|
150 | + return apply_filters('wpinv_session_use_secure_cookie', $is_https && is_ssl()); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -156,15 +156,15 @@ discard block |
||
156 | 156 | * @return bool |
157 | 157 | */ |
158 | 158 | public function has_session() { |
159 | - return isset( $_COOKIE[ $this->_cookie ] ) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
159 | + return isset($_COOKIE[$this->_cookie]) || $this->_has_cookie || is_user_logged_in(); // @codingStandardsIgnoreLine. |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | 163 | * Set session expiration. |
164 | 164 | */ |
165 | 165 | public function set_session_expiration() { |
166 | - $this->_session_expiring = time() + intval( apply_filters( 'wpinv_session_expiring', 60 * 60 * 47 ) ); // 47 Hours. |
|
167 | - $this->_session_expiration = time() + intval( apply_filters( 'wpinv_session_expiration', 60 * 60 * 48 ) ); // 48 Hours. |
|
166 | + $this->_session_expiring = time() + intval(apply_filters('wpinv_session_expiring', 60 * 60 * 47)); // 47 Hours. |
|
167 | + $this->_session_expiration = time() + intval(apply_filters('wpinv_session_expiration', 60 * 60 * 48)); // 48 Hours. |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -174,8 +174,8 @@ discard block |
||
174 | 174 | */ |
175 | 175 | public function generate_customer_id() { |
176 | 176 | require_once ABSPATH . 'wp-includes/class-phpass.php'; |
177 | - $hasher = new PasswordHash( 8, false ); |
|
178 | - return md5( $hasher->get_random_bytes( 32 ) ); |
|
177 | + $hasher = new PasswordHash(8, false); |
|
178 | + return md5($hasher->get_random_bytes(32)); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
@@ -186,27 +186,27 @@ discard block |
||
186 | 186 | * @return bool|array |
187 | 187 | */ |
188 | 188 | public function get_session_cookie() { |
189 | - $cookie_value = isset( $_COOKIE[ $this->_cookie ] ) ? wp_unslash( $_COOKIE[ $this->_cookie ] ) : false; // @codingStandardsIgnoreLine. |
|
189 | + $cookie_value = isset($_COOKIE[$this->_cookie]) ? wp_unslash($_COOKIE[$this->_cookie]) : false; // @codingStandardsIgnoreLine. |
|
190 | 190 | |
191 | - if ( empty( $cookie_value ) || ! is_string( $cookie_value ) ) { |
|
191 | + if (empty($cookie_value) || !is_string($cookie_value)) { |
|
192 | 192 | return false; |
193 | 193 | } |
194 | 194 | |
195 | - list( $customer_id, $session_expiration, $session_expiring, $cookie_hash ) = explode( '||', $cookie_value ); |
|
195 | + list($customer_id, $session_expiration, $session_expiring, $cookie_hash) = explode('||', $cookie_value); |
|
196 | 196 | |
197 | - if ( empty( $customer_id ) ) { |
|
197 | + if (empty($customer_id)) { |
|
198 | 198 | return false; |
199 | 199 | } |
200 | 200 | |
201 | 201 | // Validate hash. |
202 | 202 | $to_hash = $customer_id . '|' . $session_expiration; |
203 | - $hash = hash_hmac( 'md5', $to_hash, wp_hash( $to_hash ) ); |
|
203 | + $hash = hash_hmac('md5', $to_hash, wp_hash($to_hash)); |
|
204 | 204 | |
205 | - if ( empty( $cookie_hash ) || ! hash_equals( $hash, $cookie_hash ) ) { |
|
205 | + if (empty($cookie_hash) || !hash_equals($hash, $cookie_hash)) { |
|
206 | 206 | return false; |
207 | 207 | } |
208 | 208 | |
209 | - return array( $customer_id, $session_expiration, $session_expiring, $cookie_hash ); |
|
209 | + return array($customer_id, $session_expiration, $session_expiring, $cookie_hash); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | /** |
@@ -215,15 +215,15 @@ discard block |
||
215 | 215 | * @return array |
216 | 216 | */ |
217 | 217 | public function get_session_data() { |
218 | - return $this->has_session() ? (array) $this->get_session( $this->_customer_id ) : array(); |
|
218 | + return $this->has_session() ? (array) $this->get_session($this->_customer_id) : array(); |
|
219 | 219 | } |
220 | 220 | |
221 | - public function generate_key($customer_id){ |
|
222 | - if(!$customer_id){ |
|
221 | + public function generate_key($customer_id) { |
|
222 | + if (!$customer_id) { |
|
223 | 223 | return; |
224 | 224 | } |
225 | 225 | |
226 | - return 'wpi_trans_'.$customer_id; |
|
226 | + return 'wpi_trans_' . $customer_id; |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | /** |
@@ -231,9 +231,9 @@ discard block |
||
231 | 231 | */ |
232 | 232 | public function save_data() { |
233 | 233 | // Dirty if something changed - prevents saving nothing new. |
234 | - if ( $this->_dirty && $this->has_session() ) { |
|
234 | + if ($this->_dirty && $this->has_session()) { |
|
235 | 235 | |
236 | - set_transient( $this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
|
236 | + set_transient($this->generate_key($this->_customer_id), $this->_data, $this->_session_expiration); |
|
237 | 237 | |
238 | 238 | $this->_dirty = false; |
239 | 239 | } |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | * Destroy all session data. |
244 | 244 | */ |
245 | 245 | public function destroy_session() { |
246 | - $this->delete_session( $this->_customer_id ); |
|
246 | + $this->delete_session($this->_customer_id); |
|
247 | 247 | $this->forget_session(); |
248 | 248 | } |
249 | 249 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | * Forget all session data without destroying it. |
252 | 252 | */ |
253 | 253 | public function forget_session() { |
254 | - $this->setcookie( $this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true ); |
|
254 | + $this->setcookie($this->_cookie, '', time() - YEAR_IN_SECONDS, $this->use_secure_cookie(), true); |
|
255 | 255 | |
256 | 256 | wpinv_empty_cart(); |
257 | 257 | |
@@ -266,10 +266,10 @@ discard block |
||
266 | 266 | * @param int $uid User ID. |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function nonce_user_logged_out( $uid ) { |
|
269 | + public function nonce_user_logged_out($uid) { |
|
270 | 270 | |
271 | 271 | // Check if one of our nonces. |
272 | - if ( substr( $uid, 0, 5 ) === 'wpinv' || substr( $uid, 0, 7 ) === 'getpaid' ) { |
|
272 | + if (substr($uid, 0, 5) === 'wpinv' || substr($uid, 0, 7) === 'getpaid') { |
|
273 | 273 | return $this->has_session() && $this->_customer_id ? $this->_customer_id : $uid; |
274 | 274 | } |
275 | 275 | |
@@ -283,20 +283,20 @@ discard block |
||
283 | 283 | * @param mixed $default Default session value. |
284 | 284 | * @return string|array |
285 | 285 | */ |
286 | - public function get_session( $customer_id, $default = false ) { |
|
286 | + public function get_session($customer_id, $default = false) { |
|
287 | 287 | |
288 | - if ( defined( 'WP_SETUP_CONFIG' ) ) { |
|
288 | + if (defined('WP_SETUP_CONFIG')) { |
|
289 | 289 | return array(); |
290 | 290 | } |
291 | 291 | |
292 | 292 | $key = $this->generate_key($customer_id); |
293 | 293 | $value = get_transient($key); |
294 | 294 | |
295 | - if ( !$value ) { |
|
295 | + if (!$value) { |
|
296 | 296 | $value = $default; |
297 | 297 | } |
298 | 298 | |
299 | - return maybe_unserialize( $value ); |
|
299 | + return maybe_unserialize($value); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @param int $customer_id Customer ID. |
306 | 306 | */ |
307 | - public function delete_session( $customer_id ) { |
|
307 | + public function delete_session($customer_id) { |
|
308 | 308 | |
309 | 309 | $key = $this->generate_key($customer_id); |
310 | 310 | |
@@ -317,9 +317,9 @@ discard block |
||
317 | 317 | * @param string $customer_id Customer ID. |
318 | 318 | * @param int $timestamp Timestamp to expire the cookie. |
319 | 319 | */ |
320 | - public function update_session_timestamp( $customer_id, $timestamp ) { |
|
320 | + public function update_session_timestamp($customer_id, $timestamp) { |
|
321 | 321 | |
322 | - set_transient( $this->generate_key($customer_id), maybe_serialize( $this->_data ), $timestamp); |
|
322 | + set_transient($this->generate_key($customer_id), maybe_serialize($this->_data), $timestamp); |
|
323 | 323 | |
324 | 324 | } |
325 | 325 | } |
@@ -7,40 +7,40 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_is_checkout() { |
15 | 15 | global $wp_query; |
16 | 16 | |
17 | - $is_object_set = isset( $wp_query->queried_object ); |
|
18 | - $is_object_id_set = isset( $wp_query->queried_object_id ); |
|
19 | - $checkout_page = wpinv_get_option( 'checkout_page' ); |
|
20 | - $is_checkout = ! empty( $checkout_page ) && is_page( $checkout_page ); |
|
17 | + $is_object_set = isset($wp_query->queried_object); |
|
18 | + $is_object_id_set = isset($wp_query->queried_object_id); |
|
19 | + $checkout_page = wpinv_get_option('checkout_page'); |
|
20 | + $is_checkout = !empty($checkout_page) && is_page($checkout_page); |
|
21 | 21 | |
22 | - if ( !$is_object_set ) { |
|
23 | - unset( $wp_query->queried_object ); |
|
22 | + if (!$is_object_set) { |
|
23 | + unset($wp_query->queried_object); |
|
24 | 24 | } |
25 | 25 | |
26 | - if ( !$is_object_id_set ) { |
|
27 | - unset( $wp_query->queried_object_id ); |
|
26 | + if (!$is_object_id_set) { |
|
27 | + unset($wp_query->queried_object_id); |
|
28 | 28 | } |
29 | 29 | |
30 | - return apply_filters( 'wpinv_is_checkout', $is_checkout ); |
|
30 | + return apply_filters('wpinv_is_checkout', $is_checkout); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | function wpinv_can_checkout() { |
34 | 34 | $can_checkout = true; // Always true for now |
35 | 35 | |
36 | - return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout ); |
|
36 | + return (bool) apply_filters('wpinv_can_checkout', $can_checkout); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | function wpinv_get_success_page_uri() { |
40 | - $page_id = wpinv_get_option( 'success_page', 0 ); |
|
41 | - $page_id = absint( $page_id ); |
|
40 | + $page_id = wpinv_get_option('success_page', 0); |
|
41 | + $page_id = absint($page_id); |
|
42 | 42 | |
43 | - return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) ); |
|
43 | + return apply_filters('wpinv_get_success_page_uri', get_permalink($page_id)); |
|
44 | 44 | } |
45 | 45 | |
46 | 46 | /** |
@@ -49,139 +49,139 @@ discard block |
||
49 | 49 | * @param string $post_type The post type or invoice type. |
50 | 50 | * @return string The history page URL. |
51 | 51 | */ |
52 | -function wpinv_get_history_page_uri( $post_type = 'wpi_invoice' ) { |
|
53 | - $post_type = sanitize_key( str_replace( 'wpi_', '', $post_type ) ); |
|
54 | - $page_id = wpinv_get_option( "{$post_type}_history_page", 0 ); |
|
55 | - $page_id = absint( $page_id ); |
|
56 | - return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ), $post_type ); |
|
52 | +function wpinv_get_history_page_uri($post_type = 'wpi_invoice') { |
|
53 | + $post_type = sanitize_key(str_replace('wpi_', '', $post_type)); |
|
54 | + $page_id = wpinv_get_option("{$post_type}_history_page", 0); |
|
55 | + $page_id = absint($page_id); |
|
56 | + return apply_filters('wpinv_get_history_page_uri', get_permalink($page_id), $post_type); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | function wpinv_is_success_page() { |
60 | - $is_success_page = wpinv_get_option( 'success_page', false ); |
|
61 | - $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false; |
|
60 | + $is_success_page = wpinv_get_option('success_page', false); |
|
61 | + $is_success_page = !empty($is_success_page) ? is_page($is_success_page) : false; |
|
62 | 62 | |
63 | - return apply_filters( 'wpinv_is_success_page', $is_success_page ); |
|
63 | + return apply_filters('wpinv_is_success_page', $is_success_page); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | function wpinv_is_invoice_history_page() { |
67 | - $ret = wpinv_get_option( 'invoice_history_page', false ); |
|
68 | - $ret = $ret ? is_page( $ret ) : false; |
|
69 | - return apply_filters( 'wpinv_is_invoice_history_page', $ret ); |
|
67 | + $ret = wpinv_get_option('invoice_history_page', false); |
|
68 | + $ret = $ret ? is_page($ret) : false; |
|
69 | + return apply_filters('wpinv_is_invoice_history_page', $ret); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | function wpinv_is_subscriptions_history_page() { |
73 | - $ret = wpinv_get_option( 'invoice_subscription_page', false ); |
|
74 | - $ret = $ret ? is_page( $ret ) : false; |
|
75 | - return apply_filters( 'wpinv_is_subscriptions_history_page', $ret ); |
|
73 | + $ret = wpinv_get_option('invoice_subscription_page', false); |
|
74 | + $ret = $ret ? is_page($ret) : false; |
|
75 | + return apply_filters('wpinv_is_subscriptions_history_page', $ret); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | /** |
79 | 79 | * Redirects a user the success page. |
80 | 80 | */ |
81 | -function wpinv_send_to_success_page( $args = array() ) { |
|
81 | +function wpinv_send_to_success_page($args = array()) { |
|
82 | 82 | |
83 | 83 | $redirect = add_query_arg( |
84 | - wp_parse_args( $args ), |
|
84 | + wp_parse_args($args), |
|
85 | 85 | wpinv_get_success_page_uri() |
86 | 86 | ); |
87 | 87 | |
88 | - $redirect = apply_filters( 'wpinv_send_to_success_page_url', $redirect, $args ); |
|
88 | + $redirect = apply_filters('wpinv_send_to_success_page_url', $redirect, $args); |
|
89 | 89 | |
90 | - wp_redirect( $redirect ); |
|
90 | + wp_redirect($redirect); |
|
91 | 91 | exit; |
92 | 92 | } |
93 | 93 | |
94 | -function wpinv_send_to_failed_page( $args = null ) { |
|
94 | +function wpinv_send_to_failed_page($args = null) { |
|
95 | 95 | $redirect = wpinv_get_failed_transaction_uri(); |
96 | 96 | |
97 | - if ( !empty( $args ) ) { |
|
97 | + if (!empty($args)) { |
|
98 | 98 | // Check for backward compatibility |
99 | - if ( is_string( $args ) ) |
|
100 | - $args = str_replace( '?', '', $args ); |
|
99 | + if (is_string($args)) |
|
100 | + $args = str_replace('?', '', $args); |
|
101 | 101 | |
102 | - $args = wp_parse_args( $args ); |
|
102 | + $args = wp_parse_args($args); |
|
103 | 103 | |
104 | - $redirect = add_query_arg( $args, $redirect ); |
|
104 | + $redirect = add_query_arg($args, $redirect); |
|
105 | 105 | } |
106 | 106 | |
107 | - $gateway = isset( $_REQUEST['wpi-gateway'] ) ? $_REQUEST['wpi-gateway'] : ''; |
|
107 | + $gateway = isset($_REQUEST['wpi-gateway']) ? $_REQUEST['wpi-gateway'] : ''; |
|
108 | 108 | |
109 | - $redirect = apply_filters( 'wpinv_failed_page_redirect', $redirect, $gateway, $args ); |
|
110 | - wp_redirect( $redirect ); |
|
109 | + $redirect = apply_filters('wpinv_failed_page_redirect', $redirect, $gateway, $args); |
|
110 | + wp_redirect($redirect); |
|
111 | 111 | exit; |
112 | 112 | } |
113 | 113 | |
114 | -function wpinv_get_checkout_uri( $args = array() ) { |
|
115 | - $uri = wpinv_get_option( 'checkout_page', false ); |
|
116 | - $uri = isset( $uri ) ? get_permalink( $uri ) : NULL; |
|
114 | +function wpinv_get_checkout_uri($args = array()) { |
|
115 | + $uri = wpinv_get_option('checkout_page', false); |
|
116 | + $uri = isset($uri) ? get_permalink($uri) : NULL; |
|
117 | 117 | |
118 | - if ( !empty( $args ) ) { |
|
118 | + if (!empty($args)) { |
|
119 | 119 | // Check for backward compatibility |
120 | - if ( is_string( $args ) ) |
|
121 | - $args = str_replace( '?', '', $args ); |
|
120 | + if (is_string($args)) |
|
121 | + $args = str_replace('?', '', $args); |
|
122 | 122 | |
123 | - $args = wp_parse_args( $args ); |
|
123 | + $args = wp_parse_args($args); |
|
124 | 124 | |
125 | - $uri = add_query_arg( $args, $uri ); |
|
125 | + $uri = add_query_arg($args, $uri); |
|
126 | 126 | } |
127 | 127 | |
128 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
128 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
129 | 129 | |
130 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
130 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
131 | 131 | |
132 | - if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) { |
|
133 | - $uri = preg_replace( '/^http:/', 'https:', $uri ); |
|
132 | + if ((!preg_match('/^https/', $uri) && preg_match('/^https/', $ajax_url)) || wpinv_is_ssl_enforced()) { |
|
133 | + $uri = preg_replace('/^http:/', 'https:', $uri); |
|
134 | 134 | } |
135 | 135 | |
136 | - return apply_filters( 'wpinv_get_checkout_uri', $uri ); |
|
136 | + return apply_filters('wpinv_get_checkout_uri', $uri); |
|
137 | 137 | } |
138 | 138 | |
139 | -function wpinv_get_success_page_url( $query_string = null ) { |
|
140 | - $success_page = wpinv_get_option( 'success_page', 0 ); |
|
141 | - $success_page = get_permalink( $success_page ); |
|
139 | +function wpinv_get_success_page_url($query_string = null) { |
|
140 | + $success_page = wpinv_get_option('success_page', 0); |
|
141 | + $success_page = get_permalink($success_page); |
|
142 | 142 | |
143 | - if ( $query_string ) |
|
143 | + if ($query_string) |
|
144 | 144 | $success_page .= $query_string; |
145 | 145 | |
146 | - return apply_filters( 'wpinv_success_page_url', $success_page ); |
|
146 | + return apply_filters('wpinv_success_page_url', $success_page); |
|
147 | 147 | } |
148 | 148 | |
149 | -function wpinv_get_failed_transaction_uri( $extras = false ) { |
|
150 | - $uri = wpinv_get_option( 'failure_page', '' ); |
|
151 | - $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url(); |
|
149 | +function wpinv_get_failed_transaction_uri($extras = false) { |
|
150 | + $uri = wpinv_get_option('failure_page', ''); |
|
151 | + $uri = !empty($uri) ? trailingslashit(get_permalink($uri)) : home_url(); |
|
152 | 152 | |
153 | - if ( $extras ) |
|
153 | + if ($extras) |
|
154 | 154 | $uri .= $extras; |
155 | 155 | |
156 | - return apply_filters( 'wpinv_get_failed_transaction_uri', $uri ); |
|
156 | + return apply_filters('wpinv_get_failed_transaction_uri', $uri); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | function wpinv_is_failed_transaction_page() { |
160 | - $ret = wpinv_get_option( 'failure_page', false ); |
|
161 | - $ret = isset( $ret ) ? is_page( $ret ) : false; |
|
160 | + $ret = wpinv_get_option('failure_page', false); |
|
161 | + $ret = isset($ret) ? is_page($ret) : false; |
|
162 | 162 | |
163 | - return apply_filters( 'wpinv_is_failure_page', $ret ); |
|
163 | + return apply_filters('wpinv_is_failure_page', $ret); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_transaction_query( $type = 'start' ) { |
|
166 | +function wpinv_transaction_query($type = 'start') { |
|
167 | 167 | global $wpdb; |
168 | 168 | |
169 | 169 | $wpdb->hide_errors(); |
170 | 170 | |
171 | - if ( ! defined( 'WPINV_USE_TRANSACTIONS' ) ) { |
|
172 | - define( 'WPINV_USE_TRANSACTIONS', true ); |
|
171 | + if (!defined('WPINV_USE_TRANSACTIONS')) { |
|
172 | + define('WPINV_USE_TRANSACTIONS', true); |
|
173 | 173 | } |
174 | 174 | |
175 | - if ( WPINV_USE_TRANSACTIONS ) { |
|
176 | - switch ( $type ) { |
|
175 | + if (WPINV_USE_TRANSACTIONS) { |
|
176 | + switch ($type) { |
|
177 | 177 | case 'commit' : |
178 | - $wpdb->query( 'COMMIT' ); |
|
178 | + $wpdb->query('COMMIT'); |
|
179 | 179 | break; |
180 | 180 | case 'rollback' : |
181 | - $wpdb->query( 'ROLLBACK' ); |
|
181 | + $wpdb->query('ROLLBACK'); |
|
182 | 182 | break; |
183 | 183 | default : |
184 | - $wpdb->query( 'START TRANSACTION' ); |
|
184 | + $wpdb->query('START TRANSACTION'); |
|
185 | 185 | break; |
186 | 186 | } |
187 | 187 | } |
@@ -190,141 +190,141 @@ discard block |
||
190 | 190 | function wpinv_get_prefix() { |
191 | 191 | $invoice_prefix = 'INV-'; |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_prefix', $invoice_prefix ); |
|
193 | + return apply_filters('wpinv_get_prefix', $invoice_prefix); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | function wpinv_get_business_logo() { |
197 | - $business_logo = wpinv_get_option( 'logo' ); |
|
198 | - return apply_filters( 'wpinv_get_business_logo', $business_logo ); |
|
197 | + $business_logo = wpinv_get_option('logo'); |
|
198 | + return apply_filters('wpinv_get_business_logo', $business_logo); |
|
199 | 199 | } |
200 | 200 | |
201 | 201 | function wpinv_get_business_name() { |
202 | - $business_name = wpinv_get_option('store_name', wpinv_get_blogname() ); |
|
203 | - return apply_filters( 'wpinv_get_business_name', $business_name ); |
|
202 | + $business_name = wpinv_get_option('store_name', wpinv_get_blogname()); |
|
203 | + return apply_filters('wpinv_get_business_name', $business_name); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | function wpinv_get_blogname() { |
207 | - return wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ); |
|
207 | + return wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | function wpinv_get_admin_email() { |
211 | - $admin_email = wpinv_get_option( 'admin_email', get_option( 'admin_email' ) ); |
|
212 | - return apply_filters( 'wpinv_admin_email', $admin_email ); |
|
211 | + $admin_email = wpinv_get_option('admin_email', get_option('admin_email')); |
|
212 | + return apply_filters('wpinv_admin_email', $admin_email); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | function wpinv_get_business_website() { |
216 | - $business_website = home_url( '/' ); |
|
217 | - return apply_filters( 'wpinv_get_business_website', $business_website ); |
|
216 | + $business_website = home_url('/'); |
|
217 | + return apply_filters('wpinv_get_business_website', $business_website); |
|
218 | 218 | } |
219 | 219 | |
220 | -function wpinv_get_terms_text( $invoice_id = 0 ) { |
|
220 | +function wpinv_get_terms_text($invoice_id = 0) { |
|
221 | 221 | $terms_text = ''; |
222 | - return apply_filters( 'wpinv_get_terms_text', $terms_text, $invoice_id ); |
|
222 | + return apply_filters('wpinv_get_terms_text', $terms_text, $invoice_id); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | function wpinv_get_business_footer() { |
226 | - $site_link = '<a target="_blank" href="' . esc_url( wpinv_get_business_website() ) . '">' . esc_html( wpinv_get_business_name() ) . '</a>'; |
|
227 | - $business_footer = wp_sprintf( __( 'Thanks for using %s', 'invoicing' ), $site_link ); |
|
228 | - return apply_filters( 'wpinv_get_business_footer', $business_footer ); |
|
226 | + $site_link = '<a target="_blank" href="' . esc_url(wpinv_get_business_website()) . '">' . esc_html(wpinv_get_business_name()) . '</a>'; |
|
227 | + $business_footer = wp_sprintf(__('Thanks for using %s', 'invoicing'), $site_link); |
|
228 | + return apply_filters('wpinv_get_business_footer', $business_footer); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | function wpinv_checkout_required_fields() { |
232 | 232 | $required_fields = array(); |
233 | 233 | |
234 | 234 | // Let payment gateways and other extensions determine if address fields should be required |
235 | - $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() ); |
|
235 | + $require_billing_details = apply_filters('wpinv_checkout_required_billing_details', wpinv_use_taxes()); |
|
236 | 236 | |
237 | - if ( $require_billing_details ) { |
|
238 | - if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) { |
|
237 | + if ($require_billing_details) { |
|
238 | + if ((bool) wpinv_get_option('fname_mandatory')) { |
|
239 | 239 | $required_fields['first_name'] = array( |
240 | 240 | 'error_id' => 'invalid_first_name', |
241 | - 'error_message' => __( 'Please enter your first name', 'invoicing' ) |
|
241 | + 'error_message' => __('Please enter your first name', 'invoicing') |
|
242 | 242 | ); |
243 | 243 | } |
244 | - if ( (bool)wpinv_get_option( 'address_mandatory' ) ) { |
|
244 | + if ((bool) wpinv_get_option('address_mandatory')) { |
|
245 | 245 | $required_fields['address'] = array( |
246 | 246 | 'error_id' => 'invalid_address', |
247 | - 'error_message' => __( 'Please enter your address', 'invoicing' ) |
|
247 | + 'error_message' => __('Please enter your address', 'invoicing') |
|
248 | 248 | ); |
249 | 249 | } |
250 | - if ( (bool)wpinv_get_option( 'city_mandatory' ) ) { |
|
250 | + if ((bool) wpinv_get_option('city_mandatory')) { |
|
251 | 251 | $required_fields['city'] = array( |
252 | 252 | 'error_id' => 'invalid_city', |
253 | - 'error_message' => __( 'Please enter your billing city', 'invoicing' ) |
|
253 | + 'error_message' => __('Please enter your billing city', 'invoicing') |
|
254 | 254 | ); |
255 | 255 | } |
256 | - if ( (bool)wpinv_get_option( 'state_mandatory' ) ) { |
|
256 | + if ((bool) wpinv_get_option('state_mandatory')) { |
|
257 | 257 | $required_fields['state'] = array( |
258 | 258 | 'error_id' => 'invalid_state', |
259 | - 'error_message' => __( 'Please enter billing state / province', 'invoicing' ) |
|
259 | + 'error_message' => __('Please enter billing state / province', 'invoicing') |
|
260 | 260 | ); |
261 | 261 | } |
262 | - if ( (bool)wpinv_get_option( 'country_mandatory' ) ) { |
|
262 | + if ((bool) wpinv_get_option('country_mandatory')) { |
|
263 | 263 | $required_fields['country'] = array( |
264 | 264 | 'error_id' => 'invalid_country', |
265 | - 'error_message' => __( 'Please select your billing country', 'invoicing' ) |
|
265 | + 'error_message' => __('Please select your billing country', 'invoicing') |
|
266 | 266 | ); |
267 | 267 | } |
268 | 268 | } |
269 | 269 | |
270 | - return apply_filters( 'wpinv_checkout_required_fields', $required_fields ); |
|
270 | + return apply_filters('wpinv_checkout_required_fields', $required_fields); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | function wpinv_is_ssl_enforced() { |
274 | - $ssl_enforced = wpinv_get_option( 'enforce_ssl', false ); |
|
275 | - return (bool) apply_filters( 'wpinv_is_ssl_enforced', $ssl_enforced ); |
|
274 | + $ssl_enforced = wpinv_get_option('enforce_ssl', false); |
|
275 | + return (bool) apply_filters('wpinv_is_ssl_enforced', $ssl_enforced); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | function wpinv_schedule_event_twicedaily() { |
279 | 279 | wpinv_email_payment_reminders(); |
280 | 280 | } |
281 | -add_action( 'wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily' ); |
|
281 | +add_action('wpinv_register_schedule_event_daily', 'wpinv_schedule_event_twicedaily'); |
|
282 | 282 | |
283 | 283 | function wpinv_require_login_to_checkout() { |
284 | - $return = wpinv_get_option( 'login_to_checkout', false ); |
|
285 | - return (bool) apply_filters( 'wpinv_require_login_to_checkout', $return ); |
|
284 | + $return = wpinv_get_option('login_to_checkout', false); |
|
285 | + return (bool) apply_filters('wpinv_require_login_to_checkout', $return); |
|
286 | 286 | } |
287 | 287 | |
288 | -function wpinv_sequential_number_active( $type = '' ) { |
|
289 | - $check = apply_filters( 'wpinv_pre_check_sequential_number_active', null, $type ); |
|
290 | - if ( null !== $check ) { |
|
288 | +function wpinv_sequential_number_active($type = '') { |
|
289 | + $check = apply_filters('wpinv_pre_check_sequential_number_active', null, $type); |
|
290 | + if (null !== $check) { |
|
291 | 291 | return $check; |
292 | 292 | } |
293 | 293 | |
294 | - return wpinv_get_option( 'sequential_invoice_number' ); |
|
294 | + return wpinv_get_option('sequential_invoice_number'); |
|
295 | 295 | } |
296 | 296 | |
297 | -function wpinv_switch_to_locale( $locale = NULL ) { |
|
297 | +function wpinv_switch_to_locale($locale = NULL) { |
|
298 | 298 | global $invoicing, $wpi_switch_locale; |
299 | 299 | |
300 | - if ( ! empty( $invoicing ) && function_exists( 'switch_to_locale' ) ) { |
|
301 | - $locale = empty( $locale ) ? get_locale() : $locale; |
|
300 | + if (!empty($invoicing) && function_exists('switch_to_locale')) { |
|
301 | + $locale = empty($locale) ? get_locale() : $locale; |
|
302 | 302 | |
303 | - switch_to_locale( $locale ); |
|
303 | + switch_to_locale($locale); |
|
304 | 304 | |
305 | 305 | $wpi_switch_locale = $locale; |
306 | 306 | |
307 | - add_filter( 'plugin_locale', 'get_locale' ); |
|
307 | + add_filter('plugin_locale', 'get_locale'); |
|
308 | 308 | |
309 | 309 | $invoicing->load_textdomain(); |
310 | 310 | |
311 | - do_action( 'wpinv_switch_to_locale', $locale ); |
|
311 | + do_action('wpinv_switch_to_locale', $locale); |
|
312 | 312 | } |
313 | 313 | } |
314 | 314 | |
315 | 315 | function wpinv_restore_locale() { |
316 | 316 | global $invoicing, $wpi_switch_locale; |
317 | 317 | |
318 | - if ( ! empty( $invoicing ) && function_exists( 'restore_previous_locale' ) && $wpi_switch_locale ) { |
|
318 | + if (!empty($invoicing) && function_exists('restore_previous_locale') && $wpi_switch_locale) { |
|
319 | 319 | restore_previous_locale(); |
320 | 320 | |
321 | 321 | $wpi_switch_locale = NULL; |
322 | 322 | |
323 | - remove_filter( 'plugin_locale', 'get_locale' ); |
|
323 | + remove_filter('plugin_locale', 'get_locale'); |
|
324 | 324 | |
325 | 325 | $invoicing->load_textdomain(); |
326 | 326 | |
327 | - do_action( 'wpinv_restore_locale' ); |
|
327 | + do_action('wpinv_restore_locale'); |
|
328 | 328 | } |
329 | 329 | } |
330 | 330 | |
@@ -332,26 +332,26 @@ discard block |
||
332 | 332 | * Returns the default form's id. |
333 | 333 | */ |
334 | 334 | function wpinv_get_default_payment_form() { |
335 | - $form = get_option( 'wpinv_default_payment_form' ); |
|
335 | + $form = get_option('wpinv_default_payment_form'); |
|
336 | 336 | |
337 | - if ( empty( $form ) || 'publish' != get_post_status( $form ) ) { |
|
337 | + if (empty($form) || 'publish' != get_post_status($form)) { |
|
338 | 338 | $form = wp_insert_post( |
339 | 339 | array( |
340 | 340 | 'post_type' => 'wpi_payment_form', |
341 | - 'post_title' => __( 'Checkout (default)', 'invoicing' ), |
|
341 | + 'post_title' => __('Checkout (default)', 'invoicing'), |
|
342 | 342 | 'post_status' => 'publish', |
343 | 343 | 'meta_input' => array( |
344 | - 'wpinv_form_elements' => wpinv_get_data( 'default-payment-form' ), |
|
344 | + 'wpinv_form_elements' => wpinv_get_data('default-payment-form'), |
|
345 | 345 | 'wpinv_form_items' => array(), |
346 | 346 | ) |
347 | 347 | ) |
348 | 348 | ); |
349 | 349 | |
350 | - update_option( 'wpinv_default_payment_form', $form ); |
|
350 | + update_option('wpinv_default_payment_form', $form); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | // WPML support. |
354 | - $form = apply_filters( 'wpml_object_id', $form, 'wpi_payment_form', TRUE ); |
|
354 | + $form = apply_filters('wpml_object_id', $form, 'wpi_payment_form', TRUE); |
|
355 | 355 | return $form; |
356 | 356 | } |
357 | 357 | |
@@ -360,19 +360,19 @@ discard block |
||
360 | 360 | * |
361 | 361 | * @param int $payment_form |
362 | 362 | */ |
363 | -function getpaid_get_payment_form_elements( $payment_form ) { |
|
363 | +function getpaid_get_payment_form_elements($payment_form) { |
|
364 | 364 | |
365 | - if ( empty( $payment_form ) ) { |
|
366 | - return wpinv_get_data( 'sample-payment-form' ); |
|
365 | + if (empty($payment_form)) { |
|
366 | + return wpinv_get_data('sample-payment-form'); |
|
367 | 367 | } |
368 | 368 | |
369 | - $form_elements = get_post_meta( $payment_form, 'wpinv_form_elements', true ); |
|
369 | + $form_elements = get_post_meta($payment_form, 'wpinv_form_elements', true); |
|
370 | 370 | |
371 | - if ( is_array( $form_elements ) ) { |
|
371 | + if (is_array($form_elements)) { |
|
372 | 372 | return $form_elements; |
373 | 373 | } |
374 | 374 | |
375 | - return wpinv_get_data( 'sample-payment-form' ); |
|
375 | + return wpinv_get_data('sample-payment-form'); |
|
376 | 376 | |
377 | 377 | } |
378 | 378 | |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | * |
382 | 382 | * @param int $payment_form |
383 | 383 | */ |
384 | -function gepaid_get_form_items( $id ) { |
|
385 | - $form = new GetPaid_Payment_Form( $id ); |
|
384 | +function gepaid_get_form_items($id) { |
|
385 | + $form = new GetPaid_Payment_Form($id); |
|
386 | 386 | |
387 | 387 | // Is this a default form? |
388 | - if ( $form->is_default() ) { |
|
388 | + if ($form->is_default()) { |
|
389 | 389 | return array(); |
390 | 390 | } |
391 | 391 | |
392 | - return $form->get_items( 'view', 'arrays' ); |
|
392 | + return $form->get_items('view', 'arrays'); |
|
393 | 393 | } |