@@ -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,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = $prefix + $postfix; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | |
209 | 209 | <?php |
210 | 210 | |
211 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
211 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
212 | 212 | |
213 | 213 | // Display the country. |
214 | - if ( 'country' == $key ) { |
|
214 | + if ('country' == $key) { |
|
215 | 215 | |
216 | 216 | echo aui()->select( |
217 | 217 | array( |
218 | 218 | 'options' => wpinv_get_country_list(), |
219 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
220 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
221 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
219 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
220 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
221 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
222 | 222 | 'placeholder' => $label, |
223 | - 'label' => wp_kses_post( $label ), |
|
223 | + 'label' => wp_kses_post($label), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'getpaid-address-field', |
226 | 226 | ) |
@@ -229,30 +229,30 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Display the state. |
232 | - else if ( 'state' == $key ) { |
|
232 | + else if ('state' == $key) { |
|
233 | 233 | |
234 | - echo getpaid_get_states_select_markup ( |
|
235 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
236 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
234 | + echo getpaid_get_states_select_markup( |
|
235 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
236 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
237 | 237 | $label, |
238 | 238 | $label, |
239 | 239 | '', |
240 | 240 | false, |
241 | 241 | '', |
242 | - 'getpaid_address[' . esc_attr( $key ) . ']' |
|
242 | + 'getpaid_address[' . esc_attr($key) . ']' |
|
243 | 243 | ); |
244 | 244 | |
245 | 245 | } else { |
246 | 246 | |
247 | 247 | echo aui()->input( |
248 | 248 | array( |
249 | - 'name' => 'getpaid_address[' . esc_attr( $key ) . ']', |
|
250 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
249 | + 'name' => 'getpaid_address[' . esc_attr($key) . ']', |
|
250 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
251 | 251 | 'placeholder' => $label, |
252 | - 'label' => wp_kses_post( $label ), |
|
252 | + 'label' => wp_kses_post($label), |
|
253 | 253 | 'label_type' => 'vertical', |
254 | 254 | 'type' => 'text', |
255 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
255 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
256 | 256 | 'class' => 'getpaid-address-field', |
257 | 257 | ) |
258 | 258 | ); |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
264 | + do_action('getpaid_display_address_edit_tab'); |
|
265 | 265 | |
266 | 266 | echo aui()->input( |
267 | 267 | array( |
268 | 268 | 'name' => 'getpaid_profile_edit_submit_button', |
269 | 269 | 'id' => 'getpaid_profile_edit_submit_button', |
270 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
271 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
270 | + 'value' => __('Save Address', 'invoicing'), |
|
271 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
272 | 272 | 'type' => 'submit', |
273 | 273 | 'class' => 'btn btn-primary btn-block submit-button', |
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
278 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
277 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
278 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
279 | 279 | ?> |
280 | 280 | |
281 | 281 | </form> |
@@ -292,27 +292,27 @@ discard block |
||
292 | 292 | * @since 2.1.4 |
293 | 293 | * @param array $data |
294 | 294 | */ |
295 | -function getpaid_save_address_edit_tab( $data ) { |
|
295 | +function getpaid_save_address_edit_tab($data) { |
|
296 | 296 | |
297 | - if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) { |
|
297 | + if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) { |
|
298 | 298 | return; |
299 | 299 | } |
300 | 300 | |
301 | 301 | $data = $data['getpaid_address']; |
302 | 302 | $user_id = get_current_user_id(); |
303 | 303 | |
304 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
304 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
305 | 305 | |
306 | - if ( isset( $data[ $field ] ) ) { |
|
307 | - $value = sanitize_text_field( $data[ $field ] ); |
|
308 | - update_user_meta( $user_id, '_wpinv_' . $field, $value ); |
|
306 | + if (isset($data[$field])) { |
|
307 | + $value = sanitize_text_field($data[$field]); |
|
308 | + update_user_meta($user_id, '_wpinv_' . $field, $value); |
|
309 | 309 | } |
310 | 310 | |
311 | - wpinv_set_error( 'address_updated', __( 'Your billing address has been updated', 'invoicing' ), 'success'); |
|
311 | + wpinv_set_error('address_updated', __('Your billing address has been updated', 'invoicing'), 'success'); |
|
312 | 312 | } |
313 | 313 | |
314 | 314 | } |
315 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
315 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
316 | 316 | |
317 | 317 | |
318 | 318 | /* |
@@ -330,27 +330,27 @@ discard block |
||
330 | 330 | * @param array $tabs |
331 | 331 | * @return array |
332 | 332 | */ |
333 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
333 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
334 | 334 | |
335 | 335 | // Abort if the integration is inactive. |
336 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
336 | + if (!getpaid_is_userswp_integration_active()) { |
|
337 | 337 | return $tabs; |
338 | 338 | } |
339 | 339 | |
340 | - $new_tabs = array(); |
|
340 | + $new_tabs = array(); |
|
341 | 341 | |
342 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
342 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
343 | 343 | |
344 | - $new_tabs[ $slug ] = array( |
|
345 | - 'title' => $tab[ 'label'], |
|
346 | - 'icon' => $tab[ 'icon'], |
|
344 | + $new_tabs[$slug] = array( |
|
345 | + 'title' => $tab['label'], |
|
346 | + 'icon' => $tab['icon'], |
|
347 | 347 | ); |
348 | 348 | |
349 | 349 | } |
350 | 350 | |
351 | - return array_merge( $tabs, $new_tabs ); |
|
351 | + return array_merge($tabs, $new_tabs); |
|
352 | 352 | } |
353 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
353 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * Display our UsersWP account tabs. |
@@ -359,18 +359,18 @@ discard block |
||
359 | 359 | * @param array $tabs |
360 | 360 | * @return array |
361 | 361 | */ |
362 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
362 | +function getpaid_display_userswp_account_tabs($tab) { |
|
363 | 363 | global $getpaid_tab_url; |
364 | 364 | |
365 | 365 | $our_tabs = getpaid_get_user_content_tabs(); |
366 | 366 | |
367 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
368 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
369 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
367 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
368 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
369 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | } |
373 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
373 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
374 | 374 | |
375 | 375 | |
376 | 376 | /** |
@@ -381,17 +381,17 @@ discard block |
||
381 | 381 | * @param string $tab Current tab. |
382 | 382 | * @return string Title. |
383 | 383 | */ |
384 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
384 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
385 | 385 | |
386 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
386 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
387 | 387 | |
388 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
389 | - return $our_tabs[ $tab ]['label']; |
|
388 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
389 | + return $our_tabs[$tab]['label']; |
|
390 | 390 | } |
391 | 391 | |
392 | 392 | return $title; |
393 | 393 | } |
394 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
394 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
395 | 395 | |
396 | 396 | /** |
397 | 397 | * Registers the UsersWP integration settings. |
@@ -400,26 +400,26 @@ discard block |
||
400 | 400 | * @param array $settings An array of integration settings. |
401 | 401 | * @return array |
402 | 402 | */ |
403 | -function getpaid_register_userswp_settings( $settings ) { |
|
403 | +function getpaid_register_userswp_settings($settings) { |
|
404 | 404 | |
405 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
405 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
406 | 406 | |
407 | 407 | $settings[] = array( |
408 | 408 | |
409 | 409 | 'id' => 'userswp', |
410 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
410 | + 'label' => __('UsersWP', 'invoicing'), |
|
411 | 411 | 'settings' => array( |
412 | 412 | |
413 | 413 | 'userswp_settings' => array( |
414 | 414 | 'id' => 'userswp_settings', |
415 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
415 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
416 | 416 | 'type' => 'header', |
417 | 417 | ), |
418 | 418 | |
419 | 419 | 'enable_userswp' => array( |
420 | 420 | 'id' => 'enable_userswp', |
421 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
422 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
421 | + 'name' => __('Enable Integration', 'invoicing'), |
|
422 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
423 | 423 | 'type' => 'checkbox', |
424 | 424 | 'std' => 1, |
425 | 425 | ) |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | |
433 | 433 | return $settings; |
434 | 434 | } |
435 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
435 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
436 | 436 | |
437 | 437 | /** |
438 | 438 | * Ovewrites the invoices history page to UsersWP. |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @since 2.3.1 |
441 | 441 | * @return bool |
442 | 442 | */ |
443 | -function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) { |
|
443 | +function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) { |
|
444 | 444 | |
445 | 445 | $our_tabs = getpaid_get_user_content_tabs(); |
446 | 446 | $tab = "gp-{$post_type}s"; |
447 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
448 | - return add_query_arg( 'type', $tab, uwp_get_account_page_url() ); |
|
447 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
448 | + return add_query_arg('type', $tab, uwp_get_account_page_url()); |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | return $url; |
452 | 452 | |
453 | 453 | } |
454 | -add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 ); |
|
454 | +add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2); |
|
455 | 455 | |
456 | 456 | /** |
457 | 457 | * Checks if the integration is enabled. |
@@ -460,8 +460,8 @@ discard block |
||
460 | 460 | * @return bool |
461 | 461 | */ |
462 | 462 | function getpaid_is_userswp_integration_active() { |
463 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
464 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
463 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
464 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /* |
@@ -479,26 +479,26 @@ discard block |
||
479 | 479 | * @param array $settings An array of integration settings. |
480 | 480 | * @return array |
481 | 481 | */ |
482 | -function getpaid_register_buddypress_settings( $settings ) { |
|
482 | +function getpaid_register_buddypress_settings($settings) { |
|
483 | 483 | |
484 | - if ( class_exists( 'BuddyPress' ) ) { |
|
484 | + if (class_exists('BuddyPress')) { |
|
485 | 485 | |
486 | 486 | $settings[] = array( |
487 | 487 | |
488 | 488 | 'id' => 'buddypress', |
489 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
489 | + 'label' => __('BuddyPress', 'invoicing'), |
|
490 | 490 | 'settings' => array( |
491 | 491 | |
492 | 492 | 'buddypress_settings' => array( |
493 | 493 | 'id' => 'buddypress_settings', |
494 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
494 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
495 | 495 | 'type' => 'header', |
496 | 496 | ), |
497 | 497 | |
498 | 498 | 'enable_buddypress' => array( |
499 | 499 | 'id' => 'enable_buddypress', |
500 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
501 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
500 | + 'name' => __('Enable Integration', 'invoicing'), |
|
501 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
502 | 502 | 'type' => 'checkbox', |
503 | 503 | 'std' => 1, |
504 | 504 | ) |
@@ -511,7 +511,7 @@ discard block |
||
511 | 511 | |
512 | 512 | return $settings; |
513 | 513 | } |
514 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
514 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Checks if the integration is enabled. |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | * @return bool |
521 | 521 | */ |
522 | 522 | function getpaid_is_buddypress_integration_active() { |
523 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
524 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
523 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
524 | + return class_exists('BuddyPress') && !empty($enabled); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | /** |
@@ -532,10 +532,10 @@ discard block |
||
532 | 532 | */ |
533 | 533 | function getpaid_setup_buddypress_integration() { |
534 | 534 | |
535 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
536 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php' ); |
|
535 | + if (getpaid_is_buddypress_integration_active()) { |
|
536 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'); |
|
537 | 537 | buddypress()->getpaid = new BP_GetPaid_Component(); |
538 | 538 | } |
539 | 539 | |
540 | 540 | } |
541 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
541 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |