@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This function is responsible for sending emails. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @return bool |
34 | 34 | */ |
35 | - public function send( $to, $subject, $email, $attachments = array() ) { |
|
35 | + public function send($to, $subject, $email, $attachments = array()) { |
|
36 | 36 | |
37 | 37 | /* |
38 | 38 | * Allow to filter data on per-email basis. |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | $data = apply_filters( |
41 | 41 | 'getpaid_email_data', |
42 | 42 | array( |
43 | - 'to' => array_filter( array_unique( wpinv_parse_list( $to ) ) ), |
|
44 | - 'subject' => htmlspecialchars_decode( strip_tags( $subject ), ENT_QUOTES ), |
|
45 | - 'email' => apply_filters( 'wpinv_mail_content', $email ), |
|
43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
45 | + 'email' => apply_filters('wpinv_mail_content', $email), |
|
46 | 46 | 'headers' => $this->get_headers(), |
47 | 47 | 'attachments' => $attachments, |
48 | 48 | ), |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | ); |
51 | 51 | |
52 | 52 | // Remove slashes. |
53 | - $data = (array) wp_unslash( $data ); |
|
53 | + $data = (array) wp_unslash($data); |
|
54 | 54 | |
55 | 55 | // Cache it. |
56 | 56 | $this->wp_mail_data = $data; |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | |
61 | 61 | $result = false; |
62 | 62 | |
63 | - foreach ( $this->wp_mail_data['to'] as $to ) { |
|
64 | - $result = $this->_send( $to, $data ); |
|
63 | + foreach ($this->wp_mail_data['to'] as $to) { |
|
64 | + $result = $this->_send($to, $data); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | // Remove our hooks. |
@@ -82,24 +82,24 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return bool |
84 | 84 | */ |
85 | - protected function _send( $to, $data ) { |
|
85 | + protected function _send($to, $data) { |
|
86 | 86 | |
87 | 87 | // Prepare the sending function. |
88 | - $sending_function = apply_filters( 'getpaid_email_email_sending_function', 'wp_mail' ); |
|
88 | + $sending_function = apply_filters('getpaid_email_email_sending_function', 'wp_mail'); |
|
89 | 89 | |
90 | 90 | // Send the actual email. |
91 | 91 | $result = call_user_func( |
92 | 92 | $sending_function, |
93 | 93 | $to, |
94 | - html_entity_decode( $data['subject'], ENT_QUOTES, get_bloginfo( 'charset' ) ), |
|
94 | + html_entity_decode($data['subject'], ENT_QUOTES, get_bloginfo('charset')), |
|
95 | 95 | $data['email'], |
96 | 96 | $data['headers'], |
97 | 97 | $data['attachments'] |
98 | 98 | ); |
99 | 99 | |
100 | - if ( ! $result ) { |
|
101 | - $log_message = wp_sprintf( __( "\nTime: %1\$s\nTo: %2\$s\nSubject: %3\$s\n", 'invoicing' ), date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), $to, $data['subject'] ); |
|
102 | - wpinv_error_log( $log_message, __( 'Email from Invoicing plugin failed to send', 'invoicing' ), __FILE__, __LINE__ ); |
|
100 | + if (!$result) { |
|
101 | + $log_message = wp_sprintf(__("\nTime: %1\$s\nTo: %2\$s\nSubject: %3\$s\n", 'invoicing'), date_i18n('F j Y H:i:s', current_time('timestamp')), $to, $data['subject']); |
|
102 | + wpinv_error_log($log_message, __('Email from Invoicing plugin failed to send', 'invoicing'), __FILE__, __LINE__); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $result; |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | |
113 | 113 | $name = $this->get_from_name(); |
114 | 114 | $reply_to = $this->get_reply_to(); |
115 | - $headers = array( "Reply-To:$name <$reply_to>" ); |
|
115 | + $headers = array("Reply-To:$name <$reply_to>"); |
|
116 | 116 | |
117 | - return apply_filters( 'getpaid_email_headers', $headers, $this ); |
|
117 | + return apply_filters('getpaid_email_headers', $headers, $this); |
|
118 | 118 | |
119 | 119 | } |
120 | 120 | |
@@ -125,11 +125,11 @@ discard block |
||
125 | 125 | */ |
126 | 126 | public function before_sending() { |
127 | 127 | |
128 | - do_action( 'getpaid_before_send_email', $this ); |
|
129 | - add_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
130 | - add_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
131 | - add_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
132 | - add_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
128 | + do_action('getpaid_before_send_email', $this); |
|
129 | + add_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
130 | + add_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
131 | + add_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
132 | + add_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
133 | 133 | |
134 | 134 | } |
135 | 135 | |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | */ |
139 | 139 | public function get_from_name() { |
140 | 140 | |
141 | - $from_name = wpinv_get_option( 'email_from_name', get_bloginfo( 'name' ) ); |
|
141 | + $from_name = wpinv_get_option('email_from_name', get_bloginfo('name')); |
|
142 | 142 | |
143 | - if ( empty( $from_name ) ) { |
|
144 | - $from_name = get_bloginfo( 'name' ); |
|
143 | + if (empty($from_name)) { |
|
144 | + $from_name = get_bloginfo('name'); |
|
145 | 145 | } |
146 | 146 | |
147 | - return wp_specialchars_decode( $from_name, ENT_QUOTES ); |
|
147 | + return wp_specialchars_decode($from_name, ENT_QUOTES); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function get_from_address() { |
154 | 154 | |
155 | - $from_address = wpinv_get_option( 'email_from', $this->default_from_address() ); |
|
155 | + $from_address = wpinv_get_option('email_from', $this->default_from_address()); |
|
156 | 156 | |
157 | - if ( ! is_email( $from_address ) ) { |
|
157 | + if (!is_email($from_address)) { |
|
158 | 158 | $from_address = $this->default_from_address(); |
159 | 159 | } |
160 | 160 | |
@@ -174,14 +174,14 @@ discard block |
||
174 | 174 | public function default_from_address() { |
175 | 175 | |
176 | 176 | // Get the site domain and get rid of www. |
177 | - $sitename = strtolower( $_SERVER['SERVER_NAME'] ); |
|
178 | - if ( substr( $sitename, 0, 4 ) == 'www.' ) { |
|
179 | - $sitename = substr( $sitename, 4 ); |
|
177 | + $sitename = strtolower($_SERVER['SERVER_NAME']); |
|
178 | + if (substr($sitename, 0, 4) == 'www.') { |
|
179 | + $sitename = substr($sitename, 4); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $from_email = 'wordpress@' . $sitename; |
183 | 183 | |
184 | - return apply_filters( 'getpaid_default_from_address', $from_email ); |
|
184 | + return apply_filters('getpaid_default_from_address', $from_email); |
|
185 | 185 | |
186 | 186 | } |
187 | 187 | |
@@ -195,8 +195,8 @@ discard block |
||
195 | 195 | |
196 | 196 | $reply_to = wpinv_get_admin_email(); |
197 | 197 | |
198 | - if ( ! is_email( $reply_to ) ) { |
|
199 | - $reply_to = get_option( 'admin_email' ); |
|
198 | + if (!is_email($reply_to)) { |
|
199 | + $reply_to = get_option('admin_email'); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | return $reply_to; |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | * |
208 | 208 | */ |
209 | 209 | public function get_content_type() { |
210 | - return apply_filters( 'getpaid_email_content_type', 'text/html', $this ); |
|
210 | + return apply_filters('getpaid_email_content_type', 'text/html', $this); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | /** |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return array wp_mail_data. |
217 | 217 | */ |
218 | - public function ensure_email_content( $args ) { |
|
218 | + public function ensure_email_content($args) { |
|
219 | 219 | $args['message'] = $this->wp_mail_data['email']; |
220 | 220 | return $args; |
221 | 221 | } |
@@ -226,11 +226,11 @@ discard block |
||
226 | 226 | */ |
227 | 227 | public function after_sending() { |
228 | 228 | |
229 | - do_action( 'getpaid_after_send_email', $this->wp_mail_data ); |
|
230 | - remove_filter( 'wp_mail_from', array( $this, 'get_from_address' ), 1000 ); |
|
231 | - remove_filter( 'wp_mail_from_name', array( $this, 'get_from_name' ), 1000 ); |
|
232 | - remove_filter( 'wp_mail_content_type', array( $this, 'get_content_type' ), 1000 ); |
|
233 | - remove_filter( 'wp_mail', array( $this, 'ensure_email_content' ), 1000 ); |
|
229 | + do_action('getpaid_after_send_email', $this->wp_mail_data); |
|
230 | + remove_filter('wp_mail_from', array($this, 'get_from_address'), 1000); |
|
231 | + remove_filter('wp_mail_from_name', array($this, 'get_from_name'), 1000); |
|
232 | + remove_filter('wp_mail_content_type', array($this, 'get_content_type'), 1000); |
|
233 | + remove_filter('wp_mail', array($this, 'ensure_email_content'), 1000); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns the errors as html |
@@ -15,35 +15,35 @@ discard block |
||
15 | 15 | * @param bool $wrap whether or not to wrap the errors. |
16 | 16 | * @since 1.0.19 |
17 | 17 | */ |
18 | -function getpaid_get_errors_html( $clear = true, $wrap = true ) { |
|
18 | +function getpaid_get_errors_html($clear = true, $wrap = true) { |
|
19 | 19 | |
20 | 20 | $errors = ''; |
21 | - foreach ( wpinv_get_errors() as $id => $error ) { |
|
22 | - $type = 'error'; |
|
21 | + foreach (wpinv_get_errors() as $id => $error) { |
|
22 | + $type = 'error'; |
|
23 | 23 | |
24 | - if ( is_array( $error ) ) { |
|
24 | + if (is_array($error)) { |
|
25 | 25 | $type = $error['type']; |
26 | 26 | $error = $error['text']; |
27 | 27 | } |
28 | 28 | |
29 | - if ( $wrap ) { |
|
29 | + if ($wrap) { |
|
30 | 30 | |
31 | 31 | $errors .= aui()->alert( |
32 | 32 | array( |
33 | - 'content' => wp_kses_post( $error ), |
|
33 | + 'content' => wp_kses_post($error), |
|
34 | 34 | 'type' => $type, |
35 | 35 | ) |
36 | 36 | ); |
37 | 37 | |
38 | 38 | } else { |
39 | 39 | |
40 | - $id = esc_attr( $id ); |
|
41 | - $error = wp_kses_post( $error ); |
|
40 | + $id = esc_attr($id); |
|
41 | + $error = wp_kses_post($error); |
|
42 | 42 | $errors .= "<div data-code='$id'>$error</div>"; |
43 | 43 | } |
44 | 44 | } |
45 | 45 | |
46 | - if ( $clear ) { |
|
46 | + if ($clear) { |
|
47 | 47 | wpinv_clear_errors(); |
48 | 48 | } |
49 | 49 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * Prints (then clears) all available errors. |
56 | 56 | */ |
57 | 57 | function wpinv_print_errors() { |
58 | - echo wp_kses_post( getpaid_get_errors_html() ); |
|
58 | + echo wp_kses_post(getpaid_get_errors_html()); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | /** |
@@ -64,8 +64,8 @@ discard block |
||
64 | 64 | * @return array |
65 | 65 | */ |
66 | 66 | function wpinv_get_errors() { |
67 | - $errors = getpaid_session()->get( 'wpinv_errors' ); |
|
68 | - return is_array( $errors ) ? $errors : array(); |
|
67 | + $errors = getpaid_session()->get('wpinv_errors'); |
|
68 | + return is_array($errors) ? $errors : array(); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | /** |
@@ -75,15 +75,15 @@ discard block |
||
75 | 75 | * @param string $error_message The error message. |
76 | 76 | * @param string $type Either error, info, warning, primary, dark, light or success. |
77 | 77 | */ |
78 | -function wpinv_set_error( $error_id, $error_message, $type = 'error' ) { |
|
78 | +function wpinv_set_error($error_id, $error_message, $type = 'error') { |
|
79 | 79 | |
80 | 80 | $errors = wpinv_get_errors(); |
81 | - $errors[ $error_id ] = array( |
|
81 | + $errors[$error_id] = array( |
|
82 | 82 | 'type' => $type, |
83 | 83 | 'text' => $error_message, |
84 | 84 | ); |
85 | 85 | |
86 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
86 | + getpaid_session()->set('wpinv_errors', $errors); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | */ |
93 | 93 | function wpinv_has_errors() { |
94 | - return count( wpinv_get_errors() ) > 0; |
|
94 | + return count(wpinv_get_errors()) > 0; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -99,21 +99,21 @@ discard block |
||
99 | 99 | * |
100 | 100 | */ |
101 | 101 | function wpinv_clear_errors() { |
102 | - getpaid_session()->set( 'wpinv_errors', null ); |
|
102 | + getpaid_session()->set('wpinv_errors', null); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | /** |
106 | 106 | * Clears a single error. |
107 | 107 | * |
108 | 108 | */ |
109 | -function wpinv_unset_error( $error_id ) { |
|
109 | +function wpinv_unset_error($error_id) { |
|
110 | 110 | $errors = wpinv_get_errors(); |
111 | 111 | |
112 | - if ( isset( $errors[ $error_id ] ) ) { |
|
113 | - unset( $errors[ $error_id ] ); |
|
112 | + if (isset($errors[$error_id])) { |
|
113 | + unset($errors[$error_id]); |
|
114 | 114 | } |
115 | 115 | |
116 | - getpaid_session()->set( 'wpinv_errors', $errors ); |
|
116 | + getpaid_session()->set('wpinv_errors', $errors); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | /** |
@@ -124,15 +124,15 @@ discard block |
||
124 | 124 | * @param string $message Message to log. |
125 | 125 | * @param string $version Version the message was added in. |
126 | 126 | */ |
127 | -function getpaid_doing_it_wrong( $function, $message, $version ) { |
|
127 | +function getpaid_doing_it_wrong($function, $message, $version) { |
|
128 | 128 | |
129 | 129 | $message .= ' Backtrace: ' . wp_debug_backtrace_summary(); |
130 | 130 | |
131 | - if ( wp_doing_ajax() || defined( 'REST_REQUEST' ) ) { |
|
132 | - do_action( 'doing_it_wrong_run', $function, $message, $version ); |
|
133 | - error_log( "{$function} was called incorrectly. {$message}. This message was added in version {$version}." ); |
|
131 | + if (wp_doing_ajax() || defined('REST_REQUEST')) { |
|
132 | + do_action('doing_it_wrong_run', $function, $message, $version); |
|
133 | + error_log("{$function} was called incorrectly. {$message}. This message was added in version {$version}."); |
|
134 | 134 | } else { |
135 | - _doing_it_wrong( $function, $message, $version ); |
|
135 | + _doing_it_wrong($function, $message, $version); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | } |
@@ -146,41 +146,41 @@ discard block |
||
146 | 146 | * @param string $line The line that contains the error. |
147 | 147 | * @param bool $exit Whether or not to exit function execution. |
148 | 148 | */ |
149 | -function wpinv_error_log( $log, $title = '', $file = '', $line = '', $exit = false ) { |
|
149 | +function wpinv_error_log($log, $title = '', $file = '', $line = '', $exit = false) { |
|
150 | 150 | |
151 | - if ( true === apply_filters( 'wpinv_log_errors', true ) ) { |
|
151 | + if (true === apply_filters('wpinv_log_errors', true)) { |
|
152 | 152 | |
153 | 153 | // Ensure the log is a scalar. |
154 | - if ( ! is_scalar( $log ) ) { |
|
155 | - $log = print_r( $log, true ); |
|
154 | + if (!is_scalar($log)) { |
|
155 | + $log = print_r($log, true); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add title. |
159 | - if ( ! empty( $title ) ) { |
|
160 | - $log = $title . ' ' . trim( $log ); |
|
159 | + if (!empty($title)) { |
|
160 | + $log = $title . ' ' . trim($log); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Add the file to the label. |
164 | - if ( ! empty( $file ) ) { |
|
164 | + if (!empty($file)) { |
|
165 | 165 | $log .= ' in ' . $file; |
166 | 166 | } |
167 | 167 | |
168 | 168 | // Add the line number to the label. |
169 | - if ( ! empty( $line ) ) { |
|
169 | + if (!empty($line)) { |
|
170 | 170 | $log .= ' on line ' . $line; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Log the message. |
174 | - error_log( trim( $log ) ); |
|
174 | + error_log(trim($log)); |
|
175 | 175 | |
176 | 176 | // ... and a backtrace. |
177 | - if ( false !== $title && false !== $file ) { |
|
178 | - error_log( 'Backtrace ' . wp_debug_backtrace_summary() ); |
|
177 | + if (false !== $title && false !== $file) { |
|
178 | + error_log('Backtrace ' . wp_debug_backtrace_summary()); |
|
179 | 179 | } |
180 | 180 | } |
181 | 181 | |
182 | 182 | // Maybe exit. |
183 | - if ( $exit ) { |
|
183 | + if ($exit) { |
|
184 | 184 | exit; |
185 | 185 | } |
186 | 186 |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @since 1.0.0 |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Main Invoicing class. |
@@ -56,8 +56,8 @@ discard block |
||
56 | 56 | * @param string $prop The prop to set. |
57 | 57 | * @param mixed $value The value to retrieve. |
58 | 58 | */ |
59 | - public function set( $prop, $value ) { |
|
60 | - $this->data[ $prop ] = $value; |
|
59 | + public function set($prop, $value) { |
|
60 | + $this->data[$prop] = $value; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -66,10 +66,10 @@ discard block |
||
66 | 66 | * @param string $prop The prop to set. |
67 | 67 | * @return mixed The value. |
68 | 68 | */ |
69 | - public function get( $prop ) { |
|
69 | + public function get($prop) { |
|
70 | 70 | |
71 | - if ( isset( $this->data[ $prop ] ) ) { |
|
72 | - return $this->data[ $prop ]; |
|
71 | + if (isset($this->data[$prop])) { |
|
72 | + return $this->data[$prop]; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | return null; |
@@ -81,23 +81,23 @@ discard block |
||
81 | 81 | public function set_properties() { |
82 | 82 | |
83 | 83 | // Sessions. |
84 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
85 | - $GLOBALS['wpi_session'] = $this->get( 'session' ); // Backwards compatibility. |
|
84 | + $this->set('session', new WPInv_Session_Handler()); |
|
85 | + $GLOBALS['wpi_session'] = $this->get('session'); // Backwards compatibility. |
|
86 | 86 | $GLOBALS['wpinv_euvat'] = new WPInv_EUVat(); // Backwards compatibility. |
87 | 87 | |
88 | 88 | // Init other objects. |
89 | - $this->set( 'session', new WPInv_Session_Handler() ); |
|
90 | - $this->set( 'notes', new WPInv_Notes() ); |
|
91 | - $this->set( 'api', new WPInv_API() ); |
|
92 | - $this->set( 'post_types', new GetPaid_Post_Types() ); |
|
93 | - $this->set( 'template', new GetPaid_Template() ); |
|
94 | - $this->set( 'admin', new GetPaid_Admin() ); |
|
95 | - $this->set( 'subscriptions', new WPInv_Subscriptions() ); |
|
96 | - $this->set( 'invoice_emails', new GetPaid_Invoice_Notification_Emails() ); |
|
97 | - $this->set( 'subscription_emails', new GetPaid_Subscription_Notification_Emails() ); |
|
98 | - $this->set( 'daily_maintenace', new GetPaid_Daily_Maintenance() ); |
|
99 | - $this->set( 'payment_forms', new GetPaid_Payment_Forms() ); |
|
100 | - $this->set( 'maxmind', new GetPaid_MaxMind_Geolocation() ); |
|
89 | + $this->set('session', new WPInv_Session_Handler()); |
|
90 | + $this->set('notes', new WPInv_Notes()); |
|
91 | + $this->set('api', new WPInv_API()); |
|
92 | + $this->set('post_types', new GetPaid_Post_Types()); |
|
93 | + $this->set('template', new GetPaid_Template()); |
|
94 | + $this->set('admin', new GetPaid_Admin()); |
|
95 | + $this->set('subscriptions', new WPInv_Subscriptions()); |
|
96 | + $this->set('invoice_emails', new GetPaid_Invoice_Notification_Emails()); |
|
97 | + $this->set('subscription_emails', new GetPaid_Subscription_Notification_Emails()); |
|
98 | + $this->set('daily_maintenace', new GetPaid_Daily_Maintenance()); |
|
99 | + $this->set('payment_forms', new GetPaid_Payment_Forms()); |
|
100 | + $this->set('maxmind', new GetPaid_MaxMind_Geolocation()); |
|
101 | 101 | |
102 | 102 | } |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * Define plugin constants. |
106 | 106 | */ |
107 | 107 | public function define_constants() { |
108 | - define( 'WPINV_PLUGIN_DIR', plugin_dir_path( WPINV_PLUGIN_FILE ) ); |
|
109 | - define( 'WPINV_PLUGIN_URL', plugin_dir_url( WPINV_PLUGIN_FILE ) ); |
|
108 | + define('WPINV_PLUGIN_DIR', plugin_dir_path(WPINV_PLUGIN_FILE)); |
|
109 | + define('WPINV_PLUGIN_URL', plugin_dir_url(WPINV_PLUGIN_FILE)); |
|
110 | 110 | $this->version = WPINV_VERSION; |
111 | 111 | } |
112 | 112 | |
@@ -117,27 +117,27 @@ discard block |
||
117 | 117 | */ |
118 | 118 | protected function init_hooks() { |
119 | 119 | /* Internationalize the text strings used. */ |
120 | - add_action( 'plugins_loaded', array( &$this, 'plugins_loaded' ) ); |
|
120 | + add_action('plugins_loaded', array(&$this, 'plugins_loaded')); |
|
121 | 121 | |
122 | 122 | // Init the plugin after WordPress inits. |
123 | - add_action( 'init', array( $this, 'init' ), 1 ); |
|
124 | - add_action( 'init', array( $this, 'maybe_process_ipn' ), 10 ); |
|
125 | - add_action( 'init', array( $this, 'wpinv_actions' ) ); |
|
126 | - add_action( 'init', array( $this, 'maybe_do_authenticated_action' ), 100 ); |
|
127 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 11 ); |
|
128 | - add_action( 'wp_footer', array( $this, 'wp_footer' ) ); |
|
129 | - add_action( 'wp_head', array( $this, 'wp_head' ) ); |
|
130 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
131 | - add_filter( 'wpseo_exclude_from_sitemap_by_post_ids', array( $this, 'wpseo_exclude_from_sitemap_by_post_ids' ) ); |
|
132 | - add_filter( 'pre_get_posts', array( &$this, 'pre_get_posts' ) ); |
|
133 | - |
|
134 | - add_filter( 'query_vars', array( $this, 'custom_query_vars' ) ); |
|
135 | - add_action( 'init', array( $this, 'add_rewrite_rule' ), 10, 0 ); |
|
136 | - add_action( 'pre_get_posts', array( $this, 'maybe_process_new_ipn' ), 1 ); |
|
123 | + add_action('init', array($this, 'init'), 1); |
|
124 | + add_action('init', array($this, 'maybe_process_ipn'), 10); |
|
125 | + add_action('init', array($this, 'wpinv_actions')); |
|
126 | + add_action('init', array($this, 'maybe_do_authenticated_action'), 100); |
|
127 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 11); |
|
128 | + add_action('wp_footer', array($this, 'wp_footer')); |
|
129 | + add_action('wp_head', array($this, 'wp_head')); |
|
130 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
131 | + add_filter('wpseo_exclude_from_sitemap_by_post_ids', array($this, 'wpseo_exclude_from_sitemap_by_post_ids')); |
|
132 | + add_filter('pre_get_posts', array(&$this, 'pre_get_posts')); |
|
133 | + |
|
134 | + add_filter('query_vars', array($this, 'custom_query_vars')); |
|
135 | + add_action('init', array($this, 'add_rewrite_rule'), 10, 0); |
|
136 | + add_action('pre_get_posts', array($this, 'maybe_process_new_ipn'), 1); |
|
137 | 137 | |
138 | 138 | // Fires after registering actions. |
139 | - do_action( 'wpinv_actions', $this ); |
|
140 | - do_action( 'getpaid_actions', $this ); |
|
139 | + do_action('wpinv_actions', $this); |
|
140 | + do_action('getpaid_actions', $this); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -145,10 +145,10 @@ discard block |
||
145 | 145 | /* Internationalize the text strings used. */ |
146 | 146 | $this->load_textdomain(); |
147 | 147 | |
148 | - do_action( 'wpinv_loaded' ); |
|
148 | + do_action('wpinv_loaded'); |
|
149 | 149 | |
150 | 150 | // Fix oxygen page builder conflict |
151 | - if ( function_exists( 'ct_css_output' ) ) { |
|
151 | + if (function_exists('ct_css_output')) { |
|
152 | 152 | wpinv_oxygen_fix_conflict(); |
153 | 153 | } |
154 | 154 | } |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | load_plugin_textdomain( |
170 | 170 | 'invoicing', |
171 | 171 | false, |
172 | - plugin_basename( dirname( WPINV_PLUGIN_FILE ) ) . '/languages/' |
|
172 | + plugin_basename(dirname(WPINV_PLUGIN_FILE)) . '/languages/' |
|
173 | 173 | ); |
174 | 174 | |
175 | 175 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | |
206 | 206 | // Register autoloader. |
207 | 207 | try { |
208 | - spl_autoload_register( array( $this, 'autoload' ), true ); |
|
209 | - } catch ( Exception $e ) { |
|
210 | - wpinv_error_log( $e->getMessage(), '', __FILE__, 149, true ); |
|
208 | + spl_autoload_register(array($this, 'autoload'), true); |
|
209 | + } catch (Exception $e) { |
|
210 | + wpinv_error_log($e->getMessage(), '', __FILE__, 149, true); |
|
211 | 211 | } |
212 | 212 | |
213 | 213 | require_once WPINV_PLUGIN_DIR . 'includes/abstracts/abstract-wpinv-session.php'; |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | require_once WPINV_PLUGIN_DIR . 'widgets/invoice.php'; |
234 | 234 | require_once WPINV_PLUGIN_DIR . 'includes/admin/admin-pages.php'; |
235 | 235 | |
236 | - if ( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) { |
|
236 | + if (is_admin() || (defined('WP_CLI') && WP_CLI)) { |
|
237 | 237 | GetPaid_Post_Types_Admin::init(); |
238 | 238 | |
239 | 239 | require_once WPINV_PLUGIN_DIR . 'includes/admin/wpinv-admin-functions.php'; |
@@ -244,15 +244,15 @@ discard block |
||
244 | 244 | require_once WPINV_PLUGIN_DIR . 'includes/admin/class-getpaid-admin-profile.php'; |
245 | 245 | // load the user class only on the users.php page |
246 | 246 | global $pagenow; |
247 | - if ( $pagenow == 'users.php' ) { |
|
247 | + if ($pagenow == 'users.php') { |
|
248 | 248 | new WPInv_Admin_Users(); |
249 | 249 | } |
250 | 250 | } |
251 | 251 | |
252 | 252 | // Register cli commands |
253 | - if ( defined( 'WP_CLI' ) && WP_CLI ) { |
|
253 | + if (defined('WP_CLI') && WP_CLI) { |
|
254 | 254 | require_once WPINV_PLUGIN_DIR . 'includes/class-wpinv-cli.php'; |
255 | - WP_CLI::add_command( 'invoicing', 'WPInv_CLI' ); |
|
255 | + WP_CLI::add_command('invoicing', 'WPInv_CLI'); |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | } |
@@ -265,21 +265,21 @@ discard block |
||
265 | 265 | * @since 1.0.19 |
266 | 266 | * @return void |
267 | 267 | */ |
268 | - public function autoload( $class_name ) { |
|
268 | + public function autoload($class_name) { |
|
269 | 269 | |
270 | 270 | // Normalize the class name... |
271 | - $class_name = strtolower( $class_name ); |
|
271 | + $class_name = strtolower($class_name); |
|
272 | 272 | |
273 | 273 | // ... and make sure it is our class. |
274 | - if ( false === strpos( $class_name, 'getpaid_' ) && false === strpos( $class_name, 'wpinv_' ) ) { |
|
274 | + if (false === strpos($class_name, 'getpaid_') && false === strpos($class_name, 'wpinv_')) { |
|
275 | 275 | return; |
276 | 276 | } |
277 | 277 | |
278 | 278 | // Next, prepare the file name from the class. |
279 | - $file_name = 'class-' . str_replace( '_', '-', $class_name ) . '.php'; |
|
279 | + $file_name = 'class-' . str_replace('_', '-', $class_name) . '.php'; |
|
280 | 280 | |
281 | 281 | // Base path of the classes. |
282 | - $plugin_path = untrailingslashit( WPINV_PLUGIN_DIR ); |
|
282 | + $plugin_path = untrailingslashit(WPINV_PLUGIN_DIR); |
|
283 | 283 | |
284 | 284 | // And an array of possible locations in order of importance. |
285 | 285 | $locations = array( |
@@ -294,10 +294,10 @@ discard block |
||
294 | 294 | "$plugin_path/includes/admin/meta-boxes", |
295 | 295 | ); |
296 | 296 | |
297 | - foreach ( apply_filters( 'getpaid_autoload_locations', $locations ) as $location ) { |
|
297 | + foreach (apply_filters('getpaid_autoload_locations', $locations) as $location) { |
|
298 | 298 | |
299 | - if ( file_exists( trailingslashit( $location ) . $file_name ) ) { |
|
300 | - include trailingslashit( $location ) . $file_name; |
|
299 | + if (file_exists(trailingslashit($location) . $file_name)) { |
|
300 | + include trailingslashit($location) . $file_name; |
|
301 | 301 | break; |
302 | 302 | } |
303 | 303 | } |
@@ -310,7 +310,7 @@ discard block |
||
310 | 310 | public function init() { |
311 | 311 | |
312 | 312 | // Fires before getpaid inits. |
313 | - do_action( 'before_getpaid_init', $this ); |
|
313 | + do_action('before_getpaid_init', $this); |
|
314 | 314 | |
315 | 315 | // Maybe upgrade. |
316 | 316 | $this->maybe_upgrade_database(); |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | ) |
328 | 328 | ); |
329 | 329 | |
330 | - foreach ( $gateways as $id => $class ) { |
|
331 | - $this->gateways[ $id ] = new $class(); |
|
330 | + foreach ($gateways as $id => $class) { |
|
331 | + $this->gateways[$id] = new $class(); |
|
332 | 332 | } |
333 | 333 | |
334 | - if ( 'yes' != get_option( 'wpinv_renamed_gateways' ) ) { |
|
334 | + if ('yes' != get_option('wpinv_renamed_gateways')) { |
|
335 | 335 | GetPaid_Installer::rename_gateways_label(); |
336 | - update_option( 'wpinv_renamed_gateways', 'yes' ); |
|
336 | + update_option('wpinv_renamed_gateways', 'yes'); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Fires after getpaid inits. |
340 | - do_action( 'getpaid_init', $this ); |
|
340 | + do_action('getpaid_init', $this); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,14 +347,14 @@ discard block |
||
347 | 347 | public function maybe_process_ipn() { |
348 | 348 | |
349 | 349 | // Ensure that this is an IPN request. |
350 | - if ( empty( $_GET['wpi-listener'] ) || 'IPN' !== $_GET['wpi-listener'] || empty( $_GET['wpi-gateway'] ) ) { |
|
350 | + if (empty($_GET['wpi-listener']) || 'IPN' !== $_GET['wpi-listener'] || empty($_GET['wpi-gateway'])) { |
|
351 | 351 | return; |
352 | 352 | } |
353 | 353 | |
354 | - $gateway = sanitize_text_field( $_GET['wpi-gateway'] ); |
|
354 | + $gateway = sanitize_text_field($_GET['wpi-gateway']); |
|
355 | 355 | |
356 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
357 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
356 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
357 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
358 | 358 | exit; |
359 | 359 | |
360 | 360 | } |
@@ -362,33 +362,33 @@ discard block |
||
362 | 362 | public function enqueue_scripts() { |
363 | 363 | |
364 | 364 | // Fires before adding scripts. |
365 | - do_action( 'getpaid_enqueue_scripts' ); |
|
365 | + do_action('getpaid_enqueue_scripts'); |
|
366 | 366 | |
367 | 367 | $localize = array(); |
368 | - $localize['ajax_url'] = admin_url( 'admin-ajax.php' ); |
|
368 | + $localize['ajax_url'] = admin_url('admin-ajax.php'); |
|
369 | 369 | $localize['thousands'] = wpinv_thousands_separator(); |
370 | 370 | $localize['decimals'] = wpinv_decimal_separator(); |
371 | - $localize['nonce'] = wp_create_nonce( 'wpinv-nonce' ); |
|
372 | - $localize['txtComplete'] = __( 'Continue', 'invoicing' ); |
|
371 | + $localize['nonce'] = wp_create_nonce('wpinv-nonce'); |
|
372 | + $localize['txtComplete'] = __('Continue', 'invoicing'); |
|
373 | 373 | $localize['UseTaxes'] = wpinv_use_taxes(); |
374 | - $localize['formNonce'] = wp_create_nonce( 'getpaid_form_nonce' ); |
|
375 | - $localize['loading'] = __( 'Loading...', 'invoicing' ); |
|
376 | - $localize['connectionError'] = __( 'Could not establish a connection to the server.', 'invoicing' ); |
|
374 | + $localize['formNonce'] = wp_create_nonce('getpaid_form_nonce'); |
|
375 | + $localize['loading'] = __('Loading...', 'invoicing'); |
|
376 | + $localize['connectionError'] = __('Could not establish a connection to the server.', 'invoicing'); |
|
377 | 377 | |
378 | - $localize = apply_filters( 'wpinv_front_js_localize', $localize ); |
|
378 | + $localize = apply_filters('wpinv_front_js_localize', $localize); |
|
379 | 379 | |
380 | - $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js' ); |
|
381 | - wp_enqueue_script( 'wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array( 'jquery' ), $version, true ); |
|
382 | - wp_localize_script( 'wpinv-front-script', 'WPInv', $localize ); |
|
380 | + $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/payment-forms.js'); |
|
381 | + wp_enqueue_script('wpinv-front-script', WPINV_PLUGIN_URL . 'assets/js/payment-forms.js', array('jquery'), $version, true); |
|
382 | + wp_localize_script('wpinv-front-script', 'WPInv', $localize); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | public function wpinv_actions() { |
386 | - if ( isset( $_REQUEST['wpi_action'] ) ) { |
|
387 | - do_action( 'wpinv_' . wpinv_sanitize_key( $_REQUEST['wpi_action'] ), $_REQUEST ); |
|
386 | + if (isset($_REQUEST['wpi_action'])) { |
|
387 | + do_action('wpinv_' . wpinv_sanitize_key($_REQUEST['wpi_action']), $_REQUEST); |
|
388 | 388 | } |
389 | 389 | |
390 | - if ( defined( 'WP_ALL_IMPORT_ROOT_DIR' ) ) { |
|
391 | - include plugin_dir_path( __FILE__ ) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
390 | + if (defined('WP_ALL_IMPORT_ROOT_DIR')) { |
|
391 | + include plugin_dir_path(__FILE__) . 'libraries/wp-all-import/class-getpaid-wp-all-import.php'; |
|
392 | 392 | } |
393 | 393 | } |
394 | 394 | |
@@ -400,24 +400,24 @@ discard block |
||
400 | 400 | */ |
401 | 401 | public function maybe_do_authenticated_action() { |
402 | 402 | |
403 | - if ( isset( $_REQUEST['getpaid-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) { |
|
403 | + if (isset($_REQUEST['getpaid-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) { |
|
404 | 404 | |
405 | - $key = sanitize_key( $_REQUEST['getpaid-action'] ); |
|
406 | - $data = wp_unslash( $_REQUEST ); |
|
407 | - if ( is_user_logged_in() ) { |
|
408 | - do_action( "getpaid_authenticated_action_$key", $data ); |
|
405 | + $key = sanitize_key($_REQUEST['getpaid-action']); |
|
406 | + $data = wp_unslash($_REQUEST); |
|
407 | + if (is_user_logged_in()) { |
|
408 | + do_action("getpaid_authenticated_action_$key", $data); |
|
409 | 409 | } |
410 | 410 | |
411 | - do_action( "getpaid_unauthenticated_action_$key", $data ); |
|
411 | + do_action("getpaid_unauthenticated_action_$key", $data); |
|
412 | 412 | |
413 | 413 | } |
414 | 414 | |
415 | 415 | } |
416 | 416 | |
417 | - public function pre_get_posts( $wp_query ) { |
|
417 | + public function pre_get_posts($wp_query) { |
|
418 | 418 | |
419 | - if ( ! is_admin() && ! empty( $wp_query->query_vars['post_type'] ) && getpaid_is_invoice_post_type( $wp_query->query_vars['post_type'] ) && is_user_logged_in() && is_single() && $wp_query->is_main_query() ) { |
|
420 | - $wp_query->query_vars['post_status'] = array_keys( wpinv_get_invoice_statuses( false, false, $wp_query->query_vars['post_type'] ) ); |
|
419 | + if (!is_admin() && !empty($wp_query->query_vars['post_type']) && getpaid_is_invoice_post_type($wp_query->query_vars['post_type']) && is_user_logged_in() && is_single() && $wp_query->is_main_query()) { |
|
420 | + $wp_query->query_vars['post_status'] = array_keys(wpinv_get_invoice_statuses(false, false, $wp_query->query_vars['post_type'])); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | return $wp_query; |
@@ -432,18 +432,18 @@ discard block |
||
432 | 432 | |
433 | 433 | // Currently, UX Builder does not work particulaly well with SuperDuper. |
434 | 434 | // So we disable our widgets when editing a page with UX Builder. |
435 | - if ( function_exists( 'ux_builder_is_active' ) && ux_builder_is_active() ) { |
|
435 | + if (function_exists('ux_builder_is_active') && ux_builder_is_active()) { |
|
436 | 436 | return; |
437 | 437 | } |
438 | 438 | |
439 | - $block_widget_init_screens = function_exists( 'sd_pagenow_exclude' ) ? sd_pagenow_exclude() : array(); |
|
439 | + $block_widget_init_screens = function_exists('sd_pagenow_exclude') ? sd_pagenow_exclude() : array(); |
|
440 | 440 | |
441 | - if ( is_admin() && $pagenow && in_array( $pagenow, $block_widget_init_screens ) ) { |
|
441 | + if (is_admin() && $pagenow && in_array($pagenow, $block_widget_init_screens)) { |
|
442 | 442 | // don't initiate in these conditions. |
443 | 443 | } else { |
444 | 444 | |
445 | 445 | // Only load allowed widgets. |
446 | - $exclude = function_exists( 'sd_widget_exclude' ) ? sd_widget_exclude() : array(); |
|
446 | + $exclude = function_exists('sd_widget_exclude') ? sd_widget_exclude() : array(); |
|
447 | 447 | $widgets = apply_filters( |
448 | 448 | 'getpaid_widget_classes', |
449 | 449 | array( |
@@ -459,16 +459,16 @@ discard block |
||
459 | 459 | ); |
460 | 460 | |
461 | 461 | // For each widget... |
462 | - foreach ( $widgets as $widget ) { |
|
462 | + foreach ($widgets as $widget) { |
|
463 | 463 | |
464 | 464 | // Abort early if it is excluded for this page. |
465 | - if ( in_array( $widget, $exclude ) ) { |
|
465 | + if (in_array($widget, $exclude)) { |
|
466 | 466 | continue; |
467 | 467 | } |
468 | 468 | |
469 | 469 | // SD V1 used to extend the widget class. V2 does not, so we cannot call register widget on it. |
470 | - if ( is_subclass_of( $widget, 'WP_Widget' ) ) { |
|
471 | - register_widget( $widget ); |
|
470 | + if (is_subclass_of($widget, 'WP_Widget')) { |
|
471 | + register_widget($widget); |
|
472 | 472 | } else { |
473 | 473 | new $widget(); |
474 | 474 | } |
@@ -484,29 +484,29 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function maybe_upgrade_database() { |
486 | 486 | |
487 | - $wpi_version = get_option( 'wpinv_version', 0 ); |
|
487 | + $wpi_version = get_option('wpinv_version', 0); |
|
488 | 488 | |
489 | - if ( $wpi_version == WPINV_VERSION ) { |
|
489 | + if ($wpi_version == WPINV_VERSION) { |
|
490 | 490 | return; |
491 | 491 | } |
492 | 492 | |
493 | 493 | $installer = new GetPaid_Installer(); |
494 | 494 | |
495 | - if ( empty( $wpi_version ) ) { |
|
496 | - return $installer->upgrade_db( 0 ); |
|
495 | + if (empty($wpi_version)) { |
|
496 | + return $installer->upgrade_db(0); |
|
497 | 497 | } |
498 | 498 | |
499 | - $upgrades = array( |
|
499 | + $upgrades = array( |
|
500 | 500 | '0.0.5' => '004', |
501 | 501 | '1.0.3' => '102', |
502 | 502 | '2.0.0' => '118', |
503 | 503 | '2.0.8' => '207', |
504 | 504 | ); |
505 | 505 | |
506 | - foreach ( $upgrades as $key => $method ) { |
|
506 | + foreach ($upgrades as $key => $method) { |
|
507 | 507 | |
508 | - if ( version_compare( $wpi_version, $key, '<' ) ) { |
|
509 | - return $installer->upgrade_db( $method ); |
|
508 | + if (version_compare($wpi_version, $key, '<')) { |
|
509 | + return $installer->upgrade_db($method); |
|
510 | 510 | } |
511 | 511 | } |
512 | 512 | |
@@ -519,11 +519,11 @@ discard block |
||
519 | 519 | */ |
520 | 520 | public function maybe_flush_permalinks() { |
521 | 521 | |
522 | - $flush = get_option( 'wpinv_flush_permalinks', 0 ); |
|
522 | + $flush = get_option('wpinv_flush_permalinks', 0); |
|
523 | 523 | |
524 | - if ( ! empty( $flush ) ) { |
|
524 | + if (!empty($flush)) { |
|
525 | 525 | flush_rewrite_rules(); |
526 | - delete_option( 'wpinv_flush_permalinks' ); |
|
526 | + delete_option('wpinv_flush_permalinks'); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | } |
@@ -534,10 +534,10 @@ discard block |
||
534 | 534 | * @since 1.0.19 |
535 | 535 | * @param int[] $excluded_posts_ids |
536 | 536 | */ |
537 | - public function wpseo_exclude_from_sitemap_by_post_ids( $excluded_posts_ids ) { |
|
537 | + public function wpseo_exclude_from_sitemap_by_post_ids($excluded_posts_ids) { |
|
538 | 538 | |
539 | 539 | // Ensure that we have an array. |
540 | - if ( ! is_array( $excluded_posts_ids ) ) { |
|
540 | + if (!is_array($excluded_posts_ids)) { |
|
541 | 541 | $excluded_posts_ids = array(); |
542 | 542 | } |
543 | 543 | |
@@ -545,24 +545,24 @@ discard block |
||
545 | 545 | $our_pages = array(); |
546 | 546 | |
547 | 547 | // Checkout page. |
548 | - $our_pages[] = wpinv_get_option( 'checkout_page', false ); |
|
548 | + $our_pages[] = wpinv_get_option('checkout_page', false); |
|
549 | 549 | |
550 | 550 | // Success page. |
551 | - $our_pages[] = wpinv_get_option( 'success_page', false ); |
|
551 | + $our_pages[] = wpinv_get_option('success_page', false); |
|
552 | 552 | |
553 | 553 | // Failure page. |
554 | - $our_pages[] = wpinv_get_option( 'failure_page', false ); |
|
554 | + $our_pages[] = wpinv_get_option('failure_page', false); |
|
555 | 555 | |
556 | 556 | // History page. |
557 | - $our_pages[] = wpinv_get_option( 'invoice_history_page', false ); |
|
557 | + $our_pages[] = wpinv_get_option('invoice_history_page', false); |
|
558 | 558 | |
559 | 559 | // Subscriptions page. |
560 | - $our_pages[] = wpinv_get_option( 'invoice_subscription_page', false ); |
|
560 | + $our_pages[] = wpinv_get_option('invoice_subscription_page', false); |
|
561 | 561 | |
562 | - $our_pages = array_map( 'intval', array_filter( $our_pages ) ); |
|
562 | + $our_pages = array_map('intval', array_filter($our_pages)); |
|
563 | 563 | |
564 | 564 | $excluded_posts_ids = $excluded_posts_ids + $our_pages; |
565 | - return array_unique( $excluded_posts_ids ); |
|
565 | + return array_unique($excluded_posts_ids); |
|
566 | 566 | |
567 | 567 | } |
568 | 568 | |
@@ -572,7 +572,7 @@ discard block |
||
572 | 572 | * @since 2.0.0 |
573 | 573 | */ |
574 | 574 | public function wp_footer() { |
575 | - wpinv_get_template( 'frontend-footer.php' ); |
|
575 | + wpinv_get_template('frontend-footer.php'); |
|
576 | 576 | } |
577 | 577 | |
578 | 578 | /** |
@@ -581,14 +581,14 @@ discard block |
||
581 | 581 | * @since 2.0.0 |
582 | 582 | */ |
583 | 583 | public function wp_head() { |
584 | - wpinv_get_template( 'frontend-head.php' ); |
|
584 | + wpinv_get_template('frontend-head.php'); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
588 | 588 | * Custom query vars. |
589 | 589 | * |
590 | 590 | */ |
591 | - public function custom_query_vars( $vars ) { |
|
591 | + public function custom_query_vars($vars) { |
|
592 | 592 | $vars[] = 'getpaid-ipn'; |
593 | 593 | return $vars; |
594 | 594 | } |
@@ -599,28 +599,28 @@ discard block |
||
599 | 599 | */ |
600 | 600 | public function add_rewrite_rule() { |
601 | 601 | $tag = 'getpaid-ipn'; |
602 | - add_rewrite_tag( "%$tag%", '([^&]+)' ); |
|
603 | - add_rewrite_rule( "^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top' ); |
|
602 | + add_rewrite_tag("%$tag%", '([^&]+)'); |
|
603 | + add_rewrite_rule("^$tag/([^/]*)/?", "index.php?$tag=\$matches[1]", 'top'); |
|
604 | 604 | } |
605 | 605 | |
606 | 606 | /** |
607 | 607 | * Processes non-query string ipns. |
608 | 608 | * |
609 | 609 | */ |
610 | - public function maybe_process_new_ipn( $query ) { |
|
610 | + public function maybe_process_new_ipn($query) { |
|
611 | 611 | |
612 | - if ( is_admin() || ! $query->is_main_query() ) { |
|
612 | + if (is_admin() || !$query->is_main_query()) { |
|
613 | 613 | return; |
614 | 614 | } |
615 | 615 | |
616 | - $gateway = get_query_var( 'getpaid-ipn' ); |
|
616 | + $gateway = get_query_var('getpaid-ipn'); |
|
617 | 617 | |
618 | - if ( ! empty( $gateway ) ) { |
|
618 | + if (!empty($gateway)) { |
|
619 | 619 | |
620 | - $gateway = sanitize_text_field( $gateway ); |
|
620 | + $gateway = sanitize_text_field($gateway); |
|
621 | 621 | nocache_headers(); |
622 | - do_action( 'wpinv_verify_payment_ipn', $gateway ); |
|
623 | - do_action( "wpinv_verify_{$gateway}_ipn" ); |
|
622 | + do_action('wpinv_verify_payment_ipn', $gateway); |
|
623 | + do_action("wpinv_verify_{$gateway}_ipn"); |
|
624 | 624 | exit; |
625 | 625 | |
626 | 626 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invoice class. |
@@ -145,39 +145,39 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
147 | 147 | */ |
148 | - public function __construct( $invoice = 0 ) { |
|
148 | + public function __construct($invoice = 0) { |
|
149 | 149 | |
150 | - parent::__construct( $invoice ); |
|
150 | + parent::__construct($invoice); |
|
151 | 151 | |
152 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) { |
|
153 | - $this->set_id( (int) $invoice ); |
|
154 | - } elseif ( $invoice instanceof self ) { |
|
155 | - $this->set_id( $invoice->get_id() ); |
|
156 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
157 | - $this->set_id( $invoice->ID ); |
|
158 | - } elseif ( is_array( $invoice ) ) { |
|
159 | - $this->set_props( $invoice ); |
|
152 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) { |
|
153 | + $this->set_id((int) $invoice); |
|
154 | + } elseif ($invoice instanceof self) { |
|
155 | + $this->set_id($invoice->get_id()); |
|
156 | + } elseif (!empty($invoice->ID)) { |
|
157 | + $this->set_id($invoice->ID); |
|
158 | + } elseif (is_array($invoice)) { |
|
159 | + $this->set_props($invoice); |
|
160 | 160 | |
161 | - if ( isset( $invoice['ID'] ) ) { |
|
162 | - $this->set_id( $invoice['ID'] ); |
|
161 | + if (isset($invoice['ID'])) { |
|
162 | + $this->set_id($invoice['ID']); |
|
163 | 163 | } |
164 | -} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
165 | - $this->set_id( $invoice_id ); |
|
166 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
167 | - $this->set_id( $invoice_id ); |
|
168 | - } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
169 | - $this->set_id( $invoice_id ); |
|
164 | +} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
165 | + $this->set_id($invoice_id); |
|
166 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
167 | + $this->set_id($invoice_id); |
|
168 | + } elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
169 | + $this->set_id($invoice_id); |
|
170 | 170 | } else { |
171 | - $this->set_object_read( true ); |
|
171 | + $this->set_object_read(true); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Load the datastore. |
175 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
175 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
176 | 176 | |
177 | - if ( $this->get_id() > 0 ) { |
|
178 | - $this->post = get_post( $this->get_id() ); |
|
177 | + if ($this->get_id() > 0) { |
|
178 | + $this->post = get_post($this->get_id()); |
|
179 | 179 | $this->ID = $this->get_id(); |
180 | - $this->data_store->read( $this ); |
|
180 | + $this->data_store->read($this); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | } |
@@ -192,38 +192,38 @@ discard block |
||
192 | 192 | * @since 1.0.15 |
193 | 193 | * @return int |
194 | 194 | */ |
195 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
195 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
196 | 196 | global $wpdb; |
197 | 197 | |
198 | 198 | // Trim the value. |
199 | - $value = trim( $value ); |
|
199 | + $value = trim($value); |
|
200 | 200 | |
201 | - if ( empty( $value ) ) { |
|
201 | + if (empty($value)) { |
|
202 | 202 | return 0; |
203 | 203 | } |
204 | 204 | |
205 | 205 | // Valid fields. |
206 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
206 | + $fields = array('key', 'number', 'transaction_id'); |
|
207 | 207 | |
208 | 208 | // Ensure a field has been passed. |
209 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
209 | + if (empty($field) || !in_array($field, $fields)) { |
|
210 | 210 | return 0; |
211 | 211 | } |
212 | 212 | |
213 | 213 | // Maybe retrieve from the cache. |
214 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
215 | - if ( false !== $invoice_id ) { |
|
214 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
215 | + if (false !== $invoice_id) { |
|
216 | 216 | return $invoice_id; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Fetch from the db. |
220 | 220 | $table = $wpdb->prefix . 'getpaid_invoices'; |
221 | 221 | $invoice_id = (int) $wpdb->get_var( |
222 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
222 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
223 | 223 | ); |
224 | 224 | |
225 | 225 | // Update the cache with our data |
226 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
226 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
227 | 227 | |
228 | 228 | return $invoice_id; |
229 | 229 | } |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | /** |
232 | 232 | * Checks if an invoice key is set. |
233 | 233 | */ |
234 | - public function _isset( $key ) { |
|
235 | - return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" ); |
|
234 | + public function _isset($key) { |
|
235 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /* |
@@ -257,8 +257,8 @@ discard block |
||
257 | 257 | * @param string $context View or edit context. |
258 | 258 | * @return int |
259 | 259 | */ |
260 | - public function get_parent_id( $context = 'view' ) { |
|
261 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
260 | + public function get_parent_id($context = 'view') { |
|
261 | + return (int) $this->get_prop('parent_id', $context); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | * @return WPInv_Invoice |
269 | 269 | */ |
270 | 270 | public function get_parent_payment() { |
271 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
271 | + return new WPInv_Invoice($this->get_parent_id()); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -288,8 +288,8 @@ discard block |
||
288 | 288 | * @param string $context View or edit context. |
289 | 289 | * @return string |
290 | 290 | */ |
291 | - public function get_status( $context = 'view' ) { |
|
292 | - return $this->get_prop( 'status', $context ); |
|
291 | + public function get_status($context = 'view') { |
|
292 | + return $this->get_prop('status', $context); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | * @return array |
300 | 300 | */ |
301 | 301 | public function get_all_statuses() { |
302 | - return wpinv_get_invoice_statuses( true, true, $this ); |
|
302 | + return wpinv_get_invoice_statuses(true, true, $this); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -311,9 +311,9 @@ discard block |
||
311 | 311 | public function get_status_nicename() { |
312 | 312 | $statuses = $this->get_all_statuses(); |
313 | 313 | |
314 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
314 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
315 | 315 | |
316 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
316 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | */ |
325 | 325 | public function get_status_class() { |
326 | 326 | $statuses = getpaid_get_invoice_status_classes(); |
327 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
327 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -335,9 +335,9 @@ discard block |
||
335 | 335 | */ |
336 | 336 | public function get_status_label_html() { |
337 | 337 | |
338 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
339 | - $status = sanitize_html_class( $this->get_status() ); |
|
340 | - $class = esc_attr( $this->get_status_class() ); |
|
338 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
339 | + $status = sanitize_html_class($this->get_status()); |
|
340 | + $class = esc_attr($this->get_status_class()); |
|
341 | 341 | |
342 | 342 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
343 | 343 | } |
@@ -349,23 +349,23 @@ discard block |
||
349 | 349 | * @param string $context View or edit context. |
350 | 350 | * @return string |
351 | 351 | */ |
352 | - public function get_version( $context = 'view' ) { |
|
353 | - return $this->get_prop( 'version', $context ); |
|
352 | + public function get_version($context = 'view') { |
|
353 | + return $this->get_prop('version', $context); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
357 | 357 | * @deprecated |
358 | 358 | */ |
359 | - public function get_invoice_date( $format = true ) { |
|
360 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
361 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
362 | - $formatted = getpaid_format_date( $date ); |
|
359 | + public function get_invoice_date($format = true) { |
|
360 | + $date = getpaid_format_date($this->get_date_completed()); |
|
361 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
362 | + $formatted = getpaid_format_date($date); |
|
363 | 363 | |
364 | - if ( $format ) { |
|
364 | + if ($format) { |
|
365 | 365 | return $formatted; |
366 | 366 | } |
367 | 367 | |
368 | - return empty( $formatted ) ? '' : $date; |
|
368 | + return empty($formatted) ? '' : $date; |
|
369 | 369 | |
370 | 370 | } |
371 | 371 | |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param string $context View or edit context. |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function get_date_created( $context = 'view' ) { |
|
380 | - return $this->get_prop( 'date_created', $context ); |
|
379 | + public function get_date_created($context = 'view') { |
|
380 | + return $this->get_prop('date_created', $context); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | /** |
@@ -387,8 +387,8 @@ discard block |
||
387 | 387 | * @param string $context View or edit context. |
388 | 388 | * @return string |
389 | 389 | */ |
390 | - public function get_created_date( $context = 'view' ) { |
|
391 | - return $this->get_date_created( $context ); |
|
390 | + public function get_created_date($context = 'view') { |
|
391 | + return $this->get_date_created($context); |
|
392 | 392 | } |
393 | 393 | |
394 | 394 | /** |
@@ -398,11 +398,11 @@ discard block |
||
398 | 398 | * @param string $context View or edit context. |
399 | 399 | * @return string |
400 | 400 | */ |
401 | - public function get_date_created_gmt( $context = 'view' ) { |
|
402 | - $date = $this->get_date_created( $context ); |
|
401 | + public function get_date_created_gmt($context = 'view') { |
|
402 | + $date = $this->get_date_created($context); |
|
403 | 403 | |
404 | - if ( $date ) { |
|
405 | - $date = get_gmt_from_date( $date ); |
|
404 | + if ($date) { |
|
405 | + $date = get_gmt_from_date($date); |
|
406 | 406 | } |
407 | 407 | return $date; |
408 | 408 | } |
@@ -414,8 +414,8 @@ discard block |
||
414 | 414 | * @param string $context View or edit context. |
415 | 415 | * @return string |
416 | 416 | */ |
417 | - public function get_date_modified( $context = 'view' ) { |
|
418 | - return $this->get_prop( 'date_modified', $context ); |
|
417 | + public function get_date_modified($context = 'view') { |
|
418 | + return $this->get_prop('date_modified', $context); |
|
419 | 419 | } |
420 | 420 | |
421 | 421 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param string $context View or edit context. |
426 | 426 | * @return string |
427 | 427 | */ |
428 | - public function get_modified_date( $context = 'view' ) { |
|
429 | - return $this->get_date_modified( $context ); |
|
428 | + public function get_modified_date($context = 'view') { |
|
429 | + return $this->get_date_modified($context); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -436,11 +436,11 @@ discard block |
||
436 | 436 | * @param string $context View or edit context. |
437 | 437 | * @return string |
438 | 438 | */ |
439 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
440 | - $date = $this->get_date_modified( $context ); |
|
439 | + public function get_date_modified_gmt($context = 'view') { |
|
440 | + $date = $this->get_date_modified($context); |
|
441 | 441 | |
442 | - if ( $date ) { |
|
443 | - $date = get_gmt_from_date( $date ); |
|
442 | + if ($date) { |
|
443 | + $date = get_gmt_from_date($date); |
|
444 | 444 | } |
445 | 445 | return $date; |
446 | 446 | } |
@@ -452,8 +452,8 @@ discard block |
||
452 | 452 | * @param string $context View or edit context. |
453 | 453 | * @return string |
454 | 454 | */ |
455 | - public function get_due_date( $context = 'view' ) { |
|
456 | - return $this->get_prop( 'due_date', $context ); |
|
455 | + public function get_due_date($context = 'view') { |
|
456 | + return $this->get_prop('due_date', $context); |
|
457 | 457 | } |
458 | 458 | |
459 | 459 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @param string $context View or edit context. |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public function get_date_due( $context = 'view' ) { |
|
467 | - return $this->get_due_date( $context ); |
|
466 | + public function get_date_due($context = 'view') { |
|
467 | + return $this->get_due_date($context); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -474,11 +474,11 @@ discard block |
||
474 | 474 | * @param string $context View or edit context. |
475 | 475 | * @return string |
476 | 476 | */ |
477 | - public function get_due_date_gmt( $context = 'view' ) { |
|
478 | - $date = $this->get_due_date( $context ); |
|
477 | + public function get_due_date_gmt($context = 'view') { |
|
478 | + $date = $this->get_due_date($context); |
|
479 | 479 | |
480 | - if ( $date ) { |
|
481 | - $date = get_gmt_from_date( $date ); |
|
480 | + if ($date) { |
|
481 | + $date = get_gmt_from_date($date); |
|
482 | 482 | } |
483 | 483 | return $date; |
484 | 484 | } |
@@ -490,8 +490,8 @@ discard block |
||
490 | 490 | * @param string $context View or edit context. |
491 | 491 | * @return string |
492 | 492 | */ |
493 | - public function get_gmt_date_due( $context = 'view' ) { |
|
494 | - return $this->get_due_date_gmt( $context ); |
|
493 | + public function get_gmt_date_due($context = 'view') { |
|
494 | + return $this->get_due_date_gmt($context); |
|
495 | 495 | } |
496 | 496 | |
497 | 497 | /** |
@@ -501,8 +501,8 @@ discard block |
||
501 | 501 | * @param string $context View or edit context. |
502 | 502 | * @return string |
503 | 503 | */ |
504 | - public function get_completed_date( $context = 'view' ) { |
|
505 | - return $this->get_prop( 'completed_date', $context ); |
|
504 | + public function get_completed_date($context = 'view') { |
|
505 | + return $this->get_prop('completed_date', $context); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | /** |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | * @param string $context View or edit context. |
513 | 513 | * @return string |
514 | 514 | */ |
515 | - public function get_date_completed( $context = 'view' ) { |
|
516 | - return $this->get_completed_date( $context ); |
|
515 | + public function get_date_completed($context = 'view') { |
|
516 | + return $this->get_completed_date($context); |
|
517 | 517 | } |
518 | 518 | |
519 | 519 | /** |
@@ -523,11 +523,11 @@ discard block |
||
523 | 523 | * @param string $context View or edit context. |
524 | 524 | * @return string |
525 | 525 | */ |
526 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
527 | - $date = $this->get_completed_date( $context ); |
|
526 | + public function get_completed_date_gmt($context = 'view') { |
|
527 | + $date = $this->get_completed_date($context); |
|
528 | 528 | |
529 | - if ( $date ) { |
|
530 | - $date = get_gmt_from_date( $date ); |
|
529 | + if ($date) { |
|
530 | + $date = get_gmt_from_date($date); |
|
531 | 531 | } |
532 | 532 | return $date; |
533 | 533 | } |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @param string $context View or edit context. |
540 | 540 | * @return string |
541 | 541 | */ |
542 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
543 | - return $this->get_completed_date_gmt( $context ); |
|
542 | + public function get_gmt_completed_date($context = 'view') { |
|
543 | + return $this->get_completed_date_gmt($context); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -550,12 +550,12 @@ discard block |
||
550 | 550 | * @param string $context View or edit context. |
551 | 551 | * @return string |
552 | 552 | */ |
553 | - public function get_number( $context = 'view' ) { |
|
554 | - $number = $this->get_prop( 'number', $context ); |
|
553 | + public function get_number($context = 'view') { |
|
554 | + $number = $this->get_prop('number', $context); |
|
555 | 555 | |
556 | - if ( empty( $number ) ) { |
|
556 | + if (empty($number)) { |
|
557 | 557 | $number = $this->generate_number(); |
558 | - $this->set_number( $this->generate_number() ); |
|
558 | + $this->set_number($this->generate_number()); |
|
559 | 559 | } |
560 | 560 | |
561 | 561 | return $number; |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | public function maybe_set_number() { |
570 | 570 | $number = $this->get_number(); |
571 | 571 | |
572 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
573 | - $this->set_number( $this->generate_number() ); |
|
572 | + if (empty($number) || $this->get_id() == $number) { |
|
573 | + $this->set_number($this->generate_number()); |
|
574 | 574 | } |
575 | 575 | |
576 | 576 | } |
@@ -582,8 +582,8 @@ discard block |
||
582 | 582 | * @param string $context View or edit context. |
583 | 583 | * @return string |
584 | 584 | */ |
585 | - public function get_key( $context = 'view' ) { |
|
586 | - return $this->get_prop( 'key', $context ); |
|
585 | + public function get_key($context = 'view') { |
|
586 | + return $this->get_prop('key', $context); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -594,9 +594,9 @@ discard block |
||
594 | 594 | public function maybe_set_key() { |
595 | 595 | $key = $this->get_key(); |
596 | 596 | |
597 | - if ( empty( $key ) ) { |
|
598 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
599 | - $this->set_key( $key ); |
|
597 | + if (empty($key)) { |
|
598 | + $key = $this->generate_key($this->get_type() . '_'); |
|
599 | + $this->set_key($key); |
|
600 | 600 | } |
601 | 601 | |
602 | 602 | } |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | * @param string $context View or edit context. |
609 | 609 | * @return string |
610 | 610 | */ |
611 | - public function get_type( $context = 'view' ) { |
|
612 | - return $this->get_prop( 'type', $context ); |
|
611 | + public function get_type($context = 'view') { |
|
612 | + return $this->get_prop('type', $context); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | /** |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | * @return string |
620 | 620 | */ |
621 | 621 | public function get_invoice_quote_type() { |
622 | - return getpaid_get_post_type_label( $this->get_post_type(), false ); |
|
622 | + return getpaid_get_post_type_label($this->get_post_type(), false); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -629,8 +629,8 @@ discard block |
||
629 | 629 | * @param string $context View or edit context. |
630 | 630 | * @return string |
631 | 631 | */ |
632 | - public function get_label( $context = 'view' ) { |
|
633 | - return getpaid_get_post_type_label( $this->get_post_type( $context ), false ); |
|
632 | + public function get_label($context = 'view') { |
|
633 | + return getpaid_get_post_type_label($this->get_post_type($context), false); |
|
634 | 634 | } |
635 | 635 | |
636 | 636 | /** |
@@ -640,8 +640,8 @@ discard block |
||
640 | 640 | * @param string $context View or edit context. |
641 | 641 | * @return string |
642 | 642 | */ |
643 | - public function get_post_type( $context = 'view' ) { |
|
644 | - return $this->get_prop( 'post_type', $context ); |
|
643 | + public function get_post_type($context = 'view') { |
|
644 | + return $this->get_prop('post_type', $context); |
|
645 | 645 | } |
646 | 646 | |
647 | 647 | /** |
@@ -651,8 +651,8 @@ discard block |
||
651 | 651 | * @param string $context View or edit context. |
652 | 652 | * @return string |
653 | 653 | */ |
654 | - public function get_mode( $context = 'view' ) { |
|
655 | - return $this->get_prop( 'mode', $context ); |
|
654 | + public function get_mode($context = 'view') { |
|
655 | + return $this->get_prop('mode', $context); |
|
656 | 656 | } |
657 | 657 | |
658 | 658 | /** |
@@ -662,13 +662,13 @@ discard block |
||
662 | 662 | * @param string $context View or edit context. |
663 | 663 | * @return string |
664 | 664 | */ |
665 | - public function get_path( $context = 'view' ) { |
|
666 | - $path = $this->get_prop( 'path', $context ); |
|
665 | + public function get_path($context = 'view') { |
|
666 | + $path = $this->get_prop('path', $context); |
|
667 | 667 | $prefix = $this->get_type(); |
668 | 668 | |
669 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
670 | - $path = sanitize_title( $prefix . '-' . $this->get_id() ); |
|
671 | - $this->set_path( $path ); |
|
669 | + if (0 !== strpos($path, $prefix)) { |
|
670 | + $path = sanitize_title($prefix . '-' . $this->get_id()); |
|
671 | + $this->set_path($path); |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | return $path; |
@@ -681,8 +681,8 @@ discard block |
||
681 | 681 | * @param string $context View or edit context. |
682 | 682 | * @return string |
683 | 683 | */ |
684 | - public function get_name( $context = 'view' ) { |
|
685 | - return $this->get_prop( 'title', $context ); |
|
684 | + public function get_name($context = 'view') { |
|
685 | + return $this->get_prop('title', $context); |
|
686 | 686 | } |
687 | 687 | |
688 | 688 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | * @param string $context View or edit context. |
693 | 693 | * @return string |
694 | 694 | */ |
695 | - public function get_title( $context = 'view' ) { |
|
696 | - return $this->get_name( $context ); |
|
695 | + public function get_title($context = 'view') { |
|
696 | + return $this->get_name($context); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -703,8 +703,8 @@ discard block |
||
703 | 703 | * @param string $context View or edit context. |
704 | 704 | * @return string |
705 | 705 | */ |
706 | - public function get_description( $context = 'view' ) { |
|
707 | - return $this->get_prop( 'description', $context ); |
|
706 | + public function get_description($context = 'view') { |
|
707 | + return $this->get_prop('description', $context); |
|
708 | 708 | } |
709 | 709 | |
710 | 710 | /** |
@@ -714,8 +714,8 @@ discard block |
||
714 | 714 | * @param string $context View or edit context. |
715 | 715 | * @return string |
716 | 716 | */ |
717 | - public function get_excerpt( $context = 'view' ) { |
|
718 | - return $this->get_description( $context ); |
|
717 | + public function get_excerpt($context = 'view') { |
|
718 | + return $this->get_description($context); |
|
719 | 719 | } |
720 | 720 | |
721 | 721 | /** |
@@ -725,8 +725,8 @@ discard block |
||
725 | 725 | * @param string $context View or edit context. |
726 | 726 | * @return string |
727 | 727 | */ |
728 | - public function get_summary( $context = 'view' ) { |
|
729 | - return $this->get_description( $context ); |
|
728 | + public function get_summary($context = 'view') { |
|
729 | + return $this->get_description($context); |
|
730 | 730 | } |
731 | 731 | |
732 | 732 | /** |
@@ -736,26 +736,26 @@ discard block |
||
736 | 736 | * @param string $context View or edit context. |
737 | 737 | * @return array |
738 | 738 | */ |
739 | - public function get_user_info( $context = 'view' ) { |
|
739 | + public function get_user_info($context = 'view') { |
|
740 | 740 | |
741 | 741 | $user_info = array( |
742 | - 'user_id' => $this->get_user_id( $context ), |
|
743 | - 'email' => $this->get_email( $context ), |
|
744 | - 'first_name' => $this->get_first_name( $context ), |
|
745 | - 'last_name' => $this->get_last_name( $context ), |
|
746 | - 'address' => $this->get_address( $context ), |
|
747 | - 'phone' => $this->get_phone( $context ), |
|
748 | - 'city' => $this->get_city( $context ), |
|
749 | - 'country' => $this->get_country( $context ), |
|
750 | - 'state' => $this->get_state( $context ), |
|
751 | - 'zip' => $this->get_zip( $context ), |
|
752 | - 'company' => $this->get_company( $context ), |
|
753 | - 'company_id' => $this->get_company_id( $context ), |
|
754 | - 'vat_number' => $this->get_vat_number( $context ), |
|
755 | - 'discount' => $this->get_discount_code( $context ), |
|
742 | + 'user_id' => $this->get_user_id($context), |
|
743 | + 'email' => $this->get_email($context), |
|
744 | + 'first_name' => $this->get_first_name($context), |
|
745 | + 'last_name' => $this->get_last_name($context), |
|
746 | + 'address' => $this->get_address($context), |
|
747 | + 'phone' => $this->get_phone($context), |
|
748 | + 'city' => $this->get_city($context), |
|
749 | + 'country' => $this->get_country($context), |
|
750 | + 'state' => $this->get_state($context), |
|
751 | + 'zip' => $this->get_zip($context), |
|
752 | + 'company' => $this->get_company($context), |
|
753 | + 'company_id' => $this->get_company_id($context), |
|
754 | + 'vat_number' => $this->get_vat_number($context), |
|
755 | + 'discount' => $this->get_discount_code($context), |
|
756 | 756 | ); |
757 | 757 | |
758 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
758 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
759 | 759 | |
760 | 760 | } |
761 | 761 | |
@@ -766,8 +766,8 @@ discard block |
||
766 | 766 | * @param string $context View or edit context. |
767 | 767 | * @return int |
768 | 768 | */ |
769 | - public function get_author( $context = 'view' ) { |
|
770 | - return (int) $this->get_prop( 'author', $context ); |
|
769 | + public function get_author($context = 'view') { |
|
770 | + return (int) $this->get_prop('author', $context); |
|
771 | 771 | } |
772 | 772 | |
773 | 773 | /** |
@@ -777,8 +777,8 @@ discard block |
||
777 | 777 | * @param string $context View or edit context. |
778 | 778 | * @return int |
779 | 779 | */ |
780 | - public function get_user_id( $context = 'view' ) { |
|
781 | - return $this->get_author( $context ); |
|
780 | + public function get_user_id($context = 'view') { |
|
781 | + return $this->get_author($context); |
|
782 | 782 | } |
783 | 783 | |
784 | 784 | /** |
@@ -788,8 +788,8 @@ discard block |
||
788 | 788 | * @param string $context View or edit context. |
789 | 789 | * @return int |
790 | 790 | */ |
791 | - public function get_customer_id( $context = 'view' ) { |
|
792 | - return $this->get_author( $context ); |
|
791 | + public function get_customer_id($context = 'view') { |
|
792 | + return $this->get_author($context); |
|
793 | 793 | } |
794 | 794 | |
795 | 795 | /** |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | * @param string $context View or edit context. |
800 | 800 | * @return string |
801 | 801 | */ |
802 | - public function get_ip( $context = 'view' ) { |
|
803 | - return $this->get_prop( 'user_ip', $context ); |
|
802 | + public function get_ip($context = 'view') { |
|
803 | + return $this->get_prop('user_ip', $context); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -810,8 +810,8 @@ discard block |
||
810 | 810 | * @param string $context View or edit context. |
811 | 811 | * @return string |
812 | 812 | */ |
813 | - public function get_user_ip( $context = 'view' ) { |
|
814 | - return $this->get_ip( $context ); |
|
813 | + public function get_user_ip($context = 'view') { |
|
814 | + return $this->get_ip($context); |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
@@ -821,8 +821,8 @@ discard block |
||
821 | 821 | * @param string $context View or edit context. |
822 | 822 | * @return string |
823 | 823 | */ |
824 | - public function get_customer_ip( $context = 'view' ) { |
|
825 | - return $this->get_ip( $context ); |
|
824 | + public function get_customer_ip($context = 'view') { |
|
825 | + return $this->get_ip($context); |
|
826 | 826 | } |
827 | 827 | |
828 | 828 | /** |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @param string $context View or edit context. |
833 | 833 | * @return string |
834 | 834 | */ |
835 | - public function get_first_name( $context = 'view' ) { |
|
836 | - return $this->get_prop( 'first_name', $context ); |
|
835 | + public function get_first_name($context = 'view') { |
|
836 | + return $this->get_prop('first_name', $context); |
|
837 | 837 | } |
838 | 838 | |
839 | 839 | /** |
@@ -843,8 +843,8 @@ discard block |
||
843 | 843 | * @param string $context View or edit context. |
844 | 844 | * @return string |
845 | 845 | */ |
846 | - public function get_user_first_name( $context = 'view' ) { |
|
847 | - return $this->get_first_name( $context ); |
|
846 | + public function get_user_first_name($context = 'view') { |
|
847 | + return $this->get_first_name($context); |
|
848 | 848 | } |
849 | 849 | |
850 | 850 | /** |
@@ -854,8 +854,8 @@ discard block |
||
854 | 854 | * @param string $context View or edit context. |
855 | 855 | * @return string |
856 | 856 | */ |
857 | - public function get_customer_first_name( $context = 'view' ) { |
|
858 | - return $this->get_first_name( $context ); |
|
857 | + public function get_customer_first_name($context = 'view') { |
|
858 | + return $this->get_first_name($context); |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | * @param string $context View or edit context. |
866 | 866 | * @return string |
867 | 867 | */ |
868 | - public function get_last_name( $context = 'view' ) { |
|
869 | - return $this->get_prop( 'last_name', $context ); |
|
868 | + public function get_last_name($context = 'view') { |
|
869 | + return $this->get_prop('last_name', $context); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | /** |
@@ -876,8 +876,8 @@ discard block |
||
876 | 876 | * @param string $context View or edit context. |
877 | 877 | * @return string |
878 | 878 | */ |
879 | - public function get_user_last_name( $context = 'view' ) { |
|
880 | - return $this->get_last_name( $context ); |
|
879 | + public function get_user_last_name($context = 'view') { |
|
880 | + return $this->get_last_name($context); |
|
881 | 881 | } |
882 | 882 | |
883 | 883 | /** |
@@ -887,8 +887,8 @@ discard block |
||
887 | 887 | * @param string $context View or edit context. |
888 | 888 | * @return string |
889 | 889 | */ |
890 | - public function get_customer_last_name( $context = 'view' ) { |
|
891 | - return $this->get_last_name( $context ); |
|
890 | + public function get_customer_last_name($context = 'view') { |
|
891 | + return $this->get_last_name($context); |
|
892 | 892 | } |
893 | 893 | |
894 | 894 | /** |
@@ -898,22 +898,22 @@ discard block |
||
898 | 898 | * @param string $context View or edit context. |
899 | 899 | * @return string |
900 | 900 | */ |
901 | - public function get_full_name( $context = 'view' ) { |
|
902 | - $name = trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
901 | + public function get_full_name($context = 'view') { |
|
902 | + $name = trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
903 | 903 | |
904 | - if ( ! $name ) { |
|
905 | - $user = get_userdata( $this->get_author( $context ) ); |
|
904 | + if (!$name) { |
|
905 | + $user = get_userdata($this->get_author($context)); |
|
906 | 906 | |
907 | - if ( $user ) { |
|
907 | + if ($user) { |
|
908 | 908 | $name = $user->display_name; |
909 | 909 | } |
910 | 910 | } |
911 | 911 | |
912 | - if ( ! $name ) { |
|
913 | - $name = $this->get_email( $context ); |
|
912 | + if (!$name) { |
|
913 | + $name = $this->get_email($context); |
|
914 | 914 | } |
915 | 915 | |
916 | - return apply_filters( 'wpinv_invoice_user_full_name', $name, $this ); |
|
916 | + return apply_filters('wpinv_invoice_user_full_name', $name, $this); |
|
917 | 917 | } |
918 | 918 | |
919 | 919 | /** |
@@ -923,8 +923,8 @@ discard block |
||
923 | 923 | * @param string $context View or edit context. |
924 | 924 | * @return string |
925 | 925 | */ |
926 | - public function get_user_full_name( $context = 'view' ) { |
|
927 | - return $this->get_full_name( $context ); |
|
926 | + public function get_user_full_name($context = 'view') { |
|
927 | + return $this->get_full_name($context); |
|
928 | 928 | } |
929 | 929 | |
930 | 930 | /** |
@@ -934,8 +934,8 @@ discard block |
||
934 | 934 | * @param string $context View or edit context. |
935 | 935 | * @return string |
936 | 936 | */ |
937 | - public function get_customer_full_name( $context = 'view' ) { |
|
938 | - return $this->get_full_name( $context ); |
|
937 | + public function get_customer_full_name($context = 'view') { |
|
938 | + return $this->get_full_name($context); |
|
939 | 939 | } |
940 | 940 | |
941 | 941 | /** |
@@ -945,8 +945,8 @@ discard block |
||
945 | 945 | * @param string $context View or edit context. |
946 | 946 | * @return string |
947 | 947 | */ |
948 | - public function get_phone( $context = 'view' ) { |
|
949 | - return $this->get_prop( 'phone', $context ); |
|
948 | + public function get_phone($context = 'view') { |
|
949 | + return $this->get_prop('phone', $context); |
|
950 | 950 | } |
951 | 951 | |
952 | 952 | /** |
@@ -956,8 +956,8 @@ discard block |
||
956 | 956 | * @param string $context View or edit context. |
957 | 957 | * @return string |
958 | 958 | */ |
959 | - public function get_phone_number( $context = 'view' ) { |
|
960 | - return $this->get_phone( $context ); |
|
959 | + public function get_phone_number($context = 'view') { |
|
960 | + return $this->get_phone($context); |
|
961 | 961 | } |
962 | 962 | |
963 | 963 | /** |
@@ -967,8 +967,8 @@ discard block |
||
967 | 967 | * @param string $context View or edit context. |
968 | 968 | * @return string |
969 | 969 | */ |
970 | - public function get_user_phone( $context = 'view' ) { |
|
971 | - return $this->get_phone( $context ); |
|
970 | + public function get_user_phone($context = 'view') { |
|
971 | + return $this->get_phone($context); |
|
972 | 972 | } |
973 | 973 | |
974 | 974 | /** |
@@ -978,8 +978,8 @@ discard block |
||
978 | 978 | * @param string $context View or edit context. |
979 | 979 | * @return string |
980 | 980 | */ |
981 | - public function get_customer_phone( $context = 'view' ) { |
|
982 | - return $this->get_phone( $context ); |
|
981 | + public function get_customer_phone($context = 'view') { |
|
982 | + return $this->get_phone($context); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | /** |
@@ -989,8 +989,8 @@ discard block |
||
989 | 989 | * @param string $context View or edit context. |
990 | 990 | * @return string |
991 | 991 | */ |
992 | - public function get_email( $context = 'view' ) { |
|
993 | - return $this->get_prop( 'email', $context ); |
|
992 | + public function get_email($context = 'view') { |
|
993 | + return $this->get_prop('email', $context); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
@@ -1000,8 +1000,8 @@ discard block |
||
1000 | 1000 | * @param string $context View or edit context. |
1001 | 1001 | * @return string |
1002 | 1002 | */ |
1003 | - public function get_email_address( $context = 'view' ) { |
|
1004 | - return $this->get_email( $context ); |
|
1003 | + public function get_email_address($context = 'view') { |
|
1004 | + return $this->get_email($context); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
@@ -1011,8 +1011,8 @@ discard block |
||
1011 | 1011 | * @param string $context View or edit context. |
1012 | 1012 | * @return string |
1013 | 1013 | */ |
1014 | - public function get_user_email( $context = 'view' ) { |
|
1015 | - return $this->get_email( $context ); |
|
1014 | + public function get_user_email($context = 'view') { |
|
1015 | + return $this->get_email($context); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
@@ -1022,8 +1022,8 @@ discard block |
||
1022 | 1022 | * @param string $context View or edit context. |
1023 | 1023 | * @return string |
1024 | 1024 | */ |
1025 | - public function get_customer_email( $context = 'view' ) { |
|
1026 | - return $this->get_email( $context ); |
|
1025 | + public function get_customer_email($context = 'view') { |
|
1026 | + return $this->get_email($context); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | /** |
@@ -1033,9 +1033,9 @@ discard block |
||
1033 | 1033 | * @param string $context View or edit context. |
1034 | 1034 | * @return string |
1035 | 1035 | */ |
1036 | - public function get_country( $context = 'view' ) { |
|
1037 | - $country = $this->get_prop( 'country', $context ); |
|
1038 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
1036 | + public function get_country($context = 'view') { |
|
1037 | + $country = $this->get_prop('country', $context); |
|
1038 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
1039 | 1039 | } |
1040 | 1040 | |
1041 | 1041 | /** |
@@ -1045,8 +1045,8 @@ discard block |
||
1045 | 1045 | * @param string $context View or edit context. |
1046 | 1046 | * @return string |
1047 | 1047 | */ |
1048 | - public function get_user_country( $context = 'view' ) { |
|
1049 | - return $this->get_country( $context ); |
|
1048 | + public function get_user_country($context = 'view') { |
|
1049 | + return $this->get_country($context); |
|
1050 | 1050 | } |
1051 | 1051 | |
1052 | 1052 | /** |
@@ -1056,8 +1056,8 @@ discard block |
||
1056 | 1056 | * @param string $context View or edit context. |
1057 | 1057 | * @return string |
1058 | 1058 | */ |
1059 | - public function get_customer_country( $context = 'view' ) { |
|
1060 | - return $this->get_country( $context ); |
|
1059 | + public function get_customer_country($context = 'view') { |
|
1060 | + return $this->get_country($context); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | 1063 | /** |
@@ -1067,9 +1067,9 @@ discard block |
||
1067 | 1067 | * @param string $context View or edit context. |
1068 | 1068 | * @return string |
1069 | 1069 | */ |
1070 | - public function get_state( $context = 'view' ) { |
|
1071 | - $state = $this->get_prop( 'state', $context ); |
|
1072 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1070 | + public function get_state($context = 'view') { |
|
1071 | + $state = $this->get_prop('state', $context); |
|
1072 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | /** |
@@ -1079,8 +1079,8 @@ discard block |
||
1079 | 1079 | * @param string $context View or edit context. |
1080 | 1080 | * @return string |
1081 | 1081 | */ |
1082 | - public function get_user_state( $context = 'view' ) { |
|
1083 | - return $this->get_state( $context ); |
|
1082 | + public function get_user_state($context = 'view') { |
|
1083 | + return $this->get_state($context); |
|
1084 | 1084 | } |
1085 | 1085 | |
1086 | 1086 | /** |
@@ -1090,8 +1090,8 @@ discard block |
||
1090 | 1090 | * @param string $context View or edit context. |
1091 | 1091 | * @return string |
1092 | 1092 | */ |
1093 | - public function get_customer_state( $context = 'view' ) { |
|
1094 | - return $this->get_state( $context ); |
|
1093 | + public function get_customer_state($context = 'view') { |
|
1094 | + return $this->get_state($context); |
|
1095 | 1095 | } |
1096 | 1096 | |
1097 | 1097 | /** |
@@ -1101,8 +1101,8 @@ discard block |
||
1101 | 1101 | * @param string $context View or edit context. |
1102 | 1102 | * @return string |
1103 | 1103 | */ |
1104 | - public function get_city( $context = 'view' ) { |
|
1105 | - return $this->get_prop( 'city', $context ); |
|
1104 | + public function get_city($context = 'view') { |
|
1105 | + return $this->get_prop('city', $context); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | /** |
@@ -1112,8 +1112,8 @@ discard block |
||
1112 | 1112 | * @param string $context View or edit context. |
1113 | 1113 | * @return string |
1114 | 1114 | */ |
1115 | - public function get_user_city( $context = 'view' ) { |
|
1116 | - return $this->get_city( $context ); |
|
1115 | + public function get_user_city($context = 'view') { |
|
1116 | + return $this->get_city($context); |
|
1117 | 1117 | } |
1118 | 1118 | |
1119 | 1119 | /** |
@@ -1123,8 +1123,8 @@ discard block |
||
1123 | 1123 | * @param string $context View or edit context. |
1124 | 1124 | * @return string |
1125 | 1125 | */ |
1126 | - public function get_customer_city( $context = 'view' ) { |
|
1127 | - return $this->get_city( $context ); |
|
1126 | + public function get_customer_city($context = 'view') { |
|
1127 | + return $this->get_city($context); |
|
1128 | 1128 | } |
1129 | 1129 | |
1130 | 1130 | /** |
@@ -1134,8 +1134,8 @@ discard block |
||
1134 | 1134 | * @param string $context View or edit context. |
1135 | 1135 | * @return string |
1136 | 1136 | */ |
1137 | - public function get_zip( $context = 'view' ) { |
|
1138 | - return $this->get_prop( 'zip', $context ); |
|
1137 | + public function get_zip($context = 'view') { |
|
1138 | + return $this->get_prop('zip', $context); |
|
1139 | 1139 | } |
1140 | 1140 | |
1141 | 1141 | /** |
@@ -1145,8 +1145,8 @@ discard block |
||
1145 | 1145 | * @param string $context View or edit context. |
1146 | 1146 | * @return string |
1147 | 1147 | */ |
1148 | - public function get_user_zip( $context = 'view' ) { |
|
1149 | - return $this->get_zip( $context ); |
|
1148 | + public function get_user_zip($context = 'view') { |
|
1149 | + return $this->get_zip($context); |
|
1150 | 1150 | } |
1151 | 1151 | |
1152 | 1152 | /** |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | * @param string $context View or edit context. |
1157 | 1157 | * @return string |
1158 | 1158 | */ |
1159 | - public function get_customer_zip( $context = 'view' ) { |
|
1160 | - return $this->get_zip( $context ); |
|
1159 | + public function get_customer_zip($context = 'view') { |
|
1160 | + return $this->get_zip($context); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1167,8 +1167,8 @@ discard block |
||
1167 | 1167 | * @param string $context View or edit context. |
1168 | 1168 | * @return string |
1169 | 1169 | */ |
1170 | - public function get_company( $context = 'view' ) { |
|
1171 | - return $this->get_prop( 'company', $context ); |
|
1170 | + public function get_company($context = 'view') { |
|
1171 | + return $this->get_prop('company', $context); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1178,8 +1178,8 @@ discard block |
||
1178 | 1178 | * @param string $context View or edit context. |
1179 | 1179 | * @return string |
1180 | 1180 | */ |
1181 | - public function get_user_company( $context = 'view' ) { |
|
1182 | - return $this->get_company( $context ); |
|
1181 | + public function get_user_company($context = 'view') { |
|
1182 | + return $this->get_company($context); |
|
1183 | 1183 | } |
1184 | 1184 | |
1185 | 1185 | /** |
@@ -1189,8 +1189,8 @@ discard block |
||
1189 | 1189 | * @param string $context View or edit context. |
1190 | 1190 | * @return string |
1191 | 1191 | */ |
1192 | - public function get_customer_company( $context = 'view' ) { |
|
1193 | - return $this->get_company( $context ); |
|
1192 | + public function get_customer_company($context = 'view') { |
|
1193 | + return $this->get_company($context); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | /** |
@@ -1200,8 +1200,8 @@ discard block |
||
1200 | 1200 | * @param string $context View or edit context. |
1201 | 1201 | * @return string |
1202 | 1202 | */ |
1203 | - public function get_company_id( $context = 'view' ) { |
|
1204 | - return $this->get_prop( 'company_id', $context ); |
|
1203 | + public function get_company_id($context = 'view') { |
|
1204 | + return $this->get_prop('company_id', $context); |
|
1205 | 1205 | } |
1206 | 1206 | |
1207 | 1207 | /** |
@@ -1211,8 +1211,8 @@ discard block |
||
1211 | 1211 | * @param string $context View or edit context. |
1212 | 1212 | * @return string |
1213 | 1213 | */ |
1214 | - public function get_vat_number( $context = 'view' ) { |
|
1215 | - return $this->get_prop( 'vat_number', $context ); |
|
1214 | + public function get_vat_number($context = 'view') { |
|
1215 | + return $this->get_prop('vat_number', $context); |
|
1216 | 1216 | } |
1217 | 1217 | |
1218 | 1218 | /** |
@@ -1222,8 +1222,8 @@ discard block |
||
1222 | 1222 | * @param string $context View or edit context. |
1223 | 1223 | * @return string |
1224 | 1224 | */ |
1225 | - public function get_user_vat_number( $context = 'view' ) { |
|
1226 | - return $this->get_vat_number( $context ); |
|
1225 | + public function get_user_vat_number($context = 'view') { |
|
1226 | + return $this->get_vat_number($context); |
|
1227 | 1227 | } |
1228 | 1228 | |
1229 | 1229 | /** |
@@ -1233,8 +1233,8 @@ discard block |
||
1233 | 1233 | * @param string $context View or edit context. |
1234 | 1234 | * @return string |
1235 | 1235 | */ |
1236 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1237 | - return $this->get_vat_number( $context ); |
|
1236 | + public function get_customer_vat_number($context = 'view') { |
|
1237 | + return $this->get_vat_number($context); |
|
1238 | 1238 | } |
1239 | 1239 | |
1240 | 1240 | /** |
@@ -1244,8 +1244,8 @@ discard block |
||
1244 | 1244 | * @param string $context View or edit context. |
1245 | 1245 | * @return string |
1246 | 1246 | */ |
1247 | - public function get_vat_rate( $context = 'view' ) { |
|
1248 | - return $this->get_prop( 'vat_rate', $context ); |
|
1247 | + public function get_vat_rate($context = 'view') { |
|
1248 | + return $this->get_prop('vat_rate', $context); |
|
1249 | 1249 | } |
1250 | 1250 | |
1251 | 1251 | /** |
@@ -1255,8 +1255,8 @@ discard block |
||
1255 | 1255 | * @param string $context View or edit context. |
1256 | 1256 | * @return string |
1257 | 1257 | */ |
1258 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1259 | - return $this->get_vat_rate( $context ); |
|
1258 | + public function get_user_vat_rate($context = 'view') { |
|
1259 | + return $this->get_vat_rate($context); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | /** |
@@ -1266,8 +1266,8 @@ discard block |
||
1266 | 1266 | * @param string $context View or edit context. |
1267 | 1267 | * @return string |
1268 | 1268 | */ |
1269 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1270 | - return $this->get_vat_rate( $context ); |
|
1269 | + public function get_customer_vat_rate($context = 'view') { |
|
1270 | + return $this->get_vat_rate($context); |
|
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | /** |
@@ -1277,8 +1277,8 @@ discard block |
||
1277 | 1277 | * @param string $context View or edit context. |
1278 | 1278 | * @return string |
1279 | 1279 | */ |
1280 | - public function get_address( $context = 'view' ) { |
|
1281 | - return $this->get_prop( 'address', $context ); |
|
1280 | + public function get_address($context = 'view') { |
|
1281 | + return $this->get_prop('address', $context); |
|
1282 | 1282 | } |
1283 | 1283 | |
1284 | 1284 | /** |
@@ -1288,8 +1288,8 @@ discard block |
||
1288 | 1288 | * @param string $context View or edit context. |
1289 | 1289 | * @return string |
1290 | 1290 | */ |
1291 | - public function get_user_address( $context = 'view' ) { |
|
1292 | - return $this->get_address( $context ); |
|
1291 | + public function get_user_address($context = 'view') { |
|
1292 | + return $this->get_address($context); |
|
1293 | 1293 | } |
1294 | 1294 | |
1295 | 1295 | /** |
@@ -1299,8 +1299,8 @@ discard block |
||
1299 | 1299 | * @param string $context View or edit context. |
1300 | 1300 | * @return string |
1301 | 1301 | */ |
1302 | - public function get_customer_address( $context = 'view' ) { |
|
1303 | - return $this->get_address( $context ); |
|
1302 | + public function get_customer_address($context = 'view') { |
|
1303 | + return $this->get_address($context); |
|
1304 | 1304 | } |
1305 | 1305 | |
1306 | 1306 | /** |
@@ -1310,8 +1310,8 @@ discard block |
||
1310 | 1310 | * @param string $context View or edit context. |
1311 | 1311 | * @return bool |
1312 | 1312 | */ |
1313 | - public function get_is_viewed( $context = 'view' ) { |
|
1314 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1313 | + public function get_is_viewed($context = 'view') { |
|
1314 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1315 | 1315 | } |
1316 | 1316 | |
1317 | 1317 | /** |
@@ -1321,8 +1321,8 @@ discard block |
||
1321 | 1321 | * @param string $context View or edit context. |
1322 | 1322 | * @return bool |
1323 | 1323 | */ |
1324 | - public function get_email_cc( $context = 'view' ) { |
|
1325 | - return $this->get_prop( 'email_cc', $context ); |
|
1324 | + public function get_email_cc($context = 'view') { |
|
1325 | + return $this->get_prop('email_cc', $context); |
|
1326 | 1326 | } |
1327 | 1327 | |
1328 | 1328 | /** |
@@ -1332,8 +1332,8 @@ discard block |
||
1332 | 1332 | * @param string $context View or edit context. |
1333 | 1333 | * @return bool |
1334 | 1334 | */ |
1335 | - public function get_template( $context = 'view' ) { |
|
1336 | - return $this->get_prop( 'template', $context ); |
|
1335 | + public function get_template($context = 'view') { |
|
1336 | + return $this->get_prop('template', $context); |
|
1337 | 1337 | } |
1338 | 1338 | |
1339 | 1339 | /** |
@@ -1343,8 +1343,8 @@ discard block |
||
1343 | 1343 | * @param string $context View or edit context. |
1344 | 1344 | * @return bool |
1345 | 1345 | */ |
1346 | - public function get_created_via( $context = 'view' ) { |
|
1347 | - return $this->get_prop( 'created_via', $context ); |
|
1346 | + public function get_created_via($context = 'view') { |
|
1347 | + return $this->get_prop('created_via', $context); |
|
1348 | 1348 | } |
1349 | 1349 | |
1350 | 1350 | /** |
@@ -1354,8 +1354,8 @@ discard block |
||
1354 | 1354 | * @param string $context View or edit context. |
1355 | 1355 | * @return bool |
1356 | 1356 | */ |
1357 | - public function get_address_confirmed( $context = 'view' ) { |
|
1358 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1357 | + public function get_address_confirmed($context = 'view') { |
|
1358 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | /** |
@@ -1365,8 +1365,8 @@ discard block |
||
1365 | 1365 | * @param string $context View or edit context. |
1366 | 1366 | * @return bool |
1367 | 1367 | */ |
1368 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1369 | - return $this->get_address_confirmed( $context ); |
|
1368 | + public function get_user_address_confirmed($context = 'view') { |
|
1369 | + return $this->get_address_confirmed($context); |
|
1370 | 1370 | } |
1371 | 1371 | |
1372 | 1372 | /** |
@@ -1376,8 +1376,8 @@ discard block |
||
1376 | 1376 | * @param string $context View or edit context. |
1377 | 1377 | * @return bool |
1378 | 1378 | */ |
1379 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1380 | - return $this->get_address_confirmed( $context ); |
|
1379 | + public function get_customer_address_confirmed($context = 'view') { |
|
1380 | + return $this->get_address_confirmed($context); |
|
1381 | 1381 | } |
1382 | 1382 | |
1383 | 1383 | /** |
@@ -1388,8 +1388,8 @@ discard block |
||
1388 | 1388 | */ |
1389 | 1389 | public function get_shipping_address() { |
1390 | 1390 | |
1391 | - $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true ); |
|
1392 | - return is_array( $shipping_address ) ? $shipping_address : false; |
|
1391 | + $shipping_address = get_post_meta($this->get_id(), 'shipping_address', true); |
|
1392 | + return is_array($shipping_address) ? $shipping_address : false; |
|
1393 | 1393 | } |
1394 | 1394 | |
1395 | 1395 | /** |
@@ -1406,17 +1406,17 @@ discard block |
||
1406 | 1406 | * @param string $context View or edit context. |
1407 | 1407 | * @return float |
1408 | 1408 | */ |
1409 | - public function get_shipping( $context = 'view' ) { |
|
1409 | + public function get_shipping($context = 'view') { |
|
1410 | 1410 | |
1411 | - if ( $context = 'view' ) { |
|
1412 | - return floatval( $this->get_prop( 'shipping', $context ) ); |
|
1411 | + if ($context = 'view') { |
|
1412 | + return floatval($this->get_prop('shipping', $context)); |
|
1413 | 1413 | } |
1414 | 1414 | |
1415 | - return $this->get_prop( 'shipping', $context ); |
|
1415 | + return $this->get_prop('shipping', $context); |
|
1416 | 1416 | } |
1417 | 1417 | |
1418 | 1418 | public function has_shipping() { |
1419 | - return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' ); |
|
1419 | + return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit'); |
|
1420 | 1420 | } |
1421 | 1421 | |
1422 | 1422 | /** |
@@ -1426,12 +1426,12 @@ discard block |
||
1426 | 1426 | * @param string $context View or edit context. |
1427 | 1427 | * @return float |
1428 | 1428 | */ |
1429 | - public function get_subtotal( $context = 'view' ) { |
|
1430 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1429 | + public function get_subtotal($context = 'view') { |
|
1430 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1431 | 1431 | |
1432 | 1432 | // Backwards compatibility. |
1433 | - if ( is_bool( $context ) && $context ) { |
|
1434 | - return wpinv_price( $subtotal, $this->get_currency() ); |
|
1433 | + if (is_bool($context) && $context) { |
|
1434 | + return wpinv_price($subtotal, $this->get_currency()); |
|
1435 | 1435 | } |
1436 | 1436 | |
1437 | 1437 | return $subtotal; |
@@ -1444,8 +1444,8 @@ discard block |
||
1444 | 1444 | * @param string $context View or edit context. |
1445 | 1445 | * @return float |
1446 | 1446 | */ |
1447 | - public function get_total_discount( $context = 'view' ) { |
|
1448 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) ); |
|
1447 | + public function get_total_discount($context = 'view') { |
|
1448 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context))); |
|
1449 | 1449 | } |
1450 | 1450 | |
1451 | 1451 | /** |
@@ -1455,18 +1455,18 @@ discard block |
||
1455 | 1455 | * @param string $context View or edit context. |
1456 | 1456 | * @return float |
1457 | 1457 | */ |
1458 | - public function get_total_tax( $context = 'view' ) { |
|
1459 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) ); |
|
1458 | + public function get_total_tax($context = 'view') { |
|
1459 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context))); |
|
1460 | 1460 | } |
1461 | 1461 | |
1462 | 1462 | /** |
1463 | 1463 | * @deprecated |
1464 | 1464 | */ |
1465 | - public function get_final_tax( $currency = false ) { |
|
1465 | + public function get_final_tax($currency = false) { |
|
1466 | 1466 | $tax = $this->get_total_tax(); |
1467 | 1467 | |
1468 | - if ( $currency ) { |
|
1469 | - return wpinv_price( $tax, $this->get_currency() ); |
|
1468 | + if ($currency) { |
|
1469 | + return wpinv_price($tax, $this->get_currency()); |
|
1470 | 1470 | } |
1471 | 1471 | |
1472 | 1472 | return $tax; |
@@ -1479,8 +1479,8 @@ discard block |
||
1479 | 1479 | * @param string $context View or edit context. |
1480 | 1480 | * @return float |
1481 | 1481 | */ |
1482 | - public function get_total_fees( $context = 'view' ) { |
|
1483 | - return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) ); |
|
1482 | + public function get_total_fees($context = 'view') { |
|
1483 | + return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context))); |
|
1484 | 1484 | } |
1485 | 1485 | |
1486 | 1486 | /** |
@@ -1490,8 +1490,8 @@ discard block |
||
1490 | 1490 | * @param string $context View or edit context. |
1491 | 1491 | * @return float |
1492 | 1492 | */ |
1493 | - public function get_fees_total( $context = 'view' ) { |
|
1494 | - return $this->get_total_fees( $context ); |
|
1493 | + public function get_fees_total($context = 'view') { |
|
1494 | + return $this->get_total_fees($context); |
|
1495 | 1495 | } |
1496 | 1496 | |
1497 | 1497 | /** |
@@ -1500,14 +1500,14 @@ discard block |
||
1500 | 1500 | * @since 1.0.19 |
1501 | 1501 | * @return float |
1502 | 1502 | */ |
1503 | - public function get_total( $context = 'view' ) { |
|
1504 | - $total = $this->get_prop( 'total', $context ); |
|
1503 | + public function get_total($context = 'view') { |
|
1504 | + $total = $this->get_prop('total', $context); |
|
1505 | 1505 | |
1506 | - if ( $this->has_shipping() && $context == 'view' ) { |
|
1507 | - $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context ); |
|
1506 | + if ($this->has_shipping() && $context == 'view') { |
|
1507 | + $total = $this->get_prop('total', $context) + $this->get_shipping($context); |
|
1508 | 1508 | } |
1509 | 1509 | |
1510 | - return wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1510 | + return wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | /** |
@@ -1519,20 +1519,20 @@ discard block |
||
1519 | 1519 | public function get_non_recurring_total() { |
1520 | 1520 | |
1521 | 1521 | $subtotal = 0; |
1522 | - foreach ( $this->get_items() as $item ) { |
|
1523 | - if ( ! $item->is_recurring() ) { |
|
1522 | + foreach ($this->get_items() as $item) { |
|
1523 | + if (!$item->is_recurring()) { |
|
1524 | 1524 | $subtotal += $item->get_sub_total(); |
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 | |
1528 | - foreach ( $this->get_fees() as $fee ) { |
|
1529 | - if ( empty( $fee['recurring_fee'] ) ) { |
|
1530 | - $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
1528 | + foreach ($this->get_fees() as $fee) { |
|
1529 | + if (empty($fee['recurring_fee'])) { |
|
1530 | + $subtotal += wpinv_sanitize_amount($fee['initial_fee']); |
|
1531 | 1531 | } |
1532 | 1532 | } |
1533 | 1533 | |
1534 | - $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) ); |
|
1535 | - return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this ); |
|
1534 | + $subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal)); |
|
1535 | + return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this); |
|
1536 | 1536 | |
1537 | 1537 | } |
1538 | 1538 | |
@@ -1555,7 +1555,7 @@ discard block |
||
1555 | 1555 | */ |
1556 | 1556 | public function get_initial_total() { |
1557 | 1557 | |
1558 | - if ( empty( $this->totals ) ) { |
|
1558 | + if (empty($this->totals)) { |
|
1559 | 1559 | $this->recalculate_total(); |
1560 | 1560 | } |
1561 | 1561 | |
@@ -1565,12 +1565,12 @@ discard block |
||
1565 | 1565 | $subtotal = $this->totals['subtotal']['initial']; |
1566 | 1566 | $total = $tax + $fee - $discount + $subtotal; |
1567 | 1567 | |
1568 | - if ( 0 > $total ) { |
|
1568 | + if (0 > $total) { |
|
1569 | 1569 | $total = 0; |
1570 | 1570 | } |
1571 | 1571 | |
1572 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1573 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1572 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1573 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1574 | 1574 | } |
1575 | 1575 | |
1576 | 1576 | /** |
@@ -1582,7 +1582,7 @@ discard block |
||
1582 | 1582 | */ |
1583 | 1583 | public function get_recurring_total() { |
1584 | 1584 | |
1585 | - if ( empty( $this->totals ) ) { |
|
1585 | + if (empty($this->totals)) { |
|
1586 | 1586 | $this->recalculate_total(); |
1587 | 1587 | } |
1588 | 1588 | |
@@ -1592,12 +1592,12 @@ discard block |
||
1592 | 1592 | $subtotal = $this->totals['subtotal']['recurring']; |
1593 | 1593 | $total = $tax + $fee - $discount + $subtotal; |
1594 | 1594 | |
1595 | - if ( 0 > $total ) { |
|
1595 | + if (0 > $total) { |
|
1596 | 1596 | $total = 0; |
1597 | 1597 | } |
1598 | 1598 | |
1599 | - $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) ); |
|
1600 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1599 | + $total = wpinv_round_amount(wpinv_sanitize_amount($total)); |
|
1600 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | 1603 | /** |
@@ -1608,10 +1608,10 @@ discard block |
||
1608 | 1608 | * @param string $currency Whether to include the currency. |
1609 | 1609 | * @return float|string |
1610 | 1610 | */ |
1611 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1611 | + public function get_recurring_details($field = '', $currency = false) { |
|
1612 | 1612 | |
1613 | 1613 | // Maybe recalculate totals. |
1614 | - if ( empty( $this->totals ) ) { |
|
1614 | + if (empty($this->totals)) { |
|
1615 | 1615 | $this->recalculate_total(); |
1616 | 1616 | } |
1617 | 1617 | |
@@ -1631,8 +1631,8 @@ discard block |
||
1631 | 1631 | $currency |
1632 | 1632 | ); |
1633 | 1633 | |
1634 | - if ( isset( $data[ $field ] ) ) { |
|
1635 | - return ( $currency ? wpinv_price( $data[ $field ], $this->get_currency() ) : $data[ $field ] ); |
|
1634 | + if (isset($data[$field])) { |
|
1635 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1636 | 1636 | } |
1637 | 1637 | |
1638 | 1638 | return $data; |
@@ -1645,8 +1645,8 @@ discard block |
||
1645 | 1645 | * @param string $context View or edit context. |
1646 | 1646 | * @return array |
1647 | 1647 | */ |
1648 | - public function get_fees( $context = 'view' ) { |
|
1649 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1648 | + public function get_fees($context = 'view') { |
|
1649 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1650 | 1650 | } |
1651 | 1651 | |
1652 | 1652 | /** |
@@ -1656,8 +1656,8 @@ discard block |
||
1656 | 1656 | * @param string $context View or edit context. |
1657 | 1657 | * @return array |
1658 | 1658 | */ |
1659 | - public function get_discounts( $context = 'view' ) { |
|
1660 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1659 | + public function get_discounts($context = 'view') { |
|
1660 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | /** |
@@ -1667,8 +1667,8 @@ discard block |
||
1667 | 1667 | * @param string $context View or edit context. |
1668 | 1668 | * @return array |
1669 | 1669 | */ |
1670 | - public function get_taxes( $context = 'view' ) { |
|
1671 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1670 | + public function get_taxes($context = 'view') { |
|
1671 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1672 | 1672 | } |
1673 | 1673 | |
1674 | 1674 | /** |
@@ -1678,8 +1678,8 @@ discard block |
||
1678 | 1678 | * @param string $context View or edit context. |
1679 | 1679 | * @return GetPaid_Form_Item[] |
1680 | 1680 | */ |
1681 | - public function get_items( $context = 'view' ) { |
|
1682 | - return $this->get_prop( 'items', $context ); |
|
1681 | + public function get_items($context = 'view') { |
|
1682 | + return $this->get_prop('items', $context); |
|
1683 | 1683 | } |
1684 | 1684 | |
1685 | 1685 | /** |
@@ -1689,7 +1689,7 @@ discard block |
||
1689 | 1689 | * @return string |
1690 | 1690 | */ |
1691 | 1691 | public function get_item_ids() { |
1692 | - return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) ); |
|
1692 | + return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id')); |
|
1693 | 1693 | } |
1694 | 1694 | |
1695 | 1695 | /** |
@@ -1699,8 +1699,8 @@ discard block |
||
1699 | 1699 | * @param string $context View or edit context. |
1700 | 1700 | * @return int |
1701 | 1701 | */ |
1702 | - public function get_payment_form( $context = 'view' ) { |
|
1703 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1702 | + public function get_payment_form($context = 'view') { |
|
1703 | + return intval($this->get_prop('payment_form', $context)); |
|
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | /** |
@@ -1710,8 +1710,8 @@ discard block |
||
1710 | 1710 | * @param string $context View or edit context. |
1711 | 1711 | * @return string |
1712 | 1712 | */ |
1713 | - public function get_submission_id( $context = 'view' ) { |
|
1714 | - return $this->get_prop( 'submission_id', $context ); |
|
1713 | + public function get_submission_id($context = 'view') { |
|
1714 | + return $this->get_prop('submission_id', $context); |
|
1715 | 1715 | } |
1716 | 1716 | |
1717 | 1717 | /** |
@@ -1721,8 +1721,8 @@ discard block |
||
1721 | 1721 | * @param string $context View or edit context. |
1722 | 1722 | * @return string |
1723 | 1723 | */ |
1724 | - public function get_discount_code( $context = 'view' ) { |
|
1725 | - return $this->get_prop( 'discount_code', $context ); |
|
1724 | + public function get_discount_code($context = 'view') { |
|
1725 | + return $this->get_prop('discount_code', $context); |
|
1726 | 1726 | } |
1727 | 1727 | |
1728 | 1728 | /** |
@@ -1732,8 +1732,8 @@ discard block |
||
1732 | 1732 | * @param string $context View or edit context. |
1733 | 1733 | * @return string |
1734 | 1734 | */ |
1735 | - public function get_gateway( $context = 'view' ) { |
|
1736 | - return $this->get_prop( 'gateway', $context ); |
|
1735 | + public function get_gateway($context = 'view') { |
|
1736 | + return $this->get_prop('gateway', $context); |
|
1737 | 1737 | } |
1738 | 1738 | |
1739 | 1739 | /** |
@@ -1743,8 +1743,8 @@ discard block |
||
1743 | 1743 | * @return string |
1744 | 1744 | */ |
1745 | 1745 | public function get_gateway_title() { |
1746 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1747 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1746 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1747 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1748 | 1748 | } |
1749 | 1749 | |
1750 | 1750 | /** |
@@ -1754,8 +1754,8 @@ discard block |
||
1754 | 1754 | * @param string $context View or edit context. |
1755 | 1755 | * @return string |
1756 | 1756 | */ |
1757 | - public function get_transaction_id( $context = 'view' ) { |
|
1758 | - return $this->get_prop( 'transaction_id', $context ); |
|
1757 | + public function get_transaction_id($context = 'view') { |
|
1758 | + return $this->get_prop('transaction_id', $context); |
|
1759 | 1759 | } |
1760 | 1760 | |
1761 | 1761 | /** |
@@ -1765,9 +1765,9 @@ discard block |
||
1765 | 1765 | * @param string $context View or edit context. |
1766 | 1766 | * @return string |
1767 | 1767 | */ |
1768 | - public function get_currency( $context = 'view' ) { |
|
1769 | - $currency = $this->get_prop( 'currency', $context ); |
|
1770 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1768 | + public function get_currency($context = 'view') { |
|
1769 | + $currency = $this->get_prop('currency', $context); |
|
1770 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1771 | 1771 | } |
1772 | 1772 | |
1773 | 1773 | /** |
@@ -1777,8 +1777,8 @@ discard block |
||
1777 | 1777 | * @param string $context View or edit context. |
1778 | 1778 | * @return bool |
1779 | 1779 | */ |
1780 | - public function get_disable_taxes( $context = 'view' ) { |
|
1781 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1780 | + public function get_disable_taxes($context = 'view') { |
|
1781 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1782 | 1782 | } |
1783 | 1783 | |
1784 | 1784 | /** |
@@ -1788,8 +1788,8 @@ discard block |
||
1788 | 1788 | * @param string $context View or edit context. |
1789 | 1789 | * @return int |
1790 | 1790 | */ |
1791 | - public function get_subscription_id( $context = 'view' ) { |
|
1792 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1791 | + public function get_subscription_id($context = 'view') { |
|
1792 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1793 | 1793 | } |
1794 | 1794 | |
1795 | 1795 | /** |
@@ -1799,12 +1799,12 @@ discard block |
||
1799 | 1799 | * @param string $context View or edit context. |
1800 | 1800 | * @return int |
1801 | 1801 | */ |
1802 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1803 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1802 | + public function get_remote_subscription_id($context = 'view') { |
|
1803 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1804 | 1804 | |
1805 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1805 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1806 | 1806 | $parent = $this->get_parent(); |
1807 | - return $parent->get_remote_subscription_id( $context ); |
|
1807 | + return $parent->get_remote_subscription_id($context); |
|
1808 | 1808 | } |
1809 | 1809 | |
1810 | 1810 | return $subscription_id; |
@@ -1817,20 +1817,20 @@ discard block |
||
1817 | 1817 | * @param string $context View or edit context. |
1818 | 1818 | * @return array |
1819 | 1819 | */ |
1820 | - public function get_payment_meta( $context = 'view' ) { |
|
1820 | + public function get_payment_meta($context = 'view') { |
|
1821 | 1821 | |
1822 | 1822 | return array( |
1823 | - 'price' => $this->get_total( $context ), |
|
1824 | - 'date' => $this->get_date_created( $context ), |
|
1825 | - 'user_email' => $this->get_email( $context ), |
|
1826 | - 'invoice_key' => $this->get_key( $context ), |
|
1827 | - 'currency' => $this->get_currency( $context ), |
|
1828 | - 'items' => $this->get_items( $context ), |
|
1829 | - 'user_info' => $this->get_user_info( $context ), |
|
1823 | + 'price' => $this->get_total($context), |
|
1824 | + 'date' => $this->get_date_created($context), |
|
1825 | + 'user_email' => $this->get_email($context), |
|
1826 | + 'invoice_key' => $this->get_key($context), |
|
1827 | + 'currency' => $this->get_currency($context), |
|
1828 | + 'items' => $this->get_items($context), |
|
1829 | + 'user_info' => $this->get_user_info($context), |
|
1830 | 1830 | 'cart_details' => $this->get_cart_details(), |
1831 | - 'status' => $this->get_status( $context ), |
|
1832 | - 'fees' => $this->get_fees( $context ), |
|
1833 | - 'taxes' => $this->get_taxes( $context ), |
|
1831 | + 'status' => $this->get_status($context), |
|
1832 | + 'fees' => $this->get_fees($context), |
|
1833 | + 'taxes' => $this->get_taxes($context), |
|
1834 | 1834 | ); |
1835 | 1835 | |
1836 | 1836 | } |
@@ -1845,9 +1845,9 @@ discard block |
||
1845 | 1845 | $items = $this->get_items(); |
1846 | 1846 | $cart_details = array(); |
1847 | 1847 | |
1848 | - foreach ( $items as $item ) { |
|
1848 | + foreach ($items as $item) { |
|
1849 | 1849 | $item->invoice_id = $this->get_id(); |
1850 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1850 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1851 | 1851 | } |
1852 | 1852 | |
1853 | 1853 | return $cart_details; |
@@ -1858,11 +1858,11 @@ discard block |
||
1858 | 1858 | * |
1859 | 1859 | * @return null|GetPaid_Form_Item|int |
1860 | 1860 | */ |
1861 | - public function get_recurring( $object = false ) { |
|
1861 | + public function get_recurring($object = false) { |
|
1862 | 1862 | |
1863 | 1863 | // Are we returning an object? |
1864 | - if ( $object ) { |
|
1865 | - return $this->get_item( $this->recurring_item ); |
|
1864 | + if ($object) { |
|
1865 | + return $this->get_item($this->recurring_item); |
|
1866 | 1866 | } |
1867 | 1867 | |
1868 | 1868 | return $this->recurring_item; |
@@ -1877,15 +1877,15 @@ discard block |
||
1877 | 1877 | public function get_subscription_name() { |
1878 | 1878 | |
1879 | 1879 | // Retrieve the recurring name |
1880 | - $item = $this->get_recurring( true ); |
|
1880 | + $item = $this->get_recurring(true); |
|
1881 | 1881 | |
1882 | 1882 | // Abort if it does not exist. |
1883 | - if ( empty( $item ) ) { |
|
1883 | + if (empty($item)) { |
|
1884 | 1884 | return ''; |
1885 | 1885 | } |
1886 | 1886 | |
1887 | 1887 | // Return the item name. |
1888 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1888 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1889 | 1889 | } |
1890 | 1890 | |
1891 | 1891 | /** |
@@ -1895,9 +1895,9 @@ discard block |
||
1895 | 1895 | * @return string |
1896 | 1896 | */ |
1897 | 1897 | public function get_view_url() { |
1898 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1899 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1900 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1898 | + $invoice_url = get_permalink($this->get_id()); |
|
1899 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1900 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | /** |
@@ -1906,25 +1906,25 @@ discard block |
||
1906 | 1906 | * @since 1.0.19 |
1907 | 1907 | * @return string |
1908 | 1908 | */ |
1909 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1909 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1910 | 1910 | |
1911 | 1911 | // Retrieve the checkout url. |
1912 | 1912 | $pay_url = wpinv_get_checkout_uri(); |
1913 | 1913 | |
1914 | 1914 | // Maybe force ssl. |
1915 | - if ( is_ssl() ) { |
|
1916 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1915 | + if (is_ssl()) { |
|
1916 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1917 | 1917 | } |
1918 | 1918 | |
1919 | 1919 | // Add the invoice key. |
1920 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1920 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1921 | 1921 | |
1922 | 1922 | // (Maybe?) add a secret |
1923 | - if ( $secret ) { |
|
1924 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1923 | + if ($secret) { |
|
1924 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1925 | 1925 | } |
1926 | 1926 | |
1927 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1927 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1928 | 1928 | } |
1929 | 1929 | |
1930 | 1930 | /** |
@@ -1939,14 +1939,14 @@ discard block |
||
1939 | 1939 | $receipt_url = wpinv_get_success_page_uri(); |
1940 | 1940 | |
1941 | 1941 | // Maybe force ssl. |
1942 | - if ( is_ssl() ) { |
|
1943 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1942 | + if (is_ssl()) { |
|
1943 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | // Add the invoice key. |
1947 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1947 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1948 | 1948 | |
1949 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1949 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1950 | 1950 | } |
1951 | 1951 | |
1952 | 1952 | /** |
@@ -1956,7 +1956,7 @@ discard block |
||
1956 | 1956 | * @return string |
1957 | 1957 | */ |
1958 | 1958 | public function get_transaction_url() { |
1959 | - return apply_filters( 'getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this ); |
|
1959 | + return apply_filters('getpaid_gateway_' . $this->get_gateway() . '_transaction_url', '', $this); |
|
1960 | 1960 | } |
1961 | 1961 | |
1962 | 1962 | /** |
@@ -1969,7 +1969,7 @@ discard block |
||
1969 | 1969 | |
1970 | 1970 | $type = $this->get_type(); |
1971 | 1971 | $status = "wpi-$type-pending"; |
1972 | - return str_replace( '-invoice', '', $status ); |
|
1972 | + return str_replace('-invoice', '', $status); |
|
1973 | 1973 | |
1974 | 1974 | } |
1975 | 1975 | |
@@ -1983,8 +1983,8 @@ discard block |
||
1983 | 1983 | * @param string $context View or edit context. |
1984 | 1984 | * @return mixed Value of the given invoice property (if set). |
1985 | 1985 | */ |
1986 | - public function get( $key, $context = 'view' ) { |
|
1987 | - return $this->get_prop( $key, $context ); |
|
1986 | + public function get($key, $context = 'view') { |
|
1987 | + return $this->get_prop($key, $context); |
|
1988 | 1988 | } |
1989 | 1989 | |
1990 | 1990 | /* |
@@ -2007,11 +2007,11 @@ discard block |
||
2007 | 2007 | * @param mixed $value new value. |
2008 | 2008 | * @return mixed Value of the given invoice property (if set). |
2009 | 2009 | */ |
2010 | - public function set( $key, $value ) { |
|
2010 | + public function set($key, $value) { |
|
2011 | 2011 | |
2012 | 2012 | $setter = "set_$key"; |
2013 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
2014 | - $this->{$setter}( $value ); |
|
2013 | + if (is_callable(array($this, $setter))) { |
|
2014 | + $this->{$setter}($value); |
|
2015 | 2015 | } |
2016 | 2016 | |
2017 | 2017 | } |
@@ -2025,45 +2025,45 @@ discard block |
||
2025 | 2025 | * @param bool $manual_update Is this a manual status change?. |
2026 | 2026 | * @return array details of change. |
2027 | 2027 | */ |
2028 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
2028 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
2029 | 2029 | $old_status = $this->get_status(); |
2030 | 2030 | |
2031 | 2031 | $statuses = $this->get_all_statuses(); |
2032 | 2032 | |
2033 | - if ( isset( $statuses['draft'] ) ) { |
|
2034 | - unset( $statuses['draft'] ); |
|
2033 | + if (isset($statuses['draft'])) { |
|
2034 | + unset($statuses['draft']); |
|
2035 | 2035 | } |
2036 | 2036 | |
2037 | - $this->set_prop( 'status', $new_status ); |
|
2037 | + $this->set_prop('status', $new_status); |
|
2038 | 2038 | |
2039 | 2039 | // If setting the status, ensure it's set to a valid status. |
2040 | - if ( true === $this->object_read ) { |
|
2040 | + if (true === $this->object_read) { |
|
2041 | 2041 | |
2042 | 2042 | // Only allow valid new status. |
2043 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
2043 | + if (!array_key_exists($new_status, $statuses)) { |
|
2044 | 2044 | $new_status = $this->get_default_status(); |
2045 | 2045 | } |
2046 | 2046 | |
2047 | 2047 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
2048 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
2048 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
2049 | 2049 | $old_status = $this->get_default_status(); |
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
2053 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
2053 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
2054 | 2054 | $old_status = 'wpi-pending'; |
2055 | 2055 | } |
2056 | 2056 | |
2057 | - if ( $old_status !== $new_status ) { |
|
2057 | + if ($old_status !== $new_status) { |
|
2058 | 2058 | $this->status_transition = array( |
2059 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
2059 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
2060 | 2060 | 'to' => $new_status, |
2061 | 2061 | 'note' => $note, |
2062 | 2062 | 'manual' => (bool) $manual_update, |
2063 | 2063 | ); |
2064 | 2064 | |
2065 | - if ( $manual_update ) { |
|
2066 | - do_action( 'getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status ); |
|
2065 | + if ($manual_update) { |
|
2066 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
2067 | 2067 | } |
2068 | 2068 | |
2069 | 2069 | $this->maybe_set_date_paid(); |
@@ -2087,8 +2087,8 @@ discard block |
||
2087 | 2087 | */ |
2088 | 2088 | public function maybe_set_date_paid() { |
2089 | 2089 | |
2090 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
2091 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
2090 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
2091 | + $this->set_date_completed(current_time('mysql')); |
|
2092 | 2092 | } |
2093 | 2093 | } |
2094 | 2094 | |
@@ -2097,11 +2097,11 @@ discard block |
||
2097 | 2097 | * |
2098 | 2098 | * @since 1.0.19 |
2099 | 2099 | */ |
2100 | - public function set_parent_id( $value ) { |
|
2101 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
2100 | + public function set_parent_id($value) { |
|
2101 | + if ($value && ($value === $this->get_id())) { |
|
2102 | 2102 | return; |
2103 | 2103 | } |
2104 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
2104 | + $this->set_prop('parent_id', absint($value)); |
|
2105 | 2105 | } |
2106 | 2106 | |
2107 | 2107 | /** |
@@ -2109,8 +2109,8 @@ discard block |
||
2109 | 2109 | * |
2110 | 2110 | * @since 1.0.19 |
2111 | 2111 | */ |
2112 | - public function set_version( $value ) { |
|
2113 | - $this->set_prop( 'version', $value ); |
|
2112 | + public function set_version($value) { |
|
2113 | + $this->set_prop('version', $value); |
|
2114 | 2114 | } |
2115 | 2115 | |
2116 | 2116 | /** |
@@ -2120,15 +2120,15 @@ discard block |
||
2120 | 2120 | * @param string $value Value to set. |
2121 | 2121 | * @return bool Whether or not the date was set. |
2122 | 2122 | */ |
2123 | - public function set_date_created( $value ) { |
|
2124 | - $date = strtotime( $value ); |
|
2123 | + public function set_date_created($value) { |
|
2124 | + $date = strtotime($value); |
|
2125 | 2125 | |
2126 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2127 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
2126 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2127 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
2128 | 2128 | return true; |
2129 | 2129 | } |
2130 | 2130 | |
2131 | - $this->set_prop( 'date_created', '' ); |
|
2131 | + $this->set_prop('date_created', ''); |
|
2132 | 2132 | return false; |
2133 | 2133 | |
2134 | 2134 | } |
@@ -2140,15 +2140,15 @@ discard block |
||
2140 | 2140 | * @param string $value Value to set. |
2141 | 2141 | * @return bool Whether or not the date was set. |
2142 | 2142 | */ |
2143 | - public function set_due_date( $value ) { |
|
2144 | - $date = strtotime( $value ); |
|
2143 | + public function set_due_date($value) { |
|
2144 | + $date = strtotime($value); |
|
2145 | 2145 | |
2146 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2147 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2146 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2147 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
2148 | 2148 | return true; |
2149 | 2149 | } |
2150 | 2150 | |
2151 | - $this->set_prop( 'due_date', '' ); |
|
2151 | + $this->set_prop('due_date', ''); |
|
2152 | 2152 | return false; |
2153 | 2153 | |
2154 | 2154 | } |
@@ -2159,8 +2159,8 @@ discard block |
||
2159 | 2159 | * @since 1.0.19 |
2160 | 2160 | * @param string $value New name. |
2161 | 2161 | */ |
2162 | - public function set_date_due( $value ) { |
|
2163 | - $this->set_due_date( $value ); |
|
2162 | + public function set_date_due($value) { |
|
2163 | + $this->set_due_date($value); |
|
2164 | 2164 | } |
2165 | 2165 | |
2166 | 2166 | /** |
@@ -2170,15 +2170,15 @@ discard block |
||
2170 | 2170 | * @param string $value Value to set. |
2171 | 2171 | * @return bool Whether or not the date was set. |
2172 | 2172 | */ |
2173 | - public function set_completed_date( $value ) { |
|
2174 | - $date = strtotime( $value ); |
|
2173 | + public function set_completed_date($value) { |
|
2174 | + $date = strtotime($value); |
|
2175 | 2175 | |
2176 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2177 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2176 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2177 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2178 | 2178 | return true; |
2179 | 2179 | } |
2180 | 2180 | |
2181 | - $this->set_prop( 'completed_date', '' ); |
|
2181 | + $this->set_prop('completed_date', ''); |
|
2182 | 2182 | return false; |
2183 | 2183 | |
2184 | 2184 | } |
@@ -2189,8 +2189,8 @@ discard block |
||
2189 | 2189 | * @since 1.0.19 |
2190 | 2190 | * @param string $value New name. |
2191 | 2191 | */ |
2192 | - public function set_date_completed( $value ) { |
|
2193 | - $this->set_completed_date( $value ); |
|
2192 | + public function set_date_completed($value) { |
|
2193 | + $this->set_completed_date($value); |
|
2194 | 2194 | } |
2195 | 2195 | |
2196 | 2196 | /** |
@@ -2200,15 +2200,15 @@ discard block |
||
2200 | 2200 | * @param string $value Value to set. |
2201 | 2201 | * @return bool Whether or not the date was set. |
2202 | 2202 | */ |
2203 | - public function set_date_modified( $value ) { |
|
2204 | - $date = strtotime( $value ); |
|
2203 | + public function set_date_modified($value) { |
|
2204 | + $date = strtotime($value); |
|
2205 | 2205 | |
2206 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2207 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2206 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2207 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2208 | 2208 | return true; |
2209 | 2209 | } |
2210 | 2210 | |
2211 | - $this->set_prop( 'date_modified', '' ); |
|
2211 | + $this->set_prop('date_modified', ''); |
|
2212 | 2212 | return false; |
2213 | 2213 | |
2214 | 2214 | } |
@@ -2219,9 +2219,9 @@ discard block |
||
2219 | 2219 | * @since 1.0.19 |
2220 | 2220 | * @param string $value New number. |
2221 | 2221 | */ |
2222 | - public function set_number( $value ) { |
|
2223 | - $number = sanitize_text_field( $value ); |
|
2224 | - $this->set_prop( 'number', $number ); |
|
2222 | + public function set_number($value) { |
|
2223 | + $number = sanitize_text_field($value); |
|
2224 | + $this->set_prop('number', $number); |
|
2225 | 2225 | } |
2226 | 2226 | |
2227 | 2227 | /** |
@@ -2230,9 +2230,9 @@ discard block |
||
2230 | 2230 | * @since 1.0.19 |
2231 | 2231 | * @param string $value Type. |
2232 | 2232 | */ |
2233 | - public function set_type( $value ) { |
|
2234 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2235 | - $this->set_prop( 'type', $type ); |
|
2233 | + public function set_type($value) { |
|
2234 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2235 | + $this->set_prop('type', $type); |
|
2236 | 2236 | } |
2237 | 2237 | |
2238 | 2238 | /** |
@@ -2241,10 +2241,10 @@ discard block |
||
2241 | 2241 | * @since 1.0.19 |
2242 | 2242 | * @param string $value Post type. |
2243 | 2243 | */ |
2244 | - public function set_post_type( $value ) { |
|
2245 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2246 | - $this->set_type( $value ); |
|
2247 | - $this->set_prop( 'post_type', $value ); |
|
2244 | + public function set_post_type($value) { |
|
2245 | + if (getpaid_is_invoice_post_type($value)) { |
|
2246 | + $this->set_type($value); |
|
2247 | + $this->set_prop('post_type', $value); |
|
2248 | 2248 | } |
2249 | 2249 | } |
2250 | 2250 | |
@@ -2254,9 +2254,9 @@ discard block |
||
2254 | 2254 | * @since 1.0.19 |
2255 | 2255 | * @param string $value New key. |
2256 | 2256 | */ |
2257 | - public function set_key( $value ) { |
|
2258 | - $key = sanitize_text_field( $value ); |
|
2259 | - $this->set_prop( 'key', $key ); |
|
2257 | + public function set_key($value) { |
|
2258 | + $key = sanitize_text_field($value); |
|
2259 | + $this->set_prop('key', $key); |
|
2260 | 2260 | } |
2261 | 2261 | |
2262 | 2262 | /** |
@@ -2265,9 +2265,9 @@ discard block |
||
2265 | 2265 | * @since 1.0.19 |
2266 | 2266 | * @param string $value mode. |
2267 | 2267 | */ |
2268 | - public function set_mode( $value ) { |
|
2269 | - if ( in_array( $value, array( 'live', 'test' ) ) ) { |
|
2270 | - $this->set_prop( 'mode', $value ); |
|
2268 | + public function set_mode($value) { |
|
2269 | + if (in_array($value, array('live', 'test'))) { |
|
2270 | + $this->set_prop('mode', $value); |
|
2271 | 2271 | } |
2272 | 2272 | } |
2273 | 2273 | |
@@ -2277,8 +2277,8 @@ discard block |
||
2277 | 2277 | * @since 1.0.19 |
2278 | 2278 | * @param string $value path. |
2279 | 2279 | */ |
2280 | - public function set_path( $value ) { |
|
2281 | - $this->set_prop( 'path', $value ); |
|
2280 | + public function set_path($value) { |
|
2281 | + $this->set_prop('path', $value); |
|
2282 | 2282 | } |
2283 | 2283 | |
2284 | 2284 | /** |
@@ -2287,9 +2287,9 @@ discard block |
||
2287 | 2287 | * @since 1.0.19 |
2288 | 2288 | * @param string $value New name. |
2289 | 2289 | */ |
2290 | - public function set_name( $value ) { |
|
2291 | - $name = sanitize_text_field( $value ); |
|
2292 | - $this->set_prop( 'name', $name ); |
|
2290 | + public function set_name($value) { |
|
2291 | + $name = sanitize_text_field($value); |
|
2292 | + $this->set_prop('name', $name); |
|
2293 | 2293 | } |
2294 | 2294 | |
2295 | 2295 | /** |
@@ -2298,8 +2298,8 @@ discard block |
||
2298 | 2298 | * @since 1.0.19 |
2299 | 2299 | * @param string $value New name. |
2300 | 2300 | */ |
2301 | - public function set_title( $value ) { |
|
2302 | - $this->set_name( $value ); |
|
2301 | + public function set_title($value) { |
|
2302 | + $this->set_name($value); |
|
2303 | 2303 | } |
2304 | 2304 | |
2305 | 2305 | /** |
@@ -2308,9 +2308,9 @@ discard block |
||
2308 | 2308 | * @since 1.0.19 |
2309 | 2309 | * @param string $value New description. |
2310 | 2310 | */ |
2311 | - public function set_description( $value ) { |
|
2312 | - $description = wp_kses_post( $value ); |
|
2313 | - $this->set_prop( 'description', $description ); |
|
2311 | + public function set_description($value) { |
|
2312 | + $description = wp_kses_post($value); |
|
2313 | + $this->set_prop('description', $description); |
|
2314 | 2314 | } |
2315 | 2315 | |
2316 | 2316 | /** |
@@ -2319,8 +2319,8 @@ discard block |
||
2319 | 2319 | * @since 1.0.19 |
2320 | 2320 | * @param string $value New description. |
2321 | 2321 | */ |
2322 | - public function set_excerpt( $value ) { |
|
2323 | - $this->set_description( $value ); |
|
2322 | + public function set_excerpt($value) { |
|
2323 | + $this->set_description($value); |
|
2324 | 2324 | } |
2325 | 2325 | |
2326 | 2326 | /** |
@@ -2329,8 +2329,8 @@ discard block |
||
2329 | 2329 | * @since 1.0.19 |
2330 | 2330 | * @param string $value New description. |
2331 | 2331 | */ |
2332 | - public function set_summary( $value ) { |
|
2333 | - $this->set_description( $value ); |
|
2332 | + public function set_summary($value) { |
|
2333 | + $this->set_description($value); |
|
2334 | 2334 | } |
2335 | 2335 | |
2336 | 2336 | /** |
@@ -2339,12 +2339,12 @@ discard block |
||
2339 | 2339 | * @since 1.0.19 |
2340 | 2340 | * @param int $value New author. |
2341 | 2341 | */ |
2342 | - public function set_author( $value ) { |
|
2343 | - $user = get_user_by( 'id', (int) $value ); |
|
2342 | + public function set_author($value) { |
|
2343 | + $user = get_user_by('id', (int) $value); |
|
2344 | 2344 | |
2345 | - if ( $user && $user->ID ) { |
|
2346 | - $this->set_prop( 'author', $user->ID ); |
|
2347 | - $this->set_prop( 'email', $user->user_email ); |
|
2345 | + if ($user && $user->ID) { |
|
2346 | + $this->set_prop('author', $user->ID); |
|
2347 | + $this->set_prop('email', $user->user_email); |
|
2348 | 2348 | } |
2349 | 2349 | |
2350 | 2350 | } |
@@ -2355,8 +2355,8 @@ discard block |
||
2355 | 2355 | * @since 1.0.19 |
2356 | 2356 | * @param int $value New user id. |
2357 | 2357 | */ |
2358 | - public function set_user_id( $value ) { |
|
2359 | - $this->set_author( $value ); |
|
2358 | + public function set_user_id($value) { |
|
2359 | + $this->set_author($value); |
|
2360 | 2360 | } |
2361 | 2361 | |
2362 | 2362 | /** |
@@ -2365,8 +2365,8 @@ discard block |
||
2365 | 2365 | * @since 1.0.19 |
2366 | 2366 | * @param int $value New user id. |
2367 | 2367 | */ |
2368 | - public function set_customer_id( $value ) { |
|
2369 | - $this->set_author( $value ); |
|
2368 | + public function set_customer_id($value) { |
|
2369 | + $this->set_author($value); |
|
2370 | 2370 | } |
2371 | 2371 | |
2372 | 2372 | /** |
@@ -2375,8 +2375,8 @@ discard block |
||
2375 | 2375 | * @since 1.0.19 |
2376 | 2376 | * @param string $value ip address. |
2377 | 2377 | */ |
2378 | - public function set_ip( $value ) { |
|
2379 | - $this->set_prop( 'ip', $value ); |
|
2378 | + public function set_ip($value) { |
|
2379 | + $this->set_prop('ip', $value); |
|
2380 | 2380 | } |
2381 | 2381 | |
2382 | 2382 | /** |
@@ -2385,8 +2385,8 @@ discard block |
||
2385 | 2385 | * @since 1.0.19 |
2386 | 2386 | * @param string $value ip address. |
2387 | 2387 | */ |
2388 | - public function set_user_ip( $value ) { |
|
2389 | - $this->set_ip( $value ); |
|
2388 | + public function set_user_ip($value) { |
|
2389 | + $this->set_ip($value); |
|
2390 | 2390 | } |
2391 | 2391 | |
2392 | 2392 | /** |
@@ -2395,8 +2395,8 @@ discard block |
||
2395 | 2395 | * @since 1.0.19 |
2396 | 2396 | * @param string $value first name. |
2397 | 2397 | */ |
2398 | - public function set_first_name( $value ) { |
|
2399 | - $this->set_prop( 'first_name', $value ); |
|
2398 | + public function set_first_name($value) { |
|
2399 | + $this->set_prop('first_name', $value); |
|
2400 | 2400 | } |
2401 | 2401 | |
2402 | 2402 | /** |
@@ -2405,8 +2405,8 @@ discard block |
||
2405 | 2405 | * @since 1.0.19 |
2406 | 2406 | * @param string $value first name. |
2407 | 2407 | */ |
2408 | - public function set_user_first_name( $value ) { |
|
2409 | - $this->set_first_name( $value ); |
|
2408 | + public function set_user_first_name($value) { |
|
2409 | + $this->set_first_name($value); |
|
2410 | 2410 | } |
2411 | 2411 | |
2412 | 2412 | /** |
@@ -2415,8 +2415,8 @@ discard block |
||
2415 | 2415 | * @since 1.0.19 |
2416 | 2416 | * @param string $value first name. |
2417 | 2417 | */ |
2418 | - public function set_customer_first_name( $value ) { |
|
2419 | - $this->set_first_name( $value ); |
|
2418 | + public function set_customer_first_name($value) { |
|
2419 | + $this->set_first_name($value); |
|
2420 | 2420 | } |
2421 | 2421 | |
2422 | 2422 | /** |
@@ -2425,8 +2425,8 @@ discard block |
||
2425 | 2425 | * @since 1.0.19 |
2426 | 2426 | * @param string $value last name. |
2427 | 2427 | */ |
2428 | - public function set_last_name( $value ) { |
|
2429 | - $this->set_prop( 'last_name', $value ); |
|
2428 | + public function set_last_name($value) { |
|
2429 | + $this->set_prop('last_name', $value); |
|
2430 | 2430 | } |
2431 | 2431 | |
2432 | 2432 | /** |
@@ -2435,8 +2435,8 @@ discard block |
||
2435 | 2435 | * @since 1.0.19 |
2436 | 2436 | * @param string $value last name. |
2437 | 2437 | */ |
2438 | - public function set_user_last_name( $value ) { |
|
2439 | - $this->set_last_name( $value ); |
|
2438 | + public function set_user_last_name($value) { |
|
2439 | + $this->set_last_name($value); |
|
2440 | 2440 | } |
2441 | 2441 | |
2442 | 2442 | /** |
@@ -2445,8 +2445,8 @@ discard block |
||
2445 | 2445 | * @since 1.0.19 |
2446 | 2446 | * @param string $value last name. |
2447 | 2447 | */ |
2448 | - public function set_customer_last_name( $value ) { |
|
2449 | - $this->set_last_name( $value ); |
|
2448 | + public function set_customer_last_name($value) { |
|
2449 | + $this->set_last_name($value); |
|
2450 | 2450 | } |
2451 | 2451 | |
2452 | 2452 | /** |
@@ -2455,8 +2455,8 @@ discard block |
||
2455 | 2455 | * @since 1.0.19 |
2456 | 2456 | * @param string $value phone. |
2457 | 2457 | */ |
2458 | - public function set_phone( $value ) { |
|
2459 | - $this->set_prop( 'phone', $value ); |
|
2458 | + public function set_phone($value) { |
|
2459 | + $this->set_prop('phone', $value); |
|
2460 | 2460 | } |
2461 | 2461 | |
2462 | 2462 | /** |
@@ -2465,8 +2465,8 @@ discard block |
||
2465 | 2465 | * @since 1.0.19 |
2466 | 2466 | * @param string $value phone. |
2467 | 2467 | */ |
2468 | - public function set_user_phone( $value ) { |
|
2469 | - $this->set_phone( $value ); |
|
2468 | + public function set_user_phone($value) { |
|
2469 | + $this->set_phone($value); |
|
2470 | 2470 | } |
2471 | 2471 | |
2472 | 2472 | /** |
@@ -2475,8 +2475,8 @@ discard block |
||
2475 | 2475 | * @since 1.0.19 |
2476 | 2476 | * @param string $value phone. |
2477 | 2477 | */ |
2478 | - public function set_customer_phone( $value ) { |
|
2479 | - $this->set_phone( $value ); |
|
2478 | + public function set_customer_phone($value) { |
|
2479 | + $this->set_phone($value); |
|
2480 | 2480 | } |
2481 | 2481 | |
2482 | 2482 | /** |
@@ -2485,8 +2485,8 @@ discard block |
||
2485 | 2485 | * @since 1.0.19 |
2486 | 2486 | * @param string $value phone. |
2487 | 2487 | */ |
2488 | - public function set_phone_number( $value ) { |
|
2489 | - $this->set_phone( $value ); |
|
2488 | + public function set_phone_number($value) { |
|
2489 | + $this->set_phone($value); |
|
2490 | 2490 | } |
2491 | 2491 | |
2492 | 2492 | /** |
@@ -2495,8 +2495,8 @@ discard block |
||
2495 | 2495 | * @since 1.0.19 |
2496 | 2496 | * @param string $value email address. |
2497 | 2497 | */ |
2498 | - public function set_email( $value ) { |
|
2499 | - $this->set_prop( 'email', $value ); |
|
2498 | + public function set_email($value) { |
|
2499 | + $this->set_prop('email', $value); |
|
2500 | 2500 | } |
2501 | 2501 | |
2502 | 2502 | /** |
@@ -2505,8 +2505,8 @@ discard block |
||
2505 | 2505 | * @since 1.0.19 |
2506 | 2506 | * @param string $value email address. |
2507 | 2507 | */ |
2508 | - public function set_user_email( $value ) { |
|
2509 | - $this->set_email( $value ); |
|
2508 | + public function set_user_email($value) { |
|
2509 | + $this->set_email($value); |
|
2510 | 2510 | } |
2511 | 2511 | |
2512 | 2512 | /** |
@@ -2515,8 +2515,8 @@ discard block |
||
2515 | 2515 | * @since 1.0.19 |
2516 | 2516 | * @param string $value email address. |
2517 | 2517 | */ |
2518 | - public function set_email_address( $value ) { |
|
2519 | - $this->set_email( $value ); |
|
2518 | + public function set_email_address($value) { |
|
2519 | + $this->set_email($value); |
|
2520 | 2520 | } |
2521 | 2521 | |
2522 | 2522 | /** |
@@ -2525,8 +2525,8 @@ discard block |
||
2525 | 2525 | * @since 1.0.19 |
2526 | 2526 | * @param string $value email address. |
2527 | 2527 | */ |
2528 | - public function set_customer_email( $value ) { |
|
2529 | - $this->set_email( $value ); |
|
2528 | + public function set_customer_email($value) { |
|
2529 | + $this->set_email($value); |
|
2530 | 2530 | } |
2531 | 2531 | |
2532 | 2532 | /** |
@@ -2535,8 +2535,8 @@ discard block |
||
2535 | 2535 | * @since 1.0.19 |
2536 | 2536 | * @param string $value country. |
2537 | 2537 | */ |
2538 | - public function set_country( $value ) { |
|
2539 | - $this->set_prop( 'country', $value ); |
|
2538 | + public function set_country($value) { |
|
2539 | + $this->set_prop('country', $value); |
|
2540 | 2540 | } |
2541 | 2541 | |
2542 | 2542 | /** |
@@ -2545,8 +2545,8 @@ discard block |
||
2545 | 2545 | * @since 1.0.19 |
2546 | 2546 | * @param string $value country. |
2547 | 2547 | */ |
2548 | - public function set_user_country( $value ) { |
|
2549 | - $this->set_country( $value ); |
|
2548 | + public function set_user_country($value) { |
|
2549 | + $this->set_country($value); |
|
2550 | 2550 | } |
2551 | 2551 | |
2552 | 2552 | /** |
@@ -2555,8 +2555,8 @@ discard block |
||
2555 | 2555 | * @since 1.0.19 |
2556 | 2556 | * @param string $value country. |
2557 | 2557 | */ |
2558 | - public function set_customer_country( $value ) { |
|
2559 | - $this->set_country( $value ); |
|
2558 | + public function set_customer_country($value) { |
|
2559 | + $this->set_country($value); |
|
2560 | 2560 | } |
2561 | 2561 | |
2562 | 2562 | /** |
@@ -2565,8 +2565,8 @@ discard block |
||
2565 | 2565 | * @since 1.0.19 |
2566 | 2566 | * @param string $value state. |
2567 | 2567 | */ |
2568 | - public function set_state( $value ) { |
|
2569 | - $this->set_prop( 'state', $value ); |
|
2568 | + public function set_state($value) { |
|
2569 | + $this->set_prop('state', $value); |
|
2570 | 2570 | } |
2571 | 2571 | |
2572 | 2572 | /** |
@@ -2575,8 +2575,8 @@ discard block |
||
2575 | 2575 | * @since 1.0.19 |
2576 | 2576 | * @param string $value state. |
2577 | 2577 | */ |
2578 | - public function set_user_state( $value ) { |
|
2579 | - $this->set_state( $value ); |
|
2578 | + public function set_user_state($value) { |
|
2579 | + $this->set_state($value); |
|
2580 | 2580 | } |
2581 | 2581 | |
2582 | 2582 | /** |
@@ -2585,8 +2585,8 @@ discard block |
||
2585 | 2585 | * @since 1.0.19 |
2586 | 2586 | * @param string $value state. |
2587 | 2587 | */ |
2588 | - public function set_customer_state( $value ) { |
|
2589 | - $this->set_state( $value ); |
|
2588 | + public function set_customer_state($value) { |
|
2589 | + $this->set_state($value); |
|
2590 | 2590 | } |
2591 | 2591 | |
2592 | 2592 | /** |
@@ -2595,8 +2595,8 @@ discard block |
||
2595 | 2595 | * @since 1.0.19 |
2596 | 2596 | * @param string $value city. |
2597 | 2597 | */ |
2598 | - public function set_city( $value ) { |
|
2599 | - $this->set_prop( 'city', $value ); |
|
2598 | + public function set_city($value) { |
|
2599 | + $this->set_prop('city', $value); |
|
2600 | 2600 | } |
2601 | 2601 | |
2602 | 2602 | /** |
@@ -2605,8 +2605,8 @@ discard block |
||
2605 | 2605 | * @since 1.0.19 |
2606 | 2606 | * @param string $value city. |
2607 | 2607 | */ |
2608 | - public function set_user_city( $value ) { |
|
2609 | - $this->set_city( $value ); |
|
2608 | + public function set_user_city($value) { |
|
2609 | + $this->set_city($value); |
|
2610 | 2610 | } |
2611 | 2611 | |
2612 | 2612 | /** |
@@ -2615,8 +2615,8 @@ discard block |
||
2615 | 2615 | * @since 1.0.19 |
2616 | 2616 | * @param string $value city. |
2617 | 2617 | */ |
2618 | - public function set_customer_city( $value ) { |
|
2619 | - $this->set_city( $value ); |
|
2618 | + public function set_customer_city($value) { |
|
2619 | + $this->set_city($value); |
|
2620 | 2620 | } |
2621 | 2621 | |
2622 | 2622 | /** |
@@ -2625,8 +2625,8 @@ discard block |
||
2625 | 2625 | * @since 1.0.19 |
2626 | 2626 | * @param string $value zip. |
2627 | 2627 | */ |
2628 | - public function set_zip( $value ) { |
|
2629 | - $this->set_prop( 'zip', $value ); |
|
2628 | + public function set_zip($value) { |
|
2629 | + $this->set_prop('zip', $value); |
|
2630 | 2630 | } |
2631 | 2631 | |
2632 | 2632 | /** |
@@ -2635,8 +2635,8 @@ discard block |
||
2635 | 2635 | * @since 1.0.19 |
2636 | 2636 | * @param string $value zip. |
2637 | 2637 | */ |
2638 | - public function set_user_zip( $value ) { |
|
2639 | - $this->set_zip( $value ); |
|
2638 | + public function set_user_zip($value) { |
|
2639 | + $this->set_zip($value); |
|
2640 | 2640 | } |
2641 | 2641 | |
2642 | 2642 | /** |
@@ -2645,8 +2645,8 @@ discard block |
||
2645 | 2645 | * @since 1.0.19 |
2646 | 2646 | * @param string $value zip. |
2647 | 2647 | */ |
2648 | - public function set_customer_zip( $value ) { |
|
2649 | - $this->set_zip( $value ); |
|
2648 | + public function set_customer_zip($value) { |
|
2649 | + $this->set_zip($value); |
|
2650 | 2650 | } |
2651 | 2651 | |
2652 | 2652 | /** |
@@ -2655,8 +2655,8 @@ discard block |
||
2655 | 2655 | * @since 1.0.19 |
2656 | 2656 | * @param string $value company. |
2657 | 2657 | */ |
2658 | - public function set_company( $value ) { |
|
2659 | - $this->set_prop( 'company', $value ); |
|
2658 | + public function set_company($value) { |
|
2659 | + $this->set_prop('company', $value); |
|
2660 | 2660 | } |
2661 | 2661 | |
2662 | 2662 | /** |
@@ -2665,8 +2665,8 @@ discard block |
||
2665 | 2665 | * @since 1.0.19 |
2666 | 2666 | * @param string $value company. |
2667 | 2667 | */ |
2668 | - public function set_user_company( $value ) { |
|
2669 | - $this->set_company( $value ); |
|
2668 | + public function set_user_company($value) { |
|
2669 | + $this->set_company($value); |
|
2670 | 2670 | } |
2671 | 2671 | |
2672 | 2672 | /** |
@@ -2675,8 +2675,8 @@ discard block |
||
2675 | 2675 | * @since 1.0.19 |
2676 | 2676 | * @param string $value company. |
2677 | 2677 | */ |
2678 | - public function set_customer_company( $value ) { |
|
2679 | - $this->set_company( $value ); |
|
2678 | + public function set_customer_company($value) { |
|
2679 | + $this->set_company($value); |
|
2680 | 2680 | } |
2681 | 2681 | |
2682 | 2682 | /** |
@@ -2685,8 +2685,8 @@ discard block |
||
2685 | 2685 | * @since 1.0.19 |
2686 | 2686 | * @param string $value company id. |
2687 | 2687 | */ |
2688 | - public function set_company_id( $value ) { |
|
2689 | - $this->set_prop( 'company_id', $value ); |
|
2688 | + public function set_company_id($value) { |
|
2689 | + $this->set_prop('company_id', $value); |
|
2690 | 2690 | } |
2691 | 2691 | |
2692 | 2692 | /** |
@@ -2695,8 +2695,8 @@ discard block |
||
2695 | 2695 | * @since 1.0.19 |
2696 | 2696 | * @param string $value var number. |
2697 | 2697 | */ |
2698 | - public function set_vat_number( $value ) { |
|
2699 | - $this->set_prop( 'vat_number', $value ); |
|
2698 | + public function set_vat_number($value) { |
|
2699 | + $this->set_prop('vat_number', $value); |
|
2700 | 2700 | } |
2701 | 2701 | |
2702 | 2702 | /** |
@@ -2705,8 +2705,8 @@ discard block |
||
2705 | 2705 | * @since 1.0.19 |
2706 | 2706 | * @param string $value var number. |
2707 | 2707 | */ |
2708 | - public function set_user_vat_number( $value ) { |
|
2709 | - $this->set_vat_number( $value ); |
|
2708 | + public function set_user_vat_number($value) { |
|
2709 | + $this->set_vat_number($value); |
|
2710 | 2710 | } |
2711 | 2711 | |
2712 | 2712 | /** |
@@ -2715,8 +2715,8 @@ discard block |
||
2715 | 2715 | * @since 1.0.19 |
2716 | 2716 | * @param string $value var number. |
2717 | 2717 | */ |
2718 | - public function set_customer_vat_number( $value ) { |
|
2719 | - $this->set_vat_number( $value ); |
|
2718 | + public function set_customer_vat_number($value) { |
|
2719 | + $this->set_vat_number($value); |
|
2720 | 2720 | } |
2721 | 2721 | |
2722 | 2722 | /** |
@@ -2725,8 +2725,8 @@ discard block |
||
2725 | 2725 | * @since 1.0.19 |
2726 | 2726 | * @param string $value var rate. |
2727 | 2727 | */ |
2728 | - public function set_vat_rate( $value ) { |
|
2729 | - $this->set_prop( 'vat_rate', $value ); |
|
2728 | + public function set_vat_rate($value) { |
|
2729 | + $this->set_prop('vat_rate', $value); |
|
2730 | 2730 | } |
2731 | 2731 | |
2732 | 2732 | /** |
@@ -2735,8 +2735,8 @@ discard block |
||
2735 | 2735 | * @since 1.0.19 |
2736 | 2736 | * @param string $value var number. |
2737 | 2737 | */ |
2738 | - public function set_user_vat_rate( $value ) { |
|
2739 | - $this->set_vat_rate( $value ); |
|
2738 | + public function set_user_vat_rate($value) { |
|
2739 | + $this->set_vat_rate($value); |
|
2740 | 2740 | } |
2741 | 2741 | |
2742 | 2742 | /** |
@@ -2745,8 +2745,8 @@ discard block |
||
2745 | 2745 | * @since 1.0.19 |
2746 | 2746 | * @param string $value var number. |
2747 | 2747 | */ |
2748 | - public function set_customer_vat_rate( $value ) { |
|
2749 | - $this->set_vat_rate( $value ); |
|
2748 | + public function set_customer_vat_rate($value) { |
|
2749 | + $this->set_vat_rate($value); |
|
2750 | 2750 | } |
2751 | 2751 | |
2752 | 2752 | /** |
@@ -2755,8 +2755,8 @@ discard block |
||
2755 | 2755 | * @since 1.0.19 |
2756 | 2756 | * @param string $value address. |
2757 | 2757 | */ |
2758 | - public function set_address( $value ) { |
|
2759 | - $this->set_prop( 'address', $value ); |
|
2758 | + public function set_address($value) { |
|
2759 | + $this->set_prop('address', $value); |
|
2760 | 2760 | } |
2761 | 2761 | |
2762 | 2762 | /** |
@@ -2765,8 +2765,8 @@ discard block |
||
2765 | 2765 | * @since 1.0.19 |
2766 | 2766 | * @param string $value address. |
2767 | 2767 | */ |
2768 | - public function set_user_address( $value ) { |
|
2769 | - $this->set_address( $value ); |
|
2768 | + public function set_user_address($value) { |
|
2769 | + $this->set_address($value); |
|
2770 | 2770 | } |
2771 | 2771 | |
2772 | 2772 | /** |
@@ -2775,8 +2775,8 @@ discard block |
||
2775 | 2775 | * @since 1.0.19 |
2776 | 2776 | * @param string $value address. |
2777 | 2777 | */ |
2778 | - public function set_customer_address( $value ) { |
|
2779 | - $this->set_address( $value ); |
|
2778 | + public function set_customer_address($value) { |
|
2779 | + $this->set_address($value); |
|
2780 | 2780 | } |
2781 | 2781 | |
2782 | 2782 | /** |
@@ -2785,8 +2785,8 @@ discard block |
||
2785 | 2785 | * @since 1.0.19 |
2786 | 2786 | * @param int|bool $value confirmed. |
2787 | 2787 | */ |
2788 | - public function set_is_viewed( $value ) { |
|
2789 | - $this->set_prop( 'is_viewed', $value ); |
|
2788 | + public function set_is_viewed($value) { |
|
2789 | + $this->set_prop('is_viewed', $value); |
|
2790 | 2790 | } |
2791 | 2791 | |
2792 | 2792 | /** |
@@ -2795,8 +2795,8 @@ discard block |
||
2795 | 2795 | * @since 1.0.19 |
2796 | 2796 | * @param string $value email recipients. |
2797 | 2797 | */ |
2798 | - public function set_email_cc( $value ) { |
|
2799 | - $this->set_prop( 'email_cc', $value ); |
|
2798 | + public function set_email_cc($value) { |
|
2799 | + $this->set_prop('email_cc', $value); |
|
2800 | 2800 | } |
2801 | 2801 | |
2802 | 2802 | /** |
@@ -2805,9 +2805,9 @@ discard block |
||
2805 | 2805 | * @since 1.0.19 |
2806 | 2806 | * @param string $value template. |
2807 | 2807 | */ |
2808 | - public function set_template( $value ) { |
|
2809 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2810 | - $this->set_prop( 'template', $value ); |
|
2808 | + public function set_template($value) { |
|
2809 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2810 | + $this->set_prop('template', $value); |
|
2811 | 2811 | } |
2812 | 2812 | } |
2813 | 2813 | |
@@ -2818,8 +2818,8 @@ discard block |
||
2818 | 2818 | * @param string $value source. |
2819 | 2819 | * @deprecated |
2820 | 2820 | */ |
2821 | - public function created_via( $value ) { |
|
2822 | - $this->set_created_via( sanitize_text_field( $value ) ); |
|
2821 | + public function created_via($value) { |
|
2822 | + $this->set_created_via(sanitize_text_field($value)); |
|
2823 | 2823 | } |
2824 | 2824 | |
2825 | 2825 | /** |
@@ -2828,8 +2828,8 @@ discard block |
||
2828 | 2828 | * @since 1.0.19 |
2829 | 2829 | * @param string $value source. |
2830 | 2830 | */ |
2831 | - public function set_created_via( $value ) { |
|
2832 | - $this->set_prop( 'created_via', sanitize_text_field( $value ) ); |
|
2831 | + public function set_created_via($value) { |
|
2832 | + $this->set_prop('created_via', sanitize_text_field($value)); |
|
2833 | 2833 | } |
2834 | 2834 | |
2835 | 2835 | /** |
@@ -2838,8 +2838,8 @@ discard block |
||
2838 | 2838 | * @since 1.0.19 |
2839 | 2839 | * @param int|bool $value confirmed. |
2840 | 2840 | */ |
2841 | - public function set_address_confirmed( $value ) { |
|
2842 | - $this->set_prop( 'address_confirmed', $value ); |
|
2841 | + public function set_address_confirmed($value) { |
|
2842 | + $this->set_prop('address_confirmed', $value); |
|
2843 | 2843 | } |
2844 | 2844 | |
2845 | 2845 | /** |
@@ -2848,8 +2848,8 @@ discard block |
||
2848 | 2848 | * @since 1.0.19 |
2849 | 2849 | * @param int|bool $value confirmed. |
2850 | 2850 | */ |
2851 | - public function set_user_address_confirmed( $value ) { |
|
2852 | - $this->set_address_confirmed( $value ); |
|
2851 | + public function set_user_address_confirmed($value) { |
|
2852 | + $this->set_address_confirmed($value); |
|
2853 | 2853 | } |
2854 | 2854 | |
2855 | 2855 | /** |
@@ -2858,8 +2858,8 @@ discard block |
||
2858 | 2858 | * @since 1.0.19 |
2859 | 2859 | * @param int|bool $value confirmed. |
2860 | 2860 | */ |
2861 | - public function set_customer_address_confirmed( $value ) { |
|
2862 | - $this->set_address_confirmed( $value ); |
|
2861 | + public function set_customer_address_confirmed($value) { |
|
2862 | + $this->set_address_confirmed($value); |
|
2863 | 2863 | } |
2864 | 2864 | |
2865 | 2865 | /** |
@@ -2868,13 +2868,13 @@ discard block |
||
2868 | 2868 | * @since 1.0.19 |
2869 | 2869 | * @param float $value shipping amount. |
2870 | 2870 | */ |
2871 | - public function set_shipping( $value ) { |
|
2871 | + public function set_shipping($value) { |
|
2872 | 2872 | |
2873 | - if ( ! is_numeric( $value ) ) { |
|
2874 | - return $this->set_prop( 'shipping', null ); |
|
2873 | + if (!is_numeric($value)) { |
|
2874 | + return $this->set_prop('shipping', null); |
|
2875 | 2875 | } |
2876 | 2876 | |
2877 | - $this->set_prop( 'shipping', max( 0, floatval( $value ) ) ); |
|
2877 | + $this->set_prop('shipping', max(0, floatval($value))); |
|
2878 | 2878 | } |
2879 | 2879 | |
2880 | 2880 | /** |
@@ -2883,8 +2883,8 @@ discard block |
||
2883 | 2883 | * @since 1.0.19 |
2884 | 2884 | * @param float $value sub total. |
2885 | 2885 | */ |
2886 | - public function set_subtotal( $value ) { |
|
2887 | - $this->set_prop( 'subtotal', max( 0, $value ) ); |
|
2886 | + public function set_subtotal($value) { |
|
2887 | + $this->set_prop('subtotal', max(0, $value)); |
|
2888 | 2888 | } |
2889 | 2889 | |
2890 | 2890 | /** |
@@ -2893,8 +2893,8 @@ discard block |
||
2893 | 2893 | * @since 1.0.19 |
2894 | 2894 | * @param float $value sub total. |
2895 | 2895 | */ |
2896 | - public function set_total( $value ) { |
|
2897 | - $this->set_prop( 'total', max( 0, $value ) ); |
|
2896 | + public function set_total($value) { |
|
2897 | + $this->set_prop('total', max(0, $value)); |
|
2898 | 2898 | } |
2899 | 2899 | |
2900 | 2900 | /** |
@@ -2903,8 +2903,8 @@ discard block |
||
2903 | 2903 | * @since 1.0.19 |
2904 | 2904 | * @param float $value discount total. |
2905 | 2905 | */ |
2906 | - public function set_total_discount( $value ) { |
|
2907 | - $this->set_prop( 'total_discount', max( 0, $value ) ); |
|
2906 | + public function set_total_discount($value) { |
|
2907 | + $this->set_prop('total_discount', max(0, $value)); |
|
2908 | 2908 | } |
2909 | 2909 | |
2910 | 2910 | /** |
@@ -2913,8 +2913,8 @@ discard block |
||
2913 | 2913 | * @since 1.0.19 |
2914 | 2914 | * @param float $value discount total. |
2915 | 2915 | */ |
2916 | - public function set_discount( $value ) { |
|
2917 | - $this->set_total_discount( $value ); |
|
2916 | + public function set_discount($value) { |
|
2917 | + $this->set_total_discount($value); |
|
2918 | 2918 | } |
2919 | 2919 | |
2920 | 2920 | /** |
@@ -2923,8 +2923,8 @@ discard block |
||
2923 | 2923 | * @since 1.0.19 |
2924 | 2924 | * @param float $value tax total. |
2925 | 2925 | */ |
2926 | - public function set_total_tax( $value ) { |
|
2927 | - $this->set_prop( 'total_tax', max( 0, $value ) ); |
|
2926 | + public function set_total_tax($value) { |
|
2927 | + $this->set_prop('total_tax', max(0, $value)); |
|
2928 | 2928 | } |
2929 | 2929 | |
2930 | 2930 | /** |
@@ -2933,8 +2933,8 @@ discard block |
||
2933 | 2933 | * @since 1.0.19 |
2934 | 2934 | * @param float $value tax total. |
2935 | 2935 | */ |
2936 | - public function set_tax_total( $value ) { |
|
2937 | - $this->set_total_tax( $value ); |
|
2936 | + public function set_tax_total($value) { |
|
2937 | + $this->set_total_tax($value); |
|
2938 | 2938 | } |
2939 | 2939 | |
2940 | 2940 | /** |
@@ -2943,8 +2943,8 @@ discard block |
||
2943 | 2943 | * @since 1.0.19 |
2944 | 2944 | * @param float $value fees total. |
2945 | 2945 | */ |
2946 | - public function set_total_fees( $value ) { |
|
2947 | - $this->set_prop( 'total_fees', max( 0, $value ) ); |
|
2946 | + public function set_total_fees($value) { |
|
2947 | + $this->set_prop('total_fees', max(0, $value)); |
|
2948 | 2948 | } |
2949 | 2949 | |
2950 | 2950 | /** |
@@ -2953,8 +2953,8 @@ discard block |
||
2953 | 2953 | * @since 1.0.19 |
2954 | 2954 | * @param float $value fees total. |
2955 | 2955 | */ |
2956 | - public function set_fees_total( $value ) { |
|
2957 | - $this->set_total_fees( $value ); |
|
2956 | + public function set_fees_total($value) { |
|
2957 | + $this->set_total_fees($value); |
|
2958 | 2958 | } |
2959 | 2959 | |
2960 | 2960 | /** |
@@ -2963,13 +2963,13 @@ discard block |
||
2963 | 2963 | * @since 1.0.19 |
2964 | 2964 | * @param array $value fees. |
2965 | 2965 | */ |
2966 | - public function set_fees( $value ) { |
|
2966 | + public function set_fees($value) { |
|
2967 | 2967 | |
2968 | - if ( ! is_array( $value ) ) { |
|
2968 | + if (!is_array($value)) { |
|
2969 | 2969 | $value = array(); |
2970 | 2970 | } |
2971 | 2971 | |
2972 | - $this->set_prop( 'fees', $value ); |
|
2972 | + $this->set_prop('fees', $value); |
|
2973 | 2973 | |
2974 | 2974 | } |
2975 | 2975 | |
@@ -2979,13 +2979,13 @@ discard block |
||
2979 | 2979 | * @since 1.0.19 |
2980 | 2980 | * @param array $value taxes. |
2981 | 2981 | */ |
2982 | - public function set_taxes( $value ) { |
|
2982 | + public function set_taxes($value) { |
|
2983 | 2983 | |
2984 | - if ( ! is_array( $value ) ) { |
|
2984 | + if (!is_array($value)) { |
|
2985 | 2985 | $value = array(); |
2986 | 2986 | } |
2987 | 2987 | |
2988 | - $this->set_prop( 'taxes', $value ); |
|
2988 | + $this->set_prop('taxes', $value); |
|
2989 | 2989 | |
2990 | 2990 | } |
2991 | 2991 | |
@@ -2995,13 +2995,13 @@ discard block |
||
2995 | 2995 | * @since 1.0.19 |
2996 | 2996 | * @param array $value discounts. |
2997 | 2997 | */ |
2998 | - public function set_discounts( $value ) { |
|
2998 | + public function set_discounts($value) { |
|
2999 | 2999 | |
3000 | - if ( ! is_array( $value ) ) { |
|
3000 | + if (!is_array($value)) { |
|
3001 | 3001 | $value = array(); |
3002 | 3002 | } |
3003 | 3003 | |
3004 | - $this->set_prop( 'discounts', $value ); |
|
3004 | + $this->set_prop('discounts', $value); |
|
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | /** |
@@ -3010,19 +3010,19 @@ discard block |
||
3010 | 3010 | * @since 1.0.19 |
3011 | 3011 | * @param GetPaid_Form_Item[] $value items. |
3012 | 3012 | */ |
3013 | - public function set_items( $value ) { |
|
3013 | + public function set_items($value) { |
|
3014 | 3014 | |
3015 | 3015 | // Remove existing items. |
3016 | - $this->set_prop( 'items', array() ); |
|
3016 | + $this->set_prop('items', array()); |
|
3017 | 3017 | $this->recurring_item = null; |
3018 | 3018 | |
3019 | 3019 | // Ensure that we have an array. |
3020 | - if ( ! is_array( $value ) ) { |
|
3020 | + if (!is_array($value)) { |
|
3021 | 3021 | return; |
3022 | 3022 | } |
3023 | 3023 | |
3024 | - foreach ( $value as $item ) { |
|
3025 | - $this->add_item( $item ); |
|
3024 | + foreach ($value as $item) { |
|
3025 | + $this->add_item($item); |
|
3026 | 3026 | } |
3027 | 3027 | |
3028 | 3028 | } |
@@ -3033,8 +3033,8 @@ discard block |
||
3033 | 3033 | * @since 1.0.19 |
3034 | 3034 | * @param int $value payment form. |
3035 | 3035 | */ |
3036 | - public function set_payment_form( $value ) { |
|
3037 | - $this->set_prop( 'payment_form', $value ); |
|
3036 | + public function set_payment_form($value) { |
|
3037 | + $this->set_prop('payment_form', $value); |
|
3038 | 3038 | } |
3039 | 3039 | |
3040 | 3040 | /** |
@@ -3043,8 +3043,8 @@ discard block |
||
3043 | 3043 | * @since 1.0.19 |
3044 | 3044 | * @param string $value submission id. |
3045 | 3045 | */ |
3046 | - public function set_submission_id( $value ) { |
|
3047 | - $this->set_prop( 'submission_id', $value ); |
|
3046 | + public function set_submission_id($value) { |
|
3047 | + $this->set_prop('submission_id', $value); |
|
3048 | 3048 | } |
3049 | 3049 | |
3050 | 3050 | /** |
@@ -3053,8 +3053,8 @@ discard block |
||
3053 | 3053 | * @since 1.0.19 |
3054 | 3054 | * @param string $value discount code. |
3055 | 3055 | */ |
3056 | - public function set_discount_code( $value ) { |
|
3057 | - $this->set_prop( 'discount_code', sanitize_text_field( $value ) ); |
|
3056 | + public function set_discount_code($value) { |
|
3057 | + $this->set_prop('discount_code', sanitize_text_field($value)); |
|
3058 | 3058 | } |
3059 | 3059 | |
3060 | 3060 | /** |
@@ -3063,8 +3063,8 @@ discard block |
||
3063 | 3063 | * @since 1.0.19 |
3064 | 3064 | * @param string $value gateway. |
3065 | 3065 | */ |
3066 | - public function set_gateway( $value ) { |
|
3067 | - $this->set_prop( 'gateway', $value ); |
|
3066 | + public function set_gateway($value) { |
|
3067 | + $this->set_prop('gateway', $value); |
|
3068 | 3068 | } |
3069 | 3069 | |
3070 | 3070 | /** |
@@ -3073,9 +3073,9 @@ discard block |
||
3073 | 3073 | * @since 1.0.19 |
3074 | 3074 | * @param string $value transaction id. |
3075 | 3075 | */ |
3076 | - public function set_transaction_id( $value ) { |
|
3077 | - if ( ! empty( $value ) ) { |
|
3078 | - $this->set_prop( 'transaction_id', $value ); |
|
3076 | + public function set_transaction_id($value) { |
|
3077 | + if (!empty($value)) { |
|
3078 | + $this->set_prop('transaction_id', $value); |
|
3079 | 3079 | } |
3080 | 3080 | } |
3081 | 3081 | |
@@ -3085,8 +3085,8 @@ discard block |
||
3085 | 3085 | * @since 1.0.19 |
3086 | 3086 | * @param string $value currency id. |
3087 | 3087 | */ |
3088 | - public function set_currency( $value ) { |
|
3089 | - $this->set_prop( 'currency', $value ); |
|
3088 | + public function set_currency($value) { |
|
3089 | + $this->set_prop('currency', $value); |
|
3090 | 3090 | } |
3091 | 3091 | |
3092 | 3092 | /** |
@@ -3095,8 +3095,8 @@ discard block |
||
3095 | 3095 | * @since 1.0.19 |
3096 | 3096 | * @param bool $value value. |
3097 | 3097 | */ |
3098 | - public function set_disable_taxes( $value ) { |
|
3099 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
3098 | + public function set_disable_taxes($value) { |
|
3099 | + $this->set_prop('disable_taxes', (bool) $value); |
|
3100 | 3100 | } |
3101 | 3101 | |
3102 | 3102 | /** |
@@ -3105,8 +3105,8 @@ discard block |
||
3105 | 3105 | * @since 1.0.19 |
3106 | 3106 | * @param string $value subscription id. |
3107 | 3107 | */ |
3108 | - public function set_subscription_id( $value ) { |
|
3109 | - $this->set_prop( 'subscription_id', $value ); |
|
3108 | + public function set_subscription_id($value) { |
|
3109 | + $this->set_prop('subscription_id', $value); |
|
3110 | 3110 | } |
3111 | 3111 | |
3112 | 3112 | /** |
@@ -3115,8 +3115,8 @@ discard block |
||
3115 | 3115 | * @since 1.0.19 |
3116 | 3116 | * @param string $value subscription id. |
3117 | 3117 | */ |
3118 | - public function set_remote_subscription_id( $value ) { |
|
3119 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
3118 | + public function set_remote_subscription_id($value) { |
|
3119 | + $this->set_prop('remote_subscription_id', $value); |
|
3120 | 3120 | } |
3121 | 3121 | |
3122 | 3122 | /* |
@@ -3133,28 +3133,28 @@ discard block |
||
3133 | 3133 | */ |
3134 | 3134 | public function is_parent() { |
3135 | 3135 | $parent = $this->get_parent_id(); |
3136 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
3136 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
3137 | 3137 | } |
3138 | 3138 | |
3139 | 3139 | /** |
3140 | 3140 | * Checks if this is a renewal invoice. |
3141 | 3141 | */ |
3142 | 3142 | public function is_renewal() { |
3143 | - return $this->is_recurring() && ! $this->is_parent(); |
|
3143 | + return $this->is_recurring() && !$this->is_parent(); |
|
3144 | 3144 | } |
3145 | 3145 | |
3146 | 3146 | /** |
3147 | 3147 | * Checks if this is a recurring invoice. |
3148 | 3148 | */ |
3149 | 3149 | public function is_recurring() { |
3150 | - return ! empty( $this->recurring_item ); |
|
3150 | + return !empty($this->recurring_item); |
|
3151 | 3151 | } |
3152 | 3152 | |
3153 | 3153 | /** |
3154 | 3154 | * Checks if this is a taxable invoice. |
3155 | 3155 | */ |
3156 | 3156 | public function is_taxable() { |
3157 | - return ! $this->get_disable_taxes(); |
|
3157 | + return !$this->get_disable_taxes(); |
|
3158 | 3158 | } |
3159 | 3159 | |
3160 | 3160 | /** |
@@ -3168,45 +3168,45 @@ discard block |
||
3168 | 3168 | * Checks to see if the invoice requires payment. |
3169 | 3169 | */ |
3170 | 3170 | public function is_free() { |
3171 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
3171 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
3172 | 3172 | |
3173 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
3173 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
3174 | 3174 | $is_free = false; |
3175 | 3175 | } |
3176 | 3176 | |
3177 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
3177 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
3178 | 3178 | } |
3179 | 3179 | |
3180 | 3180 | /** |
3181 | 3181 | * Checks if the invoice is paid. |
3182 | 3182 | */ |
3183 | 3183 | public function is_paid() { |
3184 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
3185 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
3184 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
3185 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
3186 | 3186 | } |
3187 | 3187 | |
3188 | 3188 | /** |
3189 | 3189 | * Checks if the invoice needs payment. |
3190 | 3190 | */ |
3191 | 3191 | public function needs_payment() { |
3192 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
3193 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
3192 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
3193 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
3194 | 3194 | } |
3195 | 3195 | |
3196 | 3196 | /** |
3197 | 3197 | * Checks if the invoice is refunded. |
3198 | 3198 | */ |
3199 | 3199 | public function is_refunded() { |
3200 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
3201 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
3200 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
3201 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
3202 | 3202 | } |
3203 | 3203 | |
3204 | 3204 | /** |
3205 | 3205 | * Checks if the invoice is held. |
3206 | 3206 | */ |
3207 | 3207 | public function is_held() { |
3208 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
3209 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
3208 | + $is_held = $this->has_status('wpi-onhold'); |
|
3209 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
3210 | 3210 | } |
3211 | 3211 | |
3212 | 3212 | /** |
@@ -3214,30 +3214,30 @@ discard block |
||
3214 | 3214 | */ |
3215 | 3215 | public function is_due() { |
3216 | 3216 | $due_date = $this->get_due_date(); |
3217 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
3217 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
3218 | 3218 | } |
3219 | 3219 | |
3220 | 3220 | /** |
3221 | 3221 | * Checks if the invoice is draft. |
3222 | 3222 | */ |
3223 | 3223 | public function is_draft() { |
3224 | - return $this->has_status( 'draft, auto-draft' ); |
|
3224 | + return $this->has_status('draft, auto-draft'); |
|
3225 | 3225 | } |
3226 | 3226 | |
3227 | 3227 | /** |
3228 | 3228 | * Checks if the invoice has a given status. |
3229 | 3229 | */ |
3230 | - public function has_status( $status ) { |
|
3231 | - $status = wpinv_parse_list( $status ); |
|
3232 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3230 | + public function has_status($status) { |
|
3231 | + $status = wpinv_parse_list($status); |
|
3232 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3233 | 3233 | } |
3234 | 3234 | |
3235 | 3235 | /** |
3236 | 3236 | * Checks if the invoice is of a given type. |
3237 | 3237 | */ |
3238 | - public function is_type( $type ) { |
|
3239 | - $type = wpinv_parse_list( $type ); |
|
3240 | - return in_array( $this->get_type(), $type ); |
|
3238 | + public function is_type($type) { |
|
3239 | + $type = wpinv_parse_list($type); |
|
3240 | + return in_array($this->get_type(), $type); |
|
3241 | 3241 | } |
3242 | 3242 | |
3243 | 3243 | /** |
@@ -3269,8 +3269,8 @@ discard block |
||
3269 | 3269 | * |
3270 | 3270 | */ |
3271 | 3271 | public function is_initial_free() { |
3272 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3273 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3272 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3273 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3274 | 3274 | } |
3275 | 3275 | |
3276 | 3276 | /** |
@@ -3280,11 +3280,11 @@ discard block |
||
3280 | 3280 | public function item_has_free_trial() { |
3281 | 3281 | |
3282 | 3282 | // Ensure we have a recurring item. |
3283 | - if ( ! $this->is_recurring() ) { |
|
3283 | + if (!$this->is_recurring()) { |
|
3284 | 3284 | return false; |
3285 | 3285 | } |
3286 | 3286 | |
3287 | - $item = $this->get_recurring( true ); |
|
3287 | + $item = $this->get_recurring(true); |
|
3288 | 3288 | return $item->has_free_trial(); |
3289 | 3289 | } |
3290 | 3290 | |
@@ -3292,7 +3292,7 @@ discard block |
||
3292 | 3292 | * Check if the free trial is a result of a discount. |
3293 | 3293 | */ |
3294 | 3294 | public function is_free_trial_from_discount() { |
3295 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3295 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3296 | 3296 | } |
3297 | 3297 | |
3298 | 3298 | /** |
@@ -3300,12 +3300,12 @@ discard block |
||
3300 | 3300 | */ |
3301 | 3301 | public function discount_first_payment_only() { |
3302 | 3302 | |
3303 | - $discount = wpinv_get_discount_obj( $this->get_discount_code() ); |
|
3304 | - if ( ! $discount->exists() || ! $this->is_recurring() ) { |
|
3303 | + $discount = wpinv_get_discount_obj($this->get_discount_code()); |
|
3304 | + if (!$discount->exists() || !$this->is_recurring()) { |
|
3305 | 3305 | return true; |
3306 | 3306 | } |
3307 | 3307 | |
3308 | - return ! $discount->get_is_recurring(); |
|
3308 | + return !$discount->get_is_recurring(); |
|
3309 | 3309 | } |
3310 | 3310 | |
3311 | 3311 | /* |
@@ -3323,23 +3323,23 @@ discard block |
||
3323 | 3323 | * @param GetPaid_Form_Item|array $item |
3324 | 3324 | * @return WP_Error|Bool |
3325 | 3325 | */ |
3326 | - public function add_item( $item ) { |
|
3326 | + public function add_item($item) { |
|
3327 | 3327 | |
3328 | - if ( is_array( $item ) ) { |
|
3329 | - $item = $this->process_array_item( $item ); |
|
3328 | + if (is_array($item)) { |
|
3329 | + $item = $this->process_array_item($item); |
|
3330 | 3330 | } |
3331 | 3331 | |
3332 | - if ( is_numeric( $item ) ) { |
|
3333 | - $item = new GetPaid_Form_Item( $item ); |
|
3332 | + if (is_numeric($item)) { |
|
3333 | + $item = new GetPaid_Form_Item($item); |
|
3334 | 3334 | } |
3335 | 3335 | |
3336 | 3336 | // Make sure that it is available for purchase. |
3337 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3338 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3337 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3338 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3339 | 3339 | } |
3340 | 3340 | |
3341 | 3341 | // Do we have a recurring item? |
3342 | - if ( $item->is_recurring() ) { |
|
3342 | + if ($item->is_recurring()) { |
|
3343 | 3343 | $this->recurring_item = $item->get_id(); |
3344 | 3344 | } |
3345 | 3345 | |
@@ -3347,9 +3347,9 @@ discard block |
||
3347 | 3347 | $item->invoice_id = (int) $this->get_id(); |
3348 | 3348 | |
3349 | 3349 | // Remove duplicates. |
3350 | - $this->remove_item( $item->get_id() ); |
|
3350 | + $this->remove_item($item->get_id()); |
|
3351 | 3351 | |
3352 | - if ( 0 == $item->get_quantity() ) { |
|
3352 | + if (0 == $item->get_quantity()) { |
|
3353 | 3353 | return; |
3354 | 3354 | } |
3355 | 3355 | |
@@ -3359,7 +3359,7 @@ discard block |
||
3359 | 3359 | // Add new item. |
3360 | 3360 | $items[] = $item; |
3361 | 3361 | |
3362 | - $this->set_prop( 'items', $items ); |
|
3362 | + $this->set_prop('items', $items); |
|
3363 | 3363 | |
3364 | 3364 | return true; |
3365 | 3365 | } |
@@ -3370,26 +3370,26 @@ discard block |
||
3370 | 3370 | * @since 1.0.19 |
3371 | 3371 | * @return GetPaid_Form_Item |
3372 | 3372 | */ |
3373 | - protected function process_array_item( $array ) { |
|
3373 | + protected function process_array_item($array) { |
|
3374 | 3374 | |
3375 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3376 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3375 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3376 | + $item = new GetPaid_Form_Item($item_id); |
|
3377 | 3377 | |
3378 | 3378 | // Set item data. |
3379 | - foreach ( array( 'name', 'price', 'description' ) as $key ) { |
|
3380 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3379 | + foreach (array('name', 'price', 'description') as $key) { |
|
3380 | + if (isset($array["item_$key"])) { |
|
3381 | 3381 | $method = "set_$key"; |
3382 | - $item->$method( $array[ "item_$key" ] ); |
|
3382 | + $item->$method($array["item_$key"]); |
|
3383 | 3383 | } |
3384 | 3384 | } |
3385 | 3385 | |
3386 | - if ( isset( $array['quantity'] ) ) { |
|
3387 | - $item->set_quantity( $array['quantity'] ); |
|
3386 | + if (isset($array['quantity'])) { |
|
3387 | + $item->set_quantity($array['quantity']); |
|
3388 | 3388 | } |
3389 | 3389 | |
3390 | 3390 | // Set item meta. |
3391 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3392 | - $item->set_item_meta( $array['meta'] ); |
|
3391 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3392 | + $item->set_item_meta($array['meta']); |
|
3393 | 3393 | } |
3394 | 3394 | |
3395 | 3395 | return $item; |
@@ -3402,10 +3402,10 @@ discard block |
||
3402 | 3402 | * @since 1.0.19 |
3403 | 3403 | * @return GetPaid_Form_Item|null |
3404 | 3404 | */ |
3405 | - public function get_item( $item_id ) { |
|
3405 | + public function get_item($item_id) { |
|
3406 | 3406 | |
3407 | - foreach ( $this->get_items() as $item ) { |
|
3408 | - if ( (int) $item_id == $item->get_id() ) { |
|
3407 | + foreach ($this->get_items() as $item) { |
|
3408 | + if ((int) $item_id == $item->get_id()) { |
|
3409 | 3409 | return $item; |
3410 | 3410 | } |
3411 | 3411 | } |
@@ -3418,16 +3418,16 @@ discard block |
||
3418 | 3418 | * |
3419 | 3419 | * @since 1.0.19 |
3420 | 3420 | */ |
3421 | - public function remove_item( $item_id ) { |
|
3421 | + public function remove_item($item_id) { |
|
3422 | 3422 | $items = $this->get_items(); |
3423 | 3423 | $item_id = (int) $item_id; |
3424 | 3424 | |
3425 | - foreach ( $items as $index => $item ) { |
|
3426 | - if ( (int) $item_id == $item->get_id() ) { |
|
3427 | - unset( $items[ $index ] ); |
|
3428 | - $this->set_prop( 'items', $items ); |
|
3425 | + foreach ($items as $index => $item) { |
|
3426 | + if ((int) $item_id == $item->get_id()) { |
|
3427 | + unset($items[$index]); |
|
3428 | + $this->set_prop('items', $items); |
|
3429 | 3429 | |
3430 | - if ( $item_id == $this->recurring_item ) { |
|
3430 | + if ($item_id == $this->recurring_item) { |
|
3431 | 3431 | $this->recurring_item = null; |
3432 | 3432 | } |
3433 | 3433 | } |
@@ -3441,11 +3441,11 @@ discard block |
||
3441 | 3441 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3442 | 3442 | * @since 1.0.19 |
3443 | 3443 | */ |
3444 | - public function add_fee( $fee ) { |
|
3444 | + public function add_fee($fee) { |
|
3445 | 3445 | |
3446 | 3446 | $fees = $this->get_fees(); |
3447 | - $fees[ $fee['name'] ] = $fee; |
|
3448 | - $this->set_prop( 'fees', $fees ); |
|
3447 | + $fees[$fee['name']] = $fee; |
|
3448 | + $this->set_prop('fees', $fees); |
|
3449 | 3449 | |
3450 | 3450 | } |
3451 | 3451 | |
@@ -3454,9 +3454,9 @@ discard block |
||
3454 | 3454 | * |
3455 | 3455 | * @since 1.0.19 |
3456 | 3456 | */ |
3457 | - public function get_fee( $fee ) { |
|
3457 | + public function get_fee($fee) { |
|
3458 | 3458 | $fees = $this->get_fees(); |
3459 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3459 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3460 | 3460 | } |
3461 | 3461 | |
3462 | 3462 | /** |
@@ -3464,11 +3464,11 @@ discard block |
||
3464 | 3464 | * |
3465 | 3465 | * @since 1.0.19 |
3466 | 3466 | */ |
3467 | - public function remove_fee( $fee ) { |
|
3467 | + public function remove_fee($fee) { |
|
3468 | 3468 | $fees = $this->get_fees(); |
3469 | - if ( isset( $fees[ $fee ] ) ) { |
|
3470 | - unset( $fees[ $fee ] ); |
|
3471 | - $this->set_prop( 'fees', $fees ); |
|
3469 | + if (isset($fees[$fee])) { |
|
3470 | + unset($fees[$fee]); |
|
3471 | + $this->set_prop('fees', $fees); |
|
3472 | 3472 | } |
3473 | 3473 | } |
3474 | 3474 | |
@@ -3478,11 +3478,11 @@ discard block |
||
3478 | 3478 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3479 | 3479 | * @since 1.0.19 |
3480 | 3480 | */ |
3481 | - public function add_discount( $discount ) { |
|
3481 | + public function add_discount($discount) { |
|
3482 | 3482 | |
3483 | 3483 | $discounts = $this->get_discounts(); |
3484 | - $discounts[ $discount['name'] ] = $discount; |
|
3485 | - $this->set_prop( 'discounts', $discounts ); |
|
3484 | + $discounts[$discount['name']] = $discount; |
|
3485 | + $this->set_prop('discounts', $discounts); |
|
3486 | 3486 | |
3487 | 3487 | } |
3488 | 3488 | |
@@ -3492,15 +3492,15 @@ discard block |
||
3492 | 3492 | * @since 1.0.19 |
3493 | 3493 | * @return float |
3494 | 3494 | */ |
3495 | - public function get_discount( $discount = false ) { |
|
3495 | + public function get_discount($discount = false) { |
|
3496 | 3496 | |
3497 | 3497 | // Backwards compatibilty. |
3498 | - if ( empty( $discount ) ) { |
|
3498 | + if (empty($discount)) { |
|
3499 | 3499 | return $this->get_total_discount(); |
3500 | 3500 | } |
3501 | 3501 | |
3502 | 3502 | $discounts = $this->get_discounts(); |
3503 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3503 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3504 | 3504 | } |
3505 | 3505 | |
3506 | 3506 | /** |
@@ -3508,15 +3508,15 @@ discard block |
||
3508 | 3508 | * |
3509 | 3509 | * @since 1.0.19 |
3510 | 3510 | */ |
3511 | - public function remove_discount( $discount ) { |
|
3511 | + public function remove_discount($discount) { |
|
3512 | 3512 | $discounts = $this->get_discounts(); |
3513 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3514 | - unset( $discounts[ $discount ] ); |
|
3515 | - $this->set_prop( 'discounts', $discounts ); |
|
3513 | + if (isset($discounts[$discount])) { |
|
3514 | + unset($discounts[$discount]); |
|
3515 | + $this->set_prop('discounts', $discounts); |
|
3516 | 3516 | } |
3517 | 3517 | |
3518 | - if ( 'discount_code' == $discount ) { |
|
3519 | - foreach ( $this->get_items() as $item ) { |
|
3518 | + if ('discount_code' == $discount) { |
|
3519 | + foreach ($this->get_items() as $item) { |
|
3520 | 3520 | $item->item_discount = 0; |
3521 | 3521 | $item->recurring_item_discount = 0; |
3522 | 3522 | } |
@@ -3529,12 +3529,12 @@ discard block |
||
3529 | 3529 | * |
3530 | 3530 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
3531 | 3531 | */ |
3532 | - public function add_tax( $tax ) { |
|
3533 | - if ( $this->is_taxable() ) { |
|
3532 | + public function add_tax($tax) { |
|
3533 | + if ($this->is_taxable()) { |
|
3534 | 3534 | |
3535 | - $taxes = $this->get_taxes(); |
|
3536 | - $taxes[ $tax['name'] ] = $tax; |
|
3537 | - $this->set_prop( 'taxes', $tax ); |
|
3535 | + $taxes = $this->get_taxes(); |
|
3536 | + $taxes[$tax['name']] = $tax; |
|
3537 | + $this->set_prop('taxes', $tax); |
|
3538 | 3538 | |
3539 | 3539 | } |
3540 | 3540 | } |
@@ -3544,15 +3544,15 @@ discard block |
||
3544 | 3544 | * |
3545 | 3545 | * @since 1.0.19 |
3546 | 3546 | */ |
3547 | - public function get_tax( $tax = null ) { |
|
3547 | + public function get_tax($tax = null) { |
|
3548 | 3548 | |
3549 | 3549 | // Backwards compatility. |
3550 | - if ( empty( $tax ) ) { |
|
3550 | + if (empty($tax)) { |
|
3551 | 3551 | return $this->get_total_tax(); |
3552 | 3552 | } |
3553 | 3553 | |
3554 | 3554 | $taxes = $this->get_taxes(); |
3555 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3555 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3556 | 3556 | } |
3557 | 3557 | |
3558 | 3558 | /** |
@@ -3560,11 +3560,11 @@ discard block |
||
3560 | 3560 | * |
3561 | 3561 | * @since 1.0.19 |
3562 | 3562 | */ |
3563 | - public function remove_tax( $tax ) { |
|
3563 | + public function remove_tax($tax) { |
|
3564 | 3564 | $taxes = $this->get_taxes(); |
3565 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3566 | - unset( $taxes[ $tax ] ); |
|
3567 | - $this->set_prop( 'taxes', $taxes ); |
|
3565 | + if (isset($taxes[$tax])) { |
|
3566 | + unset($taxes[$tax]); |
|
3567 | + $this->set_prop('taxes', $taxes); |
|
3568 | 3568 | } |
3569 | 3569 | } |
3570 | 3570 | |
@@ -3575,22 +3575,22 @@ discard block |
||
3575 | 3575 | * @return float The recalculated subtotal |
3576 | 3576 | */ |
3577 | 3577 | public function recalculate_subtotal() { |
3578 | - $items = $this->get_items(); |
|
3578 | + $items = $this->get_items(); |
|
3579 | 3579 | $subtotal = 0; |
3580 | 3580 | $recurring = 0; |
3581 | 3581 | |
3582 | - foreach ( $items as $item ) { |
|
3583 | - $subtotal += $item->get_sub_total( 'edit' ); |
|
3584 | - $recurring += $item->get_recurring_sub_total( 'edit' ); |
|
3582 | + foreach ($items as $item) { |
|
3583 | + $subtotal += $item->get_sub_total('edit'); |
|
3584 | + $recurring += $item->get_recurring_sub_total('edit'); |
|
3585 | 3585 | } |
3586 | 3586 | |
3587 | - if ( wpinv_prices_include_tax() ) { |
|
3588 | - $subtotal = max( 0, $subtotal - $this->totals['tax']['initial'] ); |
|
3589 | - $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] ); |
|
3587 | + if (wpinv_prices_include_tax()) { |
|
3588 | + $subtotal = max(0, $subtotal - $this->totals['tax']['initial']); |
|
3589 | + $recurring = max(0, $recurring - $this->totals['tax']['recurring']); |
|
3590 | 3590 | } |
3591 | 3591 | |
3592 | 3592 | $current = $this->is_renewal() ? $recurring : $subtotal; |
3593 | - $this->set_subtotal( $current ); |
|
3593 | + $this->set_subtotal($current); |
|
3594 | 3594 | |
3595 | 3595 | $this->totals['subtotal'] = array( |
3596 | 3596 | 'initial' => $subtotal, |
@@ -3611,14 +3611,14 @@ discard block |
||
3611 | 3611 | $discount = 0; |
3612 | 3612 | $recurring = 0; |
3613 | 3613 | |
3614 | - foreach ( $discounts as $data ) { |
|
3615 | - $discount += wpinv_sanitize_amount( $data['initial_discount'] ); |
|
3616 | - $recurring += wpinv_sanitize_amount( $data['recurring_discount'] ); |
|
3614 | + foreach ($discounts as $data) { |
|
3615 | + $discount += wpinv_sanitize_amount($data['initial_discount']); |
|
3616 | + $recurring += wpinv_sanitize_amount($data['recurring_discount']); |
|
3617 | 3617 | } |
3618 | 3618 | |
3619 | 3619 | $current = $this->is_renewal() ? $recurring : $discount; |
3620 | 3620 | |
3621 | - $this->set_total_discount( $current ); |
|
3621 | + $this->set_total_discount($current); |
|
3622 | 3622 | |
3623 | 3623 | $this->totals['discount'] = array( |
3624 | 3624 | 'initial' => $discount, |
@@ -3639,13 +3639,13 @@ discard block |
||
3639 | 3639 | |
3640 | 3640 | // Maybe disable taxes. |
3641 | 3641 | $vat_number = $this->get_vat_number(); |
3642 | - $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number ); |
|
3642 | + $skip_tax = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number); |
|
3643 | 3643 | |
3644 | - if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
3644 | + if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
3645 | 3645 | $skip_tax = false; |
3646 | 3646 | } |
3647 | 3647 | |
3648 | - if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax ) { |
|
3648 | + if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) { |
|
3649 | 3649 | |
3650 | 3650 | $this->totals['tax'] = array( |
3651 | 3651 | 'initial' => 0, |
@@ -3654,37 +3654,37 @@ discard block |
||
3654 | 3654 | |
3655 | 3655 | $this->tax_rate = 0; |
3656 | 3656 | |
3657 | - $this->set_taxes( array() ); |
|
3657 | + $this->set_taxes(array()); |
|
3658 | 3658 | $current = 0; |
3659 | 3659 | } else { |
3660 | 3660 | |
3661 | 3661 | $item_taxes = array(); |
3662 | 3662 | |
3663 | - foreach ( $this->get_items() as $item ) { |
|
3664 | - $rates = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() ); |
|
3665 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
3666 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates ); |
|
3667 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates ); |
|
3668 | - foreach ( $taxes as $name => $amount ) { |
|
3669 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
3670 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
3671 | - |
|
3672 | - if ( ! isset( $item_taxes[ $name ] ) ) { |
|
3673 | - $item_taxes[ $name ] = $tax; |
|
3663 | + foreach ($this->get_items() as $item) { |
|
3664 | + $rates = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state()); |
|
3665 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
3666 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates); |
|
3667 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates); |
|
3668 | + foreach ($taxes as $name => $amount) { |
|
3669 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
3670 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
3671 | + |
|
3672 | + if (!isset($item_taxes[$name])) { |
|
3673 | + $item_taxes[$name] = $tax; |
|
3674 | 3674 | continue; |
3675 | 3675 | } |
3676 | 3676 | |
3677 | - $item_taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
3678 | - $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
3677 | + $item_taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
3678 | + $item_taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
3679 | 3679 | |
3680 | 3680 | } |
3681 | 3681 | } |
3682 | 3682 | |
3683 | - $item_taxes = array_replace( $this->get_taxes(), $item_taxes ); |
|
3684 | - $this->set_taxes( $item_taxes ); |
|
3683 | + $item_taxes = array_replace($this->get_taxes(), $item_taxes); |
|
3684 | + $this->set_taxes($item_taxes); |
|
3685 | 3685 | |
3686 | - $initial_tax = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) ); |
|
3687 | - $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) ); |
|
3686 | + $initial_tax = array_sum(wp_list_pluck($item_taxes, 'initial_tax')); |
|
3687 | + $recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax')); |
|
3688 | 3688 | |
3689 | 3689 | $current = $this->is_renewal() ? $recurring_tax : $initial_tax; |
3690 | 3690 | |
@@ -3695,7 +3695,7 @@ discard block |
||
3695 | 3695 | |
3696 | 3696 | } |
3697 | 3697 | |
3698 | - $this->set_total_tax( $current ); |
|
3698 | + $this->set_total_tax($current); |
|
3699 | 3699 | |
3700 | 3700 | return $current; |
3701 | 3701 | |
@@ -3712,20 +3712,20 @@ discard block |
||
3712 | 3712 | $fee = 0; |
3713 | 3713 | $recurring = 0; |
3714 | 3714 | |
3715 | - foreach ( $fees as $data ) { |
|
3716 | - $fee += wpinv_sanitize_amount( $data['initial_fee'] ); |
|
3717 | - $recurring += wpinv_sanitize_amount( $data['recurring_fee'] ); |
|
3715 | + foreach ($fees as $data) { |
|
3716 | + $fee += wpinv_sanitize_amount($data['initial_fee']); |
|
3717 | + $recurring += wpinv_sanitize_amount($data['recurring_fee']); |
|
3718 | 3718 | } |
3719 | 3719 | |
3720 | 3720 | $current = $this->is_renewal() ? $recurring : $fee; |
3721 | - $this->set_total_fees( $current ); |
|
3721 | + $this->set_total_fees($current); |
|
3722 | 3722 | |
3723 | 3723 | $this->totals['fee'] = array( |
3724 | 3724 | 'initial' => $fee, |
3725 | 3725 | 'recurring' => $recurring, |
3726 | 3726 | ); |
3727 | 3727 | |
3728 | - $this->set_total_fees( $fee ); |
|
3728 | + $this->set_total_fees($fee); |
|
3729 | 3729 | return $current; |
3730 | 3730 | } |
3731 | 3731 | |
@@ -3740,7 +3740,7 @@ discard block |
||
3740 | 3740 | $this->recalculate_total_discount(); |
3741 | 3741 | $this->recalculate_total_tax(); |
3742 | 3742 | $this->recalculate_subtotal(); |
3743 | - $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) ); |
|
3743 | + $this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit')); |
|
3744 | 3744 | return $this->get_total(); |
3745 | 3745 | } |
3746 | 3746 | |
@@ -3749,7 +3749,7 @@ discard block |
||
3749 | 3749 | */ |
3750 | 3750 | public function recalculate_totals() { |
3751 | 3751 | $this->recalculate_total(); |
3752 | - $this->save( true ); |
|
3752 | + $this->save(true); |
|
3753 | 3753 | return $this; |
3754 | 3754 | } |
3755 | 3755 | |
@@ -3767,8 +3767,8 @@ discard block |
||
3767 | 3767 | * @return int|false The new note's ID on success, false on failure. |
3768 | 3768 | * |
3769 | 3769 | */ |
3770 | - public function add_system_note( $note ) { |
|
3771 | - return $this->add_note( $note, false, false, true ); |
|
3770 | + public function add_system_note($note) { |
|
3771 | + return $this->add_note($note, false, false, true); |
|
3772 | 3772 | } |
3773 | 3773 | |
3774 | 3774 | /** |
@@ -3778,10 +3778,10 @@ discard block |
||
3778 | 3778 | * @return int|false The new note's ID on success, false on failure. |
3779 | 3779 | * |
3780 | 3780 | */ |
3781 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3781 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3782 | 3782 | |
3783 | 3783 | // Bail if no note specified or this invoice is not yet saved. |
3784 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3784 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3785 | 3785 | return false; |
3786 | 3786 | } |
3787 | 3787 | |
@@ -3789,23 +3789,23 @@ discard block |
||
3789 | 3789 | $author_email = '[email protected]'; |
3790 | 3790 | |
3791 | 3791 | // If this is an admin comment or it has been added by the user. |
3792 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3793 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3792 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3793 | + $user = get_user_by('id', get_current_user_id()); |
|
3794 | 3794 | $author = $user->display_name; |
3795 | 3795 | $author_email = $user->user_email; |
3796 | 3796 | } |
3797 | 3797 | |
3798 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3798 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3799 | 3799 | |
3800 | 3800 | } |
3801 | 3801 | |
3802 | 3802 | /** |
3803 | 3803 | * Generates a unique key for the invoice. |
3804 | 3804 | */ |
3805 | - public function generate_key( $string = '' ) { |
|
3806 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3805 | + public function generate_key($string = '') { |
|
3806 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3807 | 3807 | return strtolower( |
3808 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3808 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3809 | 3809 | ); |
3810 | 3810 | } |
3811 | 3811 | |
@@ -3815,11 +3815,11 @@ discard block |
||
3815 | 3815 | public function generate_number() { |
3816 | 3816 | $number = $this->get_id(); |
3817 | 3817 | |
3818 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3819 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3818 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3819 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3820 | 3820 | } |
3821 | 3821 | |
3822 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3822 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3823 | 3823 | |
3824 | 3824 | } |
3825 | 3825 | |
@@ -3832,55 +3832,55 @@ discard block |
||
3832 | 3832 | // Reset status transition variable. |
3833 | 3833 | $this->status_transition = false; |
3834 | 3834 | |
3835 | - if ( $status_transition ) { |
|
3835 | + if ($status_transition) { |
|
3836 | 3836 | try { |
3837 | 3837 | |
3838 | 3838 | // Fire a hook for the status change. |
3839 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3839 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3840 | 3840 | |
3841 | 3841 | // @deprecated this is deprecated and will be removed in the future. |
3842 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3842 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3843 | 3843 | |
3844 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3844 | + if (!empty($status_transition['from'])) { |
|
3845 | 3845 | |
3846 | 3846 | /* translators: 1: old invoice status 2: new invoice status */ |
3847 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'], $this ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3847 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this)); |
|
3848 | 3848 | |
3849 | 3849 | // Fire another hook. |
3850 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3851 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3850 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3851 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3852 | 3852 | |
3853 | 3853 | // @deprecated this is deprecated and will be removed in the future. |
3854 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3854 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3855 | 3855 | |
3856 | 3856 | // Note the transition occurred. |
3857 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] ); |
|
3857 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']); |
|
3858 | 3858 | |
3859 | 3859 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3860 | 3860 | if ( |
3861 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3862 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3861 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3862 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3863 | 3863 | ) { |
3864 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3864 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3865 | 3865 | } |
3866 | 3866 | |
3867 | 3867 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3868 | 3868 | if ( |
3869 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3870 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3869 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3870 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3871 | 3871 | ) { |
3872 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3872 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3873 | 3873 | } |
3874 | 3874 | } else { |
3875 | 3875 | /* translators: %s: new invoice status */ |
3876 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this ) ); |
|
3876 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this)); |
|
3877 | 3877 | |
3878 | 3878 | // Note the transition occurred. |
3879 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3879 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3880 | 3880 | |
3881 | 3881 | } |
3882 | - } catch ( Exception $e ) { |
|
3883 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3882 | + } catch (Exception $e) { |
|
3883 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3884 | 3884 | } |
3885 | 3885 | } |
3886 | 3886 | } |
@@ -3888,13 +3888,13 @@ discard block |
||
3888 | 3888 | /** |
3889 | 3889 | * Updates an invoice status. |
3890 | 3890 | */ |
3891 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3891 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3892 | 3892 | |
3893 | 3893 | // Fires before updating a status. |
3894 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3894 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3895 | 3895 | |
3896 | 3896 | // Update the status. |
3897 | - $this->set_status( $new_status, $note, $manual ); |
|
3897 | + $this->set_status($new_status, $note, $manual); |
|
3898 | 3898 | |
3899 | 3899 | // Save the order. |
3900 | 3900 | return $this->save(); |
@@ -3905,18 +3905,18 @@ discard block |
||
3905 | 3905 | * @deprecated |
3906 | 3906 | */ |
3907 | 3907 | public function refresh_item_ids() { |
3908 | - $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) ); |
|
3909 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3908 | + $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id'))); |
|
3909 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3910 | 3910 | } |
3911 | 3911 | |
3912 | 3912 | /** |
3913 | 3913 | * @deprecated |
3914 | 3914 | */ |
3915 | - public function update_items( $temp = false ) { |
|
3915 | + public function update_items($temp = false) { |
|
3916 | 3916 | |
3917 | - $this->set_items( $this->get_items() ); |
|
3917 | + $this->set_items($this->get_items()); |
|
3918 | 3918 | |
3919 | - if ( ! $temp ) { |
|
3919 | + if (!$temp) { |
|
3920 | 3920 | $this->save(); |
3921 | 3921 | } |
3922 | 3922 | |
@@ -3930,11 +3930,11 @@ discard block |
||
3930 | 3930 | |
3931 | 3931 | $discount_code = $this->get_discount_code(); |
3932 | 3932 | |
3933 | - if ( empty( $discount_code ) ) { |
|
3933 | + if (empty($discount_code)) { |
|
3934 | 3934 | return false; |
3935 | 3935 | } |
3936 | 3936 | |
3937 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3937 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3938 | 3938 | |
3939 | 3939 | // Ensure it is active. |
3940 | 3940 | return $discount->exists(); |
@@ -3945,7 +3945,7 @@ discard block |
||
3945 | 3945 | * Refunds an invoice. |
3946 | 3946 | */ |
3947 | 3947 | public function refund() { |
3948 | - $this->set_status( 'wpi-refunded' ); |
|
3948 | + $this->set_status('wpi-refunded'); |
|
3949 | 3949 | $this->save(); |
3950 | 3950 | } |
3951 | 3951 | |
@@ -3954,53 +3954,53 @@ discard block |
||
3954 | 3954 | * |
3955 | 3955 | * @param string $transaction_id |
3956 | 3956 | */ |
3957 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3957 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3958 | 3958 | |
3959 | 3959 | // Set the transaction id. |
3960 | - if ( empty( $transaction_id ) ) { |
|
3961 | - $transaction_id = $this->generate_key( 'trans_' ); |
|
3960 | + if (empty($transaction_id)) { |
|
3961 | + $transaction_id = $this->generate_key('trans_'); |
|
3962 | 3962 | } |
3963 | 3963 | |
3964 | - if ( ! $this->get_transaction_id() ) { |
|
3965 | - $this->set_transaction_id( $transaction_id ); |
|
3964 | + if (!$this->get_transaction_id()) { |
|
3965 | + $this->set_transaction_id($transaction_id); |
|
3966 | 3966 | } |
3967 | 3967 | |
3968 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3968 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3969 | 3969 | return $this->save(); |
3970 | 3970 | } |
3971 | 3971 | |
3972 | 3972 | // Set the completed date. |
3973 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3973 | + $this->set_date_completed(current_time('mysql')); |
|
3974 | 3974 | |
3975 | 3975 | // Set the new status. |
3976 | - $gateway = sanitize_text_field( $this->get_gateway_title() ); |
|
3977 | - if ( $this->is_renewal() || ! $this->is_parent() ) { |
|
3976 | + $gateway = sanitize_text_field($this->get_gateway_title()); |
|
3977 | + if ($this->is_renewal() || !$this->is_parent()) { |
|
3978 | 3978 | |
3979 | - $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway ); |
|
3980 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3979 | + $_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway); |
|
3980 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3981 | 3981 | |
3982 | - if ( 'none' == $this->get_gateway() ) { |
|
3982 | + if ('none' == $this->get_gateway()) { |
|
3983 | 3983 | $_note = $note; |
3984 | 3984 | } |
3985 | 3985 | |
3986 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3986 | + $this->set_status('wpi-renewal', $_note); |
|
3987 | 3987 | |
3988 | 3988 | } else { |
3989 | 3989 | |
3990 | - $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway ); |
|
3991 | - $_note = $_note . empty( $note ) ? '' : " ($note)"; |
|
3990 | + $_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway); |
|
3991 | + $_note = $_note . empty($note) ? '' : " ($note)"; |
|
3992 | 3992 | |
3993 | - if ( 'none' == $this->get_gateway() ) { |
|
3993 | + if ('none' == $this->get_gateway()) { |
|
3994 | 3994 | $_note = $note; |
3995 | 3995 | } |
3996 | 3996 | |
3997 | - $this->set_status( 'publish', $_note ); |
|
3997 | + $this->set_status('publish', $_note); |
|
3998 | 3998 | |
3999 | 3999 | } |
4000 | 4000 | |
4001 | 4001 | // Set checkout mode. |
4002 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
4003 | - $this->set_mode( $mode ); |
|
4002 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
4003 | + $this->set_mode($mode); |
|
4004 | 4004 | |
4005 | 4005 | // Save the invoice. |
4006 | 4006 | $this->save(); |
@@ -4025,9 +4025,9 @@ discard block |
||
4025 | 4025 | * Clears the subscription's cache. |
4026 | 4026 | */ |
4027 | 4027 | public function clear_cache() { |
4028 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
4029 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
4030 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
4028 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
4029 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
4030 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
4031 | 4031 | } |
4032 | 4032 | |
4033 | 4033 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Personal data exporters. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy_Exporters Class. |
@@ -17,39 +17,39 @@ discard block |
||
17 | 17 | * @param int $page Page. |
18 | 18 | * @return array An array of invoice data in name value pairs |
19 | 19 | */ |
20 | - public static function customer_invoice_data_exporter( $email_address, $page ) { |
|
20 | + public static function customer_invoice_data_exporter($email_address, $page) { |
|
21 | 21 | $done = false; |
22 | 22 | $page = (int) $page; |
23 | 23 | $data_to_export = array(); |
24 | 24 | |
25 | - $user = get_user_by( 'email', $email_address ); |
|
26 | - if ( ! $user instanceof WP_User ) { |
|
25 | + $user = get_user_by('email', $email_address); |
|
26 | + if (!$user instanceof WP_User) { |
|
27 | 27 | return array( |
28 | 28 | 'data' => $data_to_export, |
29 | 29 | 'done' => true, |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - $args = array( |
|
34 | - 'limit' => get_option( 'posts_per_page' ), |
|
33 | + $args = array( |
|
34 | + 'limit' => get_option('posts_per_page'), |
|
35 | 35 | 'page' => $page, |
36 | 36 | 'user' => $user->ID, |
37 | 37 | 'paginate' => false, |
38 | 38 | ); |
39 | 39 | |
40 | - $invoices = wpinv_get_invoices( $args ); |
|
40 | + $invoices = wpinv_get_invoices($args); |
|
41 | 41 | |
42 | - if ( 0 < count( $invoices ) ) { |
|
43 | - foreach ( $invoices as $invoice ) { |
|
42 | + if (0 < count($invoices)) { |
|
43 | + foreach ($invoices as $invoice) { |
|
44 | 44 | $data_to_export[] = array( |
45 | 45 | 'group_id' => 'customer_invoices', |
46 | - 'group_label' => __( 'GetPaid: Invoices', 'invoicing' ), |
|
47 | - 'group_description' => __( 'Customer invoices.', 'invoicing' ), |
|
46 | + 'group_label' => __('GetPaid: Invoices', 'invoicing'), |
|
47 | + 'group_description' => __('Customer invoices.', 'invoicing'), |
|
48 | 48 | 'item_id' => "wpinv-{$invoice->get_id()}", |
49 | - 'data' => self::get_customer_invoice_data( $invoice ), |
|
49 | + 'data' => self::get_customer_invoice_data($invoice), |
|
50 | 50 | ); |
51 | 51 | } |
52 | - $done = get_option( 'posts_per_page' ) > count( $invoices ); |
|
52 | + $done = get_option('posts_per_page') > count($invoices); |
|
53 | 53 | } else { |
54 | 54 | $done = true; |
55 | 55 | } |
@@ -67,116 +67,116 @@ discard block |
||
67 | 67 | * @param WPInv_Invoice $invoice invoice object. |
68 | 68 | * @return array |
69 | 69 | */ |
70 | - public static function get_customer_invoice_data( $invoice ) { |
|
70 | + public static function get_customer_invoice_data($invoice) { |
|
71 | 71 | |
72 | 72 | // Prepare basic properties. |
73 | 73 | $props_to_export = array( |
74 | 74 | 'number' => array( |
75 | - 'name' => __( 'Invoice Number', 'invoicing' ), |
|
75 | + 'name' => __('Invoice Number', 'invoicing'), |
|
76 | 76 | 'value' => $invoice->get_number(), |
77 | 77 | ), |
78 | 78 | 'created_date' => array( |
79 | - 'name' => __( 'Created Date', 'invoicing' ), |
|
79 | + 'name' => __('Created Date', 'invoicing'), |
|
80 | 80 | 'value' => $invoice->get_date_created(), |
81 | 81 | ), |
82 | 82 | 'due_date' => array( |
83 | - 'name' => __( 'Due Date', 'invoicing' ), |
|
83 | + 'name' => __('Due Date', 'invoicing'), |
|
84 | 84 | 'value' => $invoice->get_due_date(), |
85 | 85 | ), |
86 | 86 | 'items' => array( |
87 | - 'name' => __( 'Invoice Items', 'invoicing' ), |
|
88 | - 'value' => self::process_invoice_items( $invoice ), |
|
87 | + 'name' => __('Invoice Items', 'invoicing'), |
|
88 | + 'value' => self::process_invoice_items($invoice), |
|
89 | 89 | ), |
90 | 90 | 'discount' => array( |
91 | - 'name' => __( 'Invoice Discount', 'invoicing' ), |
|
92 | - 'value' => wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ), |
|
91 | + 'name' => __('Invoice Discount', 'invoicing'), |
|
92 | + 'value' => wpinv_price($invoice->get_total_discount(), $invoice->get_currency()), |
|
93 | 93 | ), |
94 | 94 | 'total' => array( |
95 | - 'name' => __( 'Invoice Total', 'invoicing' ), |
|
96 | - 'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ), |
|
95 | + 'name' => __('Invoice Total', 'invoicing'), |
|
96 | + 'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()), |
|
97 | 97 | ), |
98 | 98 | 'status' => array( |
99 | - 'name' => __( 'Invoice Status', 'invoicing' ), |
|
99 | + 'name' => __('Invoice Status', 'invoicing'), |
|
100 | 100 | 'value' => $invoice->get_status_nicename(), |
101 | 101 | ), |
102 | 102 | 'first_name' => array( |
103 | - 'name' => __( 'First Name', 'invoicing' ), |
|
103 | + 'name' => __('First Name', 'invoicing'), |
|
104 | 104 | 'value' => $invoice->get_first_name(), |
105 | 105 | ), |
106 | 106 | 'last_name' => array( |
107 | - 'name' => __( 'Last Name', 'invoicing' ), |
|
107 | + 'name' => __('Last Name', 'invoicing'), |
|
108 | 108 | 'value' => $invoice->get_last_name(), |
109 | 109 | ), |
110 | 110 | 'email' => array( |
111 | - 'name' => __( 'Email Address', 'invoicing' ), |
|
111 | + 'name' => __('Email Address', 'invoicing'), |
|
112 | 112 | 'value' => $invoice->get_email(), |
113 | 113 | ), |
114 | 114 | 'company' => array( |
115 | - 'name' => __( 'Company', 'invoicing' ), |
|
115 | + 'name' => __('Company', 'invoicing'), |
|
116 | 116 | 'value' => $invoice->get_company(), |
117 | 117 | ), |
118 | 118 | 'phone' => array( |
119 | - 'name' => __( 'Phone Number', 'invoicing' ), |
|
119 | + 'name' => __('Phone Number', 'invoicing'), |
|
120 | 120 | 'value' => $invoice->get_phone(), |
121 | 121 | ), |
122 | 122 | 'address' => array( |
123 | - 'name' => __( 'Address', 'invoicing' ), |
|
123 | + 'name' => __('Address', 'invoicing'), |
|
124 | 124 | 'value' => $invoice->get_address(), |
125 | 125 | ), |
126 | 126 | 'city' => array( |
127 | - 'name' => __( 'City', 'invoicing' ), |
|
127 | + 'name' => __('City', 'invoicing'), |
|
128 | 128 | 'value' => $invoice->get_city(), |
129 | 129 | ), |
130 | 130 | 'state' => array( |
131 | - 'name' => __( 'State', 'invoicing' ), |
|
131 | + 'name' => __('State', 'invoicing'), |
|
132 | 132 | 'value' => $invoice->get_state(), |
133 | 133 | ), |
134 | 134 | 'zip' => array( |
135 | - 'name' => __( 'Zip', 'invoicing' ), |
|
135 | + 'name' => __('Zip', 'invoicing'), |
|
136 | 136 | 'value' => $invoice->get_zip(), |
137 | 137 | ), |
138 | 138 | 'vat_number' => array( |
139 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
139 | + 'name' => __('VAT Number', 'invoicing'), |
|
140 | 140 | 'value' => $invoice->get_vat_number(), |
141 | 141 | ), |
142 | 142 | 'description' => array( |
143 | - 'name' => __( 'Description', 'invoicing' ), |
|
143 | + 'name' => __('Description', 'invoicing'), |
|
144 | 144 | 'value' => $invoice->get_description(), |
145 | 145 | ), |
146 | 146 | ); |
147 | 147 | |
148 | 148 | // In case the invoice is paid, add the payment date and gateway. |
149 | - if ( $invoice->is_paid() ) { |
|
149 | + if ($invoice->is_paid()) { |
|
150 | 150 | |
151 | 151 | $props_to_export['completed_date'] = array( |
152 | - 'name' => __( 'Completed Date', 'invoicing' ), |
|
152 | + 'name' => __('Completed Date', 'invoicing'), |
|
153 | 153 | 'value' => $invoice->get_completed_date(), |
154 | 154 | ); |
155 | 155 | |
156 | 156 | $props_to_export['gateway'] = array( |
157 | - 'name' => __( 'Paid Via', 'invoicing' ), |
|
157 | + 'name' => __('Paid Via', 'invoicing'), |
|
158 | 158 | 'value' => $invoice->get_gateway(), |
159 | 159 | ); |
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | // Maybe add subscription details. |
164 | - $props_to_export = self::process_subscription( $invoice, $props_to_export ); |
|
164 | + $props_to_export = self::process_subscription($invoice, $props_to_export); |
|
165 | 165 | |
166 | 166 | // Add the ip address. |
167 | 167 | $props_to_export['ip'] = array( |
168 | - 'name' => __( 'IP Address', 'invoicing' ), |
|
168 | + 'name' => __('IP Address', 'invoicing'), |
|
169 | 169 | 'value' => $invoice->get_ip(), |
170 | 170 | ); |
171 | 171 | |
172 | 172 | // Add the invoice url. |
173 | 173 | $props_to_export['view_url'] = array( |
174 | - 'name' => __( 'Invoice URL', 'invoicing' ), |
|
174 | + 'name' => __('Invoice URL', 'invoicing'), |
|
175 | 175 | 'value' => $invoice->get_view_url(), |
176 | 176 | ); |
177 | 177 | |
178 | 178 | // Return the values. |
179 | - return apply_filters( 'getpaid_privacy_export_invoice_personal_data', array_values( $props_to_export ), $invoice ); |
|
179 | + return apply_filters('getpaid_privacy_export_invoice_personal_data', array_values($props_to_export), $invoice); |
|
180 | 180 | |
181 | 181 | } |
182 | 182 | |
@@ -188,40 +188,40 @@ discard block |
||
188 | 188 | * @param array $props invoice props. |
189 | 189 | * @return array |
190 | 190 | */ |
191 | - public static function process_subscription( $invoice, $props ) { |
|
191 | + public static function process_subscription($invoice, $props) { |
|
192 | 192 | |
193 | - $subscription = wpinv_get_subscription( $invoice ); |
|
194 | - if ( ! empty( $subscription ) ) { |
|
193 | + $subscription = wpinv_get_subscription($invoice); |
|
194 | + if (!empty($subscription)) { |
|
195 | 195 | |
196 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency() ); |
|
197 | - $period = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency; |
|
198 | - $initial_amt = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
199 | - $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() ); |
|
200 | - $renewal_date = getpaid_format_date_value( $subscription->get_expiration() ); |
|
196 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency()); |
|
197 | + $period = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency; |
|
198 | + $initial_amt = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
199 | + $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times()); |
|
200 | + $renewal_date = getpaid_format_date_value($subscription->get_expiration()); |
|
201 | 201 | |
202 | 202 | // Billing cycle. |
203 | 203 | $props['period'] = array( |
204 | - 'name' => __( 'Billing Cycle', 'invoicing' ), |
|
204 | + 'name' => __('Billing Cycle', 'invoicing'), |
|
205 | 205 | 'value' => $period, |
206 | 206 | ); |
207 | 207 | |
208 | 208 | // Initial amount. |
209 | 209 | $props['initial_amount'] = array( |
210 | - 'name' => __( 'Initial Amount', 'invoicing' ), |
|
210 | + 'name' => __('Initial Amount', 'invoicing'), |
|
211 | 211 | 'value' => $initial_amt, |
212 | 212 | ); |
213 | 213 | |
214 | 214 | // Bill times. |
215 | 215 | $props['bill_times'] = array( |
216 | - 'name' => __( 'Times Billed', 'invoicing' ), |
|
216 | + 'name' => __('Times Billed', 'invoicing'), |
|
217 | 217 | 'value' => $bill_times, |
218 | 218 | ); |
219 | 219 | |
220 | 220 | // Add expiry date. |
221 | - if ( $subscription->is_active() ) { |
|
221 | + if ($subscription->is_active()) { |
|
222 | 222 | |
223 | 223 | $props['renewal_date'] = array( |
224 | - 'name' => __( 'Expires', 'invoicing' ), |
|
224 | + 'name' => __('Expires', 'invoicing'), |
|
225 | 225 | 'value' => $renewal_date, |
226 | 226 | ); |
227 | 227 | |
@@ -239,19 +239,19 @@ discard block |
||
239 | 239 | * @param WPInv_Invoice $invoice invoice object. |
240 | 240 | * @return array |
241 | 241 | */ |
242 | - public static function process_invoice_items( $invoice ) { |
|
242 | + public static function process_invoice_items($invoice) { |
|
243 | 243 | |
244 | 244 | $item_names = array(); |
245 | - foreach ( $invoice->get_items() as $cart_item ) { |
|
245 | + foreach ($invoice->get_items() as $cart_item) { |
|
246 | 246 | $item_names[] = sprintf( |
247 | 247 | '%s x %s - %s', |
248 | 248 | $cart_item->get_name(), |
249 | 249 | $cart_item->get_quantity(), |
250 | - wpinv_price( $invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency() ) |
|
250 | + wpinv_price($invoice->is_renewal() ? $cart_item->get_recurring_sub_total() : $cart_item->get_sub_total(), $invoice->get_currency()) |
|
251 | 251 | ); |
252 | 252 | } |
253 | 253 | |
254 | - return implode( ', ', $item_names ); |
|
254 | + return implode(', ', $item_names); |
|
255 | 255 | |
256 | 256 | } |
257 | 257 |
@@ -1,155 +1,155 @@ discard block |
||
1 | 1 | <?php |
2 | -function wpinv_is_subscription_payment( $invoice = '' ) { |
|
3 | - if ( empty( $invoice ) ) { |
|
2 | +function wpinv_is_subscription_payment($invoice = '') { |
|
3 | + if (empty($invoice)) { |
|
4 | 4 | return false; |
5 | 5 | } |
6 | 6 | |
7 | - if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
8 | - $invoice = wpinv_get_invoice( $invoice ); |
|
7 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
8 | + $invoice = wpinv_get_invoice($invoice); |
|
9 | 9 | } |
10 | 10 | |
11 | - if ( empty( $invoice ) ) { |
|
11 | + if (empty($invoice)) { |
|
12 | 12 | return false; |
13 | 13 | } |
14 | 14 | |
15 | - if ( $invoice->is_renewal() ) { |
|
15 | + if ($invoice->is_renewal()) { |
|
16 | 16 | return true; |
17 | 17 | } |
18 | 18 | |
19 | 19 | return false; |
20 | 20 | } |
21 | 21 | |
22 | -function wpinv_payment_link_transaction_id( $invoice = '' ) { |
|
23 | - if ( empty( $invoice ) ) { |
|
22 | +function wpinv_payment_link_transaction_id($invoice = '') { |
|
23 | + if (empty($invoice)) { |
|
24 | 24 | return false; |
25 | 25 | } |
26 | 26 | |
27 | - if ( ! is_object( $invoice ) && is_scalar( $invoice ) ) { |
|
28 | - $invoice = wpinv_get_invoice( $invoice ); |
|
27 | + if (!is_object($invoice) && is_scalar($invoice)) { |
|
28 | + $invoice = wpinv_get_invoice($invoice); |
|
29 | 29 | } |
30 | 30 | |
31 | - if ( empty( $invoice ) ) { |
|
31 | + if (empty($invoice)) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | |
35 | - return apply_filters( 'wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice ); |
|
35 | + return apply_filters('wpinv_payment_details_transaction_id-' . $invoice->gateway, $invoice->get_transaction_id(), $invoice->ID, $invoice); |
|
36 | 36 | } |
37 | 37 | |
38 | -function wpinv_subscription_initial_payment_desc( $amount, $period, $interval, $trial_period = '', $trial_interval = 0 ) { |
|
39 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
38 | +function wpinv_subscription_initial_payment_desc($amount, $period, $interval, $trial_period = '', $trial_interval = 0) { |
|
39 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
40 | 40 | |
41 | - if ( $trial_interval > 0 && ! empty( $trial_period ) ) { |
|
42 | - $amount = __( 'Free', 'invoicing' ); |
|
41 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
42 | + $amount = __('Free', 'invoicing'); |
|
43 | 43 | $interval = $trial_interval; |
44 | 44 | $period = $trial_period; |
45 | 45 | } |
46 | 46 | |
47 | 47 | $description = ''; |
48 | - switch ( $period ) { |
|
48 | + switch ($period) { |
|
49 | 49 | case 'D': |
50 | 50 | case 'day': |
51 | - $description = wp_sprintf( _n( '%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
51 | + $description = wp_sprintf(_n('%s for the first day.', '%1$s for the first %2$d days.', $interval, 'invoicing'), $amount, $interval); |
|
52 | 52 | break; |
53 | 53 | case 'W': |
54 | 54 | case 'week': |
55 | - $description = wp_sprintf( _n( '%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
55 | + $description = wp_sprintf(_n('%s for the first week.', '%1$s for the first %2$d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
56 | 56 | break; |
57 | 57 | case 'M': |
58 | 58 | case 'month': |
59 | - $description = wp_sprintf( _n( '%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
59 | + $description = wp_sprintf(_n('%s for the first month.', '%1$s for the first %2$d months.', $interval, 'invoicing'), $amount, $interval); |
|
60 | 60 | break; |
61 | 61 | case 'Y': |
62 | 62 | case 'year': |
63 | - $description = wp_sprintf( _n( '%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
63 | + $description = wp_sprintf(_n('%s for the first year.', '%1$s for the first %2$d years.', $interval, 'invoicing'), $amount, $interval); |
|
64 | 64 | break; |
65 | 65 | } |
66 | 66 | |
67 | - return apply_filters( 'wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval ); |
|
67 | + return apply_filters('wpinv_subscription_initial_payment_desc', $description, $amount, $period, $interval, $trial_period, $trial_interval); |
|
68 | 68 | } |
69 | 69 | |
70 | -function wpinv_subscription_recurring_payment_desc( $amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0 ) { |
|
71 | - $interval = (int)$interval > 0 ? (int)$interval : 1; |
|
72 | - $bill_times = (int)$bill_times > 0 ? (int)$bill_times : 0; |
|
70 | +function wpinv_subscription_recurring_payment_desc($amount, $period, $interval, $bill_times = 0, $trial_period = '', $trial_interval = 0) { |
|
71 | + $interval = (int) $interval > 0 ? (int) $interval : 1; |
|
72 | + $bill_times = (int) $bill_times > 0 ? (int) $bill_times : 0; |
|
73 | 73 | |
74 | 74 | $description = ''; |
75 | - switch ( $period ) { |
|
75 | + switch ($period) { |
|
76 | 76 | case 'D': |
77 | 77 | case 'day': |
78 | - if ( (int)$bill_times > 0 ) { |
|
79 | - if ( $interval > 1 ) { |
|
80 | - if ( $bill_times > 1 ) { |
|
81 | - $description = wp_sprintf( __( '%1$s for each %2$d days, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
78 | + if ((int) $bill_times > 0) { |
|
79 | + if ($interval > 1) { |
|
80 | + if ($bill_times > 1) { |
|
81 | + $description = wp_sprintf(__('%1$s for each %2$d days, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
82 | 82 | } else { |
83 | - $description = wp_sprintf( __( '%1$s for %2$d days.', 'invoicing' ), $amount, $interval ); |
|
83 | + $description = wp_sprintf(__('%1$s for %2$d days.', 'invoicing'), $amount, $interval); |
|
84 | 84 | } |
85 | 85 | } else { |
86 | - $description = wp_sprintf( _n( '%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
86 | + $description = wp_sprintf(_n('%s for one day.', '%1$s for each day, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
87 | 87 | } |
88 | 88 | } else { |
89 | - $description = wp_sprintf( _n( '%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing' ), $amount, $interval ); |
|
89 | + $description = wp_sprintf(_n('%s for each day.', '%1$s for each %2$d days.', $interval, 'invoicing'), $amount, $interval); |
|
90 | 90 | } |
91 | 91 | break; |
92 | 92 | case 'W': |
93 | 93 | case 'week': |
94 | - if ( (int)$bill_times > 0 ) { |
|
95 | - if ( $interval > 1 ) { |
|
96 | - if ( $bill_times > 1 ) { |
|
97 | - $description = wp_sprintf( __( '%1$s for each %2$d weeks, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
94 | + if ((int) $bill_times > 0) { |
|
95 | + if ($interval > 1) { |
|
96 | + if ($bill_times > 1) { |
|
97 | + $description = wp_sprintf(__('%1$s for each %2$d weeks, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
98 | 98 | } else { |
99 | - $description = wp_sprintf( __( '%1$s for %2$d weeks.', 'invoicing' ), $amount, $interval ); |
|
99 | + $description = wp_sprintf(__('%1$s for %2$d weeks.', 'invoicing'), $amount, $interval); |
|
100 | 100 | } |
101 | 101 | } else { |
102 | - $description = wp_sprintf( _n( '%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
102 | + $description = wp_sprintf(_n('%s for one week.', '%1$s for each week, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
103 | 103 | } |
104 | 104 | } else { |
105 | - $description = wp_sprintf( _n( '%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing' ), $amount, $interval ); |
|
105 | + $description = wp_sprintf(_n('%s for each week.', '%1$s for each %2$d weeks.', $interval, 'invoicing'), $amount, $interval); |
|
106 | 106 | } |
107 | 107 | break; |
108 | 108 | case 'M': |
109 | 109 | case 'month': |
110 | - if ( (int)$bill_times > 0 ) { |
|
111 | - if ( $interval > 1 ) { |
|
112 | - if ( $bill_times > 1 ) { |
|
113 | - $description = wp_sprintf( __( '%1$s for each %2$d months, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
110 | + if ((int) $bill_times > 0) { |
|
111 | + if ($interval > 1) { |
|
112 | + if ($bill_times > 1) { |
|
113 | + $description = wp_sprintf(__('%1$s for each %2$d months, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
114 | 114 | } else { |
115 | - $description = wp_sprintf( __( '%1$s for %2$d months.', 'invoicing' ), $amount, $interval ); |
|
115 | + $description = wp_sprintf(__('%1$s for %2$d months.', 'invoicing'), $amount, $interval); |
|
116 | 116 | } |
117 | 117 | } else { |
118 | - $description = wp_sprintf( _n( '%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
118 | + $description = wp_sprintf(_n('%s for one month.', '%1$s for each month, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
119 | 119 | } |
120 | 120 | } else { |
121 | - $description = wp_sprintf( _n( '%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing' ), $amount, $interval ); |
|
121 | + $description = wp_sprintf(_n('%s for each month.', '%1$s for each %2$d months.', $interval, 'invoicing'), $amount, $interval); |
|
122 | 122 | } |
123 | 123 | break; |
124 | 124 | case 'Y': |
125 | 125 | case 'year': |
126 | - if ( (int)$bill_times > 0 ) { |
|
127 | - if ( $interval > 1 ) { |
|
128 | - if ( $bill_times > 1 ) { |
|
129 | - $description = wp_sprintf( __( '%1$s for each %2$d years, for %3$d installments.', 'invoicing' ), $amount, $interval, $bill_times ); |
|
126 | + if ((int) $bill_times > 0) { |
|
127 | + if ($interval > 1) { |
|
128 | + if ($bill_times > 1) { |
|
129 | + $description = wp_sprintf(__('%1$s for each %2$d years, for %3$d installments.', 'invoicing'), $amount, $interval, $bill_times); |
|
130 | 130 | } else { |
131 | - $description = wp_sprintf( __( '%1$s for %2$d years.', 'invoicing' ), $amount, $interval ); |
|
131 | + $description = wp_sprintf(__('%1$s for %2$d years.', 'invoicing'), $amount, $interval); |
|
132 | 132 | } |
133 | 133 | } else { |
134 | - $description = wp_sprintf( _n( '%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing' ), $amount, $bill_times ); |
|
134 | + $description = wp_sprintf(_n('%s for one year.', '%1$s for each year, for %2$d installments.', $bill_times, 'invoicing'), $amount, $bill_times); |
|
135 | 135 | } |
136 | 136 | } else { |
137 | - $description = wp_sprintf( _n( '%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing' ), $amount, $interval ); |
|
137 | + $description = wp_sprintf(_n('%s for each year.', '%1$s for each %2$d years.', $interval, 'invoicing'), $amount, $interval); |
|
138 | 138 | } |
139 | 139 | break; |
140 | 140 | } |
141 | 141 | |
142 | - return apply_filters( 'wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
142 | + return apply_filters('wpinv_subscription_recurring_payment_desc', $description, $amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
143 | 143 | } |
144 | 144 | |
145 | -function wpinv_subscription_payment_desc( $invoice ) { |
|
146 | - if ( empty( $invoice ) ) { |
|
145 | +function wpinv_subscription_payment_desc($invoice) { |
|
146 | + if (empty($invoice)) { |
|
147 | 147 | return null; |
148 | 148 | } |
149 | 149 | |
150 | 150 | $description = ''; |
151 | - if ( $invoice->is_parent() && $item = $invoice->get_recurring( true ) ) { |
|
152 | - if ( $item->has_free_trial() ) { |
|
151 | + if ($invoice->is_parent() && $item = $invoice->get_recurring(true)) { |
|
152 | + if ($item->has_free_trial()) { |
|
153 | 153 | $trial_period = $item->get_trial_period(); |
154 | 154 | $trial_interval = $item->get_trial_interval(); |
155 | 155 | } else { |
@@ -157,40 +157,40 @@ discard block |
||
157 | 157 | $trial_interval = 0; |
158 | 158 | } |
159 | 159 | |
160 | - $description = wpinv_get_billing_cycle( $invoice->get_total(), $invoice->get_recurring_details( 'total' ), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency() ); |
|
160 | + $description = wpinv_get_billing_cycle($invoice->get_total(), $invoice->get_recurring_details('total'), $item->get_recurring_period(), $item->get_recurring_interval(), $item->get_recurring_limit(), $trial_period, $trial_interval, $invoice->get_currency()); |
|
161 | 161 | } |
162 | 162 | |
163 | - return apply_filters( 'wpinv_subscription_payment_desc', $description, $invoice ); |
|
163 | + return apply_filters('wpinv_subscription_payment_desc', $description, $invoice); |
|
164 | 164 | } |
165 | 165 | |
166 | -function wpinv_get_billing_cycle( $initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '' ) { |
|
167 | - $initial_total = wpinv_round_amount( $initial ); |
|
168 | - $recurring_total = wpinv_round_amount( $recurring ); |
|
166 | +function wpinv_get_billing_cycle($initial, $recurring, $period, $interval, $bill_times, $trial_period = '', $trial_interval = 0, $currency = '') { |
|
167 | + $initial_total = wpinv_round_amount($initial); |
|
168 | + $recurring_total = wpinv_round_amount($recurring); |
|
169 | 169 | |
170 | - if ( $trial_interval > 0 && ! empty( $trial_period ) ) { |
|
170 | + if ($trial_interval > 0 && !empty($trial_period)) { |
|
171 | 171 | // Free trial |
172 | 172 | } else { |
173 | - if ( $bill_times == 1 ) { |
|
173 | + if ($bill_times == 1) { |
|
174 | 174 | $recurring_total = $initial_total; |
175 | - } elseif ( $bill_times > 1 && $initial_total != $recurring_total ) { |
|
175 | + } elseif ($bill_times > 1 && $initial_total != $recurring_total) { |
|
176 | 176 | $bill_times--; |
177 | 177 | } |
178 | 178 | } |
179 | 179 | |
180 | - $initial_amount = wpinv_price( $initial_total, $currency ); |
|
181 | - $recurring_amount = wpinv_price( $recurring_total, $currency ); |
|
180 | + $initial_amount = wpinv_price($initial_total, $currency); |
|
181 | + $recurring_amount = wpinv_price($recurring_total, $currency); |
|
182 | 182 | |
183 | - $recurring = wpinv_subscription_recurring_payment_desc( $recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval ); |
|
183 | + $recurring = wpinv_subscription_recurring_payment_desc($recurring_amount, $period, $interval, $bill_times, $trial_period, $trial_interval); |
|
184 | 184 | |
185 | - if ( $initial_total != $recurring_total ) { |
|
186 | - $initial = wpinv_subscription_initial_payment_desc( $initial_amount, $period, $interval, $trial_period, $trial_interval ); |
|
185 | + if ($initial_total != $recurring_total) { |
|
186 | + $initial = wpinv_subscription_initial_payment_desc($initial_amount, $period, $interval, $trial_period, $trial_interval); |
|
187 | 187 | |
188 | - $description = wp_sprintf( __( '%1$s Then %2$s', 'invoicing' ), $initial, $recurring ); |
|
188 | + $description = wp_sprintf(__('%1$s Then %2$s', 'invoicing'), $initial, $recurring); |
|
189 | 189 | } else { |
190 | 190 | $description = $recurring; |
191 | 191 | } |
192 | 192 | |
193 | - return apply_filters( 'wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency ); |
|
193 | + return apply_filters('wpinv_get_billing_cycle', $description, $initial, $recurring, $period, $interval, $bill_times, $trial_period, $trial_interval, $currency); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,27 +200,27 @@ discard block |
||
200 | 200 | * @param string $card_number Card number. |
201 | 201 | * @return string |
202 | 202 | */ |
203 | -function getpaid_get_card_name( $card_number ) { |
|
203 | +function getpaid_get_card_name($card_number) { |
|
204 | 204 | |
205 | 205 | // Known regexes. |
206 | 206 | $regexes = array( |
207 | - '/^4/' => __( 'Visa', 'invoicing' ), |
|
208 | - '/^5[1-5]/' => __( 'Mastercard', 'invoicing' ), |
|
209 | - '/^3[47]/' => __( 'Amex', 'invoicing' ), |
|
210 | - '/^3(?:0[0-5]|[68])/' => __( 'Diners Club', 'invoicing' ), |
|
211 | - '/^6(?:011|5)/' => __( 'Discover', 'invoicing' ), |
|
212 | - '/^(?:2131|1800|35\d{3})/' => __( 'JCB', 'invoicing' ), |
|
207 | + '/^4/' => __('Visa', 'invoicing'), |
|
208 | + '/^5[1-5]/' => __('Mastercard', 'invoicing'), |
|
209 | + '/^3[47]/' => __('Amex', 'invoicing'), |
|
210 | + '/^3(?:0[0-5]|[68])/' => __('Diners Club', 'invoicing'), |
|
211 | + '/^6(?:011|5)/' => __('Discover', 'invoicing'), |
|
212 | + '/^(?:2131|1800|35\d{3})/' => __('JCB', 'invoicing'), |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | // Confirm if one matches. |
216 | - foreach ( $regexes as $regex => $card ) { |
|
217 | - if ( preg_match( $regex, $card_number ) >= 1 ) { |
|
216 | + foreach ($regexes as $regex => $card) { |
|
217 | + if (preg_match($regex, $card_number) >= 1) { |
|
218 | 218 | return $card; |
219 | 219 | } |
220 | 220 | } |
221 | 221 | |
222 | 222 | // None matched. |
223 | - return __( 'Card', 'invoicing' ); |
|
223 | + return __('Card', 'invoicing'); |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
@@ -229,23 +229,23 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @param WPInv_Invoice|int|null $invoice |
231 | 231 | */ |
232 | -function wpinv_send_back_to_checkout( $invoice = null ) { |
|
233 | - $response = array( 'success' => false ); |
|
234 | - $invoice = wpinv_get_invoice( $invoice ); |
|
232 | +function wpinv_send_back_to_checkout($invoice = null) { |
|
233 | + $response = array('success' => false); |
|
234 | + $invoice = wpinv_get_invoice($invoice); |
|
235 | 235 | |
236 | 236 | // Was an invoice created? |
237 | - if ( ! empty( $invoice ) ) { |
|
238 | - $invoice = is_scalar( $invoice ) ? new WPInv_Invoice( $invoice ) : $invoice; |
|
237 | + if (!empty($invoice)) { |
|
238 | + $invoice = is_scalar($invoice) ? new WPInv_Invoice($invoice) : $invoice; |
|
239 | 239 | $response['invoice'] = $invoice->get_id(); |
240 | - do_action( 'getpaid_checkout_invoice_exception', $invoice ); |
|
240 | + do_action('getpaid_checkout_invoice_exception', $invoice); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | // Do we have any errors? |
244 | - if ( wpinv_get_errors() ) { |
|
245 | - $response['data'] = getpaid_get_errors_html( true, false ); |
|
244 | + if (wpinv_get_errors()) { |
|
245 | + $response['data'] = getpaid_get_errors_html(true, false); |
|
246 | 246 | } else { |
247 | - $response['data'] = __( 'An error occured while processing your payment. Please try again.', 'invoicing' ); |
|
247 | + $response['data'] = __('An error occured while processing your payment. Please try again.', 'invoicing'); |
|
248 | 248 | } |
249 | 249 | |
250 | - wp_send_json( $response ); |
|
250 | + wp_send_json($response); |
|
251 | 251 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Returns an array of discount type. |
@@ -17,8 +17,8 @@ discard block |
||
17 | 17 | return apply_filters( |
18 | 18 | 'wpinv_discount_types', |
19 | 19 | array( |
20 | - 'percent' => __( 'Percentage', 'invoicing' ), |
|
21 | - 'flat' => __( 'Flat Amount', 'invoicing' ), |
|
20 | + 'percent' => __('Percentage', 'invoicing'), |
|
21 | + 'flat' => __('Flat Amount', 'invoicing'), |
|
22 | 22 | ) |
23 | 23 | ); |
24 | 24 | } |
@@ -28,46 +28,46 @@ discard block |
||
28 | 28 | * |
29 | 29 | * @return string |
30 | 30 | */ |
31 | -function wpinv_get_discount_type_name( $type = '' ) { |
|
31 | +function wpinv_get_discount_type_name($type = '') { |
|
32 | 32 | $types = wpinv_get_discount_types(); |
33 | - return isset( $types[ $type ] ) ? $types[ $type ] : $type; |
|
33 | + return isset($types[$type]) ? $types[$type] : $type; |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
37 | 37 | * Deletes a discount via the admin page. |
38 | 38 | * |
39 | 39 | */ |
40 | -function wpinv_delete_discount( $data ) { |
|
40 | +function wpinv_delete_discount($data) { |
|
41 | 41 | |
42 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
43 | - $discount->delete( true ); |
|
42 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
43 | + $discount->delete(true); |
|
44 | 44 | |
45 | 45 | } |
46 | -add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' ); |
|
46 | +add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount'); |
|
47 | 47 | |
48 | 48 | /** |
49 | 49 | * Deactivates a discount via the admin page. |
50 | 50 | */ |
51 | -function wpinv_activate_discount( $data ) { |
|
51 | +function wpinv_activate_discount($data) { |
|
52 | 52 | |
53 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
54 | - $discount->set_status( 'publish' ); |
|
53 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
54 | + $discount->set_status('publish'); |
|
55 | 55 | $discount->save(); |
56 | 56 | |
57 | 57 | } |
58 | -add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' ); |
|
58 | +add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount'); |
|
59 | 59 | |
60 | 60 | /** |
61 | 61 | * Activates a discount via the admin page. |
62 | 62 | */ |
63 | -function wpinv_deactivate_discount( $data ) { |
|
63 | +function wpinv_deactivate_discount($data) { |
|
64 | 64 | |
65 | - $discount = new WPInv_Discount( absint( $data['discount'] ) ); |
|
66 | - $discount->set_status( 'pending' ); |
|
65 | + $discount = new WPInv_Discount(absint($data['discount'])); |
|
66 | + $discount->set_status('pending'); |
|
67 | 67 | $discount->save(); |
68 | 68 | |
69 | 69 | } |
70 | -add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' ); |
|
70 | +add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount'); |
|
71 | 71 | |
72 | 72 | /** |
73 | 73 | * Fetches a discount object. |
@@ -76,8 +76,8 @@ discard block |
||
76 | 76 | * @since 1.0.15 |
77 | 77 | * @return WPInv_Discount |
78 | 78 | */ |
79 | -function wpinv_get_discount( $discount ) { |
|
80 | - return new WPInv_Discount( $discount ); |
|
79 | +function wpinv_get_discount($discount) { |
|
80 | + return new WPInv_Discount($discount); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @since 1.0.15 |
88 | 88 | * @return WPInv_Discount |
89 | 89 | */ |
90 | -function wpinv_get_discount_obj( $discount = 0 ) { |
|
91 | - return new WPInv_Discount( $discount ); |
|
90 | +function wpinv_get_discount_obj($discount = 0) { |
|
91 | + return new WPInv_Discount($discount); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -98,10 +98,10 @@ discard block |
||
98 | 98 | * @param string|int $value The field value |
99 | 99 | * @return bool|WPInv_Discount |
100 | 100 | */ |
101 | -function wpinv_get_discount_by( $deprecated = null, $value = '' ) { |
|
102 | - $discount = new WPInv_Discount( $value ); |
|
101 | +function wpinv_get_discount_by($deprecated = null, $value = '') { |
|
102 | + $discount = new WPInv_Discount($value); |
|
103 | 103 | |
104 | - if ( $discount->get_id() != 0 ) { |
|
104 | + if ($discount->get_id() != 0) { |
|
105 | 105 | return $discount; |
106 | 106 | } |
107 | 107 | |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | function wpinv_get_discount_statuses() { |
117 | 117 | |
118 | 118 | return array( |
119 | - 'expired' => __( 'Expired', 'invoicing' ), |
|
120 | - 'publish' => __( 'Active', 'invoicing' ), |
|
121 | - 'inactive' => __( 'Inactive', 'invoicing' ), |
|
119 | + 'expired' => __('Expired', 'invoicing'), |
|
120 | + 'publish' => __('Active', 'invoicing'), |
|
121 | + 'inactive' => __('Inactive', 'invoicing'), |
|
122 | 122 | ); |
123 | 123 | |
124 | 124 | } |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | /** |
127 | 127 | * Retrieves an invoice status label. |
128 | 128 | */ |
129 | -function wpinv_discount_status( $status ) { |
|
129 | +function wpinv_discount_status($status) { |
|
130 | 130 | $statuses = wpinv_get_discount_statuses(); |
131 | - return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' ); |
|
131 | + return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @param int|array|string|WPInv_Discount $code discount data, object, ID or code. |
139 | 139 | * @return bool |
140 | 140 | */ |
141 | -function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) { |
|
141 | +function wpinv_discount_is_recurring($discount = 0, $code = 0) { |
|
142 | 142 | |
143 | - if ( ! empty( $discount ) ) { |
|
144 | - $discount = wpinv_get_discount_obj( $discount ); |
|
143 | + if (!empty($discount)) { |
|
144 | + $discount = wpinv_get_discount_obj($discount); |
|
145 | 145 | } else { |
146 | - $discount = wpinv_get_discount_obj( $code ); |
|
146 | + $discount = wpinv_get_discount_obj($code); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | return $discount->get_is_recurring(); |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param WPInv_Discount $discount |
159 | 159 | * @return array |
160 | 160 | */ |
161 | -function getpaid_calculate_invoice_discount( $invoice, $discount ) { |
|
161 | +function getpaid_calculate_invoice_discount($invoice, $discount) { |
|
162 | 162 | |
163 | 163 | $initial_discount = 0; |
164 | 164 | $recurring_discount = 0; |
165 | 165 | |
166 | - foreach ( $invoice->get_items() as $item ) { |
|
166 | + foreach ($invoice->get_items() as $item) { |
|
167 | 167 | |
168 | 168 | // Abort if it is not valid for this item. |
169 | - if ( ! $discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
169 | + if (!$discount->is_valid_for_items(array($item->get_id()))) { |
|
170 | 170 | continue; |
171 | 171 | } |
172 | 172 | |
173 | 173 | // Calculate the initial amount... |
174 | - $item_discount = $discount->get_discounted_amount( $item->get_sub_total() ); |
|
174 | + $item_discount = $discount->get_discounted_amount($item->get_sub_total()); |
|
175 | 175 | $recurring_item_discount = 0; |
176 | 176 | |
177 | 177 | // ... and maybe the recurring amount. |
178 | - if ( $item->is_recurring() && $discount->is_recurring() ) { |
|
179 | - $recurring_item_discount = $discount->get_discounted_amount( $item->get_recurring_sub_total() ); |
|
178 | + if ($item->is_recurring() && $discount->is_recurring()) { |
|
179 | + $recurring_item_discount = $discount->get_discounted_amount($item->get_recurring_sub_total()); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | // Discount should not exceed discounted amount. |
183 | - if ( ! $discount->is_type( 'percent' ) ) { |
|
183 | + if (!$discount->is_type('percent')) { |
|
184 | 184 | |
185 | - if ( ( $initial_discount + $item_discount ) > $discount->get_amount() ) { |
|
185 | + if (($initial_discount + $item_discount) > $discount->get_amount()) { |
|
186 | 186 | $item_discount = $discount->get_amount() - $initial_discount; |
187 | 187 | } |
188 | 188 | |
189 | - if ( ( $recurring_discount + $recurring_item_discount ) > $discount->get_amount() ) { |
|
189 | + if (($recurring_discount + $recurring_item_discount) > $discount->get_amount()) { |
|
190 | 190 | $recurring_item_discount = $discount->get_amount() - $recurring_discount; |
191 | 191 | } |
192 | 192 | } |
@@ -218,10 +218,10 @@ discard block |
||
218 | 218 | array( |
219 | 219 | 'post_type' => 'wpi_discount', |
220 | 220 | 'numberposts' => 1, |
221 | - 'fields' => array( 'ids' ), |
|
221 | + 'fields' => array('ids'), |
|
222 | 222 | ) |
223 | 223 | ); |
224 | 224 | |
225 | - return ! empty( $discounts ); |
|
225 | + return !empty($discounts); |
|
226 | 226 | |
227 | 227 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The Subscription Class |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
69 | 69 | * @param bool $deprecated |
70 | 70 | */ |
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
71 | + function __construct($subscription = 0, $deprecated = false) { |
|
72 | 72 | |
73 | - parent::__construct( $subscription ); |
|
73 | + parent::__construct($subscription); |
|
74 | 74 | |
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
80 | - $this->set_id( $subscription_id ); |
|
81 | - } elseif ( ! empty( $subscription->id ) ) { |
|
82 | - $this->set_id( $subscription->id ); |
|
75 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
76 | + $this->set_id($subscription); |
|
77 | + } elseif ($subscription instanceof self) { |
|
78 | + $this->set_id($subscription->get_id()); |
|
79 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
80 | + $this->set_id($subscription_id); |
|
81 | + } elseif (!empty($subscription->id)) { |
|
82 | + $this->set_id($subscription->id); |
|
83 | 83 | } else { |
84 | - $this->set_object_read( true ); |
|
84 | + $this->set_object_read(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Load the datastore. |
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
88 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
89 | 89 | |
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
90 | + if ($this->get_id() > 0) { |
|
91 | + $this->data_store->read($this); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @since 1.0.19 |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
106 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | 109 | // Trim the value. |
110 | - $value = trim( $value ); |
|
110 | + $value = trim($value); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
112 | + if (empty($value)) { |
|
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
116 | + if ('invoice_id' == $field) { |
|
117 | 117 | $field = 'parent_payment_id'; |
118 | 118 | } |
119 | 119 | |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Ensure a field has been passed. |
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
128 | + if (empty($field) || !in_array($field, $fields)) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Maybe retrieve from the cache. |
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
133 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
134 | + if (!empty($subscription_id)) { |
|
135 | 135 | return $subscription_id; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
140 | 140 | $subscription_id = (int) $wpdb->get_var( |
141 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
141 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
144 | + if (empty($subscription_id)) { |
|
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Update the cache with our data. |
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
149 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
150 | 150 | |
151 | 151 | return $subscription_id; |
152 | 152 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
158 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
159 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
160 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | - public function _isset( $key ) { |
|
168 | - return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" ); |
|
167 | + public function _isset($key) { |
|
168 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /* |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $context View or edit context. |
191 | 191 | * @return int |
192 | 192 | */ |
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
193 | + public function get_customer_id($context = 'view') { |
|
194 | + return (int) $this->get_prop('customer_id', $context); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $context View or edit context. |
202 | 202 | * @return WP_User|false WP_User object on success, false on failure. |
203 | 203 | */ |
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
204 | + public function get_customer($context = 'view') { |
|
205 | + return get_userdata($this->get_customer_id($context)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $context View or edit context. |
213 | 213 | * @return int |
214 | 214 | */ |
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
215 | + public function get_parent_invoice_id($context = 'view') { |
|
216 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $context View or edit context. |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
226 | + public function get_parent_payment_id($context = 'view') { |
|
227 | + return $this->get_parent_invoice_id($context); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @since 1.0.0 |
234 | 234 | * @return int |
235 | 235 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
236 | + public function get_original_payment_id($context = 'view') { |
|
237 | + return $this->get_parent_invoice_id($context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return WPInv_Invoice |
246 | 246 | */ |
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
247 | + public function get_parent_invoice($context = 'view') { |
|
248 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return WPInv_Invoice |
257 | 257 | */ |
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
258 | + public function get_parent_payment($context = 'view') { |
|
259 | + return $this->get_parent_invoice($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return int |
268 | 268 | */ |
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
269 | + public function get_product_id($context = 'view') { |
|
270 | + return (int) $this->get_prop('product_id', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return WPInv_Item |
279 | 279 | */ |
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
280 | + public function get_product($context = 'view') { |
|
281 | + return new WPInv_Item($this->get_product_id($context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param string $context View or edit context. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
293 | + public function get_gateway($context = 'view') { |
|
294 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
304 | + public function get_period($context = 'view') { |
|
305 | + return $this->get_prop('period', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
315 | + public function get_frequency($context = 'view') { |
|
316 | + return (int) $this->get_prop('frequency', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
326 | + public function get_initial_amount($context = 'view') { |
|
327 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return float |
336 | 336 | */ |
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
337 | + public function get_recurring_amount($context = 'view') { |
|
338 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return int |
347 | 347 | */ |
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
348 | + public function get_bill_times($context = 'view') { |
|
349 | + return (int) $this->get_prop('bill_times', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
359 | + public function get_transaction_id($context = 'view') { |
|
360 | + return $this->get_prop('transaction_id', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
370 | + public function get_created($context = 'view') { |
|
371 | + return $this->get_prop('created', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
381 | + public function get_date_created($context = 'view') { |
|
382 | + return $this->get_created($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function get_time_created() { |
392 | 392 | $created = $this->get_date_created(); |
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
393 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
403 | + public function get_date_created_gmt($context = 'view') { |
|
404 | + $date = $this->get_date_created($context); |
|
405 | 405 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
406 | + if ($date) { |
|
407 | + $date = get_gmt_from_date($date); |
|
408 | 408 | } |
409 | 409 | return $date; |
410 | 410 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
419 | + public function get_next_renewal_date($context = 'view') { |
|
420 | + return $this->get_prop('expiration', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return string |
429 | 429 | */ |
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
430 | + public function get_expiration($context = 'view') { |
|
431 | + return $this->get_next_renewal_date($context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | public function get_expiration_time() { |
441 | 441 | $expiration = $this->get_expiration(); |
442 | 442 | |
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
443 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
444 | + return current_time('timestamp'); |
|
445 | 445 | } |
446 | 446 | |
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
447 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
448 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $context View or edit context. |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
458 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
459 | + $date = $this->get_next_renewal_date($context); |
|
460 | 460 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
461 | + if ($date) { |
|
462 | + $date = get_gmt_from_date($date); |
|
463 | 463 | } |
464 | 464 | return $date; |
465 | 465 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param string $context View or edit context. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
474 | + public function get_trial_period($context = 'view') { |
|
475 | + return $this->get_prop('trial_period', $context); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $context View or edit context. |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
485 | + public function get_status($context = 'view') { |
|
486 | + return $this->get_prop('status', $context); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * @param string $context View or edit context. |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
496 | + public function get_profile_id($context = 'view') { |
|
497 | + return $this->get_prop('profile_id', $context); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /* |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @since 1.0.19 |
510 | 510 | * @param int $value The customer's id. |
511 | 511 | */ |
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
512 | + public function set_customer_id($value) { |
|
513 | + $this->set_prop('customer_id', (int) $value); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @since 1.0.19 |
520 | 520 | * @param int $value The parent invoice id. |
521 | 521 | */ |
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
522 | + public function set_parent_invoice_id($value) { |
|
523 | + $this->set_prop('parent_payment_id', (int) $value); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @since 1.0.19 |
530 | 530 | * @param int $value The parent invoice id. |
531 | 531 | */ |
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
532 | + public function set_parent_payment_id($value) { |
|
533 | + $this->set_parent_invoice_id($value); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @since 1.0.19 |
540 | 540 | * @param int $value The parent invoice id. |
541 | 541 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
542 | + public function set_original_payment_id($value) { |
|
543 | + $this->set_parent_invoice_id($value); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @since 1.0.19 |
550 | 550 | * @param int $value The subscription product id. |
551 | 551 | */ |
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
552 | + public function set_product_id($value) { |
|
553 | + $this->set_prop('product_id', (int) $value); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @since 1.0.19 |
560 | 560 | * @param string $value The renewal period. |
561 | 561 | */ |
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
562 | + public function set_period($value) { |
|
563 | + $this->set_prop('period', $value); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * @since 1.0.19 |
570 | 570 | * @param int $value The subscription frequency. |
571 | 571 | */ |
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
572 | + public function set_frequency($value) { |
|
573 | + $value = empty($value) ? 1 : (int) $value; |
|
574 | + $this->set_prop('frequency', absint($value)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param float $value The initial subcription amount. |
582 | 582 | */ |
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
583 | + public function set_initial_amount($value) { |
|
584 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | * @param float $value The recurring subcription amount. |
592 | 592 | */ |
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
593 | + public function set_recurring_amount($value) { |
|
594 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | * @param int $value Bill times. |
602 | 602 | */ |
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
603 | + public function set_bill_times($value) { |
|
604 | + $this->set_prop('bill_times', (int) $value); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param string $value Bill times. |
612 | 612 | */ |
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
613 | + public function set_transaction_id($value) { |
|
614 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | * @since 1.0.19 |
621 | 621 | * @param string $value strtotime compliant date. |
622 | 622 | */ |
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
623 | + public function set_created($value) { |
|
624 | + $date = strtotime($value); |
|
625 | 625 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
626 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
627 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $this->set_prop( 'created', '' ); |
|
631 | + $this->set_prop('created', ''); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @since 1.0.19 |
639 | 639 | * @param string $value strtotime compliant date. |
640 | 640 | */ |
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
641 | + public function set_date_created($value) { |
|
642 | + $this->set_created($value); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | * @since 1.0.19 |
649 | 649 | * @param string $value strtotime compliant date. |
650 | 650 | */ |
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
651 | + public function set_next_renewal_date($value) { |
|
652 | + $date = strtotime($value); |
|
653 | 653 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
654 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
655 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $this->set_prop( 'expiration', '' ); |
|
659 | + $this->set_prop('expiration', ''); |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @since 1.0.19 |
667 | 667 | * @param string $value strtotime compliant date. |
668 | 668 | */ |
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
669 | + public function set_expiration($value) { |
|
670 | + $this->set_next_renewal_date($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @since 1.0.19 |
677 | 677 | * @param string $value trial period e.g 1 year. |
678 | 678 | */ |
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
679 | + public function set_trial_period($value) { |
|
680 | + $this->set_prop('trial_period', $value); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -686,22 +686,22 @@ discard block |
||
686 | 686 | * @since 1.0.19 |
687 | 687 | * @param string $new_status New subscription status. |
688 | 688 | */ |
689 | - public function set_status( $new_status ) { |
|
689 | + public function set_status($new_status) { |
|
690 | 690 | |
691 | 691 | // Abort if this is not a valid status; |
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
692 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | - $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
697 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
696 | + $old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status(); |
|
697 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
698 | 698 | $this->status_transition = array( |
699 | 699 | 'from' => $old_status, |
700 | 700 | 'to' => $new_status, |
701 | 701 | ); |
702 | 702 | } |
703 | 703 | |
704 | - $this->set_prop( 'status', $new_status ); |
|
704 | + $this->set_prop('status', $new_status); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -710,8 +710,8 @@ discard block |
||
710 | 710 | * @since 1.0.19 |
711 | 711 | * @param string $value the remote profile id. |
712 | 712 | */ |
713 | - public function set_profile_id( $value ) { |
|
714 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
713 | + public function set_profile_id($value) { |
|
714 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
715 | 715 | } |
716 | 716 | |
717 | 717 | /* |
@@ -729,8 +729,8 @@ discard block |
||
729 | 729 | * @param string|array String or array of strings to check for. |
730 | 730 | * @return bool |
731 | 731 | */ |
732 | - public function has_status( $status ) { |
|
733 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
732 | + public function has_status($status) { |
|
733 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
734 | 734 | } |
735 | 735 | |
736 | 736 | /** |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | public function has_trial_period() { |
742 | 742 | $period = $this->get_trial_period(); |
743 | - return ! empty( $period ); |
|
743 | + return !empty($period); |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | /** |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @return bool |
750 | 750 | */ |
751 | 751 | public function is_active() { |
752 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
752 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -758,7 +758,7 @@ discard block |
||
758 | 758 | * @return bool |
759 | 759 | */ |
760 | 760 | public function is_expired() { |
761 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) ); |
|
761 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp')); |
|
762 | 762 | } |
763 | 763 | |
764 | 764 | /** |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | */ |
769 | 769 | public function is_last_renewal() { |
770 | 770 | $max_bills = $this->get_bill_times(); |
771 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
771 | + return !empty($max_bills) && $max_bills <= $this->get_times_billed(); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /* |
@@ -783,11 +783,11 @@ discard block |
||
783 | 783 | /** |
784 | 784 | * Backwards compatibilty. |
785 | 785 | */ |
786 | - public function create( $data = array() ) { |
|
786 | + public function create($data = array()) { |
|
787 | 787 | |
788 | 788 | // Set the properties. |
789 | - if ( is_array( $data ) ) { |
|
790 | - $this->set_props( $data ); |
|
789 | + if (is_array($data)) { |
|
790 | + $this->set_props($data); |
|
791 | 791 | } |
792 | 792 | |
793 | 793 | // Save the item. |
@@ -798,8 +798,8 @@ discard block |
||
798 | 798 | /** |
799 | 799 | * Backwards compatibilty. |
800 | 800 | */ |
801 | - public function update( $args = array() ) { |
|
802 | - return $this->create( $args ); |
|
801 | + public function update($args = array()) { |
|
802 | + return $this->create($args); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | /** |
@@ -808,12 +808,12 @@ discard block |
||
808 | 808 | * @since 1.0.0 |
809 | 809 | * @return WP_Post[] |
810 | 810 | */ |
811 | - public function get_child_payments( $hide_pending = true ) { |
|
811 | + public function get_child_payments($hide_pending = true) { |
|
812 | 812 | |
813 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
813 | + $statuses = array('publish', 'wpi-processing', 'wpi-renewal'); |
|
814 | 814 | |
815 | - if ( ! $hide_pending ) { |
|
816 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
815 | + if (!$hide_pending) { |
|
816 | + $statuses = array_keys(wpinv_get_invoice_statuses()); |
|
817 | 817 | } |
818 | 818 | |
819 | 819 | return get_posts( |
@@ -835,7 +835,7 @@ discard block |
||
835 | 835 | * @return int |
836 | 836 | */ |
837 | 837 | public function get_total_payments() { |
838 | - return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
838 | + return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id()); |
|
839 | 839 | } |
840 | 840 | |
841 | 841 | /** |
@@ -847,7 +847,7 @@ discard block |
||
847 | 847 | public function get_times_billed() { |
848 | 848 | $times_billed = $this->get_total_payments(); |
849 | 849 | |
850 | - if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) { |
|
850 | + if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) { |
|
851 | 851 | $times_billed--; |
852 | 852 | } |
853 | 853 | |
@@ -862,48 +862,48 @@ discard block |
||
862 | 862 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
863 | 863 | * @return bool |
864 | 864 | */ |
865 | - public function add_payment( $args = array(), $invoice = false ) { |
|
865 | + public function add_payment($args = array(), $invoice = false) { |
|
866 | 866 | |
867 | 867 | // Process each payment once. |
868 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
868 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
869 | 869 | return false; |
870 | 870 | } |
871 | 871 | |
872 | 872 | // Are we creating a new invoice? |
873 | - if ( empty( $invoice ) ) { |
|
873 | + if (empty($invoice)) { |
|
874 | 874 | $invoice = $this->create_payment(); |
875 | 875 | |
876 | - if ( empty( $invoice ) ) { |
|
876 | + if (empty($invoice)) { |
|
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | } |
880 | 880 | |
881 | - $invoice->set_status( 'wpi-renewal' ); |
|
881 | + $invoice->set_status('wpi-renewal'); |
|
882 | 882 | |
883 | 883 | // Maybe set a transaction id. |
884 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
885 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
884 | + if (!empty($args['transaction_id'])) { |
|
885 | + $invoice->set_transaction_id($args['transaction_id']); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | // Set the completed date. |
889 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
889 | + $invoice->set_completed_date(current_time('mysql')); |
|
890 | 890 | |
891 | 891 | // And the gateway. |
892 | - if ( ! empty( $args['gateway'] ) ) { |
|
893 | - $invoice->set_gateway( $args['gateway'] ); |
|
892 | + if (!empty($args['gateway'])) { |
|
893 | + $invoice->set_gateway($args['gateway']); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | $invoice->save(); |
897 | 897 | |
898 | - if ( ! $invoice->exists() ) { |
|
898 | + if (!$invoice->exists()) { |
|
899 | 899 | return false; |
900 | 900 | } |
901 | 901 | |
902 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
903 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
904 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
902 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
903 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
904 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
905 | 905 | |
906 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
906 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
907 | 907 | |
908 | 908 | return $invoice->get_id(); |
909 | 909 | } |
@@ -918,41 +918,41 @@ discard block |
||
918 | 918 | |
919 | 919 | $parent_invoice = $this->get_parent_payment(); |
920 | 920 | |
921 | - if ( ! $parent_invoice->exists() ) { |
|
921 | + if (!$parent_invoice->exists()) { |
|
922 | 922 | return false; |
923 | 923 | } |
924 | 924 | |
925 | 925 | // Duplicate the parent invoice. |
926 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
927 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
928 | - $invoice->set_subscription_id( $this->get_id() ); |
|
929 | - $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
926 | + $invoice = getpaid_duplicate_invoice($parent_invoice); |
|
927 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
928 | + $invoice->set_subscription_id($this->get_id()); |
|
929 | + $invoice->set_remote_subscription_id($this->get_profile_id()); |
|
930 | 930 | |
931 | 931 | // Set invoice items. |
932 | - $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
933 | - $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
932 | + $subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id()); |
|
933 | + $allowed_items = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']); |
|
934 | 934 | $invoice_items = array(); |
935 | 935 | |
936 | - foreach ( $invoice->get_items() as $item ) { |
|
937 | - if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
936 | + foreach ($invoice->get_items() as $item) { |
|
937 | + if (in_array($item->get_id(), $allowed_items)) { |
|
938 | 938 | $invoice_items[] = $item; |
939 | 939 | } |
940 | 940 | } |
941 | 941 | |
942 | - $invoice->set_items( $invoice_items ); |
|
942 | + $invoice->set_items($invoice_items); |
|
943 | 943 | |
944 | - if ( ! empty( $subscription_group['fees'] ) ) { |
|
945 | - $invoice->set_fees( $subscription_group['fees'] ); |
|
944 | + if (!empty($subscription_group['fees'])) { |
|
945 | + $invoice->set_fees($subscription_group['fees']); |
|
946 | 946 | } |
947 | 947 | |
948 | 948 | // Maybe recalculate discount (Pre-GetPaid Fix). |
949 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
950 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
951 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
949 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
950 | + if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) { |
|
951 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
952 | 952 | } |
953 | 953 | |
954 | 954 | $invoice->recalculate_total(); |
955 | - $invoice->set_status( 'wpi-pending' ); |
|
955 | + $invoice->set_status('wpi-pending'); |
|
956 | 956 | $invoice->save(); |
957 | 957 | |
958 | 958 | return $invoice->exists() ? $invoice : false; |
@@ -967,20 +967,20 @@ discard block |
||
967 | 967 | public function renew() { |
968 | 968 | |
969 | 969 | // Complete subscription if applicable |
970 | - if ( $this->is_last_renewal() ) { |
|
970 | + if ($this->is_last_renewal()) { |
|
971 | 971 | return $this->complete(); |
972 | 972 | } |
973 | 973 | |
974 | 974 | // Calculate new expiration |
975 | 975 | $frequency = $this->get_frequency(); |
976 | 976 | $period = $this->get_period(); |
977 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
977 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
978 | 978 | |
979 | - $this->set_expiration( date( 'Y-m-d H:i:s', $new_expiration ) ); |
|
980 | - $this->set_status( 'active' ); |
|
979 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
980 | + $this->set_status('active'); |
|
981 | 981 | $this->save(); |
982 | 982 | |
983 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
983 | + do_action('getpaid_subscription_renewed', $this); |
|
984 | 984 | |
985 | 985 | return $this->get_id(); |
986 | 986 | } |
@@ -996,11 +996,11 @@ discard block |
||
996 | 996 | public function complete() { |
997 | 997 | |
998 | 998 | // Only mark a subscription as complete if it's not already cancelled. |
999 | - if ( $this->has_status( 'cancelled' ) ) { |
|
999 | + if ($this->has_status('cancelled')) { |
|
1000 | 1000 | return false; |
1001 | 1001 | } |
1002 | 1002 | |
1003 | - $this->set_status( 'completed' ); |
|
1003 | + $this->set_status('completed'); |
|
1004 | 1004 | return $this->save(); |
1005 | 1005 | |
1006 | 1006 | } |
@@ -1012,14 +1012,14 @@ discard block |
||
1012 | 1012 | * @param bool $check_expiration |
1013 | 1013 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
1014 | 1014 | */ |
1015 | - public function expire( $check_expiration = false ) { |
|
1015 | + public function expire($check_expiration = false) { |
|
1016 | 1016 | |
1017 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1017 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
1018 | 1018 | // Do not mark as expired since real expiration date is in the future |
1019 | 1019 | return false; |
1020 | 1020 | } |
1021 | 1021 | |
1022 | - $this->set_status( 'expired' ); |
|
1022 | + $this->set_status('expired'); |
|
1023 | 1023 | return $this->save(); |
1024 | 1024 | |
1025 | 1025 | } |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | * @return int Subscription id. |
1032 | 1032 | */ |
1033 | 1033 | public function failing() { |
1034 | - $this->set_status( 'failing' ); |
|
1034 | + $this->set_status('failing'); |
|
1035 | 1035 | return $this->save(); |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | * @return int Subscription id. |
1043 | 1043 | */ |
1044 | 1044 | public function cancel() { |
1045 | - $this->set_status( 'cancelled' ); |
|
1045 | + $this->set_status('cancelled'); |
|
1046 | 1046 | return $this->save(); |
1047 | 1047 | } |
1048 | 1048 | |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | * @return bool |
1054 | 1054 | */ |
1055 | 1055 | public function can_cancel() { |
1056 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1056 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1064,7 +1064,7 @@ discard block |
||
1064 | 1064 | * @return array |
1065 | 1065 | */ |
1066 | 1066 | public function get_cancellable_statuses() { |
1067 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1067 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @return string |
1075 | 1075 | */ |
1076 | 1076 | public function get_cancel_url() { |
1077 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1078 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1077 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
1078 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1086,10 +1086,10 @@ discard block |
||
1086 | 1086 | */ |
1087 | 1087 | public function get_view_url() { |
1088 | 1088 | |
1089 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1090 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
1089 | + $url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
1090 | + $url = add_query_arg('subscription', $this->get_id(), $url); |
|
1091 | 1091 | |
1092 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1092 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
@@ -1102,7 +1102,7 @@ discard block |
||
1102 | 1102 | * @return bool |
1103 | 1103 | */ |
1104 | 1104 | public function can_renew() { |
1105 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1105 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | /** |
@@ -1121,7 +1121,7 @@ discard block |
||
1121 | 1121 | ), |
1122 | 1122 | 'getpaid-nonce' |
1123 | 1123 | ); |
1124 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1124 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1125 | 1125 | } |
1126 | 1126 | |
1127 | 1127 | /** |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @return bool |
1132 | 1132 | */ |
1133 | 1133 | public function can_update() { |
1134 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1134 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1135 | 1135 | } |
1136 | 1136 | |
1137 | 1137 | /** |
@@ -1147,7 +1147,7 @@ discard block |
||
1147 | 1147 | 'subscription_id' => $this->get_id(), |
1148 | 1148 | ) |
1149 | 1149 | ); |
1150 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1150 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1157,7 +1157,7 @@ discard block |
||
1157 | 1157 | * @return string |
1158 | 1158 | */ |
1159 | 1159 | public function get_status_label() { |
1160 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1160 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1161 | 1161 | } |
1162 | 1162 | |
1163 | 1163 | /** |
@@ -1168,7 +1168,7 @@ discard block |
||
1168 | 1168 | */ |
1169 | 1169 | public function get_status_class() { |
1170 | 1170 | $statuses = getpaid_get_subscription_status_classes(); |
1171 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark'; |
|
1171 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark'; |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1179,9 +1179,9 @@ discard block |
||
1179 | 1179 | */ |
1180 | 1180 | public function get_status_label_html() { |
1181 | 1181 | |
1182 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1183 | - $class = esc_attr( $this->get_status_class() ); |
|
1184 | - $status = sanitize_html_class( $this->get_status() ); |
|
1182 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1183 | + $class = esc_attr($this->get_status_class()); |
|
1184 | + $status = sanitize_html_class($this->get_status()); |
|
1185 | 1185 | |
1186 | 1186 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
1187 | 1187 | } |
@@ -1193,9 +1193,9 @@ discard block |
||
1193 | 1193 | * @param string $txn_id The transaction ID from the merchant processor |
1194 | 1194 | * @return bool |
1195 | 1195 | */ |
1196 | - public function payment_exists( $txn_id = '' ) { |
|
1197 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1198 | - return ! empty( $invoice_id ); |
|
1196 | + public function payment_exists($txn_id = '') { |
|
1197 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1198 | + return !empty($invoice_id); |
|
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | /** |
@@ -1207,35 +1207,35 @@ discard block |
||
1207 | 1207 | // Reset status transition variable. |
1208 | 1208 | $this->status_transition = false; |
1209 | 1209 | |
1210 | - if ( $status_transition ) { |
|
1210 | + if ($status_transition) { |
|
1211 | 1211 | try { |
1212 | 1212 | |
1213 | 1213 | // Fire a hook for the status change. |
1214 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1215 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1214 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1215 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1216 | 1216 | |
1217 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1217 | + if (!empty($status_transition['from'])) { |
|
1218 | 1218 | |
1219 | 1219 | /* translators: 1: old subscription status 2: new subscription status */ |
1220 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1220 | + $transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1221 | 1221 | |
1222 | 1222 | // Note the transition occurred. |
1223 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1223 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1224 | 1224 | |
1225 | 1225 | // Fire another hook. |
1226 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1227 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1226 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1227 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
1228 | 1228 | |
1229 | 1229 | } else { |
1230 | 1230 | /* translators: %s: new invoice status */ |
1231 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1231 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1232 | 1232 | |
1233 | 1233 | // Note the transition occurred. |
1234 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1234 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1235 | 1235 | |
1236 | 1236 | } |
1237 | - } catch ( Exception $e ) { |
|
1238 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1237 | + } catch (Exception $e) { |
|
1238 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1239 | 1239 | } |
1240 | 1240 | } |
1241 | 1241 | |
@@ -1261,7 +1261,7 @@ discard block |
||
1261 | 1261 | */ |
1262 | 1262 | public function activate() { |
1263 | 1263 | $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
1264 | - $this->set_status( $status ); |
|
1264 | + $this->set_status($status); |
|
1265 | 1265 | return $this->save(); |
1266 | 1266 | } |
1267 | 1267 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; // Exit if accessed directly |
4 | 4 | } |
5 | 5 | |
@@ -14,18 +14,18 @@ discard block |
||
14 | 14 | * Hook in methods. |
15 | 15 | */ |
16 | 16 | public static function init() { |
17 | - add_action( 'init', array( __CLASS__, 'init_hooks' ), 0 ); |
|
18 | - add_action( 'admin_notices', array( __CLASS__, 'notices' ) ); |
|
17 | + add_action('init', array(__CLASS__, 'init_hooks'), 0); |
|
18 | + add_action('admin_notices', array(__CLASS__, 'notices')); |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public static function init_hooks() { |
22 | - if ( false === ( $page_uris = get_transient( 'wpinv_cache_excluded_uris' ) ) ) { |
|
23 | - $checkout_page = wpinv_get_option( 'checkout_page', '' ); |
|
24 | - $success_page = wpinv_get_option( 'success_page', '' ); |
|
25 | - $failure_page = wpinv_get_option( 'failure_page', '' ); |
|
26 | - $history_page = wpinv_get_option( 'invoice_history_page', '' ); |
|
27 | - $subscr_page = wpinv_get_option( 'invoice_subscription_page', '' ); |
|
28 | - if ( empty( $checkout_page ) || empty( $success_page ) || empty( $failure_page ) || empty( $history_page ) || empty( $subscr_page ) ) { |
|
22 | + if (false === ($page_uris = get_transient('wpinv_cache_excluded_uris'))) { |
|
23 | + $checkout_page = wpinv_get_option('checkout_page', ''); |
|
24 | + $success_page = wpinv_get_option('success_page', ''); |
|
25 | + $failure_page = wpinv_get_option('failure_page', ''); |
|
26 | + $history_page = wpinv_get_option('invoice_history_page', ''); |
|
27 | + $subscr_page = wpinv_get_option('invoice_subscription_page', ''); |
|
28 | + if (empty($checkout_page) || empty($success_page) || empty($failure_page) || empty($history_page) || empty($subscr_page)) { |
|
29 | 29 | return; |
30 | 30 | } |
31 | 31 | |
@@ -39,34 +39,34 @@ discard block |
||
39 | 39 | $page_uris[] = 'p=' . $subscr_page; |
40 | 40 | |
41 | 41 | // Exclude permalinks |
42 | - $checkout_page = get_post( $checkout_page ); |
|
43 | - $success_page = get_post( $success_page ); |
|
44 | - $failure_page = get_post( $failure_page ); |
|
45 | - $history_page = get_post( $history_page ); |
|
46 | - $subscr_page = get_post( $subscr_page ); |
|
42 | + $checkout_page = get_post($checkout_page); |
|
43 | + $success_page = get_post($success_page); |
|
44 | + $failure_page = get_post($failure_page); |
|
45 | + $history_page = get_post($history_page); |
|
46 | + $subscr_page = get_post($subscr_page); |
|
47 | 47 | |
48 | - if ( ! is_null( $checkout_page ) ) { |
|
48 | + if (!is_null($checkout_page)) { |
|
49 | 49 | $page_uris[] = '/' . $checkout_page->post_name; |
50 | 50 | } |
51 | - if ( ! is_null( $success_page ) ) { |
|
51 | + if (!is_null($success_page)) { |
|
52 | 52 | $page_uris[] = '/' . $success_page->post_name; |
53 | 53 | } |
54 | - if ( ! is_null( $failure_page ) ) { |
|
54 | + if (!is_null($failure_page)) { |
|
55 | 55 | $page_uris[] = '/' . $failure_page->post_name; |
56 | 56 | } |
57 | - if ( ! is_null( $history_page ) ) { |
|
57 | + if (!is_null($history_page)) { |
|
58 | 58 | $page_uris[] = '/' . $history_page->post_name; |
59 | 59 | } |
60 | - if ( ! is_null( $subscr_page ) ) { |
|
60 | + if (!is_null($subscr_page)) { |
|
61 | 61 | $page_uris[] = '/' . $subscr_page->post_name; |
62 | 62 | } |
63 | 63 | |
64 | - set_transient( 'wpinv_cache_excluded_uris', $page_uris ); |
|
64 | + set_transient('wpinv_cache_excluded_uris', $page_uris); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ( is_array( $page_uris ) ) { |
|
68 | - foreach ( $page_uris as $uri ) { |
|
69 | - if ( strstr( $_SERVER['REQUEST_URI'], $uri ) ) { |
|
67 | + if (is_array($page_uris)) { |
|
68 | + foreach ($page_uris as $uri) { |
|
69 | + if (strstr($_SERVER['REQUEST_URI'], $uri)) { |
|
70 | 70 | self::nocache(); |
71 | 71 | break; |
72 | 72 | } |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * @access private |
80 | 80 | */ |
81 | 81 | private static function nocache() { |
82 | - if ( ! defined( 'DONOTCACHEPAGE' ) ) { |
|
83 | - define( 'DONOTCACHEPAGE', true ); |
|
82 | + if (!defined('DONOTCACHEPAGE')) { |
|
83 | + define('DONOTCACHEPAGE', true); |
|
84 | 84 | } |
85 | - if ( ! defined( 'DONOTCACHEOBJECT' ) ) { |
|
86 | - define( 'DONOTCACHEOBJECT', true ); |
|
85 | + if (!defined('DONOTCACHEOBJECT')) { |
|
86 | + define('DONOTCACHEOBJECT', true); |
|
87 | 87 | } |
88 | - if ( ! defined( 'DONOTCACHEDB' ) ) { |
|
89 | - define( 'DONOTCACHEDB', true ); |
|
88 | + if (!defined('DONOTCACHEDB')) { |
|
89 | + define('DONOTCACHEDB', true); |
|
90 | 90 | } |
91 | 91 | nocache_headers(); |
92 | 92 | } |
@@ -95,18 +95,18 @@ discard block |
||
95 | 95 | * notices function. |
96 | 96 | */ |
97 | 97 | public static function notices() { |
98 | - if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) { |
|
98 | + if (!function_exists('w3tc_pgcache_flush') || !function_exists('w3_instance')) { |
|
99 | 99 | return; |
100 | 100 | } |
101 | 101 | |
102 | - $config = w3_instance( 'W3_Config' ); |
|
103 | - $enabled = $config->get_integer( 'dbcache.enabled' ); |
|
104 | - $settings = array_map( 'trim', $config->get_array( 'dbcache.reject.sql' ) ); |
|
102 | + $config = w3_instance('W3_Config'); |
|
103 | + $enabled = $config->get_integer('dbcache.enabled'); |
|
104 | + $settings = array_map('trim', $config->get_array('dbcache.reject.sql')); |
|
105 | 105 | |
106 | - if ( $enabled && ! in_array( '_wp_session_', $settings ) ) { |
|
106 | + if ($enabled && !in_array('_wp_session_', $settings)) { |
|
107 | 107 | ?> |
108 | 108 | <div class="error"> |
109 | - <p><?php printf( __( 'In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing' ), '<code>_wp_session_</code>', admin_url( 'admin.php?page=w3tc_dbcache' ) ); ?></p> |
|
109 | + <p><?php printf(__('In order for <strong>database caching</strong> to work with Invoicing you must add %1$s to the "Ignored Query Strings" option in <a href="%2$s">W3 Total Cache settings</a>.', 'invoicing'), '<code>_wp_session_</code>', admin_url('admin.php?page=w3tc_dbcache')); ?></p> |
|
110 | 110 | </div> |
111 | 111 | <?php |
112 | 112 | } |