Advertisement
Guest User

Untitled

a guest
Mar 10th, 2017
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.54 KB | None | 0 0
  1. function yak_contribute_zip($form_id) {
  2. ?>
  3.         <div id="give-zipcode-wrap">
  4.             <label class="give-label" for="give-zipcode"><? _e('Zip Code', 'give'); ?>
  5.             <span class="give-required-indicator">*</span>
  6.                 <span class="give-tooltip icon icon-question" data-tooltip="<?php _e( 'We are required to record Zip Codes for compliance with state and federal law.', 'give' ) ?>"></span>
  7.             </label>
  8.             <input type="number" class="give-text-input" name="give_zipcode" id="give-zipcode" placeholder="Zip Code" required>
  9.         </div>
  10. <?
  11. }
  12. add_action('give_before_donation_levels', 'yak_contribute_zip', 10, 2);
  13.  
  14. function yak_contribute_validate_zip($valid_data, $data) {
  15.     if (empty( $data['give_zipcode'])) {
  16.         give_set_error('give_zipcode', __('Zip Code is required.', 'give'));
  17.     }
  18. }
  19. add_action('give_checkout_error_checks', 'yak_contribute_validate_zip', 10, 3);
  20.  
  21. function yak_contribute_store_zip( $payment_meta ) {
  22.     $payment_meta['zipcode'] = isset( $_POST['give_zipcode'] ) ? implode( "n", array_map( 'sanitize_text_field', explode( "n", $_POST['give_zipcode'] ) ) ) : '';
  23.  
  24.     return $payment_meta;
  25. }
  26.  
  27. add_filter('give_payment_meta', 'yak_contribute_store_zip');
  28.  
  29. function yak_show_zip_in_contributions_list( $payment_meta, $user_info ) {
  30.     if ( ! isset( $payment_meta['zipcode'] ) ) {
  31.         return;
  32.     }
  33.  
  34.     ?>
  35.     <div class="zipcode-data">
  36.         <label><?php echo __( 'Zip Code:', 'give' ); ?></label>
  37.         <?php echo wpautop( $payment_meta['zipcode'] ); ?>
  38.     </div>
  39.  
  40. <?
  41. }
  42. add_action( 'give_payment_personal_details_list', 'yak_show_zip_in_contributions_list', 10, 4);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement