|
8 | 8 | * @var array $value |
9 | 9 | * @var string $form_id |
10 | 10 | */ |
11 | | -if (!defined('ABSPATH')) exit; |
| 11 | +if (!defined('ABSPATH')) |
| 12 | + exit; |
12 | 13 |
|
13 | 14 | $amount_layout = get_post_meta($product_id, 'wcdp-settings[0]', true); |
14 | 15 |
|
15 | 16 | //Donation Amount field |
16 | 17 | $wcdp_price_decimals = apply_filters('wcdp_donation_amount_decimals', pow(10, wc_get_price_decimals() * (-1))); |
17 | | -$max_range = (float)get_option('wcdp_max_range', 500); |
| 18 | +$max_range = (float) get_option('wcdp_max_range', 500); |
18 | 19 | $value_donation_amount = ""; |
19 | 20 | $currency_symbol = get_woocommerce_currency_symbol(); |
20 | 21 |
|
|
38 | 39 | } |
39 | 40 |
|
40 | 41 | ?> |
41 | | - <div id="wcdp_va_amount" class="wcdp_variation wcdp-row"> |
42 | | - <?php |
43 | | - if ($amount_layout == 3) { //Expert design - action wcdp_custom_html_amount |
44 | | - do_action('wcdp_custom_html_amount'); |
45 | | - do_action('wcdp_custom_html_amount_' . $value['id']); |
46 | | - } else if ($amount_layout == 2) { //Input box with range slider ?> |
| 42 | +<div id="wcdp_va_amount" class="wcdp_variation wcdp-row"> |
| 43 | + <?php |
| 44 | + if ($amount_layout == 3) { //Expert design - action wcdp_custom_html_amount |
| 45 | + do_action('wcdp_custom_html_amount'); |
| 46 | + do_action('wcdp_custom_html_amount_' . $value['id']); |
| 47 | + } else if ($amount_layout == 2) { //Input box with range slider ?> |
47 | 48 | <div class="wcdp-amount"> |
48 | 49 | <label for="wcdp-donation-amount"> |
49 | 50 | <?php |
|
56 | 57 | <?php |
57 | 58 | $wcdp_price_field = sprintf($wcdp_price_field, 'wcdp-amount-range-field'); |
58 | 59 | echo $wcdp_price_field |
59 | | - ?> |
60 | | - <input id="<?php echo $form_id?>wcdp-range" name="wcdp-range" class="wcdp-range" aria-hidden="true" type="range" |
61 | | - step="<?php echo (float)apply_filters('wcdp_range_slider_steps', 1); ?>" |
62 | | - min="<?php echo $min_donation_amount ?>" max="<?php echo $max_range ?>"> |
| 60 | + ?> |
| 61 | + <input id="<?php echo $form_id ?>wcdp-range" name="wcdp-range" class="wcdp-range" aria-hidden="true" |
| 62 | + type="range" step="<?php echo (float) apply_filters('wcdp_range_slider_steps', 1); ?>" |
| 63 | + min="<?php echo $min_donation_amount ?>" max="<?php echo $max_range ?>"> |
63 | 64 | </div> <?php |
64 | | - } else if ($amount_layout == 1) { //Radio/Button choices |
65 | | - $suggestions = json_decode(get_post_meta($value['id'], 'wcdp-settings[1]', true)); |
66 | | - $price_format = get_woocommerce_price_format(); |
| 65 | + } else if ($amount_layout == 1) { //Radio/Button choices |
| 66 | + $suggestions = json_decode(get_post_meta($value['id'], 'wcdp-settings[1]', true)); |
| 67 | + $price_format = get_woocommerce_price_format(); |
67 | 68 |
|
68 | | - $args = array( |
69 | | - 'ul-id' => 'wcdp_amount', |
70 | | - 'ul-class' => 'wcdp_options wcdp_amount', |
71 | | - 'name' => 'donation-amount', |
72 | | - 'options' => array() |
73 | | - ); |
| 69 | + $args = array( |
| 70 | + 'ul-id' => 'wcdp_amount', |
| 71 | + 'ul-class' => 'wcdp_options wcdp_amount', |
| 72 | + 'name' => 'donation-amount', |
| 73 | + 'options' => array() |
| 74 | + ); |
74 | 75 |
|
75 | | - $option_already_checked = false; |
| 76 | + $option_already_checked = false; |
76 | 77 |
|
77 | | - if (!is_null($suggestions)) { |
78 | | - foreach ($suggestions as $suggestion) { |
79 | | - $suggestion = apply_filters('wcdp_suggestion', $suggestion, $product); |
80 | | - if (is_numeric($suggestion) && $suggestion > 0 && $suggestion >= $min_donation_amount && $suggestion <= $max_donation_amount) { |
81 | | - $option = array( |
82 | | - 'input-id' => 'amount_' . str_replace('.', '-', $suggestion), |
83 | | - 'input-value' => $suggestion, |
84 | | - 'input-class' => 'wcdp_amount_suggestion wcdp_amount_' . str_replace('.', '-', $suggestion), |
85 | | - 'label-text' => wc_price($suggestion), |
86 | | - ); |
87 | | - if ($suggestion == $value_donation_amount) { |
88 | | - $option['input-checked'] = true; |
89 | | - $option_already_checked = true; |
90 | | - } |
91 | | - $args['options'][] = $option; |
| 78 | + if (!is_null($suggestions)) { |
| 79 | + foreach ($suggestions as $suggestion) { |
| 80 | + $suggestion = apply_filters('wcdp_suggestion', $suggestion, $product); |
| 81 | + if (is_numeric($suggestion) && $suggestion > 0 && $suggestion >= $min_donation_amount && $suggestion <= $max_donation_amount) { |
| 82 | + $option = array( |
| 83 | + 'input-id' => 'amount_' . str_replace('.', '-', $suggestion), |
| 84 | + 'input-value' => $suggestion, |
| 85 | + 'input-class' => 'wcdp_amount_suggestion wcdp_amount_' . str_replace('.', '-', $suggestion), |
| 86 | + 'label-text' => wc_price($suggestion, ['decimals' => 0]), |
| 87 | + ); |
| 88 | + if ($suggestion == $value_donation_amount) { |
| 89 | + $option['input-checked'] = true; |
| 90 | + $option_already_checked = true; |
92 | 91 | } |
| 92 | + $args['options'][] = $option; |
93 | 93 | } |
94 | 94 | } |
95 | | - $wcdp_price_field = sprintf($wcdp_price_field, ''); |
96 | | - $option = array( |
97 | | - 'input-id' => 'wcdp_value_other', |
98 | | - 'input-value' => 'other', |
99 | | - 'input-class' => 'wcdp_value_other', |
100 | | - 'label-id' => 'label_custom_amount', |
101 | | - 'label-class' => 'wcdp_label_custom_amount', |
102 | | - 'label-text' => '<div id="wcdp_other" class="wcdp_other">' . apply_filters('wcdp_other_label', esc_html__('Other', 'wc-donation-platform')) . '</div><div class="wcdp_cu_field">' . $wcdp_price_field . '</div>', |
103 | | - ); |
104 | | - if (!$option_already_checked && $value_donation_amount) { |
105 | | - $option['input-checked'] = true; |
106 | | - } |
107 | | - $args['options'][] = $option; ?> |
108 | | - <label class="wcdp-variation-heading" for="donation-amount"> |
| 95 | + } |
| 96 | + $wcdp_price_field = sprintf($wcdp_price_field, ''); |
| 97 | + $option = array( |
| 98 | + 'input-id' => 'wcdp_value_other', |
| 99 | + 'input-value' => 'other', |
| 100 | + 'input-class' => 'wcdp_value_other', |
| 101 | + 'label-id' => 'label_custom_amount', |
| 102 | + 'label-class' => 'wcdp_label_custom_amount', |
| 103 | + 'label-text' => '<div id="wcdp_other" class="wcdp_other">' . apply_filters('wcdp_other_label', esc_html__('Other', 'wc-donation-platform')) . '</div><div class="wcdp_cu_field">' . $wcdp_price_field . '</div>', |
| 104 | + ); |
| 105 | + if (!$option_already_checked && $value_donation_amount) { |
| 106 | + $option['input-checked'] = true; |
| 107 | + } |
| 108 | + $args['options'][] = $option; ?> |
| 109 | + <label class="wcdp-variation-heading" for="donation-amount"> |
109 | 110 | <?php |
110 | 111 | $title = get_option('wcdp_choose_amount_title', __('Choose an amount', 'wc-donation-platform')); |
111 | 112 | echo esc_html($title); |
112 | 113 | ?> |
113 | | - <abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr> |
114 | | - </label> <?php |
115 | | - echo WCDP_Form::wcdp_generate_fieldset($args, null, $form_id); |
116 | | - } else { //Default: just input box ?> |
117 | | - <div class="wcdp-amount"> |
118 | | - <label for="wcdp-donation-amount"> |
| 114 | + <abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr> |
| 115 | + </label> <?php |
| 116 | + echo WCDP_Form::wcdp_generate_fieldset($args, null, $form_id); |
| 117 | + } else { //Default: just input box ?> |
| 118 | + <div class="wcdp-amount"> |
| 119 | + <label for="wcdp-donation-amount"> |
119 | 120 | <?php |
120 | 121 | $title = get_option('wcdp_contribution_title', __('Your Contribution', 'wc-donation-platform')); |
121 | 122 | echo esc_html($title); |
122 | 123 | ?> |
123 | | - <abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr> |
124 | | - </label> |
125 | | - <br> |
| 124 | + <abbr class="required" title="<?php esc_html_e('required', 'wc-donation-platform'); ?>">*</abbr> |
| 125 | + </label> |
| 126 | + <br> |
126 | 127 | <?php |
127 | 128 | $wcdp_price_field = sprintf($wcdp_price_field, ''); |
128 | 129 | echo $wcdp_price_field; |
129 | 130 | ?> |
130 | | - </div> <?php |
131 | | - } ?> |
132 | | - </div> |
| 131 | + </div> <?php |
| 132 | + } ?> |
| 133 | +</div> |
133 | 134 | <?php |
0 commit comments