Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function yak_contribute_zip($form_id) {
- ?>
- <div id="give-zipcode-wrap">
- <label class="give-label" for="give-zipcode"><? _e('Zip Code', 'give'); ?>
- <span class="give-required-indicator">*</span>
- <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>
- </label>
- <input type="number" class="give-text-input" name="give_zipcode" id="give-zipcode" placeholder="Zip Code" required>
- </div>
- <?
- }
- add_action('give_before_donation_levels', 'yak_contribute_zip', 10, 2);
- function yak_contribute_validate_zip($valid_data, $data) {
- if (empty( $data['give_zipcode'])) {
- give_set_error('give_zipcode', __('Zip Code is required.', 'give'));
- }
- }
- add_action('give_checkout_error_checks', 'yak_contribute_validate_zip', 10, 3);
- function yak_contribute_store_zip( $payment_meta ) {
- $payment_meta['zipcode'] = isset( $_POST['give_zipcode'] ) ? implode( "n", array_map( 'sanitize_text_field', explode( "n", $_POST['give_zipcode'] ) ) ) : '';
- return $payment_meta;
- }
- add_filter('give_payment_meta', 'yak_contribute_store_zip');
- function yak_show_zip_in_contributions_list( $payment_meta, $user_info ) {
- if ( ! isset( $payment_meta['zipcode'] ) ) {
- return;
- }
- ?>
- <div class="zipcode-data">
- <label><?php echo __( 'Zip Code:', 'give' ); ?></label>
- <?php echo wpautop( $payment_meta['zipcode'] ); ?>
- </div>
- <?
- }
- 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