@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | * @access public |
| 891 | 891 | * |
| 892 | 892 | * @param string $meta_key Metadata name. Default is empty. |
| 893 | - * @param mixed $meta_value Metadata value. |
|
| 893 | + * @param string $meta_value Metadata value. |
|
| 894 | 894 | * @param bool $unique Optional. Whether the same key should not be added. Default is false. |
| 895 | 895 | * |
| 896 | 896 | * @return bool False for failure. True for success. |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | * @access public |
| 923 | 923 | * |
| 924 | 924 | * @param string $meta_key Metadata name. Default is empty. |
| 925 | - * @param mixed $meta_value Optional. Metadata value. Default is empty. |
|
| 925 | + * @param string $meta_value Optional. Metadata value. Default is empty. |
|
| 926 | 926 | * |
| 927 | 927 | * @return bool False for failure. True for success. |
| 928 | 928 | */ |
@@ -714,12 +714,12 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | /** |
| 716 | 716 | * Decrease/Increase a customer's lifetime value. |
| 717 | - * |
|
| 718 | - * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 719 | - * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 720 | - * |
|
| 717 | + * |
|
| 718 | + * This function will update donation stat on basis of current amount and new amount donation difference. |
|
| 719 | + * Difference value can positive or negative. Negative value will decrease user donation stat while positive value increase donation stat. |
|
| 720 | + * |
|
| 721 | 721 | * @since 1.0 |
| 722 | - * @access public |
|
| 722 | + * @access public |
|
| 723 | 723 | * |
| 724 | 724 | * @param float $curr_amount Current Donation amount. |
| 725 | 725 | * @param float $new_amount New (changed) Donation amount. |
@@ -727,35 +727,35 @@ discard block |
||
| 727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 728 | 728 | */ |
| 729 | 729 | public function update_donation_value( $curr_amount, $new_amount ) { |
| 730 | - /** |
|
| 731 | - * Payment total difference value can be: |
|
| 732 | - * zero (in case amount not change) |
|
| 733 | - * or -ve (in case amount decrease) |
|
| 734 | - * or +ve (in case amount increase) |
|
| 735 | - */ |
|
| 736 | - $payment_total_diff = $new_amount - $curr_amount; |
|
| 737 | - |
|
| 738 | - // We do not need to update donation stat if donation did not change. |
|
| 739 | - if( ! $payment_total_diff ) { |
|
| 740 | - return false; |
|
| 741 | - } |
|
| 742 | - |
|
| 743 | - |
|
| 744 | - if( $payment_total_diff > 0 ) { |
|
| 745 | - $this->increase_value( $payment_total_diff ); |
|
| 746 | - } else { |
|
| 747 | - // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 748 | - $this->decrease_value( -$payment_total_diff ); |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - return $this->purchase_value; |
|
| 730 | + /** |
|
| 731 | + * Payment total difference value can be: |
|
| 732 | + * zero (in case amount not change) |
|
| 733 | + * or -ve (in case amount decrease) |
|
| 734 | + * or +ve (in case amount increase) |
|
| 735 | + */ |
|
| 736 | + $payment_total_diff = $new_amount - $curr_amount; |
|
| 737 | + |
|
| 738 | + // We do not need to update donation stat if donation did not change. |
|
| 739 | + if( ! $payment_total_diff ) { |
|
| 740 | + return false; |
|
| 741 | + } |
|
| 742 | + |
|
| 743 | + |
|
| 744 | + if( $payment_total_diff > 0 ) { |
|
| 745 | + $this->increase_value( $payment_total_diff ); |
|
| 746 | + } else { |
|
| 747 | + // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
|
| 748 | + $this->decrease_value( -$payment_total_diff ); |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + return $this->purchase_value; |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
| 755 | 755 | * Get the parsed notes for a customer as an array. |
| 756 | 756 | * |
| 757 | 757 | * @since 1.0 |
| 758 | - * @access public |
|
| 758 | + * @access public |
|
| 759 | 759 | * |
| 760 | 760 | * @param int $length The number of notes to get. |
| 761 | 761 | * @param int $paged What note to start at. |
@@ -780,7 +780,7 @@ discard block |
||
| 780 | 780 | * Get the total number of notes we have after parsing. |
| 781 | 781 | * |
| 782 | 782 | * @since 1.0 |
| 783 | - * @access public |
|
| 783 | + * @access public |
|
| 784 | 784 | * |
| 785 | 785 | * @return int The number of notes for the customer. |
| 786 | 786 | */ |
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | * Add a note for the customer. |
| 798 | 798 | * |
| 799 | 799 | * @since 1.0 |
| 800 | - * @access public |
|
| 800 | + * @access public |
|
| 801 | 801 | * |
| 802 | 802 | * @param string $note The note to add. Default is empty. |
| 803 | 803 | * |
@@ -856,7 +856,7 @@ discard block |
||
| 856 | 856 | * Get the notes column for the customer |
| 857 | 857 | * |
| 858 | 858 | * @since 1.0 |
| 859 | - * @access private |
|
| 859 | + * @access private |
|
| 860 | 860 | * |
| 861 | 861 | * @return string The Notes for the customer, non-parsed. |
| 862 | 862 | */ |
@@ -934,7 +934,7 @@ discard block |
||
| 934 | 934 | * Sanitize the data for update/create |
| 935 | 935 | * |
| 936 | 936 | * @since 1.0 |
| 937 | - * @access private |
|
| 937 | + * @access private |
|
| 938 | 938 | * |
| 939 | 939 | * @param array $data The data to sanitize. |
| 940 | 940 | * |
@@ -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 | |
@@ -144,29 +144,29 @@ discard block |
||
| 144 | 144 | * @param bool $_id_or_email |
| 145 | 145 | * @param bool $by_user_id |
| 146 | 146 | */ |
| 147 | - public function __construct( $_id_or_email = false, $by_user_id = false ) { |
|
| 147 | + public function __construct($_id_or_email = false, $by_user_id = false) { |
|
| 148 | 148 | |
| 149 | 149 | $this->db = new Give_DB_Customers; |
| 150 | 150 | |
| 151 | - if ( false === $_id_or_email || ( is_numeric( $_id_or_email ) && (int) $_id_or_email !== absint( $_id_or_email ) ) ) { |
|
| 151 | + if (false === $_id_or_email || (is_numeric($_id_or_email) && (int) $_id_or_email !== absint($_id_or_email))) { |
|
| 152 | 152 | return false; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | - $by_user_id = is_bool( $by_user_id ) ? $by_user_id : false; |
|
| 155 | + $by_user_id = is_bool($by_user_id) ? $by_user_id : false; |
|
| 156 | 156 | |
| 157 | - if ( is_numeric( $_id_or_email ) ) { |
|
| 157 | + if (is_numeric($_id_or_email)) { |
|
| 158 | 158 | $field = $by_user_id ? 'user_id' : 'id'; |
| 159 | 159 | } else { |
| 160 | 160 | $field = 'email'; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - $customer = $this->db->get_customer_by( $field, $_id_or_email ); |
|
| 163 | + $customer = $this->db->get_customer_by($field, $_id_or_email); |
|
| 164 | 164 | |
| 165 | - if ( empty( $customer ) || ! is_object( $customer ) ) { |
|
| 165 | + if (empty($customer) || ! is_object($customer)) { |
|
| 166 | 166 | return false; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - $this->setup_customer( $customer ); |
|
| 169 | + $this->setup_customer($customer); |
|
| 170 | 170 | |
| 171 | 171 | } |
| 172 | 172 | |
@@ -182,15 +182,15 @@ discard block |
||
| 182 | 182 | * |
| 183 | 183 | * @return bool If the setup was successful or not. |
| 184 | 184 | */ |
| 185 | - private function setup_customer( $customer ) { |
|
| 185 | + private function setup_customer($customer) { |
|
| 186 | 186 | |
| 187 | - if ( ! is_object( $customer ) ) { |
|
| 187 | + if ( ! is_object($customer)) { |
|
| 188 | 188 | return false; |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | - foreach ( $customer as $key => $value ) { |
|
| 191 | + foreach ($customer as $key => $value) { |
|
| 192 | 192 | |
| 193 | - switch ( $key ) { |
|
| 193 | + switch ($key) { |
|
| 194 | 194 | |
| 195 | 195 | case 'notes': |
| 196 | 196 | $this->$key = $this->get_notes(); |
@@ -205,11 +205,11 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | // Get donor's all email including primary email. |
| 208 | - $this->emails = (array) $this->get_meta( 'additional_email', false ); |
|
| 209 | - $this->emails = array( 'primary' => $this->email ) + $this->emails; |
|
| 208 | + $this->emails = (array) $this->get_meta('additional_email', false); |
|
| 209 | + $this->emails = array('primary' => $this->email) + $this->emails; |
|
| 210 | 210 | |
| 211 | 211 | // Customer ID and email are the only things that are necessary, make sure they exist. |
| 212 | - if ( ! empty( $this->id ) && ! empty( $this->email ) ) { |
|
| 212 | + if ( ! empty($this->id) && ! empty($this->email)) { |
|
| 213 | 213 | return true; |
| 214 | 214 | } |
| 215 | 215 | |
@@ -223,16 +223,16 @@ discard block |
||
| 223 | 223 | * @since 1.0 |
| 224 | 224 | * @access public |
| 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-customer-invalid-property', sprintf( esc_html__( 'Can\'t get property %s.', 'give' ), $key ) ); |
|
| 235 | + return new WP_Error('give-customer-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, customer 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 Customer attributes. |
| 278 | 278 | */ |
| 279 | - do_action( 'give_customer_pre_create', $args ); |
|
| 279 | + do_action('give_customer_pre_create', $args); |
|
| 280 | 280 | |
| 281 | 281 | $created = false; |
| 282 | 282 | |
| 283 | 283 | // The DB class 'add' implies an update if the customer 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 customer, reset the class vars with the new data |
| 287 | - $customer = $this->db->get_customer_by( 'email', $args['email'] ); |
|
| 287 | + $customer = $this->db->get_customer_by('email', $args['email']); |
|
| 288 | 288 | |
| 289 | 289 | // Setup the customer data with the values from DB |
| 290 | - $this->setup_customer( $customer ); |
|
| 290 | + $this->setup_customer($customer); |
|
| 291 | 291 | |
| 292 | 292 | $created = $this->id; |
| 293 | 293 | } |
@@ -301,7 +301,7 @@ discard block |
||
| 301 | 301 | * customer ID if user is found or valid creation. |
| 302 | 302 | * @param array $args Customer attributes. |
| 303 | 303 | */ |
| 304 | - do_action( 'give_customer_post_create', $created, $args ); |
|
| 304 | + do_action('give_customer_post_create', $created, $args); |
|
| 305 | 305 | |
| 306 | 306 | return $created; |
| 307 | 307 | |
@@ -317,13 +317,13 @@ discard block |
||
| 317 | 317 | * |
| 318 | 318 | * @return bool If the update was successful or not. |
| 319 | 319 | */ |
| 320 | - public function update( $data = array() ) { |
|
| 320 | + public function update($data = array()) { |
|
| 321 | 321 | |
| 322 | - if ( empty( $data ) ) { |
|
| 322 | + if (empty($data)) { |
|
| 323 | 323 | return false; |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | - $data = $this->sanitize_columns( $data ); |
|
| 326 | + $data = $this->sanitize_columns($data); |
|
| 327 | 327 | |
| 328 | 328 | /** |
| 329 | 329 | * Fires before updating customers. |
@@ -333,14 +333,14 @@ discard block |
||
| 333 | 333 | * @param int $customer_id Customer id. |
| 334 | 334 | * @param array $data Customer attributes. |
| 335 | 335 | */ |
| 336 | - do_action( 'give_customer_pre_update', $this->id, $data ); |
|
| 336 | + do_action('give_customer_pre_update', $this->id, $data); |
|
| 337 | 337 | |
| 338 | 338 | $updated = false; |
| 339 | 339 | |
| 340 | - if ( $this->db->update( $this->id, $data ) ) { |
|
| 340 | + if ($this->db->update($this->id, $data)) { |
|
| 341 | 341 | |
| 342 | - $customer = $this->db->get_customer_by( 'id', $this->id ); |
|
| 343 | - $this->setup_customer( $customer ); |
|
| 342 | + $customer = $this->db->get_customer_by('id', $this->id); |
|
| 343 | + $this->setup_customer($customer); |
|
| 344 | 344 | |
| 345 | 345 | $updated = true; |
| 346 | 346 | } |
@@ -354,7 +354,7 @@ discard block |
||
| 354 | 354 | * @param int $customer_id Customer id. |
| 355 | 355 | * @param array $data Customer attributes. |
| 356 | 356 | */ |
| 357 | - do_action( 'give_customer_post_update', $updated, $this->id, $data ); |
|
| 357 | + do_action('give_customer_post_update', $updated, $this->id, $data); |
|
| 358 | 358 | |
| 359 | 359 | return $updated; |
| 360 | 360 | } |
@@ -372,27 +372,27 @@ discard block |
||
| 372 | 372 | * |
| 373 | 373 | * @return bool If the attachment was successfuly. |
| 374 | 374 | */ |
| 375 | - public function attach_payment( $payment_id = 0, $update_stats = true ) { |
|
| 375 | + public function attach_payment($payment_id = 0, $update_stats = true) { |
|
| 376 | 376 | |
| 377 | - if ( empty( $payment_id ) ) { |
|
| 377 | + if (empty($payment_id)) { |
|
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - if ( empty( $this->payment_ids ) ) { |
|
| 381 | + if (empty($this->payment_ids)) { |
|
| 382 | 382 | |
| 383 | 383 | $new_payment_ids = $payment_id; |
| 384 | 384 | |
| 385 | 385 | } else { |
| 386 | 386 | |
| 387 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 387 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 388 | 388 | |
| 389 | - if ( in_array( $payment_id, $payment_ids ) ) { |
|
| 389 | + if (in_array($payment_id, $payment_ids)) { |
|
| 390 | 390 | $update_stats = false; |
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | $payment_ids[] = $payment_id; |
| 394 | 394 | |
| 395 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 395 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 396 | 396 | |
| 397 | 397 | } |
| 398 | 398 | |
@@ -404,20 +404,20 @@ discard block |
||
| 404 | 404 | * @param int $payment_id Payment id. |
| 405 | 405 | * @param int $customer_id Customer id. |
| 406 | 406 | */ |
| 407 | - do_action( 'give_customer_pre_attach_payment', $payment_id, $this->id ); |
|
| 407 | + do_action('give_customer_pre_attach_payment', $payment_id, $this->id); |
|
| 408 | 408 | |
| 409 | - $payment_added = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 409 | + $payment_added = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 410 | 410 | |
| 411 | - if ( $payment_added ) { |
|
| 411 | + if ($payment_added) { |
|
| 412 | 412 | |
| 413 | 413 | $this->payment_ids = $new_payment_ids; |
| 414 | 414 | |
| 415 | 415 | // We added this payment successfully, increment the stats |
| 416 | - if ( $update_stats ) { |
|
| 417 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 416 | + if ($update_stats) { |
|
| 417 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 418 | 418 | |
| 419 | - if ( ! empty( $payment_amount ) ) { |
|
| 420 | - $this->increase_value( $payment_amount ); |
|
| 419 | + if ( ! empty($payment_amount)) { |
|
| 420 | + $this->increase_value($payment_amount); |
|
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | $this->increase_purchase_count(); |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | * @param int $payment_id Payment id. |
| 435 | 435 | * @param int $customer_id Customer id. |
| 436 | 436 | */ |
| 437 | - do_action( 'give_customer_post_attach_payment', $payment_added, $payment_id, $this->id ); |
|
| 437 | + do_action('give_customer_post_attach_payment', $payment_added, $payment_id, $this->id); |
|
| 438 | 438 | |
| 439 | 439 | return $payment_added; |
| 440 | 440 | } |
@@ -452,33 +452,33 @@ discard block |
||
| 452 | 452 | * |
| 453 | 453 | * @return boolean If the removal was successful. |
| 454 | 454 | */ |
| 455 | - public function remove_payment( $payment_id = 0, $update_stats = true ) { |
|
| 455 | + public function remove_payment($payment_id = 0, $update_stats = true) { |
|
| 456 | 456 | |
| 457 | - if ( empty( $payment_id ) ) { |
|
| 457 | + if (empty($payment_id)) { |
|
| 458 | 458 | return false; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | - $payment = new Give_Payment( $payment_id ); |
|
| 461 | + $payment = new Give_Payment($payment_id); |
|
| 462 | 462 | |
| 463 | - if ( 'publish' !== $payment->status && 'revoked' !== $payment->status ) { |
|
| 463 | + if ('publish' !== $payment->status && 'revoked' !== $payment->status) { |
|
| 464 | 464 | $update_stats = false; |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | $new_payment_ids = ''; |
| 468 | 468 | |
| 469 | - if ( ! empty( $this->payment_ids ) ) { |
|
| 469 | + if ( ! empty($this->payment_ids)) { |
|
| 470 | 470 | |
| 471 | - $payment_ids = array_map( 'absint', explode( ',', $this->payment_ids ) ); |
|
| 471 | + $payment_ids = array_map('absint', explode(',', $this->payment_ids)); |
|
| 472 | 472 | |
| 473 | - $pos = array_search( $payment_id, $payment_ids ); |
|
| 474 | - if ( false === $pos ) { |
|
| 473 | + $pos = array_search($payment_id, $payment_ids); |
|
| 474 | + if (false === $pos) { |
|
| 475 | 475 | return false; |
| 476 | 476 | } |
| 477 | 477 | |
| 478 | - unset( $payment_ids[ $pos ] ); |
|
| 479 | - $payment_ids = array_filter( $payment_ids ); |
|
| 478 | + unset($payment_ids[$pos]); |
|
| 479 | + $payment_ids = array_filter($payment_ids); |
|
| 480 | 480 | |
| 481 | - $new_payment_ids = implode( ',', array_unique( array_values( $payment_ids ) ) ); |
|
| 481 | + $new_payment_ids = implode(',', array_unique(array_values($payment_ids))); |
|
| 482 | 482 | |
| 483 | 483 | } |
| 484 | 484 | |
@@ -490,20 +490,20 @@ discard block |
||
| 490 | 490 | * @param int $payment_id Payment id. |
| 491 | 491 | * @param int $customer_id Customer id. |
| 492 | 492 | */ |
| 493 | - do_action( 'give_customer_pre_remove_payment', $payment_id, $this->id ); |
|
| 493 | + do_action('give_customer_pre_remove_payment', $payment_id, $this->id); |
|
| 494 | 494 | |
| 495 | - $payment_removed = $this->update( array( 'payment_ids' => $new_payment_ids ) ); |
|
| 495 | + $payment_removed = $this->update(array('payment_ids' => $new_payment_ids)); |
|
| 496 | 496 | |
| 497 | - if ( $payment_removed ) { |
|
| 497 | + if ($payment_removed) { |
|
| 498 | 498 | |
| 499 | 499 | $this->payment_ids = $new_payment_ids; |
| 500 | 500 | |
| 501 | - if ( $update_stats ) { |
|
| 501 | + if ($update_stats) { |
|
| 502 | 502 | // We removed this payment successfully, decrement the stats |
| 503 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 503 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 504 | 504 | |
| 505 | - if ( ! empty( $payment_amount ) ) { |
|
| 506 | - $this->decrease_value( $payment_amount ); |
|
| 505 | + if ( ! empty($payment_amount)) { |
|
| 506 | + $this->decrease_value($payment_amount); |
|
| 507 | 507 | } |
| 508 | 508 | |
| 509 | 509 | $this->decrease_purchase_count(); |
@@ -520,7 +520,7 @@ discard block |
||
| 520 | 520 | * @param int $payment_id Payment id. |
| 521 | 521 | * @param int $customer_id Customer id. |
| 522 | 522 | */ |
| 523 | - do_action( 'give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id ); |
|
| 523 | + do_action('give_customer_post_remove_payment', $payment_removed, $payment_id, $this->id); |
|
| 524 | 524 | |
| 525 | 525 | return $payment_removed; |
| 526 | 526 | |
@@ -536,10 +536,10 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | * @return int The donation count. |
| 538 | 538 | */ |
| 539 | - public function increase_purchase_count( $count = 1 ) { |
|
| 539 | + public function increase_purchase_count($count = 1) { |
|
| 540 | 540 | |
| 541 | 541 | // Make sure it's numeric and not negative. |
| 542 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 542 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 543 | 543 | return false; |
| 544 | 544 | } |
| 545 | 545 | |
@@ -553,9 +553,9 @@ discard block |
||
| 553 | 553 | * @param int $count The number to increase by. |
| 554 | 554 | * @param int $customer_id Customer id. |
| 555 | 555 | */ |
| 556 | - do_action( 'give_customer_pre_increase_purchase_count', $count, $this->id ); |
|
| 556 | + do_action('give_customer_pre_increase_purchase_count', $count, $this->id); |
|
| 557 | 557 | |
| 558 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 558 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 559 | 559 | $this->purchase_count = $new_total; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @param int $count The number increased by. |
| 569 | 569 | * @param int $customer_id Customer id. |
| 570 | 570 | */ |
| 571 | - do_action( 'give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 571 | + do_action('give_customer_post_increase_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 572 | 572 | |
| 573 | 573 | return $this->purchase_count; |
| 574 | 574 | } |
@@ -583,16 +583,16 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return mixed If successful, the new count, otherwise false. |
| 585 | 585 | */ |
| 586 | - public function decrease_purchase_count( $count = 1 ) { |
|
| 586 | + public function decrease_purchase_count($count = 1) { |
|
| 587 | 587 | |
| 588 | 588 | // Make sure it's numeric and not negative |
| 589 | - if ( ! is_numeric( $count ) || $count != absint( $count ) ) { |
|
| 589 | + if ( ! is_numeric($count) || $count != absint($count)) { |
|
| 590 | 590 | return false; |
| 591 | 591 | } |
| 592 | 592 | |
| 593 | 593 | $new_total = (int) $this->purchase_count - (int) $count; |
| 594 | 594 | |
| 595 | - if ( $new_total < 0 ) { |
|
| 595 | + if ($new_total < 0) { |
|
| 596 | 596 | $new_total = 0; |
| 597 | 597 | } |
| 598 | 598 | |
@@ -604,9 +604,9 @@ discard block |
||
| 604 | 604 | * @param int $count The number to decrease by. |
| 605 | 605 | * @param int $customer_id Customer id. |
| 606 | 606 | */ |
| 607 | - do_action( 'give_customer_pre_decrease_purchase_count', $count, $this->id ); |
|
| 607 | + do_action('give_customer_pre_decrease_purchase_count', $count, $this->id); |
|
| 608 | 608 | |
| 609 | - if ( $this->update( array( 'purchase_count' => $new_total ) ) ) { |
|
| 609 | + if ($this->update(array('purchase_count' => $new_total))) { |
|
| 610 | 610 | $this->purchase_count = $new_total; |
| 611 | 611 | } |
| 612 | 612 | |
@@ -619,7 +619,7 @@ discard block |
||
| 619 | 619 | * @param int $count The number decreased by. |
| 620 | 620 | * @param int $customer_id Customer id. |
| 621 | 621 | */ |
| 622 | - do_action( 'give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id ); |
|
| 622 | + do_action('give_customer_post_decrease_purchase_count', $this->purchase_count, $count, $this->id); |
|
| 623 | 623 | |
| 624 | 624 | return $this->purchase_count; |
| 625 | 625 | } |
@@ -634,9 +634,9 @@ discard block |
||
| 634 | 634 | * |
| 635 | 635 | * @return mixed If successful, the new value, otherwise false. |
| 636 | 636 | */ |
| 637 | - public function increase_value( $value = 0.00 ) { |
|
| 637 | + public function increase_value($value = 0.00) { |
|
| 638 | 638 | |
| 639 | - $new_value = floatval( $this->purchase_value ) + $value; |
|
| 639 | + $new_value = floatval($this->purchase_value) + $value; |
|
| 640 | 640 | |
| 641 | 641 | /** |
| 642 | 642 | * Fires before increasing customer lifetime value. |
@@ -646,9 +646,9 @@ discard block |
||
| 646 | 646 | * @param float $value The value to increase by. |
| 647 | 647 | * @param int $customer_id Customer id. |
| 648 | 648 | */ |
| 649 | - do_action( 'give_customer_pre_increase_value', $value, $this->id ); |
|
| 649 | + do_action('give_customer_pre_increase_value', $value, $this->id); |
|
| 650 | 650 | |
| 651 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 651 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 652 | 652 | $this->purchase_value = $new_value; |
| 653 | 653 | } |
| 654 | 654 | |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @param float $value The value increased by. |
| 662 | 662 | * @param int $customer_id Customer id. |
| 663 | 663 | */ |
| 664 | - do_action( 'give_customer_post_increase_value', $this->purchase_value, $value, $this->id ); |
|
| 664 | + do_action('give_customer_post_increase_value', $this->purchase_value, $value, $this->id); |
|
| 665 | 665 | |
| 666 | 666 | return $this->purchase_value; |
| 667 | 667 | } |
@@ -676,11 +676,11 @@ discard block |
||
| 676 | 676 | * |
| 677 | 677 | * @return mixed If successful, the new value, otherwise false. |
| 678 | 678 | */ |
| 679 | - public function decrease_value( $value = 0.00 ) { |
|
| 679 | + public function decrease_value($value = 0.00) { |
|
| 680 | 680 | |
| 681 | - $new_value = floatval( $this->purchase_value ) - $value; |
|
| 681 | + $new_value = floatval($this->purchase_value) - $value; |
|
| 682 | 682 | |
| 683 | - if ( $new_value < 0 ) { |
|
| 683 | + if ($new_value < 0) { |
|
| 684 | 684 | $new_value = 0.00; |
| 685 | 685 | } |
| 686 | 686 | |
@@ -692,9 +692,9 @@ discard block |
||
| 692 | 692 | * @param float $value The value to decrease by. |
| 693 | 693 | * @param int $customer_id Customer id. |
| 694 | 694 | */ |
| 695 | - do_action( 'give_customer_pre_decrease_value', $value, $this->id ); |
|
| 695 | + do_action('give_customer_pre_decrease_value', $value, $this->id); |
|
| 696 | 696 | |
| 697 | - if ( $this->update( array( 'purchase_value' => $new_value ) ) ) { |
|
| 697 | + if ($this->update(array('purchase_value' => $new_value))) { |
|
| 698 | 698 | $this->purchase_value = $new_value; |
| 699 | 699 | } |
| 700 | 700 | |
@@ -707,7 +707,7 @@ discard block |
||
| 707 | 707 | * @param float $value The value decreased by. |
| 708 | 708 | * @param int $customer_id Customer id. |
| 709 | 709 | */ |
| 710 | - do_action( 'give_customer_post_decrease_value', $this->purchase_value, $value, $this->id ); |
|
| 710 | + do_action('give_customer_post_decrease_value', $this->purchase_value, $value, $this->id); |
|
| 711 | 711 | |
| 712 | 712 | return $this->purchase_value; |
| 713 | 713 | } |
@@ -726,7 +726,7 @@ discard block |
||
| 726 | 726 | * |
| 727 | 727 | * @return mixed If successful, the new donation stat value, otherwise false. |
| 728 | 728 | */ |
| 729 | - public function update_donation_value( $curr_amount, $new_amount ) { |
|
| 729 | + public function update_donation_value($curr_amount, $new_amount) { |
|
| 730 | 730 | /** |
| 731 | 731 | * Payment total difference value can be: |
| 732 | 732 | * zero (in case amount not change) |
@@ -736,13 +736,13 @@ discard block |
||
| 736 | 736 | $payment_total_diff = $new_amount - $curr_amount; |
| 737 | 737 | |
| 738 | 738 | // We do not need to update donation stat if donation did not change. |
| 739 | - if( ! $payment_total_diff ) { |
|
| 739 | + if ( ! $payment_total_diff) { |
|
| 740 | 740 | return false; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | 743 | |
| 744 | - if( $payment_total_diff > 0 ) { |
|
| 745 | - $this->increase_value( $payment_total_diff ); |
|
| 744 | + if ($payment_total_diff > 0) { |
|
| 745 | + $this->increase_value($payment_total_diff); |
|
| 746 | 746 | } else { |
| 747 | 747 | // Pass payment total difference as +ve value to decrease amount from user lifetime stat. |
| 748 | 748 | $this->decrease_value( -$payment_total_diff ); |
@@ -762,15 +762,15 @@ discard block |
||
| 762 | 762 | * |
| 763 | 763 | * @return array The notes requested. |
| 764 | 764 | */ |
| 765 | - public function get_notes( $length = 20, $paged = 1 ) { |
|
| 765 | + public function get_notes($length = 20, $paged = 1) { |
|
| 766 | 766 | |
| 767 | - $length = is_numeric( $length ) ? $length : 20; |
|
| 768 | - $offset = is_numeric( $paged ) && $paged != 1 ? ( ( absint( $paged ) - 1 ) * $length ) : 0; |
|
| 767 | + $length = is_numeric($length) ? $length : 20; |
|
| 768 | + $offset = is_numeric($paged) && $paged != 1 ? ((absint($paged) - 1) * $length) : 0; |
|
| 769 | 769 | |
| 770 | 770 | $all_notes = $this->get_raw_notes(); |
| 771 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 771 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 772 | 772 | |
| 773 | - $desired_notes = array_slice( $notes_array, $offset, $length ); |
|
| 773 | + $desired_notes = array_slice($notes_array, $offset, $length); |
|
| 774 | 774 | |
| 775 | 775 | return $desired_notes; |
| 776 | 776 | |
@@ -787,9 +787,9 @@ discard block |
||
| 787 | 787 | public function get_notes_count() { |
| 788 | 788 | |
| 789 | 789 | $all_notes = $this->get_raw_notes(); |
| 790 | - $notes_array = array_reverse( array_filter( explode( "\n\n", $all_notes ) ) ); |
|
| 790 | + $notes_array = array_reverse(array_filter(explode("\n\n", $all_notes))); |
|
| 791 | 791 | |
| 792 | - return count( $notes_array ); |
|
| 792 | + return count($notes_array); |
|
| 793 | 793 | |
| 794 | 794 | } |
| 795 | 795 | |
@@ -803,22 +803,22 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @return string|boolean The new note if added successfully, false otherwise. |
| 805 | 805 | */ |
| 806 | - public function add_note( $note = '' ) { |
|
| 806 | + public function add_note($note = '') { |
|
| 807 | 807 | |
| 808 | - $note = trim( $note ); |
|
| 809 | - if ( empty( $note ) ) { |
|
| 808 | + $note = trim($note); |
|
| 809 | + if (empty($note)) { |
|
| 810 | 810 | return false; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | $notes = $this->get_raw_notes(); |
| 814 | 814 | |
| 815 | - if ( empty( $notes ) ) { |
|
| 815 | + if (empty($notes)) { |
|
| 816 | 816 | $notes = ''; |
| 817 | 817 | } |
| 818 | 818 | |
| 819 | - $note_string = date_i18n( 'F j, Y H:i:s', current_time( 'timestamp' ) ) . ' - ' . $note; |
|
| 820 | - $new_note = apply_filters( 'give_customer_add_note_string', $note_string ); |
|
| 821 | - $notes .= "\n\n" . $new_note; |
|
| 819 | + $note_string = date_i18n('F j, Y H:i:s', current_time('timestamp')).' - '.$note; |
|
| 820 | + $new_note = apply_filters('give_customer_add_note_string', $note_string); |
|
| 821 | + $notes .= "\n\n".$new_note; |
|
| 822 | 822 | |
| 823 | 823 | /** |
| 824 | 824 | * Fires before customer note added. |
@@ -828,11 +828,11 @@ discard block |
||
| 828 | 828 | * @param string $new_note New note to add. |
| 829 | 829 | * @param int $customer_id Customer id. |
| 830 | 830 | */ |
| 831 | - do_action( 'give_customer_pre_add_note', $new_note, $this->id ); |
|
| 831 | + do_action('give_customer_pre_add_note', $new_note, $this->id); |
|
| 832 | 832 | |
| 833 | - $updated = $this->update( array( 'notes' => $notes ) ); |
|
| 833 | + $updated = $this->update(array('notes' => $notes)); |
|
| 834 | 834 | |
| 835 | - if ( $updated ) { |
|
| 835 | + if ($updated) { |
|
| 836 | 836 | $this->notes = $this->get_notes(); |
| 837 | 837 | } |
| 838 | 838 | |
@@ -845,7 +845,7 @@ discard block |
||
| 845 | 845 | * @param string $new_note New note added. |
| 846 | 846 | * @param int $customer_id Customer id. |
| 847 | 847 | */ |
| 848 | - do_action( 'give_customer_post_add_note', $this->notes, $new_note, $this->id ); |
|
| 848 | + do_action('give_customer_post_add_note', $this->notes, $new_note, $this->id); |
|
| 849 | 849 | |
| 850 | 850 | // Return the formatted note, so we can test, as well as update any displays |
| 851 | 851 | return $new_note; |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | */ |
| 863 | 863 | private function get_raw_notes() { |
| 864 | 864 | |
| 865 | - $all_notes = $this->db->get_column( 'notes', $this->id ); |
|
| 865 | + $all_notes = $this->db->get_column('notes', $this->id); |
|
| 866 | 866 | |
| 867 | 867 | return $all_notes; |
| 868 | 868 | |
@@ -879,8 +879,8 @@ discard block |
||
| 879 | 879 | * |
| 880 | 880 | * @return mixed Will be an array if $single is false. Will be value of meta data field if $single is true. |
| 881 | 881 | */ |
| 882 | - public function get_meta( $meta_key = '', $single = true ) { |
|
| 883 | - return Give()->customer_meta->get_meta( $this->id, $meta_key, $single ); |
|
| 882 | + public function get_meta($meta_key = '', $single = true) { |
|
| 883 | + return Give()->customer_meta->get_meta($this->id, $meta_key, $single); |
|
| 884 | 884 | } |
| 885 | 885 | |
| 886 | 886 | /** |
@@ -895,8 +895,8 @@ discard block |
||
| 895 | 895 | * |
| 896 | 896 | * @return bool False for failure. True for success. |
| 897 | 897 | */ |
| 898 | - public function add_meta( $meta_key = '', $meta_value, $unique = false ) { |
|
| 899 | - return Give()->customer_meta->add_meta( $this->id, $meta_key, $meta_value, $unique ); |
|
| 898 | + public function add_meta($meta_key = '', $meta_value, $unique = false) { |
|
| 899 | + return Give()->customer_meta->add_meta($this->id, $meta_key, $meta_value, $unique); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | 902 | /** |
@@ -911,8 +911,8 @@ discard block |
||
| 911 | 911 | * |
| 912 | 912 | * @return bool False on failure, true if success. |
| 913 | 913 | */ |
| 914 | - public function update_meta( $meta_key = '', $meta_value, $prev_value = '' ) { |
|
| 915 | - return Give()->customer_meta->update_meta( $this->id, $meta_key, $meta_value, $prev_value ); |
|
| 914 | + public function update_meta($meta_key = '', $meta_value, $prev_value = '') { |
|
| 915 | + return Give()->customer_meta->update_meta($this->id, $meta_key, $meta_value, $prev_value); |
|
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | /** |
@@ -926,8 +926,8 @@ discard block |
||
| 926 | 926 | * |
| 927 | 927 | * @return bool False for failure. True for success. |
| 928 | 928 | */ |
| 929 | - public function delete_meta( $meta_key = '', $meta_value = '' ) { |
|
| 930 | - return Give()->customer_meta->delete_meta( $this->id, $meta_key, $meta_value ); |
|
| 929 | + public function delete_meta($meta_key = '', $meta_value = '') { |
|
| 930 | + return Give()->customer_meta->delete_meta($this->id, $meta_key, $meta_value); |
|
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | /** |
@@ -940,51 +940,51 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @return array The sanitized data, based off column defaults. |
| 942 | 942 | */ |
| 943 | - private function sanitize_columns( $data ) { |
|
| 943 | + private function sanitize_columns($data) { |
|
| 944 | 944 | |
| 945 | 945 | $columns = $this->db->get_columns(); |
| 946 | 946 | $default_values = $this->db->get_column_defaults(); |
| 947 | 947 | |
| 948 | - foreach ( $columns as $key => $type ) { |
|
| 948 | + foreach ($columns as $key => $type) { |
|
| 949 | 949 | |
| 950 | 950 | // Only sanitize data that we were provided |
| 951 | - if ( ! array_key_exists( $key, $data ) ) { |
|
| 951 | + if ( ! array_key_exists($key, $data)) { |
|
| 952 | 952 | continue; |
| 953 | 953 | } |
| 954 | 954 | |
| 955 | - switch ( $type ) { |
|
| 955 | + switch ($type) { |
|
| 956 | 956 | |
| 957 | 957 | case '%s': |
| 958 | - if ( 'email' == $key ) { |
|
| 959 | - $data[ $key ] = sanitize_email( $data[ $key ] ); |
|
| 960 | - } elseif ( 'notes' == $key ) { |
|
| 961 | - $data[ $key ] = strip_tags( $data[ $key ] ); |
|
| 958 | + if ('email' == $key) { |
|
| 959 | + $data[$key] = sanitize_email($data[$key]); |
|
| 960 | + } elseif ('notes' == $key) { |
|
| 961 | + $data[$key] = strip_tags($data[$key]); |
|
| 962 | 962 | } else { |
| 963 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 963 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 964 | 964 | } |
| 965 | 965 | break; |
| 966 | 966 | |
| 967 | 967 | case '%d': |
| 968 | - if ( ! is_numeric( $data[ $key ] ) || (int) $data[ $key ] !== absint( $data[ $key ] ) ) { |
|
| 969 | - $data[ $key ] = $default_values[ $key ]; |
|
| 968 | + if ( ! is_numeric($data[$key]) || (int) $data[$key] !== absint($data[$key])) { |
|
| 969 | + $data[$key] = $default_values[$key]; |
|
| 970 | 970 | } else { |
| 971 | - $data[ $key ] = absint( $data[ $key ] ); |
|
| 971 | + $data[$key] = absint($data[$key]); |
|
| 972 | 972 | } |
| 973 | 973 | break; |
| 974 | 974 | |
| 975 | 975 | case '%f': |
| 976 | 976 | // Convert what was given to a float |
| 977 | - $value = floatval( $data[ $key ] ); |
|
| 977 | + $value = floatval($data[$key]); |
|
| 978 | 978 | |
| 979 | - if ( ! is_float( $value ) ) { |
|
| 980 | - $data[ $key ] = $default_values[ $key ]; |
|
| 979 | + if ( ! is_float($value)) { |
|
| 980 | + $data[$key] = $default_values[$key]; |
|
| 981 | 981 | } else { |
| 982 | - $data[ $key ] = $value; |
|
| 982 | + $data[$key] = $value; |
|
| 983 | 983 | } |
| 984 | 984 | break; |
| 985 | 985 | |
| 986 | 986 | default: |
| 987 | - $data[ $key ] = sanitize_text_field( $data[ $key ] ); |
|
| 987 | + $data[$key] = sanitize_text_field($data[$key]); |
|
| 988 | 988 | break; |
| 989 | 989 | |
| 990 | 990 | } |
@@ -1002,33 +1002,33 @@ discard block |
||
| 1002 | 1002 | * @param bool $primary Allows setting the email added as the primary |
| 1003 | 1003 | * @return bool If the email was added successfully |
| 1004 | 1004 | */ |
| 1005 | - public function add_email( $email = '', $primary = false ) { |
|
| 1006 | - if( ! is_email( $email ) ) { |
|
| 1005 | + public function add_email($email = '', $primary = false) { |
|
| 1006 | + if ( ! is_email($email)) { |
|
| 1007 | 1007 | return false; |
| 1008 | 1008 | } |
| 1009 | - $existing = new Give_Customer( $email ); |
|
| 1009 | + $existing = new Give_Customer($email); |
|
| 1010 | 1010 | |
| 1011 | - if( $existing->id > 0 ) { |
|
| 1011 | + if ($existing->id > 0) { |
|
| 1012 | 1012 | // Email address already belongs to another customer |
| 1013 | 1013 | return false; |
| 1014 | 1014 | } |
| 1015 | 1015 | |
| 1016 | - if ( email_exists( $email ) ) { |
|
| 1017 | - $user = get_user_by( 'email', $email ); |
|
| 1018 | - if ( $user->ID != $this->user_id ) { |
|
| 1016 | + if (email_exists($email)) { |
|
| 1017 | + $user = get_user_by('email', $email); |
|
| 1018 | + if ($user->ID != $this->user_id) { |
|
| 1019 | 1019 | return false; |
| 1020 | 1020 | } |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | - do_action( 'give_donor_pre_add_email', $email, $this->id, $this ); |
|
| 1023 | + do_action('give_donor_pre_add_email', $email, $this->id, $this); |
|
| 1024 | 1024 | |
| 1025 | 1025 | // Add is used to ensure duplicate emails are not added |
| 1026 | - $ret = (bool) $this->add_meta( 'additional_email', $email ); |
|
| 1026 | + $ret = (bool) $this->add_meta('additional_email', $email); |
|
| 1027 | 1027 | |
| 1028 | - do_action( 'give_donor_post_add_email', $email, $this->id, $this ); |
|
| 1028 | + do_action('give_donor_post_add_email', $email, $this->id, $this); |
|
| 1029 | 1029 | |
| 1030 | - if ( $ret && true === $primary ) { |
|
| 1031 | - $this->set_primary_email( $email ); |
|
| 1030 | + if ($ret && true === $primary) { |
|
| 1031 | + $this->set_primary_email($email); |
|
| 1032 | 1032 | } |
| 1033 | 1033 | |
| 1034 | 1034 | return $ret; |
@@ -1042,16 +1042,16 @@ discard block |
||
| 1042 | 1042 | * @param string $email The email address to remove from the customer |
| 1043 | 1043 | * @return bool If the email was removeed 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 | } |
@@ -1065,16 +1065,16 @@ discard block |
||
| 1065 | 1065 | * @param string $new_primary_email The email address to remove from the customer |
| 1066 | 1066 | * @return bool If the email was set as primary successfully |
| 1067 | 1067 | */ |
| 1068 | - public function set_primary_email( $new_primary_email = '' ) { |
|
| 1069 | - if( ! is_email( $new_primary_email ) ) { |
|
| 1068 | + public function set_primary_email($new_primary_email = '') { |
|
| 1069 | + if ( ! is_email($new_primary_email)) { |
|
| 1070 | 1070 | return false; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | - do_action( 'give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1073 | + do_action('give_donor_pre_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1074 | 1074 | |
| 1075 | - $existing = new Give_Customer( $new_primary_email ); |
|
| 1075 | + $existing = new Give_Customer($new_primary_email); |
|
| 1076 | 1076 | |
| 1077 | - if( $existing->id > 0 && (int) $existing->id !== (int) $this->id ) { |
|
| 1077 | + if ($existing->id > 0 && (int) $existing->id !== (int) $this->id) { |
|
| 1078 | 1078 | // This email belongs to another customer |
| 1079 | 1079 | return false; |
| 1080 | 1080 | } |
@@ -1082,21 +1082,21 @@ discard block |
||
| 1082 | 1082 | $old_email = $this->email; |
| 1083 | 1083 | |
| 1084 | 1084 | // Update customer record with new email |
| 1085 | - $update = $this->update( array( 'email' => $new_primary_email ) ); |
|
| 1085 | + $update = $this->update(array('email' => $new_primary_email)); |
|
| 1086 | 1086 | |
| 1087 | 1087 | // Remove new primary from list of additional emails |
| 1088 | - $remove = $this->remove_email( $new_primary_email ); |
|
| 1088 | + $remove = $this->remove_email($new_primary_email); |
|
| 1089 | 1089 | |
| 1090 | 1090 | // Add old email to additional emails list |
| 1091 | - $add = $this->add_email( $old_email ); |
|
| 1091 | + $add = $this->add_email($old_email); |
|
| 1092 | 1092 | |
| 1093 | 1093 | $ret = $update && $remove && $add; |
| 1094 | 1094 | |
| 1095 | - if( $ret ) { |
|
| 1095 | + if ($ret) { |
|
| 1096 | 1096 | $this->email = $new_primary_email; |
| 1097 | 1097 | } |
| 1098 | 1098 | |
| 1099 | - do_action( 'give_donor_post_set_primary_email', $new_primary_email, $this->id, $this ); |
|
| 1099 | + do_action('give_donor_post_set_primary_email', $new_primary_email, $this->id, $this); |
|
| 1100 | 1100 | |
| 1101 | 1101 | return $ret; |
| 1102 | 1102 | } |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | * |
| 22 | 22 | * @param array $args An array of form arguments. |
| 23 | 23 | * |
| 24 | - * @return string Donation form. |
|
| 24 | + * @return false|null Donation form. |
|
| 25 | 25 | */ |
| 26 | 26 | function give_get_donation_form( $args = array() ) { |
| 27 | 27 | |
@@ -1359,7 +1359,7 @@ discard block |
||
| 1359 | 1359 | * |
| 1360 | 1360 | * @param int $form_id The form ID. |
| 1361 | 1361 | * |
| 1362 | - * @return void|bool |
|
| 1362 | + * @return false|null |
|
| 1363 | 1363 | */ |
| 1364 | 1364 | function give_terms_agreement( $form_id ) { |
| 1365 | 1365 | $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
@@ -1552,7 +1552,7 @@ discard block |
||
| 1552 | 1552 | * @param int $form_id The form ID. |
| 1553 | 1553 | * @param array $args An array of form arguments. |
| 1554 | 1554 | * |
| 1555 | - * @return mixed |
|
| 1555 | + * @return boolean |
|
| 1556 | 1556 | */ |
| 1557 | 1557 | function give_show_goal_progress( $form_id, $args ) { |
| 1558 | 1558 | |
@@ -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 | |
@@ -23,47 +23,47 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | * @return string Donation form. |
| 25 | 25 | */ |
| 26 | -function give_get_donation_form( $args = array() ) { |
|
| 26 | +function give_get_donation_form($args = array()) { |
|
| 27 | 27 | |
| 28 | 28 | global $post; |
| 29 | 29 | |
| 30 | - $form_id = is_object( $post ) ? $post->ID : 0; |
|
| 30 | + $form_id = is_object($post) ? $post->ID : 0; |
|
| 31 | 31 | |
| 32 | - if ( isset( $args['id'] ) ) { |
|
| 32 | + if (isset($args['id'])) { |
|
| 33 | 33 | $form_id = $args['id']; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | - $defaults = apply_filters( 'give_form_args_defaults', array( |
|
| 36 | + $defaults = apply_filters('give_form_args_defaults', array( |
|
| 37 | 37 | 'form_id' => $form_id, |
| 38 | - ) ); |
|
| 38 | + )); |
|
| 39 | 39 | |
| 40 | - $args = wp_parse_args( $args, $defaults ); |
|
| 40 | + $args = wp_parse_args($args, $defaults); |
|
| 41 | 41 | |
| 42 | - $form = new Give_Donate_Form( $args['form_id'] ); |
|
| 42 | + $form = new Give_Donate_Form($args['form_id']); |
|
| 43 | 43 | |
| 44 | 44 | //bail if no form ID. |
| 45 | - if ( empty( $form->ID ) ) { |
|
| 45 | + if (empty($form->ID)) { |
|
| 46 | 46 | return false; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - $payment_mode = give_get_chosen_gateway( $form->ID ); |
|
| 49 | + $payment_mode = give_get_chosen_gateway($form->ID); |
|
| 50 | 50 | |
| 51 | - $form_action = add_query_arg( apply_filters( 'give_form_action_args', array( |
|
| 51 | + $form_action = add_query_arg(apply_filters('give_form_action_args', array( |
|
| 52 | 52 | 'payment-mode' => $payment_mode, |
| 53 | - ) ), |
|
| 53 | + )), |
|
| 54 | 54 | give_get_current_page_url() |
| 55 | 55 | ); |
| 56 | 56 | |
| 57 | 57 | //Sanity Check: Donation form not published or user doesn't have permission to view drafts. |
| 58 | - if ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) { |
|
| 58 | + if ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) { |
|
| 59 | 59 | return false; |
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | //Get the form wrap CSS classes. |
| 63 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 63 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 64 | 64 | |
| 65 | 65 | //Get the <form> tag wrap CSS classes. |
| 66 | - $form_classes = $form->get_form_classes( $args ); |
|
| 66 | + $form_classes = $form->get_form_classes($args); |
|
| 67 | 67 | |
| 68 | 68 | ob_start(); |
| 69 | 69 | |
@@ -75,25 +75,25 @@ discard block |
||
| 75 | 75 | * @param int $form_id The form ID. |
| 76 | 76 | * @param array $args An array of form arguments. |
| 77 | 77 | */ |
| 78 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
| 78 | + do_action('give_pre_form_output', $form->ID, $args); |
|
| 79 | 79 | |
| 80 | 80 | ?> |
| 81 | 81 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 82 | 82 | |
| 83 | - <?php if ( $form->is_close_donation_form() ) { |
|
| 83 | + <?php if ($form->is_close_donation_form()) { |
|
| 84 | 84 | |
| 85 | 85 | //Get Goal thank you message. |
| 86 | - $display_thankyou_message = get_post_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 87 | - $display_thankyou_message = ! empty( $display_thankyou_message ) ? $display_thankyou_message : esc_html__( 'Thank you to all our donors, we have met our fundraising goal.', 'give' ); |
|
| 86 | + $display_thankyou_message = get_post_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 87 | + $display_thankyou_message = ! empty($display_thankyou_message) ? $display_thankyou_message : esc_html__('Thank you to all our donors, we have met our fundraising goal.', 'give'); |
|
| 88 | 88 | |
| 89 | 89 | //Print thank you message. |
| 90 | - apply_filters( 'give_goal_closed_output', give_output_error( $display_thankyou_message, true, 'success' ) ); |
|
| 90 | + apply_filters('give_goal_closed_output', give_output_error($display_thankyou_message, true, 'success')); |
|
| 91 | 91 | |
| 92 | 92 | } else { |
| 93 | 93 | |
| 94 | - if ( isset( $args['show_title'] ) && $args['show_title'] == true ) { |
|
| 94 | + if (isset($args['show_title']) && $args['show_title'] == true) { |
|
| 95 | 95 | |
| 96 | - echo apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
| 96 | + echo apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
| 97 | 97 | |
| 98 | 98 | } |
| 99 | 99 | |
@@ -105,15 +105,15 @@ discard block |
||
| 105 | 105 | * @param int $form_id The form ID. |
| 106 | 106 | * @param array $args An array of form arguments. |
| 107 | 107 | */ |
| 108 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
| 108 | + do_action('give_pre_form', $form->ID, $args); |
|
| 109 | 109 | ?> |
| 110 | 110 | |
| 111 | - <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
| 111 | + <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
| 112 | 112 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
| 113 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
| 114 | - <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 115 | - <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 116 | - <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ) ); ?>"/> |
|
| 113 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
| 114 | + <input type="hidden" name="give-current-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 115 | + <input type="hidden" name="give-form-url" value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 116 | + <input type="hidden" name="give-form-minimum" value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID)); ?>"/> |
|
| 117 | 117 | |
| 118 | 118 | <!-- The following field is for robots only, invisible to humans: --> |
| 119 | 119 | <span class="give-hidden" style="display: none !important;"> |
@@ -124,13 +124,13 @@ discard block |
||
| 124 | 124 | <?php |
| 125 | 125 | |
| 126 | 126 | //Price ID hidden field for variable (mult-level) donation forms. |
| 127 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 127 | + if (give_has_variable_prices($form_id)) { |
|
| 128 | 128 | //get default selected price ID. |
| 129 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 129 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 130 | 130 | $price_id = 0; |
| 131 | 131 | //loop through prices. |
| 132 | - foreach ( $prices as $price ) { |
|
| 133 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 132 | + foreach ($prices as $price) { |
|
| 133 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 134 | 134 | $price_id = $price['_give_id']['level_id']; |
| 135 | 135 | }; |
| 136 | 136 | } |
@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | * @param int $form_id The form ID. |
| 147 | 147 | * @param array $args An array of form arguments. |
| 148 | 148 | */ |
| 149 | - do_action( 'give_checkout_form_top', $form->ID, $args ); |
|
| 149 | + do_action('give_checkout_form_top', $form->ID, $args); |
|
| 150 | 150 | |
| 151 | 151 | /** |
| 152 | 152 | * Fires while outputing donation form, for payment gatways fields. |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | * @param int $form_id The form ID. |
| 157 | 157 | * @param array $args An array of form arguments. |
| 158 | 158 | */ |
| 159 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
| 159 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Fires while outputing donation form, after all other fields. |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | * @param int $form_id The form ID. |
| 167 | 167 | * @param array $args An array of form arguments. |
| 168 | 168 | */ |
| 169 | - do_action( 'give_checkout_form_bottom', $form->ID, $args ); |
|
| 169 | + do_action('give_checkout_form_bottom', $form->ID, $args); |
|
| 170 | 170 | |
| 171 | 171 | ?> |
| 172 | 172 | </form> |
@@ -180,12 +180,12 @@ discard block |
||
| 180 | 180 | * @param int $form_id The form ID. |
| 181 | 181 | * @param array $args An array of form arguments. |
| 182 | 182 | */ |
| 183 | - do_action( 'give_post_form', $form->ID, $args ); |
|
| 183 | + do_action('give_post_form', $form->ID, $args); |
|
| 184 | 184 | |
| 185 | 185 | } |
| 186 | 186 | ?> |
| 187 | 187 | |
| 188 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 188 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 189 | 189 | <?php |
| 190 | 190 | |
| 191 | 191 | /** |
@@ -196,11 +196,11 @@ discard block |
||
| 196 | 196 | * @param int $form_id The form ID. |
| 197 | 197 | * @param array $args An array of form arguments. |
| 198 | 198 | */ |
| 199 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 199 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 200 | 200 | |
| 201 | 201 | $final_output = ob_get_clean(); |
| 202 | 202 | |
| 203 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 203 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | /** |
@@ -217,11 +217,11 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @return string |
| 219 | 219 | */ |
| 220 | -function give_show_purchase_form( $form_id ) { |
|
| 220 | +function give_show_purchase_form($form_id) { |
|
| 221 | 221 | |
| 222 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 222 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 223 | 223 | |
| 224 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 224 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 225 | 225 | $form_id = $_POST['give_form_id']; |
| 226 | 226 | } |
| 227 | 227 | |
@@ -230,33 +230,33 @@ discard block |
||
| 230 | 230 | * |
| 231 | 231 | * @since 1.7 |
| 232 | 232 | */ |
| 233 | - do_action( 'give_donation_form_top', $form_id ); |
|
| 233 | + do_action('give_donation_form_top', $form_id); |
|
| 234 | 234 | |
| 235 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 235 | + if (give_can_checkout() && isset($form_id)) { |
|
| 236 | 236 | |
| 237 | 237 | /** |
| 238 | 238 | * Fires while displaying donation form, before registration login. |
| 239 | 239 | * |
| 240 | 240 | * @since 1.7 |
| 241 | 241 | */ |
| 242 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
| 242 | + do_action('give_donation_form_before_register_login', $form_id); |
|
| 243 | 243 | |
| 244 | 244 | /** |
| 245 | 245 | * Fire when register/login form fields render. |
| 246 | 246 | * |
| 247 | 247 | * @since 1.7 |
| 248 | 248 | */ |
| 249 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 249 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * Fire when credit card form fields render. |
| 253 | 253 | * |
| 254 | 254 | * @since 1.7 |
| 255 | 255 | */ |
| 256 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
| 256 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
| 257 | 257 | |
| 258 | 258 | // Load the credit card form and allow gateways to load their own if they wish. |
| 259 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 259 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 260 | 260 | /** |
| 261 | 261 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 262 | 262 | * |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | * |
| 265 | 265 | * @param int $form_id The form ID. |
| 266 | 266 | */ |
| 267 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
| 267 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
| 268 | 268 | } else { |
| 269 | 269 | /** |
| 270 | 270 | * Fires while displaying donation form, credit card form fields. |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | * |
| 274 | 274 | * @param int $form_id The form ID. |
| 275 | 275 | */ |
| 276 | - do_action( 'give_cc_form', $form_id ); |
|
| 276 | + do_action('give_cc_form', $form_id); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -281,7 +281,7 @@ discard block |
||
| 281 | 281 | * |
| 282 | 282 | * @since 1.7 |
| 283 | 283 | */ |
| 284 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
| 284 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
| 285 | 285 | |
| 286 | 286 | } else { |
| 287 | 287 | /** |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | * |
| 290 | 290 | * @since 1.7 |
| 291 | 291 | */ |
| 292 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 292 | + do_action('give_donation_form_no_access', $form_id); |
|
| 293 | 293 | |
| 294 | 294 | } |
| 295 | 295 | |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | * |
| 299 | 299 | * @since 1.7 |
| 300 | 300 | */ |
| 301 | - do_action( 'give_donation_form_bottom', $form_id ); |
|
| 301 | + do_action('give_donation_form_bottom', $form_id); |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
| 304 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | 307 | * Give Show Login/Register Form Fields. |
@@ -312,11 +312,11 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @return void |
| 314 | 314 | */ |
| 315 | -function give_show_register_login_fields( $form_id ) { |
|
| 315 | +function give_show_register_login_fields($form_id) { |
|
| 316 | 316 | |
| 317 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 317 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 318 | 318 | |
| 319 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 319 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 320 | 320 | ?> |
| 321 | 321 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 322 | 322 | <?php |
@@ -325,11 +325,11 @@ discard block |
||
| 325 | 325 | * |
| 326 | 326 | * @since 1.7 |
| 327 | 327 | */ |
| 328 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 328 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 329 | 329 | ?> |
| 330 | 330 | </div> |
| 331 | 331 | <?php |
| 332 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 332 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 333 | 333 | ?> |
| 334 | 334 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 335 | 335 | <?php |
@@ -338,23 +338,23 @@ discard block |
||
| 338 | 338 | * |
| 339 | 339 | * @since 1.7 |
| 340 | 340 | */ |
| 341 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 341 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 342 | 342 | ?> |
| 343 | 343 | </div> |
| 344 | 344 | <?php |
| 345 | 345 | endif; |
| 346 | 346 | |
| 347 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 347 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 348 | 348 | /** |
| 349 | 349 | * Fire when user info render. |
| 350 | 350 | * |
| 351 | 351 | * @since 1.7 |
| 352 | 352 | */ |
| 353 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 353 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 357 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 358 | 358 | |
| 359 | 359 | /** |
| 360 | 360 | * Donation Amount Field. |
@@ -368,16 +368,16 @@ discard block |
||
| 368 | 368 | * |
| 369 | 369 | * @return void |
| 370 | 370 | */ |
| 371 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 371 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 372 | 372 | |
| 373 | 373 | $give_options = give_get_settings(); |
| 374 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 375 | - $allow_custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
| 376 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 377 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
| 378 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 379 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ) ); |
|
| 380 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 374 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 375 | + $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
| 376 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 377 | + $symbol = give_currency_symbol(give_get_currency()); |
|
| 378 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 379 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id)); |
|
| 380 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 381 | 381 | |
| 382 | 382 | /** |
| 383 | 383 | * Fires while displaying donation form, before donation level fields. |
@@ -387,19 +387,19 @@ discard block |
||
| 387 | 387 | * @param int $form_id The form ID. |
| 388 | 388 | * @param array $args An array of form arguments. |
| 389 | 389 | */ |
| 390 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 390 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 391 | 391 | |
| 392 | 392 | //Set Price, No Custom Amount Allowed means hidden price field. |
| 393 | - if ( $allow_custom_amount == 'no' ) { |
|
| 393 | + if ($allow_custom_amount == 'no') { |
|
| 394 | 394 | ?> |
| 395 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 395 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 396 | 396 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" value="<?php echo $default_amount; ?>" required aria-required="true" /> |
| 397 | 397 | <div class="set-price give-donation-amount form-row-wide"> |
| 398 | - <?php if ( $currency_position == 'before' ) { |
|
| 398 | + <?php if ($currency_position == 'before') { |
|
| 399 | 399 | echo $currency_output; |
| 400 | 400 | } ?> |
| 401 | 401 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 402 | - <?php if ( $currency_position == 'after' ) { |
|
| 402 | + <?php if ($currency_position == 'after') { |
|
| 403 | 403 | echo $currency_output; |
| 404 | 404 | } ?> |
| 405 | 405 | </div> |
@@ -409,12 +409,12 @@ discard block |
||
| 409 | 409 | ?> |
| 410 | 410 | <div class="give-total-wrap"> |
| 411 | 411 | <div class="give-donation-amount form-row-wide"> |
| 412 | - <?php if ( $currency_position == 'before' ) { |
|
| 412 | + <?php if ($currency_position == 'before') { |
|
| 413 | 413 | echo $currency_output; |
| 414 | 414 | } ?> |
| 415 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 415 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 416 | 416 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 417 | - <?php if ( $currency_position == 'after' ) { |
|
| 417 | + <?php if ($currency_position == 'after') { |
|
| 418 | 418 | echo $currency_output; |
| 419 | 419 | } ?> |
| 420 | 420 | </div> |
@@ -429,16 +429,16 @@ discard block |
||
| 429 | 429 | * @param int $form_id The form ID. |
| 430 | 430 | * @param array $args An array of form arguments. |
| 431 | 431 | */ |
| 432 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 432 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 433 | 433 | |
| 434 | 434 | //Custom Amount Text. |
| 435 | - if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty( $custom_amount_text ) ) { ?> |
|
| 435 | + if ( ! $variable_pricing && $allow_custom_amount == 'yes' && ! empty($custom_amount_text)) { ?> |
|
| 436 | 436 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 437 | 437 | <?php } |
| 438 | 438 | |
| 439 | 439 | //Output Variable Pricing Levels. |
| 440 | - if ( $variable_pricing ) { |
|
| 441 | - give_output_levels( $form_id ); |
|
| 440 | + if ($variable_pricing) { |
|
| 441 | + give_output_levels($form_id); |
|
| 442 | 442 | } |
| 443 | 443 | |
| 444 | 444 | /** |
@@ -449,10 +449,10 @@ discard block |
||
| 449 | 449 | * @param int $form_id The form ID. |
| 450 | 450 | * @param array $args An array of form arguments. |
| 451 | 451 | */ |
| 452 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 452 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | -add_action( 'give_checkout_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 455 | +add_action('give_checkout_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 456 | 456 | |
| 457 | 457 | /** |
| 458 | 458 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -463,32 +463,32 @@ discard block |
||
| 463 | 463 | * |
| 464 | 464 | * @return string Donation levels. |
| 465 | 465 | */ |
| 466 | -function give_output_levels( $form_id ) { |
|
| 466 | +function give_output_levels($form_id) { |
|
| 467 | 467 | |
| 468 | 468 | //Get variable pricing. |
| 469 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 470 | - $display_style = get_post_meta( $form_id, '_give_display_style', true ); |
|
| 471 | - $custom_amount = get_post_meta( $form_id, '_give_custom_amount', true ); |
|
| 472 | - $custom_amount_text = get_post_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 473 | - if ( empty( $custom_amount_text ) ) { |
|
| 474 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 469 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 470 | + $display_style = get_post_meta($form_id, '_give_display_style', true); |
|
| 471 | + $custom_amount = get_post_meta($form_id, '_give_custom_amount', true); |
|
| 472 | + $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); |
|
| 473 | + if (empty($custom_amount_text)) { |
|
| 474 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 475 | 475 | } |
| 476 | 476 | |
| 477 | 477 | $output = ''; |
| 478 | 478 | $counter = 0; |
| 479 | 479 | |
| 480 | - switch ( $display_style ) { |
|
| 480 | + switch ($display_style) { |
|
| 481 | 481 | case 'buttons': |
| 482 | 482 | |
| 483 | 483 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 484 | 484 | |
| 485 | - foreach ( $prices as $price ) { |
|
| 486 | - $counter ++; |
|
| 487 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 488 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $counter . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 485 | + foreach ($prices as $price) { |
|
| 486 | + $counter++; |
|
| 487 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 488 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$counter.' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 489 | 489 | |
| 490 | 490 | $output .= '<li>'; |
| 491 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 491 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 492 | 492 | $output .= $level_text; |
| 493 | 493 | $output .= '</button>'; |
| 494 | 494 | $output .= '</li>'; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | //Custom Amount. |
| 499 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 499 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 500 | 500 | $output .= '<li>'; |
| 501 | 501 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
| 502 | 502 | $output .= $custom_amount_text; |
@@ -512,23 +512,23 @@ discard block |
||
| 512 | 512 | |
| 513 | 513 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 514 | 514 | |
| 515 | - foreach ( $prices as $price ) { |
|
| 516 | - $counter ++; |
|
| 517 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 518 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $counter . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 515 | + foreach ($prices as $price) { |
|
| 516 | + $counter++; |
|
| 517 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 518 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$counter.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 519 | 519 | |
| 520 | 520 | $output .= '<li>'; |
| 521 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $counter . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 522 | - $output .= '<label for="give-radio-level-' . $counter . '">' . $level_text . '</label>'; |
|
| 521 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$counter.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 522 | + $output .= '<label for="give-radio-level-'.$counter.'">'.$level_text.'</label>'; |
|
| 523 | 523 | $output .= '</li>'; |
| 524 | 524 | |
| 525 | 525 | } |
| 526 | 526 | |
| 527 | 527 | //Custom Amount. |
| 528 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 528 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 529 | 529 | $output .= '<li>'; |
| 530 | 530 | $output .= '<input type="radio" data-price-id="custom" class="give-radio-input give-radio-input-level give-radio-level-custom" name="give-radio-donation-level" id="give-radio-level-custom" value="custom">'; |
| 531 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
| 531 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
| 532 | 532 | $output .= '</li>'; |
| 533 | 533 | } |
| 534 | 534 | |
@@ -538,23 +538,23 @@ discard block |
||
| 538 | 538 | |
| 539 | 539 | case 'dropdown': |
| 540 | 540 | |
| 541 | - $output .= '<label for="give-donation-level" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 542 | - $output .= '<select id="give-donation-level-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 541 | + $output .= '<label for="give-donation-level" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 542 | + $output .= '<select id="give-donation-level-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 543 | 543 | |
| 544 | 544 | //first loop through prices. |
| 545 | - foreach ( $prices as $price ) { |
|
| 546 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'] ) ), $form_id, $price ); |
|
| 547 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $form_id . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 545 | + foreach ($prices as $price) { |
|
| 546 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'])), $form_id, $price); |
|
| 547 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$form_id.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 548 | 548 | |
| 549 | - $output .= '<option data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'selected="selected"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'] ) . '">'; |
|
| 549 | + $output .= '<option data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'selected="selected"' : '').' value="'.give_format_amount($price['_give_amount']).'">'; |
|
| 550 | 550 | $output .= $level_text; |
| 551 | 551 | $output .= '</option>'; |
| 552 | 552 | |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | //Custom Amount. |
| 556 | - if ( $custom_amount === 'yes' && ! empty( $custom_amount_text ) ) { |
|
| 557 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
| 556 | + if ($custom_amount === 'yes' && ! empty($custom_amount_text)) { |
|
| 557 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | $output .= '</select>'; |
@@ -562,7 +562,7 @@ discard block |
||
| 562 | 562 | break; |
| 563 | 563 | } |
| 564 | 564 | |
| 565 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 565 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | /** |
@@ -577,26 +577,26 @@ discard block |
||
| 577 | 577 | * |
| 578 | 578 | * @return string Checkout button. |
| 579 | 579 | */ |
| 580 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 580 | +function give_display_checkout_button($form_id, $args) { |
|
| 581 | 581 | |
| 582 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 582 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 583 | 583 | ? $args['display_style'] |
| 584 | - : get_post_meta( $form_id, '_give_payment_display', true ); |
|
| 584 | + : get_post_meta($form_id, '_give_payment_display', true); |
|
| 585 | 585 | |
| 586 | 586 | //no btn for onpage. |
| 587 | - if ( $display_option === 'onpage' ) { |
|
| 587 | + if ($display_option === 'onpage') { |
|
| 588 | 588 | return; |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | - $display_label_field = get_post_meta( $form_id, '_give_reveal_label', true ); |
|
| 592 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 591 | + $display_label_field = get_post_meta($form_id, '_give_reveal_label', true); |
|
| 592 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 593 | 593 | |
| 594 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 594 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 595 | 595 | |
| 596 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 596 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 599 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 600 | 600 | |
| 601 | 601 | /** |
| 602 | 602 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -607,54 +607,54 @@ discard block |
||
| 607 | 607 | * |
| 608 | 608 | * @return void |
| 609 | 609 | */ |
| 610 | -function give_user_info_fields( $form_id ) { |
|
| 610 | +function give_user_info_fields($form_id) { |
|
| 611 | 611 | // Get user info. |
| 612 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 612 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 613 | 613 | |
| 614 | 614 | /** |
| 615 | 615 | * Fire before user personal information fields |
| 616 | 616 | * |
| 617 | 617 | * @since 1.7 |
| 618 | 618 | */ |
| 619 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 619 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 620 | 620 | ?> |
| 621 | 621 | <fieldset id="give_checkout_user_info"> |
| 622 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
| 622 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
| 623 | 623 | <p id="give-first-name-wrap" class="form-row form-row-first"> |
| 624 | 624 | <label class="give-label" for="give-first"> |
| 625 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
| 626 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 625 | + <?php esc_html_e('First Name', 'give'); ?> |
|
| 626 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 627 | 627 | <span class="give-required-indicator">*</span> |
| 628 | 628 | <?php endif ?> |
| 629 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
| 629 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
| 630 | 630 | </label> |
| 631 | 631 | <input |
| 632 | 632 | class="give-input required" |
| 633 | 633 | type="text" |
| 634 | 634 | name="give_first" |
| 635 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
| 636 | - id="give-first" value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 637 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 635 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
| 636 | + id="give-first" value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 637 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 638 | 638 | /> |
| 639 | 639 | </p> |
| 640 | 640 | |
| 641 | 641 | <p id="give-last-name-wrap" class="form-row form-row-last"> |
| 642 | 642 | <label class="give-label" for="give-last"> |
| 643 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
| 644 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 643 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
| 644 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 645 | 645 | <span class="give-required-indicator">*</span> |
| 646 | 646 | <?php endif ?> |
| 647 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
| 647 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
| 648 | 648 | </label> |
| 649 | 649 | |
| 650 | 650 | <input |
| 651 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 651 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 652 | 652 | type="text" |
| 653 | 653 | name="give_last" |
| 654 | 654 | id="give-last" |
| 655 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
| 656 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 657 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 655 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
| 656 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 657 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 658 | 658 | /> |
| 659 | 659 | </p> |
| 660 | 660 | |
@@ -664,24 +664,24 @@ discard block |
||
| 664 | 664 | * |
| 665 | 665 | * @since 1.7 |
| 666 | 666 | */ |
| 667 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 667 | + do_action('give_donation_form_before_email', $form_id); |
|
| 668 | 668 | ?> |
| 669 | 669 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 670 | 670 | <label class="give-label" for="give-email"> |
| 671 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
| 672 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 671 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
| 672 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 673 | 673 | <span class="give-required-indicator">*</span> |
| 674 | 674 | <?php } ?> |
| 675 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
| 675 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
| 676 | 676 | </label> |
| 677 | 677 | |
| 678 | 678 | <input |
| 679 | 679 | class="give-input required" |
| 680 | 680 | type="email" |
| 681 | 681 | name="give_email" |
| 682 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
| 683 | - id="give-email" value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 684 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 682 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
| 683 | + id="give-email" value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 684 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 685 | 685 | /> |
| 686 | 686 | |
| 687 | 687 | </p> |
@@ -691,14 +691,14 @@ discard block |
||
| 691 | 691 | * |
| 692 | 692 | * @since 1.7 |
| 693 | 693 | */ |
| 694 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 694 | + do_action('give_donation_form_after_email', $form_id); |
|
| 695 | 695 | |
| 696 | 696 | /** |
| 697 | 697 | * Fire after personal email field |
| 698 | 698 | * |
| 699 | 699 | * @since 1.7 |
| 700 | 700 | */ |
| 701 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 701 | + do_action('give_donation_form_user_info', $form_id); |
|
| 702 | 702 | ?> |
| 703 | 703 | </fieldset> |
| 704 | 704 | <?php |
@@ -707,11 +707,11 @@ discard block |
||
| 707 | 707 | * |
| 708 | 708 | * @since 1.7 |
| 709 | 709 | */ |
| 710 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 710 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 714 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 713 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 714 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | 717 | * Renders the credit card info form. |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | * |
| 723 | 723 | * @return void |
| 724 | 724 | */ |
| 725 | -function give_get_cc_form( $form_id ) { |
|
| 725 | +function give_get_cc_form($form_id) { |
|
| 726 | 726 | |
| 727 | 727 | ob_start(); |
| 728 | 728 | |
@@ -733,45 +733,45 @@ discard block |
||
| 733 | 733 | * |
| 734 | 734 | * @param int $form_id The form ID. |
| 735 | 735 | */ |
| 736 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 736 | + do_action('give_before_cc_fields', $form_id); |
|
| 737 | 737 | ?> |
| 738 | 738 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 739 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 740 | - <?php if ( is_ssl() ) : ?> |
|
| 739 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 740 | + <?php if (is_ssl()) : ?> |
|
| 741 | 741 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 742 | 742 | <span class="give-icon padlock"></span> |
| 743 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 743 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 744 | 744 | </div> |
| 745 | 745 | <?php endif; ?> |
| 746 | 746 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
| 747 | 747 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 748 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
| 748 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
| 749 | 749 | <span class="give-required-indicator">*</span> |
| 750 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
| 750 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
| 751 | 751 | <span class="card-type"></span> |
| 752 | 752 | </label> |
| 753 | 753 | |
| 754 | - <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" required aria-required="true" /> |
|
| 754 | + <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" required aria-required="true" /> |
|
| 755 | 755 | </p> |
| 756 | 756 | |
| 757 | 757 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third"> |
| 758 | 758 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 759 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
| 759 | + <?php esc_html_e('CVC', 'give'); ?> |
|
| 760 | 760 | <span class="give-required-indicator">*</span> |
| 761 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
| 761 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
| 762 | 762 | </label> |
| 763 | 763 | |
| 764 | - <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" required aria-required="true" /> |
|
| 764 | + <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" required aria-required="true" /> |
|
| 765 | 765 | </p> |
| 766 | 766 | |
| 767 | 767 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds"> |
| 768 | 768 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 769 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
| 769 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
| 770 | 770 | <span class="give-required-indicator">*</span> |
| 771 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
| 771 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
| 772 | 772 | </label> |
| 773 | 773 | |
| 774 | - <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" required aria-required="true" /> |
|
| 774 | + <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" required aria-required="true" /> |
|
| 775 | 775 | </p> |
| 776 | 776 | <?php |
| 777 | 777 | /** |
@@ -781,19 +781,19 @@ discard block |
||
| 781 | 781 | * |
| 782 | 782 | * @param int $form_id The form ID. |
| 783 | 783 | */ |
| 784 | - do_action( 'give_before_cc_expiration' ); |
|
| 784 | + do_action('give_before_cc_expiration'); |
|
| 785 | 785 | ?> |
| 786 | 786 | <p class="card-expiration form-row form-row-one-third"> |
| 787 | 787 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 788 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
| 788 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
| 789 | 789 | <span class="give-required-indicator">*</span> |
| 790 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
| 790 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
| 791 | 791 | </label> |
| 792 | 792 | |
| 793 | 793 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" class="card-expiry-month"/> |
| 794 | 794 | <input type="hidden" id="card_exp_year-<?php echo $form_id ?>" name="card_exp_year" class="card-expiry-year"/> |
| 795 | 795 | |
| 796 | - <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" required aria-required="true" /> |
|
| 796 | + <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" required aria-required="true" /> |
|
| 797 | 797 | </p> |
| 798 | 798 | <?php |
| 799 | 799 | /** |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | * |
| 804 | 804 | * @param int $form_id The form ID. |
| 805 | 805 | */ |
| 806 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 806 | + do_action('give_after_cc_expiration', $form_id); |
|
| 807 | 807 | ?> |
| 808 | 808 | </fieldset> |
| 809 | 809 | <?php |
@@ -814,12 +814,12 @@ discard block |
||
| 814 | 814 | * |
| 815 | 815 | * @param int $form_id The form ID. |
| 816 | 816 | */ |
| 817 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 817 | + do_action('give_after_cc_fields', $form_id); |
|
| 818 | 818 | |
| 819 | 819 | echo ob_get_clean(); |
| 820 | 820 | } |
| 821 | 821 | |
| 822 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 822 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 823 | 823 | |
| 824 | 824 | /** |
| 825 | 825 | * Outputs the default credit card address fields. |
@@ -830,24 +830,24 @@ discard block |
||
| 830 | 830 | * |
| 831 | 831 | * @return void |
| 832 | 832 | */ |
| 833 | -function give_default_cc_address_fields( $form_id ) { |
|
| 833 | +function give_default_cc_address_fields($form_id) { |
|
| 834 | 834 | // Get user info. |
| 835 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 835 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 836 | 836 | |
| 837 | 837 | $logged_in = is_user_logged_in(); |
| 838 | 838 | |
| 839 | - if ( $logged_in ) { |
|
| 840 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 839 | + if ($logged_in) { |
|
| 840 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 841 | 841 | } |
| 842 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
| 843 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
| 844 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
| 845 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
| 842 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
| 843 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
| 844 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
| 845 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
| 846 | 846 | |
| 847 | 847 | ob_start(); |
| 848 | 848 | ?> |
| 849 | 849 | <fieldset id="give_cc_address" class="cc-address"> |
| 850 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 850 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 851 | 851 | <?php |
| 852 | 852 | /** |
| 853 | 853 | * Fires while rendering credit card billing form, before address fields. |
@@ -856,75 +856,75 @@ discard block |
||
| 856 | 856 | * |
| 857 | 857 | * @param int $form_id The form ID. |
| 858 | 858 | */ |
| 859 | - do_action( 'give_cc_billing_top' ); |
|
| 859 | + do_action('give_cc_billing_top'); |
|
| 860 | 860 | ?> |
| 861 | 861 | <p id="give-card-address-wrap" class="form-row form-row-two-thirds"> |
| 862 | 862 | <label for="card_address" class="give-label"> |
| 863 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
| 863 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
| 864 | 864 | <?php |
| 865 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 865 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 866 | 866 | <span class="give-required-indicator">*</span> |
| 867 | 867 | <?php endif; ?> |
| 868 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
| 868 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
| 869 | 869 | </label> |
| 870 | 870 | |
| 871 | 871 | <input |
| 872 | 872 | type="text" |
| 873 | 873 | id="card_address" |
| 874 | 874 | name="card_address" |
| 875 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 876 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
| 877 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 878 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 875 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 876 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
| 877 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 878 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 879 | 879 | /> |
| 880 | 880 | </p> |
| 881 | 881 | |
| 882 | 882 | <p id="give-card-address-2-wrap" class="form-row form-row-one-third"> |
| 883 | 883 | <label for="card_address_2" class="give-label"> |
| 884 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
| 885 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 884 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
| 885 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 886 | 886 | <span class="give-required-indicator">*</span> |
| 887 | 887 | <?php endif; ?> |
| 888 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
| 888 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
| 889 | 889 | </label> |
| 890 | 890 | |
| 891 | 891 | <input |
| 892 | 892 | type="text" |
| 893 | 893 | id="card_address_2" |
| 894 | 894 | name="card_address_2" |
| 895 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 896 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
| 897 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 898 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 895 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 896 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
| 897 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 898 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 899 | 899 | /> |
| 900 | 900 | </p> |
| 901 | 901 | |
| 902 | 902 | <p id="give-card-city-wrap" class="form-row form-row-two-thirds"> |
| 903 | 903 | <label for="card_city" class="give-label"> |
| 904 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
| 905 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 904 | + <?php esc_html_e('City', 'give'); ?> |
|
| 905 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 906 | 906 | <span class="give-required-indicator">*</span> |
| 907 | 907 | <?php endif; ?> |
| 908 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
| 908 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
| 909 | 909 | </label> |
| 910 | 910 | <input |
| 911 | 911 | type="text" |
| 912 | 912 | id="card_city" |
| 913 | 913 | name="card_city" |
| 914 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 915 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
| 916 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 917 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 914 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 915 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
| 916 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 917 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 918 | 918 | /> |
| 919 | 919 | </p> |
| 920 | 920 | |
| 921 | 921 | <p id="give-card-zip-wrap" class="form-row form-row-one-third"> |
| 922 | 922 | <label for="card_zip" class="give-label"> |
| 923 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
| 924 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 923 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
| 924 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 925 | 925 | <span class="give-required-indicator">*</span> |
| 926 | 926 | <?php endif; ?> |
| 927 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
| 927 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
| 928 | 928 | </label> |
| 929 | 929 | |
| 930 | 930 | <input |
@@ -932,39 +932,39 @@ discard block |
||
| 932 | 932 | size="4" |
| 933 | 933 | id="card_zip" |
| 934 | 934 | name="card_zip" |
| 935 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 936 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 937 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 938 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 935 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 936 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
| 937 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 938 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 939 | 939 | /> |
| 940 | 940 | </p> |
| 941 | 941 | |
| 942 | 942 | <p id="give-card-country-wrap" class="form-row form-row-first"> |
| 943 | 943 | <label for="billing_country" class="give-label"> |
| 944 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 945 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 944 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 945 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 946 | 946 | <span class="give-required-indicator">*</span> |
| 947 | 947 | <?php endif; ?> |
| 948 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 948 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 949 | 949 | </label> |
| 950 | 950 | |
| 951 | 951 | <select |
| 952 | 952 | name="billing_country" |
| 953 | 953 | id="billing_country" |
| 954 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 955 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 954 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 955 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 956 | 956 | > |
| 957 | 957 | <?php |
| 958 | 958 | |
| 959 | 959 | $selected_country = give_get_country(); |
| 960 | 960 | |
| 961 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 961 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 962 | 962 | $selected_country = $give_user_info['billing_country']; |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | 965 | $countries = give_get_country_list(); |
| 966 | - foreach ( $countries as $country_code => $country ) { |
|
| 967 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 966 | + foreach ($countries as $country_code => $country) { |
|
| 967 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 968 | 968 | } |
| 969 | 969 | ?> |
| 970 | 970 | </select> |
@@ -972,37 +972,37 @@ discard block |
||
| 972 | 972 | |
| 973 | 973 | <p id="give-card-state-wrap" class="form-row form-row-last"> |
| 974 | 974 | <label for="card_state" class="give-label"> |
| 975 | - <?php esc_html_e( 'State / Province', 'give' ); ?> |
|
| 976 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : ?> |
|
| 975 | + <?php esc_html_e('State / Province', 'give'); ?> |
|
| 976 | + <?php if (give_field_is_required('card_state', $form_id)) : ?> |
|
| 977 | 977 | <span class="give-required-indicator">*</span> |
| 978 | 978 | <?php endif; ?> |
| 979 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The state or province for your billing address.', 'give' ); ?>"></span> |
|
| 979 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The state or province for your billing address.', 'give'); ?>"></span> |
|
| 980 | 980 | </label> |
| 981 | 981 | |
| 982 | 982 | <?php |
| 983 | 983 | $selected_state = give_get_state(); |
| 984 | - $states = give_get_states( $selected_country ); |
|
| 984 | + $states = give_get_states($selected_country); |
|
| 985 | 985 | |
| 986 | - if ( ! empty( $give_user_info['card_state'] ) ) { |
|
| 986 | + if ( ! empty($give_user_info['card_state'])) { |
|
| 987 | 987 | $selected_state = $give_user_info['card_state']; |
| 988 | 988 | } |
| 989 | 989 | |
| 990 | - if ( ! empty( $states ) ) : ?> |
|
| 990 | + if ( ! empty($states)) : ?> |
|
| 991 | 991 | <select |
| 992 | 992 | name="card_state" |
| 993 | 993 | id="card_state" |
| 994 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 995 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ) { |
|
| 994 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 995 | + <?php if (give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : '') { |
|
| 996 | 996 | ; |
| 997 | 997 | } ?>> |
| 998 | 998 | <?php |
| 999 | - foreach ( $states as $state_code => $state ) { |
|
| 1000 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 999 | + foreach ($states as $state_code => $state) { |
|
| 1000 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1001 | 1001 | } |
| 1002 | 1002 | ?> |
| 1003 | 1003 | </select> |
| 1004 | 1004 | <?php else : ?> |
| 1005 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
| 1005 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e('State / Province', 'give'); ?>"/> |
|
| 1006 | 1006 | <?php endif; ?> |
| 1007 | 1007 | </p> |
| 1008 | 1008 | <?php |
@@ -1013,14 +1013,14 @@ discard block |
||
| 1013 | 1013 | * |
| 1014 | 1014 | * @param int $form_id The form ID. |
| 1015 | 1015 | */ |
| 1016 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1016 | + do_action('give_cc_billing_bottom'); |
|
| 1017 | 1017 | ?> |
| 1018 | 1018 | </fieldset> |
| 1019 | 1019 | <?php |
| 1020 | 1020 | echo ob_get_clean(); |
| 1021 | 1021 | } |
| 1022 | 1022 | |
| 1023 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1023 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1024 | 1024 | |
| 1025 | 1025 | |
| 1026 | 1026 | /** |
@@ -1032,26 +1032,26 @@ discard block |
||
| 1032 | 1032 | * |
| 1033 | 1033 | * @return string |
| 1034 | 1034 | */ |
| 1035 | -function give_get_register_fields( $form_id ) { |
|
| 1035 | +function give_get_register_fields($form_id) { |
|
| 1036 | 1036 | |
| 1037 | 1037 | global $user_ID; |
| 1038 | 1038 | |
| 1039 | - if ( is_user_logged_in() ) { |
|
| 1040 | - $user_data = get_userdata( $user_ID ); |
|
| 1039 | + if (is_user_logged_in()) { |
|
| 1040 | + $user_data = get_userdata($user_ID); |
|
| 1041 | 1041 | } |
| 1042 | 1042 | |
| 1043 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1043 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1044 | 1044 | |
| 1045 | 1045 | ob_start(); ?> |
| 1046 | 1046 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
| 1047 | 1047 | |
| 1048 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1048 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1049 | 1049 | <div class="give-login-account-wrap"> |
| 1050 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1051 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1050 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1051 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1052 | 1052 | </p> |
| 1053 | 1053 | <p class="give-loading-text"> |
| 1054 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></p> |
|
| 1054 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></p> |
|
| 1055 | 1055 | </div> |
| 1056 | 1056 | <?php } ?> |
| 1057 | 1057 | |
@@ -1063,15 +1063,15 @@ discard block |
||
| 1063 | 1063 | * |
| 1064 | 1064 | * @param int $form_id The form ID. |
| 1065 | 1065 | */ |
| 1066 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1066 | + do_action('give_register_fields_before', $form_id); |
|
| 1067 | 1067 | ?> |
| 1068 | 1068 | |
| 1069 | 1069 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
| 1070 | 1070 | <legend> |
| 1071 | 1071 | <?php |
| 1072 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
| 1073 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1074 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1072 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
| 1073 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1074 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1075 | 1075 | } |
| 1076 | 1076 | ?> |
| 1077 | 1077 | </legend> |
@@ -1083,42 +1083,42 @@ discard block |
||
| 1083 | 1083 | * |
| 1084 | 1084 | * @param int $form_id The form ID. |
| 1085 | 1085 | */ |
| 1086 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1086 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1087 | 1087 | ?> |
| 1088 | 1088 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third form-row-first"> |
| 1089 | 1089 | <label for="give-user-login-<?php echo $form_id; ?>"> |
| 1090 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1091 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1090 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1091 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1092 | 1092 | <span class="give-required-indicator">*</span> |
| 1093 | 1093 | <?php } ?> |
| 1094 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
| 1094 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
| 1095 | 1095 | </label> |
| 1096 | 1096 | |
| 1097 | - <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" type="text" placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1097 | + <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" type="text" placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1098 | 1098 | </div> |
| 1099 | 1099 | |
| 1100 | 1100 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="form-row form-row-one-third"> |
| 1101 | 1101 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
| 1102 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1103 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1102 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1103 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1104 | 1104 | <span class="give-required-indicator">*</span> |
| 1105 | 1105 | <?php } ?> |
| 1106 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
| 1106 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
| 1107 | 1107 | </label> |
| 1108 | 1108 | |
| 1109 | - <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1109 | + <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e('Password', 'give'); ?>" type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1110 | 1110 | </div> |
| 1111 | 1111 | |
| 1112 | 1112 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" class="give-register-password form-row form-row-one-third"> |
| 1113 | 1113 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
| 1114 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
| 1115 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1114 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
| 1115 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1116 | 1116 | <span class="give-required-indicator">*</span> |
| 1117 | 1117 | <?php } ?> |
| 1118 | - <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
| 1118 | + <span class="give-tooltip give-icon give-icon-question" data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
| 1119 | 1119 | </label> |
| 1120 | 1120 | |
| 1121 | - <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1121 | + <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1122 | 1122 | </div> |
| 1123 | 1123 | <?php |
| 1124 | 1124 | /** |
@@ -1128,7 +1128,7 @@ discard block |
||
| 1128 | 1128 | * |
| 1129 | 1129 | * @param int $form_id The form ID. |
| 1130 | 1130 | */ |
| 1131 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1131 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1132 | 1132 | ?> |
| 1133 | 1133 | </fieldset> |
| 1134 | 1134 | |
@@ -1140,7 +1140,7 @@ discard block |
||
| 1140 | 1140 | * |
| 1141 | 1141 | * @param int $form_id The form ID. |
| 1142 | 1142 | */ |
| 1143 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1143 | + do_action('give_register_fields_after', $form_id); |
|
| 1144 | 1144 | ?> |
| 1145 | 1145 | |
| 1146 | 1146 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | * |
| 1152 | 1152 | * @since 1.7 |
| 1153 | 1153 | */ |
| 1154 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1154 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1155 | 1155 | ?> |
| 1156 | 1156 | |
| 1157 | 1157 | </fieldset> |
@@ -1159,7 +1159,7 @@ discard block |
||
| 1159 | 1159 | echo ob_get_clean(); |
| 1160 | 1160 | } |
| 1161 | 1161 | |
| 1162 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1162 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1163 | 1163 | |
| 1164 | 1164 | /** |
| 1165 | 1165 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1172,31 +1172,31 @@ discard block |
||
| 1172 | 1172 | * |
| 1173 | 1173 | * @return string |
| 1174 | 1174 | */ |
| 1175 | -function give_get_login_fields( $form_id ) { |
|
| 1175 | +function give_get_login_fields($form_id) { |
|
| 1176 | 1176 | |
| 1177 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1178 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1177 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1178 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1179 | 1179 | |
| 1180 | 1180 | ob_start(); |
| 1181 | 1181 | ?> |
| 1182 | 1182 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1183 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
| 1184 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1185 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1183 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
| 1184 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1185 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1186 | 1186 | } ?> |
| 1187 | 1187 | </legend> |
| 1188 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1188 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1189 | 1189 | <p class="give-new-account-link"> |
| 1190 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
| 1191 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
| 1192 | - <?php esc_html_e( 'Register', 'give' ); |
|
| 1193 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1194 | - echo ' ' . esc_html__( 'or checkout as a guest »', 'give' ); |
|
| 1190 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
| 1191 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" data-action="give_checkout_register"> |
|
| 1192 | + <?php esc_html_e('Register', 'give'); |
|
| 1193 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1194 | + echo ' '.esc_html__('or checkout as a guest »', 'give'); |
|
| 1195 | 1195 | } ?> |
| 1196 | 1196 | </a> |
| 1197 | 1197 | </p> |
| 1198 | 1198 | <p class="give-loading-text"> |
| 1199 | - <span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?> </p> |
|
| 1199 | + <span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?> </p> |
|
| 1200 | 1200 | <?php } ?> |
| 1201 | 1201 | <?php |
| 1202 | 1202 | /** |
@@ -1206,40 +1206,40 @@ discard block |
||
| 1206 | 1206 | * |
| 1207 | 1207 | * @param int $form_id The form ID. |
| 1208 | 1208 | */ |
| 1209 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1209 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1210 | 1210 | ?> |
| 1211 | 1211 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first"> |
| 1212 | 1212 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1213 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1214 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1213 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1214 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1215 | 1215 | <span class="give-required-indicator">*</span> |
| 1216 | 1216 | <?php } ?> |
| 1217 | 1217 | </label> |
| 1218 | 1218 | |
| 1219 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1219 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1220 | 1220 | </div> |
| 1221 | 1221 | |
| 1222 | 1222 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" class="give_login_password form-row form-row-last"> |
| 1223 | 1223 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1224 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1225 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1224 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1225 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1226 | 1226 | <span class="give-required-indicator">*</span> |
| 1227 | 1227 | <?php } ?> |
| 1228 | 1228 | </label> |
| 1229 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1229 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1230 | 1230 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1231 | 1231 | </div> |
| 1232 | 1232 | |
| 1233 | 1233 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1234 | 1234 | <span class="give-forgot-password "> |
| 1235 | - <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
| 1235 | + <a href="<?php echo wp_lostpassword_url() ?>" target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
| 1236 | 1236 | </span> |
| 1237 | 1237 | </div> |
| 1238 | 1238 | |
| 1239 | 1239 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1240 | - <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
| 1241 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1242 | - <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
| 1240 | + <input type="submit" class="give-submit give-btn button" name="give_login_submit" value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
| 1241 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1242 | + <input type="button" data-action="give_cancel_login" class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
| 1243 | 1243 | <?php } ?> |
| 1244 | 1244 | <span class="give-loading-animation"></span> |
| 1245 | 1245 | </div> |
@@ -1251,14 +1251,14 @@ discard block |
||
| 1251 | 1251 | * |
| 1252 | 1252 | * @param int $form_id The form ID. |
| 1253 | 1253 | */ |
| 1254 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1254 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1255 | 1255 | ?> |
| 1256 | 1256 | </fieldset><!--end #give-login-fields--> |
| 1257 | 1257 | <?php |
| 1258 | 1258 | echo ob_get_clean(); |
| 1259 | 1259 | } |
| 1260 | 1260 | |
| 1261 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1261 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1262 | 1262 | |
| 1263 | 1263 | /** |
| 1264 | 1264 | * Payment Mode Select. |
@@ -1274,7 +1274,7 @@ discard block |
||
| 1274 | 1274 | * |
| 1275 | 1275 | * @return void |
| 1276 | 1276 | */ |
| 1277 | -function give_payment_mode_select( $form_id ) { |
|
| 1277 | +function give_payment_mode_select($form_id) { |
|
| 1278 | 1278 | |
| 1279 | 1279 | $gateways = give_get_enabled_payment_gateways(); |
| 1280 | 1280 | |
@@ -1285,10 +1285,10 @@ discard block |
||
| 1285 | 1285 | * |
| 1286 | 1286 | * @param int $form_id The form ID. |
| 1287 | 1287 | */ |
| 1288 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1288 | + do_action('give_payment_mode_top', $form_id); |
|
| 1289 | 1289 | ?> |
| 1290 | 1290 | |
| 1291 | - <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) echo 'style="display: none;"'; ?>> |
|
| 1291 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) echo 'style="display: none;"'; ?>> |
|
| 1292 | 1292 | <?php |
| 1293 | 1293 | /** |
| 1294 | 1294 | * Fires while selecting payment gateways, before the wrap div. |
@@ -1297,12 +1297,12 @@ discard block |
||
| 1297 | 1297 | * |
| 1298 | 1298 | * @param int $form_id The form ID. |
| 1299 | 1299 | */ |
| 1300 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1300 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1301 | 1301 | ?> |
| 1302 | - <legend class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?></legend> |
|
| 1302 | + <legend class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?></legend> |
|
| 1303 | 1303 | |
| 1304 | 1304 | <div id="give-payment-mode-wrap"> |
| 1305 | - <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e( 'Loading...', 'give' ); ?></span> |
|
| 1305 | + <span class="give-loading-text"><span class="give-loading-animation"></span> <?php esc_html_e('Loading...', 'give'); ?></span> |
|
| 1306 | 1306 | |
| 1307 | 1307 | <?php |
| 1308 | 1308 | /** |
@@ -1310,19 +1310,19 @@ discard block |
||
| 1310 | 1310 | * |
| 1311 | 1311 | * @since 1.7 |
| 1312 | 1312 | */ |
| 1313 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1313 | + do_action('give_payment_mode_before_gateways') |
|
| 1314 | 1314 | ?> |
| 1315 | 1315 | <ul id="give-gateway-radio-list"> |
| 1316 | 1316 | <?php |
| 1317 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1318 | - $selected_gateway = give_get_default_gateway( $form_id ); |
|
| 1319 | - $selected_gateway = isset( $_REQUEST['payment_mode'] ) ? $_REQUEST['payment_mode'] : $selected_gateway; |
|
| 1320 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1317 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1318 | + $selected_gateway = give_get_default_gateway($form_id); |
|
| 1319 | + $selected_gateway = isset($_REQUEST['payment_mode']) ? $_REQUEST['payment_mode'] : $selected_gateway; |
|
| 1320 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1321 | 1321 | $checked_class = $checked ? ' give-gateway-option-selected' : ''; |
| 1322 | 1322 | ?> |
| 1323 | 1323 | <li> |
| 1324 | - <input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1325 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" class="give-gateway-option<?php echo $checked_class; ?>" id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1324 | + <input type="radio" name="payment-mode" class="give-gateway" id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1325 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" class="give-gateway-option<?php echo $checked_class; ?>" id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1326 | 1326 | </li> |
| 1327 | 1327 | <?php |
| 1328 | 1328 | endforeach; |
@@ -1334,7 +1334,7 @@ discard block |
||
| 1334 | 1334 | * |
| 1335 | 1335 | * @since 1.7 |
| 1336 | 1336 | */ |
| 1337 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1337 | + do_action('give_payment_mode_after_gateways'); |
|
| 1338 | 1338 | ?> |
| 1339 | 1339 | </div> |
| 1340 | 1340 | <?php |
@@ -1345,7 +1345,7 @@ discard block |
||
| 1345 | 1345 | * |
| 1346 | 1346 | * @param int $form_id The form ID. |
| 1347 | 1347 | */ |
| 1348 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1348 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1349 | 1349 | ?> |
| 1350 | 1350 | </fieldset> |
| 1351 | 1351 | |
@@ -1357,7 +1357,7 @@ discard block |
||
| 1357 | 1357 | * |
| 1358 | 1358 | * @param int $form_id The form ID. |
| 1359 | 1359 | */ |
| 1360 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1360 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1361 | 1361 | ?> |
| 1362 | 1362 | |
| 1363 | 1363 | <div id="give_purchase_form_wrap"> |
@@ -1368,7 +1368,7 @@ discard block |
||
| 1368 | 1368 | * |
| 1369 | 1369 | * @since 1.7 |
| 1370 | 1370 | */ |
| 1371 | - do_action( 'give_donation_form', $form_id ); |
|
| 1371 | + do_action('give_donation_form', $form_id); |
|
| 1372 | 1372 | ?> |
| 1373 | 1373 | |
| 1374 | 1374 | </div> |
@@ -1379,10 +1379,10 @@ discard block |
||
| 1379 | 1379 | * |
| 1380 | 1380 | * @since 1.7 |
| 1381 | 1381 | */ |
| 1382 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1382 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1383 | 1383 | } |
| 1384 | 1384 | |
| 1385 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
| 1385 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
| 1386 | 1386 | |
| 1387 | 1387 | /** |
| 1388 | 1388 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1395,25 +1395,25 @@ discard block |
||
| 1395 | 1395 | * |
| 1396 | 1396 | * @return void|bool |
| 1397 | 1397 | */ |
| 1398 | -function give_terms_agreement( $form_id ) { |
|
| 1399 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 1398 | +function give_terms_agreement($form_id) { |
|
| 1399 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 1400 | 1400 | |
| 1401 | 1401 | // Bailout if per form and global term and conditions is not setup. |
| 1402 | - if ( 'yes' !== $form_option ) { |
|
| 1402 | + if ('yes' !== $form_option) { |
|
| 1403 | 1403 | return false; |
| 1404 | 1404 | } |
| 1405 | 1405 | |
| 1406 | - $label = get_post_meta( $form_id, '_give_agree_label', true ); |
|
| 1407 | - $terms = get_post_meta( $form_id, '_give_agree_text', true ); |
|
| 1406 | + $label = get_post_meta($form_id, '_give_agree_label', true); |
|
| 1407 | + $terms = get_post_meta($form_id, '_give_agree_text', true); |
|
| 1408 | 1408 | |
| 1409 | 1409 | // Set term and conditions label and text on basis of per form and global setting. |
| 1410 | 1410 | // $label = ( $label = get_post_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
| 1411 | 1411 | // $terms = ( $terms = get_post_meta( $form_id, '_give_agree_text', true ) ) ? $terms : give_get_option( 'agreement_text', '' ); |
| 1412 | 1412 | |
| 1413 | 1413 | // Bailout: Check if term and conditions text is empty or not. |
| 1414 | - if ( empty( $terms ) ) { |
|
| 1415 | - if ( is_user_logged_in() && current_user_can( 'manage_options' ) ) { |
|
| 1416 | - echo sprintf( __( 'Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), admin_url( 'post.php?post=' . $form_id . '&action=edit' ) ); |
|
| 1414 | + if (empty($terms)) { |
|
| 1415 | + if (is_user_logged_in() && current_user_can('manage_options')) { |
|
| 1416 | + echo sprintf(__('Please enter term and conditions in <a href="%s">this form\'s settings</a>.', 'give'), admin_url('post.php?post='.$form_id.'&action=edit')); |
|
| 1417 | 1417 | } |
| 1418 | 1418 | |
| 1419 | 1419 | return false; |
@@ -1421,7 +1421,7 @@ discard block |
||
| 1421 | 1421 | |
| 1422 | 1422 | ?> |
| 1423 | 1423 | <fieldset id="give_terms_agreement"> |
| 1424 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1424 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1425 | 1425 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1426 | 1426 | <?php |
| 1427 | 1427 | /** |
@@ -1429,20 +1429,20 @@ discard block |
||
| 1429 | 1429 | * |
| 1430 | 1430 | * @since 1.0 |
| 1431 | 1431 | */ |
| 1432 | - do_action( 'give_before_terms' ); |
|
| 1432 | + do_action('give_before_terms'); |
|
| 1433 | 1433 | |
| 1434 | - echo wpautop( stripslashes( $terms ) ); |
|
| 1434 | + echo wpautop(stripslashes($terms)); |
|
| 1435 | 1435 | /** |
| 1436 | 1436 | * Fires while rendering terms of agreement, after the fields. |
| 1437 | 1437 | * |
| 1438 | 1438 | * @since 1.0 |
| 1439 | 1439 | */ |
| 1440 | - do_action( 'give_after_terms' ); |
|
| 1440 | + do_action('give_after_terms'); |
|
| 1441 | 1441 | ?> |
| 1442 | 1442 | </div> |
| 1443 | 1443 | <div id="give_show_terms"> |
| 1444 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1445 | - <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1444 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1445 | + <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1446 | 1446 | </div> |
| 1447 | 1447 | |
| 1448 | 1448 | <input name="give_agree_to_terms" class="required" type="checkbox" id="give_agree_to_terms" value="1"/> |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | <?php |
| 1453 | 1453 | } |
| 1454 | 1454 | |
| 1455 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1455 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1456 | 1456 | |
| 1457 | 1457 | /** |
| 1458 | 1458 | * Checkout Final Total. |
@@ -1465,27 +1465,27 @@ discard block |
||
| 1465 | 1465 | * |
| 1466 | 1466 | * @return void |
| 1467 | 1467 | */ |
| 1468 | -function give_checkout_final_total( $form_id ) { |
|
| 1468 | +function give_checkout_final_total($form_id) { |
|
| 1469 | 1469 | |
| 1470 | - if ( isset( $_POST['give_total'] ) ) { |
|
| 1471 | - $total = apply_filters( 'give_donation_total', $_POST['give_total'] ); |
|
| 1470 | + if (isset($_POST['give_total'])) { |
|
| 1471 | + $total = apply_filters('give_donation_total', $_POST['give_total']); |
|
| 1472 | 1472 | } else { |
| 1473 | 1473 | //default total. |
| 1474 | - $total = give_get_default_form_amount( $form_id ); |
|
| 1474 | + $total = give_get_default_form_amount($form_id); |
|
| 1475 | 1475 | } |
| 1476 | 1476 | //Only proceed if give_total available. |
| 1477 | - if ( empty( $total ) ) { |
|
| 1477 | + if (empty($total)) { |
|
| 1478 | 1478 | return; |
| 1479 | 1479 | } |
| 1480 | 1480 | ?> |
| 1481 | 1481 | <p id="give-final-total-wrap" class="form-wrap "> |
| 1482 | - <span class="give-donation-total-label"><?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?></span> |
|
| 1483 | - <span class="give-final-total-amount" data-total="<?php echo give_format_amount( $total ); ?>"><?php echo give_currency_filter( give_format_amount( $total ) ); ?></span> |
|
| 1482 | + <span class="give-donation-total-label"><?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?></span> |
|
| 1483 | + <span class="give-final-total-amount" data-total="<?php echo give_format_amount($total); ?>"><?php echo give_currency_filter(give_format_amount($total)); ?></span> |
|
| 1484 | 1484 | </p> |
| 1485 | 1485 | <?php |
| 1486 | 1486 | } |
| 1487 | 1487 | |
| 1488 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1488 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1489 | 1489 | |
| 1490 | 1490 | /** |
| 1491 | 1491 | * Renders the Checkout Submit section. |
@@ -1496,7 +1496,7 @@ discard block |
||
| 1496 | 1496 | * |
| 1497 | 1497 | * @return void |
| 1498 | 1498 | */ |
| 1499 | -function give_checkout_submit( $form_id ) { |
|
| 1499 | +function give_checkout_submit($form_id) { |
|
| 1500 | 1500 | ?> |
| 1501 | 1501 | <fieldset id="give_purchase_submit"> |
| 1502 | 1502 | <?php |
@@ -1505,24 +1505,24 @@ discard block |
||
| 1505 | 1505 | * |
| 1506 | 1506 | * @since 1.7 |
| 1507 | 1507 | */ |
| 1508 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
| 1508 | + do_action('give_donation_form_before_submit', $form_id); |
|
| 1509 | 1509 | |
| 1510 | - give_checkout_hidden_fields( $form_id ); |
|
| 1510 | + give_checkout_hidden_fields($form_id); |
|
| 1511 | 1511 | |
| 1512 | - echo give_checkout_button_purchase( $form_id ); |
|
| 1512 | + echo give_checkout_button_purchase($form_id); |
|
| 1513 | 1513 | |
| 1514 | 1514 | /** |
| 1515 | 1515 | * Fire after donation form submit. |
| 1516 | 1516 | * |
| 1517 | 1517 | * @since 1.7 |
| 1518 | 1518 | */ |
| 1519 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
| 1519 | + do_action('give_donation_form_after_submit', $form_id); |
|
| 1520 | 1520 | ?> |
| 1521 | 1521 | </fieldset> |
| 1522 | 1522 | <?php |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
| 1525 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
| 1526 | 1526 | |
| 1527 | 1527 | /** |
| 1528 | 1528 | * Give Checkout Button. |
@@ -1535,17 +1535,17 @@ discard block |
||
| 1535 | 1535 | * |
| 1536 | 1536 | * @return string |
| 1537 | 1537 | */ |
| 1538 | -function give_checkout_button_purchase( $form_id ) { |
|
| 1538 | +function give_checkout_button_purchase($form_id) { |
|
| 1539 | 1539 | |
| 1540 | - $display_label_field = get_post_meta( $form_id, '_give_checkout_label', true ); |
|
| 1541 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1540 | + $display_label_field = get_post_meta($form_id, '_give_checkout_label', true); |
|
| 1541 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1542 | 1542 | ob_start(); ?> |
| 1543 | 1543 | <div class="give-submit-button-wrap give-clearfix"> |
| 1544 | 1544 | <input type="submit" class="give-submit give-btn" id="give-purchase-button" name="give-purchase" value="<?php echo $display_label; ?>"/> |
| 1545 | 1545 | <span class="give-loading-animation"></span> |
| 1546 | 1546 | </div> |
| 1547 | 1547 | <?php |
| 1548 | - return apply_filters( 'give_checkout_button_purchase', ob_get_clean(), $form_id ); |
|
| 1548 | + return apply_filters('give_checkout_button_purchase', ob_get_clean(), $form_id); |
|
| 1549 | 1549 | } |
| 1550 | 1550 | |
| 1551 | 1551 | /** |
@@ -1559,18 +1559,18 @@ discard block |
||
| 1559 | 1559 | * |
| 1560 | 1560 | * @return void |
| 1561 | 1561 | */ |
| 1562 | -function give_agree_to_terms_js( $form_id ) { |
|
| 1562 | +function give_agree_to_terms_js($form_id) { |
|
| 1563 | 1563 | |
| 1564 | - $form_option = get_post_meta( $form_id, '_give_terms_option', true ); |
|
| 1564 | + $form_option = get_post_meta($form_id, '_give_terms_option', true); |
|
| 1565 | 1565 | |
| 1566 | - if ( $form_option === 'yes' ) { |
|
| 1566 | + if ($form_option === 'yes') { |
|
| 1567 | 1567 | ?> |
| 1568 | 1568 | <script type="text/javascript"> |
| 1569 | 1569 | jQuery(document).ready(function ($) { |
| 1570 | - $('body').on('click', '.give_terms_links-<?php echo $form_id;?>', function (e) { |
|
| 1570 | + $('body').on('click', '.give_terms_links-<?php echo $form_id; ?>', function (e) { |
|
| 1571 | 1571 | e.preventDefault(); |
| 1572 | - $('.give_terms-<?php echo $form_id;?>').slideToggle(); |
|
| 1573 | - $('.give_terms_links-<?php echo $form_id;?>').toggle(); |
|
| 1572 | + $('.give_terms-<?php echo $form_id; ?>').slideToggle(); |
|
| 1573 | + $('.give_terms_links-<?php echo $form_id; ?>').toggle(); |
|
| 1574 | 1574 | return false; |
| 1575 | 1575 | }); |
| 1576 | 1576 | }); |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | } |
| 1580 | 1580 | } |
| 1581 | 1581 | |
| 1582 | -add_action( 'give_checkout_form_top', 'give_agree_to_terms_js', 10, 2 ); |
|
| 1582 | +add_action('give_checkout_form_top', 'give_agree_to_terms_js', 10, 2); |
|
| 1583 | 1583 | |
| 1584 | 1584 | /** |
| 1585 | 1585 | * Show Give Goals. |
@@ -1593,17 +1593,17 @@ discard block |
||
| 1593 | 1593 | * |
| 1594 | 1594 | * @return mixed |
| 1595 | 1595 | */ |
| 1596 | -function give_show_goal_progress( $form_id, $args ) { |
|
| 1596 | +function give_show_goal_progress($form_id, $args) { |
|
| 1597 | 1597 | |
| 1598 | 1598 | ob_start(); |
| 1599 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1599 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1600 | 1600 | |
| 1601 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
| 1601 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
| 1602 | 1602 | |
| 1603 | 1603 | return true; |
| 1604 | 1604 | } |
| 1605 | 1605 | |
| 1606 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1606 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1607 | 1607 | |
| 1608 | 1608 | /** |
| 1609 | 1609 | * Adds Actions to Render Form Content. |
@@ -1615,19 +1615,19 @@ discard block |
||
| 1615 | 1615 | * |
| 1616 | 1616 | * @return void |
| 1617 | 1617 | */ |
| 1618 | -function give_form_content( $form_id, $args ) { |
|
| 1618 | +function give_form_content($form_id, $args) { |
|
| 1619 | 1619 | |
| 1620 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
| 1620 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
| 1621 | 1621 | ? $args['show_content'] |
| 1622 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
| 1622 | + : get_post_meta($form_id, '_give_content_option', true); |
|
| 1623 | 1623 | |
| 1624 | - if ( $show_content !== 'none' ) { |
|
| 1624 | + if ($show_content !== 'none') { |
|
| 1625 | 1625 | //add action according to value. |
| 1626 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1626 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1627 | 1627 | } |
| 1628 | 1628 | } |
| 1629 | 1629 | |
| 1630 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1630 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1631 | 1631 | |
| 1632 | 1632 | /** |
| 1633 | 1633 | * Renders Post Form Content. |
@@ -1641,24 +1641,24 @@ discard block |
||
| 1641 | 1641 | * |
| 1642 | 1642 | * @return void |
| 1643 | 1643 | */ |
| 1644 | -function give_form_display_content( $form_id, $args ) { |
|
| 1644 | +function give_form_display_content($form_id, $args) { |
|
| 1645 | 1645 | |
| 1646 | - $content = wpautop( get_post_meta( $form_id, '_give_form_content', true ) ); |
|
| 1647 | - $show_content = ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) |
|
| 1646 | + $content = wpautop(get_post_meta($form_id, '_give_form_content', true)); |
|
| 1647 | + $show_content = (isset($args['show_content']) && ! empty($args['show_content'])) |
|
| 1648 | 1648 | ? $args['show_content'] |
| 1649 | - : get_post_meta( $form_id, '_give_content_option', true ); |
|
| 1649 | + : get_post_meta($form_id, '_give_content_option', true); |
|
| 1650 | 1650 | |
| 1651 | - if ( give_get_option( 'disable_the_content_filter' ) !== 'on' ) { |
|
| 1652 | - $content = apply_filters( 'the_content', $content ); |
|
| 1651 | + if (give_get_option('disable_the_content_filter') !== 'on') { |
|
| 1652 | + $content = apply_filters('the_content', $content); |
|
| 1653 | 1653 | } |
| 1654 | 1654 | |
| 1655 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap" >' . $content . '</div>'; |
|
| 1655 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap" >'.$content.'</div>'; |
|
| 1656 | 1656 | |
| 1657 | - echo apply_filters( 'give_form_content_output', $output ); |
|
| 1657 | + echo apply_filters('give_form_content_output', $output); |
|
| 1658 | 1658 | |
| 1659 | 1659 | //remove action to prevent content output on addition forms on page. |
| 1660 | 1660 | //@see: https://github.com/WordImpress/Give/issues/634. |
| 1661 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1661 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1662 | 1662 | } |
| 1663 | 1663 | |
| 1664 | 1664 | /** |
@@ -1670,7 +1670,7 @@ discard block |
||
| 1670 | 1670 | * |
| 1671 | 1671 | * @return void |
| 1672 | 1672 | */ |
| 1673 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1673 | +function give_checkout_hidden_fields($form_id) { |
|
| 1674 | 1674 | |
| 1675 | 1675 | /** |
| 1676 | 1676 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1679,13 +1679,13 @@ discard block |
||
| 1679 | 1679 | * |
| 1680 | 1680 | * @param int $form_id The form ID. |
| 1681 | 1681 | */ |
| 1682 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1682 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1683 | 1683 | |
| 1684 | - if ( is_user_logged_in() ) { ?> |
|
| 1684 | + if (is_user_logged_in()) { ?> |
|
| 1685 | 1685 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1686 | 1686 | <?php } ?> |
| 1687 | 1687 | <input type="hidden" name="give_action" value="purchase"/> |
| 1688 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1688 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1689 | 1689 | <?php |
| 1690 | 1690 | /** |
| 1691 | 1691 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1694,7 +1694,7 @@ discard block |
||
| 1694 | 1694 | * |
| 1695 | 1695 | * @param int $form_id The form ID. |
| 1696 | 1696 | */ |
| 1697 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1697 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1698 | 1698 | |
| 1699 | 1699 | } |
| 1700 | 1700 | |
@@ -1709,20 +1709,20 @@ discard block |
||
| 1709 | 1709 | * |
| 1710 | 1710 | * @return string $content Filtered content. |
| 1711 | 1711 | */ |
| 1712 | -function give_filter_success_page_content( $content ) { |
|
| 1712 | +function give_filter_success_page_content($content) { |
|
| 1713 | 1713 | |
| 1714 | 1714 | $give_options = give_get_settings(); |
| 1715 | 1715 | |
| 1716 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1717 | - if ( has_filter( 'give_donation_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1718 | - $content = apply_filters( 'give_donation_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1716 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1717 | + if (has_filter('give_donation_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1718 | + $content = apply_filters('give_donation_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1719 | 1719 | } |
| 1720 | 1720 | } |
| 1721 | 1721 | |
| 1722 | 1722 | return $content; |
| 1723 | 1723 | } |
| 1724 | 1724 | |
| 1725 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1725 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1726 | 1726 | |
| 1727 | 1727 | /** |
| 1728 | 1728 | * Test Mode Frontend Warning. |
@@ -1733,14 +1733,14 @@ discard block |
||
| 1733 | 1733 | */ |
| 1734 | 1734 | function give_test_mode_frontend_warning() { |
| 1735 | 1735 | |
| 1736 | - $test_mode = give_get_option( 'test_mode' ); |
|
| 1736 | + $test_mode = give_get_option('test_mode'); |
|
| 1737 | 1737 | |
| 1738 | - if ( $test_mode == 'on' ) { |
|
| 1739 | - echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>' . esc_html__( 'Notice:', 'give' ) . '</strong> ' . esc_html__( 'Test mode is enabled. While in test mode no live donations are processed.', 'give' ) . '</p></div>'; |
|
| 1738 | + if ($test_mode == 'on') { |
|
| 1739 | + echo '<div class="give_error give_warning" id="give_error_test_mode"><p><strong>'.esc_html__('Notice:', 'give').'</strong> '.esc_html__('Test mode is enabled. While in test mode no live donations are processed.', 'give').'</p></div>'; |
|
| 1740 | 1740 | } |
| 1741 | 1741 | } |
| 1742 | 1742 | |
| 1743 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1743 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1744 | 1744 | |
| 1745 | 1745 | /** |
| 1746 | 1746 | * Members-only Form. |
@@ -1754,21 +1754,21 @@ discard block |
||
| 1754 | 1754 | * |
| 1755 | 1755 | * @return string |
| 1756 | 1756 | */ |
| 1757 | -function give_members_only_form( $final_output, $args ) { |
|
| 1757 | +function give_members_only_form($final_output, $args) { |
|
| 1758 | 1758 | |
| 1759 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1759 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1760 | 1760 | |
| 1761 | 1761 | //Sanity Check: Must have form_id & not be logged in. |
| 1762 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1762 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1763 | 1763 | return $final_output; |
| 1764 | 1764 | } |
| 1765 | 1765 | |
| 1766 | 1766 | //Logged in only and Register / Login set to none. |
| 1767 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1767 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 1768 | 1768 | |
| 1769 | - $final_output = give_output_error( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 1769 | + $final_output = give_output_error(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 1770 | 1770 | |
| 1771 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 1771 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 1772 | 1772 | |
| 1773 | 1773 | } |
| 1774 | 1774 | |
@@ -1776,4 +1776,4 @@ discard block |
||
| 1776 | 1776 | |
| 1777 | 1777 | } |
| 1778 | 1778 | |
| 1779 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 1779 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
@@ -1001,8 +1001,11 @@ discard block |
||
| 1001 | 1001 | } |
| 1002 | 1002 | ?> |
| 1003 | 1003 | </select> |
| 1004 | - <?php else : ?> |
|
| 1005 | - <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); ?>"/> |
|
| 1004 | + <?php else { |
|
| 1005 | + : ?> |
|
| 1006 | + <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" placeholder="<?php esc_attr_e( 'State / Province', 'give' ); |
|
| 1007 | +} |
|
| 1008 | +?>"/> |
|
| 1006 | 1009 | <?php endif; ?> |
| 1007 | 1010 | </p> |
| 1008 | 1011 | <?php |
@@ -1288,7 +1291,10 @@ discard block |
||
| 1288 | 1291 | do_action( 'give_payment_mode_top', $form_id ); |
| 1289 | 1292 | ?> |
| 1290 | 1293 | |
| 1291 | - <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) echo 'style="display: none;"'; ?>> |
|
| 1294 | + <fieldset id="give-payment-mode-select" <?php if ( count($gateways) <= 1 ) { |
|
| 1295 | + echo 'style="display: none;"'; |
|
| 1296 | +} |
|
| 1297 | +?>> |
|
| 1292 | 1298 | <?php |
| 1293 | 1299 | /** |
| 1294 | 1300 | * Fires while selecting payment gateways, before the wrap div. |
@@ -337,7 +337,7 @@ |
||
| 337 | 337 | * |
| 338 | 338 | * @since 1.0 |
| 339 | 339 | * @uses Give()->session->get() |
| 340 | - * @return mixed array | false |
|
| 340 | + * @return string array | false |
|
| 341 | 341 | */ |
| 342 | 342 | function give_get_purchase_session() { |
| 343 | 343 | return Give()->session->get( 'give_purchase' ); |
@@ -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 | |
| 26 | 26 | $ret = give_get_option('test_mode', false); |
| 27 | 27 | |
| 28 | - return (bool) apply_filters( 'give_is_test_mode', $ret ); |
|
| 28 | + return (bool) apply_filters('give_is_test_mode', $ret); |
|
| 29 | 29 | |
| 30 | 30 | } |
| 31 | 31 | |
@@ -37,9 +37,9 @@ discard block |
||
| 37 | 37 | */ |
| 38 | 38 | function give_get_currency() { |
| 39 | 39 | |
| 40 | - $currency = give_get_option( 'currency', 'USD' ); |
|
| 40 | + $currency = give_get_option('currency', 'USD'); |
|
| 41 | 41 | |
| 42 | - return apply_filters( 'give_currency', $currency ); |
|
| 42 | + return apply_filters('give_currency', $currency); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /** |
@@ -51,9 +51,9 @@ discard block |
||
| 51 | 51 | */ |
| 52 | 52 | function give_get_currency_position() { |
| 53 | 53 | |
| 54 | - $currency_pos = give_get_option( 'currency_position', 'before' ); |
|
| 54 | + $currency_pos = give_get_option('currency_position', 'before'); |
|
| 55 | 55 | |
| 56 | - return apply_filters( 'give_currency_position', $currency_pos ); |
|
| 56 | + return apply_filters('give_currency_position', $currency_pos); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | |
@@ -66,39 +66,39 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | function give_get_currencies() { |
| 68 | 68 | $currencies = array( |
| 69 | - 'USD' => esc_html__( 'US Dollars ($)', 'give' ), |
|
| 70 | - 'EUR' => esc_html__( 'Euros (€)', 'give' ), |
|
| 71 | - 'GBP' => esc_html__( 'Pounds Sterling (£)', 'give' ), |
|
| 72 | - 'AUD' => esc_html__( 'Australian Dollars ($)', 'give' ), |
|
| 73 | - 'BRL' => esc_html__( 'Brazilian Real (R$)', 'give' ), |
|
| 74 | - 'CAD' => esc_html__( 'Canadian Dollars ($)', 'give' ), |
|
| 75 | - 'CZK' => esc_html__( 'Czech Koruna (Kč)', 'give' ), |
|
| 76 | - 'DKK' => esc_html__( 'Danish Krone (kr)', 'give' ), |
|
| 77 | - 'HKD' => esc_html__( 'Hong Kong Dollar ($)', 'give' ), |
|
| 78 | - 'HUF' => esc_html__( 'Hungarian Forint (Ft)', 'give' ), |
|
| 79 | - 'ILS' => esc_html__( 'Israeli Shekel (₪)', 'give' ), |
|
| 80 | - 'JPY' => esc_html__( 'Japanese Yen (¥)', 'give' ), |
|
| 81 | - 'MYR' => esc_html__( 'Malaysian Ringgits (RM)', 'give' ), |
|
| 82 | - 'MXN' => esc_html__( 'Mexican Peso ($)', 'give' ), |
|
| 83 | - 'MAD' => esc_html__( 'Moroccan Dirham (.د.م)', 'give' ), |
|
| 84 | - 'NZD' => esc_html__( 'New Zealand Dollar ($)', 'give' ), |
|
| 85 | - 'NOK' => esc_html__( 'Norwegian Krone (Kr.)', 'give' ), |
|
| 86 | - 'PHP' => esc_html__( 'Philippine Pesos (₱)', 'give' ), |
|
| 87 | - 'PLN' => esc_html__( 'Polish Zloty (zł)', 'give' ), |
|
| 88 | - 'SGD' => esc_html__( 'Singapore Dollar ($)', 'give' ), |
|
| 89 | - 'KRW' => esc_html__( 'South Korean Won (₩)', 'give' ), |
|
| 90 | - 'ZAR' => esc_html__( 'South African Rand (R)', 'give' ), |
|
| 91 | - 'SEK' => esc_html__( 'Swedish Krona (kr)', 'give' ), |
|
| 92 | - 'CHF' => esc_html__( 'Swiss Franc (CHF)', 'give' ), |
|
| 93 | - 'TWD' => esc_html__( 'Taiwan New Dollars (NT$)', 'give' ), |
|
| 94 | - 'THB' => esc_html__( 'Thai Baht (฿)', 'give' ), |
|
| 95 | - 'INR' => esc_html__( 'Indian Rupee (₹)', 'give' ), |
|
| 96 | - 'TRY' => esc_html__( 'Turkish Lira (₺)', 'give' ), |
|
| 97 | - 'RIAL' => esc_html__( 'Iranian Rial (﷼)', 'give' ), |
|
| 98 | - 'RUB' => esc_html__( 'Russian Rubles (руб)', 'give' ) |
|
| 69 | + 'USD' => esc_html__('US Dollars ($)', 'give'), |
|
| 70 | + 'EUR' => esc_html__('Euros (€)', 'give'), |
|
| 71 | + 'GBP' => esc_html__('Pounds Sterling (£)', 'give'), |
|
| 72 | + 'AUD' => esc_html__('Australian Dollars ($)', 'give'), |
|
| 73 | + 'BRL' => esc_html__('Brazilian Real (R$)', 'give'), |
|
| 74 | + 'CAD' => esc_html__('Canadian Dollars ($)', 'give'), |
|
| 75 | + 'CZK' => esc_html__('Czech Koruna (Kč)', 'give'), |
|
| 76 | + 'DKK' => esc_html__('Danish Krone (kr)', 'give'), |
|
| 77 | + 'HKD' => esc_html__('Hong Kong Dollar ($)', 'give'), |
|
| 78 | + 'HUF' => esc_html__('Hungarian Forint (Ft)', 'give'), |
|
| 79 | + 'ILS' => esc_html__('Israeli Shekel (₪)', 'give'), |
|
| 80 | + 'JPY' => esc_html__('Japanese Yen (¥)', 'give'), |
|
| 81 | + 'MYR' => esc_html__('Malaysian Ringgits (RM)', 'give'), |
|
| 82 | + 'MXN' => esc_html__('Mexican Peso ($)', 'give'), |
|
| 83 | + 'MAD' => esc_html__('Moroccan Dirham (.د.م)', 'give'), |
|
| 84 | + 'NZD' => esc_html__('New Zealand Dollar ($)', 'give'), |
|
| 85 | + 'NOK' => esc_html__('Norwegian Krone (Kr.)', 'give'), |
|
| 86 | + 'PHP' => esc_html__('Philippine Pesos (₱)', 'give'), |
|
| 87 | + 'PLN' => esc_html__('Polish Zloty (zł)', 'give'), |
|
| 88 | + 'SGD' => esc_html__('Singapore Dollar ($)', 'give'), |
|
| 89 | + 'KRW' => esc_html__('South Korean Won (₩)', 'give'), |
|
| 90 | + 'ZAR' => esc_html__('South African Rand (R)', 'give'), |
|
| 91 | + 'SEK' => esc_html__('Swedish Krona (kr)', 'give'), |
|
| 92 | + 'CHF' => esc_html__('Swiss Franc (CHF)', 'give'), |
|
| 93 | + 'TWD' => esc_html__('Taiwan New Dollars (NT$)', 'give'), |
|
| 94 | + 'THB' => esc_html__('Thai Baht (฿)', 'give'), |
|
| 95 | + 'INR' => esc_html__('Indian Rupee (₹)', 'give'), |
|
| 96 | + 'TRY' => esc_html__('Turkish Lira (₺)', 'give'), |
|
| 97 | + 'RIAL' => esc_html__('Iranian Rial (﷼)', 'give'), |
|
| 98 | + 'RUB' => esc_html__('Russian Rubles (руб)', 'give') |
|
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - return apply_filters( 'give_currencies', $currencies ); |
|
| 101 | + return apply_filters('give_currencies', $currencies); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -113,12 +113,12 @@ discard block |
||
| 113 | 113 | * |
| 114 | 114 | * @return string The symbol to use for the currency |
| 115 | 115 | */ |
| 116 | -function give_currency_symbol( $currency = '' ) { |
|
| 116 | +function give_currency_symbol($currency = '') { |
|
| 117 | 117 | |
| 118 | - if ( empty( $currency ) ) { |
|
| 118 | + if (empty($currency)) { |
|
| 119 | 119 | $currency = give_get_currency(); |
| 120 | 120 | } |
| 121 | - switch ( $currency ) : |
|
| 121 | + switch ($currency) : |
|
| 122 | 122 | case 'GBP' : |
| 123 | 123 | $symbol = '£'; |
| 124 | 124 | break; |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | endswitch; |
| 198 | 198 | |
| 199 | 199 | |
| 200 | - return apply_filters( 'give_currency_symbol', $symbol, $currency ); |
|
| 200 | + return apply_filters('give_currency_symbol', $symbol, $currency); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | |
@@ -209,15 +209,15 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | function give_get_current_page_url() { |
| 211 | 211 | |
| 212 | - if ( is_front_page() ) { |
|
| 213 | - $current_url = home_url( '/' ); |
|
| 212 | + if (is_front_page()) { |
|
| 213 | + $current_url = home_url('/'); |
|
| 214 | 214 | } else { |
| 215 | - $http_host = sanitize_text_field( $_SERVER['HTTP_HOST'] ); |
|
| 216 | - $request_uri = sanitize_text_field( $_SERVER['REQUEST_URI'] ); |
|
| 217 | - $current_url = set_url_scheme( 'http://' . $http_host . untrailingslashit( $request_uri ) ); |
|
| 215 | + $http_host = sanitize_text_field($_SERVER['HTTP_HOST']); |
|
| 216 | + $request_uri = sanitize_text_field($_SERVER['REQUEST_URI']); |
|
| 217 | + $current_url = set_url_scheme('http://'.$http_host.untrailingslashit($request_uri)); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - return apply_filters( 'give_get_current_page_url', $current_url ); |
|
| 220 | + return apply_filters('give_get_current_page_url', $current_url); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | |
@@ -238,15 +238,15 @@ discard block |
||
| 238 | 238 | */ |
| 239 | 239 | $gateways = give_get_enabled_payment_gateways(); |
| 240 | 240 | |
| 241 | - if ( count( $gateways ) == 1 && ! isset( $gateways['paypal'] ) && ! isset( $gateways['manual'] ) ) { |
|
| 241 | + if (count($gateways) == 1 && ! isset($gateways['paypal']) && ! isset($gateways['manual'])) { |
|
| 242 | 242 | $ret = true; |
| 243 | - } else if ( count( $gateways ) == 1 ) { |
|
| 243 | + } else if (count($gateways) == 1) { |
|
| 244 | 244 | $ret = false; |
| 245 | - } else if ( count( $gateways ) == 2 && isset( $gateways['paypal'] ) && isset( $gateways['manual'] ) ) { |
|
| 245 | + } else if (count($gateways) == 2 && isset($gateways['paypal']) && isset($gateways['manual'])) { |
|
| 246 | 246 | $ret = false; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | - return (bool) apply_filters( 'give_verify_credit_cards', $ret ); |
|
| 249 | + return (bool) apply_filters('give_verify_credit_cards', $ret); |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | /** |
@@ -258,26 +258,26 @@ discard block |
||
| 258 | 258 | function give_get_timezone_id() { |
| 259 | 259 | |
| 260 | 260 | // if site timezone string exists, return it |
| 261 | - if ( $timezone = get_option( 'timezone_string' ) ) { |
|
| 261 | + if ($timezone = get_option('timezone_string')) { |
|
| 262 | 262 | return $timezone; |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // get UTC offset, if it isn't set return UTC |
| 266 | - if ( ! ( $utc_offset = 3600 * get_option( 'gmt_offset', 0 ) ) ) { |
|
| 266 | + if ( ! ($utc_offset = 3600 * get_option('gmt_offset', 0))) { |
|
| 267 | 267 | return 'UTC'; |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | // attempt to guess the timezone string from the UTC offset |
| 271 | - $timezone = timezone_name_from_abbr( '', $utc_offset ); |
|
| 271 | + $timezone = timezone_name_from_abbr('', $utc_offset); |
|
| 272 | 272 | |
| 273 | 273 | // last try, guess timezone string manually |
| 274 | - if ( $timezone === false ) { |
|
| 274 | + if ($timezone === false) { |
|
| 275 | 275 | |
| 276 | - $is_dst = date( 'I' ); |
|
| 276 | + $is_dst = date('I'); |
|
| 277 | 277 | |
| 278 | - foreach ( timezone_abbreviations_list() as $abbr ) { |
|
| 279 | - foreach ( $abbr as $city ) { |
|
| 280 | - if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) { |
|
| 278 | + foreach (timezone_abbreviations_list() as $abbr) { |
|
| 279 | + foreach ($abbr as $city) { |
|
| 280 | + if ($city['dst'] == $is_dst && $city['offset'] == $utc_offset) { |
|
| 281 | 281 | return $city['timezone_id']; |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -301,17 +301,17 @@ discard block |
||
| 301 | 301 | |
| 302 | 302 | $ip = '127.0.0.1'; |
| 303 | 303 | |
| 304 | - if ( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) { |
|
| 304 | + if ( ! empty($_SERVER['HTTP_CLIENT_IP'])) { |
|
| 305 | 305 | //check ip from share internet |
| 306 | 306 | $ip = $_SERVER['HTTP_CLIENT_IP']; |
| 307 | - } elseif ( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) { |
|
| 307 | + } elseif ( ! empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { |
|
| 308 | 308 | //to check ip is pass from proxy |
| 309 | 309 | $ip = $_SERVER['HTTP_X_FORWARDED_FOR']; |
| 310 | - } elseif ( ! empty( $_SERVER['REMOTE_ADDR'] ) ) { |
|
| 310 | + } elseif ( ! empty($_SERVER['REMOTE_ADDR'])) { |
|
| 311 | 311 | $ip = $_SERVER['REMOTE_ADDR']; |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | - return apply_filters( 'give_get_ip', $ip ); |
|
| 314 | + return apply_filters('give_get_ip', $ip); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | |
@@ -326,9 +326,9 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @uses Give()->session->set() |
| 328 | 328 | */ |
| 329 | -function give_set_purchase_session( $purchase_data = array() ) { |
|
| 330 | - Give()->session->set( 'give_purchase', $purchase_data ); |
|
| 331 | - Give()->session->set( 'give_email', $purchase_data['user_email'] ); |
|
| 329 | +function give_set_purchase_session($purchase_data = array()) { |
|
| 330 | + Give()->session->set('give_purchase', $purchase_data); |
|
| 331 | + Give()->session->set('give_email', $purchase_data['user_email']); |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | * @return mixed array | false |
| 343 | 343 | */ |
| 344 | 344 | function give_get_purchase_session() { |
| 345 | - return Give()->session->get( 'give_purchase' ); |
|
| 345 | + return Give()->session->get('give_purchase'); |
|
| 346 | 346 | } |
| 347 | 347 | |
| 348 | 348 | /** |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @return string |
| 359 | 359 | */ |
| 360 | -function give_get_purchase_summary( $purchase_data, $email = true ) { |
|
| 360 | +function give_get_purchase_summary($purchase_data, $email = true) { |
|
| 361 | 361 | $summary = ''; |
| 362 | 362 | |
| 363 | - if ( $email ) { |
|
| 364 | - $summary .= $purchase_data['user_email'] . ' - '; |
|
| 363 | + if ($email) { |
|
| 364 | + $summary .= $purchase_data['user_email'].' - '; |
|
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - $summary .= get_the_title( $purchase_data['post_data']['give-form-id'] ); |
|
| 367 | + $summary .= get_the_title($purchase_data['post_data']['give-form-id']); |
|
| 368 | 368 | |
| 369 | 369 | return $summary; |
| 370 | 370 | } |
@@ -381,31 +381,31 @@ discard block |
||
| 381 | 381 | function give_get_host() { |
| 382 | 382 | $host = false; |
| 383 | 383 | |
| 384 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 384 | + if (defined('WPE_APIKEY')) { |
|
| 385 | 385 | $host = 'WP Engine'; |
| 386 | - } elseif ( defined( 'PAGELYBIN' ) ) { |
|
| 386 | + } elseif (defined('PAGELYBIN')) { |
|
| 387 | 387 | $host = 'Pagely'; |
| 388 | - } elseif ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 388 | + } elseif (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 389 | 389 | $host = 'ICDSoft'; |
| 390 | - } elseif ( DB_HOST == 'mysqlv5' ) { |
|
| 390 | + } elseif (DB_HOST == 'mysqlv5') { |
|
| 391 | 391 | $host = 'NetworkSolutions'; |
| 392 | - } elseif ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 392 | + } elseif (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 393 | 393 | $host = 'iPage'; |
| 394 | - } elseif ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 394 | + } elseif (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 395 | 395 | $host = 'IPower'; |
| 396 | - } elseif ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 396 | + } elseif (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 397 | 397 | $host = 'MediaTemple Grid'; |
| 398 | - } elseif ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 398 | + } elseif (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 399 | 399 | $host = 'pair Networks'; |
| 400 | - } elseif ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 400 | + } elseif (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 401 | 401 | $host = 'Rackspace Cloud'; |
| 402 | - } elseif ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 402 | + } elseif (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 403 | 403 | $host = 'SysFix.eu Power Hosting'; |
| 404 | - } elseif ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 404 | + } elseif (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 405 | 405 | $host = 'Flywheel'; |
| 406 | 406 | } else { |
| 407 | 407 | // Adding a general fallback for data gathering |
| 408 | - $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME']; |
|
| 408 | + $host = 'DBH: '.DB_HOST.', SRV: '.$_SERVER['SERVER_NAME']; |
|
| 409 | 409 | } |
| 410 | 410 | |
| 411 | 411 | return $host; |
@@ -421,67 +421,67 @@ discard block |
||
| 421 | 421 | * |
| 422 | 422 | * @return bool true if host matches, false if not |
| 423 | 423 | */ |
| 424 | -function give_is_host( $host = false ) { |
|
| 424 | +function give_is_host($host = false) { |
|
| 425 | 425 | |
| 426 | 426 | $return = false; |
| 427 | 427 | |
| 428 | - if ( $host ) { |
|
| 429 | - $host = str_replace( ' ', '', strtolower( $host ) ); |
|
| 428 | + if ($host) { |
|
| 429 | + $host = str_replace(' ', '', strtolower($host)); |
|
| 430 | 430 | |
| 431 | - switch ( $host ) { |
|
| 431 | + switch ($host) { |
|
| 432 | 432 | case 'wpengine': |
| 433 | - if ( defined( 'WPE_APIKEY' ) ) { |
|
| 433 | + if (defined('WPE_APIKEY')) { |
|
| 434 | 434 | $return = true; |
| 435 | 435 | } |
| 436 | 436 | break; |
| 437 | 437 | case 'pagely': |
| 438 | - if ( defined( 'PAGELYBIN' ) ) { |
|
| 438 | + if (defined('PAGELYBIN')) { |
|
| 439 | 439 | $return = true; |
| 440 | 440 | } |
| 441 | 441 | break; |
| 442 | 442 | case 'icdsoft': |
| 443 | - if ( DB_HOST == 'localhost:/tmp/mysql5.sock' ) { |
|
| 443 | + if (DB_HOST == 'localhost:/tmp/mysql5.sock') { |
|
| 444 | 444 | $return = true; |
| 445 | 445 | } |
| 446 | 446 | break; |
| 447 | 447 | case 'networksolutions': |
| 448 | - if ( DB_HOST == 'mysqlv5' ) { |
|
| 448 | + if (DB_HOST == 'mysqlv5') { |
|
| 449 | 449 | $return = true; |
| 450 | 450 | } |
| 451 | 451 | break; |
| 452 | 452 | case 'ipage': |
| 453 | - if ( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) { |
|
| 453 | + if (strpos(DB_HOST, 'ipagemysql.com') !== false) { |
|
| 454 | 454 | $return = true; |
| 455 | 455 | } |
| 456 | 456 | break; |
| 457 | 457 | case 'ipower': |
| 458 | - if ( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) { |
|
| 458 | + if (strpos(DB_HOST, 'ipowermysql.com') !== false) { |
|
| 459 | 459 | $return = true; |
| 460 | 460 | } |
| 461 | 461 | break; |
| 462 | 462 | case 'mediatemplegrid': |
| 463 | - if ( strpos( DB_HOST, '.gridserver.com' ) !== false ) { |
|
| 463 | + if (strpos(DB_HOST, '.gridserver.com') !== false) { |
|
| 464 | 464 | $return = true; |
| 465 | 465 | } |
| 466 | 466 | break; |
| 467 | 467 | case 'pairnetworks': |
| 468 | - if ( strpos( DB_HOST, '.pair.com' ) !== false ) { |
|
| 468 | + if (strpos(DB_HOST, '.pair.com') !== false) { |
|
| 469 | 469 | $return = true; |
| 470 | 470 | } |
| 471 | 471 | break; |
| 472 | 472 | case 'rackspacecloud': |
| 473 | - if ( strpos( DB_HOST, '.stabletransit.com' ) !== false ) { |
|
| 473 | + if (strpos(DB_HOST, '.stabletransit.com') !== false) { |
|
| 474 | 474 | $return = true; |
| 475 | 475 | } |
| 476 | 476 | break; |
| 477 | 477 | case 'sysfix.eu': |
| 478 | 478 | case 'sysfix.eupowerhosting': |
| 479 | - if ( strpos( DB_HOST, '.sysfix.eu' ) !== false ) { |
|
| 479 | + if (strpos(DB_HOST, '.sysfix.eu') !== false) { |
|
| 480 | 480 | $return = true; |
| 481 | 481 | } |
| 482 | 482 | break; |
| 483 | 483 | case 'flywheel': |
| 484 | - if ( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) { |
|
| 484 | + if (strpos($_SERVER['SERVER_NAME'], 'Flywheel') !== false) { |
|
| 485 | 485 | $return = true; |
| 486 | 486 | } |
| 487 | 487 | break; |
@@ -514,7 +514,7 @@ discard block |
||
| 514 | 514 | * @param string $replacement Optional. The function that should have been called. |
| 515 | 515 | * @param array $backtrace Optional. Contains stack backtrace of deprecated function. |
| 516 | 516 | */ |
| 517 | -function _give_deprecated_function( $function, $version, $replacement = null, $backtrace = null ) { |
|
| 517 | +function _give_deprecated_function($function, $version, $replacement = null, $backtrace = null) { |
|
| 518 | 518 | |
| 519 | 519 | /** |
| 520 | 520 | * Fires while give deprecated function call occurs. |
@@ -527,19 +527,19 @@ discard block |
||
| 527 | 527 | * @param string $replacement Optional. The function that should have been called. |
| 528 | 528 | * @param string $version The plugin version that deprecated the function. |
| 529 | 529 | */ |
| 530 | - do_action( 'give_deprecated_function_run', $function, $replacement, $version ); |
|
| 530 | + do_action('give_deprecated_function_run', $function, $replacement, $version); |
|
| 531 | 531 | |
| 532 | - $show_errors = current_user_can( 'manage_options' ); |
|
| 532 | + $show_errors = current_user_can('manage_options'); |
|
| 533 | 533 | |
| 534 | 534 | // Allow plugin to filter the output error trigger |
| 535 | - if ( WP_DEBUG && apply_filters( 'give_deprecated_function_trigger_error', $show_errors ) ) { |
|
| 536 | - if ( ! is_null( $replacement ) ) { |
|
| 537 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give' ), $function, $version, $replacement ) ); |
|
| 538 | - trigger_error( print_r( $backtrace, 1 ) ); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 535 | + if (WP_DEBUG && apply_filters('give_deprecated_function_trigger_error', $show_errors)) { |
|
| 536 | + if ( ! is_null($replacement)) { |
|
| 537 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s! Use %3$s instead.', 'give'), $function, $version, $replacement)); |
|
| 538 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 539 | 539 | // Alternatively we could dump this to a file. |
| 540 | 540 | } else { |
| 541 | - trigger_error( sprintf( __( '%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give' ), $function, $version ) ); |
|
| 542 | - trigger_error( print_r( $backtrace, 1 ) );// Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 541 | + trigger_error(sprintf(__('%1$s is <strong>deprecated</strong> since Give version %2$s with no alternative available.', 'give'), $function, $version)); |
|
| 542 | + trigger_error(print_r($backtrace, 1)); // Limited to previous 1028 characters, but since we only need to move back 1 in stack that should be fine. |
|
| 543 | 543 | // Alternatively we could dump this to a file. |
| 544 | 544 | } |
| 545 | 545 | } |
@@ -553,8 +553,8 @@ discard block |
||
| 553 | 553 | * @return string $post_id |
| 554 | 554 | */ |
| 555 | 555 | function give_get_admin_post_id() { |
| 556 | - $post_id = isset( $_GET['post'] ) ? $_GET['post'] : null; |
|
| 557 | - if ( ! $post_id && isset( $_POST['post_id'] ) ) { |
|
| 556 | + $post_id = isset($_GET['post']) ? $_GET['post'] : null; |
|
| 557 | + if ( ! $post_id && isset($_POST['post_id'])) { |
|
| 558 | 558 | $post_id = $_POST['post_id']; |
| 559 | 559 | } |
| 560 | 560 | |
@@ -568,7 +568,7 @@ discard block |
||
| 568 | 568 | * @return string Arg separator output |
| 569 | 569 | */ |
| 570 | 570 | function give_get_php_arg_separator_output() { |
| 571 | - return ini_get( 'arg_separator.output' ); |
|
| 571 | + return ini_get('arg_separator.output'); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | |
@@ -583,10 +583,10 @@ discard block |
||
| 583 | 583 | * |
| 584 | 584 | * @return string Short month name |
| 585 | 585 | */ |
| 586 | -function give_month_num_to_name( $n ) { |
|
| 587 | - $timestamp = mktime( 0, 0, 0, $n, 1, 2005 ); |
|
| 586 | +function give_month_num_to_name($n) { |
|
| 587 | + $timestamp = mktime(0, 0, 0, $n, 1, 2005); |
|
| 588 | 588 | |
| 589 | - return date_i18n( "M", $timestamp ); |
|
| 589 | + return date_i18n("M", $timestamp); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -599,10 +599,10 @@ discard block |
||
| 599 | 599 | * |
| 600 | 600 | * @return bool Whether or not function is disabled. |
| 601 | 601 | */ |
| 602 | -function give_is_func_disabled( $function ) { |
|
| 603 | - $disabled = explode( ',', ini_get( 'disable_functions' ) ); |
|
| 602 | +function give_is_func_disabled($function) { |
|
| 603 | + $disabled = explode(',', ini_get('disable_functions')); |
|
| 604 | 604 | |
| 605 | - return in_array( $function, $disabled ); |
|
| 605 | + return in_array($function, $disabled); |
|
| 606 | 606 | } |
| 607 | 607 | |
| 608 | 608 | |
@@ -613,31 +613,31 @@ discard block |
||
| 613 | 613 | */ |
| 614 | 614 | function give_get_newsletter() { ?> |
| 615 | 615 | |
| 616 | - <p class="newsletter-intro"><?php esc_html_e( 'Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give' ); ?></p> |
|
| 616 | + <p class="newsletter-intro"><?php esc_html_e('Be sure to sign up for the Give newsletter below to stay informed of important updates and news.', 'give'); ?></p> |
|
| 617 | 617 | |
| 618 | 618 | <div class="give-newsletter-form-wrap"> |
| 619 | 619 | |
| 620 | 620 | <form action="//givewp.us3.list-manage.com/subscribe/post?u=3ccb75d68bda4381e2f45794c&id=12a081aa13" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate> |
| 621 | 621 | <div class="give-newsletter-confirmation"> |
| 622 | - <p><?php esc_html_e( 'Thanks for Subscribing!', 'give' ); ?> :)</p> |
|
| 622 | + <p><?php esc_html_e('Thanks for Subscribing!', 'give'); ?> :)</p> |
|
| 623 | 623 | </div> |
| 624 | 624 | |
| 625 | 625 | <table class="form-table give-newsletter-form"> |
| 626 | 626 | <tr valign="middle"> |
| 627 | 627 | <td> |
| 628 | - <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e( 'Email Address (required)', 'give' ); ?></label> |
|
| 629 | - <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e( 'Email Address (required)', 'give' ); ?>" class="required email" value=""> |
|
| 628 | + <label for="mce-EMAIL" class="screen-reader-text"><?php esc_html_e('Email Address (required)', 'give'); ?></label> |
|
| 629 | + <input type="email" name="EMAIL" id="mce-EMAIL" placeholder="<?php esc_attr_e('Email Address (required)', 'give'); ?>" class="required email" value=""> |
|
| 630 | 630 | </td> |
| 631 | 631 | <td> |
| 632 | - <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e( 'First Name', 'give' ); ?></label> |
|
| 633 | - <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" class="" value=""> |
|
| 632 | + <label for="mce-FNAME" class="screen-reader-text"><?php esc_html_e('First Name', 'give'); ?></label> |
|
| 633 | + <input type="text" name="FNAME" id="mce-FNAME" placeholder="<?php esc_attr_e('First Name', 'give'); ?>" class="" value=""> |
|
| 634 | 634 | </td> |
| 635 | 635 | <td> |
| 636 | - <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e( 'Last Name', 'give' ); ?></label> |
|
| 637 | - <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" class="" value=""> |
|
| 636 | + <label for="mce-LNAME" class="screen-reader-text"><?php esc_html_e('Last Name', 'give'); ?></label> |
|
| 637 | + <input type="text" name="LNAME" id="mce-LNAME" placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" class="" value=""> |
|
| 638 | 638 | </td> |
| 639 | 639 | <td> |
| 640 | - <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e( 'Subscribe', 'give' ); ?>"> |
|
| 640 | + <input type="submit" name="subscribe" id="mc-embedded-subscribe" class="button" value="<?php esc_attr_e('Subscribe', 'give'); ?>"> |
|
| 641 | 641 | </td> |
| 642 | 642 | </tr> |
| 643 | 643 | </table> |
@@ -698,7 +698,7 @@ discard block |
||
| 698 | 698 | <a href="https://twitter.com/givewp" class="twitter-follow-button" data-show-count="false"><?php |
| 699 | 699 | printf( |
| 700 | 700 | /* translators: %s: Give twitter user @givewp */ |
| 701 | - esc_html_e( 'Follow %s', 'give' ), |
|
| 701 | + esc_html_e('Follow %s', 'give'), |
|
| 702 | 702 | '@givewp' |
| 703 | 703 | ); |
| 704 | 704 | ?></a> |
@@ -727,7 +727,7 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @return string |
| 729 | 729 | */ |
| 730 | -function give_svg_icons( $icon ) { |
|
| 730 | +function give_svg_icons($icon) { |
|
| 731 | 731 | |
| 732 | 732 | // Store your SVGs in an associative array |
| 733 | 733 | $svgs = array( |
@@ -739,7 +739,7 @@ discard block |
||
| 739 | 739 | ); |
| 740 | 740 | |
| 741 | 741 | // Return the chosen icon's SVG string |
| 742 | - return $svgs[ $icon ]; |
|
| 742 | + return $svgs[$icon]; |
|
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 | /** |
@@ -751,15 +751,15 @@ discard block |
||
| 751 | 751 | * |
| 752 | 752 | * @return mixed |
| 753 | 753 | */ |
| 754 | -function modify_nav_menu_meta_box_object( $post_type ) { |
|
| 755 | - if ( isset( $post_type->name ) && $post_type->name == 'give_forms' ) { |
|
| 756 | - $post_type->labels->name = esc_html__( 'Donation Forms', 'give' ); |
|
| 754 | +function modify_nav_menu_meta_box_object($post_type) { |
|
| 755 | + if (isset($post_type->name) && $post_type->name == 'give_forms') { |
|
| 756 | + $post_type->labels->name = esc_html__('Donation Forms', 'give'); |
|
| 757 | 757 | } |
| 758 | 758 | |
| 759 | 759 | return $post_type; |
| 760 | 760 | } |
| 761 | 761 | |
| 762 | -add_filter( 'nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object' ); |
|
| 762 | +add_filter('nav_menu_meta_box_object', 'modify_nav_menu_meta_box_object'); |
|
| 763 | 763 | |
| 764 | 764 | |
| 765 | 765 | /** |
@@ -773,7 +773,7 @@ discard block |
||
| 773 | 773 | * @license https://opensource.org/licenses/MIT MIT |
| 774 | 774 | */ |
| 775 | 775 | |
| 776 | -if ( ! function_exists( 'array_column' ) ) { |
|
| 776 | +if ( ! function_exists('array_column')) { |
|
| 777 | 777 | /** |
| 778 | 778 | * Returns the values from a single column of the input array, identified by |
| 779 | 779 | * the $columnKey. |
@@ -792,53 +792,53 @@ discard block |
||
| 792 | 792 | * |
| 793 | 793 | * @return array |
| 794 | 794 | */ |
| 795 | - function array_column( $input = null, $columnKey = null, $indexKey = null ) { |
|
| 795 | + function array_column($input = null, $columnKey = null, $indexKey = null) { |
|
| 796 | 796 | // Using func_get_args() in order to check for proper number of |
| 797 | 797 | // parameters and trigger errors exactly as the built-in array_column() |
| 798 | 798 | // does in PHP 5.5. |
| 799 | 799 | $argc = func_num_args(); |
| 800 | 800 | $params = func_get_args(); |
| 801 | 801 | |
| 802 | - if ( $argc < 2 ) { |
|
| 803 | - trigger_error( sprintf( esc_html__( 'array_column() expects at least 2 parameters, %s given.', 'give' ), $argc ), E_USER_WARNING ); |
|
| 802 | + if ($argc < 2) { |
|
| 803 | + trigger_error(sprintf(esc_html__('array_column() expects at least 2 parameters, %s given.', 'give'), $argc), E_USER_WARNING); |
|
| 804 | 804 | |
| 805 | 805 | return null; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | - if ( ! is_array( $params[0] ) ) { |
|
| 809 | - trigger_error( sprintf( esc_html__( 'array_column() expects parameter 1 to be array, %s given.', 'give' ), gettype( $params[0] ) ), E_USER_WARNING ); |
|
| 808 | + if ( ! is_array($params[0])) { |
|
| 809 | + trigger_error(sprintf(esc_html__('array_column() expects parameter 1 to be array, %s given.', 'give'), gettype($params[0])), E_USER_WARNING); |
|
| 810 | 810 | |
| 811 | 811 | return null; |
| 812 | 812 | } |
| 813 | 813 | |
| 814 | - if ( ! is_int( $params[1] ) |
|
| 815 | - && ! is_float( $params[1] ) |
|
| 816 | - && ! is_string( $params[1] ) |
|
| 814 | + if ( ! is_int($params[1]) |
|
| 815 | + && ! is_float($params[1]) |
|
| 816 | + && ! is_string($params[1]) |
|
| 817 | 817 | && $params[1] !== null |
| 818 | - && ! ( is_object( $params[1] ) && method_exists( $params[1], '__toString' ) ) |
|
| 818 | + && ! (is_object($params[1]) && method_exists($params[1], '__toString')) |
|
| 819 | 819 | ) { |
| 820 | - trigger_error( esc_html__( 'array_column(): The column key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 820 | + trigger_error(esc_html__('array_column(): The column key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 821 | 821 | |
| 822 | 822 | return false; |
| 823 | 823 | } |
| 824 | 824 | |
| 825 | - if ( isset( $params[2] ) |
|
| 826 | - && ! is_int( $params[2] ) |
|
| 827 | - && ! is_float( $params[2] ) |
|
| 828 | - && ! is_string( $params[2] ) |
|
| 829 | - && ! ( is_object( $params[2] ) && method_exists( $params[2], '__toString' ) ) |
|
| 825 | + if (isset($params[2]) |
|
| 826 | + && ! is_int($params[2]) |
|
| 827 | + && ! is_float($params[2]) |
|
| 828 | + && ! is_string($params[2]) |
|
| 829 | + && ! (is_object($params[2]) && method_exists($params[2], '__toString')) |
|
| 830 | 830 | ) { |
| 831 | - trigger_error( esc_html__( 'array_column(): The index key should be either a string or an integer.', 'give' ), E_USER_WARNING ); |
|
| 831 | + trigger_error(esc_html__('array_column(): The index key should be either a string or an integer.', 'give'), E_USER_WARNING); |
|
| 832 | 832 | |
| 833 | 833 | return false; |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | $paramsInput = $params[0]; |
| 837 | - $paramsColumnKey = ( $params[1] !== null ) ? (string) $params[1] : null; |
|
| 837 | + $paramsColumnKey = ($params[1] !== null) ? (string) $params[1] : null; |
|
| 838 | 838 | |
| 839 | 839 | $paramsIndexKey = null; |
| 840 | - if ( isset( $params[2] ) ) { |
|
| 841 | - if ( is_float( $params[2] ) || is_int( $params[2] ) ) { |
|
| 840 | + if (isset($params[2])) { |
|
| 841 | + if (is_float($params[2]) || is_int($params[2])) { |
|
| 842 | 842 | $paramsIndexKey = (int) $params[2]; |
| 843 | 843 | } else { |
| 844 | 844 | $paramsIndexKey = (string) $params[2]; |
@@ -847,26 +847,26 @@ discard block |
||
| 847 | 847 | |
| 848 | 848 | $resultArray = array(); |
| 849 | 849 | |
| 850 | - foreach ( $paramsInput as $row ) { |
|
| 850 | + foreach ($paramsInput as $row) { |
|
| 851 | 851 | $key = $value = null; |
| 852 | 852 | $keySet = $valueSet = false; |
| 853 | 853 | |
| 854 | - if ( $paramsIndexKey !== null && array_key_exists( $paramsIndexKey, $row ) ) { |
|
| 854 | + if ($paramsIndexKey !== null && array_key_exists($paramsIndexKey, $row)) { |
|
| 855 | 855 | $keySet = true; |
| 856 | - $key = (string) $row[ $paramsIndexKey ]; |
|
| 856 | + $key = (string) $row[$paramsIndexKey]; |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | - if ( $paramsColumnKey === null ) { |
|
| 859 | + if ($paramsColumnKey === null) { |
|
| 860 | 860 | $valueSet = true; |
| 861 | 861 | $value = $row; |
| 862 | - } elseif ( is_array( $row ) && array_key_exists( $paramsColumnKey, $row ) ) { |
|
| 862 | + } elseif (is_array($row) && array_key_exists($paramsColumnKey, $row)) { |
|
| 863 | 863 | $valueSet = true; |
| 864 | - $value = $row[ $paramsColumnKey ]; |
|
| 864 | + $value = $row[$paramsColumnKey]; |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | - if ( $valueSet ) { |
|
| 868 | - if ( $keySet ) { |
|
| 869 | - $resultArray[ $key ] = $value; |
|
| 867 | + if ($valueSet) { |
|
| 868 | + if ($keySet) { |
|
| 869 | + $resultArray[$key] = $value; |
|
| 870 | 870 | } else { |
| 871 | 871 | $resultArray[] = $value; |
| 872 | 872 | } |
@@ -888,40 +888,40 @@ discard block |
||
| 888 | 888 | * |
| 889 | 889 | * @return bool Whether the receipt is visible or not. |
| 890 | 890 | */ |
| 891 | -function give_can_view_receipt( $payment_key = '' ) { |
|
| 891 | +function give_can_view_receipt($payment_key = '') { |
|
| 892 | 892 | |
| 893 | 893 | $return = false; |
| 894 | 894 | |
| 895 | - if ( empty( $payment_key ) ) { |
|
| 895 | + if (empty($payment_key)) { |
|
| 896 | 896 | return $return; |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | global $give_receipt_args; |
| 900 | 900 | |
| 901 | - $give_receipt_args['id'] = give_get_purchase_id_by_key( $payment_key ); |
|
| 901 | + $give_receipt_args['id'] = give_get_purchase_id_by_key($payment_key); |
|
| 902 | 902 | |
| 903 | - $user_id = (int) give_get_payment_user_id( $give_receipt_args['id'] ); |
|
| 903 | + $user_id = (int) give_get_payment_user_id($give_receipt_args['id']); |
|
| 904 | 904 | |
| 905 | - $payment_meta = give_get_payment_meta( $give_receipt_args['id'] ); |
|
| 905 | + $payment_meta = give_get_payment_meta($give_receipt_args['id']); |
|
| 906 | 906 | |
| 907 | - if ( is_user_logged_in() ) { |
|
| 908 | - if ( $user_id === (int) get_current_user_id() ) { |
|
| 907 | + if (is_user_logged_in()) { |
|
| 908 | + if ($user_id === (int) get_current_user_id()) { |
|
| 909 | 909 | $return = true; |
| 910 | - } elseif ( wp_get_current_user()->user_email === give_get_payment_user_email( $give_receipt_args['id'] ) ) { |
|
| 910 | + } elseif (wp_get_current_user()->user_email === give_get_payment_user_email($give_receipt_args['id'])) { |
|
| 911 | 911 | $return = true; |
| 912 | - } elseif ( current_user_can( 'view_give_sensitive_data' ) ) { |
|
| 912 | + } elseif (current_user_can('view_give_sensitive_data')) { |
|
| 913 | 913 | $return = true; |
| 914 | 914 | } |
| 915 | 915 | } |
| 916 | 916 | |
| 917 | 917 | $session = give_get_purchase_session(); |
| 918 | - if ( ! empty( $session ) && ! is_user_logged_in() ) { |
|
| 919 | - if ( $session['purchase_key'] === $payment_meta['key'] ) { |
|
| 918 | + if ( ! empty($session) && ! is_user_logged_in()) { |
|
| 919 | + if ($session['purchase_key'] === $payment_meta['key']) { |
|
| 920 | 920 | $return = true; |
| 921 | 921 | } |
| 922 | 922 | } |
| 923 | 923 | |
| 924 | - return (bool) apply_filters( 'give_can_view_receipt', $return, $payment_key ); |
|
| 924 | + return (bool) apply_filters('give_can_view_receipt', $return, $payment_key); |
|
| 925 | 925 | |
| 926 | 926 | } |
| 927 | 927 | |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | * |
| 931 | 931 | * Fallback in case the calendar extension is not loaded in PHP; Only supports Gregorian calendar |
| 932 | 932 | */ |
| 933 | -if ( ! function_exists( 'cal_days_in_month' ) ) { |
|
| 933 | +if ( ! function_exists('cal_days_in_month')) { |
|
| 934 | 934 | /** |
| 935 | 935 | * cal_days_in_month |
| 936 | 936 | * |
@@ -940,7 +940,7 @@ discard block |
||
| 940 | 940 | * |
| 941 | 941 | * @return bool|string |
| 942 | 942 | */ |
| 943 | - function cal_days_in_month( $calendar, $month, $year ) { |
|
| 944 | - return date( 't', mktime( 0, 0, 0, $month, 1, $year ) ); |
|
| 943 | + function cal_days_in_month($calendar, $month, $year) { |
|
| 944 | + return date('t', mktime(0, 0, 0, $month, 1, $year)); |
|
| 945 | 945 | } |
| 946 | 946 | } |
@@ -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 | |
@@ -26,27 +26,27 @@ discard block |
||
| 26 | 26 | function give_test_ajax_works() { |
| 27 | 27 | |
| 28 | 28 | // Check if the Airplane Mode plugin is installed |
| 29 | - if ( class_exists( 'Airplane_Mode_Core' ) ) { |
|
| 29 | + if (class_exists('Airplane_Mode_Core')) { |
|
| 30 | 30 | |
| 31 | 31 | $airplane = Airplane_Mode_Core::getInstance(); |
| 32 | 32 | |
| 33 | - if ( method_exists( $airplane, 'enabled' ) ) { |
|
| 33 | + if (method_exists($airplane, 'enabled')) { |
|
| 34 | 34 | |
| 35 | - if ( $airplane->enabled() ) { |
|
| 35 | + if ($airplane->enabled()) { |
|
| 36 | 36 | return true; |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | } else { |
| 40 | 40 | |
| 41 | - if ( $airplane->check_status() == 'on' ) { |
|
| 41 | + if ($airplane->check_status() == 'on') { |
|
| 42 | 42 | return true; |
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - add_filter( 'block_local_requests', '__return_false' ); |
|
| 47 | + add_filter('block_local_requests', '__return_false'); |
|
| 48 | 48 | |
| 49 | - if ( get_transient( '_give_ajax_works' ) ) { |
|
| 49 | + if (get_transient('_give_ajax_works')) { |
|
| 50 | 50 | return true; |
| 51 | 51 | } |
| 52 | 52 | |
@@ -58,35 +58,35 @@ discard block |
||
| 58 | 58 | ) |
| 59 | 59 | ); |
| 60 | 60 | |
| 61 | - $ajax = wp_remote_post( give_get_ajax_url(), $params ); |
|
| 61 | + $ajax = wp_remote_post(give_get_ajax_url(), $params); |
|
| 62 | 62 | $works = true; |
| 63 | 63 | |
| 64 | - if ( is_wp_error( $ajax ) ) { |
|
| 64 | + if (is_wp_error($ajax)) { |
|
| 65 | 65 | |
| 66 | 66 | $works = false; |
| 67 | 67 | |
| 68 | 68 | } else { |
| 69 | 69 | |
| 70 | - if ( empty( $ajax['response'] ) ) { |
|
| 70 | + if (empty($ajax['response'])) { |
|
| 71 | 71 | $works = false; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if ( empty( $ajax['response']['code'] ) || 200 !== (int) $ajax['response']['code'] ) { |
|
| 74 | + if (empty($ajax['response']['code']) || 200 !== (int) $ajax['response']['code']) { |
|
| 75 | 75 | $works = false; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( empty( $ajax['response']['message'] ) || 'OK' !== $ajax['response']['message'] ) { |
|
| 78 | + if (empty($ajax['response']['message']) || 'OK' !== $ajax['response']['message']) { |
|
| 79 | 79 | $works = false; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - if ( ! isset( $ajax['body'] ) || 0 !== (int) $ajax['body'] ) { |
|
| 82 | + if ( ! isset($ajax['body']) || 0 !== (int) $ajax['body']) { |
|
| 83 | 83 | $works = false; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - if ( $works ) { |
|
| 89 | - set_transient( '_give_ajax_works', '1', DAY_IN_SECONDS ); |
|
| 88 | + if ($works) { |
|
| 89 | + set_transient('_give_ajax_works', '1', DAY_IN_SECONDS); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $works; |
@@ -101,16 +101,16 @@ discard block |
||
| 101 | 101 | * @return string |
| 102 | 102 | */ |
| 103 | 103 | function give_get_ajax_url() { |
| 104 | - $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 104 | + $scheme = defined('FORCE_SSL_ADMIN') && FORCE_SSL_ADMIN ? 'https' : 'admin'; |
|
| 105 | 105 | |
| 106 | 106 | $current_url = give_get_current_page_url(); |
| 107 | - $ajax_url = admin_url( 'admin-ajax.php', $scheme ); |
|
| 107 | + $ajax_url = admin_url('admin-ajax.php', $scheme); |
|
| 108 | 108 | |
| 109 | - if ( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) { |
|
| 110 | - $ajax_url = preg_replace( '/^http/', 'https', $ajax_url ); |
|
| 109 | + if (preg_match('/^https/', $current_url) && ! preg_match('/^https/', $ajax_url)) { |
|
| 110 | + $ajax_url = preg_replace('/^http/', 'https', $ajax_url); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - return apply_filters( 'give_ajax_url', $ajax_url ); |
|
| 113 | + return apply_filters('give_ajax_url', $ajax_url); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | /** |
@@ -126,12 +126,12 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @since 1.7 |
| 128 | 128 | */ |
| 129 | - do_action( 'give_donation_form_login_fields' ); |
|
| 129 | + do_action('give_donation_form_login_fields'); |
|
| 130 | 130 | |
| 131 | 131 | give_die(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | -add_action( 'wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields' ); |
|
| 134 | +add_action('wp_ajax_nopriv_give_checkout_login', 'give_load_checkout_login_fields'); |
|
| 135 | 135 | |
| 136 | 136 | /** |
| 137 | 137 | * Load Checkout Fields |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | * @return void |
| 142 | 142 | */ |
| 143 | 143 | function give_load_checkout_fields() { |
| 144 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : ''; |
|
| 144 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : ''; |
|
| 145 | 145 | |
| 146 | 146 | ob_start(); |
| 147 | 147 | |
@@ -150,18 +150,18 @@ discard block |
||
| 150 | 150 | * |
| 151 | 151 | * @since 1.7 |
| 152 | 152 | */ |
| 153 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 153 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 154 | 154 | |
| 155 | 155 | $fields = ob_get_clean(); |
| 156 | 156 | |
| 157 | - wp_send_json( array( |
|
| 158 | - 'fields' => wp_json_encode( $fields ), |
|
| 159 | - 'submit' => wp_json_encode( give_checkout_button_purchase( $form_id ) ), |
|
| 160 | - ) ); |
|
| 157 | + wp_send_json(array( |
|
| 158 | + 'fields' => wp_json_encode($fields), |
|
| 159 | + 'submit' => wp_json_encode(give_checkout_button_purchase($form_id)), |
|
| 160 | + )); |
|
| 161 | 161 | } |
| 162 | 162 | |
| 163 | -add_action( 'wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields' ); |
|
| 164 | -add_action( 'wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields' ); |
|
| 163 | +add_action('wp_ajax_nopriv_give_cancel_login', 'give_load_checkout_fields'); |
|
| 164 | +add_action('wp_ajax_nopriv_give_checkout_register', 'give_load_checkout_fields'); |
|
| 165 | 165 | |
| 166 | 166 | /** |
| 167 | 167 | * Get Form Title via AJAX (used only in WordPress Admin) |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | * @return void |
| 172 | 172 | */ |
| 173 | 173 | function give_ajax_get_form_title() { |
| 174 | - if ( isset( $_POST['form_id'] ) ) { |
|
| 175 | - $title = get_the_title( $_POST['form_id'] ); |
|
| 176 | - if ( $title ) { |
|
| 174 | + if (isset($_POST['form_id'])) { |
|
| 175 | + $title = get_the_title($_POST['form_id']); |
|
| 176 | + if ($title) { |
|
| 177 | 177 | echo $title; |
| 178 | 178 | } else { |
| 179 | 179 | echo 'fail'; |
@@ -182,8 +182,8 @@ discard block |
||
| 182 | 182 | give_die(); |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | -add_action( 'wp_ajax_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 186 | -add_action( 'wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title' ); |
|
| 185 | +add_action('wp_ajax_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 186 | +add_action('wp_ajax_nopriv_give_get_form_title', 'give_ajax_get_form_title'); |
|
| 187 | 187 | |
| 188 | 188 | /** |
| 189 | 189 | * Retrieve a states drop down |
@@ -194,23 +194,23 @@ discard block |
||
| 194 | 194 | */ |
| 195 | 195 | function give_ajax_get_states_field() { |
| 196 | 196 | |
| 197 | - if ( empty( $_POST['country'] ) ) { |
|
| 197 | + if (empty($_POST['country'])) { |
|
| 198 | 198 | $_POST['country'] = give_get_country(); |
| 199 | 199 | } |
| 200 | - $states = give_get_states( $_POST['country'] ); |
|
| 200 | + $states = give_get_states($_POST['country']); |
|
| 201 | 201 | |
| 202 | - if ( ! empty( $states ) ) { |
|
| 202 | + if ( ! empty($states)) { |
|
| 203 | 203 | |
| 204 | 204 | $args = array( |
| 205 | 205 | 'name' => $_POST['field_name'], |
| 206 | 206 | 'id' => $_POST['field_name'], |
| 207 | - 'class' => $_POST['field_name'] . ' give-select', |
|
| 208 | - 'options' => give_get_states( $_POST['country'] ), |
|
| 207 | + 'class' => $_POST['field_name'].' give-select', |
|
| 208 | + 'options' => give_get_states($_POST['country']), |
|
| 209 | 209 | 'show_option_all' => false, |
| 210 | 210 | 'show_option_none' => false |
| 211 | 211 | ); |
| 212 | 212 | |
| 213 | - $response = Give()->html->select( $args ); |
|
| 213 | + $response = Give()->html->select($args); |
|
| 214 | 214 | |
| 215 | 215 | } else { |
| 216 | 216 | |
@@ -222,8 +222,8 @@ discard block |
||
| 222 | 222 | give_die(); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | -add_action( 'wp_ajax_give_get_states', 'give_ajax_get_states_field' ); |
|
| 226 | -add_action( 'wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field' ); |
|
| 225 | +add_action('wp_ajax_give_get_states', 'give_ajax_get_states_field'); |
|
| 226 | +add_action('wp_ajax_nopriv_give_get_states', 'give_ajax_get_states_field'); |
|
| 227 | 227 | |
| 228 | 228 | /** |
| 229 | 229 | * Retrieve a states drop down |
@@ -235,17 +235,17 @@ discard block |
||
| 235 | 235 | function give_ajax_form_search() { |
| 236 | 236 | global $wpdb; |
| 237 | 237 | |
| 238 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 238 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 239 | 239 | $results = array(); |
| 240 | - if ( current_user_can( 'edit_give_forms' ) ) { |
|
| 241 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 240 | + if (current_user_can('edit_give_forms')) { |
|
| 241 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 242 | 242 | } else { |
| 243 | - $items = $wpdb->get_results( "SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50" ); |
|
| 243 | + $items = $wpdb->get_results("SELECT ID,post_title FROM $wpdb->posts WHERE `post_type` = 'give_forms' AND `post_status` = 'publish' AND `post_title` LIKE '%$search%' LIMIT 50"); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | - if ( $items ) { |
|
| 246 | + if ($items) { |
|
| 247 | 247 | |
| 248 | - foreach ( $items as $item ) { |
|
| 248 | + foreach ($items as $item) { |
|
| 249 | 249 | |
| 250 | 250 | $results[] = array( |
| 251 | 251 | 'id' => $item->ID, |
@@ -257,18 +257,18 @@ discard block |
||
| 257 | 257 | |
| 258 | 258 | $items[] = array( |
| 259 | 259 | 'id' => 0, |
| 260 | - 'name' => esc_html__( 'No forms found.', 'give' ) |
|
| 260 | + 'name' => esc_html__('No forms found.', 'give') |
|
| 261 | 261 | ); |
| 262 | 262 | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | - echo json_encode( $results ); |
|
| 265 | + echo json_encode($results); |
|
| 266 | 266 | |
| 267 | 267 | give_die(); |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | -add_action( 'wp_ajax_give_form_search', 'give_ajax_form_search' ); |
|
| 271 | -add_action( 'wp_ajax_nopriv_give_form_search', 'give_ajax_form_search' ); |
|
| 270 | +add_action('wp_ajax_give_form_search', 'give_ajax_form_search'); |
|
| 271 | +add_action('wp_ajax_nopriv_give_form_search', 'give_ajax_form_search'); |
|
| 272 | 272 | |
| 273 | 273 | /** |
| 274 | 274 | * Search the donors database via Ajax |
@@ -280,21 +280,21 @@ discard block |
||
| 280 | 280 | function give_ajax_donor_search() { |
| 281 | 281 | global $wpdb; |
| 282 | 282 | |
| 283 | - $search = esc_sql( sanitize_text_field( $_GET['s'] ) ); |
|
| 283 | + $search = esc_sql(sanitize_text_field($_GET['s'])); |
|
| 284 | 284 | $results = array(); |
| 285 | - if ( ! current_user_can( 'view_give_reports' ) ) { |
|
| 285 | + if ( ! current_user_can('view_give_reports')) { |
|
| 286 | 286 | $donors = array(); |
| 287 | 287 | } else { |
| 288 | - $donors = $wpdb->get_results( "SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50" ); |
|
| 288 | + $donors = $wpdb->get_results("SELECT id,name,email FROM {$wpdb->prefix}give_donors WHERE `name` LIKE '%$search%' OR `email` LIKE '%$search%' LIMIT 50"); |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | - if ( $donors ) { |
|
| 291 | + if ($donors) { |
|
| 292 | 292 | |
| 293 | - foreach ( $donors as $donor ) { |
|
| 293 | + foreach ($donors as $donor) { |
|
| 294 | 294 | |
| 295 | 295 | $results[] = array( |
| 296 | 296 | 'id' => $donor->id, |
| 297 | - 'name' => $donor->name . '(' . $donor->email . ')' |
|
| 297 | + 'name' => $donor->name.'('.$donor->email.')' |
|
| 298 | 298 | ); |
| 299 | 299 | } |
| 300 | 300 | |
@@ -302,17 +302,17 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $donors[] = array( |
| 304 | 304 | 'id' => 0, |
| 305 | - 'name' => esc_html__( 'No donors found.', 'give' ) |
|
| 305 | + 'name' => esc_html__('No donors found.', 'give') |
|
| 306 | 306 | ); |
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - echo json_encode( $results ); |
|
| 310 | + echo json_encode($results); |
|
| 311 | 311 | |
| 312 | 312 | give_die(); |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | -add_action( 'wp_ajax_give_donor_search', 'give_ajax_donor_search' ); |
|
| 315 | +add_action('wp_ajax_give_donor_search', 'give_ajax_donor_search'); |
|
| 316 | 316 | |
| 317 | 317 | |
| 318 | 318 | /** |
@@ -324,42 +324,42 @@ discard block |
||
| 324 | 324 | */ |
| 325 | 325 | function give_ajax_search_users() { |
| 326 | 326 | |
| 327 | - if ( current_user_can( 'manage_give_settings' ) ) { |
|
| 327 | + if (current_user_can('manage_give_settings')) { |
|
| 328 | 328 | |
| 329 | - $search_query = trim( $_POST['user_name'] ); |
|
| 330 | - $exclude = trim( $_POST['exclude'] ); |
|
| 329 | + $search_query = trim($_POST['user_name']); |
|
| 330 | + $exclude = trim($_POST['exclude']); |
|
| 331 | 331 | |
| 332 | 332 | $get_users_args = array( |
| 333 | 333 | 'number' => 9999, |
| 334 | - 'search' => $search_query . '*' |
|
| 334 | + 'search' => $search_query.'*' |
|
| 335 | 335 | ); |
| 336 | 336 | |
| 337 | - if ( ! empty( $exclude ) ) { |
|
| 338 | - $exclude_array = explode( ',', $exclude ); |
|
| 337 | + if ( ! empty($exclude)) { |
|
| 338 | + $exclude_array = explode(',', $exclude); |
|
| 339 | 339 | $get_users_args['exclude'] = $exclude_array; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $get_users_args = apply_filters( 'give_search_users_args', $get_users_args ); |
|
| 342 | + $get_users_args = apply_filters('give_search_users_args', $get_users_args); |
|
| 343 | 343 | |
| 344 | - $found_users = apply_filters( 'give_ajax_found_users', get_users( $get_users_args ), $search_query ); |
|
| 344 | + $found_users = apply_filters('give_ajax_found_users', get_users($get_users_args), $search_query); |
|
| 345 | 345 | |
| 346 | 346 | $user_list = '<ul>'; |
| 347 | - if ( $found_users ) { |
|
| 348 | - foreach ( $found_users as $user ) { |
|
| 349 | - $user_list .= '<li><a href="#" data-userid="' . esc_attr( $user->ID ) . '" data-login="' . esc_attr( $user->user_login ) . '">' . esc_html( $user->user_login ) . '</a></li>'; |
|
| 347 | + if ($found_users) { |
|
| 348 | + foreach ($found_users as $user) { |
|
| 349 | + $user_list .= '<li><a href="#" data-userid="'.esc_attr($user->ID).'" data-login="'.esc_attr($user->user_login).'">'.esc_html($user->user_login).'</a></li>'; |
|
| 350 | 350 | } |
| 351 | 351 | } else { |
| 352 | - $user_list .= '<li>' . esc_html__( 'No users found.', 'give' ) . '</li>'; |
|
| 352 | + $user_list .= '<li>'.esc_html__('No users found.', 'give').'</li>'; |
|
| 353 | 353 | } |
| 354 | 354 | $user_list .= '</ul>'; |
| 355 | 355 | |
| 356 | - echo json_encode( array( 'results' => $user_list ) ); |
|
| 356 | + echo json_encode(array('results' => $user_list)); |
|
| 357 | 357 | |
| 358 | 358 | } |
| 359 | 359 | die(); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | -add_action( 'wp_ajax_give_search_users', 'give_ajax_search_users' ); |
|
| 362 | +add_action('wp_ajax_give_search_users', 'give_ajax_search_users'); |
|
| 363 | 363 | |
| 364 | 364 | |
| 365 | 365 | /** |
@@ -371,32 +371,32 @@ discard block |
||
| 371 | 371 | */ |
| 372 | 372 | function give_check_for_form_price_variations() { |
| 373 | 373 | |
| 374 | - if ( ! current_user_can( 'edit_give_forms', get_current_user_id() ) ) { |
|
| 375 | - die( '-1' ); |
|
| 374 | + if ( ! current_user_can('edit_give_forms', get_current_user_id())) { |
|
| 375 | + die('-1'); |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | - $form_id = intval( $_POST['form_id'] ); |
|
| 379 | - $form = get_post( $form_id ); |
|
| 378 | + $form_id = intval($_POST['form_id']); |
|
| 379 | + $form = get_post($form_id); |
|
| 380 | 380 | |
| 381 | - if ( 'give_forms' != $form->post_type ) { |
|
| 382 | - die( '-2' ); |
|
| 381 | + if ('give_forms' != $form->post_type) { |
|
| 382 | + die('-2'); |
|
| 383 | 383 | } |
| 384 | 384 | |
| 385 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 386 | - $variable_prices = give_get_variable_prices( $form_id ); |
|
| 385 | + if (give_has_variable_prices($form_id)) { |
|
| 386 | + $variable_prices = give_get_variable_prices($form_id); |
|
| 387 | 387 | |
| 388 | - if ( $variable_prices ) { |
|
| 388 | + if ($variable_prices) { |
|
| 389 | 389 | $ajax_response = '<select class="give_price_options_select give-select give-select" name="give_price_option">'; |
| 390 | 390 | |
| 391 | - if ( isset( $_POST['all_prices'] ) ) { |
|
| 392 | - $ajax_response .= '<option value="">' . esc_html__( 'All Levels', 'give' ) . '</option>'; |
|
| 391 | + if (isset($_POST['all_prices'])) { |
|
| 392 | + $ajax_response .= '<option value="">'.esc_html__('All Levels', 'give').'</option>'; |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | - foreach ( $variable_prices as $key => $price ) { |
|
| 395 | + foreach ($variable_prices as $key => $price) { |
|
| 396 | 396 | |
| 397 | - $level_text = ! empty( $price['_give_text'] ) ? esc_html( $price['_give_text'] ) : give_currency_filter( give_format_amount( $price['_give_amount'] ) ); |
|
| 397 | + $level_text = ! empty($price['_give_text']) ? esc_html($price['_give_text']) : give_currency_filter(give_format_amount($price['_give_amount'])); |
|
| 398 | 398 | |
| 399 | - $ajax_response .= '<option value="' . esc_attr( $price['_give_id']['level_id'] ) . '">' . $level_text . '</option>'; |
|
| 399 | + $ajax_response .= '<option value="'.esc_attr($price['_give_id']['level_id']).'">'.$level_text.'</option>'; |
|
| 400 | 400 | } |
| 401 | 401 | $ajax_response .= '</select>'; |
| 402 | 402 | echo $ajax_response; |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | give_die(); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | -add_action( 'wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations' ); |
|
| 410 | +add_action('wp_ajax_give_check_for_form_price_variations', 'give_check_for_form_price_variations'); |
|
| 411 | 411 | |
| 412 | 412 | |
| 413 | 413 | /** |
@@ -418,30 +418,30 @@ discard block |
||
| 418 | 418 | * @return void |
| 419 | 419 | */ |
| 420 | 420 | function give_check_for_form_price_variations_html() { |
| 421 | - if ( ! current_user_can( 'edit_give_payments', get_current_user_id() ) ) { |
|
| 421 | + if ( ! current_user_can('edit_give_payments', get_current_user_id())) { |
|
| 422 | 422 | wp_die(); |
| 423 | 423 | } |
| 424 | 424 | |
| 425 | - $form_id = intval( $_POST['form_id'] ); |
|
| 426 | - $payment_id = intval( $_POST['payment_id'] ); |
|
| 427 | - $form = get_post( $form_id ); |
|
| 425 | + $form_id = intval($_POST['form_id']); |
|
| 426 | + $payment_id = intval($_POST['payment_id']); |
|
| 427 | + $form = get_post($form_id); |
|
| 428 | 428 | |
| 429 | - if ( 'give_forms' != $form->post_type ) { |
|
| 429 | + if ('give_forms' != $form->post_type) { |
|
| 430 | 430 | wp_die(); |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | - if ( ! give_has_variable_prices( $form_id ) ) { |
|
| 434 | - esc_html_e( 'n/a', 'give' ); |
|
| 433 | + if ( ! give_has_variable_prices($form_id)) { |
|
| 434 | + esc_html_e('n/a', 'give'); |
|
| 435 | 435 | } else { |
| 436 | 436 | // Payment object. |
| 437 | - $payment = new Give_Payment( $payment_id ); |
|
| 437 | + $payment = new Give_Payment($payment_id); |
|
| 438 | 438 | |
| 439 | 439 | // Payment meta. |
| 440 | 440 | $payment_meta = $payment->get_meta(); |
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | // Variable price dropdown options. |
| 444 | - $variable_price_dropdown_option = array( |
|
| 444 | + $variable_price_dropdown_option = array( |
|
| 445 | 445 | 'id' => $form_id, |
| 446 | 446 | 'name' => 'give-variable-price', |
| 447 | 447 | 'chosen' => true, |
@@ -450,10 +450,10 @@ discard block |
||
| 450 | 450 | ); |
| 451 | 451 | |
| 452 | 452 | // Render variable prices select tag html. |
| 453 | - give_get_form_variable_price_dropdown( $variable_price_dropdown_option, true ); |
|
| 453 | + give_get_form_variable_price_dropdown($variable_price_dropdown_option, true); |
|
| 454 | 454 | } |
| 455 | 455 | |
| 456 | 456 | give_die(); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | -add_action( 'wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html' ); |
|
| 459 | +add_action('wp_ajax_give_check_for_form_price_variations_html', 'give_check_for_form_price_variations_html'); |
|
@@ -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 | |
@@ -140,27 +140,27 @@ discard block |
||
| 140 | 140 | 'v1' => 'GIVE_API_V1', |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - foreach ( $this->get_versions() as $version => $class ) { |
|
| 144 | - require_once GIVE_PLUGIN_DIR . 'includes/api/class-give-api-' . $version . '.php'; |
|
| 143 | + foreach ($this->get_versions() as $version => $class) { |
|
| 144 | + require_once GIVE_PLUGIN_DIR.'includes/api/class-give-api-'.$version.'.php'; |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - add_action( 'init', array( $this, 'add_endpoint' ) ); |
|
| 148 | - add_action( 'wp', array( $this, 'process_query' ), - 1 ); |
|
| 149 | - add_filter( 'query_vars', array( $this, 'query_vars' ) ); |
|
| 150 | - add_action( 'show_user_profile', array( $this, 'user_key_field' ) ); |
|
| 151 | - add_action( 'edit_user_profile', array( $this, 'user_key_field' ) ); |
|
| 152 | - add_action( 'personal_options_update', array( $this, 'update_key' ) ); |
|
| 153 | - add_action( 'edit_user_profile_update', array( $this, 'update_key' ) ); |
|
| 154 | - add_action( 'give_process_api_key', array( $this, 'process_api_key' ) ); |
|
| 147 | + add_action('init', array($this, 'add_endpoint')); |
|
| 148 | + add_action('wp', array($this, 'process_query'), - 1); |
|
| 149 | + add_filter('query_vars', array($this, 'query_vars')); |
|
| 150 | + add_action('show_user_profile', array($this, 'user_key_field')); |
|
| 151 | + add_action('edit_user_profile', array($this, 'user_key_field')); |
|
| 152 | + add_action('personal_options_update', array($this, 'update_key')); |
|
| 153 | + add_action('edit_user_profile_update', array($this, 'update_key')); |
|
| 154 | + add_action('give_process_api_key', array($this, 'process_api_key')); |
|
| 155 | 155 | |
| 156 | 156 | // Setup a backwards compatibility check for user API Keys |
| 157 | - add_filter( 'get_user_metadata', array( $this, 'api_key_backwards_compat' ), 10, 4 ); |
|
| 157 | + add_filter('get_user_metadata', array($this, 'api_key_backwards_compat'), 10, 4); |
|
| 158 | 158 | |
| 159 | 159 | // Determine if JSON_PRETTY_PRINT is available |
| 160 | - $this->pretty_print = defined( 'JSON_PRETTY_PRINT' ) ? JSON_PRETTY_PRINT : null; |
|
| 160 | + $this->pretty_print = defined('JSON_PRETTY_PRINT') ? JSON_PRETTY_PRINT : null; |
|
| 161 | 161 | |
| 162 | 162 | // Allow API request logging to be turned off |
| 163 | - $this->log_requests = apply_filters( 'give_api_log_requests', $this->log_requests ); |
|
| 163 | + $this->log_requests = apply_filters('give_api_log_requests', $this->log_requests); |
|
| 164 | 164 | |
| 165 | 165 | // Setup Give_Payment_Stats instance |
| 166 | 166 | $this->stats = new Give_Payment_Stats; |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @since 1.1 |
| 178 | 178 | */ |
| 179 | - public function add_endpoint( $rewrite_rules ) { |
|
| 180 | - add_rewrite_endpoint( 'give-api', EP_ALL ); |
|
| 179 | + public function add_endpoint($rewrite_rules) { |
|
| 180 | + add_rewrite_endpoint('give-api', EP_ALL); |
|
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | /** |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return string[] $vars New query vars |
| 192 | 192 | */ |
| 193 | - public function query_vars( $vars ) { |
|
| 193 | + public function query_vars($vars) { |
|
| 194 | 194 | |
| 195 | 195 | $vars[] = 'token'; |
| 196 | 196 | $vars[] = 'key'; |
@@ -241,11 +241,11 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public function get_default_version() { |
| 243 | 243 | |
| 244 | - $version = get_option( 'give_default_api_version' ); |
|
| 244 | + $version = get_option('give_default_api_version'); |
|
| 245 | 245 | |
| 246 | - if ( defined( 'GIVE_API_VERSION' ) ) { |
|
| 246 | + if (defined('GIVE_API_VERSION')) { |
|
| 247 | 247 | $version = GIVE_API_VERSION; |
| 248 | - } elseif ( ! $version ) { |
|
| 248 | + } elseif ( ! $version) { |
|
| 249 | 249 | $version = 'v1'; |
| 250 | 250 | } |
| 251 | 251 | |
@@ -266,14 +266,14 @@ discard block |
||
| 266 | 266 | |
| 267 | 267 | $version = $wp_query->query_vars['give-api']; |
| 268 | 268 | |
| 269 | - if ( strpos( $version, '/' ) ) { |
|
| 269 | + if (strpos($version, '/')) { |
|
| 270 | 270 | |
| 271 | - $version = explode( '/', $version ); |
|
| 272 | - $version = strtolower( $version[0] ); |
|
| 271 | + $version = explode('/', $version); |
|
| 272 | + $version = strtolower($version[0]); |
|
| 273 | 273 | |
| 274 | - $wp_query->query_vars['give-api'] = str_replace( $version . '/', '', $wp_query->query_vars['give-api'] ); |
|
| 274 | + $wp_query->query_vars['give-api'] = str_replace($version.'/', '', $wp_query->query_vars['give-api']); |
|
| 275 | 275 | |
| 276 | - if ( array_key_exists( $version, $this->versions ) ) { |
|
| 276 | + if (array_key_exists($version, $this->versions)) { |
|
| 277 | 277 | |
| 278 | 278 | $this->queried_version = $version; |
| 279 | 279 | |
@@ -310,32 +310,32 @@ discard block |
||
| 310 | 310 | $this->override = false; |
| 311 | 311 | |
| 312 | 312 | // Make sure we have both user and api key |
| 313 | - if ( ! empty( $wp_query->query_vars['give-api'] ) && ( $wp_query->query_vars['give-api'] != 'forms' || ! empty( $wp_query->query_vars['token'] ) ) ) { |
|
| 313 | + if ( ! empty($wp_query->query_vars['give-api']) && ($wp_query->query_vars['give-api'] != 'forms' || ! empty($wp_query->query_vars['token']))) { |
|
| 314 | 314 | |
| 315 | - if ( empty( $wp_query->query_vars['token'] ) || empty( $wp_query->query_vars['key'] ) ) { |
|
| 315 | + if (empty($wp_query->query_vars['token']) || empty($wp_query->query_vars['key'])) { |
|
| 316 | 316 | $this->missing_auth(); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 | // Retrieve the user by public API key and ensure they exist |
| 320 | - if ( ! ( $user = $this->get_user( $wp_query->query_vars['key'] ) ) ) { |
|
| 320 | + if ( ! ($user = $this->get_user($wp_query->query_vars['key']))) { |
|
| 321 | 321 | |
| 322 | 322 | $this->invalid_key(); |
| 323 | 323 | |
| 324 | 324 | } else { |
| 325 | 325 | |
| 326 | - $token = urldecode( $wp_query->query_vars['token'] ); |
|
| 327 | - $secret = $this->get_user_secret_key( $user ); |
|
| 328 | - $public = urldecode( $wp_query->query_vars['key'] ); |
|
| 326 | + $token = urldecode($wp_query->query_vars['token']); |
|
| 327 | + $secret = $this->get_user_secret_key($user); |
|
| 328 | + $public = urldecode($wp_query->query_vars['key']); |
|
| 329 | 329 | |
| 330 | - if ( hash_equals( md5( $secret . $public ), $token ) ) { |
|
| 330 | + if (hash_equals(md5($secret.$public), $token)) { |
|
| 331 | 331 | $this->is_valid_request = true; |
| 332 | 332 | } else { |
| 333 | 333 | $this->invalid_auth(); |
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | - } elseif ( ! empty( $wp_query->query_vars['give-api'] ) && $wp_query->query_vars['give-api'] == 'forms' ) { |
|
| 336 | + } elseif ( ! empty($wp_query->query_vars['give-api']) && $wp_query->query_vars['give-api'] == 'forms') { |
|
| 337 | 337 | $this->is_valid_request = true; |
| 338 | - $wp_query->set( 'key', 'public' ); |
|
| 338 | + $wp_query->set('key', 'public'); |
|
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | |
@@ -351,25 +351,25 @@ discard block |
||
| 351 | 351 | * |
| 352 | 352 | * @return bool if user ID is found, false otherwise |
| 353 | 353 | */ |
| 354 | - public function get_user( $key = '' ) { |
|
| 354 | + public function get_user($key = '') { |
|
| 355 | 355 | global $wpdb, $wp_query; |
| 356 | 356 | |
| 357 | - if ( empty( $key ) ) { |
|
| 358 | - $key = urldecode( $wp_query->query_vars['key'] ); |
|
| 357 | + if (empty($key)) { |
|
| 358 | + $key = urldecode($wp_query->query_vars['key']); |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | - if ( empty( $key ) ) { |
|
| 361 | + if (empty($key)) { |
|
| 362 | 362 | return false; |
| 363 | 363 | } |
| 364 | 364 | |
| 365 | - $user = get_transient( md5( 'give_api_user_' . $key ) ); |
|
| 365 | + $user = get_transient(md5('give_api_user_'.$key)); |
|
| 366 | 366 | |
| 367 | - if ( false === $user ) { |
|
| 368 | - $user = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key ) ); |
|
| 369 | - set_transient( md5( 'give_api_user_' . $key ), $user, DAY_IN_SECONDS ); |
|
| 367 | + if (false === $user) { |
|
| 368 | + $user = $wpdb->get_var($wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = %s LIMIT 1", $key)); |
|
| 369 | + set_transient(md5('give_api_user_'.$key), $user, DAY_IN_SECONDS); |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if ( $user != null ) { |
|
| 372 | + if ($user != null) { |
|
| 373 | 373 | $this->user_id = $user; |
| 374 | 374 | |
| 375 | 375 | return $user; |
@@ -378,37 +378,37 @@ discard block |
||
| 378 | 378 | return false; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - public function get_user_public_key( $user_id = 0 ) { |
|
| 381 | + public function get_user_public_key($user_id = 0) { |
|
| 382 | 382 | global $wpdb; |
| 383 | 383 | |
| 384 | - if ( empty( $user_id ) ) { |
|
| 384 | + if (empty($user_id)) { |
|
| 385 | 385 | return ''; |
| 386 | 386 | } |
| 387 | 387 | |
| 388 | - $cache_key = md5( 'give_api_user_public_key' . $user_id ); |
|
| 389 | - $user_public_key = get_transient( $cache_key ); |
|
| 388 | + $cache_key = md5('give_api_user_public_key'.$user_id); |
|
| 389 | + $user_public_key = get_transient($cache_key); |
|
| 390 | 390 | |
| 391 | - if ( empty( $user_public_key ) ) { |
|
| 392 | - $user_public_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id ) ); |
|
| 393 | - set_transient( $cache_key, $user_public_key, HOUR_IN_SECONDS ); |
|
| 391 | + if (empty($user_public_key)) { |
|
| 392 | + $user_public_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_public_key' AND user_id = %d", $user_id)); |
|
| 393 | + set_transient($cache_key, $user_public_key, HOUR_IN_SECONDS); |
|
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | return $user_public_key; |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | - public function get_user_secret_key( $user_id = 0 ) { |
|
| 399 | + public function get_user_secret_key($user_id = 0) { |
|
| 400 | 400 | global $wpdb; |
| 401 | 401 | |
| 402 | - if ( empty( $user_id ) ) { |
|
| 402 | + if (empty($user_id)) { |
|
| 403 | 403 | return ''; |
| 404 | 404 | } |
| 405 | 405 | |
| 406 | - $cache_key = md5( 'give_api_user_secret_key' . $user_id ); |
|
| 407 | - $user_secret_key = get_transient( $cache_key ); |
|
| 406 | + $cache_key = md5('give_api_user_secret_key'.$user_id); |
|
| 407 | + $user_secret_key = get_transient($cache_key); |
|
| 408 | 408 | |
| 409 | - if ( empty( $user_secret_key ) ) { |
|
| 410 | - $user_secret_key = $wpdb->get_var( $wpdb->prepare( "SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id ) ); |
|
| 411 | - set_transient( $cache_key, $user_secret_key, HOUR_IN_SECONDS ); |
|
| 409 | + if (empty($user_secret_key)) { |
|
| 410 | + $user_secret_key = $wpdb->get_var($wpdb->prepare("SELECT meta_key FROM $wpdb->usermeta WHERE meta_value = 'give_user_secret_key' AND user_id = %d", $user_id)); |
|
| 411 | + set_transient($cache_key, $user_secret_key, HOUR_IN_SECONDS); |
|
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | return $user_secret_key; |
@@ -424,10 +424,10 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | private function missing_auth() { |
| 426 | 426 | $error = array(); |
| 427 | - $error['error'] = esc_html__( 'You must specify both a token and API key.', 'give' ); |
|
| 427 | + $error['error'] = esc_html__('You must specify both a token and API key.', 'give'); |
|
| 428 | 428 | |
| 429 | 429 | $this->data = $error; |
| 430 | - $this->output( 401 ); |
|
| 430 | + $this->output(401); |
|
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | /** |
@@ -441,10 +441,10 @@ discard block |
||
| 441 | 441 | */ |
| 442 | 442 | private function invalid_auth() { |
| 443 | 443 | $error = array(); |
| 444 | - $error['error'] = esc_html__( 'Your request could not be authenticated.', 'give' ); |
|
| 444 | + $error['error'] = esc_html__('Your request could not be authenticated.', 'give'); |
|
| 445 | 445 | |
| 446 | 446 | $this->data = $error; |
| 447 | - $this->output( 403 ); |
|
| 447 | + $this->output(403); |
|
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | /** |
@@ -458,10 +458,10 @@ discard block |
||
| 458 | 458 | */ |
| 459 | 459 | private function invalid_key() { |
| 460 | 460 | $error = array(); |
| 461 | - $error['error'] = esc_html__( 'Invalid API key.', 'give' ); |
|
| 461 | + $error['error'] = esc_html__('Invalid API key.', 'give'); |
|
| 462 | 462 | |
| 463 | 463 | $this->data = $error; |
| 464 | - $this->output( 403 ); |
|
| 464 | + $this->output(403); |
|
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | /** |
@@ -474,10 +474,10 @@ discard block |
||
| 474 | 474 | */ |
| 475 | 475 | private function invalid_version() { |
| 476 | 476 | $error = array(); |
| 477 | - $error['error'] = esc_html__( 'Invalid API version.', 'give' ); |
|
| 477 | + $error['error'] = esc_html__('Invalid API version.', 'give'); |
|
| 478 | 478 | |
| 479 | 479 | $this->data = $error; |
| 480 | - $this->output( 404 ); |
|
| 480 | + $this->output(404); |
|
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | /** |
@@ -493,10 +493,10 @@ discard block |
||
| 493 | 493 | global $wp_query; |
| 494 | 494 | |
| 495 | 495 | // Start logging how long the request takes for logging |
| 496 | - $before = microtime( true ); |
|
| 496 | + $before = microtime(true); |
|
| 497 | 497 | |
| 498 | 498 | // Check for give-api var. Get out if not present |
| 499 | - if ( empty( $wp_query->query_vars['give-api'] ) ) { |
|
| 499 | + if (empty($wp_query->query_vars['give-api'])) { |
|
| 500 | 500 | return; |
| 501 | 501 | } |
| 502 | 502 | |
@@ -510,45 +510,45 @@ discard block |
||
| 510 | 510 | $this->validate_request(); |
| 511 | 511 | |
| 512 | 512 | // Only proceed if no errors have been noted |
| 513 | - if ( ! $this->is_valid_request ) { |
|
| 513 | + if ( ! $this->is_valid_request) { |
|
| 514 | 514 | return; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | - if ( ! defined( 'GIVE_DOING_API' ) ) { |
|
| 518 | - define( 'GIVE_DOING_API', true ); |
|
| 517 | + if ( ! defined('GIVE_DOING_API')) { |
|
| 518 | + define('GIVE_DOING_API', true); |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | 521 | $data = array(); |
| 522 | 522 | $this->routes = new $this->versions[$this->get_queried_version()]; |
| 523 | 523 | $this->routes->validate_request(); |
| 524 | 524 | |
| 525 | - switch ( $this->endpoint ) : |
|
| 525 | + switch ($this->endpoint) : |
|
| 526 | 526 | |
| 527 | 527 | case 'stats' : |
| 528 | 528 | |
| 529 | - $data = $this->routes->get_stats( array( |
|
| 530 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 531 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 532 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 533 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 534 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null |
|
| 535 | - ) ); |
|
| 529 | + $data = $this->routes->get_stats(array( |
|
| 530 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 531 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 532 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 533 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 534 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null |
|
| 535 | + )); |
|
| 536 | 536 | |
| 537 | 537 | break; |
| 538 | 538 | |
| 539 | 539 | case 'forms' : |
| 540 | 540 | |
| 541 | - $form = isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null; |
|
| 541 | + $form = isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null; |
|
| 542 | 542 | |
| 543 | - $data = $this->routes->get_forms( $form ); |
|
| 543 | + $data = $this->routes->get_forms($form); |
|
| 544 | 544 | |
| 545 | 545 | break; |
| 546 | 546 | |
| 547 | 547 | case 'donors' : |
| 548 | 548 | |
| 549 | - $customer = isset( $wp_query->query_vars['donor'] ) ? $wp_query->query_vars['donor'] : null; |
|
| 549 | + $customer = isset($wp_query->query_vars['donor']) ? $wp_query->query_vars['donor'] : null; |
|
| 550 | 550 | |
| 551 | - $data = $this->routes->get_customers( $customer ); |
|
| 551 | + $data = $this->routes->get_customers($customer); |
|
| 552 | 552 | |
| 553 | 553 | break; |
| 554 | 554 | |
@@ -561,14 +561,14 @@ discard block |
||
| 561 | 561 | endswitch; |
| 562 | 562 | |
| 563 | 563 | // Allow extensions to setup their own return data |
| 564 | - $this->data = apply_filters( 'give_api_output_data', $data, $this->endpoint, $this ); |
|
| 564 | + $this->data = apply_filters('give_api_output_data', $data, $this->endpoint, $this); |
|
| 565 | 565 | |
| 566 | - $after = microtime( true ); |
|
| 567 | - $request_time = ( $after - $before ); |
|
| 566 | + $after = microtime(true); |
|
| 567 | + $request_time = ($after - $before); |
|
| 568 | 568 | $this->data['request_speed'] = $request_time; |
| 569 | 569 | |
| 570 | 570 | // Log this API request, if enabled. We log it here because we have access to errors. |
| 571 | - $this->log_request( $this->data ); |
|
| 571 | + $this->log_request($this->data); |
|
| 572 | 572 | |
| 573 | 573 | // Send out data to the output function |
| 574 | 574 | $this->output(); |
@@ -598,25 +598,25 @@ discard block |
||
| 598 | 598 | global $wp_query; |
| 599 | 599 | |
| 600 | 600 | // Whitelist our query options |
| 601 | - $accepted = apply_filters( 'give_api_valid_query_modes', array( |
|
| 601 | + $accepted = apply_filters('give_api_valid_query_modes', array( |
|
| 602 | 602 | 'stats', |
| 603 | 603 | 'forms', |
| 604 | 604 | 'donors', |
| 605 | 605 | 'donations' |
| 606 | - ) ); |
|
| 606 | + )); |
|
| 607 | 607 | |
| 608 | - $query = isset( $wp_query->query_vars['give-api'] ) ? $wp_query->query_vars['give-api'] : null; |
|
| 609 | - $query = str_replace( $this->queried_version . '/', '', $query ); |
|
| 608 | + $query = isset($wp_query->query_vars['give-api']) ? $wp_query->query_vars['give-api'] : null; |
|
| 609 | + $query = str_replace($this->queried_version.'/', '', $query); |
|
| 610 | 610 | |
| 611 | 611 | $error = array(); |
| 612 | 612 | |
| 613 | 613 | // Make sure our query is valid |
| 614 | - if ( ! in_array( $query, $accepted ) ) { |
|
| 615 | - $error['error'] = esc_html__( 'Invalid query.', 'give' ); |
|
| 614 | + if ( ! in_array($query, $accepted)) { |
|
| 615 | + $error['error'] = esc_html__('Invalid query.', 'give'); |
|
| 616 | 616 | |
| 617 | 617 | $this->data = $error; |
| 618 | 618 | // 400 is Bad Request |
| 619 | - $this->output( 400 ); |
|
| 619 | + $this->output(400); |
|
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | $this->endpoint = $query; |
@@ -633,7 +633,7 @@ discard block |
||
| 633 | 633 | public function get_paged() { |
| 634 | 634 | global $wp_query; |
| 635 | 635 | |
| 636 | - return isset( $wp_query->query_vars['page'] ) ? $wp_query->query_vars['page'] : 1; |
|
| 636 | + return isset($wp_query->query_vars['page']) ? $wp_query->query_vars['page'] : 1; |
|
| 637 | 637 | } |
| 638 | 638 | |
| 639 | 639 | |
@@ -648,13 +648,13 @@ discard block |
||
| 648 | 648 | public function per_page() { |
| 649 | 649 | global $wp_query; |
| 650 | 650 | |
| 651 | - $per_page = isset( $wp_query->query_vars['number'] ) ? $wp_query->query_vars['number'] : 10; |
|
| 651 | + $per_page = isset($wp_query->query_vars['number']) ? $wp_query->query_vars['number'] : 10; |
|
| 652 | 652 | |
| 653 | - if ( $per_page < 0 && $this->get_query_mode() == 'donors' ) { |
|
| 653 | + if ($per_page < 0 && $this->get_query_mode() == 'donors') { |
|
| 654 | 654 | $per_page = 99999999; |
| 655 | 655 | } // Customers query doesn't support -1 |
| 656 | 656 | |
| 657 | - return apply_filters( 'give_api_results_per_page', $per_page ); |
|
| 657 | + return apply_filters('give_api_results_per_page', $per_page); |
|
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /** |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * |
| 668 | 668 | * @return array $dates |
| 669 | 669 | */ |
| 670 | - public function get_dates( $args = array() ) { |
|
| 670 | + public function get_dates($args = array()) { |
|
| 671 | 671 | $dates = array(); |
| 672 | 672 | |
| 673 | 673 | $defaults = array( |
@@ -678,60 +678,60 @@ discard block |
||
| 678 | 678 | 'enddate' => null |
| 679 | 679 | ); |
| 680 | 680 | |
| 681 | - $args = wp_parse_args( $args, $defaults ); |
|
| 681 | + $args = wp_parse_args($args, $defaults); |
|
| 682 | 682 | |
| 683 | - $current_time = current_time( 'timestamp' ); |
|
| 683 | + $current_time = current_time('timestamp'); |
|
| 684 | 684 | |
| 685 | - if ( 'range' === $args['date'] ) { |
|
| 686 | - $startdate = strtotime( $args['startdate'] ); |
|
| 687 | - $enddate = strtotime( $args['enddate'] ); |
|
| 688 | - $dates['day_start'] = date( 'd', $startdate ); |
|
| 689 | - $dates['day_end'] = date( 'd', $enddate ); |
|
| 690 | - $dates['m_start'] = date( 'n', $startdate ); |
|
| 691 | - $dates['m_end'] = date( 'n', $enddate ); |
|
| 692 | - $dates['year'] = date( 'Y', $startdate ); |
|
| 693 | - $dates['year_end'] = date( 'Y', $enddate ); |
|
| 685 | + if ('range' === $args['date']) { |
|
| 686 | + $startdate = strtotime($args['startdate']); |
|
| 687 | + $enddate = strtotime($args['enddate']); |
|
| 688 | + $dates['day_start'] = date('d', $startdate); |
|
| 689 | + $dates['day_end'] = date('d', $enddate); |
|
| 690 | + $dates['m_start'] = date('n', $startdate); |
|
| 691 | + $dates['m_end'] = date('n', $enddate); |
|
| 692 | + $dates['year'] = date('Y', $startdate); |
|
| 693 | + $dates['year_end'] = date('Y', $enddate); |
|
| 694 | 694 | } else { |
| 695 | 695 | // Modify dates based on predefined ranges |
| 696 | - switch ( $args['date'] ) : |
|
| 696 | + switch ($args['date']) : |
|
| 697 | 697 | |
| 698 | 698 | case 'this_month' : |
| 699 | 699 | $dates['day'] = null; |
| 700 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 701 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 702 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 700 | + $dates['m_start'] = date('n', $current_time); |
|
| 701 | + $dates['m_end'] = date('n', $current_time); |
|
| 702 | + $dates['year'] = date('Y', $current_time); |
|
| 703 | 703 | break; |
| 704 | 704 | |
| 705 | 705 | case 'last_month' : |
| 706 | 706 | $dates['day'] = null; |
| 707 | - $dates['m_start'] = date( 'n', $current_time ) == 1 ? 12 : date( 'n', $current_time ) - 1; |
|
| 707 | + $dates['m_start'] = date('n', $current_time) == 1 ? 12 : date('n', $current_time) - 1; |
|
| 708 | 708 | $dates['m_end'] = $dates['m_start']; |
| 709 | - $dates['year'] = date( 'n', $current_time ) == 1 ? date( 'Y', $current_time ) - 1 : date( 'Y', $current_time ); |
|
| 709 | + $dates['year'] = date('n', $current_time) == 1 ? date('Y', $current_time) - 1 : date('Y', $current_time); |
|
| 710 | 710 | break; |
| 711 | 711 | |
| 712 | 712 | case 'today' : |
| 713 | - $dates['day'] = date( 'd', $current_time ); |
|
| 714 | - $dates['m_start'] = date( 'n', $current_time ); |
|
| 715 | - $dates['m_end'] = date( 'n', $current_time ); |
|
| 716 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 713 | + $dates['day'] = date('d', $current_time); |
|
| 714 | + $dates['m_start'] = date('n', $current_time); |
|
| 715 | + $dates['m_end'] = date('n', $current_time); |
|
| 716 | + $dates['year'] = date('Y', $current_time); |
|
| 717 | 717 | break; |
| 718 | 718 | |
| 719 | 719 | case 'yesterday' : |
| 720 | 720 | |
| 721 | - $year = date( 'Y', $current_time ); |
|
| 722 | - $month = date( 'n', $current_time ); |
|
| 723 | - $day = date( 'd', $current_time ); |
|
| 721 | + $year = date('Y', $current_time); |
|
| 722 | + $month = date('n', $current_time); |
|
| 723 | + $day = date('d', $current_time); |
|
| 724 | 724 | |
| 725 | - if ( $month == 1 && $day == 1 ) { |
|
| 725 | + if ($month == 1 && $day == 1) { |
|
| 726 | 726 | |
| 727 | 727 | $year -= 1; |
| 728 | 728 | $month = 12; |
| 729 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 729 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 730 | 730 | |
| 731 | - } elseif ( $month > 1 && $day == 1 ) { |
|
| 731 | + } elseif ($month > 1 && $day == 1) { |
|
| 732 | 732 | |
| 733 | 733 | $month -= 1; |
| 734 | - $day = cal_days_in_month( CAL_GREGORIAN, $month, $year ); |
|
| 734 | + $day = cal_days_in_month(CAL_GREGORIAN, $month, $year); |
|
| 735 | 735 | |
| 736 | 736 | } else { |
| 737 | 737 | |
@@ -747,65 +747,65 @@ discard block |
||
| 747 | 747 | break; |
| 748 | 748 | |
| 749 | 749 | case 'this_quarter' : |
| 750 | - $month_now = date( 'n', $current_time ); |
|
| 750 | + $month_now = date('n', $current_time); |
|
| 751 | 751 | |
| 752 | 752 | $dates['day'] = null; |
| 753 | 753 | |
| 754 | - if ( $month_now <= 3 ) { |
|
| 754 | + if ($month_now <= 3) { |
|
| 755 | 755 | |
| 756 | 756 | $dates['m_start'] = 1; |
| 757 | 757 | $dates['m_end'] = 3; |
| 758 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 758 | + $dates['year'] = date('Y', $current_time); |
|
| 759 | 759 | |
| 760 | - } else if ( $month_now <= 6 ) { |
|
| 760 | + } else if ($month_now <= 6) { |
|
| 761 | 761 | |
| 762 | 762 | $dates['m_start'] = 4; |
| 763 | 763 | $dates['m_end'] = 6; |
| 764 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 764 | + $dates['year'] = date('Y', $current_time); |
|
| 765 | 765 | |
| 766 | - } else if ( $month_now <= 9 ) { |
|
| 766 | + } else if ($month_now <= 9) { |
|
| 767 | 767 | |
| 768 | 768 | $dates['m_start'] = 7; |
| 769 | 769 | $dates['m_end'] = 9; |
| 770 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 770 | + $dates['year'] = date('Y', $current_time); |
|
| 771 | 771 | |
| 772 | 772 | } else { |
| 773 | 773 | |
| 774 | 774 | $dates['m_start'] = 10; |
| 775 | 775 | $dates['m_end'] = 12; |
| 776 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 776 | + $dates['year'] = date('Y', $current_time); |
|
| 777 | 777 | |
| 778 | 778 | } |
| 779 | 779 | break; |
| 780 | 780 | |
| 781 | 781 | case 'last_quarter' : |
| 782 | - $month_now = date( 'n', $current_time ); |
|
| 782 | + $month_now = date('n', $current_time); |
|
| 783 | 783 | |
| 784 | 784 | $dates['day'] = null; |
| 785 | 785 | |
| 786 | - if ( $month_now <= 3 ) { |
|
| 786 | + if ($month_now <= 3) { |
|
| 787 | 787 | |
| 788 | 788 | $dates['m_start'] = 10; |
| 789 | 789 | $dates['m_end'] = 12; |
| 790 | - $dates['year'] = date( 'Y', $current_time ) - 1; // Previous year |
|
| 790 | + $dates['year'] = date('Y', $current_time) - 1; // Previous year |
|
| 791 | 791 | |
| 792 | - } else if ( $month_now <= 6 ) { |
|
| 792 | + } else if ($month_now <= 6) { |
|
| 793 | 793 | |
| 794 | 794 | $dates['m_start'] = 1; |
| 795 | 795 | $dates['m_end'] = 3; |
| 796 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 796 | + $dates['year'] = date('Y', $current_time); |
|
| 797 | 797 | |
| 798 | - } else if ( $month_now <= 9 ) { |
|
| 798 | + } else if ($month_now <= 9) { |
|
| 799 | 799 | |
| 800 | 800 | $dates['m_start'] = 4; |
| 801 | 801 | $dates['m_end'] = 6; |
| 802 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 802 | + $dates['year'] = date('Y', $current_time); |
|
| 803 | 803 | |
| 804 | 804 | } else { |
| 805 | 805 | |
| 806 | 806 | $dates['m_start'] = 7; |
| 807 | 807 | $dates['m_end'] = 9; |
| 808 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 808 | + $dates['year'] = date('Y', $current_time); |
|
| 809 | 809 | |
| 810 | 810 | } |
| 811 | 811 | break; |
@@ -814,14 +814,14 @@ discard block |
||
| 814 | 814 | $dates['day'] = null; |
| 815 | 815 | $dates['m_start'] = null; |
| 816 | 816 | $dates['m_end'] = null; |
| 817 | - $dates['year'] = date( 'Y', $current_time ); |
|
| 817 | + $dates['year'] = date('Y', $current_time); |
|
| 818 | 818 | break; |
| 819 | 819 | |
| 820 | 820 | case 'last_year' : |
| 821 | 821 | $dates['day'] = null; |
| 822 | 822 | $dates['m_start'] = null; |
| 823 | 823 | $dates['m_end'] = null; |
| 824 | - $dates['year'] = date( 'Y', $current_time ) - 1; |
|
| 824 | + $dates['year'] = date('Y', $current_time) - 1; |
|
| 825 | 825 | break; |
| 826 | 826 | |
| 827 | 827 | endswitch; |
@@ -835,7 +835,7 @@ discard block |
||
| 835 | 835 | * @param object $dates The dates used for retrieving earnings/donations |
| 836 | 836 | */ |
| 837 | 837 | |
| 838 | - return apply_filters( 'give_api_stat_dates', $dates ); |
|
| 838 | + return apply_filters('give_api_stat_dates', $dates); |
|
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
@@ -850,11 +850,11 @@ discard block |
||
| 850 | 850 | * |
| 851 | 851 | * @return array $customers Multidimensional array of the customers |
| 852 | 852 | */ |
| 853 | - public function get_customers( $customer = null ) { |
|
| 853 | + public function get_customers($customer = null) { |
|
| 854 | 854 | |
| 855 | 855 | $customers = array(); |
| 856 | 856 | $error = array(); |
| 857 | - if ( ! user_can( $this->user_id, 'view_give_sensitive_data' ) && ! $this->override ) { |
|
| 857 | + if ( ! user_can($this->user_id, 'view_give_sensitive_data') && ! $this->override) { |
|
| 858 | 858 | return $customers; |
| 859 | 859 | } |
| 860 | 860 | |
@@ -862,64 +862,64 @@ discard block |
||
| 862 | 862 | |
| 863 | 863 | $paged = $this->get_paged(); |
| 864 | 864 | $per_page = $this->per_page(); |
| 865 | - $offset = $per_page * ( $paged - 1 ); |
|
| 865 | + $offset = $per_page * ($paged - 1); |
|
| 866 | 866 | |
| 867 | - if ( is_numeric( $customer ) ) { |
|
| 867 | + if (is_numeric($customer)) { |
|
| 868 | 868 | $field = 'id'; |
| 869 | 869 | } else { |
| 870 | 870 | $field = 'email'; |
| 871 | 871 | } |
| 872 | 872 | |
| 873 | - $customer_query = Give()->customers->get_customers( array( |
|
| 873 | + $customer_query = Give()->customers->get_customers(array( |
|
| 874 | 874 | 'number' => $per_page, |
| 875 | 875 | 'offset' => $offset, |
| 876 | 876 | $field => $customer |
| 877 | - ) ); |
|
| 877 | + )); |
|
| 878 | 878 | $customer_count = 0; |
| 879 | 879 | |
| 880 | - if ( $customer_query ) { |
|
| 880 | + if ($customer_query) { |
|
| 881 | 881 | |
| 882 | - foreach ( $customer_query as $customer_obj ) { |
|
| 882 | + foreach ($customer_query as $customer_obj) { |
|
| 883 | 883 | |
| 884 | - $names = explode( ' ', $customer_obj->name ); |
|
| 885 | - $first_name = ! empty( $names[0] ) ? $names[0] : ''; |
|
| 884 | + $names = explode(' ', $customer_obj->name); |
|
| 885 | + $first_name = ! empty($names[0]) ? $names[0] : ''; |
|
| 886 | 886 | $last_name = ''; |
| 887 | - if ( ! empty( $names[1] ) ) { |
|
| 888 | - unset( $names[0] ); |
|
| 889 | - $last_name = implode( ' ', $names ); |
|
| 887 | + if ( ! empty($names[1])) { |
|
| 888 | + unset($names[0]); |
|
| 889 | + $last_name = implode(' ', $names); |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | - $customers['donors'][ $customer_count ]['info']['user_id'] = ''; |
|
| 893 | - $customers['donors'][ $customer_count ]['info']['username'] = ''; |
|
| 894 | - $customers['donors'][ $customer_count ]['info']['display_name'] = ''; |
|
| 895 | - $customers['donors'][ $customer_count ]['info']['customer_id'] = $customer_obj->id; |
|
| 896 | - $customers['donors'][ $customer_count ]['info']['first_name'] = $first_name; |
|
| 897 | - $customers['donors'][ $customer_count ]['info']['last_name'] = $last_name; |
|
| 898 | - $customers['donors'][ $customer_count ]['info']['email'] = $customer_obj->email; |
|
| 892 | + $customers['donors'][$customer_count]['info']['user_id'] = ''; |
|
| 893 | + $customers['donors'][$customer_count]['info']['username'] = ''; |
|
| 894 | + $customers['donors'][$customer_count]['info']['display_name'] = ''; |
|
| 895 | + $customers['donors'][$customer_count]['info']['customer_id'] = $customer_obj->id; |
|
| 896 | + $customers['donors'][$customer_count]['info']['first_name'] = $first_name; |
|
| 897 | + $customers['donors'][$customer_count]['info']['last_name'] = $last_name; |
|
| 898 | + $customers['donors'][$customer_count]['info']['email'] = $customer_obj->email; |
|
| 899 | 899 | |
| 900 | - if ( ! empty( $customer_obj->user_id ) ) { |
|
| 900 | + if ( ! empty($customer_obj->user_id)) { |
|
| 901 | 901 | |
| 902 | - $user_data = get_userdata( $customer_obj->user_id ); |
|
| 902 | + $user_data = get_userdata($customer_obj->user_id); |
|
| 903 | 903 | |
| 904 | 904 | // Customer with registered account |
| 905 | - $customers['donors'][ $customer_count ]['info']['user_id'] = $customer_obj->user_id; |
|
| 906 | - $customers['donors'][ $customer_count ]['info']['username'] = $user_data->user_login; |
|
| 907 | - $customers['donors'][ $customer_count ]['info']['display_name'] = $user_data->display_name; |
|
| 905 | + $customers['donors'][$customer_count]['info']['user_id'] = $customer_obj->user_id; |
|
| 906 | + $customers['donors'][$customer_count]['info']['username'] = $user_data->user_login; |
|
| 907 | + $customers['donors'][$customer_count]['info']['display_name'] = $user_data->display_name; |
|
| 908 | 908 | |
| 909 | 909 | } |
| 910 | 910 | |
| 911 | - $customers['donors'][ $customer_count ]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 912 | - $customers['donors'][ $customer_count ]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 911 | + $customers['donors'][$customer_count]['stats']['total_donations'] = $customer_obj->purchase_count; |
|
| 912 | + $customers['donors'][$customer_count]['stats']['total_spent'] = $customer_obj->purchase_value; |
|
| 913 | 913 | |
| 914 | - $customer_count ++; |
|
| 914 | + $customer_count++; |
|
| 915 | 915 | |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | - } elseif ( $customer ) { |
|
| 918 | + } elseif ($customer) { |
|
| 919 | 919 | |
| 920 | 920 | $error['error'] = sprintf( |
| 921 | 921 | /* translators: %s: customer */ |
| 922 | - esc_html__( 'Donor %s not found.', 'give' ), |
|
| 922 | + esc_html__('Donor %s not found.', 'give'), |
|
| 923 | 923 | $customer |
| 924 | 924 | ); |
| 925 | 925 | |
@@ -927,7 +927,7 @@ discard block |
||
| 927 | 927 | |
| 928 | 928 | } else { |
| 929 | 929 | |
| 930 | - $error['error'] = esc_html__( 'No donors found.', 'give' ); |
|
| 930 | + $error['error'] = esc_html__('No donors found.', 'give'); |
|
| 931 | 931 | |
| 932 | 932 | return $error; |
| 933 | 933 | |
@@ -946,38 +946,38 @@ discard block |
||
| 946 | 946 | * |
| 947 | 947 | * @return array $customers Multidimensional array of the forms |
| 948 | 948 | */ |
| 949 | - public function get_forms( $form = null ) { |
|
| 949 | + public function get_forms($form = null) { |
|
| 950 | 950 | |
| 951 | 951 | $forms = array(); |
| 952 | 952 | $error = array(); |
| 953 | 953 | |
| 954 | - if ( $form == null ) { |
|
| 954 | + if ($form == null) { |
|
| 955 | 955 | $forms['forms'] = array(); |
| 956 | 956 | |
| 957 | - $form_list = get_posts( array( |
|
| 957 | + $form_list = get_posts(array( |
|
| 958 | 958 | 'post_type' => 'give_forms', |
| 959 | 959 | 'posts_per_page' => $this->per_page(), |
| 960 | 960 | 'suppress_filters' => true, |
| 961 | 961 | 'paged' => $this->get_paged() |
| 962 | - ) ); |
|
| 962 | + )); |
|
| 963 | 963 | |
| 964 | - if ( $form_list ) { |
|
| 964 | + if ($form_list) { |
|
| 965 | 965 | $i = 0; |
| 966 | - foreach ( $form_list as $form_info ) { |
|
| 967 | - $forms['forms'][ $i ] = $this->get_form_data( $form_info ); |
|
| 968 | - $i ++; |
|
| 966 | + foreach ($form_list as $form_info) { |
|
| 967 | + $forms['forms'][$i] = $this->get_form_data($form_info); |
|
| 968 | + $i++; |
|
| 969 | 969 | } |
| 970 | 970 | } |
| 971 | 971 | } else { |
| 972 | - if ( get_post_type( $form ) == 'give_forms' ) { |
|
| 973 | - $form_info = get_post( $form ); |
|
| 972 | + if (get_post_type($form) == 'give_forms') { |
|
| 973 | + $form_info = get_post($form); |
|
| 974 | 974 | |
| 975 | - $forms['forms'][0] = $this->get_form_data( $form_info ); |
|
| 975 | + $forms['forms'][0] = $this->get_form_data($form_info); |
|
| 976 | 976 | |
| 977 | 977 | } else { |
| 978 | 978 | $error['error'] = sprintf( |
| 979 | 979 | /* translators: %s: form */ |
| 980 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 980 | + esc_html__('Form %s not found.', 'give'), |
|
| 981 | 981 | $form |
| 982 | 982 | ); |
| 983 | 983 | |
@@ -997,7 +997,7 @@ discard block |
||
| 997 | 997 | * |
| 998 | 998 | * @return array Array of post data to return back in the API |
| 999 | 999 | */ |
| 1000 | - private function get_form_data( $form_info ) { |
|
| 1000 | + private function get_form_data($form_info) { |
|
| 1001 | 1001 | |
| 1002 | 1002 | $form = array(); |
| 1003 | 1003 | |
@@ -1007,50 +1007,50 @@ discard block |
||
| 1007 | 1007 | $form['info']['create_date'] = $form_info->post_date; |
| 1008 | 1008 | $form['info']['modified_date'] = $form_info->post_modified; |
| 1009 | 1009 | $form['info']['status'] = $form_info->post_status; |
| 1010 | - $form['info']['link'] = html_entity_decode( $form_info->guid ); |
|
| 1011 | - $form['info']['content'] = get_post_meta( $form_info->ID, '_give_form_content', true ); |
|
| 1012 | - $form['info']['thumbnail'] = wp_get_attachment_url( get_post_thumbnail_id( $form_info->ID ) ); |
|
| 1010 | + $form['info']['link'] = html_entity_decode($form_info->guid); |
|
| 1011 | + $form['info']['content'] = get_post_meta($form_info->ID, '_give_form_content', true); |
|
| 1012 | + $form['info']['thumbnail'] = wp_get_attachment_url(get_post_thumbnail_id($form_info->ID)); |
|
| 1013 | 1013 | |
| 1014 | - if ( give_get_option( 'enable_categories' ) == 'on' ) { |
|
| 1015 | - $form['info']['category'] = get_the_terms( $form_info, 'give_forms_category' ); |
|
| 1016 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1014 | + if (give_get_option('enable_categories') == 'on') { |
|
| 1015 | + $form['info']['category'] = get_the_terms($form_info, 'give_forms_category'); |
|
| 1016 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1017 | 1017 | } |
| 1018 | - if ( give_get_option( 'enable_tags' ) == 'on' ) { |
|
| 1019 | - $form['info']['tags'] = get_the_terms( $form_info, 'give_forms_tag' ); |
|
| 1018 | + if (give_get_option('enable_tags') == 'on') { |
|
| 1019 | + $form['info']['tags'] = get_the_terms($form_info, 'give_forms_tag'); |
|
| 1020 | 1020 | } |
| 1021 | 1021 | |
| 1022 | - if ( user_can( $this->user_id, 'view_give_reports' ) || $this->override ) { |
|
| 1023 | - $form['stats']['total']['donations'] = give_get_form_sales_stats( $form_info->ID ); |
|
| 1024 | - $form['stats']['total']['earnings'] = give_get_form_earnings_stats( $form_info->ID ); |
|
| 1025 | - $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales( $form_info->ID ); |
|
| 1026 | - $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings( $form_info->ID ); |
|
| 1022 | + if (user_can($this->user_id, 'view_give_reports') || $this->override) { |
|
| 1023 | + $form['stats']['total']['donations'] = give_get_form_sales_stats($form_info->ID); |
|
| 1024 | + $form['stats']['total']['earnings'] = give_get_form_earnings_stats($form_info->ID); |
|
| 1025 | + $form['stats']['monthly_average']['donations'] = give_get_average_monthly_form_sales($form_info->ID); |
|
| 1026 | + $form['stats']['monthly_average']['earnings'] = give_get_average_monthly_form_earnings($form_info->ID); |
|
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | 1029 | $counter = 0; |
| 1030 | - if ( give_has_variable_prices( $form_info->ID ) ) { |
|
| 1031 | - foreach ( give_get_variable_prices( $form_info->ID ) as $price ) { |
|
| 1032 | - $counter ++; |
|
| 1030 | + if (give_has_variable_prices($form_info->ID)) { |
|
| 1031 | + foreach (give_get_variable_prices($form_info->ID) as $price) { |
|
| 1032 | + $counter++; |
|
| 1033 | 1033 | //muli-level item |
| 1034 | - $level = isset( $price['_give_text'] ) ? $price['_give_text'] : 'level-' . $counter; |
|
| 1035 | - $form['pricing'][ sanitize_key( $level ) ] = $price['_give_amount']; |
|
| 1034 | + $level = isset($price['_give_text']) ? $price['_give_text'] : 'level-'.$counter; |
|
| 1035 | + $form['pricing'][sanitize_key($level)] = $price['_give_amount']; |
|
| 1036 | 1036 | |
| 1037 | 1037 | } |
| 1038 | 1038 | } else { |
| 1039 | - $form['pricing']['amount'] = give_get_form_price( $form_info->ID ); |
|
| 1039 | + $form['pricing']['amount'] = give_get_form_price($form_info->ID); |
|
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | - if ( user_can( $this->user_id, 'view_give_sensitive_data' ) || $this->override ) { |
|
| 1042 | + if (user_can($this->user_id, 'view_give_sensitive_data') || $this->override) { |
|
| 1043 | 1043 | |
| 1044 | 1044 | /** |
| 1045 | 1045 | * Fires when generating API sensitive data. |
| 1046 | 1046 | * |
| 1047 | 1047 | * @since 1.1 |
| 1048 | 1048 | */ |
| 1049 | - do_action( 'give_api_sensitive_data' ); |
|
| 1049 | + do_action('give_api_sensitive_data'); |
|
| 1050 | 1050 | |
| 1051 | 1051 | } |
| 1052 | 1052 | |
| 1053 | - return apply_filters( 'give_api_forms_form', $form ); |
|
| 1053 | + return apply_filters('give_api_forms_form', $form); |
|
| 1054 | 1054 | |
| 1055 | 1055 | } |
| 1056 | 1056 | |
@@ -1065,7 +1065,7 @@ discard block |
||
| 1065 | 1065 | * |
| 1066 | 1066 | * @return array |
| 1067 | 1067 | */ |
| 1068 | - public function get_stats( $args = array() ) { |
|
| 1068 | + public function get_stats($args = array()) { |
|
| 1069 | 1069 | $defaults = array( |
| 1070 | 1070 | 'type' => null, |
| 1071 | 1071 | 'form' => null, |
@@ -1074,9 +1074,9 @@ discard block |
||
| 1074 | 1074 | 'enddate' => null |
| 1075 | 1075 | ); |
| 1076 | 1076 | |
| 1077 | - $args = wp_parse_args( $args, $defaults ); |
|
| 1077 | + $args = wp_parse_args($args, $defaults); |
|
| 1078 | 1078 | |
| 1079 | - $dates = $this->get_dates( $args ); |
|
| 1079 | + $dates = $this->get_dates($args); |
|
| 1080 | 1080 | |
| 1081 | 1081 | $stats = array(); |
| 1082 | 1082 | $earnings = array( |
@@ -1087,41 +1087,41 @@ discard block |
||
| 1087 | 1087 | ); |
| 1088 | 1088 | $error = array(); |
| 1089 | 1089 | |
| 1090 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1090 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1091 | 1091 | return $stats; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - if ( $args['type'] == 'donations' ) { |
|
| 1094 | + if ($args['type'] == 'donations') { |
|
| 1095 | 1095 | |
| 1096 | - if ( $args['form'] == null ) { |
|
| 1097 | - if ( $args['date'] == null ) { |
|
| 1096 | + if ($args['form'] == null) { |
|
| 1097 | + if ($args['date'] == null) { |
|
| 1098 | 1098 | $sales = $this->get_default_sales_stats(); |
| 1099 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1099 | + } elseif ($args['date'] === 'range') { |
|
| 1100 | 1100 | // Return sales for a date range |
| 1101 | 1101 | |
| 1102 | 1102 | // Ensure the end date is later than the start date |
| 1103 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1104 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1103 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1104 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1105 | 1105 | } |
| 1106 | 1106 | |
| 1107 | 1107 | // Ensure both the start and end date are specified |
| 1108 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1109 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1108 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1109 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1110 | 1110 | } |
| 1111 | 1111 | |
| 1112 | 1112 | $total = 0; |
| 1113 | 1113 | |
| 1114 | 1114 | // Loop through the years |
| 1115 | 1115 | $y = $dates['year']; |
| 1116 | - while ( $y <= $dates['year_end'] ) : |
|
| 1116 | + while ($y <= $dates['year_end']) : |
|
| 1117 | 1117 | |
| 1118 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1118 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1119 | 1119 | $month_start = $dates['m_start']; |
| 1120 | 1120 | $month_end = $dates['m_end']; |
| 1121 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1121 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1122 | 1122 | $month_start = $dates['m_start']; |
| 1123 | 1123 | $month_end = 12; |
| 1124 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1124 | + } elseif ($y == $dates['year_end']) { |
|
| 1125 | 1125 | $month_start = 1; |
| 1126 | 1126 | $month_end = $dates['m_end']; |
| 1127 | 1127 | } else { |
@@ -1130,113 +1130,113 @@ discard block |
||
| 1130 | 1130 | } |
| 1131 | 1131 | |
| 1132 | 1132 | $i = $month_start; |
| 1133 | - while ( $i <= $month_end ) : |
|
| 1133 | + while ($i <= $month_end) : |
|
| 1134 | 1134 | |
| 1135 | - if ( $i == $dates['m_start'] ) { |
|
| 1135 | + if ($i == $dates['m_start']) { |
|
| 1136 | 1136 | $d = $dates['day_start']; |
| 1137 | 1137 | } else { |
| 1138 | 1138 | $d = 1; |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | - if ( $i == $dates['m_end'] ) { |
|
| 1141 | + if ($i == $dates['m_end']) { |
|
| 1142 | 1142 | $num_of_days = $dates['day_end']; |
| 1143 | 1143 | } else { |
| 1144 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1144 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | - while ( $d <= $num_of_days ) : |
|
| 1148 | - $sale_count = give_get_sales_by_date( $d, $i, $y ); |
|
| 1149 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1150 | - if ( ! isset( $sales['sales'][ $date_key ] ) ) { |
|
| 1151 | - $sales['sales'][ $date_key ] = 0; |
|
| 1147 | + while ($d <= $num_of_days) : |
|
| 1148 | + $sale_count = give_get_sales_by_date($d, $i, $y); |
|
| 1149 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1150 | + if ( ! isset($sales['sales'][$date_key])) { |
|
| 1151 | + $sales['sales'][$date_key] = 0; |
|
| 1152 | 1152 | } |
| 1153 | - $sales['sales'][ $date_key ] += $sale_count; |
|
| 1153 | + $sales['sales'][$date_key] += $sale_count; |
|
| 1154 | 1154 | $total += $sale_count; |
| 1155 | - $d ++; |
|
| 1155 | + $d++; |
|
| 1156 | 1156 | endwhile; |
| 1157 | - $i ++; |
|
| 1157 | + $i++; |
|
| 1158 | 1158 | endwhile; |
| 1159 | 1159 | |
| 1160 | - $y ++; |
|
| 1160 | + $y++; |
|
| 1161 | 1161 | endwhile; |
| 1162 | 1162 | |
| 1163 | 1163 | $sales['totals'] = $total; |
| 1164 | 1164 | } else { |
| 1165 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1165 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1166 | 1166 | $sales_count = 0; |
| 1167 | 1167 | |
| 1168 | 1168 | // Loop through the months |
| 1169 | 1169 | $month = $dates['m_start']; |
| 1170 | 1170 | |
| 1171 | - while ( $month <= $dates['m_end'] ) : |
|
| 1172 | - $sales_count += give_get_sales_by_date( null, $month, $dates['year'] ); |
|
| 1173 | - $month ++; |
|
| 1171 | + while ($month <= $dates['m_end']) : |
|
| 1172 | + $sales_count += give_get_sales_by_date(null, $month, $dates['year']); |
|
| 1173 | + $month++; |
|
| 1174 | 1174 | endwhile; |
| 1175 | 1175 | |
| 1176 | - $sales['donations'][ $args['date'] ] = $sales_count; |
|
| 1176 | + $sales['donations'][$args['date']] = $sales_count; |
|
| 1177 | 1177 | } else { |
| 1178 | - $sales['donations'][ $args['date'] ] = give_get_sales_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1178 | + $sales['donations'][$args['date']] = give_get_sales_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1179 | 1179 | } |
| 1180 | 1180 | } |
| 1181 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1182 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1181 | + } elseif ($args['form'] == 'all') { |
|
| 1182 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1183 | 1183 | $i = 0; |
| 1184 | - foreach ( $forms as $form_info ) { |
|
| 1185 | - $sales['donations'][ $i ] = array( $form_info->post_name => give_get_form_sales_stats( $form_info->ID ) ); |
|
| 1186 | - $i ++; |
|
| 1184 | + foreach ($forms as $form_info) { |
|
| 1185 | + $sales['donations'][$i] = array($form_info->post_name => give_get_form_sales_stats($form_info->ID)); |
|
| 1186 | + $i++; |
|
| 1187 | 1187 | } |
| 1188 | 1188 | } else { |
| 1189 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1190 | - $form_info = get_post( $args['form'] ); |
|
| 1191 | - $sales['donations'][0] = array( $form_info->post_name => give_get_form_sales_stats( $args['form'] ) ); |
|
| 1189 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1190 | + $form_info = get_post($args['form']); |
|
| 1191 | + $sales['donations'][0] = array($form_info->post_name => give_get_form_sales_stats($args['form'])); |
|
| 1192 | 1192 | } else { |
| 1193 | 1193 | $error['error'] = sprintf( |
| 1194 | 1194 | /* translators: %s: form */ |
| 1195 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 1195 | + esc_html__('Form %s not found.', 'give'), |
|
| 1196 | 1196 | $args['form'] |
| 1197 | 1197 | ); |
| 1198 | 1198 | } |
| 1199 | 1199 | } |
| 1200 | 1200 | |
| 1201 | - if ( ! empty( $error ) ) { |
|
| 1201 | + if ( ! empty($error)) { |
|
| 1202 | 1202 | return $error; |
| 1203 | 1203 | } |
| 1204 | 1204 | |
| 1205 | 1205 | return $sales; |
| 1206 | 1206 | |
| 1207 | - } elseif ( $args['type'] == 'earnings' ) { |
|
| 1208 | - if ( $args['form'] == null ) { |
|
| 1209 | - if ( $args['date'] == null ) { |
|
| 1207 | + } elseif ($args['type'] == 'earnings') { |
|
| 1208 | + if ($args['form'] == null) { |
|
| 1209 | + if ($args['date'] == null) { |
|
| 1210 | 1210 | $earnings = $this->get_default_earnings_stats(); |
| 1211 | - } elseif ( $args['date'] === 'range' ) { |
|
| 1211 | + } elseif ($args['date'] === 'range') { |
|
| 1212 | 1212 | // Return sales for a date range |
| 1213 | 1213 | |
| 1214 | 1214 | // Ensure the end date is later than the start date |
| 1215 | - if ( $args['enddate'] < $args['startdate'] ) { |
|
| 1216 | - $error['error'] = esc_html__( 'The end date must be later than the start date.', 'give' ); |
|
| 1215 | + if ($args['enddate'] < $args['startdate']) { |
|
| 1216 | + $error['error'] = esc_html__('The end date must be later than the start date.', 'give'); |
|
| 1217 | 1217 | } |
| 1218 | 1218 | |
| 1219 | 1219 | // Ensure both the start and end date are specified |
| 1220 | - if ( empty( $args['startdate'] ) || empty( $args['enddate'] ) ) { |
|
| 1221 | - $error['error'] = esc_html__( 'Invalid or no date range specified.', 'give' ); |
|
| 1220 | + if (empty($args['startdate']) || empty($args['enddate'])) { |
|
| 1221 | + $error['error'] = esc_html__('Invalid or no date range specified.', 'give'); |
|
| 1222 | 1222 | } |
| 1223 | 1223 | |
| 1224 | 1224 | $total = (float) 0.00; |
| 1225 | 1225 | |
| 1226 | 1226 | // Loop through the years |
| 1227 | 1227 | $y = $dates['year']; |
| 1228 | - if ( ! isset( $earnings['earnings'] ) ) { |
|
| 1228 | + if ( ! isset($earnings['earnings'])) { |
|
| 1229 | 1229 | $earnings['earnings'] = array(); |
| 1230 | 1230 | } |
| 1231 | - while ( $y <= $dates['year_end'] ) : |
|
| 1231 | + while ($y <= $dates['year_end']) : |
|
| 1232 | 1232 | |
| 1233 | - if ( $dates['year'] == $dates['year_end'] ) { |
|
| 1233 | + if ($dates['year'] == $dates['year_end']) { |
|
| 1234 | 1234 | $month_start = $dates['m_start']; |
| 1235 | 1235 | $month_end = $dates['m_end']; |
| 1236 | - } elseif ( $y == $dates['year'] && $dates['year_end'] > $dates['year'] ) { |
|
| 1236 | + } elseif ($y == $dates['year'] && $dates['year_end'] > $dates['year']) { |
|
| 1237 | 1237 | $month_start = $dates['m_start']; |
| 1238 | 1238 | $month_end = 12; |
| 1239 | - } elseif ( $y == $dates['year_end'] ) { |
|
| 1239 | + } elseif ($y == $dates['year_end']) { |
|
| 1240 | 1240 | $month_start = 1; |
| 1241 | 1241 | $month_end = $dates['m_end']; |
| 1242 | 1242 | } else { |
@@ -1245,92 +1245,92 @@ discard block |
||
| 1245 | 1245 | } |
| 1246 | 1246 | |
| 1247 | 1247 | $i = $month_start; |
| 1248 | - while ( $i <= $month_end ) : |
|
| 1248 | + while ($i <= $month_end) : |
|
| 1249 | 1249 | |
| 1250 | - if ( $i == $dates['m_start'] ) { |
|
| 1250 | + if ($i == $dates['m_start']) { |
|
| 1251 | 1251 | $d = $dates['day_start']; |
| 1252 | 1252 | } else { |
| 1253 | 1253 | $d = 1; |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | - if ( $i == $dates['m_end'] ) { |
|
| 1256 | + if ($i == $dates['m_end']) { |
|
| 1257 | 1257 | $num_of_days = $dates['day_end']; |
| 1258 | 1258 | } else { |
| 1259 | - $num_of_days = cal_days_in_month( CAL_GREGORIAN, $i, $y ); |
|
| 1259 | + $num_of_days = cal_days_in_month(CAL_GREGORIAN, $i, $y); |
|
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | - while ( $d <= $num_of_days ) : |
|
| 1263 | - $earnings_stat = give_get_earnings_by_date( $d, $i, $y ); |
|
| 1264 | - $date_key = date( 'Ymd', strtotime( $y . '/' . $i . '/' . $d ) ); |
|
| 1265 | - if ( ! isset( $earnings['earnings'][ $date_key ] ) ) { |
|
| 1266 | - $earnings['earnings'][ $date_key ] = 0; |
|
| 1262 | + while ($d <= $num_of_days) : |
|
| 1263 | + $earnings_stat = give_get_earnings_by_date($d, $i, $y); |
|
| 1264 | + $date_key = date('Ymd', strtotime($y.'/'.$i.'/'.$d)); |
|
| 1265 | + if ( ! isset($earnings['earnings'][$date_key])) { |
|
| 1266 | + $earnings['earnings'][$date_key] = 0; |
|
| 1267 | 1267 | } |
| 1268 | - $earnings['earnings'][ $date_key ] += $earnings_stat; |
|
| 1268 | + $earnings['earnings'][$date_key] += $earnings_stat; |
|
| 1269 | 1269 | $total += $earnings_stat; |
| 1270 | - $d ++; |
|
| 1270 | + $d++; |
|
| 1271 | 1271 | endwhile; |
| 1272 | 1272 | |
| 1273 | - $i ++; |
|
| 1273 | + $i++; |
|
| 1274 | 1274 | endwhile; |
| 1275 | 1275 | |
| 1276 | - $y ++; |
|
| 1276 | + $y++; |
|
| 1277 | 1277 | endwhile; |
| 1278 | 1278 | |
| 1279 | 1279 | $earnings['totals'] = $total; |
| 1280 | 1280 | } else { |
| 1281 | - if ( $args['date'] == 'this_quarter' || $args['date'] == 'last_quarter' ) { |
|
| 1281 | + if ($args['date'] == 'this_quarter' || $args['date'] == 'last_quarter') { |
|
| 1282 | 1282 | $earnings_count = (float) 0.00; |
| 1283 | 1283 | |
| 1284 | 1284 | // Loop through the months |
| 1285 | 1285 | $month = $dates['m_start']; |
| 1286 | 1286 | |
| 1287 | - while ( $month <= $dates['m_end'] ) : |
|
| 1288 | - $earnings_count += give_get_earnings_by_date( null, $month, $dates['year'] ); |
|
| 1289 | - $month ++; |
|
| 1287 | + while ($month <= $dates['m_end']) : |
|
| 1288 | + $earnings_count += give_get_earnings_by_date(null, $month, $dates['year']); |
|
| 1289 | + $month++; |
|
| 1290 | 1290 | endwhile; |
| 1291 | 1291 | |
| 1292 | - $earnings['earnings'][ $args['date'] ] = $earnings_count; |
|
| 1292 | + $earnings['earnings'][$args['date']] = $earnings_count; |
|
| 1293 | 1293 | } else { |
| 1294 | - $earnings['earnings'][ $args['date'] ] = give_get_earnings_by_date( $dates['day'], $dates['m_start'], $dates['year'] ); |
|
| 1294 | + $earnings['earnings'][$args['date']] = give_get_earnings_by_date($dates['day'], $dates['m_start'], $dates['year']); |
|
| 1295 | 1295 | } |
| 1296 | 1296 | } |
| 1297 | - } elseif ( $args['form'] == 'all' ) { |
|
| 1298 | - $forms = get_posts( array( 'post_type' => 'give_forms', 'nopaging' => true ) ); |
|
| 1297 | + } elseif ($args['form'] == 'all') { |
|
| 1298 | + $forms = get_posts(array('post_type' => 'give_forms', 'nopaging' => true)); |
|
| 1299 | 1299 | |
| 1300 | 1300 | $i = 0; |
| 1301 | - foreach ( $forms as $form_info ) { |
|
| 1302 | - $earnings['earnings'][ $i ] = array( $form_info->post_name => give_get_form_earnings_stats( $form_info->ID ) ); |
|
| 1303 | - $i ++; |
|
| 1301 | + foreach ($forms as $form_info) { |
|
| 1302 | + $earnings['earnings'][$i] = array($form_info->post_name => give_get_form_earnings_stats($form_info->ID)); |
|
| 1303 | + $i++; |
|
| 1304 | 1304 | } |
| 1305 | 1305 | } else { |
| 1306 | - if ( get_post_type( $args['form'] ) == 'give_forms' ) { |
|
| 1307 | - $form_info = get_post( $args['form'] ); |
|
| 1308 | - $earnings['earnings'][0] = array( $form_info->post_name => give_get_form_earnings_stats( $args['form'] ) ); |
|
| 1306 | + if (get_post_type($args['form']) == 'give_forms') { |
|
| 1307 | + $form_info = get_post($args['form']); |
|
| 1308 | + $earnings['earnings'][0] = array($form_info->post_name => give_get_form_earnings_stats($args['form'])); |
|
| 1309 | 1309 | } else { |
| 1310 | 1310 | $error['error'] = sprintf( |
| 1311 | 1311 | /* translators: %s: form */ |
| 1312 | - esc_html__( 'Form %s not found.', 'give' ), |
|
| 1312 | + esc_html__('Form %s not found.', 'give'), |
|
| 1313 | 1313 | $args['form'] |
| 1314 | 1314 | ); |
| 1315 | 1315 | } |
| 1316 | 1316 | } |
| 1317 | 1317 | |
| 1318 | - if ( ! empty( $error ) ) { |
|
| 1318 | + if ( ! empty($error)) { |
|
| 1319 | 1319 | return $error; |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | return $earnings; |
| 1323 | - } elseif ( $args['type'] == 'donors' ) { |
|
| 1323 | + } elseif ($args['type'] == 'donors') { |
|
| 1324 | 1324 | $customers = new Give_DB_Customers(); |
| 1325 | 1325 | $stats['donations']['total_donors'] = $customers->count(); |
| 1326 | 1326 | |
| 1327 | 1327 | return $stats; |
| 1328 | 1328 | |
| 1329 | - } elseif ( empty( $args['type'] ) ) { |
|
| 1330 | - $stats = array_merge( $stats, $this->get_default_sales_stats() ); |
|
| 1331 | - $stats = array_merge( $stats, $this->get_default_earnings_stats() ); |
|
| 1329 | + } elseif (empty($args['type'])) { |
|
| 1330 | + $stats = array_merge($stats, $this->get_default_sales_stats()); |
|
| 1331 | + $stats = array_merge($stats, $this->get_default_earnings_stats()); |
|
| 1332 | 1332 | |
| 1333 | - return array( 'stats' => $stats ); |
|
| 1333 | + return array('stats' => $stats); |
|
| 1334 | 1334 | } |
| 1335 | 1335 | } |
| 1336 | 1336 | |
@@ -1346,18 +1346,18 @@ discard block |
||
| 1346 | 1346 | |
| 1347 | 1347 | $sales = array(); |
| 1348 | 1348 | |
| 1349 | - if ( ! user_can( $this->user_id, 'view_give_reports' ) && ! $this->override ) { |
|
| 1349 | + if ( ! user_can($this->user_id, 'view_give_reports') && ! $this->override) { |
|
| 1350 | 1350 | return $sales; |
| 1351 | 1351 | } |
| 1352 | 1352 | |
| 1353 | - if ( isset( $wp_query->query_vars['id'] ) ) { |
|
| 1353 | + if (isset($wp_query->query_vars['id'])) { |
|
| 1354 | 1354 | $query = array(); |
| 1355 | - $query[] = new Give_Payment( $wp_query->query_vars['id'] ); |
|
| 1356 | - } elseif ( isset( $wp_query->query_vars['purchasekey'] ) ) { |
|
| 1355 | + $query[] = new Give_Payment($wp_query->query_vars['id']); |
|
| 1356 | + } elseif (isset($wp_query->query_vars['purchasekey'])) { |
|
| 1357 | 1357 | $query = array(); |
| 1358 | - $query[] = give_get_payment_by( 'key', $wp_query->query_vars['purchasekey'] ); |
|
| 1359 | - } elseif ( isset( $wp_query->query_vars['email'] ) ) { |
|
| 1360 | - $args = array( |
|
| 1358 | + $query[] = give_get_payment_by('key', $wp_query->query_vars['purchasekey']); |
|
| 1359 | + } elseif (isset($wp_query->query_vars['email'])) { |
|
| 1360 | + $args = array( |
|
| 1361 | 1361 | 'fields' => 'ids', |
| 1362 | 1362 | 'meta_key' => '_give_payment_user_email', |
| 1363 | 1363 | 'meta_value' => $wp_query->query_vars['email'], |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | 'page' => $this->get_paged(), |
| 1366 | 1366 | 'status' => 'publish' |
| 1367 | 1367 | ); |
| 1368 | - $query = give_get_payments( $args ); |
|
| 1368 | + $query = give_get_payments($args); |
|
| 1369 | 1369 | } else { |
| 1370 | 1370 | $args = array( |
| 1371 | 1371 | 'fields' => 'ids', |
@@ -1373,14 +1373,14 @@ discard block |
||
| 1373 | 1373 | 'page' => $this->get_paged(), |
| 1374 | 1374 | 'status' => 'publish' |
| 1375 | 1375 | ); |
| 1376 | - $query = give_get_payments( $args ); |
|
| 1376 | + $query = give_get_payments($args); |
|
| 1377 | 1377 | } |
| 1378 | - if ( $query ) { |
|
| 1378 | + if ($query) { |
|
| 1379 | 1379 | $i = 0; |
| 1380 | - foreach ( $query as $payment ) { |
|
| 1380 | + foreach ($query as $payment) { |
|
| 1381 | 1381 | |
| 1382 | - if ( is_numeric( $payment ) ) { |
|
| 1383 | - $payment = new Give_Payment( $payment ); |
|
| 1382 | + if (is_numeric($payment)) { |
|
| 1383 | + $payment = new Give_Payment($payment); |
|
| 1384 | 1384 | $payment_meta = $payment->get_meta(); |
| 1385 | 1385 | $user_info = $payment->user_info; |
| 1386 | 1386 | } else { |
@@ -1390,40 +1390,40 @@ discard block |
||
| 1390 | 1390 | $payment_meta = $payment->get_meta(); |
| 1391 | 1391 | $user_info = $payment->user_info; |
| 1392 | 1392 | |
| 1393 | - $first_name = isset( $user_info['first_name'] ) ? $user_info['first_name'] : ''; |
|
| 1394 | - $last_name = isset( $user_info['last_name'] ) ? $user_info['last_name'] : ''; |
|
| 1395 | - |
|
| 1396 | - $sales['donations'][ $i ]['ID'] = $payment->number; |
|
| 1397 | - $sales['donations'][ $i ]['transaction_id'] = $payment->transaction_id; |
|
| 1398 | - $sales['donations'][ $i ]['key'] = $payment->key; |
|
| 1399 | - $sales['donations'][ $i ]['total'] = $payment->total; |
|
| 1400 | - $sales['donations'][ $i ]['gateway'] = $payment->gateway; |
|
| 1401 | - $sales['donations'][ $i ]['name'] = $first_name . ' ' . $last_name; |
|
| 1402 | - $sales['donations'][ $i ]['fname'] = $first_name; |
|
| 1403 | - $sales['donations'][ $i ]['lname'] = $last_name; |
|
| 1404 | - $sales['donations'][ $i ]['email'] = $payment->email; |
|
| 1405 | - $sales['donations'][ $i ]['date'] = $payment->date; |
|
| 1406 | - |
|
| 1407 | - $form_id = isset( $payment_meta['form_id'] ) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1408 | - $price = isset( $payment_meta['form_id'] ) ? give_get_form_price( $payment_meta['form_id'] ) : false; |
|
| 1409 | - $price_id = isset( $payment_meta['price_id'] ) ? $payment_meta['price_id'] : null; |
|
| 1410 | - |
|
| 1411 | - $sales['donations'][ $i ]['form']['id'] = $form_id; |
|
| 1412 | - $sales['donations'][ $i ]['form']['name'] = get_the_title( $payment_meta['form_id'] ); |
|
| 1413 | - $sales['donations'][ $i ]['form']['price'] = $price; |
|
| 1414 | - |
|
| 1415 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 1416 | - if ( isset( $payment_meta['price_id'] ) ) { |
|
| 1417 | - $price_name = give_get_price_option_name( $form_id, $payment_meta['price_id'], $payment->ID ); |
|
| 1418 | - $sales['donations'][ $i ]['form']['price_name'] = $price_name; |
|
| 1419 | - $sales['donations'][ $i ]['form']['price_id'] = $price_id; |
|
| 1420 | - $sales['donations'][ $i ]['form']['price'] = give_get_price_option_amount( $form_id, $price_id ); |
|
| 1393 | + $first_name = isset($user_info['first_name']) ? $user_info['first_name'] : ''; |
|
| 1394 | + $last_name = isset($user_info['last_name']) ? $user_info['last_name'] : ''; |
|
| 1395 | + |
|
| 1396 | + $sales['donations'][$i]['ID'] = $payment->number; |
|
| 1397 | + $sales['donations'][$i]['transaction_id'] = $payment->transaction_id; |
|
| 1398 | + $sales['donations'][$i]['key'] = $payment->key; |
|
| 1399 | + $sales['donations'][$i]['total'] = $payment->total; |
|
| 1400 | + $sales['donations'][$i]['gateway'] = $payment->gateway; |
|
| 1401 | + $sales['donations'][$i]['name'] = $first_name.' '.$last_name; |
|
| 1402 | + $sales['donations'][$i]['fname'] = $first_name; |
|
| 1403 | + $sales['donations'][$i]['lname'] = $last_name; |
|
| 1404 | + $sales['donations'][$i]['email'] = $payment->email; |
|
| 1405 | + $sales['donations'][$i]['date'] = $payment->date; |
|
| 1406 | + |
|
| 1407 | + $form_id = isset($payment_meta['form_id']) ? $payment_meta['form_id'] : $payment_meta; |
|
| 1408 | + $price = isset($payment_meta['form_id']) ? give_get_form_price($payment_meta['form_id']) : false; |
|
| 1409 | + $price_id = isset($payment_meta['price_id']) ? $payment_meta['price_id'] : null; |
|
| 1410 | + |
|
| 1411 | + $sales['donations'][$i]['form']['id'] = $form_id; |
|
| 1412 | + $sales['donations'][$i]['form']['name'] = get_the_title($payment_meta['form_id']); |
|
| 1413 | + $sales['donations'][$i]['form']['price'] = $price; |
|
| 1414 | + |
|
| 1415 | + if (give_has_variable_prices($form_id)) { |
|
| 1416 | + if (isset($payment_meta['price_id'])) { |
|
| 1417 | + $price_name = give_get_price_option_name($form_id, $payment_meta['price_id'], $payment->ID); |
|
| 1418 | + $sales['donations'][$i]['form']['price_name'] = $price_name; |
|
| 1419 | + $sales['donations'][$i]['form']['price_id'] = $price_id; |
|
| 1420 | + $sales['donations'][$i]['form']['price'] = give_get_price_option_amount($form_id, $price_id); |
|
| 1421 | 1421 | |
| 1422 | 1422 | } |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 | //Add custom meta to API |
| 1426 | - foreach ( $payment_meta as $meta_key => $meta_value ) { |
|
| 1426 | + foreach ($payment_meta as $meta_key => $meta_value) { |
|
| 1427 | 1427 | |
| 1428 | 1428 | $exceptions = array( |
| 1429 | 1429 | 'form_title', |
@@ -1436,19 +1436,19 @@ discard block |
||
| 1436 | 1436 | ); |
| 1437 | 1437 | |
| 1438 | 1438 | //Don't clutter up results with dupes |
| 1439 | - if ( in_array( $meta_key, $exceptions ) ) { |
|
| 1439 | + if (in_array($meta_key, $exceptions)) { |
|
| 1440 | 1440 | continue; |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | - $sales['donations'][ $i ]['payment_meta'][ $meta_key ] = $meta_value; |
|
| 1443 | + $sales['donations'][$i]['payment_meta'][$meta_key] = $meta_value; |
|
| 1444 | 1444 | |
| 1445 | 1445 | } |
| 1446 | 1446 | |
| 1447 | - $i ++; |
|
| 1447 | + $i++; |
|
| 1448 | 1448 | } |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | - return apply_filters( 'give_api_donations_endpoint', $sales ); |
|
| 1451 | + return apply_filters('give_api_donations_endpoint', $sales); |
|
| 1452 | 1452 | } |
| 1453 | 1453 | |
| 1454 | 1454 | /** |
@@ -1464,9 +1464,9 @@ discard block |
||
| 1464 | 1464 | public function get_output_format() { |
| 1465 | 1465 | global $wp_query; |
| 1466 | 1466 | |
| 1467 | - $format = isset( $wp_query->query_vars['format'] ) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1467 | + $format = isset($wp_query->query_vars['format']) ? $wp_query->query_vars['format'] : 'json'; |
|
| 1468 | 1468 | |
| 1469 | - return apply_filters( 'give_api_output_format', $format ); |
|
| 1469 | + return apply_filters('give_api_output_format', $format); |
|
| 1470 | 1470 | } |
| 1471 | 1471 | |
| 1472 | 1472 | |
@@ -1483,8 +1483,8 @@ discard block |
||
| 1483 | 1483 | * |
| 1484 | 1484 | * @return void |
| 1485 | 1485 | */ |
| 1486 | - private function log_request( $data = array() ) { |
|
| 1487 | - if ( ! $this->log_requests ) { |
|
| 1486 | + private function log_request($data = array()) { |
|
| 1487 | + if ( ! $this->log_requests) { |
|
| 1488 | 1488 | return; |
| 1489 | 1489 | } |
| 1490 | 1490 | |
@@ -1500,36 +1500,36 @@ discard block |
||
| 1500 | 1500 | |
| 1501 | 1501 | $query = array( |
| 1502 | 1502 | 'give-api' => $wp_query->query_vars['give-api'], |
| 1503 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1504 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1505 | - 'query' => isset( $wp_query->query_vars['query'] ) ? $wp_query->query_vars['query'] : null, |
|
| 1506 | - 'type' => isset( $wp_query->query_vars['type'] ) ? $wp_query->query_vars['type'] : null, |
|
| 1507 | - 'form' => isset( $wp_query->query_vars['form'] ) ? $wp_query->query_vars['form'] : null, |
|
| 1508 | - 'customer' => isset( $wp_query->query_vars['customer'] ) ? $wp_query->query_vars['customer'] : null, |
|
| 1509 | - 'date' => isset( $wp_query->query_vars['date'] ) ? $wp_query->query_vars['date'] : null, |
|
| 1510 | - 'startdate' => isset( $wp_query->query_vars['startdate'] ) ? $wp_query->query_vars['startdate'] : null, |
|
| 1511 | - 'enddate' => isset( $wp_query->query_vars['enddate'] ) ? $wp_query->query_vars['enddate'] : null, |
|
| 1512 | - 'id' => isset( $wp_query->query_vars['id'] ) ? $wp_query->query_vars['id'] : null, |
|
| 1513 | - 'purchasekey' => isset( $wp_query->query_vars['purchasekey'] ) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1514 | - 'email' => isset( $wp_query->query_vars['email'] ) ? $wp_query->query_vars['email'] : null, |
|
| 1503 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1504 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1505 | + 'query' => isset($wp_query->query_vars['query']) ? $wp_query->query_vars['query'] : null, |
|
| 1506 | + 'type' => isset($wp_query->query_vars['type']) ? $wp_query->query_vars['type'] : null, |
|
| 1507 | + 'form' => isset($wp_query->query_vars['form']) ? $wp_query->query_vars['form'] : null, |
|
| 1508 | + 'customer' => isset($wp_query->query_vars['customer']) ? $wp_query->query_vars['customer'] : null, |
|
| 1509 | + 'date' => isset($wp_query->query_vars['date']) ? $wp_query->query_vars['date'] : null, |
|
| 1510 | + 'startdate' => isset($wp_query->query_vars['startdate']) ? $wp_query->query_vars['startdate'] : null, |
|
| 1511 | + 'enddate' => isset($wp_query->query_vars['enddate']) ? $wp_query->query_vars['enddate'] : null, |
|
| 1512 | + 'id' => isset($wp_query->query_vars['id']) ? $wp_query->query_vars['id'] : null, |
|
| 1513 | + 'purchasekey' => isset($wp_query->query_vars['purchasekey']) ? $wp_query->query_vars['purchasekey'] : null, |
|
| 1514 | + 'email' => isset($wp_query->query_vars['email']) ? $wp_query->query_vars['email'] : null, |
|
| 1515 | 1515 | ); |
| 1516 | 1516 | |
| 1517 | 1517 | $log_data = array( |
| 1518 | 1518 | 'log_type' => 'api_request', |
| 1519 | - 'post_excerpt' => http_build_query( $query ), |
|
| 1520 | - 'post_content' => ! empty( $data['error'] ) ? $data['error'] : '', |
|
| 1519 | + 'post_excerpt' => http_build_query($query), |
|
| 1520 | + 'post_content' => ! empty($data['error']) ? $data['error'] : '', |
|
| 1521 | 1521 | ); |
| 1522 | 1522 | |
| 1523 | 1523 | $log_meta = array( |
| 1524 | 1524 | 'request_ip' => give_get_ip(), |
| 1525 | 1525 | 'user' => $this->user_id, |
| 1526 | - 'key' => isset( $wp_query->query_vars['key'] ) ? $wp_query->query_vars['key'] : null, |
|
| 1527 | - 'token' => isset( $wp_query->query_vars['token'] ) ? $wp_query->query_vars['token'] : null, |
|
| 1526 | + 'key' => isset($wp_query->query_vars['key']) ? $wp_query->query_vars['key'] : null, |
|
| 1527 | + 'token' => isset($wp_query->query_vars['token']) ? $wp_query->query_vars['token'] : null, |
|
| 1528 | 1528 | 'time' => $data['request_speed'], |
| 1529 | 1529 | 'version' => $this->get_queried_version() |
| 1530 | 1530 | ); |
| 1531 | 1531 | |
| 1532 | - $give_logs->insert_log( $log_data, $log_meta ); |
|
| 1532 | + $give_logs->insert_log($log_data, $log_meta); |
|
| 1533 | 1533 | } |
| 1534 | 1534 | |
| 1535 | 1535 | |
@@ -1553,7 +1553,7 @@ discard block |
||
| 1553 | 1553 | * |
| 1554 | 1554 | * @param int $status_code |
| 1555 | 1555 | */ |
| 1556 | - public function output( $status_code = 200 ) { |
|
| 1556 | + public function output($status_code = 200) { |
|
| 1557 | 1557 | /** |
| 1558 | 1558 | * @var WP_Query $wp_query |
| 1559 | 1559 | */ |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | |
| 1562 | 1562 | $format = $this->get_output_format(); |
| 1563 | 1563 | |
| 1564 | - status_header( $status_code ); |
|
| 1564 | + status_header($status_code); |
|
| 1565 | 1565 | |
| 1566 | 1566 | /** |
| 1567 | 1567 | * Fires before outputing the API. |
@@ -1572,25 +1572,25 @@ discard block |
||
| 1572 | 1572 | * @param Give_API $this The Give_API object. |
| 1573 | 1573 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1574 | 1574 | */ |
| 1575 | - do_action( 'give_api_output_before', $this->data, $this, $format ); |
|
| 1575 | + do_action('give_api_output_before', $this->data, $this, $format); |
|
| 1576 | 1576 | |
| 1577 | - switch ( $format ) : |
|
| 1577 | + switch ($format) : |
|
| 1578 | 1578 | |
| 1579 | 1579 | case 'xml' : |
| 1580 | 1580 | |
| 1581 | - require_once GIVE_PLUGIN_DIR . 'includes/libraries/array2xml.php'; |
|
| 1582 | - $xml = Array2XML::createXML( 'give', $this->data ); |
|
| 1581 | + require_once GIVE_PLUGIN_DIR.'includes/libraries/array2xml.php'; |
|
| 1582 | + $xml = Array2XML::createXML('give', $this->data); |
|
| 1583 | 1583 | echo $xml->saveXML(); |
| 1584 | 1584 | |
| 1585 | 1585 | break; |
| 1586 | 1586 | |
| 1587 | 1587 | case 'json' : |
| 1588 | 1588 | |
| 1589 | - header( 'Content-Type: application/json' ); |
|
| 1590 | - if ( ! empty( $this->pretty_print ) ) { |
|
| 1591 | - echo json_encode( $this->data, $this->pretty_print ); |
|
| 1589 | + header('Content-Type: application/json'); |
|
| 1590 | + if ( ! empty($this->pretty_print)) { |
|
| 1591 | + echo json_encode($this->data, $this->pretty_print); |
|
| 1592 | 1592 | } else { |
| 1593 | - echo json_encode( $this->data ); |
|
| 1593 | + echo json_encode($this->data); |
|
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | break; |
@@ -1606,7 +1606,7 @@ discard block |
||
| 1606 | 1606 | * @param array $data Response data to return. |
| 1607 | 1607 | * @param Give_API $this The Give_API object. |
| 1608 | 1608 | */ |
| 1609 | - do_action( "give_api_output_{$format}", $this->data, $this ); |
|
| 1609 | + do_action("give_api_output_{$format}", $this->data, $this); |
|
| 1610 | 1610 | |
| 1611 | 1611 | break; |
| 1612 | 1612 | |
@@ -1621,7 +1621,7 @@ discard block |
||
| 1621 | 1621 | * @param Give_API $this The Give_API object. |
| 1622 | 1622 | * @param string $format Output format, XML or JSON. Default is JSON. |
| 1623 | 1623 | */ |
| 1624 | - do_action( 'give_api_output_after', $this->data, $this, $format ); |
|
| 1624 | + do_action('give_api_output_after', $this->data, $this, $format); |
|
| 1625 | 1625 | |
| 1626 | 1626 | give_die(); |
| 1627 | 1627 | } |
@@ -1638,37 +1638,37 @@ discard block |
||
| 1638 | 1638 | * |
| 1639 | 1639 | * @return void |
| 1640 | 1640 | */ |
| 1641 | - function user_key_field( $user ) { |
|
| 1641 | + function user_key_field($user) { |
|
| 1642 | 1642 | |
| 1643 | - if ( ( give_get_option( 'api_allow_user_keys', false ) || current_user_can( 'manage_give_settings' ) ) && current_user_can( 'edit_user', $user->ID ) ) { |
|
| 1644 | - $user = get_userdata( $user->ID ); |
|
| 1643 | + if ((give_get_option('api_allow_user_keys', false) || current_user_can('manage_give_settings')) && current_user_can('edit_user', $user->ID)) { |
|
| 1644 | + $user = get_userdata($user->ID); |
|
| 1645 | 1645 | ?> |
| 1646 | 1646 | <table class="form-table"> |
| 1647 | 1647 | <tbody> |
| 1648 | 1648 | <tr> |
| 1649 | 1649 | <th> |
| 1650 | - <?php esc_html_e( 'Give API Keys', 'give' ); ?> |
|
| 1650 | + <?php esc_html_e('Give API Keys', 'give'); ?> |
|
| 1651 | 1651 | </th> |
| 1652 | 1652 | <td> |
| 1653 | 1653 | <?php |
| 1654 | - $public_key = $this->get_user_public_key( $user->ID ); |
|
| 1655 | - $secret_key = $this->get_user_secret_key( $user->ID ); |
|
| 1654 | + $public_key = $this->get_user_public_key($user->ID); |
|
| 1655 | + $secret_key = $this->get_user_secret_key($user->ID); |
|
| 1656 | 1656 | ?> |
| 1657 | - <?php if ( empty( $user->give_user_public_key ) ) { ?> |
|
| 1657 | + <?php if (empty($user->give_user_public_key)) { ?> |
|
| 1658 | 1658 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1659 | - <span class="description"><?php esc_html_e( 'Generate API Key', 'give' ); ?></span> |
|
| 1659 | + <span class="description"><?php esc_html_e('Generate API Key', 'give'); ?></span> |
|
| 1660 | 1660 | <?php } else { ?> |
| 1661 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Public key:', 'give' ); ?> </strong> |
|
| 1662 | - <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr( $public_key ); ?>"/> |
|
| 1661 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Public key:', 'give'); ?> </strong> |
|
| 1662 | + <input type="text" disabled="disabled" class="regular-text" id="publickey" value="<?php echo esc_attr($public_key); ?>"/> |
|
| 1663 | 1663 | <br/> |
| 1664 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Secret key:', 'give' ); ?> </strong> |
|
| 1665 | - <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr( $secret_key ); ?>"/> |
|
| 1664 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Secret key:', 'give'); ?> </strong> |
|
| 1665 | + <input type="text" disabled="disabled" class="regular-text" id="privatekey" value="<?php echo esc_attr($secret_key); ?>"/> |
|
| 1666 | 1666 | <br/> |
| 1667 | - <strong style="display:inline-block; width: 125px;"><?php esc_html_e( 'Token:', 'give' ); ?> </strong> |
|
| 1668 | - <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr( $this->get_token( $user->ID ) ); ?>"/> |
|
| 1667 | + <strong style="display:inline-block; width: 125px;"><?php esc_html_e('Token:', 'give'); ?> </strong> |
|
| 1668 | + <input type="text" disabled="disabled" class="regular-text" id="token" value="<?php echo esc_attr($this->get_token($user->ID)); ?>"/> |
|
| 1669 | 1669 | <br/> |
| 1670 | 1670 | <input name="give_set_api_key" type="checkbox" id="give_set_api_key" value="0"/> |
| 1671 | - <span class="description"><label for="give_set_api_key"><?php esc_html_e( 'Revoke API Keys', 'give' ); ?></label></span> |
|
| 1671 | + <span class="description"><label for="give_set_api_key"><?php esc_html_e('Revoke API Keys', 'give'); ?></label></span> |
|
| 1672 | 1672 | <?php } ?> |
| 1673 | 1673 | </td> |
| 1674 | 1674 | </tr> |
@@ -1687,69 +1687,69 @@ discard block |
||
| 1687 | 1687 | * |
| 1688 | 1688 | * @return void |
| 1689 | 1689 | */ |
| 1690 | - public function process_api_key( $args ) { |
|
| 1690 | + public function process_api_key($args) { |
|
| 1691 | 1691 | |
| 1692 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'give-api-nonce' ) ) { |
|
| 1692 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'give-api-nonce')) { |
|
| 1693 | 1693 | |
| 1694 | - wp_die( esc_html__( 'Nonce verification failed.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 403 ) ); |
|
| 1694 | + wp_die(esc_html__('Nonce verification failed.', 'give'), esc_html__('Error', 'give'), array('response' => 403)); |
|
| 1695 | 1695 | |
| 1696 | 1696 | } |
| 1697 | 1697 | |
| 1698 | - if ( empty( $args['user_id'] ) ) { |
|
| 1699 | - wp_die( esc_html__( 'User ID Required.', 'give' ), esc_html__( 'Error', 'give' ), array( 'response' => 401 ) ); |
|
| 1698 | + if (empty($args['user_id'])) { |
|
| 1699 | + wp_die(esc_html__('User ID Required.', 'give'), esc_html__('Error', 'give'), array('response' => 401)); |
|
| 1700 | 1700 | } |
| 1701 | 1701 | |
| 1702 | - if ( is_numeric( $args['user_id'] ) ) { |
|
| 1703 | - $user_id = isset( $args['user_id'] ) ? absint( $args['user_id'] ) : get_current_user_id(); |
|
| 1702 | + if (is_numeric($args['user_id'])) { |
|
| 1703 | + $user_id = isset($args['user_id']) ? absint($args['user_id']) : get_current_user_id(); |
|
| 1704 | 1704 | } else { |
| 1705 | - $userdata = get_user_by( 'login', $args['user_id'] ); |
|
| 1705 | + $userdata = get_user_by('login', $args['user_id']); |
|
| 1706 | 1706 | $user_id = $userdata->ID; |
| 1707 | 1707 | } |
| 1708 | - $process = isset( $args['give_api_process'] ) ? strtolower( $args['give_api_process'] ) : false; |
|
| 1708 | + $process = isset($args['give_api_process']) ? strtolower($args['give_api_process']) : false; |
|
| 1709 | 1709 | |
| 1710 | - if ( $user_id == get_current_user_id() && ! give_get_option( 'allow_user_api_keys' ) && ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1710 | + if ($user_id == get_current_user_id() && ! give_get_option('allow_user_api_keys') && ! current_user_can('manage_give_settings')) { |
|
| 1711 | 1711 | wp_die( |
| 1712 | 1712 | sprintf( |
| 1713 | 1713 | /* translators: %s: process */ |
| 1714 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1714 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1715 | 1715 | $process |
| 1716 | 1716 | ), |
| 1717 | - esc_html__( 'Error', 'give' ), |
|
| 1718 | - array( 'response' => 403 ) |
|
| 1717 | + esc_html__('Error', 'give'), |
|
| 1718 | + array('response' => 403) |
|
| 1719 | 1719 | ); |
| 1720 | - } elseif ( ! current_user_can( 'manage_give_settings' ) ) { |
|
| 1720 | + } elseif ( ! current_user_can('manage_give_settings')) { |
|
| 1721 | 1721 | wp_die( |
| 1722 | 1722 | sprintf( |
| 1723 | 1723 | /* translators: %s: process */ |
| 1724 | - esc_html__( 'You do not have permission to %s API keys for this user.', 'give' ), |
|
| 1724 | + esc_html__('You do not have permission to %s API keys for this user.', 'give'), |
|
| 1725 | 1725 | $process |
| 1726 | 1726 | ), |
| 1727 | - esc_html__( 'Error', 'give' ), |
|
| 1728 | - array( 'response' => 403 ) |
|
| 1727 | + esc_html__('Error', 'give'), |
|
| 1728 | + array('response' => 403) |
|
| 1729 | 1729 | ); |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | - switch ( $process ) { |
|
| 1732 | + switch ($process) { |
|
| 1733 | 1733 | case 'generate': |
| 1734 | - if ( $this->generate_api_key( $user_id ) ) { |
|
| 1735 | - delete_transient( 'give_total_api_keys' ); |
|
| 1736 | - wp_redirect( add_query_arg( 'give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1734 | + if ($this->generate_api_key($user_id)) { |
|
| 1735 | + delete_transient('give_total_api_keys'); |
|
| 1736 | + wp_redirect(add_query_arg('give-message', 'api-key-generated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1737 | 1737 | exit(); |
| 1738 | 1738 | } else { |
| 1739 | - wp_redirect( add_query_arg( 'give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1739 | + wp_redirect(add_query_arg('give-message', 'api-key-failed', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1740 | 1740 | exit(); |
| 1741 | 1741 | } |
| 1742 | 1742 | break; |
| 1743 | 1743 | case 'regenerate': |
| 1744 | - $this->generate_api_key( $user_id, true ); |
|
| 1745 | - delete_transient( 'give_total_api_keys' ); |
|
| 1746 | - wp_redirect( add_query_arg( 'give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1744 | + $this->generate_api_key($user_id, true); |
|
| 1745 | + delete_transient('give_total_api_keys'); |
|
| 1746 | + wp_redirect(add_query_arg('give-message', 'api-key-regenerated', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1747 | 1747 | exit(); |
| 1748 | 1748 | break; |
| 1749 | 1749 | case 'revoke': |
| 1750 | - $this->revoke_api_key( $user_id ); |
|
| 1751 | - delete_transient( 'give_total_api_keys' ); |
|
| 1752 | - wp_redirect( add_query_arg( 'give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api' ) ); |
|
| 1750 | + $this->revoke_api_key($user_id); |
|
| 1751 | + delete_transient('give_total_api_keys'); |
|
| 1752 | + wp_redirect(add_query_arg('give-message', 'api-key-revoked', 'edit.php?post_type=give_forms&page=give-settings&tab=api')); |
|
| 1753 | 1753 | exit(); |
| 1754 | 1754 | break; |
| 1755 | 1755 | default; |
@@ -1768,34 +1768,34 @@ discard block |
||
| 1768 | 1768 | * |
| 1769 | 1769 | * @return boolean True if (re)generated succesfully, false otherwise. |
| 1770 | 1770 | */ |
| 1771 | - public function generate_api_key( $user_id = 0, $regenerate = false ) { |
|
| 1771 | + public function generate_api_key($user_id = 0, $regenerate = false) { |
|
| 1772 | 1772 | |
| 1773 | - if ( empty( $user_id ) ) { |
|
| 1773 | + if (empty($user_id)) { |
|
| 1774 | 1774 | return false; |
| 1775 | 1775 | } |
| 1776 | 1776 | |
| 1777 | - $user = get_userdata( $user_id ); |
|
| 1777 | + $user = get_userdata($user_id); |
|
| 1778 | 1778 | |
| 1779 | - if ( ! $user ) { |
|
| 1779 | + if ( ! $user) { |
|
| 1780 | 1780 | return false; |
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1784 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1783 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1784 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1785 | 1785 | |
| 1786 | - if ( empty( $public_key ) || $regenerate == true ) { |
|
| 1787 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1788 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1786 | + if (empty($public_key) || $regenerate == true) { |
|
| 1787 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1788 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1789 | 1789 | } else { |
| 1790 | 1790 | return false; |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | - if ( $regenerate == true ) { |
|
| 1794 | - $this->revoke_api_key( $user->ID ); |
|
| 1793 | + if ($regenerate == true) { |
|
| 1794 | + $this->revoke_api_key($user->ID); |
|
| 1795 | 1795 | } |
| 1796 | 1796 | |
| 1797 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1798 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1797 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1798 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1799 | 1799 | |
| 1800 | 1800 | return true; |
| 1801 | 1801 | } |
@@ -1810,26 +1810,26 @@ discard block |
||
| 1810 | 1810 | * |
| 1811 | 1811 | * @return string |
| 1812 | 1812 | */ |
| 1813 | - public function revoke_api_key( $user_id = 0 ) { |
|
| 1813 | + public function revoke_api_key($user_id = 0) { |
|
| 1814 | 1814 | |
| 1815 | - if ( empty( $user_id ) ) { |
|
| 1815 | + if (empty($user_id)) { |
|
| 1816 | 1816 | return false; |
| 1817 | 1817 | } |
| 1818 | 1818 | |
| 1819 | - $user = get_userdata( $user_id ); |
|
| 1819 | + $user = get_userdata($user_id); |
|
| 1820 | 1820 | |
| 1821 | - if ( ! $user ) { |
|
| 1821 | + if ( ! $user) { |
|
| 1822 | 1822 | return false; |
| 1823 | 1823 | } |
| 1824 | 1824 | |
| 1825 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1826 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1827 | - if ( ! empty( $public_key ) ) { |
|
| 1828 | - delete_transient( md5( 'give_api_user_' . $public_key ) ); |
|
| 1829 | - delete_transient( md5( 'give_api_user_public_key' . $user_id ) ); |
|
| 1830 | - delete_transient( md5( 'give_api_user_secret_key' . $user_id ) ); |
|
| 1831 | - delete_user_meta( $user_id, $public_key ); |
|
| 1832 | - delete_user_meta( $user_id, $secret_key ); |
|
| 1825 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1826 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1827 | + if ( ! empty($public_key)) { |
|
| 1828 | + delete_transient(md5('give_api_user_'.$public_key)); |
|
| 1829 | + delete_transient(md5('give_api_user_public_key'.$user_id)); |
|
| 1830 | + delete_transient(md5('give_api_user_secret_key'.$user_id)); |
|
| 1831 | + delete_user_meta($user_id, $public_key); |
|
| 1832 | + delete_user_meta($user_id, $secret_key); |
|
| 1833 | 1833 | } else { |
| 1834 | 1834 | return false; |
| 1835 | 1835 | } |
@@ -1854,22 +1854,22 @@ discard block |
||
| 1854 | 1854 | * |
| 1855 | 1855 | * @return void |
| 1856 | 1856 | */ |
| 1857 | - public function update_key( $user_id ) { |
|
| 1858 | - if ( current_user_can( 'edit_user', $user_id ) && isset( $_POST['give_set_api_key'] ) ) { |
|
| 1857 | + public function update_key($user_id) { |
|
| 1858 | + if (current_user_can('edit_user', $user_id) && isset($_POST['give_set_api_key'])) { |
|
| 1859 | 1859 | |
| 1860 | - $user = get_userdata( $user_id ); |
|
| 1860 | + $user = get_userdata($user_id); |
|
| 1861 | 1861 | |
| 1862 | - $public_key = $this->get_user_public_key( $user_id ); |
|
| 1863 | - $secret_key = $this->get_user_secret_key( $user_id ); |
|
| 1862 | + $public_key = $this->get_user_public_key($user_id); |
|
| 1863 | + $secret_key = $this->get_user_secret_key($user_id); |
|
| 1864 | 1864 | |
| 1865 | - if ( empty( $public_key ) ) { |
|
| 1866 | - $new_public_key = $this->generate_public_key( $user->user_email ); |
|
| 1867 | - $new_secret_key = $this->generate_private_key( $user->ID ); |
|
| 1865 | + if (empty($public_key)) { |
|
| 1866 | + $new_public_key = $this->generate_public_key($user->user_email); |
|
| 1867 | + $new_secret_key = $this->generate_private_key($user->ID); |
|
| 1868 | 1868 | |
| 1869 | - update_user_meta( $user_id, $new_public_key, 'give_user_public_key' ); |
|
| 1870 | - update_user_meta( $user_id, $new_secret_key, 'give_user_secret_key' ); |
|
| 1869 | + update_user_meta($user_id, $new_public_key, 'give_user_public_key'); |
|
| 1870 | + update_user_meta($user_id, $new_secret_key, 'give_user_secret_key'); |
|
| 1871 | 1871 | } else { |
| 1872 | - $this->revoke_api_key( $user_id ); |
|
| 1872 | + $this->revoke_api_key($user_id); |
|
| 1873 | 1873 | } |
| 1874 | 1874 | } |
| 1875 | 1875 | } |
@@ -1884,9 +1884,9 @@ discard block |
||
| 1884 | 1884 | * |
| 1885 | 1885 | * @return string |
| 1886 | 1886 | */ |
| 1887 | - private function generate_public_key( $user_email = '' ) { |
|
| 1888 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1889 | - $public = hash( 'md5', $user_email . $auth_key . date( 'U' ) ); |
|
| 1887 | + private function generate_public_key($user_email = '') { |
|
| 1888 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1889 | + $public = hash('md5', $user_email.$auth_key.date('U')); |
|
| 1890 | 1890 | |
| 1891 | 1891 | return $public; |
| 1892 | 1892 | } |
@@ -1901,9 +1901,9 @@ discard block |
||
| 1901 | 1901 | * |
| 1902 | 1902 | * @return string |
| 1903 | 1903 | */ |
| 1904 | - private function generate_private_key( $user_id = 0 ) { |
|
| 1905 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 1906 | - $secret = hash( 'md5', $user_id . $auth_key . date( 'U' ) ); |
|
| 1904 | + private function generate_private_key($user_id = 0) { |
|
| 1905 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 1906 | + $secret = hash('md5', $user_id.$auth_key.date('U')); |
|
| 1907 | 1907 | |
| 1908 | 1908 | return $secret; |
| 1909 | 1909 | } |
@@ -1918,8 +1918,8 @@ discard block |
||
| 1918 | 1918 | * |
| 1919 | 1919 | * @return string |
| 1920 | 1920 | */ |
| 1921 | - public function get_token( $user_id = 0 ) { |
|
| 1922 | - return hash( 'md5', $this->get_user_secret_key( $user_id ) . $this->get_user_public_key( $user_id ) ); |
|
| 1921 | + public function get_token($user_id = 0) { |
|
| 1922 | + return hash('md5', $this->get_user_secret_key($user_id).$this->get_user_public_key($user_id)); |
|
| 1923 | 1923 | } |
| 1924 | 1924 | |
| 1925 | 1925 | /** |
@@ -1933,9 +1933,9 @@ discard block |
||
| 1933 | 1933 | |
| 1934 | 1934 | // Default sales return |
| 1935 | 1935 | $sales = array(); |
| 1936 | - $sales['donations']['today'] = $this->stats->get_sales( 0, 'today' ); |
|
| 1937 | - $sales['donations']['current_month'] = $this->stats->get_sales( 0, 'this_month' ); |
|
| 1938 | - $sales['donations']['last_month'] = $this->stats->get_sales( 0, 'last_month' ); |
|
| 1936 | + $sales['donations']['today'] = $this->stats->get_sales(0, 'today'); |
|
| 1937 | + $sales['donations']['current_month'] = $this->stats->get_sales(0, 'this_month'); |
|
| 1938 | + $sales['donations']['last_month'] = $this->stats->get_sales(0, 'last_month'); |
|
| 1939 | 1939 | $sales['donations']['totals'] = give_get_total_sales(); |
| 1940 | 1940 | |
| 1941 | 1941 | return $sales; |
@@ -1952,9 +1952,9 @@ discard block |
||
| 1952 | 1952 | |
| 1953 | 1953 | // Default earnings return |
| 1954 | 1954 | $earnings = array(); |
| 1955 | - $earnings['earnings']['today'] = $this->stats->get_earnings( 0, 'today' ); |
|
| 1956 | - $earnings['earnings']['current_month'] = $this->stats->get_earnings( 0, 'this_month' ); |
|
| 1957 | - $earnings['earnings']['last_month'] = $this->stats->get_earnings( 0, 'last_month' ); |
|
| 1955 | + $earnings['earnings']['today'] = $this->stats->get_earnings(0, 'today'); |
|
| 1956 | + $earnings['earnings']['current_month'] = $this->stats->get_earnings(0, 'this_month'); |
|
| 1957 | + $earnings['earnings']['last_month'] = $this->stats->get_earnings(0, 'last_month'); |
|
| 1958 | 1958 | $earnings['earnings']['totals'] = give_get_total_earnings(); |
| 1959 | 1959 | |
| 1960 | 1960 | return $earnings; |
@@ -1974,25 +1974,25 @@ discard block |
||
| 1974 | 1974 | * |
| 1975 | 1975 | * @return string The API key/secret for the user supplied |
| 1976 | 1976 | */ |
| 1977 | - public function api_key_backwards_compat( $check, $object_id, $meta_key, $single ) { |
|
| 1977 | + public function api_key_backwards_compat($check, $object_id, $meta_key, $single) { |
|
| 1978 | 1978 | |
| 1979 | - if ( $meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key' ) { |
|
| 1979 | + if ($meta_key !== 'give_user_public_key' && $meta_key !== 'give_user_secret_key') { |
|
| 1980 | 1980 | return $check; |
| 1981 | 1981 | } |
| 1982 | 1982 | |
| 1983 | 1983 | $return = $check; |
| 1984 | 1984 | |
| 1985 | - switch ( $meta_key ) { |
|
| 1985 | + switch ($meta_key) { |
|
| 1986 | 1986 | case 'give_user_public_key': |
| 1987 | - $return = Give()->api->get_user_public_key( $object_id ); |
|
| 1987 | + $return = Give()->api->get_user_public_key($object_id); |
|
| 1988 | 1988 | break; |
| 1989 | 1989 | case 'give_user_secret_key': |
| 1990 | - $return = Give()->api->get_user_secret_key( $object_id ); |
|
| 1990 | + $return = Give()->api->get_user_secret_key($object_id); |
|
| 1991 | 1991 | break; |
| 1992 | 1992 | } |
| 1993 | 1993 | |
| 1994 | - if ( ! $single ) { |
|
| 1995 | - $return = array( $return ); |
|
| 1994 | + if ( ! $single) { |
|
| 1995 | + $return = array($return); |
|
| 1996 | 1996 | } |
| 1997 | 1997 | |
| 1998 | 1998 | return $return; |
@@ -10,7 +10,7 @@ |
||
| 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 | |
@@ -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 | |
@@ -62,50 +62,50 @@ discard block |
||
| 62 | 62 | * |
| 63 | 63 | * @return bool If the gravatar exists or not |
| 64 | 64 | */ |
| 65 | - public function validate_gravatar( $id_or_email ) { |
|
| 65 | + public function validate_gravatar($id_or_email) { |
|
| 66 | 66 | //id or email code borrowed from wp-includes/pluggable.php |
| 67 | 67 | $email = ''; |
| 68 | - if ( is_numeric( $id_or_email ) ) { |
|
| 68 | + if (is_numeric($id_or_email)) { |
|
| 69 | 69 | $id = (int) $id_or_email; |
| 70 | - $user = get_userdata( $id ); |
|
| 71 | - if ( $user ) { |
|
| 70 | + $user = get_userdata($id); |
|
| 71 | + if ($user) { |
|
| 72 | 72 | $email = $user->user_email; |
| 73 | 73 | } |
| 74 | - } elseif ( is_object( $id_or_email ) ) { |
|
| 74 | + } elseif (is_object($id_or_email)) { |
|
| 75 | 75 | // No avatar for pingbacks or trackbacks |
| 76 | - $allowed_comment_types = apply_filters( 'get_avatar_comment_types', array( 'comment' ) ); |
|
| 77 | - if ( ! empty( $id_or_email->comment_type ) && ! in_array( $id_or_email->comment_type, (array) $allowed_comment_types ) ) { |
|
| 76 | + $allowed_comment_types = apply_filters('get_avatar_comment_types', array('comment')); |
|
| 77 | + if ( ! empty($id_or_email->comment_type) && ! in_array($id_or_email->comment_type, (array) $allowed_comment_types)) { |
|
| 78 | 78 | return false; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if ( ! empty( $id_or_email->user_id ) ) { |
|
| 81 | + if ( ! empty($id_or_email->user_id)) { |
|
| 82 | 82 | $id = (int) $id_or_email->user_id; |
| 83 | - $user = get_userdata( $id ); |
|
| 84 | - if ( $user ) { |
|
| 83 | + $user = get_userdata($id); |
|
| 84 | + if ($user) { |
|
| 85 | 85 | $email = $user->user_email; |
| 86 | 86 | } |
| 87 | - } elseif ( ! empty( $id_or_email->comment_author_email ) ) { |
|
| 87 | + } elseif ( ! empty($id_or_email->comment_author_email)) { |
|
| 88 | 88 | $email = $id_or_email->comment_author_email; |
| 89 | 89 | } |
| 90 | 90 | } else { |
| 91 | 91 | $email = $id_or_email; |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | - $hashkey = md5( strtolower( trim( $email ) ) ); |
|
| 95 | - $uri = 'http://www.gravatar.com/avatar/' . $hashkey . '?d=404'; |
|
| 94 | + $hashkey = md5(strtolower(trim($email))); |
|
| 95 | + $uri = 'http://www.gravatar.com/avatar/'.$hashkey.'?d=404'; |
|
| 96 | 96 | |
| 97 | - $data = wp_cache_get( $hashkey ); |
|
| 98 | - if ( false === $data ) { |
|
| 99 | - $response = wp_remote_head( $uri ); |
|
| 100 | - if ( is_wp_error( $response ) ) { |
|
| 97 | + $data = wp_cache_get($hashkey); |
|
| 98 | + if (false === $data) { |
|
| 99 | + $response = wp_remote_head($uri); |
|
| 100 | + if (is_wp_error($response)) { |
|
| 101 | 101 | $data = 'not200'; |
| 102 | 102 | } else { |
| 103 | 103 | $data = $response['response']['code']; |
| 104 | 104 | } |
| 105 | - wp_cache_set( $hashkey, $data, $group = '', $expire = 60 * 5 ); |
|
| 105 | + wp_cache_set($hashkey, $data, $group = '', $expire = 60 * 5); |
|
| 106 | 106 | |
| 107 | 107 | } |
| 108 | - if ( $data == '200' ) { |
|
| 108 | + if ($data == '200') { |
|
| 109 | 109 | return true; |
| 110 | 110 | } else { |
| 111 | 111 | return false; |
@@ -122,19 +122,19 @@ discard block |
||
| 122 | 122 | * |
| 123 | 123 | * @return array IDs if logs, false otherwise |
| 124 | 124 | */ |
| 125 | - public function get_log_ids( $form_id = '' ) { |
|
| 125 | + public function get_log_ids($form_id = '') { |
|
| 126 | 126 | |
| 127 | 127 | // get Give_Logging class |
| 128 | 128 | global $give_logs; |
| 129 | 129 | |
| 130 | 130 | // get log for this form |
| 131 | - $logs = $give_logs->get_logs( $form_id ); |
|
| 131 | + $logs = $give_logs->get_logs($form_id); |
|
| 132 | 132 | |
| 133 | - if ( $logs ) { |
|
| 133 | + if ($logs) { |
|
| 134 | 134 | $log_ids = array(); |
| 135 | 135 | |
| 136 | 136 | // make an array with all the donor IDs |
| 137 | - foreach ( $logs as $log ) { |
|
| 137 | + foreach ($logs as $log) { |
|
| 138 | 138 | $log_ids[] = $log->ID; |
| 139 | 139 | } |
| 140 | 140 | |
@@ -155,51 +155,51 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @return mixed |
| 157 | 157 | */ |
| 158 | - public function get_payment_ids( $form_id = '' ) { |
|
| 158 | + public function get_payment_ids($form_id = '') { |
|
| 159 | 159 | |
| 160 | 160 | $give_options = give_get_settings(); |
| 161 | 161 | |
| 162 | - $log_ids = $this->get_log_ids( $form_id ); |
|
| 162 | + $log_ids = $this->get_log_ids($form_id); |
|
| 163 | 163 | |
| 164 | - if ( $log_ids ) { |
|
| 164 | + if ($log_ids) { |
|
| 165 | 165 | |
| 166 | 166 | $payment_ids = array(); |
| 167 | 167 | |
| 168 | - foreach ( $log_ids as $id ) { |
|
| 168 | + foreach ($log_ids as $id) { |
|
| 169 | 169 | // get the payment ID for each corresponding log ID |
| 170 | - $payment_ids[] = get_post_meta( $id, '_give_log_payment_id', true ); |
|
| 170 | + $payment_ids[] = get_post_meta($id, '_give_log_payment_id', true); |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // remove donors who have donated more than once so we can have unique avatars |
| 174 | 174 | $unique_emails = array(); |
| 175 | 175 | |
| 176 | - foreach ( $payment_ids as $key => $id ) { |
|
| 176 | + foreach ($payment_ids as $key => $id) { |
|
| 177 | 177 | |
| 178 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 178 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 179 | 179 | |
| 180 | - if ( isset ( $give_options['give_donors_gravatars_has_gravatar_account'] ) ) { |
|
| 181 | - if ( ! $this->validate_gravatar( $email ) ) { |
|
| 180 | + if (isset ($give_options['give_donors_gravatars_has_gravatar_account'])) { |
|
| 181 | + if ( ! $this->validate_gravatar($email)) { |
|
| 182 | 182 | continue; |
| 183 | 183 | } |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - $unique_emails[ $id ] = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 186 | + $unique_emails[$id] = get_post_meta($id, '_give_payment_user_email', true); |
|
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $unique_ids = array(); |
| 191 | 191 | |
| 192 | 192 | // strip duplicate emails |
| 193 | - $unique_emails = array_unique( $unique_emails ); |
|
| 193 | + $unique_emails = array_unique($unique_emails); |
|
| 194 | 194 | |
| 195 | 195 | // convert the unique IDs back into simple array |
| 196 | - foreach ( $unique_emails as $id => $email ) { |
|
| 196 | + foreach ($unique_emails as $id => $email) { |
|
| 197 | 197 | $unique_ids[] = $id; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // randomize the payment IDs if enabled |
| 201 | - if ( isset( $give_options['give_donors_gravatars_random_gravatars'] ) ) { |
|
| 202 | - shuffle( $unique_ids ); |
|
| 201 | + if (isset($give_options['give_donors_gravatars_random_gravatars'])) { |
|
| 202 | + shuffle($unique_ids); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | // return our unique IDs |
@@ -220,22 +220,22 @@ discard block |
||
| 220 | 220 | * |
| 221 | 221 | * @return string |
| 222 | 222 | */ |
| 223 | - public function gravatars( $form_id = false, $title = '' ) { |
|
| 223 | + public function gravatars($form_id = false, $title = '') { |
|
| 224 | 224 | |
| 225 | 225 | // unique $payment_ids |
| 226 | - $payment_ids = $this->get_payment_ids( $form_id ); |
|
| 226 | + $payment_ids = $this->get_payment_ids($form_id); |
|
| 227 | 227 | |
| 228 | 228 | $give_options = give_get_settings(); |
| 229 | 229 | |
| 230 | 230 | // return if no ID |
| 231 | - if ( ! $form_id ) { |
|
| 231 | + if ( ! $form_id) { |
|
| 232 | 232 | return; |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | // minimum amount of donations before showing gravatars |
| 236 | 236 | // if the number of items in array is not greater or equal to the number specified, then exit |
| 237 | - if ( isset( $give_options['give_donors_gravatars_min_purchases_required'] ) && '' != $give_options['give_donors_gravatars_min_purchases_required'] ) { |
|
| 238 | - if ( ! ( count( $payment_ids ) >= $give_options['give_donors_gravatars_min_purchases_required'] ) ) { |
|
| 237 | + if (isset($give_options['give_donors_gravatars_min_purchases_required']) && '' != $give_options['give_donors_gravatars_min_purchases_required']) { |
|
| 238 | + if ( ! (count($payment_ids) >= $give_options['give_donors_gravatars_min_purchases_required'])) { |
|
| 239 | 239 | return; |
| 240 | 240 | } |
| 241 | 241 | } |
@@ -246,51 +246,51 @@ discard block |
||
| 246 | 246 | echo '<div id="give-purchase-gravatars">'; |
| 247 | 247 | |
| 248 | 248 | |
| 249 | - if ( isset ( $title ) ) { |
|
| 249 | + if (isset ($title)) { |
|
| 250 | 250 | |
| 251 | - if ( $title ) { |
|
| 252 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $title ) . '</h3>' ); |
|
| 253 | - } elseif ( isset( $give_options['give_donors_gravatars_heading'] ) ) { |
|
| 254 | - echo apply_filters( 'give_donors_gravatars_title', '<h3 class="give-gravatars-title">' . esc_attr( $give_options['give_donors_gravatars_heading'] ) . '</h2>' ); |
|
| 251 | + if ($title) { |
|
| 252 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($title).'</h3>'); |
|
| 253 | + } elseif (isset($give_options['give_donors_gravatars_heading'])) { |
|
| 254 | + echo apply_filters('give_donors_gravatars_title', '<h3 class="give-gravatars-title">'.esc_attr($give_options['give_donors_gravatars_heading']).'</h2>'); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | } |
| 258 | 258 | echo '<ul class="give-purchase-gravatars-list">'; |
| 259 | 259 | $i = 0; |
| 260 | 260 | |
| 261 | - if ( $payment_ids ) { |
|
| 262 | - foreach ( $payment_ids as $id ) { |
|
| 261 | + if ($payment_ids) { |
|
| 262 | + foreach ($payment_ids as $id) { |
|
| 263 | 263 | |
| 264 | 264 | // Give saves a blank option even when the control is turned off, hence the extra check |
| 265 | - if ( isset( $give_options['give_donors_gravatars_maximum_number'] ) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number'] ) { |
|
| 265 | + if (isset($give_options['give_donors_gravatars_maximum_number']) && '' != $give_options['give_donors_gravatars_maximum_number'] && $i == $give_options['give_donors_gravatars_maximum_number']) { |
|
| 266 | 266 | continue; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // get the payment meta |
| 270 | - $payment_meta = get_post_meta( $id, '_give_payment_meta', true ); |
|
| 270 | + $payment_meta = get_post_meta($id, '_give_payment_meta', true); |
|
| 271 | 271 | |
| 272 | 272 | // unserialize the payment meta |
| 273 | - $user_info = maybe_unserialize( $payment_meta['user_info'] ); |
|
| 273 | + $user_info = maybe_unserialize($payment_meta['user_info']); |
|
| 274 | 274 | |
| 275 | 275 | // get donor's first name |
| 276 | 276 | $name = $user_info['first_name']; |
| 277 | 277 | |
| 278 | 278 | // get donor's email |
| 279 | - $email = get_post_meta( $id, '_give_payment_user_email', true ); |
|
| 279 | + $email = get_post_meta($id, '_give_payment_user_email', true); |
|
| 280 | 280 | |
| 281 | 281 | // set gravatar size and provide filter |
| 282 | - $size = isset( $give_options['give_donors_gravatars_gravatar_size'] ) ? apply_filters( 'give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size'] ) : ''; |
|
| 282 | + $size = isset($give_options['give_donors_gravatars_gravatar_size']) ? apply_filters('give_donors_gravatars_gravatar_size', $give_options['give_donors_gravatars_gravatar_size']) : ''; |
|
| 283 | 283 | |
| 284 | 284 | // default image |
| 285 | - $default_image = apply_filters( 'give_donors_gravatars_gravatar_default_image', false ); |
|
| 285 | + $default_image = apply_filters('give_donors_gravatars_gravatar_default_image', false); |
|
| 286 | 286 | |
| 287 | 287 | // assemble output |
| 288 | 288 | $output .= '<li>'; |
| 289 | 289 | |
| 290 | - $output .= get_avatar( $email, $size, $default_image, $name ); |
|
| 290 | + $output .= get_avatar($email, $size, $default_image, $name); |
|
| 291 | 291 | $output .= '</li>'; |
| 292 | 292 | |
| 293 | - $i ++; |
|
| 293 | + $i++; |
|
| 294 | 294 | |
| 295 | 295 | } // end foreach |
| 296 | 296 | } |
@@ -299,7 +299,7 @@ discard block |
||
| 299 | 299 | echo '</ul>'; |
| 300 | 300 | echo '</div>'; |
| 301 | 301 | |
| 302 | - return apply_filters( 'give_donors_gravatars', ob_get_clean() ); |
|
| 302 | + return apply_filters('give_donors_gravatars', ob_get_clean()); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @return void |
| 312 | 312 | */ |
| 313 | 313 | public function register_widget() { |
| 314 | - register_widget( 'Give_Donors_Gravatars_Widget' ); |
|
| 314 | + register_widget('Give_Donors_Gravatars_Widget'); |
|
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | /** |
@@ -327,19 +327,19 @@ discard block |
||
| 327 | 327 | * |
| 328 | 328 | * @todo Set the ID to get_the_ID() if ID parameter is not passed through. Otherwise it will incorrectly get other gravatars |
| 329 | 329 | */ |
| 330 | - public function shortcode( $atts, $content = null ) { |
|
| 330 | + public function shortcode($atts, $content = null) { |
|
| 331 | 331 | |
| 332 | - $atts = shortcode_atts( array( |
|
| 332 | + $atts = shortcode_atts(array( |
|
| 333 | 333 | 'id' => '', |
| 334 | 334 | 'title' => '' |
| 335 | - ), $atts, 'give_donors_gravatars' ); |
|
| 335 | + ), $atts, 'give_donors_gravatars'); |
|
| 336 | 336 | |
| 337 | 337 | // if no ID is passed on single give_forms pages, get the correct ID |
| 338 | - if ( is_singular( 'give_forms' ) ) { |
|
| 338 | + if (is_singular('give_forms')) { |
|
| 339 | 339 | $id = get_the_ID(); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $content = $this->gravatars( $atts['id'], $atts['title'] ); |
|
| 342 | + $content = $this->gravatars($atts['id'], $atts['title']); |
|
| 343 | 343 | |
| 344 | 344 | return $content; |
| 345 | 345 | |
@@ -355,56 +355,56 @@ discard block |
||
| 355 | 355 | * |
| 356 | 356 | * @return array Gravatar settings. |
| 357 | 357 | */ |
| 358 | - public function settings( $settings ) { |
|
| 358 | + public function settings($settings) { |
|
| 359 | 359 | |
| 360 | 360 | $give_gravatar_settings = array( |
| 361 | 361 | array( |
| 362 | - 'name' => esc_html__( 'Donator Gravatars', 'give' ), |
|
| 362 | + 'name' => esc_html__('Donator Gravatars', 'give'), |
|
| 363 | 363 | 'desc' => '<hr>', |
| 364 | 364 | 'id' => 'give_title', |
| 365 | 365 | 'type' => 'give_title' |
| 366 | 366 | ), |
| 367 | 367 | array( |
| 368 | - 'name' => esc_html__( 'Heading', 'give' ), |
|
| 369 | - 'desc' => esc_html__( 'The heading to display above the Gravatars.', 'give' ), |
|
| 368 | + 'name' => esc_html__('Heading', 'give'), |
|
| 369 | + 'desc' => esc_html__('The heading to display above the Gravatars.', 'give'), |
|
| 370 | 370 | 'type' => 'text', |
| 371 | 371 | 'id' => 'give_donors_gravatars_heading' |
| 372 | 372 | ), |
| 373 | 373 | array( |
| 374 | - 'name' => esc_html__( 'Gravatar Size', 'give' ), |
|
| 375 | - 'desc' => esc_html__( 'The size of each Gravatar in pixels (512px maximum).', 'give' ), |
|
| 374 | + 'name' => esc_html__('Gravatar Size', 'give'), |
|
| 375 | + 'desc' => esc_html__('The size of each Gravatar in pixels (512px maximum).', 'give'), |
|
| 376 | 376 | 'type' => 'text_small', |
| 377 | 377 | 'id' => 'give_donors_gravatars_gravatar_size', |
| 378 | 378 | 'default' => '64' |
| 379 | 379 | ), |
| 380 | 380 | array( |
| 381 | - 'name' => esc_html__( 'Minimum Unique Donations Required', 'give' ), |
|
| 382 | - 'desc' => esc_html__( 'The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give' ), |
|
| 381 | + 'name' => esc_html__('Minimum Unique Donations Required', 'give'), |
|
| 382 | + 'desc' => esc_html__('The minimum number of unique donations a form must have before the Gravatars are shown. Leave blank for no minimum.', 'give'), |
|
| 383 | 383 | 'type' => 'text_small', |
| 384 | 384 | 'id' => 'give_donors_gravatars_min_purchases_required', |
| 385 | 385 | ), |
| 386 | 386 | array( |
| 387 | - 'name' => esc_html__( 'Maximum Gravatars To Show', 'give' ), |
|
| 388 | - 'desc' => esc_html__( 'The maximum number of gravatars to show. Leave blank for no limit.', 'give' ), |
|
| 387 | + 'name' => esc_html__('Maximum Gravatars To Show', 'give'), |
|
| 388 | + 'desc' => esc_html__('The maximum number of gravatars to show. Leave blank for no limit.', 'give'), |
|
| 389 | 389 | 'type' => 'text', |
| 390 | 390 | 'id' => 'give_donors_gravatars_maximum_number', |
| 391 | 391 | 'default' => '20', |
| 392 | 392 | ), |
| 393 | 393 | array( |
| 394 | - 'name' => esc_html__( 'Gravatar Visibility', 'give' ), |
|
| 395 | - 'desc' => esc_html__( 'Show only donors with a Gravatar account.', 'give' ), |
|
| 394 | + 'name' => esc_html__('Gravatar Visibility', 'give'), |
|
| 395 | + 'desc' => esc_html__('Show only donors with a Gravatar account.', 'give'), |
|
| 396 | 396 | 'id' => 'give_donors_gravatars_has_gravatar_account', |
| 397 | 397 | 'type' => 'checkbox', |
| 398 | 398 | ), |
| 399 | 399 | array( |
| 400 | - 'name' => esc_html__( 'Randomize Gravatars', 'give' ), |
|
| 401 | - 'desc' => esc_html__( 'Randomize the Gravatars.', 'give' ), |
|
| 400 | + 'name' => esc_html__('Randomize Gravatars', 'give'), |
|
| 401 | + 'desc' => esc_html__('Randomize the Gravatars.', 'give'), |
|
| 402 | 402 | 'id' => 'give_donors_gravatars_random_gravatars', |
| 403 | 403 | 'type' => 'checkbox', |
| 404 | 404 | ), |
| 405 | 405 | ); |
| 406 | 406 | |
| 407 | - return array_merge( $settings, $give_gravatar_settings ); |
|
| 407 | + return array_merge($settings, $give_gravatar_settings); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | } |
@@ -430,7 +430,7 @@ discard block |
||
| 430 | 430 | // widget settings |
| 431 | 431 | $widget_ops = array( |
| 432 | 432 | 'classname' => 'give-donors-gravatars', |
| 433 | - 'description' => esc_html__( 'Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give' ), |
|
| 433 | + 'description' => esc_html__('Displays gravatars of people who have donated using your your form. Will only show on the single form page.', 'give'), |
|
| 434 | 434 | ); |
| 435 | 435 | |
| 436 | 436 | // widget control settings |
@@ -443,7 +443,7 @@ discard block |
||
| 443 | 443 | // create the widget |
| 444 | 444 | parent::__construct( |
| 445 | 445 | 'give_donors_gravatars_widget', |
| 446 | - esc_html__( 'Give Donors Gravatars', 'give' ), |
|
| 446 | + esc_html__('Give Donors Gravatars', 'give'), |
|
| 447 | 447 | $widget_ops, |
| 448 | 448 | $control_ops |
| 449 | 449 | ); |
@@ -463,29 +463,29 @@ discard block |
||
| 463 | 463 | * |
| 464 | 464 | * @return void |
| 465 | 465 | */ |
| 466 | - public function widget( $args, $instance ) { |
|
| 466 | + public function widget($args, $instance) { |
|
| 467 | 467 | |
| 468 | 468 | //@TODO: Don't extract it!!! |
| 469 | - extract( $args ); |
|
| 469 | + extract($args); |
|
| 470 | 470 | |
| 471 | - if ( ! is_singular( 'give_forms' ) ) { |
|
| 471 | + if ( ! is_singular('give_forms')) { |
|
| 472 | 472 | return; |
| 473 | 473 | } |
| 474 | 474 | |
| 475 | 475 | // Variables from widget settings |
| 476 | - $title = apply_filters( 'widget_title', $instance['title'] ); |
|
| 476 | + $title = apply_filters('widget_title', $instance['title']); |
|
| 477 | 477 | |
| 478 | 478 | // Used by themes. Opens the widget |
| 479 | 479 | echo $before_widget; |
| 480 | 480 | |
| 481 | 481 | // Display the widget title |
| 482 | - if ( $title ) { |
|
| 483 | - echo $before_title . $title . $after_title; |
|
| 482 | + if ($title) { |
|
| 483 | + echo $before_title.$title.$after_title; |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | $gravatars = new Give_Donors_Gravatars(); |
| 487 | 487 | |
| 488 | - echo $gravatars->gravatars( get_the_ID(), null ); // remove title |
|
| 488 | + echo $gravatars->gravatars(get_the_ID(), null); // remove title |
|
| 489 | 489 | |
| 490 | 490 | // Used by themes. Closes the widget |
| 491 | 491 | echo $after_widget; |
@@ -505,11 +505,11 @@ discard block |
||
| 505 | 505 | * |
| 506 | 506 | * @return array Updated settings to save. |
| 507 | 507 | */ |
| 508 | - public function update( $new_instance, $old_instance ) { |
|
| 508 | + public function update($new_instance, $old_instance) { |
|
| 509 | 509 | |
| 510 | 510 | $instance = $old_instance; |
| 511 | 511 | |
| 512 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
| 512 | + $instance['title'] = strip_tags($new_instance['title']); |
|
| 513 | 513 | |
| 514 | 514 | return $instance; |
| 515 | 515 | |
@@ -527,19 +527,19 @@ discard block |
||
| 527 | 527 | * |
| 528 | 528 | * @return void |
| 529 | 529 | */ |
| 530 | - public function form( $instance ) { |
|
| 530 | + public function form($instance) { |
|
| 531 | 531 | |
| 532 | 532 | // Set up some default widget settings. |
| 533 | 533 | $defaults = array( |
| 534 | 534 | 'title' => '', |
| 535 | 535 | ); |
| 536 | 536 | |
| 537 | - $instance = wp_parse_args( (array) $instance, $defaults ); ?> |
|
| 537 | + $instance = wp_parse_args((array) $instance, $defaults); ?> |
|
| 538 | 538 | |
| 539 | 539 | <!-- Title --> |
| 540 | 540 | <p> |
| 541 | - <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php esc_html_e( 'Title:', 'give' ) ?></label> |
|
| 542 | - <input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 541 | + <label for="<?php echo $this->get_field_id('title'); ?>"><?php esc_html_e('Title:', 'give') ?></label> |
|
| 542 | + <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo $instance['title']; ?>" /> |
|
| 543 | 543 | </p> |
| 544 | 544 | |
| 545 | 545 | <?php |
@@ -9,13 +9,13 @@ discard block |
||
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | // Exit if accessed directly |
| 12 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 12 | +if ( ! defined('ABSPATH')) { |
|
| 13 | 13 | exit; |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | // Load WP_List_Table if not loaded |
| 17 | -if ( ! class_exists( 'WP_List_Table' ) ) { |
|
| 18 | - require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; |
|
| 17 | +if ( ! class_exists('WP_List_Table')) { |
|
| 18 | + require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php'; |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | global $status, $page; |
| 45 | 45 | |
| 46 | 46 | // Set parent defaults |
| 47 | - parent::__construct( array( |
|
| 48 | - 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 49 | - 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 47 | + parent::__construct(array( |
|
| 48 | + 'singular' => give_get_forms_label_singular(), // Singular name of the listed records |
|
| 49 | + 'plural' => give_get_forms_label_plural(), // Plural name of the listed records |
|
| 50 | 50 | 'ajax' => false // Does this table support ajax? |
| 51 | - ) ); |
|
| 51 | + )); |
|
| 52 | 52 | |
| 53 | - add_action( 'give_log_view_actions', array( $this, 'give_forms_filter' ) ); |
|
| 53 | + add_action('give_log_view_actions', array($this, 'give_forms_filter')); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -64,37 +64,37 @@ discard block |
||
| 64 | 64 | * |
| 65 | 65 | * @return string Column Name |
| 66 | 66 | */ |
| 67 | - public function column_default( $item, $column_name ) { |
|
| 67 | + public function column_default($item, $column_name) { |
|
| 68 | 68 | |
| 69 | - $payment = give_get_payment_by( 'id', $item['payment_id'] ); |
|
| 69 | + $payment = give_get_payment_by('id', $item['payment_id']); |
|
| 70 | 70 | |
| 71 | - switch ( $column_name ) { |
|
| 71 | + switch ($column_name) { |
|
| 72 | 72 | case 'form' : |
| 73 | - return '<a href="' . esc_url( add_query_arg( 'form', $item[ $column_name ] ) ) . '" >' . get_the_title( $item[ $column_name ] ) . '</a>'; |
|
| 73 | + return '<a href="'.esc_url(add_query_arg('form', $item[$column_name])).'" >'.get_the_title($item[$column_name]).'</a>'; |
|
| 74 | 74 | |
| 75 | 75 | case 'user_id' : |
| 76 | - return '<a href="' . |
|
| 77 | - admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&user=' . ( ! empty( $item['user_id'] ) ? urlencode( $item['user_id'] ) : give_get_payment_user_email( $item['payment_id'] ) ) ) . |
|
| 78 | - '">' . $item['user_name'] . '</a>'; |
|
| 76 | + return '<a href="'. |
|
| 77 | + admin_url('edit.php?post_type=give_forms&page=give-payment-history&user='.( ! empty($item['user_id']) ? urlencode($item['user_id']) : give_get_payment_user_email($item['payment_id']))). |
|
| 78 | + '">'.$item['user_name'].'</a>'; |
|
| 79 | 79 | |
| 80 | 80 | case 'amount' : |
| 81 | - return give_currency_filter( give_format_amount( $item['amount'] ) ); |
|
| 81 | + return give_currency_filter(give_format_amount($item['amount'])); |
|
| 82 | 82 | |
| 83 | 83 | case 'status' : |
| 84 | 84 | |
| 85 | - $value = '<div class="give-donation-status status-' . sanitize_title( give_get_payment_status( $payment, true ) ) . '"><span class="give-donation-status-icon"></span> ' . give_get_payment_status( $payment, true ) . '</div>'; |
|
| 85 | + $value = '<div class="give-donation-status status-'.sanitize_title(give_get_payment_status($payment, true)).'"><span class="give-donation-status-icon"></span> '.give_get_payment_status($payment, true).'</div>'; |
|
| 86 | 86 | |
| 87 | - if ( $payment->mode == 'test' ) { |
|
| 88 | - $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="' . esc_attr__( 'This donation was made in test mode.', 'give' ) . '">' . esc_html__( 'Test', 'give' ) . '</span>'; |
|
| 87 | + if ($payment->mode == 'test') { |
|
| 88 | + $value .= ' <span class="give-item-label give-item-label-orange give-test-mode-transactions-label" data-tooltip="'.esc_attr__('This donation was made in test mode.', 'give').'">'.esc_html__('Test', 'give').'</span>'; |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | return $value; |
| 92 | 92 | |
| 93 | 93 | case 'payment_id' : |
| 94 | - return '<a href="' . admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id=' . $item['payment_id'] ) . '">' . give_get_payment_number( $item['payment_id'] ) . '</a>'; |
|
| 94 | + return '<a href="'.admin_url('edit.php?post_type=give_forms&page=give-payment-history&view=view-order-details&id='.$item['payment_id']).'">'.give_get_payment_number($item['payment_id']).'</a>'; |
|
| 95 | 95 | |
| 96 | 96 | default: |
| 97 | - return $item[ $column_name ]; |
|
| 97 | + return $item[$column_name]; |
|
| 98 | 98 | } |
| 99 | 99 | } |
| 100 | 100 | |
@@ -107,13 +107,13 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function get_columns() { |
| 109 | 109 | $columns = array( |
| 110 | - 'ID' => esc_html__( 'Log ID', 'give' ), |
|
| 111 | - 'user_id' => esc_html__( 'Donor', 'give' ), |
|
| 112 | - 'form' => esc_html__( 'Form', 'give' ), |
|
| 113 | - 'amount' => esc_html__( 'Donation Amount', 'give' ), |
|
| 114 | - 'status' => esc_html__( 'Status', 'give' ), |
|
| 115 | - 'payment_id' => esc_html__( 'Transaction ID', 'give' ), |
|
| 116 | - 'date' => esc_html__( 'Date', 'give' ) |
|
| 110 | + 'ID' => esc_html__('Log ID', 'give'), |
|
| 111 | + 'user_id' => esc_html__('Donor', 'give'), |
|
| 112 | + 'form' => esc_html__('Form', 'give'), |
|
| 113 | + 'amount' => esc_html__('Donation Amount', 'give'), |
|
| 114 | + 'status' => esc_html__('Status', 'give'), |
|
| 115 | + 'payment_id' => esc_html__('Transaction ID', 'give'), |
|
| 116 | + 'date' => esc_html__('Date', 'give') |
|
| 117 | 117 | ); |
| 118 | 118 | |
| 119 | 119 | return $columns; |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * @return int Current page number |
| 128 | 128 | */ |
| 129 | 129 | public function get_paged() { |
| 130 | - return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; |
|
| 130 | + return isset($_GET['paged']) ? absint($_GET['paged']) : 1; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | * @return mixed int If User ID, string If Email/Login |
| 139 | 139 | */ |
| 140 | 140 | public function get_filtered_user() { |
| 141 | - return isset( $_GET['user'] ) ? absint( $_GET['user'] ) : false; |
|
| 141 | + return isset($_GET['user']) ? absint($_GET['user']) : false; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /** |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | * @return int Download ID |
| 150 | 150 | */ |
| 151 | 151 | public function get_filtered_give_form() { |
| 152 | - return ! empty( $_GET['form'] ) ? absint( $_GET['form'] ) : false; |
|
| 152 | + return ! empty($_GET['form']) ? absint($_GET['form']) : false; |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @return mixed string If search is present, false otherwise |
| 161 | 161 | */ |
| 162 | 162 | public function get_search() { |
| 163 | - return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; |
|
| 163 | + return ! empty($_GET['s']) ? urldecode(trim($_GET['s'])) : false; |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | |
@@ -176,20 +176,20 @@ discard block |
||
| 176 | 176 | * |
| 177 | 177 | * @param string $which |
| 178 | 178 | */ |
| 179 | - protected function display_tablenav( $which ) { |
|
| 179 | + protected function display_tablenav($which) { |
|
| 180 | 180 | |
| 181 | - if ( 'top' === $which ) { |
|
| 182 | - wp_nonce_field( 'bulk-' . $this->_args['plural'] ); |
|
| 181 | + if ('top' === $which) { |
|
| 182 | + wp_nonce_field('bulk-'.$this->_args['plural']); |
|
| 183 | 183 | } |
| 184 | 184 | ?> |
| 185 | - <div class="tablenav <?php echo esc_attr( $which ); ?>"> |
|
| 185 | + <div class="tablenav <?php echo esc_attr($which); ?>"> |
|
| 186 | 186 | |
| 187 | 187 | <div class="alignleft actions bulkactions"> |
| 188 | - <?php $this->bulk_actions( $which ); ?> |
|
| 188 | + <?php $this->bulk_actions($which); ?> |
|
| 189 | 189 | </div> |
| 190 | 190 | <?php |
| 191 | - $this->extra_tablenav( $which ); |
|
| 192 | - $this->pagination( $which ); |
|
| 191 | + $this->extra_tablenav($which); |
|
| 192 | + $this->pagination($which); |
|
| 193 | 193 | ?> |
| 194 | 194 | |
| 195 | 195 | <br class="clear"/> |
@@ -212,7 +212,7 @@ discard block |
||
| 212 | 212 | |
| 213 | 213 | $meta_query = array(); |
| 214 | 214 | |
| 215 | - if ( $user ) { |
|
| 215 | + if ($user) { |
|
| 216 | 216 | // Show only logs from a specific user |
| 217 | 217 | $meta_query[] = array( |
| 218 | 218 | 'key' => '_give_log_user_id', |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | $search = $this->get_search(); |
| 224 | - if ( $search ) { |
|
| 225 | - if ( is_email( $search ) ) { |
|
| 224 | + if ($search) { |
|
| 225 | + if (is_email($search)) { |
|
| 226 | 226 | // This is an email search. We use this to ensure it works for guest users and logged-in users |
| 227 | 227 | $key = '_give_log_user_info'; |
| 228 | 228 | $compare = 'LIKE'; |
@@ -231,32 +231,32 @@ discard block |
||
| 231 | 231 | $key = '_give_log_user_id'; |
| 232 | 232 | $compare = 'LIKE'; |
| 233 | 233 | |
| 234 | - if ( ! is_numeric( $search ) ) { |
|
| 234 | + if ( ! is_numeric($search)) { |
|
| 235 | 235 | // Searching for user by username |
| 236 | - $user = get_user_by( 'login', $search ); |
|
| 236 | + $user = get_user_by('login', $search); |
|
| 237 | 237 | |
| 238 | - if ( $user ) { |
|
| 238 | + if ($user) { |
|
| 239 | 239 | // Found one, set meta value to user's ID |
| 240 | 240 | $search = $user->ID; |
| 241 | 241 | } else { |
| 242 | 242 | // No user found so let's do a real search query |
| 243 | - $users = new WP_User_Query( array( |
|
| 243 | + $users = new WP_User_Query(array( |
|
| 244 | 244 | 'search' => $search, |
| 245 | - 'search_columns' => array( 'user_url', 'user_nicename' ), |
|
| 245 | + 'search_columns' => array('user_url', 'user_nicename'), |
|
| 246 | 246 | 'number' => 1, |
| 247 | 247 | 'fields' => 'ids' |
| 248 | - ) ); |
|
| 248 | + )); |
|
| 249 | 249 | |
| 250 | 250 | $found_user = $users->get_results(); |
| 251 | 251 | |
| 252 | - if ( $found_user ) { |
|
| 252 | + if ($found_user) { |
|
| 253 | 253 | $search = $found_user[0]; |
| 254 | 254 | } |
| 255 | 255 | } |
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - if ( ! $this->file_search ) { |
|
| 259 | + if ( ! $this->file_search) { |
|
| 260 | 260 | // Meta query only works for non file name searche |
| 261 | 261 | $meta_query[] = array( |
| 262 | 262 | 'key' => $key, |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * @since 1.0 |
| 278 | 278 | * @return void |
| 279 | 279 | */ |
| 280 | - function bulk_actions( $which = '' ) { |
|
| 280 | + function bulk_actions($which = '') { |
|
| 281 | 281 | give_log_views(); |
| 282 | 282 | } |
| 283 | 283 | |
@@ -289,22 +289,22 @@ discard block |
||
| 289 | 289 | * @return void |
| 290 | 290 | */ |
| 291 | 291 | public function give_forms_filter() { |
| 292 | - $give_forms = get_posts( array( |
|
| 292 | + $give_forms = get_posts(array( |
|
| 293 | 293 | 'post_type' => 'give_forms', |
| 294 | 294 | 'post_status' => 'any', |
| 295 | - 'posts_per_page' => - 1, |
|
| 295 | + 'posts_per_page' => -1, |
|
| 296 | 296 | 'orderby' => 'title', |
| 297 | 297 | 'order' => 'ASC', |
| 298 | 298 | 'fields' => 'ids', |
| 299 | 299 | 'update_post_meta_cache' => false, |
| 300 | 300 | 'update_post_term_cache' => false |
| 301 | - ) ); |
|
| 301 | + )); |
|
| 302 | 302 | |
| 303 | - if ( $give_forms ) { |
|
| 303 | + if ($give_forms) { |
|
| 304 | 304 | echo '<select name="form" id="give-log-form-filter">'; |
| 305 | - echo '<option value="0">' . esc_html__( 'All', 'give' ) . '</option>'; |
|
| 306 | - foreach ( $give_forms as $form ) { |
|
| 307 | - echo '<option value="' . $form . '"' . selected( $form, $this->get_filtered_give_form() ) . '>' . esc_html( get_the_title( $form ) ) . '</option>'; |
|
| 305 | + echo '<option value="0">'.esc_html__('All', 'give').'</option>'; |
|
| 306 | + foreach ($give_forms as $form) { |
|
| 307 | + echo '<option value="'.$form.'"'.selected($form, $this->get_filtered_give_form()).'>'.esc_html(get_the_title($form)).'</option>'; |
|
| 308 | 308 | } |
| 309 | 309 | echo '</select>'; |
| 310 | 310 | } |
@@ -322,11 +322,11 @@ discard block |
||
| 322 | 322 | global $give_logs; |
| 323 | 323 | |
| 324 | 324 | // Prevent the queries from getting cached. Without this there are occasional memory issues for some installs |
| 325 | - wp_suspend_cache_addition( true ); |
|
| 325 | + wp_suspend_cache_addition(true); |
|
| 326 | 326 | |
| 327 | 327 | $logs_data = array(); |
| 328 | 328 | $paged = $this->get_paged(); |
| 329 | - $give_form = empty( $_GET['s'] ) ? $this->get_filtered_give_form() : null; |
|
| 329 | + $give_form = empty($_GET['s']) ? $this->get_filtered_give_form() : null; |
|
| 330 | 330 | $user = $this->get_filtered_user(); |
| 331 | 331 | |
| 332 | 332 | $log_query = array( |
@@ -336,26 +336,26 @@ discard block |
||
| 336 | 336 | 'meta_query' => $this->get_meta_query() |
| 337 | 337 | ); |
| 338 | 338 | |
| 339 | - $logs = $give_logs->get_connected_logs( $log_query ); |
|
| 339 | + $logs = $give_logs->get_connected_logs($log_query); |
|
| 340 | 340 | |
| 341 | - if ( $logs ) { |
|
| 342 | - foreach ( $logs as $log ) { |
|
| 343 | - $payment_id = get_post_meta( $log->ID, '_give_log_payment_id', true ); |
|
| 341 | + if ($logs) { |
|
| 342 | + foreach ($logs as $log) { |
|
| 343 | + $payment_id = get_post_meta($log->ID, '_give_log_payment_id', true); |
|
| 344 | 344 | |
| 345 | 345 | // Make sure this payment hasn't been deleted |
| 346 | - if ( get_post( $payment_id ) ) : |
|
| 347 | - $user_info = give_get_payment_meta_user_info( $payment_id ); |
|
| 348 | - $payment_meta = give_get_payment_meta( $payment_id ); |
|
| 349 | - $payment_amount = give_get_payment_amount( $payment_id ); |
|
| 346 | + if (get_post($payment_id)) : |
|
| 347 | + $user_info = give_get_payment_meta_user_info($payment_id); |
|
| 348 | + $payment_meta = give_get_payment_meta($payment_id); |
|
| 349 | + $payment_amount = give_get_payment_amount($payment_id); |
|
| 350 | 350 | |
| 351 | 351 | $logs_data[] = array( |
| 352 | - 'ID' => '<span class="give-item-label give-item-label-gray">' . $log->ID . '</span>', |
|
| 352 | + 'ID' => '<span class="give-item-label give-item-label-gray">'.$log->ID.'</span>', |
|
| 353 | 353 | 'payment_id' => $payment_id, |
| 354 | 354 | 'form' => $log->post_parent, |
| 355 | 355 | 'amount' => $payment_amount, |
| 356 | 356 | 'user_id' => $user_info['id'], |
| 357 | - 'user_name' => $user_info['first_name'] . ' ' . $user_info['last_name'], |
|
| 358 | - 'date' => get_post_field( 'post_date', $payment_id ) |
|
| 357 | + 'user_name' => $user_info['first_name'].' '.$user_info['last_name'], |
|
| 358 | + 'date' => get_post_field('post_date', $payment_id) |
|
| 359 | 359 | ); |
| 360 | 360 | |
| 361 | 361 | endif; |
@@ -384,15 +384,15 @@ discard block |
||
| 384 | 384 | $columns = $this->get_columns(); |
| 385 | 385 | $hidden = array(); |
| 386 | 386 | $sortable = $this->get_sortable_columns(); |
| 387 | - $this->_column_headers = array( $columns, $hidden, $sortable ); |
|
| 387 | + $this->_column_headers = array($columns, $hidden, $sortable); |
|
| 388 | 388 | $current_page = $this->get_pagenum(); |
| 389 | 389 | $this->items = $this->get_logs(); |
| 390 | - $total_items = $give_logs->get_log_count( $this->get_filtered_give_form(), 'sale', $this->get_meta_query() ); |
|
| 390 | + $total_items = $give_logs->get_log_count($this->get_filtered_give_form(), 'sale', $this->get_meta_query()); |
|
| 391 | 391 | |
| 392 | - $this->set_pagination_args( array( |
|
| 392 | + $this->set_pagination_args(array( |
|
| 393 | 393 | 'total_items' => $total_items, |
| 394 | 394 | 'per_page' => $this->per_page, |
| 395 | - 'total_pages' => ceil( $total_items / $this->per_page ) |
|
| 395 | + 'total_pages' => ceil($total_items / $this->per_page) |
|
| 396 | 396 | ) |
| 397 | 397 | ); |
| 398 | 398 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | */ |
| 17 | 17 | |
| 18 | 18 | // Exit if accessed directly |
| 19 | -if ( ! defined( 'ABSPATH' ) ) { |
|
| 19 | +if ( ! defined('ABSPATH')) { |
|
| 20 | 20 | exit; |
| 21 | 21 | } |
| 22 | 22 | |
@@ -29,32 +29,32 @@ discard block |
||
| 29 | 29 | * @return void |
| 30 | 30 | */ |
| 31 | 31 | function give_reports_page() { |
| 32 | - $current_page = admin_url( 'edit.php?post_type=give_forms&page=give-reports' ); |
|
| 33 | - $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'reports'; |
|
| 32 | + $current_page = admin_url('edit.php?post_type=give_forms&page=give-reports'); |
|
| 33 | + $active_tab = isset($_GET['tab']) ? $_GET['tab'] : 'reports'; |
|
| 34 | 34 | ?> |
| 35 | 35 | <div class="wrap"> |
| 36 | 36 | |
| 37 | 37 | <h1 class="screen-reader-text"><?php echo get_admin_page_title(); ?></h1> |
| 38 | 38 | |
| 39 | 39 | <h2 class="nav-tab-wrapper"> |
| 40 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 40 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 41 | 41 | 'tab' => 'reports', |
| 42 | 42 | 'settings-updated' => false |
| 43 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Reports', 'give' ); ?></a> |
|
| 44 | - <?php if ( current_user_can( 'export_give_reports' ) ) { ?> |
|
| 45 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 43 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'reports' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Reports', 'give'); ?></a> |
|
| 44 | + <?php if (current_user_can('export_give_reports')) { ?> |
|
| 45 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 46 | 46 | 'tab' => 'export', |
| 47 | 47 | 'settings-updated' => false |
| 48 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Export', 'give' ); ?></a> |
|
| 48 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'export' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Export', 'give'); ?></a> |
|
| 49 | 49 | <?php } ?> |
| 50 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 50 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 51 | 51 | 'tab' => 'logs', |
| 52 | 52 | 'settings-updated' => false |
| 53 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Logs', 'give' ); ?></a> |
|
| 54 | - <a href="<?php echo esc_url( add_query_arg( array( |
|
| 53 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'logs' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Logs', 'give'); ?></a> |
|
| 54 | + <a href="<?php echo esc_url(add_query_arg(array( |
|
| 55 | 55 | 'tab' => 'tools', |
| 56 | 56 | 'settings-updated' => false |
| 57 | - ), $current_page ) ); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e( 'Tools', 'give' ); ?></a> |
|
| 57 | + ), $current_page)); ?>" class="nav-tab <?php echo $active_tab == 'tools' ? 'nav-tab-active' : ''; ?>"><?php esc_html_e('Tools', 'give'); ?></a> |
|
| 58 | 58 | <?php |
| 59 | 59 | /** |
| 60 | 60 | * Fires in the report tabs. |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @since 1.0 |
| 65 | 65 | */ |
| 66 | - do_action( 'give_reports_tabs' ); |
|
| 66 | + do_action('give_reports_tabs'); |
|
| 67 | 67 | ?> |
| 68 | 68 | </h2> |
| 69 | 69 | |
@@ -73,21 +73,21 @@ discard block |
||
| 73 | 73 | * |
| 74 | 74 | * @since 1.0 |
| 75 | 75 | */ |
| 76 | - do_action( 'give_reports_page_top' ); |
|
| 76 | + do_action('give_reports_page_top'); |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * Fires the report page active tab. |
| 80 | 80 | * |
| 81 | 81 | * @since 1.0 |
| 82 | 82 | */ |
| 83 | - do_action( "give_reports_tab_{$active_tab}" ); |
|
| 83 | + do_action("give_reports_tab_{$active_tab}"); |
|
| 84 | 84 | |
| 85 | 85 | /** |
| 86 | 86 | * Fires after the report page. |
| 87 | 87 | * |
| 88 | 88 | * @since 1.0 |
| 89 | 89 | */ |
| 90 | - do_action( 'give_reports_page_bottom' ); |
|
| 90 | + do_action('give_reports_page_bottom'); |
|
| 91 | 91 | ?> |
| 92 | 92 | </div><!-- .wrap --> |
| 93 | 93 | <?php |
@@ -101,13 +101,13 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | function give_reports_default_views() { |
| 103 | 103 | $views = array( |
| 104 | - 'earnings' => esc_html__( 'Income', 'give' ), |
|
| 105 | - 'forms' => esc_html__( 'Forms', 'give' ), |
|
| 106 | - 'donors' => esc_html__( 'Donors', 'give' ), |
|
| 107 | - 'gateways' => esc_html__( 'Payment Methods', 'give' ) |
|
| 104 | + 'earnings' => esc_html__('Income', 'give'), |
|
| 105 | + 'forms' => esc_html__('Forms', 'give'), |
|
| 106 | + 'donors' => esc_html__('Donors', 'give'), |
|
| 107 | + 'gateways' => esc_html__('Payment Methods', 'give') |
|
| 108 | 108 | ); |
| 109 | 109 | |
| 110 | - $views = apply_filters( 'give_report_views', $views ); |
|
| 110 | + $views = apply_filters('give_report_views', $views); |
|
| 111 | 111 | |
| 112 | 112 | return $views; |
| 113 | 113 | } |
@@ -123,15 +123,15 @@ discard block |
||
| 123 | 123 | * @return string $view Report View |
| 124 | 124 | * |
| 125 | 125 | */ |
| 126 | -function give_get_reporting_view( $default = 'earnings' ) { |
|
| 126 | +function give_get_reporting_view($default = 'earnings') { |
|
| 127 | 127 | |
| 128 | - if ( ! isset( $_GET['view'] ) || ! in_array( $_GET['view'], array_keys( give_reports_default_views() ) ) ) { |
|
| 128 | + if ( ! isset($_GET['view']) || ! in_array($_GET['view'], array_keys(give_reports_default_views()))) { |
|
| 129 | 129 | $view = $default; |
| 130 | 130 | } else { |
| 131 | 131 | $view = $_GET['view']; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - return apply_filters( 'give_get_reporting_view', $view ); |
|
| 134 | + return apply_filters('give_get_reporting_view', $view); |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | /** |
@@ -144,7 +144,7 @@ discard block |
||
| 144 | 144 | $current_view = 'earnings'; |
| 145 | 145 | $views = give_reports_default_views(); |
| 146 | 146 | |
| 147 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $views ) ) { |
|
| 147 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $views)) { |
|
| 148 | 148 | $current_view = $_GET['view']; |
| 149 | 149 | } |
| 150 | 150 | |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | * |
| 154 | 154 | * @since 1.0 |
| 155 | 155 | */ |
| 156 | - do_action( "give_reports_view_{$current_view}" ); |
|
| 156 | + do_action("give_reports_view_{$current_view}"); |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | -add_action( 'give_reports_tab_reports', 'give_reports_tab_reports' ); |
|
| 159 | +add_action('give_reports_tab_reports', 'give_reports_tab_reports'); |
|
| 160 | 160 | |
| 161 | 161 | /** |
| 162 | 162 | * Renders the Reports Page Views Drop Downs |
@@ -166,19 +166,19 @@ discard block |
||
| 166 | 166 | */ |
| 167 | 167 | function give_report_views() { |
| 168 | 168 | $views = give_reports_default_views(); |
| 169 | - $current_view = isset( $_GET['view'] ) ? $_GET['view'] : 'earnings'; |
|
| 169 | + $current_view = isset($_GET['view']) ? $_GET['view'] : 'earnings'; |
|
| 170 | 170 | /** |
| 171 | 171 | * Fires before the report page actions form. |
| 172 | 172 | * |
| 173 | 173 | * @since 1.0 |
| 174 | 174 | */ |
| 175 | - do_action( 'give_report_view_actions_before' ); |
|
| 175 | + do_action('give_report_view_actions_before'); |
|
| 176 | 176 | ?> |
| 177 | 177 | <form id="give-reports-filter" method="get"> |
| 178 | 178 | <select id="give-reports-view" name="view"> |
| 179 | - <option value="-1"><?php esc_html_e( 'Report Type', 'give' ); ?></option> |
|
| 180 | - <?php foreach ( $views as $view_id => $label ) : ?> |
|
| 181 | - <option value="<?php echo esc_attr( $view_id ); ?>" <?php selected( $view_id, $current_view ); ?>><?php echo $label; ?></option> |
|
| 179 | + <option value="-1"><?php esc_html_e('Report Type', 'give'); ?></option> |
|
| 180 | + <?php foreach ($views as $view_id => $label) : ?> |
|
| 181 | + <option value="<?php echo esc_attr($view_id); ?>" <?php selected($view_id, $current_view); ?>><?php echo $label; ?></option> |
|
| 182 | 182 | <?php endforeach; ?> |
| 183 | 183 | </select> |
| 184 | 184 | |
@@ -190,12 +190,12 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @since 1.0 |
| 192 | 192 | */ |
| 193 | - do_action( 'give_report_view_actions' ); |
|
| 193 | + do_action('give_report_view_actions'); |
|
| 194 | 194 | ?> |
| 195 | 195 | |
| 196 | 196 | <input type="hidden" name="post_type" value="give_forms"/> |
| 197 | 197 | <input type="hidden" name="page" value="give-reports"/> |
| 198 | - <?php submit_button( esc_html__( 'Show', 'give' ), 'secondary', 'submit', false ); ?> |
|
| 198 | + <?php submit_button(esc_html__('Show', 'give'), 'secondary', 'submit', false); ?> |
|
| 199 | 199 | </form> |
| 200 | 200 | <?php |
| 201 | 201 | /** |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * |
| 204 | 204 | * @since 1.0 |
| 205 | 205 | */ |
| 206 | - do_action( 'give_report_view_actions_after' ); |
|
| 206 | + do_action('give_report_view_actions_after'); |
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | /** |
@@ -216,18 +216,18 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | function give_reports_forms_table() { |
| 218 | 218 | |
| 219 | - if ( isset( $_GET['form-id'] ) ) { |
|
| 219 | + if (isset($_GET['form-id'])) { |
|
| 220 | 220 | return; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - include( dirname( __FILE__ ) . '/class-form-reports-table.php' ); |
|
| 223 | + include(dirname(__FILE__).'/class-form-reports-table.php'); |
|
| 224 | 224 | |
| 225 | 225 | $give_table = new Give_Form_Reports_Table(); |
| 226 | 226 | $give_table->prepare_items(); |
| 227 | 227 | $give_table->display(); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | -add_action( 'give_reports_view_forms', 'give_reports_forms_table' ); |
|
| 230 | +add_action('give_reports_view_forms', 'give_reports_forms_table'); |
|
| 231 | 231 | |
| 232 | 232 | /** |
| 233 | 233 | * Renders the detailed report for a specific give form |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * @return void |
| 237 | 237 | */ |
| 238 | 238 | function give_reports_form_details() { |
| 239 | - if ( ! isset( $_GET['form-id'] ) ) { |
|
| 239 | + if ( ! isset($_GET['form-id'])) { |
|
| 240 | 240 | return; |
| 241 | 241 | } |
| 242 | 242 | ?> |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | <div class="actions bulkactions"> |
| 245 | 245 | <?php give_report_views(); ?> |
| 246 | 246 | |
| 247 | - <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e( 'Go Back', 'give' ); ?></button> |
|
| 247 | + <button onclick="history.go(-1);" class="button-secondary"><?php esc_html_e('Go Back', 'give'); ?></button> |
|
| 248 | 248 | </div> |
| 249 | 249 | </div> |
| 250 | 250 | <?php |
| 251 | - give_reports_graph_of_form( absint( $_GET['form-id'] ) ); |
|
| 251 | + give_reports_graph_of_form(absint($_GET['form-id'])); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | -add_action( 'give_reports_view_forms', 'give_reports_form_details' ); |
|
| 254 | +add_action('give_reports_view_forms', 'give_reports_form_details'); |
|
| 255 | 255 | |
| 256 | 256 | /** |
| 257 | 257 | * Renders the Reports Donors Table |
@@ -262,7 +262,7 @@ discard block |
||
| 262 | 262 | * @return void |
| 263 | 263 | */ |
| 264 | 264 | function give_reports_donors_table() { |
| 265 | - include( dirname( __FILE__ ) . '/class-donor-reports-table.php' ); |
|
| 265 | + include(dirname(__FILE__).'/class-donor-reports-table.php'); |
|
| 266 | 266 | |
| 267 | 267 | $give_table = new Give_Donor_Reports_Table(); |
| 268 | 268 | $give_table->prepare_items(); |
@@ -274,11 +274,11 @@ discard block |
||
| 274 | 274 | * |
| 275 | 275 | * @since 1.0 |
| 276 | 276 | */ |
| 277 | - do_action( 'give_logs_donors_table_top' ); |
|
| 277 | + do_action('give_logs_donors_table_top'); |
|
| 278 | 278 | ?> |
| 279 | - <form id="give-donors-filter" method="get" action="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-reports&view=donors' ); ?>"> |
|
| 279 | + <form id="give-donors-filter" method="get" action="<?php echo admin_url('edit.php?post_type=give_forms&page=give-reports&view=donors'); ?>"> |
|
| 280 | 280 | <?php |
| 281 | - $give_table->search_box( esc_html__( 'Search', 'give' ), 'give-donors' ); |
|
| 281 | + $give_table->search_box(esc_html__('Search', 'give'), 'give-donors'); |
|
| 282 | 282 | $give_table->display(); |
| 283 | 283 | ?> |
| 284 | 284 | <input type="hidden" name="post_type" value="give_forms"/> |
@@ -291,13 +291,13 @@ discard block |
||
| 291 | 291 | * |
| 292 | 292 | * @since 1.0 |
| 293 | 293 | */ |
| 294 | - do_action( 'give_logs_donors_table_bottom' ); |
|
| 294 | + do_action('give_logs_donors_table_bottom'); |
|
| 295 | 295 | ?> |
| 296 | 296 | </div> |
| 297 | 297 | <?php |
| 298 | 298 | } |
| 299 | 299 | |
| 300 | -add_action( 'give_reports_view_donors', 'give_reports_donors_table' ); |
|
| 300 | +add_action('give_reports_view_donors', 'give_reports_donors_table'); |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | /** |
@@ -309,14 +309,14 @@ discard block |
||
| 309 | 309 | * @return void |
| 310 | 310 | */ |
| 311 | 311 | function give_reports_gateways_table() { |
| 312 | - include( dirname( __FILE__ ) . '/class-gateways-reports-table.php' ); |
|
| 312 | + include(dirname(__FILE__).'/class-gateways-reports-table.php'); |
|
| 313 | 313 | |
| 314 | 314 | $give_table = new Give_Gateawy_Reports_Table(); |
| 315 | 315 | $give_table->prepare_items(); |
| 316 | 316 | $give_table->display(); |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | -add_action( 'give_reports_view_gateways', 'give_reports_gateways_table' ); |
|
| 319 | +add_action('give_reports_view_gateways', 'give_reports_gateways_table'); |
|
| 320 | 320 | |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | function give_reports_earnings() { |
| 329 | 329 | ?> |
| 330 | 330 | <div class="tablenav top reports-table-nav"> |
| 331 | - <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e( 'Income Over Time', 'give' ); ?></span></h3> |
|
| 331 | + <h3 class="alignleft reports-earnings-title"><span><?php esc_html_e('Income Over Time', 'give'); ?></span></h3> |
|
| 332 | 332 | |
| 333 | 333 | <div class="alignright actions reports-views-wrap"><?php give_report_views(); ?></div> |
| 334 | 334 | </div> |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | give_reports_graph(); |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | -add_action( 'give_reports_view_earnings', 'give_reports_earnings' ); |
|
| 339 | +add_action('give_reports_view_earnings', 'give_reports_earnings'); |
|
| 340 | 340 | |
| 341 | 341 | |
| 342 | 342 | /** |
@@ -357,14 +357,14 @@ discard block |
||
| 357 | 357 | * |
| 358 | 358 | * @since 1.0 |
| 359 | 359 | */ |
| 360 | - do_action( 'give_reports_tab_export_content_top' ); |
|
| 360 | + do_action('give_reports_tab_export_content_top'); |
|
| 361 | 361 | ?> |
| 362 | 362 | |
| 363 | 363 | <table class="widefat export-options-table give-table"> |
| 364 | 364 | <thead> |
| 365 | 365 | <tr> |
| 366 | - <th scope="col"><?php esc_html_e( 'Export Type', 'give' ); ?></th> |
|
| 367 | - <th scope="col"><?php esc_html_e( 'Export Options', 'give' ); ?></th> |
|
| 366 | + <th scope="col"><?php esc_html_e('Export Type', 'give'); ?></th> |
|
| 367 | + <th scope="col"><?php esc_html_e('Export Options', 'give'); ?></th> |
|
| 368 | 368 | </tr> |
| 369 | 369 | </thead> |
| 370 | 370 | <tbody> |
@@ -376,41 +376,41 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @since 1.0 |
| 378 | 378 | */ |
| 379 | - do_action( 'give_reports_tab_export_table_top' ); |
|
| 379 | + do_action('give_reports_tab_export_table_top'); |
|
| 380 | 380 | ?> |
| 381 | 381 | <tr class="give-export-pdf-sales-earnings"> |
| 382 | 382 | <td scope="row" class="row-title"> |
| 383 | - <h3><span><?php esc_html_e( 'Export PDF of Donations and Income', 'give' ); ?></span></h3> |
|
| 384 | - <p><?php esc_html_e( 'Download a PDF of Donations and Income reports for all forms for the current year.', 'give' ); ?></p> |
|
| 383 | + <h3><span><?php esc_html_e('Export PDF of Donations and Income', 'give'); ?></span></h3> |
|
| 384 | + <p><?php esc_html_e('Download a PDF of Donations and Income reports for all forms for the current year.', 'give'); ?></p> |
|
| 385 | 385 | </td> |
| 386 | 386 | <td> |
| 387 | - <a class="button" href="<?php echo wp_nonce_url( add_query_arg( array( 'give-action' => 'generate_pdf' ) ), 'give_generate_pdf' ); ?>"><?php esc_html_e( 'Generate PDF', 'give' ); ?></a> |
|
| 387 | + <a class="button" href="<?php echo wp_nonce_url(add_query_arg(array('give-action' => 'generate_pdf')), 'give_generate_pdf'); ?>"><?php esc_html_e('Generate PDF', 'give'); ?></a> |
|
| 388 | 388 | </td> |
| 389 | 389 | </tr> |
| 390 | 390 | <tr class="alternate give-export-sales-earnings"> |
| 391 | 391 | <td scope="row" class="row-title"> |
| 392 | - <h3><span><?php esc_html_e( 'Export Income and Donation Stats', 'give' ); ?></span></h3> |
|
| 393 | - <p><?php esc_html_e( 'Download a CSV of income and donations over time.', 'give' ); ?></p> |
|
| 392 | + <h3><span><?php esc_html_e('Export Income and Donation Stats', 'give'); ?></span></h3> |
|
| 393 | + <p><?php esc_html_e('Download a CSV of income and donations over time.', 'give'); ?></p> |
|
| 394 | 394 | </td> |
| 395 | 395 | <td> |
| 396 | 396 | <form method="post"> |
| 397 | 397 | <?php |
| 398 | 398 | printf( |
| 399 | 399 | /* translators: 1: start date dropdown 2: end date dropdown */ |
| 400 | - esc_html__( '%1$s to %2$s', 'give' ), |
|
| 401 | - Give()->html->year_dropdown( 'start_year' ) . ' ' . Give()->html->month_dropdown( 'start_month' ), |
|
| 402 | - Give()->html->year_dropdown( 'end_year' ) . ' ' . Give()->html->month_dropdown( 'end_month' ) |
|
| 400 | + esc_html__('%1$s to %2$s', 'give'), |
|
| 401 | + Give()->html->year_dropdown('start_year').' '.Give()->html->month_dropdown('start_month'), |
|
| 402 | + Give()->html->year_dropdown('end_year').' '.Give()->html->month_dropdown('end_month') |
|
| 403 | 403 | ); |
| 404 | 404 | ?> |
| 405 | 405 | <input type="hidden" name="give-action" value="earnings_export"/> |
| 406 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 406 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 407 | 407 | </form> |
| 408 | 408 | </td> |
| 409 | 409 | </tr> |
| 410 | 410 | <tr class="give-export-payment-history"> |
| 411 | 411 | <td scope="row" class="row-title"> |
| 412 | - <h3><span><?php esc_html_e( 'Export Donation History', 'give' ); ?></span></h3> |
|
| 413 | - <p><?php esc_html_e( 'Download a CSV of all donations recorded.', 'give' ); ?></p> |
|
| 412 | + <h3><span><?php esc_html_e('Export Donation History', 'give'); ?></span></h3> |
|
| 413 | + <p><?php esc_html_e('Download a CSV of all donations recorded.', 'give'); ?></p> |
|
| 414 | 414 | </td> |
| 415 | 415 | <td> |
| 416 | 416 | <form id="give-export-payments" class="give-export-form" method="post"> |
@@ -418,29 +418,29 @@ discard block |
||
| 418 | 418 | $args = array( |
| 419 | 419 | 'id' => 'give-payment-export-start', |
| 420 | 420 | 'name' => 'start', |
| 421 | - 'placeholder' => esc_attr__( 'Start date', 'give' ) |
|
| 421 | + 'placeholder' => esc_attr__('Start date', 'give') |
|
| 422 | 422 | ); |
| 423 | - echo Give()->html->date_field( $args ); ?> |
|
| 423 | + echo Give()->html->date_field($args); ?> |
|
| 424 | 424 | <?php |
| 425 | 425 | $args = array( |
| 426 | 426 | 'id' => 'give-payment-export-end', |
| 427 | 427 | 'name' => 'end', |
| 428 | - 'placeholder' => esc_attr__( 'End date', 'give' ) |
|
| 428 | + 'placeholder' => esc_attr__('End date', 'give') |
|
| 429 | 429 | ); |
| 430 | - echo Give()->html->date_field( $args ); ?> |
|
| 430 | + echo Give()->html->date_field($args); ?> |
|
| 431 | 431 | <select name="status"> |
| 432 | - <option value="any"><?php esc_html_e( 'All Statuses', 'give' ); ?></option> |
|
| 432 | + <option value="any"><?php esc_html_e('All Statuses', 'give'); ?></option> |
|
| 433 | 433 | <?php |
| 434 | 434 | $statuses = give_get_payment_statuses(); |
| 435 | - foreach ( $statuses as $status => $label ) { |
|
| 436 | - echo '<option value="' . $status . '">' . $label . '</option>'; |
|
| 435 | + foreach ($statuses as $status => $label) { |
|
| 436 | + echo '<option value="'.$status.'">'.$label.'</option>'; |
|
| 437 | 437 | } |
| 438 | 438 | ?> |
| 439 | 439 | </select> |
| 440 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 440 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 441 | 441 | <input type="hidden" name="give-export-class" value="Give_Batch_Payments_Export"/> |
| 442 | 442 | <span> |
| 443 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 443 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 444 | 444 | <span class="spinner"></span> |
| 445 | 445 | </span> |
| 446 | 446 | </form> |
@@ -448,8 +448,8 @@ discard block |
||
| 448 | 448 | </tr> |
| 449 | 449 | <tr class="alternate give-export-donors"> |
| 450 | 450 | <td scope="row" class="row-title"> |
| 451 | - <h3><span><?php esc_html_e( 'Export Donors in CSV', 'give' ); ?></span></h3> |
|
| 452 | - <p><?php esc_html_e( 'Download an export of donors for all donation forms or only those who have given to a particular form.', 'give' ); ?></p> |
|
| 451 | + <h3><span><?php esc_html_e('Export Donors in CSV', 'give'); ?></span></h3> |
|
| 452 | + <p><?php esc_html_e('Download an export of donors for all donation forms or only those who have given to a particular form.', 'give'); ?></p> |
|
| 453 | 453 | </td> |
| 454 | 454 | <td> |
| 455 | 455 | <form method="post" id="give_donor_export" class="give-export-form"> |
@@ -460,44 +460,44 @@ discard block |
||
| 460 | 460 | 'id' => 'give_customer_export_form', |
| 461 | 461 | 'chosen' => true |
| 462 | 462 | ); |
| 463 | - echo Give()->html->forms_dropdown( $args ); ?> |
|
| 463 | + echo Give()->html->forms_dropdown($args); ?> |
|
| 464 | 464 | |
| 465 | - <input type="submit" value="<?php esc_attr_e( 'Generate CSV', 'give' ); ?>" class="button-secondary"/> |
|
| 465 | + <input type="submit" value="<?php esc_attr_e('Generate CSV', 'give'); ?>" class="button-secondary"/> |
|
| 466 | 466 | |
| 467 | 467 | <div id="export-donor-options-wrap" class="give-clearfix"> |
| 468 | - <p><?php esc_html_e( 'Export Columns:', 'give' ); ?></p> |
|
| 468 | + <p><?php esc_html_e('Export Columns:', 'give'); ?></p> |
|
| 469 | 469 | <ul id="give-export-option-ul"> |
| 470 | 470 | <li> |
| 471 | - <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e( 'Name', 'give' ); ?> |
|
| 471 | + <label for="give-export-fullname"><input type="checkbox" checked name="give_export_option[full_name]" id="give-export-fullname"><?php esc_html_e('Name', 'give'); ?> |
|
| 472 | 472 | </label> |
| 473 | 473 | </li> |
| 474 | 474 | <li> |
| 475 | - <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e( 'Email', 'give' ); ?> |
|
| 475 | + <label for="give-export-email"><input type="checkbox" checked name="give_export_option[email]" id="give-export-email"><?php esc_html_e('Email', 'give'); ?> |
|
| 476 | 476 | </label> |
| 477 | 477 | </li> |
| 478 | 478 | <li> |
| 479 | - <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e( 'Address', 'give' ); ?> |
|
| 479 | + <label for="give-export-address"><input type="checkbox" checked name="give_export_option[address]" id="give-export-address"><?php esc_html_e('Address', 'give'); ?> |
|
| 480 | 480 | </label> |
| 481 | 481 | </li> |
| 482 | 482 | <li> |
| 483 | - <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e( 'User ID', 'give' ); ?> |
|
| 483 | + <label for="give-export-userid"><input type="checkbox" checked name="give_export_option[userid]" id="give-export-userid"><?php esc_html_e('User ID', 'give'); ?> |
|
| 484 | 484 | </label> |
| 485 | 485 | </li> |
| 486 | 486 | <li> |
| 487 | - <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e( 'First Donation Date', 'give' ); ?> |
|
| 487 | + <label for="give-export-first-donation-date"><input type="checkbox" checked name="give_export_option[date_first_donated]" id="give-export-first-donation-date"><?php esc_html_e('First Donation Date', 'give'); ?> |
|
| 488 | 488 | </label> |
| 489 | 489 | </li> |
| 490 | 490 | <li> |
| 491 | - <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e( 'Number of Donations', 'give' ); ?> |
|
| 491 | + <label for="give-export-donation-number"><input type="checkbox" checked name="give_export_option[donations]" id="give-export-donation-number"><?php esc_html_e('Number of Donations', 'give'); ?> |
|
| 492 | 492 | </label> |
| 493 | 493 | </li> |
| 494 | 494 | <li> |
| 495 | - <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e( 'Total Donated', 'give' ); ?> |
|
| 495 | + <label for="give-export-donation-sum"><input type="checkbox" checked name="give_export_option[donation_sum]" id="give-export-donation-sum"><?php esc_html_e('Total Donated', 'give'); ?> |
|
| 496 | 496 | </label> |
| 497 | 497 | </li> |
| 498 | 498 | </ul> |
| 499 | 499 | </div> |
| 500 | - <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?> |
|
| 500 | + <?php wp_nonce_field('give_ajax_export', 'give_ajax_export'); ?> |
|
| 501 | 501 | <input type="hidden" name="give-export-class" value="Give_Batch_Customers_Export"/> |
| 502 | 502 | <input type="hidden" name="give-action" value="email_export"/> |
| 503 | 503 | </form> |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | * |
| 512 | 512 | * @since 1.0 |
| 513 | 513 | */ |
| 514 | - do_action( 'give_reports_tab_export_table_bottom' ); |
|
| 514 | + do_action('give_reports_tab_export_table_bottom'); |
|
| 515 | 515 | ?> |
| 516 | 516 | </tbody> |
| 517 | 517 | </table> |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * |
| 523 | 523 | * @since 1.0 |
| 524 | 524 | */ |
| 525 | - do_action( 'give_reports_tab_export_content_bottom' ); |
|
| 525 | + do_action('give_reports_tab_export_content_bottom'); |
|
| 526 | 526 | ?> |
| 527 | 527 | |
| 528 | 528 | </div> |
@@ -533,7 +533,7 @@ discard block |
||
| 533 | 533 | <?php |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | -add_action( 'give_reports_tab_export', 'give_reports_tab_export' ); |
|
| 536 | +add_action('give_reports_tab_export', 'give_reports_tab_export'); |
|
| 537 | 537 | |
| 538 | 538 | /** |
| 539 | 539 | * Renders the Reports page |
@@ -543,12 +543,12 @@ discard block |
||
| 543 | 543 | */ |
| 544 | 544 | function give_reports_tab_logs() { |
| 545 | 545 | |
| 546 | - require( GIVE_PLUGIN_DIR . 'includes/admin/reporting/logs.php' ); |
|
| 546 | + require(GIVE_PLUGIN_DIR.'includes/admin/reporting/logs.php'); |
|
| 547 | 547 | |
| 548 | 548 | $current_view = 'sales'; |
| 549 | 549 | $log_views = give_log_default_views(); |
| 550 | 550 | |
| 551 | - if ( isset( $_GET['view'] ) && array_key_exists( $_GET['view'], $log_views ) ) { |
|
| 551 | + if (isset($_GET['view']) && array_key_exists($_GET['view'], $log_views)) { |
|
| 552 | 552 | $current_view = $_GET['view']; |
| 553 | 553 | } |
| 554 | 554 | |
@@ -557,10 +557,10 @@ discard block |
||
| 557 | 557 | * |
| 558 | 558 | * @since 1.0 |
| 559 | 559 | */ |
| 560 | - do_action( "give_logs_view_{$current_view}" ); |
|
| 560 | + do_action("give_logs_view_{$current_view}"); |
|
| 561 | 561 | } |
| 562 | 562 | |
| 563 | -add_action( 'give_reports_tab_logs', 'give_reports_tab_logs' ); |
|
| 563 | +add_action('give_reports_tab_logs', 'give_reports_tab_logs'); |
|
| 564 | 564 | |
| 565 | 565 | /** |
| 566 | 566 | * Retrieves estimated monthly earnings and sales |
@@ -570,9 +570,9 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | function give_estimated_monthly_stats() { |
| 572 | 572 | |
| 573 | - $estimated = get_transient( 'give_estimated_monthly_stats' ); |
|
| 573 | + $estimated = get_transient('give_estimated_monthly_stats'); |
|
| 574 | 574 | |
| 575 | - if ( false === $estimated ) { |
|
| 575 | + if (false === $estimated) { |
|
| 576 | 576 | |
| 577 | 577 | $estimated = array( |
| 578 | 578 | 'earnings' => 0, |
@@ -581,20 +581,20 @@ discard block |
||
| 581 | 581 | |
| 582 | 582 | $stats = new Give_Payment_Stats; |
| 583 | 583 | |
| 584 | - $to_date_earnings = $stats->get_earnings( 0, 'this_month' ); |
|
| 585 | - $to_date_sales = $stats->get_sales( 0, 'this_month' ); |
|
| 584 | + $to_date_earnings = $stats->get_earnings(0, 'this_month'); |
|
| 585 | + $to_date_sales = $stats->get_sales(0, 'this_month'); |
|
| 586 | 586 | |
| 587 | - $current_day = date( 'd', current_time( 'timestamp' ) ); |
|
| 588 | - $current_month = date( 'n', current_time( 'timestamp' ) ); |
|
| 589 | - $current_year = date( 'Y', current_time( 'timestamp' ) ); |
|
| 590 | - $days_in_month = cal_days_in_month( CAL_GREGORIAN, $current_month, $current_year ); |
|
| 587 | + $current_day = date('d', current_time('timestamp')); |
|
| 588 | + $current_month = date('n', current_time('timestamp')); |
|
| 589 | + $current_year = date('Y', current_time('timestamp')); |
|
| 590 | + $days_in_month = cal_days_in_month(CAL_GREGORIAN, $current_month, $current_year); |
|
| 591 | 591 | |
| 592 | - $estimated['earnings'] = ( $to_date_earnings / $current_day ) * $days_in_month; |
|
| 593 | - $estimated['sales'] = ( $to_date_sales / $current_day ) * $days_in_month; |
|
| 592 | + $estimated['earnings'] = ($to_date_earnings / $current_day) * $days_in_month; |
|
| 593 | + $estimated['sales'] = ($to_date_sales / $current_day) * $days_in_month; |
|
| 594 | 594 | |
| 595 | 595 | // Cache for one day |
| 596 | - set_transient( 'give_estimated_monthly_stats', $estimated, 86400 ); |
|
| 596 | + set_transient('give_estimated_monthly_stats', $estimated, 86400); |
|
| 597 | 597 | } |
| 598 | 598 | |
| 599 | - return maybe_unserialize( $estimated ); |
|
| 599 | + return maybe_unserialize($estimated); |
|
| 600 | 600 | } |