@@ -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,8 +40,8 @@ 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 ), |
|
43 | + 'to' => array_filter(array_unique(wpinv_parse_list($to))), |
|
44 | + 'subject' => htmlspecialchars_decode(strip_tags($subject), ENT_QUOTES), |
|
45 | 45 | 'email' => $email, |
46 | 46 | 'headers' => $this->get_headers(), |
47 | 47 | 'attachments' => $attachments, |
@@ -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: %s\nTo: %s\nSubject: %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: %s\nTo: %s\nSubject: %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,10 +152,10 @@ 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 ) ) { |
|
158 | - $from_address = $this->default_from_address(); |
|
157 | + if (!is_email($from_address)) { |
|
158 | + $from_address = $this->default_from_address(); |
|
159 | 159 | } |
160 | 160 | |
161 | 161 | return $from_address; |
@@ -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' ), 1000000 ); |
|
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'), 1000000); |
|
234 | 234 | |
235 | 235 | } |
236 | 236 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -72,28 +72,28 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
74 | 74 | */ |
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
75 | + public function __construct($form = 0) { |
|
76 | + parent::__construct($form); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if (is_numeric($form) && $form > 0) { |
|
79 | + $this->set_id($form); |
|
80 | + } elseif ($form instanceof self) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
82 | + $this->set_id($form->get_id()); |
|
83 | 83 | $this->invoice = $form->invoice; |
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
85 | + } elseif (!empty($form->ID)) { |
|
86 | + $this->set_id($form->ID); |
|
87 | 87 | } else { |
88 | - $this->set_object_read( true ); |
|
88 | + $this->set_object_read(true); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
95 | - $this->post = get_post( $this->get_id() ); |
|
96 | - $this->data_store->read( $this ); |
|
94 | + if ($this->get_id() > 0) { |
|
95 | + $this->post = get_post($this->get_id()); |
|
96 | + $this->data_store->read($this); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | } |
@@ -120,8 +120,8 @@ discard block |
||
120 | 120 | * @param string $context View or edit context. |
121 | 121 | * @return string |
122 | 122 | */ |
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
123 | + public function get_version($context = 'view') { |
|
124 | + return $this->get_prop('version', $context); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * @param string $context View or edit context. |
132 | 132 | * @return string |
133 | 133 | */ |
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
134 | + public function get_date_created($context = 'view') { |
|
135 | + return $this->get_prop('date_created', $context); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -142,11 +142,11 @@ discard block |
||
142 | 142 | * @param string $context View or edit context. |
143 | 143 | * @return string |
144 | 144 | */ |
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
146 | - $date = $this->get_date_created( $context ); |
|
145 | + public function get_date_created_gmt($context = 'view') { |
|
146 | + $date = $this->get_date_created($context); |
|
147 | 147 | |
148 | - if ( $date ) { |
|
149 | - $date = get_gmt_from_date( $date ); |
|
148 | + if ($date) { |
|
149 | + $date = get_gmt_from_date($date); |
|
150 | 150 | } |
151 | 151 | return $date; |
152 | 152 | } |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param string $context View or edit context. |
159 | 159 | * @return string |
160 | 160 | */ |
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
161 | + public function get_date_modified($context = 'view') { |
|
162 | + return $this->get_prop('date_modified', $context); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | * @param string $context View or edit context. |
170 | 170 | * @return string |
171 | 171 | */ |
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | - $date = $this->get_date_modified( $context ); |
|
172 | + public function get_date_modified_gmt($context = 'view') { |
|
173 | + $date = $this->get_date_modified($context); |
|
174 | 174 | |
175 | - if ( $date ) { |
|
176 | - $date = get_gmt_from_date( $date ); |
|
175 | + if ($date) { |
|
176 | + $date = get_gmt_from_date($date); |
|
177 | 177 | } |
178 | 178 | return $date; |
179 | 179 | } |
@@ -185,8 +185,8 @@ discard block |
||
185 | 185 | * @param string $context View or edit context. |
186 | 186 | * @return string |
187 | 187 | */ |
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
188 | + public function get_name($context = 'view') { |
|
189 | + return $this->get_prop('name', $context); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
@@ -196,8 +196,8 @@ discard block |
||
196 | 196 | * @param string $context View or edit context. |
197 | 197 | * @return string |
198 | 198 | */ |
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
199 | + public function get_title($context = 'view') { |
|
200 | + return $this->get_name($context); |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | /** |
@@ -207,8 +207,8 @@ discard block |
||
207 | 207 | * @param string $context View or edit context. |
208 | 208 | * @return int |
209 | 209 | */ |
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
210 | + public function get_author($context = 'view') { |
|
211 | + return (int) $this->get_prop('author', $context); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
@@ -218,21 +218,21 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return array |
220 | 220 | */ |
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
221 | + public function get_elements($context = 'view') { |
|
222 | + $elements = $this->get_prop('elements', $context); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | - return wpinv_get_data( 'sample-payment-form' ); |
|
224 | + if (empty($elements) || !is_array($elements)) { |
|
225 | + return wpinv_get_data('sample-payment-form'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | // Ensure that all required elements exist. |
229 | 229 | $_elements = array(); |
230 | - foreach ( $elements as $element ) { |
|
230 | + foreach ($elements as $element) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ($element['type'] == 'pay_button' && !$this->has_element_type('gateway_select')) { |
|
233 | 233 | |
234 | 234 | $_elements[] = array( |
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
235 | + 'text' => __('Select Payment Method', 'invoicing'), |
|
236 | 236 | 'id' => 'gtscicd', |
237 | 237 | 'name' => 'gtscicd', |
238 | 238 | 'type' => 'gateway_select', |
@@ -257,22 +257,22 @@ discard block |
||
257 | 257 | * @param string $return objects or arrays. |
258 | 258 | * @return GetPaid_Form_Item[] |
259 | 259 | */ |
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
260 | + public function get_items($context = 'view', $return = 'objects') { |
|
261 | + $items = $this->get_prop('items', $context); |
|
262 | 262 | |
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | - $items = wpinv_get_data( 'sample-payment-form-items' ); |
|
263 | + if (empty($items) || !is_array($items)) { |
|
264 | + $items = wpinv_get_data('sample-payment-form-items'); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Convert the items. |
268 | 268 | $prepared = array(); |
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ($items as $key => $value) { |
|
271 | 271 | |
272 | 272 | // Form items. |
273 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | + if ($value instanceof GetPaid_Form_Item) { |
|
274 | 274 | |
275 | - if ( $value->can_purchase() ) { |
|
275 | + if ($value->can_purchase()) { |
|
276 | 276 | $prepared[] = $value; |
277 | 277 | } |
278 | 278 | |
@@ -281,16 +281,16 @@ discard block |
||
281 | 281 | } |
282 | 282 | |
283 | 283 | // $item_id => $quantity (buy buttons) |
284 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
285 | - $item = new GetPaid_Form_Item( $key ); |
|
284 | + if (is_numeric($key) && is_numeric($value)) { |
|
285 | + $item = new GetPaid_Form_Item($key); |
|
286 | 286 | |
287 | - if ( $item->can_purchase() ) { |
|
287 | + if ($item->can_purchase()) { |
|
288 | 288 | |
289 | 289 | $value = (int) $value; |
290 | - $item->set_quantity( $value ); |
|
291 | - if ( 0 == $value ) { |
|
292 | - $item->set_quantity( 1 ); |
|
293 | - $item->set_allow_quantities( true ); |
|
290 | + $item->set_quantity($value); |
|
291 | + if (0 == $value) { |
|
292 | + $item->set_quantity(1); |
|
293 | + $item->set_allow_quantities(true); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | $prepared[] = $item; |
@@ -300,33 +300,33 @@ discard block |
||
300 | 300 | } |
301 | 301 | |
302 | 302 | // Items saved via payment forms editor. |
303 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
303 | + if (is_array($value) && isset($value['id'])) { |
|
304 | 304 | |
305 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
305 | + $item = new GetPaid_Form_Item($value['id']); |
|
306 | 306 | |
307 | - if ( ! $item->can_purchase() ) { |
|
307 | + if (!$item->can_purchase()) { |
|
308 | 308 | continue; |
309 | 309 | } |
310 | 310 | |
311 | 311 | // Sub-total (Cart items). |
312 | - if ( isset( $value['subtotal'] ) ) { |
|
313 | - $item->set_price( $value['subtotal'] ); |
|
312 | + if (isset($value['subtotal'])) { |
|
313 | + $item->set_price($value['subtotal']); |
|
314 | 314 | } |
315 | 315 | |
316 | - if ( isset( $value['quantity'] ) ) { |
|
317 | - $item->set_quantity( $value['quantity'] ); |
|
316 | + if (isset($value['quantity'])) { |
|
317 | + $item->set_quantity($value['quantity']); |
|
318 | 318 | } |
319 | 319 | |
320 | - if ( isset( $value['allow_quantities'] ) ) { |
|
321 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
320 | + if (isset($value['allow_quantities'])) { |
|
321 | + $item->set_allow_quantities($value['allow_quantities']); |
|
322 | 322 | } |
323 | 323 | |
324 | - if ( isset( $value['required'] ) ) { |
|
325 | - $item->set_is_required( $value['required'] ); |
|
324 | + if (isset($value['required'])) { |
|
325 | + $item->set_is_required($value['required']); |
|
326 | 326 | } |
327 | 327 | |
328 | - if ( isset( $value['description'] ) ) { |
|
329 | - $item->set_custom_description( $value['description'] ); |
|
328 | + if (isset($value['description'])) { |
|
329 | + $item->set_custom_description($value['description']); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $prepared[] = $item; |
@@ -335,14 +335,14 @@ discard block |
||
335 | 335 | } |
336 | 336 | |
337 | 337 | // $item_id => array( 'price' => 10 ) (item variations) |
338 | - if ( is_numeric( $key ) && is_array( $value ) ) { |
|
339 | - $item = new GetPaid_Form_Item( $key ); |
|
338 | + if (is_numeric($key) && is_array($value)) { |
|
339 | + $item = new GetPaid_Form_Item($key); |
|
340 | 340 | |
341 | - if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) { |
|
342 | - $item->set_price( $value['price'] ); |
|
341 | + if (isset($value['price']) && $item->user_can_set_their_price()) { |
|
342 | + $item->set_price($value['price']); |
|
343 | 343 | } |
344 | 344 | |
345 | - if ( $item->can_purchase() ) { |
|
345 | + if ($item->can_purchase()) { |
|
346 | 346 | $prepared[] = $item; |
347 | 347 | } |
348 | 348 | |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | |
352 | 352 | } |
353 | 353 | |
354 | - if ( 'objects' == $return && 'view' == $context ) { |
|
354 | + if ('objects' == $return && 'view' == $context) { |
|
355 | 355 | return $prepared; |
356 | 356 | } |
357 | 357 | |
358 | 358 | $items = array(); |
359 | - foreach ( $prepared as $item ) { |
|
359 | + foreach ($prepared as $item) { |
|
360 | 360 | $items[] = $item->prepare_data_for_use(); |
361 | 361 | } |
362 | 362 | |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | * @param int $item_id The item id to return. |
371 | 371 | * @return GetPaid_Form_Item|bool |
372 | 372 | */ |
373 | - public function get_item( $item_id ) { |
|
373 | + public function get_item($item_id) { |
|
374 | 374 | |
375 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
375 | + if (empty($item_id) || !is_numeric($item_id)) { |
|
376 | 376 | return false; |
377 | 377 | } |
378 | 378 | |
379 | - foreach( $this->get_items() as $item ) { |
|
380 | - if ( $item->get_id() == (int) $item_id ) { |
|
379 | + foreach ($this->get_items() as $item) { |
|
380 | + if ($item->get_id() == (int) $item_id) { |
|
381 | 381 | return $item; |
382 | 382 | } |
383 | 383 | } |
@@ -393,15 +393,15 @@ discard block |
||
393 | 393 | * @param string $element_type The element type to return. |
394 | 394 | * @return array|bool |
395 | 395 | */ |
396 | - public function get_element_type( $element_type ) { |
|
396 | + public function get_element_type($element_type) { |
|
397 | 397 | |
398 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
398 | + if (empty($element_type) || !is_scalar($element_type)) { |
|
399 | 399 | return false; |
400 | 400 | } |
401 | 401 | |
402 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
402 | + foreach ($this->get_prop('elements') as $element) { |
|
403 | 403 | |
404 | - if ( $element['type'] == $element_type ) { |
|
404 | + if ($element['type'] == $element_type) { |
|
405 | 405 | return $element; |
406 | 406 | } |
407 | 407 | |
@@ -418,8 +418,8 @@ discard block |
||
418 | 418 | * @param string $context View or edit context. |
419 | 419 | * @return array |
420 | 420 | */ |
421 | - public function get_earned( $context = 'view' ) { |
|
422 | - return $this->get_prop( 'earned', $context ); |
|
421 | + public function get_earned($context = 'view') { |
|
422 | + return $this->get_prop('earned', $context); |
|
423 | 423 | } |
424 | 424 | |
425 | 425 | /** |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * @param string $context View or edit context. |
430 | 430 | * @return array |
431 | 431 | */ |
432 | - public function get_refunded( $context = 'view' ) { |
|
433 | - return $this->get_prop( 'refunded', $context ); |
|
432 | + public function get_refunded($context = 'view') { |
|
433 | + return $this->get_prop('refunded', $context); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $context View or edit context. |
441 | 441 | * @return array |
442 | 442 | */ |
443 | - public function get_cancelled( $context = 'view' ) { |
|
444 | - return $this->get_prop( 'cancelled', $context ); |
|
443 | + public function get_cancelled($context = 'view') { |
|
444 | + return $this->get_prop('cancelled', $context); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | * @param string $context View or edit context. |
452 | 452 | * @return array |
453 | 453 | */ |
454 | - public function get_failed( $context = 'view' ) { |
|
455 | - return $this->get_prop( 'failed', $context ); |
|
454 | + public function get_failed($context = 'view') { |
|
455 | + return $this->get_prop('failed', $context); |
|
456 | 456 | } |
457 | 457 | |
458 | 458 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * @return string |
464 | 464 | */ |
465 | 465 | public function get_currency() { |
466 | - $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | - return apply_filters( 'getpaid-payment-form-currency', $currency, $this ); |
|
466 | + $currency = empty($this->invoice) ? wpinv_get_currency() : $this->invoice->get_currency(); |
|
467 | + return apply_filters('getpaid-payment-form-currency', $currency, $this); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /* |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * |
483 | 483 | * @since 1.0.19 |
484 | 484 | */ |
485 | - public function set_version( $value ) { |
|
486 | - $this->set_prop( 'version', $value ); |
|
485 | + public function set_version($value) { |
|
486 | + $this->set_prop('version', $value); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,11 +493,11 @@ discard block |
||
493 | 493 | * @param string $value Value to set. |
494 | 494 | * @return bool Whether or not the date was set. |
495 | 495 | */ |
496 | - public function set_date_created( $value ) { |
|
497 | - $date = strtotime( $value ); |
|
496 | + public function set_date_created($value) { |
|
497 | + $date = strtotime($value); |
|
498 | 498 | |
499 | - if ( $date ) { |
|
500 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
499 | + if ($date) { |
|
500 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
501 | 501 | return true; |
502 | 502 | } |
503 | 503 | |
@@ -512,11 +512,11 @@ discard block |
||
512 | 512 | * @param string $value Value to set. |
513 | 513 | * @return bool Whether or not the date was set. |
514 | 514 | */ |
515 | - public function set_date_modified( $value ) { |
|
516 | - $date = strtotime( $value ); |
|
515 | + public function set_date_modified($value) { |
|
516 | + $date = strtotime($value); |
|
517 | 517 | |
518 | - if ( $date ) { |
|
519 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
518 | + if ($date) { |
|
519 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
520 | 520 | return true; |
521 | 521 | } |
522 | 522 | |
@@ -530,8 +530,8 @@ discard block |
||
530 | 530 | * @since 1.0.19 |
531 | 531 | * @param string $value New name. |
532 | 532 | */ |
533 | - public function set_name( $value ) { |
|
534 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
533 | + public function set_name($value) { |
|
534 | + $this->set_prop('name', sanitize_text_field($value)); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | /** |
@@ -540,8 +540,8 @@ discard block |
||
540 | 540 | * @since 1.0.19 |
541 | 541 | * @param string $value New name. |
542 | 542 | */ |
543 | - public function set_title( $value ) { |
|
544 | - $this->set_name( $value ); |
|
543 | + public function set_title($value) { |
|
544 | + $this->set_name($value); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | /** |
@@ -550,8 +550,8 @@ discard block |
||
550 | 550 | * @since 1.0.19 |
551 | 551 | * @param int $value New author. |
552 | 552 | */ |
553 | - public function set_author( $value ) { |
|
554 | - $this->set_prop( 'author', (int) $value ); |
|
553 | + public function set_author($value) { |
|
554 | + $this->set_prop('author', (int) $value); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | /** |
@@ -560,9 +560,9 @@ discard block |
||
560 | 560 | * @since 1.0.19 |
561 | 561 | * @param array $value Form elements. |
562 | 562 | */ |
563 | - public function set_elements( $value ) { |
|
564 | - if ( is_array( $value ) ) { |
|
565 | - $this->set_prop( 'elements', $value ); |
|
563 | + public function set_elements($value) { |
|
564 | + if (is_array($value)) { |
|
565 | + $this->set_prop('elements', $value); |
|
566 | 566 | } |
567 | 567 | } |
568 | 568 | |
@@ -572,9 +572,9 @@ discard block |
||
572 | 572 | * @since 1.0.19 |
573 | 573 | * @param array $value Form elements. |
574 | 574 | */ |
575 | - public function set_items( $value ) { |
|
576 | - if ( is_array( $value ) ) { |
|
577 | - $this->set_prop( 'items', $value ); |
|
575 | + public function set_items($value) { |
|
576 | + if (is_array($value)) { |
|
577 | + $this->set_prop('items', $value); |
|
578 | 578 | } |
579 | 579 | } |
580 | 580 | |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * @since 1.0.19 |
585 | 585 | * @param float $value Amount earned. |
586 | 586 | */ |
587 | - public function set_earned( $value ) { |
|
588 | - $value = max( (float) $value, 0 ); |
|
589 | - $this->set_prop( 'earned', $value ); |
|
587 | + public function set_earned($value) { |
|
588 | + $value = max((float) $value, 0); |
|
589 | + $this->set_prop('earned', $value); |
|
590 | 590 | } |
591 | 591 | |
592 | 592 | /** |
@@ -595,9 +595,9 @@ discard block |
||
595 | 595 | * @since 1.0.19 |
596 | 596 | * @param float $value Amount refunded. |
597 | 597 | */ |
598 | - public function set_refunded( $value ) { |
|
599 | - $value = max( (float) $value, 0 ); |
|
600 | - $this->set_prop( 'refunded', $value ); |
|
598 | + public function set_refunded($value) { |
|
599 | + $value = max((float) $value, 0); |
|
600 | + $this->set_prop('refunded', $value); |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | * @param float $value Amount cancelled. |
608 | 608 | */ |
609 | - public function set_cancelled( $value ) { |
|
610 | - $value = max( (float) $value, 0 ); |
|
611 | - $this->set_prop( 'cancelled', $value ); |
|
609 | + public function set_cancelled($value) { |
|
610 | + $value = max((float) $value, 0); |
|
611 | + $this->set_prop('cancelled', $value); |
|
612 | 612 | } |
613 | 613 | |
614 | 614 | /** |
@@ -617,9 +617,9 @@ discard block |
||
617 | 617 | * @since 1.0.19 |
618 | 618 | * @param float $value Amount cancelled. |
619 | 619 | */ |
620 | - public function set_failed( $value ) { |
|
621 | - $value = max( (float) $value, 0 ); |
|
622 | - $this->set_prop( 'failed', $value ); |
|
620 | + public function set_failed($value) { |
|
621 | + $value = max((float) $value, 0); |
|
622 | + $this->set_prop('failed', $value); |
|
623 | 623 | } |
624 | 624 | |
625 | 625 | /** |
@@ -628,11 +628,11 @@ discard block |
||
628 | 628 | * @deprecated |
629 | 629 | * @return int item id |
630 | 630 | */ |
631 | - public function create( $data = array() ) { |
|
631 | + public function create($data = array()) { |
|
632 | 632 | |
633 | 633 | // Set the properties. |
634 | - if ( is_array( $data ) ) { |
|
635 | - $this->set_props( $data ); |
|
634 | + if (is_array($data)) { |
|
635 | + $this->set_props($data); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | // Save the item. |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | * @deprecated |
647 | 647 | * @return int item id |
648 | 648 | */ |
649 | - public function update( $data = array() ) { |
|
650 | - return $this->create( $data ); |
|
649 | + public function update($data = array()) { |
|
650 | + return $this->create($data); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | /* |
@@ -667,7 +667,7 @@ discard block |
||
667 | 667 | */ |
668 | 668 | public function is_default() { |
669 | 669 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
670 | - return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
|
670 | + return (bool) apply_filters('wpinv_is_default_payment_form', $is_default, $this->get_id(), $this); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -679,11 +679,11 @@ discard block |
||
679 | 679 | public function is_active() { |
680 | 680 | $is_active = 0 !== (int) $this->get_id(); |
681 | 681 | |
682 | - if ( $is_active && ! current_user_can( 'edit_post', $this->get_id() ) && $this->get_status() != 'publish' ) { |
|
682 | + if ($is_active && !current_user_can('edit_post', $this->get_id()) && $this->get_status() != 'publish') { |
|
683 | 683 | $is_active = false; |
684 | 684 | } |
685 | 685 | |
686 | - return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
|
686 | + return (bool) apply_filters('wpinv_is_payment_form_active', $is_active, $this); |
|
687 | 687 | } |
688 | 688 | |
689 | 689 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | * @since 1.0.19 |
693 | 693 | * @return bool |
694 | 694 | */ |
695 | - public function has_item( $item_id ) { |
|
696 | - return false !== $this->get_item( $item_id ); |
|
695 | + public function has_item($item_id) { |
|
696 | + return false !== $this->get_item($item_id); |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | /** |
@@ -702,8 +702,8 @@ discard block |
||
702 | 702 | * @since 1.0.19 |
703 | 703 | * @return bool |
704 | 704 | */ |
705 | - public function has_element_type( $element_type ) { |
|
706 | - return false !== $this->get_element_type( $element_type ); |
|
705 | + public function has_element_type($element_type) { |
|
706 | + return false !== $this->get_element_type($element_type); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -714,13 +714,13 @@ discard block |
||
714 | 714 | */ |
715 | 715 | public function is_recurring() { |
716 | 716 | |
717 | - if ( ! empty( $this->invoice ) ) { |
|
717 | + if (!empty($this->invoice)) { |
|
718 | 718 | return $this->invoice->is_recurring(); |
719 | 719 | } |
720 | 720 | |
721 | - foreach ( $this->get_items() as $item ) { |
|
721 | + foreach ($this->get_items() as $item) { |
|
722 | 722 | |
723 | - if ( $item->is_recurring() ) { |
|
723 | + if ($item->is_recurring()) { |
|
724 | 724 | return true; |
725 | 725 | } |
726 | 726 | |
@@ -734,7 +734,7 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @since 1.0.19 |
736 | 736 | */ |
737 | - public function get_html( $extra_markup = '' ) { |
|
737 | + public function get_html($extra_markup = '') { |
|
738 | 738 | |
739 | 739 | // Return the HTML. |
740 | 740 | return wpinv_get_template_html( |
@@ -752,8 +752,8 @@ discard block |
||
752 | 752 | * |
753 | 753 | * @since 1.0.19 |
754 | 754 | */ |
755 | - public function display( $extra_markup = '' ) { |
|
756 | - echo $this->get_html( $extra_markup ); |
|
755 | + public function display($extra_markup = '') { |
|
756 | + echo $this->get_html($extra_markup); |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_item_type form-group row"> |
35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
36 | - <?php _e( 'Item Type', 'invoicing' );?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags( self::get_tooltip( $post ) ); ?>"></span> |
|
36 | + <?php _e('Item Type', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo strip_tags(self::get_tooltip($post)); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'id' => 'wpinv_item_type', |
46 | 46 | 'name' => 'wpinv_item_type', |
47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
48 | - 'value' => $item->get_type( 'edit' ), |
|
47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
48 | + 'value' => $item->get_type('edit'), |
|
49 | 49 | 'select2' => true, |
50 | 50 | 'data-allow-clear' => 'false', |
51 | 51 | 'no_wrap' => true, |
@@ -59,38 +59,38 @@ discard block |
||
59 | 59 | |
60 | 60 | <div class="wpinv_item_shortcode form-group row"> |
61 | 61 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
62 | - <?php _e( 'Payment Form Shortcode', 'invoicing' );?> |
|
63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
62 | + <?php _e('Payment Form Shortcode', 'invoicing'); ?> |
|
63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
64 | 64 | </label> |
65 | 65 | |
66 | 66 | <div class="col-sm-12"> |
67 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
|
67 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
71 | 71 | <div class="wpinv_item_buy_shortcode form-group row"> |
72 | 72 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
73 | - <?php _e( 'Payment Button Shortcode', 'invoicing' );?> |
|
74 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
73 | + <?php _e('Payment Button Shortcode', 'invoicing'); ?> |
|
74 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
75 | 75 | </label> |
76 | 76 | |
77 | 77 | <div class="col-sm-12"> |
78 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
78 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
79 | 79 | </div> |
80 | 80 | </div> |
81 | 81 | |
82 | 82 | <div class="wpinv_item_custom_id form-group"> |
83 | - <?php _e( 'Custom ID', 'invoicing' );?> — <?php echo sanitize_text_field( $item->get_custom_id() ) ?> |
|
83 | + <?php _e('Custom ID', 'invoicing'); ?> — <?php echo sanitize_text_field($item->get_custom_id()) ?> |
|
84 | 84 | </div> |
85 | 85 | |
86 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
87 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
86 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
87 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
88 | 88 | <div class="wpinv_item_custom_id form-group"> |
89 | - <?php sanitize_text_field( $meta_key );?> — <?php echo sanitize_text_field( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
89 | + <?php sanitize_text_field($meta_key); ?> — <?php echo sanitize_text_field(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
90 | 90 | </div> |
91 | 91 | <?php endforeach; ?> |
92 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
93 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
92 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
93 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
94 | 94 | </div> |
95 | 95 | <?php |
96 | 96 | |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | * Returns item type tolltip. |
101 | 101 | * |
102 | 102 | */ |
103 | - public static function get_tooltip( $post ) { |
|
103 | + public static function get_tooltip($post) { |
|
104 | 104 | |
105 | 105 | ob_start(); |
106 | 106 | ?> |
107 | 107 | |
108 | - <?php _e( 'Standard: Standard item type', 'invoicing' );?> |
|
109 | - <?php _e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' );?> |
|
108 | + <?php _e('Standard: Standard item type', 'invoicing'); ?> |
|
109 | + <?php _e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?> |
|
110 | 110 | |
111 | 111 | <?php |
112 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
112 | + do_action('wpinv_item_info_metabox_after', $post); |
|
113 | 113 | |
114 | 114 | return ob_get_clean(); |
115 | 115 |
@@ -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 | * Payment form submission itemss class |
@@ -23,26 +23,26 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $data = $submission->get_data(); |
29 | 29 | $payment_form = $submission->get_payment_form(); |
30 | 30 | |
31 | 31 | // Prepare the selected items. |
32 | 32 | $selected_items = array(); |
33 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
34 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
33 | + if (!empty($data['getpaid-items'])) { |
|
34 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | // For default forms, ensure that an item has been set. |
38 | - if ( $payment_form->is_default() && ! $submission->has_invoice() && isset( $data['getpaid-form-items'] ) ) { |
|
39 | - $form_items = wpinv_clean( $data['getpaid-form-items'] ); |
|
40 | - $payment_form->set_items( getpaid_convert_items_to_array( $form_items ) ); |
|
38 | + if ($payment_form->is_default() && !$submission->has_invoice() && isset($data['getpaid-form-items'])) { |
|
39 | + $form_items = wpinv_clean($data['getpaid-form-items']); |
|
40 | + $payment_form->set_items(getpaid_convert_items_to_array($form_items)); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Process each individual item. |
44 | - foreach ( $payment_form->get_items() as $item ) { |
|
45 | - $this->process_item( $item, $selected_items ); |
|
44 | + foreach ($payment_form->get_items() as $item) { |
|
45 | + $this->process_item($item, $selected_items); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | } |
@@ -53,30 +53,30 @@ discard block |
||
53 | 53 | * @param GetPaid_Form_Item $item |
54 | 54 | * @param array $selected_items |
55 | 55 | */ |
56 | - public function process_item( $item, $selected_items ) { |
|
56 | + public function process_item($item, $selected_items) { |
|
57 | 57 | |
58 | 58 | // Abort if this is an optional item and it has not been selected. |
59 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
59 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
60 | 60 | return; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // (maybe) let customers change the quantities and prices. |
64 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
64 | + if (isset($selected_items[$item->get_id()])) { |
|
65 | 65 | |
66 | 66 | // Maybe change the quantities. |
67 | - if ( $item->allows_quantities() ) { |
|
68 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
67 | + if ($item->allows_quantities()) { |
|
68 | + $item->set_quantity((int) $selected_items[$item->get_id()]['quantity']); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | // Maybe change the price. |
72 | - if ( $item->user_can_set_their_price() ) { |
|
73 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
72 | + if ($item->user_can_set_their_price()) { |
|
73 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
74 | 74 | |
75 | - if ( $item->get_minimum_price() > $price ) { |
|
76 | - throw new Exception( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), wpinv_sanitize_amount( $item->get_minimum_price() ) ) ); |
|
75 | + if ($item->get_minimum_price() > $price) { |
|
76 | + throw new Exception(sprintf(__('The minimum allowed amount is %s', 'invoicing'), wpinv_sanitize_amount($item->get_minimum_price()))); |
|
77 | 77 | } |
78 | 78 | |
79 | - $item->set_price( $price ); |
|
79 | + $item->set_price($price); |
|
80 | 80 | |
81 | 81 | } |
82 | 82 |
@@ -7,80 +7,80 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
12 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
13 | 13 | |
14 | 14 | $currency = $form->get_currency(); |
15 | 15 | |
16 | 16 | ?> |
17 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
17 | +<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?>'> |
|
18 | 18 | <div class="form-row"> |
19 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
20 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?> getpaid-form-cart-item-<?php echo esc_attr( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
19 | + <?php foreach ($columns as $key => $label) : ?> |
|
20 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-5' : 'col-12 col-sm' ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?> getpaid-form-cart-item-<?php echo esc_attr($key); ?>-<?php echo $item->get_id(); ?>"> |
|
21 | 21 | <?php |
22 | 22 | |
23 | 23 | // Item name. |
24 | - if ( 'name' == $key ) { |
|
25 | - echo sanitize_text_field( $item->get_name() ); |
|
24 | + if ('name' == $key) { |
|
25 | + echo sanitize_text_field($item->get_name()); |
|
26 | 26 | $description = $item->get_description(); |
27 | 27 | |
28 | - if ( ! empty( $description ) ) { |
|
29 | - $description = wp_kses_post( $description ); |
|
28 | + if (!empty($description)) { |
|
29 | + $description = wp_kses_post($description); |
|
30 | 30 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
31 | 31 | } |
32 | 32 | |
33 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
33 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
34 | 34 | |
35 | - if ( $description ) { |
|
35 | + if ($description) { |
|
36 | 36 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | 40 | // Item price. |
41 | - if ( 'price' == $key ) { |
|
41 | + if ('price' == $key) { |
|
42 | 42 | |
43 | 43 | // Set the currency position. |
44 | 44 | $position = wpinv_currency_position(); |
45 | 45 | |
46 | - if ( $position == 'left_space' ) { |
|
46 | + if ($position == 'left_space') { |
|
47 | 47 | $position = 'left'; |
48 | 48 | } |
49 | 49 | |
50 | - if ( $position == 'right_space' ) { |
|
50 | + if ($position == 'right_space') { |
|
51 | 51 | $position = 'right'; |
52 | 52 | } |
53 | 53 | |
54 | - if ( $item->user_can_set_their_price() ) { |
|
55 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
54 | + if ($item->user_can_set_their_price()) { |
|
55 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
56 | 56 | ?> |
57 | 57 | <div class="input-group input-group-sm"> |
58 | - <?php if( 'left' == $position ) : ?> |
|
58 | + <?php if ('left' == $position) : ?> |
|
59 | 59 | <div class="input-group-prepend"> |
60 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
60 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
61 | 61 | </div> |
62 | 62 | <?php endif; ?> |
63 | - <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input"> |
|
63 | + <input type="text" name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input"> |
|
64 | 64 | |
65 | - <?php if( 'left' != $position ) : ?> |
|
65 | + <?php if ('left' != $position) : ?> |
|
66 | 66 | <div class="input-group-append"> |
67 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
67 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
68 | 68 | </div> |
69 | 69 | <?php endif; ?> |
70 | 70 | </div> |
71 | 71 | <?php |
72 | 72 | } else { |
73 | - echo wpinv_price( wpinv_format_amount( $item->get_price() ), $currency ); |
|
73 | + echo wpinv_price(wpinv_format_amount($item->get_price()), $currency); |
|
74 | 74 | ?> |
75 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
75 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
76 | 76 | <?php |
77 | 77 | } |
78 | 78 | } |
79 | 79 | |
80 | 80 | // Item quantity. |
81 | - if ( 'quantity' == $key ) { |
|
81 | + if ('quantity' == $key) { |
|
82 | 82 | |
83 | - if ( $item->allows_quantities() ) { |
|
83 | + if ($item->allows_quantities()) { |
|
84 | 84 | ?> |
85 | 85 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='number' class='getpaid-item-quantity-input pr-1' value='<?php echo (int) $item->get_qantity(); ?>' min='1' required> |
86 | 86 | <?php |
@@ -94,15 +94,15 @@ discard block |
||
94 | 94 | } |
95 | 95 | |
96 | 96 | // Item sub total. |
97 | - if ( 'subtotal' == $key ) { |
|
98 | - echo wpinv_price( wpinv_format_amount( $item->get_sub_total() ), $currency ); |
|
97 | + if ('subtotal' == $key) { |
|
98 | + echo wpinv_price(wpinv_format_amount($item->get_sub_total()), $currency); |
|
99 | 99 | } |
100 | 100 | |
101 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
101 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
102 | 102 | ?> |
103 | 103 | </div> |
104 | 104 | <?php endforeach; ?> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <?php |
108 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
108 | +do_action('getpaid_payment_form_cart_item', $form, $item); |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
8 | +if (!defined('ABSPATH')) exit; |
|
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | 14 | |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | |
39 | 39 | // Set parent defaults |
40 | - parent::__construct( array( |
|
40 | + parent::__construct(array( |
|
41 | 41 | 'singular' => 'id', |
42 | 42 | 'plural' => 'ids', |
43 | 43 | 'ajax' => false, |
44 | - ) ); |
|
44 | + )); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string Column Name |
69 | 69 | */ |
70 | - public function column_default( $item, $column_name ) { |
|
71 | - return wp_kses_post( $item[ $column_name ] ); |
|
70 | + public function column_default($item, $column_name) { |
|
71 | + return wp_kses_post($item[$column_name]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,11 +80,11 @@ discard block |
||
80 | 80 | public function get_columns() { |
81 | 81 | |
82 | 82 | return array( |
83 | - 'item' => __( 'Item', 'invoicing' ), |
|
84 | - 'sales' => __( 'Quantity Sold', 'invoicing' ), |
|
85 | - 'total' => __( 'Total Earnings', 'invoicing' ), |
|
86 | - 'discount' => __( 'Total Discounts', 'invoicing' ), |
|
87 | - 'tax' => __( 'Total Taxes', 'invoicing' ), |
|
83 | + 'item' => __('Item', 'invoicing'), |
|
84 | + 'sales' => __('Quantity Sold', 'invoicing'), |
|
85 | + 'total' => __('Total Earnings', 'invoicing'), |
|
86 | + 'discount' => __('Total Discounts', 'invoicing'), |
|
87 | + 'tax' => __('Total Taxes', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return int Current page number |
97 | 97 | */ |
98 | 98 | public function get_paged() { |
99 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
99 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @since 1.0.19 |
106 | 106 | * @return void |
107 | 107 | */ |
108 | - public function bulk_actions( $which = '' ) { |
|
108 | + public function bulk_actions($which = '') { |
|
109 | 109 | return array(); |
110 | 110 | } |
111 | 111 | |
@@ -120,13 +120,13 @@ discard block |
||
120 | 120 | $reports_data = $this->revenue_reports_data(); |
121 | 121 | |
122 | 122 | $prepared = array(); |
123 | - foreach ( $reports_data as $report_data ) { |
|
123 | + foreach ($reports_data as $report_data) { |
|
124 | 124 | $prepared[] = array( |
125 | 125 | 'item' => $report_data['item_name'], |
126 | 126 | 'sales' => $report_data['sales'], |
127 | - 'total' => wpinv_price( wpinv_format_amount( $report_data['total'] ) ), |
|
128 | - 'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ), |
|
129 | - 'tax' => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ), |
|
127 | + 'total' => wpinv_price(wpinv_format_amount($report_data['total'])), |
|
128 | + 'discount' => wpinv_price(wpinv_format_amount($report_data['discount'])), |
|
129 | + 'tax' => wpinv_price(wpinv_format_amount($report_data['tax'])), |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | public function revenue_reports_data() { |
142 | 142 | global $wpdb; |
143 | 143 | |
144 | - $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
144 | + $table = $wpdb->prefix . 'getpaid_invoice_items'; |
|
145 | 145 | return $wpdb->get_results( |
146 | 146 | "SELECT |
147 | 147 | SUM(quantity) as sales, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | $columns = $this->get_columns(); |
170 | 170 | $hidden = array(); // No hidden columns |
171 | 171 | $sortable = $this->get_sortable_columns(); |
172 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
172 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
173 | 173 | $this->items = $this->reports_data(); |
174 | 174 | } |
175 | 175 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
8 | +if (!defined('ABSPATH')) exit; |
|
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | 14 | |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | |
39 | 39 | // Set parent defaults |
40 | - parent::__construct( array( |
|
40 | + parent::__construct(array( |
|
41 | 41 | 'singular' => 'id', |
42 | 42 | 'plural' => 'ids', |
43 | 43 | 'ajax' => false, |
44 | - ) ); |
|
44 | + )); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string Column Name |
69 | 69 | */ |
70 | - public function column_default( $item, $column_name ) { |
|
71 | - return wp_kses_post( $item[ $column_name ] ); |
|
70 | + public function column_default($item, $column_name) { |
|
71 | + return wp_kses_post($item[$column_name]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,12 +80,12 @@ discard block |
||
80 | 80 | public function get_columns() { |
81 | 81 | |
82 | 82 | return array( |
83 | - 'gateway' => __( 'Gateway', 'invoicing' ), |
|
84 | - 'sales' => __( 'Total Sales', 'invoicing' ), |
|
85 | - 'total' => __( 'Total Earnings', 'invoicing' ), |
|
86 | - 'discount' => __( 'Total Discounts', 'invoicing' ), |
|
87 | - 'tax' => __( 'Total Taxes', 'invoicing' ), |
|
88 | - 'fees' => __( 'Total Fees', 'invoicing' ), |
|
83 | + 'gateway' => __('Gateway', 'invoicing'), |
|
84 | + 'sales' => __('Total Sales', 'invoicing'), |
|
85 | + 'total' => __('Total Earnings', 'invoicing'), |
|
86 | + 'discount' => __('Total Discounts', 'invoicing'), |
|
87 | + 'tax' => __('Total Taxes', 'invoicing'), |
|
88 | + 'fees' => __('Total Fees', 'invoicing'), |
|
89 | 89 | ); |
90 | 90 | |
91 | 91 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @return int Current page number |
98 | 98 | */ |
99 | 99 | public function get_paged() { |
100 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
100 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | /** |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @since 1.0.19 |
107 | 107 | * @return void |
108 | 108 | */ |
109 | - public function bulk_actions( $which = '' ) { |
|
109 | + public function bulk_actions($which = '') { |
|
110 | 110 | return array(); |
111 | 111 | } |
112 | 112 | |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | $reports_data = $this->revenue_reports_data(); |
122 | 122 | $gateways = wpinv_get_payment_gateways(); |
123 | 123 | |
124 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
124 | + foreach ($gateways as $gateway_id => $gateway) { |
|
125 | 125 | |
126 | - if ( ! empty( $reports_data[ $gateway_id ] ) ) { |
|
126 | + if (!empty($reports_data[$gateway_id])) { |
|
127 | 127 | continue; |
128 | 128 | } |
129 | 129 | |
@@ -138,14 +138,14 @@ discard block |
||
138 | 138 | } |
139 | 139 | |
140 | 140 | $prepared = array(); |
141 | - foreach ( $reports_data as $report_data ) { |
|
141 | + foreach ($reports_data as $report_data) { |
|
142 | 142 | $prepared[] = array( |
143 | - 'gateway' => wpinv_get_gateway_admin_label( $report_data['gateway'] ), |
|
143 | + 'gateway' => wpinv_get_gateway_admin_label($report_data['gateway']), |
|
144 | 144 | 'sales' => $report_data['sales'], |
145 | - 'total' => wpinv_price( wpinv_format_amount( $report_data['total'] ) ), |
|
146 | - 'discount' => wpinv_price( wpinv_format_amount( $report_data['discount'] ) ), |
|
147 | - 'tax' => wpinv_price( wpinv_format_amount( $report_data['tax'] ) ), |
|
148 | - 'fees' => wpinv_price( wpinv_format_amount( $report_data['fees'] ) ), |
|
145 | + 'total' => wpinv_price(wpinv_format_amount($report_data['total'])), |
|
146 | + 'discount' => wpinv_price(wpinv_format_amount($report_data['discount'])), |
|
147 | + 'tax' => wpinv_price(wpinv_format_amount($report_data['tax'])), |
|
148 | + 'fees' => wpinv_price(wpinv_format_amount($report_data['fees'])), |
|
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
@@ -160,7 +160,7 @@ discard block |
||
160 | 160 | public function revenue_reports_data() { |
161 | 161 | global $wpdb; |
162 | 162 | |
163 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
163 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
164 | 164 | $data = $wpdb->get_results( |
165 | 165 | "SELECT |
166 | 166 | COUNT(posts.ID) as sales, |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | |
180 | 180 | $return = array(); |
181 | 181 | |
182 | - foreach ( $data as $gateway ) { |
|
183 | - $return[ $gateway ['gateway']] = $gateway; |
|
182 | + foreach ($data as $gateway) { |
|
183 | + $return[$gateway ['gateway']] = $gateway; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | return $return; |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | $columns = $this->get_columns(); |
198 | 198 | $hidden = array(); // No hidden columns |
199 | 199 | $sortable = $this->get_sortable_columns(); |
200 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
200 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
201 | 201 | $this->items = $this->reports_data(); |
202 | 202 | } |
203 | 203 | } |
@@ -5,10 +5,10 @@ discard block |
||
5 | 5 | */ |
6 | 6 | |
7 | 7 | // Exit if accessed directly |
8 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
8 | +if (!defined('ABSPATH')) exit; |
|
9 | 9 | |
10 | 10 | // Load WP_List_Table if not loaded |
11 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
11 | +if (!class_exists('WP_List_Table')) { |
|
12 | 12 | require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
13 | 13 | } |
14 | 14 | |
@@ -37,11 +37,11 @@ discard block |
||
37 | 37 | public function __construct() { |
38 | 38 | |
39 | 39 | // Set parent defaults |
40 | - parent::__construct( array( |
|
40 | + parent::__construct(array( |
|
41 | 41 | 'singular' => 'id', |
42 | 42 | 'plural' => 'ids', |
43 | 43 | 'ajax' => false, |
44 | - ) ); |
|
44 | + )); |
|
45 | 45 | |
46 | 46 | } |
47 | 47 | |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string Column Name |
69 | 69 | */ |
70 | - public function column_default( $item, $column_name ) { |
|
71 | - return wp_kses_post( $item[ $column_name ] ); |
|
70 | + public function column_default($item, $column_name) { |
|
71 | + return wp_kses_post($item[$column_name]); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | public function get_columns() { |
81 | 81 | |
82 | 82 | return array( |
83 | - 'month' => __( 'Month', 'invoicing' ), |
|
84 | - 'tax' => __( 'Total Taxes', 'invoicing' ), |
|
83 | + 'month' => __('Month', 'invoicing'), |
|
84 | + 'tax' => __('Total Taxes', 'invoicing'), |
|
85 | 85 | ); |
86 | 86 | |
87 | 87 | } |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @return int Current page number |
94 | 94 | */ |
95 | 95 | public function get_paged() { |
96 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
96 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | /** |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @since 1.0.19 |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - public function bulk_actions( $which = '' ) { |
|
105 | + public function bulk_actions($which = '') { |
|
106 | 106 | return array(); |
107 | 107 | } |
108 | 108 | |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | |
117 | 117 | $reports_data = $this->taxes_reports_data(); |
118 | 118 | $months = array( |
119 | - '1' => __( 'January', 'invoicing' ), |
|
120 | - '2' => __( 'February', 'invoicing' ), |
|
121 | - '3' => __( 'March', 'invoicing' ), |
|
122 | - '4' => __( 'April', 'invoicing' ), |
|
123 | - '5' => __( 'May', 'invoicing' ), |
|
124 | - '6' => __( 'June', 'invoicing' ), |
|
125 | - '7' => __( 'July', 'invoicing' ), |
|
126 | - '8' => __( 'August', 'invoicing' ), |
|
127 | - '9' => __( 'September', 'invoicing' ), |
|
128 | - '10' => __( 'October', 'invoicing' ), |
|
129 | - '11' => __( 'November', 'invoicing' ), |
|
130 | - '12' => __( 'December', 'invoicing' ), |
|
119 | + '1' => __('January', 'invoicing'), |
|
120 | + '2' => __('February', 'invoicing'), |
|
121 | + '3' => __('March', 'invoicing'), |
|
122 | + '4' => __('April', 'invoicing'), |
|
123 | + '5' => __('May', 'invoicing'), |
|
124 | + '6' => __('June', 'invoicing'), |
|
125 | + '7' => __('July', 'invoicing'), |
|
126 | + '8' => __('August', 'invoicing'), |
|
127 | + '9' => __('September', 'invoicing'), |
|
128 | + '10' => __('October', 'invoicing'), |
|
129 | + '11' => __('November', 'invoicing'), |
|
130 | + '12' => __('December', 'invoicing'), |
|
131 | 131 | ); |
132 | 132 | |
133 | 133 | $prepared = array(); |
134 | - foreach ( $months as $month => $label ) { |
|
134 | + foreach ($months as $month => $label) { |
|
135 | 135 | |
136 | - $tax = wpinv_price( 0 ); |
|
137 | - if ( ! empty( $reports_data[ $month ] ) ) { |
|
138 | - $tax = wpinv_price( wpinv_format_amount( $reports_data[ $month ] ) ); |
|
136 | + $tax = wpinv_price(0); |
|
137 | + if (!empty($reports_data[$month])) { |
|
138 | + $tax = wpinv_price(wpinv_format_amount($reports_data[$month])); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | $prepared[] = array( |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | public function taxes_reports_data() { |
157 | 157 | global $wpdb; |
158 | 158 | |
159 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
160 | - $year = isset( $_GET['year'] ) ? absint( $_GET['year'] ) : date( 'Y' ); |
|
159 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
160 | + $year = isset($_GET['year']) ? absint($_GET['year']) : date('Y'); |
|
161 | 161 | $data = $wpdb->get_results( |
162 | 162 | "SELECT |
163 | 163 | MONTH(meta.completed_date) as _month, |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | AND ( YEAR(meta.completed_date) = '$year' ) |
172 | 172 | GROUP BY MONTH(meta.completed_date)"); |
173 | 173 | |
174 | - return wp_list_pluck( $data, 'tax', '_month' ); |
|
174 | + return wp_list_pluck($data, 'tax', '_month'); |
|
175 | 175 | |
176 | 176 | } |
177 | 177 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | $columns = $this->get_columns(); |
186 | 186 | $hidden = array(); // No hidden columns |
187 | 187 | $sortable = $this->get_sortable_columns(); |
188 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
188 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
189 | 189 | $this->items = $this->reports_data(); |
190 | 190 | } |
191 | 191 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | */ |
8 | 8 | |
9 | 9 | // MUST have WordPress. |
10 | -if ( !defined( 'WPINC' ) ) { |
|
10 | +if (!defined('WPINC')) { |
|
11 | 11 | exit; |
12 | 12 | } |
13 | 13 | |
@@ -24,40 +24,40 @@ discard block |
||
24 | 24 | * @param Array $assoc_args Key value arguments stored in associated array format. |
25 | 25 | * @since 1.0.13 |
26 | 26 | */ |
27 | - public function insert_invoice( $args, $assoc_args ) { |
|
27 | + public function insert_invoice($args, $assoc_args) { |
|
28 | 28 | |
29 | 29 | // Fetch invoice data from the args |
30 | - $invoice_data = wp_unslash( $assoc_args ); |
|
30 | + $invoice_data = wp_unslash($assoc_args); |
|
31 | 31 | |
32 | 32 | // Abort if no invoice data is provided |
33 | - if( empty( $invoice_data ) ) { |
|
34 | - return WP_CLI::error( __( 'Invoice data not provided', 'invoicing' ) ); |
|
33 | + if (empty($invoice_data)) { |
|
34 | + return WP_CLI::error(__('Invoice data not provided', 'invoicing')); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | //Cart details |
38 | - if( !empty( $invoice_data['cart_details'] ) ) { |
|
39 | - $invoice_data['cart_details'] = json_decode( $invoice_data['cart_details'], true ); |
|
38 | + if (!empty($invoice_data['cart_details'])) { |
|
39 | + $invoice_data['cart_details'] = json_decode($invoice_data['cart_details'], true); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | //User details |
43 | - if( !empty( $invoice_data['user_info'] ) ) { |
|
44 | - $invoice_data['user_info'] = json_decode( $invoice_data['user_info'], true ); |
|
43 | + if (!empty($invoice_data['user_info'])) { |
|
44 | + $invoice_data['user_info'] = json_decode($invoice_data['user_info'], true); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | //Payment info |
48 | - if( !empty( $invoice_data['payment_details'] ) ) { |
|
49 | - $invoice_data['payment_details'] = json_decode( $invoice_data['payment_details'], true ); |
|
48 | + if (!empty($invoice_data['payment_details'])) { |
|
49 | + $invoice_data['payment_details'] = json_decode($invoice_data['payment_details'], true); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | // Try creating the invoice |
53 | - $invoice = wpinv_insert_invoice( $invoice_data, true ); |
|
53 | + $invoice = wpinv_insert_invoice($invoice_data, true); |
|
54 | 54 | |
55 | - if ( is_wp_error( $invoice ) ) { |
|
56 | - return WP_CLI::error( $invoice->get_error_message() ); |
|
55 | + if (is_wp_error($invoice)) { |
|
56 | + return WP_CLI::error($invoice->get_error_message()); |
|
57 | 57 | } |
58 | 58 | |
59 | - $message = sprintf( __( 'Invoice %s created', 'invoicing' ), $invoice->get_id() ); |
|
60 | - WP_CLI::success( $message ); |
|
59 | + $message = sprintf(__('Invoice %s created', 'invoicing'), $invoice->get_id()); |
|
60 | + WP_CLI::success($message); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 |