@@ -7,17 +7,17 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -if ( empty( $text ) ) { |
|
12 | +if (empty($text)) { |
|
13 | 13 | return; |
14 | 14 | } |
15 | 15 | |
16 | 16 | aui()->alert( |
17 | 17 | array( |
18 | - 'content' => wp_kses_post( $text ), |
|
19 | - 'dismissible' => ! empty( $dismissible ), |
|
20 | - 'type' => empty( $class ) ? 'info' : str_replace( 'alert-', '', $class ), |
|
18 | + 'content' => wp_kses_post($text), |
|
19 | + 'dismissible' => !empty($dismissible), |
|
20 | + 'type' => empty($class) ? 'info' : str_replace('alert-', '', $class), |
|
21 | 21 | ), |
22 | 22 | true |
23 | 23 | ); |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[ $item->get_id() ] = strip_tags( $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ) ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = strip_tags($item->get_name() . ' — ' . wpinv_price($item->get_initial_price())); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | aui()->select( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'inline' => false, |
35 | 35 | 'options' => $selectable, |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the selectable items. |
13 | 13 | $selectable = array(); |
14 | -foreach ( $form->get_items() as $item ) { |
|
15 | - if ( ! $item->is_required ) { |
|
16 | - $selectable[ $item->get_id() ] = $item->get_name() . ' — ' . wpinv_price( $item->get_initial_price() ); |
|
14 | +foreach ($form->get_items() as $item) { |
|
15 | + if (!$item->is_required) { |
|
16 | + $selectable[$item->get_id()] = $item->get_name() . ' — ' . wpinv_price($item->get_initial_price()); |
|
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | -if ( empty( $selectable ) ) { |
|
20 | +if (empty($selectable)) { |
|
21 | 21 | return; |
22 | 22 | } |
23 | 23 | |
@@ -27,9 +27,9 @@ discard block |
||
27 | 27 | aui()->radio( |
28 | 28 | array( |
29 | 29 | 'name' => 'getpaid-payment-form-selected-item', |
30 | - 'id' => 'getpaid-payment-form-selected-item' . uniqid( '_' ), |
|
30 | + 'id' => 'getpaid-payment-form-selected-item' . uniqid('_'), |
|
31 | 31 | 'required' => true, |
32 | - 'label' => __( 'Select Item', 'invoicing' ), |
|
32 | + 'label' => __('Select Item', 'invoicing'), |
|
33 | 33 | 'label_type' => 'vertical', |
34 | 34 | 'class' => 'w-auto', |
35 | 35 | 'inline' => false, |
@@ -1,51 +1,51 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | - die( '-1' ); |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | + die('-1'); |
|
5 | 5 | } |
6 | 6 | |
7 | -do_action( 'wpinv_email_before_billing_details', $invoice ); ?> |
|
7 | +do_action('wpinv_email_before_billing_details', $invoice); ?> |
|
8 | 8 | <div id="wpinv-email-billing"> |
9 | - <h3 class="wpinv-address-t"><?php echo esc_html( apply_filters( 'wpinv_email_billing_title', __( 'Billing Details', 'invoicing' ) ) ); ?></h3> |
|
9 | + <h3 class="wpinv-address-t"><?php echo esc_html(apply_filters('wpinv_email_billing_title', __('Billing Details', 'invoicing'))); ?></h3> |
|
10 | 10 | |
11 | 11 | <table class="table table-bordered table-sm wpi-billing-details"> |
12 | 12 | <tbody> |
13 | - <?php do_action( 'wpinv_email_billing_fields_first', $invoice ); ?> |
|
13 | + <?php do_action('wpinv_email_billing_fields_first', $invoice); ?> |
|
14 | 14 | <tr class="wpi-receipt-name"> |
15 | - <th class="text-left"><?php esc_html_e( 'Name', 'invoicing' ); ?></th> |
|
15 | + <th class="text-left"><?php esc_html_e('Name', 'invoicing'); ?></th> |
|
16 | 16 | <td> |
17 | 17 | <?php |
18 | - if ( $sent_to_admin && $invoice->get_user_id() ) { |
|
18 | + if ($sent_to_admin && $invoice->get_user_id()) { |
|
19 | 19 | ?> |
20 | -<a href="<?php echo esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), self_admin_url( 'user-edit.php' ) ) ); ?>"><?php echo esc_html( $invoice->get_user_full_name() ); ?></a> |
|
20 | +<a href="<?php echo esc_url(add_query_arg('user_id', $invoice->get_user_id(), self_admin_url('user-edit.php'))); ?>"><?php echo esc_html($invoice->get_user_full_name()); ?></a> |
|
21 | 21 | <?php |
22 | 22 | } else { |
23 | - echo esc_html( $invoice->get_user_full_name() ); } |
|
23 | + echo esc_html($invoice->get_user_full_name()); } |
|
24 | 24 | ?> |
25 | 25 | </td> |
26 | 26 | </tr> |
27 | 27 | <tr class="wpi-receipt-email"> |
28 | - <th class="text-left"><?php esc_html_e( 'Email', 'invoicing' ); ?></th> |
|
29 | - <td><?php echo esc_html( sanitize_email( $invoice->get_email() ) ); ?></td> |
|
28 | + <th class="text-left"><?php esc_html_e('Email', 'invoicing'); ?></th> |
|
29 | + <td><?php echo esc_html(sanitize_email($invoice->get_email())); ?></td> |
|
30 | 30 | </tr> |
31 | - <?php if ( $invoice->get_company() ) { ?> |
|
31 | + <?php if ($invoice->get_company()) { ?> |
|
32 | 32 | <tr class="wpi-receipt-company"> |
33 | - <th class="text-left"><?php esc_html_e( 'Company', 'invoicing' ); ?></th> |
|
34 | - <td><?php echo esc_html( $invoice->get_company() ); ?></td> |
|
33 | + <th class="text-left"><?php esc_html_e('Company', 'invoicing'); ?></th> |
|
34 | + <td><?php echo esc_html($invoice->get_company()); ?></td> |
|
35 | 35 | </tr> |
36 | 36 | <?php } ?> |
37 | 37 | <tr class="wpi-receipt-address"> |
38 | - <th class="text-left"><?php esc_html_e( 'Address', 'invoicing' ); ?></th> |
|
39 | - <td><?php echo wp_kses_post( wpinv_get_invoice_address_markup( $invoice->get_user_info() ) ); ?></td> |
|
38 | + <th class="text-left"><?php esc_html_e('Address', 'invoicing'); ?></th> |
|
39 | + <td><?php echo wp_kses_post(wpinv_get_invoice_address_markup($invoice->get_user_info())); ?></td> |
|
40 | 40 | </tr> |
41 | - <?php if ( $invoice->get_phone() ) { ?> |
|
41 | + <?php if ($invoice->get_phone()) { ?> |
|
42 | 42 | <tr class="wpi-receipt-phone"> |
43 | - <th class="text-left"><?php esc_html_e( 'Phone', 'invoicing' ); ?></th> |
|
44 | - <td><?php echo esc_html( $invoice->get_phone() ); ?></td> |
|
43 | + <th class="text-left"><?php esc_html_e('Phone', 'invoicing'); ?></th> |
|
44 | + <td><?php echo esc_html($invoice->get_phone()); ?></td> |
|
45 | 45 | </tr> |
46 | 46 | <?php } ?> |
47 | - <?php do_action( 'wpinv_email_billing_fields_last', $invoice ); ?> |
|
47 | + <?php do_action('wpinv_email_billing_fields_last', $invoice); ?> |
|
48 | 48 | </tbody> |
49 | 49 | </table> |
50 | 50 | </div> |
51 | -<?php do_action( 'wpinv_email_after_billing_details', $invoice ); ?> |
|
51 | +<?php do_action('wpinv_email_after_billing_details', $invoice); ?> |
@@ -1,20 +1,20 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( ! defined( 'ABSPATH' ) ) { |
|
4 | - die( '-1' ); |
|
3 | +if (!defined('ABSPATH')) { |
|
4 | + die('-1'); |
|
5 | 5 | } |
6 | 6 | |
7 | -if ( ! isset( $email_heading ) ) { |
|
7 | +if (!isset($email_heading)) { |
|
8 | 8 | global $email_heading; |
9 | 9 | } |
10 | 10 | ?> |
11 | 11 | <!DOCTYPE html> |
12 | 12 | <html dir="<?php echo is_rtl() ? 'rtl' : 'ltr'; ?>"> |
13 | 13 | <head> |
14 | - <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo( 'charset' ); ?>" /> |
|
14 | + <meta http-equiv="Content-Type" content="text/html; charset=<?php bloginfo('charset'); ?>" /> |
|
15 | 15 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
16 | 16 | <meta name="robots" content="noindex,nofollow"> |
17 | - <title><?php echo esc_html( wpinv_get_blogname() ); ?></title> |
|
17 | + <title><?php echo esc_html(wpinv_get_blogname()); ?></title> |
|
18 | 18 | </head> |
19 | 19 | <body <?php echo is_rtl() ? 'rightmargin' : 'leftmargin'; ?>="0" marginwidth="0" topmargin="0" marginheight="0" offset="0"> |
20 | 20 | <div id="wrapper" dir="<?php echo is_rtl() ? 'rtl' : 'ltr'; ?>"> |
@@ -23,21 +23,21 @@ discard block |
||
23 | 23 | <td align="center" valign="top"> |
24 | 24 | <div id="template_header_image"> |
25 | 25 | <?php |
26 | - $img = wpinv_get_option( 'email_header_image', '' ); |
|
27 | - if ( $img ) { |
|
28 | - echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url( $img ) . '" alt="' . esc_attr( wpinv_get_blogname() ) . '" /></p>'; |
|
26 | + $img = wpinv_get_option('email_header_image', ''); |
|
27 | + if ($img) { |
|
28 | + echo '<p style="margin-top:0;"><img style="max-width:100%" src="' . esc_url($img) . '" alt="' . esc_attr(wpinv_get_blogname()) . '" /></p>'; |
|
29 | 29 | } |
30 | 30 | ?> |
31 | 31 | </div> |
32 | 32 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_container"> |
33 | - <?php if ( ! empty( $email_heading ) ) { ?> |
|
33 | + <?php if (!empty($email_heading)) { ?> |
|
34 | 34 | <tr> |
35 | 35 | <td align="center" valign="top"> |
36 | 36 | <!-- Header --> |
37 | 37 | <table border="0" cellpadding="0" cellspacing="0" width="100%" id="template_header"> |
38 | 38 | <tr> |
39 | 39 | <td id="header_wrapper"> |
40 | - <h1><?php echo esc_html( $email_heading ); ?></h1> |
|
40 | + <h1><?php echo esc_html($email_heading); ?></h1> |
|
41 | 41 | </td> |
42 | 42 | </tr> |
43 | 43 | </table> |
@@ -4,15 +4,15 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | |
11 | 11 | <div class="card shadow-sm my-5"> |
12 | 12 | |
13 | 13 | <form method="post" class="text-left card-body" action="options.php"> |
14 | - <?php settings_fields( 'wpinv_settings' ); ?> |
|
15 | - <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url( $next_url ); ?>"> |
|
14 | + <?php settings_fields('wpinv_settings'); ?> |
|
15 | + <input type="hidden" name="_wp_http_referer" value="<?php echo esc_url($next_url); ?>"> |
|
16 | 16 | |
17 | 17 | <table class="gp-setup-maps w-100 " cellspacing="0"> |
18 | 18 | <tbody> |
@@ -20,28 +20,28 @@ discard block |
||
20 | 20 | |
21 | 21 | global $wp_settings_fields; |
22 | 22 | |
23 | - if ( isset( $wp_settings_fields[ $page ][ $section ] ) ) { |
|
24 | - $settings = $wp_settings_fields[ $page ][ $section ]; |
|
23 | + if (isset($wp_settings_fields[$page][$section])) { |
|
24 | + $settings = $wp_settings_fields[$page][$section]; |
|
25 | 25 | |
26 | - foreach ( $settings as $field ) { |
|
26 | + foreach ($settings as $field) { |
|
27 | 27 | |
28 | - $name = esc_attr( $field['id'] ); |
|
29 | - $id = sanitize_key( $name ); |
|
28 | + $name = esc_attr($field['id']); |
|
29 | + $id = sanitize_key($name); |
|
30 | 30 | $class = ''; |
31 | - $value = isset( $field['args']['std'] ) ? $field['args']['std'] : ''; |
|
32 | - $value = wpinv_clean( wpinv_get_option( $field['args']['id'], $value ) ); |
|
33 | - $help_text = isset( $field['args']['desc'] ) ? wp_kses_post( $field['args']['desc'] ) : ''; |
|
34 | - $type = str_replace( 'wpinv_', '', str_replace( '_callback', '', $field['callback'] ) ); |
|
35 | - $label = isset( $field['args']['name'] ) ? wp_kses_post( $field['args']['name'] ) : ''; |
|
36 | - $options = isset( $field['args']['options'] ) ? $field['args']['options'] : array(); |
|
37 | - |
|
38 | - if ( false !== strpos( $name, 'logo' ) ) { |
|
31 | + $value = isset($field['args']['std']) ? $field['args']['std'] : ''; |
|
32 | + $value = wpinv_clean(wpinv_get_option($field['args']['id'], $value)); |
|
33 | + $help_text = isset($field['args']['desc']) ? wp_kses_post($field['args']['desc']) : ''; |
|
34 | + $type = str_replace('wpinv_', '', str_replace('_callback', '', $field['callback'])); |
|
35 | + $label = isset($field['args']['name']) ? wp_kses_post($field['args']['name']) : ''; |
|
36 | + $options = isset($field['args']['options']) ? $field['args']['options'] : array(); |
|
37 | + |
|
38 | + if (false !== strpos($name, 'logo')) { |
|
39 | 39 | $type = 'hidden'; |
40 | 40 | } |
41 | 41 | |
42 | - if ( 'country_states' == $type ) { |
|
42 | + if ('country_states' == $type) { |
|
43 | 43 | |
44 | - if ( 0 == count( wpinv_get_country_states( wpinv_get_default_country() ) ) ) { |
|
44 | + if (0 == count(wpinv_get_country_states(wpinv_get_default_country()))) { |
|
45 | 45 | $type = 'text'; |
46 | 46 | } else { |
47 | 47 | $type = 'select'; |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | $class = 'getpaid_js_field-state'; |
51 | 51 | } |
52 | 52 | |
53 | - if ( 'wpinv_settings[default_country]' == $name ) { |
|
53 | + if ('wpinv_settings[default_country]' == $name) { |
|
54 | 54 | $class = 'getpaid_js_field-country'; |
55 | 55 | } |
56 | 56 | |
57 | - switch ( $type ) { |
|
57 | + switch ($type) { |
|
58 | 58 | |
59 | 59 | case 'hidden': |
60 | - echo "<input type='hidden' id='" . esc_attr( $id ) . "' name='" . esc_attr( $name ) . "' value='" . esc_attr( $value ) . "' />"; |
|
60 | + echo "<input type='hidden' id='" . esc_attr($id) . "' name='" . esc_attr($name) . "' value='" . esc_attr($value) . "' />"; |
|
61 | 61 | break; |
62 | 62 | case 'text': |
63 | 63 | case 'number': |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | 'type' => $type, |
67 | 67 | 'id' => $id, |
68 | 68 | 'name' => $name, |
69 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
69 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
70 | 70 | 'required' => false, |
71 | 71 | 'help_text' => $help_text, |
72 | 72 | 'label' => $label, |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | array( |
83 | 83 | 'id' => $id, |
84 | 84 | 'name' => $name, |
85 | - 'value' => is_scalar( $value ) ? esc_textarea( $value ) : '', |
|
85 | + 'value' => is_scalar($value) ? esc_textarea($value) : '', |
|
86 | 86 | 'required' => false, |
87 | 87 | 'help_text' => $help_text, |
88 | 88 | 'label' => $label, |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | 'id' => $id, |
102 | 102 | 'name' => $name, |
103 | 103 | 'placeholder' => '', |
104 | - 'value' => is_scalar( $value ) ? esc_attr( $value ) : '', |
|
104 | + 'value' => is_scalar($value) ? esc_attr($value) : '', |
|
105 | 105 | 'required' => false, |
106 | 106 | 'help_text' => $help_text, |
107 | 107 | 'label' => $label, |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | <input |
128 | 128 | type="submit" |
129 | 129 | class="btn btn-primary button-next" |
130 | - value="<?php esc_attr_e( 'Continue', 'invoicing' ); ?>" name="save_step"/> |
|
130 | + value="<?php esc_attr_e('Continue', 'invoicing'); ?>" name="save_step"/> |
|
131 | 131 | </p> |
132 | 132 | </table> |
133 | 133 | </form> |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @version 2.4.0 |
11 | 11 | * @info GetPaid Setup Wizard. |
12 | 12 | */ |
13 | -defined( 'ABSPATH' ) || exit; |
|
13 | +defined('ABSPATH') || exit; |
|
14 | 14 | |
15 | 15 | /** |
16 | 16 | * GetPaid_Admin_Setup_Wizard class. |
@@ -44,9 +44,9 @@ discard block |
||
44 | 44 | */ |
45 | 45 | public function __construct() { |
46 | 46 | |
47 | - if ( apply_filters( 'getpaid_enable_setup_wizard', true ) && wpinv_current_user_can_manage_invoicing() ) { |
|
48 | - add_action( 'admin_menu', array( $this, 'add_menu' ) ); |
|
49 | - add_action( 'current_screen', array( $this, 'setup_wizard' ) ); |
|
47 | + if (apply_filters('getpaid_enable_setup_wizard', true) && wpinv_current_user_can_manage_invoicing()) { |
|
48 | + add_action('admin_menu', array($this, 'add_menu')); |
|
49 | + add_action('current_screen', array($this, 'setup_wizard')); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | } |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * @since 2.4.0 |
58 | 58 | */ |
59 | 59 | public function add_menu() { |
60 | - add_dashboard_page( '', '', wpinv_get_capability(), 'gp-setup', '' ); |
|
60 | + add_dashboard_page('', '', wpinv_get_capability(), 'gp-setup', ''); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | */ |
68 | 68 | public function setup_wizard() { |
69 | 69 | |
70 | - if ( isset( $_GET['page'] ) && 'gp-setup' === $_GET['page'] ) { |
|
70 | + if (isset($_GET['page']) && 'gp-setup' === $_GET['page']) { |
|
71 | 71 | $this->setup_globals(); |
72 | 72 | $this->maybe_save_current_step(); |
73 | 73 | $this->display_wizard(); |
@@ -94,8 +94,8 @@ discard block |
||
94 | 94 | * @since 2.4.0 |
95 | 95 | */ |
96 | 96 | protected function maybe_save_current_step() { |
97 | - if ( ! empty( $_POST['save_step'] ) && is_callable( $this->steps[ $this->step ]['handler'] ) ) { |
|
98 | - call_user_func( $this->steps[ $this->step ]['handler'], $this ); |
|
97 | + if (!empty($_POST['save_step']) && is_callable($this->steps[$this->step]['handler'])) { |
|
98 | + call_user_func($this->steps[$this->step]['handler'], $this); |
|
99 | 99 | } |
100 | 100 | } |
101 | 101 | |
@@ -110,44 +110,44 @@ discard block |
||
110 | 110 | $steps = array( |
111 | 111 | |
112 | 112 | 'introduction' => array( |
113 | - 'name' => __( 'Introduction', 'invoicing' ), |
|
114 | - 'view' => array( $this, 'setup_introduction' ), |
|
113 | + 'name' => __('Introduction', 'invoicing'), |
|
114 | + 'view' => array($this, 'setup_introduction'), |
|
115 | 115 | 'handler' => '', |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'business_details' => array( |
119 | - 'name' => __( 'Business Details', 'invoicing' ), |
|
120 | - 'view' => array( $this, 'setup_business' ), |
|
119 | + 'name' => __('Business Details', 'invoicing'), |
|
120 | + 'view' => array($this, 'setup_business'), |
|
121 | 121 | 'handler' => '', |
122 | 122 | ), |
123 | 123 | |
124 | 124 | 'currency' => array( |
125 | - 'name' => __( 'Currency', 'invoicing' ), |
|
126 | - 'view' => array( $this, 'setup_currency' ), |
|
125 | + 'name' => __('Currency', 'invoicing'), |
|
126 | + 'view' => array($this, 'setup_currency'), |
|
127 | 127 | 'handler' => '', |
128 | 128 | ), |
129 | 129 | |
130 | 130 | 'payments' => array( |
131 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
132 | - 'view' => array( $this, 'setup_payments' ), |
|
133 | - 'handler' => array( $this, 'setup_payments_save' ), |
|
131 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
132 | + 'view' => array($this, 'setup_payments'), |
|
133 | + 'handler' => array($this, 'setup_payments_save'), |
|
134 | 134 | ), |
135 | 135 | |
136 | 136 | 'recommend' => array( |
137 | - 'name' => __( 'Recommend', 'invoicing' ), |
|
138 | - 'view' => array( $this, 'setup_recommend' ), |
|
137 | + 'name' => __('Recommend', 'invoicing'), |
|
138 | + 'view' => array($this, 'setup_recommend'), |
|
139 | 139 | 'handler' => '', |
140 | 140 | ), |
141 | 141 | |
142 | 142 | 'next_steps' => array( |
143 | - 'name' => __( 'Get Paid', 'invoicing' ), |
|
144 | - 'view' => array( $this, 'setup_ready' ), |
|
143 | + 'name' => __('Get Paid', 'invoicing'), |
|
144 | + 'view' => array($this, 'setup_ready'), |
|
145 | 145 | 'handler' => '', |
146 | 146 | ), |
147 | 147 | |
148 | 148 | ); |
149 | 149 | |
150 | - return apply_filters( 'getpaid_setup_wizard_steps', $steps ); |
|
150 | + return apply_filters('getpaid_setup_wizard_steps', $steps); |
|
151 | 151 | |
152 | 152 | } |
153 | 153 | |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @return string |
159 | 159 | */ |
160 | 160 | protected function get_current_step() { |
161 | - $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : ''; |
|
162 | - return ! empty( $step ) && in_array( $step, array_keys( $this->steps ) ) ? $step : current( array_keys( $this->steps ) ); |
|
161 | + $step = isset($_GET['step']) ? sanitize_key($_GET['step']) : ''; |
|
162 | + return !empty($step) && in_array($step, array_keys($this->steps)) ? $step : current(array_keys($this->steps)); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | |
173 | 173 | $previous = false; |
174 | 174 | $current = $this->step; |
175 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
176 | - if ( $current === $step ) { |
|
175 | + foreach (array_keys($this->steps) as $step) { |
|
176 | + if ($current === $step) { |
|
177 | 177 | return $previous; |
178 | 178 | } |
179 | 179 | |
@@ -193,13 +193,13 @@ discard block |
||
193 | 193 | |
194 | 194 | $on_current = false; |
195 | 195 | $current = $this->step; |
196 | - foreach ( array_keys( $this->steps ) as $step ) { |
|
196 | + foreach (array_keys($this->steps) as $step) { |
|
197 | 197 | |
198 | - if ( $on_current ) { |
|
198 | + if ($on_current) { |
|
199 | 199 | return $step; |
200 | 200 | } |
201 | 201 | |
202 | - if ( $current === $step ) { |
|
202 | + if ($current === $step) { |
|
203 | 203 | return $on_current = true; |
204 | 204 | } |
205 | 205 | } |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | $steps = $this->steps; |
228 | 228 | $current = $this->step; |
229 | 229 | $next_step = $this->next_step; |
230 | - array_shift( $steps ); |
|
231 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-header.php'; |
|
230 | + array_shift($steps); |
|
231 | + include plugin_dir_path(__FILE__) . 'views/wizard-header.php'; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | ?> |
241 | 241 | <div class="gp-setup-content rowx mw-100 text-center mb-3"> |
242 | 242 | <div class="col-12 col-md-5 m-auto"> |
243 | - <?php call_user_func( $this->steps[ $this->step ]['view'], $this ); ?> |
|
243 | + <?php call_user_func($this->steps[$this->step]['view'], $this); ?> |
|
244 | 244 | </div> |
245 | 245 | </div> |
246 | 246 | <?php |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function display_footer() { |
255 | 255 | |
256 | - if ( isset( $_GET['step'] ) ) { |
|
257 | - $label = $this->step == 'next_steps' ? __( 'Return to the WordPress Dashboard', 'invoicing' ) : __( 'Skip this step', 'invoicing' ); |
|
256 | + if (isset($_GET['step'])) { |
|
257 | + $label = $this->step == 'next_steps' ? __('Return to the WordPress Dashboard', 'invoicing') : __('Skip this step', 'invoicing'); |
|
258 | 258 | |
259 | - echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url( $this->get_next_step_link() ) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html( $label ) . '</a></p>'; |
|
259 | + echo '<p class="gd-return-to-dashboard-wrap"> <a href="' . esc_url($this->get_next_step_link()) . '" class="gd-return-to-dashboard btn btn-link d-block text-muted">' . esc_html($label) . '</a></p>'; |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | echo '</body></html>'; |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | */ |
270 | 270 | public function setup_introduction() { |
271 | 271 | $next_url = $this->get_next_step_link(); |
272 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-introduction.php'; |
|
272 | + include plugin_dir_path(__FILE__) . 'views/wizard-introduction.php'; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | /** |
@@ -282,22 +282,22 @@ discard block |
||
282 | 282 | * Empty string on failure. |
283 | 283 | * @since 3.0.0 |
284 | 284 | */ |
285 | - public function get_next_step_link( $step = '' ) { |
|
286 | - if ( ! $step ) { |
|
285 | + public function get_next_step_link($step = '') { |
|
286 | + if (!$step) { |
|
287 | 287 | $step = $this->step; |
288 | 288 | } |
289 | 289 | |
290 | - $keys = array_keys( $this->steps ); |
|
291 | - if ( end( $keys ) === $step ) { |
|
290 | + $keys = array_keys($this->steps); |
|
291 | + if (end($keys) === $step) { |
|
292 | 292 | return admin_url(); |
293 | 293 | } |
294 | 294 | |
295 | - $step_index = array_search( $step, $keys ); |
|
296 | - if ( false === $step_index ) { |
|
295 | + $step_index = array_search($step, $keys); |
|
296 | + if (false === $step_index) { |
|
297 | 297 | return ''; |
298 | 298 | } |
299 | 299 | |
300 | - return remove_query_arg( 'settings-updated', add_query_arg( 'step', $keys[ $step_index + 1 ] ) ); |
|
300 | + return remove_query_arg('settings-updated', add_query_arg('step', $keys[$step_index + 1])); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | $wizard = $this; |
311 | 311 | $page = 'wpinv_settings_general_main'; |
312 | 312 | $section = 'wpinv_settings_general_main'; |
313 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
313 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $wizard = $this; |
324 | 324 | $page = 'wpinv_settings_general_currency_section'; |
325 | 325 | $section = 'wpinv_settings_general_currency_section'; |
326 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-settings.php'; |
|
326 | + include plugin_dir_path(__FILE__) . 'views/wizard-settings.php'; |
|
327 | 327 | } |
328 | 328 | |
329 | 329 | /** |
@@ -334,7 +334,7 @@ discard block |
||
334 | 334 | public function setup_recommend() { |
335 | 335 | $next_url = $this->get_next_step_link(); |
336 | 336 | $recommended_plugins = self::get_recommend_wp_plugins(); |
337 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-plugins.php'; |
|
337 | + include plugin_dir_path(__FILE__) . 'views/wizard-plugins.php'; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
@@ -348,21 +348,21 @@ discard block |
||
348 | 348 | 'url' => 'https://wordpress.org/plugins/ayecode-connect/', |
349 | 349 | 'slug' => 'ayecode-connect', |
350 | 350 | 'name' => 'AyeCode Connect', |
351 | - 'desc' => __( 'Documentation and Support from within your WordPress admin.', 'invoicing' ), |
|
351 | + 'desc' => __('Documentation and Support from within your WordPress admin.', 'invoicing'), |
|
352 | 352 | ), |
353 | 353 | 'invoicing-quotes' => array( |
354 | 354 | 'file' => 'invoicing-quotes/wpinv-quote.php', |
355 | 355 | 'url' => 'https://wordpress.org/plugins/invoicing-quotes/', |
356 | 356 | 'slug' => 'invoicing-quotes', |
357 | 357 | 'name' => 'Customer Quotes', |
358 | - 'desc' => __( 'Create & Send Quotes to Customers and have them accept and pay.', 'invoicing' ), |
|
358 | + 'desc' => __('Create & Send Quotes to Customers and have them accept and pay.', 'invoicing'), |
|
359 | 359 | ), |
360 | 360 | 'userswp' => array( |
361 | 361 | 'file' => 'userswp/userswp.php', |
362 | 362 | 'url' => 'https://wordpress.org/plugins/userswp/', |
363 | 363 | 'slug' => 'userswp', |
364 | 364 | 'name' => 'UsersWP', |
365 | - 'desc' => __( 'Frontend user login and registration as well as slick profile pages.', 'invoicing' ), |
|
365 | + 'desc' => __('Frontend user login and registration as well as slick profile pages.', 'invoicing'), |
|
366 | 366 | ), |
367 | 367 | ); |
368 | 368 | } |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | */ |
375 | 375 | public function setup_payments() { |
376 | 376 | $next_url = $this->get_next_step_link(); |
377 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-gateways.php'; |
|
377 | + include plugin_dir_path(__FILE__) . 'views/wizard-gateways.php'; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -385,16 +385,16 @@ discard block |
||
385 | 385 | * @since 2.0.0 |
386 | 386 | */ |
387 | 387 | public function setup_payments_save() { |
388 | - check_admin_referer( 'getpaid-setup-wizard', 'getpaid-setup-wizard' ); |
|
389 | - wpinv_update_option( 'manual_active', ! empty( $_POST['enable-manual-gateway'] ) ); |
|
388 | + check_admin_referer('getpaid-setup-wizard', 'getpaid-setup-wizard'); |
|
389 | + wpinv_update_option('manual_active', !empty($_POST['enable-manual-gateway'])); |
|
390 | 390 | |
391 | - if ( ! empty( $_POST['paypal-email'] ) ) { |
|
392 | - wpinv_update_option( 'paypal_email', sanitize_email( $_POST['paypal-email'] ) ); |
|
393 | - wpinv_update_option( 'paypal_active', 1 ); |
|
394 | - wpinv_update_option( 'paypal_sandbox', 0 ); |
|
391 | + if (!empty($_POST['paypal-email'])) { |
|
392 | + wpinv_update_option('paypal_email', sanitize_email($_POST['paypal-email'])); |
|
393 | + wpinv_update_option('paypal_active', 1); |
|
394 | + wpinv_update_option('paypal_sandbox', 0); |
|
395 | 395 | } |
396 | 396 | |
397 | - wp_redirect( esc_url_raw( $this->get_next_step_link() ) ); |
|
397 | + wp_redirect(esc_url_raw($this->get_next_step_link())); |
|
398 | 398 | exit; |
399 | 399 | } |
400 | 400 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @since 2.0.0 |
405 | 405 | */ |
406 | 406 | public function setup_ready() { |
407 | - include plugin_dir_path( __FILE__ ) . 'views/wizard-thank-you.php'; |
|
407 | + include plugin_dir_path(__FILE__) . 'views/wizard-thank-you.php'; |
|
408 | 408 | } |
409 | 409 | |
410 | 410 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( ! defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | /** |
20 | 20 | * Invoice id. |
21 | 21 | */ |
22 | - public $ID = 0; |
|
22 | + public $ID = 0; |
|
23 | 23 | |
24 | 24 | /** |
25 | 25 | * The title of the invoice. Usually the invoice number. |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | /** |
136 | 136 | * The invoice status. |
137 | 137 | */ |
138 | - public $status = 'wpi-pending'; |
|
138 | + public $status = 'wpi-pending'; |
|
139 | 139 | |
140 | 140 | /** |
141 | 141 | * Same as self::$status. |
@@ -262,17 +262,17 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public $parent_invoice = 0; |
264 | 264 | |
265 | - public function __construct( $invoice_id = false ) { |
|
266 | - if ( empty( $invoice_id ) ) { |
|
265 | + public function __construct($invoice_id = false) { |
|
266 | + if (empty($invoice_id)) { |
|
267 | 267 | return false; |
268 | 268 | } |
269 | 269 | |
270 | - $this->setup_invoice( $invoice_id ); |
|
270 | + $this->setup_invoice($invoice_id); |
|
271 | 271 | } |
272 | 272 | |
273 | - public function get( $key ) { |
|
274 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
275 | - $value = call_user_func( array( $this, 'get_' . $key ) ); |
|
273 | + public function get($key) { |
|
274 | + if (method_exists($this, 'get_' . $key)) { |
|
275 | + $value = call_user_func(array($this, 'get_' . $key)); |
|
276 | 276 | } else { |
277 | 277 | $value = $this->$key; |
278 | 278 | } |
@@ -280,43 +280,43 @@ discard block |
||
280 | 280 | return $value; |
281 | 281 | } |
282 | 282 | |
283 | - public function set( $key, $value ) { |
|
284 | - $ignore = array( 'items', 'cart_details', 'fees', '_ID' ); |
|
283 | + public function set($key, $value) { |
|
284 | + $ignore = array('items', 'cart_details', 'fees', '_ID'); |
|
285 | 285 | |
286 | - if ( $key === 'status' ) { |
|
286 | + if ($key === 'status') { |
|
287 | 287 | $this->old_status = $this->status; |
288 | 288 | } |
289 | 289 | |
290 | - if ( ! in_array( $key, $ignore ) ) { |
|
291 | - $this->pending[ $key ] = $value; |
|
290 | + if (!in_array($key, $ignore)) { |
|
291 | + $this->pending[$key] = $value; |
|
292 | 292 | } |
293 | 293 | |
294 | - if ( '_ID' !== $key ) { |
|
294 | + if ('_ID' !== $key) { |
|
295 | 295 | $this->$key = $value; |
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | - public function _isset( $name ) { |
|
300 | - if ( property_exists( $this, $name ) ) { |
|
301 | - return false === empty( $this->$name ); |
|
299 | + public function _isset($name) { |
|
300 | + if (property_exists($this, $name)) { |
|
301 | + return false === empty($this->$name); |
|
302 | 302 | } else { |
303 | 303 | return null; |
304 | 304 | } |
305 | 305 | } |
306 | 306 | |
307 | - private function setup_invoice( $invoice_id ) { |
|
307 | + private function setup_invoice($invoice_id) { |
|
308 | 308 | $this->pending = array(); |
309 | 309 | |
310 | - $invoice = get_post( $invoice_id ); |
|
310 | + $invoice = get_post($invoice_id); |
|
311 | 311 | |
312 | - if ( ! $invoice || is_wp_error( $invoice ) ) { |
|
312 | + if (!$invoice || is_wp_error($invoice)) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
316 | - do_action( 'wpinv_pre_setup_invoice', $this, $invoice_id ); |
|
316 | + do_action('wpinv_pre_setup_invoice', $this, $invoice_id); |
|
317 | 317 | |
318 | 318 | // Primary Identifier |
319 | - $this->ID = absint( $invoice_id ); |
|
319 | + $this->ID = absint($invoice_id); |
|
320 | 320 | $this->post_type = $invoice->post_type; |
321 | 321 | |
322 | 322 | // We have a payment, get the generic payment_meta item to reduce calls to it |
@@ -326,15 +326,15 @@ discard block |
||
326 | 326 | $this->completed_date = $this->setup_completed_date(); |
327 | 327 | $this->status = $invoice->post_status; |
328 | 328 | |
329 | - if ( 'future' == $this->status ) { |
|
329 | + if ('future' == $this->status) { |
|
330 | 330 | $this->status = 'publish'; |
331 | 331 | } |
332 | 332 | |
333 | 333 | $this->post_status = $this->status; |
334 | 334 | $this->mode = $this->setup_mode(); |
335 | 335 | $this->parent_invoice = $invoice->post_parent; |
336 | - $this->post_name = $this->setup_post_name( $invoice ); |
|
337 | - $this->status_nicename = $this->setup_status_nicename( $invoice->post_status ); |
|
336 | + $this->post_name = $this->setup_post_name($invoice); |
|
337 | + $this->status_nicename = $this->setup_status_nicename($invoice->post_status); |
|
338 | 338 | |
339 | 339 | // Items |
340 | 340 | $this->fees = $this->setup_fees(); |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | |
357 | 357 | // User based |
358 | 358 | $this->ip = $this->setup_ip(); |
359 | - $this->user_id = ! empty( $invoice->post_author ) ? $invoice->post_author : get_current_user_id();///$this->setup_user_id(); |
|
360 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
359 | + $this->user_id = !empty($invoice->post_author) ? $invoice->post_author : get_current_user_id(); ///$this->setup_user_id(); |
|
360 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
361 | 361 | |
362 | 362 | $this->user_info = $this->setup_user_info(); |
363 | 363 | |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | $this->company = $this->user_info['company']; |
367 | 367 | $this->vat_number = $this->user_info['vat_number']; |
368 | 368 | $this->vat_rate = $this->user_info['vat_rate']; |
369 | - $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
369 | + $this->adddress_confirmed = $this->user_info['adddress_confirmed']; |
|
370 | 370 | $this->address = $this->user_info['address']; |
371 | 371 | $this->city = $this->user_info['city']; |
372 | 372 | $this->country = $this->user_info['country']; |
@@ -381,31 +381,31 @@ discard block |
||
381 | 381 | // Other Identifiers |
382 | 382 | $this->key = $this->setup_invoice_key(); |
383 | 383 | $this->number = $this->setup_invoice_number(); |
384 | - $this->title = ! empty( $invoice->post_title ) ? $invoice->post_title : $this->number; |
|
384 | + $this->title = !empty($invoice->post_title) ? $invoice->post_title : $this->number; |
|
385 | 385 | |
386 | - $this->full_name = trim( $this->first_name . ' ' . $this->last_name ); |
|
386 | + $this->full_name = trim($this->first_name . ' ' . $this->last_name); |
|
387 | 387 | |
388 | 388 | // Allow extensions to add items to this object via hook |
389 | - do_action( 'wpinv_setup_invoice', $this, $invoice_id ); |
|
389 | + do_action('wpinv_setup_invoice', $this, $invoice_id); |
|
390 | 390 | |
391 | 391 | return true; |
392 | 392 | } |
393 | 393 | |
394 | - private function setup_status_nicename( $status ) { |
|
394 | + private function setup_status_nicename($status) { |
|
395 | 395 | return $status; |
396 | 396 | } |
397 | 397 | |
398 | - private function setup_post_name( $post ) { |
|
398 | + private function setup_post_name($post) { |
|
399 | 399 | $this->post_name = $post->post_name; |
400 | 400 | } |
401 | 401 | |
402 | 402 | private function setup_due_date() { |
403 | - $due_date = $this->get_meta( '_wpinv_due_date' ); |
|
403 | + $due_date = $this->get_meta('_wpinv_due_date'); |
|
404 | 404 | |
405 | - if ( empty( $due_date ) ) { |
|
406 | - $overdue_time = strtotime( $this->date ) + ( DAY_IN_SECONDS * absint( wpinv_get_option( 'overdue_days', 0 ) ) ); |
|
407 | - $due_date = date_i18n( 'Y-m-d', $overdue_time ); |
|
408 | - } elseif ( $due_date == 'none' ) { |
|
405 | + if (empty($due_date)) { |
|
406 | + $overdue_time = strtotime($this->date) + (DAY_IN_SECONDS * absint(wpinv_get_option('overdue_days', 0))); |
|
407 | + $due_date = date_i18n('Y-m-d', $overdue_time); |
|
408 | + } elseif ($due_date == 'none') { |
|
409 | 409 | $due_date = ''; |
410 | 410 | } |
411 | 411 | |
@@ -413,67 +413,67 @@ discard block |
||
413 | 413 | } |
414 | 414 | |
415 | 415 | private function setup_completed_date() { |
416 | - $invoice = get_post( $this->ID ); |
|
416 | + $invoice = get_post($this->ID); |
|
417 | 417 | |
418 | - if ( 'wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status ) { |
|
418 | + if ('wpi-pending' == $invoice->post_status || 'preapproved' == $invoice->post_status) { |
|
419 | 419 | return false; // This invoice was never paid |
420 | 420 | } |
421 | 421 | |
422 | - $date = ( $date = $this->get_meta( '_wpinv_completed_date', true ) ) ? $date : $invoice->modified_date; |
|
422 | + $date = ($date = $this->get_meta('_wpinv_completed_date', true)) ? $date : $invoice->modified_date; |
|
423 | 423 | |
424 | 424 | return $date; |
425 | 425 | } |
426 | 426 | |
427 | 427 | private function setup_cart_details() { |
428 | - $cart_details = isset( $this->payment_meta['cart_details'] ) ? maybe_unserialize( $this->payment_meta['cart_details'] ) : array(); |
|
428 | + $cart_details = isset($this->payment_meta['cart_details']) ? maybe_unserialize($this->payment_meta['cart_details']) : array(); |
|
429 | 429 | return $cart_details; |
430 | 430 | } |
431 | 431 | |
432 | 432 | public function array_convert() { |
433 | - return get_object_vars( $this ); |
|
433 | + return get_object_vars($this); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | private function setup_items() { |
437 | - $items = isset( $this->payment_meta['items'] ) ? maybe_unserialize( $this->payment_meta['items'] ) : array(); |
|
437 | + $items = isset($this->payment_meta['items']) ? maybe_unserialize($this->payment_meta['items']) : array(); |
|
438 | 438 | return $items; |
439 | 439 | } |
440 | 440 | |
441 | 441 | private function setup_fees() { |
442 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
442 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
443 | 443 | return $payment_fees; |
444 | 444 | } |
445 | 445 | |
446 | 446 | private function setup_currency() { |
447 | - $currency = isset( $this->payment_meta['currency'] ) ? $this->payment_meta['currency'] : apply_filters( 'wpinv_currency_default', wpinv_get_currency(), $this ); |
|
447 | + $currency = isset($this->payment_meta['currency']) ? $this->payment_meta['currency'] : apply_filters('wpinv_currency_default', wpinv_get_currency(), $this); |
|
448 | 448 | return $currency; |
449 | 449 | } |
450 | 450 | |
451 | 451 | private function setup_discount() { |
452 | 452 | //$discount = $this->get_meta( '_wpinv_discount', true ); |
453 | - $discount = (float)$this->subtotal - ( (float)$this->total - (float)$this->tax - (float)$this->fees_total ); |
|
454 | - if ( $discount < 0 ) { |
|
453 | + $discount = (float) $this->subtotal - ((float) $this->total - (float) $this->tax - (float) $this->fees_total); |
|
454 | + if ($discount < 0) { |
|
455 | 455 | $discount = 0; |
456 | 456 | } |
457 | - $discount = wpinv_round_amount( $discount ); |
|
457 | + $discount = wpinv_round_amount($discount); |
|
458 | 458 | |
459 | 459 | return $discount; |
460 | 460 | } |
461 | 461 | |
462 | 462 | private function setup_discount_code() { |
463 | - $discount_code = ! empty( $this->discounts ) ? $this->discounts : $this->get_meta( '_wpinv_discount_code', true ); |
|
463 | + $discount_code = !empty($this->discounts) ? $this->discounts : $this->get_meta('_wpinv_discount_code', true); |
|
464 | 464 | return $discount_code; |
465 | 465 | } |
466 | 466 | |
467 | 467 | private function setup_tax() { |
468 | 468 | |
469 | - $tax = $this->get_meta( '_wpinv_tax', true ); |
|
469 | + $tax = $this->get_meta('_wpinv_tax', true); |
|
470 | 470 | |
471 | 471 | // We don't have tax as it's own meta and no meta was passed |
472 | - if ( '' === $tax ) { |
|
473 | - $tax = isset( $this->payment_meta['tax'] ) ? $this->payment_meta['tax'] : 0; |
|
472 | + if ('' === $tax) { |
|
473 | + $tax = isset($this->payment_meta['tax']) ? $this->payment_meta['tax'] : 0; |
|
474 | 474 | } |
475 | 475 | |
476 | - if ( $tax < 0 || ! $this->is_taxable() ) { |
|
476 | + if ($tax < 0 || !$this->is_taxable()) { |
|
477 | 477 | $tax = 0; |
478 | 478 | } |
479 | 479 | |
@@ -484,16 +484,16 @@ discard block |
||
484 | 484 | * If taxes are enabled, allow users to enable/disable taxes per invoice. |
485 | 485 | */ |
486 | 486 | private function setup_is_taxable() { |
487 | - return (int) $this->get_meta( '_wpinv_disable_taxes', true ); |
|
487 | + return (int) $this->get_meta('_wpinv_disable_taxes', true); |
|
488 | 488 | } |
489 | 489 | |
490 | 490 | private function setup_subtotal() { |
491 | 491 | $subtotal = 0; |
492 | 492 | $cart_details = $this->cart_details; |
493 | 493 | |
494 | - if ( is_array( $cart_details ) ) { |
|
495 | - foreach ( $cart_details as $item ) { |
|
496 | - if ( isset( $item['subtotal'] ) ) { |
|
494 | + if (is_array($cart_details)) { |
|
495 | + foreach ($cart_details as $item) { |
|
496 | + if (isset($item['subtotal'])) { |
|
497 | 497 | $subtotal += $item['subtotal']; |
498 | 498 | } |
499 | 499 | } |
@@ -507,23 +507,23 @@ discard block |
||
507 | 507 | } |
508 | 508 | |
509 | 509 | private function setup_discounts() { |
510 | - $discounts = ! empty( $this->payment_meta['user_info']['discount'] ) ? $this->payment_meta['user_info']['discount'] : array(); |
|
510 | + $discounts = !empty($this->payment_meta['user_info']['discount']) ? $this->payment_meta['user_info']['discount'] : array(); |
|
511 | 511 | return $discounts; |
512 | 512 | } |
513 | 513 | |
514 | 514 | private function setup_total() { |
515 | - $amount = $this->get_meta( '_wpinv_total', true ); |
|
515 | + $amount = $this->get_meta('_wpinv_total', true); |
|
516 | 516 | |
517 | - if ( empty( $amount ) && '0.00' != $amount ) { |
|
518 | - $meta = $this->get_meta( '_wpinv_payment_meta', true ); |
|
519 | - $meta = maybe_unserialize( $meta ); |
|
517 | + if (empty($amount) && '0.00' != $amount) { |
|
518 | + $meta = $this->get_meta('_wpinv_payment_meta', true); |
|
519 | + $meta = maybe_unserialize($meta); |
|
520 | 520 | |
521 | - if ( isset( $meta['amount'] ) ) { |
|
521 | + if (isset($meta['amount'])) { |
|
522 | 522 | $amount = $meta['amount']; |
523 | 523 | } |
524 | 524 | } |
525 | 525 | |
526 | - if ( $amount < 0 ) { |
|
526 | + if ($amount < 0) { |
|
527 | 527 | $amount = 0; |
528 | 528 | } |
529 | 529 | |
@@ -531,13 +531,13 @@ discard block |
||
531 | 531 | } |
532 | 532 | |
533 | 533 | private function setup_mode() { |
534 | - return $this->get_meta( '_wpinv_mode' ); |
|
534 | + return $this->get_meta('_wpinv_mode'); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | private function setup_gateway() { |
538 | - $gateway = $this->get_meta( '_wpinv_gateway' ); |
|
538 | + $gateway = $this->get_meta('_wpinv_gateway'); |
|
539 | 539 | |
540 | - if ( empty( $gateway ) && 'publish' === $this->status ) { |
|
540 | + if (empty($gateway) && 'publish' === $this->status) { |
|
541 | 541 | $gateway = 'manual'; |
542 | 542 | } |
543 | 543 | |
@@ -545,23 +545,23 @@ discard block |
||
545 | 545 | } |
546 | 546 | |
547 | 547 | private function setup_gateway_title() { |
548 | - $gateway_title = wpinv_get_gateway_checkout_label( $this->gateway ); |
|
548 | + $gateway_title = wpinv_get_gateway_checkout_label($this->gateway); |
|
549 | 549 | return $gateway_title; |
550 | 550 | } |
551 | 551 | |
552 | 552 | private function setup_transaction_id() { |
553 | - $transaction_id = $this->get_meta( '_wpinv_transaction_id' ); |
|
553 | + $transaction_id = $this->get_meta('_wpinv_transaction_id'); |
|
554 | 554 | |
555 | - if ( empty( $transaction_id ) || (int) $transaction_id === (int) $this->ID ) { |
|
555 | + if (empty($transaction_id) || (int) $transaction_id === (int) $this->ID) { |
|
556 | 556 | $gateway = $this->gateway; |
557 | - $transaction_id = apply_filters( 'wpinv_get_invoice_transaction_id-' . $gateway, $this->ID ); |
|
557 | + $transaction_id = apply_filters('wpinv_get_invoice_transaction_id-' . $gateway, $this->ID); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | return $transaction_id; |
561 | 561 | } |
562 | 562 | |
563 | 563 | private function setup_ip() { |
564 | - $ip = $this->get_meta( '_wpinv_user_ip' ); |
|
564 | + $ip = $this->get_meta('_wpinv_user_ip'); |
|
565 | 565 | return $ip; |
566 | 566 | } |
567 | 567 | |
@@ -571,62 +571,62 @@ discard block |
||
571 | 571 | ///} |
572 | 572 | |
573 | 573 | private function setup_first_name() { |
574 | - $first_name = $this->get_meta( '_wpinv_first_name' ); |
|
574 | + $first_name = $this->get_meta('_wpinv_first_name'); |
|
575 | 575 | return $first_name; |
576 | 576 | } |
577 | 577 | |
578 | 578 | private function setup_last_name() { |
579 | - $last_name = $this->get_meta( '_wpinv_last_name' ); |
|
579 | + $last_name = $this->get_meta('_wpinv_last_name'); |
|
580 | 580 | return $last_name; |
581 | 581 | } |
582 | 582 | |
583 | 583 | private function setup_company() { |
584 | - $company = $this->get_meta( '_wpinv_company' ); |
|
584 | + $company = $this->get_meta('_wpinv_company'); |
|
585 | 585 | return $company; |
586 | 586 | } |
587 | 587 | |
588 | 588 | private function setup_vat_number() { |
589 | - $vat_number = $this->get_meta( '_wpinv_vat_number' ); |
|
589 | + $vat_number = $this->get_meta('_wpinv_vat_number'); |
|
590 | 590 | return $vat_number; |
591 | 591 | } |
592 | 592 | |
593 | 593 | private function setup_vat_rate() { |
594 | - $vat_rate = $this->get_meta( '_wpinv_vat_rate' ); |
|
594 | + $vat_rate = $this->get_meta('_wpinv_vat_rate'); |
|
595 | 595 | return $vat_rate; |
596 | 596 | } |
597 | 597 | |
598 | 598 | private function setup_adddress_confirmed() { |
599 | - $adddress_confirmed = $this->get_meta( '_wpinv_adddress_confirmed' ); |
|
599 | + $adddress_confirmed = $this->get_meta('_wpinv_adddress_confirmed'); |
|
600 | 600 | return $adddress_confirmed; |
601 | 601 | } |
602 | 602 | |
603 | 603 | private function setup_phone() { |
604 | - $phone = $this->get_meta( '_wpinv_phone' ); |
|
604 | + $phone = $this->get_meta('_wpinv_phone'); |
|
605 | 605 | return $phone; |
606 | 606 | } |
607 | 607 | |
608 | 608 | private function setup_address() { |
609 | - $address = $this->get_meta( '_wpinv_address', true ); |
|
609 | + $address = $this->get_meta('_wpinv_address', true); |
|
610 | 610 | return $address; |
611 | 611 | } |
612 | 612 | |
613 | 613 | private function setup_city() { |
614 | - $city = $this->get_meta( '_wpinv_city', true ); |
|
614 | + $city = $this->get_meta('_wpinv_city', true); |
|
615 | 615 | return $city; |
616 | 616 | } |
617 | 617 | |
618 | 618 | private function setup_country() { |
619 | - $country = $this->get_meta( '_wpinv_country', true ); |
|
619 | + $country = $this->get_meta('_wpinv_country', true); |
|
620 | 620 | return $country; |
621 | 621 | } |
622 | 622 | |
623 | 623 | private function setup_state() { |
624 | - $state = $this->get_meta( '_wpinv_state', true ); |
|
624 | + $state = $this->get_meta('_wpinv_state', true); |
|
625 | 625 | return $state; |
626 | 626 | } |
627 | 627 | |
628 | 628 | private function setup_zip() { |
629 | - $zip = $this->get_meta( '_wpinv_zip', true ); |
|
629 | + $zip = $this->get_meta('_wpinv_zip', true); |
|
630 | 630 | return $zip; |
631 | 631 | } |
632 | 632 | |
@@ -635,7 +635,7 @@ discard block |
||
635 | 635 | 'user_id' => $this->user_id, |
636 | 636 | 'first_name' => $this->first_name, |
637 | 637 | 'last_name' => $this->last_name, |
638 | - 'email' => get_the_author_meta( 'email', $this->user_id ), |
|
638 | + 'email' => get_the_author_meta('email', $this->user_id), |
|
639 | 639 | 'phone' => $this->phone, |
640 | 640 | 'address' => $this->address, |
641 | 641 | 'city' => $this->city, |
@@ -650,12 +650,12 @@ discard block |
||
650 | 650 | ); |
651 | 651 | |
652 | 652 | $user_info = array(); |
653 | - if ( isset( $this->payment_meta['user_info'] ) ) { |
|
654 | - $user_info = maybe_unserialize( $this->payment_meta['user_info'] ); |
|
653 | + if (isset($this->payment_meta['user_info'])) { |
|
654 | + $user_info = maybe_unserialize($this->payment_meta['user_info']); |
|
655 | 655 | |
656 | - if ( ! empty( $user_info ) && isset( $user_info['user_id'] ) && $post = get_post( $this->ID ) ) { |
|
656 | + if (!empty($user_info) && isset($user_info['user_id']) && $post = get_post($this->ID)) { |
|
657 | 657 | $this->user_id = $post->post_author; |
658 | - $this->email = get_the_author_meta( 'email', $this->user_id ); |
|
658 | + $this->email = get_the_author_meta('email', $this->user_id); |
|
659 | 659 | |
660 | 660 | $user_info['user_id'] = $this->user_id; |
661 | 661 | $user_info['email'] = $this->email; |
@@ -664,13 +664,13 @@ discard block |
||
664 | 664 | } |
665 | 665 | } |
666 | 666 | |
667 | - $user_info = wp_parse_args( $user_info, $defaults ); |
|
667 | + $user_info = wp_parse_args($user_info, $defaults); |
|
668 | 668 | |
669 | 669 | // Get the user, but only if it's been created |
670 | - $user = get_userdata( $this->user_id ); |
|
670 | + $user = get_userdata($this->user_id); |
|
671 | 671 | |
672 | - if ( ! empty( $user ) && $user->ID > 0 ) { |
|
673 | - if ( empty( $user_info ) ) { |
|
672 | + if (!empty($user) && $user->ID > 0) { |
|
673 | + if (empty($user_info)) { |
|
674 | 674 | $user_info = array( |
675 | 675 | 'user_id' => $user->ID, |
676 | 676 | 'first_name' => $user->first_name, |
@@ -679,23 +679,23 @@ discard block |
||
679 | 679 | 'discount' => '', |
680 | 680 | ); |
681 | 681 | } else { |
682 | - foreach ( $user_info as $key => $value ) { |
|
683 | - if ( ! empty( $value ) ) { |
|
682 | + foreach ($user_info as $key => $value) { |
|
683 | + if (!empty($value)) { |
|
684 | 684 | continue; |
685 | 685 | } |
686 | 686 | |
687 | - switch ( $key ) { |
|
687 | + switch ($key) { |
|
688 | 688 | case 'user_id': |
689 | - $user_info[ $key ] = $user->ID; |
|
689 | + $user_info[$key] = $user->ID; |
|
690 | 690 | break; |
691 | 691 | case 'first_name': |
692 | - $user_info[ $key ] = $user->first_name; |
|
692 | + $user_info[$key] = $user->first_name; |
|
693 | 693 | break; |
694 | 694 | case 'last_name': |
695 | - $user_info[ $key ] = $user->last_name; |
|
695 | + $user_info[$key] = $user->last_name; |
|
696 | 696 | break; |
697 | 697 | case 'email': |
698 | - $user_info[ $key ] = $user->user_email; |
|
698 | + $user_info[$key] = $user->user_email; |
|
699 | 699 | break; |
700 | 700 | } |
701 | 701 | } |
@@ -706,25 +706,25 @@ discard block |
||
706 | 706 | } |
707 | 707 | |
708 | 708 | private function setup_invoice_key() { |
709 | - $key = $this->get_meta( '_wpinv_key', true ); |
|
709 | + $key = $this->get_meta('_wpinv_key', true); |
|
710 | 710 | |
711 | 711 | return $key; |
712 | 712 | } |
713 | 713 | |
714 | 714 | private function setup_invoice_number() { |
715 | - $number = $this->get_meta( '_wpinv_number', true ); |
|
715 | + $number = $this->get_meta('_wpinv_number', true); |
|
716 | 716 | |
717 | - if ( ! $number ) { |
|
717 | + if (!$number) { |
|
718 | 718 | $number = $this->ID; |
719 | 719 | |
720 | - if ( $this->status == 'auto-draft' ) { |
|
721 | - if ( wpinv_sequential_number_active( $this->post_type ) ) { |
|
722 | - $next_number = wpinv_get_next_invoice_number( $this->post_type ); |
|
720 | + if ($this->status == 'auto-draft') { |
|
721 | + if (wpinv_sequential_number_active($this->post_type)) { |
|
722 | + $next_number = wpinv_get_next_invoice_number($this->post_type); |
|
723 | 723 | $number = $next_number; |
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
727 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
727 | + $number = wpinv_format_invoice_number($number, $this->post_type); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | return $number; |
@@ -732,7 +732,7 @@ discard block |
||
732 | 732 | |
733 | 733 | public function save() {} |
734 | 734 | |
735 | - public function add_fee( $args ) { |
|
735 | + public function add_fee($args) { |
|
736 | 736 | $default_args = array( |
737 | 737 | 'label' => '', |
738 | 738 | 'amount' => 0, |
@@ -742,36 +742,36 @@ discard block |
||
742 | 742 | 'item_id' => 0, |
743 | 743 | ); |
744 | 744 | |
745 | - $fee = wp_parse_args( $args, $default_args ); |
|
745 | + $fee = wp_parse_args($args, $default_args); |
|
746 | 746 | |
747 | - if ( empty( $fee['label'] ) ) { |
|
747 | + if (empty($fee['label'])) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
751 | - $fee['id'] = sanitize_title( $fee['label'] ); |
|
751 | + $fee['id'] = sanitize_title($fee['label']); |
|
752 | 752 | |
753 | - $this->fees[] = $fee; |
|
753 | + $this->fees[] = $fee; |
|
754 | 754 | |
755 | 755 | $added_fee = $fee; |
756 | 756 | $added_fee['action'] = 'add'; |
757 | 757 | $this->pending['fees'][] = $added_fee; |
758 | - reset( $this->fees ); |
|
758 | + reset($this->fees); |
|
759 | 759 | |
760 | - $this->increase_fees( $fee['amount'] ); |
|
760 | + $this->increase_fees($fee['amount']); |
|
761 | 761 | return true; |
762 | 762 | } |
763 | 763 | |
764 | - public function remove_fee( $key ) { |
|
764 | + public function remove_fee($key) { |
|
765 | 765 | $removed = false; |
766 | 766 | |
767 | - if ( is_numeric( $key ) ) { |
|
768 | - $removed = $this->remove_fee_by( 'index', $key ); |
|
767 | + if (is_numeric($key)) { |
|
768 | + $removed = $this->remove_fee_by('index', $key); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | return $removed; |
772 | 772 | } |
773 | 773 | |
774 | - public function remove_fee_by( $key, $value, $global = false ) { |
|
774 | + public function remove_fee_by($key, $value, $global = false) { |
|
775 | 775 | $allowed_fee_keys = apply_filters( |
776 | 776 | 'wpinv_fee_keys', |
777 | 777 | array( |
@@ -782,41 +782,41 @@ discard block |
||
782 | 782 | ) |
783 | 783 | ); |
784 | 784 | |
785 | - if ( ! in_array( $key, $allowed_fee_keys ) ) { |
|
785 | + if (!in_array($key, $allowed_fee_keys)) { |
|
786 | 786 | return false; |
787 | 787 | } |
788 | 788 | |
789 | 789 | $removed = false; |
790 | - if ( 'index' === $key && array_key_exists( $value, $this->fees ) ) { |
|
791 | - $removed_fee = $this->fees[ $value ]; |
|
790 | + if ('index' === $key && array_key_exists($value, $this->fees)) { |
|
791 | + $removed_fee = $this->fees[$value]; |
|
792 | 792 | $removed_fee['action'] = 'remove'; |
793 | 793 | $this->pending['fees'][] = $removed_fee; |
794 | 794 | |
795 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
795 | + $this->decrease_fees($removed_fee['amount']); |
|
796 | 796 | |
797 | - unset( $this->fees[ $value ] ); |
|
797 | + unset($this->fees[$value]); |
|
798 | 798 | $removed = true; |
799 | - } elseif ( 'index' !== $key ) { |
|
800 | - foreach ( $this->fees as $index => $fee ) { |
|
801 | - if ( isset( $fee[ $key ] ) && $fee[ $key ] == $value ) { |
|
799 | + } elseif ('index' !== $key) { |
|
800 | + foreach ($this->fees as $index => $fee) { |
|
801 | + if (isset($fee[$key]) && $fee[$key] == $value) { |
|
802 | 802 | $removed_fee = $fee; |
803 | 803 | $removed_fee['action'] = 'remove'; |
804 | 804 | $this->pending['fees'][] = $removed_fee; |
805 | 805 | |
806 | - $this->decrease_fees( $removed_fee['amount'] ); |
|
806 | + $this->decrease_fees($removed_fee['amount']); |
|
807 | 807 | |
808 | - unset( $this->fees[ $index ] ); |
|
808 | + unset($this->fees[$index]); |
|
809 | 809 | $removed = true; |
810 | 810 | |
811 | - if ( false === $global ) { |
|
811 | + if (false === $global) { |
|
812 | 812 | break; |
813 | 813 | } |
814 | 814 | } |
815 | 815 | } |
816 | 816 | } |
817 | 817 | |
818 | - if ( true === $removed ) { |
|
819 | - $this->fees = array_values( $this->fees ); |
|
818 | + if (true === $removed) { |
|
819 | + $this->fees = array_values($this->fees); |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | return $removed; |
@@ -824,28 +824,28 @@ discard block |
||
824 | 824 | |
825 | 825 | |
826 | 826 | |
827 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
827 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
828 | 828 | // Bail if no note specified |
829 | - if ( ! $note ) { |
|
829 | + if (!$note) { |
|
830 | 830 | return false; |
831 | 831 | } |
832 | 832 | |
833 | - if ( empty( $this->ID ) ) { |
|
833 | + if (empty($this->ID)) { |
|
834 | 834 | return false; |
835 | 835 | } |
836 | 836 | |
837 | - if ( ( ( is_user_logged_in() && wpinv_current_user_can_manage_invoicing() ) || $added_by_user ) && ! $system ) { |
|
838 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
837 | + if (((is_user_logged_in() && wpinv_current_user_can_manage_invoicing()) || $added_by_user) && !$system) { |
|
838 | + $user = get_user_by('id', get_current_user_id()); |
|
839 | 839 | $comment_author = $user->display_name; |
840 | 840 | $comment_author_email = $user->user_email; |
841 | 841 | } else { |
842 | 842 | $comment_author = 'System'; |
843 | 843 | $comment_author_email = 'system@'; |
844 | - $comment_author_email .= isset( $_SERVER['HTTP_HOST'] ) ? str_replace( 'www.', '', $_SERVER['HTTP_HOST'] ) : 'noreply.com'; |
|
845 | - $comment_author_email = sanitize_email( $comment_author_email ); |
|
844 | + $comment_author_email .= isset($_SERVER['HTTP_HOST']) ? str_replace('www.', '', $_SERVER['HTTP_HOST']) : 'noreply.com'; |
|
845 | + $comment_author_email = sanitize_email($comment_author_email); |
|
846 | 846 | } |
847 | 847 | |
848 | - do_action( 'wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type ); |
|
848 | + do_action('wpinv_pre_insert_invoice_note', $this->ID, $note, $customer_type); |
|
849 | 849 | |
850 | 850 | $note_id = wp_insert_comment( |
851 | 851 | wp_filter_comment( |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | 'comment_content' => $note, |
855 | 855 | 'comment_agent' => 'WPInvoicing', |
856 | 856 | 'user_id' => is_admin() ? get_current_user_id() : 0, |
857 | - 'comment_date' => current_time( 'mysql' ), |
|
858 | - 'comment_date_gmt' => current_time( 'mysql', 1 ), |
|
857 | + 'comment_date' => current_time('mysql'), |
|
858 | + 'comment_date_gmt' => current_time('mysql', 1), |
|
859 | 859 | 'comment_approved' => 1, |
860 | 860 | 'comment_parent' => 0, |
861 | 861 | 'comment_author' => $comment_author, |
@@ -867,10 +867,10 @@ discard block |
||
867 | 867 | ) |
868 | 868 | ); |
869 | 869 | |
870 | - do_action( 'wpinv_insert_payment_note', $note_id, $this->ID, $note ); |
|
870 | + do_action('wpinv_insert_payment_note', $note_id, $this->ID, $note); |
|
871 | 871 | |
872 | - if ( $customer_type ) { |
|
873 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
872 | + if ($customer_type) { |
|
873 | + add_comment_meta($note_id, '_wpi_customer_note', 1); |
|
874 | 874 | |
875 | 875 | do_action( |
876 | 876 | 'wpinv_new_customer_note', |
@@ -884,40 +884,40 @@ discard block |
||
884 | 884 | return $note_id; |
885 | 885 | } |
886 | 886 | |
887 | - private function increase_subtotal( $amount = 0.00 ) { |
|
887 | + private function increase_subtotal($amount = 0.00) { |
|
888 | 888 | $amount = (float) $amount; |
889 | 889 | $this->subtotal += $amount; |
890 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
890 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
891 | 891 | |
892 | 892 | $this->recalculate_total(); |
893 | 893 | } |
894 | 894 | |
895 | - private function decrease_subtotal( $amount = 0.00 ) { |
|
895 | + private function decrease_subtotal($amount = 0.00) { |
|
896 | 896 | $amount = (float) $amount; |
897 | 897 | $this->subtotal -= $amount; |
898 | - $this->subtotal = wpinv_round_amount( $this->subtotal ); |
|
898 | + $this->subtotal = wpinv_round_amount($this->subtotal); |
|
899 | 899 | |
900 | - if ( $this->subtotal < 0 ) { |
|
900 | + if ($this->subtotal < 0) { |
|
901 | 901 | $this->subtotal = 0; |
902 | 902 | } |
903 | 903 | |
904 | 904 | $this->recalculate_total(); |
905 | 905 | } |
906 | 906 | |
907 | - private function increase_fees( $amount = 0.00 ) { |
|
908 | - $amount = (float)$amount; |
|
907 | + private function increase_fees($amount = 0.00) { |
|
908 | + $amount = (float) $amount; |
|
909 | 909 | $this->fees_total += $amount; |
910 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
910 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
911 | 911 | |
912 | 912 | $this->recalculate_total(); |
913 | 913 | } |
914 | 914 | |
915 | - private function decrease_fees( $amount = 0.00 ) { |
|
915 | + private function decrease_fees($amount = 0.00) { |
|
916 | 916 | $amount = (float) $amount; |
917 | 917 | $this->fees_total -= $amount; |
918 | - $this->fees_total = wpinv_round_amount( $this->fees_total ); |
|
918 | + $this->fees_total = wpinv_round_amount($this->fees_total); |
|
919 | 919 | |
920 | - if ( $this->fees_total < 0 ) { |
|
920 | + if ($this->fees_total < 0) { |
|
921 | 921 | $this->fees_total = 0; |
922 | 922 | } |
923 | 923 | |
@@ -928,56 +928,56 @@ discard block |
||
928 | 928 | global $wpi_nosave; |
929 | 929 | |
930 | 930 | $this->total = $this->subtotal + $this->tax + $this->fees_total; |
931 | - $this->total = wpinv_round_amount( $this->total ); |
|
931 | + $this->total = wpinv_round_amount($this->total); |
|
932 | 932 | |
933 | - do_action( 'wpinv_invoice_recalculate_total', $this, $wpi_nosave ); |
|
933 | + do_action('wpinv_invoice_recalculate_total', $this, $wpi_nosave); |
|
934 | 934 | } |
935 | 935 | |
936 | - public function increase_tax( $amount = 0.00 ) { |
|
936 | + public function increase_tax($amount = 0.00) { |
|
937 | 937 | $amount = (float) $amount; |
938 | 938 | $this->tax += $amount; |
939 | 939 | |
940 | 940 | $this->recalculate_total(); |
941 | 941 | } |
942 | 942 | |
943 | - public function decrease_tax( $amount = 0.00 ) { |
|
943 | + public function decrease_tax($amount = 0.00) { |
|
944 | 944 | $amount = (float) $amount; |
945 | 945 | $this->tax -= $amount; |
946 | 946 | |
947 | - if ( $this->tax < 0 ) { |
|
947 | + if ($this->tax < 0) { |
|
948 | 948 | $this->tax = 0; |
949 | 949 | } |
950 | 950 | |
951 | 951 | $this->recalculate_total(); |
952 | 952 | } |
953 | 953 | |
954 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
955 | - $old_status = ! empty( $this->old_status ) ? $this->old_status : get_post_status( $this->ID ); |
|
954 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
955 | + $old_status = !empty($this->old_status) ? $this->old_status : get_post_status($this->ID); |
|
956 | 956 | |
957 | - if ( $old_status === $new_status && in_array( $new_status, array_keys( wpinv_get_invoice_statuses( true ) ) ) ) { |
|
957 | + if ($old_status === $new_status && in_array($new_status, array_keys(wpinv_get_invoice_statuses(true)))) { |
|
958 | 958 | return false; // Don't permit status changes that aren't changes |
959 | 959 | } |
960 | 960 | |
961 | - $do_change = apply_filters( 'wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status ); |
|
961 | + $do_change = apply_filters('wpinv_should_update_invoice_status', true, $this->ID, $new_status, $old_status); |
|
962 | 962 | $updated = false; |
963 | 963 | |
964 | - if ( $do_change ) { |
|
965 | - do_action( 'wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status ); |
|
964 | + if ($do_change) { |
|
965 | + do_action('wpinv_before_invoice_status_change', $this->ID, $new_status, $old_status); |
|
966 | 966 | |
967 | 967 | $update_post_data = array(); |
968 | 968 | $update_post_data['ID'] = $this->ID; |
969 | 969 | $update_post_data['post_status'] = $new_status; |
970 | - $update_post_data['edit_date'] = current_time( 'mysql', 0 ); |
|
971 | - $update_post_data['edit_date_gmt'] = current_time( 'mysql', 1 ); |
|
970 | + $update_post_data['edit_date'] = current_time('mysql', 0); |
|
971 | + $update_post_data['edit_date_gmt'] = current_time('mysql', 1); |
|
972 | 972 | |
973 | - $update_post_data = apply_filters( 'wpinv_update_invoice_status_fields', $update_post_data, $this->ID ); |
|
973 | + $update_post_data = apply_filters('wpinv_update_invoice_status_fields', $update_post_data, $this->ID); |
|
974 | 974 | |
975 | - $updated = wp_update_post( $update_post_data ); |
|
975 | + $updated = wp_update_post($update_post_data); |
|
976 | 976 | |
977 | 977 | // Status was changed. |
978 | - do_action( 'wpinv_status_' . $new_status, $this->ID, $old_status ); |
|
979 | - do_action( 'wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status ); |
|
980 | - do_action( 'wpinv_update_status', $this->ID, $new_status, $old_status ); |
|
978 | + do_action('wpinv_status_' . $new_status, $this->ID, $old_status); |
|
979 | + do_action('wpinv_status_' . $old_status . '_to_' . $new_status, $this->ID, $old_status); |
|
980 | + do_action('wpinv_update_status', $this->ID, $new_status, $old_status); |
|
981 | 981 | } |
982 | 982 | |
983 | 983 | return $updated; |
@@ -994,114 +994,114 @@ discard block |
||
994 | 994 | public function update_meta() {} |
995 | 995 | |
996 | 996 | // get data |
997 | - public function get_meta( $meta_key = '_wpinv_payment_meta', $single = true ) { |
|
998 | - $meta = get_post_meta( $this->ID, $meta_key, $single ); |
|
997 | + public function get_meta($meta_key = '_wpinv_payment_meta', $single = true) { |
|
998 | + $meta = get_post_meta($this->ID, $meta_key, $single); |
|
999 | 999 | |
1000 | - if ( $meta_key === '_wpinv_payment_meta' ) { |
|
1000 | + if ($meta_key === '_wpinv_payment_meta') { |
|
1001 | 1001 | |
1002 | - if ( ! is_array( $meta ) ) { |
|
1003 | -$meta = array();} // we need this to be an array so make sure it is. |
|
1002 | + if (!is_array($meta)) { |
|
1003 | +$meta = array(); } // we need this to be an array so make sure it is. |
|
1004 | 1004 | |
1005 | - if ( empty( $meta['key'] ) ) { |
|
1005 | + if (empty($meta['key'])) { |
|
1006 | 1006 | $meta['key'] = $this->setup_invoice_key(); |
1007 | 1007 | } |
1008 | 1008 | |
1009 | - if ( empty( $meta['date'] ) ) { |
|
1010 | - $meta['date'] = get_post_field( 'post_date', $this->ID ); |
|
1009 | + if (empty($meta['date'])) { |
|
1010 | + $meta['date'] = get_post_field('post_date', $this->ID); |
|
1011 | 1011 | } |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - $meta = apply_filters( 'wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID ); |
|
1014 | + $meta = apply_filters('wpinv_get_invoice_meta_' . $meta_key, $meta, $this->ID); |
|
1015 | 1015 | |
1016 | - return apply_filters( 'wpinv_get_invoice_meta', $meta, $this->ID, $meta_key ); |
|
1016 | + return apply_filters('wpinv_get_invoice_meta', $meta, $this->ID, $meta_key); |
|
1017 | 1017 | } |
1018 | 1018 | |
1019 | 1019 | public function get_description() { |
1020 | - $post = get_post( $this->ID ); |
|
1020 | + $post = get_post($this->ID); |
|
1021 | 1021 | |
1022 | - $description = ! empty( $post ) ? $post->post_content : ''; |
|
1023 | - return apply_filters( 'wpinv_get_description', $description, $this->ID, $this ); |
|
1022 | + $description = !empty($post) ? $post->post_content : ''; |
|
1023 | + return apply_filters('wpinv_get_description', $description, $this->ID, $this); |
|
1024 | 1024 | } |
1025 | 1025 | |
1026 | - public function get_status( $nicename = false ) { |
|
1027 | - if ( ! $nicename ) { |
|
1026 | + public function get_status($nicename = false) { |
|
1027 | + if (!$nicename) { |
|
1028 | 1028 | $status = $this->status; |
1029 | 1029 | } else { |
1030 | 1030 | $status = $this->status_nicename; |
1031 | 1031 | } |
1032 | 1032 | |
1033 | - return apply_filters( 'wpinv_get_status', $status, $nicename, $this->ID, $this ); |
|
1033 | + return apply_filters('wpinv_get_status', $status, $nicename, $this->ID, $this); |
|
1034 | 1034 | } |
1035 | 1035 | |
1036 | 1036 | public function get_cart_details() { |
1037 | - return apply_filters( 'wpinv_cart_details', $this->cart_details, $this->ID, $this ); |
|
1037 | + return apply_filters('wpinv_cart_details', $this->cart_details, $this->ID, $this); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | - public function get_subtotal( $currency = false ) { |
|
1041 | - $subtotal = wpinv_round_amount( $this->subtotal ); |
|
1040 | + public function get_subtotal($currency = false) { |
|
1041 | + $subtotal = wpinv_round_amount($this->subtotal); |
|
1042 | 1042 | |
1043 | - if ( $currency ) { |
|
1044 | - $subtotal = wpinv_price( wpinv_format_amount( $subtotal, null, ! $currency ), $this->get_currency() ); |
|
1043 | + if ($currency) { |
|
1044 | + $subtotal = wpinv_price(wpinv_format_amount($subtotal, null, !$currency), $this->get_currency()); |
|
1045 | 1045 | } |
1046 | 1046 | |
1047 | - return apply_filters( 'wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency ); |
|
1047 | + return apply_filters('wpinv_get_invoice_subtotal', $subtotal, $this->ID, $this, $currency); |
|
1048 | 1048 | } |
1049 | 1049 | |
1050 | - public function get_total( $currency = false ) { |
|
1051 | - if ( $this->is_free_trial() ) { |
|
1052 | - $total = wpinv_round_amount( 0 ); |
|
1050 | + public function get_total($currency = false) { |
|
1051 | + if ($this->is_free_trial()) { |
|
1052 | + $total = wpinv_round_amount(0); |
|
1053 | 1053 | } else { |
1054 | - $total = wpinv_round_amount( $this->total ); |
|
1054 | + $total = wpinv_round_amount($this->total); |
|
1055 | 1055 | } |
1056 | - if ( $currency ) { |
|
1057 | - $total = wpinv_price( wpinv_format_amount( $total, null, ! $currency ), $this->get_currency() ); |
|
1056 | + if ($currency) { |
|
1057 | + $total = wpinv_price(wpinv_format_amount($total, null, !$currency), $this->get_currency()); |
|
1058 | 1058 | } |
1059 | 1059 | |
1060 | - return apply_filters( 'wpinv_get_invoice_total', $total, $this->ID, $this, $currency ); |
|
1060 | + return apply_filters('wpinv_get_invoice_total', $total, $this->ID, $this, $currency); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | public function get_recurring_details() {} |
1064 | 1064 | |
1065 | - public function get_final_tax( $currency = false ) { |
|
1066 | - $final_total = wpinv_round_amount( $this->tax ); |
|
1067 | - if ( $currency ) { |
|
1068 | - $final_total = wpinv_price( wpinv_format_amount( $final_total, null, ! $currency ), $this->get_currency() ); |
|
1065 | + public function get_final_tax($currency = false) { |
|
1066 | + $final_total = wpinv_round_amount($this->tax); |
|
1067 | + if ($currency) { |
|
1068 | + $final_total = wpinv_price(wpinv_format_amount($final_total, null, !$currency), $this->get_currency()); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | - return apply_filters( 'wpinv_get_invoice_final_total', $final_total, $this, $currency ); |
|
1071 | + return apply_filters('wpinv_get_invoice_final_total', $final_total, $this, $currency); |
|
1072 | 1072 | } |
1073 | 1073 | |
1074 | - public function get_discounts( $array = false ) { |
|
1074 | + public function get_discounts($array = false) { |
|
1075 | 1075 | $discounts = $this->discounts; |
1076 | - if ( $array && $discounts ) { |
|
1077 | - $discounts = explode( ',', $discounts ); |
|
1076 | + if ($array && $discounts) { |
|
1077 | + $discounts = explode(',', $discounts); |
|
1078 | 1078 | } |
1079 | - return apply_filters( 'wpinv_payment_discounts', $discounts, $this->ID, $this, $array ); |
|
1079 | + return apply_filters('wpinv_payment_discounts', $discounts, $this->ID, $this, $array); |
|
1080 | 1080 | } |
1081 | 1081 | |
1082 | - public function get_discount( $currency = false, $dash = false ) { |
|
1083 | - if ( ! empty( $this->discounts ) ) { |
|
1082 | + public function get_discount($currency = false, $dash = false) { |
|
1083 | + if (!empty($this->discounts)) { |
|
1084 | 1084 | global $ajax_cart_details; |
1085 | 1085 | $ajax_cart_details = $this->get_cart_details(); |
1086 | 1086 | |
1087 | - if ( ! empty( $ajax_cart_details ) && count( $ajax_cart_details ) == count( $this->items ) ) { |
|
1087 | + if (!empty($ajax_cart_details) && count($ajax_cart_details) == count($this->items)) { |
|
1088 | 1088 | $cart_items = $ajax_cart_details; |
1089 | 1089 | } else { |
1090 | 1090 | $cart_items = $this->items; |
1091 | 1091 | } |
1092 | 1092 | |
1093 | - $this->discount = wpinv_get_cart_items_discount_amount( $cart_items, $this->discounts ); |
|
1093 | + $this->discount = wpinv_get_cart_items_discount_amount($cart_items, $this->discounts); |
|
1094 | 1094 | } |
1095 | - $discount = wpinv_round_amount( $this->discount ); |
|
1095 | + $discount = wpinv_round_amount($this->discount); |
|
1096 | 1096 | $dash = $dash && $discount > 0 ? '–' : ''; |
1097 | 1097 | |
1098 | - if ( $currency ) { |
|
1099 | - $discount = wpinv_price( wpinv_format_amount( $discount, null, ! $currency ), $this->get_currency() ); |
|
1098 | + if ($currency) { |
|
1099 | + $discount = wpinv_price(wpinv_format_amount($discount, null, !$currency), $this->get_currency()); |
|
1100 | 1100 | } |
1101 | 1101 | |
1102 | - $discount = $dash . $discount; |
|
1102 | + $discount = $dash . $discount; |
|
1103 | 1103 | |
1104 | - return apply_filters( 'wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash ); |
|
1104 | + return apply_filters('wpinv_get_invoice_discount', $discount, $this->ID, $this, $currency, $dash); |
|
1105 | 1105 | } |
1106 | 1106 | |
1107 | 1107 | public function get_discount_code() { |
@@ -1113,150 +1113,150 @@ discard block |
||
1113 | 1113 | return (int) $this->disable_taxes === 0; |
1114 | 1114 | } |
1115 | 1115 | |
1116 | - public function get_tax( $currency = false ) { |
|
1117 | - $tax = wpinv_round_amount( $this->tax ); |
|
1116 | + public function get_tax($currency = false) { |
|
1117 | + $tax = wpinv_round_amount($this->tax); |
|
1118 | 1118 | |
1119 | - if ( $currency ) { |
|
1120 | - $tax = wpinv_price( wpinv_format_amount( $tax, null, ! $currency ), $this->get_currency() ); |
|
1119 | + if ($currency) { |
|
1120 | + $tax = wpinv_price(wpinv_format_amount($tax, null, !$currency), $this->get_currency()); |
|
1121 | 1121 | } |
1122 | 1122 | |
1123 | - if ( ! $this->is_taxable() ) { |
|
1124 | - $tax = wpinv_round_amount( 0.00 ); |
|
1123 | + if (!$this->is_taxable()) { |
|
1124 | + $tax = wpinv_round_amount(0.00); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | - return apply_filters( 'wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency ); |
|
1127 | + return apply_filters('wpinv_get_invoice_tax', $tax, $this->ID, $this, $currency); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | - public function get_fees( $type = 'all' ) { |
|
1131 | - $fees = array(); |
|
1130 | + public function get_fees($type = 'all') { |
|
1131 | + $fees = array(); |
|
1132 | 1132 | |
1133 | - if ( ! empty( $this->fees ) && is_array( $this->fees ) ) { |
|
1134 | - foreach ( $this->fees as $fee ) { |
|
1135 | - if ( 'all' != $type && ! empty( $fee['type'] ) && $type != $fee['type'] ) { |
|
1133 | + if (!empty($this->fees) && is_array($this->fees)) { |
|
1134 | + foreach ($this->fees as $fee) { |
|
1135 | + if ('all' != $type && !empty($fee['type']) && $type != $fee['type']) { |
|
1136 | 1136 | continue; |
1137 | 1137 | } |
1138 | 1138 | |
1139 | - $fee['label'] = stripslashes( $fee['label'] ); |
|
1140 | - $fee['amount_display'] = wpinv_price( $fee['amount'], $this->get_currency() ); |
|
1141 | - $fees[] = $fee; |
|
1139 | + $fee['label'] = stripslashes($fee['label']); |
|
1140 | + $fee['amount_display'] = wpinv_price($fee['amount'], $this->get_currency()); |
|
1141 | + $fees[] = $fee; |
|
1142 | 1142 | } |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - return apply_filters( 'wpinv_get_invoice_fees', $fees, $this->ID, $this ); |
|
1145 | + return apply_filters('wpinv_get_invoice_fees', $fees, $this->ID, $this); |
|
1146 | 1146 | } |
1147 | 1147 | |
1148 | 1148 | public function get_fees_total() { |
1149 | 1149 | $fees_total = (float) 0.00; |
1150 | 1150 | |
1151 | - $payment_fees = isset( $this->payment_meta['fees'] ) ? $this->payment_meta['fees'] : array(); |
|
1152 | - if ( ! empty( $payment_fees ) ) { |
|
1153 | - foreach ( $payment_fees as $fee ) { |
|
1151 | + $payment_fees = isset($this->payment_meta['fees']) ? $this->payment_meta['fees'] : array(); |
|
1152 | + if (!empty($payment_fees)) { |
|
1153 | + foreach ($payment_fees as $fee) { |
|
1154 | 1154 | $fees_total += (float) $fee['amount']; |
1155 | 1155 | } |
1156 | 1156 | } |
1157 | 1157 | |
1158 | - return apply_filters( 'wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this ); |
|
1158 | + return apply_filters('wpinv_get_invoice_fees_total', $fees_total, $this->ID, $this); |
|
1159 | 1159 | |
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | public function get_user_id() { |
1163 | - return apply_filters( 'wpinv_user_id', $this->user_id, $this->ID, $this ); |
|
1163 | + return apply_filters('wpinv_user_id', $this->user_id, $this->ID, $this); |
|
1164 | 1164 | } |
1165 | 1165 | |
1166 | 1166 | public function get_first_name() { |
1167 | - return apply_filters( 'wpinv_first_name', $this->first_name, $this->ID, $this ); |
|
1167 | + return apply_filters('wpinv_first_name', $this->first_name, $this->ID, $this); |
|
1168 | 1168 | } |
1169 | 1169 | |
1170 | 1170 | public function get_last_name() { |
1171 | - return apply_filters( 'wpinv_last_name', $this->last_name, $this->ID, $this ); |
|
1171 | + return apply_filters('wpinv_last_name', $this->last_name, $this->ID, $this); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | public function get_user_full_name() { |
1175 | - return apply_filters( 'wpinv_user_full_name', $this->full_name, $this->ID, $this ); |
|
1175 | + return apply_filters('wpinv_user_full_name', $this->full_name, $this->ID, $this); |
|
1176 | 1176 | } |
1177 | 1177 | |
1178 | 1178 | public function get_user_info() { |
1179 | - return apply_filters( 'wpinv_user_info', $this->user_info, $this->ID, $this ); |
|
1179 | + return apply_filters('wpinv_user_info', $this->user_info, $this->ID, $this); |
|
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | public function get_email() { |
1183 | - return apply_filters( 'wpinv_user_email', $this->email, $this->ID, $this ); |
|
1183 | + return apply_filters('wpinv_user_email', $this->email, $this->ID, $this); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | public function get_address() { |
1187 | - return apply_filters( 'wpinv_address', $this->address, $this->ID, $this ); |
|
1187 | + return apply_filters('wpinv_address', $this->address, $this->ID, $this); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | 1190 | public function get_phone() { |
1191 | - return apply_filters( 'wpinv_phone', $this->phone, $this->ID, $this ); |
|
1191 | + return apply_filters('wpinv_phone', $this->phone, $this->ID, $this); |
|
1192 | 1192 | } |
1193 | 1193 | |
1194 | 1194 | public function get_number() { |
1195 | - return apply_filters( 'wpinv_number', $this->number, $this->ID, $this ); |
|
1195 | + return apply_filters('wpinv_number', $this->number, $this->ID, $this); |
|
1196 | 1196 | } |
1197 | 1197 | |
1198 | 1198 | public function get_items() { |
1199 | - return apply_filters( 'wpinv_payment_meta_items', $this->items, $this->ID, $this ); |
|
1199 | + return apply_filters('wpinv_payment_meta_items', $this->items, $this->ID, $this); |
|
1200 | 1200 | } |
1201 | 1201 | |
1202 | 1202 | public function get_key() { |
1203 | - return apply_filters( 'wpinv_key', $this->key, $this->ID, $this ); |
|
1203 | + return apply_filters('wpinv_key', $this->key, $this->ID, $this); |
|
1204 | 1204 | } |
1205 | 1205 | |
1206 | 1206 | public function get_transaction_id() { |
1207 | - return apply_filters( 'wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this ); |
|
1207 | + return apply_filters('wpinv_get_invoice_transaction_id', $this->transaction_id, $this->ID, $this); |
|
1208 | 1208 | } |
1209 | 1209 | |
1210 | 1210 | public function get_gateway() { |
1211 | - return apply_filters( 'wpinv_gateway', $this->gateway, $this->ID, $this ); |
|
1211 | + return apply_filters('wpinv_gateway', $this->gateway, $this->ID, $this); |
|
1212 | 1212 | } |
1213 | 1213 | |
1214 | 1214 | public function get_gateway_title() {} |
1215 | 1215 | |
1216 | 1216 | public function get_currency() { |
1217 | - return apply_filters( 'wpinv_currency_code', $this->currency, $this->ID, $this ); |
|
1217 | + return apply_filters('wpinv_currency_code', $this->currency, $this->ID, $this); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | public function get_created_date() { |
1221 | - return apply_filters( 'wpinv_created_date', $this->date, $this->ID, $this ); |
|
1221 | + return apply_filters('wpinv_created_date', $this->date, $this->ID, $this); |
|
1222 | 1222 | } |
1223 | 1223 | |
1224 | - public function get_due_date( $display = false ) { |
|
1225 | - $due_date = apply_filters( 'wpinv_due_date', $this->due_date, $this->ID, $this ); |
|
1224 | + public function get_due_date($display = false) { |
|
1225 | + $due_date = apply_filters('wpinv_due_date', $this->due_date, $this->ID, $this); |
|
1226 | 1226 | |
1227 | - if ( ! $display ) { |
|
1227 | + if (!$display) { |
|
1228 | 1228 | return $due_date; |
1229 | 1229 | } |
1230 | 1230 | |
1231 | - return getpaid_format_date( $this->due_date ); |
|
1231 | + return getpaid_format_date($this->due_date); |
|
1232 | 1232 | } |
1233 | 1233 | |
1234 | 1234 | public function get_completed_date() { |
1235 | - return apply_filters( 'wpinv_completed_date', $this->completed_date, $this->ID, $this ); |
|
1235 | + return apply_filters('wpinv_completed_date', $this->completed_date, $this->ID, $this); |
|
1236 | 1236 | } |
1237 | 1237 | |
1238 | - public function get_invoice_date( $formatted = true ) { |
|
1238 | + public function get_invoice_date($formatted = true) { |
|
1239 | 1239 | $date_completed = $this->completed_date; |
1240 | 1240 | $invoice_date = $date_completed != '' && $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
1241 | 1241 | |
1242 | - if ( $invoice_date == '' ) { |
|
1242 | + if ($invoice_date == '') { |
|
1243 | 1243 | $date_created = $this->date; |
1244 | 1244 | $invoice_date = $date_created != '' && $date_created != '0000-00-00 00:00:00' ? $date_created : ''; |
1245 | 1245 | } |
1246 | 1246 | |
1247 | - if ( $formatted && $invoice_date ) { |
|
1248 | - $invoice_date = getpaid_format_date( $invoice_date ); |
|
1247 | + if ($formatted && $invoice_date) { |
|
1248 | + $invoice_date = getpaid_format_date($invoice_date); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | - return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this ); |
|
1251 | + return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->ID, $this); |
|
1252 | 1252 | } |
1253 | 1253 | |
1254 | 1254 | public function get_ip() { |
1255 | - return apply_filters( 'wpinv_user_ip', $this->ip, $this->ID, $this ); |
|
1255 | + return apply_filters('wpinv_user_ip', $this->ip, $this->ID, $this); |
|
1256 | 1256 | } |
1257 | 1257 | |
1258 | - public function has_status( $status ) { |
|
1259 | - return apply_filters( 'wpinv_has_status', ( is_array( $status ) && in_array( $this->get_status(), $status ) ) || $this->get_status() === $status ? true : false, $this, $status ); |
|
1258 | + public function has_status($status) { |
|
1259 | + return apply_filters('wpinv_has_status', (is_array($status) && in_array($this->get_status(), $status)) || $this->get_status() === $status ? true : false, $this, $status); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | public function add_item() {} |
@@ -1273,66 +1273,66 @@ discard block |
||
1273 | 1273 | |
1274 | 1274 | public function get_view_url() {} |
1275 | 1275 | |
1276 | - public function generate_key( $string = '' ) { |
|
1277 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
1278 | - return strtolower( md5( $string . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) ); // Unique key |
|
1276 | + public function generate_key($string = '') { |
|
1277 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
1278 | + return strtolower(md5($string . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))); // Unique key |
|
1279 | 1279 | } |
1280 | 1280 | |
1281 | 1281 | public function is_recurring() { |
1282 | - if ( empty( $this->cart_details ) ) { |
|
1282 | + if (empty($this->cart_details)) { |
|
1283 | 1283 | return false; |
1284 | 1284 | } |
1285 | 1285 | |
1286 | 1286 | $has_subscription = false; |
1287 | - foreach ( $this->cart_details as $cart_item ) { |
|
1288 | - if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
1287 | + foreach ($this->cart_details as $cart_item) { |
|
1288 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
1289 | 1289 | $has_subscription = true; |
1290 | 1290 | break; |
1291 | 1291 | } |
1292 | 1292 | } |
1293 | 1293 | |
1294 | - if ( count( $this->cart_details ) > 1 ) { |
|
1294 | + if (count($this->cart_details) > 1) { |
|
1295 | 1295 | $has_subscription = false; |
1296 | 1296 | } |
1297 | 1297 | |
1298 | - return apply_filters( 'wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details ); |
|
1298 | + return apply_filters('wpinv_invoice_has_recurring_item', $has_subscription, $this->cart_details); |
|
1299 | 1299 | } |
1300 | 1300 | |
1301 | 1301 | public function is_free_trial() { |
1302 | 1302 | $is_free_trial = false; |
1303 | 1303 | |
1304 | - if ( $this->is_parent() && $item = $this->get_recurring( true ) ) { |
|
1305 | - if ( ! empty( $item ) && $item->has_free_trial() ) { |
|
1304 | + if ($this->is_parent() && $item = $this->get_recurring(true)) { |
|
1305 | + if (!empty($item) && $item->has_free_trial()) { |
|
1306 | 1306 | $is_free_trial = true; |
1307 | 1307 | } |
1308 | 1308 | } |
1309 | 1309 | |
1310 | - return apply_filters( 'wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this ); |
|
1310 | + return apply_filters('wpinv_invoice_is_free_trial', $is_free_trial, $this->cart_details, $this); |
|
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | public function is_initial_free() {} |
1314 | 1314 | |
1315 | - public function get_recurring( $object = false ) { |
|
1315 | + public function get_recurring($object = false) { |
|
1316 | 1316 | $item = null; |
1317 | 1317 | |
1318 | - if ( empty( $this->cart_details ) ) { |
|
1318 | + if (empty($this->cart_details)) { |
|
1319 | 1319 | return $item; |
1320 | 1320 | } |
1321 | 1321 | |
1322 | - foreach ( $this->cart_details as $cart_item ) { |
|
1323 | - if ( ! empty( $cart_item['id'] ) && wpinv_is_recurring_item( $cart_item['id'] ) ) { |
|
1322 | + foreach ($this->cart_details as $cart_item) { |
|
1323 | + if (!empty($cart_item['id']) && wpinv_is_recurring_item($cart_item['id'])) { |
|
1324 | 1324 | $item = $cart_item['id']; |
1325 | 1325 | break; |
1326 | 1326 | } |
1327 | 1327 | } |
1328 | 1328 | |
1329 | - if ( $object ) { |
|
1330 | - $item = $item ? new WPInv_Item( $item ) : null; |
|
1329 | + if ($object) { |
|
1330 | + $item = $item ? new WPInv_Item($item) : null; |
|
1331 | 1331 | |
1332 | - apply_filters( 'wpinv_invoice_get_recurring_item', $item, $this ); |
|
1332 | + apply_filters('wpinv_invoice_get_recurring_item', $item, $this); |
|
1333 | 1333 | } |
1334 | 1334 | |
1335 | - return apply_filters( 'wpinv_invoice_get_recurring_item_id', $item, $this ); |
|
1335 | + return apply_filters('wpinv_invoice_get_recurring_item_id', $item, $this); |
|
1336 | 1336 | } |
1337 | 1337 | |
1338 | 1338 | public function get_subscription_name() {} |
@@ -1340,7 +1340,7 @@ discard block |
||
1340 | 1340 | public function get_subscription_id() {} |
1341 | 1341 | |
1342 | 1342 | public function is_parent() { |
1343 | - return ! empty( $this->parent_invoice ); |
|
1343 | + return !empty($this->parent_invoice); |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | public function is_renewal() {} |
@@ -1354,8 +1354,8 @@ discard block |
||
1354 | 1354 | public function is_refunded() {} |
1355 | 1355 | |
1356 | 1356 | public function is_free() { |
1357 | - $total = (float) wpinv_round_amount( $this->get_total() ); |
|
1358 | - return $total > 0 && ! $this->is_recurring(); |
|
1357 | + $total = (float) wpinv_round_amount($this->get_total()); |
|
1358 | + return $total > 0 && !$this->is_recurring(); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | public function has_vat() {} |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | <h2 class="h3 text-dark"> |
14 | - <?php echo esc_html( apply_filters( 'getpaid_invoice_type_label', esc_html( ucfirst( $invoice->get_invoice_quote_type() ) ), $invoice ) ); ?> |
|
14 | + <?php echo esc_html(apply_filters('getpaid_invoice_type_label', esc_html(ucfirst($invoice->get_invoice_quote_type())), $invoice)); ?> |
|
15 | 15 | </h2> |
16 | 16 | |
17 | 17 | <?php |