/** * Donation Levels Output * * Outputs donation levels based on the specific form ID. * The output generated can be overridden by the filters provided or by removing * the action and adding your own custom action. * * @since 1.0 * * @param int $form_id Give Form ID * * @return void */ function give_output_donation_levels($form_id = 0, $args = array()) { global $give_options; $variable_pricing = give_has_variable_prices($form_id); $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; $symbol = isset($give_options['currency']) ? give_currency_symbol($give_options['currency']) : '$'; $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; $default_amount = give_format_amount(give_get_default_form_amount($form_id)); $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); do_action('give_before_donation_levels', $form_id); //Set Price, No Custom Amount Allowed means hidden price field if ($allow_custom_amount == 'no') { ?> <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" value="<?php echo $default_amount; ?> " required> <p class="set-price give-donation-amount form-row-wide"> <?php if ($currency_position == 'before') { echo $currency_output; } ?> <span id="give-amount" class="give-text-input"><?php echo give_format_amount($default_amount); ?> </span> </p> <?php } else { //Custom Amount Allowed ?> <div class="give-total-wrap"> <div class="give-donation-amount form-row-wide"> <?php if ($currency_position == 'before') { echo $currency_output; } ?> <input class="give-text-input" id="give-amount" name="give-amount" type="text" placeholder="" value="<?php echo $default_amount; ?> " required autocomplete="off"> <?php if ($currency_position == 'after') { echo $currency_output; } ?> <p class="give-loading-text give-updating-price-loader" style="display: none;"> <span class="give-loading-animation"></span> <?php _e('Updating Price', 'Give'); ?> <span class="elipsis">.</span><span class="elipsis">.</span><span class="elipsis">.</span></p> </div> </div> <?php } //Custom Amount Text if (!empty($custom_amount_text) && !$variable_pricing && $allow_custom_amount == 'yes') { ?> <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?> </p> <?php } //Output Variable Pricing Levels if ($variable_pricing) { give_output_levels($form_id); } do_action('give_after_donation_levels', $form_id); }
/** * Donation Amount Field * * Outputs the donation amount field that appears at the top of the donation forms. If the user has custom amount enabled the field will output as a customizable input * * @since 1.0 * * @param int $form_id Give Form ID * @param array $args * * @return void */ function give_output_donation_amount_top($form_id = 0, $args = array()) { global $give_options; $variable_pricing = give_has_variable_prices($form_id); $allow_custom_amount = get_post_meta($form_id, '_give_custom_amount', true); $currency_position = isset($give_options['currency_position']) ? $give_options['currency_position'] : 'before'; $symbol = give_currency_symbol(give_get_currency()); $currency_output = '<span class="give-currency-symbol give-currency-position-' . $currency_position . '">' . $symbol . '</span>'; $default_amount = give_format_amount(give_get_default_form_amount($form_id)); $custom_amount_text = get_post_meta($form_id, '_give_custom_amount_text', true); do_action('give_before_donation_levels', $form_id, $args); //Set Price, No Custom Amount Allowed means hidden price field if ($allow_custom_amount == 'no') { ?> <label class="give-hidden" for="give-amount-hidden"><?php echo esc_html__('Donation Amount:', 'give'); ?> </label> <input id="give-amount" class="give-amount-hidden" type="hidden" name="give-amount" value="<?php echo $default_amount; ?> " required> <div class="set-price give-donation-amount form-row-wide"> <?php if ($currency_position == 'before') { echo $currency_output; } ?> <span id="give-amount-text" class="give-text-input give-amount-top"><?php echo $default_amount; ?> </span> <?php if ($currency_position == 'after') { echo $currency_output; } ?> </div> <?php } else { //Custom Amount Allowed ?> <div class="give-total-wrap"> <div class="give-donation-amount form-row-wide"> <?php if ($currency_position == 'before') { echo $currency_output; } ?> <label class="give-hidden" for="give-amount"><?php echo esc_html__('Donation Amount:', 'give'); ?> </label> <input class="give-text-input give-amount-top" id="give-amount" name="give-amount" type="tel" placeholder="" value="<?php echo $default_amount; ?> " autocomplete="off"> <?php if ($currency_position == 'after') { echo $currency_output; } ?> </div> </div> <?php } do_action('give_after_donation_amount', $form_id, $args); //Custom Amount Text if (!$variable_pricing && $allow_custom_amount == 'yes' && !empty($custom_amount_text)) { ?> <p class="give-custom-amount-text"><?php echo $custom_amount_text; ?> </p> <?php } //Output Variable Pricing Levels if ($variable_pricing) { give_output_levels($form_id); } do_action('give_after_donation_levels', $form_id, $args); }