@@ -1,7 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if ( !defined('ABSPATH') ) { |
|
4 | 4 | die('-1'); |
5 | +} |
|
5 | 6 | |
6 | 7 | do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
7 | 8 |
@@ -1,12 +1,12 @@ |
||
1 | 1 | <?php |
2 | 2 | // don't load directly |
3 | -if ( !defined('ABSPATH') ) |
|
3 | +if (!defined('ABSPATH')) |
|
4 | 4 | die('-1'); |
5 | 5 | |
6 | -do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin ); |
|
6 | +do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin); |
|
7 | 7 | |
8 | -if ( ! empty( $message_body ) ) { |
|
9 | - echo wpautop( wptexturize( $message_body ) ); |
|
8 | +if (!empty($message_body)) { |
|
9 | + echo wpautop(wptexturize($message_body)); |
|
10 | 10 | } |
11 | 11 | |
12 | -do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin ); |
|
13 | 12 | \ No newline at end of file |
13 | +do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin); |
|
14 | 14 | \ No newline at end of file |
@@ -1,41 +1,41 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | global $post; |
6 | 6 | $invoice_id = $post->ID; |
7 | -$invoice = wpinv_get_invoice( $invoice_id ); |
|
8 | -if ( empty( $invoice ) ) { |
|
7 | +$invoice = wpinv_get_invoice($invoice_id); |
|
8 | +if (empty($invoice)) { |
|
9 | 9 | exit; |
10 | 10 | } |
11 | -$type = $post->post_type == 'wpi_invoice' ? __( 'Invoice', 'invoicing' ): __( 'Quotation', 'invoicing' ); |
|
12 | -do_action( 'wpinv_invoice_print_before_display', $invoice ); ?><!DOCTYPE html> |
|
11 | +$type = $post->post_type == 'wpi_invoice' ? __('Invoice', 'invoicing') : __('Quotation', 'invoicing'); |
|
12 | +do_action('wpinv_invoice_print_before_display', $invoice); ?><!DOCTYPE html> |
|
13 | 13 | <html <?php language_attributes(); ?>> |
14 | 14 | <head> |
15 | 15 | <meta charset="UTF-8"> |
16 | 16 | <title><?php wp_title() ?></title> |
17 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
17 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
18 | 18 | <meta name="viewport" content="width=device-width, initial-scale=1"> |
19 | 19 | <meta name="robots" content="noindex,nofollow"> |
20 | 20 | |
21 | - <?php do_action( 'wpinv_invoice_print_head', $invoice ); ?> |
|
21 | + <?php do_action('wpinv_invoice_print_head', $invoice); ?> |
|
22 | 22 | </head> |
23 | 23 | <body class="body wpinv wpinv-print"> |
24 | - <?php do_action( 'wpinv_invoice_print_body_start', $invoice ); ?> |
|
24 | + <?php do_action('wpinv_invoice_print_body_start', $invoice); ?> |
|
25 | 25 | <div class="container wpinv-wrap"> |
26 | - <?php if ( $watermark = wpinv_watermark( $invoice_id ) ) { ?> |
|
27 | - <div class="watermark no-print"><p><?php echo esc_html( $watermark ) ?></p></div> |
|
26 | + <?php if ($watermark = wpinv_watermark($invoice_id)) { ?> |
|
27 | + <div class="watermark no-print"><p><?php echo esc_html($watermark) ?></p></div> |
|
28 | 28 | <?php } ?> |
29 | 29 | <!-- ///// Start PDF header --> |
30 | 30 | <htmlpageheader name="wpinv-pdf-header"> |
31 | - <?php do_action( 'wpinv_invoice_print_before_header', $invoice ); ?> |
|
31 | + <?php do_action('wpinv_invoice_print_before_header', $invoice); ?> |
|
32 | 32 | <div class="row wpinv-header"> |
33 | 33 | <div class="col-xs-6 wpinv-business"> |
34 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
35 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
36 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
34 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
35 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
36 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
37 | 37 | <?php } else { ?> |
38 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
38 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
39 | 39 | <?php } ?> |
40 | 40 | </a> |
41 | 41 | </div> |
@@ -44,56 +44,56 @@ discard block |
||
44 | 44 | <h2><?php echo $type; ?></h2> |
45 | 45 | </div> |
46 | 46 | </div> |
47 | - <?php do_action( 'wpinv_invoice_print_after_header', $invoice ); ?> |
|
47 | + <?php do_action('wpinv_invoice_print_after_header', $invoice); ?> |
|
48 | 48 | </htmlpageheader> |
49 | 49 | <!-- End PDF header ///// --> |
50 | 50 | |
51 | - <?php do_action( 'wpinv_invoice_print_before_top_content', $invoice ); ?> |
|
51 | + <?php do_action('wpinv_invoice_print_before_top_content', $invoice); ?> |
|
52 | 52 | <div class="row wpinv-top-content"> |
53 | 53 | <div class="col-xs-12 col-sm-6 wpinv-addresses"> |
54 | 54 | <div class="col-xs-12 wpinv-address wpinv-from-address"> |
55 | 55 | <?php wpinv_display_from_address(); ?> |
56 | 56 | </div> |
57 | 57 | <div class="col-xs-12 wpinv-address wpinv-to-address"> |
58 | - <?php wpinv_display_to_address( $invoice_id ); ?> |
|
58 | + <?php wpinv_display_to_address($invoice_id); ?> |
|
59 | 59 | </div> |
60 | 60 | </div> |
61 | 61 | <div class="col-xs-12 col-sm-6 wpinv-details"> |
62 | 62 | <div class="col-xs-12 wpinv-line-details"> |
63 | - <?php do_action( 'wpinv_invoice_print_before_details', $invoice ); ?> |
|
64 | - <?php wpinv_display_invoice_details( $invoice ); ?> |
|
65 | - <?php do_action( 'wpinv_invoice_print_after_details', $invoice ); ?> |
|
63 | + <?php do_action('wpinv_invoice_print_before_details', $invoice); ?> |
|
64 | + <?php wpinv_display_invoice_details($invoice); ?> |
|
65 | + <?php do_action('wpinv_invoice_print_after_details', $invoice); ?> |
|
66 | 66 | </div> |
67 | 67 | </div> |
68 | 68 | </div> |
69 | - <?php do_action( 'wpinv_invoice_print_after_top_content', $invoice ); ?> |
|
69 | + <?php do_action('wpinv_invoice_print_after_top_content', $invoice); ?> |
|
70 | 70 | |
71 | - <?php do_action( 'wpinv_invoice_print_middle', $invoice ); ?> |
|
71 | + <?php do_action('wpinv_invoice_print_middle', $invoice); ?> |
|
72 | 72 | |
73 | - <?php do_action( 'wpinv_invoice_print_before_line_items', $invoice ); ?> |
|
73 | + <?php do_action('wpinv_invoice_print_before_line_items', $invoice); ?> |
|
74 | 74 | <div class="row wpinv-items"> |
75 | 75 | <div class="col-sm-12 wpinv-line-items"> |
76 | - <?php wpinv_display_line_items( $invoice_id ); ?> |
|
76 | + <?php wpinv_display_line_items($invoice_id); ?> |
|
77 | 77 | </div> |
78 | 78 | </div> |
79 | - <?php do_action( 'wpinv_invoice_print_after_line_items', $invoice ); ?> |
|
79 | + <?php do_action('wpinv_invoice_print_after_line_items', $invoice); ?> |
|
80 | 80 | |
81 | 81 | <!-- ///// Start PDF footer --> |
82 | 82 | <htmlpagefooter name="wpinv-pdf-footer"> |
83 | - <?php do_action( 'wpinv_invoice_print_before_footer', $invoice ); ?> |
|
83 | + <?php do_action('wpinv_invoice_print_before_footer', $invoice); ?> |
|
84 | 84 | <div class="row wpinv-footer"> |
85 | 85 | <div class="col-sm-12"> |
86 | - <?php if ( $term_text = wpinv_get_terms_text() ) { ?> |
|
87 | - <div class="terms-text"><?php echo wpautop( $term_text ); ?></div> |
|
86 | + <?php if ($term_text = wpinv_get_terms_text()) { ?> |
|
87 | + <div class="terms-text"><?php echo wpautop($term_text); ?></div> |
|
88 | 88 | <?php } ?> |
89 | 89 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
90 | - <div class="print-only"><?php _e( 'Page ', 'invoicing' ) ?> {PAGENO}/{nbpg}</div> |
|
90 | + <div class="print-only"><?php _e('Page ', 'invoicing') ?> {PAGENO}/{nbpg}</div> |
|
91 | 91 | </div> |
92 | 92 | </div> |
93 | - <?php do_action( 'wpinv_invoice_print_after_footer', $invoice ); ?> |
|
93 | + <?php do_action('wpinv_invoice_print_after_footer', $invoice); ?> |
|
94 | 94 | </htmlpagefooter> |
95 | 95 | <!-- End PDF footer ///// --> |
96 | 96 | </div><!-- END wpinv-wrap --> |
97 | - <?php do_action( 'wpinv_invoice_print_body_end', $invoice ); ?> |
|
97 | + <?php do_action('wpinv_invoice_print_body_end', $invoice); ?> |
|
98 | 98 | </body> |
99 | 99 | </html> |
100 | 100 | \ No newline at end of file |
@@ -47,6 +47,9 @@ discard block |
||
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | + /** |
|
51 | + * @param integer $code |
|
52 | + */ |
|
50 | 53 | public function send_status( $code ) { |
51 | 54 | status_header( $code ); |
52 | 55 | } |
@@ -195,6 +198,11 @@ discard block |
||
195 | 198 | class WPInv_API_Exception extends Exception { |
196 | 199 | protected $error_code; |
197 | 200 | |
201 | + /** |
|
202 | + * @param string $error_code |
|
203 | + * @param string $error_message |
|
204 | + * @param integer $http_status_code |
|
205 | + */ |
|
198 | 206 | public function __construct( $error_code, $error_message, $http_status_code ) { |
199 | 207 | $this->error_code = $error_code; |
200 | 208 | parent::__construct( $error_message, $http_status_code ); |
@@ -7,51 +7,51 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | class WPInv_API { |
15 | 15 | protected $post_type = 'wpi_invoice'; |
16 | 16 | |
17 | - public function __construct( $params = array() ) { |
|
17 | + public function __construct($params = array()) { |
|
18 | 18 | } |
19 | - public function insert_invoice( $data ) { |
|
19 | + public function insert_invoice($data) { |
|
20 | 20 | global $wpdb; |
21 | 21 | //wpinv_transaction_query( 'start' ); |
22 | 22 | |
23 | 23 | try { |
24 | - if ( empty( $data['invoice'] ) ) { |
|
25 | - throw new WPInv_API_Exception( 'wpinv_api_missing_invoice_data', sprintf( __( 'No %1$s data specified to create %1$s', 'invoicing' ), 'invoice' ), 400 ); |
|
24 | + if (empty($data['invoice'])) { |
|
25 | + throw new WPInv_API_Exception('wpinv_api_missing_invoice_data', sprintf(__('No %1$s data specified to create %1$s', 'invoicing'), 'invoice'), 400); |
|
26 | 26 | } |
27 | 27 | |
28 | - $data = apply_filters( 'wpinv_api_create_invoice_data', $data['invoice'], $this ); |
|
28 | + $data = apply_filters('wpinv_api_create_invoice_data', $data['invoice'], $this); |
|
29 | 29 | |
30 | - $invoice = wpinv_insert_invoice( $data, true ); |
|
31 | - if ( empty( $invoice->ID ) || is_wp_error( $invoice ) ) { |
|
32 | - throw new WPInv_API_Exception( 'wpinv_api_cannot_create_invoice', sprintf( __( 'Cannot create invoice: %s', 'invoicing' ), implode( ', ', $invoice->get_error_messages() ) ), 400 ); |
|
30 | + $invoice = wpinv_insert_invoice($data, true); |
|
31 | + if (empty($invoice->ID) || is_wp_error($invoice)) { |
|
32 | + throw new WPInv_API_Exception('wpinv_api_cannot_create_invoice', sprintf(__('Cannot create invoice: %s', 'invoicing'), implode(', ', $invoice->get_error_messages())), 400); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | // HTTP 201 Created |
36 | - $this->send_status( 201 ); |
|
36 | + $this->send_status(201); |
|
37 | 37 | |
38 | - do_action( 'wpinv_api_create_invoice', $invoice->ID, $data, $this ); |
|
38 | + do_action('wpinv_api_create_invoice', $invoice->ID, $data, $this); |
|
39 | 39 | |
40 | 40 | //wpinv_transaction_query( 'commit' ); |
41 | 41 | |
42 | - return wpinv_get_invoice( $invoice->ID ); |
|
43 | - } catch ( WPInv_API_Exception $e ) { |
|
42 | + return wpinv_get_invoice($invoice->ID); |
|
43 | + } catch (WPInv_API_Exception $e) { |
|
44 | 44 | //wpinv_transaction_query( 'rollback' ); |
45 | 45 | |
46 | - return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) ); |
|
46 | + return new WP_Error($e->getErrorCode(), $e->getMessage(), array('status' => $e->getCode())); |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | |
50 | - public function send_status( $code ) { |
|
51 | - status_header( $code ); |
|
50 | + public function send_status($code) { |
|
51 | + status_header($code); |
|
52 | 52 | } |
53 | 53 | |
54 | - protected function set_billing_details( $invoice, $data ) { |
|
54 | + protected function set_billing_details($invoice, $data) { |
|
55 | 55 | $address_fields = array( |
56 | 56 | 'user_id', |
57 | 57 | 'first_name', |
@@ -70,66 +70,66 @@ discard block |
||
70 | 70 | $billing_details = array(); |
71 | 71 | $user_id = $invoice->get_user_id(); |
72 | 72 | |
73 | - foreach ( $address_fields as $field ) { |
|
74 | - if ( isset( $data['billing_details'][ $field ] ) ) { |
|
75 | - $value = sanitize_text_field( $data['billing_details'][ $field ] ); |
|
73 | + foreach ($address_fields as $field) { |
|
74 | + if (isset($data['billing_details'][$field])) { |
|
75 | + $value = sanitize_text_field($data['billing_details'][$field]); |
|
76 | 76 | |
77 | - if ( $field == 'country' && empty( $value ) ) { |
|
78 | - if ( !empty( $invoice->country ) ) { |
|
77 | + if ($field == 'country' && empty($value)) { |
|
78 | + if (!empty($invoice->country)) { |
|
79 | 79 | $value = $invoice->country; |
80 | 80 | } else { |
81 | - $value = wpinv_default_billing_country( '', $user_id ); |
|
81 | + $value = wpinv_default_billing_country('', $user_id); |
|
82 | 82 | } |
83 | 83 | } |
84 | 84 | |
85 | - if ( $field == 'state' && empty( $value ) ) { |
|
86 | - if ( !empty( $invoice->state ) ) { |
|
85 | + if ($field == 'state' && empty($value)) { |
|
86 | + if (!empty($invoice->state)) { |
|
87 | 87 | $value = $invoice->state; |
88 | 88 | } else { |
89 | 89 | $value = wpinv_get_default_state(); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | - $invoice->set( $field, $value ); |
|
93 | + $invoice->set($field, $value); |
|
94 | 94 | |
95 | - update_post_meta( $invoice->ID, '_wpinv_' . $field, $value ); |
|
95 | + update_post_meta($invoice->ID, '_wpinv_' . $field, $value); |
|
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | 99 | return $invoice; |
100 | 100 | } |
101 | 101 | |
102 | - protected function set_discount( $invoice, $data ) { |
|
103 | - if ( isset( $data['discount'] ) ) { |
|
104 | - $invoice->set( 'discount', wpinv_round_amount( $data['discount'] ) ); |
|
102 | + protected function set_discount($invoice, $data) { |
|
103 | + if (isset($data['discount'])) { |
|
104 | + $invoice->set('discount', wpinv_round_amount($data['discount'])); |
|
105 | 105 | |
106 | - update_post_meta( $invoice->ID, '_wpinv_discount', wpinv_round_amount( $data['discount'] ) ); |
|
106 | + update_post_meta($invoice->ID, '_wpinv_discount', wpinv_round_amount($data['discount'])); |
|
107 | 107 | |
108 | - if ( isset( $data['discount_code'] ) ) { |
|
109 | - $invoice->set( 'discount_code', $data['discount_code'] ); |
|
108 | + if (isset($data['discount_code'])) { |
|
109 | + $invoice->set('discount_code', $data['discount_code']); |
|
110 | 110 | |
111 | - update_post_meta( $invoice->ID, '_wpinv_discount_code', $data['discount_code'] ); |
|
111 | + update_post_meta($invoice->ID, '_wpinv_discount_code', $data['discount_code']); |
|
112 | 112 | } |
113 | 113 | } |
114 | 114 | |
115 | 115 | return $invoice; |
116 | 116 | } |
117 | 117 | |
118 | - protected function set_items( $invoice, $data ) { |
|
119 | - if ( !empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
118 | + protected function set_items($invoice, $data) { |
|
119 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
120 | 120 | $items_array = array(); |
121 | 121 | |
122 | - if ( !empty( $invoice->country ) ) { |
|
122 | + if (!empty($invoice->country)) { |
|
123 | 123 | $country = $invoice->country; |
124 | - } else if ( !empty( $data['billing_details']['country'] ) ) { |
|
124 | + } else if (!empty($data['billing_details']['country'])) { |
|
125 | 125 | $country = $data['billing_details']['country']; |
126 | 126 | } else { |
127 | - $country = wpinv_default_billing_country( '', $invoice->get_user_id() ); |
|
127 | + $country = wpinv_default_billing_country('', $invoice->get_user_id()); |
|
128 | 128 | } |
129 | 129 | |
130 | - if ( !empty( $invoice->state ) ) { |
|
130 | + if (!empty($invoice->state)) { |
|
131 | 131 | $state = $invoice->state; |
132 | - } else if ( !empty( $data['billing_details']['state'] ) ) { |
|
132 | + } else if (!empty($data['billing_details']['state'])) { |
|
133 | 133 | $state = $data['billing_details']['state']; |
134 | 134 | } else { |
135 | 135 | $state = wpinv_get_default_state(); |
@@ -138,54 +138,54 @@ discard block |
||
138 | 138 | $_POST['country'] = $country; |
139 | 139 | $_POST['state'] = $state; |
140 | 140 | |
141 | - $rate = wpinv_get_tax_rate( $country, $state, 'global' ); |
|
141 | + $rate = wpinv_get_tax_rate($country, $state, 'global'); |
|
142 | 142 | |
143 | 143 | $total_tax = 0; |
144 | - foreach ( $data['items'] as $item ) { |
|
145 | - $id = isset( $item['id'] ) ? sanitize_text_field( $item['id'] ) : ''; |
|
146 | - $title = isset( $item['title'] ) ? sanitize_text_field( $item['title'] ) : ''; |
|
147 | - $desc = isset( $item['description'] ) ? sanitize_text_field( $item['description'] ) : ''; |
|
148 | - $amount = isset( $item['amount'] ) ? wpinv_round_amount( $item['amount'] ) : 0; |
|
144 | + foreach ($data['items'] as $item) { |
|
145 | + $id = isset($item['id']) ? sanitize_text_field($item['id']) : ''; |
|
146 | + $title = isset($item['title']) ? sanitize_text_field($item['title']) : ''; |
|
147 | + $desc = isset($item['description']) ? sanitize_text_field($item['description']) : ''; |
|
148 | + $amount = isset($item['amount']) ? wpinv_round_amount($item['amount']) : 0; |
|
149 | 149 | |
150 | - if ( !empty( $item['vat_rates_class'] ) ) { |
|
150 | + if (!empty($item['vat_rates_class'])) { |
|
151 | 151 | $vat_rates_class = $item['vat_rates_class']; |
152 | 152 | } else { |
153 | 153 | $vat_rates_class = '_standard'; |
154 | 154 | } |
155 | - $vat_rate = wpinv_get_tax_rate( $country, $state, $id ); |
|
155 | + $vat_rate = wpinv_get_tax_rate($country, $state, $id); |
|
156 | 156 | |
157 | - $tax = $amount > 0 ? ( $amount * 0.01 * (float)$vat_rate ) : 0; |
|
157 | + $tax = $amount > 0 ? ($amount * 0.01 * (float)$vat_rate) : 0; |
|
158 | 158 | $total_tax += $tax; |
159 | 159 | |
160 | 160 | $items_array[] = array( |
161 | 161 | 'id' => $id, |
162 | - 'title' => esc_html( $title ), |
|
163 | - 'description' => esc_html( $desc ), |
|
164 | - 'amount' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
165 | - 'subtotal' => $amount > 0 ? wpinv_round_amount( $amount ) : 0, |
|
162 | + 'title' => esc_html($title), |
|
163 | + 'description' => esc_html($desc), |
|
164 | + 'amount' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
165 | + 'subtotal' => $amount > 0 ? wpinv_round_amount($amount) : 0, |
|
166 | 166 | 'vat_rates_class' => $vat_rates_class, |
167 | 167 | 'vat_rate' => $vat_rate, |
168 | - 'tax' => $tax > 0 ? wpinv_round_amount( $tax ) : 0, |
|
168 | + 'tax' => $tax > 0 ? wpinv_round_amount($tax) : 0, |
|
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
172 | - update_post_meta( $invoice->ID, '_wpinv_tax', wpinv_round_amount( $total_tax ) ); |
|
173 | - $invoice->set( 'tax', wpinv_round_amount( $total_tax ) ); |
|
172 | + update_post_meta($invoice->ID, '_wpinv_tax', wpinv_round_amount($total_tax)); |
|
173 | + $invoice->set('tax', wpinv_round_amount($total_tax)); |
|
174 | 174 | |
175 | - $items_array = apply_filters( 'wpinv_save_invoice_items', $items_array, $data['items'], $invoice ); |
|
175 | + $items_array = apply_filters('wpinv_save_invoice_items', $items_array, $data['items'], $invoice); |
|
176 | 176 | |
177 | - $invoice->set( 'items', $items_array ); |
|
178 | - update_post_meta( $invoice->ID, '_wpinv_items', $items_array ); |
|
177 | + $invoice->set('items', $items_array); |
|
178 | + update_post_meta($invoice->ID, '_wpinv_items', $items_array); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | return $invoice; |
182 | 182 | } |
183 | 183 | |
184 | - protected function set_invoice_meta( $invoice_id, $invoice_meta ) { |
|
185 | - foreach ( $invoice_meta as $meta_key => $meta_value ) { |
|
184 | + protected function set_invoice_meta($invoice_id, $invoice_meta) { |
|
185 | + foreach ($invoice_meta as $meta_key => $meta_value) { |
|
186 | 186 | |
187 | - if ( is_string( $meta_key) && ! is_protected_meta( $meta_key ) && is_scalar( $meta_value ) ) { |
|
188 | - update_post_meta( $invoice_id, $meta_key, $meta_value ); |
|
187 | + if (is_string($meta_key) && !is_protected_meta($meta_key) && is_scalar($meta_value)) { |
|
188 | + update_post_meta($invoice_id, $meta_key, $meta_value); |
|
189 | 189 | } |
190 | 190 | } |
191 | 191 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | class WPInv_API_Exception extends Exception { |
196 | 196 | protected $error_code; |
197 | 197 | |
198 | - public function __construct( $error_code, $error_message, $http_status_code ) { |
|
198 | + public function __construct($error_code, $error_message, $http_status_code) { |
|
199 | 199 | $this->error_code = $error_code; |
200 | - parent::__construct( $error_message, $http_status_code ); |
|
200 | + parent::__construct($error_message, $http_status_code); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | public function getErrorCode() { |
@@ -664,6 +664,9 @@ discard block |
||
664 | 664 | return $sent; |
665 | 665 | } |
666 | 666 | |
667 | +/** |
|
668 | + * @return string |
|
669 | + */ |
|
667 | 670 | function wpinv_mail_get_from_address() { |
668 | 671 | $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
669 | 672 | return sanitize_email( $from_address ); |
@@ -1123,6 +1126,9 @@ discard block |
||
1123 | 1126 | } |
1124 | 1127 | add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
1125 | 1128 | |
1129 | +/** |
|
1130 | + * @param string $email_type |
|
1131 | + */ |
|
1126 | 1132 | function wpinv_email_is_enabled( $email_type ) { |
1127 | 1133 | $emails = wpinv_get_emails(); |
1128 | 1134 | $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
@@ -7,12 +7,12 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
11 | - exit( 'Do NOT access this file directly: ' . basename( __FILE__ ) ); |
|
10 | +if (!defined('WPINC')) { |
|
11 | + exit('Do NOT access this file directly: ' . basename(__FILE__)); |
|
12 | 12 | } |
13 | 13 | |
14 | 14 | function wpinv_init_transactional_emails() { |
15 | - $email_actions = apply_filters( 'wpinv_email_actions', array( |
|
15 | + $email_actions = apply_filters('wpinv_email_actions', array( |
|
16 | 16 | 'wpinv_status_wpi-pending_to_wpi-processing', |
17 | 17 | 'wpinv_status_wpi-pending_to_publish', |
18 | 18 | 'wpinv_status_wpi-pending_to_wpi-cancelled', |
@@ -30,381 +30,381 @@ discard block |
||
30 | 30 | 'wpinv_fully_refunded', |
31 | 31 | 'wpinv_partially_refunded', |
32 | 32 | 'wpinv_new_invoice_note' |
33 | - ) ); |
|
33 | + )); |
|
34 | 34 | |
35 | - foreach ( $email_actions as $action ) { |
|
36 | - add_action( $action, 'wpinv_send_transactional_email', 10, 10 ); |
|
35 | + foreach ($email_actions as $action) { |
|
36 | + add_action($action, 'wpinv_send_transactional_email', 10, 10); |
|
37 | 37 | } |
38 | 38 | } |
39 | -add_action( 'init', 'wpinv_init_transactional_emails' ); |
|
39 | +add_action('init', 'wpinv_init_transactional_emails'); |
|
40 | 40 | |
41 | 41 | // New invoice email |
42 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
43 | -add_action( 'wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
44 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
45 | -add_action( 'wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification' ); |
|
46 | -add_action( 'wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification' ); |
|
47 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification' ); |
|
42 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
43 | +add_action('wpinv_status_wpi-pending_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
44 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
45 | +add_action('wpinv_status_wpi-failed_to_wpi-processing_notification', 'wpinv_new_invoice_notification'); |
|
46 | +add_action('wpinv_status_wpi-failed_to_publish_notification', 'wpinv_new_invoice_notification'); |
|
47 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_new_invoice_notification'); |
|
48 | 48 | |
49 | 49 | // Cancelled invoice email |
50 | -add_action( 'wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
51 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification' ); |
|
50 | +add_action('wpinv_status_wpi-pending_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
51 | +add_action('wpinv_status_wpi-onhold_to_wpi-cancelled_notification', 'wpinv_cancelled_invoice_notification'); |
|
52 | 52 | |
53 | 53 | // Failed invoice email |
54 | -add_action( 'wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
55 | -add_action( 'wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification' ); |
|
54 | +add_action('wpinv_status_wpi-pending_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
55 | +add_action('wpinv_status_wpi-onhold_to_wpi-failed_notification', 'wpinv_failed_invoice_notification'); |
|
56 | 56 | |
57 | 57 | // On hold invoice email |
58 | -add_action( 'wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
59 | -add_action( 'wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification' ); |
|
58 | +add_action('wpinv_status_wpi-pending_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
59 | +add_action('wpinv_status_wpi-failed_to_wpi-onhold_notification', 'wpinv_onhold_invoice_notification'); |
|
60 | 60 | |
61 | 61 | // Processing invoice email |
62 | -add_action( 'wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification' ); |
|
62 | +add_action('wpinv_status_wpi-pending_to_wpi-processing_notification', 'wpinv_processing_invoice_notification'); |
|
63 | 63 | |
64 | 64 | // Paid invoice email |
65 | -add_action( 'wpinv_status_publish_notification', 'wpinv_completed_invoice_notification' ); |
|
65 | +add_action('wpinv_status_publish_notification', 'wpinv_completed_invoice_notification'); |
|
66 | 66 | |
67 | 67 | // Refunded invoice email |
68 | -add_action( 'wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
69 | -add_action( 'wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification' ); |
|
70 | -add_action( 'wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
71 | -add_action( 'wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification' ); |
|
68 | +add_action('wpinv_fully_refunded_notification', 'wpinv_fully_refunded_notification'); |
|
69 | +add_action('wpinv_partially_refunded_notification', 'wpinv_partially_refunded_notification'); |
|
70 | +add_action('wpinv_status_publish_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
71 | +add_action('wpinv_status_wpi-processing_to_wpi-refunded_notification', 'wpinv_fully_refunded_notification'); |
|
72 | 72 | |
73 | 73 | // Invoice note |
74 | -add_action( 'wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification' ); |
|
74 | +add_action('wpinv_new_invoice_note_notification', 'wpinv_new_invoice_note_notification'); |
|
75 | 75 | |
76 | -add_action( 'wpinv_email_header', 'wpinv_email_header' ); |
|
77 | -add_action( 'wpinv_email_footer', 'wpinv_email_footer' ); |
|
78 | -add_action( 'wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3 ); |
|
79 | -add_action( 'wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3 ); |
|
80 | -add_action( 'wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3 ); |
|
76 | +add_action('wpinv_email_header', 'wpinv_email_header'); |
|
77 | +add_action('wpinv_email_footer', 'wpinv_email_footer'); |
|
78 | +add_action('wpinv_email_invoice_details', 'wpinv_email_invoice_details', 10, 3); |
|
79 | +add_action('wpinv_email_invoice_items', 'wpinv_email_invoice_items', 10, 3); |
|
80 | +add_action('wpinv_email_billing_details', 'wpinv_email_billing_details', 10, 3); |
|
81 | 81 | |
82 | 82 | function wpinv_send_transactional_email() { |
83 | 83 | $args = func_get_args(); |
84 | 84 | $function = current_filter() . '_notification'; |
85 | - do_action_ref_array( $function, $args ); |
|
85 | + do_action_ref_array($function, $args); |
|
86 | 86 | } |
87 | 87 | |
88 | -function wpinv_new_invoice_notification( $invoice_id, $new_status = '' ) { |
|
88 | +function wpinv_new_invoice_notification($invoice_id, $new_status = '') { |
|
89 | 89 | $email_type = 'new_invoice'; |
90 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
90 | + if (!wpinv_email_is_enabled($email_type)) { |
|
91 | 91 | return false; |
92 | 92 | } |
93 | 93 | |
94 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
95 | - if ( empty( $invoice ) ) { |
|
94 | + $invoice = wpinv_get_invoice($invoice_id); |
|
95 | + if (empty($invoice)) { |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
99 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | |
103 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
104 | - if ( !is_email( $recipient ) ) { |
|
103 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
104 | + if (!is_email($recipient)) { |
|
105 | 105 | return false; |
106 | 106 | } |
107 | 107 | |
108 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
108 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
109 | 109 | |
110 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
111 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
112 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
113 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
114 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
110 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
111 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
112 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
113 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
114 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
115 | 115 | |
116 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
116 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
117 | 117 | 'invoice' => $invoice, |
118 | 118 | 'email_type' => $email_type, |
119 | 119 | 'email_heading' => $email_heading, |
120 | 120 | 'sent_to_admin' => true, |
121 | 121 | 'plain_text' => false, |
122 | 122 | 'message_body' => $message_body, |
123 | - ) ); |
|
123 | + )); |
|
124 | 124 | |
125 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
125 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
126 | 126 | |
127 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
127 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
128 | 128 | |
129 | 129 | return $sent; |
130 | 130 | } |
131 | 131 | |
132 | -function wpinv_cancelled_invoice_notification( $invoice_id, $new_status = '' ) { |
|
132 | +function wpinv_cancelled_invoice_notification($invoice_id, $new_status = '') { |
|
133 | 133 | $email_type = 'cancelled_invoice'; |
134 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
134 | + if (!wpinv_email_is_enabled($email_type)) { |
|
135 | 135 | return false; |
136 | 136 | } |
137 | 137 | |
138 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
139 | - if ( empty( $invoice ) ) { |
|
138 | + $invoice = wpinv_get_invoice($invoice_id); |
|
139 | + if (empty($invoice)) { |
|
140 | 140 | return false; |
141 | 141 | } |
142 | 142 | |
143 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
143 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
144 | 144 | return false; |
145 | 145 | } |
146 | 146 | |
147 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
148 | - if ( !is_email( $recipient ) ) { |
|
147 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
148 | + if (!is_email($recipient)) { |
|
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | |
152 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
152 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
153 | 153 | |
154 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
155 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
156 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
157 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
158 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
154 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
155 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
156 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
157 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
158 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
159 | 159 | |
160 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
160 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
161 | 161 | 'invoice' => $invoice, |
162 | 162 | 'email_type' => $email_type, |
163 | 163 | 'email_heading' => $email_heading, |
164 | 164 | 'sent_to_admin' => true, |
165 | 165 | 'plain_text' => false, |
166 | 166 | 'message_body' => $message_body, |
167 | - ) ); |
|
167 | + )); |
|
168 | 168 | |
169 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
169 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
170 | 170 | |
171 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
171 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
172 | 172 | |
173 | 173 | return $sent; |
174 | 174 | } |
175 | 175 | |
176 | -function wpinv_failed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
176 | +function wpinv_failed_invoice_notification($invoice_id, $new_status = '') { |
|
177 | 177 | $email_type = 'failed_invoice'; |
178 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
178 | + if (!wpinv_email_is_enabled($email_type)) { |
|
179 | 179 | return false; |
180 | 180 | } |
181 | 181 | |
182 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
183 | - if ( empty( $invoice ) ) { |
|
182 | + $invoice = wpinv_get_invoice($invoice_id); |
|
183 | + if (empty($invoice)) { |
|
184 | 184 | return false; |
185 | 185 | } |
186 | 186 | |
187 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
187 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
188 | 188 | return false; |
189 | 189 | } |
190 | 190 | |
191 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
192 | - if ( !is_email( $recipient ) ) { |
|
191 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
192 | + if (!is_email($recipient)) { |
|
193 | 193 | return false; |
194 | 194 | } |
195 | 195 | |
196 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type, true ); |
|
196 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type, true); |
|
197 | 197 | |
198 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
199 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
200 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
201 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
202 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
198 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
199 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
200 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
201 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
202 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
203 | 203 | |
204 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
204 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
205 | 205 | 'invoice' => $invoice, |
206 | 206 | 'email_type' => $email_type, |
207 | 207 | 'email_heading' => $email_heading, |
208 | 208 | 'sent_to_admin' => true, |
209 | 209 | 'plain_text' => false, |
210 | 210 | 'message_body' => $message_body, |
211 | - ) ); |
|
211 | + )); |
|
212 | 212 | |
213 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
213 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
214 | 214 | |
215 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type, true ); |
|
215 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type, true); |
|
216 | 216 | |
217 | 217 | return $sent; |
218 | 218 | } |
219 | 219 | |
220 | -function wpinv_onhold_invoice_notification( $invoice_id, $new_status = '' ) { |
|
220 | +function wpinv_onhold_invoice_notification($invoice_id, $new_status = '') { |
|
221 | 221 | $email_type = 'onhold_invoice'; |
222 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
222 | + if (!wpinv_email_is_enabled($email_type)) { |
|
223 | 223 | return false; |
224 | 224 | } |
225 | 225 | |
226 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
227 | - if ( empty( $invoice ) ) { |
|
226 | + $invoice = wpinv_get_invoice($invoice_id); |
|
227 | + if (empty($invoice)) { |
|
228 | 228 | return false; |
229 | 229 | } |
230 | 230 | |
231 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
231 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
232 | 232 | return false; |
233 | 233 | } |
234 | 234 | |
235 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
236 | - if ( !is_email( $recipient ) ) { |
|
235 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
236 | + if (!is_email($recipient)) { |
|
237 | 237 | return false; |
238 | 238 | } |
239 | 239 | |
240 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
240 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
241 | 241 | |
242 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
243 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
244 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
245 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
246 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
242 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
243 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
244 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
245 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
246 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
247 | 247 | |
248 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
248 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
249 | 249 | 'invoice' => $invoice, |
250 | 250 | 'email_type' => $email_type, |
251 | 251 | 'email_heading' => $email_heading, |
252 | 252 | 'sent_to_admin' => false, |
253 | 253 | 'plain_text' => false, |
254 | 254 | 'message_body' => $message_body, |
255 | - ) ); |
|
255 | + )); |
|
256 | 256 | |
257 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
257 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
258 | 258 | |
259 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
260 | - $recipient = wpinv_get_admin_email(); |
|
261 | - $subject .= ' - ADMIN BCC COPY'; |
|
262 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
259 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
260 | + $recipient = wpinv_get_admin_email(); |
|
261 | + $subject .= ' - ADMIN BCC COPY'; |
|
262 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
263 | 263 | } |
264 | 264 | |
265 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
265 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
266 | 266 | |
267 | 267 | return $sent; |
268 | 268 | } |
269 | 269 | |
270 | -function wpinv_processing_invoice_notification( $invoice_id, $new_status = '' ) { |
|
270 | +function wpinv_processing_invoice_notification($invoice_id, $new_status = '') { |
|
271 | 271 | $email_type = 'processing_invoice'; |
272 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
272 | + if (!wpinv_email_is_enabled($email_type)) { |
|
273 | 273 | return false; |
274 | 274 | } |
275 | 275 | |
276 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
277 | - if ( empty( $invoice ) ) { |
|
276 | + $invoice = wpinv_get_invoice($invoice_id); |
|
277 | + if (empty($invoice)) { |
|
278 | 278 | return false; |
279 | 279 | } |
280 | 280 | |
281 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
281 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
282 | 282 | return false; |
283 | 283 | } |
284 | 284 | |
285 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
286 | - if ( !is_email( $recipient ) ) { |
|
285 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
286 | + if (!is_email($recipient)) { |
|
287 | 287 | return false; |
288 | 288 | } |
289 | 289 | |
290 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
290 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
291 | 291 | |
292 | 292 | $search = array(); |
293 | 293 | $search['invoice_number'] = '{invoice_number}'; |
294 | 294 | $search['invoice_date'] = '{invoice_date}'; |
295 | 295 | $search['name'] = '{name}'; |
296 | 296 | |
297 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
298 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
299 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
300 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
301 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
297 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
298 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
299 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
300 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
301 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
302 | 302 | |
303 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
303 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
304 | 304 | 'invoice' => $invoice, |
305 | 305 | 'email_type' => $email_type, |
306 | 306 | 'email_heading' => $email_heading, |
307 | 307 | 'sent_to_admin' => false, |
308 | 308 | 'plain_text' => false, |
309 | 309 | 'message_body' => $message_body, |
310 | - ) ); |
|
310 | + )); |
|
311 | 311 | |
312 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
312 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
313 | 313 | |
314 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
315 | - $recipient = wpinv_get_admin_email(); |
|
316 | - $subject .= ' - ADMIN BCC COPY'; |
|
317 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
314 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
315 | + $recipient = wpinv_get_admin_email(); |
|
316 | + $subject .= ' - ADMIN BCC COPY'; |
|
317 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
318 | 318 | } |
319 | 319 | |
320 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
320 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
321 | 321 | |
322 | 322 | return $sent; |
323 | 323 | } |
324 | 324 | |
325 | -function wpinv_completed_invoice_notification( $invoice_id, $new_status = '' ) { |
|
325 | +function wpinv_completed_invoice_notification($invoice_id, $new_status = '') { |
|
326 | 326 | $email_type = 'completed_invoice'; |
327 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
327 | + if (!wpinv_email_is_enabled($email_type)) { |
|
328 | 328 | return false; |
329 | 329 | } |
330 | 330 | |
331 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
332 | - if ( empty( $invoice ) ) { |
|
331 | + $invoice = wpinv_get_invoice($invoice_id); |
|
332 | + if (empty($invoice)) { |
|
333 | 333 | return false; |
334 | 334 | } |
335 | 335 | |
336 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
336 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | - if($invoice->is_renewal() && wpinv_email_is_enabled( 'completed_invoice_renewal' )){ |
|
340 | + if ($invoice->is_renewal() && wpinv_email_is_enabled('completed_invoice_renewal')) { |
|
341 | 341 | return false; |
342 | 342 | } |
343 | 343 | |
344 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
345 | - if ( !is_email( $recipient ) ) { |
|
344 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
345 | + if (!is_email($recipient)) { |
|
346 | 346 | return false; |
347 | 347 | } |
348 | 348 | |
349 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
349 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
350 | 350 | |
351 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
352 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
353 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
354 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
355 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
351 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
352 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
353 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
354 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
355 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
356 | 356 | |
357 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
357 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
358 | 358 | 'invoice' => $invoice, |
359 | 359 | 'email_type' => $email_type, |
360 | 360 | 'email_heading' => $email_heading, |
361 | 361 | 'sent_to_admin' => false, |
362 | 362 | 'plain_text' => false, |
363 | 363 | 'message_body' => $message_body, |
364 | - ) ); |
|
364 | + )); |
|
365 | 365 | |
366 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
366 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
367 | 367 | |
368 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
369 | - $recipient = wpinv_get_admin_email(); |
|
370 | - $subject .= ' - ADMIN BCC COPY'; |
|
371 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
368 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
369 | + $recipient = wpinv_get_admin_email(); |
|
370 | + $subject .= ' - ADMIN BCC COPY'; |
|
371 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
372 | 372 | } |
373 | 373 | |
374 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
374 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
375 | 375 | |
376 | 376 | return $sent; |
377 | 377 | } |
378 | 378 | |
379 | -function wpinv_fully_refunded_notification( $invoice_id, $new_status = '' ) { |
|
379 | +function wpinv_fully_refunded_notification($invoice_id, $new_status = '') { |
|
380 | 380 | $email_type = 'refunded_invoice'; |
381 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
381 | + if (!wpinv_email_is_enabled($email_type)) { |
|
382 | 382 | return false; |
383 | 383 | } |
384 | 384 | |
385 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
386 | - if ( empty( $invoice ) ) { |
|
385 | + $invoice = wpinv_get_invoice($invoice_id); |
|
386 | + if (empty($invoice)) { |
|
387 | 387 | return false; |
388 | 388 | } |
389 | 389 | |
390 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
390 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
391 | 391 | return false; |
392 | 392 | } |
393 | 393 | |
394 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
395 | - if ( !is_email( $recipient ) ) { |
|
394 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
395 | + if (!is_email($recipient)) { |
|
396 | 396 | return false; |
397 | 397 | } |
398 | 398 | |
399 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
399 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
400 | 400 | |
401 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
402 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
403 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
404 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
405 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
401 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
402 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
403 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
404 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
405 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
406 | 406 | |
407 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
407 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
408 | 408 | 'invoice' => $invoice, |
409 | 409 | 'email_type' => $email_type, |
410 | 410 | 'email_heading' => $email_heading, |
@@ -412,50 +412,50 @@ discard block |
||
412 | 412 | 'plain_text' => false, |
413 | 413 | 'partial_refund' => false, |
414 | 414 | 'message_body' => $message_body, |
415 | - ) ); |
|
415 | + )); |
|
416 | 416 | |
417 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
417 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
418 | 418 | |
419 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
420 | - $recipient = wpinv_get_admin_email(); |
|
421 | - $subject .= ' - ADMIN BCC COPY'; |
|
422 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
419 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
420 | + $recipient = wpinv_get_admin_email(); |
|
421 | + $subject .= ' - ADMIN BCC COPY'; |
|
422 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
423 | 423 | } |
424 | 424 | |
425 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
425 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
426 | 426 | |
427 | 427 | return $sent; |
428 | 428 | } |
429 | 429 | |
430 | -function wpinv_partially_refunded_notification( $invoice_id, $new_status = '' ) { |
|
430 | +function wpinv_partially_refunded_notification($invoice_id, $new_status = '') { |
|
431 | 431 | $email_type = 'refunded_invoice'; |
432 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
432 | + if (!wpinv_email_is_enabled($email_type)) { |
|
433 | 433 | return false; |
434 | 434 | } |
435 | 435 | |
436 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
437 | - if ( empty( $invoice ) ) { |
|
436 | + $invoice = wpinv_get_invoice($invoice_id); |
|
437 | + if (empty($invoice)) { |
|
438 | 438 | return false; |
439 | 439 | } |
440 | 440 | |
441 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
441 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
442 | 442 | return false; |
443 | 443 | } |
444 | 444 | |
445 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
446 | - if ( !is_email( $recipient ) ) { |
|
445 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
446 | + if (!is_email($recipient)) { |
|
447 | 447 | return false; |
448 | 448 | } |
449 | 449 | |
450 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
450 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
451 | 451 | |
452 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
453 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
454 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
455 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
456 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
452 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
453 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
454 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
455 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
456 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
457 | 457 | |
458 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
458 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
459 | 459 | 'invoice' => $invoice, |
460 | 460 | 'email_type' => $email_type, |
461 | 461 | 'email_heading' => $email_heading, |
@@ -463,95 +463,95 @@ discard block |
||
463 | 463 | 'plain_text' => false, |
464 | 464 | 'partial_refund' => true, |
465 | 465 | 'message_body' => $message_body, |
466 | - ) ); |
|
466 | + )); |
|
467 | 467 | |
468 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
468 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
469 | 469 | |
470 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
471 | - $recipient = wpinv_get_admin_email(); |
|
472 | - $subject .= ' - ADMIN BCC COPY'; |
|
473 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
470 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
471 | + $recipient = wpinv_get_admin_email(); |
|
472 | + $subject .= ' - ADMIN BCC COPY'; |
|
473 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
474 | 474 | } |
475 | 475 | |
476 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
476 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
477 | 477 | |
478 | 478 | return $sent; |
479 | 479 | } |
480 | 480 | |
481 | -function wpinv_new_invoice_note_notification( $invoice_id, $new_status = '' ) { |
|
481 | +function wpinv_new_invoice_note_notification($invoice_id, $new_status = '') { |
|
482 | 482 | } |
483 | 483 | |
484 | -function wpinv_user_invoice_notification( $invoice_id ) { |
|
484 | +function wpinv_user_invoice_notification($invoice_id) { |
|
485 | 485 | $email_type = 'user_invoice'; |
486 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
486 | + if (!wpinv_email_is_enabled($email_type)) { |
|
487 | 487 | return -1; |
488 | 488 | } |
489 | 489 | |
490 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
491 | - if ( empty( $invoice ) ) { |
|
490 | + $invoice = wpinv_get_invoice($invoice_id); |
|
491 | + if (empty($invoice)) { |
|
492 | 492 | return false; |
493 | 493 | } |
494 | 494 | |
495 | - if ( !("wpi_invoice" === $invoice->post_type) ) { |
|
495 | + if (!("wpi_invoice" === $invoice->post_type)) { |
|
496 | 496 | return false; |
497 | 497 | } |
498 | 498 | |
499 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
500 | - if ( !is_email( $recipient ) ) { |
|
499 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
500 | + if (!is_email($recipient)) { |
|
501 | 501 | return false; |
502 | 502 | } |
503 | 503 | |
504 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
504 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
505 | 505 | |
506 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
507 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
508 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
509 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
510 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
506 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
507 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
508 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
509 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
510 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
511 | 511 | |
512 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
512 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
513 | 513 | 'invoice' => $invoice, |
514 | 514 | 'email_type' => $email_type, |
515 | 515 | 'email_heading' => $email_heading, |
516 | 516 | 'sent_to_admin' => false, |
517 | 517 | 'plain_text' => false, |
518 | 518 | 'message_body' => $message_body, |
519 | - ) ); |
|
519 | + )); |
|
520 | 520 | |
521 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
521 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
522 | 522 | |
523 | - if ( wpinv_mail_admin_bcc_active( $email_type ) ) { |
|
524 | - $recipient = wpinv_get_admin_email(); |
|
525 | - $subject .= ' - ADMIN BCC COPY'; |
|
526 | - wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
523 | + if (wpinv_mail_admin_bcc_active($email_type)) { |
|
524 | + $recipient = wpinv_get_admin_email(); |
|
525 | + $subject .= ' - ADMIN BCC COPY'; |
|
526 | + wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
527 | 527 | } |
528 | 528 | |
529 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
529 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
530 | 530 | |
531 | - if ( $sent ) { |
|
532 | - $note = __( 'Invoice has been emailed to the user.', 'invoicing' ); |
|
531 | + if ($sent) { |
|
532 | + $note = __('Invoice has been emailed to the user.', 'invoicing'); |
|
533 | 533 | } else { |
534 | - $note = __( 'Fail to send invoice to the user!', 'invoicing' ); |
|
534 | + $note = __('Fail to send invoice to the user!', 'invoicing'); |
|
535 | 535 | } |
536 | 536 | |
537 | - $invoice->add_note( $note, '', '', true ); // Add system note. |
|
537 | + $invoice->add_note($note, '', '', true); // Add system note. |
|
538 | 538 | |
539 | 539 | return $sent; |
540 | 540 | } |
541 | 541 | |
542 | -function wpinv_user_note_notification( $invoice_id, $args = array() ) { |
|
542 | +function wpinv_user_note_notification($invoice_id, $args = array()) { |
|
543 | 543 | $email_type = 'user_note'; |
544 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
544 | + if (!wpinv_email_is_enabled($email_type)) { |
|
545 | 545 | return false; |
546 | 546 | } |
547 | 547 | |
548 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
549 | - if ( empty( $invoice ) ) { |
|
548 | + $invoice = wpinv_get_invoice($invoice_id); |
|
549 | + if (empty($invoice)) { |
|
550 | 550 | return false; |
551 | 551 | } |
552 | 552 | |
553 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
554 | - if ( !is_email( $recipient ) ) { |
|
553 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
554 | + if (!is_email($recipient)) { |
|
555 | 555 | return false; |
556 | 556 | } |
557 | 557 | |
@@ -559,19 +559,19 @@ discard block |
||
559 | 559 | 'user_note' => '' |
560 | 560 | ); |
561 | 561 | |
562 | - $args = wp_parse_args( $args, $defaults ); |
|
562 | + $args = wp_parse_args($args, $defaults); |
|
563 | 563 | |
564 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
564 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
565 | 565 | |
566 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
567 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
568 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
569 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
570 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
566 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
567 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
568 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
569 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
570 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
571 | 571 | |
572 | - $message_body = str_replace( '{customer_note}', $args['user_note'], $message_body ); |
|
572 | + $message_body = str_replace('{customer_note}', $args['user_note'], $message_body); |
|
573 | 573 | |
574 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
574 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
575 | 575 | 'invoice' => $invoice, |
576 | 576 | 'email_type' => $email_type, |
577 | 577 | 'email_heading' => $email_heading, |
@@ -579,36 +579,36 @@ discard block |
||
579 | 579 | 'plain_text' => false, |
580 | 580 | 'message_body' => $message_body, |
581 | 581 | 'customer_note' => $args['user_note'] |
582 | - ) ); |
|
582 | + )); |
|
583 | 583 | |
584 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
584 | + $content = wpinv_email_format_text($content, $invoice); |
|
585 | 585 | |
586 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
586 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
587 | 587 | |
588 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
588 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
589 | 589 | |
590 | 590 | return $sent; |
591 | 591 | } |
592 | 592 | |
593 | 593 | function wpinv_mail_get_from_address() { |
594 | - $from_address = apply_filters( 'wpinv_mail_from_address', wpinv_get_option( 'email_from' ) ); |
|
595 | - return sanitize_email( $from_address ); |
|
594 | + $from_address = apply_filters('wpinv_mail_from_address', wpinv_get_option('email_from')); |
|
595 | + return sanitize_email($from_address); |
|
596 | 596 | } |
597 | 597 | |
598 | 598 | function wpinv_mail_get_from_name() { |
599 | - $from_name = apply_filters( 'wpinv_mail_from_name', wpinv_get_option( 'email_from_name' ) ); |
|
600 | - return wp_specialchars_decode( esc_html( $from_name ), ENT_QUOTES ); |
|
599 | + $from_name = apply_filters('wpinv_mail_from_name', wpinv_get_option('email_from_name')); |
|
600 | + return wp_specialchars_decode(esc_html($from_name), ENT_QUOTES); |
|
601 | 601 | } |
602 | 602 | |
603 | -function wpinv_mail_admin_bcc_active( $mail_type = '' ) { |
|
604 | - $active = apply_filters( 'wpinv_mail_admin_bcc_active', wpinv_get_option( 'email_' . $mail_type . '_admin_bcc' ) ); |
|
605 | - return ( $active ? true : false ); |
|
603 | +function wpinv_mail_admin_bcc_active($mail_type = '') { |
|
604 | + $active = apply_filters('wpinv_mail_admin_bcc_active', wpinv_get_option('email_' . $mail_type . '_admin_bcc')); |
|
605 | + return ($active ? true : false); |
|
606 | 606 | } |
607 | 607 | |
608 | -function wpinv_mail_get_content_type( $content_type = 'text/html', $email_type = 'html' ) { |
|
609 | - $email_type = apply_filters( 'wpinv_mail_content_type', $email_type ); |
|
608 | +function wpinv_mail_get_content_type($content_type = 'text/html', $email_type = 'html') { |
|
609 | + $email_type = apply_filters('wpinv_mail_content_type', $email_type); |
|
610 | 610 | |
611 | - switch ( $email_type ) { |
|
611 | + switch ($email_type) { |
|
612 | 612 | case 'html' : |
613 | 613 | $content_type = 'text/html'; |
614 | 614 | break; |
@@ -623,35 +623,35 @@ discard block |
||
623 | 623 | return $content_type; |
624 | 624 | } |
625 | 625 | |
626 | -function wpinv_mail_send( $to, $subject, $message, $headers, $attachments ) { |
|
627 | - add_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
628 | - add_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
629 | - add_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
626 | +function wpinv_mail_send($to, $subject, $message, $headers, $attachments) { |
|
627 | + add_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
628 | + add_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
629 | + add_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
630 | 630 | |
631 | - $message = wpinv_email_style_body( $message ); |
|
632 | - $message = apply_filters( 'wpinv_mail_content', $message ); |
|
631 | + $message = wpinv_email_style_body($message); |
|
632 | + $message = apply_filters('wpinv_mail_content', $message); |
|
633 | 633 | |
634 | - $sent = wp_mail( $to, $subject, $message, $headers, $attachments ); |
|
634 | + $sent = wp_mail($to, $subject, $message, $headers, $attachments); |
|
635 | 635 | |
636 | - if ( !$sent ) { |
|
637 | - $log_message = wp_sprintf( __( "\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), ( is_array( $to ) ? implode( ', ', $to ) : $to ), $subject ); |
|
638 | - wpinv_error_log( $log_message, __( "Email from Invoicing plugin failed to send", 'invoicing' ), __FILE__, __LINE__ ); |
|
636 | + if (!$sent) { |
|
637 | + $log_message = wp_sprintf(__("\nTime: %s\nTo: %s\nSubject: %s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), (is_array($to) ? implode(', ', $to) : $to), $subject); |
|
638 | + wpinv_error_log($log_message, __("Email from Invoicing plugin failed to send", 'invoicing'), __FILE__, __LINE__); |
|
639 | 639 | } |
640 | 640 | |
641 | - remove_filter( 'wp_mail_from', 'wpinv_mail_get_from_address' ); |
|
642 | - remove_filter( 'wp_mail_from_name', 'wpinv_mail_get_from_name' ); |
|
643 | - remove_filter( 'wp_mail_content_type', 'wpinv_mail_get_content_type' ); |
|
641 | + remove_filter('wp_mail_from', 'wpinv_mail_get_from_address'); |
|
642 | + remove_filter('wp_mail_from_name', 'wpinv_mail_get_from_name'); |
|
643 | + remove_filter('wp_mail_content_type', 'wpinv_mail_get_content_type'); |
|
644 | 644 | |
645 | 645 | return $sent; |
646 | 646 | } |
647 | 647 | |
648 | 648 | function wpinv_get_emails() { |
649 | 649 | $overdue_days_options = array(); |
650 | - $overdue_days_options[0] = __( 'On the Due Date', 'invoicing' ); |
|
651 | - $overdue_days_options[1] = __( '1 day after Due Date', 'invoicing' ); |
|
650 | + $overdue_days_options[0] = __('On the Due Date', 'invoicing'); |
|
651 | + $overdue_days_options[1] = __('1 day after Due Date', 'invoicing'); |
|
652 | 652 | |
653 | - for ( $i = 2; $i <= 10; $i++ ) { |
|
654 | - $overdue_days_options[$i] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
653 | + for ($i = 2; $i <= 10; $i++) { |
|
654 | + $overdue_days_options[$i] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | // Default, built-in gateways |
@@ -659,39 +659,39 @@ discard block |
||
659 | 659 | 'new_invoice' => array( |
660 | 660 | 'email_new_invoice_header' => array( |
661 | 661 | 'id' => 'email_new_invoice_header', |
662 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
663 | - 'desc' => __( 'New invoice emails are sent to admin when a new invoice is received.', 'invoicing' ), |
|
662 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
663 | + 'desc' => __('New invoice emails are sent to admin when a new invoice is received.', 'invoicing'), |
|
664 | 664 | 'type' => 'header', |
665 | 665 | ), |
666 | 666 | 'email_new_invoice_active' => array( |
667 | 667 | 'id' => 'email_new_invoice_active', |
668 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
669 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
668 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
669 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
670 | 670 | 'type' => 'checkbox', |
671 | 671 | 'std' => 1 |
672 | 672 | ), |
673 | 673 | 'email_new_invoice_subject' => array( |
674 | 674 | 'id' => 'email_new_invoice_subject', |
675 | - 'name' => __( 'Subject', 'invoicing' ), |
|
676 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
675 | + 'name' => __('Subject', 'invoicing'), |
|
676 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
677 | 677 | 'type' => 'text', |
678 | - 'std' => __( '[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing' ), |
|
678 | + 'std' => __('[{site_title}] New payment invoice ({invoice_number}) - {invoice_date}', 'invoicing'), |
|
679 | 679 | 'size' => 'large' |
680 | 680 | ), |
681 | 681 | 'email_new_invoice_heading' => array( |
682 | 682 | 'id' => 'email_new_invoice_heading', |
683 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
684 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
683 | + 'name' => __('Email Heading', 'invoicing'), |
|
684 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
685 | 685 | 'type' => 'text', |
686 | - 'std' => __( 'New payment invoice', 'invoicing' ), |
|
686 | + 'std' => __('New payment invoice', 'invoicing'), |
|
687 | 687 | 'size' => 'large' |
688 | 688 | ), |
689 | 689 | 'email_new_invoice_body' => array( |
690 | 690 | 'id' => 'email_new_invoice_body', |
691 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
692 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
691 | + 'name' => __('Email Content', 'invoicing'), |
|
692 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
693 | 693 | 'type' => 'rich_editor', |
694 | - 'std' => __( '<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing' ), |
|
694 | + 'std' => __('<p>Hi Admin,</p><p>You have received payment invoice from {name}.</p>', 'invoicing'), |
|
695 | 695 | 'class' => 'large', |
696 | 696 | 'size' => '10' |
697 | 697 | ), |
@@ -699,39 +699,39 @@ discard block |
||
699 | 699 | 'cancelled_invoice' => array( |
700 | 700 | 'email_cancelled_invoice_header' => array( |
701 | 701 | 'id' => 'email_cancelled_invoice_header', |
702 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
703 | - 'desc' => __( 'Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing' ), |
|
702 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
703 | + 'desc' => __('Cancelled invoice emails are sent to admin when invoices have been marked cancelled.', 'invoicing'), |
|
704 | 704 | 'type' => 'header', |
705 | 705 | ), |
706 | 706 | 'email_cancelled_invoice_active' => array( |
707 | 707 | 'id' => 'email_cancelled_invoice_active', |
708 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
709 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
708 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
709 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
710 | 710 | 'type' => 'checkbox', |
711 | 711 | 'std' => 1 |
712 | 712 | ), |
713 | 713 | 'email_cancelled_invoice_subject' => array( |
714 | 714 | 'id' => 'email_cancelled_invoice_subject', |
715 | - 'name' => __( 'Subject', 'invoicing' ), |
|
716 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
715 | + 'name' => __('Subject', 'invoicing'), |
|
716 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
717 | 717 | 'type' => 'text', |
718 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
718 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
719 | 719 | 'size' => 'large' |
720 | 720 | ), |
721 | 721 | 'email_cancelled_invoice_heading' => array( |
722 | 722 | 'id' => 'email_cancelled_invoice_heading', |
723 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
724 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
723 | + 'name' => __('Email Heading', 'invoicing'), |
|
724 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
725 | 725 | 'type' => 'text', |
726 | - 'std' => __( 'Cancelled invoice', 'invoicing' ), |
|
726 | + 'std' => __('Cancelled invoice', 'invoicing'), |
|
727 | 727 | 'size' => 'large' |
728 | 728 | ), |
729 | 729 | 'email_cancelled_invoice_body' => array( |
730 | 730 | 'id' => 'email_cancelled_invoice_body', |
731 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
732 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
731 | + 'name' => __('Email Content', 'invoicing'), |
|
732 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
733 | 733 | 'type' => 'rich_editor', |
734 | - 'std' => __( '<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing' ), |
|
734 | + 'std' => __('<p>Hi Admin,</p><p>The invoice #{invoice_number} from {site_title} has been cancelled.</p>', 'invoicing'), |
|
735 | 735 | 'class' => 'large', |
736 | 736 | 'size' => '10' |
737 | 737 | ), |
@@ -739,39 +739,39 @@ discard block |
||
739 | 739 | 'failed_invoice' => array( |
740 | 740 | 'email_failed_invoice_header' => array( |
741 | 741 | 'id' => 'email_failed_invoice_header', |
742 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
743 | - 'desc' => __( 'Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing' ), |
|
742 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
743 | + 'desc' => __('Failed invoice emails are sent to admin when invoices have been marked failed (if they were previously processing or on-hold).', 'invoicing'), |
|
744 | 744 | 'type' => 'header', |
745 | 745 | ), |
746 | 746 | 'email_failed_invoice_active' => array( |
747 | 747 | 'id' => 'email_failed_invoice_active', |
748 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
749 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
748 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
749 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
750 | 750 | 'type' => 'checkbox', |
751 | 751 | 'std' => 1 |
752 | 752 | ), |
753 | 753 | 'email_failed_invoice_subject' => array( |
754 | 754 | 'id' => 'email_failed_invoice_subject', |
755 | - 'name' => __( 'Subject', 'invoicing' ), |
|
756 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
755 | + 'name' => __('Subject', 'invoicing'), |
|
756 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
757 | 757 | 'type' => 'text', |
758 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
758 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
759 | 759 | 'size' => 'large' |
760 | 760 | ), |
761 | 761 | 'email_failed_invoice_heading' => array( |
762 | 762 | 'id' => 'email_failed_invoice_heading', |
763 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
764 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
763 | + 'name' => __('Email Heading', 'invoicing'), |
|
764 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
765 | 765 | 'type' => 'text', |
766 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
766 | + 'std' => __('Failed invoice', 'invoicing'), |
|
767 | 767 | 'size' => 'large' |
768 | 768 | ), |
769 | 769 | 'email_failed_invoice_body' => array( |
770 | 770 | 'id' => 'email_failed_invoice_body', |
771 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
772 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
771 | + 'name' => __('Email Content', 'invoicing'), |
|
772 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
773 | 773 | 'type' => 'rich_editor', |
774 | - 'std' => __( '<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing' ), |
|
774 | + 'std' => __('<p>Hi Admin,</p><p>Payment for invoice #{invoice_number} from {site_title} has been failed.</p>', 'invoicing'), |
|
775 | 775 | 'class' => 'large', |
776 | 776 | 'size' => '10' |
777 | 777 | ), |
@@ -779,46 +779,46 @@ discard block |
||
779 | 779 | 'onhold_invoice' => array( |
780 | 780 | 'email_onhold_invoice_header' => array( |
781 | 781 | 'id' => 'email_onhold_invoice_header', |
782 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
783 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing' ), |
|
782 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
783 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after an invoice is placed on-hold.', 'invoicing'), |
|
784 | 784 | 'type' => 'header', |
785 | 785 | ), |
786 | 786 | 'email_onhold_invoice_active' => array( |
787 | 787 | 'id' => 'email_onhold_invoice_active', |
788 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
789 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
788 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
789 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
790 | 790 | 'type' => 'checkbox', |
791 | 791 | 'std' => 1 |
792 | 792 | ), |
793 | 793 | 'email_onhold_invoice_subject' => array( |
794 | 794 | 'id' => 'email_onhold_invoice_subject', |
795 | - 'name' => __( 'Subject', 'invoicing' ), |
|
796 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
795 | + 'name' => __('Subject', 'invoicing'), |
|
796 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
797 | 797 | 'type' => 'text', |
798 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
798 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
799 | 799 | 'size' => 'large' |
800 | 800 | ), |
801 | 801 | 'email_onhold_invoice_heading' => array( |
802 | 802 | 'id' => 'email_onhold_invoice_heading', |
803 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
804 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
803 | + 'name' => __('Email Heading', 'invoicing'), |
|
804 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
805 | 805 | 'type' => 'text', |
806 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
806 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
807 | 807 | 'size' => 'large' |
808 | 808 | ), |
809 | 809 | 'email_onhold_invoice_admin_bcc' => array( |
810 | 810 | 'id' => 'email_onhold_invoice_admin_bcc', |
811 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
812 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
811 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
812 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
813 | 813 | 'type' => 'checkbox', |
814 | 814 | 'std' => 1 |
815 | 815 | ), |
816 | 816 | 'email_onhold_invoice_body' => array( |
817 | 817 | 'id' => 'email_onhold_invoice_body', |
818 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
819 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
818 | + 'name' => __('Email Content', 'invoicing'), |
|
819 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
820 | 820 | 'type' => 'rich_editor', |
821 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing' ), |
|
821 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold until we confirm your payment has been received.</p>', 'invoicing'), |
|
822 | 822 | 'class' => 'large', |
823 | 823 | 'size' => '10' |
824 | 824 | ), |
@@ -826,46 +826,46 @@ discard block |
||
826 | 826 | 'processing_invoice' => array( |
827 | 827 | 'email_processing_invoice_header' => array( |
828 | 828 | 'id' => 'email_processing_invoice_header', |
829 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
830 | - 'desc' => __( 'This is an invoice notification sent to users containing invoice details after payment.', 'invoicing' ), |
|
829 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
830 | + 'desc' => __('This is an invoice notification sent to users containing invoice details after payment.', 'invoicing'), |
|
831 | 831 | 'type' => 'header', |
832 | 832 | ), |
833 | 833 | 'email_processing_invoice_active' => array( |
834 | 834 | 'id' => 'email_processing_invoice_active', |
835 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
836 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
835 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
836 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
837 | 837 | 'type' => 'checkbox', |
838 | 838 | 'std' => 1 |
839 | 839 | ), |
840 | 840 | 'email_processing_invoice_subject' => array( |
841 | 841 | 'id' => 'email_processing_invoice_subject', |
842 | - 'name' => __( 'Subject', 'invoicing' ), |
|
843 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
842 | + 'name' => __('Subject', 'invoicing'), |
|
843 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
844 | 844 | 'type' => 'text', |
845 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
845 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
846 | 846 | 'size' => 'large' |
847 | 847 | ), |
848 | 848 | 'email_processing_invoice_heading' => array( |
849 | 849 | 'id' => 'email_processing_invoice_heading', |
850 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
851 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
850 | + 'name' => __('Email Heading', 'invoicing'), |
|
851 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
852 | 852 | 'type' => 'text', |
853 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
853 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
854 | 854 | 'size' => 'large' |
855 | 855 | ), |
856 | 856 | 'email_processing_invoice_admin_bcc' => array( |
857 | 857 | 'id' => 'email_processing_invoice_admin_bcc', |
858 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
859 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
858 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
859 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
860 | 860 | 'type' => 'checkbox', |
861 | 861 | 'std' => 1 |
862 | 862 | ), |
863 | 863 | 'email_processing_invoice_body' => array( |
864 | 864 | 'id' => 'email_processing_invoice_body', |
865 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
866 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
865 | + 'name' => __('Email Content', 'invoicing'), |
|
866 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
867 | 867 | 'type' => 'rich_editor', |
868 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing' ), |
|
868 | + 'std' => __('<p>Hi {name},</p><p>Your invoice has been received at {site_title} and is now being processed.</p>', 'invoicing'), |
|
869 | 869 | 'class' => 'large', |
870 | 870 | 'size' => '10' |
871 | 871 | ), |
@@ -873,52 +873,52 @@ discard block |
||
873 | 873 | 'completed_invoice' => array( |
874 | 874 | 'email_completed_invoice_header' => array( |
875 | 875 | 'id' => 'email_completed_invoice_header', |
876 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
877 | - 'desc' => __( 'Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing' ), |
|
876 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
877 | + 'desc' => __('Invoice paid emails are sent to users when their invoices are marked paid and usually indicate that their payment has been done.', 'invoicing'), |
|
878 | 878 | 'type' => 'header', |
879 | 879 | ), |
880 | 880 | 'email_completed_invoice_active' => array( |
881 | 881 | 'id' => 'email_completed_invoice_active', |
882 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
883 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
882 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
883 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
884 | 884 | 'type' => 'checkbox', |
885 | 885 | 'std' => 1 |
886 | 886 | ), |
887 | 887 | 'email_completed_invoice_renewal_active' => array( |
888 | 888 | 'id' => 'email_completed_invoice_renewal_active', |
889 | - 'name' => __( 'Enable renewal notification', 'invoicing' ), |
|
890 | - 'desc' => __( 'Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing' ), |
|
889 | + 'name' => __('Enable renewal notification', 'invoicing'), |
|
890 | + 'desc' => __('Enable renewal invoice email notification. This notification will be sent on renewal.', 'invoicing'), |
|
891 | 891 | 'type' => 'checkbox', |
892 | 892 | 'std' => 0 |
893 | 893 | ), |
894 | 894 | 'email_completed_invoice_subject' => array( |
895 | 895 | 'id' => 'email_completed_invoice_subject', |
896 | - 'name' => __( 'Subject', 'invoicing' ), |
|
897 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
896 | + 'name' => __('Subject', 'invoicing'), |
|
897 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
898 | 898 | 'type' => 'text', |
899 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
899 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
900 | 900 | 'size' => 'large' |
901 | 901 | ), |
902 | 902 | 'email_completed_invoice_heading' => array( |
903 | 903 | 'id' => 'email_completed_invoice_heading', |
904 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
905 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
904 | + 'name' => __('Email Heading', 'invoicing'), |
|
905 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
906 | 906 | 'type' => 'text', |
907 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
907 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
908 | 908 | 'size' => 'large' |
909 | 909 | ), |
910 | 910 | 'email_completed_invoice_admin_bcc' => array( |
911 | 911 | 'id' => 'email_completed_invoice_admin_bcc', |
912 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
913 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
912 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
913 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
914 | 914 | 'type' => 'checkbox', |
915 | 915 | ), |
916 | 916 | 'email_completed_invoice_body' => array( |
917 | 917 | 'id' => 'email_completed_invoice_body', |
918 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
919 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
918 | + 'name' => __('Email Content', 'invoicing'), |
|
919 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
920 | 920 | 'type' => 'rich_editor', |
921 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ), |
|
921 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'), |
|
922 | 922 | 'class' => 'large', |
923 | 923 | 'size' => '10' |
924 | 924 | ), |
@@ -927,46 +927,46 @@ discard block |
||
927 | 927 | 'refunded_invoice' => array( |
928 | 928 | 'email_refunded_invoice_header' => array( |
929 | 929 | 'id' => 'email_refunded_invoice_header', |
930 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
931 | - 'desc' => __( 'Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing' ), |
|
930 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
931 | + 'desc' => __('Invoice refunded emails are sent to users when their invoices are marked refunded.', 'invoicing'), |
|
932 | 932 | 'type' => 'header', |
933 | 933 | ), |
934 | 934 | 'email_refunded_invoice_active' => array( |
935 | 935 | 'id' => 'email_refunded_invoice_active', |
936 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
937 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
936 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
937 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
938 | 938 | 'type' => 'checkbox', |
939 | 939 | 'std' => 1 |
940 | 940 | ), |
941 | 941 | 'email_refunded_invoice_subject' => array( |
942 | 942 | 'id' => 'email_refunded_invoice_subject', |
943 | - 'name' => __( 'Subject', 'invoicing' ), |
|
944 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
943 | + 'name' => __('Subject', 'invoicing'), |
|
944 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
945 | 945 | 'type' => 'text', |
946 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
946 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
947 | 947 | 'size' => 'large' |
948 | 948 | ), |
949 | 949 | 'email_refunded_invoice_heading' => array( |
950 | 950 | 'id' => 'email_refunded_invoice_heading', |
951 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
952 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
951 | + 'name' => __('Email Heading', 'invoicing'), |
|
952 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
953 | 953 | 'type' => 'text', |
954 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
954 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
955 | 955 | 'size' => 'large' |
956 | 956 | ), |
957 | 957 | 'email_refunded_invoice_admin_bcc' => array( |
958 | 958 | 'id' => 'email_refunded_invoice_admin_bcc', |
959 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
960 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
959 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
960 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
961 | 961 | 'type' => 'checkbox', |
962 | 962 | 'std' => 1 |
963 | 963 | ), |
964 | 964 | 'email_refunded_invoice_body' => array( |
965 | 965 | 'id' => 'email_refunded_invoice_body', |
966 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
967 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
966 | + 'name' => __('Email Content', 'invoicing'), |
|
967 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
968 | 968 | 'type' => 'rich_editor', |
969 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
969 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
970 | 970 | 'class' => 'large', |
971 | 971 | 'size' => '10' |
972 | 972 | ), |
@@ -974,46 +974,46 @@ discard block |
||
974 | 974 | 'user_invoice' => array( |
975 | 975 | 'email_user_invoice_header' => array( |
976 | 976 | 'id' => 'email_user_invoice_header', |
977 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
978 | - 'desc' => __( 'Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
977 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
978 | + 'desc' => __('Customer invoice emails can be sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
979 | 979 | 'type' => 'header', |
980 | 980 | ), |
981 | 981 | 'email_user_invoice_active' => array( |
982 | 982 | 'id' => 'email_user_invoice_active', |
983 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
984 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
983 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
984 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
985 | 985 | 'type' => 'checkbox', |
986 | 986 | 'std' => 1 |
987 | 987 | ), |
988 | 988 | 'email_user_invoice_subject' => array( |
989 | 989 | 'id' => 'email_user_invoice_subject', |
990 | - 'name' => __( 'Subject', 'invoicing' ), |
|
991 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
990 | + 'name' => __('Subject', 'invoicing'), |
|
991 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
992 | 992 | 'type' => 'text', |
993 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
993 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
994 | 994 | 'size' => 'large' |
995 | 995 | ), |
996 | 996 | 'email_user_invoice_heading' => array( |
997 | 997 | 'id' => 'email_user_invoice_heading', |
998 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
999 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
998 | + 'name' => __('Email Heading', 'invoicing'), |
|
999 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
1000 | 1000 | 'type' => 'text', |
1001 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
1001 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
1002 | 1002 | 'size' => 'large' |
1003 | 1003 | ), |
1004 | 1004 | 'email_user_invoice_admin_bcc' => array( |
1005 | 1005 | 'id' => 'email_user_invoice_admin_bcc', |
1006 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
1007 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
1006 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
1007 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
1008 | 1008 | 'type' => 'checkbox', |
1009 | 1009 | 'std' => 1 |
1010 | 1010 | ), |
1011 | 1011 | 'email_user_invoice_body' => array( |
1012 | 1012 | 'id' => 'email_user_invoice_body', |
1013 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1014 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
1013 | + 'name' => __('Email Content', 'invoicing'), |
|
1014 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
1015 | 1015 | 'type' => 'rich_editor', |
1016 | - 'std' => __( '<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
1016 | + 'std' => __('<p>Hi {name},</p><p>An invoice has been created for you on {site_title}. To view / pay for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
1017 | 1017 | 'class' => 'large', |
1018 | 1018 | 'size' => '10' |
1019 | 1019 | ), |
@@ -1021,39 +1021,39 @@ discard block |
||
1021 | 1021 | 'user_note' => array( |
1022 | 1022 | 'email_user_note_header' => array( |
1023 | 1023 | 'id' => 'email_user_note_header', |
1024 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
1025 | - 'desc' => __( 'Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing' ), |
|
1024 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
1025 | + 'desc' => __('Customer note emails are sent when you add a note to an invoice/quote.', 'invoicing'), |
|
1026 | 1026 | 'type' => 'header', |
1027 | 1027 | ), |
1028 | 1028 | 'email_user_note_active' => array( |
1029 | 1029 | 'id' => 'email_user_note_active', |
1030 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1031 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1030 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1031 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1032 | 1032 | 'type' => 'checkbox', |
1033 | 1033 | 'std' => 1 |
1034 | 1034 | ), |
1035 | 1035 | 'email_user_note_subject' => array( |
1036 | 1036 | 'id' => 'email_user_note_subject', |
1037 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1038 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1037 | + 'name' => __('Subject', 'invoicing'), |
|
1038 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1039 | 1039 | 'type' => 'text', |
1040 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
1040 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
1041 | 1041 | 'size' => 'large' |
1042 | 1042 | ), |
1043 | 1043 | 'email_user_note_heading' => array( |
1044 | 1044 | 'id' => 'email_user_note_heading', |
1045 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1046 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1045 | + 'name' => __('Email Heading', 'invoicing'), |
|
1046 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1047 | 1047 | 'type' => 'text', |
1048 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
1048 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
1049 | 1049 | 'size' => 'large' |
1050 | 1050 | ), |
1051 | 1051 | 'email_user_note_body' => array( |
1052 | 1052 | 'id' => 'email_user_note_body', |
1053 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1054 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
1053 | + 'name' => __('Email Content', 'invoicing'), |
|
1054 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
1055 | 1055 | 'type' => 'rich_editor', |
1056 | - 'std' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
1056 | + 'std' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
1057 | 1057 | 'class' => 'large', |
1058 | 1058 | 'size' => '10' |
1059 | 1059 | ), |
@@ -1061,158 +1061,158 @@ discard block |
||
1061 | 1061 | 'overdue' => array( |
1062 | 1062 | 'email_overdue_header' => array( |
1063 | 1063 | 'id' => 'email_overdue_header', |
1064 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
1065 | - 'desc' => __( 'Payment reminder emails are sent to user automatically.', 'invoicing' ), |
|
1064 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
1065 | + 'desc' => __('Payment reminder emails are sent to user automatically.', 'invoicing'), |
|
1066 | 1066 | 'type' => 'header', |
1067 | 1067 | ), |
1068 | 1068 | 'email_overdue_active' => array( |
1069 | 1069 | 'id' => 'email_overdue_active', |
1070 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
1071 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
1070 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
1071 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
1072 | 1072 | 'type' => 'checkbox', |
1073 | 1073 | 'std' => 1 |
1074 | 1074 | ), |
1075 | 1075 | 'email_due_reminder_days' => array( |
1076 | 1076 | 'id' => 'email_due_reminder_days', |
1077 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
1078 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
1077 | + 'name' => __('When to Send', 'invoicing'), |
|
1078 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
1079 | 1079 | 'default' => '', |
1080 | 1080 | 'type' => 'multicheck', |
1081 | 1081 | 'options' => $overdue_days_options, |
1082 | 1082 | ), |
1083 | 1083 | 'email_overdue_subject' => array( |
1084 | 1084 | 'id' => 'email_overdue_subject', |
1085 | - 'name' => __( 'Subject', 'invoicing' ), |
|
1086 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
1085 | + 'name' => __('Subject', 'invoicing'), |
|
1086 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
1087 | 1087 | 'type' => 'text', |
1088 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
1088 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
1089 | 1089 | 'size' => 'large' |
1090 | 1090 | ), |
1091 | 1091 | 'email_overdue_heading' => array( |
1092 | 1092 | 'id' => 'email_overdue_heading', |
1093 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
1094 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
1093 | + 'name' => __('Email Heading', 'invoicing'), |
|
1094 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
1095 | 1095 | 'type' => 'text', |
1096 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
1096 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
1097 | 1097 | 'size' => 'large' |
1098 | 1098 | ), |
1099 | 1099 | 'email_overdue_body' => array( |
1100 | 1100 | 'id' => 'email_overdue_body', |
1101 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
1102 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
1101 | + 'name' => __('Email Content', 'invoicing'), |
|
1102 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
1103 | 1103 | 'type' => 'rich_editor', |
1104 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
1104 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
1105 | 1105 | 'class' => 'large', |
1106 | 1106 | 'size' => 10, |
1107 | 1107 | ), |
1108 | 1108 | ), |
1109 | 1109 | ); |
1110 | 1110 | |
1111 | - return apply_filters( 'wpinv_get_emails', $emails ); |
|
1111 | + return apply_filters('wpinv_get_emails', $emails); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | -function wpinv_settings_emails( $settings = array() ) { |
|
1114 | +function wpinv_settings_emails($settings = array()) { |
|
1115 | 1115 | $emails = wpinv_get_emails(); |
1116 | 1116 | |
1117 | - if ( !empty( $emails ) ) { |
|
1118 | - foreach ( $emails as $key => $email ) { |
|
1117 | + if (!empty($emails)) { |
|
1118 | + foreach ($emails as $key => $email) { |
|
1119 | 1119 | $settings[$key] = $email; |
1120 | 1120 | } |
1121 | 1121 | } |
1122 | 1122 | |
1123 | - return apply_filters( 'wpinv_settings_get_emails', $settings ); |
|
1123 | + return apply_filters('wpinv_settings_get_emails', $settings); |
|
1124 | 1124 | } |
1125 | -add_filter( 'wpinv_settings_emails', 'wpinv_settings_emails', 10, 1 ); |
|
1125 | +add_filter('wpinv_settings_emails', 'wpinv_settings_emails', 10, 1); |
|
1126 | 1126 | |
1127 | -function wpinv_settings_sections_emails( $settings ) { |
|
1127 | +function wpinv_settings_sections_emails($settings) { |
|
1128 | 1128 | $emails = wpinv_get_emails(); |
1129 | 1129 | |
1130 | 1130 | if (!empty($emails)) { |
1131 | - foreach ($emails as $key => $email) { |
|
1132 | - $settings[$key] = !empty( $email['email_' . $key . '_header']['name'] ) ? strip_tags( $email['email_' . $key . '_header']['name'] ) : $key; |
|
1131 | + foreach ($emails as $key => $email) { |
|
1132 | + $settings[$key] = !empty($email['email_' . $key . '_header']['name']) ? strip_tags($email['email_' . $key . '_header']['name']) : $key; |
|
1133 | 1133 | } |
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | return $settings; |
1137 | 1137 | } |
1138 | -add_filter( 'wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1 ); |
|
1138 | +add_filter('wpinv_settings_sections_emails', 'wpinv_settings_sections_emails', 10, 1); |
|
1139 | 1139 | |
1140 | -function wpinv_email_is_enabled( $email_type ) { |
|
1140 | +function wpinv_email_is_enabled($email_type) { |
|
1141 | 1141 | $emails = wpinv_get_emails(); |
1142 | - $enabled = isset( $emails[$email_type] ) && wpinv_get_option( 'email_'. $email_type . '_active', 0 ) ? true : false; |
|
1142 | + $enabled = isset($emails[$email_type]) && wpinv_get_option('email_' . $email_type . '_active', 0) ? true : false; |
|
1143 | 1143 | |
1144 | - return apply_filters( 'wpinv_email_is_enabled', $enabled, $email_type ); |
|
1144 | + return apply_filters('wpinv_email_is_enabled', $enabled, $email_type); |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | -function wpinv_email_get_recipient( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1148 | - switch ( $email_type ) { |
|
1147 | +function wpinv_email_get_recipient($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1148 | + switch ($email_type) { |
|
1149 | 1149 | case 'new_invoice': |
1150 | 1150 | case 'cancelled_invoice': |
1151 | 1151 | case 'failed_invoice': |
1152 | 1152 | $recipient = wpinv_get_admin_email(); |
1153 | 1153 | break; |
1154 | 1154 | default: |
1155 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1156 | - $recipient = !empty( $invoice ) ? $invoice->get_email() : ''; |
|
1155 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1156 | + $recipient = !empty($invoice) ? $invoice->get_email() : ''; |
|
1157 | 1157 | break; |
1158 | 1158 | } |
1159 | 1159 | |
1160 | - return apply_filters( 'wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice ); |
|
1160 | + return apply_filters('wpinv_email_recipient', $recipient, $email_type, $invoice_id, $invoice); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | -function wpinv_email_get_subject( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1164 | - $subject = wpinv_get_option( 'email_' . $email_type . '_subject' ); |
|
1165 | - $subject = __( $subject, 'invoicing' ); |
|
1163 | +function wpinv_email_get_subject($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1164 | + $subject = wpinv_get_option('email_' . $email_type . '_subject'); |
|
1165 | + $subject = __($subject, 'invoicing'); |
|
1166 | 1166 | |
1167 | - $subject = wpinv_email_format_text( $subject, $invoice ); |
|
1167 | + $subject = wpinv_email_format_text($subject, $invoice); |
|
1168 | 1168 | |
1169 | - return apply_filters( 'wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice ); |
|
1169 | + return apply_filters('wpinv_email_subject', $subject, $email_type, $invoice_id, $invoice); |
|
1170 | 1170 | } |
1171 | 1171 | |
1172 | -function wpinv_email_get_heading( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1173 | - $email_heading = wpinv_get_option( 'email_' . $email_type . '_heading' ); |
|
1174 | - $email_heading = __( $email_heading, 'invoicing' ); |
|
1172 | +function wpinv_email_get_heading($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1173 | + $email_heading = wpinv_get_option('email_' . $email_type . '_heading'); |
|
1174 | + $email_heading = __($email_heading, 'invoicing'); |
|
1175 | 1175 | |
1176 | - $email_heading = wpinv_email_format_text( $email_heading, $invoice ); |
|
1176 | + $email_heading = wpinv_email_format_text($email_heading, $invoice); |
|
1177 | 1177 | |
1178 | - return apply_filters( 'wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice ); |
|
1178 | + return apply_filters('wpinv_email_heading', $email_heading, $email_type, $invoice_id, $invoice); |
|
1179 | 1179 | } |
1180 | 1180 | |
1181 | -function wpinv_email_get_content( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1182 | - $content = wpinv_get_option( 'email_' . $email_type . '_body' ); |
|
1183 | - $content = __( $content, 'invoicing' ); |
|
1181 | +function wpinv_email_get_content($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1182 | + $content = wpinv_get_option('email_' . $email_type . '_body'); |
|
1183 | + $content = __($content, 'invoicing'); |
|
1184 | 1184 | |
1185 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1185 | + $content = wpinv_email_format_text($content, $invoice); |
|
1186 | 1186 | |
1187 | - return apply_filters( 'wpinv_email_content', $content, $email_type, $invoice_id, $invoice ); |
|
1187 | + return apply_filters('wpinv_email_content', $content, $email_type, $invoice_id, $invoice); |
|
1188 | 1188 | } |
1189 | 1189 | |
1190 | -function wpinv_email_get_headers( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1190 | +function wpinv_email_get_headers($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1191 | 1191 | $from_name = wpinv_mail_get_from_address(); |
1192 | 1192 | $from_email = wpinv_mail_get_from_address(); |
1193 | 1193 | |
1194 | - $invoice = !empty( $invoice ) && is_object( $invoice ) ? $invoice : ( $invoice_id > 0 ? wpinv_get_invoice( $invoice_id ) : NULL ); |
|
1194 | + $invoice = !empty($invoice) && is_object($invoice) ? $invoice : ($invoice_id > 0 ? wpinv_get_invoice($invoice_id) : NULL); |
|
1195 | 1195 | |
1196 | - $headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n"; |
|
1197 | - $headers .= "Reply-To: ". $from_email . "\r\n"; |
|
1196 | + $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <$from_email>\r\n"; |
|
1197 | + $headers .= "Reply-To: " . $from_email . "\r\n"; |
|
1198 | 1198 | $headers .= "Content-Type: " . wpinv_mail_get_content_type() . "\r\n"; |
1199 | 1199 | |
1200 | - return apply_filters( 'wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice ); |
|
1200 | + return apply_filters('wpinv_email_headers', $headers, $email_type, $invoice_id, $invoice); |
|
1201 | 1201 | } |
1202 | 1202 | |
1203 | -function wpinv_email_get_attachments( $email_type = '', $invoice_id = 0, $invoice = array() ) { |
|
1203 | +function wpinv_email_get_attachments($email_type = '', $invoice_id = 0, $invoice = array()) { |
|
1204 | 1204 | $attachments = array(); |
1205 | 1205 | |
1206 | - return apply_filters( 'wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice ); |
|
1206 | + return apply_filters('wpinv_email_attachments', $attachments, $email_type, $invoice_id, $invoice); |
|
1207 | 1207 | } |
1208 | 1208 | |
1209 | -function wpinv_email_format_text( $content, $invoice ) { |
|
1209 | +function wpinv_email_format_text($content, $invoice) { |
|
1210 | 1210 | $replace_array = array( |
1211 | 1211 | '{site_title}' => wpinv_get_blogname(), |
1212 | - '{date}' => date_i18n( get_option( 'date_format' ), (int) current_time( 'timestamp' ) ), |
|
1212 | + '{date}' => date_i18n(get_option('date_format'), (int)current_time('timestamp')), |
|
1213 | 1213 | ); |
1214 | 1214 | |
1215 | - if ( !empty( $invoice->ID ) ) { |
|
1215 | + if (!empty($invoice->ID)) { |
|
1216 | 1216 | $replace_array = array_merge( |
1217 | 1217 | $replace_array, |
1218 | 1218 | array( |
@@ -1222,65 +1222,65 @@ discard block |
||
1222 | 1222 | '{last_name}' => $invoice->get_last_name(), |
1223 | 1223 | '{email}' => $invoice->get_email(), |
1224 | 1224 | '{invoice_number}' => $invoice->get_number(), |
1225 | - '{invoice_total}' => $invoice->get_total( true ), |
|
1226 | - '{invoice_link}' => $invoice->get_view_url( true ), |
|
1227 | - '{invoice_pay_link}'=> $invoice->get_view_url( true ), |
|
1228 | - '{invoice_date}' => $invoice->get_invoice_date( true ), |
|
1229 | - '{invoice_due_date}'=> $invoice->get_due_date( true ), |
|
1230 | - '{invoice_quote}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1231 | - '{invoice_label}' => $invoice->get_invoice_quote_type( $invoice->ID ), |
|
1232 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < strtotime( date_i18n( 'Y-m-d' ) ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
1225 | + '{invoice_total}' => $invoice->get_total(true), |
|
1226 | + '{invoice_link}' => $invoice->get_view_url(true), |
|
1227 | + '{invoice_pay_link}'=> $invoice->get_view_url(true), |
|
1228 | + '{invoice_date}' => $invoice->get_invoice_date(true), |
|
1229 | + '{invoice_due_date}'=> $invoice->get_due_date(true), |
|
1230 | + '{invoice_quote}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1231 | + '{invoice_label}' => $invoice->get_invoice_quote_type($invoice->ID), |
|
1232 | + '{is_was}' => strtotime($invoice->get_due_date()) < strtotime(date_i18n('Y-m-d')) ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
1233 | 1233 | ) |
1234 | 1234 | ); |
1235 | 1235 | } |
1236 | 1236 | |
1237 | - $replace_array = apply_filters( 'wpinv_email_format_text', $replace_array, $content, $invoice ); |
|
1237 | + $replace_array = apply_filters('wpinv_email_format_text', $replace_array, $content, $invoice); |
|
1238 | 1238 | |
1239 | - foreach ( $replace_array as $key => $value ) { |
|
1240 | - $content = str_replace( $key, $value, $content ); |
|
1239 | + foreach ($replace_array as $key => $value) { |
|
1240 | + $content = str_replace($key, $value, $content); |
|
1241 | 1241 | } |
1242 | 1242 | |
1243 | - return apply_filters( 'wpinv_email_content_replace', $content ); |
|
1243 | + return apply_filters('wpinv_email_content_replace', $content); |
|
1244 | 1244 | } |
1245 | 1245 | |
1246 | -function wpinv_email_style_body( $content ) { |
|
1246 | +function wpinv_email_style_body($content) { |
|
1247 | 1247 | // make sure we only inline CSS for html emails |
1248 | - if ( in_array( wpinv_mail_get_content_type(), array( 'text/html', 'multipart/alternative' ) ) && class_exists( 'DOMDocument' ) ) { |
|
1248 | + if (in_array(wpinv_mail_get_content_type(), array('text/html', 'multipart/alternative')) && class_exists('DOMDocument')) { |
|
1249 | 1249 | ob_start(); |
1250 | - wpinv_get_template( 'emails/wpinv-email-styles.php' ); |
|
1251 | - $css = apply_filters( 'wpinv_email_styles', ob_get_clean() ); |
|
1250 | + wpinv_get_template('emails/wpinv-email-styles.php'); |
|
1251 | + $css = apply_filters('wpinv_email_styles', ob_get_clean()); |
|
1252 | 1252 | |
1253 | 1253 | // apply CSS styles inline for picky email clients |
1254 | 1254 | try { |
1255 | - $emogrifier = new Emogrifier( $content, $css ); |
|
1255 | + $emogrifier = new Emogrifier($content, $css); |
|
1256 | 1256 | $content = $emogrifier->emogrify(); |
1257 | - } catch ( Exception $e ) { |
|
1258 | - wpinv_error_log( $e->getMessage(), 'emogrifier' ); |
|
1257 | + } catch (Exception $e) { |
|
1258 | + wpinv_error_log($e->getMessage(), 'emogrifier'); |
|
1259 | 1259 | } |
1260 | 1260 | } |
1261 | 1261 | return $content; |
1262 | 1262 | } |
1263 | 1263 | |
1264 | -function wpinv_email_header( $email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1265 | - wpinv_get_template( 'emails/wpinv-email-header.php', array( 'email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1264 | +function wpinv_email_header($email_heading = '', $invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1265 | + wpinv_get_template('emails/wpinv-email-header.php', array('email_heading' => $email_heading, 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1266 | 1266 | } |
1267 | 1267 | |
1268 | 1268 | /** |
1269 | 1269 | * Get the email footer. |
1270 | 1270 | */ |
1271 | -function wpinv_email_footer( $invoice = array(), $email_type = '', $sent_to_admin = false ) { |
|
1272 | - wpinv_get_template( 'emails/wpinv-email-footer.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1271 | +function wpinv_email_footer($invoice = array(), $email_type = '', $sent_to_admin = false) { |
|
1272 | + wpinv_get_template('emails/wpinv-email-footer.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1273 | 1273 | } |
1274 | 1274 | |
1275 | -function wpinv_email_wrap_message( $message ) { |
|
1275 | +function wpinv_email_wrap_message($message) { |
|
1276 | 1276 | // Buffer |
1277 | 1277 | ob_start(); |
1278 | 1278 | |
1279 | - do_action( 'wpinv_email_header' ); |
|
1279 | + do_action('wpinv_email_header'); |
|
1280 | 1280 | |
1281 | - echo wpautop( wptexturize( $message ) ); |
|
1281 | + echo wpautop(wptexturize($message)); |
|
1282 | 1282 | |
1283 | - do_action( 'wpinv_email_footer' ); |
|
1283 | + do_action('wpinv_email_footer'); |
|
1284 | 1284 | |
1285 | 1285 | // Get contents |
1286 | 1286 | $message = ob_get_clean(); |
@@ -1288,92 +1288,92 @@ discard block |
||
1288 | 1288 | return $message; |
1289 | 1289 | } |
1290 | 1290 | |
1291 | -function wpinv_email_invoice_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1292 | - wpinv_get_template( 'emails/wpinv-email-invoice-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1291 | +function wpinv_email_invoice_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1292 | + wpinv_get_template('emails/wpinv-email-invoice-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | -function wpinv_email_invoice_items( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1296 | - wpinv_get_template( 'emails/wpinv-email-invoice-items.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1295 | +function wpinv_email_invoice_items($invoice, $email_type = '', $sent_to_admin = false) { |
|
1296 | + wpinv_get_template('emails/wpinv-email-invoice-items.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | -function wpinv_email_billing_details( $invoice, $email_type = '', $sent_to_admin = false ) { |
|
1300 | - wpinv_get_template( 'emails/wpinv-email-billing-details.php', array( 'invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin ) ); |
|
1299 | +function wpinv_email_billing_details($invoice, $email_type = '', $sent_to_admin = false) { |
|
1300 | + wpinv_get_template('emails/wpinv-email-billing-details.php', array('invoice' => $invoice, 'email_type' => $email_type, 'sent_to_admin' => $sent_to_admin)); |
|
1301 | 1301 | } |
1302 | 1302 | |
1303 | -function wpinv_send_customer_invoice( $data = array() ) { |
|
1304 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1303 | +function wpinv_send_customer_invoice($data = array()) { |
|
1304 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1305 | 1305 | |
1306 | - if ( empty( $invoice_id ) ) { |
|
1306 | + if (empty($invoice_id)) { |
|
1307 | 1307 | return; |
1308 | 1308 | } |
1309 | 1309 | |
1310 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1311 | - wp_die( __( 'You do not have permission to send invoice notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1310 | + if (!current_user_can('manage_options')) { |
|
1311 | + wp_die(__('You do not have permission to send invoice notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1312 | 1312 | } |
1313 | 1313 | |
1314 | - $sent = wpinv_user_invoice_notification( $invoice_id ); |
|
1314 | + $sent = wpinv_user_invoice_notification($invoice_id); |
|
1315 | 1315 | |
1316 | 1316 | if ( -1 === $sent ) { |
1317 | 1317 | $status = 'email_disabled'; |
1318 | - } elseif ( $sent ) { |
|
1318 | + } elseif ($sent) { |
|
1319 | 1319 | $status = 'email_sent'; |
1320 | 1320 | } else { |
1321 | 1321 | $status = 'email_fail'; |
1322 | 1322 | } |
1323 | 1323 | |
1324 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1325 | - wp_redirect( $redirect ); |
|
1324 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1325 | + wp_redirect($redirect); |
|
1326 | 1326 | exit; |
1327 | 1327 | } |
1328 | -add_action( 'wpinv_send_invoice', 'wpinv_send_customer_invoice' ); |
|
1328 | +add_action('wpinv_send_invoice', 'wpinv_send_customer_invoice'); |
|
1329 | 1329 | |
1330 | -function wpinv_send_overdue_reminder( $data = array() ) { |
|
1331 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1330 | +function wpinv_send_overdue_reminder($data = array()) { |
|
1331 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1332 | 1332 | |
1333 | - if ( empty( $invoice_id ) ) { |
|
1333 | + if (empty($invoice_id)) { |
|
1334 | 1334 | return; |
1335 | 1335 | } |
1336 | 1336 | |
1337 | - if ( !current_user_can( 'manage_options' ) ) { |
|
1338 | - wp_die( __( 'You do not have permission to send reminder notification', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) ); |
|
1337 | + if (!current_user_can('manage_options')) { |
|
1338 | + wp_die(__('You do not have permission to send reminder notification', 'invoicing'), __('Error', 'invoicing'), array('response' => 403)); |
|
1339 | 1339 | } |
1340 | 1340 | |
1341 | - $sent = wpinv_send_payment_reminder_notification( $invoice_id ); |
|
1341 | + $sent = wpinv_send_payment_reminder_notification($invoice_id); |
|
1342 | 1342 | |
1343 | 1343 | $status = $sent ? 'email_sent' : 'email_fail'; |
1344 | 1344 | |
1345 | - $redirect = add_query_arg( array( 'wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false ) ); |
|
1346 | - wp_redirect( $redirect ); |
|
1345 | + $redirect = add_query_arg(array('wpinv-message' => $status, 'wpi_action' => false, 'invoice_id' => false)); |
|
1346 | + wp_redirect($redirect); |
|
1347 | 1347 | exit; |
1348 | 1348 | } |
1349 | -add_action( 'wpinv_send_reminder', 'wpinv_send_overdue_reminder' ); |
|
1349 | +add_action('wpinv_send_reminder', 'wpinv_send_overdue_reminder'); |
|
1350 | 1350 | |
1351 | -function wpinv_send_customer_note_email( $data ) { |
|
1352 | - $invoice_id = !empty( $data['invoice_id'] ) ? absint( $data['invoice_id'] ) : NULL; |
|
1351 | +function wpinv_send_customer_note_email($data) { |
|
1352 | + $invoice_id = !empty($data['invoice_id']) ? absint($data['invoice_id']) : NULL; |
|
1353 | 1353 | |
1354 | - if ( empty( $invoice_id ) ) { |
|
1354 | + if (empty($invoice_id)) { |
|
1355 | 1355 | return; |
1356 | 1356 | } |
1357 | 1357 | |
1358 | - $sent = wpinv_user_note_notification( $invoice_id, $data ); |
|
1358 | + $sent = wpinv_user_note_notification($invoice_id, $data); |
|
1359 | 1359 | } |
1360 | -add_action( 'wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1 ); |
|
1360 | +add_action('wpinv_new_customer_note', 'wpinv_send_customer_note_email', 10, 1); |
|
1361 | 1361 | |
1362 | -function wpinv_add_notes_to_invoice_email( $invoice, $email_type, $sent_to_admin ) { |
|
1363 | - if ( !empty( $invoice ) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes( $invoice->ID, true ) ) { |
|
1364 | - $date_format = get_option( 'date_format' ); |
|
1365 | - $time_format = get_option( 'time_format' ); |
|
1362 | +function wpinv_add_notes_to_invoice_email($invoice, $email_type, $sent_to_admin) { |
|
1363 | + if (!empty($invoice) && $email_type == 'user_invoice' && $invoice_notes = wpinv_get_invoice_notes($invoice->ID, true)) { |
|
1364 | + $date_format = get_option('date_format'); |
|
1365 | + $time_format = get_option('time_format'); |
|
1366 | 1366 | ?> |
1367 | 1367 | <div id="wpinv-email-notes"> |
1368 | - <h3 class="wpinv-notes-t"><?php echo apply_filters( 'wpinv_email_invoice_notes_title', __( 'Invoice Notes', 'invoicing' ) ); ?></h3> |
|
1368 | + <h3 class="wpinv-notes-t"><?php echo apply_filters('wpinv_email_invoice_notes_title', __('Invoice Notes', 'invoicing')); ?></h3> |
|
1369 | 1369 | <ol class="wpinv-notes-lists"> |
1370 | 1370 | <?php |
1371 | - foreach ( $invoice_notes as $note ) { |
|
1372 | - $note_time = strtotime( $note->comment_date ); |
|
1371 | + foreach ($invoice_notes as $note) { |
|
1372 | + $note_time = strtotime($note->comment_date); |
|
1373 | 1373 | ?> |
1374 | 1374 | <li class="comment wpinv-note"> |
1375 | - <p class="wpinv-note-date meta"><?php printf( __( '%2$s at %3$s', 'invoicing' ), $note->comment_author, date_i18n( $date_format, $note_time ), date_i18n( $time_format, $note_time ), $note_time ); ?></p> |
|
1376 | - <div class="wpinv-note-desc description"><?php echo wpautop( wptexturize( $note->comment_content ) ); ?></div> |
|
1375 | + <p class="wpinv-note-date meta"><?php printf(__('%2$s at %3$s', 'invoicing'), $note->comment_author, date_i18n($date_format, $note_time), date_i18n($time_format, $note_time), $note_time); ?></p> |
|
1376 | + <div class="wpinv-note-desc description"><?php echo wpautop(wptexturize($note->comment_content)); ?></div> |
|
1377 | 1377 | </li> |
1378 | 1378 | <?php |
1379 | 1379 | } |
@@ -1382,21 +1382,21 @@ discard block |
||
1382 | 1382 | <?php |
1383 | 1383 | } |
1384 | 1384 | } |
1385 | -add_action( 'wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3 ); |
|
1385 | +add_action('wpinv_email_billing_details', 'wpinv_add_notes_to_invoice_email', 10, 3); |
|
1386 | 1386 | |
1387 | 1387 | function wpinv_email_payment_reminders() { |
1388 | 1388 | global $wpi_auto_reminder; |
1389 | - if ( !wpinv_get_option( 'email_overdue_active' ) ) { |
|
1389 | + if (!wpinv_get_option('email_overdue_active')) { |
|
1390 | 1390 | return; |
1391 | 1391 | } |
1392 | 1392 | |
1393 | - if ( $reminder_days = wpinv_get_option( 'email_due_reminder_days' ) ) { |
|
1394 | - $reminder_days = is_array( $reminder_days ) ? array_values( $reminder_days ) : ''; |
|
1393 | + if ($reminder_days = wpinv_get_option('email_due_reminder_days')) { |
|
1394 | + $reminder_days = is_array($reminder_days) ? array_values($reminder_days) : ''; |
|
1395 | 1395 | |
1396 | - if ( empty( $reminder_days ) ) { |
|
1396 | + if (empty($reminder_days)) { |
|
1397 | 1397 | return; |
1398 | 1398 | } |
1399 | - $reminder_days = array_unique( array_map( 'absint', $reminder_days ) ); |
|
1399 | + $reminder_days = array_unique(array_map('absint', $reminder_days)); |
|
1400 | 1400 | |
1401 | 1401 | $args = array( |
1402 | 1402 | 'post_type' => 'wpi_invoice', |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | 'meta_query' => array( |
1407 | 1407 | array( |
1408 | 1408 | 'key' => '_wpinv_due_date', |
1409 | - 'value' => array( '', 'none' ), |
|
1409 | + 'value' => array('', 'none'), |
|
1410 | 1410 | 'compare' => 'NOT IN', |
1411 | 1411 | ) |
1412 | 1412 | ), |
@@ -1415,143 +1415,143 @@ discard block |
||
1415 | 1415 | 'order' => 'ASC', |
1416 | 1416 | ); |
1417 | 1417 | |
1418 | - $invoices = get_posts( $args ); |
|
1418 | + $invoices = get_posts($args); |
|
1419 | 1419 | |
1420 | - if ( empty( $invoices ) ) { |
|
1420 | + if (empty($invoices)) { |
|
1421 | 1421 | return; |
1422 | 1422 | } |
1423 | 1423 | |
1424 | - $date_to_send = array(); |
|
1424 | + $date_to_send = array(); |
|
1425 | 1425 | |
1426 | - foreach ( $invoices as $id ) { |
|
1427 | - $due_date = get_post_meta( $id, '_wpinv_due_date', true ); |
|
1426 | + foreach ($invoices as $id) { |
|
1427 | + $due_date = get_post_meta($id, '_wpinv_due_date', true); |
|
1428 | 1428 | |
1429 | - foreach ( $reminder_days as $key => $days ) { |
|
1430 | - if ( $days !== '' ) { |
|
1431 | - $date_to_send[$id][] = date_i18n( 'Y-m-d', strtotime( $due_date ) + ( $days * DAY_IN_SECONDS ) ); |
|
1429 | + foreach ($reminder_days as $key => $days) { |
|
1430 | + if ($days !== '') { |
|
1431 | + $date_to_send[$id][] = date_i18n('Y-m-d', strtotime($due_date) + ($days * DAY_IN_SECONDS)); |
|
1432 | 1432 | } |
1433 | 1433 | } |
1434 | 1434 | } |
1435 | 1435 | |
1436 | - $today = date_i18n( 'Y-m-d' ); |
|
1436 | + $today = date_i18n('Y-m-d'); |
|
1437 | 1437 | $wpi_auto_reminder = true; |
1438 | 1438 | |
1439 | - foreach ( $date_to_send as $id => $values ) { |
|
1440 | - if ( in_array( $today, $values ) ) { |
|
1441 | - $sent = get_post_meta( $id, '_wpinv_reminder_sent', true ); |
|
1439 | + foreach ($date_to_send as $id => $values) { |
|
1440 | + if (in_array($today, $values)) { |
|
1441 | + $sent = get_post_meta($id, '_wpinv_reminder_sent', true); |
|
1442 | 1442 | |
1443 | - if ( isset( $sent ) && !empty( $sent ) ) { |
|
1444 | - if ( !in_array( $today, $sent ) ) { |
|
1445 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1443 | + if (isset($sent) && !empty($sent)) { |
|
1444 | + if (!in_array($today, $sent)) { |
|
1445 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1446 | 1446 | } |
1447 | 1447 | } else { |
1448 | - do_action( 'wpinv_send_payment_reminder_notification', $id ); |
|
1448 | + do_action('wpinv_send_payment_reminder_notification', $id); |
|
1449 | 1449 | } |
1450 | 1450 | } |
1451 | 1451 | } |
1452 | 1452 | |
1453 | - $wpi_auto_reminder = false; |
|
1453 | + $wpi_auto_reminder = false; |
|
1454 | 1454 | } |
1455 | 1455 | } |
1456 | 1456 | |
1457 | -function wpinv_send_payment_reminder_notification( $invoice_id ) { |
|
1457 | +function wpinv_send_payment_reminder_notification($invoice_id) { |
|
1458 | 1458 | $email_type = 'overdue'; |
1459 | - if ( !wpinv_email_is_enabled( $email_type ) ) { |
|
1459 | + if (!wpinv_email_is_enabled($email_type)) { |
|
1460 | 1460 | return false; |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
1464 | - if ( empty( $invoice ) ) { |
|
1463 | + $invoice = wpinv_get_invoice($invoice_id); |
|
1464 | + if (empty($invoice)) { |
|
1465 | 1465 | return false; |
1466 | 1466 | } |
1467 | 1467 | |
1468 | - if ( !$invoice->needs_payment() ) { |
|
1468 | + if (!$invoice->needs_payment()) { |
|
1469 | 1469 | return false; |
1470 | 1470 | } |
1471 | 1471 | |
1472 | - $recipient = wpinv_email_get_recipient( $email_type, $invoice_id, $invoice ); |
|
1473 | - if ( !is_email( $recipient ) ) { |
|
1472 | + $recipient = wpinv_email_get_recipient($email_type, $invoice_id, $invoice); |
|
1473 | + if (!is_email($recipient)) { |
|
1474 | 1474 | return false; |
1475 | 1475 | } |
1476 | 1476 | |
1477 | - do_action( 'wpinv_pre_send_invoice_notification', $invoice, $email_type ); |
|
1477 | + do_action('wpinv_pre_send_invoice_notification', $invoice, $email_type); |
|
1478 | 1478 | |
1479 | - $subject = wpinv_email_get_subject( $email_type, $invoice_id, $invoice ); |
|
1480 | - $email_heading = wpinv_email_get_heading( $email_type, $invoice_id, $invoice ); |
|
1481 | - $headers = wpinv_email_get_headers( $email_type, $invoice_id, $invoice ); |
|
1482 | - $message_body = wpinv_email_get_content( $email_type, $invoice_id, $invoice ); |
|
1483 | - $attachments = wpinv_email_get_attachments( $email_type, $invoice_id, $invoice ); |
|
1479 | + $subject = wpinv_email_get_subject($email_type, $invoice_id, $invoice); |
|
1480 | + $email_heading = wpinv_email_get_heading($email_type, $invoice_id, $invoice); |
|
1481 | + $headers = wpinv_email_get_headers($email_type, $invoice_id, $invoice); |
|
1482 | + $message_body = wpinv_email_get_content($email_type, $invoice_id, $invoice); |
|
1483 | + $attachments = wpinv_email_get_attachments($email_type, $invoice_id, $invoice); |
|
1484 | 1484 | |
1485 | - $content = wpinv_get_template_html( 'emails/wpinv-email-' . $email_type . '.php', array( |
|
1485 | + $content = wpinv_get_template_html('emails/wpinv-email-' . $email_type . '.php', array( |
|
1486 | 1486 | 'invoice' => $invoice, |
1487 | 1487 | 'email_type' => $email_type, |
1488 | 1488 | 'email_heading' => $email_heading, |
1489 | 1489 | 'sent_to_admin' => false, |
1490 | 1490 | 'plain_text' => false, |
1491 | 1491 | 'message_body' => $message_body |
1492 | - ) ); |
|
1492 | + )); |
|
1493 | 1493 | |
1494 | - $content = wpinv_email_format_text( $content, $invoice ); |
|
1494 | + $content = wpinv_email_format_text($content, $invoice); |
|
1495 | 1495 | |
1496 | - $sent = wpinv_mail_send( $recipient, $subject, $content, $headers, $attachments ); |
|
1497 | - if ( $sent ) { |
|
1498 | - do_action( 'wpinv_payment_reminder_sent', $invoice_id, $invoice ); |
|
1496 | + $sent = wpinv_mail_send($recipient, $subject, $content, $headers, $attachments); |
|
1497 | + if ($sent) { |
|
1498 | + do_action('wpinv_payment_reminder_sent', $invoice_id, $invoice); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | - do_action( 'wpinv_post_send_invoice_notification', $invoice, $email_type ); |
|
1501 | + do_action('wpinv_post_send_invoice_notification', $invoice, $email_type); |
|
1502 | 1502 | |
1503 | 1503 | return $sent; |
1504 | 1504 | } |
1505 | -add_action( 'wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1 ); |
|
1505 | +add_action('wpinv_send_payment_reminder_notification', 'wpinv_send_payment_reminder_notification', 10, 1); |
|
1506 | 1506 | |
1507 | -function wpinv_payment_reminder_sent( $invoice_id, $invoice ) { |
|
1507 | +function wpinv_payment_reminder_sent($invoice_id, $invoice) { |
|
1508 | 1508 | global $wpi_auto_reminder; |
1509 | 1509 | |
1510 | - $sent = get_post_meta( $invoice_id, '_wpinv_reminder_sent', true ); |
|
1510 | + $sent = get_post_meta($invoice_id, '_wpinv_reminder_sent', true); |
|
1511 | 1511 | |
1512 | - if ( empty( $sent ) ) { |
|
1512 | + if (empty($sent)) { |
|
1513 | 1513 | $sent = array(); |
1514 | 1514 | } |
1515 | - $sent[] = date_i18n( 'Y-m-d' ); |
|
1515 | + $sent[] = date_i18n('Y-m-d'); |
|
1516 | 1516 | |
1517 | - update_post_meta( $invoice_id, '_wpinv_reminder_sent', $sent ); |
|
1517 | + update_post_meta($invoice_id, '_wpinv_reminder_sent', $sent); |
|
1518 | 1518 | |
1519 | - if ( $wpi_auto_reminder ) { // Auto reminder note. |
|
1520 | - $note = __( 'Automated reminder sent to the user.', 'invoicing' ); |
|
1521 | - $invoice->add_note( $note, false, false, true ); |
|
1519 | + if ($wpi_auto_reminder) { // Auto reminder note. |
|
1520 | + $note = __('Automated reminder sent to the user.', 'invoicing'); |
|
1521 | + $invoice->add_note($note, false, false, true); |
|
1522 | 1522 | } else { // Menual reminder note. |
1523 | - $note = __( 'Manual reminder sent to the user.', 'invoicing' ); |
|
1524 | - $invoice->add_note( $note ); |
|
1523 | + $note = __('Manual reminder sent to the user.', 'invoicing'); |
|
1524 | + $invoice->add_note($note); |
|
1525 | 1525 | } |
1526 | 1526 | } |
1527 | -add_action( 'wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2 ); |
|
1527 | +add_action('wpinv_payment_reminder_sent', 'wpinv_payment_reminder_sent', 10, 2); |
|
1528 | 1528 | |
1529 | -function wpinv_invoice_notification_set_locale( $invoice, $email_type, $site = false ) { |
|
1530 | - if ( empty( $invoice ) ) { |
|
1529 | +function wpinv_invoice_notification_set_locale($invoice, $email_type, $site = false) { |
|
1530 | + if (empty($invoice)) { |
|
1531 | 1531 | return; |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - if ( is_int( $invoice ) ) { |
|
1535 | - $invoice = new wpinv_get_invoice( $invoice ); |
|
1534 | + if (is_int($invoice)) { |
|
1535 | + $invoice = new wpinv_get_invoice($invoice); |
|
1536 | 1536 | } |
1537 | 1537 | |
1538 | - if ( ! empty( $invoice ) && is_object( $invoice ) ) { |
|
1539 | - if ( ! $site && function_exists( 'get_user_locale' ) ) { |
|
1540 | - $locale = get_user_locale( $invoice->get_user_id() ); |
|
1538 | + if (!empty($invoice) && is_object($invoice)) { |
|
1539 | + if (!$site && function_exists('get_user_locale')) { |
|
1540 | + $locale = get_user_locale($invoice->get_user_id()); |
|
1541 | 1541 | } else { |
1542 | 1542 | $locale = get_locale(); |
1543 | 1543 | } |
1544 | 1544 | |
1545 | - wpinv_switch_to_locale( $locale ); |
|
1545 | + wpinv_switch_to_locale($locale); |
|
1546 | 1546 | } |
1547 | 1547 | } |
1548 | -add_action( 'wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3 ); |
|
1548 | +add_action('wpinv_pre_send_invoice_notification', 'wpinv_invoice_notification_set_locale', 10, 3); |
|
1549 | 1549 | |
1550 | -function wpinv_invoice_notification_restore_locale( $invoice, $email_type, $site = false ) { |
|
1551 | - if ( empty( $invoice ) ) { |
|
1550 | +function wpinv_invoice_notification_restore_locale($invoice, $email_type, $site = false) { |
|
1551 | + if (empty($invoice)) { |
|
1552 | 1552 | return; |
1553 | 1553 | } |
1554 | 1554 | |
1555 | 1555 | wpinv_restore_locale(); |
1556 | 1556 | } |
1557 | -add_action( 'wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3 ); |
|
1557 | +add_action('wpinv_post_send_invoice_notification', 'wpinv_invoice_notification_restore_locale', 10, 3); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | |
31 | 31 | <tbody> |
32 | 32 | <?php foreach ( $user_invoices->invoices as $invoice ) { |
33 | - ?> |
|
33 | + ?> |
|
34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
35 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
36 | 36 | <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
53 | 53 | |
54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
55 | 55 | <?php |
56 | - $actions = array( |
|
57 | - 'pay' => array( |
|
58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
56 | + $actions = array( |
|
57 | + 'pay' => array( |
|
58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
60 | 60 | 'class' => 'btn-success' |
61 | - ), |
|
61 | + ), |
|
62 | 62 | 'print' => array( |
63 | - 'url' => $invoice->get_view_url(), |
|
64 | - 'name' => __( 'Print', 'invoicing' ), |
|
63 | + 'url' => $invoice->get_view_url(), |
|
64 | + 'name' => __( 'Print', 'invoicing' ), |
|
65 | 65 | 'class' => 'btn-primary', |
66 | 66 | 'attrs' => 'target="_blank"' |
67 | - ) |
|
68 | - ); |
|
67 | + ) |
|
68 | + ); |
|
69 | 69 | |
70 | - if ( ! $invoice->needs_payment() ) { |
|
71 | - unset( $actions['pay'] ); |
|
72 | - } |
|
70 | + if ( ! $invoice->needs_payment() ) { |
|
71 | + unset( $actions['pay'] ); |
|
72 | + } |
|
73 | 73 | |
74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | - foreach ( $actions as $key => $action ) { |
|
76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
75 | + foreach ( $actions as $key => $action ) { |
|
76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
77 | 77 | echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
78 | - } |
|
79 | - } |
|
80 | - ?> |
|
78 | + } |
|
79 | + } |
|
80 | + ?> |
|
81 | 81 | <?php endif; ?> |
82 | 82 | </td> |
83 | 83 | <?php endforeach; ?> |
@@ -91,22 +91,22 @@ discard block |
||
91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
92 | 92 | <div class="invoicing-Pagination"> |
93 | 93 | <?php |
94 | - $big = 999999; |
|
95 | - |
|
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
102 | - |
|
103 | - echo paginate_links( array( |
|
104 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | - 'format' => '?paged=%#%', |
|
106 | - 'current' => max( 1, $current_page ), |
|
107 | - 'total' => $user_invoices->max_num_pages, |
|
108 | - ) ); |
|
109 | - ?> |
|
94 | + $big = 999999; |
|
95 | + |
|
96 | + if (get_query_var('paged')) |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + elseif (get_query_var('page')) |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + else |
|
101 | + $current_page = 1; |
|
102 | + |
|
103 | + echo paginate_links( array( |
|
104 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
105 | + 'format' => '?paged=%#%', |
|
106 | + 'current' => max( 1, $current_page ), |
|
107 | + 'total' => $user_invoices->max_num_pages, |
|
108 | + ) ); |
|
109 | + ?> |
|
110 | 110 | </div> |
111 | 111 | <?php endif; ?> |
112 | 112 |
@@ -93,12 +93,13 @@ |
||
93 | 93 | <?php |
94 | 94 | $big = 999999; |
95 | 95 | |
96 | - if (get_query_var('paged')) |
|
97 | - $current_page = get_query_var('paged'); |
|
98 | - elseif (get_query_var('page')) |
|
99 | - $current_page = get_query_var('page'); |
|
100 | - else |
|
101 | - $current_page = 1; |
|
96 | + if (get_query_var('paged')) { |
|
97 | + $current_page = get_query_var('paged'); |
|
98 | + } elseif (get_query_var('page')) { |
|
99 | + $current_page = get_query_var('page'); |
|
100 | + } else { |
|
101 | + $current_page = 1; |
|
102 | + } |
|
102 | 103 | |
103 | 104 | echo paginate_links( array( |
104 | 105 | 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
@@ -1,83 +1,83 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
6 | -if ( !( $user_id = get_current_user_id() ) ) { |
|
6 | +if (!($user_id = get_current_user_id())) { |
|
7 | 7 | ?> |
8 | - <div class="wpinv-empty alert alert-error"><?php _e( 'You are not allowed to access this section', 'invoicing' ) ;?></div> |
|
8 | + <div class="wpinv-empty alert alert-error"><?php _e('You are not allowed to access this section', 'invoicing'); ?></div> |
|
9 | 9 | <?php |
10 | 10 | return; |
11 | 11 | } |
12 | 12 | |
13 | 13 | global $current_page; |
14 | -$current_page = empty( $current_page ) ? 1 : absint( $current_page ); |
|
15 | -$query = apply_filters( 'wpinv_user_invoices_query', array( 'user' => $user_id, 'page' => $current_page, 'paginate' => true, 'orderby' => 'invoice_date' ) ); |
|
16 | -$user_invoices = wpinv_get_invoices( $query ); |
|
14 | +$current_page = empty($current_page) ? 1 : absint($current_page); |
|
15 | +$query = apply_filters('wpinv_user_invoices_query', array('user' => $user_id, 'page' => $current_page, 'paginate' => true, 'orderby' => 'invoice_date')); |
|
16 | +$user_invoices = wpinv_get_invoices($query); |
|
17 | 17 | $has_invoices = 0 < $user_invoices->total; |
18 | 18 | |
19 | -do_action( 'wpinv_before_user_invoices', $has_invoices ); ?> |
|
19 | +do_action('wpinv_before_user_invoices', $has_invoices); ?> |
|
20 | 20 | |
21 | -<?php if ( $has_invoices ) { ?> |
|
21 | +<?php if ($has_invoices) { ?> |
|
22 | 22 | <table class="table table-bordered table-hover table-responsive wpi-user-invoices"> |
23 | 23 | <thead> |
24 | 24 | <tr> |
25 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
26 | - <th class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>"><span class="nobr"><?php echo esc_html( $column_name['title'] ); ?></span></th> |
|
25 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
26 | + <th class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>"><span class="nobr"><?php echo esc_html($column_name['title']); ?></span></th> |
|
27 | 27 | <?php endforeach; ?> |
28 | 28 | </tr> |
29 | 29 | </thead> |
30 | 30 | |
31 | 31 | <tbody> |
32 | - <?php foreach ( $user_invoices->invoices as $invoice ) { |
|
32 | + <?php foreach ($user_invoices->invoices as $invoice) { |
|
33 | 33 | ?> |
34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
35 | - <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
|
36 | - <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
|
37 | - <?php if ( has_action( 'wpinv_user_invoices_column_' . $column_id ) ) : ?> |
|
38 | - <?php do_action( 'wpinv_user_invoices_column_' . $column_id, $invoice ); ?> |
|
39 | - |
|
40 | - <?php elseif ( 'invoice-number' === $column_id ) : ?> |
|
41 | - <a href="<?php echo esc_url( $invoice->get_view_url() ); ?>"> |
|
42 | - <?php echo _x( '#', 'hash before invoice number', 'invoicing' ) . $invoice->get_number(); ?> |
|
35 | + <?php foreach (wpinv_get_user_invoices_columns() as $column_id => $column_name) : ?> |
|
36 | + <td class="<?php echo esc_attr($column_id); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : ''); ?>" data-title="<?php echo esc_attr($column_name['title']); ?>"> |
|
37 | + <?php if (has_action('wpinv_user_invoices_column_' . $column_id)) : ?> |
|
38 | + <?php do_action('wpinv_user_invoices_column_' . $column_id, $invoice); ?> |
|
39 | + |
|
40 | + <?php elseif ('invoice-number' === $column_id) : ?> |
|
41 | + <a href="<?php echo esc_url($invoice->get_view_url()); ?>"> |
|
42 | + <?php echo _x('#', 'hash before invoice number', 'invoicing') . $invoice->get_number(); ?> |
|
43 | 43 | </a> |
44 | 44 | |
45 | - <?php elseif ( 'created-date' === $column_id ) : $date = wpinv_get_date_created( $invoice->ID ); $dateYMD = wpinv_get_date_created( $invoice->ID, 'Y-m-d H:i:s' ); ?> |
|
46 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
45 | + <?php elseif ('created-date' === $column_id) : $date = wpinv_get_date_created($invoice->ID); $dateYMD = wpinv_get_date_created($invoice->ID, 'Y-m-d H:i:s'); ?> |
|
46 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
47 | 47 | |
48 | - <?php elseif ( 'payment-date' === $column_id ) : $date = wpinv_get_invoice_date( $invoice->ID, '', false ); $dateYMD = wpinv_get_invoice_date( $invoice->ID, 'Y-m-d H:i:s', false ); ?> |
|
49 | - <time datetime="<?php echo strtotime( $dateYMD ); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
48 | + <?php elseif ('payment-date' === $column_id) : $date = wpinv_get_invoice_date($invoice->ID, '', false); $dateYMD = wpinv_get_invoice_date($invoice->ID, 'Y-m-d H:i:s', false); ?> |
|
49 | + <time datetime="<?php echo strtotime($dateYMD); ?>" title="<?php echo $dateYMD; ?>"><?php echo $date; ?></time> |
|
50 | 50 | |
51 | - <?php elseif ( 'invoice-status' === $column_id ) : ?> |
|
52 | - <?php echo wpinv_invoice_status_label( $invoice_status, $invoice->get_status( true ) ) ; ?> |
|
51 | + <?php elseif ('invoice-status' === $column_id) : ?> |
|
52 | + <?php echo wpinv_invoice_status_label($invoice_status, $invoice->get_status(true)); ?> |
|
53 | 53 | |
54 | - <?php elseif ( 'invoice-total' === $column_id ) : ?> |
|
55 | - <?php echo $invoice->get_total( true ); ?> |
|
54 | + <?php elseif ('invoice-total' === $column_id) : ?> |
|
55 | + <?php echo $invoice->get_total(true); ?> |
|
56 | 56 | |
57 | - <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
|
57 | + <?php elseif ('invoice-actions' === $column_id) : ?> |
|
58 | 58 | <?php |
59 | 59 | $actions = array( |
60 | 60 | 'pay' => array( |
61 | 61 | 'url' => $invoice->get_checkout_payment_url(), |
62 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
62 | + 'name' => __('Pay Now', 'invoicing'), |
|
63 | 63 | 'class' => 'btn-success' |
64 | 64 | ), |
65 | 65 | 'print' => array( |
66 | 66 | 'url' => $invoice->get_view_url(), |
67 | - 'name' => __( 'Print', 'invoicing' ), |
|
67 | + 'name' => __('Print', 'invoicing'), |
|
68 | 68 | 'class' => 'btn-primary', |
69 | 69 | 'attrs' => 'target="_blank"' |
70 | 70 | ) |
71 | 71 | ); |
72 | 72 | |
73 | - if ( ! $invoice->needs_payment() ) { |
|
74 | - unset( $actions['pay'] ); |
|
73 | + if (!$invoice->needs_payment()) { |
|
74 | + unset($actions['pay']); |
|
75 | 75 | } |
76 | 76 | |
77 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
78 | - foreach ( $actions as $key => $action ) { |
|
77 | + if ($actions = apply_filters('wpinv_user_invoices_actions', $actions, $invoice)) { |
|
78 | + foreach ($actions as $key => $action) { |
|
79 | 79 | $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
80 | - echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
|
80 | + echo '<a href="' . esc_url($action['url']) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class($key) . '" ' . (!empty($action['attrs']) ? $action['attrs'] : '') . '>' . $action['name'] . '</a>'; |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | ?> |
@@ -89,9 +89,9 @@ discard block |
||
89 | 89 | </tbody> |
90 | 90 | </table> |
91 | 91 | |
92 | - <?php do_action( 'wpinv_before_user_invoices_pagination' ); ?> |
|
92 | + <?php do_action('wpinv_before_user_invoices_pagination'); ?> |
|
93 | 93 | |
94 | - <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
|
94 | + <?php if (1 < $user_invoices->max_num_pages) : ?> |
|
95 | 95 | <div class="invoicing-Pagination"> |
96 | 96 | <?php |
97 | 97 | $big = 999999; |
@@ -103,20 +103,20 @@ discard block |
||
103 | 103 | else |
104 | 104 | $current_page = 1; |
105 | 105 | |
106 | - echo paginate_links( array( |
|
107 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
106 | + echo paginate_links(array( |
|
107 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
108 | 108 | 'format' => '?paged=%#%', |
109 | - 'current' => max( 1, $current_page ), |
|
109 | + 'current' => max(1, $current_page), |
|
110 | 110 | 'total' => $user_invoices->max_num_pages, |
111 | - ) ); |
|
111 | + )); |
|
112 | 112 | ?> |
113 | 113 | </div> |
114 | 114 | <?php endif; ?> |
115 | 115 | |
116 | 116 | <?php } else { ?> |
117 | 117 | <div class="wpinv-empty alert-info"> |
118 | - <?php _e( 'No invoice has been made yet.', 'invoicing' ); ?> |
|
118 | + <?php _e('No invoice has been made yet.', 'invoicing'); ?> |
|
119 | 119 | </div> |
120 | 120 | <?php } ?> |
121 | 121 | |
122 | -<?php do_action( 'wpinv_after_user_invoices', $has_invoices ); ?> |
|
122 | +<?php do_action('wpinv_after_user_invoices', $has_invoices); ?> |
@@ -1,56 +1,56 @@ |
||
1 | 1 | <?php |
2 | -if ( !defined('ABSPATH') ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | -do_action( 'wpinv_invalid_invoice_before_display' ); ?><!DOCTYPE html> |
|
5 | +do_action('wpinv_invalid_invoice_before_display'); ?><!DOCTYPE html> |
|
6 | 6 | <html <?php language_attributes(); ?>> |
7 | 7 | <head> |
8 | 8 | <meta charset="UTF-8"> |
9 | 9 | <title><?php wp_title() ?></title> |
10 | - <meta charset="<?php bloginfo( 'charset' ); ?>" /> |
|
10 | + <meta charset="<?php bloginfo('charset'); ?>" /> |
|
11 | 11 | <meta name="viewport" content="width=device-width,initial-scale=1"> |
12 | 12 | <meta name="robots" content="noindex,nofollow"> |
13 | - <?php do_action( 'wpinv_invalid_invoice_head' ); ?> |
|
13 | + <?php do_action('wpinv_invalid_invoice_head'); ?> |
|
14 | 14 | </head> |
15 | 15 | <body class="body wpinv wpinv-print wpinv-invalid-invoice"> |
16 | - <?php do_action( 'wpinv_invalid_invoice_body_start' ); ?> |
|
16 | + <?php do_action('wpinv_invalid_invoice_body_start'); ?> |
|
17 | 17 | <div class="container wpinv-wrap"> |
18 | 18 | <!-- ///// Start Header --> |
19 | 19 | <htmlpageheader name="wpinv-pdf-header"> |
20 | - <?php do_action( 'wpinv_invalid_invoice_before_header' ); ?> |
|
20 | + <?php do_action('wpinv_invalid_invoice_before_header'); ?> |
|
21 | 21 | <div class="row wpinv-header"> |
22 | 22 | <div class="col-xs-12 wpinv-business"> |
23 | - <a target="_blank" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
24 | - <?php if ( $logo = wpinv_get_business_logo() ) { ?> |
|
25 | - <img class="logo" src="<?php echo esc_url( $logo ); ?>"> |
|
23 | + <a target="_blank" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
24 | + <?php if ($logo = wpinv_get_business_logo()) { ?> |
|
25 | + <img class="logo" src="<?php echo esc_url($logo); ?>"> |
|
26 | 26 | <?php } else { ?> |
27 | - <h1><?php echo esc_html( wpinv_get_business_name() ); ?></h1> |
|
27 | + <h1><?php echo esc_html(wpinv_get_business_name()); ?></h1> |
|
28 | 28 | <?php } ?> |
29 | 29 | </a> |
30 | 30 | </div> |
31 | 31 | </div> |
32 | - <?php do_action( 'wpinv_invalid_invoice_after_header' ); ?> |
|
32 | + <?php do_action('wpinv_invalid_invoice_after_header'); ?> |
|
33 | 33 | </htmlpageheader> |
34 | 34 | <!-- End Header ///// --> |
35 | 35 | |
36 | - <?php do_action( 'wpinv_invalid_invoice_before_content' ); ?> |
|
36 | + <?php do_action('wpinv_invalid_invoice_before_content'); ?> |
|
37 | 37 | |
38 | - <?php do_action( 'wpinv_invalid_invoice_content' ); ?> |
|
38 | + <?php do_action('wpinv_invalid_invoice_content'); ?> |
|
39 | 39 | |
40 | - <?php do_action( 'wpinv_invalid_invoice_after_content' ); ?> |
|
40 | + <?php do_action('wpinv_invalid_invoice_after_content'); ?> |
|
41 | 41 | |
42 | 42 | <!-- ///// Start Footer --> |
43 | 43 | <htmlpagefooter name="wpinv-pdf-footer"> |
44 | - <?php do_action( 'wpinv_invalid_invoice_before_footer' ); ?> |
|
44 | + <?php do_action('wpinv_invalid_invoice_before_footer'); ?> |
|
45 | 45 | <div class="row wpinv-footer"> |
46 | 46 | <div class="col-sm-12"> |
47 | 47 | <div class="footer-text"><?php echo wpinv_get_business_footer(); ?></div> |
48 | 48 | </div> |
49 | 49 | </div> |
50 | - <?php do_action( 'wpinv_invalid_invoice_after_footer' ); ?> |
|
50 | + <?php do_action('wpinv_invalid_invoice_after_footer'); ?> |
|
51 | 51 | </htmlpagefooter> |
52 | 52 | <!-- End Footer ///// --> |
53 | 53 | </div> |
54 | - <?php do_action( 'wpinv_invalid_invoice_body_end' ); ?> |
|
54 | + <?php do_action('wpinv_invalid_invoice_body_end'); ?> |
|
55 | 55 | </body> |
56 | 56 | </html> |
57 | 57 | \ No newline at end of file |
@@ -1,6 +1,8 @@ |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined( 'ABSPATH' ) ) { |
|
4 | + exit; |
|
5 | +} |
|
4 | 6 | |
5 | 7 | /** |
6 | 8 | * The Subscriptions DB Class |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | // Exit if accessed directly. |
3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
3 | +if (!defined('ABSPATH')) exit; |
|
4 | 4 | |
5 | 5 | /** |
6 | 6 | * The Subscriptions DB Class |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | 'transaction_id' => '', |
69 | 69 | 'parent_payment_id' => 0, |
70 | 70 | 'product_id' => 0, |
71 | - 'created' => date( 'Y-m-d H:i:s' ), |
|
72 | - 'expiration' => date( 'Y-m-d H:i:s' ), |
|
71 | + 'created' => date('Y-m-d H:i:s'), |
|
72 | + 'expiration' => date('Y-m-d H:i:s'), |
|
73 | 73 | 'trial_period' => '', |
74 | 74 | 'status' => '', |
75 | 75 | 'profile_id' => '', |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | * @access public |
83 | 83 | * @since 1.0.0 |
84 | 84 | */ |
85 | - public function get_subscriptions( $args = array() ) { |
|
85 | + public function get_subscriptions($args = array()) { |
|
86 | 86 | global $wpdb; |
87 | 87 | |
88 | 88 | $defaults = array( |
89 | - 'number' => get_option( 'posts_per_page' ), |
|
89 | + 'number' => get_option('posts_per_page'), |
|
90 | 90 | 'offset' => 0, |
91 | 91 | 'search' => '', |
92 | 92 | 'customer_id' => 0, |
@@ -94,21 +94,21 @@ discard block |
||
94 | 94 | 'order' => 'DESC' |
95 | 95 | ); |
96 | 96 | |
97 | - $args = wp_parse_args( $args, $defaults ); |
|
97 | + $args = wp_parse_args($args, $defaults); |
|
98 | 98 | |
99 | - if( $args['number'] < 1 ) { |
|
99 | + if ($args['number'] < 1) { |
|
100 | 100 | $args['number'] = 999999999999; |
101 | 101 | } |
102 | 102 | |
103 | 103 | $where = ' WHERE 1=1 '; |
104 | 104 | |
105 | 105 | // specific customers |
106 | - if( ! empty( $args['id'] ) ) { |
|
106 | + if (!empty($args['id'])) { |
|
107 | 107 | |
108 | - if( is_array( $args['id'] ) ) { |
|
109 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
108 | + if (is_array($args['id'])) { |
|
109 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
110 | 110 | } else { |
111 | - $ids = intval( $args['id'] ); |
|
111 | + $ids = intval($args['id']); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | } |
117 | 117 | |
118 | 118 | // Specific products |
119 | - if( ! empty( $args['product_id'] ) ) { |
|
119 | + if (!empty($args['product_id'])) { |
|
120 | 120 | |
121 | - if( is_array( $args['product_id'] ) ) { |
|
122 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
121 | + if (is_array($args['product_id'])) { |
|
122 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
123 | 123 | } else { |
124 | - $product_ids = intval( $args['product_id'] ); |
|
124 | + $product_ids = intval($args['product_id']); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -129,12 +129,12 @@ discard block |
||
129 | 129 | } |
130 | 130 | |
131 | 131 | // Specific parent payments |
132 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
132 | + if (!empty($args['parent_payment_id'])) { |
|
133 | 133 | |
134 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
135 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
134 | + if (is_array($args['parent_payment_id'])) { |
|
135 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
136 | 136 | } else { |
137 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
137 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -142,12 +142,12 @@ discard block |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | // Specific transaction IDs |
145 | - if( ! empty( $args['transaction_id'] ) ) { |
|
145 | + if (!empty($args['transaction_id'])) { |
|
146 | 146 | |
147 | - if( is_array( $args['transaction_id'] ) ) { |
|
148 | - $transaction_ids = implode( "','", array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
147 | + if (is_array($args['transaction_id'])) { |
|
148 | + $transaction_ids = implode("','", array_map('sanitize_text_field', $args['transaction_id'])); |
|
149 | 149 | } else { |
150 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
150 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | $where .= " AND `transaction_id` IN ( '{$transaction_ids}' ) "; |
@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | } |
156 | 156 | |
157 | 157 | // Subscriptoins for specific customers |
158 | - if( ! empty( $args['customer_id'] ) ) { |
|
158 | + if (!empty($args['customer_id'])) { |
|
159 | 159 | |
160 | - if( is_array( $args['customer_id'] ) ) { |
|
161 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
160 | + if (is_array($args['customer_id'])) { |
|
161 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
162 | 162 | } else { |
163 | - $customer_ids = intval( $args['customer_id'] ); |
|
163 | + $customer_ids = intval($args['customer_id']); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -168,12 +168,12 @@ discard block |
||
168 | 168 | } |
169 | 169 | |
170 | 170 | // Subscriptions for specific profile IDs |
171 | - if( ! empty( $args['profile_id'] ) ) { |
|
171 | + if (!empty($args['profile_id'])) { |
|
172 | 172 | |
173 | - if( is_array( $args['profile_id'] ) ) { |
|
174 | - $profile_ids = implode( "','", array_map('sanitize_text_field', $args['profile_id'] ) ); |
|
173 | + if (is_array($args['profile_id'])) { |
|
174 | + $profile_ids = implode("','", array_map('sanitize_text_field', $args['profile_id'])); |
|
175 | 175 | } else { |
176 | - $profile_ids = sanitize_text_field( $args['profile_id'] ); |
|
176 | + $profile_ids = sanitize_text_field($args['profile_id']); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $where .= " AND `profile_id` IN( '{$profile_ids}' ) "; |
@@ -181,12 +181,12 @@ discard block |
||
181 | 181 | } |
182 | 182 | |
183 | 183 | // Subscriptions for specific statuses |
184 | - if( ! empty( $args['status'] ) ) { |
|
184 | + if (!empty($args['status'])) { |
|
185 | 185 | |
186 | - if( is_array( $args['status'] ) ) { |
|
187 | - $statuses = implode( "','", array_map( 'sanitize_text_field', $args['status'] ) ); |
|
186 | + if (is_array($args['status'])) { |
|
187 | + $statuses = implode("','", array_map('sanitize_text_field', $args['status'])); |
|
188 | 188 | } else { |
189 | - $statuses = sanitize_text_field( $args['status'] ); |
|
189 | + $statuses = sanitize_text_field($args['status']); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | $where .= " AND `status` IN( '{$statuses}' ) "; |
@@ -194,21 +194,21 @@ discard block |
||
194 | 194 | } |
195 | 195 | |
196 | 196 | // Subscriptions created for a specific date or in a date range |
197 | - if( ! empty( $args['date'] ) ) { |
|
197 | + if (!empty($args['date'])) { |
|
198 | 198 | |
199 | - if( is_array( $args['date'] ) ) { |
|
199 | + if (is_array($args['date'])) { |
|
200 | 200 | |
201 | - if( ! empty( $args['date']['start'] ) ) { |
|
201 | + if (!empty($args['date']['start'])) { |
|
202 | 202 | |
203 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
203 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
204 | 204 | |
205 | 205 | $where .= " AND `created` >= '{$start}'"; |
206 | 206 | |
207 | 207 | } |
208 | 208 | |
209 | - if( ! empty( $args['date']['end'] ) ) { |
|
209 | + if (!empty($args['date']['end'])) { |
|
210 | 210 | |
211 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
211 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
212 | 212 | |
213 | 213 | $where .= " AND `created` <= '{$end}'"; |
214 | 214 | |
@@ -216,9 +216,9 @@ discard block |
||
216 | 216 | |
217 | 217 | } else { |
218 | 218 | |
219 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
220 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
221 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
219 | + $year = date('Y', strtotime($args['date'])); |
|
220 | + $month = date('m', strtotime($args['date'])); |
|
221 | + $day = date('d', strtotime($args['date'])); |
|
222 | 222 | |
223 | 223 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
224 | 224 | } |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | } |
227 | 227 | |
228 | 228 | // Subscriptions with a specific expiration date or in an expiration date range |
229 | - if( ! empty( $args['expiration'] ) ) { |
|
229 | + if (!empty($args['expiration'])) { |
|
230 | 230 | |
231 | - if( is_array( $args['expiration'] ) ) { |
|
231 | + if (is_array($args['expiration'])) { |
|
232 | 232 | |
233 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
233 | + if (!empty($args['expiration']['start'])) { |
|
234 | 234 | |
235 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
235 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
236 | 236 | |
237 | 237 | $where .= " AND `expiration` >= '{$start}'"; |
238 | 238 | |
239 | 239 | } |
240 | 240 | |
241 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
241 | + if (!empty($args['expiration']['end'])) { |
|
242 | 242 | |
243 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
243 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
244 | 244 | |
245 | 245 | $where .= " AND `expiration` <= '{$end}'"; |
246 | 246 | |
@@ -248,73 +248,73 @@ discard block |
||
248 | 248 | |
249 | 249 | } else { |
250 | 250 | |
251 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
252 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
253 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
251 | + $year = date('Y', strtotime($args['expiration'])); |
|
252 | + $month = date('m', strtotime($args['expiration'])); |
|
253 | + $day = date('d', strtotime($args['expiration'])); |
|
254 | 254 | |
255 | 255 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
259 | 259 | |
260 | - if ( ! empty( $args['search'] ) ) { |
|
260 | + if (!empty($args['search'])) { |
|
261 | 261 | |
262 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
262 | + if (false !== strpos('id:', $args['search'])) { |
|
263 | 263 | |
264 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
265 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
264 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
265 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
266 | 266 | |
267 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
267 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
268 | 268 | |
269 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
270 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
269 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
270 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
271 | 271 | |
272 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
272 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
273 | 273 | |
274 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
275 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
274 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
275 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
276 | 276 | |
277 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
277 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
278 | 278 | |
279 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
280 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
279 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
280 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
281 | 281 | |
282 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
282 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
283 | 283 | |
284 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
285 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
284 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
285 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
286 | 286 | |
287 | 287 | } else { |
288 | 288 | |
289 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
289 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
290 | 290 | |
291 | 291 | } |
292 | 292 | |
293 | 293 | } |
294 | 294 | |
295 | - $args['orderby'] = ! array_key_exists( $args['orderby'], $this->get_columns() ) ? 'id' : $args['orderby']; |
|
295 | + $args['orderby'] = !array_key_exists($args['orderby'], $this->get_columns()) ? 'id' : $args['orderby']; |
|
296 | 296 | |
297 | - if( 'amount' == $args['orderby'] ) { |
|
297 | + if ('amount' == $args['orderby']) { |
|
298 | 298 | $args['orderby'] = 'amount+0'; |
299 | 299 | } |
300 | 300 | |
301 | - $cache_key = md5( 'wpinv_subscriptions_' . serialize( $args ) ); |
|
301 | + $cache_key = md5('wpinv_subscriptions_' . serialize($args)); |
|
302 | 302 | |
303 | - $subscriptions = wp_cache_get( $cache_key, 'subscriptions' ); |
|
303 | + $subscriptions = wp_cache_get($cache_key, 'subscriptions'); |
|
304 | 304 | |
305 | - $args['orderby'] = esc_sql( $args['orderby'] ); |
|
306 | - $args['order'] = esc_sql( $args['order'] ); |
|
305 | + $args['orderby'] = esc_sql($args['orderby']); |
|
306 | + $args['order'] = esc_sql($args['order']); |
|
307 | 307 | |
308 | - if( $subscriptions === false ) { |
|
309 | - $subscriptions = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint( $args['offset'] ), absint( $args['number'] ) ), OBJECT ); |
|
308 | + if ($subscriptions === false) { |
|
309 | + $subscriptions = $wpdb->get_results($wpdb->prepare("SELECT * FROM $this->table_name $where ORDER BY {$args['orderby']} {$args['order']} LIMIT %d,%d;", absint($args['offset']), absint($args['number'])), OBJECT); |
|
310 | 310 | |
311 | - if( ! empty( $subscriptions ) ) { |
|
311 | + if (!empty($subscriptions)) { |
|
312 | 312 | |
313 | - foreach( $subscriptions as $key => $subscription ) { |
|
314 | - $subscriptions[ $key ] = new WPInv_Subscription( $subscription ); |
|
313 | + foreach ($subscriptions as $key => $subscription) { |
|
314 | + $subscriptions[$key] = new WPInv_Subscription($subscription); |
|
315 | 315 | } |
316 | 316 | |
317 | - wp_cache_set( $cache_key, $subscriptions, 'subscriptions', 3600 ); |
|
317 | + wp_cache_set($cache_key, $subscriptions, 'subscriptions', 3600); |
|
318 | 318 | |
319 | 319 | } |
320 | 320 | |
@@ -329,19 +329,19 @@ discard block |
||
329 | 329 | * @access public |
330 | 330 | * @since 1.0.0 |
331 | 331 | */ |
332 | - public function count( $args = array() ) { |
|
332 | + public function count($args = array()) { |
|
333 | 333 | |
334 | 334 | global $wpdb; |
335 | 335 | |
336 | 336 | $where = ' WHERE 1=1 '; |
337 | 337 | |
338 | 338 | // specific customers |
339 | - if( ! empty( $args['id'] ) ) { |
|
339 | + if (!empty($args['id'])) { |
|
340 | 340 | |
341 | - if( is_array( $args['id'] ) ) { |
|
342 | - $ids = implode( ',', array_map('intval', $args['id'] ) ); |
|
341 | + if (is_array($args['id'])) { |
|
342 | + $ids = implode(',', array_map('intval', $args['id'])); |
|
343 | 343 | } else { |
344 | - $ids = intval( $args['id'] ); |
|
344 | + $ids = intval($args['id']); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | $where .= " AND `id` IN( {$ids} ) "; |
@@ -349,12 +349,12 @@ discard block |
||
349 | 349 | } |
350 | 350 | |
351 | 351 | // Specific products |
352 | - if( ! empty( $args['product_id'] ) ) { |
|
352 | + if (!empty($args['product_id'])) { |
|
353 | 353 | |
354 | - if( is_array( $args['product_id'] ) ) { |
|
355 | - $product_ids = implode( ',', array_map('intval', $args['product_id'] ) ); |
|
354 | + if (is_array($args['product_id'])) { |
|
355 | + $product_ids = implode(',', array_map('intval', $args['product_id'])); |
|
356 | 356 | } else { |
357 | - $product_ids = intval( $args['product_id'] ); |
|
357 | + $product_ids = intval($args['product_id']); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | $where .= " AND `product_id` IN( {$product_ids} ) "; |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | } |
363 | 363 | |
364 | 364 | // Specific parent payments |
365 | - if( ! empty( $args['parent_payment_id'] ) ) { |
|
365 | + if (!empty($args['parent_payment_id'])) { |
|
366 | 366 | |
367 | - if( is_array( $args['parent_payment_id'] ) ) { |
|
368 | - $parent_payment_ids = implode( ',', array_map('intval', $args['parent_payment_id'] ) ); |
|
367 | + if (is_array($args['parent_payment_id'])) { |
|
368 | + $parent_payment_ids = implode(',', array_map('intval', $args['parent_payment_id'])); |
|
369 | 369 | } else { |
370 | - $parent_payment_ids = intval( $args['parent_payment_id'] ); |
|
370 | + $parent_payment_ids = intval($args['parent_payment_id']); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | $where .= " AND `parent_payment_id` IN( {$parent_payment_ids} ) "; |
@@ -375,12 +375,12 @@ discard block |
||
375 | 375 | } |
376 | 376 | |
377 | 377 | // Subscriptoins for specific customers |
378 | - if( ! empty( $args['customer_id'] ) ) { |
|
378 | + if (!empty($args['customer_id'])) { |
|
379 | 379 | |
380 | - if( is_array( $args['customer_id'] ) ) { |
|
381 | - $customer_ids = implode( ',', array_map('intval', $args['customer_id'] ) ); |
|
380 | + if (is_array($args['customer_id'])) { |
|
381 | + $customer_ids = implode(',', array_map('intval', $args['customer_id'])); |
|
382 | 382 | } else { |
383 | - $customer_ids = intval( $args['customer_id'] ); |
|
383 | + $customer_ids = intval($args['customer_id']); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | $where .= " AND `customer_id` IN( {$customer_ids} ) "; |
@@ -388,12 +388,12 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | // Subscriptions for specific profile IDs |
391 | - if( ! empty( $args['profile_id'] ) ) { |
|
391 | + if (!empty($args['profile_id'])) { |
|
392 | 392 | |
393 | - if( is_array( $args['profile_id'] ) ) { |
|
394 | - $profile_ids = implode( ',', array_map('intval', $args['profile_id'] ) ); |
|
393 | + if (is_array($args['profile_id'])) { |
|
394 | + $profile_ids = implode(',', array_map('intval', $args['profile_id'])); |
|
395 | 395 | } else { |
396 | - $profile_ids = intval( $args['profile_id'] ); |
|
396 | + $profile_ids = intval($args['profile_id']); |
|
397 | 397 | } |
398 | 398 | |
399 | 399 | $where .= " AND `profile_id` IN( {$profile_ids} ) "; |
@@ -401,12 +401,12 @@ discard block |
||
401 | 401 | } |
402 | 402 | |
403 | 403 | // Specific transaction IDs |
404 | - if( ! empty( $args['transaction_id'] ) ) { |
|
404 | + if (!empty($args['transaction_id'])) { |
|
405 | 405 | |
406 | - if( is_array( $args['transaction_id'] ) ) { |
|
407 | - $transaction_ids = implode( ',', array_map('sanitize_text_field', $args['transaction_id'] ) ); |
|
406 | + if (is_array($args['transaction_id'])) { |
|
407 | + $transaction_ids = implode(',', array_map('sanitize_text_field', $args['transaction_id'])); |
|
408 | 408 | } else { |
409 | - $transaction_ids = sanitize_text_field( $args['transaction_id'] ); |
|
409 | + $transaction_ids = sanitize_text_field($args['transaction_id']); |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | $where .= " AND `transaction_id` IN( {$transaction_ids} ) "; |
@@ -414,10 +414,10 @@ discard block |
||
414 | 414 | } |
415 | 415 | |
416 | 416 | // Subscriptions for specific statuses |
417 | - if( ! empty( $args['status'] ) ) { |
|
417 | + if (!empty($args['status'])) { |
|
418 | 418 | |
419 | - if( is_array( $args['status'] ) ) { |
|
420 | - $statuses = implode( ',', $args['status'] ); |
|
419 | + if (is_array($args['status'])) { |
|
420 | + $statuses = implode(',', $args['status']); |
|
421 | 421 | $where .= " AND `status` IN( {$statuses} ) "; |
422 | 422 | } else { |
423 | 423 | $statuses = $args['status']; |
@@ -429,21 +429,21 @@ discard block |
||
429 | 429 | } |
430 | 430 | |
431 | 431 | // Subscriptions created for a specific date or in a date range |
432 | - if( ! empty( $args['date'] ) ) { |
|
432 | + if (!empty($args['date'])) { |
|
433 | 433 | |
434 | - if( is_array( $args['date'] ) ) { |
|
434 | + if (is_array($args['date'])) { |
|
435 | 435 | |
436 | - if( ! empty( $args['date']['start'] ) ) { |
|
436 | + if (!empty($args['date']['start'])) { |
|
437 | 437 | |
438 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['date']['start'] ) ); |
|
438 | + $start = date('Y-m-d H:i:s', strtotime($args['date']['start'])); |
|
439 | 439 | |
440 | 440 | $where .= " AND `created` >= '{$start}'"; |
441 | 441 | |
442 | 442 | } |
443 | 443 | |
444 | - if( ! empty( $args['date']['end'] ) ) { |
|
444 | + if (!empty($args['date']['end'])) { |
|
445 | 445 | |
446 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['date']['end'] ) ); |
|
446 | + $end = date('Y-m-d H:i:s', strtotime($args['date']['end'])); |
|
447 | 447 | |
448 | 448 | $where .= " AND `created` <= '{$end}'"; |
449 | 449 | |
@@ -451,9 +451,9 @@ discard block |
||
451 | 451 | |
452 | 452 | } else { |
453 | 453 | |
454 | - $year = date( 'Y', strtotime( $args['date'] ) ); |
|
455 | - $month = date( 'm', strtotime( $args['date'] ) ); |
|
456 | - $day = date( 'd', strtotime( $args['date'] ) ); |
|
454 | + $year = date('Y', strtotime($args['date'])); |
|
455 | + $month = date('m', strtotime($args['date'])); |
|
456 | + $day = date('d', strtotime($args['date'])); |
|
457 | 457 | |
458 | 458 | $where .= " AND $year = YEAR ( created ) AND $month = MONTH ( created ) AND $day = DAY ( created )"; |
459 | 459 | } |
@@ -461,21 +461,21 @@ discard block |
||
461 | 461 | } |
462 | 462 | |
463 | 463 | // Subscriptions with a specific expiration date or in an expiration date range |
464 | - if( ! empty( $args['expiration'] ) ) { |
|
464 | + if (!empty($args['expiration'])) { |
|
465 | 465 | |
466 | - if( is_array( $args['expiration'] ) ) { |
|
466 | + if (is_array($args['expiration'])) { |
|
467 | 467 | |
468 | - if( ! empty( $args['expiration']['start'] ) ) { |
|
468 | + if (!empty($args['expiration']['start'])) { |
|
469 | 469 | |
470 | - $start = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['start'] ) ); |
|
470 | + $start = date('Y-m-d H:i:s', strtotime($args['expiration']['start'])); |
|
471 | 471 | |
472 | 472 | $where .= " AND `expiration` >= '{$start}'"; |
473 | 473 | |
474 | 474 | } |
475 | 475 | |
476 | - if( ! empty( $args['expiration']['end'] ) ) { |
|
476 | + if (!empty($args['expiration']['end'])) { |
|
477 | 477 | |
478 | - $end = date( 'Y-m-d H:i:s', strtotime( $args['expiration']['end'] ) ); |
|
478 | + $end = date('Y-m-d H:i:s', strtotime($args['expiration']['end'])); |
|
479 | 479 | |
480 | 480 | $where .= " AND `expiration` <= '{$end}'"; |
481 | 481 | |
@@ -483,64 +483,64 @@ discard block |
||
483 | 483 | |
484 | 484 | } else { |
485 | 485 | |
486 | - $year = date( 'Y', strtotime( $args['expiration'] ) ); |
|
487 | - $month = date( 'm', strtotime( $args['expiration'] ) ); |
|
488 | - $day = date( 'd', strtotime( $args['expiration'] ) ); |
|
486 | + $year = date('Y', strtotime($args['expiration'])); |
|
487 | + $month = date('m', strtotime($args['expiration'])); |
|
488 | + $day = date('d', strtotime($args['expiration'])); |
|
489 | 489 | |
490 | 490 | $where .= " AND $year = YEAR ( expiration ) AND $month = MONTH ( expiration ) AND $day = DAY ( expiration )"; |
491 | 491 | } |
492 | 492 | |
493 | 493 | } |
494 | 494 | |
495 | - if ( ! empty( $args['search'] ) ) { |
|
495 | + if (!empty($args['search'])) { |
|
496 | 496 | |
497 | - if( false !== strpos( 'id:', $args['search'] ) ) { |
|
497 | + if (false !== strpos('id:', $args['search'])) { |
|
498 | 498 | |
499 | - $args['search'] = trim( str_replace( 'id:', '', $args['search'] ) ); |
|
500 | - $where .= " AND `id` = '" . esc_sql( $args['search'] ) . "'"; |
|
499 | + $args['search'] = trim(str_replace('id:', '', $args['search'])); |
|
500 | + $where .= " AND `id` = '" . esc_sql($args['search']) . "'"; |
|
501 | 501 | |
502 | - } else if( false !== strpos( $args['search'], 'txn:' ) ) { |
|
502 | + } else if (false !== strpos($args['search'], 'txn:')) { |
|
503 | 503 | |
504 | - $args['search'] = trim( str_replace( 'txn:', '', $args['search'] ) ); |
|
505 | - $where .= " AND `transaction_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
504 | + $args['search'] = trim(str_replace('txn:', '', $args['search'])); |
|
505 | + $where .= " AND `transaction_id` = '" . esc_sql($args['search']) . "'"; |
|
506 | 506 | |
507 | - } else if( false !== strpos( $args['search'], 'profile_id:' ) ) { |
|
507 | + } else if (false !== strpos($args['search'], 'profile_id:')) { |
|
508 | 508 | |
509 | - $args['search'] = trim( str_replace( 'profile_id:', '', $args['search'] ) ); |
|
510 | - $where .= " AND `profile_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
509 | + $args['search'] = trim(str_replace('profile_id:', '', $args['search'])); |
|
510 | + $where .= " AND `profile_id` = '" . esc_sql($args['search']) . "'"; |
|
511 | 511 | |
512 | - } else if( false !== strpos( $args['search'], 'product_id:' ) ) { |
|
512 | + } else if (false !== strpos($args['search'], 'product_id:')) { |
|
513 | 513 | |
514 | - $args['search'] = trim( str_replace( 'product_id:', '', $args['search'] ) ); |
|
515 | - $where .= " AND `product_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
514 | + $args['search'] = trim(str_replace('product_id:', '', $args['search'])); |
|
515 | + $where .= " AND `product_id` = '" . esc_sql($args['search']) . "'"; |
|
516 | 516 | |
517 | - } else if( false !== strpos( $args['search'], 'customer_id:' ) ) { |
|
517 | + } else if (false !== strpos($args['search'], 'customer_id:')) { |
|
518 | 518 | |
519 | - $args['search'] = trim( str_replace( 'customer_id:', '', $args['search'] ) ); |
|
520 | - $where .= " AND `customer_id` = '" . esc_sql( $args['search'] ) . "'"; |
|
519 | + $args['search'] = trim(str_replace('customer_id:', '', $args['search'])); |
|
520 | + $where .= " AND `customer_id` = '" . esc_sql($args['search']) . "'"; |
|
521 | 521 | |
522 | 522 | } else { |
523 | 523 | |
524 | - $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `profile_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `transaction_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `product_id` LIKE '%%" . esc_sql( $args['search'] ) . "%%' OR `id` = '" . esc_sql( $args['search'] ) . "' )"; |
|
524 | + $where .= " AND ( `parent_payment_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `profile_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `transaction_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `product_id` LIKE '%%" . esc_sql($args['search']) . "%%' OR `id` = '" . esc_sql($args['search']) . "' )"; |
|
525 | 525 | |
526 | 526 | } |
527 | 527 | |
528 | 528 | } |
529 | 529 | |
530 | - $cache_key = md5( 'wpinv_subscriptions_count' . serialize( $args ) ); |
|
530 | + $cache_key = md5('wpinv_subscriptions_count' . serialize($args)); |
|
531 | 531 | |
532 | - $count = wp_cache_get( $cache_key, 'subscriptions' ); |
|
532 | + $count = wp_cache_get($cache_key, 'subscriptions'); |
|
533 | 533 | |
534 | - if( $count === false ) { |
|
534 | + if ($count === false) { |
|
535 | 535 | |
536 | 536 | $sql = "SELECT COUNT($this->primary_key) FROM " . $this->table_name . "{$where};"; |
537 | - $count = $wpdb->get_var( $sql ); |
|
537 | + $count = $wpdb->get_var($sql); |
|
538 | 538 | |
539 | - wp_cache_set( $cache_key, $count, 'subscriptions', 3600 ); |
|
539 | + wp_cache_set($cache_key, $count, 'subscriptions', 3600); |
|
540 | 540 | |
541 | 541 | } |
542 | 542 | |
543 | - return absint( $count ); |
|
543 | + return absint($count); |
|
544 | 544 | |
545 | 545 | } |
546 | 546 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | public function create_table() { |
554 | 554 | global $wpdb; |
555 | 555 | |
556 | - require_once( ABSPATH . 'wp-admin/includes/upgrade.php' ); |
|
556 | + require_once(ABSPATH . 'wp-admin/includes/upgrade.php'); |
|
557 | 557 | |
558 | 558 | $sql = "CREATE TABLE " . $this->table_name . " ( |
559 | 559 | id bigint(20) NOT NULL AUTO_INCREMENT, |
@@ -578,9 +578,9 @@ discard block |
||
578 | 578 | KEY customer_and_status ( customer_id, status) |
579 | 579 | ) CHARACTER SET utf8 COLLATE utf8_general_ci;"; |
580 | 580 | |
581 | - dbDelta( $sql ); |
|
581 | + dbDelta($sql); |
|
582 | 582 | |
583 | - update_option( $this->table_name . '_db_version', $this->version ); |
|
583 | + update_option($this->table_name . '_db_version', $this->version); |
|
584 | 584 | } |
585 | 585 | |
586 | 586 | } |
587 | 587 | \ No newline at end of file |
@@ -5,237 +5,237 @@ |
||
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
8 | - /** |
|
9 | - * The name of our database table |
|
10 | - * |
|
11 | - * @access public |
|
12 | - * @since 1.0.0 |
|
13 | - */ |
|
14 | - public $table_name; |
|
15 | - |
|
16 | - /** |
|
17 | - * The version of our database table |
|
18 | - * |
|
19 | - * @access public |
|
20 | - * @since 1.0.0 |
|
21 | - */ |
|
22 | - public $version; |
|
23 | - |
|
24 | - /** |
|
25 | - * The name of the primary column |
|
26 | - * |
|
27 | - * @access public |
|
28 | - * @since 1.0.0 |
|
29 | - */ |
|
30 | - public $primary_key; |
|
31 | - |
|
32 | - /** |
|
33 | - * Get things started |
|
34 | - * |
|
35 | - * @access public |
|
36 | - * @since 1.0.0 |
|
37 | - */ |
|
38 | - public function __construct() {} |
|
39 | - |
|
40 | - /** |
|
41 | - * Whitelist of columns |
|
42 | - * |
|
43 | - * @access public |
|
44 | - * @since 1.0.0 |
|
45 | - * @return array |
|
46 | - */ |
|
47 | - public function get_columns() { |
|
48 | - return array(); |
|
49 | - } |
|
50 | - |
|
51 | - /** |
|
52 | - * Default column values |
|
53 | - * |
|
54 | - * @access public |
|
55 | - * @since 1.0.0 |
|
56 | - * @return array |
|
57 | - */ |
|
58 | - public function get_column_defaults() { |
|
59 | - return array(); |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Retrieve a row by the primary key |
|
64 | - * |
|
65 | - * @access public |
|
66 | - * @since 1.0.0 |
|
67 | - * @return object |
|
68 | - */ |
|
69 | - public function get( $row_id ) { |
|
70 | - global $wpdb; |
|
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * Retrieve a row by a specific column / value |
|
76 | - * |
|
77 | - * @access public |
|
78 | - * @since 1.0.0 |
|
79 | - * @return object |
|
80 | - */ |
|
81 | - public function get_by( $column, $row_id ) { |
|
82 | - global $wpdb; |
|
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Retrieve a specific column's value by the primary key |
|
89 | - * |
|
90 | - * @access public |
|
91 | - * @since 1.0.0 |
|
92 | - * @return string |
|
93 | - */ |
|
94 | - public function get_column( $column, $row_id ) { |
|
95 | - global $wpdb; |
|
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | - } |
|
99 | - |
|
100 | - /** |
|
101 | - * Retrieve a specific column's value by the the specified column / value |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @since 1.0.0 |
|
105 | - * @return string |
|
106 | - */ |
|
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | - global $wpdb; |
|
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * Insert a new row |
|
116 | - * |
|
117 | - * @access public |
|
118 | - * @since 1.0.0 |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function insert( $data, $type = '' ) { |
|
122 | - global $wpdb; |
|
123 | - |
|
124 | - // Set default values |
|
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | - |
|
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | - |
|
129 | - // Initialise column format array |
|
130 | - $column_formats = $this->get_columns(); |
|
131 | - |
|
132 | - // Force fields to lower case |
|
133 | - $data = array_change_key_case( $data ); |
|
134 | - |
|
135 | - // White list columns |
|
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
137 | - |
|
138 | - // Reorder $column_formats to match the order of columns given in $data |
|
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | - |
|
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | - $wpdb_insert_id = $wpdb->insert_id; |
|
144 | - |
|
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | - |
|
147 | - return $wpdb_insert_id; |
|
148 | - } |
|
149 | - |
|
150 | - /** |
|
151 | - * Update a row |
|
152 | - * |
|
153 | - * @access public |
|
154 | - * @since 1.0.0 |
|
155 | - * @return bool |
|
156 | - */ |
|
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | - |
|
159 | - global $wpdb; |
|
160 | - |
|
161 | - // Row ID must be positive integer |
|
162 | - $row_id = absint( $row_id ); |
|
163 | - |
|
164 | - if( empty( $row_id ) ) { |
|
165 | - return false; |
|
166 | - } |
|
167 | - |
|
168 | - if( empty( $where ) ) { |
|
169 | - $where = $this->primary_key; |
|
170 | - } |
|
171 | - |
|
172 | - // Initialise column format array |
|
173 | - $column_formats = $this->get_columns(); |
|
174 | - |
|
175 | - // Force fields to lower case |
|
176 | - $data = array_change_key_case( $data ); |
|
177 | - |
|
178 | - // White list columns |
|
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
180 | - |
|
181 | - // Reorder $column_formats to match the order of columns given in $data |
|
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | - |
|
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | - return false; |
|
187 | - } |
|
188 | - |
|
189 | - return true; |
|
190 | - } |
|
191 | - |
|
192 | - /** |
|
193 | - * Delete a row identified by the primary key |
|
194 | - * |
|
195 | - * @access public |
|
196 | - * @since 1.0.0 |
|
197 | - * @return bool |
|
198 | - */ |
|
199 | - public function delete( $row_id = 0 ) { |
|
200 | - |
|
201 | - global $wpdb; |
|
202 | - |
|
203 | - // Row ID must be positive integer |
|
204 | - $row_id = absint( $row_id ); |
|
205 | - |
|
206 | - if( empty( $row_id ) ) { |
|
207 | - return false; |
|
208 | - } |
|
209 | - |
|
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | - return false; |
|
212 | - } |
|
213 | - |
|
214 | - return true; |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Check if the given table exists |
|
219 | - * |
|
220 | - * @since 2.4 |
|
221 | - * @param string $table The table name |
|
222 | - * @return bool If the table name exists |
|
223 | - */ |
|
224 | - public function table_exists( $table ) { |
|
225 | - global $wpdb; |
|
226 | - $table = sanitize_text_field( $table ); |
|
227 | - |
|
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Check if the table was ever installed |
|
233 | - * |
|
234 | - * @since 2.4 |
|
235 | - * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | - */ |
|
237 | - public function installed() { |
|
238 | - return $this->table_exists( $this->table_name ); |
|
239 | - } |
|
8 | + /** |
|
9 | + * The name of our database table |
|
10 | + * |
|
11 | + * @access public |
|
12 | + * @since 1.0.0 |
|
13 | + */ |
|
14 | + public $table_name; |
|
15 | + |
|
16 | + /** |
|
17 | + * The version of our database table |
|
18 | + * |
|
19 | + * @access public |
|
20 | + * @since 1.0.0 |
|
21 | + */ |
|
22 | + public $version; |
|
23 | + |
|
24 | + /** |
|
25 | + * The name of the primary column |
|
26 | + * |
|
27 | + * @access public |
|
28 | + * @since 1.0.0 |
|
29 | + */ |
|
30 | + public $primary_key; |
|
31 | + |
|
32 | + /** |
|
33 | + * Get things started |
|
34 | + * |
|
35 | + * @access public |
|
36 | + * @since 1.0.0 |
|
37 | + */ |
|
38 | + public function __construct() {} |
|
39 | + |
|
40 | + /** |
|
41 | + * Whitelist of columns |
|
42 | + * |
|
43 | + * @access public |
|
44 | + * @since 1.0.0 |
|
45 | + * @return array |
|
46 | + */ |
|
47 | + public function get_columns() { |
|
48 | + return array(); |
|
49 | + } |
|
50 | + |
|
51 | + /** |
|
52 | + * Default column values |
|
53 | + * |
|
54 | + * @access public |
|
55 | + * @since 1.0.0 |
|
56 | + * @return array |
|
57 | + */ |
|
58 | + public function get_column_defaults() { |
|
59 | + return array(); |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Retrieve a row by the primary key |
|
64 | + * |
|
65 | + * @access public |
|
66 | + * @since 1.0.0 |
|
67 | + * @return object |
|
68 | + */ |
|
69 | + public function get( $row_id ) { |
|
70 | + global $wpdb; |
|
71 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * Retrieve a row by a specific column / value |
|
76 | + * |
|
77 | + * @access public |
|
78 | + * @since 1.0.0 |
|
79 | + * @return object |
|
80 | + */ |
|
81 | + public function get_by( $column, $row_id ) { |
|
82 | + global $wpdb; |
|
83 | + $column = esc_sql( $column ); |
|
84 | + return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
85 | + } |
|
86 | + |
|
87 | + /** |
|
88 | + * Retrieve a specific column's value by the primary key |
|
89 | + * |
|
90 | + * @access public |
|
91 | + * @since 1.0.0 |
|
92 | + * @return string |
|
93 | + */ |
|
94 | + public function get_column( $column, $row_id ) { |
|
95 | + global $wpdb; |
|
96 | + $column = esc_sql( $column ); |
|
97 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
98 | + } |
|
99 | + |
|
100 | + /** |
|
101 | + * Retrieve a specific column's value by the the specified column / value |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @since 1.0.0 |
|
105 | + * @return string |
|
106 | + */ |
|
107 | + public function get_column_by( $column, $column_where, $column_value ) { |
|
108 | + global $wpdb; |
|
109 | + $column_where = esc_sql( $column_where ); |
|
110 | + $column = esc_sql( $column ); |
|
111 | + return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * Insert a new row |
|
116 | + * |
|
117 | + * @access public |
|
118 | + * @since 1.0.0 |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function insert( $data, $type = '' ) { |
|
122 | + global $wpdb; |
|
123 | + |
|
124 | + // Set default values |
|
125 | + $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
126 | + |
|
127 | + do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
128 | + |
|
129 | + // Initialise column format array |
|
130 | + $column_formats = $this->get_columns(); |
|
131 | + |
|
132 | + // Force fields to lower case |
|
133 | + $data = array_change_key_case( $data ); |
|
134 | + |
|
135 | + // White list columns |
|
136 | + $data = array_intersect_key( $data, $column_formats ); |
|
137 | + |
|
138 | + // Reorder $column_formats to match the order of columns given in $data |
|
139 | + $data_keys = array_keys( $data ); |
|
140 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
141 | + |
|
142 | + $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
143 | + $wpdb_insert_id = $wpdb->insert_id; |
|
144 | + |
|
145 | + do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
146 | + |
|
147 | + return $wpdb_insert_id; |
|
148 | + } |
|
149 | + |
|
150 | + /** |
|
151 | + * Update a row |
|
152 | + * |
|
153 | + * @access public |
|
154 | + * @since 1.0.0 |
|
155 | + * @return bool |
|
156 | + */ |
|
157 | + public function update( $row_id, $data = array(), $where = '' ) { |
|
158 | + |
|
159 | + global $wpdb; |
|
160 | + |
|
161 | + // Row ID must be positive integer |
|
162 | + $row_id = absint( $row_id ); |
|
163 | + |
|
164 | + if( empty( $row_id ) ) { |
|
165 | + return false; |
|
166 | + } |
|
167 | + |
|
168 | + if( empty( $where ) ) { |
|
169 | + $where = $this->primary_key; |
|
170 | + } |
|
171 | + |
|
172 | + // Initialise column format array |
|
173 | + $column_formats = $this->get_columns(); |
|
174 | + |
|
175 | + // Force fields to lower case |
|
176 | + $data = array_change_key_case( $data ); |
|
177 | + |
|
178 | + // White list columns |
|
179 | + $data = array_intersect_key( $data, $column_formats ); |
|
180 | + |
|
181 | + // Reorder $column_formats to match the order of columns given in $data |
|
182 | + $data_keys = array_keys( $data ); |
|
183 | + $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
184 | + |
|
185 | + if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
186 | + return false; |
|
187 | + } |
|
188 | + |
|
189 | + return true; |
|
190 | + } |
|
191 | + |
|
192 | + /** |
|
193 | + * Delete a row identified by the primary key |
|
194 | + * |
|
195 | + * @access public |
|
196 | + * @since 1.0.0 |
|
197 | + * @return bool |
|
198 | + */ |
|
199 | + public function delete( $row_id = 0 ) { |
|
200 | + |
|
201 | + global $wpdb; |
|
202 | + |
|
203 | + // Row ID must be positive integer |
|
204 | + $row_id = absint( $row_id ); |
|
205 | + |
|
206 | + if( empty( $row_id ) ) { |
|
207 | + return false; |
|
208 | + } |
|
209 | + |
|
210 | + if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
211 | + return false; |
|
212 | + } |
|
213 | + |
|
214 | + return true; |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Check if the given table exists |
|
219 | + * |
|
220 | + * @since 2.4 |
|
221 | + * @param string $table The table name |
|
222 | + * @return bool If the table name exists |
|
223 | + */ |
|
224 | + public function table_exists( $table ) { |
|
225 | + global $wpdb; |
|
226 | + $table = sanitize_text_field( $table ); |
|
227 | + |
|
228 | + return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Check if the table was ever installed |
|
233 | + * |
|
234 | + * @since 2.4 |
|
235 | + * @return bool Returns if the customers table was installed and upgrade routine run |
|
236 | + */ |
|
237 | + public function installed() { |
|
238 | + return $this->table_exists( $this->table_name ); |
|
239 | + } |
|
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if (!defined('ABSPATH')) exit; |
|
5 | 5 | |
6 | 6 | abstract class Wpinv_DB { |
7 | 7 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @since 1.0.0 |
67 | 67 | * @return object |
68 | 68 | */ |
69 | - public function get( $row_id ) { |
|
69 | + public function get($row_id) { |
|
70 | 70 | global $wpdb; |
71 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
71 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -78,10 +78,10 @@ discard block |
||
78 | 78 | * @since 1.0.0 |
79 | 79 | * @return object |
80 | 80 | */ |
81 | - public function get_by( $column, $row_id ) { |
|
81 | + public function get_by($column, $row_id) { |
|
82 | 82 | global $wpdb; |
83 | - $column = esc_sql( $column ); |
|
84 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
83 | + $column = esc_sql($column); |
|
84 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | * @since 1.0.0 |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public function get_column( $column, $row_id ) { |
|
94 | + public function get_column($column, $row_id) { |
|
95 | 95 | global $wpdb; |
96 | - $column = esc_sql( $column ); |
|
97 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
96 | + $column = esc_sql($column); |
|
97 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
@@ -104,11 +104,11 @@ discard block |
||
104 | 104 | * @since 1.0.0 |
105 | 105 | * @return string |
106 | 106 | */ |
107 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
107 | + public function get_column_by($column, $column_where, $column_value) { |
|
108 | 108 | global $wpdb; |
109 | - $column_where = esc_sql( $column_where ); |
|
110 | - $column = esc_sql( $column ); |
|
111 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
109 | + $column_where = esc_sql($column_where); |
|
110 | + $column = esc_sql($column); |
|
111 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | /** |
@@ -118,31 +118,31 @@ discard block |
||
118 | 118 | * @since 1.0.0 |
119 | 119 | * @return int |
120 | 120 | */ |
121 | - public function insert( $data, $type = '' ) { |
|
121 | + public function insert($data, $type = '') { |
|
122 | 122 | global $wpdb; |
123 | 123 | |
124 | 124 | // Set default values |
125 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
125 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
126 | 126 | |
127 | - do_action( 'wpinv_pre_insert_' . $type, $data ); |
|
127 | + do_action('wpinv_pre_insert_' . $type, $data); |
|
128 | 128 | |
129 | 129 | // Initialise column format array |
130 | 130 | $column_formats = $this->get_columns(); |
131 | 131 | |
132 | 132 | // Force fields to lower case |
133 | - $data = array_change_key_case( $data ); |
|
133 | + $data = array_change_key_case($data); |
|
134 | 134 | |
135 | 135 | // White list columns |
136 | - $data = array_intersect_key( $data, $column_formats ); |
|
136 | + $data = array_intersect_key($data, $column_formats); |
|
137 | 137 | |
138 | 138 | // Reorder $column_formats to match the order of columns given in $data |
139 | - $data_keys = array_keys( $data ); |
|
140 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
139 | + $data_keys = array_keys($data); |
|
140 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
141 | 141 | |
142 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
142 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
143 | 143 | $wpdb_insert_id = $wpdb->insert_id; |
144 | 144 | |
145 | - do_action( 'wpinv_post_insert_' . $type, $wpdb_insert_id, $data ); |
|
145 | + do_action('wpinv_post_insert_' . $type, $wpdb_insert_id, $data); |
|
146 | 146 | |
147 | 147 | return $wpdb_insert_id; |
148 | 148 | } |
@@ -154,18 +154,18 @@ discard block |
||
154 | 154 | * @since 1.0.0 |
155 | 155 | * @return bool |
156 | 156 | */ |
157 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
157 | + public function update($row_id, $data = array(), $where = '') { |
|
158 | 158 | |
159 | 159 | global $wpdb; |
160 | 160 | |
161 | 161 | // Row ID must be positive integer |
162 | - $row_id = absint( $row_id ); |
|
162 | + $row_id = absint($row_id); |
|
163 | 163 | |
164 | - if( empty( $row_id ) ) { |
|
164 | + if (empty($row_id)) { |
|
165 | 165 | return false; |
166 | 166 | } |
167 | 167 | |
168 | - if( empty( $where ) ) { |
|
168 | + if (empty($where)) { |
|
169 | 169 | $where = $this->primary_key; |
170 | 170 | } |
171 | 171 | |
@@ -173,16 +173,16 @@ discard block |
||
173 | 173 | $column_formats = $this->get_columns(); |
174 | 174 | |
175 | 175 | // Force fields to lower case |
176 | - $data = array_change_key_case( $data ); |
|
176 | + $data = array_change_key_case($data); |
|
177 | 177 | |
178 | 178 | // White list columns |
179 | - $data = array_intersect_key( $data, $column_formats ); |
|
179 | + $data = array_intersect_key($data, $column_formats); |
|
180 | 180 | |
181 | 181 | // Reorder $column_formats to match the order of columns given in $data |
182 | - $data_keys = array_keys( $data ); |
|
183 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
182 | + $data_keys = array_keys($data); |
|
183 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
184 | 184 | |
185 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
185 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
@@ -196,18 +196,18 @@ discard block |
||
196 | 196 | * @since 1.0.0 |
197 | 197 | * @return bool |
198 | 198 | */ |
199 | - public function delete( $row_id = 0 ) { |
|
199 | + public function delete($row_id = 0) { |
|
200 | 200 | |
201 | 201 | global $wpdb; |
202 | 202 | |
203 | 203 | // Row ID must be positive integer |
204 | - $row_id = absint( $row_id ); |
|
204 | + $row_id = absint($row_id); |
|
205 | 205 | |
206 | - if( empty( $row_id ) ) { |
|
206 | + if (empty($row_id)) { |
|
207 | 207 | return false; |
208 | 208 | } |
209 | 209 | |
210 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
210 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
211 | 211 | return false; |
212 | 212 | } |
213 | 213 | |
@@ -221,11 +221,11 @@ discard block |
||
221 | 221 | * @param string $table The table name |
222 | 222 | * @return bool If the table name exists |
223 | 223 | */ |
224 | - public function table_exists( $table ) { |
|
224 | + public function table_exists($table) { |
|
225 | 225 | global $wpdb; |
226 | - $table = sanitize_text_field( $table ); |
|
226 | + $table = sanitize_text_field($table); |
|
227 | 227 | |
228 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
228 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * @return bool Returns if the customers table was installed and upgrade routine run |
236 | 236 | */ |
237 | 237 | public function installed() { |
238 | - return $this->table_exists( $this->table_name ); |
|
238 | + return $this->table_exists($this->table_name); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | } |
@@ -1,7 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // Exit if accessed directly |
4 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
4 | +if ( ! defined( 'ABSPATH' ) ) { |
|
5 | + exit; |
|
6 | +} |
|
5 | 7 | |
6 | 8 | abstract class Wpinv_DB { |
7 | 9 |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
11 | +if ( ! defined( 'ABSPATH' ) ) { |
|
12 | + exit; |
|
13 | +} |
|
12 | 14 | |
13 | 15 | |
14 | 16 | // Load WP_List_Table if not loaded |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | |
14 | 14 | // Load WP_List_Table if not loaded |
15 | 15 | if( ! class_exists( 'WP_List_Table' ) ) { |
16 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
16 | + require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
17 | 17 | } |
18 | 18 | |
19 | 19 | /** |
@@ -23,102 +23,102 @@ discard block |
||
23 | 23 | */ |
24 | 24 | class WPInv_Subscription_Reports_Table extends WP_List_Table { |
25 | 25 | |
26 | - /** |
|
27 | - * Number of results to show per page |
|
28 | - * |
|
29 | - * @since 1.0.0 |
|
30 | - */ |
|
31 | - |
|
32 | - public $per_page = 20; |
|
33 | - public $total_count = 0; |
|
34 | - public $active_count = 0; |
|
35 | - public $pending_count = 0; |
|
36 | - public $expired_count = 0; |
|
37 | - public $completed_count = 0; |
|
38 | - public $trialling_count = 0; |
|
39 | - public $cancelled_count = 0; |
|
40 | - public $failing_count = 0; |
|
41 | - |
|
42 | - /** |
|
43 | - * Get things started |
|
44 | - * |
|
45 | - * @access private |
|
46 | - * @since 1.0.0 |
|
47 | - * @return void |
|
48 | - */ |
|
49 | - function __construct(){ |
|
50 | - global $status, $page; |
|
51 | - |
|
52 | - // Set parent defaults |
|
53 | - parent::__construct( array( |
|
54 | - 'singular' => 'subscription', |
|
55 | - 'plural' => 'subscriptions', |
|
56 | - 'ajax' => false |
|
57 | - ) ); |
|
58 | - |
|
59 | - $this->get_subscription_counts(); |
|
60 | - |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Retrieve the view types |
|
65 | - * |
|
66 | - * @access public |
|
67 | - * @since 1.0.0 |
|
68 | - * @return array $views All the views available |
|
69 | - */ |
|
70 | - public function get_views() { |
|
71 | - |
|
72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | - $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
75 | - $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | - $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | - |
|
82 | - $views = array( |
|
83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
91 | - ); |
|
92 | - |
|
93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Show the search field |
|
98 | - * |
|
99 | - * @since 2.5 |
|
100 | - * @access public |
|
101 | - * |
|
102 | - * @param string $text Label for the search box |
|
103 | - * @param string $input_id ID of the search box |
|
104 | - * |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function search_box( $text, $input_id ) { |
|
108 | - |
|
109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
110 | - return; |
|
111 | - } |
|
112 | - |
|
113 | - $input_id = $input_id . '-search-input'; |
|
114 | - |
|
115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
117 | - } |
|
118 | - |
|
119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
121 | - } |
|
26 | + /** |
|
27 | + * Number of results to show per page |
|
28 | + * |
|
29 | + * @since 1.0.0 |
|
30 | + */ |
|
31 | + |
|
32 | + public $per_page = 20; |
|
33 | + public $total_count = 0; |
|
34 | + public $active_count = 0; |
|
35 | + public $pending_count = 0; |
|
36 | + public $expired_count = 0; |
|
37 | + public $completed_count = 0; |
|
38 | + public $trialling_count = 0; |
|
39 | + public $cancelled_count = 0; |
|
40 | + public $failing_count = 0; |
|
41 | + |
|
42 | + /** |
|
43 | + * Get things started |
|
44 | + * |
|
45 | + * @access private |
|
46 | + * @since 1.0.0 |
|
47 | + * @return void |
|
48 | + */ |
|
49 | + function __construct(){ |
|
50 | + global $status, $page; |
|
51 | + |
|
52 | + // Set parent defaults |
|
53 | + parent::__construct( array( |
|
54 | + 'singular' => 'subscription', |
|
55 | + 'plural' => 'subscriptions', |
|
56 | + 'ajax' => false |
|
57 | + ) ); |
|
58 | + |
|
59 | + $this->get_subscription_counts(); |
|
60 | + |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Retrieve the view types |
|
65 | + * |
|
66 | + * @access public |
|
67 | + * @since 1.0.0 |
|
68 | + * @return array $views All the views available |
|
69 | + */ |
|
70 | + public function get_views() { |
|
71 | + |
|
72 | + $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | + $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
|
75 | + $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
|
76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | + $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
|
78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | + |
|
82 | + $views = array( |
|
83 | + 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | + 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | + 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | + 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | + 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | + 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | + 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | + 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
91 | + ); |
|
92 | + |
|
93 | + return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Show the search field |
|
98 | + * |
|
99 | + * @since 2.5 |
|
100 | + * @access public |
|
101 | + * |
|
102 | + * @param string $text Label for the search box |
|
103 | + * @param string $input_id ID of the search box |
|
104 | + * |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function search_box( $text, $input_id ) { |
|
108 | + |
|
109 | + if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
110 | + return; |
|
111 | + } |
|
112 | + |
|
113 | + $input_id = $input_id . '-search-input'; |
|
114 | + |
|
115 | + if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
117 | + } |
|
118 | + |
|
119 | + if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | + echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
121 | + } |
|
122 | 122 | ?> |
123 | 123 | <p class="search-box"> |
124 | 124 | <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
@@ -127,18 +127,18 @@ discard block |
||
127 | 127 | <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
128 | 128 | </p> |
129 | 129 | <?php |
130 | - } |
|
131 | - |
|
132 | - /** |
|
133 | - * Render most columns |
|
134 | - * |
|
135 | - * @access private |
|
136 | - * @since 1.0.0 |
|
137 | - * @return string |
|
138 | - */ |
|
139 | - function column_default( $item, $column_name ) { |
|
140 | - return $item->$column_name; |
|
141 | - } |
|
130 | + } |
|
131 | + |
|
132 | + /** |
|
133 | + * Render most columns |
|
134 | + * |
|
135 | + * @access private |
|
136 | + * @since 1.0.0 |
|
137 | + * @return string |
|
138 | + */ |
|
139 | + function column_default( $item, $column_name ) { |
|
140 | + return $item->$column_name; |
|
141 | + } |
|
142 | 142 | |
143 | 143 | /** |
144 | 144 | * Subscription id column |
@@ -151,244 +151,244 @@ discard block |
||
151 | 151 | return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
152 | 152 | } |
153 | 153 | |
154 | - /** |
|
155 | - * Customer column |
|
156 | - * |
|
157 | - * @access private |
|
158 | - * @since 1.0.0 |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - function column_customer_id( $item ) { |
|
162 | - $subscriber = get_userdata( $item->customer_id ); |
|
163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | - |
|
165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Status column |
|
170 | - * |
|
171 | - * @access private |
|
172 | - * @since 1.0.0 |
|
173 | - * @return string |
|
174 | - */ |
|
175 | - function column_status( $item ) { |
|
176 | - return $item->get_status_label(); |
|
177 | - } |
|
178 | - |
|
179 | - /** |
|
180 | - * Period column |
|
181 | - * |
|
182 | - * @access private |
|
183 | - * @since 1.0.0 |
|
184 | - * @return string |
|
185 | - */ |
|
186 | - function column_period( $item ) { |
|
187 | - |
|
188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
189 | - |
|
190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
191 | - } |
|
192 | - |
|
193 | - /** |
|
194 | - * Billing Times column |
|
195 | - * |
|
196 | - * @access private |
|
197 | - * @since 1.0.0 |
|
198 | - * @return string |
|
199 | - */ |
|
200 | - function column_bill_times( $item ) { |
|
201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
202 | - } |
|
203 | - |
|
204 | - /** |
|
205 | - * Initial Amount column |
|
206 | - * |
|
207 | - * @access private |
|
208 | - * @since 1.0.0 |
|
209 | - * @return string |
|
210 | - */ |
|
211 | - function column_initial_amount( $item ) { |
|
212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
213 | - } |
|
214 | - |
|
215 | - /** |
|
216 | - * Renewal date column |
|
217 | - * |
|
218 | - * @access private |
|
219 | - * @since 1.0.0 |
|
220 | - * @return string |
|
221 | - */ |
|
222 | - function column_renewal_date( $item ) { |
|
223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
224 | - } |
|
225 | - |
|
226 | - /** |
|
227 | - * Payment column |
|
228 | - * |
|
229 | - * @access private |
|
230 | - * @since 1.0.0 |
|
231 | - * @return string |
|
232 | - */ |
|
233 | - function column_parent_payment_id( $item ) { |
|
234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
235 | - } |
|
236 | - |
|
237 | - /** |
|
238 | - * Product ID column |
|
239 | - * |
|
240 | - * @access private |
|
241 | - * @since 1.0.0 |
|
242 | - * @return string |
|
243 | - */ |
|
244 | - function column_product_id( $item ) { |
|
245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
246 | - } |
|
247 | - |
|
248 | - /** |
|
249 | - * Render the edit column |
|
250 | - * |
|
251 | - * @access private |
|
252 | - * @since 2.0 |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - function column_actions( $item ) { |
|
256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * Retrieve the table columns |
|
262 | - * |
|
263 | - * @access private |
|
264 | - * @since 1.0.0 |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - |
|
268 | - function get_columns(){ |
|
269 | - $columns = array( |
|
270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | - 'status' => __( 'Status', 'invoicing' ), |
|
273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
280 | - ); |
|
281 | - |
|
282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
283 | - } |
|
284 | - |
|
285 | - /** |
|
286 | - * Retrieve the current page number |
|
287 | - * |
|
288 | - * @access private |
|
289 | - * @since 1.0.0 |
|
290 | - * @return int |
|
291 | - */ |
|
292 | - function get_paged() { |
|
293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
294 | - } |
|
295 | - |
|
296 | - /** |
|
297 | - * Retrieve the subscription counts |
|
298 | - * |
|
299 | - * @access public |
|
300 | - * @since 1.4 |
|
301 | - * @return void |
|
302 | - */ |
|
303 | - public function get_subscription_counts() { |
|
304 | - |
|
305 | - global $wp_query; |
|
306 | - |
|
307 | - $db = new WPInv_Subscriptions_DB; |
|
308 | - |
|
309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
310 | - |
|
311 | - $this->total_count = $db->count(); |
|
312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
319 | - |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * Setup the final data for the table |
|
324 | - * |
|
325 | - * @access private |
|
326 | - * @since 1.0.0 |
|
327 | - * @uses $this->_column_headers |
|
328 | - * @uses $this->items |
|
329 | - * @uses $this->get_columns() |
|
330 | - * @uses $this->get_sortable_columns() |
|
331 | - * @uses $this->get_pagenum() |
|
332 | - * @uses $this->set_pagination_args() |
|
333 | - * @return array |
|
334 | - */ |
|
335 | - function prepare_items() { |
|
336 | - |
|
337 | - $columns = $this->get_columns(); |
|
338 | - $hidden = array(); // No hidden columns |
|
339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
340 | - $sortable = $this->get_sortable_columns(); |
|
341 | - |
|
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
343 | - |
|
344 | - $current_page = $this->get_pagenum(); |
|
345 | - |
|
346 | - $db = new WPInv_Subscriptions_DB; |
|
347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
348 | - $args = array( |
|
349 | - 'number' => $this->per_page, |
|
350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
351 | - 'search' => $search |
|
352 | - ); |
|
353 | - |
|
354 | - if ( 'any' !== $status ) { |
|
355 | - $args['status'] = $status; |
|
356 | - } |
|
357 | - |
|
358 | - $this->items = $db->get_subscriptions( $args ); |
|
359 | - |
|
360 | - switch ( $status ) { |
|
361 | - case 'active': |
|
362 | - $total_items = $this->active_count; |
|
363 | - break; |
|
364 | - case 'pending': |
|
365 | - $total_items = $this->pending_count; |
|
366 | - break; |
|
367 | - case 'expired': |
|
368 | - $total_items = $this->expired_count; |
|
369 | - break; |
|
370 | - case 'cancelled': |
|
371 | - $total_items = $this->cancelled_count; |
|
372 | - break; |
|
373 | - case 'failing': |
|
374 | - $total_items = $this->failing_count; |
|
375 | - break; |
|
376 | - case 'trialling': |
|
377 | - $total_items = $this->trialling_count; |
|
378 | - break; |
|
379 | - case 'completed': |
|
380 | - $total_items = $this->completed_count; |
|
381 | - break; |
|
382 | - case 'any': |
|
383 | - default: |
|
384 | - $total_items = $this->total_count; |
|
385 | - break; |
|
386 | - } |
|
387 | - |
|
388 | - $this->set_pagination_args( array( |
|
389 | - 'total_items' => $total_items, |
|
390 | - 'per_page' => $this->per_page, |
|
391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | - ) ); |
|
393 | - } |
|
154 | + /** |
|
155 | + * Customer column |
|
156 | + * |
|
157 | + * @access private |
|
158 | + * @since 1.0.0 |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + function column_customer_id( $item ) { |
|
162 | + $subscriber = get_userdata( $item->customer_id ); |
|
163 | + $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | + |
|
165 | + return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Status column |
|
170 | + * |
|
171 | + * @access private |
|
172 | + * @since 1.0.0 |
|
173 | + * @return string |
|
174 | + */ |
|
175 | + function column_status( $item ) { |
|
176 | + return $item->get_status_label(); |
|
177 | + } |
|
178 | + |
|
179 | + /** |
|
180 | + * Period column |
|
181 | + * |
|
182 | + * @access private |
|
183 | + * @since 1.0.0 |
|
184 | + * @return string |
|
185 | + */ |
|
186 | + function column_period( $item ) { |
|
187 | + |
|
188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
189 | + |
|
190 | + return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
191 | + } |
|
192 | + |
|
193 | + /** |
|
194 | + * Billing Times column |
|
195 | + * |
|
196 | + * @access private |
|
197 | + * @since 1.0.0 |
|
198 | + * @return string |
|
199 | + */ |
|
200 | + function column_bill_times( $item ) { |
|
201 | + return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
202 | + } |
|
203 | + |
|
204 | + /** |
|
205 | + * Initial Amount column |
|
206 | + * |
|
207 | + * @access private |
|
208 | + * @since 1.0.0 |
|
209 | + * @return string |
|
210 | + */ |
|
211 | + function column_initial_amount( $item ) { |
|
212 | + return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
213 | + } |
|
214 | + |
|
215 | + /** |
|
216 | + * Renewal date column |
|
217 | + * |
|
218 | + * @access private |
|
219 | + * @since 1.0.0 |
|
220 | + * @return string |
|
221 | + */ |
|
222 | + function column_renewal_date( $item ) { |
|
223 | + return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
224 | + } |
|
225 | + |
|
226 | + /** |
|
227 | + * Payment column |
|
228 | + * |
|
229 | + * @access private |
|
230 | + * @since 1.0.0 |
|
231 | + * @return string |
|
232 | + */ |
|
233 | + function column_parent_payment_id( $item ) { |
|
234 | + return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
235 | + } |
|
236 | + |
|
237 | + /** |
|
238 | + * Product ID column |
|
239 | + * |
|
240 | + * @access private |
|
241 | + * @since 1.0.0 |
|
242 | + * @return string |
|
243 | + */ |
|
244 | + function column_product_id( $item ) { |
|
245 | + return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
246 | + } |
|
247 | + |
|
248 | + /** |
|
249 | + * Render the edit column |
|
250 | + * |
|
251 | + * @access private |
|
252 | + * @since 2.0 |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + function column_actions( $item ) { |
|
256 | + return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * Retrieve the table columns |
|
262 | + * |
|
263 | + * @access private |
|
264 | + * @since 1.0.0 |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + |
|
268 | + function get_columns(){ |
|
269 | + $columns = array( |
|
270 | + 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | + 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | + 'status' => __( 'Status', 'invoicing' ), |
|
273 | + 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | + 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | + 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | + 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | + 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | + 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | + 'actions' => __( 'Actions', 'invoicing' ), |
|
280 | + ); |
|
281 | + |
|
282 | + return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
283 | + } |
|
284 | + |
|
285 | + /** |
|
286 | + * Retrieve the current page number |
|
287 | + * |
|
288 | + * @access private |
|
289 | + * @since 1.0.0 |
|
290 | + * @return int |
|
291 | + */ |
|
292 | + function get_paged() { |
|
293 | + return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
294 | + } |
|
295 | + |
|
296 | + /** |
|
297 | + * Retrieve the subscription counts |
|
298 | + * |
|
299 | + * @access public |
|
300 | + * @since 1.4 |
|
301 | + * @return void |
|
302 | + */ |
|
303 | + public function get_subscription_counts() { |
|
304 | + |
|
305 | + global $wp_query; |
|
306 | + |
|
307 | + $db = new WPInv_Subscriptions_DB; |
|
308 | + |
|
309 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
310 | + |
|
311 | + $this->total_count = $db->count(); |
|
312 | + $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | + $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | + $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | + $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | + $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | + $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | + $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
319 | + |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Setup the final data for the table |
|
324 | + * |
|
325 | + * @access private |
|
326 | + * @since 1.0.0 |
|
327 | + * @uses $this->_column_headers |
|
328 | + * @uses $this->items |
|
329 | + * @uses $this->get_columns() |
|
330 | + * @uses $this->get_sortable_columns() |
|
331 | + * @uses $this->get_pagenum() |
|
332 | + * @uses $this->set_pagination_args() |
|
333 | + * @return array |
|
334 | + */ |
|
335 | + function prepare_items() { |
|
336 | + |
|
337 | + $columns = $this->get_columns(); |
|
338 | + $hidden = array(); // No hidden columns |
|
339 | + $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
340 | + $sortable = $this->get_sortable_columns(); |
|
341 | + |
|
342 | + $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
343 | + |
|
344 | + $current_page = $this->get_pagenum(); |
|
345 | + |
|
346 | + $db = new WPInv_Subscriptions_DB; |
|
347 | + $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
348 | + $args = array( |
|
349 | + 'number' => $this->per_page, |
|
350 | + 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
351 | + 'search' => $search |
|
352 | + ); |
|
353 | + |
|
354 | + if ( 'any' !== $status ) { |
|
355 | + $args['status'] = $status; |
|
356 | + } |
|
357 | + |
|
358 | + $this->items = $db->get_subscriptions( $args ); |
|
359 | + |
|
360 | + switch ( $status ) { |
|
361 | + case 'active': |
|
362 | + $total_items = $this->active_count; |
|
363 | + break; |
|
364 | + case 'pending': |
|
365 | + $total_items = $this->pending_count; |
|
366 | + break; |
|
367 | + case 'expired': |
|
368 | + $total_items = $this->expired_count; |
|
369 | + break; |
|
370 | + case 'cancelled': |
|
371 | + $total_items = $this->cancelled_count; |
|
372 | + break; |
|
373 | + case 'failing': |
|
374 | + $total_items = $this->failing_count; |
|
375 | + break; |
|
376 | + case 'trialling': |
|
377 | + $total_items = $this->trialling_count; |
|
378 | + break; |
|
379 | + case 'completed': |
|
380 | + $total_items = $this->completed_count; |
|
381 | + break; |
|
382 | + case 'any': |
|
383 | + default: |
|
384 | + $total_items = $this->total_count; |
|
385 | + break; |
|
386 | + } |
|
387 | + |
|
388 | + $this->set_pagination_args( array( |
|
389 | + 'total_items' => $total_items, |
|
390 | + 'per_page' => $this->per_page, |
|
391 | + 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | + ) ); |
|
393 | + } |
|
394 | 394 | } |
@@ -8,11 +8,11 @@ discard block |
||
8 | 8 | |
9 | 9 | |
10 | 10 | // Exit if accessed directly |
11 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
11 | +if (!defined('ABSPATH')) exit; |
|
12 | 12 | |
13 | 13 | |
14 | 14 | // Load WP_List_Table if not loaded |
15 | -if( ! class_exists( 'WP_List_Table' ) ) { |
|
15 | +if (!class_exists('WP_List_Table')) { |
|
16 | 16 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
17 | 17 | } |
18 | 18 | |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | public $pending_count = 0; |
36 | 36 | public $expired_count = 0; |
37 | 37 | public $completed_count = 0; |
38 | - public $trialling_count = 0; |
|
38 | + public $trialling_count = 0; |
|
39 | 39 | public $cancelled_count = 0; |
40 | 40 | public $failing_count = 0; |
41 | 41 | |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | * @since 1.0.0 |
47 | 47 | * @return void |
48 | 48 | */ |
49 | - function __construct(){ |
|
49 | + function __construct() { |
|
50 | 50 | global $status, $page; |
51 | 51 | |
52 | 52 | // Set parent defaults |
53 | - parent::__construct( array( |
|
53 | + parent::__construct(array( |
|
54 | 54 | 'singular' => 'subscription', |
55 | 55 | 'plural' => 'subscriptions', |
56 | 56 | 'ajax' => false |
57 | - ) ); |
|
57 | + )); |
|
58 | 58 | |
59 | 59 | $this->get_subscription_counts(); |
60 | 60 | |
@@ -69,28 +69,28 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function get_views() { |
71 | 71 | |
72 | - $current = isset( $_GET['status'] ) ? $_GET['status'] : ''; |
|
73 | - $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
72 | + $current = isset($_GET['status']) ? $_GET['status'] : ''; |
|
73 | + $total_count = ' <span class="count">(' . $this->total_count . ')</span>'; |
|
74 | 74 | $active_count = ' <span class="count">(' . $this->active_count . ')</span>'; |
75 | 75 | $pending_count = ' <span class="count">(' . $this->pending_count . ')</span>'; |
76 | - $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
76 | + $expired_count = ' <span class="count">(' . $this->expired_count . ')</span>'; |
|
77 | 77 | $completed_count = ' <span class="count">(' . $this->completed_count . ')</span>'; |
78 | - $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | - $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | - $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
78 | + $trialling_count = ' <span class="count">(' . $this->trialling_count . ')</span>'; |
|
79 | + $cancelled_count = ' <span class="count">(' . $this->cancelled_count . ')</span>'; |
|
80 | + $failing_count = ' <span class="count">(' . $this->failing_count . ')</span>'; |
|
81 | 81 | |
82 | 82 | $views = array( |
83 | - 'all' => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ), |
|
84 | - 'active' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ), |
|
85 | - 'pending' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ), |
|
86 | - 'expired' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ), |
|
87 | - 'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ), |
|
88 | - 'trialling' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ), |
|
89 | - 'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ), |
|
90 | - 'failing' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ), |
|
83 | + 'all' => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array('status', 'paged')), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'invoicing') . $total_count), |
|
84 | + 'active' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'active', 'paged' => FALSE)), $current === 'active' ? ' class="current"' : '', __('Active', 'invoicing') . $active_count), |
|
85 | + 'pending' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'pending', 'paged' => FALSE)), $current === 'pending' ? ' class="current"' : '', __('Pending', 'invoicing') . $pending_count), |
|
86 | + 'expired' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'expired', 'paged' => FALSE)), $current === 'expired' ? ' class="current"' : '', __('Expired', 'invoicing') . $expired_count), |
|
87 | + 'completed' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'completed', 'paged' => FALSE)), $current === 'completed' ? ' class="current"' : '', __('Completed', 'invoicing') . $completed_count), |
|
88 | + 'trialling' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'trialling', 'paged' => FALSE)), $current === 'trialling' ? ' class="current"' : '', __('Trialling', 'invoicing') . $trialling_count), |
|
89 | + 'cancelled' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'cancelled', 'paged' => FALSE)), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'invoicing') . $cancelled_count), |
|
90 | + 'failing' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'failing', 'paged' => FALSE)), $current === 'failing' ? ' class="current"' : '', __('Failing', 'invoicing') . $failing_count), |
|
91 | 91 | ); |
92 | 92 | |
93 | - return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views ); |
|
93 | + return apply_filters('wpinv_recurring_subscriptions_table_views', $views); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | /** |
@@ -104,27 +104,27 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @return void |
106 | 106 | */ |
107 | - public function search_box( $text, $input_id ) { |
|
107 | + public function search_box($text, $input_id) { |
|
108 | 108 | |
109 | - if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) { |
|
109 | + if (empty($_REQUEST['s']) && !$this->has_items()) { |
|
110 | 110 | return; |
111 | 111 | } |
112 | 112 | |
113 | 113 | $input_id = $input_id . '-search-input'; |
114 | 114 | |
115 | - if ( ! empty( $_REQUEST['orderby'] ) ) { |
|
116 | - echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />'; |
|
115 | + if (!empty($_REQUEST['orderby'])) { |
|
116 | + echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />'; |
|
117 | 117 | } |
118 | 118 | |
119 | - if ( ! empty( $_REQUEST['order'] ) ) { |
|
120 | - echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />'; |
|
119 | + if (!empty($_REQUEST['order'])) { |
|
120 | + echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />'; |
|
121 | 121 | } |
122 | 122 | ?> |
123 | 123 | <p class="search-box"> |
124 | - <?php do_action( 'wpinv_recurring_subscription_search_box' ); ?> |
|
124 | + <?php do_action('wpinv_recurring_subscription_search_box'); ?> |
|
125 | 125 | <label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label> |
126 | 126 | <input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" /> |
127 | - <?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/> |
|
127 | + <?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/> |
|
128 | 128 | </p> |
129 | 129 | <?php |
130 | 130 | } |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | * @since 1.0.0 |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - function column_default( $item, $column_name ) { |
|
139 | + function column_default($item, $column_name) { |
|
140 | 140 | return $item->$column_name; |
141 | 141 | } |
142 | 142 | |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * @since 1.0.0 |
148 | 148 | * @return string |
149 | 149 | */ |
150 | - function column_sub_id( $item ) { |
|
151 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>'; |
|
150 | + function column_sub_id($item) { |
|
151 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" target="_blank">' . $item->id . '</a>'; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | * @since 1.0.0 |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - function column_customer_id( $item ) { |
|
162 | - $subscriber = get_userdata( $item->customer_id ); |
|
163 | - $customer = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email; |
|
161 | + function column_customer_id($item) { |
|
162 | + $subscriber = get_userdata($item->customer_id); |
|
163 | + $customer = !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email; |
|
164 | 164 | |
165 | - return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>'; |
|
165 | + return '<a href="' . esc_url(get_edit_user_link($item->customer_id)) . '" target="_blank">' . $customer . '</a>'; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * @since 1.0.0 |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - function column_status( $item ) { |
|
175 | + function column_status($item) { |
|
176 | 176 | return $item->get_status_label(); |
177 | 177 | } |
178 | 178 | |
@@ -183,11 +183,11 @@ discard block |
||
183 | 183 | * @since 1.0.0 |
184 | 184 | * @return string |
185 | 185 | */ |
186 | - function column_period( $item ) { |
|
186 | + function column_period($item) { |
|
187 | 187 | |
188 | - $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency ); |
|
188 | + $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->period, $item->frequency); |
|
189 | 189 | |
190 | - return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period; |
|
190 | + return wpinv_price(wpinv_format_amount($item->recurring_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)) . ' / ' . $period; |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | /** |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @since 1.0.0 |
198 | 198 | * @return string |
199 | 199 | */ |
200 | - function column_bill_times( $item ) { |
|
201 | - return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? 'Until Cancelled' : $item->bill_times ); |
|
200 | + function column_bill_times($item) { |
|
201 | + return $item->get_times_billed() . ' / ' . (($item->bill_times == 0) ? 'Until Cancelled' : $item->bill_times); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | /** |
@@ -208,8 +208,8 @@ discard block |
||
208 | 208 | * @since 1.0.0 |
209 | 209 | * @return string |
210 | 210 | */ |
211 | - function column_initial_amount( $item ) { |
|
212 | - return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ); |
|
211 | + function column_initial_amount($item) { |
|
212 | + return wpinv_price(wpinv_format_amount($item->initial_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | /** |
@@ -219,8 +219,8 @@ discard block |
||
219 | 219 | * @since 1.0.0 |
220 | 220 | * @return string |
221 | 221 | */ |
222 | - function column_renewal_date( $item ) { |
|
223 | - return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' ); |
|
222 | + function column_renewal_date($item) { |
|
223 | + return $renewal_date = !empty($item->expiration) ? date_i18n(get_option('date_format'), strtotime($item->expiration)) : __('N/A', 'invoicing'); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | /** |
@@ -230,8 +230,8 @@ discard block |
||
230 | 230 | * @since 1.0.0 |
231 | 231 | * @return string |
232 | 232 | */ |
233 | - function column_parent_payment_id( $item ) { |
|
234 | - return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>'; |
|
233 | + function column_parent_payment_id($item) { |
|
234 | + return '<a href="' . get_edit_post_link($item->parent_payment_id) . '" target="_blank">' . wpinv_get_invoice_number($item->parent_payment_id) . '</a>'; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | /** |
@@ -241,8 +241,8 @@ discard block |
||
241 | 241 | * @since 1.0.0 |
242 | 242 | * @return string |
243 | 243 | */ |
244 | - function column_product_id( $item ) { |
|
245 | - return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>'; |
|
244 | + function column_product_id($item) { |
|
245 | + return '<a href="' . esc_url(admin_url('post.php?action=edit&post=' . $item->product_id)) . '" target="_blank">' . get_the_title($item->product_id) . '</a>'; |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
252 | 252 | * @since 2.0 |
253 | 253 | * @return string |
254 | 254 | */ |
255 | - function column_actions( $item ) { |
|
256 | - return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>'; |
|
255 | + function column_actions($item) { |
|
256 | + return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" title="' . esc_attr(__('View or edit subscription', 'invoicing')) . '" target="_blank">' . __('View', 'invoicing') . '</a>'; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | |
@@ -265,21 +265,21 @@ discard block |
||
265 | 265 | * @return array |
266 | 266 | */ |
267 | 267 | |
268 | - function get_columns(){ |
|
268 | + function get_columns() { |
|
269 | 269 | $columns = array( |
270 | - 'sub_id' => __( 'ID', 'invoicing' ), |
|
271 | - 'customer_id' => __( 'Customer', 'invoicing' ), |
|
272 | - 'status' => __( 'Status', 'invoicing' ), |
|
273 | - 'period' => __( 'Billing Cycle', 'invoicing' ), |
|
274 | - 'initial_amount' => __( 'Initial Amount', 'invoicing' ), |
|
275 | - 'bill_times' => __( 'Times Billed', 'invoicing' ), |
|
276 | - 'renewal_date' => __( 'Renewal Date', 'invoicing' ), |
|
277 | - 'parent_payment_id' => __( 'Invoice', 'invoicing' ), |
|
278 | - 'product_id' => __( 'Item', 'invoicing' ), |
|
279 | - 'actions' => __( 'Actions', 'invoicing' ), |
|
270 | + 'sub_id' => __('ID', 'invoicing'), |
|
271 | + 'customer_id' => __('Customer', 'invoicing'), |
|
272 | + 'status' => __('Status', 'invoicing'), |
|
273 | + 'period' => __('Billing Cycle', 'invoicing'), |
|
274 | + 'initial_amount' => __('Initial Amount', 'invoicing'), |
|
275 | + 'bill_times' => __('Times Billed', 'invoicing'), |
|
276 | + 'renewal_date' => __('Renewal Date', 'invoicing'), |
|
277 | + 'parent_payment_id' => __('Invoice', 'invoicing'), |
|
278 | + 'product_id' => __('Item', 'invoicing'), |
|
279 | + 'actions' => __('Actions', 'invoicing'), |
|
280 | 280 | ); |
281 | 281 | |
282 | - return apply_filters( 'wpinv_report_subscription_columns', $columns ); |
|
282 | + return apply_filters('wpinv_report_subscription_columns', $columns); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | * @return int |
291 | 291 | */ |
292 | 292 | function get_paged() { |
293 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
293 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -306,16 +306,16 @@ discard block |
||
306 | 306 | |
307 | 307 | $db = new WPInv_Subscriptions_DB; |
308 | 308 | |
309 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
309 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
310 | 310 | |
311 | 311 | $this->total_count = $db->count(); |
312 | - $this->active_count = $db->count( array( 'status' => 'active', 'search' => $search ) ); |
|
313 | - $this->pending_count = $db->count( array( 'status' => 'pending', 'search' => $search ) ); |
|
314 | - $this->expired_count = $db->count( array( 'status' => 'expired', 'search' => $search ) ); |
|
315 | - $this->trialling_count = $db->count( array( 'status' => 'trialling', 'search' => $search ) ); |
|
316 | - $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) ); |
|
317 | - $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) ); |
|
318 | - $this->failing_count = $db->count( array( 'status' => 'failing', 'search' => $search ) ); |
|
312 | + $this->active_count = $db->count(array('status' => 'active', 'search' => $search)); |
|
313 | + $this->pending_count = $db->count(array('status' => 'pending', 'search' => $search)); |
|
314 | + $this->expired_count = $db->count(array('status' => 'expired', 'search' => $search)); |
|
315 | + $this->trialling_count = $db->count(array('status' => 'trialling', 'search' => $search)); |
|
316 | + $this->cancelled_count = $db->count(array('status' => 'cancelled', 'search' => $search)); |
|
317 | + $this->completed_count = $db->count(array('status' => 'completed', 'search' => $search)); |
|
318 | + $this->failing_count = $db->count(array('status' => 'failing', 'search' => $search)); |
|
319 | 319 | |
320 | 320 | } |
321 | 321 | |
@@ -336,28 +336,28 @@ discard block |
||
336 | 336 | |
337 | 337 | $columns = $this->get_columns(); |
338 | 338 | $hidden = array(); // No hidden columns |
339 | - $status = isset( $_GET['status'] ) ? $_GET['status'] : 'any'; |
|
339 | + $status = isset($_GET['status']) ? $_GET['status'] : 'any'; |
|
340 | 340 | $sortable = $this->get_sortable_columns(); |
341 | 341 | |
342 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
342 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
343 | 343 | |
344 | 344 | $current_page = $this->get_pagenum(); |
345 | 345 | |
346 | 346 | $db = new WPInv_Subscriptions_DB; |
347 | - $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : ''; |
|
347 | + $search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : ''; |
|
348 | 348 | $args = array( |
349 | 349 | 'number' => $this->per_page, |
350 | - 'offset' => $this->per_page * ( $this->get_paged() - 1 ), |
|
350 | + 'offset' => $this->per_page * ($this->get_paged() - 1), |
|
351 | 351 | 'search' => $search |
352 | 352 | ); |
353 | 353 | |
354 | - if ( 'any' !== $status ) { |
|
354 | + if ('any' !== $status) { |
|
355 | 355 | $args['status'] = $status; |
356 | 356 | } |
357 | 357 | |
358 | - $this->items = $db->get_subscriptions( $args ); |
|
358 | + $this->items = $db->get_subscriptions($args); |
|
359 | 359 | |
360 | - switch ( $status ) { |
|
360 | + switch ($status) { |
|
361 | 361 | case 'active': |
362 | 362 | $total_items = $this->active_count; |
363 | 363 | break; |
@@ -385,10 +385,10 @@ discard block |
||
385 | 385 | break; |
386 | 386 | } |
387 | 387 | |
388 | - $this->set_pagination_args( array( |
|
388 | + $this->set_pagination_args(array( |
|
389 | 389 | 'total_items' => $total_items, |
390 | 390 | 'per_page' => $this->per_page, |
391 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
392 | - ) ); |
|
391 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
392 | + )); |
|
393 | 393 | } |
394 | 394 | } |