@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | ?> |
| 344 | 344 | </div> |
| 345 | 345 | <?php |
| 346 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 346 | + elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 347 | 347 | ?> |
| 348 | 348 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 349 | 349 | <?php |
@@ -945,10 +945,10 @@ discard block |
||
| 945 | 945 | <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
| 946 | 946 | > |
| 947 | 947 | <?php |
| 948 | - foreach ( $countries as $country_code => $country ) { |
|
| 949 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 950 | - } |
|
| 951 | - ?> |
|
| 948 | + foreach ( $countries as $country_code => $country ) { |
|
| 949 | + echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 950 | + } |
|
| 951 | + ?> |
|
| 952 | 952 | </select> |
| 953 | 953 | </p> |
| 954 | 954 | |
@@ -956,7 +956,7 @@ discard block |
||
| 956 | 956 | <label for="card_address" class="give-label"> |
| 957 | 957 | <?php esc_html_e( 'Address 1', 'give' ); ?> |
| 958 | 958 | <?php |
| 959 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 959 | + if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 960 | 960 | <span class="give-required-indicator">*</span> |
| 961 | 961 | <?php endif; ?> |
| 962 | 962 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1000,7 +1000,7 @@ discard block |
||
| 1000 | 1000 | <label for="card_state" class="give-label"> |
| 1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1002 | 1002 | <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
| 1003 | - ?> |
|
| 1003 | + ?> |
|
| 1004 | 1004 | <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
| 1005 | 1005 | <?php endif; ?> |
| 1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
@@ -1008,17 +1008,17 @@ discard block |
||
| 1008 | 1008 | </label> |
| 1009 | 1009 | <?php |
| 1010 | 1010 | |
| 1011 | - if ( ! empty( $states ) ) : ?> |
|
| 1011 | + if ( ! empty( $states ) ) : ?> |
|
| 1012 | 1012 | <select |
| 1013 | 1013 | name="card_state" |
| 1014 | 1014 | id="card_state" |
| 1015 | 1015 | class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
| 1016 | 1016 | <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
| 1017 | 1017 | <?php |
| 1018 | - foreach ( $states as $state_code => $state ) { |
|
| 1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1020 | - } |
|
| 1021 | - ?> |
|
| 1018 | + foreach ( $states as $state_code => $state ) { |
|
| 1019 | + echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1020 | + } |
|
| 1021 | + ?> |
|
| 1022 | 1022 | </select> |
| 1023 | 1023 | <?php else : ?> |
| 1024 | 1024 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
@@ -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,50 +23,50 @@ 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 | 58 | if ( |
| 59 | - ( 'publish' !== $form->post_status && ! current_user_can( 'edit_give_forms', $form->ID ) ) |
|
| 60 | - || ( 'trash' === $form->post_status ) |
|
| 59 | + ('publish' !== $form->post_status && ! current_user_can('edit_give_forms', $form->ID)) |
|
| 60 | + || ('trash' === $form->post_status) |
|
| 61 | 61 | ) { |
| 62 | 62 | return false; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | //Get the form wrap CSS classes. |
| 66 | - $form_wrap_classes = $form->get_form_wrap_classes( $args ); |
|
| 66 | + $form_wrap_classes = $form->get_form_wrap_classes($args); |
|
| 67 | 67 | |
| 68 | 68 | //Get the <form> tag wrap CSS classes. |
| 69 | - $form_classes = $form->get_form_classes( $args ); |
|
| 69 | + $form_classes = $form->get_form_classes($args); |
|
| 70 | 70 | |
| 71 | 71 | ob_start(); |
| 72 | 72 | |
@@ -78,19 +78,19 @@ discard block |
||
| 78 | 78 | * @param int $form_id The form ID. |
| 79 | 79 | * @param array $args An array of form arguments. |
| 80 | 80 | */ |
| 81 | - do_action( 'give_pre_form_output', $form->ID, $args ); |
|
| 81 | + do_action('give_pre_form_output', $form->ID, $args); |
|
| 82 | 82 | |
| 83 | 83 | ?> |
| 84 | 84 | <div id="give-form-<?php echo $form->ID; ?>-wrap" class="<?php echo $form_wrap_classes; ?>"> |
| 85 | 85 | |
| 86 | - <?php if ( $form->is_close_donation_form() ) { |
|
| 86 | + <?php if ($form->is_close_donation_form()) { |
|
| 87 | 87 | |
| 88 | 88 | // Get Goal thank you message. |
| 89 | - $goal_achieved_message = give_get_meta( $form->ID, '_give_form_goal_achieved_message', true ); |
|
| 90 | - $goal_achieved_message = ! empty( $goal_achieved_message ) ? apply_filters( 'the_content', $goal_achieved_message ) : ''; |
|
| 89 | + $goal_achieved_message = give_get_meta($form->ID, '_give_form_goal_achieved_message', true); |
|
| 90 | + $goal_achieved_message = ! empty($goal_achieved_message) ? apply_filters('the_content', $goal_achieved_message) : ''; |
|
| 91 | 91 | |
| 92 | 92 | // Print thank you message. |
| 93 | - echo apply_filters( 'give_goal_closed_output', $goal_achieved_message, $form->ID ); |
|
| 93 | + echo apply_filters('give_goal_closed_output', $goal_achieved_message, $form->ID); |
|
| 94 | 94 | |
| 95 | 95 | } else { |
| 96 | 96 | /** |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | * 1. if show_title params set to true |
| 99 | 99 | * 2. if admin set form display_style to button |
| 100 | 100 | */ |
| 101 | - $form_title = apply_filters( 'give_form_title', '<h2 class="give-form-title">' . get_the_title( $form_id ) . '</h2>' ); |
|
| 101 | + $form_title = apply_filters('give_form_title', '<h2 class="give-form-title">'.get_the_title($form_id).'</h2>'); |
|
| 102 | 102 | if ( |
| 103 | - ( isset( $args['show_title'] ) && $args['show_title'] == true ) |
|
| 104 | - && ! doing_action( 'give_single_form_summary' ) |
|
| 103 | + (isset($args['show_title']) && $args['show_title'] == true) |
|
| 104 | + && ! doing_action('give_single_form_summary') |
|
| 105 | 105 | ) { |
| 106 | 106 | echo $form_title; |
| 107 | 107 | } |
@@ -114,19 +114,19 @@ discard block |
||
| 114 | 114 | * @param int $form_id The form ID. |
| 115 | 115 | * @param array $args An array of form arguments. |
| 116 | 116 | */ |
| 117 | - do_action( 'give_pre_form', $form->ID, $args ); |
|
| 117 | + do_action('give_pre_form', $form->ID, $args); |
|
| 118 | 118 | ?> |
| 119 | 119 | |
| 120 | 120 | <form id="give-form-<?php echo $form_id; ?>" class="<?php echo $form_classes; ?>" |
| 121 | - action="<?php echo esc_url_raw( $form_action ); ?>" method="post"> |
|
| 121 | + action="<?php echo esc_url_raw($form_action); ?>" method="post"> |
|
| 122 | 122 | <input type="hidden" name="give-form-id" value="<?php echo $form->ID; ?>"/> |
| 123 | - <input type="hidden" name="give-form-title" value="<?php echo htmlentities( $form->post_title ); ?>"/> |
|
| 123 | + <input type="hidden" name="give-form-title" value="<?php echo htmlentities($form->post_title); ?>"/> |
|
| 124 | 124 | <input type="hidden" name="give-current-url" |
| 125 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 125 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 126 | 126 | <input type="hidden" name="give-form-url" |
| 127 | - value="<?php echo htmlspecialchars( give_get_current_page_url() ); ?>"/> |
|
| 127 | + value="<?php echo htmlspecialchars(give_get_current_page_url()); ?>"/> |
|
| 128 | 128 | <input type="hidden" name="give-form-minimum" |
| 129 | - value="<?php echo give_format_amount( give_get_form_minimum_price( $form->ID ), array( 'sanitize' => false ) ); ?>"/> |
|
| 129 | + value="<?php echo give_format_amount(give_get_form_minimum_price($form->ID), array('sanitize' => false)); ?>"/> |
|
| 130 | 130 | |
| 131 | 131 | <!-- The following field is for robots only, invisible to humans: --> |
| 132 | 132 | <span class="give-hidden" style="display: none !important;"> |
@@ -138,13 +138,13 @@ discard block |
||
| 138 | 138 | <?php |
| 139 | 139 | |
| 140 | 140 | // Price ID hidden field for variable (multi-level) donation forms. |
| 141 | - if ( give_has_variable_prices( $form_id ) ) { |
|
| 141 | + if (give_has_variable_prices($form_id)) { |
|
| 142 | 142 | // Get default selected price ID. |
| 143 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 143 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 144 | 144 | $price_id = 0; |
| 145 | 145 | //loop through prices. |
| 146 | - foreach ( $prices as $price ) { |
|
| 147 | - if ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) { |
|
| 146 | + foreach ($prices as $price) { |
|
| 147 | + if (isset($price['_give_default']) && $price['_give_default'] === 'default') { |
|
| 148 | 148 | $price_id = $price['_give_id']['level_id']; |
| 149 | 149 | }; |
| 150 | 150 | } |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | * @param int $form_id The form ID. |
| 161 | 161 | * @param array $args An array of form arguments. |
| 162 | 162 | */ |
| 163 | - do_action( 'give_donation_form_top', $form->ID, $args ); |
|
| 163 | + do_action('give_donation_form_top', $form->ID, $args); |
|
| 164 | 164 | |
| 165 | 165 | /** |
| 166 | 166 | * Fires while outputting donation form, for payment gateway fields. |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param int $form_id The form ID. |
| 171 | 171 | * @param array $args An array of form arguments. |
| 172 | 172 | */ |
| 173 | - do_action( 'give_payment_mode_select', $form->ID, $args ); |
|
| 173 | + do_action('give_payment_mode_select', $form->ID, $args); |
|
| 174 | 174 | |
| 175 | 175 | /** |
| 176 | 176 | * Fires while outputting donation form, after all other fields. |
@@ -180,7 +180,7 @@ 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_donation_form_bottom', $form->ID, $args ); |
|
| 183 | + do_action('give_donation_form_bottom', $form->ID, $args); |
|
| 184 | 184 | |
| 185 | 185 | ?> |
| 186 | 186 | </form> |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | * @param int $form_id The form ID. |
| 195 | 195 | * @param array $args An array of form arguments. |
| 196 | 196 | */ |
| 197 | - do_action( 'give_post_form', $form->ID, $args ); |
|
| 197 | + do_action('give_post_form', $form->ID, $args); |
|
| 198 | 198 | |
| 199 | 199 | } |
| 200 | 200 | ?> |
| 201 | 201 | |
| 202 | - </div><!--end #give-form-<?php echo absint( $form->ID ); ?>--> |
|
| 202 | + </div><!--end #give-form-<?php echo absint($form->ID); ?>--> |
|
| 203 | 203 | <?php |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -210,11 +210,11 @@ discard block |
||
| 210 | 210 | * @param int $form_id The form ID. |
| 211 | 211 | * @param array $args An array of form arguments. |
| 212 | 212 | */ |
| 213 | - do_action( 'give_post_form_output', $form->ID, $args ); |
|
| 213 | + do_action('give_post_form_output', $form->ID, $args); |
|
| 214 | 214 | |
| 215 | 215 | $final_output = ob_get_clean(); |
| 216 | 216 | |
| 217 | - echo apply_filters( 'give_donate_form', $final_output, $args ); |
|
| 217 | + echo apply_filters('give_donate_form', $final_output, $args); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -231,11 +231,11 @@ discard block |
||
| 231 | 231 | * |
| 232 | 232 | * @return string |
| 233 | 233 | */ |
| 234 | -function give_show_purchase_form( $form_id ) { |
|
| 234 | +function give_show_purchase_form($form_id) { |
|
| 235 | 235 | |
| 236 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 236 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 237 | 237 | |
| 238 | - if ( ! isset( $form_id ) && isset( $_POST['give_form_id'] ) ) { |
|
| 238 | + if ( ! isset($form_id) && isset($_POST['give_form_id'])) { |
|
| 239 | 239 | $form_id = $_POST['give_form_id']; |
| 240 | 240 | } |
| 241 | 241 | |
@@ -244,33 +244,33 @@ discard block |
||
| 244 | 244 | * |
| 245 | 245 | * @since 1.7 |
| 246 | 246 | */ |
| 247 | - do_action( 'give_payment_fields_top', $form_id ); |
|
| 247 | + do_action('give_payment_fields_top', $form_id); |
|
| 248 | 248 | |
| 249 | - if ( give_can_checkout() && isset( $form_id ) ) { |
|
| 249 | + if (give_can_checkout() && isset($form_id)) { |
|
| 250 | 250 | |
| 251 | 251 | /** |
| 252 | 252 | * Fires while displaying donation form, before registration login. |
| 253 | 253 | * |
| 254 | 254 | * @since 1.7 |
| 255 | 255 | */ |
| 256 | - do_action( 'give_donation_form_before_register_login', $form_id ); |
|
| 256 | + do_action('give_donation_form_before_register_login', $form_id); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * Fire when register/login form fields render. |
| 260 | 260 | * |
| 261 | 261 | * @since 1.7 |
| 262 | 262 | */ |
| 263 | - do_action( 'give_donation_form_register_login_fields', $form_id ); |
|
| 263 | + do_action('give_donation_form_register_login_fields', $form_id); |
|
| 264 | 264 | |
| 265 | 265 | /** |
| 266 | 266 | * Fire when credit card form fields render. |
| 267 | 267 | * |
| 268 | 268 | * @since 1.7 |
| 269 | 269 | */ |
| 270 | - do_action( 'give_donation_form_before_cc_form', $form_id ); |
|
| 270 | + do_action('give_donation_form_before_cc_form', $form_id); |
|
| 271 | 271 | |
| 272 | 272 | // Load the credit card form and allow gateways to load their own if they wish. |
| 273 | - if ( has_action( 'give_' . $payment_mode . '_cc_form' ) ) { |
|
| 273 | + if (has_action('give_'.$payment_mode.'_cc_form')) { |
|
| 274 | 274 | /** |
| 275 | 275 | * Fires while displaying donation form, credit card form fields for a given gateway. |
| 276 | 276 | * |
@@ -278,7 +278,7 @@ discard block |
||
| 278 | 278 | * |
| 279 | 279 | * @param int $form_id The form ID. |
| 280 | 280 | */ |
| 281 | - do_action( "give_{$payment_mode}_cc_form", $form_id ); |
|
| 281 | + do_action("give_{$payment_mode}_cc_form", $form_id); |
|
| 282 | 282 | } else { |
| 283 | 283 | /** |
| 284 | 284 | * Fires while displaying donation form, credit card form fields. |
@@ -287,7 +287,7 @@ discard block |
||
| 287 | 287 | * |
| 288 | 288 | * @param int $form_id The form ID. |
| 289 | 289 | */ |
| 290 | - do_action( 'give_cc_form', $form_id ); |
|
| 290 | + do_action('give_cc_form', $form_id); |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | * |
| 296 | 296 | * @since 1.7 |
| 297 | 297 | */ |
| 298 | - do_action( 'give_donation_form_after_cc_form', $form_id ); |
|
| 298 | + do_action('give_donation_form_after_cc_form', $form_id); |
|
| 299 | 299 | |
| 300 | 300 | } else { |
| 301 | 301 | /** |
@@ -303,7 +303,7 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @since 1.7 |
| 305 | 305 | */ |
| 306 | - do_action( 'give_donation_form_no_access', $form_id ); |
|
| 306 | + do_action('give_donation_form_no_access', $form_id); |
|
| 307 | 307 | |
| 308 | 308 | } |
| 309 | 309 | |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | * |
| 313 | 313 | * @since 1.7 |
| 314 | 314 | */ |
| 315 | - do_action( 'give_payment_fields_bottom', $form_id ); |
|
| 315 | + do_action('give_payment_fields_bottom', $form_id); |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | -add_action( 'give_donation_form', 'give_show_purchase_form' ); |
|
| 318 | +add_action('give_donation_form', 'give_show_purchase_form'); |
|
| 319 | 319 | |
| 320 | 320 | /** |
| 321 | 321 | * Give Show Login/Register Form Fields. |
@@ -326,11 +326,11 @@ discard block |
||
| 326 | 326 | * |
| 327 | 327 | * @return void |
| 328 | 328 | */ |
| 329 | -function give_show_register_login_fields( $form_id ) { |
|
| 329 | +function give_show_register_login_fields($form_id) { |
|
| 330 | 330 | |
| 331 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 331 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 332 | 332 | |
| 333 | - if ( ( $show_register_form === 'registration' || ( $show_register_form === 'both' && ! isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 333 | + if (($show_register_form === 'registration' || ($show_register_form === 'both' && ! isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 334 | 334 | ?> |
| 335 | 335 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 336 | 336 | <?php |
@@ -339,11 +339,11 @@ discard block |
||
| 339 | 339 | * |
| 340 | 340 | * @since 1.7 |
| 341 | 341 | */ |
| 342 | - do_action( 'give_donation_form_register_fields', $form_id ); |
|
| 342 | + do_action('give_donation_form_register_fields', $form_id); |
|
| 343 | 343 | ?> |
| 344 | 344 | </div> |
| 345 | 345 | <?php |
| 346 | - elseif ( ( $show_register_form === 'login' || ( $show_register_form === 'both' && isset( $_GET['login'] ) ) ) && ! is_user_logged_in() ) : |
|
| 346 | + elseif (($show_register_form === 'login' || ($show_register_form === 'both' && isset($_GET['login']))) && ! is_user_logged_in()) : |
|
| 347 | 347 | ?> |
| 348 | 348 | <div id="give-checkout-login-register-<?php echo $form_id; ?>"> |
| 349 | 349 | <?php |
@@ -352,23 +352,23 @@ discard block |
||
| 352 | 352 | * |
| 353 | 353 | * @since 1.7 |
| 354 | 354 | */ |
| 355 | - do_action( 'give_donation_form_login_fields', $form_id ); |
|
| 355 | + do_action('give_donation_form_login_fields', $form_id); |
|
| 356 | 356 | ?> |
| 357 | 357 | </div> |
| 358 | 358 | <?php |
| 359 | 359 | endif; |
| 360 | 360 | |
| 361 | - if ( ( ! isset( $_GET['login'] ) && is_user_logged_in() ) || ! isset( $show_register_form ) || 'none' === $show_register_form || 'login' === $show_register_form ) { |
|
| 361 | + if (( ! isset($_GET['login']) && is_user_logged_in()) || ! isset($show_register_form) || 'none' === $show_register_form || 'login' === $show_register_form) { |
|
| 362 | 362 | /** |
| 363 | 363 | * Fire when user info render. |
| 364 | 364 | * |
| 365 | 365 | * @since 1.7 |
| 366 | 366 | */ |
| 367 | - do_action( 'give_donation_form_after_user_info', $form_id ); |
|
| 367 | + do_action('give_donation_form_after_user_info', $form_id); |
|
| 368 | 368 | } |
| 369 | 369 | } |
| 370 | 370 | |
| 371 | -add_action( 'give_donation_form_register_login_fields', 'give_show_register_login_fields' ); |
|
| 371 | +add_action('give_donation_form_register_login_fields', 'give_show_register_login_fields'); |
|
| 372 | 372 | |
| 373 | 373 | /** |
| 374 | 374 | * Donation Amount Field. |
@@ -383,16 +383,16 @@ discard block |
||
| 383 | 383 | * |
| 384 | 384 | * @return void |
| 385 | 385 | */ |
| 386 | -function give_output_donation_amount_top( $form_id = 0, $args = array() ) { |
|
| 386 | +function give_output_donation_amount_top($form_id = 0, $args = array()) { |
|
| 387 | 387 | |
| 388 | 388 | $give_options = give_get_settings(); |
| 389 | - $variable_pricing = give_has_variable_prices( $form_id ); |
|
| 390 | - $allow_custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 391 | - $currency_position = isset( $give_options['currency_position'] ) ? $give_options['currency_position'] : 'before'; |
|
| 392 | - $symbol = give_currency_symbol( give_get_currency() ); |
|
| 393 | - $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; |
|
| 394 | - $default_amount = give_format_amount( give_get_default_form_amount( $form_id ), array( 'sanitize' => false ) ); |
|
| 395 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 389 | + $variable_pricing = give_has_variable_prices($form_id); |
|
| 390 | + $allow_custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 391 | + $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; |
|
| 392 | + $symbol = give_currency_symbol(give_get_currency()); |
|
| 393 | + $currency_output = '<span class="give-currency-symbol give-currency-position-'.$currency_position.'">'.$symbol.'</span>'; |
|
| 394 | + $default_amount = give_format_amount(give_get_default_form_amount($form_id), array('sanitize' => false)); |
|
| 395 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 396 | 396 | |
| 397 | 397 | /** |
| 398 | 398 | * Fires while displaying donation form, before donation level fields. |
@@ -402,20 +402,20 @@ discard block |
||
| 402 | 402 | * @param int $form_id The form ID. |
| 403 | 403 | * @param array $args An array of form arguments. |
| 404 | 404 | */ |
| 405 | - do_action( 'give_before_donation_levels', $form_id, $args ); |
|
| 405 | + do_action('give_before_donation_levels', $form_id, $args); |
|
| 406 | 406 | |
| 407 | 407 | //Set Price, No Custom Amount Allowed means hidden price field |
| 408 | - if ( ! give_is_setting_enabled( $allow_custom_amount ) ) { |
|
| 408 | + if ( ! give_is_setting_enabled($allow_custom_amount)) { |
|
| 409 | 409 | ?> |
| 410 | - <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 410 | + <label class="give-hidden" for="give-amount-hidden"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 411 | 411 | <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" |
| 412 | 412 | value="<?php echo $default_amount; ?>" required aria-required="true"/> |
| 413 | 413 | <div class="set-price give-donation-amount form-row-wide"> |
| 414 | - <?php if ( $currency_position == 'before' ) { |
|
| 414 | + <?php if ($currency_position == 'before') { |
|
| 415 | 415 | echo $currency_output; |
| 416 | 416 | } ?> |
| 417 | 417 | <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?></span> |
| 418 | - <?php if ( $currency_position == 'after' ) { |
|
| 418 | + <?php if ($currency_position == 'after') { |
|
| 419 | 419 | echo $currency_output; |
| 420 | 420 | } ?> |
| 421 | 421 | </div> |
@@ -425,13 +425,13 @@ discard block |
||
| 425 | 425 | ?> |
| 426 | 426 | <div class="give-total-wrap"> |
| 427 | 427 | <div class="give-donation-amount form-row-wide"> |
| 428 | - <?php if ( $currency_position == 'before' ) { |
|
| 428 | + <?php if ($currency_position == 'before') { |
|
| 429 | 429 | echo $currency_output; |
| 430 | 430 | } ?> |
| 431 | - <label class="give-hidden" for="give-amount"><?php esc_html_e( 'Donation Amount:', 'give' ); ?></label> |
|
| 431 | + <label class="give-hidden" for="give-amount"><?php esc_html_e('Donation Amount:', 'give'); ?></label> |
|
| 432 | 432 | <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" |
| 433 | 433 | placeholder="" value="<?php echo $default_amount; ?>" autocomplete="off"> |
| 434 | - <?php if ( $currency_position == 'after' ) { |
|
| 434 | + <?php if ($currency_position == 'after') { |
|
| 435 | 435 | echo $currency_output; |
| 436 | 436 | } ?> |
| 437 | 437 | </div> |
@@ -446,16 +446,16 @@ discard block |
||
| 446 | 446 | * @param int $form_id The form ID. |
| 447 | 447 | * @param array $args An array of form arguments. |
| 448 | 448 | */ |
| 449 | - do_action( 'give_after_donation_amount', $form_id, $args ); |
|
| 449 | + do_action('give_after_donation_amount', $form_id, $args); |
|
| 450 | 450 | |
| 451 | 451 | //Custom Amount Text |
| 452 | - if ( ! $variable_pricing && give_is_setting_enabled( $allow_custom_amount ) && ! empty( $custom_amount_text ) ) { ?> |
|
| 452 | + if ( ! $variable_pricing && give_is_setting_enabled($allow_custom_amount) && ! empty($custom_amount_text)) { ?> |
|
| 453 | 453 | <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?></p> |
| 454 | 454 | <?php } |
| 455 | 455 | |
| 456 | 456 | //Output Variable Pricing Levels. |
| 457 | - if ( $variable_pricing ) { |
|
| 458 | - give_output_levels( $form_id ); |
|
| 457 | + if ($variable_pricing) { |
|
| 458 | + give_output_levels($form_id); |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | /** |
@@ -466,10 +466,10 @@ discard block |
||
| 466 | 466 | * @param int $form_id The form ID. |
| 467 | 467 | * @param array $args An array of form arguments. |
| 468 | 468 | */ |
| 469 | - do_action( 'give_after_donation_levels', $form_id, $args ); |
|
| 469 | + do_action('give_after_donation_levels', $form_id, $args); |
|
| 470 | 470 | } |
| 471 | 471 | |
| 472 | -add_action( 'give_donation_form_top', 'give_output_donation_amount_top', 10, 2 ); |
|
| 472 | +add_action('give_donation_form_top', 'give_output_donation_amount_top', 10, 2); |
|
| 473 | 473 | |
| 474 | 474 | /** |
| 475 | 475 | * Outputs the Donation Levels in various formats such as dropdown, radios, and buttons. |
@@ -480,30 +480,30 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return string Donation levels. |
| 482 | 482 | */ |
| 483 | -function give_output_levels( $form_id ) { |
|
| 483 | +function give_output_levels($form_id) { |
|
| 484 | 484 | |
| 485 | 485 | //Get variable pricing. |
| 486 | - $prices = apply_filters( 'give_form_variable_prices', give_get_variable_prices( $form_id ), $form_id ); |
|
| 487 | - $display_style = give_get_meta( $form_id, '_give_display_style', true ); |
|
| 488 | - $custom_amount = give_get_meta( $form_id, '_give_custom_amount', true ); |
|
| 489 | - $custom_amount_text = give_get_meta( $form_id, '_give_custom_amount_text', true ); |
|
| 490 | - if ( empty( $custom_amount_text ) ) { |
|
| 491 | - $custom_amount_text = esc_html__( 'Give a Custom Amount', 'give' ); |
|
| 486 | + $prices = apply_filters('give_form_variable_prices', give_get_variable_prices($form_id), $form_id); |
|
| 487 | + $display_style = give_get_meta($form_id, '_give_display_style', true); |
|
| 488 | + $custom_amount = give_get_meta($form_id, '_give_custom_amount', true); |
|
| 489 | + $custom_amount_text = give_get_meta($form_id, '_give_custom_amount_text', true); |
|
| 490 | + if (empty($custom_amount_text)) { |
|
| 491 | + $custom_amount_text = esc_html__('Give a Custom Amount', 'give'); |
|
| 492 | 492 | } |
| 493 | 493 | |
| 494 | 494 | $output = ''; |
| 495 | 495 | |
| 496 | - switch ( $display_style ) { |
|
| 496 | + switch ($display_style) { |
|
| 497 | 497 | case 'buttons': |
| 498 | 498 | |
| 499 | 499 | $output .= '<ul id="give-donation-level-button-wrap" class="give-donation-levels-wrap give-list-inline">'; |
| 500 | 500 | |
| 501 | - foreach ( $prices as $price ) { |
|
| 502 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 503 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-' . $price['_give_id']['level_id'] . ' ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'give-default-level' : '' ), $form_id, $price ); |
|
| 501 | + foreach ($prices as $price) { |
|
| 502 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 503 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-btn give-btn give-btn-level-'.$price['_give_id']['level_id'].' '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'give-default-level' : ''), $form_id, $price); |
|
| 504 | 504 | |
| 505 | 505 | $output .= '<li>'; |
| 506 | - $output .= '<button type="button" data-price-id="' . $price['_give_id']['level_id'] . '" class=" ' . $level_classes . '" value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 506 | + $output .= '<button type="button" data-price-id="'.$price['_give_id']['level_id'].'" class=" '.$level_classes.'" value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 507 | 507 | $output .= $level_text; |
| 508 | 508 | $output .= '</button>'; |
| 509 | 509 | $output .= '</li>'; |
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | } |
| 512 | 512 | |
| 513 | 513 | //Custom Amount. |
| 514 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 514 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 515 | 515 | $output .= '<li>'; |
| 516 | 516 | $output .= '<button type="button" data-price-id="custom" class="give-donation-level-btn give-btn give-btn-level-custom" value="custom">'; |
| 517 | 517 | $output .= $custom_amount_text; |
@@ -527,22 +527,22 @@ discard block |
||
| 527 | 527 | |
| 528 | 528 | $output .= '<ul id="give-donation-level-radio-list" class="give-donation-levels-wrap">'; |
| 529 | 529 | |
| 530 | - foreach ( $prices as $price ) { |
|
| 531 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 532 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 530 | + foreach ($prices as $price) { |
|
| 531 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 532 | + $level_classes = apply_filters('give_form_level_classes', 'give-radio-input give-radio-input-level give-radio-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 533 | 533 | |
| 534 | 534 | $output .= '<li>'; |
| 535 | - $output .= '<input type="radio" data-price-id="' . $price['_give_id']['level_id'] . '" class="' . $level_classes . '" name="give-radio-donation-level" id="give-radio-level-' . $price['_give_id']['level_id'] . '" ' . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? 'checked="checked"' : '' ) . ' value="' . give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) . '">'; |
|
| 536 | - $output .= '<label for="give-radio-level-' . $price['_give_id']['level_id'] . '">' . $level_text . '</label>'; |
|
| 535 | + $output .= '<input type="radio" data-price-id="'.$price['_give_id']['level_id'].'" class="'.$level_classes.'" name="give-radio-donation-level" id="give-radio-level-'.$price['_give_id']['level_id'].'" '.((isset($price['_give_default']) && $price['_give_default'] === 'default') ? 'checked="checked"' : '').' value="'.give_format_amount($price['_give_amount'], array('sanitize' => false)).'">'; |
|
| 536 | + $output .= '<label for="give-radio-level-'.$price['_give_id']['level_id'].'">'.$level_text.'</label>'; |
|
| 537 | 537 | $output .= '</li>'; |
| 538 | 538 | |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | //Custom Amount. |
| 542 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 542 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 543 | 543 | $output .= '<li>'; |
| 544 | 544 | $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">'; |
| 545 | - $output .= '<label for="give-radio-level-custom">' . $custom_amount_text . '</label>'; |
|
| 545 | + $output .= '<label for="give-radio-level-custom">'.$custom_amount_text.'</label>'; |
|
| 546 | 546 | $output .= '</li>'; |
| 547 | 547 | } |
| 548 | 548 | |
@@ -552,23 +552,23 @@ discard block |
||
| 552 | 552 | |
| 553 | 553 | case 'dropdown': |
| 554 | 554 | |
| 555 | - $output .= '<label for="give-donation-level-select-' . $form_id . '" class="give-hidden">' . esc_html__( 'Choose Your Donation Amount', 'give' ) . ':</label>'; |
|
| 556 | - $output .= '<select id="give-donation-level-select-' . $form_id . '" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 555 | + $output .= '<label for="give-donation-level-select-'.$form_id.'" class="give-hidden">'.esc_html__('Choose Your Donation Amount', 'give').':</label>'; |
|
| 556 | + $output .= '<select id="give-donation-level-select-'.$form_id.'" class="give-select give-select-level give-donation-levels-wrap">'; |
|
| 557 | 557 | |
| 558 | 558 | //first loop through prices. |
| 559 | - foreach ( $prices as $price ) { |
|
| 560 | - $level_text = apply_filters( 'give_form_level_text', ! empty( $price['_give_text'] ) ? $price['_give_text'] : give_currency_filter( give_format_amount( $price['_give_amount'], array( 'sanitize' => false ) ) ), $form_id, $price ); |
|
| 561 | - $level_classes = apply_filters( 'give_form_level_classes', 'give-donation-level-' . $price['_give_id']['level_id'] . ( ( isset( $price['_give_default'] ) && $price['_give_default'] === 'default' ) ? ' give-default-level' : '' ), $form_id, $price ); |
|
| 559 | + foreach ($prices as $price) { |
|
| 560 | + $level_text = apply_filters('give_form_level_text', ! empty($price['_give_text']) ? $price['_give_text'] : give_currency_filter(give_format_amount($price['_give_amount'], array('sanitize' => false))), $form_id, $price); |
|
| 561 | + $level_classes = apply_filters('give_form_level_classes', 'give-donation-level-'.$price['_give_id']['level_id'].((isset($price['_give_default']) && $price['_give_default'] === 'default') ? ' give-default-level' : ''), $form_id, $price); |
|
| 562 | 562 | |
| 563 | - $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'], array( 'sanitize' => false ) ) . '">'; |
|
| 563 | + $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'], array('sanitize' => false)).'">'; |
|
| 564 | 564 | $output .= $level_text; |
| 565 | 565 | $output .= '</option>'; |
| 566 | 566 | |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | //Custom Amount. |
| 570 | - if ( give_is_setting_enabled( $custom_amount ) && ! empty( $custom_amount_text ) ) { |
|
| 571 | - $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">' . $custom_amount_text . '</option>'; |
|
| 570 | + if (give_is_setting_enabled($custom_amount) && ! empty($custom_amount_text)) { |
|
| 571 | + $output .= '<option data-price-id="custom" class="give-donation-level-custom" value="custom">'.$custom_amount_text.'</option>'; |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | $output .= '</select>'; |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | break; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - echo apply_filters( 'give_form_level_output', $output, $form_id ); |
|
| 579 | + echo apply_filters('give_form_level_output', $output, $form_id); |
|
| 580 | 580 | } |
| 581 | 581 | |
| 582 | 582 | /** |
@@ -591,27 +591,27 @@ discard block |
||
| 591 | 591 | * |
| 592 | 592 | * @return string Checkout button. |
| 593 | 593 | */ |
| 594 | -function give_display_checkout_button( $form_id, $args ) { |
|
| 594 | +function give_display_checkout_button($form_id, $args) { |
|
| 595 | 595 | |
| 596 | - $display_option = ( isset( $args['display_style'] ) && ! empty( $args['display_style'] ) ) |
|
| 596 | + $display_option = (isset($args['display_style']) && ! empty($args['display_style'])) |
|
| 597 | 597 | ? $args['display_style'] |
| 598 | - : give_get_meta( $form_id, '_give_payment_display', true ); |
|
| 598 | + : give_get_meta($form_id, '_give_payment_display', true); |
|
| 599 | 599 | |
| 600 | - if ( 'button' === $display_option ) { |
|
| 600 | + if ('button' === $display_option) { |
|
| 601 | 601 | $display_option = 'modal'; |
| 602 | - } elseif ( $display_option === 'onpage' ) { |
|
| 602 | + } elseif ($display_option === 'onpage') { |
|
| 603 | 603 | return ''; |
| 604 | 604 | } |
| 605 | 605 | |
| 606 | - $display_label_field = give_get_meta( $form_id, '_give_reveal_label', true ); |
|
| 607 | - $display_label = ! empty( $args['continue_button_title'] ) ? $args['continue_button_title'] : ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 606 | + $display_label_field = give_get_meta($form_id, '_give_reveal_label', true); |
|
| 607 | + $display_label = ! empty($args['continue_button_title']) ? $args['continue_button_title'] : ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 608 | 608 | |
| 609 | - $output = '<button type="button" class="give-btn give-btn-' . $display_option . '">' . $display_label . '</button>'; |
|
| 609 | + $output = '<button type="button" class="give-btn give-btn-'.$display_option.'">'.$display_label.'</button>'; |
|
| 610 | 610 | |
| 611 | - echo apply_filters( 'give_display_checkout_button', $output ); |
|
| 611 | + echo apply_filters('give_display_checkout_button', $output); |
|
| 612 | 612 | } |
| 613 | 613 | |
| 614 | -add_action( 'give_after_donation_levels', 'give_display_checkout_button', 10, 2 ); |
|
| 614 | +add_action('give_after_donation_levels', 'give_display_checkout_button', 10, 2); |
|
| 615 | 615 | |
| 616 | 616 | /** |
| 617 | 617 | * Shows the User Info fields in the Personal Info box, more fields can be added via the hooks provided. |
@@ -622,57 +622,57 @@ discard block |
||
| 622 | 622 | * |
| 623 | 623 | * @return void |
| 624 | 624 | */ |
| 625 | -function give_user_info_fields( $form_id ) { |
|
| 625 | +function give_user_info_fields($form_id) { |
|
| 626 | 626 | // Get user info. |
| 627 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 627 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 628 | 628 | |
| 629 | 629 | /** |
| 630 | 630 | * Fire before user personal information fields |
| 631 | 631 | * |
| 632 | 632 | * @since 1.7 |
| 633 | 633 | */ |
| 634 | - do_action( 'give_donation_form_before_personal_info', $form_id ); |
|
| 634 | + do_action('give_donation_form_before_personal_info', $form_id); |
|
| 635 | 635 | ?> |
| 636 | 636 | <fieldset id="give_checkout_user_info"> |
| 637 | - <legend><?php echo apply_filters( 'give_checkout_personal_info_text', esc_html__( 'Personal Info', 'give' ) ); ?></legend> |
|
| 637 | + <legend><?php echo apply_filters('give_checkout_personal_info_text', esc_html__('Personal Info', 'give')); ?></legend> |
|
| 638 | 638 | <p id="give-first-name-wrap" class="form-row form-row-first form-row-responsive"> |
| 639 | 639 | <label class="give-label" for="give-first"> |
| 640 | - <?php esc_html_e( 'First Name', 'give' ); ?> |
|
| 641 | - <?php if ( give_field_is_required( 'give_first', $form_id ) ) : ?> |
|
| 640 | + <?php esc_html_e('First Name', 'give'); ?> |
|
| 641 | + <?php if (give_field_is_required('give_first', $form_id)) : ?> |
|
| 642 | 642 | <span class="give-required-indicator">*</span> |
| 643 | 643 | <?php endif ?> |
| 644 | 644 | <span class="give-tooltip give-icon give-icon-question" |
| 645 | - data-tooltip="<?php esc_attr_e( 'We will use this to personalize your account experience.', 'give' ); ?>"></span> |
|
| 645 | + data-tooltip="<?php esc_attr_e('We will use this to personalize your account experience.', 'give'); ?>"></span> |
|
| 646 | 646 | </label> |
| 647 | 647 | <input |
| 648 | 648 | class="give-input required" |
| 649 | 649 | type="text" |
| 650 | 650 | name="give_first" |
| 651 | - placeholder="<?php esc_attr_e( 'First Name', 'give' ); ?>" |
|
| 651 | + placeholder="<?php esc_attr_e('First Name', 'give'); ?>" |
|
| 652 | 652 | id="give-first" |
| 653 | - value="<?php echo isset( $give_user_info['give_first'] ) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | - <?php echo( give_field_is_required( 'give_first', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 653 | + value="<?php echo isset($give_user_info['give_first']) ? $give_user_info['give_first'] : ''; ?>" |
|
| 654 | + <?php echo(give_field_is_required('give_first', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 655 | 655 | /> |
| 656 | 656 | </p> |
| 657 | 657 | |
| 658 | 658 | <p id="give-last-name-wrap" class="form-row form-row-last form-row-responsive"> |
| 659 | 659 | <label class="give-label" for="give-last"> |
| 660 | - <?php esc_html_e( 'Last Name', 'give' ); ?> |
|
| 661 | - <?php if ( give_field_is_required( 'give_last', $form_id ) ) : ?> |
|
| 660 | + <?php esc_html_e('Last Name', 'give'); ?> |
|
| 661 | + <?php if (give_field_is_required('give_last', $form_id)) : ?> |
|
| 662 | 662 | <span class="give-required-indicator">*</span> |
| 663 | 663 | <?php endif ?> |
| 664 | 664 | <span class="give-tooltip give-icon give-icon-question" |
| 665 | - data-tooltip="<?php esc_attr_e( 'We will use this as well to personalize your account experience.', 'give' ); ?>"></span> |
|
| 665 | + data-tooltip="<?php esc_attr_e('We will use this as well to personalize your account experience.', 'give'); ?>"></span> |
|
| 666 | 666 | </label> |
| 667 | 667 | |
| 668 | 668 | <input |
| 669 | - class="give-input<?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required' : '' ); ?>" |
|
| 669 | + class="give-input<?php echo(give_field_is_required('give_last', $form_id) ? ' required' : ''); ?>" |
|
| 670 | 670 | type="text" |
| 671 | 671 | name="give_last" |
| 672 | 672 | id="give-last" |
| 673 | - placeholder="<?php esc_attr_e( 'Last Name', 'give' ); ?>" |
|
| 674 | - value="<?php echo isset( $give_user_info['give_last'] ) ? $give_user_info['give_last'] : ''; ?>" |
|
| 675 | - <?php echo( give_field_is_required( 'give_last', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 673 | + placeholder="<?php esc_attr_e('Last Name', 'give'); ?>" |
|
| 674 | + value="<?php echo isset($give_user_info['give_last']) ? $give_user_info['give_last'] : ''; ?>" |
|
| 675 | + <?php echo(give_field_is_required('give_last', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 676 | 676 | /> |
| 677 | 677 | </p> |
| 678 | 678 | |
@@ -682,26 +682,26 @@ discard block |
||
| 682 | 682 | * |
| 683 | 683 | * @since 1.7 |
| 684 | 684 | */ |
| 685 | - do_action( 'give_donation_form_before_email', $form_id ); |
|
| 685 | + do_action('give_donation_form_before_email', $form_id); |
|
| 686 | 686 | ?> |
| 687 | 687 | <p id="give-email-wrap" class="form-row form-row-wide"> |
| 688 | 688 | <label class="give-label" for="give-email"> |
| 689 | - <?php esc_html_e( 'Email Address', 'give' ); ?> |
|
| 690 | - <?php if ( give_field_is_required( 'give_email', $form_id ) ) { ?> |
|
| 689 | + <?php esc_html_e('Email Address', 'give'); ?> |
|
| 690 | + <?php if (give_field_is_required('give_email', $form_id)) { ?> |
|
| 691 | 691 | <span class="give-required-indicator">*</span> |
| 692 | 692 | <?php } ?> |
| 693 | 693 | <span class="give-tooltip give-icon give-icon-question" |
| 694 | - data-tooltip="<?php esc_attr_e( 'We will send the donation receipt to this address.', 'give' ); ?>"></span> |
|
| 694 | + data-tooltip="<?php esc_attr_e('We will send the donation receipt to this address.', 'give'); ?>"></span> |
|
| 695 | 695 | </label> |
| 696 | 696 | |
| 697 | 697 | <input |
| 698 | 698 | class="give-input required" |
| 699 | 699 | type="email" |
| 700 | 700 | name="give_email" |
| 701 | - placeholder="<?php esc_attr_e( 'Email Address', 'give' ); ?>" |
|
| 701 | + placeholder="<?php esc_attr_e('Email Address', 'give'); ?>" |
|
| 702 | 702 | id="give-email" |
| 703 | - value="<?php echo isset( $give_user_info['give_email'] ) ? $give_user_info['give_email'] : ''; ?>" |
|
| 704 | - <?php echo( give_field_is_required( 'give_email', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 703 | + value="<?php echo isset($give_user_info['give_email']) ? $give_user_info['give_email'] : ''; ?>" |
|
| 704 | + <?php echo(give_field_is_required('give_email', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 705 | 705 | /> |
| 706 | 706 | |
| 707 | 707 | </p> |
@@ -711,14 +711,14 @@ discard block |
||
| 711 | 711 | * |
| 712 | 712 | * @since 1.7 |
| 713 | 713 | */ |
| 714 | - do_action( 'give_donation_form_after_email', $form_id ); |
|
| 714 | + do_action('give_donation_form_after_email', $form_id); |
|
| 715 | 715 | |
| 716 | 716 | /** |
| 717 | 717 | * Fire after personal email field |
| 718 | 718 | * |
| 719 | 719 | * @since 1.7 |
| 720 | 720 | */ |
| 721 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 721 | + do_action('give_donation_form_user_info', $form_id); |
|
| 722 | 722 | ?> |
| 723 | 723 | </fieldset> |
| 724 | 724 | <?php |
@@ -727,11 +727,11 @@ discard block |
||
| 727 | 727 | * |
| 728 | 728 | * @since 1.7 |
| 729 | 729 | */ |
| 730 | - do_action( 'give_donation_form_after_personal_info', $form_id ); |
|
| 730 | + do_action('give_donation_form_after_personal_info', $form_id); |
|
| 731 | 731 | } |
| 732 | 732 | |
| 733 | -add_action( 'give_donation_form_after_user_info', 'give_user_info_fields' ); |
|
| 734 | -add_action( 'give_register_fields_before', 'give_user_info_fields' ); |
|
| 733 | +add_action('give_donation_form_after_user_info', 'give_user_info_fields'); |
|
| 734 | +add_action('give_register_fields_before', 'give_user_info_fields'); |
|
| 735 | 735 | |
| 736 | 736 | /** |
| 737 | 737 | * Renders the credit card info form. |
@@ -742,7 +742,7 @@ discard block |
||
| 742 | 742 | * |
| 743 | 743 | * @return void |
| 744 | 744 | */ |
| 745 | -function give_get_cc_form( $form_id ) { |
|
| 745 | +function give_get_cc_form($form_id) { |
|
| 746 | 746 | |
| 747 | 747 | ob_start(); |
| 748 | 748 | |
@@ -753,53 +753,53 @@ discard block |
||
| 753 | 753 | * |
| 754 | 754 | * @param int $form_id The form ID. |
| 755 | 755 | */ |
| 756 | - do_action( 'give_before_cc_fields', $form_id ); |
|
| 756 | + do_action('give_before_cc_fields', $form_id); |
|
| 757 | 757 | ?> |
| 758 | 758 | <fieldset id="give_cc_fields-<?php echo $form_id ?>" class="give-do-validate"> |
| 759 | - <legend><?php echo apply_filters( 'give_credit_card_fieldset_heading', esc_html__( 'Credit Card Info', 'give' ) ); ?></legend> |
|
| 760 | - <?php if ( is_ssl() ) : ?> |
|
| 759 | + <legend><?php echo apply_filters('give_credit_card_fieldset_heading', esc_html__('Credit Card Info', 'give')); ?></legend> |
|
| 760 | + <?php if (is_ssl()) : ?> |
|
| 761 | 761 | <div id="give_secure_site_wrapper-<?php echo $form_id ?>"> |
| 762 | 762 | <span class="give-icon padlock"></span> |
| 763 | - <span><?php esc_html_e( 'This is a secure SSL encrypted payment.', 'give' ); ?></span> |
|
| 763 | + <span><?php esc_html_e('This is a secure SSL encrypted payment.', 'give'); ?></span> |
|
| 764 | 764 | </div> |
| 765 | 765 | <?php endif; ?> |
| 766 | 766 | <p id="give-card-number-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 767 | 767 | <label for="card_number-<?php echo $form_id ?>" class="give-label"> |
| 768 | - <?php esc_html_e( 'Card Number', 'give' ); ?> |
|
| 768 | + <?php esc_html_e('Card Number', 'give'); ?> |
|
| 769 | 769 | <span class="give-required-indicator">*</span> |
| 770 | 770 | <span class="give-tooltip give-icon give-icon-question" |
| 771 | - data-tooltip="<?php esc_attr_e( 'The (typically) 16 digits on the front of your credit card.', 'give' ); ?>"></span> |
|
| 771 | + data-tooltip="<?php esc_attr_e('The (typically) 16 digits on the front of your credit card.', 'give'); ?>"></span> |
|
| 772 | 772 | <span class="card-type"></span> |
| 773 | 773 | </label> |
| 774 | 774 | |
| 775 | 775 | <input type="tel" autocomplete="off" name="card_number" id="card_number-<?php echo $form_id ?>" |
| 776 | - class="card-number give-input required" placeholder="<?php esc_attr_e( 'Card number', 'give' ); ?>" |
|
| 776 | + class="card-number give-input required" placeholder="<?php esc_attr_e('Card number', 'give'); ?>" |
|
| 777 | 777 | required aria-required="true"/> |
| 778 | 778 | </p> |
| 779 | 779 | |
| 780 | 780 | <p id="give-card-cvc-wrap-<?php echo $form_id ?>" class="form-row form-row-one-third form-row-responsive"> |
| 781 | 781 | <label for="card_cvc-<?php echo $form_id ?>" class="give-label"> |
| 782 | - <?php esc_html_e( 'CVC', 'give' ); ?> |
|
| 782 | + <?php esc_html_e('CVC', 'give'); ?> |
|
| 783 | 783 | <span class="give-required-indicator">*</span> |
| 784 | 784 | <span class="give-tooltip give-icon give-icon-question" |
| 785 | - data-tooltip="<?php esc_attr_e( 'The 3 digit (back) or 4 digit (front) value on your card.', 'give' ); ?>"></span> |
|
| 785 | + data-tooltip="<?php esc_attr_e('The 3 digit (back) or 4 digit (front) value on your card.', 'give'); ?>"></span> |
|
| 786 | 786 | </label> |
| 787 | 787 | |
| 788 | 788 | <input type="tel" size="4" autocomplete="off" name="card_cvc" id="card_cvc-<?php echo $form_id ?>" |
| 789 | - class="card-cvc give-input required" placeholder="<?php esc_attr_e( 'Security code', 'give' ); ?>" |
|
| 789 | + class="card-cvc give-input required" placeholder="<?php esc_attr_e('Security code', 'give'); ?>" |
|
| 790 | 790 | required aria-required="true"/> |
| 791 | 791 | </p> |
| 792 | 792 | |
| 793 | 793 | <p id="give-card-name-wrap-<?php echo $form_id ?>" class="form-row form-row-two-thirds form-row-responsive"> |
| 794 | 794 | <label for="card_name-<?php echo $form_id ?>" class="give-label"> |
| 795 | - <?php esc_html_e( 'Name on the Card', 'give' ); ?> |
|
| 795 | + <?php esc_html_e('Name on the Card', 'give'); ?> |
|
| 796 | 796 | <span class="give-required-indicator">*</span> |
| 797 | 797 | <span class="give-tooltip give-icon give-icon-question" |
| 798 | - data-tooltip="<?php esc_attr_e( 'The name printed on the front of your credit card.', 'give' ); ?>"></span> |
|
| 798 | + data-tooltip="<?php esc_attr_e('The name printed on the front of your credit card.', 'give'); ?>"></span> |
|
| 799 | 799 | </label> |
| 800 | 800 | |
| 801 | 801 | <input type="text" autocomplete="off" name="card_name" id="card_name-<?php echo $form_id ?>" |
| 802 | - class="card-name give-input required" placeholder="<?php esc_attr_e( 'Card name', 'give' ); ?>" |
|
| 802 | + class="card-name give-input required" placeholder="<?php esc_attr_e('Card name', 'give'); ?>" |
|
| 803 | 803 | required aria-required="true"/> |
| 804 | 804 | </p> |
| 805 | 805 | <?php |
@@ -810,14 +810,14 @@ discard block |
||
| 810 | 810 | * |
| 811 | 811 | * @param int $form_id The form ID. |
| 812 | 812 | */ |
| 813 | - do_action( 'give_before_cc_expiration' ); |
|
| 813 | + do_action('give_before_cc_expiration'); |
|
| 814 | 814 | ?> |
| 815 | 815 | <p class="card-expiration form-row form-row-one-third form-row-responsive"> |
| 816 | 816 | <label for="card_expiry-<?php echo $form_id ?>" class="give-label"> |
| 817 | - <?php esc_html_e( 'Expiration', 'give' ); ?> |
|
| 817 | + <?php esc_html_e('Expiration', 'give'); ?> |
|
| 818 | 818 | <span class="give-required-indicator">*</span> |
| 819 | 819 | <span class="give-tooltip give-icon give-icon-question" |
| 820 | - data-tooltip="<?php esc_attr_e( 'The date your credit card expires, typically on the front of the card.', 'give' ); ?>"></span> |
|
| 820 | + data-tooltip="<?php esc_attr_e('The date your credit card expires, typically on the front of the card.', 'give'); ?>"></span> |
|
| 821 | 821 | </label> |
| 822 | 822 | |
| 823 | 823 | <input type="hidden" id="card_exp_month-<?php echo $form_id ?>" name="card_exp_month" |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | class="card-expiry-year"/> |
| 827 | 827 | |
| 828 | 828 | <input type="tel" autocomplete="off" name="card_expiry" id="card_expiry-<?php echo $form_id ?>" |
| 829 | - class="card-expiry give-input required" placeholder="<?php esc_attr_e( 'MM / YY', 'give' ); ?>" |
|
| 829 | + class="card-expiry give-input required" placeholder="<?php esc_attr_e('MM / YY', 'give'); ?>" |
|
| 830 | 830 | required aria-required="true"/> |
| 831 | 831 | </p> |
| 832 | 832 | <?php |
@@ -837,7 +837,7 @@ discard block |
||
| 837 | 837 | * |
| 838 | 838 | * @param int $form_id The form ID. |
| 839 | 839 | */ |
| 840 | - do_action( 'give_after_cc_expiration', $form_id ); |
|
| 840 | + do_action('give_after_cc_expiration', $form_id); |
|
| 841 | 841 | ?> |
| 842 | 842 | </fieldset> |
| 843 | 843 | <?php |
@@ -848,12 +848,12 @@ discard block |
||
| 848 | 848 | * |
| 849 | 849 | * @param int $form_id The form ID. |
| 850 | 850 | */ |
| 851 | - do_action( 'give_after_cc_fields', $form_id ); |
|
| 851 | + do_action('give_after_cc_fields', $form_id); |
|
| 852 | 852 | |
| 853 | 853 | echo ob_get_clean(); |
| 854 | 854 | } |
| 855 | 855 | |
| 856 | -add_action( 'give_cc_form', 'give_get_cc_form' ); |
|
| 856 | +add_action('give_cc_form', 'give_get_cc_form'); |
|
| 857 | 857 | |
| 858 | 858 | /** |
| 859 | 859 | * Outputs the default credit card address fields. |
@@ -864,24 +864,24 @@ discard block |
||
| 864 | 864 | * |
| 865 | 865 | * @return void |
| 866 | 866 | */ |
| 867 | -function give_default_cc_address_fields( $form_id ) { |
|
| 867 | +function give_default_cc_address_fields($form_id) { |
|
| 868 | 868 | // Get user info. |
| 869 | - $give_user_info = _give_get_prefill_form_field_values( $form_id ); |
|
| 869 | + $give_user_info = _give_get_prefill_form_field_values($form_id); |
|
| 870 | 870 | |
| 871 | 871 | $logged_in = is_user_logged_in(); |
| 872 | 872 | |
| 873 | - if ( $logged_in ) { |
|
| 874 | - $user_address = get_user_meta( get_current_user_id(), '_give_user_address', true ); |
|
| 873 | + if ($logged_in) { |
|
| 874 | + $user_address = get_user_meta(get_current_user_id(), '_give_user_address', true); |
|
| 875 | 875 | } |
| 876 | - $line1 = $logged_in && ! empty( $user_address['line1'] ) ? $user_address['line1'] : ''; |
|
| 877 | - $line2 = $logged_in && ! empty( $user_address['line2'] ) ? $user_address['line2'] : ''; |
|
| 878 | - $city = $logged_in && ! empty( $user_address['city'] ) ? $user_address['city'] : ''; |
|
| 879 | - $zip = $logged_in && ! empty( $user_address['zip'] ) ? $user_address['zip'] : ''; |
|
| 876 | + $line1 = $logged_in && ! empty($user_address['line1']) ? $user_address['line1'] : ''; |
|
| 877 | + $line2 = $logged_in && ! empty($user_address['line2']) ? $user_address['line2'] : ''; |
|
| 878 | + $city = $logged_in && ! empty($user_address['city']) ? $user_address['city'] : ''; |
|
| 879 | + $zip = $logged_in && ! empty($user_address['zip']) ? $user_address['zip'] : ''; |
|
| 880 | 880 | |
| 881 | 881 | ob_start(); |
| 882 | 882 | ?> |
| 883 | 883 | <fieldset id="give_cc_address" class="cc-address"> |
| 884 | - <legend><?php echo apply_filters( 'give_billing_details_fieldset_heading', esc_html__( 'Billing Details', 'give' ) ); ?></legend> |
|
| 884 | + <legend><?php echo apply_filters('give_billing_details_fieldset_heading', esc_html__('Billing Details', 'give')); ?></legend> |
|
| 885 | 885 | <?php |
| 886 | 886 | /** |
| 887 | 887 | * Fires while rendering credit card billing form, before address fields. |
@@ -890,38 +890,38 @@ discard block |
||
| 890 | 890 | * |
| 891 | 891 | * @param int $form_id The form ID. |
| 892 | 892 | */ |
| 893 | - do_action( 'give_cc_billing_top' ); |
|
| 893 | + do_action('give_cc_billing_top'); |
|
| 894 | 894 | |
| 895 | 895 | |
| 896 | 896 | |
| 897 | 897 | // For Country. |
| 898 | 898 | $selected_country = give_get_country(); |
| 899 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 899 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 900 | 900 | $selected_country = $give_user_info['billing_country']; |
| 901 | 901 | } |
| 902 | 902 | $countries = give_get_country_list(); |
| 903 | 903 | |
| 904 | 904 | // For state |
| 905 | 905 | $selected_state = ''; |
| 906 | - if ( $selected_country === give_get_country() ) { |
|
| 906 | + if ($selected_country === give_get_country()) { |
|
| 907 | 907 | // Get defalut selected state by admin. |
| 908 | 908 | $selected_state = give_get_state(); |
| 909 | 909 | } |
| 910 | 910 | // Get the last payment made by user states. |
| 911 | - if ( ! empty( $give_user_info['card_state'] ) && '*' !== $give_user_info['card_state'] ) { |
|
| 911 | + if ( ! empty($give_user_info['card_state']) && '*' !== $give_user_info['card_state']) { |
|
| 912 | 912 | $selected_state = $give_user_info['card_state']; |
| 913 | 913 | } |
| 914 | 914 | // Get the country code |
| 915 | - if ( ! empty( $give_user_info['billing_country'] ) && '*' !== $give_user_info['billing_country'] ) { |
|
| 915 | + if ( ! empty($give_user_info['billing_country']) && '*' !== $give_user_info['billing_country']) { |
|
| 916 | 916 | $selected_country = $give_user_info['billing_country']; |
| 917 | 917 | } |
| 918 | - $label = __( 'State', 'give' ); |
|
| 918 | + $label = __('State', 'give'); |
|
| 919 | 919 | $states_label = give_get_states_label(); |
| 920 | 920 | // Check if $country code exists in the array key for states label. |
| 921 | - if ( array_key_exists( $selected_country, $states_label ) ) { |
|
| 922 | - $label = $states_label[ $selected_country ]; |
|
| 921 | + if (array_key_exists($selected_country, $states_label)) { |
|
| 922 | + $label = $states_label[$selected_country]; |
|
| 923 | 923 | } |
| 924 | - $states = give_get_states( $selected_country ); |
|
| 924 | + $states = give_get_states($selected_country); |
|
| 925 | 925 | // Get the country list that do not have any states init. |
| 926 | 926 | $no_states_country = give_no_states_country_list(); |
| 927 | 927 | // Get the country list that does not require states. |
@@ -930,23 +930,23 @@ discard block |
||
| 930 | 930 | ?> |
| 931 | 931 | <p id="give-card-country-wrap" class="form-row form-row-wide"> |
| 932 | 932 | <label for="billing_country" class="give-label"> |
| 933 | - <?php esc_html_e( 'Country', 'give' ); ?> |
|
| 934 | - <?php if ( give_field_is_required( 'billing_country', $form_id ) ) : ?> |
|
| 933 | + <?php esc_html_e('Country', 'give'); ?> |
|
| 934 | + <?php if (give_field_is_required('billing_country', $form_id)) : ?> |
|
| 935 | 935 | <span class="give-required-indicator">*</span> |
| 936 | 936 | <?php endif; ?> |
| 937 | 937 | <span class="give-tooltip give-icon give-icon-question" |
| 938 | - data-tooltip="<?php esc_attr_e( 'The country for your billing address.', 'give' ); ?>"></span> |
|
| 938 | + data-tooltip="<?php esc_attr_e('The country for your billing address.', 'give'); ?>"></span> |
|
| 939 | 939 | </label> |
| 940 | 940 | |
| 941 | 941 | <select |
| 942 | 942 | name="billing_country" |
| 943 | 943 | id="billing_country" |
| 944 | - class="billing-country billing_country give-select<?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required' : '' ); ?>" |
|
| 945 | - <?php echo( give_field_is_required( 'billing_country', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 944 | + class="billing-country billing_country give-select<?php echo(give_field_is_required('billing_country', $form_id) ? ' required' : ''); ?>" |
|
| 945 | + <?php echo(give_field_is_required('billing_country', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 946 | 946 | > |
| 947 | 947 | <?php |
| 948 | - foreach ( $countries as $country_code => $country ) { |
|
| 949 | - echo '<option value="' . esc_attr( $country_code ) . '"' . selected( $country_code, $selected_country, false ) . '>' . $country . '</option>'; |
|
| 948 | + foreach ($countries as $country_code => $country) { |
|
| 949 | + echo '<option value="'.esc_attr($country_code).'"'.selected($country_code, $selected_country, false).'>'.$country.'</option>'; |
|
| 950 | 950 | } |
| 951 | 951 | ?> |
| 952 | 952 | </select> |
@@ -954,69 +954,69 @@ discard block |
||
| 954 | 954 | |
| 955 | 955 | <p id="give-card-address-wrap" class="form-row form-row-wide"> |
| 956 | 956 | <label for="card_address" class="give-label"> |
| 957 | - <?php esc_html_e( 'Address 1', 'give' ); ?> |
|
| 957 | + <?php esc_html_e('Address 1', 'give'); ?> |
|
| 958 | 958 | <?php |
| 959 | - if ( give_field_is_required( 'card_address', $form_id ) ) : ?> |
|
| 959 | + if (give_field_is_required('card_address', $form_id)) : ?> |
|
| 960 | 960 | <span class="give-required-indicator">*</span> |
| 961 | 961 | <?php endif; ?> |
| 962 | 962 | <span class="give-tooltip give-icon give-icon-question" |
| 963 | - data-tooltip="<?php esc_attr_e( 'The primary billing address for your credit card.', 'give' ); ?>"></span> |
|
| 963 | + data-tooltip="<?php esc_attr_e('The primary billing address for your credit card.', 'give'); ?>"></span> |
|
| 964 | 964 | </label> |
| 965 | 965 | |
| 966 | 966 | <input |
| 967 | 967 | type="text" |
| 968 | 968 | id="card_address" |
| 969 | 969 | name="card_address" |
| 970 | - class="card-address give-input<?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required' : '' ); ?>" |
|
| 971 | - placeholder="<?php esc_attr_e( 'Address line 1', 'give' ); ?>" |
|
| 972 | - value="<?php echo isset( $give_user_info['card_address'] ) ? $give_user_info['card_address'] : ''; ?>" |
|
| 973 | - <?php echo( give_field_is_required( 'card_address', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 970 | + class="card-address give-input<?php echo(give_field_is_required('card_address', $form_id) ? ' required' : ''); ?>" |
|
| 971 | + placeholder="<?php esc_attr_e('Address line 1', 'give'); ?>" |
|
| 972 | + value="<?php echo isset($give_user_info['card_address']) ? $give_user_info['card_address'] : ''; ?>" |
|
| 973 | + <?php echo(give_field_is_required('card_address', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 974 | 974 | /> |
| 975 | 975 | </p> |
| 976 | 976 | |
| 977 | 977 | <p id="give-card-address-2-wrap" class="form-row form-row-wide"> |
| 978 | 978 | <label for="card_address_2" class="give-label"> |
| 979 | - <?php esc_html_e( 'Address 2', 'give' ); ?> |
|
| 980 | - <?php if ( give_field_is_required( 'card_address_2', $form_id ) ) : ?> |
|
| 979 | + <?php esc_html_e('Address 2', 'give'); ?> |
|
| 980 | + <?php if (give_field_is_required('card_address_2', $form_id)) : ?> |
|
| 981 | 981 | <span class="give-required-indicator">*</span> |
| 982 | 982 | <?php endif; ?> |
| 983 | 983 | <span class="give-tooltip give-icon give-icon-question" |
| 984 | - data-tooltip="<?php esc_attr_e( '(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give' ); ?>"></span> |
|
| 984 | + data-tooltip="<?php esc_attr_e('(optional) The suite, apt no, PO box, etc, associated with your billing address.', 'give'); ?>"></span> |
|
| 985 | 985 | </label> |
| 986 | 986 | |
| 987 | 987 | <input |
| 988 | 988 | type="text" |
| 989 | 989 | id="card_address_2" |
| 990 | 990 | name="card_address_2" |
| 991 | - class="card-address-2 give-input<?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required' : '' ); ?>" |
|
| 992 | - placeholder="<?php esc_attr_e( 'Address line 2', 'give' ); ?>" |
|
| 993 | - value="<?php echo isset( $give_user_info['card_address_2'] ) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 994 | - <?php echo( give_field_is_required( 'card_address_2', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 991 | + class="card-address-2 give-input<?php echo(give_field_is_required('card_address_2', $form_id) ? ' required' : ''); ?>" |
|
| 992 | + placeholder="<?php esc_attr_e('Address line 2', 'give'); ?>" |
|
| 993 | + value="<?php echo isset($give_user_info['card_address_2']) ? $give_user_info['card_address_2'] : ''; ?>" |
|
| 994 | + <?php echo(give_field_is_required('card_address_2', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 995 | 995 | /> |
| 996 | 996 | </p> |
| 997 | 997 | |
| 998 | 998 | <p id="give-card-state-wrap" |
| 999 | - class="form-row form-row-wide <?php echo ( ! empty( $selected_country ) && array_key_exists( $selected_country, $no_states_country ) ) ? 'give-hidden' : ''; ?> "> |
|
| 999 | + class="form-row form-row-wide <?php echo ( ! empty($selected_country) && array_key_exists($selected_country, $no_states_country)) ? 'give-hidden' : ''; ?> "> |
|
| 1000 | 1000 | <label for="card_state" class="give-label"> |
| 1001 | 1001 | <span class="state-label-text"><?php echo $label; ?></span> |
| 1002 | - <?php if ( give_field_is_required( 'card_state', $form_id ) ) : |
|
| 1002 | + <?php if (give_field_is_required('card_state', $form_id)) : |
|
| 1003 | 1003 | ?> |
| 1004 | - <span class="give-required-indicator <?php echo( array_key_exists( $selected_country, $states_not_required_country_list ) ? 'give-hidden' : '' ) ?> ">*</span> |
|
| 1004 | + <span class="give-required-indicator <?php echo(array_key_exists($selected_country, $states_not_required_country_list) ? 'give-hidden' : '') ?> ">*</span> |
|
| 1005 | 1005 | <?php endif; ?> |
| 1006 | 1006 | <span class="give-tooltip give-icon give-icon-question" |
| 1007 | - data-tooltip="<?php esc_attr_e( 'The state, province, or county for your billing address.', 'give' ); ?>"></span> |
|
| 1007 | + data-tooltip="<?php esc_attr_e('The state, province, or county for your billing address.', 'give'); ?>"></span> |
|
| 1008 | 1008 | </label> |
| 1009 | 1009 | <?php |
| 1010 | 1010 | |
| 1011 | - if ( ! empty( $states ) ) : ?> |
|
| 1011 | + if ( ! empty($states)) : ?> |
|
| 1012 | 1012 | <select |
| 1013 | 1013 | name="card_state" |
| 1014 | 1014 | id="card_state" |
| 1015 | - class="card_state give-select<?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required' : '' ); ?>" |
|
| 1016 | - <?php echo( give_field_is_required( 'card_state', $form_id ) ? ' required aria-required="true" ' : '' ); ?>> |
|
| 1015 | + class="card_state give-select<?php echo(give_field_is_required('card_state', $form_id) ? ' required' : ''); ?>" |
|
| 1016 | + <?php echo(give_field_is_required('card_state', $form_id) ? ' required aria-required="true" ' : ''); ?>> |
|
| 1017 | 1017 | <?php |
| 1018 | - foreach ( $states as $state_code => $state ) { |
|
| 1019 | - echo '<option value="' . $state_code . '"' . selected( $state_code, $selected_state, false ) . '>' . $state . '</option>'; |
|
| 1018 | + foreach ($states as $state_code => $state) { |
|
| 1019 | + echo '<option value="'.$state_code.'"'.selected($state_code, $selected_state, false).'>'.$state.'</option>'; |
|
| 1020 | 1020 | } |
| 1021 | 1021 | ?> |
| 1022 | 1022 | </select> |
@@ -1028,32 +1028,32 @@ discard block |
||
| 1028 | 1028 | |
| 1029 | 1029 | <p id="give-card-city-wrap" class="form-row form-row-first form-row-responsive"> |
| 1030 | 1030 | <label for="card_city" class="give-label"> |
| 1031 | - <?php esc_html_e( 'City', 'give' ); ?> |
|
| 1032 | - <?php if ( give_field_is_required( 'card_city', $form_id ) ) : ?> |
|
| 1031 | + <?php esc_html_e('City', 'give'); ?> |
|
| 1032 | + <?php if (give_field_is_required('card_city', $form_id)) : ?> |
|
| 1033 | 1033 | <span class="give-required-indicator">*</span> |
| 1034 | 1034 | <?php endif; ?> |
| 1035 | 1035 | <span class="give-tooltip give-icon give-icon-question" |
| 1036 | - data-tooltip="<?php esc_attr_e( 'The city for your billing address.', 'give' ); ?>"></span> |
|
| 1036 | + data-tooltip="<?php esc_attr_e('The city for your billing address.', 'give'); ?>"></span> |
|
| 1037 | 1037 | </label> |
| 1038 | 1038 | <input |
| 1039 | 1039 | type="text" |
| 1040 | 1040 | id="card_city" |
| 1041 | 1041 | name="card_city" |
| 1042 | - class="card-city give-input<?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required' : '' ); ?>" |
|
| 1043 | - placeholder="<?php esc_attr_e( 'City', 'give' ); ?>" |
|
| 1044 | - value="<?php echo isset( $give_user_info['card_city'] ) ? $give_user_info['card_city'] : ''; ?>" |
|
| 1045 | - <?php echo( give_field_is_required( 'card_city', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1042 | + class="card-city give-input<?php echo(give_field_is_required('card_city', $form_id) ? ' required' : ''); ?>" |
|
| 1043 | + placeholder="<?php esc_attr_e('City', 'give'); ?>" |
|
| 1044 | + value="<?php echo isset($give_user_info['card_city']) ? $give_user_info['card_city'] : ''; ?>" |
|
| 1045 | + <?php echo(give_field_is_required('card_city', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1046 | 1046 | /> |
| 1047 | 1047 | </p> |
| 1048 | 1048 | |
| 1049 | 1049 | <p id="give-card-zip-wrap" class="form-row form-row-last form-row-responsive"> |
| 1050 | 1050 | <label for="card_zip" class="give-label"> |
| 1051 | - <?php esc_html_e( 'Zip / Postal Code', 'give' ); ?> |
|
| 1052 | - <?php if ( give_field_is_required( 'card_zip', $form_id ) ) : ?> |
|
| 1051 | + <?php esc_html_e('Zip / Postal Code', 'give'); ?> |
|
| 1052 | + <?php if (give_field_is_required('card_zip', $form_id)) : ?> |
|
| 1053 | 1053 | <span class="give-required-indicator">*</span> |
| 1054 | 1054 | <?php endif; ?> |
| 1055 | 1055 | <span class="give-tooltip give-icon give-icon-question" |
| 1056 | - data-tooltip="<?php esc_attr_e( 'The zip or postal code for your billing address.', 'give' ); ?>"></span> |
|
| 1056 | + data-tooltip="<?php esc_attr_e('The zip or postal code for your billing address.', 'give'); ?>"></span> |
|
| 1057 | 1057 | </label> |
| 1058 | 1058 | |
| 1059 | 1059 | <input |
@@ -1061,10 +1061,10 @@ discard block |
||
| 1061 | 1061 | size="4" |
| 1062 | 1062 | id="card_zip" |
| 1063 | 1063 | name="card_zip" |
| 1064 | - class="card-zip give-input<?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required' : '' ); ?>" |
|
| 1065 | - placeholder="<?php esc_attr_e( 'Zip / Postal Code', 'give' ); ?>" |
|
| 1066 | - value="<?php echo isset( $give_user_info['card_zip'] ) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1067 | - <?php echo( give_field_is_required( 'card_zip', $form_id ) ? ' required aria-required="true" ' : '' ); ?> |
|
| 1064 | + class="card-zip give-input<?php echo(give_field_is_required('card_zip', $form_id) ? ' required' : ''); ?>" |
|
| 1065 | + placeholder="<?php esc_attr_e('Zip / Postal Code', 'give'); ?>" |
|
| 1066 | + value="<?php echo isset($give_user_info['card_zip']) ? $give_user_info['card_zip'] : ''; ?>" |
|
| 1067 | + <?php echo(give_field_is_required('card_zip', $form_id) ? ' required aria-required="true" ' : ''); ?> |
|
| 1068 | 1068 | /> |
| 1069 | 1069 | </p> |
| 1070 | 1070 | <?php |
@@ -1075,14 +1075,14 @@ discard block |
||
| 1075 | 1075 | * |
| 1076 | 1076 | * @param int $form_id The form ID. |
| 1077 | 1077 | */ |
| 1078 | - do_action( 'give_cc_billing_bottom' ); |
|
| 1078 | + do_action('give_cc_billing_bottom'); |
|
| 1079 | 1079 | ?> |
| 1080 | 1080 | </fieldset> |
| 1081 | 1081 | <?php |
| 1082 | 1082 | echo ob_get_clean(); |
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | -add_action( 'give_after_cc_fields', 'give_default_cc_address_fields' ); |
|
| 1085 | +add_action('give_after_cc_fields', 'give_default_cc_address_fields'); |
|
| 1086 | 1086 | |
| 1087 | 1087 | |
| 1088 | 1088 | /** |
@@ -1095,24 +1095,24 @@ discard block |
||
| 1095 | 1095 | * |
| 1096 | 1096 | * @return string |
| 1097 | 1097 | */ |
| 1098 | -function give_get_register_fields( $form_id ) { |
|
| 1098 | +function give_get_register_fields($form_id) { |
|
| 1099 | 1099 | |
| 1100 | 1100 | global $user_ID; |
| 1101 | 1101 | |
| 1102 | - if ( is_user_logged_in() ) { |
|
| 1103 | - $user_data = get_userdata( $user_ID ); |
|
| 1102 | + if (is_user_logged_in()) { |
|
| 1103 | + $user_data = get_userdata($user_ID); |
|
| 1104 | 1104 | } |
| 1105 | 1105 | |
| 1106 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1106 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1107 | 1107 | |
| 1108 | 1108 | ob_start(); ?> |
| 1109 | 1109 | <fieldset id="give-register-fields-<?php echo $form_id; ?>"> |
| 1110 | 1110 | |
| 1111 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1111 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1112 | 1112 | <div class="give-login-account-wrap"> |
| 1113 | - <p class="give-login-message"><?php esc_html_e( 'Already have an account?', 'give' ); ?> |
|
| 1114 | - <a href="<?php echo esc_url( add_query_arg( 'login', 1 ) ); ?>" class="give-checkout-login" |
|
| 1115 | - data-action="give_checkout_login"><?php esc_html_e( 'Login', 'give' ); ?></a> |
|
| 1113 | + <p class="give-login-message"><?php esc_html_e('Already have an account?', 'give'); ?> |
|
| 1114 | + <a href="<?php echo esc_url(add_query_arg('login', 1)); ?>" class="give-checkout-login" |
|
| 1115 | + data-action="give_checkout_login"><?php esc_html_e('Login', 'give'); ?></a> |
|
| 1116 | 1116 | </p> |
| 1117 | 1117 | <p class="give-loading-text"> |
| 1118 | 1118 | <span class="give-loading-animation"></span> |
@@ -1128,15 +1128,15 @@ discard block |
||
| 1128 | 1128 | * |
| 1129 | 1129 | * @param int $form_id The form ID. |
| 1130 | 1130 | */ |
| 1131 | - do_action( 'give_register_fields_before', $form_id ); |
|
| 1131 | + do_action('give_register_fields_before', $form_id); |
|
| 1132 | 1132 | ?> |
| 1133 | 1133 | |
| 1134 | 1134 | <fieldset id="give-register-account-fields-<?php echo $form_id; ?>"> |
| 1135 | 1135 | <legend> |
| 1136 | 1136 | <?php |
| 1137 | - echo apply_filters( 'give_create_account_fieldset_heading', esc_html__( 'Create an account', 'give' ) ); |
|
| 1138 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1139 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1137 | + echo apply_filters('give_create_account_fieldset_heading', esc_html__('Create an account', 'give')); |
|
| 1138 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1139 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1140 | 1140 | } |
| 1141 | 1141 | ?> |
| 1142 | 1142 | </legend> |
@@ -1148,54 +1148,54 @@ discard block |
||
| 1148 | 1148 | * |
| 1149 | 1149 | * @param int $form_id The form ID. |
| 1150 | 1150 | */ |
| 1151 | - do_action( 'give_register_account_fields_before', $form_id ); |
|
| 1151 | + do_action('give_register_account_fields_before', $form_id); |
|
| 1152 | 1152 | ?> |
| 1153 | 1153 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" |
| 1154 | 1154 | class="form-row form-row-one-third form-row-first form-row-responsive"> |
| 1155 | 1155 | <label for="give-user-login-<?php echo $form_id; ?>"> |
| 1156 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1157 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1156 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1157 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1158 | 1158 | <span class="give-required-indicator">*</span> |
| 1159 | 1159 | <?php } ?> |
| 1160 | 1160 | <span class="give-tooltip give-icon give-icon-question" |
| 1161 | - data-tooltip="<?php esc_attr_e( 'The username you will use to log into your account.', 'give' ); ?>"></span> |
|
| 1161 | + data-tooltip="<?php esc_attr_e('The username you will use to log into your account.', 'give'); ?>"></span> |
|
| 1162 | 1162 | </label> |
| 1163 | 1163 | |
| 1164 | 1164 | <input name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" class="give-input" |
| 1165 | 1165 | type="text" |
| 1166 | - placeholder="<?php esc_attr_e( 'Username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1166 | + placeholder="<?php esc_attr_e('Username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1167 | 1167 | </div> |
| 1168 | 1168 | |
| 1169 | 1169 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1170 | 1170 | class="form-row form-row-one-third form-row-responsive"> |
| 1171 | 1171 | <label for="give-user-pass-<?php echo $form_id; ?>"> |
| 1172 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1173 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1172 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1173 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1174 | 1174 | <span class="give-required-indicator">*</span> |
| 1175 | 1175 | <?php } ?> |
| 1176 | 1176 | <span class="give-tooltip give-icon give-icon-question" |
| 1177 | - data-tooltip="<?php esc_attr_e( 'The password used to access your account.', 'give' ); ?>"></span> |
|
| 1177 | + data-tooltip="<?php esc_attr_e('The password used to access your account.', 'give'); ?>"></span> |
|
| 1178 | 1178 | </label> |
| 1179 | 1179 | |
| 1180 | 1180 | <input name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" class="give-input" |
| 1181 | - placeholder="<?php esc_attr_e( 'Password', 'give' ); ?>" |
|
| 1182 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1181 | + placeholder="<?php esc_attr_e('Password', 'give'); ?>" |
|
| 1182 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1183 | 1183 | </div> |
| 1184 | 1184 | |
| 1185 | 1185 | <div id="give-user-pass-confirm-wrap-<?php echo $form_id; ?>" |
| 1186 | 1186 | class="give-register-password form-row form-row-one-third form-row-responsive"> |
| 1187 | 1187 | <label for="give-user-pass-confirm-<?php echo $form_id; ?>"> |
| 1188 | - <?php esc_html_e( 'Confirm PW', 'give' ); ?> |
|
| 1189 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1188 | + <?php esc_html_e('Confirm PW', 'give'); ?> |
|
| 1189 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1190 | 1190 | <span class="give-required-indicator">*</span> |
| 1191 | 1191 | <?php } ?> |
| 1192 | 1192 | <span class="give-tooltip give-icon give-icon-question" |
| 1193 | - data-tooltip="<?php esc_attr_e( 'Please retype your password to confirm.', 'give' ); ?>"></span> |
|
| 1193 | + data-tooltip="<?php esc_attr_e('Please retype your password to confirm.', 'give'); ?>"></span> |
|
| 1194 | 1194 | </label> |
| 1195 | 1195 | |
| 1196 | 1196 | <input name="give_user_pass_confirm" id="give-user-pass-confirm-<?php echo $form_id; ?>" |
| 1197 | - class="give-input" placeholder="<?php esc_attr_e( 'Confirm password', 'give' ); ?>" |
|
| 1198 | - type="password"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1197 | + class="give-input" placeholder="<?php esc_attr_e('Confirm password', 'give'); ?>" |
|
| 1198 | + type="password"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1199 | 1199 | </div> |
| 1200 | 1200 | <?php |
| 1201 | 1201 | /** |
@@ -1205,7 +1205,7 @@ discard block |
||
| 1205 | 1205 | * |
| 1206 | 1206 | * @param int $form_id The form ID. |
| 1207 | 1207 | */ |
| 1208 | - do_action( 'give_register_account_fields_after', $form_id ); |
|
| 1208 | + do_action('give_register_account_fields_after', $form_id); |
|
| 1209 | 1209 | ?> |
| 1210 | 1210 | </fieldset> |
| 1211 | 1211 | |
@@ -1217,7 +1217,7 @@ discard block |
||
| 1217 | 1217 | * |
| 1218 | 1218 | * @param int $form_id The form ID. |
| 1219 | 1219 | */ |
| 1220 | - do_action( 'give_register_fields_after', $form_id ); |
|
| 1220 | + do_action('give_register_fields_after', $form_id); |
|
| 1221 | 1221 | ?> |
| 1222 | 1222 | |
| 1223 | 1223 | <input type="hidden" name="give-purchase-var" value="needs-to-register"/> |
@@ -1228,7 +1228,7 @@ discard block |
||
| 1228 | 1228 | * |
| 1229 | 1229 | * @since 1.7 |
| 1230 | 1230 | */ |
| 1231 | - do_action( 'give_donation_form_user_info', $form_id ); |
|
| 1231 | + do_action('give_donation_form_user_info', $form_id); |
|
| 1232 | 1232 | ?> |
| 1233 | 1233 | |
| 1234 | 1234 | </fieldset> |
@@ -1236,7 +1236,7 @@ discard block |
||
| 1236 | 1236 | echo ob_get_clean(); |
| 1237 | 1237 | } |
| 1238 | 1238 | |
| 1239 | -add_action( 'give_donation_form_register_fields', 'give_get_register_fields' ); |
|
| 1239 | +add_action('give_donation_form_register_fields', 'give_get_register_fields'); |
|
| 1240 | 1240 | |
| 1241 | 1241 | /** |
| 1242 | 1242 | * Gets the login fields for the login form on the checkout. This function hooks |
@@ -1249,27 +1249,27 @@ discard block |
||
| 1249 | 1249 | * |
| 1250 | 1250 | * @return string |
| 1251 | 1251 | */ |
| 1252 | -function give_get_login_fields( $form_id ) { |
|
| 1252 | +function give_get_login_fields($form_id) { |
|
| 1253 | 1253 | |
| 1254 | - $form_id = isset( $_POST['form_id'] ) ? $_POST['form_id'] : $form_id; |
|
| 1255 | - $show_register_form = give_show_login_register_option( $form_id ); |
|
| 1254 | + $form_id = isset($_POST['form_id']) ? $_POST['form_id'] : $form_id; |
|
| 1255 | + $show_register_form = give_show_login_register_option($form_id); |
|
| 1256 | 1256 | |
| 1257 | 1257 | ob_start(); |
| 1258 | 1258 | ?> |
| 1259 | 1259 | <fieldset id="give-login-fields-<?php echo $form_id; ?>"> |
| 1260 | - <legend><?php echo apply_filters( 'give_account_login_fieldset_heading', esc_html__( 'Login to Your Account', 'give' ) ); |
|
| 1261 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1262 | - echo ' <span class="sub-text">' . esc_html__( '(optional)', 'give' ) . '</span>'; |
|
| 1260 | + <legend><?php echo apply_filters('give_account_login_fieldset_heading', esc_html__('Login to Your Account', 'give')); |
|
| 1261 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1262 | + echo ' <span class="sub-text">'.esc_html__('(optional)', 'give').'</span>'; |
|
| 1263 | 1263 | } ?> |
| 1264 | 1264 | </legend> |
| 1265 | - <?php if ( $show_register_form == 'both' ) { ?> |
|
| 1265 | + <?php if ($show_register_form == 'both') { ?> |
|
| 1266 | 1266 | <p class="give-new-account-link"> |
| 1267 | - <?php esc_html_e( 'Need to create an account?', 'give' ); ?> |
|
| 1268 | - <a href="<?php echo remove_query_arg( 'login' ); ?>" class="give-checkout-register-cancel" |
|
| 1267 | + <?php esc_html_e('Need to create an account?', 'give'); ?> |
|
| 1268 | + <a href="<?php echo remove_query_arg('login'); ?>" class="give-checkout-register-cancel" |
|
| 1269 | 1269 | data-action="give_checkout_register"> |
| 1270 | - <?php esc_html_e( 'Register', 'give' ); |
|
| 1271 | - if ( ! give_logged_in_only( $form_id ) ) { |
|
| 1272 | - echo ' ' . esc_html__( 'and donate as a guest »', 'give' ); |
|
| 1270 | + <?php esc_html_e('Register', 'give'); |
|
| 1271 | + if ( ! give_logged_in_only($form_id)) { |
|
| 1272 | + echo ' '.esc_html__('and donate as a guest »', 'give'); |
|
| 1273 | 1273 | } ?> |
| 1274 | 1274 | </a> |
| 1275 | 1275 | </p> |
@@ -1285,49 +1285,49 @@ discard block |
||
| 1285 | 1285 | * |
| 1286 | 1286 | * @param int $form_id The form ID. |
| 1287 | 1287 | */ |
| 1288 | - do_action( 'give_checkout_login_fields_before', $form_id ); |
|
| 1288 | + do_action('give_checkout_login_fields_before', $form_id); |
|
| 1289 | 1289 | ?> |
| 1290 | 1290 | <div id="give-user-login-wrap-<?php echo $form_id; ?>" class="form-row form-row-first form-row-responsive"> |
| 1291 | 1291 | <label class="give-label" for="give-user-login-<?php echo $form_id; ?>"> |
| 1292 | - <?php esc_html_e( 'Username', 'give' ); ?> |
|
| 1293 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1292 | + <?php esc_html_e('Username', 'give'); ?> |
|
| 1293 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1294 | 1294 | <span class="give-required-indicator">*</span> |
| 1295 | 1295 | <?php } ?> |
| 1296 | 1296 | </label> |
| 1297 | 1297 | |
| 1298 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" type="text" |
|
| 1298 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" type="text" |
|
| 1299 | 1299 | name="give_user_login" id="give-user-login-<?php echo $form_id; ?>" value="" |
| 1300 | - placeholder="<?php esc_attr_e( 'Your username', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1300 | + placeholder="<?php esc_attr_e('Your username', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1301 | 1301 | </div> |
| 1302 | 1302 | |
| 1303 | 1303 | <div id="give-user-pass-wrap-<?php echo $form_id; ?>" |
| 1304 | 1304 | class="give_login_password form-row form-row-last form-row-responsive"> |
| 1305 | 1305 | <label class="give-label" for="give-user-pass-<?php echo $form_id; ?>"> |
| 1306 | - <?php esc_html_e( 'Password', 'give' ); ?> |
|
| 1307 | - <?php if ( give_logged_in_only( $form_id ) ) { ?> |
|
| 1306 | + <?php esc_html_e('Password', 'give'); ?> |
|
| 1307 | + <?php if (give_logged_in_only($form_id)) { ?> |
|
| 1308 | 1308 | <span class="give-required-indicator">*</span> |
| 1309 | 1309 | <?php } ?> |
| 1310 | 1310 | </label> |
| 1311 | - <input class="give-input<?php echo ( give_logged_in_only( $form_id ) ) ? ' required' : ''; ?>" |
|
| 1311 | + <input class="give-input<?php echo (give_logged_in_only($form_id)) ? ' required' : ''; ?>" |
|
| 1312 | 1312 | type="password" name="give_user_pass" id="give-user-pass-<?php echo $form_id; ?>" |
| 1313 | - placeholder="<?php esc_attr_e( 'Your password', 'give' ); ?>"<?php echo ( give_logged_in_only( $form_id ) ) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1313 | + placeholder="<?php esc_attr_e('Your password', 'give'); ?>"<?php echo (give_logged_in_only($form_id)) ? ' required aria-required="true" ' : ''; ?>/> |
|
| 1314 | 1314 | <input type="hidden" name="give-purchase-var" value="needs-to-login"/> |
| 1315 | 1315 | </div> |
| 1316 | 1316 | |
| 1317 | 1317 | <div id="give-forgot-password-wrap-<?php echo $form_id; ?>" class="give_login_forgot_password"> |
| 1318 | 1318 | <span class="give-forgot-password "> |
| 1319 | 1319 | <a href="<?php echo wp_lostpassword_url() ?>" |
| 1320 | - target="_blank"><?php esc_html_e( 'Reset Password', 'give' ) ?></a> |
|
| 1320 | + target="_blank"><?php esc_html_e('Reset Password', 'give') ?></a> |
|
| 1321 | 1321 | </span> |
| 1322 | 1322 | </div> |
| 1323 | 1323 | |
| 1324 | 1324 | <div id="give-user-login-submit-<?php echo $form_id; ?>" class="give-clearfix"> |
| 1325 | 1325 | <input type="submit" class="give-submit give-btn button" name="give_login_submit" |
| 1326 | - value="<?php esc_attr_e( 'Login', 'give' ); ?>"/> |
|
| 1327 | - <?php if ( $show_register_form !== 'login' ) { ?> |
|
| 1326 | + value="<?php esc_attr_e('Login', 'give'); ?>"/> |
|
| 1327 | + <?php if ($show_register_form !== 'login') { ?> |
|
| 1328 | 1328 | <input type="button" data-action="give_cancel_login" |
| 1329 | 1329 | class="give-cancel-login give-checkout-register-cancel give-btn button" name="give_login_cancel" |
| 1330 | - value="<?php esc_attr_e( 'Cancel', 'give' ); ?>"/> |
|
| 1330 | + value="<?php esc_attr_e('Cancel', 'give'); ?>"/> |
|
| 1331 | 1331 | <?php } ?> |
| 1332 | 1332 | <span class="give-loading-animation"></span> |
| 1333 | 1333 | </div> |
@@ -1339,14 +1339,14 @@ discard block |
||
| 1339 | 1339 | * |
| 1340 | 1340 | * @param int $form_id The form ID. |
| 1341 | 1341 | */ |
| 1342 | - do_action( 'give_checkout_login_fields_after', $form_id ); |
|
| 1342 | + do_action('give_checkout_login_fields_after', $form_id); |
|
| 1343 | 1343 | ?> |
| 1344 | 1344 | </fieldset><!--end #give-login-fields--> |
| 1345 | 1345 | <?php |
| 1346 | 1346 | echo ob_get_clean(); |
| 1347 | 1347 | } |
| 1348 | 1348 | |
| 1349 | -add_action( 'give_donation_form_login_fields', 'give_get_login_fields', 10, 1 ); |
|
| 1349 | +add_action('give_donation_form_login_fields', 'give_get_login_fields', 10, 1); |
|
| 1350 | 1350 | |
| 1351 | 1351 | /** |
| 1352 | 1352 | * Payment Mode Select. |
@@ -1362,9 +1362,9 @@ discard block |
||
| 1362 | 1362 | * |
| 1363 | 1363 | * @return void |
| 1364 | 1364 | */ |
| 1365 | -function give_payment_mode_select( $form_id ) { |
|
| 1365 | +function give_payment_mode_select($form_id) { |
|
| 1366 | 1366 | |
| 1367 | - $gateways = give_get_enabled_payment_gateways( $form_id ); |
|
| 1367 | + $gateways = give_get_enabled_payment_gateways($form_id); |
|
| 1368 | 1368 | |
| 1369 | 1369 | /** |
| 1370 | 1370 | * Fires while selecting payment gateways, before the fields. |
@@ -1373,10 +1373,10 @@ discard block |
||
| 1373 | 1373 | * |
| 1374 | 1374 | * @param int $form_id The form ID. |
| 1375 | 1375 | */ |
| 1376 | - do_action( 'give_payment_mode_top', $form_id ); |
|
| 1376 | + do_action('give_payment_mode_top', $form_id); |
|
| 1377 | 1377 | ?> |
| 1378 | 1378 | |
| 1379 | - <fieldset id="give-payment-mode-select" <?php if ( count( $gateways ) <= 1 ) { |
|
| 1379 | + <fieldset id="give-payment-mode-select" <?php if (count($gateways) <= 1) { |
|
| 1380 | 1380 | echo 'style="display: none;"'; |
| 1381 | 1381 | } ?>> |
| 1382 | 1382 | <?php |
@@ -1387,10 +1387,10 @@ discard block |
||
| 1387 | 1387 | * |
| 1388 | 1388 | * @param int $form_id The form ID. |
| 1389 | 1389 | */ |
| 1390 | - do_action( 'give_payment_mode_before_gateways_wrap' ); |
|
| 1390 | + do_action('give_payment_mode_before_gateways_wrap'); |
|
| 1391 | 1391 | ?> |
| 1392 | 1392 | <legend |
| 1393 | - class="give-payment-mode-label"><?php echo apply_filters( 'give_checkout_payment_method_text', esc_html__( 'Select Payment Method', 'give' ) ); ?> |
|
| 1393 | + class="give-payment-mode-label"><?php echo apply_filters('give_checkout_payment_method_text', esc_html__('Select Payment Method', 'give')); ?> |
|
| 1394 | 1394 | <span class="give-loading-text"><span |
| 1395 | 1395 | class="give-loading-animation"></span> |
| 1396 | 1396 | </span> |
@@ -1403,26 +1403,26 @@ discard block |
||
| 1403 | 1403 | * |
| 1404 | 1404 | * @since 1.7 |
| 1405 | 1405 | */ |
| 1406 | - do_action( 'give_payment_mode_before_gateways' ) |
|
| 1406 | + do_action('give_payment_mode_before_gateways') |
|
| 1407 | 1407 | ?> |
| 1408 | 1408 | <ul id="give-gateway-radio-list"> |
| 1409 | 1409 | <?php |
| 1410 | 1410 | /** |
| 1411 | 1411 | * Loop through the active payment gateways. |
| 1412 | 1412 | */ |
| 1413 | - $selected_gateway = give_get_chosen_gateway( $form_id ); |
|
| 1413 | + $selected_gateway = give_get_chosen_gateway($form_id); |
|
| 1414 | 1414 | |
| 1415 | - foreach ( $gateways as $gateway_id => $gateway ) : |
|
| 1415 | + foreach ($gateways as $gateway_id => $gateway) : |
|
| 1416 | 1416 | //Determine the default gateway. |
| 1417 | - $checked = checked( $gateway_id, $selected_gateway, false ); |
|
| 1417 | + $checked = checked($gateway_id, $selected_gateway, false); |
|
| 1418 | 1418 | $checked_class = $checked ? ' class="give-gateway-option-selected"' : ''; ?> |
| 1419 | 1419 | <li<?php echo $checked_class ?>> |
| 1420 | 1420 | <input type="radio" name="payment-mode" class="give-gateway" |
| 1421 | - id="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1422 | - value="<?php echo esc_attr( $gateway_id ); ?>"<?php echo $checked; ?>> |
|
| 1423 | - <label for="give-gateway-<?php echo esc_attr( $gateway_id ) . '-' . $form_id; ?>" |
|
| 1421 | + id="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1422 | + value="<?php echo esc_attr($gateway_id); ?>"<?php echo $checked; ?>> |
|
| 1423 | + <label for="give-gateway-<?php echo esc_attr($gateway_id).'-'.$form_id; ?>" |
|
| 1424 | 1424 | class="give-gateway-option" |
| 1425 | - id="give-gateway-option-<?php echo esc_attr( $gateway_id ); ?>"> <?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
|
| 1425 | + id="give-gateway-option-<?php echo esc_attr($gateway_id); ?>"> <?php echo esc_html($gateway['checkout_label']); ?></label> |
|
| 1426 | 1426 | </li> |
| 1427 | 1427 | <?php |
| 1428 | 1428 | endforeach; |
@@ -1434,7 +1434,7 @@ discard block |
||
| 1434 | 1434 | * |
| 1435 | 1435 | * @since 1.7 |
| 1436 | 1436 | */ |
| 1437 | - do_action( 'give_payment_mode_after_gateways' ); |
|
| 1437 | + do_action('give_payment_mode_after_gateways'); |
|
| 1438 | 1438 | ?> |
| 1439 | 1439 | </div> |
| 1440 | 1440 | <?php |
@@ -1445,7 +1445,7 @@ discard block |
||
| 1445 | 1445 | * |
| 1446 | 1446 | * @param int $form_id The form ID. |
| 1447 | 1447 | */ |
| 1448 | - do_action( 'give_payment_mode_after_gateways_wrap' ); |
|
| 1448 | + do_action('give_payment_mode_after_gateways_wrap'); |
|
| 1449 | 1449 | ?> |
| 1450 | 1450 | </fieldset> |
| 1451 | 1451 | |
@@ -1457,7 +1457,7 @@ discard block |
||
| 1457 | 1457 | * |
| 1458 | 1458 | * @param int $form_id The form ID. |
| 1459 | 1459 | */ |
| 1460 | - do_action( 'give_payment_mode_bottom', $form_id ); |
|
| 1460 | + do_action('give_payment_mode_bottom', $form_id); |
|
| 1461 | 1461 | ?> |
| 1462 | 1462 | |
| 1463 | 1463 | <div id="give_purchase_form_wrap"> |
@@ -1468,7 +1468,7 @@ discard block |
||
| 1468 | 1468 | * |
| 1469 | 1469 | * @since 1.7 |
| 1470 | 1470 | */ |
| 1471 | - do_action( 'give_donation_form', $form_id ); |
|
| 1471 | + do_action('give_donation_form', $form_id); |
|
| 1472 | 1472 | ?> |
| 1473 | 1473 | |
| 1474 | 1474 | </div> |
@@ -1479,10 +1479,10 @@ discard block |
||
| 1479 | 1479 | * |
| 1480 | 1480 | * @since 1.7 |
| 1481 | 1481 | */ |
| 1482 | - do_action( 'give_donation_form_wrap_bottom', $form_id ); |
|
| 1482 | + do_action('give_donation_form_wrap_bottom', $form_id); |
|
| 1483 | 1483 | } |
| 1484 | 1484 | |
| 1485 | -add_action( 'give_payment_mode_select', 'give_payment_mode_select' ); |
|
| 1485 | +add_action('give_payment_mode_select', 'give_payment_mode_select'); |
|
| 1486 | 1486 | |
| 1487 | 1487 | /** |
| 1488 | 1488 | * Renders the Checkout Agree to Terms, this displays a checkbox for users to |
@@ -1495,31 +1495,31 @@ discard block |
||
| 1495 | 1495 | * |
| 1496 | 1496 | * @return bool |
| 1497 | 1497 | */ |
| 1498 | -function give_terms_agreement( $form_id ) { |
|
| 1499 | - $form_option = give_get_meta( $form_id, '_give_terms_option', true ); |
|
| 1498 | +function give_terms_agreement($form_id) { |
|
| 1499 | + $form_option = give_get_meta($form_id, '_give_terms_option', true); |
|
| 1500 | 1500 | |
| 1501 | 1501 | // Bailout if per form and global term and conditions is not setup. |
| 1502 | 1502 | if ( |
| 1503 | - give_is_setting_enabled( $form_option, 'global' ) |
|
| 1504 | - && give_is_setting_enabled( give_get_option( 'terms' ) ) |
|
| 1503 | + give_is_setting_enabled($form_option, 'global') |
|
| 1504 | + && give_is_setting_enabled(give_get_option('terms')) |
|
| 1505 | 1505 | ) { |
| 1506 | - $label = give_get_option( 'agree_to_terms_label', esc_html__( 'Agree to Terms?', 'give' ) ); |
|
| 1507 | - $terms = $terms = give_get_option( 'agreement_text', '' ); |
|
| 1508 | - $edit_term_url = admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions' ); |
|
| 1506 | + $label = give_get_option('agree_to_terms_label', esc_html__('Agree to Terms?', 'give')); |
|
| 1507 | + $terms = $terms = give_get_option('agreement_text', ''); |
|
| 1508 | + $edit_term_url = admin_url('edit.php?post_type=give_forms&page=give-settings&tab=display§ion=term-and-conditions'); |
|
| 1509 | 1509 | |
| 1510 | - } elseif ( give_is_setting_enabled( $form_option ) ) { |
|
| 1511 | - $label = ( $label = give_get_meta( $form_id, '_give_agree_label', true ) ) ? stripslashes( $label ) : esc_html__( 'Agree to Terms?', 'give' ); |
|
| 1512 | - $terms = give_get_meta( $form_id, '_give_agree_text', true ); |
|
| 1513 | - $edit_term_url = admin_url( 'post.php?post=' . $form_id . '&action=edit#form_terms_options' ); |
|
| 1510 | + } elseif (give_is_setting_enabled($form_option)) { |
|
| 1511 | + $label = ($label = give_get_meta($form_id, '_give_agree_label', true)) ? stripslashes($label) : esc_html__('Agree to Terms?', 'give'); |
|
| 1512 | + $terms = give_get_meta($form_id, '_give_agree_text', true); |
|
| 1513 | + $edit_term_url = admin_url('post.php?post='.$form_id.'&action=edit#form_terms_options'); |
|
| 1514 | 1514 | |
| 1515 | 1515 | } else { |
| 1516 | 1516 | return false; |
| 1517 | 1517 | } |
| 1518 | 1518 | |
| 1519 | 1519 | // Bailout: Check if term and conditions text is empty or not. |
| 1520 | - if ( empty( $terms ) ) { |
|
| 1521 | - if ( is_user_logged_in() && current_user_can( 'edit_give_forms' ) ) { |
|
| 1522 | - echo sprintf( __( 'Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give' ), $edit_term_url ); |
|
| 1520 | + if (empty($terms)) { |
|
| 1521 | + if (is_user_logged_in() && current_user_can('edit_give_forms')) { |
|
| 1522 | + echo sprintf(__('Please enter valid terms and conditions in <a href="%s">this form\'s settings</a>.', 'give'), $edit_term_url); |
|
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | 1525 | return false; |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | |
| 1528 | 1528 | ?> |
| 1529 | 1529 | <fieldset id="give_terms_agreement"> |
| 1530 | - <legend><?php echo apply_filters( 'give_terms_agreement_text', esc_html__( 'Terms', 'give' ) ); ?></legend> |
|
| 1530 | + <legend><?php echo apply_filters('give_terms_agreement_text', esc_html__('Terms', 'give')); ?></legend> |
|
| 1531 | 1531 | <div id="give_terms" class="give_terms-<?php echo $form_id; ?>" style="display:none;"> |
| 1532 | 1532 | <?php |
| 1533 | 1533 | /** |
@@ -1535,22 +1535,22 @@ discard block |
||
| 1535 | 1535 | * |
| 1536 | 1536 | * @since 1.0 |
| 1537 | 1537 | */ |
| 1538 | - do_action( 'give_before_terms' ); |
|
| 1538 | + do_action('give_before_terms'); |
|
| 1539 | 1539 | |
| 1540 | - echo wpautop( stripslashes( $terms ) ); |
|
| 1540 | + echo wpautop(stripslashes($terms)); |
|
| 1541 | 1541 | /** |
| 1542 | 1542 | * Fires while rendering terms of agreement, after the fields. |
| 1543 | 1543 | * |
| 1544 | 1544 | * @since 1.0 |
| 1545 | 1545 | */ |
| 1546 | - do_action( 'give_after_terms' ); |
|
| 1546 | + do_action('give_after_terms'); |
|
| 1547 | 1547 | ?> |
| 1548 | 1548 | </div> |
| 1549 | 1549 | <div id="give_show_terms"> |
| 1550 | 1550 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1551 | - aria-controls="give_terms"><?php esc_html_e( 'Show Terms', 'give' ); ?></a> |
|
| 1551 | + aria-controls="give_terms"><?php esc_html_e('Show Terms', 'give'); ?></a> |
|
| 1552 | 1552 | <a href="#" class="give_terms_links give_terms_links-<?php echo $form_id; ?>" role="button" |
| 1553 | - aria-controls="give_terms" style="display:none;"><?php esc_html_e( 'Hide Terms', 'give' ); ?></a> |
|
| 1553 | + aria-controls="give_terms" style="display:none;"><?php esc_html_e('Hide Terms', 'give'); ?></a> |
|
| 1554 | 1554 | </div> |
| 1555 | 1555 | |
| 1556 | 1556 | <input name="give_agree_to_terms" class="required" type="checkbox" |
@@ -1561,7 +1561,7 @@ discard block |
||
| 1561 | 1561 | <?php |
| 1562 | 1562 | } |
| 1563 | 1563 | |
| 1564 | -add_action( 'give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1 ); |
|
| 1564 | +add_action('give_donation_form_after_cc_form', 'give_terms_agreement', 8888, 1); |
|
| 1565 | 1565 | |
| 1566 | 1566 | /** |
| 1567 | 1567 | * Checkout Final Total. |
@@ -1574,31 +1574,30 @@ discard block |
||
| 1574 | 1574 | * |
| 1575 | 1575 | * @return void |
| 1576 | 1576 | */ |
| 1577 | -function give_checkout_final_total( $form_id ) { |
|
| 1577 | +function give_checkout_final_total($form_id) { |
|
| 1578 | 1578 | |
| 1579 | - $total = isset( $_POST['give_total'] ) ? |
|
| 1580 | - apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give_total'] ) ) : |
|
| 1581 | - give_get_default_form_amount( $form_id ); |
|
| 1579 | + $total = isset($_POST['give_total']) ? |
|
| 1580 | + apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give_total'])) : give_get_default_form_amount($form_id); |
|
| 1582 | 1581 | |
| 1583 | 1582 | |
| 1584 | 1583 | //Only proceed if give_total available. |
| 1585 | - if ( empty( $total ) ) { |
|
| 1584 | + if (empty($total)) { |
|
| 1586 | 1585 | return; |
| 1587 | 1586 | } |
| 1588 | 1587 | ?> |
| 1589 | 1588 | <p id="give-final-total-wrap" class="form-wrap "> |
| 1590 | 1589 | <span class="give-donation-total-label"> |
| 1591 | - <?php echo apply_filters( 'give_donation_total_label', esc_html__( 'Donation Total:', 'give' ) ); ?> |
|
| 1590 | + <?php echo apply_filters('give_donation_total_label', esc_html__('Donation Total:', 'give')); ?> |
|
| 1592 | 1591 | </span> |
| 1593 | 1592 | <span class="give-final-total-amount" |
| 1594 | - data-total="<?php echo give_format_amount( $total, array( 'sanitize' => false ) ); ?>"> |
|
| 1595 | - <?php echo give_currency_filter( give_format_amount( $total, array( 'sanitize' => false ) ) ); ?> |
|
| 1593 | + data-total="<?php echo give_format_amount($total, array('sanitize' => false)); ?>"> |
|
| 1594 | + <?php echo give_currency_filter(give_format_amount($total, array('sanitize' => false))); ?> |
|
| 1596 | 1595 | </span> |
| 1597 | 1596 | </p> |
| 1598 | 1597 | <?php |
| 1599 | 1598 | } |
| 1600 | 1599 | |
| 1601 | -add_action( 'give_donation_form_before_submit', 'give_checkout_final_total', 999 ); |
|
| 1600 | +add_action('give_donation_form_before_submit', 'give_checkout_final_total', 999); |
|
| 1602 | 1601 | |
| 1603 | 1602 | /** |
| 1604 | 1603 | * Renders the Checkout Submit section. |
@@ -1609,7 +1608,7 @@ discard block |
||
| 1609 | 1608 | * |
| 1610 | 1609 | * @return void |
| 1611 | 1610 | */ |
| 1612 | -function give_checkout_submit( $form_id ) { |
|
| 1611 | +function give_checkout_submit($form_id) { |
|
| 1613 | 1612 | ?> |
| 1614 | 1613 | <fieldset id="give_purchase_submit"> |
| 1615 | 1614 | <?php |
@@ -1618,24 +1617,24 @@ discard block |
||
| 1618 | 1617 | * |
| 1619 | 1618 | * @since 1.7 |
| 1620 | 1619 | */ |
| 1621 | - do_action( 'give_donation_form_before_submit', $form_id ); |
|
| 1620 | + do_action('give_donation_form_before_submit', $form_id); |
|
| 1622 | 1621 | |
| 1623 | - give_checkout_hidden_fields( $form_id ); |
|
| 1622 | + give_checkout_hidden_fields($form_id); |
|
| 1624 | 1623 | |
| 1625 | - echo give_get_donation_form_submit_button( $form_id ); |
|
| 1624 | + echo give_get_donation_form_submit_button($form_id); |
|
| 1626 | 1625 | |
| 1627 | 1626 | /** |
| 1628 | 1627 | * Fire after donation form submit. |
| 1629 | 1628 | * |
| 1630 | 1629 | * @since 1.7 |
| 1631 | 1630 | */ |
| 1632 | - do_action( 'give_donation_form_after_submit', $form_id ); |
|
| 1631 | + do_action('give_donation_form_after_submit', $form_id); |
|
| 1633 | 1632 | ?> |
| 1634 | 1633 | </fieldset> |
| 1635 | 1634 | <?php |
| 1636 | 1635 | } |
| 1637 | 1636 | |
| 1638 | -add_action( 'give_donation_form_after_cc_form', 'give_checkout_submit', 9999 ); |
|
| 1637 | +add_action('give_donation_form_after_cc_form', 'give_checkout_submit', 9999); |
|
| 1639 | 1638 | |
| 1640 | 1639 | /** |
| 1641 | 1640 | * Give Donation form submit button. |
@@ -1646,10 +1645,10 @@ discard block |
||
| 1646 | 1645 | * |
| 1647 | 1646 | * @return string |
| 1648 | 1647 | */ |
| 1649 | -function give_get_donation_form_submit_button( $form_id ) { |
|
| 1648 | +function give_get_donation_form_submit_button($form_id) { |
|
| 1650 | 1649 | |
| 1651 | - $display_label_field = give_get_meta( $form_id, '_give_checkout_label', true ); |
|
| 1652 | - $display_label = ( ! empty( $display_label_field ) ? $display_label_field : esc_html__( 'Donate Now', 'give' ) ); |
|
| 1650 | + $display_label_field = give_get_meta($form_id, '_give_checkout_label', true); |
|
| 1651 | + $display_label = ( ! empty($display_label_field) ? $display_label_field : esc_html__('Donate Now', 'give')); |
|
| 1653 | 1652 | ob_start(); |
| 1654 | 1653 | ?> |
| 1655 | 1654 | <div class="give-submit-button-wrap give-clearfix"> |
@@ -1658,7 +1657,7 @@ discard block |
||
| 1658 | 1657 | <span class="give-loading-animation"></span> |
| 1659 | 1658 | </div> |
| 1660 | 1659 | <?php |
| 1661 | - return apply_filters( 'give_donation_form_submit_button', ob_get_clean(), $form_id ); |
|
| 1660 | + return apply_filters('give_donation_form_submit_button', ob_get_clean(), $form_id); |
|
| 1662 | 1661 | } |
| 1663 | 1662 | |
| 1664 | 1663 | /** |
@@ -1673,17 +1672,17 @@ discard block |
||
| 1673 | 1672 | * |
| 1674 | 1673 | * @return mixed |
| 1675 | 1674 | */ |
| 1676 | -function give_show_goal_progress( $form_id, $args ) { |
|
| 1675 | +function give_show_goal_progress($form_id, $args) { |
|
| 1677 | 1676 | |
| 1678 | 1677 | ob_start(); |
| 1679 | - give_get_template( 'shortcode-goal', array( 'form_id' => $form_id, 'args' => $args ) ); |
|
| 1678 | + give_get_template('shortcode-goal', array('form_id' => $form_id, 'args' => $args)); |
|
| 1680 | 1679 | |
| 1681 | - echo apply_filters( 'give_goal_output', ob_get_clean() ); |
|
| 1680 | + echo apply_filters('give_goal_output', ob_get_clean()); |
|
| 1682 | 1681 | |
| 1683 | 1682 | return true; |
| 1684 | 1683 | } |
| 1685 | 1684 | |
| 1686 | -add_action( 'give_pre_form', 'give_show_goal_progress', 10, 2 ); |
|
| 1685 | +add_action('give_pre_form', 'give_show_goal_progress', 10, 2); |
|
| 1687 | 1686 | |
| 1688 | 1687 | |
| 1689 | 1688 | /** |
@@ -1696,10 +1695,10 @@ discard block |
||
| 1696 | 1695 | * |
| 1697 | 1696 | * @return mixed|string |
| 1698 | 1697 | */ |
| 1699 | -function give_get_form_content_placement( $form_id, $args ) { |
|
| 1698 | +function give_get_form_content_placement($form_id, $args) { |
|
| 1700 | 1699 | $show_content = ''; |
| 1701 | 1700 | |
| 1702 | - if ( isset( $args['show_content'] ) && ! empty( $args['show_content'] ) ) { |
|
| 1701 | + if (isset($args['show_content']) && ! empty($args['show_content'])) { |
|
| 1703 | 1702 | // Content positions. |
| 1704 | 1703 | $content_placement = array( |
| 1705 | 1704 | 'above' => 'give_pre_form', |
@@ -1707,18 +1706,18 @@ discard block |
||
| 1707 | 1706 | ); |
| 1708 | 1707 | |
| 1709 | 1708 | // Check if content position already decoded. |
| 1710 | - if ( in_array( $args['show_content'], $content_placement ) ) { |
|
| 1709 | + if (in_array($args['show_content'], $content_placement)) { |
|
| 1711 | 1710 | return $args['show_content']; |
| 1712 | 1711 | } |
| 1713 | 1712 | |
| 1714 | - $show_content = ( 'none' !== $args['show_content'] ? $content_placement[ $args['show_content'] ] : '' ); |
|
| 1713 | + $show_content = ('none' !== $args['show_content'] ? $content_placement[$args['show_content']] : ''); |
|
| 1715 | 1714 | |
| 1716 | - } elseif ( give_is_setting_enabled( give_get_meta( $form_id, '_give_display_content', true ) ) ) { |
|
| 1717 | - $show_content = give_get_meta( $form_id, '_give_content_placement', true ); |
|
| 1715 | + } elseif (give_is_setting_enabled(give_get_meta($form_id, '_give_display_content', true))) { |
|
| 1716 | + $show_content = give_get_meta($form_id, '_give_content_placement', true); |
|
| 1718 | 1717 | |
| 1719 | - } elseif ( 'none' !== give_get_meta( $form_id, '_give_content_option', true ) ) { |
|
| 1718 | + } elseif ('none' !== give_get_meta($form_id, '_give_content_option', true)) { |
|
| 1720 | 1719 | // Backward compatibility for _give_content_option for v18. |
| 1721 | - $show_content = give_get_meta( $form_id, '_give_content_option', true ); |
|
| 1720 | + $show_content = give_get_meta($form_id, '_give_content_option', true); |
|
| 1722 | 1721 | } |
| 1723 | 1722 | |
| 1724 | 1723 | return $show_content; |
@@ -1734,20 +1733,20 @@ discard block |
||
| 1734 | 1733 | * |
| 1735 | 1734 | * @return void|bool |
| 1736 | 1735 | */ |
| 1737 | -function give_form_content( $form_id, $args ) { |
|
| 1736 | +function give_form_content($form_id, $args) { |
|
| 1738 | 1737 | |
| 1739 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1738 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1740 | 1739 | |
| 1741 | 1740 | // Bailout. |
| 1742 | - if ( empty( $show_content ) ) { |
|
| 1741 | + if (empty($show_content)) { |
|
| 1743 | 1742 | return false; |
| 1744 | 1743 | } |
| 1745 | 1744 | |
| 1746 | 1745 | // Add action according to value. |
| 1747 | - add_action( $show_content, 'give_form_display_content', 10, 2 ); |
|
| 1746 | + add_action($show_content, 'give_form_display_content', 10, 2); |
|
| 1748 | 1747 | } |
| 1749 | 1748 | |
| 1750 | -add_action( 'give_pre_form_output', 'give_form_content', 10, 2 ); |
|
| 1749 | +add_action('give_pre_form_output', 'give_form_content', 10, 2); |
|
| 1751 | 1750 | |
| 1752 | 1751 | /** |
| 1753 | 1752 | * Renders Post Form Content. |
@@ -1761,22 +1760,22 @@ discard block |
||
| 1761 | 1760 | * |
| 1762 | 1761 | * @return void |
| 1763 | 1762 | */ |
| 1764 | -function give_form_display_content( $form_id, $args ) { |
|
| 1763 | +function give_form_display_content($form_id, $args) { |
|
| 1765 | 1764 | |
| 1766 | - $content = wpautop( give_get_meta( $form_id, '_give_form_content', true ) ); |
|
| 1767 | - $show_content = give_get_form_content_placement( $form_id, $args ); |
|
| 1765 | + $content = wpautop(give_get_meta($form_id, '_give_form_content', true)); |
|
| 1766 | + $show_content = give_get_form_content_placement($form_id, $args); |
|
| 1768 | 1767 | |
| 1769 | - if ( give_is_setting_enabled( give_get_option( 'the_content_filter' ) ) ) { |
|
| 1770 | - $content = apply_filters( 'the_content', $content ); |
|
| 1768 | + if (give_is_setting_enabled(give_get_option('the_content_filter'))) { |
|
| 1769 | + $content = apply_filters('the_content', $content); |
|
| 1771 | 1770 | } |
| 1772 | 1771 | |
| 1773 | - $output = '<div id="give-form-content-' . $form_id . '" class="give-form-content-wrap ' . $show_content . '-content">' . $content . '</div>'; |
|
| 1772 | + $output = '<div id="give-form-content-'.$form_id.'" class="give-form-content-wrap '.$show_content.'-content">'.$content.'</div>'; |
|
| 1774 | 1773 | |
| 1775 | - echo apply_filters( 'give_form_content_output', $output ); |
|
| 1774 | + echo apply_filters('give_form_content_output', $output); |
|
| 1776 | 1775 | |
| 1777 | 1776 | //remove action to prevent content output on addition forms on page. |
| 1778 | 1777 | //@see: https://github.com/WordImpress/Give/issues/634. |
| 1779 | - remove_action( $show_content, 'give_form_display_content' ); |
|
| 1778 | + remove_action($show_content, 'give_form_display_content'); |
|
| 1780 | 1779 | } |
| 1781 | 1780 | |
| 1782 | 1781 | /** |
@@ -1788,7 +1787,7 @@ discard block |
||
| 1788 | 1787 | * |
| 1789 | 1788 | * @return void |
| 1790 | 1789 | */ |
| 1791 | -function give_checkout_hidden_fields( $form_id ) { |
|
| 1790 | +function give_checkout_hidden_fields($form_id) { |
|
| 1792 | 1791 | |
| 1793 | 1792 | /** |
| 1794 | 1793 | * Fires while rendering hidden checkout fields, before the fields. |
@@ -1797,13 +1796,13 @@ discard block |
||
| 1797 | 1796 | * |
| 1798 | 1797 | * @param int $form_id The form ID. |
| 1799 | 1798 | */ |
| 1800 | - do_action( 'give_hidden_fields_before', $form_id ); |
|
| 1799 | + do_action('give_hidden_fields_before', $form_id); |
|
| 1801 | 1800 | |
| 1802 | - if ( is_user_logged_in() ) { ?> |
|
| 1801 | + if (is_user_logged_in()) { ?> |
|
| 1803 | 1802 | <input type="hidden" name="give-user-id" value="<?php echo get_current_user_id(); ?>"/> |
| 1804 | 1803 | <?php } ?> |
| 1805 | 1804 | <input type="hidden" name="give_action" value="purchase"/> |
| 1806 | - <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway( $form_id ); ?>"/> |
|
| 1805 | + <input type="hidden" name="give-gateway" value="<?php echo give_get_chosen_gateway($form_id); ?>"/> |
|
| 1807 | 1806 | <?php |
| 1808 | 1807 | /** |
| 1809 | 1808 | * Fires while rendering hidden checkout fields, after the fields. |
@@ -1812,7 +1811,7 @@ discard block |
||
| 1812 | 1811 | * |
| 1813 | 1812 | * @param int $form_id The form ID. |
| 1814 | 1813 | */ |
| 1815 | - do_action( 'give_hidden_fields_after', $form_id ); |
|
| 1814 | + do_action('give_hidden_fields_after', $form_id); |
|
| 1816 | 1815 | |
| 1817 | 1816 | } |
| 1818 | 1817 | |
@@ -1827,20 +1826,20 @@ discard block |
||
| 1827 | 1826 | * |
| 1828 | 1827 | * @return string $content Filtered content. |
| 1829 | 1828 | */ |
| 1830 | -function give_filter_success_page_content( $content ) { |
|
| 1829 | +function give_filter_success_page_content($content) { |
|
| 1831 | 1830 | |
| 1832 | 1831 | $give_options = give_get_settings(); |
| 1833 | 1832 | |
| 1834 | - if ( isset( $give_options['success_page'] ) && isset( $_GET['payment-confirmation'] ) && is_page( $give_options['success_page'] ) ) { |
|
| 1835 | - if ( has_filter( 'give_payment_confirm_' . $_GET['payment-confirmation'] ) ) { |
|
| 1836 | - $content = apply_filters( 'give_payment_confirm_' . $_GET['payment-confirmation'], $content ); |
|
| 1833 | + if (isset($give_options['success_page']) && isset($_GET['payment-confirmation']) && is_page($give_options['success_page'])) { |
|
| 1834 | + if (has_filter('give_payment_confirm_'.$_GET['payment-confirmation'])) { |
|
| 1835 | + $content = apply_filters('give_payment_confirm_'.$_GET['payment-confirmation'], $content); |
|
| 1837 | 1836 | } |
| 1838 | 1837 | } |
| 1839 | 1838 | |
| 1840 | 1839 | return $content; |
| 1841 | 1840 | } |
| 1842 | 1841 | |
| 1843 | -add_filter( 'the_content', 'give_filter_success_page_content' ); |
|
| 1842 | +add_filter('the_content', 'give_filter_success_page_content'); |
|
| 1844 | 1843 | |
| 1845 | 1844 | /** |
| 1846 | 1845 | * Test Mode Frontend Warning. |
@@ -1851,12 +1850,12 @@ discard block |
||
| 1851 | 1850 | */ |
| 1852 | 1851 | function give_test_mode_frontend_warning() { |
| 1853 | 1852 | |
| 1854 | - if ( give_is_test_mode() ) { |
|
| 1855 | - 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>'; |
|
| 1853 | + if (give_is_test_mode()) { |
|
| 1854 | + 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>'; |
|
| 1856 | 1855 | } |
| 1857 | 1856 | } |
| 1858 | 1857 | |
| 1859 | -add_action( 'give_pre_form', 'give_test_mode_frontend_warning', 10 ); |
|
| 1858 | +add_action('give_pre_form', 'give_test_mode_frontend_warning', 10); |
|
| 1860 | 1859 | |
| 1861 | 1860 | /** |
| 1862 | 1861 | * Members-only Form. |
@@ -1870,21 +1869,21 @@ discard block |
||
| 1870 | 1869 | * |
| 1871 | 1870 | * @return string |
| 1872 | 1871 | */ |
| 1873 | -function give_members_only_form( $final_output, $args ) { |
|
| 1872 | +function give_members_only_form($final_output, $args) { |
|
| 1874 | 1873 | |
| 1875 | - $form_id = isset( $args['form_id'] ) ? $args['form_id'] : 0; |
|
| 1874 | + $form_id = isset($args['form_id']) ? $args['form_id'] : 0; |
|
| 1876 | 1875 | |
| 1877 | 1876 | //Sanity Check: Must have form_id & not be logged in. |
| 1878 | - if ( empty( $form_id ) || is_user_logged_in() ) { |
|
| 1877 | + if (empty($form_id) || is_user_logged_in()) { |
|
| 1879 | 1878 | return $final_output; |
| 1880 | 1879 | } |
| 1881 | 1880 | |
| 1882 | 1881 | //Logged in only and Register / Login set to none. |
| 1883 | - if ( give_logged_in_only( $form_id ) && give_show_login_register_option( $form_id ) == 'none' ) { |
|
| 1882 | + if (give_logged_in_only($form_id) && give_show_login_register_option($form_id) == 'none') { |
|
| 1884 | 1883 | |
| 1885 | - $final_output = Give()->notices->print_frontend_notice( esc_html__( 'Please log in in order to complete your donation.', 'give' ), false ); |
|
| 1884 | + $final_output = Give()->notices->print_frontend_notice(esc_html__('Please log in in order to complete your donation.', 'give'), false); |
|
| 1886 | 1885 | |
| 1887 | - return apply_filters( 'give_members_only_output', $final_output, $form_id ); |
|
| 1886 | + return apply_filters('give_members_only_output', $final_output, $form_id); |
|
| 1888 | 1887 | |
| 1889 | 1888 | } |
| 1890 | 1889 | |
@@ -1892,4 +1891,4 @@ discard block |
||
| 1892 | 1891 | |
| 1893 | 1892 | } |
| 1894 | 1893 | |
| 1895 | -add_filter( 'give_donate_form', 'give_members_only_form', 10, 2 ); |
|
| 1894 | +add_filter('give_donate_form', 'give_members_only_form', 10, 2); |
|
@@ -1020,9 +1020,12 @@ |
||
| 1020 | 1020 | } |
| 1021 | 1021 | ?> |
| 1022 | 1022 | </select> |
| 1023 | - <?php else : ?> |
|
| 1023 | + <?php else { |
|
| 1024 | + : ?> |
|
| 1024 | 1025 | <input type="text" size="6" name="card_state" id="card_state" class="card_state give-input" |
| 1025 | - placeholder="<?php echo $label; ?>" value="<?php echo $selected_state; ?>"/> |
|
| 1026 | + placeholder="<?php echo $label; |
|
| 1027 | +} |
|
| 1028 | +?>" value="<?php echo $selected_state; ?>"/> |
|
| 1026 | 1029 | <?php endif; ?> |
| 1027 | 1030 | </p> |
| 1028 | 1031 | |
@@ -288,8 +288,8 @@ |
||
| 288 | 288 | |
| 289 | 289 | // Check spam detect. |
| 290 | 290 | if ( isset( $_POST['action'] ) |
| 291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
| 292 | - && give_is_spam_donation() |
|
| 291 | + && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
| 292 | + && give_is_spam_donation() |
|
| 293 | 293 | ) { |
| 294 | 294 | give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
| 295 | 295 | } |
@@ -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 | |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @since 1.0 |
| 32 | 32 | */ |
| 33 | - do_action( 'give_pre_process_donation' ); |
|
| 33 | + do_action('give_pre_process_donation'); |
|
| 34 | 34 | |
| 35 | 35 | // Validate the form $_POST data |
| 36 | 36 | $valid_data = give_donation_form_validate_fields(); |
@@ -45,26 +45,26 @@ discard block |
||
| 45 | 45 | * @param bool|array $valid_data Validate fields. |
| 46 | 46 | * @param array $_POST Array of variables passed via the HTTP POST. |
| 47 | 47 | */ |
| 48 | - do_action( 'give_checkout_error_checks', $valid_data, $_POST ); |
|
| 48 | + do_action('give_checkout_error_checks', $valid_data, $_POST); |
|
| 49 | 49 | |
| 50 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 50 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 51 | 51 | |
| 52 | 52 | // Process the login form |
| 53 | - if ( isset( $_POST['give_login_submit'] ) ) { |
|
| 53 | + if (isset($_POST['give_login_submit'])) { |
|
| 54 | 54 | give_process_form_login(); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | // Validate the user |
| 58 | - $user = give_get_donation_form_user( $valid_data ); |
|
| 58 | + $user = give_get_donation_form_user($valid_data); |
|
| 59 | 59 | |
| 60 | - if ( false === $valid_data || give_get_errors() || ! $user ) { |
|
| 61 | - if ( $is_ajax ) { |
|
| 60 | + if (false === $valid_data || give_get_errors() || ! $user) { |
|
| 61 | + if ($is_ajax) { |
|
| 62 | 62 | /** |
| 63 | 63 | * Fires when AJAX sends back errors from the donation form. |
| 64 | 64 | * |
| 65 | 65 | * @since 1.0 |
| 66 | 66 | */ |
| 67 | - do_action( 'give_ajax_donation_errors' ); |
|
| 67 | + do_action('give_ajax_donation_errors'); |
|
| 68 | 68 | give_die(); |
| 69 | 69 | } else { |
| 70 | 70 | return false; |
@@ -72,17 +72,17 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | // If AJAX send back success to proceed with form submission |
| 75 | - if ( $is_ajax ) { |
|
| 75 | + if ($is_ajax) { |
|
| 76 | 76 | echo 'success'; |
| 77 | 77 | give_die(); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | // After AJAX: Setup session if not using php_sessions |
| 81 | - if ( ! Give()->session->use_php_sessions() ) { |
|
| 81 | + if ( ! Give()->session->use_php_sessions()) { |
|
| 82 | 82 | // Double-check that set_cookie is publicly accessible; |
| 83 | 83 | // we're using a slightly modified class-wp-sessions.php |
| 84 | - $session_reflection = new ReflectionMethod( 'WP_Session', 'set_cookie' ); |
|
| 85 | - if ( $session_reflection->isPublic() ) { |
|
| 84 | + $session_reflection = new ReflectionMethod('WP_Session', 'set_cookie'); |
|
| 85 | + if ($session_reflection->isPublic()) { |
|
| 86 | 86 | // Manually set the cookie. |
| 87 | 87 | Give()->session->init()->set_cookie(); |
| 88 | 88 | } |
@@ -97,20 +97,19 @@ discard block |
||
| 97 | 97 | 'address' => $user['address'], |
| 98 | 98 | ); |
| 99 | 99 | |
| 100 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
| 100 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
| 101 | 101 | |
| 102 | - $price = isset( $_POST['give-amount'] ) ? |
|
| 103 | - (float) apply_filters( 'give_donation_total', give_maybe_sanitize_amount( $_POST['give-amount'] ) ) : |
|
| 104 | - '0.00'; |
|
| 105 | - $purchase_key = strtolower( md5( $user['user_email'] . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'give', true ) ) ); |
|
| 102 | + $price = isset($_POST['give-amount']) ? |
|
| 103 | + (float) apply_filters('give_donation_total', give_maybe_sanitize_amount($_POST['give-amount'])) : '0.00'; |
|
| 104 | + $purchase_key = strtolower(md5($user['user_email'].date('Y-m-d H:i:s').$auth_key.uniqid('give', true))); |
|
| 106 | 105 | |
| 107 | 106 | // Setup donation information |
| 108 | 107 | $donation_data = array( |
| 109 | 108 | 'price' => $price, |
| 110 | 109 | 'purchase_key' => $purchase_key, |
| 111 | 110 | 'user_email' => $user['user_email'], |
| 112 | - 'date' => date( 'Y-m-d H:i:s', current_time( 'timestamp' ) ), |
|
| 113 | - 'user_info' => stripslashes_deep( $user_info ), |
|
| 111 | + 'date' => date('Y-m-d H:i:s', current_time('timestamp')), |
|
| 112 | + 'user_info' => stripslashes_deep($user_info), |
|
| 114 | 113 | 'post_data' => $_POST, |
| 115 | 114 | 'gateway' => $valid_data['gateway'], |
| 116 | 115 | 'card_info' => $valid_data['cc_info'], |
@@ -130,10 +129,10 @@ discard block |
||
| 130 | 129 | * @param array $user_info Array containing basic user information. |
| 131 | 130 | * @param bool|array $valid_data Validate fields. |
| 132 | 131 | */ |
| 133 | - do_action( 'give_checkout_before_gateway', $_POST, $user_info, $valid_data ); |
|
| 132 | + do_action('give_checkout_before_gateway', $_POST, $user_info, $valid_data); |
|
| 134 | 133 | |
| 135 | 134 | // Sanity check for price |
| 136 | - if ( ! $donation_data['price'] ) { |
|
| 135 | + if ( ! $donation_data['price']) { |
|
| 137 | 136 | // Revert to manual |
| 138 | 137 | $donation_data['gateway'] = 'manual'; |
| 139 | 138 | $_POST['give-gateway'] = 'manual'; |
@@ -144,27 +143,27 @@ discard block |
||
| 144 | 143 | * |
| 145 | 144 | * @since 1.7 |
| 146 | 145 | */ |
| 147 | - $donation_data = apply_filters( 'give_donation_data_before_gateway', $donation_data, $valid_data ); |
|
| 146 | + $donation_data = apply_filters('give_donation_data_before_gateway', $donation_data, $valid_data); |
|
| 148 | 147 | |
| 149 | 148 | // Setup the data we're storing in the donation session |
| 150 | 149 | $session_data = $donation_data; |
| 151 | 150 | |
| 152 | 151 | // Make sure credit card numbers are never stored in sessions |
| 153 | - unset( $session_data['card_info']['card_number'] ); |
|
| 154 | - unset( $session_data['post_data']['card_number'] ); |
|
| 152 | + unset($session_data['card_info']['card_number']); |
|
| 153 | + unset($session_data['post_data']['card_number']); |
|
| 155 | 154 | |
| 156 | 155 | // Used for showing data to non logged-in users after donation, and for other plugins needing donation data. |
| 157 | - give_set_purchase_session( $session_data ); |
|
| 156 | + give_set_purchase_session($session_data); |
|
| 158 | 157 | |
| 159 | 158 | // Send info to the gateway for payment processing |
| 160 | - give_send_to_gateway( $donation_data['gateway'], $donation_data ); |
|
| 159 | + give_send_to_gateway($donation_data['gateway'], $donation_data); |
|
| 161 | 160 | give_die(); |
| 162 | 161 | |
| 163 | 162 | } |
| 164 | 163 | |
| 165 | -add_action( 'give_purchase', 'give_process_donation_form' ); |
|
| 166 | -add_action( 'wp_ajax_give_process_donation', 'give_process_donation_form' ); |
|
| 167 | -add_action( 'wp_ajax_nopriv_give_process_donation', 'give_process_donation_form' ); |
|
| 164 | +add_action('give_purchase', 'give_process_donation_form'); |
|
| 165 | +add_action('wp_ajax_give_process_donation', 'give_process_donation_form'); |
|
| 166 | +add_action('wp_ajax_nopriv_give_process_donation', 'give_process_donation_form'); |
|
| 168 | 167 | |
| 169 | 168 | |
| 170 | 169 | /** |
@@ -177,29 +176,29 @@ discard block |
||
| 177 | 176 | * |
| 178 | 177 | * @return void |
| 179 | 178 | */ |
| 180 | -function give_check_logged_in_user_for_existing_email( $valid_data, $post ) { |
|
| 179 | +function give_check_logged_in_user_for_existing_email($valid_data, $post) { |
|
| 181 | 180 | |
| 182 | 181 | // Verify that the email address belongs to this customer. |
| 183 | - if ( is_user_logged_in() ) { |
|
| 182 | + if (is_user_logged_in()) { |
|
| 184 | 183 | |
| 185 | 184 | $submitted_email = $valid_data['logged_in_user']['user_email']; |
| 186 | - $donor = new Give_Donor( get_current_user_id(), true ); |
|
| 185 | + $donor = new Give_Donor(get_current_user_id(), true); |
|
| 187 | 186 | |
| 188 | 187 | // If this email address is not registered with this customer, see if it belongs to any other customer |
| 189 | 188 | if ( |
| 190 | 189 | $submitted_email !== $donor->email |
| 191 | - && ( is_array( $donor->emails ) && ! in_array( $submitted_email, $donor->emails ) ) |
|
| 190 | + && (is_array($donor->emails) && ! in_array($submitted_email, $donor->emails)) |
|
| 192 | 191 | ) { |
| 193 | - $found_donor = new Give_Donor( $submitted_email ); |
|
| 192 | + $found_donor = new Give_Donor($submitted_email); |
|
| 194 | 193 | |
| 195 | - if ( $found_donor->id > 0 ) { |
|
| 196 | - give_set_error( 'give-customer-email-exists', sprintf( __( 'You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give' ), $donor->email, $submitted_email ) ); |
|
| 194 | + if ($found_donor->id > 0) { |
|
| 195 | + give_set_error('give-customer-email-exists', sprintf(__('You are logged in as %1$s, and are submitting a donation as %2$s, which is an existing donor. To ensure that the email address is tied to the correct donor, please submit this donation from a logged-out browser, or choose another email address.', 'give'), $donor->email, $submitted_email)); |
|
| 197 | 196 | } |
| 198 | 197 | } |
| 199 | 198 | } |
| 200 | 199 | } |
| 201 | 200 | |
| 202 | -add_action( 'give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2 ); |
|
| 201 | +add_action('give_checkout_error_checks', 'give_check_logged_in_user_for_existing_email', 10, 2); |
|
| 203 | 202 | |
| 204 | 203 | /** |
| 205 | 204 | * Process the checkout login form |
@@ -209,49 +208,49 @@ discard block |
||
| 209 | 208 | * @return void |
| 210 | 209 | */ |
| 211 | 210 | function give_process_form_login() { |
| 212 | - $is_ajax = isset( $_POST['give_ajax'] ); |
|
| 211 | + $is_ajax = isset($_POST['give_ajax']); |
|
| 213 | 212 | |
| 214 | 213 | $user_data = give_donation_form_validate_user_login(); |
| 215 | 214 | |
| 216 | - if ( give_get_errors() || $user_data['user_id'] < 1 ) { |
|
| 217 | - if ( $is_ajax ) { |
|
| 215 | + if (give_get_errors() || $user_data['user_id'] < 1) { |
|
| 216 | + if ($is_ajax) { |
|
| 218 | 217 | /** |
| 219 | 218 | * Fires when AJAX sends back errors from the donation form. |
| 220 | 219 | * |
| 221 | 220 | * @since 1.0 |
| 222 | 221 | */ |
| 223 | 222 | ob_start(); |
| 224 | - do_action( 'give_ajax_donation_errors' ); |
|
| 223 | + do_action('give_ajax_donation_errors'); |
|
| 225 | 224 | $message = ob_get_contents(); |
| 226 | 225 | ob_end_clean(); |
| 227 | - wp_send_json_error( $message ); |
|
| 226 | + wp_send_json_error($message); |
|
| 228 | 227 | } else { |
| 229 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 228 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 230 | 229 | exit; |
| 231 | 230 | } |
| 232 | 231 | } |
| 233 | 232 | |
| 234 | - give_log_user_in( $user_data['user_id'], $user_data['user_login'], $user_data['user_pass'] ); |
|
| 233 | + give_log_user_in($user_data['user_id'], $user_data['user_login'], $user_data['user_pass']); |
|
| 235 | 234 | |
| 236 | - if ( $is_ajax ) { |
|
| 235 | + if ($is_ajax) { |
|
| 237 | 236 | $message = Give()->notices->print_frontend_notice( |
| 238 | 237 | sprintf( |
| 239 | 238 | /* translators: %s: user first name */ |
| 240 | - esc_html__( 'Welcome %s! You have successfully logged into your account.', 'give' ), |
|
| 241 | - ( ! empty( $user_data['user_first'] ) ) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 239 | + esc_html__('Welcome %s! You have successfully logged into your account.', 'give'), |
|
| 240 | + ( ! empty($user_data['user_first'])) ? $user_data['user_first'] : $user_data['user_login'] |
|
| 242 | 241 | ), |
| 243 | 242 | false, |
| 244 | 243 | 'success' |
| 245 | 244 | ); |
| 246 | 245 | |
| 247 | - wp_send_json_success( $message ); |
|
| 246 | + wp_send_json_success($message); |
|
| 248 | 247 | } else { |
| 249 | - wp_redirect( $_SERVER['HTTP_REFERER'] ); |
|
| 248 | + wp_redirect($_SERVER['HTTP_REFERER']); |
|
| 250 | 249 | } |
| 251 | 250 | } |
| 252 | 251 | |
| 253 | -add_action( 'wp_ajax_give_process_donation_login', 'give_process_form_login' ); |
|
| 254 | -add_action( 'wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login' ); |
|
| 252 | +add_action('wp_ajax_give_process_donation_login', 'give_process_form_login'); |
|
| 253 | +add_action('wp_ajax_nopriv_give_process_donation_login', 'give_process_form_login'); |
|
| 255 | 254 | |
| 256 | 255 | /** |
| 257 | 256 | * Donation Form Validate Fields. |
@@ -263,63 +262,63 @@ discard block |
||
| 263 | 262 | function give_donation_form_validate_fields() { |
| 264 | 263 | |
| 265 | 264 | // Check if there is $_POST |
| 266 | - if ( empty( $_POST ) ) { |
|
| 265 | + if (empty($_POST)) { |
|
| 267 | 266 | return false; |
| 268 | 267 | } |
| 269 | 268 | |
| 270 | - $form_id = ! empty( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 269 | + $form_id = ! empty($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 271 | 270 | |
| 272 | 271 | // Start an array to collect valid data |
| 273 | 272 | $valid_data = array( |
| 274 | 273 | 'gateway' => give_donation_form_validate_gateway(), // Gateway fallback (amount is validated here) |
| 275 | - 'need_new_user' => false, // New user flag |
|
| 276 | - 'need_user_login' => false, // Login user flag |
|
| 277 | - 'logged_user_data' => array(), // Logged user collected data |
|
| 278 | - 'new_user_data' => array(), // New user collected data |
|
| 279 | - 'login_user_data' => array(), // Login user collected data |
|
| 280 | - 'guest_user_data' => array(), // Guest user collected data |
|
| 281 | - 'cc_info' => give_donation_form_validate_cc(),// Credit card info |
|
| 274 | + 'need_new_user' => false, // New user flag |
|
| 275 | + 'need_user_login' => false, // Login user flag |
|
| 276 | + 'logged_user_data' => array(), // Logged user collected data |
|
| 277 | + 'new_user_data' => array(), // New user collected data |
|
| 278 | + 'login_user_data' => array(), // Login user collected data |
|
| 279 | + 'guest_user_data' => array(), // Guest user collected data |
|
| 280 | + 'cc_info' => give_donation_form_validate_cc(), // Credit card info |
|
| 282 | 281 | ); |
| 283 | 282 | |
| 284 | 283 | // Validate Honeypot First |
| 285 | - if ( ! empty( $_POST['give-honeypot'] ) ) { |
|
| 286 | - give_set_error( 'invalid_honeypot', esc_html__( 'Honeypot field detected. Go away bad bot!', 'give' ) ); |
|
| 284 | + if ( ! empty($_POST['give-honeypot'])) { |
|
| 285 | + give_set_error('invalid_honeypot', esc_html__('Honeypot field detected. Go away bad bot!', 'give')); |
|
| 287 | 286 | } |
| 288 | 287 | |
| 289 | 288 | // Check spam detect. |
| 290 | - if ( isset( $_POST['action'] ) |
|
| 291 | - && give_is_setting_enabled( give_get_option( 'akismet_spam_protection' ) ) |
|
| 289 | + if (isset($_POST['action']) |
|
| 290 | + && give_is_setting_enabled(give_get_option('akismet_spam_protection')) |
|
| 292 | 291 | && give_is_spam_donation() |
| 293 | 292 | ) { |
| 294 | - give_set_error( 'invalid_donation', __( 'This donation has been flagged as spam. Please try again.', 'give' ) ); |
|
| 293 | + give_set_error('invalid_donation', __('This donation has been flagged as spam. Please try again.', 'give')); |
|
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | // Validate agree to terms |
| 298 | - if ( give_is_terms_enabled( $form_id ) ) { |
|
| 297 | + if (give_is_terms_enabled($form_id)) { |
|
| 299 | 298 | give_donation_form_validate_agree_to_terms(); |
| 300 | 299 | } |
| 301 | 300 | |
| 302 | 301 | // Stop processing donor registration, if donor registration is optional and donor can do guest checkout. |
| 303 | 302 | // If registration form username field is empty that means donor do not want to registration instead want guest checkout. |
| 304 | 303 | if ( |
| 305 | - ! give_logged_in_only( $form_id ) |
|
| 306 | - && isset( $_POST['give-purchase-var'] ) |
|
| 304 | + ! give_logged_in_only($form_id) |
|
| 305 | + && isset($_POST['give-purchase-var']) |
|
| 307 | 306 | && $_POST['give-purchase-var'] == 'needs-to-register' |
| 308 | - && empty( $_POST['give_user_login'] ) |
|
| 307 | + && empty($_POST['give_user_login']) |
|
| 309 | 308 | ) { |
| 310 | - unset( $_POST['give-purchase-var'] ); |
|
| 309 | + unset($_POST['give-purchase-var']); |
|
| 311 | 310 | } |
| 312 | 311 | |
| 313 | - if ( is_user_logged_in() ) { |
|
| 312 | + if (is_user_logged_in()) { |
|
| 314 | 313 | // Collect logged in user data. |
| 315 | 314 | $valid_data['logged_in_user'] = give_donation_form_validate_logged_in_user(); |
| 316 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-register' ) { |
|
| 315 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-register') { |
|
| 317 | 316 | // Set new user registration as required. |
| 318 | 317 | $valid_data['need_new_user'] = true; |
| 319 | 318 | // Validate new user data. |
| 320 | 319 | $valid_data['new_user_data'] = give_donation_form_validate_new_user(); |
| 321 | 320 | // Check if login validation is needed. |
| 322 | - } elseif ( isset( $_POST['give-purchase-var'] ) && $_POST['give-purchase-var'] == 'needs-to-login' ) { |
|
| 321 | + } elseif (isset($_POST['give-purchase-var']) && $_POST['give-purchase-var'] == 'needs-to-login') { |
|
| 323 | 322 | // Set user login as required. |
| 324 | 323 | $valid_data['need_user_login'] = true; |
| 325 | 324 | // Validate users login info. |
@@ -343,14 +342,14 @@ discard block |
||
| 343 | 342 | function give_is_spam_donation() { |
| 344 | 343 | $spam = false; |
| 345 | 344 | |
| 346 | - $user_agent = (string) isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 345 | + $user_agent = (string) isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; |
|
| 347 | 346 | |
| 348 | - if ( strlen( $user_agent ) < 2 ) { |
|
| 347 | + if (strlen($user_agent) < 2) { |
|
| 349 | 348 | $spam = true; |
| 350 | 349 | } |
| 351 | 350 | |
| 352 | 351 | // Allow developer to customized Akismet spam detect API call and it's response. |
| 353 | - return apply_filters( 'give_spam', $spam ); |
|
| 352 | + return apply_filters('give_spam', $spam); |
|
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | /** |
@@ -364,41 +363,41 @@ discard block |
||
| 364 | 363 | */ |
| 365 | 364 | function give_donation_form_validate_gateway() { |
| 366 | 365 | |
| 367 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 368 | - $amount = isset( $_REQUEST['give-amount'] ) ? give_maybe_sanitize_amount( $_REQUEST['give-amount'] ) : 0; |
|
| 369 | - $gateway = give_get_default_gateway( $form_id ); |
|
| 366 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 367 | + $amount = isset($_REQUEST['give-amount']) ? give_maybe_sanitize_amount($_REQUEST['give-amount']) : 0; |
|
| 368 | + $gateway = give_get_default_gateway($form_id); |
|
| 370 | 369 | |
| 371 | 370 | // Check if a gateway value is present. |
| 372 | - if ( ! empty( $_REQUEST['give-gateway'] ) ) { |
|
| 371 | + if ( ! empty($_REQUEST['give-gateway'])) { |
|
| 373 | 372 | |
| 374 | - $gateway = sanitize_text_field( $_REQUEST['give-gateway'] ); |
|
| 373 | + $gateway = sanitize_text_field($_REQUEST['give-gateway']); |
|
| 375 | 374 | |
| 376 | 375 | // Is amount being donated in LIVE mode 0.00? If so, error: |
| 377 | - if ( $amount == 0 && ! give_is_test_mode() ) { |
|
| 376 | + if ($amount == 0 && ! give_is_test_mode()) { |
|
| 378 | 377 | |
| 379 | - give_set_error( 'invalid_donation_amount', __( 'Please insert a valid donation amount.', 'give' ) ); |
|
| 378 | + give_set_error('invalid_donation_amount', __('Please insert a valid donation amount.', 'give')); |
|
| 380 | 379 | |
| 381 | 380 | } // End if(). |
| 382 | - elseif ( ! give_verify_minimum_price() ) { |
|
| 381 | + elseif ( ! give_verify_minimum_price()) { |
|
| 383 | 382 | // translators: %s: minimum donation amount. |
| 384 | 383 | give_set_error( |
| 385 | 384 | 'invalid_donation_minimum', |
| 386 | 385 | sprintf( |
| 387 | 386 | /* translators: %s: minimum donation amount */ |
| 388 | - __( 'This form has a minimum donation amount of %s.', 'give' ), |
|
| 389 | - give_currency_filter( give_format_amount( give_get_form_minimum_price( $form_id ), array( 'sanitize' => false ) ) ) |
|
| 387 | + __('This form has a minimum donation amount of %s.', 'give'), |
|
| 388 | + give_currency_filter(give_format_amount(give_get_form_minimum_price($form_id), array('sanitize' => false))) |
|
| 390 | 389 | ) |
| 391 | 390 | ); |
| 392 | 391 | |
| 393 | 392 | } //Is this test mode zero donation? Let it through but set to manual gateway. |
| 394 | - elseif ( $amount == 0 && give_is_test_mode() ) { |
|
| 393 | + elseif ($amount == 0 && give_is_test_mode()) { |
|
| 395 | 394 | |
| 396 | 395 | $gateway = 'manual'; |
| 397 | 396 | |
| 398 | 397 | } //Check if this gateway is active. |
| 399 | - elseif ( ! give_is_gateway_active( $gateway ) ) { |
|
| 398 | + elseif ( ! give_is_gateway_active($gateway)) { |
|
| 400 | 399 | |
| 401 | - give_set_error( 'invalid_gateway', __( 'The selected payment gateway is not enabled.', 'give' ) ); |
|
| 400 | + give_set_error('invalid_gateway', __('The selected payment gateway is not enabled.', 'give')); |
|
| 402 | 401 | |
| 403 | 402 | } |
| 404 | 403 | } |
@@ -416,21 +415,21 @@ discard block |
||
| 416 | 415 | */ |
| 417 | 416 | function give_verify_minimum_price() { |
| 418 | 417 | |
| 419 | - $amount = give_maybe_sanitize_amount( $_REQUEST['give-amount'] ); |
|
| 420 | - $form_id = isset( $_REQUEST['give-form-id'] ) ? $_REQUEST['give-form-id'] : 0; |
|
| 421 | - $price_id = isset( $_REQUEST['give-price-id'] ) ? $_REQUEST['give-price-id'] : null; |
|
| 422 | - $variable_prices = give_has_variable_prices( $form_id ); |
|
| 418 | + $amount = give_maybe_sanitize_amount($_REQUEST['give-amount']); |
|
| 419 | + $form_id = isset($_REQUEST['give-form-id']) ? $_REQUEST['give-form-id'] : 0; |
|
| 420 | + $price_id = isset($_REQUEST['give-price-id']) ? $_REQUEST['give-price-id'] : null; |
|
| 421 | + $variable_prices = give_has_variable_prices($form_id); |
|
| 423 | 422 | |
| 424 | - if ( $variable_prices && in_array( $price_id, give_get_variable_price_ids( $form_id ) ) ) { |
|
| 423 | + if ($variable_prices && in_array($price_id, give_get_variable_price_ids($form_id))) { |
|
| 425 | 424 | |
| 426 | - $price_level_amount = give_get_price_option_amount( $form_id, $price_id ); |
|
| 425 | + $price_level_amount = give_get_price_option_amount($form_id, $price_id); |
|
| 427 | 426 | |
| 428 | - if ( $price_level_amount == $amount ) { |
|
| 427 | + if ($price_level_amount == $amount) { |
|
| 429 | 428 | return true; |
| 430 | 429 | } |
| 431 | 430 | } |
| 432 | 431 | |
| 433 | - if ( give_get_form_minimum_price( $form_id ) > $amount ) { |
|
| 432 | + if (give_get_form_minimum_price($form_id) > $amount) { |
|
| 434 | 433 | return false; |
| 435 | 434 | } |
| 436 | 435 | |
@@ -446,9 +445,9 @@ discard block |
||
| 446 | 445 | */ |
| 447 | 446 | function give_donation_form_validate_agree_to_terms() { |
| 448 | 447 | // Validate agree to terms. |
| 449 | - if ( ! isset( $_POST['give_agree_to_terms'] ) || $_POST['give_agree_to_terms'] != 1 ) { |
|
| 448 | + if ( ! isset($_POST['give_agree_to_terms']) || $_POST['give_agree_to_terms'] != 1) { |
|
| 450 | 449 | // User did not agree. |
| 451 | - give_set_error( 'agree_to_terms', apply_filters( 'give_agree_to_terms_text', __( 'You must agree to the terms and conditions.', 'give' ) ) ); |
|
| 450 | + give_set_error('agree_to_terms', apply_filters('give_agree_to_terms_text', __('You must agree to the terms and conditions.', 'give'))); |
|
| 452 | 451 | } |
| 453 | 452 | } |
| 454 | 453 | |
@@ -462,59 +461,59 @@ discard block |
||
| 462 | 461 | * |
| 463 | 462 | * @return array |
| 464 | 463 | */ |
| 465 | -function give_get_required_fields( $form_id ) { |
|
| 464 | +function give_get_required_fields($form_id) { |
|
| 466 | 465 | |
| 467 | - $payment_mode = give_get_chosen_gateway( $form_id ); |
|
| 466 | + $payment_mode = give_get_chosen_gateway($form_id); |
|
| 468 | 467 | |
| 469 | 468 | $required_fields = array( |
| 470 | 469 | 'give_email' => array( |
| 471 | 470 | 'error_id' => 'invalid_email', |
| 472 | - 'error_message' => __( 'Please enter a valid email address.', 'give' ), |
|
| 471 | + 'error_message' => __('Please enter a valid email address.', 'give'), |
|
| 473 | 472 | ), |
| 474 | 473 | 'give_first' => array( |
| 475 | 474 | 'error_id' => 'invalid_first_name', |
| 476 | - 'error_message' => __( 'Please enter your first name.', 'give' ), |
|
| 475 | + 'error_message' => __('Please enter your first name.', 'give'), |
|
| 477 | 476 | ), |
| 478 | 477 | ); |
| 479 | 478 | |
| 480 | - $require_address = give_require_billing_address( $payment_mode ); |
|
| 479 | + $require_address = give_require_billing_address($payment_mode); |
|
| 481 | 480 | |
| 482 | - if ( $require_address ) { |
|
| 483 | - $required_fields['card_address'] = array( |
|
| 481 | + if ($require_address) { |
|
| 482 | + $required_fields['card_address'] = array( |
|
| 484 | 483 | 'error_id' => 'invalid_card_address', |
| 485 | - 'error_message' => __( 'Please enter your primary billing address.', 'give' ), |
|
| 484 | + 'error_message' => __('Please enter your primary billing address.', 'give'), |
|
| 486 | 485 | ); |
| 487 | - $required_fields['card_zip'] = array( |
|
| 486 | + $required_fields['card_zip'] = array( |
|
| 488 | 487 | 'error_id' => 'invalid_zip_code', |
| 489 | - 'error_message' => __( 'Please enter your zip / postal code.', 'give' ), |
|
| 488 | + 'error_message' => __('Please enter your zip / postal code.', 'give'), |
|
| 490 | 489 | ); |
| 491 | - $required_fields['card_city'] = array( |
|
| 490 | + $required_fields['card_city'] = array( |
|
| 492 | 491 | 'error_id' => 'invalid_city', |
| 493 | - 'error_message' => __( 'Please enter your billing city.', 'give' ), |
|
| 492 | + 'error_message' => __('Please enter your billing city.', 'give'), |
|
| 494 | 493 | ); |
| 495 | 494 | $required_fields['billing_country'] = array( |
| 496 | 495 | 'error_id' => 'invalid_country', |
| 497 | - 'error_message' => __( 'Please select your billing country.', 'give' ), |
|
| 496 | + 'error_message' => __('Please select your billing country.', 'give'), |
|
| 498 | 497 | ); |
| 499 | 498 | |
| 500 | 499 | |
| 501 | 500 | $required_fields['card_state'] = array( |
| 502 | 501 | 'error_id' => 'invalid_state', |
| 503 | - 'error_message' => __( 'Please enter billing state / province / County.', 'give' ), |
|
| 502 | + 'error_message' => __('Please enter billing state / province / County.', 'give'), |
|
| 504 | 503 | ); |
| 505 | 504 | |
| 506 | 505 | // Check if billing country alredy exists. |
| 507 | - if ( ! empty( $_POST['billing_country'] ) ) { |
|
| 506 | + if ( ! empty($_POST['billing_country'])) { |
|
| 508 | 507 | // Get the value from $_POST. |
| 509 | - $country = sanitize_text_field( $_POST['billing_country'] ); |
|
| 508 | + $country = sanitize_text_field($_POST['billing_country']); |
|
| 510 | 509 | |
| 511 | 510 | // Get the country list that does not required any states init. |
| 512 | 511 | $states_country = give_states_not_required_country_list(); |
| 513 | 512 | |
| 514 | 513 | // Check if states is empty or not. |
| 515 | - if ( array_key_exists( $country, $states_country ) ) { |
|
| 514 | + if (array_key_exists($country, $states_country)) { |
|
| 516 | 515 | // If states is empty remove the required feilds of state in billing cart. |
| 517 | - unset( $required_fields['card_state'] ); |
|
| 516 | + unset($required_fields['card_state']); |
|
| 518 | 517 | } |
| 519 | 518 | } |
| 520 | 519 | } |
@@ -524,7 +523,7 @@ discard block |
||
| 524 | 523 | * |
| 525 | 524 | * @since 1.7 |
| 526 | 525 | */ |
| 527 | - $required_fields = apply_filters( 'give_donation_form_required_fields', $required_fields, $form_id ); |
|
| 526 | + $required_fields = apply_filters('give_donation_form_required_fields', $required_fields, $form_id); |
|
| 528 | 527 | |
| 529 | 528 | return $required_fields; |
| 530 | 529 | |
@@ -539,16 +538,16 @@ discard block |
||
| 539 | 538 | * |
| 540 | 539 | * @return bool |
| 541 | 540 | */ |
| 542 | -function give_require_billing_address( $payment_mode ) { |
|
| 541 | +function give_require_billing_address($payment_mode) { |
|
| 543 | 542 | |
| 544 | 543 | $return = false; |
| 545 | 544 | |
| 546 | - if ( isset( $_POST['billing_country'] ) || did_action( "give_{$payment_mode}_cc_form" ) || did_action( 'give_cc_form' ) ) { |
|
| 545 | + if (isset($_POST['billing_country']) || did_action("give_{$payment_mode}_cc_form") || did_action('give_cc_form')) { |
|
| 547 | 546 | $return = true; |
| 548 | 547 | } |
| 549 | 548 | |
| 550 | 549 | // Let payment gateways and other extensions determine if address fields should be required. |
| 551 | - return apply_filters( 'give_require_billing_address', $return ); |
|
| 550 | + return apply_filters('give_require_billing_address', $return); |
|
| 552 | 551 | |
| 553 | 552 | } |
| 554 | 553 | |
@@ -562,42 +561,42 @@ discard block |
||
| 562 | 561 | function give_donation_form_validate_logged_in_user() { |
| 563 | 562 | global $user_ID; |
| 564 | 563 | |
| 565 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 564 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 566 | 565 | |
| 567 | 566 | // Start empty array to collect valid user data. |
| 568 | 567 | $valid_user_data = array( |
| 569 | 568 | // Assume there will be errors. |
| 570 | - 'user_id' => - 1, |
|
| 569 | + 'user_id' => -1, |
|
| 571 | 570 | ); |
| 572 | 571 | |
| 573 | 572 | // Verify there is a user_ID. |
| 574 | - if ( $user_ID > 0 ) { |
|
| 573 | + if ($user_ID > 0) { |
|
| 575 | 574 | // Get the logged in user data. |
| 576 | - $user_data = get_userdata( $user_ID ); |
|
| 575 | + $user_data = get_userdata($user_ID); |
|
| 577 | 576 | |
| 578 | 577 | // Loop through required fields and show error messages. |
| 579 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 580 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 581 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 578 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 579 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 580 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 582 | 581 | } |
| 583 | 582 | } |
| 584 | 583 | |
| 585 | 584 | // Verify data. |
| 586 | - if ( $user_data ) { |
|
| 585 | + if ($user_data) { |
|
| 587 | 586 | // Collected logged in user data. |
| 588 | 587 | $valid_user_data = array( |
| 589 | 588 | 'user_id' => $user_ID, |
| 590 | - 'user_email' => isset( $_POST['give_email'] ) ? sanitize_email( $_POST['give_email'] ) : $user_data->user_email, |
|
| 591 | - 'user_first' => isset( $_POST['give_first'] ) && ! empty( $_POST['give_first'] ) ? sanitize_text_field( $_POST['give_first'] ) : $user_data->first_name, |
|
| 592 | - 'user_last' => isset( $_POST['give_last'] ) && ! empty( $_POST['give_last'] ) ? sanitize_text_field( $_POST['give_last'] ) : $user_data->last_name, |
|
| 589 | + 'user_email' => isset($_POST['give_email']) ? sanitize_email($_POST['give_email']) : $user_data->user_email, |
|
| 590 | + 'user_first' => isset($_POST['give_first']) && ! empty($_POST['give_first']) ? sanitize_text_field($_POST['give_first']) : $user_data->first_name, |
|
| 591 | + 'user_last' => isset($_POST['give_last']) && ! empty($_POST['give_last']) ? sanitize_text_field($_POST['give_last']) : $user_data->last_name, |
|
| 593 | 592 | ); |
| 594 | 593 | |
| 595 | - if ( ! is_email( $valid_user_data['user_email'] ) ) { |
|
| 596 | - give_set_error( 'email_invalid', esc_html__( 'Invalid email.', 'give' ) ); |
|
| 594 | + if ( ! is_email($valid_user_data['user_email'])) { |
|
| 595 | + give_set_error('email_invalid', esc_html__('Invalid email.', 'give')); |
|
| 597 | 596 | } |
| 598 | 597 | } else { |
| 599 | 598 | // Set invalid user error. |
| 600 | - give_set_error( 'invalid_user', esc_html__( 'The user information is invalid.', 'give' ) ); |
|
| 599 | + give_set_error('invalid_user', esc_html__('The user information is invalid.', 'give')); |
|
| 601 | 600 | } |
| 602 | 601 | } |
| 603 | 602 | |
@@ -616,7 +615,7 @@ discard block |
||
| 616 | 615 | // Default user data. |
| 617 | 616 | $default_user_data = array( |
| 618 | 617 | 'give-form-id' => '', |
| 619 | - 'user_id' => - 1, // Assume there will be errors. |
|
| 618 | + 'user_id' => -1, // Assume there will be errors. |
|
| 620 | 619 | 'user_first' => '', |
| 621 | 620 | 'user_last' => '', |
| 622 | 621 | 'give_user_login' => false, |
@@ -626,14 +625,14 @@ discard block |
||
| 626 | 625 | ); |
| 627 | 626 | |
| 628 | 627 | // Get user data. |
| 629 | - $user_data = wp_parse_args( array_map( 'trim', give_clean( $_POST ) ), $default_user_data ); |
|
| 628 | + $user_data = wp_parse_args(array_map('trim', give_clean($_POST)), $default_user_data); |
|
| 630 | 629 | $registering_new_user = false; |
| 631 | - $form_id = absint( $user_data['give-form-id'] ); |
|
| 630 | + $form_id = absint($user_data['give-form-id']); |
|
| 632 | 631 | |
| 633 | 632 | // Start an empty array to collect valid user data. |
| 634 | 633 | $valid_user_data = array( |
| 635 | 634 | // Assume there will be errors. |
| 636 | - 'user_id' => - 1, |
|
| 635 | + 'user_id' => -1, |
|
| 637 | 636 | |
| 638 | 637 | // Get first name. |
| 639 | 638 | 'user_first' => $user_data['give_first'], |
@@ -643,25 +642,25 @@ discard block |
||
| 643 | 642 | ); |
| 644 | 643 | |
| 645 | 644 | // Loop through required fields and show error messages. |
| 646 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 647 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 648 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 645 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 646 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 647 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 649 | 648 | } |
| 650 | 649 | } |
| 651 | 650 | |
| 652 | 651 | // Check if we have an username to register. |
| 653 | - if ( give_validate_username( $user_data['give_user_login'] ) ) { |
|
| 652 | + if (give_validate_username($user_data['give_user_login'])) { |
|
| 654 | 653 | $registering_new_user = true; |
| 655 | 654 | $valid_user_data['user_login'] = $user_data['give_user_login']; |
| 656 | 655 | } |
| 657 | 656 | |
| 658 | 657 | // Check if we have an email to verify. |
| 659 | - if ( give_validate_user_email( $user_data['give_email'], $registering_new_user ) ) { |
|
| 658 | + if (give_validate_user_email($user_data['give_email'], $registering_new_user)) { |
|
| 660 | 659 | $valid_user_data['user_email'] = $user_data['give_email']; |
| 661 | 660 | } |
| 662 | 661 | |
| 663 | 662 | // Check password. |
| 664 | - if ( give_validate_user_password( $user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user ) ) { |
|
| 663 | + if (give_validate_user_password($user_data['give_user_pass'], $user_data['give_user_pass_confirm'], $registering_new_user)) { |
|
| 665 | 664 | // All is good to go. |
| 666 | 665 | $valid_user_data['user_pass'] = $user_data['give_user_pass']; |
| 667 | 666 | } |
@@ -681,36 +680,36 @@ discard block |
||
| 681 | 680 | // Start an array to collect valid user data. |
| 682 | 681 | $valid_user_data = array( |
| 683 | 682 | // Assume there will be errors. |
| 684 | - 'user_id' => - 1, |
|
| 683 | + 'user_id' => -1, |
|
| 685 | 684 | ); |
| 686 | 685 | |
| 687 | 686 | // Username. |
| 688 | - if ( ! isset( $_POST['give_user_login'] ) || $_POST['give_user_login'] == '' ) { |
|
| 689 | - give_set_error( 'must_log_in', __( 'You must register or login to complete your donation.', 'give' ) ); |
|
| 687 | + if ( ! isset($_POST['give_user_login']) || $_POST['give_user_login'] == '') { |
|
| 688 | + give_set_error('must_log_in', __('You must register or login to complete your donation.', 'give')); |
|
| 690 | 689 | |
| 691 | 690 | return $valid_user_data; |
| 692 | 691 | } |
| 693 | 692 | |
| 694 | 693 | // Get the user by login. |
| 695 | - $user_data = get_user_by( 'login', strip_tags( $_POST['give_user_login'] ) ); |
|
| 694 | + $user_data = get_user_by('login', strip_tags($_POST['give_user_login'])); |
|
| 696 | 695 | |
| 697 | 696 | // Check if user exists. |
| 698 | - if ( $user_data ) { |
|
| 697 | + if ($user_data) { |
|
| 699 | 698 | // Get password. |
| 700 | - $user_pass = isset( $_POST['give_user_pass'] ) ? $_POST['give_user_pass'] : false; |
|
| 699 | + $user_pass = isset($_POST['give_user_pass']) ? $_POST['give_user_pass'] : false; |
|
| 701 | 700 | |
| 702 | 701 | // Check user_pass. |
| 703 | - if ( $user_pass ) { |
|
| 702 | + if ($user_pass) { |
|
| 704 | 703 | // Check if password is valid. |
| 705 | - if ( ! wp_check_password( $user_pass, $user_data->user_pass, $user_data->ID ) ) { |
|
| 704 | + if ( ! wp_check_password($user_pass, $user_data->user_pass, $user_data->ID)) { |
|
| 706 | 705 | // Incorrect password. |
| 707 | 706 | give_set_error( |
| 708 | 707 | 'password_incorrect', |
| 709 | 708 | sprintf( |
| 710 | 709 | '%1$s <a href="%2$s">%3$s</a>', |
| 711 | - __( 'The password you entered is incorrect.', 'give' ), |
|
| 712 | - wp_lostpassword_url( "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]" ), |
|
| 713 | - __( 'Reset Password', 'give' ) |
|
| 710 | + __('The password you entered is incorrect.', 'give'), |
|
| 711 | + wp_lostpassword_url("http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"), |
|
| 712 | + __('Reset Password', 'give') |
|
| 714 | 713 | ) |
| 715 | 714 | ); |
| 716 | 715 | // All is correct. |
@@ -728,11 +727,11 @@ discard block |
||
| 728 | 727 | } |
| 729 | 728 | } else { |
| 730 | 729 | // Empty password. |
| 731 | - give_set_error( 'password_empty', __( 'Enter a password.', 'give' ) ); |
|
| 730 | + give_set_error('password_empty', __('Enter a password.', 'give')); |
|
| 732 | 731 | } |
| 733 | 732 | } else { |
| 734 | 733 | // No username. |
| 735 | - give_set_error( 'username_incorrect', __( 'The username you entered does not exist.', 'give' ) ); |
|
| 734 | + give_set_error('username_incorrect', __('The username you entered does not exist.', 'give')); |
|
| 736 | 735 | }// End if(). |
| 737 | 736 | |
| 738 | 737 | return $valid_user_data; |
@@ -747,7 +746,7 @@ discard block |
||
| 747 | 746 | */ |
| 748 | 747 | function give_donation_form_validate_guest_user() { |
| 749 | 748 | |
| 750 | - $form_id = isset( $_POST['give-form-id'] ) ? $_POST['give-form-id'] : ''; |
|
| 749 | + $form_id = isset($_POST['give-form-id']) ? $_POST['give-form-id'] : ''; |
|
| 751 | 750 | |
| 752 | 751 | // Start an array to collect valid user data. |
| 753 | 752 | $valid_user_data = array( |
@@ -756,38 +755,38 @@ discard block |
||
| 756 | 755 | ); |
| 757 | 756 | |
| 758 | 757 | // Show error message if user must be logged in. |
| 759 | - if ( give_logged_in_only( $form_id ) ) { |
|
| 760 | - give_set_error( 'logged_in_only', __( 'You must be logged in to donate.', 'give' ) ); |
|
| 758 | + if (give_logged_in_only($form_id)) { |
|
| 759 | + give_set_error('logged_in_only', __('You must be logged in to donate.', 'give')); |
|
| 761 | 760 | } |
| 762 | 761 | |
| 763 | 762 | // Get the guest email. |
| 764 | - $guest_email = isset( $_POST['give_email'] ) ? $_POST['give_email'] : false; |
|
| 763 | + $guest_email = isset($_POST['give_email']) ? $_POST['give_email'] : false; |
|
| 765 | 764 | |
| 766 | 765 | // Check email. |
| 767 | - if ( $guest_email && strlen( $guest_email ) > 0 ) { |
|
| 766 | + if ($guest_email && strlen($guest_email) > 0) { |
|
| 768 | 767 | // Validate email. |
| 769 | - if ( ! is_email( $guest_email ) ) { |
|
| 768 | + if ( ! is_email($guest_email)) { |
|
| 770 | 769 | // Invalid email. |
| 771 | - give_set_error( 'email_invalid', __( 'Invalid email.', 'give' ) ); |
|
| 770 | + give_set_error('email_invalid', __('Invalid email.', 'give')); |
|
| 772 | 771 | } else { |
| 773 | 772 | // All is good to go. |
| 774 | 773 | $valid_user_data['user_email'] = $guest_email; |
| 775 | 774 | |
| 776 | 775 | // Get user_id from donor if exist. |
| 777 | - $donor = new Give_Donor( $guest_email ); |
|
| 778 | - if ( $donor->id && $donor->user_id ) { |
|
| 776 | + $donor = new Give_Donor($guest_email); |
|
| 777 | + if ($donor->id && $donor->user_id) { |
|
| 779 | 778 | $valid_user_data['user_id'] = $donor->user_id; |
| 780 | 779 | } |
| 781 | 780 | } |
| 782 | 781 | } else { |
| 783 | 782 | // No email. |
| 784 | - give_set_error( 'email_empty', __( 'Enter an email.', 'give' ) ); |
|
| 783 | + give_set_error('email_empty', __('Enter an email.', 'give')); |
|
| 785 | 784 | } |
| 786 | 785 | |
| 787 | 786 | // Loop through required fields and show error messages. |
| 788 | - foreach ( give_get_required_fields( $form_id ) as $field_name => $value ) { |
|
| 789 | - if ( in_array( $value, give_get_required_fields( $form_id ) ) && empty( $_POST[ $field_name ] ) ) { |
|
| 790 | - give_set_error( $value['error_id'], $value['error_message'] ); |
|
| 787 | + foreach (give_get_required_fields($form_id) as $field_name => $value) { |
|
| 788 | + if (in_array($value, give_get_required_fields($form_id)) && empty($_POST[$field_name])) { |
|
| 789 | + give_set_error($value['error_id'], $value['error_message']); |
|
| 791 | 790 | } |
| 792 | 791 | } |
| 793 | 792 | |
@@ -803,36 +802,36 @@ discard block |
||
| 803 | 802 | * @since 1.0 |
| 804 | 803 | * @return integer |
| 805 | 804 | */ |
| 806 | -function give_register_and_login_new_user( $user_data = array() ) { |
|
| 805 | +function give_register_and_login_new_user($user_data = array()) { |
|
| 807 | 806 | // Verify the array. |
| 808 | - if ( empty( $user_data ) ) { |
|
| 809 | - return - 1; |
|
| 807 | + if (empty($user_data)) { |
|
| 808 | + return -1; |
|
| 810 | 809 | } |
| 811 | 810 | |
| 812 | - if ( give_get_errors() ) { |
|
| 813 | - return - 1; |
|
| 811 | + if (give_get_errors()) { |
|
| 812 | + return -1; |
|
| 814 | 813 | } |
| 815 | 814 | |
| 816 | - $user_args = apply_filters( 'give_insert_user_args', array( |
|
| 817 | - 'user_login' => isset( $user_data['user_login'] ) ? $user_data['user_login'] : '', |
|
| 818 | - 'user_pass' => isset( $user_data['user_pass'] ) ? $user_data['user_pass'] : '', |
|
| 819 | - 'user_email' => isset( $user_data['user_email'] ) ? $user_data['user_email'] : '', |
|
| 820 | - 'first_name' => isset( $user_data['user_first'] ) ? $user_data['user_first'] : '', |
|
| 821 | - 'last_name' => isset( $user_data['user_last'] ) ? $user_data['user_last'] : '', |
|
| 822 | - 'user_registered' => date( 'Y-m-d H:i:s' ), |
|
| 823 | - 'role' => give_get_option( 'donor_default_user_role', 'give_donor' ), |
|
| 824 | - ), $user_data ); |
|
| 815 | + $user_args = apply_filters('give_insert_user_args', array( |
|
| 816 | + 'user_login' => isset($user_data['user_login']) ? $user_data['user_login'] : '', |
|
| 817 | + 'user_pass' => isset($user_data['user_pass']) ? $user_data['user_pass'] : '', |
|
| 818 | + 'user_email' => isset($user_data['user_email']) ? $user_data['user_email'] : '', |
|
| 819 | + 'first_name' => isset($user_data['user_first']) ? $user_data['user_first'] : '', |
|
| 820 | + 'last_name' => isset($user_data['user_last']) ? $user_data['user_last'] : '', |
|
| 821 | + 'user_registered' => date('Y-m-d H:i:s'), |
|
| 822 | + 'role' => give_get_option('donor_default_user_role', 'give_donor'), |
|
| 823 | + ), $user_data); |
|
| 825 | 824 | |
| 826 | 825 | // Insert new user. |
| 827 | - $user_id = wp_insert_user( $user_args ); |
|
| 826 | + $user_id = wp_insert_user($user_args); |
|
| 828 | 827 | |
| 829 | 828 | // Validate inserted user. |
| 830 | - if ( is_wp_error( $user_id ) ) { |
|
| 831 | - return - 1; |
|
| 829 | + if (is_wp_error($user_id)) { |
|
| 830 | + return -1; |
|
| 832 | 831 | } |
| 833 | 832 | |
| 834 | 833 | // Allow themes and plugins to filter the user data. |
| 835 | - $user_data = apply_filters( 'give_insert_user_data', $user_data, $user_args ); |
|
| 834 | + $user_data = apply_filters('give_insert_user_data', $user_data, $user_args); |
|
| 836 | 835 | |
| 837 | 836 | /** |
| 838 | 837 | * Fires after inserting user. |
@@ -842,7 +841,7 @@ discard block |
||
| 842 | 841 | * @param int $user_id User id. |
| 843 | 842 | * @param array $user_data Array containing user data. |
| 844 | 843 | */ |
| 845 | - do_action( 'give_insert_user', $user_id, $user_data ); |
|
| 844 | + do_action('give_insert_user', $user_id, $user_data); |
|
| 846 | 845 | |
| 847 | 846 | /** |
| 848 | 847 | * Filter allow user to alter if user when to login or not when user is register for the first time. |
@@ -851,9 +850,9 @@ discard block |
||
| 851 | 850 | * |
| 852 | 851 | * return bool True if login with registration and False if only want to register. |
| 853 | 852 | */ |
| 854 | - if ( true === (bool) apply_filters( 'give_log_user_in_on_register', true ) ) { |
|
| 853 | + if (true === (bool) apply_filters('give_log_user_in_on_register', true)) { |
|
| 855 | 854 | // Login new user. |
| 856 | - give_log_user_in( $user_id, $user_data['user_login'], $user_data['user_pass'] ); |
|
| 855 | + give_log_user_in($user_id, $user_data['user_login'], $user_data['user_pass']); |
|
| 857 | 856 | } |
| 858 | 857 | |
| 859 | 858 | // Return user id. |
@@ -869,27 +868,27 @@ discard block |
||
| 869 | 868 | * @since 1.0 |
| 870 | 869 | * @return array|bool |
| 871 | 870 | */ |
| 872 | -function give_get_donation_form_user( $valid_data = array() ) { |
|
| 871 | +function give_get_donation_form_user($valid_data = array()) { |
|
| 873 | 872 | |
| 874 | 873 | // Initialize user. |
| 875 | 874 | $user = false; |
| 876 | - $is_ajax = defined( 'DOING_AJAX' ) && DOING_AJAX; |
|
| 875 | + $is_ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 877 | 876 | |
| 878 | - if ( $is_ajax ) { |
|
| 877 | + if ($is_ajax) { |
|
| 879 | 878 | // Do not create or login the user during the ajax submission (check for errors only). |
| 880 | 879 | return true; |
| 881 | - } elseif ( is_user_logged_in() ) { |
|
| 880 | + } elseif (is_user_logged_in()) { |
|
| 882 | 881 | // Set the valid user as the logged in collected data. |
| 883 | 882 | $user = $valid_data['logged_in_user']; |
| 884 | - } elseif ( $valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true ) { |
|
| 883 | + } elseif ($valid_data['need_new_user'] === true || $valid_data['need_user_login'] === true) { |
|
| 885 | 884 | // New user registration. |
| 886 | - if ( $valid_data['need_new_user'] === true ) { |
|
| 885 | + if ($valid_data['need_new_user'] === true) { |
|
| 887 | 886 | // Set user. |
| 888 | 887 | $user = $valid_data['new_user_data']; |
| 889 | 888 | // Register and login new user. |
| 890 | - $user['user_id'] = give_register_and_login_new_user( $user ); |
|
| 889 | + $user['user_id'] = give_register_and_login_new_user($user); |
|
| 891 | 890 | // User login |
| 892 | - } elseif ( $valid_data['need_user_login'] === true && ! $is_ajax ) { |
|
| 891 | + } elseif ($valid_data['need_user_login'] === true && ! $is_ajax) { |
|
| 893 | 892 | |
| 894 | 893 | /** |
| 895 | 894 | * The login form is now processed in the give_process_donation_login() function. |
@@ -901,48 +900,48 @@ discard block |
||
| 901 | 900 | // Set user. |
| 902 | 901 | $user = $valid_data['login_user_data']; |
| 903 | 902 | // Login user. |
| 904 | - give_log_user_in( $user['user_id'], $user['user_login'], $user['user_pass'] ); |
|
| 903 | + give_log_user_in($user['user_id'], $user['user_login'], $user['user_pass']); |
|
| 905 | 904 | } |
| 906 | 905 | } |
| 907 | 906 | |
| 908 | 907 | // Check guest checkout. |
| 909 | - if ( false === $user && false === give_logged_in_only( $_POST['give-form-id'] ) ) { |
|
| 908 | + if (false === $user && false === give_logged_in_only($_POST['give-form-id'])) { |
|
| 910 | 909 | // Set user |
| 911 | 910 | $user = $valid_data['guest_user_data']; |
| 912 | 911 | } |
| 913 | 912 | |
| 914 | 913 | // Verify we have an user. |
| 915 | - if ( false === $user || empty( $user ) ) { |
|
| 914 | + if (false === $user || empty($user)) { |
|
| 916 | 915 | // Return false. |
| 917 | 916 | return false; |
| 918 | 917 | } |
| 919 | 918 | |
| 920 | 919 | // Get user first name. |
| 921 | - if ( ! isset( $user['user_first'] ) || strlen( trim( $user['user_first'] ) ) < 1 ) { |
|
| 922 | - $user['user_first'] = isset( $_POST['give_first'] ) ? strip_tags( trim( $_POST['give_first'] ) ) : ''; |
|
| 920 | + if ( ! isset($user['user_first']) || strlen(trim($user['user_first'])) < 1) { |
|
| 921 | + $user['user_first'] = isset($_POST['give_first']) ? strip_tags(trim($_POST['give_first'])) : ''; |
|
| 923 | 922 | } |
| 924 | 923 | |
| 925 | 924 | // Get user last name. |
| 926 | - if ( ! isset( $user['user_last'] ) || strlen( trim( $user['user_last'] ) ) < 1 ) { |
|
| 927 | - $user['user_last'] = isset( $_POST['give_last'] ) ? strip_tags( trim( $_POST['give_last'] ) ) : ''; |
|
| 925 | + if ( ! isset($user['user_last']) || strlen(trim($user['user_last'])) < 1) { |
|
| 926 | + $user['user_last'] = isset($_POST['give_last']) ? strip_tags(trim($_POST['give_last'])) : ''; |
|
| 928 | 927 | } |
| 929 | 928 | |
| 930 | 929 | // Get the user's billing address details. |
| 931 | 930 | $user['address'] = array(); |
| 932 | - $user['address']['line1'] = ! empty( $_POST['card_address'] ) ? give_clean( $_POST['card_address'] ) : false; |
|
| 933 | - $user['address']['line2'] = ! empty( $_POST['card_address_2'] ) ? give_clean( $_POST['card_address_2'] ) : false; |
|
| 934 | - $user['address']['city'] = ! empty( $_POST['card_city'] ) ? give_clean( $_POST['card_city'] ) : false; |
|
| 935 | - $user['address']['state'] = ! empty( $_POST['card_state'] ) ? give_clean( $_POST['card_state'] ) : false; |
|
| 936 | - $user['address']['zip'] = ! empty( $_POST['card_zip'] ) ? give_clean( $_POST['card_zip'] ) : false; |
|
| 937 | - $user['address']['country'] = ! empty( $_POST['billing_country'] ) ? give_clean( $_POST['billing_country'] ) : false; |
|
| 938 | - |
|
| 939 | - if ( empty( $user['address']['country'] ) ) { |
|
| 931 | + $user['address']['line1'] = ! empty($_POST['card_address']) ? give_clean($_POST['card_address']) : false; |
|
| 932 | + $user['address']['line2'] = ! empty($_POST['card_address_2']) ? give_clean($_POST['card_address_2']) : false; |
|
| 933 | + $user['address']['city'] = ! empty($_POST['card_city']) ? give_clean($_POST['card_city']) : false; |
|
| 934 | + $user['address']['state'] = ! empty($_POST['card_state']) ? give_clean($_POST['card_state']) : false; |
|
| 935 | + $user['address']['zip'] = ! empty($_POST['card_zip']) ? give_clean($_POST['card_zip']) : false; |
|
| 936 | + $user['address']['country'] = ! empty($_POST['billing_country']) ? give_clean($_POST['billing_country']) : false; |
|
| 937 | + |
|
| 938 | + if (empty($user['address']['country'])) { |
|
| 940 | 939 | $user['address'] = false; |
| 941 | 940 | } // End if(). |
| 942 | 941 | |
| 943 | - if ( ! empty( $user['user_id'] ) && $user['user_id'] > 0 && ! empty( $user['address'] ) ) { |
|
| 942 | + if ( ! empty($user['user_id']) && $user['user_id'] > 0 && ! empty($user['address'])) { |
|
| 944 | 943 | // Store the address in the user's meta so the donation form can be pre-populated with it on return donation. |
| 945 | - update_user_meta( $user['user_id'], '_give_user_address', $user['address'] ); |
|
| 944 | + update_user_meta($user['user_id'], '_give_user_address', $user['address']); |
|
| 946 | 945 | } |
| 947 | 946 | |
| 948 | 947 | // Return valid user. |
@@ -961,16 +960,16 @@ discard block |
||
| 961 | 960 | $card_data = give_get_donation_cc_info(); |
| 962 | 961 | |
| 963 | 962 | // Validate the card zip. |
| 964 | - if ( ! empty( $card_data['card_zip'] ) ) { |
|
| 965 | - if ( ! give_donation_form_validate_cc_zip( $card_data['card_zip'], $card_data['card_country'] ) ) { |
|
| 966 | - give_set_error( 'invalid_cc_zip', __( 'The zip / postal code you entered for your billing address is invalid.', 'give' ) ); |
|
| 963 | + if ( ! empty($card_data['card_zip'])) { |
|
| 964 | + if ( ! give_donation_form_validate_cc_zip($card_data['card_zip'], $card_data['card_country'])) { |
|
| 965 | + give_set_error('invalid_cc_zip', __('The zip / postal code you entered for your billing address is invalid.', 'give')); |
|
| 967 | 966 | } |
| 968 | 967 | } |
| 969 | 968 | |
| 970 | 969 | // Ensure no spaces. |
| 971 | - if ( ! empty( $card_data['card_number'] ) ) { |
|
| 972 | - $card_data['card_number'] = str_replace( '+', '', $card_data['card_number'] ); // no "+" signs |
|
| 973 | - $card_data['card_number'] = str_replace( ' ', '', $card_data['card_number'] ); // No spaces |
|
| 970 | + if ( ! empty($card_data['card_number'])) { |
|
| 971 | + $card_data['card_number'] = str_replace('+', '', $card_data['card_number']); // no "+" signs |
|
| 972 | + $card_data['card_number'] = str_replace(' ', '', $card_data['card_number']); // No spaces |
|
| 974 | 973 | } |
| 975 | 974 | |
| 976 | 975 | // This should validate card numbers at some point too. |
@@ -987,17 +986,17 @@ discard block |
||
| 987 | 986 | function give_get_donation_cc_info() { |
| 988 | 987 | |
| 989 | 988 | $cc_info = array(); |
| 990 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 991 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 992 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 993 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 994 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 995 | - $cc_info['card_address'] = isset( $_POST['card_address'] ) ? sanitize_text_field( $_POST['card_address'] ) : ''; |
|
| 996 | - $cc_info['card_address_2'] = isset( $_POST['card_address_2'] ) ? sanitize_text_field( $_POST['card_address_2'] ) : ''; |
|
| 997 | - $cc_info['card_city'] = isset( $_POST['card_city'] ) ? sanitize_text_field( $_POST['card_city'] ) : ''; |
|
| 998 | - $cc_info['card_state'] = isset( $_POST['card_state'] ) ? sanitize_text_field( $_POST['card_state'] ) : ''; |
|
| 999 | - $cc_info['card_country'] = isset( $_POST['billing_country'] ) ? sanitize_text_field( $_POST['billing_country'] ) : ''; |
|
| 1000 | - $cc_info['card_zip'] = isset( $_POST['card_zip'] ) ? sanitize_text_field( $_POST['card_zip'] ) : ''; |
|
| 989 | + $cc_info['card_name'] = isset($_POST['card_name']) ? sanitize_text_field($_POST['card_name']) : ''; |
|
| 990 | + $cc_info['card_number'] = isset($_POST['card_number']) ? sanitize_text_field($_POST['card_number']) : ''; |
|
| 991 | + $cc_info['card_cvc'] = isset($_POST['card_cvc']) ? sanitize_text_field($_POST['card_cvc']) : ''; |
|
| 992 | + $cc_info['card_exp_month'] = isset($_POST['card_exp_month']) ? sanitize_text_field($_POST['card_exp_month']) : ''; |
|
| 993 | + $cc_info['card_exp_year'] = isset($_POST['card_exp_year']) ? sanitize_text_field($_POST['card_exp_year']) : ''; |
|
| 994 | + $cc_info['card_address'] = isset($_POST['card_address']) ? sanitize_text_field($_POST['card_address']) : ''; |
|
| 995 | + $cc_info['card_address_2'] = isset($_POST['card_address_2']) ? sanitize_text_field($_POST['card_address_2']) : ''; |
|
| 996 | + $cc_info['card_city'] = isset($_POST['card_city']) ? sanitize_text_field($_POST['card_city']) : ''; |
|
| 997 | + $cc_info['card_state'] = isset($_POST['card_state']) ? sanitize_text_field($_POST['card_state']) : ''; |
|
| 998 | + $cc_info['card_country'] = isset($_POST['billing_country']) ? sanitize_text_field($_POST['billing_country']) : ''; |
|
| 999 | + $cc_info['card_zip'] = isset($_POST['card_zip']) ? sanitize_text_field($_POST['card_zip']) : ''; |
|
| 1001 | 1000 | |
| 1002 | 1001 | // Return cc info. |
| 1003 | 1002 | return $cc_info; |
@@ -1013,14 +1012,14 @@ discard block |
||
| 1013 | 1012 | * |
| 1014 | 1013 | * @return bool|mixed |
| 1015 | 1014 | */ |
| 1016 | -function give_donation_form_validate_cc_zip( $zip = 0, $country_code = '' ) { |
|
| 1015 | +function give_donation_form_validate_cc_zip($zip = 0, $country_code = '') { |
|
| 1017 | 1016 | $ret = false; |
| 1018 | 1017 | |
| 1019 | - if ( empty( $zip ) || empty( $country_code ) ) { |
|
| 1018 | + if (empty($zip) || empty($country_code)) { |
|
| 1020 | 1019 | return $ret; |
| 1021 | 1020 | } |
| 1022 | 1021 | |
| 1023 | - $country_code = strtoupper( $country_code ); |
|
| 1022 | + $country_code = strtoupper($country_code); |
|
| 1024 | 1023 | |
| 1025 | 1024 | $zip_regex = array( |
| 1026 | 1025 | 'AD' => 'AD\d{3}', |
@@ -1180,11 +1179,11 @@ discard block |
||
| 1180 | 1179 | 'ZM' => '\d{5}', |
| 1181 | 1180 | ); |
| 1182 | 1181 | |
| 1183 | - if ( ! isset( $zip_regex[ $country_code ] ) || preg_match( '/' . $zip_regex[ $country_code ] . '/i', $zip ) ) { |
|
| 1182 | + if ( ! isset($zip_regex[$country_code]) || preg_match('/'.$zip_regex[$country_code].'/i', $zip)) { |
|
| 1184 | 1183 | $ret = true; |
| 1185 | 1184 | } |
| 1186 | 1185 | |
| 1187 | - return apply_filters( 'give_is_zip_valid', $ret, $zip, $country_code ); |
|
| 1186 | + return apply_filters('give_is_zip_valid', $ret, $zip, $country_code); |
|
| 1188 | 1187 | } |
| 1189 | 1188 | |
| 1190 | 1189 | |
@@ -1198,33 +1197,33 @@ discard block |
||
| 1198 | 1197 | * |
| 1199 | 1198 | * @return bool |
| 1200 | 1199 | */ |
| 1201 | -function give_validate_multi_donation_form_level( $valid_data, $data ) { |
|
| 1200 | +function give_validate_multi_donation_form_level($valid_data, $data) { |
|
| 1202 | 1201 | /* @var Give_Donate_Form $form */ |
| 1203 | - $form = new Give_Donate_Form( $data['give-form-id'] ); |
|
| 1202 | + $form = new Give_Donate_Form($data['give-form-id']); |
|
| 1204 | 1203 | |
| 1205 | 1204 | $donation_level_matched = false; |
| 1206 | 1205 | |
| 1207 | - if ( $form->is_multi_type_donation_form() ) { |
|
| 1206 | + if ($form->is_multi_type_donation_form()) { |
|
| 1208 | 1207 | |
| 1209 | 1208 | // Bailout. |
| 1210 | - if ( ! ( $variable_prices = $form->get_prices() ) ) { |
|
| 1209 | + if ( ! ($variable_prices = $form->get_prices())) { |
|
| 1211 | 1210 | return false; |
| 1212 | 1211 | } |
| 1213 | 1212 | |
| 1214 | 1213 | // Sanitize donation amount. |
| 1215 | - $data['give-amount'] = give_maybe_sanitize_amount( $data['give-amount'] ); |
|
| 1214 | + $data['give-amount'] = give_maybe_sanitize_amount($data['give-amount']); |
|
| 1216 | 1215 | |
| 1217 | - if ( $data['give-amount'] === give_maybe_sanitize_amount( give_get_price_option_amount( $data['give-form-id'], $data['give-price-id'] ) ) ) { |
|
| 1216 | + if ($data['give-amount'] === give_maybe_sanitize_amount(give_get_price_option_amount($data['give-form-id'], $data['give-price-id']))) { |
|
| 1218 | 1217 | return true; |
| 1219 | 1218 | } |
| 1220 | 1219 | |
| 1221 | 1220 | // Find correct donation level from all donation levels. |
| 1222 | - foreach ( $variable_prices as $variable_price ) { |
|
| 1221 | + foreach ($variable_prices as $variable_price) { |
|
| 1223 | 1222 | // Sanitize level amount. |
| 1224 | - $variable_price['_give_amount'] = give_maybe_sanitize_amount( $variable_price['_give_amount'] ); |
|
| 1223 | + $variable_price['_give_amount'] = give_maybe_sanitize_amount($variable_price['_give_amount']); |
|
| 1225 | 1224 | |
| 1226 | 1225 | // Set first match donation level ID. |
| 1227 | - if ( $data['give-amount'] === $variable_price['_give_amount'] ) { |
|
| 1226 | + if ($data['give-amount'] === $variable_price['_give_amount']) { |
|
| 1228 | 1227 | $_POST['give-price-id'] = $variable_price['_give_id']['level_id']; |
| 1229 | 1228 | $donation_level_matched = true; |
| 1230 | 1229 | break; |
@@ -1235,19 +1234,19 @@ discard block |
||
| 1235 | 1234 | // If yes then set price id to custom if amount is greater then custom minimum amount (if any). |
| 1236 | 1235 | if ( |
| 1237 | 1236 | ! $donation_level_matched |
| 1238 | - && ( give_is_setting_enabled( give_get_meta( $data['give-form-id'], '_give_custom_amount', true ) ) ) |
|
| 1237 | + && (give_is_setting_enabled(give_get_meta($data['give-form-id'], '_give_custom_amount', true))) |
|
| 1239 | 1238 | ) { |
| 1240 | 1239 | // Sanitize custom minimum amount. |
| 1241 | - $custom_minimum_amount = give_maybe_sanitize_amount( give_get_meta( $data['give-form-id'], '_give_custom_amount_minimum', true ) ); |
|
| 1240 | + $custom_minimum_amount = give_maybe_sanitize_amount(give_get_meta($data['give-form-id'], '_give_custom_amount_minimum', true)); |
|
| 1242 | 1241 | |
| 1243 | - if ( $data['give-amount'] >= $custom_minimum_amount ) { |
|
| 1242 | + if ($data['give-amount'] >= $custom_minimum_amount) { |
|
| 1244 | 1243 | $_POST['give-price-id'] = 'custom'; |
| 1245 | 1244 | $donation_level_matched = true; |
| 1246 | 1245 | } |
| 1247 | 1246 | } |
| 1248 | 1247 | }// End if(). |
| 1249 | 1248 | |
| 1250 | - return ( $donation_level_matched ? true : false ); |
|
| 1249 | + return ($donation_level_matched ? true : false); |
|
| 1251 | 1250 | } |
| 1252 | 1251 | |
| 1253 | -add_action( 'give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2 ); |
|
| 1252 | +add_action('give_checkout_error_checks', 'give_validate_multi_donation_form_level', 10, 2); |
|
@@ -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 | |
@@ -26,15 +26,15 @@ discard block |
||
| 26 | 26 | * @global $wpdb |
| 27 | 27 | * @return void |
| 28 | 28 | */ |
| 29 | -function give_install( $network_wide = false ) { |
|
| 29 | +function give_install($network_wide = false) { |
|
| 30 | 30 | |
| 31 | 31 | global $wpdb; |
| 32 | 32 | |
| 33 | - if ( is_multisite() && $network_wide ) { |
|
| 33 | + if (is_multisite() && $network_wide) { |
|
| 34 | 34 | |
| 35 | - foreach ( $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs LIMIT 100" ) as $blog_id ) { |
|
| 35 | + foreach ($wpdb->get_col("SELECT blog_id FROM $wpdb->blogs LIMIT 100") as $blog_id) { |
|
| 36 | 36 | |
| 37 | - switch_to_blog( $blog_id ); |
|
| 37 | + switch_to_blog($blog_id); |
|
| 38 | 38 | give_run_install(); |
| 39 | 39 | restore_current_blog(); |
| 40 | 40 | |
@@ -61,31 +61,31 @@ discard block |
||
| 61 | 61 | give_setup_post_types(); |
| 62 | 62 | |
| 63 | 63 | // Add Upgraded From Option. |
| 64 | - $current_version = get_option( 'give_version' ); |
|
| 65 | - if ( $current_version ) { |
|
| 66 | - update_option( 'give_version_upgraded_from', $current_version ); |
|
| 64 | + $current_version = get_option('give_version'); |
|
| 65 | + if ($current_version) { |
|
| 66 | + update_option('give_version_upgraded_from', $current_version); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | 69 | // Setup some default options. |
| 70 | 70 | $options = array(); |
| 71 | 71 | |
| 72 | 72 | //Fresh Install? Setup Test Mode, Base Country (US), Test Gateway, Currency. |
| 73 | - if ( empty( $current_version ) ) { |
|
| 74 | - $options = array_merge( $options, give_get_default_settings() ); |
|
| 73 | + if (empty($current_version)) { |
|
| 74 | + $options = array_merge($options, give_get_default_settings()); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | // Populate the default values. |
| 78 | - update_option( 'give_settings', array_merge( $give_options, $options ) ); |
|
| 78 | + update_option('give_settings', array_merge($give_options, $options)); |
|
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | 81 | * Run plugin upgrades. |
| 82 | 82 | * |
| 83 | 83 | * @since 1.8 |
| 84 | 84 | */ |
| 85 | - do_action( 'give_upgrades' ); |
|
| 85 | + do_action('give_upgrades'); |
|
| 86 | 86 | |
| 87 | - if ( GIVE_VERSION !== get_option( 'give_version' ) ) { |
|
| 88 | - update_option( 'give_version', GIVE_VERSION ); |
|
| 87 | + if (GIVE_VERSION !== get_option('give_version')) { |
|
| 88 | + update_option('give_version', GIVE_VERSION); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | // Create Give roles. |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // Set api version, end point and refresh permalink. |
| 97 | 97 | $api = new Give_API(); |
| 98 | 98 | $api->add_endpoint(); |
| 99 | - update_option( 'give_default_api_version', 'v' . $api->get_version() ); |
|
| 99 | + update_option('give_default_api_version', 'v'.$api->get_version()); |
|
| 100 | 100 | |
| 101 | 101 | flush_rewrite_rules(); |
| 102 | 102 | |
@@ -105,11 +105,11 @@ discard block |
||
| 105 | 105 | $give_sessions->use_php_sessions(); |
| 106 | 106 | |
| 107 | 107 | // Add a temporary option to note that Give pages have been created. |
| 108 | - Give_Cache::set( '_give_installed', $options, 30, true ); |
|
| 108 | + Give_Cache::set('_give_installed', $options, 30, true); |
|
| 109 | 109 | |
| 110 | - if ( ! $current_version ) { |
|
| 110 | + if ( ! $current_version) { |
|
| 111 | 111 | |
| 112 | - require_once GIVE_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php'; |
|
| 112 | + require_once GIVE_PLUGIN_DIR.'includes/admin/upgrades/upgrade-functions.php'; |
|
| 113 | 113 | |
| 114 | 114 | // When new upgrade routines are added, mark them as complete on fresh install. |
| 115 | 115 | $upgrade_routines = array( |
@@ -125,18 +125,18 @@ discard block |
||
| 125 | 125 | 'v1813_update_donor_user_roles' |
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | - foreach ( $upgrade_routines as $upgrade ) { |
|
| 129 | - give_set_upgrade_complete( $upgrade ); |
|
| 128 | + foreach ($upgrade_routines as $upgrade) { |
|
| 129 | + give_set_upgrade_complete($upgrade); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | // Bail if activating from network, or bulk. |
| 134 | - if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) { |
|
| 134 | + if (is_network_admin() || isset($_GET['activate-multi'])) { |
|
| 135 | 135 | return; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | // Add the transient to redirect. |
| 139 | - Give_Cache::set( '_give_activation_redirect', true, 30, true ); |
|
| 139 | + Give_Cache::set('_give_activation_redirect', true, 30, true); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | /** |
@@ -153,11 +153,11 @@ discard block |
||
| 153 | 153 | * @param int $site_id The Site ID. |
| 154 | 154 | * @param array $meta Blog Meta. |
| 155 | 155 | */ |
| 156 | -function give_on_create_blog( $blog_id, $user_id, $domain, $path, $site_id, $meta ) { |
|
| 156 | +function give_on_create_blog($blog_id, $user_id, $domain, $path, $site_id, $meta) { |
|
| 157 | 157 | |
| 158 | - if ( is_plugin_active_for_network( GIVE_PLUGIN_BASENAME ) ) { |
|
| 158 | + if (is_plugin_active_for_network(GIVE_PLUGIN_BASENAME)) { |
|
| 159 | 159 | |
| 160 | - switch_to_blog( $blog_id ); |
|
| 160 | + switch_to_blog($blog_id); |
|
| 161 | 161 | give_install(); |
| 162 | 162 | restore_current_blog(); |
| 163 | 163 | |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | -add_action( 'wpmu_new_blog', 'give_on_create_blog', 10, 6 ); |
|
| 168 | +add_action('wpmu_new_blog', 'give_on_create_blog', 10, 6); |
|
| 169 | 169 | |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -178,13 +178,13 @@ discard block |
||
| 178 | 178 | * |
| 179 | 179 | * @return array The tables to drop. |
| 180 | 180 | */ |
| 181 | -function give_wpmu_drop_tables( $tables, $blog_id ) { |
|
| 181 | +function give_wpmu_drop_tables($tables, $blog_id) { |
|
| 182 | 182 | |
| 183 | - switch_to_blog( $blog_id ); |
|
| 183 | + switch_to_blog($blog_id); |
|
| 184 | 184 | $donors_db = new Give_DB_Donors(); |
| 185 | 185 | $donor_meta_db = new Give_DB_Donor_Meta(); |
| 186 | 186 | |
| 187 | - if ( $donors_db->installed() ) { |
|
| 187 | + if ($donors_db->installed()) { |
|
| 188 | 188 | $tables[] = $donors_db->table_name; |
| 189 | 189 | $tables[] = $donor_meta_db->table_name; |
| 190 | 190 | } |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | |
| 195 | 195 | } |
| 196 | 196 | |
| 197 | -add_filter( 'wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2 ); |
|
| 197 | +add_filter('wpmu_drop_tables', 'give_wpmu_drop_tables', 10, 2); |
|
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | 200 | * Post-installation |
@@ -206,16 +206,16 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | function give_after_install() { |
| 208 | 208 | |
| 209 | - if ( ! is_admin() ) { |
|
| 209 | + if ( ! is_admin()) { |
|
| 210 | 210 | return; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | - $give_options = Give_Cache::get( '_give_installed', true ); |
|
| 214 | - $give_table_check = get_option( '_give_table_check', false ); |
|
| 213 | + $give_options = Give_Cache::get('_give_installed', true); |
|
| 214 | + $give_table_check = get_option('_give_table_check', false); |
|
| 215 | 215 | |
| 216 | - if ( false === $give_table_check || current_time( 'timestamp' ) > $give_table_check ) { |
|
| 216 | + if (false === $give_table_check || current_time('timestamp') > $give_table_check) { |
|
| 217 | 217 | |
| 218 | - if ( ! @Give()->donor_meta->installed() ) { |
|
| 218 | + if ( ! @Give()->donor_meta->installed()) { |
|
| 219 | 219 | |
| 220 | 220 | // Create the donor meta database. |
| 221 | 221 | // (this ensures it creates it on multisite instances where it is network activated). |
@@ -223,7 +223,7 @@ discard block |
||
| 223 | 223 | |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - if ( ! @Give()->donors->installed() ) { |
|
| 226 | + if ( ! @Give()->donors->installed()) { |
|
| 227 | 227 | // Create the donor database. |
| 228 | 228 | // (this ensures it creates it on multisite instances where it is network activated). |
| 229 | 229 | @Give()->donors->create_table(); |
@@ -235,22 +235,22 @@ discard block |
||
| 235 | 235 | * |
| 236 | 236 | * @param array $give_options Give plugin options. |
| 237 | 237 | */ |
| 238 | - do_action( 'give_after_install', $give_options ); |
|
| 238 | + do_action('give_after_install', $give_options); |
|
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - update_option( '_give_table_check', ( current_time( 'timestamp' ) + WEEK_IN_SECONDS ) ); |
|
| 241 | + update_option('_give_table_check', (current_time('timestamp') + WEEK_IN_SECONDS)); |
|
| 242 | 242 | |
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | // Delete the transient |
| 246 | - if ( false !== $give_options ) { |
|
| 247 | - Give_Cache::delete( Give_Cache::get_key( '_give_installed' ) ); |
|
| 246 | + if (false !== $give_options) { |
|
| 247 | + Give_Cache::delete(Give_Cache::get_key('_give_installed')); |
|
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | |
| 251 | 251 | } |
| 252 | 252 | |
| 253 | -add_action( 'admin_init', 'give_after_install' ); |
|
| 253 | +add_action('admin_init', 'give_after_install'); |
|
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -265,11 +265,11 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | global $wp_roles; |
| 267 | 267 | |
| 268 | - if ( ! is_object( $wp_roles ) ) { |
|
| 268 | + if ( ! is_object($wp_roles)) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - if ( ! array_key_exists( 'give_manager', $wp_roles->roles ) ) { |
|
| 272 | + if ( ! array_key_exists('give_manager', $wp_roles->roles)) { |
|
| 273 | 273 | |
| 274 | 274 | // Create Give plugin roles |
| 275 | 275 | $roles = new Give_Roles(); |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | -add_action( 'admin_init', 'give_install_roles_on_network' ); |
|
| 283 | +add_action('admin_init', 'give_install_roles_on_network'); |
|
| 284 | 284 | |
| 285 | 285 | /** |
| 286 | 286 | * Default core setting values. |
@@ -318,14 +318,14 @@ discard block |
||
| 318 | 318 | 'uninstall_on_delete' => 'disabled', |
| 319 | 319 | 'the_content_filter' => 'enabled', |
| 320 | 320 | 'scripts_footer' => 'disabled', |
| 321 | - 'agree_to_terms_label' => __( 'Agree to Terms?', 'give' ), |
|
| 321 | + 'agree_to_terms_label' => __('Agree to Terms?', 'give'), |
|
| 322 | 322 | 'agreement_text' => give_get_default_agreement_text(), |
| 323 | 323 | |
| 324 | 324 | // Paypal IPN verification. |
| 325 | 325 | 'paypal_verification' => 'enabled', |
| 326 | 326 | |
| 327 | 327 | // Default is manual gateway. |
| 328 | - 'gateways' => array( 'manual' => 1, 'offline' => 1 ), |
|
| 328 | + 'gateways' => array('manual' => 1, 'offline' => 1), |
|
| 329 | 329 | 'default_gateway' => 'manual', |
| 330 | 330 | |
| 331 | 331 | // Offline gateway setup. |
@@ -353,7 +353,7 @@ discard block |
||
| 353 | 353 | */ |
| 354 | 354 | function give_get_default_agreement_text() { |
| 355 | 355 | |
| 356 | - $org_name = get_bloginfo( 'name' ); |
|
| 356 | + $org_name = get_bloginfo('name'); |
|
| 357 | 357 | |
| 358 | 358 | $agreement = sprintf( |
| 359 | 359 | '<p>Acceptance of any contribution, gift or grant is at the discretion of the %1$s. The %1$s will not accept any gift unless it can be used or expended consistently with the purpose and mission of the %1$s.</p> |
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $org_name |
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | - return apply_filters( 'give_get_default_agreement_text', $agreement, $org_name ); |
|
| 370 | + return apply_filters('give_get_default_agreement_text', $agreement, $org_name); |
|
| 371 | 371 | } |
| 372 | 372 | |
| 373 | 373 | |
@@ -376,22 +376,22 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @since 1.8.11 |
| 378 | 378 | */ |
| 379 | -function give_create_pages(){ |
|
| 379 | +function give_create_pages() { |
|
| 380 | 380 | |
| 381 | 381 | // Bailout if pages already created. |
| 382 | - if( get_option( 'give_install_pages_created') ) { |
|
| 382 | + if (get_option('give_install_pages_created')) { |
|
| 383 | 383 | return false; |
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | $options = array(); |
| 387 | 387 | |
| 388 | 388 | // Checks if the Success Page option exists AND that the page exists. |
| 389 | - if ( ! get_post( give_get_option( 'success_page' ) ) ) { |
|
| 389 | + if ( ! get_post(give_get_option('success_page'))) { |
|
| 390 | 390 | |
| 391 | 391 | // Donation Confirmation (Success) Page |
| 392 | 392 | $success = wp_insert_post( |
| 393 | 393 | array( |
| 394 | - 'post_title' => esc_html__( 'Donation Confirmation', 'give' ), |
|
| 394 | + 'post_title' => esc_html__('Donation Confirmation', 'give'), |
|
| 395 | 395 | 'post_content' => '[give_receipt]', |
| 396 | 396 | 'post_status' => 'publish', |
| 397 | 397 | 'post_author' => 1, |
@@ -405,13 +405,13 @@ discard block |
||
| 405 | 405 | } |
| 406 | 406 | |
| 407 | 407 | // Checks if the Failure Page option exists AND that the page exists. |
| 408 | - if ( ! get_post( give_get_option( 'failure_page' ) ) ) { |
|
| 408 | + if ( ! get_post(give_get_option('failure_page'))) { |
|
| 409 | 409 | |
| 410 | 410 | // Failed Donation Page |
| 411 | 411 | $failed = wp_insert_post( |
| 412 | 412 | array( |
| 413 | - 'post_title' => esc_html__( 'Donation Failed', 'give' ), |
|
| 414 | - 'post_content' => esc_html__( 'We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give' ), |
|
| 413 | + 'post_title' => esc_html__('Donation Failed', 'give'), |
|
| 414 | + 'post_content' => esc_html__('We\'re sorry, your donation failed to process. Please try again or contact site support.', 'give'), |
|
| 415 | 415 | 'post_status' => 'publish', |
| 416 | 416 | 'post_author' => 1, |
| 417 | 417 | 'post_type' => 'page', |
@@ -423,11 +423,11 @@ discard block |
||
| 423 | 423 | } |
| 424 | 424 | |
| 425 | 425 | // Checks if the History Page option exists AND that the page exists. |
| 426 | - if ( ! get_post( give_get_option( 'history_page' ) ) ) { |
|
| 426 | + if ( ! get_post(give_get_option('history_page'))) { |
|
| 427 | 427 | // Donation History Page |
| 428 | 428 | $history = wp_insert_post( |
| 429 | 429 | array( |
| 430 | - 'post_title' => esc_html__( 'Donation History', 'give' ), |
|
| 430 | + 'post_title' => esc_html__('Donation History', 'give'), |
|
| 431 | 431 | 'post_content' => '[donation_history]', |
| 432 | 432 | 'post_status' => 'publish', |
| 433 | 433 | 'post_author' => 1, |
@@ -439,10 +439,10 @@ discard block |
||
| 439 | 439 | $options['history_page'] = $history; |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | - if( ! empty( $options ) ) { |
|
| 443 | - update_option( 'give_settings', array_merge( give_get_settings(), $options ) ); |
|
| 442 | + if ( ! empty($options)) { |
|
| 443 | + update_option('give_settings', array_merge(give_get_settings(), $options)); |
|
| 444 | 444 | } |
| 445 | 445 | |
| 446 | - add_option( 'give_install_pages_created', 1, '', 'no' ); |
|
| 446 | + add_option('give_install_pages_created', 1, '', 'no'); |
|
| 447 | 447 | } |
| 448 | -add_action( 'admin_init', 'give_create_pages', -1 ); |
|
| 448 | +add_action('admin_init', 'give_create_pages', -1); |
|