@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @return mixed array if errors are present, false if none found |
26 | 26 | */ |
27 | 27 | function give_get_errors() { |
28 | - return Give()->session->get( 'give_errors' ); |
|
28 | + return Give()->session->get('give_errors'); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -42,23 +42,23 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return void |
44 | 44 | */ |
45 | -function give_set_error( $error_id, $error_message, $notice_args = array() ) { |
|
45 | +function give_set_error($error_id, $error_message, $notice_args = array()) { |
|
46 | 46 | $errors = give_get_errors(); |
47 | - if ( ! $errors ) { |
|
47 | + if ( ! $errors) { |
|
48 | 48 | $errors = array(); |
49 | 49 | } |
50 | 50 | |
51 | - if( is_array( $notice_args ) && ! empty( $notice_args ) ) { |
|
52 | - $errors[ $error_id ] = array( |
|
51 | + if (is_array($notice_args) && ! empty($notice_args)) { |
|
52 | + $errors[$error_id] = array( |
|
53 | 53 | 'message' => $error_message, |
54 | 54 | 'notice_args' => $notice_args, |
55 | 55 | ); |
56 | 56 | } else { |
57 | 57 | // Backward compatibility v<1.8.11. |
58 | - $errors[ $error_id ] = $error_message; |
|
58 | + $errors[$error_id] = $error_message; |
|
59 | 59 | } |
60 | 60 | |
61 | - Give()->session->set( 'give_errors', $errors ); |
|
61 | + Give()->session->set('give_errors', $errors); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * @return void |
70 | 70 | */ |
71 | 71 | function give_clear_errors() { |
72 | - Give()->session->set( 'give_errors', null ); |
|
72 | + Give()->session->set('give_errors', null); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,19 +82,19 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @return void |
84 | 84 | */ |
85 | -function give_unset_error( $error_id ) { |
|
85 | +function give_unset_error($error_id) { |
|
86 | 86 | $errors = give_get_errors(); |
87 | - if ( $errors ) { |
|
87 | + if ($errors) { |
|
88 | 88 | /** |
89 | 89 | * Check If $error_id exists in the array. |
90 | 90 | * If exists then unset it. |
91 | 91 | * |
92 | 92 | * @since 1.8.13 |
93 | 93 | */ |
94 | - if ( isset( $errors[ $error_id ] ) ) { |
|
95 | - unset( $errors[ $error_id ] ); |
|
94 | + if (isset($errors[$error_id])) { |
|
95 | + unset($errors[$error_id]); |
|
96 | 96 | } |
97 | - Give()->session->set( 'give_errors', $errors ); |
|
97 | + Give()->session->set('give_errors', $errors); |
|
98 | 98 | } |
99 | 99 | } |
100 | 100 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return string |
106 | 106 | */ |
107 | 107 | function _give_die_handler() { |
108 | - if ( defined( 'GIVE_UNIT_TESTS' ) ) { |
|
108 | + if (defined('GIVE_UNIT_TESTS')) { |
|
109 | 109 | return '_give_die_handler'; |
110 | 110 | } else { |
111 | 111 | die(); |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @return void |
127 | 127 | */ |
128 | -function give_die( $message = '', $title = '', $status = 400 ) { |
|
129 | - add_filter( 'wp_die_ajax_handler', '_give_die_handler', 10, 3 ); |
|
130 | - add_filter( 'wp_die_handler', '_give_die_handler', 10, 3 ); |
|
131 | - wp_die( $message, $title, array( 'response' => $status ) ); |
|
128 | +function give_die($message = '', $title = '', $status = 400) { |
|
129 | + add_filter('wp_die_ajax_handler', '_give_die_handler', 10, 3); |
|
130 | + add_filter('wp_die_handler', '_give_die_handler', 10, 3); |
|
131 | + wp_die($message, $title, array('response' => $status)); |
|
132 | 132 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -139,32 +139,32 @@ discard block |
||
139 | 139 | * @param bool $_id_or_email |
140 | 140 | * @param bool $by_user_id |
141 | 141 | */ |
142 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
142 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
143 | 143 | |
144 | 144 | $this->db = Give()->donors; |
145 | 145 | |
146 | 146 | if ( |
147 | 147 | false === $_id_or_email |
148 | - || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) |
|
148 | + || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email)) |
|
149 | 149 | ) { |
150 | 150 | return false; |
151 | 151 | } |
152 | 152 | |
153 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
153 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
154 | 154 | |
155 | - if ( is_numeric( $_id_or_email ) ) { |
|
155 | + if (is_numeric($_id_or_email)) { |
|
156 | 156 | $field = $by_user_id ? 'user_id' : 'id'; |
157 | 157 | } else { |
158 | 158 | $field = 'email'; |
159 | 159 | } |
160 | 160 | |
161 | - $donor = $this->db->get_donor_by( $field, $_id_or_email ); |
|
161 | + $donor = $this->db->get_donor_by($field, $_id_or_email); |
|
162 | 162 | |
163 | - if ( empty( $donor ) || ! is_object( $donor ) ) { |
|
163 | + if (empty($donor) || ! is_object($donor)) { |
|
164 | 164 | return false; |
165 | 165 | } |
166 | 166 | |
167 | - $this->setup_donor( $donor ); |
|
167 | + $this->setup_donor($donor); |
|
168 | 168 | |
169 | 169 | } |
170 | 170 | |
@@ -180,15 +180,15 @@ discard block |
||
180 | 180 | * |
181 | 181 | * @return bool If the setup was successful or not. |
182 | 182 | */ |
183 | - private function setup_donor( $donor ) { |
|
183 | + private function setup_donor($donor) { |
|
184 | 184 | |
185 | - if ( ! is_object( $donor ) ) { |
|
185 | + if ( ! is_object($donor)) { |
|
186 | 186 | return false; |
187 | 187 | } |
188 | 188 | |
189 | - foreach ( $donor as $key => $value ) { |
|
189 | + foreach ($donor as $key => $value) { |
|
190 | 190 | |
191 | - switch ( $key ) { |
|
191 | + switch ($key) { |
|
192 | 192 | |
193 | 193 | case 'notes': |
194 | 194 | $this->$key = $this->get_notes(); |
@@ -202,11 +202,11 @@ discard block |
||
202 | 202 | } |
203 | 203 | |
204 | 204 | // Get donor's all email including primary email. |
205 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
206 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
205 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
206 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
207 | 207 | |
208 | 208 | // Donor ID and email are the only things that are necessary, make sure they exist. |
209 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
209 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
210 | 210 | return true; |
211 | 211 | } |
212 | 212 | |
@@ -223,16 +223,16 @@ discard block |
||
223 | 223 | * |
224 | 224 | * @return mixed|\WP_Error |
225 | 225 | */ |
226 | - public function __get( $key ) { |
|
226 | + public function __get($key) { |
|
227 | 227 | |
228 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
228 | + if (method_exists($this, 'get_'.$key)) { |
|
229 | 229 | |
230 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
230 | + return call_user_func(array($this, 'get_'.$key)); |
|
231 | 231 | |
232 | 232 | } else { |
233 | 233 | |
234 | 234 | /* translators: %s: property key */ |
235 | - return new WP_Error( 'give-donor-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
235 | + return new WP_Error('give-donor-invalid-property', sprintf(esc_html__('Can\'t get property %s.', 'give'), $key)); |
|
236 | 236 | |
237 | 237 | } |
238 | 238 | |
@@ -248,9 +248,9 @@ discard block |
||
248 | 248 | * |
249 | 249 | * @return bool|int False if not a valid creation, donor ID if user is found or valid creation. |
250 | 250 | */ |
251 | - public function create( $data = array() ) { |
|
251 | + public function create($data = array()) { |
|
252 | 252 | |
253 | - if ( $this->id != 0 || empty( $data ) ) { |
|
253 | + if ($this->id != 0 || empty($data)) { |
|
254 | 254 | return false; |
255 | 255 | } |
256 | 256 | |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | 'payment_ids' => '', |
259 | 259 | ); |
260 | 260 | |
261 | - $args = wp_parse_args( $data, $defaults ); |
|
262 | - $args = $this->sanitize_columns( $args ); |
|
261 | + $args = wp_parse_args($data, $defaults); |
|
262 | + $args = $this->sanitize_columns($args); |
|
263 | 263 | |
264 | - if ( empty( $args['email'] ) || ! is_email( $args['email'] ) ) { |
|
264 | + if (empty($args['email']) || ! is_email($args['email'])) { |
|
265 | 265 | return false; |
266 | 266 | } |
267 | 267 | |
268 | - if ( ! empty( $args['payment_ids'] ) && is_array( $args['payment_ids'] ) ) { |
|
269 | - $args['payment_ids'] = implode( ',', array_unique( array_values( $args['payment_ids'] ) ) ); |
|
268 | + if ( ! empty($args['payment_ids']) && is_array($args['payment_ids'])) { |
|
269 | + $args['payment_ids'] = implode(',', array_unique(array_values($args['payment_ids']))); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
@@ -276,18 +276,18 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param array $args Donor attributes. |
278 | 278 | */ |
279 | - do_action( 'give_donor_pre_create', $args ); |
|
279 | + do_action('give_donor_pre_create', $args); |
|
280 | 280 | |
281 | 281 | $created = false; |
282 | 282 | |
283 | 283 | // The DB class 'add' implies an update if the donor being asked to be created already exists |
284 | - if ( $this->db->add( $data ) ) { |
|
284 | + if ($this->db->add($data)) { |
|
285 | 285 | |
286 | 286 | // We've successfully added/updated the donor, reset the class vars with the new data |
287 | - $donor = $this->db->get_donor_by( 'email', $args['email'] ); |
|
287 | + $donor = $this->db->get_donor_by('email', $args['email']); |
|
288 | 288 | |
289 | 289 | // Setup the donor data with the values from DB |
290 | - $this->setup_donor( $donor ); |
|
290 | + $this->setup_donor($donor); |
|
291 | 291 | |
292 | 292 | $created = $this->id; |
293 | 293 | } |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | * @param bool|int $created False if not a valid creation, donor ID if user is found or valid creation. |
301 | 301 | * @param array $args Customer attributes. |
302 | 302 | */ |
303 | - do_action( 'give_donor_post_create', $created, $args ); |
|
303 | + do_action('give_donor_post_create', $created, $args); |
|
304 | 304 | |
305 | 305 | return $created; |
306 | 306 | |
@@ -316,13 +316,13 @@ discard block |
||
316 | 316 | * |
317 | 317 | * @return bool If the update was successful or not. |
318 | 318 | */ |
319 | - public function update( $data = array() ) { |
|
319 | + public function update($data = array()) { |
|
320 | 320 | |
321 | - if ( empty( $data ) ) { |
|
321 | + if (empty($data)) { |
|
322 | 322 | return false; |
323 | 323 | } |
324 | 324 | |
325 | - $data = $this->sanitize_columns( $data ); |
|
325 | + $data = $this->sanitize_columns($data); |
|
326 | 326 | |
327 | 327 | /** |
328 | 328 | * Fires before updating donors. |
@@ -332,14 +332,14 @@ discard block |
||
332 | 332 | * @param int $donor_id Donor id. |
333 | 333 | * @param array $data Donor attributes. |
334 | 334 | */ |
335 | - do_action( 'give_donor_pre_update', $this->id, $data ); |
|
335 | + do_action('give_donor_pre_update', $this->id, $data); |
|
336 | 336 | |
337 | 337 | $updated = false; |
338 | 338 | |
339 | - if ( $this->db->update( $this->id, $data ) ) { |
|
339 | + if ($this->db->update($this->id, $data)) { |
|
340 | 340 | |
341 | - $donor = $this->db->get_donor_by( 'id', $this->id ); |
|
342 | - $this->setup_donor( $donor ); |
|
341 | + $donor = $this->db->get_donor_by('id', $this->id); |
|
342 | + $this->setup_donor($donor); |
|
343 | 343 | |
344 | 344 | $updated = true; |
345 | 345 | } |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | * @param int $donor_id Donor id. |
354 | 354 | * @param array $data Donor attributes. |
355 | 355 | */ |
356 | - do_action( 'give_donor_post_update', $updated, $this->id, $data ); |
|
356 | + do_action('give_donor_post_update', $updated, $this->id, $data); |
|
357 | 357 | |
358 | 358 | return $updated; |
359 | 359 | } |
@@ -371,27 +371,27 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @return bool If the attachment was successfully. |
373 | 373 | */ |
374 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
374 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
375 | 375 | |
376 | - if ( empty( $payment_id ) ) { |
|
376 | + if (empty($payment_id)) { |
|
377 | 377 | return false; |
378 | 378 | } |
379 | 379 | |
380 | - if ( empty( $this->payment_ids ) ) { |
|
380 | + if (empty($this->payment_ids)) { |
|
381 | 381 | |
382 | 382 | $new_payment_ids = $payment_id; |
383 | 383 | |
384 | 384 | } else { |
385 | 385 | |
386 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
386 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
387 | 387 | |
388 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
388 | + if (in_array($payment_id, $payment_ids)) { |
|
389 | 389 | $update_stats = false; |
390 | 390 | } |
391 | 391 | |
392 | 392 | $payment_ids[] = $payment_id; |
393 | 393 | |
394 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
394 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -403,20 +403,20 @@ discard block |
||
403 | 403 | * @param int $payment_id Payment id. |
404 | 404 | * @param int $donor_id Customer id. |
405 | 405 | */ |
406 | - do_action( 'give_donor_pre_attach_payment', $payment_id, $this->id ); |
|
406 | + do_action('give_donor_pre_attach_payment', $payment_id, $this->id); |
|
407 | 407 | |
408 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
408 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
409 | 409 | |
410 | - if ( $payment_added ) { |
|
410 | + if ($payment_added) { |
|
411 | 411 | |
412 | 412 | $this->payment_ids = $new_payment_ids; |
413 | 413 | |
414 | 414 | // We added this payment successfully, increment the stats |
415 | - if ( $update_stats ) { |
|
416 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
415 | + if ($update_stats) { |
|
416 | + $payment_amount = give_get_payment_amount($payment_id); |
|
417 | 417 | |
418 | - if ( ! empty( $payment_amount ) ) { |
|
419 | - $this->increase_value( $payment_amount ); |
|
418 | + if ( ! empty($payment_amount)) { |
|
419 | + $this->increase_value($payment_amount); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | $this->increase_purchase_count(); |
@@ -432,7 +432,7 @@ discard block |
||
432 | 432 | * @param int $payment_id Payment id. |
433 | 433 | * @param int $donor_id Donor id. |
434 | 434 | */ |
435 | - do_action( 'give_donor_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
435 | + do_action('give_donor_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
436 | 436 | |
437 | 437 | return $payment_added; |
438 | 438 | } |
@@ -450,33 +450,33 @@ discard block |
||
450 | 450 | * |
451 | 451 | * @return boolean If the removal was successful. |
452 | 452 | */ |
453 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
453 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
454 | 454 | |
455 | - if ( empty( $payment_id ) ) { |
|
455 | + if (empty($payment_id)) { |
|
456 | 456 | return false; |
457 | 457 | } |
458 | 458 | |
459 | - $payment = new Give_Payment( $payment_id ); |
|
459 | + $payment = new Give_Payment($payment_id); |
|
460 | 460 | |
461 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
461 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
462 | 462 | $update_stats = false; |
463 | 463 | } |
464 | 464 | |
465 | 465 | $new_payment_ids = ''; |
466 | 466 | |
467 | - if ( ! empty( $this->payment_ids ) ) { |
|
467 | + if ( ! empty($this->payment_ids)) { |
|
468 | 468 | |
469 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
469 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
470 | 470 | |
471 | - $pos = array_search( $payment_id, $payment_ids ); |
|
472 | - if ( false === $pos ) { |
|
471 | + $pos = array_search($payment_id, $payment_ids); |
|
472 | + if (false === $pos) { |
|
473 | 473 | return false; |
474 | 474 | } |
475 | 475 | |
476 | - unset( $payment_ids[ $pos ] ); |
|
477 | - $payment_ids = array_filter( $payment_ids ); |
|
476 | + unset($payment_ids[$pos]); |
|
477 | + $payment_ids = array_filter($payment_ids); |
|
478 | 478 | |
479 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
479 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
480 | 480 | |
481 | 481 | } |
482 | 482 | |
@@ -488,20 +488,20 @@ discard block |
||
488 | 488 | * @param int $payment_id Payment id. |
489 | 489 | * @param int $donor_id Customer id. |
490 | 490 | */ |
491 | - do_action( 'give_donor_pre_remove_payment', $payment_id, $this->id ); |
|
491 | + do_action('give_donor_pre_remove_payment', $payment_id, $this->id); |
|
492 | 492 | |
493 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
493 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
494 | 494 | |
495 | - if ( $payment_removed ) { |
|
495 | + if ($payment_removed) { |
|
496 | 496 | |
497 | 497 | $this->payment_ids = $new_payment_ids; |
498 | 498 | |
499 | - if ( $update_stats ) { |
|
499 | + if ($update_stats) { |
|
500 | 500 | // We removed this payment successfully, decrement the stats |
501 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
501 | + $payment_amount = give_get_payment_amount($payment_id); |
|
502 | 502 | |
503 | - if ( ! empty( $payment_amount ) ) { |
|
504 | - $this->decrease_value( $payment_amount ); |
|
503 | + if ( ! empty($payment_amount)) { |
|
504 | + $this->decrease_value($payment_amount); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | $this->decrease_donation_count(); |
@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * @param int $payment_id Payment id. |
518 | 518 | * @param int $donor_id Donor id. |
519 | 519 | */ |
520 | - do_action( 'give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
520 | + do_action('give_donor_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
521 | 521 | |
522 | 522 | return $payment_removed; |
523 | 523 | |
@@ -533,10 +533,10 @@ discard block |
||
533 | 533 | * |
534 | 534 | * @return int The donation count. |
535 | 535 | */ |
536 | - public function increase_purchase_count( $count = 1 ) { |
|
536 | + public function increase_purchase_count($count = 1) { |
|
537 | 537 | |
538 | 538 | // Make sure it's numeric and not negative. |
539 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
539 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
540 | 540 | return false; |
541 | 541 | } |
542 | 542 | |
@@ -550,9 +550,9 @@ discard block |
||
550 | 550 | * @param int $count The number to increase by. |
551 | 551 | * @param int $donor_id Donor id. |
552 | 552 | */ |
553 | - do_action( 'give_donor_pre_increase_donation_count', $count, $this->id ); |
|
553 | + do_action('give_donor_pre_increase_donation_count', $count, $this->id); |
|
554 | 554 | |
555 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
555 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
556 | 556 | $this->purchase_count = $new_total; |
557 | 557 | } |
558 | 558 | |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | * @param int $count The number increased by. |
566 | 566 | * @param int $donor_id Donor id. |
567 | 567 | */ |
568 | - do_action( 'give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id ); |
|
568 | + do_action('give_donor_post_increase_donation_count', $this->purchase_count, $count, $this->id); |
|
569 | 569 | |
570 | 570 | return $this->purchase_count; |
571 | 571 | } |
@@ -580,16 +580,16 @@ discard block |
||
580 | 580 | * |
581 | 581 | * @return mixed If successful, the new count, otherwise false. |
582 | 582 | */ |
583 | - public function decrease_donation_count( $count = 1 ) { |
|
583 | + public function decrease_donation_count($count = 1) { |
|
584 | 584 | |
585 | 585 | // Make sure it's numeric and not negative |
586 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
586 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
587 | 587 | return false; |
588 | 588 | } |
589 | 589 | |
590 | 590 | $new_total = (int) $this->purchase_count - (int) $count; |
591 | 591 | |
592 | - if ( $new_total < 0 ) { |
|
592 | + if ($new_total < 0) { |
|
593 | 593 | $new_total = 0; |
594 | 594 | } |
595 | 595 | |
@@ -601,9 +601,9 @@ discard block |
||
601 | 601 | * @param int $count The number to decrease by. |
602 | 602 | * @param int $donor_id Customer id. |
603 | 603 | */ |
604 | - do_action( 'give_donor_pre_decrease_donation_count', $count, $this->id ); |
|
604 | + do_action('give_donor_pre_decrease_donation_count', $count, $this->id); |
|
605 | 605 | |
606 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
606 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
607 | 607 | $this->purchase_count = $new_total; |
608 | 608 | } |
609 | 609 | |
@@ -616,7 +616,7 @@ discard block |
||
616 | 616 | * @param int $count The number decreased by. |
617 | 617 | * @param int $donor_id Donor id. |
618 | 618 | */ |
619 | - do_action( 'give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id ); |
|
619 | + do_action('give_donor_post_decrease_donation_count', $this->purchase_count, $count, $this->id); |
|
620 | 620 | |
621 | 621 | return $this->purchase_count; |
622 | 622 | } |
@@ -631,9 +631,9 @@ discard block |
||
631 | 631 | * |
632 | 632 | * @return mixed If successful, the new value, otherwise false. |
633 | 633 | */ |
634 | - public function increase_value( $value = 0.00 ) { |
|
634 | + public function increase_value($value = 0.00) { |
|
635 | 635 | |
636 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
636 | + $new_value = floatval($this->purchase_value) + $value; |
|
637 | 637 | |
638 | 638 | /** |
639 | 639 | * Fires before increasing donor lifetime value. |
@@ -643,9 +643,9 @@ discard block |
||
643 | 643 | * @param float $value The value to increase by. |
644 | 644 | * @param int $donor_id Customer id. |
645 | 645 | */ |
646 | - do_action( 'give_donor_pre_increase_value', $value, $this->id ); |
|
646 | + do_action('give_donor_pre_increase_value', $value, $this->id); |
|
647 | 647 | |
648 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
648 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
649 | 649 | $this->purchase_value = $new_value; |
650 | 650 | } |
651 | 651 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @param float $value The value increased by. |
659 | 659 | * @param int $donor_id Donor id. |
660 | 660 | */ |
661 | - do_action( 'give_donor_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
661 | + do_action('give_donor_post_increase_value', $this->purchase_value, $value, $this->id); |
|
662 | 662 | |
663 | 663 | return $this->purchase_value; |
664 | 664 | } |
@@ -673,11 +673,11 @@ discard block |
||
673 | 673 | * |
674 | 674 | * @return mixed If successful, the new value, otherwise false. |
675 | 675 | */ |
676 | - public function decrease_value( $value = 0.00 ) { |
|
676 | + public function decrease_value($value = 0.00) { |
|
677 | 677 | |
678 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
678 | + $new_value = floatval($this->purchase_value) - $value; |
|
679 | 679 | |
680 | - if ( $new_value < 0 ) { |
|
680 | + if ($new_value < 0) { |
|
681 | 681 | $new_value = 0.00; |
682 | 682 | } |
683 | 683 | |
@@ -689,9 +689,9 @@ discard block |
||
689 | 689 | * @param float $value The value to decrease by. |
690 | 690 | * @param int $donor_id Donor id. |
691 | 691 | */ |
692 | - do_action( 'give_donor_pre_decrease_value', $value, $this->id ); |
|
692 | + do_action('give_donor_pre_decrease_value', $value, $this->id); |
|
693 | 693 | |
694 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
694 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
695 | 695 | $this->purchase_value = $new_value; |
696 | 696 | } |
697 | 697 | |
@@ -704,7 +704,7 @@ discard block |
||
704 | 704 | * @param float $value The value decreased by. |
705 | 705 | * @param int $donor_id Donor id. |
706 | 706 | */ |
707 | - do_action( 'give_donor_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
707 | + do_action('give_donor_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
708 | 708 | |
709 | 709 | return $this->purchase_value; |
710 | 710 | } |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | * |
724 | 724 | * @return mixed If successful, the new donation stat value, otherwise false. |
725 | 725 | */ |
726 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
726 | + public function update_donation_value($curr_amount, $new_amount) { |
|
727 | 727 | /** |
728 | 728 | * Payment total difference value can be: |
729 | 729 | * zero (in case amount not change) |
@@ -733,15 +733,15 @@ discard block |
||
733 | 733 | $payment_total_diff = $new_amount - $curr_amount; |
734 | 734 | |
735 | 735 | // We do not need to update donation stat if donation did not change. |
736 | - if ( ! $payment_total_diff ) { |
|
736 | + if ( ! $payment_total_diff) { |
|
737 | 737 | return false; |
738 | 738 | } |
739 | 739 | |
740 | - if ( $payment_total_diff > 0 ) { |
|
741 | - $this->increase_value( $payment_total_diff ); |
|
740 | + if ($payment_total_diff > 0) { |
|
741 | + $this->increase_value($payment_total_diff); |
|
742 | 742 | } else { |
743 | 743 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
744 | - $this->decrease_value( - $payment_total_diff ); |
|
744 | + $this->decrease_value( -$payment_total_diff ); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | return $this->purchase_value; |
@@ -758,15 +758,15 @@ discard block |
||
758 | 758 | * |
759 | 759 | * @return array The notes requested. |
760 | 760 | */ |
761 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
761 | + public function get_notes($length = 20, $paged = 1) { |
|
762 | 762 | |
763 | - $length = is_numeric( $length ) ? $length : 20; |
|
764 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
763 | + $length = is_numeric($length) ? $length : 20; |
|
764 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
765 | 765 | |
766 | 766 | $all_notes = $this->get_raw_notes(); |
767 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
767 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
768 | 768 | |
769 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
769 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
770 | 770 | |
771 | 771 | return $desired_notes; |
772 | 772 | |
@@ -783,9 +783,9 @@ discard block |
||
783 | 783 | public function get_notes_count() { |
784 | 784 | |
785 | 785 | $all_notes = $this->get_raw_notes(); |
786 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
786 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
787 | 787 | |
788 | - return count( $notes_array ); |
|
788 | + return count($notes_array); |
|
789 | 789 | |
790 | 790 | } |
791 | 791 | |
@@ -799,22 +799,22 @@ discard block |
||
799 | 799 | * |
800 | 800 | * @return string|boolean The new note if added successfully, false otherwise. |
801 | 801 | */ |
802 | - public function add_note( $note = '' ) { |
|
802 | + public function add_note($note = '') { |
|
803 | 803 | |
804 | - $note = trim( $note ); |
|
805 | - if ( empty( $note ) ) { |
|
804 | + $note = trim($note); |
|
805 | + if (empty($note)) { |
|
806 | 806 | return false; |
807 | 807 | } |
808 | 808 | |
809 | 809 | $notes = $this->get_raw_notes(); |
810 | 810 | |
811 | - if ( empty( $notes ) ) { |
|
811 | + if (empty($notes)) { |
|
812 | 812 | $notes = ''; |
813 | 813 | } |
814 | 814 | |
815 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
816 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
817 | - $notes .= "\n\n" . $new_note; |
|
815 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
816 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
817 | + $notes .= "\n\n".$new_note; |
|
818 | 818 | |
819 | 819 | /** |
820 | 820 | * Fires before donor note is added. |
@@ -824,11 +824,11 @@ discard block |
||
824 | 824 | * @param string $new_note New note to add. |
825 | 825 | * @param int $donor_id Donor id. |
826 | 826 | */ |
827 | - do_action( 'give_donor_pre_add_note', $new_note, $this->id ); |
|
827 | + do_action('give_donor_pre_add_note', $new_note, $this->id); |
|
828 | 828 | |
829 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
829 | + $updated = $this->update(array('notes' => $notes)); |
|
830 | 830 | |
831 | - if ( $updated ) { |
|
831 | + if ($updated) { |
|
832 | 832 | $this->notes = $this->get_notes(); |
833 | 833 | } |
834 | 834 | |
@@ -841,7 +841,7 @@ discard block |
||
841 | 841 | * @param string $new_note New note added. |
842 | 842 | * @param int $donor_id Donor id. |
843 | 843 | */ |
844 | - do_action( 'give_donor_post_add_note', $this->notes, $new_note, $this->id ); |
|
844 | + do_action('give_donor_post_add_note', $this->notes, $new_note, $this->id); |
|
845 | 845 | |
846 | 846 | // Return the formatted note, so we can test, as well as update any displays |
847 | 847 | return $new_note; |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | */ |
859 | 859 | private function get_raw_notes() { |
860 | 860 | |
861 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
861 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
862 | 862 | |
863 | 863 | return $all_notes; |
864 | 864 | |
@@ -875,8 +875,8 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
877 | 877 | */ |
878 | - public function get_meta( $meta_key = '', $single = true ) { |
|
879 | - return Give()->donor_meta->get_meta( $this->id, $meta_key, $single ); |
|
878 | + public function get_meta($meta_key = '', $single = true) { |
|
879 | + return Give()->donor_meta->get_meta($this->id, $meta_key, $single); |
|
880 | 880 | } |
881 | 881 | |
882 | 882 | /** |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * |
892 | 892 | * @return bool False for failure. True for success. |
893 | 893 | */ |
894 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
895 | - return Give()->donor_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
894 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
895 | + return Give()->donor_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -907,8 +907,8 @@ discard block |
||
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
909 | 909 | */ |
910 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
911 | - return Give()->donor_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
910 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
911 | + return Give()->donor_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | /** |
@@ -922,8 +922,8 @@ discard block |
||
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
925 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
926 | - return Give()->donor_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
925 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
926 | + return Give()->donor_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
927 | 927 | } |
928 | 928 | |
929 | 929 | /** |
@@ -936,51 +936,51 @@ discard block |
||
936 | 936 | * |
937 | 937 | * @return array The sanitized data, based off column defaults. |
938 | 938 | */ |
939 | - private function sanitize_columns( $data ) { |
|
939 | + private function sanitize_columns($data) { |
|
940 | 940 | |
941 | 941 | $columns = $this->db->get_columns(); |
942 | 942 | $default_values = $this->db->get_column_defaults(); |
943 | 943 | |
944 | - foreach ( $columns as $key => $type ) { |
|
944 | + foreach ($columns as $key => $type) { |
|
945 | 945 | |
946 | 946 | // Only sanitize data that we were provided |
947 | - if ( ! array_key_exists( $key, $data ) ) { |
|
947 | + if ( ! array_key_exists($key, $data)) { |
|
948 | 948 | continue; |
949 | 949 | } |
950 | 950 | |
951 | - switch ( $type ) { |
|
951 | + switch ($type) { |
|
952 | 952 | |
953 | 953 | case '%s': |
954 | - if ( 'email' == $key ) { |
|
955 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
956 | - } elseif ( 'notes' == $key ) { |
|
957 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
954 | + if ('email' == $key) { |
|
955 | + $data[$key] = sanitize_email($data[$key]); |
|
956 | + } elseif ('notes' == $key) { |
|
957 | + $data[$key] = strip_tags($data[$key]); |
|
958 | 958 | } else { |
959 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
959 | + $data[$key] = sanitize_text_field($data[$key]); |
|
960 | 960 | } |
961 | 961 | break; |
962 | 962 | |
963 | 963 | case '%d': |
964 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
965 | - $data[ $key ] = $default_values[ $key ]; |
|
964 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
965 | + $data[$key] = $default_values[$key]; |
|
966 | 966 | } else { |
967 | - $data[ $key ] = absint( $data[ $key ] ); |
|
967 | + $data[$key] = absint($data[$key]); |
|
968 | 968 | } |
969 | 969 | break; |
970 | 970 | |
971 | 971 | case '%f': |
972 | 972 | // Convert what was given to a float |
973 | - $value = floatval( $data[ $key ] ); |
|
973 | + $value = floatval($data[$key]); |
|
974 | 974 | |
975 | - if ( ! is_float( $value ) ) { |
|
976 | - $data[ $key ] = $default_values[ $key ]; |
|
975 | + if ( ! is_float($value)) { |
|
976 | + $data[$key] = $default_values[$key]; |
|
977 | 977 | } else { |
978 | - $data[ $key ] = $value; |
|
978 | + $data[$key] = $value; |
|
979 | 979 | } |
980 | 980 | break; |
981 | 981 | |
982 | 982 | default: |
983 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
983 | + $data[$key] = sanitize_text_field($data[$key]); |
|
984 | 984 | break; |
985 | 985 | |
986 | 986 | } |
@@ -1000,33 +1000,33 @@ discard block |
||
1000 | 1000 | * |
1001 | 1001 | * @return bool If the email was added successfully |
1002 | 1002 | */ |
1003 | - public function add_email( $email = '', $primary = false ) { |
|
1004 | - if ( ! is_email( $email ) ) { |
|
1003 | + public function add_email($email = '', $primary = false) { |
|
1004 | + if ( ! is_email($email)) { |
|
1005 | 1005 | return false; |
1006 | 1006 | } |
1007 | - $existing = new Give_Donor( $email ); |
|
1007 | + $existing = new Give_Donor($email); |
|
1008 | 1008 | |
1009 | - if ( $existing->id > 0 ) { |
|
1009 | + if ($existing->id > 0) { |
|
1010 | 1010 | // Email address already belongs to another donor |
1011 | 1011 | return false; |
1012 | 1012 | } |
1013 | 1013 | |
1014 | - if ( email_exists( $email ) ) { |
|
1015 | - $user = get_user_by( 'email', $email ); |
|
1016 | - if ( $user->ID != $this->user_id ) { |
|
1014 | + if (email_exists($email)) { |
|
1015 | + $user = get_user_by('email', $email); |
|
1016 | + if ($user->ID != $this->user_id) { |
|
1017 | 1017 | return false; |
1018 | 1018 | } |
1019 | 1019 | } |
1020 | 1020 | |
1021 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
1021 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
1022 | 1022 | |
1023 | 1023 | // Add is used to ensure duplicate emails are not added |
1024 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
1024 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
1025 | 1025 | |
1026 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
1026 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
1027 | 1027 | |
1028 | - if ( $ret && true === $primary ) { |
|
1029 | - $this->set_primary_email( $email ); |
|
1028 | + if ($ret && true === $primary) { |
|
1029 | + $this->set_primary_email($email); |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
1042 | 1042 | * |
1043 | 1043 | * @return bool If the email was removed successfully. |
1044 | 1044 | */ |
1045 | - public function remove_email( $email = '' ) { |
|
1046 | - if ( ! is_email( $email ) ) { |
|
1045 | + public function remove_email($email = '') { |
|
1046 | + if ( ! is_email($email)) { |
|
1047 | 1047 | return false; |
1048 | 1048 | } |
1049 | 1049 | |
1050 | - do_action( 'give_donor_pre_remove_email', $email, $this->id, $this ); |
|
1050 | + do_action('give_donor_pre_remove_email', $email, $this->id, $this); |
|
1051 | 1051 | |
1052 | - $ret = (bool) $this->delete_meta( 'additional_email', $email ); |
|
1052 | + $ret = (bool) $this->delete_meta('additional_email', $email); |
|
1053 | 1053 | |
1054 | - do_action( 'give_donor_post_remove_email', $email, $this->id, $this ); |
|
1054 | + do_action('give_donor_post_remove_email', $email, $this->id, $this); |
|
1055 | 1055 | |
1056 | 1056 | return $ret; |
1057 | 1057 | } |
@@ -1068,16 +1068,16 @@ discard block |
||
1068 | 1068 | * |
1069 | 1069 | * @return bool If the email was set as primary successfully. |
1070 | 1070 | */ |
1071 | - public function set_primary_email( $new_primary_email = '' ) { |
|
1072 | - if ( ! is_email( $new_primary_email ) ) { |
|
1071 | + public function set_primary_email($new_primary_email = '') { |
|
1072 | + if ( ! is_email($new_primary_email)) { |
|
1073 | 1073 | return false; |
1074 | 1074 | } |
1075 | 1075 | |
1076 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1076 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
1077 | 1077 | |
1078 | - $existing = new Give_Donor( $new_primary_email ); |
|
1078 | + $existing = new Give_Donor($new_primary_email); |
|
1079 | 1079 | |
1080 | - if ( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
1080 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
1081 | 1081 | // This email belongs to another donor. |
1082 | 1082 | return false; |
1083 | 1083 | } |
@@ -1085,21 +1085,21 @@ discard block |
||
1085 | 1085 | $old_email = $this->email; |
1086 | 1086 | |
1087 | 1087 | // Update donor record with new email. |
1088 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
1088 | + $update = $this->update(array('email' => $new_primary_email)); |
|
1089 | 1089 | |
1090 | 1090 | // Remove new primary from list of additional emails. |
1091 | - $remove = $this->remove_email( $new_primary_email ); |
|
1091 | + $remove = $this->remove_email($new_primary_email); |
|
1092 | 1092 | |
1093 | 1093 | // Add old email to additional emails list. |
1094 | - $add = $this->add_email( $old_email ); |
|
1094 | + $add = $this->add_email($old_email); |
|
1095 | 1095 | |
1096 | 1096 | $ret = $update && $remove && $add; |
1097 | 1097 | |
1098 | - if ( $ret ) { |
|
1098 | + if ($ret) { |
|
1099 | 1099 | $this->email = $new_primary_email; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
1102 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
1103 | 1103 | |
1104 | 1104 | return $ret; |
1105 | 1105 | } |
@@ -902,7 +902,7 @@ discard block |
||
902 | 902 | * @access public |
903 | 903 | * |
904 | 904 | * @param string $meta_key Metadata key. Default is empty. |
905 | - * @param mixed $meta_value Metadata value. |
|
905 | + * @param integer $meta_value Metadata value. |
|
906 | 906 | * @param mixed $prev_value Optional. Previous value to check before removing. Default is empty. |
907 | 907 | * |
908 | 908 | * @return bool False on failure, true if success. |
@@ -918,7 +918,7 @@ discard block |
||
918 | 918 | * @access public |
919 | 919 | * |
920 | 920 | * @param string $meta_key Metadata name. Default is empty. |
921 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
921 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
922 | 922 | * |
923 | 923 | * @return bool False for failure. True for success. |
924 | 924 | */ |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | * |
166 | 166 | * @since 1.0 |
167 | 167 | * @access public |
168 | - * |
|
169 | - * @param int $column Column ID. |
|
170 | - * @param string $column_where Column name. |
|
171 | - * @param string $column_value Column value. |
|
172 | - * |
|
168 | + * |
|
169 | + * @param int $column Column ID. |
|
170 | + * @param string $column_where Column name. |
|
171 | + * @param string $column_value Column value. |
|
172 | + * |
|
173 | 173 | * @return string |
174 | 174 | */ |
175 | 175 | public function get_column_by( $column, $column_where, $column_value ) { |
176 | - /* @var WPDB $wpdb */ |
|
177 | - global $wpdb; |
|
176 | + /* @var WPDB $wpdb */ |
|
177 | + global $wpdb; |
|
178 | 178 | |
179 | 179 | // Bailout. |
180 | 180 | if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
@@ -191,15 +191,15 @@ discard block |
||
191 | 191 | * |
192 | 192 | * @since 1.0 |
193 | 193 | * @access public |
194 | - * |
|
195 | - * @param array $data |
|
196 | - * @param string $type |
|
197 | - * |
|
194 | + * |
|
195 | + * @param array $data |
|
196 | + * @param string $type |
|
197 | + * |
|
198 | 198 | * @return int |
199 | 199 | */ |
200 | 200 | public function insert( $data, $type = '' ) { |
201 | - /* @var WPDB $wpdb */ |
|
202 | - global $wpdb; |
|
201 | + /* @var WPDB $wpdb */ |
|
202 | + global $wpdb; |
|
203 | 203 | |
204 | 204 | // Set default values. |
205 | 205 | $data = wp_parse_args( $data, $this->get_column_defaults() ); |
@@ -246,16 +246,16 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @since 1.0 |
248 | 248 | * @access public |
249 | - * |
|
250 | - * @param int $row_id Column ID |
|
251 | - * @param array $data |
|
252 | - * @param string $where Column value |
|
253 | - * |
|
249 | + * |
|
250 | + * @param int $row_id Column ID |
|
251 | + * @param array $data |
|
252 | + * @param string $where Column value |
|
253 | + * |
|
254 | 254 | * @return bool |
255 | 255 | */ |
256 | 256 | public function update( $row_id, $data = array(), $where = '' ) { |
257 | - /* @var WPDB $wpdb */ |
|
258 | - global $wpdb; |
|
257 | + /* @var WPDB $wpdb */ |
|
258 | + global $wpdb; |
|
259 | 259 | |
260 | 260 | // Row ID must be positive integer |
261 | 261 | $row_id = absint( $row_id ); |
@@ -293,14 +293,14 @@ discard block |
||
293 | 293 | * |
294 | 294 | * @since 1.0 |
295 | 295 | * @access public |
296 | - * |
|
297 | - * @param int $row_id Column ID. |
|
298 | - * |
|
296 | + * |
|
297 | + * @param int $row_id Column ID. |
|
298 | + * |
|
299 | 299 | * @return bool |
300 | 300 | */ |
301 | 301 | public function delete( $row_id = 0 ) { |
302 | - /* @var WPDB $wpdb */ |
|
303 | - global $wpdb; |
|
302 | + /* @var WPDB $wpdb */ |
|
303 | + global $wpdb; |
|
304 | 304 | |
305 | 305 | // Row ID must be positive integer |
306 | 306 | $row_id = absint( $row_id ); |
@@ -321,13 +321,13 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @since 1.3.2 |
323 | 323 | * @access public |
324 | - * |
|
324 | + * |
|
325 | 325 | * @param string $table The table name. |
326 | - * |
|
326 | + * |
|
327 | 327 | * @return bool If the table name exists. |
328 | 328 | */ |
329 | 329 | public function table_exists( $table ) { |
330 | - /* @var WPDB $wpdb */ |
|
330 | + /* @var WPDB $wpdb */ |
|
331 | 331 | global $wpdb; |
332 | 332 | |
333 | 333 | $table = sanitize_text_field( $table ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -98,16 +98,16 @@ discard block |
||
98 | 98 | * |
99 | 99 | * @return object |
100 | 100 | */ |
101 | - public function get( $row_id ) { |
|
101 | + public function get($row_id) { |
|
102 | 102 | /* @var WPDB $wpdb */ |
103 | 103 | global $wpdb; |
104 | 104 | |
105 | 105 | // Bailout. |
106 | - if ( empty( $row_id ) ) { |
|
106 | + if (empty($row_id)) { |
|
107 | 107 | return null; |
108 | 108 | } |
109 | 109 | |
110 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
110 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -121,18 +121,18 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @return object |
123 | 123 | */ |
124 | - public function get_by( $column, $row_id ) { |
|
124 | + public function get_by($column, $row_id) { |
|
125 | 125 | /* @var WPDB $wpdb */ |
126 | 126 | global $wpdb; |
127 | 127 | |
128 | 128 | // Bailout. |
129 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
129 | + if (empty($column) || empty($row_id)) { |
|
130 | 130 | return null; |
131 | 131 | } |
132 | 132 | |
133 | - $column = esc_sql( $column ); |
|
133 | + $column = esc_sql($column); |
|
134 | 134 | |
135 | - return $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id ) ); |
|
135 | + return $wpdb->get_row($wpdb->prepare("SELECT * FROM $this->table_name WHERE $column = %s LIMIT 1;", $row_id)); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
@@ -146,18 +146,18 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @return string Column value. |
148 | 148 | */ |
149 | - public function get_column( $column, $row_id ) { |
|
149 | + public function get_column($column, $row_id) { |
|
150 | 150 | /* @var WPDB $wpdb */ |
151 | 151 | global $wpdb; |
152 | 152 | |
153 | 153 | // Bailout. |
154 | - if ( empty( $column ) || empty( $row_id ) ) { |
|
154 | + if (empty($column) || empty($row_id)) { |
|
155 | 155 | return null; |
156 | 156 | } |
157 | 157 | |
158 | - $column = esc_sql( $column ); |
|
158 | + $column = esc_sql($column); |
|
159 | 159 | |
160 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id ) ); |
|
160 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $this->primary_key = %s LIMIT 1;", $row_id)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | /** |
@@ -172,18 +172,18 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return string |
174 | 174 | */ |
175 | - public function get_column_by( $column, $column_where, $column_value ) { |
|
175 | + public function get_column_by($column, $column_where, $column_value) { |
|
176 | 176 | /* @var WPDB $wpdb */ |
177 | 177 | global $wpdb; |
178 | 178 | |
179 | 179 | // Bailout. |
180 | - if ( empty( $column ) || empty( $column_where ) || empty( $column_value ) ) { |
|
180 | + if (empty($column) || empty($column_where) || empty($column_value)) { |
|
181 | 181 | return null; |
182 | 182 | } |
183 | 183 | |
184 | - $column_where = esc_sql( $column_where ); |
|
185 | - $column = esc_sql( $column ); |
|
186 | - return $wpdb->get_var( $wpdb->prepare( "SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value ) ); |
|
184 | + $column_where = esc_sql($column_where); |
|
185 | + $column = esc_sql($column); |
|
186 | + return $wpdb->get_var($wpdb->prepare("SELECT $column FROM $this->table_name WHERE $column_where = %s LIMIT 1;", $column_value)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | /** |
@@ -197,12 +197,12 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @return int |
199 | 199 | */ |
200 | - public function insert( $data, $type = '' ) { |
|
200 | + public function insert($data, $type = '') { |
|
201 | 201 | /* @var WPDB $wpdb */ |
202 | 202 | global $wpdb; |
203 | 203 | |
204 | 204 | // Set default values. |
205 | - $data = wp_parse_args( $data, $this->get_column_defaults() ); |
|
205 | + $data = wp_parse_args($data, $this->get_column_defaults()); |
|
206 | 206 | |
207 | 207 | /** |
208 | 208 | * Fires before inserting data to the database. |
@@ -211,22 +211,22 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param array $data |
213 | 213 | */ |
214 | - do_action( "give_pre_insert_{$type}", $data ); |
|
214 | + do_action("give_pre_insert_{$type}", $data); |
|
215 | 215 | |
216 | 216 | // Initialise column format array |
217 | 217 | $column_formats = $this->get_columns(); |
218 | 218 | |
219 | 219 | // Force fields to lower case |
220 | - $data = array_change_key_case( $data ); |
|
220 | + $data = array_change_key_case($data); |
|
221 | 221 | |
222 | 222 | // White list columns |
223 | - $data = array_intersect_key( $data, $column_formats ); |
|
223 | + $data = array_intersect_key($data, $column_formats); |
|
224 | 224 | |
225 | 225 | // Reorder $column_formats to match the order of columns given in $data |
226 | - $data_keys = array_keys( $data ); |
|
227 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
226 | + $data_keys = array_keys($data); |
|
227 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
228 | 228 | |
229 | - $wpdb->insert( $this->table_name, $data, $column_formats ); |
|
229 | + $wpdb->insert($this->table_name, $data, $column_formats); |
|
230 | 230 | |
231 | 231 | /** |
232 | 232 | * Fires after inserting data to the database. |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * @param int $insert_id |
237 | 237 | * @param array $data |
238 | 238 | */ |
239 | - do_action( "give_post_insert_{$type}", $wpdb->insert_id, $data ); |
|
239 | + do_action("give_post_insert_{$type}", $wpdb->insert_id, $data); |
|
240 | 240 | |
241 | 241 | return $wpdb->insert_id; |
242 | 242 | } |
@@ -253,18 +253,18 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return bool |
255 | 255 | */ |
256 | - public function update( $row_id, $data = array(), $where = '' ) { |
|
256 | + public function update($row_id, $data = array(), $where = '') { |
|
257 | 257 | /* @var WPDB $wpdb */ |
258 | 258 | global $wpdb; |
259 | 259 | |
260 | 260 | // Row ID must be positive integer |
261 | - $row_id = absint( $row_id ); |
|
261 | + $row_id = absint($row_id); |
|
262 | 262 | |
263 | - if ( empty( $row_id ) ) { |
|
263 | + if (empty($row_id)) { |
|
264 | 264 | return false; |
265 | 265 | } |
266 | 266 | |
267 | - if ( empty( $where ) ) { |
|
267 | + if (empty($where)) { |
|
268 | 268 | $where = $this->primary_key; |
269 | 269 | } |
270 | 270 | |
@@ -272,16 +272,16 @@ discard block |
||
272 | 272 | $column_formats = $this->get_columns(); |
273 | 273 | |
274 | 274 | // Force fields to lower case |
275 | - $data = array_change_key_case( $data ); |
|
275 | + $data = array_change_key_case($data); |
|
276 | 276 | |
277 | 277 | // White list columns |
278 | - $data = array_intersect_key( $data, $column_formats ); |
|
278 | + $data = array_intersect_key($data, $column_formats); |
|
279 | 279 | |
280 | 280 | // Reorder $column_formats to match the order of columns given in $data |
281 | - $data_keys = array_keys( $data ); |
|
282 | - $column_formats = array_merge( array_flip( $data_keys ), $column_formats ); |
|
281 | + $data_keys = array_keys($data); |
|
282 | + $column_formats = array_merge(array_flip($data_keys), $column_formats); |
|
283 | 283 | |
284 | - if ( false === $wpdb->update( $this->table_name, $data, array( $where => $row_id ), $column_formats ) ) { |
|
284 | + if (false === $wpdb->update($this->table_name, $data, array($where => $row_id), $column_formats)) { |
|
285 | 285 | return false; |
286 | 286 | } |
287 | 287 | |
@@ -298,18 +298,18 @@ discard block |
||
298 | 298 | * |
299 | 299 | * @return bool |
300 | 300 | */ |
301 | - public function delete( $row_id = 0 ) { |
|
301 | + public function delete($row_id = 0) { |
|
302 | 302 | /* @var WPDB $wpdb */ |
303 | 303 | global $wpdb; |
304 | 304 | |
305 | 305 | // Row ID must be positive integer |
306 | - $row_id = absint( $row_id ); |
|
306 | + $row_id = absint($row_id); |
|
307 | 307 | |
308 | - if ( empty( $row_id ) ) { |
|
308 | + if (empty($row_id)) { |
|
309 | 309 | return false; |
310 | 310 | } |
311 | 311 | |
312 | - if ( false === $wpdb->query( $wpdb->prepare( "DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id ) ) ) { |
|
312 | + if (false === $wpdb->query($wpdb->prepare("DELETE FROM $this->table_name WHERE $this->primary_key = %d", $row_id))) { |
|
313 | 313 | return false; |
314 | 314 | } |
315 | 315 | |
@@ -326,13 +326,13 @@ discard block |
||
326 | 326 | * |
327 | 327 | * @return bool If the table name exists. |
328 | 328 | */ |
329 | - public function table_exists( $table ) { |
|
329 | + public function table_exists($table) { |
|
330 | 330 | /* @var WPDB $wpdb */ |
331 | 331 | global $wpdb; |
332 | 332 | |
333 | - $table = sanitize_text_field( $table ); |
|
333 | + $table = sanitize_text_field($table); |
|
334 | 334 | |
335 | - return $wpdb->get_var( $wpdb->prepare( "SHOW TABLES LIKE '%s'", $table ) ) === $table; |
|
335 | + return $wpdb->get_var($wpdb->prepare("SHOW TABLES LIKE '%s'", $table)) === $table; |
|
336 | 336 | } |
337 | 337 | |
338 | 338 | /** |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @return bool Returns if the customers table was installed and upgrade routine run. |
345 | 345 | */ |
346 | 346 | public function installed() { |
347 | - return $this->table_exists( $this->table_name ); |
|
347 | + return $this->table_exists($this->table_name); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -354,8 +354,8 @@ discard block |
||
354 | 354 | * @access public |
355 | 355 | */ |
356 | 356 | public function register_table() { |
357 | - $current_version = get_option( $this->table_name . '_db_version' ); |
|
358 | - if ( ! $current_version || version_compare( $current_version, $this->version, '<' ) ) { |
|
357 | + $current_version = get_option($this->table_name.'_db_version'); |
|
358 | + if ( ! $current_version || version_compare($current_version, $this->version, '<')) { |
|
359 | 359 | $this->create_table(); |
360 | 360 | } |
361 | 361 | } |
@@ -366,5 +366,5 @@ discard block |
||
366 | 366 | * @since 1.8.9 |
367 | 367 | * @access public |
368 | 368 | */ |
369 | - public function create_table(){} |
|
369 | + public function create_table() {} |
|
370 | 370 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | */ |
11 | 11 | |
12 | 12 | // Exit if accessed directly. |
13 | -if ( ! defined( 'ABSPATH' ) ) { |
|
13 | +if ( ! defined('ABSPATH')) { |
|
14 | 14 | exit; |
15 | 15 | } |
16 | 16 | |
@@ -74,57 +74,57 @@ discard block |
||
74 | 74 | public function __construct() { |
75 | 75 | |
76 | 76 | $this->use_php_sessions = $this->use_php_sessions(); |
77 | - $this->exp_option = give_get_option( 'session_lifetime' ); |
|
77 | + $this->exp_option = give_get_option('session_lifetime'); |
|
78 | 78 | |
79 | 79 | // PHP Sessions. |
80 | - if ( $this->use_php_sessions ) { |
|
80 | + if ($this->use_php_sessions) { |
|
81 | 81 | |
82 | - if ( is_multisite() ) { |
|
82 | + if (is_multisite()) { |
|
83 | 83 | |
84 | - $this->prefix = '_' . get_current_blog_id(); |
|
84 | + $this->prefix = '_'.get_current_blog_id(); |
|
85 | 85 | |
86 | 86 | } |
87 | 87 | |
88 | - add_action( 'init', array( $this, 'maybe_start_session' ), - 2 ); |
|
88 | + add_action('init', array($this, 'maybe_start_session'), - 2); |
|
89 | 89 | |
90 | 90 | } else { |
91 | 91 | |
92 | - if ( ! $this->should_start_session() ) { |
|
92 | + if ( ! $this->should_start_session()) { |
|
93 | 93 | return; |
94 | 94 | } |
95 | 95 | |
96 | 96 | // Use WP_Session. |
97 | - if ( ! defined( 'WP_SESSION_COOKIE' ) ) { |
|
98 | - define( 'WP_SESSION_COOKIE', 'give_wp_session' ); |
|
97 | + if ( ! defined('WP_SESSION_COOKIE')) { |
|
98 | + define('WP_SESSION_COOKIE', 'give_wp_session'); |
|
99 | 99 | } |
100 | 100 | |
101 | - if ( ! class_exists( 'Recursive_ArrayAccess' ) ) { |
|
102 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
101 | + if ( ! class_exists('Recursive_ArrayAccess')) { |
|
102 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-recursive-arrayaccess.php'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | // Include utilities class |
106 | - if ( ! class_exists( 'WP_Session_Utils' ) ) { |
|
107 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session-utils.php'; |
|
106 | + if ( ! class_exists('WP_Session_Utils')) { |
|
107 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session-utils.php'; |
|
108 | 108 | } |
109 | - if ( ! class_exists( 'WP_Session' ) ) { |
|
110 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/class-wp-session.php'; |
|
111 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/sessions/wp-session.php'; |
|
109 | + if ( ! class_exists('WP_Session')) { |
|
110 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/class-wp-session.php'; |
|
111 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/sessions/wp-session.php'; |
|
112 | 112 | } |
113 | 113 | |
114 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
115 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
114 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
115 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
116 | 116 | |
117 | 117 | } |
118 | 118 | |
119 | 119 | // Init Session. |
120 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
121 | - add_action( 'plugins_loaded', array( $this, 'init' ), 9999 ); |
|
120 | + if (empty($this->session) && ! $this->use_php_sessions) { |
|
121 | + add_action('plugins_loaded', array($this, 'init'), 9999); |
|
122 | 122 | } else { |
123 | - add_action( 'init', array( $this, 'init' ), - 1 ); |
|
123 | + add_action('init', array($this, 'init'), - 1); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | // Set cookie on Donation Completion page. |
127 | - add_action( 'give_pre_process_donation', array( $this, 'set_session_cookies' ) ); |
|
127 | + add_action('give_pre_process_donation', array($this, 'set_session_cookies')); |
|
128 | 128 | |
129 | 129 | } |
130 | 130 | |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function init() { |
142 | 142 | |
143 | - if ( $this->use_php_sessions ) { |
|
144 | - $this->session = isset( $_SESSION[ 'give' . $this->prefix ] ) && is_array( $_SESSION[ 'give' . $this->prefix ] ) ? $_SESSION[ 'give' . $this->prefix ] : array(); |
|
143 | + if ($this->use_php_sessions) { |
|
144 | + $this->session = isset($_SESSION['give'.$this->prefix]) && is_array($_SESSION['give'.$this->prefix]) ? $_SESSION['give'.$this->prefix] : array(); |
|
145 | 145 | } else { |
146 | 146 | $this->session = WP_Session::get_instance(); |
147 | 147 | } |
@@ -176,37 +176,37 @@ discard block |
||
176 | 176 | * |
177 | 177 | * @return string|array Session variable. |
178 | 178 | */ |
179 | - public function get( $key ) { |
|
180 | - $key = sanitize_key( $key ); |
|
179 | + public function get($key) { |
|
180 | + $key = sanitize_key($key); |
|
181 | 181 | $return = false; |
182 | 182 | |
183 | - if ( isset( $this->session[ $key ] ) && ! empty( $this->session[ $key ] ) ) { |
|
183 | + if (isset($this->session[$key]) && ! empty($this->session[$key])) { |
|
184 | 184 | |
185 | - preg_match( '/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[ $key ], $matches ); |
|
186 | - if ( ! empty( $matches ) ) { |
|
187 | - $this->set( $key, null ); |
|
185 | + preg_match('/[oO]\s*:\s*\d+\s*:\s*"\s*(?!(?i)(stdClass))/', $this->session[$key], $matches); |
|
186 | + if ( ! empty($matches)) { |
|
187 | + $this->set($key, null); |
|
188 | 188 | |
189 | 189 | return false; |
190 | 190 | } |
191 | 191 | |
192 | - if ( is_numeric( $this->session[ $key ] ) ) { |
|
193 | - $return = $this->session[ $key ]; |
|
192 | + if (is_numeric($this->session[$key])) { |
|
193 | + $return = $this->session[$key]; |
|
194 | 194 | } else { |
195 | 195 | |
196 | - $maybe_json = json_decode( $this->session[ $key ] ); |
|
196 | + $maybe_json = json_decode($this->session[$key]); |
|
197 | 197 | |
198 | 198 | // Since json_last_error is PHP 5.3+, we have to rely on a `null` value for failing to parse JSON. |
199 | - if ( is_null( $maybe_json ) ) { |
|
200 | - $is_serialized = is_serialized( $this->session[ $key ] ); |
|
201 | - if ( $is_serialized ) { |
|
202 | - $value = @unserialize( $this->session[ $key ] ); |
|
203 | - $this->set( $key, (array) $value ); |
|
199 | + if (is_null($maybe_json)) { |
|
200 | + $is_serialized = is_serialized($this->session[$key]); |
|
201 | + if ($is_serialized) { |
|
202 | + $value = @unserialize($this->session[$key]); |
|
203 | + $this->set($key, (array) $value); |
|
204 | 204 | $return = $value; |
205 | 205 | } else { |
206 | - $return = $this->session[ $key ]; |
|
206 | + $return = $this->session[$key]; |
|
207 | 207 | } |
208 | 208 | } else { |
209 | - $return = json_decode( $this->session[ $key ], true ); |
|
209 | + $return = json_decode($this->session[$key], true); |
|
210 | 210 | } |
211 | 211 | |
212 | 212 | } |
@@ -229,21 +229,21 @@ discard block |
||
229 | 229 | * |
230 | 230 | * @return string Session variable. |
231 | 231 | */ |
232 | - public function set( $key, $value ) { |
|
232 | + public function set($key, $value) { |
|
233 | 233 | |
234 | - $key = sanitize_key( $key ); |
|
234 | + $key = sanitize_key($key); |
|
235 | 235 | |
236 | - if ( is_array( $value ) ) { |
|
237 | - $this->session[ $key ] = wp_json_encode( $value ); |
|
236 | + if (is_array($value)) { |
|
237 | + $this->session[$key] = wp_json_encode($value); |
|
238 | 238 | } else { |
239 | - $this->session[ $key ] = esc_attr( $value ); |
|
239 | + $this->session[$key] = esc_attr($value); |
|
240 | 240 | } |
241 | 241 | |
242 | - if ( $this->use_php_sessions ) { |
|
243 | - $_SESSION[ 'give' . $this->prefix ] = $this->session; |
|
242 | + if ($this->use_php_sessions) { |
|
243 | + $_SESSION['give'.$this->prefix] = $this->session; |
|
244 | 244 | } |
245 | 245 | |
246 | - return $this->session[ $key ]; |
|
246 | + return $this->session[$key]; |
|
247 | 247 | } |
248 | 248 | |
249 | 249 | /** |
@@ -258,10 +258,10 @@ discard block |
||
258 | 258 | * @hook |
259 | 259 | */ |
260 | 260 | public function set_session_cookies() { |
261 | - if ( ! headers_sent() ) { |
|
262 | - $lifetime = current_time( 'timestamp' ) + $this->set_expiration_time(); |
|
263 | - @setcookie( session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
264 | - @setcookie( session_name() . '_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false ); |
|
261 | + if ( ! headers_sent()) { |
|
262 | + $lifetime = current_time('timestamp') + $this->set_expiration_time(); |
|
263 | + @setcookie(session_name(), session_id(), $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
264 | + @setcookie(session_name().'_expiration', $lifetime, $lifetime, COOKIEPATH, COOKIE_DOMAIN, false); |
|
265 | 265 | } |
266 | 266 | } |
267 | 267 | |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | */ |
278 | 278 | public function set_expiration_variant_time() { |
279 | 279 | |
280 | - return ( ! empty( $this->exp_option ) ? ( intval( $this->exp_option ) - 3600 ) : 30 * 60 * 23 ); |
|
280 | + return ( ! empty($this->exp_option) ? (intval($this->exp_option) - 3600) : 30 * 60 * 23); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public function set_expiration_time() { |
294 | 294 | |
295 | - return ( ! empty( $this->exp_option ) ? intval( $this->exp_option ) : 30 * 60 * 24 ); |
|
295 | + return ( ! empty($this->exp_option) ? intval($this->exp_option) : 30 * 60 * 24); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | $ret = false; |
311 | 311 | |
312 | 312 | // If the database variable is already set, no need to run auto detection. |
313 | - $give_use_php_sessions = (bool) get_option( 'give_use_php_sessions' ); |
|
313 | + $give_use_php_sessions = (bool) get_option('give_use_php_sessions'); |
|
314 | 314 | |
315 | - if ( ! $give_use_php_sessions ) { |
|
315 | + if ( ! $give_use_php_sessions) { |
|
316 | 316 | |
317 | 317 | // Attempt to detect if the server supports PHP sessions. |
318 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
318 | + if (function_exists('session_start') && ! ini_get('safe_mode')) { |
|
319 | 319 | |
320 | - $this->set( 'give_use_php_sessions', 1 ); |
|
320 | + $this->set('give_use_php_sessions', 1); |
|
321 | 321 | |
322 | - if ( $this->get( 'give_use_php_sessions' ) ) { |
|
322 | + if ($this->get('give_use_php_sessions')) { |
|
323 | 323 | |
324 | 324 | $ret = true; |
325 | 325 | |
326 | 326 | // Set the database option. |
327 | - update_option( 'give_use_php_sessions', true ); |
|
327 | + update_option('give_use_php_sessions', true); |
|
328 | 328 | |
329 | 329 | } |
330 | 330 | } |
@@ -334,13 +334,13 @@ discard block |
||
334 | 334 | } |
335 | 335 | |
336 | 336 | // Enable or disable PHP Sessions based on the GIVE_USE_PHP_SESSIONS constant. |
337 | - if ( defined( 'GIVE_USE_PHP_SESSIONS' ) && GIVE_USE_PHP_SESSIONS ) { |
|
337 | + if (defined('GIVE_USE_PHP_SESSIONS') && GIVE_USE_PHP_SESSIONS) { |
|
338 | 338 | $ret = true; |
339 | - } elseif ( defined( 'GIVE_USE_PHP_SESSIONS' ) && ! GIVE_USE_PHP_SESSIONS ) { |
|
339 | + } elseif (defined('GIVE_USE_PHP_SESSIONS') && ! GIVE_USE_PHP_SESSIONS) { |
|
340 | 340 | $ret = false; |
341 | 341 | } |
342 | 342 | |
343 | - return (bool) apply_filters( 'give_use_php_sessions', $ret ); |
|
343 | + return (bool) apply_filters('give_use_php_sessions', $ret); |
|
344 | 344 | } |
345 | 345 | |
346 | 346 | /** |
@@ -357,9 +357,9 @@ discard block |
||
357 | 357 | |
358 | 358 | $start_session = true; |
359 | 359 | |
360 | - if ( ! empty( $_SERVER['REQUEST_URI'] ) ) { |
|
360 | + if ( ! empty($_SERVER['REQUEST_URI'])) { |
|
361 | 361 | |
362 | - $blacklist = apply_filters( 'give_session_start_uri_blacklist', array( |
|
362 | + $blacklist = apply_filters('give_session_start_uri_blacklist', array( |
|
363 | 363 | 'feed', |
364 | 364 | 'feed', |
365 | 365 | 'feed/rss', |
@@ -367,21 +367,21 @@ discard block |
||
367 | 367 | 'feed/rdf', |
368 | 368 | 'feed/atom', |
369 | 369 | 'comments/feed/', |
370 | - ) ); |
|
371 | - $uri = ltrim( $_SERVER['REQUEST_URI'], '/' ); |
|
372 | - $uri = untrailingslashit( $uri ); |
|
373 | - if ( in_array( $uri, $blacklist ) ) { |
|
370 | + )); |
|
371 | + $uri = ltrim($_SERVER['REQUEST_URI'], '/'); |
|
372 | + $uri = untrailingslashit($uri); |
|
373 | + if (in_array($uri, $blacklist)) { |
|
374 | 374 | $start_session = false; |
375 | 375 | } |
376 | - if ( false !== strpos( $uri, 'feed=' ) ) { |
|
376 | + if (false !== strpos($uri, 'feed=')) { |
|
377 | 377 | $start_session = false; |
378 | 378 | } |
379 | - if ( is_admin() ) { |
|
379 | + if (is_admin()) { |
|
380 | 380 | $start_session = false; |
381 | 381 | } |
382 | 382 | } |
383 | 383 | |
384 | - return apply_filters( 'give_start_session', $start_session ); |
|
384 | + return apply_filters('give_start_session', $start_session); |
|
385 | 385 | } |
386 | 386 | |
387 | 387 | /** |
@@ -397,11 +397,11 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function maybe_start_session() { |
399 | 399 | |
400 | - if ( ! $this->should_start_session() ) { |
|
400 | + if ( ! $this->should_start_session()) { |
|
401 | 401 | return; |
402 | 402 | } |
403 | 403 | |
404 | - if ( ! session_id() && ! headers_sent() ) { |
|
404 | + if ( ! session_id() && ! headers_sent()) { |
|
405 | 405 | session_start(); |
406 | 406 | } |
407 | 407 | |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | |
421 | 421 | $expiration = false; |
422 | 422 | |
423 | - if ( session_id() && isset( $_COOKIE[ session_name() . '_expiration' ] ) ) { |
|
423 | + if (session_id() && isset($_COOKIE[session_name().'_expiration'])) { |
|
424 | 424 | |
425 | - $expiration = date( 'D, d M Y h:i:s', intval( $_COOKIE[ session_name() . '_expiration' ] ) ); |
|
425 | + $expiration = date('D, d M Y h:i:s', intval($_COOKIE[session_name().'_expiration'])); |
|
426 | 426 | |
427 | 427 | } |
428 | 428 |
@@ -70,24 +70,24 @@ discard block |
||
70 | 70 | * |
71 | 71 | * @param array $args |
72 | 72 | */ |
73 | - public function register( $args ) { |
|
73 | + public function register($args) { |
|
74 | 74 | $args_default = array( |
75 | 75 | 'id' => '', |
76 | 76 | 'version' => '', |
77 | 77 | 'callback' => '', |
78 | 78 | ); |
79 | 79 | |
80 | - $args = wp_parse_args( $args, $args_default ); |
|
80 | + $args = wp_parse_args($args, $args_default); |
|
81 | 81 | |
82 | 82 | // You can only register database upgrade. |
83 | 83 | $args['type'] = 'database'; |
84 | 84 | |
85 | 85 | // Bailout. |
86 | - if ( empty( $args['id'] ) || empty( $args['version'] ) || empty( $args['callback'] ) || ! is_callable( $args['callback'] ) ) { |
|
86 | + if (empty($args['id']) || empty($args['version']) || empty($args['callback']) || ! is_callable($args['callback'])) { |
|
87 | 87 | return; |
88 | 88 | } |
89 | 89 | |
90 | - $this->updates[ $args['type'] ][] = $args; |
|
90 | + $this->updates[$args['type']][] = $args; |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | |
@@ -102,32 +102,32 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - public function get_updates( $update_type = '', $status = 'all' ) { |
|
105 | + public function get_updates($update_type = '', $status = 'all') { |
|
106 | 106 | // return all updates. |
107 | - if ( empty( $update_type ) ) { |
|
107 | + if (empty($update_type)) { |
|
108 | 108 | return $this->updates; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // Get specific update. |
112 | - $updates = ! empty( $this->updates[ $update_type ] ) ? $this->updates[ $update_type ] : array(); |
|
112 | + $updates = ! empty($this->updates[$update_type]) ? $this->updates[$update_type] : array(); |
|
113 | 113 | |
114 | 114 | // Bailout. |
115 | - if ( empty( $updates ) ) { |
|
115 | + if (empty($updates)) { |
|
116 | 116 | return $updates; |
117 | 117 | } |
118 | 118 | |
119 | - switch ( $status ) { |
|
119 | + switch ($status) { |
|
120 | 120 | case 'new': |
121 | 121 | // Remove already completed updates. |
122 | 122 | $completed_updates = give_get_completed_upgrades(); |
123 | 123 | |
124 | - if ( ! empty( $completed_updates ) ) { |
|
125 | - foreach ( $updates as $index => $update ) { |
|
126 | - if ( in_array( $update['id'], $completed_updates ) ) { |
|
127 | - unset( $updates[ $index ] ); |
|
124 | + if ( ! empty($completed_updates)) { |
|
125 | + foreach ($updates as $index => $update) { |
|
126 | + if (in_array($update['id'], $completed_updates)) { |
|
127 | + unset($updates[$index]); |
|
128 | 128 | } |
129 | 129 | } |
130 | - $updates = array_values( $updates ); |
|
130 | + $updates = array_values($updates); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | break; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @return static |
145 | 145 | */ |
146 | 146 | static function get_instance() { |
147 | - if ( is_null( self::$instance ) ) { |
|
147 | + if (is_null(self::$instance)) { |
|
148 | 148 | self::$instance = new self(); |
149 | 149 | } |
150 | 150 | |
@@ -162,16 +162,16 @@ discard block |
||
162 | 162 | /** |
163 | 163 | * Setup hooks. |
164 | 164 | */ |
165 | - add_action( 'init', array( $this, '__register_upgrade' ), 9999 ); |
|
166 | - add_action( 'admin_init', array( $this, '__change_donations_label' ), 9999 ); |
|
167 | - add_action( 'admin_menu', array( $this, '__register_menu' ), 9999 ); |
|
168 | - add_action( 'give_set_upgrade_completed', array( $this, '__flush_resume_updates' ), 9999 ); |
|
169 | - add_action( 'wp_ajax_give_do_ajax_updates', array( $this, '__give_ajax_updates' ) ); |
|
165 | + add_action('init', array($this, '__register_upgrade'), 9999); |
|
166 | + add_action('admin_init', array($this, '__change_donations_label'), 9999); |
|
167 | + add_action('admin_menu', array($this, '__register_menu'), 9999); |
|
168 | + add_action('give_set_upgrade_completed', array($this, '__flush_resume_updates'), 9999); |
|
169 | + add_action('wp_ajax_give_do_ajax_updates', array($this, '__give_ajax_updates')); |
|
170 | 170 | |
171 | 171 | /** |
172 | 172 | * Load file |
173 | 173 | */ |
174 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
174 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | /** |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | $addons = give_get_plugins(); |
185 | 185 | $plugin_updates = get_plugin_updates(); |
186 | 186 | |
187 | - foreach ( $addons as $key => $info ) { |
|
188 | - if ( 'active' != $info['Status'] || 'add-on' != $info['Type'] || empty( $plugin_updates[ $key ] ) ) { |
|
187 | + foreach ($addons as $key => $info) { |
|
188 | + if ('active' != $info['Status'] || 'add-on' != $info['Type'] || empty($plugin_updates[$key])) { |
|
189 | 189 | continue; |
190 | 190 | } |
191 | 191 | |
192 | - $this->updates['plugin'][] = array_merge( $info, (array) $plugin_updates[ $key ] ); |
|
192 | + $this->updates['plugin'][] = array_merge($info, (array) $plugin_updates[$key]); |
|
193 | 193 | } |
194 | 194 | } |
195 | 195 | |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | * @access public |
202 | 202 | */ |
203 | 203 | public function __register_upgrade() { |
204 | - if ( ! is_admin() ) { |
|
204 | + if ( ! is_admin()) { |
|
205 | 205 | return; |
206 | 206 | } |
207 | 207 | |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | * |
211 | 211 | * @since 1.8.12 |
212 | 212 | */ |
213 | - do_action( 'give_register_updates', $this ); |
|
213 | + do_action('give_register_updates', $this); |
|
214 | 214 | } |
215 | 215 | |
216 | 216 | /** |
@@ -224,17 +224,17 @@ discard block |
||
224 | 224 | global $submenu; |
225 | 225 | |
226 | 226 | // Bailout. |
227 | - if ( empty( $menu ) || ! $this->get_update_count() ) { |
|
227 | + if (empty($menu) || ! $this->get_update_count()) { |
|
228 | 228 | return; |
229 | 229 | } |
230 | 230 | |
231 | - foreach ( $menu as $index => $menu_item ) { |
|
232 | - if ( 'edit.php?post_type=give_forms' !== $menu_item[2] ) { |
|
231 | + foreach ($menu as $index => $menu_item) { |
|
232 | + if ('edit.php?post_type=give_forms' !== $menu_item[2]) { |
|
233 | 233 | continue; |
234 | 234 | } |
235 | 235 | |
236 | - $menu[ $index ][0] = sprintf( |
|
237 | - __( 'Donations %s', 'give' ), |
|
236 | + $menu[$index][0] = sprintf( |
|
237 | + __('Donations %s', 'give'), |
|
238 | 238 | sprintf( |
239 | 239 | '<span class="update-plugins count-%1$d"><span class="plugin-count">%1$d</span></span>', |
240 | 240 | $this->get_update_count() |
@@ -259,15 +259,15 @@ discard block |
||
259 | 259 | // Bailout. |
260 | 260 | if ( ! $this->get_update_count()) { |
261 | 261 | // Show complete update message if still on update setting page. |
262 | - if ( isset($_GET['page']) && 'give-updates' === $_GET['page'] ) { |
|
262 | + if (isset($_GET['page']) && 'give-updates' === $_GET['page']) { |
|
263 | 263 | // Upgrades |
264 | 264 | add_submenu_page( |
265 | 265 | 'edit.php?post_type=give_forms', |
266 | - esc_html__( 'Give Updates Complete', 'give' ), |
|
267 | - __( 'Updates', 'give' ), |
|
266 | + esc_html__('Give Updates Complete', 'give'), |
|
267 | + __('Updates', 'give'), |
|
268 | 268 | 'manage_give_settings', |
269 | 269 | 'give-updates', |
270 | - array( $this, 'render_complete_page' ) |
|
270 | + array($this, 'render_complete_page') |
|
271 | 271 | ); |
272 | 272 | } |
273 | 273 | |
@@ -277,15 +277,15 @@ discard block |
||
277 | 277 | // Upgrades |
278 | 278 | add_submenu_page( |
279 | 279 | 'edit.php?post_type=give_forms', |
280 | - esc_html__( 'Give Updates', 'give' ), |
|
280 | + esc_html__('Give Updates', 'give'), |
|
281 | 281 | sprintf( |
282 | 282 | '%1$s <span class="update-plugins count-%2$d"><span class="plugin-count">%2$d</span></span>', |
283 | - __( 'Updates', 'give' ), |
|
283 | + __('Updates', 'give'), |
|
284 | 284 | $this->get_update_count() |
285 | 285 | ), |
286 | 286 | 'manage_give_settings', |
287 | 287 | 'give-updates', |
288 | - array( $this, 'render_page' ) |
|
288 | + array($this, 'render_page') |
|
289 | 289 | ); |
290 | 290 | } |
291 | 291 | |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | * @return int |
298 | 298 | */ |
299 | 299 | public function get_db_update_count() { |
300 | - return count( $this->get_updates( 'database', 'new' ) ); |
|
300 | + return count($this->get_updates('database', 'new')); |
|
301 | 301 | } |
302 | 302 | |
303 | 303 | /** |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | * @access public |
308 | 308 | */ |
309 | 309 | public function render_complete_page() { |
310 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades-complete.php'; |
|
310 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades-complete.php'; |
|
311 | 311 | } |
312 | 312 | |
313 | 313 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @access public |
318 | 318 | */ |
319 | 319 | public function render_page() { |
320 | - include_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/views/upgrades.php'; |
|
320 | + include_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/views/upgrades.php'; |
|
321 | 321 | } |
322 | 322 | |
323 | 323 | /** |
@@ -328,7 +328,7 @@ discard block |
||
328 | 328 | * @return int |
329 | 329 | */ |
330 | 330 | public function get_plugin_update_count() { |
331 | - return count( $this->get_updates( 'plugin' ) ); |
|
331 | + return count($this->get_updates('plugin')); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | $db_update_count = $this->get_db_update_count(); |
344 | 344 | $plugin_update_count = $this->get_plugin_update_count(); |
345 | 345 | |
346 | - return ( $db_update_count + $plugin_update_count ); |
|
346 | + return ($db_update_count + $plugin_update_count); |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | |
@@ -354,12 +354,12 @@ discard block |
||
354 | 354 | * @access public |
355 | 355 | */ |
356 | 356 | public function __flush_resume_updates() { |
357 | - delete_option( 'give_doing_upgrade' ); |
|
358 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
357 | + delete_option('give_doing_upgrade'); |
|
358 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
359 | 359 | |
360 | 360 | // Reset counter. |
361 | 361 | $this->step = $this->percentage = 0; |
362 | - ++ $this->update; |
|
362 | + ++$this->update; |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | /** |
@@ -370,24 +370,24 @@ discard block |
||
370 | 370 | */ |
371 | 371 | public function __give_ajax_updates() { |
372 | 372 | // Check permission. |
373 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
373 | + if ( ! current_user_can('manage_give_settings')) { |
|
374 | 374 | $this->send_ajax_response( |
375 | 375 | array( |
376 | - 'message' => esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), |
|
376 | + 'message' => esc_html__('You do not have permission to do Give upgrades.', 'give'), |
|
377 | 377 | ), |
378 | 378 | 'error' |
379 | 379 | ); |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Set params. |
383 | - $this->step = absint( $_POST['step'] ); |
|
384 | - $this->update = absint( $_POST['update'] ); |
|
383 | + $this->step = absint($_POST['step']); |
|
384 | + $this->update = absint($_POST['update']); |
|
385 | 385 | |
386 | 386 | // Bailout: step and update must be positive and greater then zero. |
387 | - if ( ! $this->step ) { |
|
387 | + if ( ! $this->step) { |
|
388 | 388 | $this->send_ajax_response( |
389 | 389 | array( |
390 | - 'message' => __( 'Please reload this page and try again', 'give' ), |
|
390 | + 'message' => __('Please reload this page and try again', 'give'), |
|
391 | 391 | 'heading' => '', |
392 | 392 | 'percentage' => 0, |
393 | 393 | ), |
@@ -396,14 +396,14 @@ discard block |
||
396 | 396 | } |
397 | 397 | |
398 | 398 | // Get updates. |
399 | - $updates = $this->get_updates( 'database', 'new' ); |
|
399 | + $updates = $this->get_updates('database', 'new'); |
|
400 | 400 | |
401 | 401 | // Bailout if we do not have nay updates. |
402 | - if ( empty( $updates ) ) { |
|
402 | + if (empty($updates)) { |
|
403 | 403 | $this->send_ajax_response( |
404 | 404 | array( |
405 | - 'message' => __( 'The database is already up to date.', 'give' ), |
|
406 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
405 | + 'message' => __('The database is already up to date.', 'give'), |
|
406 | + 'heading' => __('Updates Completed.', 'give'), |
|
407 | 407 | 'percentage' => 0, |
408 | 408 | ), |
409 | 409 | 'success' |
@@ -411,26 +411,26 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | // Process update. |
414 | - foreach ( $updates as $index => $update ) { |
|
414 | + foreach ($updates as $index => $update) { |
|
415 | 415 | // Check if update depend upon any other update. |
416 | - if ( ! empty( $update['depend'] ) && ! give_has_upgrade_completed( $update['depend'] ) ) { |
|
416 | + if ( ! empty($update['depend']) && ! give_has_upgrade_completed($update['depend'])) { |
|
417 | 417 | continue; |
418 | 418 | } |
419 | 419 | |
420 | 420 | // Run update. |
421 | - if ( is_array( $update['callback'] ) ) { |
|
421 | + if (is_array($update['callback'])) { |
|
422 | 422 | $update['callback'][0]->$update['callback'][1](); |
423 | 423 | } else { |
424 | 424 | $update['callback'](); |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Check if current update completed or not. |
428 | - if ( give_has_upgrade_completed( $update['id'] ) ) { |
|
429 | - if ( 1 === count( $updates ) ) { |
|
428 | + if (give_has_upgrade_completed($update['id'])) { |
|
429 | + if (1 === count($updates)) { |
|
430 | 430 | $this->send_ajax_response( |
431 | 431 | array( |
432 | - 'message' => __( 'Database updated successfully.', 'give' ), |
|
433 | - 'heading' => __( 'Updates Completed.', 'give' ), |
|
432 | + 'message' => __('Database updated successfully.', 'give'), |
|
433 | + 'heading' => __('Updates Completed.', 'give'), |
|
434 | 434 | 'percentage' => 0, |
435 | 435 | ), |
436 | 436 | 'success' |
@@ -440,16 +440,16 @@ discard block |
||
440 | 440 | |
441 | 441 | $doing_upgrade_args = array( |
442 | 442 | 'update_info' => $update, |
443 | - 'step' => ++ $this->step, |
|
443 | + 'step' => ++$this->step, |
|
444 | 444 | 'update' => $this->update, |
445 | - 'heading' => sprintf( 'Update %s of {update_count}', $this->update ), |
|
445 | + 'heading' => sprintf('Update %s of {update_count}', $this->update), |
|
446 | 446 | 'percentage' => $this->percentage, |
447 | 447 | ); |
448 | 448 | |
449 | 449 | // Cache upgrade. |
450 | - update_option( 'give_doing_upgrade', $doing_upgrade_args ); |
|
450 | + update_option('give_doing_upgrade', $doing_upgrade_args); |
|
451 | 451 | |
452 | - $this->send_ajax_response( $doing_upgrade_args ); |
|
452 | + $this->send_ajax_response($doing_upgrade_args); |
|
453 | 453 | }// End foreach(). |
454 | 454 | } |
455 | 455 | |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | * @param $data |
463 | 463 | * @param string $type |
464 | 464 | */ |
465 | - public function send_ajax_response( $data, $type = '' ) { |
|
465 | + public function send_ajax_response($data, $type = '') { |
|
466 | 466 | $default = array( |
467 | 467 | 'message' => '', |
468 | 468 | 'heading' => '', |
@@ -472,21 +472,21 @@ discard block |
||
472 | 472 | ); |
473 | 473 | |
474 | 474 | // Set data. |
475 | - $data = wp_parse_args( $data, $default ); |
|
475 | + $data = wp_parse_args($data, $default); |
|
476 | 476 | |
477 | - switch ( $type ) { |
|
477 | + switch ($type) { |
|
478 | 478 | case 'success': |
479 | - wp_send_json_success( $data ); |
|
479 | + wp_send_json_success($data); |
|
480 | 480 | break; |
481 | 481 | |
482 | 482 | case 'error': |
483 | - wp_send_json_error( $data ); |
|
483 | + wp_send_json_error($data); |
|
484 | 484 | break; |
485 | 485 | |
486 | 486 | default: |
487 | - wp_send_json( array( |
|
487 | + wp_send_json(array( |
|
488 | 488 | 'data' => $data, |
489 | - ) ); |
|
489 | + )); |
|
490 | 490 | break; |
491 | 491 | } |
492 | 492 | } |
@@ -503,8 +503,8 @@ discard block |
||
503 | 503 | public function resume_updates() { |
504 | 504 | $status = false; |
505 | 505 | |
506 | - if ( $update = get_option( 'give_doing_upgrade' ) ) { |
|
507 | - $status = ! empty( $update['step'] ) ? $update['step'] : $status; |
|
506 | + if ($update = get_option('give_doing_upgrade')) { |
|
507 | + $status = ! empty($update['step']) ? $update['step'] : $status; |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | return $status; |
@@ -520,12 +520,12 @@ discard block |
||
520 | 520 | * @param $total |
521 | 521 | * @param $current_total |
522 | 522 | */ |
523 | - public function set_percentage( $total, $current_total ) { |
|
523 | + public function set_percentage($total, $current_total) { |
|
524 | 524 | // Set percentage. |
525 | - $this->percentage = $total ? ( ( $current_total ) / $total ) * 100 : 0; |
|
525 | + $this->percentage = $total ? (($current_total) / $total) * 100 : 0; |
|
526 | 526 | |
527 | 527 | // Verify percentage. |
528 | - $this->percentage = ( 100 < $this->percentage ) ? 100 : $this->percentage; |
|
528 | + $this->percentage = (100 < $this->percentage) ? 100 : $this->percentage; |
|
529 | 529 | } |
530 | 530 | } |
531 | 531 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | |
14 | 14 | // Exit if accessed directly. |
15 | -if ( ! defined( 'ABSPATH' ) ) { |
|
15 | +if ( ! defined('ABSPATH')) { |
|
16 | 16 | exit; |
17 | 17 | } |
18 | 18 | |
@@ -25,56 +25,56 @@ discard block |
||
25 | 25 | */ |
26 | 26 | function give_do_automatic_upgrades() { |
27 | 27 | $did_upgrade = false; |
28 | - $give_version = preg_replace( '/[^0-9.].*/', '', get_option( 'give_version' ) ); |
|
28 | + $give_version = preg_replace('/[^0-9.].*/', '', get_option('give_version')); |
|
29 | 29 | |
30 | - if ( ! $give_version ) { |
|
30 | + if ( ! $give_version) { |
|
31 | 31 | // 1.0 is the first version to use this option so we must add it. |
32 | 32 | $give_version = '1.0'; |
33 | 33 | } |
34 | 34 | |
35 | - switch ( true ) { |
|
35 | + switch (true) { |
|
36 | 36 | |
37 | - case version_compare( $give_version, '1.6', '<' ) : |
|
37 | + case version_compare($give_version, '1.6', '<') : |
|
38 | 38 | give_v16_upgrades(); |
39 | 39 | $did_upgrade = true; |
40 | 40 | |
41 | - case version_compare( $give_version, '1.7', '<' ) : |
|
41 | + case version_compare($give_version, '1.7', '<') : |
|
42 | 42 | give_v17_upgrades(); |
43 | 43 | $did_upgrade = true; |
44 | 44 | |
45 | - case version_compare( $give_version, '1.8', '<' ) : |
|
45 | + case version_compare($give_version, '1.8', '<') : |
|
46 | 46 | give_v18_upgrades(); |
47 | 47 | $did_upgrade = true; |
48 | 48 | |
49 | - case version_compare( $give_version, '1.8.7', '<' ) : |
|
49 | + case version_compare($give_version, '1.8.7', '<') : |
|
50 | 50 | give_v187_upgrades(); |
51 | 51 | $did_upgrade = true; |
52 | 52 | |
53 | - case version_compare( $give_version, '1.8.8', '<' ) : |
|
53 | + case version_compare($give_version, '1.8.8', '<') : |
|
54 | 54 | give_v188_upgrades(); |
55 | 55 | $did_upgrade = true; |
56 | 56 | |
57 | - case version_compare( $give_version, '1.8.9', '<' ) : |
|
57 | + case version_compare($give_version, '1.8.9', '<') : |
|
58 | 58 | give_v189_upgrades(); |
59 | 59 | $did_upgrade = true; |
60 | 60 | |
61 | - case version_compare( $give_version, '1.8.12', '<' ) : |
|
61 | + case version_compare($give_version, '1.8.12', '<') : |
|
62 | 62 | give_v1812_upgrades(); |
63 | 63 | $did_upgrade = true; |
64 | 64 | |
65 | - case version_compare( $give_version, '1.8.13', '<' ) : |
|
65 | + case version_compare($give_version, '1.8.13', '<') : |
|
66 | 66 | give_v1813_upgrades(); |
67 | 67 | $did_upgrade = true; |
68 | 68 | |
69 | 69 | } |
70 | 70 | |
71 | - if ( $did_upgrade ) { |
|
72 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
71 | + if ($did_upgrade) { |
|
72 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
73 | 73 | } |
74 | 74 | } |
75 | 75 | |
76 | -add_action( 'admin_init', 'give_do_automatic_upgrades' ); |
|
77 | -add_action( 'give_upgrades', 'give_do_automatic_upgrades' ); |
|
76 | +add_action('admin_init', 'give_do_automatic_upgrades'); |
|
77 | +add_action('give_upgrades', 'give_do_automatic_upgrades'); |
|
78 | 78 | |
79 | 79 | /** |
80 | 80 | * Display Upgrade Notices |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * |
87 | 87 | * @return void |
88 | 88 | */ |
89 | -function give_show_upgrade_notices( $give_updates ) { |
|
89 | +function give_show_upgrade_notices($give_updates) { |
|
90 | 90 | // v1.3.2 Upgrades |
91 | 91 | $give_updates->register( |
92 | 92 | array( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ); |
153 | 153 | } |
154 | 154 | |
155 | -add_action( 'give_register_updates', 'give_show_upgrade_notices' ); |
|
155 | +add_action('give_register_updates', 'give_show_upgrade_notices'); |
|
156 | 156 | |
157 | 157 | /** |
158 | 158 | * Triggers all upgrade functions |
@@ -164,29 +164,29 @@ discard block |
||
164 | 164 | */ |
165 | 165 | function give_trigger_upgrades() { |
166 | 166 | |
167 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
168 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
167 | + if ( ! current_user_can('manage_give_settings')) { |
|
168 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
169 | 169 | 'response' => 403, |
170 | - ) ); |
|
170 | + )); |
|
171 | 171 | } |
172 | 172 | |
173 | - $give_version = get_option( 'give_version' ); |
|
173 | + $give_version = get_option('give_version'); |
|
174 | 174 | |
175 | - if ( ! $give_version ) { |
|
175 | + if ( ! $give_version) { |
|
176 | 176 | // 1.0 is the first version to use this option so we must add it. |
177 | 177 | $give_version = '1.0'; |
178 | - add_option( 'give_version', $give_version ); |
|
178 | + add_option('give_version', $give_version); |
|
179 | 179 | } |
180 | 180 | |
181 | - update_option( 'give_version', GIVE_VERSION ); |
|
182 | - delete_option( 'give_doing_upgrade' ); |
|
181 | + update_option('give_version', GIVE_VERSION); |
|
182 | + delete_option('give_doing_upgrade'); |
|
183 | 183 | |
184 | - if ( DOING_AJAX ) { |
|
185 | - die( 'complete' ); |
|
184 | + if (DOING_AJAX) { |
|
185 | + die('complete'); |
|
186 | 186 | } // End if(). |
187 | 187 | } |
188 | 188 | |
189 | -add_action( 'wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades' ); |
|
189 | +add_action('wp_ajax_give_trigger_upgrades', 'give_trigger_upgrades'); |
|
190 | 190 | |
191 | 191 | |
192 | 192 | /** |
@@ -202,24 +202,24 @@ discard block |
||
202 | 202 | /* @var Give_Updates $give_updates */ |
203 | 203 | $give_updates = Give_Updates::get_instance(); |
204 | 204 | |
205 | - if ( ! current_user_can( 'manage_give_settings' ) ) { |
|
206 | - wp_die( esc_html__( 'You do not have permission to do Give upgrades.', 'give' ), esc_html__( 'Error', 'give' ), array( |
|
205 | + if ( ! current_user_can('manage_give_settings')) { |
|
206 | + wp_die(esc_html__('You do not have permission to do Give upgrades.', 'give'), esc_html__('Error', 'give'), array( |
|
207 | 207 | 'response' => 403, |
208 | - ) ); |
|
208 | + )); |
|
209 | 209 | } |
210 | 210 | |
211 | - ignore_user_abort( true ); |
|
211 | + ignore_user_abort(true); |
|
212 | 212 | |
213 | - if ( ! give_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) ) { |
|
214 | - @set_time_limit( 0 ); |
|
213 | + if ( ! give_is_func_disabled('set_time_limit') && ! ini_get('safe_mode')) { |
|
214 | + @set_time_limit(0); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | // UPDATE DB METAKEYS. |
218 | 218 | $sql = "UPDATE $wpdb->postmeta SET meta_key = '_give_payment_customer_id' WHERE meta_key = '_give_payment_donor_id'"; |
219 | - $query = $wpdb->query( $sql ); |
|
219 | + $query = $wpdb->query($sql); |
|
220 | 220 | |
221 | 221 | $give_updates->percentage = 100; |
222 | - give_set_upgrade_complete( 'upgrade_give_payment_customer_id' ); |
|
222 | + give_set_upgrade_complete('upgrade_give_payment_customer_id'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | |
@@ -243,24 +243,24 @@ discard block |
||
243 | 243 | $where .= "AND ( p.post_status = 'abandoned' )"; |
244 | 244 | $where .= "AND ( m.meta_key = '_give_payment_gateway' AND m.meta_value = 'offline' )"; |
245 | 245 | |
246 | - $sql = $select . $join . $where; |
|
247 | - $found_payments = $wpdb->get_col( $sql ); |
|
246 | + $sql = $select.$join.$where; |
|
247 | + $found_payments = $wpdb->get_col($sql); |
|
248 | 248 | |
249 | - foreach ( $found_payments as $payment ) { |
|
249 | + foreach ($found_payments as $payment) { |
|
250 | 250 | |
251 | 251 | // Only change ones marked abandoned since our release last week because the admin may have marked some abandoned themselves. |
252 | - $modified_time = get_post_modified_time( 'U', false, $payment ); |
|
252 | + $modified_time = get_post_modified_time('U', false, $payment); |
|
253 | 253 | |
254 | 254 | // 1450124863 = 12/10/2015 20:42:25. |
255 | - if ( $modified_time >= 1450124863 ) { |
|
255 | + if ($modified_time >= 1450124863) { |
|
256 | 256 | |
257 | - give_update_payment_status( $payment, 'pending' ); |
|
257 | + give_update_payment_status($payment, 'pending'); |
|
258 | 258 | |
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | $give_updates->percentage = 100; |
263 | - give_set_upgrade_complete( 'upgrade_give_offline_status' ); |
|
263 | + give_set_upgrade_complete('upgrade_give_offline_status'); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | |
@@ -273,17 +273,17 @@ discard block |
||
273 | 273 | */ |
274 | 274 | function give_v152_cleanup_users() { |
275 | 275 | |
276 | - $give_version = get_option( 'give_version' ); |
|
276 | + $give_version = get_option('give_version'); |
|
277 | 277 | |
278 | - if ( ! $give_version ) { |
|
278 | + if ( ! $give_version) { |
|
279 | 279 | // 1.0 is the first version to use this option so we must add it. |
280 | 280 | $give_version = '1.0'; |
281 | 281 | } |
282 | 282 | |
283 | - $give_version = preg_replace( '/[^0-9.].*/', '', $give_version ); |
|
283 | + $give_version = preg_replace('/[^0-9.].*/', '', $give_version); |
|
284 | 284 | |
285 | 285 | // v1.5.2 Upgrades |
286 | - if ( version_compare( $give_version, '1.5.2', '<' ) || ! give_has_upgrade_completed( 'upgrade_give_user_caps_cleanup' ) ) { |
|
286 | + if (version_compare($give_version, '1.5.2', '<') || ! give_has_upgrade_completed('upgrade_give_user_caps_cleanup')) { |
|
287 | 287 | |
288 | 288 | // Delete all caps with "ss". |
289 | 289 | // Also delete all unused "campaign" roles. |
@@ -330,9 +330,9 @@ discard block |
||
330 | 330 | ); |
331 | 331 | |
332 | 332 | global $wp_roles; |
333 | - foreach ( $delete_caps as $cap ) { |
|
334 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
335 | - $wp_roles->remove_cap( $role, $cap ); |
|
333 | + foreach ($delete_caps as $cap) { |
|
334 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
335 | + $wp_roles->remove_cap($role, $cap); |
|
336 | 336 | } |
337 | 337 | } |
338 | 338 | |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | $roles->add_caps(); |
343 | 343 | |
344 | 344 | // The Update Ran. |
345 | - update_option( 'give_version', preg_replace( '/[^0-9.].*/', '', GIVE_VERSION ) ); |
|
346 | - give_set_upgrade_complete( 'upgrade_give_user_caps_cleanup' ); |
|
347 | - delete_option( 'give_doing_upgrade' ); |
|
345 | + update_option('give_version', preg_replace('/[^0-9.].*/', '', GIVE_VERSION)); |
|
346 | + give_set_upgrade_complete('upgrade_give_user_caps_cleanup'); |
|
347 | + delete_option('give_doing_upgrade'); |
|
348 | 348 | |
349 | 349 | }// End if(). |
350 | 350 | |
351 | 351 | } |
352 | 352 | |
353 | -add_action( 'admin_init', 'give_v152_cleanup_users' ); |
|
353 | +add_action('admin_init', 'give_v152_cleanup_users'); |
|
354 | 354 | |
355 | 355 | /** |
356 | 356 | * 1.6 Upgrade routine to create the customer meta table. |
@@ -393,53 +393,53 @@ discard block |
||
393 | 393 | |
394 | 394 | // Get addons license key. |
395 | 395 | $addons = array(); |
396 | - foreach ( $give_options as $key => $value ) { |
|
397 | - if ( false !== strpos( $key, '_license_key' ) ) { |
|
398 | - $addons[ $key ] = $value; |
|
396 | + foreach ($give_options as $key => $value) { |
|
397 | + if (false !== strpos($key, '_license_key')) { |
|
398 | + $addons[$key] = $value; |
|
399 | 399 | } |
400 | 400 | } |
401 | 401 | |
402 | 402 | // Bailout: We do not have any addon license data to upgrade. |
403 | - if ( empty( $addons ) ) { |
|
403 | + if (empty($addons)) { |
|
404 | 404 | return false; |
405 | 405 | } |
406 | 406 | |
407 | - foreach ( $addons as $key => $addon_license ) { |
|
407 | + foreach ($addons as $key => $addon_license) { |
|
408 | 408 | |
409 | 409 | // Get addon shortname. |
410 | - $shortname = str_replace( '_license_key', '', $key ); |
|
410 | + $shortname = str_replace('_license_key', '', $key); |
|
411 | 411 | |
412 | 412 | // Addon license option name. |
413 | - $addon_license_option_name = $shortname . '_license_active'; |
|
413 | + $addon_license_option_name = $shortname.'_license_active'; |
|
414 | 414 | |
415 | 415 | // bailout if license is empty. |
416 | - if ( empty( $addon_license ) ) { |
|
417 | - delete_option( $addon_license_option_name ); |
|
416 | + if (empty($addon_license)) { |
|
417 | + delete_option($addon_license_option_name); |
|
418 | 418 | continue; |
419 | 419 | } |
420 | 420 | |
421 | 421 | // Get addon name. |
422 | 422 | $addon_name = array(); |
423 | - $addon_name_parts = explode( '_', str_replace( 'give_', '', $shortname ) ); |
|
424 | - foreach ( $addon_name_parts as $name_part ) { |
|
423 | + $addon_name_parts = explode('_', str_replace('give_', '', $shortname)); |
|
424 | + foreach ($addon_name_parts as $name_part) { |
|
425 | 425 | |
426 | 426 | // Fix addon name |
427 | - switch ( $name_part ) { |
|
427 | + switch ($name_part) { |
|
428 | 428 | case 'authorizenet' : |
429 | 429 | $name_part = 'authorize.net'; |
430 | 430 | break; |
431 | 431 | } |
432 | 432 | |
433 | - $addon_name[] = ucfirst( $name_part ); |
|
433 | + $addon_name[] = ucfirst($name_part); |
|
434 | 434 | } |
435 | 435 | |
436 | - $addon_name = implode( ' ', $addon_name ); |
|
436 | + $addon_name = implode(' ', $addon_name); |
|
437 | 437 | |
438 | 438 | // Data to send to the API |
439 | 439 | $api_params = array( |
440 | 440 | 'edd_action' => 'activate_license', // never change from "edd_" to "give_"! |
441 | 441 | 'license' => $addon_license, |
442 | - 'item_name' => urlencode( $addon_name ), |
|
442 | + 'item_name' => urlencode($addon_name), |
|
443 | 443 | 'url' => home_url(), |
444 | 444 | ); |
445 | 445 | |
@@ -454,17 +454,17 @@ discard block |
||
454 | 454 | ); |
455 | 455 | |
456 | 456 | // Make sure there are no errors. |
457 | - if ( is_wp_error( $response ) ) { |
|
458 | - delete_option( $addon_license_option_name ); |
|
457 | + if (is_wp_error($response)) { |
|
458 | + delete_option($addon_license_option_name); |
|
459 | 459 | continue; |
460 | 460 | } |
461 | 461 | |
462 | 462 | // Tell WordPress to look for updates. |
463 | - set_site_transient( 'update_plugins', null ); |
|
463 | + set_site_transient('update_plugins', null); |
|
464 | 464 | |
465 | 465 | // Decode license data. |
466 | - $license_data = json_decode( wp_remote_retrieve_body( $response ) ); |
|
467 | - update_option( $addon_license_option_name, $license_data ); |
|
466 | + $license_data = json_decode(wp_remote_retrieve_body($response)); |
|
467 | + update_option($addon_license_option_name, $license_data); |
|
468 | 468 | }// End foreach(). |
469 | 469 | } |
470 | 470 | |
@@ -494,9 +494,9 @@ discard block |
||
494 | 494 | ); |
495 | 495 | |
496 | 496 | global $wp_roles; |
497 | - foreach ( $delete_caps as $cap ) { |
|
498 | - foreach ( array_keys( $wp_roles->roles ) as $role ) { |
|
499 | - $wp_roles->remove_cap( $role, $cap ); |
|
497 | + foreach ($delete_caps as $cap) { |
|
498 | + foreach (array_keys($wp_roles->roles) as $role) { |
|
499 | + $wp_roles->remove_cap($role, $cap); |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
@@ -530,7 +530,7 @@ discard block |
||
530 | 530 | function give_v18_upgrades_core_setting() { |
531 | 531 | // Core settings which changes from checkbox to radio. |
532 | 532 | $core_setting_names = array_merge( |
533 | - array_keys( give_v18_renamed_core_settings() ), |
|
533 | + array_keys(give_v18_renamed_core_settings()), |
|
534 | 534 | array( |
535 | 535 | 'uninstall_on_delete', |
536 | 536 | 'scripts_footer', |
@@ -542,48 +542,48 @@ discard block |
||
542 | 542 | ); |
543 | 543 | |
544 | 544 | // Bailout: If not any setting define. |
545 | - if ( $give_settings = get_option( 'give_settings' ) ) { |
|
545 | + if ($give_settings = get_option('give_settings')) { |
|
546 | 546 | |
547 | 547 | $setting_changed = false; |
548 | 548 | |
549 | 549 | // Loop: check each setting field. |
550 | - foreach ( $core_setting_names as $setting_name ) { |
|
550 | + foreach ($core_setting_names as $setting_name) { |
|
551 | 551 | // New setting name. |
552 | - $new_setting_name = preg_replace( '/^(enable_|disable_)/', '', $setting_name ); |
|
552 | + $new_setting_name = preg_replace('/^(enable_|disable_)/', '', $setting_name); |
|
553 | 553 | |
554 | 554 | // Continue: If setting already set. |
555 | 555 | if ( |
556 | - array_key_exists( $new_setting_name, $give_settings ) |
|
557 | - && in_array( $give_settings[ $new_setting_name ], array( 'enabled', 'disabled' ) ) |
|
556 | + array_key_exists($new_setting_name, $give_settings) |
|
557 | + && in_array($give_settings[$new_setting_name], array('enabled', 'disabled')) |
|
558 | 558 | ) { |
559 | 559 | continue; |
560 | 560 | } |
561 | 561 | |
562 | 562 | // Set checkbox value to radio value. |
563 | - $give_settings[ $setting_name ] = ( ! empty( $give_settings[ $setting_name ] ) && 'on' === $give_settings[ $setting_name ] ? 'enabled' : 'disabled' ); |
|
563 | + $give_settings[$setting_name] = ( ! empty($give_settings[$setting_name]) && 'on' === $give_settings[$setting_name] ? 'enabled' : 'disabled'); |
|
564 | 564 | |
565 | 565 | // @see https://github.com/WordImpress/Give/issues/1063 |
566 | - if ( false !== strpos( $setting_name, 'disable_' ) ) { |
|
566 | + if (false !== strpos($setting_name, 'disable_')) { |
|
567 | 567 | |
568 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'disabled' : 'enabled' ); |
|
569 | - } elseif ( false !== strpos( $setting_name, 'enable_' ) ) { |
|
568 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'disabled' : 'enabled'); |
|
569 | + } elseif (false !== strpos($setting_name, 'enable_')) { |
|
570 | 570 | |
571 | - $give_settings[ $new_setting_name ] = ( give_is_setting_enabled( $give_settings[ $setting_name ] ) ? 'enabled' : 'disabled' ); |
|
571 | + $give_settings[$new_setting_name] = (give_is_setting_enabled($give_settings[$setting_name]) ? 'enabled' : 'disabled'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | // Tell bot to update core setting to db. |
575 | - if ( ! $setting_changed ) { |
|
575 | + if ( ! $setting_changed) { |
|
576 | 576 | $setting_changed = true; |
577 | 577 | } |
578 | 578 | } |
579 | 579 | |
580 | 580 | // Update setting only if they changed. |
581 | - if ( $setting_changed ) { |
|
582 | - update_option( 'give_settings', $give_settings ); |
|
581 | + if ($setting_changed) { |
|
582 | + update_option('give_settings', $give_settings); |
|
583 | 583 | } |
584 | 584 | }// End if(). |
585 | 585 | |
586 | - give_set_upgrade_complete( 'v18_upgrades_core_setting' ); |
|
586 | + give_set_upgrade_complete('v18_upgrades_core_setting'); |
|
587 | 587 | } |
588 | 588 | |
589 | 589 | /** |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | $give_updates = Give_Updates::get_instance(); |
598 | 598 | |
599 | 599 | // form query |
600 | - $forms = new WP_Query( array( |
|
600 | + $forms = new WP_Query(array( |
|
601 | 601 | 'paged' => $give_updates->step, |
602 | 602 | 'status' => 'any', |
603 | 603 | 'order' => 'ASC', |
@@ -606,41 +606,41 @@ discard block |
||
606 | 606 | ) |
607 | 607 | ); |
608 | 608 | |
609 | - if ( $forms->have_posts() ) { |
|
610 | - $give_updates->set_percentage( $forms->found_posts, ( $give_updates->step * 20 ) ); |
|
609 | + if ($forms->have_posts()) { |
|
610 | + $give_updates->set_percentage($forms->found_posts, ($give_updates->step * 20)); |
|
611 | 611 | |
612 | - while ( $forms->have_posts() ) { |
|
612 | + while ($forms->have_posts()) { |
|
613 | 613 | $forms->the_post(); |
614 | 614 | |
615 | 615 | // Form content. |
616 | 616 | // Note in version 1.8 display content setting split into display content and content placement setting. |
617 | 617 | // You can delete _give_content_option in future |
618 | - $show_content = give_get_meta( get_the_ID(), '_give_content_option', true ); |
|
619 | - if ( $show_content && ! give_get_meta( get_the_ID(), '_give_display_content', true ) ) { |
|
620 | - $field_value = ( 'none' !== $show_content ? 'enabled' : 'disabled' ); |
|
621 | - give_update_meta( get_the_ID(), '_give_display_content', $field_value ); |
|
618 | + $show_content = give_get_meta(get_the_ID(), '_give_content_option', true); |
|
619 | + if ($show_content && ! give_get_meta(get_the_ID(), '_give_display_content', true)) { |
|
620 | + $field_value = ('none' !== $show_content ? 'enabled' : 'disabled'); |
|
621 | + give_update_meta(get_the_ID(), '_give_display_content', $field_value); |
|
622 | 622 | |
623 | - $field_value = ( 'none' !== $show_content ? $show_content : 'give_pre_form' ); |
|
624 | - give_update_meta( get_the_ID(), '_give_content_placement', $field_value ); |
|
623 | + $field_value = ('none' !== $show_content ? $show_content : 'give_pre_form'); |
|
624 | + give_update_meta(get_the_ID(), '_give_content_placement', $field_value); |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | // "Disable" Guest Donation. Checkbox |
628 | 628 | // See: https://github.com/WordImpress/Give/issues/1470 |
629 | - $guest_donation = give_get_meta( get_the_ID(), '_give_logged_in_only', true ); |
|
630 | - $guest_donation_newval = ( in_array( $guest_donation, array( 'yes', 'on' ) ) ? 'disabled' : 'enabled' ); |
|
631 | - give_update_meta( get_the_ID(), '_give_logged_in_only', $guest_donation_newval ); |
|
629 | + $guest_donation = give_get_meta(get_the_ID(), '_give_logged_in_only', true); |
|
630 | + $guest_donation_newval = (in_array($guest_donation, array('yes', 'on')) ? 'disabled' : 'enabled'); |
|
631 | + give_update_meta(get_the_ID(), '_give_logged_in_only', $guest_donation_newval); |
|
632 | 632 | |
633 | 633 | // Offline Donations |
634 | 634 | // See: https://github.com/WordImpress/Give/issues/1579 |
635 | - $offline_donation = give_get_meta( get_the_ID(), '_give_customize_offline_donations', true ); |
|
636 | - if ( 'no' === $offline_donation ) { |
|
635 | + $offline_donation = give_get_meta(get_the_ID(), '_give_customize_offline_donations', true); |
|
636 | + if ('no' === $offline_donation) { |
|
637 | 637 | $offline_donation_newval = 'global'; |
638 | - } elseif ( 'yes' === $offline_donation ) { |
|
638 | + } elseif ('yes' === $offline_donation) { |
|
639 | 639 | $offline_donation_newval = 'enabled'; |
640 | 640 | } else { |
641 | 641 | $offline_donation_newval = 'disabled'; |
642 | 642 | } |
643 | - give_update_meta( get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval ); |
|
643 | + give_update_meta(get_the_ID(), '_give_customize_offline_donations', $offline_donation_newval); |
|
644 | 644 | |
645 | 645 | // Convert yes/no setting field to enabled/disabled. |
646 | 646 | $form_radio_settings = array( |
@@ -660,15 +660,15 @@ discard block |
||
660 | 660 | '_give_offline_donation_enable_billing_fields_single', |
661 | 661 | ); |
662 | 662 | |
663 | - foreach ( $form_radio_settings as $meta_key ) { |
|
663 | + foreach ($form_radio_settings as $meta_key) { |
|
664 | 664 | // Get value. |
665 | - $field_value = give_get_meta( get_the_ID(), $meta_key, true ); |
|
665 | + $field_value = give_get_meta(get_the_ID(), $meta_key, true); |
|
666 | 666 | |
667 | 667 | // Convert meta value only if it is in yes/no/none. |
668 | - if ( in_array( $field_value, array( 'yes', 'on', 'no', 'none' ) ) ) { |
|
668 | + if (in_array($field_value, array('yes', 'on', 'no', 'none'))) { |
|
669 | 669 | |
670 | - $field_value = ( in_array( $field_value, array( 'yes', 'on' ) ) ? 'enabled' : 'disabled' ); |
|
671 | - give_update_meta( get_the_ID(), $meta_key, $field_value ); |
|
670 | + $field_value = (in_array($field_value, array('yes', 'on')) ? 'enabled' : 'disabled'); |
|
671 | + give_update_meta(get_the_ID(), $meta_key, $field_value); |
|
672 | 672 | } |
673 | 673 | } |
674 | 674 | }// End while(). |
@@ -677,7 +677,7 @@ discard block |
||
677 | 677 | |
678 | 678 | } else { |
679 | 679 | // No more forms found, finish up. |
680 | - give_set_upgrade_complete( 'v18_upgrades_form_metadata' ); |
|
680 | + give_set_upgrade_complete('v18_upgrades_form_metadata'); |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
@@ -726,7 +726,7 @@ discard block |
||
726 | 726 | '_transient_give_stats_', |
727 | 727 | 'give_cache', |
728 | 728 | '_transient_give_add_ons_feed', |
729 | - '_transient__give_ajax_works' . |
|
729 | + '_transient__give_ajax_works'. |
|
730 | 730 | '_transient_give_total_api_keys', |
731 | 731 | '_transient_give_i18n_give_promo_hide', |
732 | 732 | '_transient_give_contributors', |
@@ -753,24 +753,24 @@ discard block |
||
753 | 753 | ARRAY_A |
754 | 754 | ); |
755 | 755 | |
756 | - if ( ! empty( $user_apikey_options ) ) { |
|
757 | - foreach ( $user_apikey_options as $user ) { |
|
758 | - $cached_options[] = '_transient_' . md5( 'give_api_user_' . $user['meta_key'] ); |
|
759 | - $cached_options[] = '_transient_' . md5( 'give_api_user_public_key' . $user['user_id'] ); |
|
760 | - $cached_options[] = '_transient_' . md5( 'give_api_user_secret_key' . $user['user_id'] ); |
|
756 | + if ( ! empty($user_apikey_options)) { |
|
757 | + foreach ($user_apikey_options as $user) { |
|
758 | + $cached_options[] = '_transient_'.md5('give_api_user_'.$user['meta_key']); |
|
759 | + $cached_options[] = '_transient_'.md5('give_api_user_public_key'.$user['user_id']); |
|
760 | + $cached_options[] = '_transient_'.md5('give_api_user_secret_key'.$user['user_id']); |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | |
764 | - if ( ! empty( $cached_options ) ) { |
|
765 | - foreach ( $cached_options as $option ) { |
|
766 | - switch ( true ) { |
|
767 | - case ( false !== strpos( $option, 'transient' ) ): |
|
768 | - $option = str_replace( '_transient_', '', $option ); |
|
769 | - delete_transient( $option ); |
|
764 | + if ( ! empty($cached_options)) { |
|
765 | + foreach ($cached_options as $option) { |
|
766 | + switch (true) { |
|
767 | + case (false !== strpos($option, 'transient')): |
|
768 | + $option = str_replace('_transient_', '', $option); |
|
769 | + delete_transient($option); |
|
770 | 770 | break; |
771 | 771 | |
772 | 772 | default: |
773 | - delete_option( $option ); |
|
773 | + delete_option($option); |
|
774 | 774 | } |
775 | 775 | } |
776 | 776 | } |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | global $wp_roles; |
789 | 789 | |
790 | 790 | // Get the role object. |
791 | - $give_worker = get_role( 'give_worker' ); |
|
791 | + $give_worker = get_role('give_worker'); |
|
792 | 792 | |
793 | 793 | // A list of capabilities to add for give workers. |
794 | 794 | $caps_to_add = array( |
@@ -796,9 +796,9 @@ discard block |
||
796 | 796 | 'edit_pages', |
797 | 797 | ); |
798 | 798 | |
799 | - foreach ( $caps_to_add as $cap ) { |
|
799 | + foreach ($caps_to_add as $cap) { |
|
800 | 800 | // Add the capability. |
801 | - $give_worker->add_cap( $cap ); |
|
801 | + $give_worker->add_cap($cap); |
|
802 | 802 | } |
803 | 803 | |
804 | 804 | } |
@@ -815,7 +815,7 @@ discard block |
||
815 | 815 | $give_updates = Give_Updates::get_instance(); |
816 | 816 | |
817 | 817 | // form query |
818 | - $donation_forms = new WP_Query( array( |
|
818 | + $donation_forms = new WP_Query(array( |
|
819 | 819 | 'paged' => $give_updates->step, |
820 | 820 | 'status' => 'any', |
821 | 821 | 'order' => 'ASC', |
@@ -824,10 +824,10 @@ discard block |
||
824 | 824 | ) |
825 | 825 | ); |
826 | 826 | |
827 | - if ( $donation_forms->have_posts() ) { |
|
828 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
827 | + if ($donation_forms->have_posts()) { |
|
828 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
829 | 829 | |
830 | - while ( $donation_forms->have_posts() ) { |
|
830 | + while ($donation_forms->have_posts()) { |
|
831 | 831 | $donation_forms->the_post(); |
832 | 832 | $form_id = get_the_ID(); |
833 | 833 | |
@@ -835,41 +835,41 @@ discard block |
||
835 | 835 | update_post_meta( |
836 | 836 | $form_id, |
837 | 837 | '_give_set_price', |
838 | - give_sanitize_amount( get_post_meta( $form_id, '_give_set_price', true ) ) |
|
838 | + give_sanitize_amount(get_post_meta($form_id, '_give_set_price', true)) |
|
839 | 839 | ); |
840 | 840 | |
841 | 841 | // Remove formatting from _give_custom_amount_minimum |
842 | 842 | update_post_meta( |
843 | 843 | $form_id, |
844 | 844 | '_give_custom_amount_minimum', |
845 | - give_sanitize_amount( get_post_meta( $form_id, '_give_custom_amount_minimum', true ) ) |
|
845 | + give_sanitize_amount(get_post_meta($form_id, '_give_custom_amount_minimum', true)) |
|
846 | 846 | ); |
847 | 847 | |
848 | 848 | // Bailout. |
849 | - if ( 'set' === get_post_meta( $form_id, '_give_price_option', true ) ) { |
|
849 | + if ('set' === get_post_meta($form_id, '_give_price_option', true)) { |
|
850 | 850 | continue; |
851 | 851 | } |
852 | 852 | |
853 | - $donation_levels = get_post_meta( $form_id, '_give_donation_levels', true ); |
|
853 | + $donation_levels = get_post_meta($form_id, '_give_donation_levels', true); |
|
854 | 854 | |
855 | - if ( ! empty( $donation_levels ) ) { |
|
855 | + if ( ! empty($donation_levels)) { |
|
856 | 856 | |
857 | - foreach ( $donation_levels as $index => $donation_level ) { |
|
858 | - if ( isset( $donation_level['_give_amount'] ) ) { |
|
859 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount( $donation_level['_give_amount'] ); |
|
857 | + foreach ($donation_levels as $index => $donation_level) { |
|
858 | + if (isset($donation_level['_give_amount'])) { |
|
859 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount($donation_level['_give_amount']); |
|
860 | 860 | } |
861 | 861 | } |
862 | 862 | |
863 | - update_post_meta( $form_id, '_give_donation_levels', $donation_levels ); |
|
863 | + update_post_meta($form_id, '_give_donation_levels', $donation_levels); |
|
864 | 864 | |
865 | - $donation_levels_amounts = wp_list_pluck( $donation_levels, '_give_amount' ); |
|
865 | + $donation_levels_amounts = wp_list_pluck($donation_levels, '_give_amount'); |
|
866 | 866 | |
867 | - $min_amount = min( $donation_levels_amounts ); |
|
868 | - $max_amount = max( $donation_levels_amounts ); |
|
867 | + $min_amount = min($donation_levels_amounts); |
|
868 | + $max_amount = max($donation_levels_amounts); |
|
869 | 869 | |
870 | 870 | // Set Minimum and Maximum amount for Multi Level Donation Forms |
871 | - give_update_meta( $form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount( $min_amount ) : 0 ); |
|
872 | - give_update_meta( $form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount( $max_amount ) : 0 ); |
|
871 | + give_update_meta($form_id, '_give_levels_minimum_amount', $min_amount ? give_sanitize_amount($min_amount) : 0); |
|
872 | + give_update_meta($form_id, '_give_levels_maximum_amount', $max_amount ? give_sanitize_amount($max_amount) : 0); |
|
873 | 873 | } |
874 | 874 | |
875 | 875 | } |
@@ -878,7 +878,7 @@ discard block |
||
878 | 878 | wp_reset_postdata(); |
879 | 879 | } else { |
880 | 880 | // The Update Ran. |
881 | - give_set_upgrade_complete( 'v189_upgrades_levels_post_meta' ); |
|
881 | + give_set_upgrade_complete('v189_upgrades_levels_post_meta'); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | } |
@@ -934,22 +934,22 @@ discard block |
||
934 | 934 | $give_settings = give_get_settings(); |
935 | 935 | $give_setting_updated = false; |
936 | 936 | |
937 | - if ( $give_settings['thousands_separator'] === $give_settings['decimal_separator'] ) { |
|
937 | + if ($give_settings['thousands_separator'] === $give_settings['decimal_separator']) { |
|
938 | 938 | $give_settings['number_decimals'] = 0; |
939 | 939 | $give_settings['decimal_separator'] = ''; |
940 | 940 | $give_setting_updated = true; |
941 | 941 | |
942 | - } elseif ( empty( $give_settings['decimal_separator'] ) ) { |
|
942 | + } elseif (empty($give_settings['decimal_separator'])) { |
|
943 | 943 | $give_settings['number_decimals'] = 0; |
944 | 944 | $give_setting_updated = true; |
945 | 945 | |
946 | - } elseif ( 6 < absint( $give_settings['number_decimals'] ) ) { |
|
946 | + } elseif (6 < absint($give_settings['number_decimals'])) { |
|
947 | 947 | $give_settings['number_decimals'] = 5; |
948 | 948 | $give_setting_updated = true; |
949 | 949 | } |
950 | 950 | |
951 | - if ( $give_setting_updated ) { |
|
952 | - update_option( 'give_settings', $give_settings ); |
|
951 | + if ($give_setting_updated) { |
|
952 | + update_option('give_settings', $give_settings); |
|
953 | 953 | } |
954 | 954 | } |
955 | 955 | |
@@ -968,70 +968,70 @@ discard block |
||
968 | 968 | $give_updates = Give_Updates::get_instance(); |
969 | 969 | |
970 | 970 | // form query |
971 | - $donation_forms = new WP_Query( array( |
|
971 | + $donation_forms = new WP_Query(array( |
|
972 | 972 | 'paged' => $give_updates->step, |
973 | 973 | 'status' => 'any', |
974 | 974 | 'order' => 'ASC', |
975 | - 'post_type' => array( 'give_forms', 'give_payment' ), |
|
975 | + 'post_type' => array('give_forms', 'give_payment'), |
|
976 | 976 | 'posts_per_page' => 20, |
977 | 977 | ) |
978 | 978 | ); |
979 | 979 | |
980 | - if ( $donation_forms->have_posts() ) { |
|
981 | - $give_updates->set_percentage( $donation_forms->found_posts, ( $give_updates->step * 20 ) ); |
|
980 | + if ($donation_forms->have_posts()) { |
|
981 | + $give_updates->set_percentage($donation_forms->found_posts, ($give_updates->step * 20)); |
|
982 | 982 | |
983 | - while ( $donation_forms->have_posts() ) { |
|
983 | + while ($donation_forms->have_posts()) { |
|
984 | 984 | $donation_forms->the_post(); |
985 | 985 | global $post; |
986 | 986 | |
987 | - $meta = get_post_meta( $post->ID ); |
|
987 | + $meta = get_post_meta($post->ID); |
|
988 | 988 | |
989 | - switch ( $post->post_type ) { |
|
989 | + switch ($post->post_type) { |
|
990 | 990 | case 'give_forms': |
991 | 991 | // _give_set_price |
992 | - if ( ! empty( $meta['_give_set_price'][0] ) ) { |
|
993 | - update_post_meta( $post->ID, '_give_set_price', give_sanitize_amount_for_db( $meta['_give_set_price'][0] ) ); |
|
992 | + if ( ! empty($meta['_give_set_price'][0])) { |
|
993 | + update_post_meta($post->ID, '_give_set_price', give_sanitize_amount_for_db($meta['_give_set_price'][0])); |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | // _give_custom_amount_minimum |
997 | - if ( ! empty( $meta['_give_custom_amount_minimum'][0] ) ) { |
|
998 | - update_post_meta( $post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db( $meta['_give_custom_amount_minimum'][0] ) ); |
|
997 | + if ( ! empty($meta['_give_custom_amount_minimum'][0])) { |
|
998 | + update_post_meta($post->ID, '_give_custom_amount_minimum', give_sanitize_amount_for_db($meta['_give_custom_amount_minimum'][0])); |
|
999 | 999 | } |
1000 | 1000 | |
1001 | 1001 | // _give_levels_minimum_amount |
1002 | - if ( ! empty( $meta['_give_levels_minimum_amount'][0] ) ) { |
|
1003 | - update_post_meta( $post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db( $meta['_give_levels_minimum_amount'][0] ) ); |
|
1002 | + if ( ! empty($meta['_give_levels_minimum_amount'][0])) { |
|
1003 | + update_post_meta($post->ID, '_give_levels_minimum_amount', give_sanitize_amount_for_db($meta['_give_levels_minimum_amount'][0])); |
|
1004 | 1004 | } |
1005 | 1005 | |
1006 | 1006 | // _give_levels_maximum_amount |
1007 | - if ( ! empty( $meta['_give_levels_maximum_amount'][0] ) ) { |
|
1008 | - update_post_meta( $post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db( $meta['_give_levels_maximum_amount'][0] ) ); |
|
1007 | + if ( ! empty($meta['_give_levels_maximum_amount'][0])) { |
|
1008 | + update_post_meta($post->ID, '_give_levels_maximum_amount', give_sanitize_amount_for_db($meta['_give_levels_maximum_amount'][0])); |
|
1009 | 1009 | } |
1010 | 1010 | |
1011 | 1011 | // _give_set_goal |
1012 | - if ( ! empty( $meta['_give_set_goal'][0] ) ) { |
|
1013 | - update_post_meta( $post->ID, '_give_set_goal', give_sanitize_amount_for_db( $meta['_give_set_goal'][0] ) ); |
|
1012 | + if ( ! empty($meta['_give_set_goal'][0])) { |
|
1013 | + update_post_meta($post->ID, '_give_set_goal', give_sanitize_amount_for_db($meta['_give_set_goal'][0])); |
|
1014 | 1014 | } |
1015 | 1015 | |
1016 | 1016 | // _give_form_earnings |
1017 | - if ( ! empty( $meta['_give_form_earnings'][0] ) ) { |
|
1018 | - update_post_meta( $post->ID, '_give_form_earnings', give_sanitize_amount_for_db( $meta['_give_form_earnings'][0] ) ); |
|
1017 | + if ( ! empty($meta['_give_form_earnings'][0])) { |
|
1018 | + update_post_meta($post->ID, '_give_form_earnings', give_sanitize_amount_for_db($meta['_give_form_earnings'][0])); |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | // _give_custom_amount_minimum |
1022 | - if ( ! empty( $meta['_give_donation_levels'][0] ) ) { |
|
1023 | - $donation_levels = unserialize( $meta['_give_donation_levels'][0] ); |
|
1022 | + if ( ! empty($meta['_give_donation_levels'][0])) { |
|
1023 | + $donation_levels = unserialize($meta['_give_donation_levels'][0]); |
|
1024 | 1024 | |
1025 | - foreach ( $donation_levels as $index => $level ) { |
|
1026 | - if ( empty( $level['_give_amount'] ) ) { |
|
1025 | + foreach ($donation_levels as $index => $level) { |
|
1026 | + if (empty($level['_give_amount'])) { |
|
1027 | 1027 | continue; |
1028 | 1028 | } |
1029 | 1029 | |
1030 | - $donation_levels[ $index ]['_give_amount'] = give_sanitize_amount_for_db( $level['_give_amount'] ); |
|
1030 | + $donation_levels[$index]['_give_amount'] = give_sanitize_amount_for_db($level['_give_amount']); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | 1033 | $meta['_give_donation_levels'] = $donation_levels; |
1034 | - update_post_meta( $post->ID, '_give_donation_levels', $meta['_give_donation_levels'] ); |
|
1034 | + update_post_meta($post->ID, '_give_donation_levels', $meta['_give_donation_levels']); |
|
1035 | 1035 | } |
1036 | 1036 | |
1037 | 1037 | |
@@ -1039,8 +1039,8 @@ discard block |
||
1039 | 1039 | |
1040 | 1040 | case 'give_payment': |
1041 | 1041 | // _give_payment_total |
1042 | - if ( ! empty( $meta['_give_payment_total'][0] ) ) { |
|
1043 | - update_post_meta( $post->ID, '_give_payment_total', give_sanitize_amount_for_db( $meta['_give_payment_total'][0] ) ); |
|
1042 | + if ( ! empty($meta['_give_payment_total'][0])) { |
|
1043 | + update_post_meta($post->ID, '_give_payment_total', give_sanitize_amount_for_db($meta['_give_payment_total'][0])); |
|
1044 | 1044 | } |
1045 | 1045 | |
1046 | 1046 | break; |
@@ -1051,7 +1051,7 @@ discard block |
||
1051 | 1051 | wp_reset_postdata(); |
1052 | 1052 | } else { |
1053 | 1053 | // The Update Ran. |
1054 | - give_set_upgrade_complete( 'v1812_update_amount_values' ); |
|
1054 | + give_set_upgrade_complete('v1812_update_amount_values'); |
|
1055 | 1055 | } |
1056 | 1056 | } |
1057 | 1057 | |
@@ -1071,22 +1071,22 @@ discard block |
||
1071 | 1071 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1072 | 1072 | |
1073 | 1073 | // form query |
1074 | - $donors = Give()->donors->get_donors( array( |
|
1074 | + $donors = Give()->donors->get_donors(array( |
|
1075 | 1075 | 'number' => 20, |
1076 | 1076 | 'offset' => $offset, |
1077 | 1077 | ) |
1078 | 1078 | ); |
1079 | 1079 | |
1080 | - if ( ! empty( $donors ) ) { |
|
1081 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1080 | + if ( ! empty($donors)) { |
|
1081 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1082 | 1082 | |
1083 | 1083 | /* @var Object $donor */ |
1084 | - foreach ( $donors as $donor ) { |
|
1085 | - Give()->donors->update( $donor->id, array( 'purchase_value' => give_sanitize_amount_for_db( $donor->purchase_value ) ) ); |
|
1084 | + foreach ($donors as $donor) { |
|
1085 | + Give()->donors->update($donor->id, array('purchase_value' => give_sanitize_amount_for_db($donor->purchase_value))); |
|
1086 | 1086 | } |
1087 | 1087 | } else { |
1088 | 1088 | // The Update Ran. |
1089 | - give_set_upgrade_complete( 'v1812_update_donor_purchase_values' ); |
|
1089 | + give_set_upgrade_complete('v1812_update_donor_purchase_values'); |
|
1090 | 1090 | } |
1091 | 1091 | } |
1092 | 1092 | |
@@ -1101,25 +1101,25 @@ discard block |
||
1101 | 1101 | $offset = 1 === $give_updates->step ? 0 : $give_updates->step * 20; |
1102 | 1102 | |
1103 | 1103 | // Fetch all the existing donors. |
1104 | - $donors = Give()->donors->get_donors( array( |
|
1104 | + $donors = Give()->donors->get_donors(array( |
|
1105 | 1105 | 'number' => 20, |
1106 | 1106 | 'offset' => $offset, |
1107 | 1107 | ) |
1108 | 1108 | ); |
1109 | 1109 | |
1110 | - if ( ! empty( $donors ) ) { |
|
1111 | - $give_updates->set_percentage( Give()->donors->count(), ( $give_updates->step * 20 ) ); |
|
1110 | + if ( ! empty($donors)) { |
|
1111 | + $give_updates->set_percentage(Give()->donors->count(), ($give_updates->step * 20)); |
|
1112 | 1112 | |
1113 | 1113 | /* @var Object $donor */ |
1114 | - foreach ( $donors as $donor ) { |
|
1114 | + foreach ($donors as $donor) { |
|
1115 | 1115 | $user_id = $donor->user_id; |
1116 | 1116 | |
1117 | 1117 | // Proceed, if donor is attached with user. |
1118 | - if ( $user_id ) { |
|
1119 | - $user = get_userdata( $user_id ); |
|
1118 | + if ($user_id) { |
|
1119 | + $user = get_userdata($user_id); |
|
1120 | 1120 | |
1121 | 1121 | // Update user role, if user has subscriber role. |
1122 | - if ( is_array( $user->roles ) && in_array( 'subscriber', $user->roles ) ) { |
|
1122 | + if (is_array($user->roles) && in_array('subscriber', $user->roles)) { |
|
1123 | 1123 | wp_update_user( |
1124 | 1124 | array( |
1125 | 1125 | 'ID' => $user_id, |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | } |
1132 | 1132 | } else { |
1133 | 1133 | // The Update Ran. |
1134 | - give_set_upgrade_complete( 'v1813_update_donor_user_roles' ); |
|
1134 | + give_set_upgrade_complete('v1813_update_donor_user_roles'); |
|
1135 | 1135 | } |
1136 | 1136 | } |
1137 | 1137 | |
@@ -1143,7 +1143,7 @@ discard block |
||
1143 | 1143 | */ |
1144 | 1144 | function give_v1813_upgrades() { |
1145 | 1145 | // Update admin setting. |
1146 | - give_update_option( 'donor_default_user_role', 'give_donor' ); |
|
1146 | + give_update_option('donor_default_user_role', 'give_donor'); |
|
1147 | 1147 | |
1148 | 1148 | // Update Give roles. |
1149 | 1149 | $roles = new Give_Roles(); |
@@ -46,24 +46,24 @@ discard block |
||
46 | 46 | */ |
47 | 47 | function __construct() { |
48 | 48 | $this->metabox_id = 'give-metabox-form-data'; |
49 | - $this->metabox_label = __( 'Donation Form Options', 'give' ); |
|
49 | + $this->metabox_label = __('Donation Form Options', 'give'); |
|
50 | 50 | |
51 | 51 | // Setup. |
52 | - add_action( 'admin_init', array( $this, 'setup' ) ); |
|
52 | + add_action('admin_init', array($this, 'setup')); |
|
53 | 53 | |
54 | 54 | // Add metabox. |
55 | - add_action( 'add_meta_boxes', array( $this, 'add_meta_box' ), 10 ); |
|
55 | + add_action('add_meta_boxes', array($this, 'add_meta_box'), 10); |
|
56 | 56 | |
57 | 57 | // Save form meta. |
58 | - add_action( 'save_post_give_forms', array( $this, 'save' ), 10, 2 ); |
|
58 | + add_action('save_post_give_forms', array($this, 'save'), 10, 2); |
|
59 | 59 | |
60 | 60 | // cmb2 old setting loaders. |
61 | 61 | // add_filter( 'give_metabox_form_data_settings', array( $this, 'cmb2_metabox_settings' ) ); |
62 | 62 | // Add offline donations options. |
63 | - add_filter( 'give_metabox_form_data_settings', array( $this, 'add_offline_donations_setting_tab' ), 0, 1 ); |
|
63 | + add_filter('give_metabox_form_data_settings', array($this, 'add_offline_donations_setting_tab'), 0, 1); |
|
64 | 64 | |
65 | 65 | // Maintain active tab query parameter after save. |
66 | - add_filter( 'redirect_post_location', array( $this, 'maintain_active_tab' ), 10, 2 ); |
|
66 | + add_filter('redirect_post_location', array($this, 'maintain_active_tab'), 10, 2); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -85,24 +85,24 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function get_settings() { |
87 | 87 | $post_id = give_get_admin_post_id(); |
88 | - $price = give_get_form_price( $post_id ); |
|
89 | - $custom_amount_minimum = give_get_form_minimum_price( $post_id ); |
|
90 | - $goal = give_format_amount( give_get_form_goal( $post_id ), array( 'sanitize' => false ) ); |
|
91 | - $price_placeholder = give_format_decimal( '1.00', false, false ); |
|
88 | + $price = give_get_form_price($post_id); |
|
89 | + $custom_amount_minimum = give_get_form_minimum_price($post_id); |
|
90 | + $goal = give_format_amount(give_get_form_goal($post_id), array('sanitize' => false)); |
|
91 | + $price_placeholder = give_format_decimal('1.00', false, false); |
|
92 | 92 | |
93 | 93 | // No empty prices - min. 1.00 for new forms |
94 | - if ( empty( $price ) && is_null( $post_id ) ) { |
|
94 | + if (empty($price) && is_null($post_id)) { |
|
95 | 95 | $price = '1.00'; |
96 | 96 | } |
97 | 97 | |
98 | 98 | // Min. $1.00 for new forms |
99 | - if ( empty( $custom_amount_minimum ) ) { |
|
99 | + if (empty($custom_amount_minimum)) { |
|
100 | 100 | $custom_amount_minimum = '1.00'; |
101 | 101 | } |
102 | 102 | |
103 | 103 | // Format amounts. |
104 | - $price = give_format_amount( $price, array( 'sanitize' => false ) ); |
|
105 | - $custom_amount_minimum = give_format_amount( $custom_amount_minimum, array( 'sanitize' => false ) ); |
|
104 | + $price = give_format_amount($price, array('sanitize' => false)); |
|
105 | + $custom_amount_minimum = give_format_amount($custom_amount_minimum, array('sanitize' => false)); |
|
106 | 106 | |
107 | 107 | // Start with an underscore to hide fields from custom fields list |
108 | 108 | $prefix = '_give_'; |
@@ -111,27 +111,27 @@ discard block |
||
111 | 111 | /** |
112 | 112 | * Repeatable Field Groups |
113 | 113 | */ |
114 | - 'form_field_options' => apply_filters( 'give_forms_field_options', array( |
|
114 | + 'form_field_options' => apply_filters('give_forms_field_options', array( |
|
115 | 115 | 'id' => 'form_field_options', |
116 | - 'title' => __( 'Donation Options', 'give' ), |
|
116 | + 'title' => __('Donation Options', 'give'), |
|
117 | 117 | 'icon-html' => '<span class="give-icon give-icon-heart"></span>', |
118 | - 'fields' => apply_filters( 'give_forms_donation_form_metabox_fields', array( |
|
118 | + 'fields' => apply_filters('give_forms_donation_form_metabox_fields', array( |
|
119 | 119 | // Donation Option |
120 | 120 | array( |
121 | - 'name' => __( 'Donation Option', 'give' ), |
|
122 | - 'description' => __( 'Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give' ), |
|
123 | - 'id' => $prefix . 'price_option', |
|
121 | + 'name' => __('Donation Option', 'give'), |
|
122 | + 'description' => __('Do you want this form to have one set donation price or multiple levels (for example, $10, $20, $50)?', 'give'), |
|
123 | + 'id' => $prefix.'price_option', |
|
124 | 124 | 'type' => 'radio_inline', |
125 | 125 | 'default' => 'set', |
126 | - 'options' => apply_filters( 'give_forms_price_options', array( |
|
127 | - 'set' => __( 'Set Donation', 'give' ), |
|
128 | - 'multi' => __( 'Multi-level Donation', 'give' ), |
|
129 | - ) ), |
|
126 | + 'options' => apply_filters('give_forms_price_options', array( |
|
127 | + 'set' => __('Set Donation', 'give'), |
|
128 | + 'multi' => __('Multi-level Donation', 'give'), |
|
129 | + )), |
|
130 | 130 | ), |
131 | 131 | array( |
132 | - 'name' => __( 'Set Donation', 'give' ), |
|
133 | - 'description' => __( 'This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give' ), |
|
134 | - 'id' => $prefix . 'set_price', |
|
132 | + 'name' => __('Set Donation', 'give'), |
|
133 | + 'description' => __('This is the set donation amount for this form. If you have a "Custom Amount Minimum" set, make sure it is less than this amount.', 'give'), |
|
134 | + 'id' => $prefix.'set_price', |
|
135 | 135 | 'type' => 'text_small', |
136 | 136 | 'data_type' => 'price', |
137 | 137 | 'attributes' => array( |
@@ -142,34 +142,34 @@ discard block |
||
142 | 142 | ), |
143 | 143 | // Display Style |
144 | 144 | array( |
145 | - 'name' => __( 'Display Style', 'give' ), |
|
146 | - 'description' => __( 'Set how the donations levels will display on the form.', 'give' ), |
|
147 | - 'id' => $prefix . 'display_style', |
|
145 | + 'name' => __('Display Style', 'give'), |
|
146 | + 'description' => __('Set how the donations levels will display on the form.', 'give'), |
|
147 | + 'id' => $prefix.'display_style', |
|
148 | 148 | 'type' => 'radio_inline', |
149 | 149 | 'default' => 'buttons', |
150 | 150 | 'options' => array( |
151 | - 'buttons' => __( 'Buttons', 'give' ), |
|
152 | - 'radios' => __( 'Radios', 'give' ), |
|
153 | - 'dropdown' => __( 'Dropdown', 'give' ), |
|
151 | + 'buttons' => __('Buttons', 'give'), |
|
152 | + 'radios' => __('Radios', 'give'), |
|
153 | + 'dropdown' => __('Dropdown', 'give'), |
|
154 | 154 | ), |
155 | 155 | 'wrapper_class' => 'give-hidden', |
156 | 156 | ), |
157 | 157 | // Custom Amount |
158 | 158 | array( |
159 | - 'name' => __( 'Custom Amount', 'give' ), |
|
160 | - 'description' => __( 'Do you want the user to be able to input their own donation amount?', 'give' ), |
|
161 | - 'id' => $prefix . 'custom_amount', |
|
159 | + 'name' => __('Custom Amount', 'give'), |
|
160 | + 'description' => __('Do you want the user to be able to input their own donation amount?', 'give'), |
|
161 | + 'id' => $prefix.'custom_amount', |
|
162 | 162 | 'type' => 'radio_inline', |
163 | 163 | 'default' => 'disabled', |
164 | 164 | 'options' => array( |
165 | - 'enabled' => __( 'Enabled', 'give' ), |
|
166 | - 'disabled' => __( 'Disabled', 'give' ), |
|
165 | + 'enabled' => __('Enabled', 'give'), |
|
166 | + 'disabled' => __('Disabled', 'give'), |
|
167 | 167 | ), |
168 | 168 | ), |
169 | 169 | array( |
170 | - 'name' => __( 'Minimum Amount', 'give' ), |
|
171 | - 'description' => __( 'Enter the minimum custom donation amount.', 'give' ), |
|
172 | - 'id' => $prefix . 'custom_amount_minimum', |
|
170 | + 'name' => __('Minimum Amount', 'give'), |
|
171 | + 'description' => __('Enter the minimum custom donation amount.', 'give'), |
|
172 | + 'id' => $prefix.'custom_amount_minimum', |
|
173 | 173 | 'type' => 'text_small', |
174 | 174 | 'data_type' => 'price', |
175 | 175 | 'attributes' => array( |
@@ -180,37 +180,37 @@ discard block |
||
180 | 180 | 'wrapper_class' => 'give-hidden', |
181 | 181 | ), |
182 | 182 | array( |
183 | - 'name' => __( 'Custom Amount Text', 'give' ), |
|
184 | - 'description' => __( 'This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give' ), |
|
185 | - 'id' => $prefix . 'custom_amount_text', |
|
183 | + 'name' => __('Custom Amount Text', 'give'), |
|
184 | + 'description' => __('This text appears as a label below the custom amount field for set donation forms. For multi-level forms the text will appear as it\'s own level (ie button, radio, or select option).', 'give'), |
|
185 | + 'id' => $prefix.'custom_amount_text', |
|
186 | 186 | 'type' => 'text_medium', |
187 | 187 | 'attributes' => array( |
188 | 188 | 'rows' => 3, |
189 | - 'placeholder' => esc_attr__( 'Give a Custom Amount', 'give' ), |
|
189 | + 'placeholder' => esc_attr__('Give a Custom Amount', 'give'), |
|
190 | 190 | ), |
191 | 191 | 'wrapper_class' => 'give-hidden', |
192 | 192 | ), |
193 | 193 | // Donation Levels: Repeatable CMB2 Group |
194 | 194 | array( |
195 | - 'id' => $prefix . 'donation_levels', |
|
195 | + 'id' => $prefix.'donation_levels', |
|
196 | 196 | 'type' => 'group', |
197 | 197 | 'options' => array( |
198 | - 'add_button' => __( 'Add Level', 'give' ), |
|
199 | - 'header_title' => __( 'Donation Level', 'give' ), |
|
198 | + 'add_button' => __('Add Level', 'give'), |
|
199 | + 'header_title' => __('Donation Level', 'give'), |
|
200 | 200 | 'remove_button' => '<span class="dashicons dashicons-no"></span>', |
201 | 201 | ), |
202 | 202 | 'wrapper_class' => 'give-hidden', |
203 | 203 | // Fields array works the same, except id's only need to be unique for this group. |
204 | 204 | // Prefix is not needed. |
205 | - 'fields' => apply_filters( 'give_donation_levels_table_row', array( |
|
205 | + 'fields' => apply_filters('give_donation_levels_table_row', array( |
|
206 | 206 | array( |
207 | - 'name' => __( 'ID', 'give' ), |
|
208 | - 'id' => $prefix . 'id', |
|
207 | + 'name' => __('ID', 'give'), |
|
208 | + 'id' => $prefix.'id', |
|
209 | 209 | 'type' => 'levels_id', |
210 | 210 | ), |
211 | 211 | array( |
212 | - 'name' => __( 'Amount', 'give' ), |
|
213 | - 'id' => $prefix . 'amount', |
|
212 | + 'name' => __('Amount', 'give'), |
|
213 | + 'id' => $prefix.'amount', |
|
214 | 214 | 'type' => 'text_small', |
215 | 215 | 'data_type' => 'price', |
216 | 216 | 'attributes' => array( |
@@ -219,112 +219,112 @@ discard block |
||
219 | 219 | ), |
220 | 220 | ), |
221 | 221 | array( |
222 | - 'name' => __( 'Text', 'give' ), |
|
223 | - 'id' => $prefix . 'text', |
|
222 | + 'name' => __('Text', 'give'), |
|
223 | + 'id' => $prefix.'text', |
|
224 | 224 | 'type' => 'text', |
225 | 225 | 'attributes' => array( |
226 | - 'placeholder' => __( 'Donation Level', 'give' ), |
|
226 | + 'placeholder' => __('Donation Level', 'give'), |
|
227 | 227 | 'class' => 'give-multilevel-text-field', |
228 | 228 | ), |
229 | 229 | ), |
230 | 230 | array( |
231 | - 'name' => __( 'Default', 'give' ), |
|
232 | - 'id' => $prefix . 'default', |
|
231 | + 'name' => __('Default', 'give'), |
|
232 | + 'id' => $prefix.'default', |
|
233 | 233 | 'type' => 'give_default_radio_inline', |
234 | 234 | ), |
235 | - ) ), |
|
235 | + )), |
|
236 | 236 | ), |
237 | 237 | array( |
238 | 238 | 'name' => 'donation_options_docs', |
239 | 239 | 'type' => 'docs_link', |
240 | 240 | 'url' => 'http://docs.givewp.com/form-donation-options', |
241 | - 'title' => __( 'Donation Options', 'give' ), |
|
241 | + 'title' => __('Donation Options', 'give'), |
|
242 | 242 | ), |
243 | 243 | ), |
244 | 244 | $post_id |
245 | 245 | ), |
246 | - ) ), |
|
246 | + )), |
|
247 | 247 | |
248 | 248 | /** |
249 | 249 | * Display Options |
250 | 250 | */ |
251 | - 'form_display_options' => apply_filters( 'give_form_display_options', array( |
|
251 | + 'form_display_options' => apply_filters('give_form_display_options', array( |
|
252 | 252 | 'id' => 'form_display_options', |
253 | - 'title' => __( 'Form Display', 'give' ), |
|
253 | + 'title' => __('Form Display', 'give'), |
|
254 | 254 | 'icon-html' => '<span class="give-icon give-icon-display"></span>', |
255 | - 'fields' => apply_filters( 'give_forms_display_options_metabox_fields', array( |
|
255 | + 'fields' => apply_filters('give_forms_display_options_metabox_fields', array( |
|
256 | 256 | array( |
257 | - 'name' => __( 'Display Options', 'give' ), |
|
258 | - 'desc' => sprintf( __( 'How would you like to display donation information for this form?', 'give' ), '#' ), |
|
259 | - 'id' => $prefix . 'payment_display', |
|
257 | + 'name' => __('Display Options', 'give'), |
|
258 | + 'desc' => sprintf(__('How would you like to display donation information for this form?', 'give'), '#'), |
|
259 | + 'id' => $prefix.'payment_display', |
|
260 | 260 | 'type' => 'radio_inline', |
261 | 261 | 'options' => array( |
262 | - 'onpage' => __( 'All Fields', 'give' ), |
|
263 | - 'modal' => __( 'Modal', 'give' ), |
|
264 | - 'reveal' => __( 'Reveal', 'give' ), |
|
265 | - 'button' => __( 'Button', 'give' ), |
|
262 | + 'onpage' => __('All Fields', 'give'), |
|
263 | + 'modal' => __('Modal', 'give'), |
|
264 | + 'reveal' => __('Reveal', 'give'), |
|
265 | + 'button' => __('Button', 'give'), |
|
266 | 266 | ), |
267 | 267 | 'default' => 'onpage', |
268 | 268 | ), |
269 | 269 | array( |
270 | - 'id' => $prefix . 'reveal_label', |
|
271 | - 'name' => __( 'Continue Button', 'give' ), |
|
272 | - 'desc' => __( 'The button label for displaying the additional payment fields.', 'give' ), |
|
270 | + 'id' => $prefix.'reveal_label', |
|
271 | + 'name' => __('Continue Button', 'give'), |
|
272 | + 'desc' => __('The button label for displaying the additional payment fields.', 'give'), |
|
273 | 273 | 'type' => 'text_small', |
274 | 274 | 'attributes' => array( |
275 | - 'placeholder' => esc_attr__( 'Donate Now', 'give' ), |
|
275 | + 'placeholder' => esc_attr__('Donate Now', 'give'), |
|
276 | 276 | ), |
277 | 277 | 'wrapper_class' => 'give-hidden', |
278 | 278 | ), |
279 | 279 | array( |
280 | - 'id' => $prefix . 'checkout_label', |
|
281 | - 'name' => __( 'Submit Button', 'give' ), |
|
282 | - 'desc' => __( 'The button label for completing a donation.', 'give' ), |
|
280 | + 'id' => $prefix.'checkout_label', |
|
281 | + 'name' => __('Submit Button', 'give'), |
|
282 | + 'desc' => __('The button label for completing a donation.', 'give'), |
|
283 | 283 | 'type' => 'text_small', |
284 | 284 | 'attributes' => array( |
285 | - 'placeholder' => __( 'Donate Now', 'give' ), |
|
285 | + 'placeholder' => __('Donate Now', 'give'), |
|
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | array( |
289 | - 'name' => __( 'Default Gateway', 'give' ), |
|
290 | - 'desc' => __( 'By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give' ), |
|
291 | - 'id' => $prefix . 'default_gateway', |
|
289 | + 'name' => __('Default Gateway', 'give'), |
|
290 | + 'desc' => __('By default, the gateway for this form will inherit the global default gateway (set under Give > Settings > Payment Gateways). This option allows you to customize the default gateway for this form only.', 'give'), |
|
291 | + 'id' => $prefix.'default_gateway', |
|
292 | 292 | 'type' => 'default_gateway', |
293 | 293 | ), |
294 | 294 | array( |
295 | - 'name' => __( 'Guest Donations', 'give' ), |
|
296 | - 'desc' => __( 'Do you want to allow non-logged-in users to make donations?', 'give' ), |
|
297 | - 'id' => $prefix . 'logged_in_only', |
|
295 | + 'name' => __('Guest Donations', 'give'), |
|
296 | + 'desc' => __('Do you want to allow non-logged-in users to make donations?', 'give'), |
|
297 | + 'id' => $prefix.'logged_in_only', |
|
298 | 298 | 'type' => 'radio_inline', |
299 | 299 | 'default' => 'enabled', |
300 | 300 | 'options' => array( |
301 | - 'enabled' => __( 'Enabled', 'give' ), |
|
302 | - 'disabled' => __( 'Disabled', 'give' ), |
|
301 | + 'enabled' => __('Enabled', 'give'), |
|
302 | + 'disabled' => __('Disabled', 'give'), |
|
303 | 303 | ), |
304 | 304 | ), |
305 | 305 | array( |
306 | - 'name' => __( 'Registration', 'give' ), |
|
307 | - 'desc' => __( 'Display the registration and login forms in the payment section for non-logged-in users.', 'give' ), |
|
308 | - 'id' => $prefix . 'show_register_form', |
|
306 | + 'name' => __('Registration', 'give'), |
|
307 | + 'desc' => __('Display the registration and login forms in the payment section for non-logged-in users.', 'give'), |
|
308 | + 'id' => $prefix.'show_register_form', |
|
309 | 309 | 'type' => 'radio', |
310 | 310 | 'options' => array( |
311 | - 'none' => __( 'None', 'give' ), |
|
312 | - 'registration' => __( 'Registration', 'give' ), |
|
313 | - 'login' => __( 'Login', 'give' ), |
|
314 | - 'both' => __( 'Registration + Login', 'give' ), |
|
311 | + 'none' => __('None', 'give'), |
|
312 | + 'registration' => __('Registration', 'give'), |
|
313 | + 'login' => __('Login', 'give'), |
|
314 | + 'both' => __('Registration + Login', 'give'), |
|
315 | 315 | ), |
316 | 316 | 'default' => 'none', |
317 | 317 | ), |
318 | 318 | array( |
319 | - 'name' => __( 'Floating Labels', 'give' ), |
|
319 | + 'name' => __('Floating Labels', 'give'), |
|
320 | 320 | /* translators: %s: forms http://docs.givewp.com/form-floating-labels */ |
321 | - 'desc' => sprintf( __( 'Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give' ), esc_url( 'http://docs.givewp.com/form-floating-labels' ) ), |
|
322 | - 'id' => $prefix . 'form_floating_labels', |
|
321 | + 'desc' => sprintf(__('Select the <a href="%s" target="_blank">floating labels</a> setting for this Give form. Be aware that if you have the "Disable CSS" option enabled, you will need to style the floating labels yourself.', 'give'), esc_url('http://docs.givewp.com/form-floating-labels')), |
|
322 | + 'id' => $prefix.'form_floating_labels', |
|
323 | 323 | 'type' => 'radio_inline', |
324 | 324 | 'options' => array( |
325 | - 'global' => __( 'Global Option', 'give' ), |
|
326 | - 'enabled' => __( 'Enabled', 'give' ), |
|
327 | - 'disabled' => __( 'Disabled', 'give' ), |
|
325 | + 'global' => __('Global Option', 'give'), |
|
326 | + 'enabled' => __('Enabled', 'give'), |
|
327 | + 'disabled' => __('Disabled', 'give'), |
|
328 | 328 | ), |
329 | 329 | 'default' => 'global', |
330 | 330 | ), |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | 'name' => 'form_display_docs', |
333 | 333 | 'type' => 'docs_link', |
334 | 334 | 'url' => 'http://docs.givewp.com/form-display-options', |
335 | - 'title' => __( 'Form Display', 'give' ), |
|
335 | + 'title' => __('Form Display', 'give'), |
|
336 | 336 | ), |
337 | 337 | ), |
338 | 338 | $post_id |
@@ -343,31 +343,31 @@ discard block |
||
343 | 343 | /** |
344 | 344 | * Donation Goals |
345 | 345 | */ |
346 | - 'donation_goal_options' => apply_filters( 'give_donation_goal_options', array( |
|
346 | + 'donation_goal_options' => apply_filters('give_donation_goal_options', array( |
|
347 | 347 | 'id' => 'donation_goal_options', |
348 | - 'title' => __( 'Donation Goal', 'give' ), |
|
348 | + 'title' => __('Donation Goal', 'give'), |
|
349 | 349 | 'icon-html' => '<span class="give-icon give-icon-target"></span>', |
350 | - 'fields' => apply_filters( 'give_forms_donation_goal_metabox_fields', array( |
|
350 | + 'fields' => apply_filters('give_forms_donation_goal_metabox_fields', array( |
|
351 | 351 | // Goals |
352 | 352 | array( |
353 | - 'name' => __( 'Donation Goal', 'give' ), |
|
354 | - 'description' => __( 'Do you want to set a donation goal for this form?', 'give' ), |
|
355 | - 'id' => $prefix . 'goal_option', |
|
353 | + 'name' => __('Donation Goal', 'give'), |
|
354 | + 'description' => __('Do you want to set a donation goal for this form?', 'give'), |
|
355 | + 'id' => $prefix.'goal_option', |
|
356 | 356 | 'type' => 'radio_inline', |
357 | 357 | 'default' => 'disabled', |
358 | 358 | 'options' => array( |
359 | - 'enabled' => __( 'Enabled', 'give' ), |
|
360 | - 'disabled' => __( 'Disabled', 'give' ), |
|
359 | + 'enabled' => __('Enabled', 'give'), |
|
360 | + 'disabled' => __('Disabled', 'give'), |
|
361 | 361 | ), |
362 | 362 | ), |
363 | 363 | array( |
364 | - 'name' => __( 'Goal Amount', 'give' ), |
|
365 | - 'description' => __( 'This is the monetary goal amount you want to reach for this form.', 'give' ), |
|
366 | - 'id' => $prefix . 'set_goal', |
|
364 | + 'name' => __('Goal Amount', 'give'), |
|
365 | + 'description' => __('This is the monetary goal amount you want to reach for this form.', 'give'), |
|
366 | + 'id' => $prefix.'set_goal', |
|
367 | 367 | 'type' => 'text_small', |
368 | 368 | 'data_type' => 'price', |
369 | 369 | 'attributes' => array( |
370 | - 'placeholder' => give_format_decimal( '0.00', false, false ), |
|
370 | + 'placeholder' => give_format_decimal('0.00', false, false), |
|
371 | 371 | 'value' => $goal, |
372 | 372 | 'class' => 'give-money-field', |
373 | 373 | ), |
@@ -375,97 +375,97 @@ discard block |
||
375 | 375 | ), |
376 | 376 | |
377 | 377 | array( |
378 | - 'name' => __( 'Goal Format', 'give' ), |
|
379 | - 'description' => __( 'Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give' ), |
|
380 | - 'id' => $prefix . 'goal_format', |
|
378 | + 'name' => __('Goal Format', 'give'), |
|
379 | + 'description' => __('Do you want to display the total amount raised based on your monetary goal or a percentage? For instance, "$500 of $1,000 raised" or "50% funded".', 'give'), |
|
380 | + 'id' => $prefix.'goal_format', |
|
381 | 381 | 'type' => 'radio_inline', |
382 | 382 | 'default' => 'amount', |
383 | 383 | 'options' => array( |
384 | - 'amount' => __( 'Amount', 'give' ), |
|
385 | - 'percentage' => __( 'Percentage', 'give' ), |
|
384 | + 'amount' => __('Amount', 'give'), |
|
385 | + 'percentage' => __('Percentage', 'give'), |
|
386 | 386 | ), |
387 | 387 | 'wrapper_class' => 'give-hidden', |
388 | 388 | ), |
389 | 389 | array( |
390 | - 'name' => __( 'Progress Bar Color', 'give' ), |
|
391 | - 'desc' => __( 'Customize the color of the goal progress bar.', 'give' ), |
|
392 | - 'id' => $prefix . 'goal_color', |
|
390 | + 'name' => __('Progress Bar Color', 'give'), |
|
391 | + 'desc' => __('Customize the color of the goal progress bar.', 'give'), |
|
392 | + 'id' => $prefix.'goal_color', |
|
393 | 393 | 'type' => 'colorpicker', |
394 | 394 | 'default' => '#2bc253', |
395 | 395 | 'wrapper_class' => 'give-hidden', |
396 | 396 | ), |
397 | 397 | |
398 | 398 | array( |
399 | - 'name' => __( 'Close Form', 'give' ), |
|
400 | - 'desc' => __( 'Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give' ), |
|
401 | - 'id' => $prefix . 'close_form_when_goal_achieved', |
|
399 | + 'name' => __('Close Form', 'give'), |
|
400 | + 'desc' => __('Do you want to close the donation forms and stop accepting donations once this goal has been met?', 'give'), |
|
401 | + 'id' => $prefix.'close_form_when_goal_achieved', |
|
402 | 402 | 'type' => 'radio_inline', |
403 | 403 | 'default' => 'disabled', |
404 | 404 | 'options' => array( |
405 | - 'enabled' => __( 'Enabled', 'give' ), |
|
406 | - 'disabled' => __( 'Disabled', 'give' ), |
|
405 | + 'enabled' => __('Enabled', 'give'), |
|
406 | + 'disabled' => __('Disabled', 'give'), |
|
407 | 407 | ), |
408 | 408 | 'wrapper_class' => 'give-hidden', |
409 | 409 | ), |
410 | 410 | array( |
411 | - 'name' => __( 'Goal Achieved Message', 'give' ), |
|
412 | - 'desc' => __( 'Do you want to display a custom message when the goal is closed?', 'give' ), |
|
413 | - 'id' => $prefix . 'form_goal_achieved_message', |
|
411 | + 'name' => __('Goal Achieved Message', 'give'), |
|
412 | + 'desc' => __('Do you want to display a custom message when the goal is closed?', 'give'), |
|
413 | + 'id' => $prefix.'form_goal_achieved_message', |
|
414 | 414 | 'type' => 'wysiwyg', |
415 | - 'default' => __( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ), |
|
415 | + 'default' => __('Thank you to all our donors, we have met our fundraising goal.', 'give'), |
|
416 | 416 | 'wrapper_class' => 'give-hidden', |
417 | 417 | ), |
418 | 418 | array( |
419 | 419 | 'name' => 'donation_goal_docs', |
420 | 420 | 'type' => 'docs_link', |
421 | 421 | 'url' => 'http://docs.givewp.com/form-donation-goal', |
422 | - 'title' => __( 'Donation Goal', 'give' ), |
|
422 | + 'title' => __('Donation Goal', 'give'), |
|
423 | 423 | ), |
424 | 424 | ), |
425 | 425 | $post_id |
426 | 426 | ), |
427 | - ) ), |
|
427 | + )), |
|
428 | 428 | |
429 | 429 | /** |
430 | 430 | * Content Field |
431 | 431 | */ |
432 | - 'form_content_options' => apply_filters( 'give_forms_content_options', array( |
|
432 | + 'form_content_options' => apply_filters('give_forms_content_options', array( |
|
433 | 433 | 'id' => 'form_content_options', |
434 | - 'title' => __( 'Form Content', 'give' ), |
|
434 | + 'title' => __('Form Content', 'give'), |
|
435 | 435 | 'icon-html' => '<span class="give-icon give-icon-edit"></span>', |
436 | - 'fields' => apply_filters( 'give_forms_content_options_metabox_fields', array( |
|
436 | + 'fields' => apply_filters('give_forms_content_options_metabox_fields', array( |
|
437 | 437 | |
438 | 438 | // Donation content. |
439 | 439 | array( |
440 | - 'name' => __( 'Display Content', 'give' ), |
|
441 | - 'description' => __( 'Do you want to add custom content to this form?', 'give' ), |
|
442 | - 'id' => $prefix . 'display_content', |
|
440 | + 'name' => __('Display Content', 'give'), |
|
441 | + 'description' => __('Do you want to add custom content to this form?', 'give'), |
|
442 | + 'id' => $prefix.'display_content', |
|
443 | 443 | 'type' => 'radio_inline', |
444 | 444 | 'options' => array( |
445 | - 'enabled' => __( 'Enabled', 'give' ), |
|
446 | - 'disabled' => __( 'Disabled', 'give' ), |
|
445 | + 'enabled' => __('Enabled', 'give'), |
|
446 | + 'disabled' => __('Disabled', 'give'), |
|
447 | 447 | ), |
448 | 448 | 'default' => 'disabled', |
449 | 449 | ), |
450 | 450 | |
451 | 451 | // Content placement. |
452 | 452 | array( |
453 | - 'name' => __( 'Content Placement', 'give' ), |
|
454 | - 'description' => __( 'This option controls where the content appears within the donation form.', 'give' ), |
|
455 | - 'id' => $prefix . 'content_placement', |
|
453 | + 'name' => __('Content Placement', 'give'), |
|
454 | + 'description' => __('This option controls where the content appears within the donation form.', 'give'), |
|
455 | + 'id' => $prefix.'content_placement', |
|
456 | 456 | 'type' => 'radio_inline', |
457 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
458 | - 'give_pre_form' => __( 'Above fields', 'give' ), |
|
459 | - 'give_post_form' => __( 'Below fields', 'give' ), |
|
457 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
458 | + 'give_pre_form' => __('Above fields', 'give'), |
|
459 | + 'give_post_form' => __('Below fields', 'give'), |
|
460 | 460 | ) |
461 | 461 | ), |
462 | 462 | 'default' => 'give_pre_form', |
463 | 463 | 'wrapper_class' => 'give-hidden', |
464 | 464 | ), |
465 | 465 | array( |
466 | - 'name' => __( 'Content', 'give' ), |
|
467 | - 'description' => __( 'This content will display on the single give form page.', 'give' ), |
|
468 | - 'id' => $prefix . 'form_content', |
|
466 | + 'name' => __('Content', 'give'), |
|
467 | + 'description' => __('This content will display on the single give form page.', 'give'), |
|
468 | + 'id' => $prefix.'form_content', |
|
469 | 469 | 'type' => 'wysiwyg', |
470 | 470 | 'wrapper_class' => 'give-hidden', |
471 | 471 | ), |
@@ -473,51 +473,51 @@ discard block |
||
473 | 473 | 'name' => 'form_content_docs', |
474 | 474 | 'type' => 'docs_link', |
475 | 475 | 'url' => 'http://docs.givewp.com/form-content', |
476 | - 'title' => __( 'Form Content', 'give' ), |
|
476 | + 'title' => __('Form Content', 'give'), |
|
477 | 477 | ), |
478 | 478 | ), |
479 | 479 | $post_id |
480 | 480 | ), |
481 | - ) ), |
|
481 | + )), |
|
482 | 482 | |
483 | 483 | /** |
484 | 484 | * Terms & Conditions |
485 | 485 | */ |
486 | - 'form_terms_options' => apply_filters( 'give_forms_terms_options', array( |
|
486 | + 'form_terms_options' => apply_filters('give_forms_terms_options', array( |
|
487 | 487 | 'id' => 'form_terms_options', |
488 | - 'title' => __( 'Terms & Conditions', 'give' ), |
|
488 | + 'title' => __('Terms & Conditions', 'give'), |
|
489 | 489 | 'icon-html' => '<span class="give-icon give-icon-checklist"></span>', |
490 | - 'fields' => apply_filters( 'give_forms_terms_options_metabox_fields', array( |
|
490 | + 'fields' => apply_filters('give_forms_terms_options_metabox_fields', array( |
|
491 | 491 | // Donation Option |
492 | 492 | array( |
493 | - 'name' => __( 'Terms and Conditions', 'give' ), |
|
494 | - 'description' => __( 'Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give' ), |
|
495 | - 'id' => $prefix . 'terms_option', |
|
493 | + 'name' => __('Terms and Conditions', 'give'), |
|
494 | + 'description' => __('Do you want to require the donor to accept terms prior to being able to complete their donation?', 'give'), |
|
495 | + 'id' => $prefix.'terms_option', |
|
496 | 496 | 'type' => 'radio_inline', |
497 | - 'options' => apply_filters( 'give_forms_content_options_select', array( |
|
498 | - 'global' => __( 'Global Option', 'give' ), |
|
499 | - 'enabled' => __( 'Customize', 'give' ), |
|
500 | - 'disabled' => __( 'Disable', 'give' ), |
|
497 | + 'options' => apply_filters('give_forms_content_options_select', array( |
|
498 | + 'global' => __('Global Option', 'give'), |
|
499 | + 'enabled' => __('Customize', 'give'), |
|
500 | + 'disabled' => __('Disable', 'give'), |
|
501 | 501 | ) |
502 | 502 | ), |
503 | 503 | 'default' => 'global', |
504 | 504 | ), |
505 | 505 | array( |
506 | - 'id' => $prefix . 'agree_label', |
|
507 | - 'name' => __( 'Agreement Label', 'give' ), |
|
508 | - 'desc' => __( 'The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give' ), |
|
506 | + 'id' => $prefix.'agree_label', |
|
507 | + 'name' => __('Agreement Label', 'give'), |
|
508 | + 'desc' => __('The label shown next to the agree to terms check box. Add your own to customize or leave blank to use the default text placeholder.', 'give'), |
|
509 | 509 | 'type' => 'text', |
510 | 510 | 'size' => 'regular', |
511 | 511 | 'attributes' => array( |
512 | - 'placeholder' => esc_attr__( 'Agree to Terms?', 'give' ), |
|
512 | + 'placeholder' => esc_attr__('Agree to Terms?', 'give'), |
|
513 | 513 | ), |
514 | 514 | 'wrapper_class' => 'give-hidden', |
515 | 515 | ), |
516 | 516 | array( |
517 | - 'id' => $prefix . 'agree_text', |
|
518 | - 'name' => __( 'Agreement Text', 'give' ), |
|
519 | - 'desc' => __( 'This is the actual text which the user will have to agree to in order to make a donation.', 'give' ), |
|
520 | - 'default' => give_get_option( 'agreement_text' ), |
|
517 | + 'id' => $prefix.'agree_text', |
|
518 | + 'name' => __('Agreement Text', 'give'), |
|
519 | + 'desc' => __('This is the actual text which the user will have to agree to in order to make a donation.', 'give'), |
|
520 | + 'default' => give_get_option('agreement_text'), |
|
521 | 521 | 'type' => 'wysiwyg', |
522 | 522 | 'wrapper_class' => 'give-hidden', |
523 | 523 | ), |
@@ -525,18 +525,18 @@ discard block |
||
525 | 525 | 'name' => 'terms_docs', |
526 | 526 | 'type' => 'docs_link', |
527 | 527 | 'url' => 'http://docs.givewp.com/form-terms', |
528 | - 'title' => __( 'Terms and Conditions', 'give' ), |
|
528 | + 'title' => __('Terms and Conditions', 'give'), |
|
529 | 529 | ), |
530 | 530 | ), |
531 | 531 | $post_id |
532 | 532 | ), |
533 | - ) ), |
|
533 | + )), |
|
534 | 534 | ); |
535 | 535 | |
536 | 536 | /** |
537 | 537 | * Filter the metabox tabbed panel settings. |
538 | 538 | */ |
539 | - $settings = apply_filters( 'give_metabox_form_data_settings', $settings, $post_id ); |
|
539 | + $settings = apply_filters('give_metabox_form_data_settings', $settings, $post_id); |
|
540 | 540 | |
541 | 541 | // Output. |
542 | 542 | return $settings; |
@@ -552,8 +552,8 @@ discard block |
||
552 | 552 | add_meta_box( |
553 | 553 | $this->get_metabox_ID(), |
554 | 554 | $this->get_metabox_label(), |
555 | - array( $this, 'output' ), |
|
556 | - array( 'give_forms' ), |
|
555 | + array($this, 'output'), |
|
556 | + array('give_forms'), |
|
557 | 557 | 'normal', |
558 | 558 | 'high' |
559 | 559 | ); |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | function enqueue_script() { |
570 | 570 | global $post; |
571 | 571 | |
572 | - if ( is_object( $post ) && 'give_forms' === $post->post_type ) { |
|
572 | + if (is_object($post) && 'give_forms' === $post->post_type) { |
|
573 | 573 | |
574 | 574 | } |
575 | 575 | } |
@@ -604,32 +604,32 @@ discard block |
||
604 | 604 | public function get_tabs() { |
605 | 605 | $tabs = array(); |
606 | 606 | |
607 | - if ( ! empty( $this->settings ) ) { |
|
608 | - foreach ( $this->settings as $setting ) { |
|
609 | - if ( ! isset( $setting['id'] ) || ! isset( $setting['title'] ) ) { |
|
607 | + if ( ! empty($this->settings)) { |
|
608 | + foreach ($this->settings as $setting) { |
|
609 | + if ( ! isset($setting['id']) || ! isset($setting['title'])) { |
|
610 | 610 | continue; |
611 | 611 | } |
612 | 612 | $tab = array( |
613 | 613 | 'id' => $setting['id'], |
614 | 614 | 'label' => $setting['title'], |
615 | - 'icon-html' => ( ! empty( $setting['icon-html'] ) ? $setting['icon-html'] : '' ), |
|
615 | + 'icon-html' => ( ! empty($setting['icon-html']) ? $setting['icon-html'] : ''), |
|
616 | 616 | ); |
617 | 617 | |
618 | - if ( $this->has_sub_tab( $setting ) ) { |
|
619 | - if ( empty( $setting['sub-fields'] ) ) { |
|
618 | + if ($this->has_sub_tab($setting)) { |
|
619 | + if (empty($setting['sub-fields'])) { |
|
620 | 620 | $tab = array(); |
621 | 621 | } else { |
622 | - foreach ( $setting['sub-fields'] as $sub_fields ) { |
|
622 | + foreach ($setting['sub-fields'] as $sub_fields) { |
|
623 | 623 | $tab['sub-fields'][] = array( |
624 | 624 | 'id' => $sub_fields['id'], |
625 | 625 | 'label' => $sub_fields['title'], |
626 | - 'icon-html' => ( ! empty( $sub_fields['icon-html'] ) ? $sub_fields['icon-html'] : '' ), |
|
626 | + 'icon-html' => ( ! empty($sub_fields['icon-html']) ? $sub_fields['icon-html'] : ''), |
|
627 | 627 | ); |
628 | 628 | } |
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | - if ( ! empty( $tab ) ) { |
|
632 | + if ( ! empty($tab)) { |
|
633 | 633 | $tabs[] = $tab; |
634 | 634 | } |
635 | 635 | } |
@@ -646,33 +646,33 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public function output() { |
648 | 648 | // Bailout. |
649 | - if ( $form_data_tabs = $this->get_tabs() ) : |
|
650 | - $active_tab = ! empty( $_GET['give_tab'] ) ? give_clean( $_GET['give_tab'] ) : 'form_field_options'; |
|
651 | - wp_nonce_field( 'give_save_form_meta', 'give_form_meta_nonce' ); |
|
649 | + if ($form_data_tabs = $this->get_tabs()) : |
|
650 | + $active_tab = ! empty($_GET['give_tab']) ? give_clean($_GET['give_tab']) : 'form_field_options'; |
|
651 | + wp_nonce_field('give_save_form_meta', 'give_form_meta_nonce'); |
|
652 | 652 | ?> |
653 | 653 | <input id="give_form_active_tab" type="hidden" name="give_form_active_tab"> |
654 | 654 | <div class="give-metabox-panel-wrap"> |
655 | 655 | <ul class="give-form-data-tabs give-metabox-tabs"> |
656 | - <?php foreach ( $form_data_tabs as $index => $form_data_tab ) : ?> |
|
656 | + <?php foreach ($form_data_tabs as $index => $form_data_tab) : ?> |
|
657 | 657 | <?php |
658 | 658 | // Determine if current tab is active. |
659 | 659 | $is_active = $active_tab === $form_data_tab['id'] ? true : false; |
660 | 660 | ?> |
661 | - <li class="<?php echo "{$form_data_tab['id']}_tab" . ( $is_active ? ' active' : '' ) . ( $this->has_sub_tab( $form_data_tab ) ? ' has-sub-fields' : '' ); ?>"> |
|
661 | + <li class="<?php echo "{$form_data_tab['id']}_tab".($is_active ? ' active' : '').($this->has_sub_tab($form_data_tab) ? ' has-sub-fields' : ''); ?>"> |
|
662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
663 | - <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
|
663 | + <?php if ( ! empty($form_data_tab['icon-html'])) : ?> |
|
664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
665 | 665 | <?php else : ?> |
666 | 666 | <span class="give-icon give-icon-default"></span> |
667 | 667 | <?php endif; ?> |
668 | 668 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
669 | 669 | </a> |
670 | - <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
|
670 | + <?php if ($this->has_sub_tab($form_data_tab)) : ?> |
|
671 | 671 | <ul class="give-metabox-sub-tabs give-hidden"> |
672 | - <?php foreach ( $form_data_tab['sub-fields'] as $sub_tab ) : ?> |
|
672 | + <?php foreach ($form_data_tab['sub-fields'] as $sub_tab) : ?> |
|
673 | 673 | <li class="<?php echo "{$sub_tab['id']}_tab"; ?>"> |
674 | 674 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
675 | - <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
|
675 | + <?php if ( ! empty($sub_tab['icon-html'])) : ?> |
|
676 | 676 | <?php echo $sub_tab['icon-html']; ?> |
677 | 677 | <?php else : ?> |
678 | 678 | <span class="give-icon give-icon-default"></span> |
@@ -687,30 +687,30 @@ discard block |
||
687 | 687 | <?php endforeach; ?> |
688 | 688 | </ul> |
689 | 689 | |
690 | - <?php foreach ( $this->settings as $setting ) : ?> |
|
691 | - <?php if ( ! $this->has_sub_tab( $setting ) ) : ?> |
|
692 | - <?php do_action( "give_before_{$setting['id']}_settings" ); ?> |
|
690 | + <?php foreach ($this->settings as $setting) : ?> |
|
691 | + <?php if ( ! $this->has_sub_tab($setting)) : ?> |
|
692 | + <?php do_action("give_before_{$setting['id']}_settings"); ?> |
|
693 | 693 | <?php |
694 | 694 | // Determine if current panel is active. |
695 | 695 | $is_active = $active_tab === $setting['id'] ? true : false; |
696 | 696 | ?> |
697 | - <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo( $is_active ? ' active' : '' ); ?>"> |
|
698 | - <?php if ( ! empty( $setting['fields'] ) ) : ?> |
|
699 | - <?php foreach ( $setting['fields'] as $field ) : ?> |
|
700 | - <?php give_render_field( $field ); ?> |
|
697 | + <div id="<?php echo $setting['id']; ?>" class="panel give_options_panel<?php echo($is_active ? ' active' : ''); ?>"> |
|
698 | + <?php if ( ! empty($setting['fields'])) : ?> |
|
699 | + <?php foreach ($setting['fields'] as $field) : ?> |
|
700 | + <?php give_render_field($field); ?> |
|
701 | 701 | <?php endforeach; ?> |
702 | 702 | <?php endif; ?> |
703 | 703 | </div> |
704 | 704 | |
705 | - <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
|
705 | + <?php do_action("give_after_{$setting['id']}_settings"); ?> |
|
706 | 706 | <?php else : ?> |
707 | - <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
|
708 | - <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
|
709 | - <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
|
707 | + <?php if ($this->has_sub_tab($setting)) : ?> |
|
708 | + <?php if ( ! empty($setting['sub-fields'])) : ?> |
|
709 | + <?php foreach ($setting['sub-fields'] as $index => $sub_fields) : ?> |
|
710 | 710 | <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
711 | - <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
|
712 | - <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
|
713 | - <?php give_render_field( $sub_field ); ?> |
|
711 | + <?php if ( ! empty($sub_fields['fields'])) : ?> |
|
712 | + <?php foreach ($sub_fields['fields'] as $sub_field) : ?> |
|
713 | + <?php give_render_field($sub_field); ?> |
|
714 | 714 | <?php endforeach; ?> |
715 | 715 | <?php endif; ?> |
716 | 716 | </div> |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | * |
735 | 735 | * @return bool |
736 | 736 | */ |
737 | - private function has_sub_tab( $field_setting ) { |
|
737 | + private function has_sub_tab($field_setting) { |
|
738 | 738 | $has_sub_tab = false; |
739 | - if ( array_key_exists( 'sub-fields', $field_setting ) ) { |
|
739 | + if (array_key_exists('sub-fields', $field_setting)) { |
|
740 | 740 | $has_sub_tab = true; |
741 | 741 | } |
742 | 742 | |
@@ -750,13 +750,13 @@ discard block |
||
750 | 750 | * @return array |
751 | 751 | */ |
752 | 752 | function cmb2_metabox_settings() { |
753 | - $all_cmb2_settings = apply_filters( 'cmb2_meta_boxes', array() ); |
|
753 | + $all_cmb2_settings = apply_filters('cmb2_meta_boxes', array()); |
|
754 | 754 | $give_forms_settings = $all_cmb2_settings; |
755 | 755 | |
756 | 756 | // Filter settings: Use only give forms related settings. |
757 | - foreach ( $all_cmb2_settings as $index => $setting ) { |
|
758 | - if ( ! in_array( 'give_forms', $setting['object_types'] ) ) { |
|
759 | - unset( $give_forms_settings[ $index ] ); |
|
757 | + foreach ($all_cmb2_settings as $index => $setting) { |
|
758 | + if ( ! in_array('give_forms', $setting['object_types'])) { |
|
759 | + unset($give_forms_settings[$index]); |
|
760 | 760 | } |
761 | 761 | } |
762 | 762 | |
@@ -774,96 +774,96 @@ discard block |
||
774 | 774 | * |
775 | 775 | * @return void |
776 | 776 | */ |
777 | - public function save( $post_id, $post ) { |
|
777 | + public function save($post_id, $post) { |
|
778 | 778 | |
779 | 779 | // $post_id and $post are required. |
780 | - if ( empty( $post_id ) || empty( $post ) ) { |
|
780 | + if (empty($post_id) || empty($post)) { |
|
781 | 781 | return; |
782 | 782 | } |
783 | 783 | |
784 | 784 | // Don't save meta boxes for revisions or autosaves. |
785 | - if ( defined( 'DOING_AUTOSAVE' ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) { |
|
785 | + if (defined('DOING_AUTOSAVE') || is_int(wp_is_post_revision($post)) || is_int(wp_is_post_autosave($post))) { |
|
786 | 786 | return; |
787 | 787 | } |
788 | 788 | |
789 | 789 | // Check the nonce. |
790 | - if ( empty( $_POST['give_form_meta_nonce'] ) || ! wp_verify_nonce( $_POST['give_form_meta_nonce'], 'give_save_form_meta' ) ) { |
|
790 | + if (empty($_POST['give_form_meta_nonce']) || ! wp_verify_nonce($_POST['give_form_meta_nonce'], 'give_save_form_meta')) { |
|
791 | 791 | return; |
792 | 792 | } |
793 | 793 | |
794 | 794 | // Check the post being saved == the $post_id to prevent triggering this call for other save_post events. |
795 | - if ( empty( $_POST['post_ID'] ) || $_POST['post_ID'] != $post_id ) { |
|
795 | + if (empty($_POST['post_ID']) || $_POST['post_ID'] != $post_id) { |
|
796 | 796 | return; |
797 | 797 | } |
798 | 798 | |
799 | 799 | // Check user has permission to edit. |
800 | - if ( ! current_user_can( 'edit_post', $post_id ) ) { |
|
800 | + if ( ! current_user_can('edit_post', $post_id)) { |
|
801 | 801 | return; |
802 | 802 | } |
803 | 803 | |
804 | 804 | // Fire action before saving form meta. |
805 | - do_action( 'give_pre_process_give_forms_meta', $post_id, $post ); |
|
805 | + do_action('give_pre_process_give_forms_meta', $post_id, $post); |
|
806 | 806 | |
807 | 807 | /** |
808 | 808 | * Filter the meta key to save. |
809 | 809 | * Third party addon developer can remove there meta keys from this array to handle saving data on there own. |
810 | 810 | */ |
811 | - $form_meta_keys = apply_filters( 'give_process_form_meta_keys', $this->get_meta_keys_from_settings() ); |
|
811 | + $form_meta_keys = apply_filters('give_process_form_meta_keys', $this->get_meta_keys_from_settings()); |
|
812 | 812 | |
813 | 813 | // Save form meta data. |
814 | - if ( ! empty( $form_meta_keys ) ) { |
|
815 | - foreach ( $form_meta_keys as $form_meta_key ) { |
|
814 | + if ( ! empty($form_meta_keys)) { |
|
815 | + foreach ($form_meta_keys as $form_meta_key) { |
|
816 | 816 | |
817 | 817 | // Set default value for checkbox fields. |
818 | 818 | if ( |
819 | - ! isset( $_POST[ $form_meta_key ] ) |
|
820 | - && ( 'checkbox' === $this->get_field_type( $form_meta_key ) ) |
|
819 | + ! isset($_POST[$form_meta_key]) |
|
820 | + && ('checkbox' === $this->get_field_type($form_meta_key)) |
|
821 | 821 | ) { |
822 | - $_POST[ $form_meta_key ] = ''; |
|
822 | + $_POST[$form_meta_key] = ''; |
|
823 | 823 | } |
824 | 824 | |
825 | - if ( isset( $_POST[ $form_meta_key ] ) ) { |
|
826 | - $setting_field = $this->get_setting_field( $form_meta_key ); |
|
827 | - if ( ! empty( $setting_field['type'] ) ) { |
|
828 | - switch ( $setting_field['type'] ) { |
|
825 | + if (isset($_POST[$form_meta_key])) { |
|
826 | + $setting_field = $this->get_setting_field($form_meta_key); |
|
827 | + if ( ! empty($setting_field['type'])) { |
|
828 | + switch ($setting_field['type']) { |
|
829 | 829 | case 'textarea': |
830 | 830 | case 'wysiwyg': |
831 | - $form_meta_value = wp_kses_post( $_POST[ $form_meta_key ] ); |
|
831 | + $form_meta_value = wp_kses_post($_POST[$form_meta_key]); |
|
832 | 832 | break; |
833 | 833 | |
834 | 834 | case 'group': |
835 | 835 | $form_meta_value = array(); |
836 | 836 | |
837 | - foreach ( $_POST[ $form_meta_key ] as $index => $group ) { |
|
837 | + foreach ($_POST[$form_meta_key] as $index => $group) { |
|
838 | 838 | |
839 | 839 | // Do not save template input field values. |
840 | - if ( '{{row-count-placeholder}}' === $index ) { |
|
840 | + if ('{{row-count-placeholder}}' === $index) { |
|
841 | 841 | continue; |
842 | 842 | } |
843 | 843 | |
844 | 844 | $group_meta_value = array(); |
845 | - foreach ( $group as $field_id => $field_value ) { |
|
846 | - switch ( $this->get_field_type( $field_id, $form_meta_key ) ) { |
|
845 | + foreach ($group as $field_id => $field_value) { |
|
846 | + switch ($this->get_field_type($field_id, $form_meta_key)) { |
|
847 | 847 | case 'wysiwyg': |
848 | - $group_meta_value[ $field_id ] = wp_kses_post( $field_value ); |
|
848 | + $group_meta_value[$field_id] = wp_kses_post($field_value); |
|
849 | 849 | break; |
850 | 850 | |
851 | 851 | default: |
852 | - $group_meta_value[ $field_id ] = give_clean( $field_value ); |
|
852 | + $group_meta_value[$field_id] = give_clean($field_value); |
|
853 | 853 | } |
854 | 854 | } |
855 | 855 | |
856 | - if ( ! empty( $group_meta_value ) ) { |
|
857 | - $form_meta_value[ $index ] = $group_meta_value; |
|
856 | + if ( ! empty($group_meta_value)) { |
|
857 | + $form_meta_value[$index] = $group_meta_value; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | 861 | // Arrange repeater field keys in order. |
862 | - $form_meta_value = array_values( $form_meta_value ); |
|
862 | + $form_meta_value = array_values($form_meta_value); |
|
863 | 863 | break; |
864 | 864 | |
865 | 865 | default: |
866 | - $form_meta_value = give_clean( $_POST[ $form_meta_key ] ); |
|
866 | + $form_meta_value = give_clean($_POST[$form_meta_key]); |
|
867 | 867 | }// End switch(). |
868 | 868 | |
869 | 869 | /** |
@@ -873,24 +873,24 @@ discard block |
||
873 | 873 | */ |
874 | 874 | $form_meta_value = apply_filters( |
875 | 875 | 'give_pre_save_form_meta_value', |
876 | - $this->sanitize_form_meta( $form_meta_value, $setting_field ), |
|
876 | + $this->sanitize_form_meta($form_meta_value, $setting_field), |
|
877 | 877 | $form_meta_key, |
878 | 878 | $this, |
879 | 879 | $post_id |
880 | 880 | ); |
881 | 881 | |
882 | 882 | // Save data. |
883 | - give_update_meta( $post_id, $form_meta_key, $form_meta_value ); |
|
883 | + give_update_meta($post_id, $form_meta_key, $form_meta_value); |
|
884 | 884 | |
885 | 885 | // Fire after saving form meta key. |
886 | - do_action( "give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post ); |
|
886 | + do_action("give_save_{$form_meta_key}", $form_meta_key, $form_meta_value, $post_id, $post); |
|
887 | 887 | }// End if(). |
888 | 888 | }// End if(). |
889 | 889 | }// End foreach(). |
890 | 890 | }// End if(). |
891 | 891 | |
892 | 892 | // Fire action after saving form meta. |
893 | - do_action( 'give_post_process_give_forms_meta', $post_id, $post ); |
|
893 | + do_action('give_post_process_give_forms_meta', $post_id, $post); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | |
@@ -903,10 +903,10 @@ discard block |
||
903 | 903 | * |
904 | 904 | * @return string |
905 | 905 | */ |
906 | - private function get_field_id( $field ) { |
|
906 | + private function get_field_id($field) { |
|
907 | 907 | $field_id = ''; |
908 | 908 | |
909 | - if ( array_key_exists( 'id', $field ) ) { |
|
909 | + if (array_key_exists('id', $field)) { |
|
910 | 910 | $field_id = $field['id']; |
911 | 911 | |
912 | 912 | } |
@@ -923,12 +923,12 @@ discard block |
||
923 | 923 | * |
924 | 924 | * @return array |
925 | 925 | */ |
926 | - private function get_fields_id( $setting ) { |
|
926 | + private function get_fields_id($setting) { |
|
927 | 927 | $meta_keys = array(); |
928 | 928 | |
929 | - if ( ! empty( $setting ) ) { |
|
930 | - foreach ( $setting['fields'] as $field ) { |
|
931 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
929 | + if ( ! empty($setting)) { |
|
930 | + foreach ($setting['fields'] as $field) { |
|
931 | + if ($field_id = $this->get_field_id($field)) { |
|
932 | 932 | $meta_keys[] = $field_id; |
933 | 933 | } |
934 | 934 | } |
@@ -946,14 +946,14 @@ discard block |
||
946 | 946 | * |
947 | 947 | * @return array |
948 | 948 | */ |
949 | - private function get_sub_fields_id( $setting ) { |
|
949 | + private function get_sub_fields_id($setting) { |
|
950 | 950 | $meta_keys = array(); |
951 | 951 | |
952 | - if ( $this->has_sub_tab( $setting ) && ! empty( $setting['sub-fields'] ) ) { |
|
953 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
954 | - if ( ! empty( $fields['fields'] ) ) { |
|
955 | - foreach ( $fields['fields'] as $field ) { |
|
956 | - if ( $field_id = $this->get_field_id( $field ) ) { |
|
952 | + if ($this->has_sub_tab($setting) && ! empty($setting['sub-fields'])) { |
|
953 | + foreach ($setting['sub-fields'] as $fields) { |
|
954 | + if ( ! empty($fields['fields'])) { |
|
955 | + foreach ($fields['fields'] as $field) { |
|
956 | + if ($field_id = $this->get_field_id($field)) { |
|
957 | 957 | $meta_keys[] = $field_id; |
958 | 958 | } |
959 | 959 | } |
@@ -974,14 +974,14 @@ discard block |
||
974 | 974 | private function get_meta_keys_from_settings() { |
975 | 975 | $meta_keys = array(); |
976 | 976 | |
977 | - foreach ( $this->settings as $setting ) { |
|
978 | - if ( $this->has_sub_tab( $setting ) ) { |
|
979 | - $meta_key = $this->get_sub_fields_id( $setting ); |
|
977 | + foreach ($this->settings as $setting) { |
|
978 | + if ($this->has_sub_tab($setting)) { |
|
979 | + $meta_key = $this->get_sub_fields_id($setting); |
|
980 | 980 | } else { |
981 | - $meta_key = $this->get_fields_id( $setting ); |
|
981 | + $meta_key = $this->get_fields_id($setting); |
|
982 | 982 | } |
983 | 983 | |
984 | - $meta_keys = array_merge( $meta_keys, $meta_key ); |
|
984 | + $meta_keys = array_merge($meta_keys, $meta_key); |
|
985 | 985 | } |
986 | 986 | |
987 | 987 | return $meta_keys; |
@@ -998,10 +998,10 @@ discard block |
||
998 | 998 | * |
999 | 999 | * @return string |
1000 | 1000 | */ |
1001 | - function get_field_type( $field_id, $group_id = '' ) { |
|
1002 | - $field = $this->get_setting_field( $field_id, $group_id ); |
|
1001 | + function get_field_type($field_id, $group_id = '') { |
|
1002 | + $field = $this->get_setting_field($field_id, $group_id); |
|
1003 | 1003 | |
1004 | - $type = array_key_exists( 'type', $field ) |
|
1004 | + $type = array_key_exists('type', $field) |
|
1005 | 1005 | ? $field['type'] |
1006 | 1006 | : ''; |
1007 | 1007 | |
@@ -1019,12 +1019,12 @@ discard block |
||
1019 | 1019 | * |
1020 | 1020 | * @return array |
1021 | 1021 | */ |
1022 | - private function get_field( $setting, $field_id ) { |
|
1022 | + private function get_field($setting, $field_id) { |
|
1023 | 1023 | $setting_field = array(); |
1024 | 1024 | |
1025 | - if ( ! empty( $setting['fields'] ) ) { |
|
1026 | - foreach ( $setting['fields'] as $field ) { |
|
1027 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $field_id ) { |
|
1025 | + if ( ! empty($setting['fields'])) { |
|
1026 | + foreach ($setting['fields'] as $field) { |
|
1027 | + if (array_key_exists('id', $field) && $field['id'] === $field_id) { |
|
1028 | 1028 | $setting_field = $field; |
1029 | 1029 | break; |
1030 | 1030 | } |
@@ -1044,12 +1044,12 @@ discard block |
||
1044 | 1044 | * |
1045 | 1045 | * @return array |
1046 | 1046 | */ |
1047 | - private function get_sub_field( $setting, $field_id ) { |
|
1047 | + private function get_sub_field($setting, $field_id) { |
|
1048 | 1048 | $setting_field = array(); |
1049 | 1049 | |
1050 | - if ( ! empty( $setting['sub-fields'] ) ) { |
|
1051 | - foreach ( $setting['sub-fields'] as $fields ) { |
|
1052 | - if ( $field = $this->get_field( $fields, $field_id ) ) { |
|
1050 | + if ( ! empty($setting['sub-fields'])) { |
|
1051 | + foreach ($setting['sub-fields'] as $fields) { |
|
1052 | + if ($field = $this->get_field($fields, $field_id)) { |
|
1053 | 1053 | $setting_field = $field; |
1054 | 1054 | break; |
1055 | 1055 | } |
@@ -1069,17 +1069,17 @@ discard block |
||
1069 | 1069 | * |
1070 | 1070 | * @return array |
1071 | 1071 | */ |
1072 | - function get_setting_field( $field_id, $group_id = '' ) { |
|
1072 | + function get_setting_field($field_id, $group_id = '') { |
|
1073 | 1073 | $setting_field = array(); |
1074 | 1074 | |
1075 | 1075 | $_field_id = $field_id; |
1076 | - $field_id = empty( $group_id ) ? $field_id : $group_id; |
|
1076 | + $field_id = empty($group_id) ? $field_id : $group_id; |
|
1077 | 1077 | |
1078 | - if ( ! empty( $this->settings ) ) { |
|
1079 | - foreach ( $this->settings as $setting ) { |
|
1078 | + if ( ! empty($this->settings)) { |
|
1079 | + foreach ($this->settings as $setting) { |
|
1080 | 1080 | if ( |
1081 | - ( $this->has_sub_tab( $setting ) && ( $setting_field = $this->get_sub_field( $setting, $field_id ) ) ) |
|
1082 | - || ( $setting_field = $this->get_field( $setting, $field_id ) ) |
|
1081 | + ($this->has_sub_tab($setting) && ($setting_field = $this->get_sub_field($setting, $field_id))) |
|
1082 | + || ($setting_field = $this->get_field($setting, $field_id)) |
|
1083 | 1083 | ) { |
1084 | 1084 | break; |
1085 | 1085 | } |
@@ -1087,9 +1087,9 @@ discard block |
||
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | // Get field from group. |
1090 | - if ( ! empty( $group_id ) ) { |
|
1091 | - foreach ( $setting_field['fields'] as $field ) { |
|
1092 | - if ( array_key_exists( 'id', $field ) && $field['id'] === $_field_id ) { |
|
1090 | + if ( ! empty($group_id)) { |
|
1091 | + foreach ($setting_field['fields'] as $field) { |
|
1092 | + if (array_key_exists('id', $field) && $field['id'] === $_field_id) { |
|
1093 | 1093 | $setting_field = $field; |
1094 | 1094 | } |
1095 | 1095 | } |
@@ -1108,14 +1108,14 @@ discard block |
||
1108 | 1108 | * |
1109 | 1109 | * @return mixed |
1110 | 1110 | */ |
1111 | - function add_offline_donations_setting_tab( $settings ) { |
|
1112 | - if ( give_is_gateway_active( 'offline' ) ) { |
|
1113 | - $settings['offline_donations_options'] = apply_filters( 'give_forms_offline_donations_options', array( |
|
1111 | + function add_offline_donations_setting_tab($settings) { |
|
1112 | + if (give_is_gateway_active('offline')) { |
|
1113 | + $settings['offline_donations_options'] = apply_filters('give_forms_offline_donations_options', array( |
|
1114 | 1114 | 'id' => 'offline_donations_options', |
1115 | - 'title' => __( 'Offline Donations', 'give' ), |
|
1115 | + 'title' => __('Offline Donations', 'give'), |
|
1116 | 1116 | 'icon-html' => '<span class="give-icon give-icon-purse"></span>', |
1117 | - 'fields' => apply_filters( 'give_forms_offline_donations_metabox_fields', array() ), |
|
1118 | - ) ); |
|
1117 | + 'fields' => apply_filters('give_forms_offline_donations_metabox_fields', array()), |
|
1118 | + )); |
|
1119 | 1119 | } |
1120 | 1120 | |
1121 | 1121 | return $settings; |
@@ -1133,22 +1133,22 @@ discard block |
||
1133 | 1133 | * |
1134 | 1134 | * @return mixed |
1135 | 1135 | */ |
1136 | - function sanitize_form_meta( $meta_value, $setting_field ) { |
|
1137 | - switch ( $setting_field['type'] ) { |
|
1136 | + function sanitize_form_meta($meta_value, $setting_field) { |
|
1137 | + switch ($setting_field['type']) { |
|
1138 | 1138 | case 'group': |
1139 | - if ( ! empty( $setting_field['fields'] ) ) { |
|
1140 | - foreach ( $setting_field['fields'] as $field ) { |
|
1141 | - if ( empty( $field['data_type'] ) || 'price' !== $field['data_type'] ) { |
|
1139 | + if ( ! empty($setting_field['fields'])) { |
|
1140 | + foreach ($setting_field['fields'] as $field) { |
|
1141 | + if (empty($field['data_type']) || 'price' !== $field['data_type']) { |
|
1142 | 1142 | continue; |
1143 | 1143 | } |
1144 | 1144 | |
1145 | - foreach ( $meta_value as $index => $meta_data ) { |
|
1146 | - if ( ! isset( $meta_value[ $index ][ $field['id'] ] ) ) { |
|
1145 | + foreach ($meta_value as $index => $meta_data) { |
|
1146 | + if ( ! isset($meta_value[$index][$field['id']])) { |
|
1147 | 1147 | continue; |
1148 | 1148 | } |
1149 | 1149 | |
1150 | - $meta_value[ $index ][ $field['id'] ] = ! empty( $meta_value[ $index ][ $field['id'] ] ) |
|
1151 | - ? give_sanitize_amount_for_db( $meta_value[ $index ][ $field['id'] ] ) |
|
1150 | + $meta_value[$index][$field['id']] = ! empty($meta_value[$index][$field['id']]) |
|
1151 | + ? give_sanitize_amount_for_db($meta_value[$index][$field['id']]) |
|
1152 | 1152 | : 0; |
1153 | 1153 | } |
1154 | 1154 | } |
@@ -1156,8 +1156,8 @@ discard block |
||
1156 | 1156 | break; |
1157 | 1157 | |
1158 | 1158 | default: |
1159 | - if ( ! empty( $setting_field['data_type'] ) && 'price' === $setting_field['data_type'] ) { |
|
1160 | - $meta_value = $meta_value ? give_sanitize_amount_for_db( $meta_value ) : 0; |
|
1159 | + if ( ! empty($setting_field['data_type']) && 'price' === $setting_field['data_type']) { |
|
1160 | + $meta_value = $meta_value ? give_sanitize_amount_for_db($meta_value) : 0; |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
@@ -1175,12 +1175,12 @@ discard block |
||
1175 | 1175 | * |
1176 | 1176 | * @return string The URL after redirect. |
1177 | 1177 | */ |
1178 | - public function maintain_active_tab( $location, $post_id ) { |
|
1178 | + public function maintain_active_tab($location, $post_id) { |
|
1179 | 1179 | if ( |
1180 | - 'give_forms' === get_post_type( $post_id ) && |
|
1181 | - ! empty( $_POST['give_form_active_tab'] ) |
|
1180 | + 'give_forms' === get_post_type($post_id) && |
|
1181 | + ! empty($_POST['give_form_active_tab']) |
|
1182 | 1182 | ) { |
1183 | - $location = add_query_arg( 'give_tab', give_clean( $_POST['give_form_active_tab'] ), $location ); |
|
1183 | + $location = add_query_arg('give_tab', give_clean($_POST['give_form_active_tab']), $location); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | return $location; |
@@ -662,9 +662,12 @@ discard block |
||
662 | 662 | <a href="#<?php echo $form_data_tab['id']; ?>" data-tab-id="<?php echo $form_data_tab['id']; ?>"> |
663 | 663 | <?php if ( ! empty( $form_data_tab['icon-html'] ) ) : ?> |
664 | 664 | <?php echo $form_data_tab['icon-html']; ?> |
665 | - <?php else : ?> |
|
665 | + <?php else { |
|
666 | + : ?> |
|
666 | 667 | <span class="give-icon give-icon-default"></span> |
667 | - <?php endif; ?> |
|
668 | + <?php endif; |
|
669 | +} |
|
670 | +?> |
|
668 | 671 | <span class="give-label"><?php echo $form_data_tab['label']; ?></span> |
669 | 672 | </a> |
670 | 673 | <?php if ( $this->has_sub_tab( $form_data_tab ) ) : ?> |
@@ -674,9 +677,12 @@ discard block |
||
674 | 677 | <a href="#<?php echo $sub_tab['id']; ?>" data-tab-id="<?php echo $sub_tab['id']; ?>"> |
675 | 678 | <?php if ( ! empty( $sub_tab['icon-html'] ) ) : ?> |
676 | 679 | <?php echo $sub_tab['icon-html']; ?> |
677 | - <?php else : ?> |
|
680 | + <?php else { |
|
681 | + : ?> |
|
678 | 682 | <span class="give-icon give-icon-default"></span> |
679 | - <?php endif; ?> |
|
683 | + <?php endif; |
|
684 | +} |
|
685 | +?> |
|
680 | 686 | <span class="give-label"><?php echo $sub_tab['label']; ?></span> |
681 | 687 | </a> |
682 | 688 | </li> |
@@ -703,11 +709,14 @@ discard block |
||
703 | 709 | </div> |
704 | 710 | |
705 | 711 | <?php do_action( "give_after_{$setting['id']}_settings" ); ?> |
706 | - <?php else : ?> |
|
712 | + <?php else { |
|
713 | + : ?> |
|
707 | 714 | <?php if ( $this->has_sub_tab( $setting ) ) : ?> |
708 | 715 | <?php if ( ! empty( $setting['sub-fields'] ) ) : ?> |
709 | 716 | <?php foreach ( $setting['sub-fields'] as $index => $sub_fields ) : ?> |
710 | - <div id="<?php echo $sub_fields['id']; ?>" class="panel give_options_panel give-hidden"> |
|
717 | + <div id="<?php echo $sub_fields['id']; |
|
718 | +} |
|
719 | +?>" class="panel give_options_panel give-hidden"> |
|
711 | 720 | <?php if ( ! empty( $sub_fields['fields'] ) ) : ?> |
712 | 721 | <?php foreach ( $sub_fields['fields'] as $sub_field ) : ?> |
713 | 722 | <?php give_render_field( $sub_field ); ?> |
@@ -9,7 +9,7 @@ discard block |
||
9 | 9 | * @since 1.8.13 |
10 | 10 | */ |
11 | 11 | |
12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
12 | +if ( ! defined('ABSPATH')) { |
|
13 | 13 | exit; |
14 | 14 | } |
15 | 15 | |
@@ -75,63 +75,63 @@ discard block |
||
75 | 75 | */ |
76 | 76 | public function init() { |
77 | 77 | // Bail early if screen cannot be detected. |
78 | - if ( empty( $this->screen ) ) { |
|
78 | + if (empty($this->screen)) { |
|
79 | 79 | return null; |
80 | 80 | } |
81 | 81 | |
82 | 82 | $content = array(); |
83 | 83 | |
84 | 84 | // Define content and hook into the appropriate action. |
85 | - switch ( $this->screen ) { |
|
85 | + switch ($this->screen) { |
|
86 | 86 | // Forms screen. |
87 | 87 | case 'edit-give_forms': |
88 | - $this->form = $this->post_exists( 'give_forms' ); |
|
88 | + $this->form = $this->post_exists('give_forms'); |
|
89 | 89 | |
90 | - if ( $this->form ) { |
|
90 | + if ($this->form) { |
|
91 | 91 | // Form exists. Bail out. |
92 | 92 | return false; |
93 | 93 | } else { |
94 | 94 | // No forms exist. |
95 | - $content = $this->get_content( 'no_forms' ); |
|
95 | + $content = $this->get_content('no_forms'); |
|
96 | 96 | } |
97 | 97 | |
98 | - add_action( 'manage_posts_extra_tablenav', array( $this, 'render' ) ); |
|
98 | + add_action('manage_posts_extra_tablenav', array($this, 'render')); |
|
99 | 99 | break; |
100 | 100 | // Donations screen. |
101 | 101 | case 'give_forms_page_give-payment-history': |
102 | - $this->form = $this->post_exists( 'give_forms' ); |
|
103 | - $this->donation = $this->post_exists( 'give_payment' ); |
|
102 | + $this->form = $this->post_exists('give_forms'); |
|
103 | + $this->donation = $this->post_exists('give_payment'); |
|
104 | 104 | |
105 | - if ( $this->donation ) { |
|
105 | + if ($this->donation) { |
|
106 | 106 | // Donation exists. Bail out. |
107 | 107 | return false; |
108 | - } elseif ( ! $this->form ) { |
|
108 | + } elseif ( ! $this->form) { |
|
109 | 109 | // No forms and no donations exist. |
110 | - $content = $this->get_content( 'no_donations_or_forms' ); |
|
110 | + $content = $this->get_content('no_donations_or_forms'); |
|
111 | 111 | } else { |
112 | 112 | // No donations exist but a form does exist. |
113 | - $content = $this->get_content( 'no_donations' ); |
|
113 | + $content = $this->get_content('no_donations'); |
|
114 | 114 | } |
115 | 115 | |
116 | - add_action( 'give_payments_page_bottom', array( $this, 'render' ) ); |
|
116 | + add_action('give_payments_page_bottom', array($this, 'render')); |
|
117 | 117 | break; |
118 | 118 | // Donors screen. |
119 | 119 | case 'give_forms_page_give-donors': |
120 | - $this->form = $this->post_exists( 'give_forms' ); |
|
120 | + $this->form = $this->post_exists('give_forms'); |
|
121 | 121 | $this->donor = $this->donor_exists(); |
122 | 122 | |
123 | - if ( $this->donor ) { |
|
123 | + if ($this->donor) { |
|
124 | 124 | // Donor exists. Bail out. |
125 | 125 | return false; |
126 | - } elseif ( ! $this->form ) { |
|
126 | + } elseif ( ! $this->form) { |
|
127 | 127 | // No forms and no donors exist. |
128 | - $content = $this->get_content( 'no_donors_or_forms' ); |
|
128 | + $content = $this->get_content('no_donors_or_forms'); |
|
129 | 129 | } else { |
130 | 130 | // No donors exist but a form does exist. |
131 | - $content = $this->get_content( 'no_donors' ); |
|
131 | + $content = $this->get_content('no_donors'); |
|
132 | 132 | } |
133 | 133 | |
134 | - add_action( 'give_donors_table_bottom', array( $this, 'render' ) ); |
|
134 | + add_action('give_donors_table_bottom', array($this, 'render')); |
|
135 | 135 | break; |
136 | 136 | default: |
137 | 137 | return null; |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | $this->content = $content; |
141 | 141 | |
142 | 142 | // Hide non-essential UI elements. |
143 | - add_action( 'admin_head', array( $this, 'hide_ui' ) ); |
|
143 | + add_action('admin_head', array($this, 'hide_ui')); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,9 +150,9 @@ discard block |
||
150 | 150 | * |
151 | 151 | * @param string $which The location of the list table hook: 'top' or 'bottom'. |
152 | 152 | */ |
153 | - public function render( $which = 'bottom') { |
|
153 | + public function render($which = 'bottom') { |
|
154 | 154 | // Bail out to prevent content from rendering twice. |
155 | - if ( 'top' === $which ) { |
|
155 | + if ('top' === $which) { |
|
156 | 156 | return null; |
157 | 157 | } |
158 | 158 | |
@@ -177,9 +177,9 @@ discard block |
||
177 | 177 | * |
178 | 178 | * @param string $screen The current screen ID. |
179 | 179 | */ |
180 | - $content = apply_filters( 'give_blank_slate_content', $this->content, $screen ); |
|
180 | + $content = apply_filters('give_blank_slate_content', $this->content, $screen); |
|
181 | 181 | |
182 | - $template_path = GIVE_PLUGIN_DIR . 'includes/admin/views/blank-slate.php'; |
|
182 | + $template_path = GIVE_PLUGIN_DIR.'includes/admin/views/blank-slate.php'; |
|
183 | 183 | |
184 | 184 | include $template_path; |
185 | 185 | } |
@@ -201,17 +201,17 @@ discard block |
||
201 | 201 | * @param string $post_type Post type used in the query. |
202 | 202 | * @return bool True if post exists, otherwise false. |
203 | 203 | */ |
204 | - private function post_exists( $post_type ) { |
|
204 | + private function post_exists($post_type) { |
|
205 | 205 | // Attempt to get a single post of the post type. |
206 | - $query = new WP_Query( array( |
|
206 | + $query = new WP_Query(array( |
|
207 | 207 | 'post_type' => $post_type, |
208 | 208 | 'posts_per_page' => 1, |
209 | 209 | 'no_found_rows' => false, |
210 | 210 | 'update_post_meta_cache' => false, |
211 | 211 | 'update_post_term_cache' => false, |
212 | 212 | 'fields' => 'ids', |
213 | - 'post_status' => array( 'any', 'trash' ), |
|
214 | - ) ); |
|
213 | + 'post_status' => array('any', 'trash'), |
|
214 | + )); |
|
215 | 215 | |
216 | 216 | return $query->have_posts(); |
217 | 217 | } |
@@ -224,9 +224,9 @@ discard block |
||
224 | 224 | * @return bool True if donor exists, otherwise false. |
225 | 225 | */ |
226 | 226 | private function donor_exists() { |
227 | - $donors = Give()->donors->get_donors( array( 'number' => 1 ) ); |
|
227 | + $donors = Give()->donors->get_donors(array('number' => 1)); |
|
228 | 228 | |
229 | - return ! empty( $donors ); |
|
229 | + return ! empty($donors); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | /** |
@@ -237,17 +237,17 @@ discard block |
||
237 | 237 | * @param string $context The key used to determine which content is returned. |
238 | 238 | * @return array Blank slate content. |
239 | 239 | */ |
240 | - private function get_content( $context ) { |
|
240 | + private function get_content($context) { |
|
241 | 241 | // Define default content. |
242 | 242 | $defaults = array( |
243 | - 'image_url' => GIVE_PLUGIN_URL . 'assets/images/svg/give-icon-full-circle.svg', |
|
244 | - 'image_alt' => __( 'Give Icon', 'give' ), |
|
245 | - 'heading' => __( 'No donation forms found.', 'give' ), |
|
246 | - 'message' => __( 'The first step towards accepting online donations is to create a form.', 'give' ), |
|
247 | - 'cta_text' => __( 'Create Donation Form', 'give' ), |
|
248 | - 'cta_link' => admin_url( 'post-new.php?post_type=give_forms' ), |
|
243 | + 'image_url' => GIVE_PLUGIN_URL.'assets/images/svg/give-icon-full-circle.svg', |
|
244 | + 'image_alt' => __('Give Icon', 'give'), |
|
245 | + 'heading' => __('No donation forms found.', 'give'), |
|
246 | + 'message' => __('The first step towards accepting online donations is to create a form.', 'give'), |
|
247 | + 'cta_text' => __('Create Donation Form', 'give'), |
|
248 | + 'cta_link' => admin_url('post-new.php?post_type=give_forms'), |
|
249 | 249 | 'help' => sprintf( |
250 | - __( 'Need help? Get started with %sGive 101%s.', 'wbpr' ), |
|
250 | + __('Need help? Get started with %sGive 101%s.', 'wbpr'), |
|
251 | 251 | '<a href="http://docs.givewp.com/give101/" target="_blank">', |
252 | 252 | '</a>' |
253 | 253 | ), |
@@ -256,40 +256,40 @@ discard block |
||
256 | 256 | // Define contextual content. |
257 | 257 | $content = array( |
258 | 258 | 'no_donations_or_forms' => array( |
259 | - 'heading' => __( 'No donations found.', 'give' ), |
|
260 | - 'message' => __( 'Your donation history will appear here, but first, you need a donation form!', 'give' ), |
|
259 | + 'heading' => __('No donations found.', 'give'), |
|
260 | + 'message' => __('Your donation history will appear here, but first, you need a donation form!', 'give'), |
|
261 | 261 | ), |
262 | 262 | 'no_donations' => array( |
263 | - 'heading' => __( 'No donations found.', 'give' ), |
|
264 | - 'message' => __( 'When your first donation arrives, a record of the donation will appear here.', 'give' ), |
|
265 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
266 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
263 | + 'heading' => __('No donations found.', 'give'), |
|
264 | + 'message' => __('When your first donation arrives, a record of the donation will appear here.', 'give'), |
|
265 | + 'cta_text' => __('View All Forms', 'give'), |
|
266 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
267 | 267 | 'help' => sprintf( |
268 | - __( 'Need help? Learn more about %sDonations%s.', 'wbpr' ), |
|
268 | + __('Need help? Learn more about %sDonations%s.', 'wbpr'), |
|
269 | 269 | '<a href="http://docs.givewp.com/core-donations/">', |
270 | 270 | '</a>' |
271 | 271 | ), |
272 | 272 | ), |
273 | 273 | 'no_donors_or_forms' => array( |
274 | - 'heading' => __( 'No donors found.', 'give' ), |
|
275 | - 'message' => __( 'Your donor history will appear here, but first, you need a donation form!', 'give' ), |
|
274 | + 'heading' => __('No donors found.', 'give'), |
|
275 | + 'message' => __('Your donor history will appear here, but first, you need a donation form!', 'give'), |
|
276 | 276 | ), |
277 | 277 | 'no_donors' => array( |
278 | - 'heading' => __( 'No donors found.', 'give' ), |
|
279 | - 'message' => __( 'When your first donation arrives, the donor will appear here.', 'give' ), |
|
280 | - 'cta_text' => __( 'View All Forms', 'give' ), |
|
281 | - 'cta_link' => admin_url( 'edit.php?post_type=give_forms' ), |
|
278 | + 'heading' => __('No donors found.', 'give'), |
|
279 | + 'message' => __('When your first donation arrives, the donor will appear here.', 'give'), |
|
280 | + 'cta_text' => __('View All Forms', 'give'), |
|
281 | + 'cta_link' => admin_url('edit.php?post_type=give_forms'), |
|
282 | 282 | 'help' => sprintf( |
283 | - __( 'Need help? Learn more about %sDonors%s.', 'wbpr' ), |
|
283 | + __('Need help? Learn more about %sDonors%s.', 'wbpr'), |
|
284 | 284 | '<a href="http://docs.givewp.com/core-donors/">', |
285 | 285 | '</a>' |
286 | 286 | ), |
287 | 287 | ), |
288 | 288 | ); |
289 | 289 | |
290 | - if ( isset( $content[ $context ] ) ) { |
|
290 | + if (isset($content[$context])) { |
|
291 | 291 | // Merge contextual content with defaults. |
292 | - return wp_parse_args( $content[ $context ], $defaults ); |
|
292 | + return wp_parse_args($content[$context], $defaults); |
|
293 | 293 | } else { |
294 | 294 | // Return defaults if context is undefined. |
295 | 295 | return $defaults; |
@@ -95,5 +95,8 @@ |
||
95 | 95 | <?php endif; ?> |
96 | 96 | <?php echo $form_close_tag; ?> |
97 | 97 | </div> |
98 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
98 | +<?php else { |
|
99 | + : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; |
|
100 | +} |
|
101 | +?> |
|
99 | 102 | <?php endif; ?> |
100 | 103 | \ No newline at end of file |
@@ -2,13 +2,13 @@ discard block |
||
2 | 2 | /** |
3 | 3 | * Admin View: Settings |
4 | 4 | */ |
5 | -if ( ! defined( 'ABSPATH' ) ) { |
|
5 | +if ( ! defined('ABSPATH')) { |
|
6 | 6 | exit; |
7 | 7 | } |
8 | 8 | |
9 | 9 | |
10 | 10 | // Bailout: Do not output anything if setting tab is not defined. |
11 | -if( ! empty( $tabs ) && array_key_exists( give_get_current_setting_tab(), $tabs ) ) : |
|
11 | +if ( ! empty($tabs) && array_key_exists(give_get_current_setting_tab(), $tabs)) : |
|
12 | 12 | /** |
13 | 13 | * Filter the form action. |
14 | 14 | * |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * |
19 | 19 | * @since 1.8 |
20 | 20 | */ |
21 | - $form_method = apply_filters( self::$setting_filter_prefix . '_form_method_tab_' . $current_tab, 'post' ); |
|
21 | + $form_method = apply_filters(self::$setting_filter_prefix.'_form_method_tab_'.$current_tab, 'post'); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * Filter the main form tab. |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.8 |
32 | 32 | */ |
33 | - $form_open_tag = apply_filters( self::$setting_filter_prefix . '_open_form', '<form method="' . $form_method . '" id="give-mainform" action="" enctype="multipart/form-data">' ); |
|
34 | - $form_close_tag = apply_filters( self::$setting_filter_prefix . '_close_form', '</form>' ); |
|
33 | + $form_open_tag = apply_filters(self::$setting_filter_prefix.'_open_form', '<form method="'.$form_method.'" id="give-mainform" action="" enctype="multipart/form-data">'); |
|
34 | + $form_close_tag = apply_filters(self::$setting_filter_prefix.'_close_form', '</form>'); |
|
35 | 35 | ?> |
36 | - <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix . '-setting-page'; ?>"> |
|
36 | + <div class="wrap give-settings-page <?php echo self::$setting_filter_prefix.'-setting-page'; ?>"> |
|
37 | 37 | <?php echo $form_open_tag; ?> |
38 | - <h1 class="wp-heading-inline"><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1> |
|
38 | + <h1 class="wp-heading-inline"><?php echo esc_html($tabs[$current_tab]); ?></h1> |
|
39 | 39 | <?php |
40 | 40 | // Show messages. |
41 | 41 | self::show_messages(); |
@@ -45,8 +45,8 @@ discard block |
||
45 | 45 | |
46 | 46 | <div class="nav-tab-wrapper give-nav-tab-wrapper"> |
47 | 47 | <?php |
48 | - foreach ( $tabs as $name => $label ) { |
|
49 | - echo '<a href="' . admin_url( "edit.php?post_type=give_forms&page=" . self::$setting_filter_prefix . "&tab={$name}" ) . '" class="nav-tab ' . ( $current_tab == $name ? 'nav-tab-active' : '' ) . '">' . $label . '</a>'; |
|
48 | + foreach ($tabs as $name => $label) { |
|
49 | + echo '<a href="'.admin_url("edit.php?post_type=give_forms&page=".self::$setting_filter_prefix."&tab={$name}").'" class="nav-tab '.($current_tab == $name ? 'nav-tab-active' : '').'">'.$label.'</a>'; |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -58,11 +58,11 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @since 1.8 |
60 | 60 | */ |
61 | - do_action( self::$setting_filter_prefix . '_tabs' ); |
|
61 | + do_action(self::$setting_filter_prefix.'_tabs'); |
|
62 | 62 | ?> |
63 | 63 | </div> |
64 | 64 | <div class="give-sub-nav-tab-wrapper"> |
65 | - <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e( 'View remaining setting tabs', 'give' ); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
65 | + <a href="#" id="give-show-sub-nav" class="nav-tab give-not-tab" title="<?php _e('View remaining setting tabs', 'give'); ?>"><span class="dashicons dashicons-arrow-down-alt2"></span></span></a> |
|
66 | 66 | <nav class="give-sub-nav-tab give-hidden"></nav> |
67 | 67 | </div> |
68 | 68 | <?php |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @since 1.8 |
78 | 78 | */ |
79 | - do_action( self::$setting_filter_prefix . "_sections_{$current_tab}_page" ); |
|
79 | + do_action(self::$setting_filter_prefix."_sections_{$current_tab}_page"); |
|
80 | 80 | |
81 | 81 | /** |
82 | 82 | * Trigger Action. |
@@ -87,15 +87,15 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @since 1.8 |
89 | 89 | */ |
90 | - do_action( self::$setting_filter_prefix . "_settings_{$current_tab}_page" ); |
|
90 | + do_action(self::$setting_filter_prefix."_settings_{$current_tab}_page"); |
|
91 | 91 | |
92 | - if ( empty( $GLOBALS['give_hide_save_button'] ) ) : ?> |
|
92 | + if (empty($GLOBALS['give_hide_save_button'])) : ?> |
|
93 | 93 | <div class="give-submit-wrap"> |
94 | - <?php wp_nonce_field( 'give-save-settings', '_give-save-settings' ); ?> |
|
95 | - <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e( 'Save changes', 'give' ); ?>" /> |
|
94 | + <?php wp_nonce_field('give-save-settings', '_give-save-settings'); ?> |
|
95 | + <input name="save" class="button-primary give-save-button" type="submit" value="<?php esc_attr_e('Save changes', 'give'); ?>" /> |
|
96 | 96 | </div> |
97 | 97 | <?php endif; ?> |
98 | 98 | <?php echo $form_close_tag; ?> |
99 | 99 | </div> |
100 | -<?php else : echo '<div class="error"><p>' . __( 'Oops, this settings page does not exist.', 'give' ) . '</p></div>'; ?> |
|
100 | +<?php else : echo '<div class="error"><p>'.__('Oops, this settings page does not exist.', 'give').'</p></div>'; ?> |
|
101 | 101 | <?php endif; ?> |
102 | 102 | \ No newline at end of file |