PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
← All changes | stripe/views/action-settings/payments-options.php +226 -90 6.26 → trunk View file →
@@ -4,142 +4,234 @@
4 4 }
5 5
6 6 $stripe_connected = FrmStrpLiteConnectHelper::at_least_one_mode_is_setup();
7 7 $square_connected = FrmSquareLiteConnectHelper::at_least_one_mode_is_setup();
8 +$paypal_connected = FrmPayPalLiteConnectHelper::at_least_one_mode_is_setup();
8 9
9 10 if ( $stripe_connected ) {
10 - FrmStrpLiteAppHelper::fee_education( 'tip', $form_action->post_content['gateway'] );
11 + FrmStrpLiteAppHelper::fee_education( 'stripe-action-tip', $form_action->post_content['gateway'] );
11 12 }
12 13
13 14 if ( $square_connected ) {
14 - FrmSquareLiteAppHelper::fee_education( 'tip', $form_action->post_content['gateway'] );
15 + FrmSquareLiteAppHelper::fee_education( 'square-action-tip', $form_action->post_content['gateway'] );
15 16 }
16 17
17 -if ( ! $stripe_connected && ! $square_connected ) {
18 +if ( $paypal_connected ) {
19 + FrmPayPalLiteAppHelper::fee_education( 'paypal-action-tip', $form_action->post_content['gateway'] );
20 +}
21 +
22 +if ( ! $stripe_connected && ! $square_connected && ! $paypal_connected ) {
18 23 FrmStrpLiteAppHelper::not_connected_warning();
19 24 }
20 25 ?>
21 26
27 +<?php
28 +// Only show gateway tabs if there are multiple gateways available.
29 +if ( count( $gateways ) > 1 ) {
30 + FrmTransLiteAppHelper::show_gateway_buttons( $gateways, $form_action, $action_control );
31 +}
32 +?>
33 +
34 +<?php
35 +/**
36 + * Show warning if amount is empty.
37 + * Only show for existing actions (has ID), not new actions.
38 + *
39 + * @since 6.31
40 + */
41 +if ( ! empty( $form_action->ID ) && empty( $form_action->post_content['amount'] ) ) :
42 + ?>
43 + <div class="frm_warning_style frm-with-icon">
44 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
45 + <span><?php esc_html_e( 'Amount is required or payments will not work.', 'formidable' ); ?></span>
46 + </div>
47 +<?php endif; ?>
48 +
49 +<p class="frm6">
50 + <label>
51 + <?php esc_html_e( 'Payment Type', 'formidable' ); ?>
52 + </label>
53 + <select name="<?php echo esc_attr( $action_control->get_field_name( 'type' ) ); ?>" class="frm_trans_type">
54 + <option value="single" <?php selected( $form_action->post_content['type'], 'one_time' ); ?>><?php esc_html_e( 'One-time Payment', 'formidable' ); ?></option>
55 + <option value="recurring" <?php selected( $form_action->post_content['type'], 'recurring' ); ?>><?php esc_html_e( 'Recurring', 'formidable' ); ?></option>
56 + </select>
57 +</p>
58 +
22 59 <div class="frm_grid_container">
23 60 <p>
24 61 <label for="<?php echo esc_attr( $action_control->get_field_id( 'description' ) ); ?>">
25 62 <?php esc_html_e( 'Description', 'formidable' ); ?>
26 63 </label>
27 - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'description' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'description' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['description'] ); ?>" class="frm_not_email_subject large-text" />
64 + <input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'description' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'description' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['description'] ); ?>" class="frm_not_email_subject large-text" />
28 65 </p>
29 66
30 67 <p class="frm6">
31 68 <label for="<?php echo esc_attr( $action_control->get_field_id( 'amount' ) ); ?>">
32 - <?php esc_html_e( 'Amount', 'formidable' ); ?>
69 + <?php esc_html_e( 'Amount', 'formidable' ); ?> <span class="frm_required">*</span>
33 70 </label>
34 - <input type="text" value="<?php echo esc_attr( $form_action->post_content['amount'] ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'amount' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'amount' ) ); ?>" class="frm_not_email_subject large-text" />
71 + <input type="text" value="<?php echo esc_attr( $form_action->post_content['amount'] ); ?>" name="<?php echo esc_attr( $action_control->get_field_name( 'amount' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'amount' ) ); ?>" class="frm_not_email_subject large-text" />
35 72 </p>
36 73
37 - <?php $cc_field_id = $this->get_credit_card_field_id( $field_dropdown_atts ); ?>
38 - <input type="hidden" name="<?php echo esc_attr( $this->get_field_name( 'credit_card' ) ); ?>" value="<?php echo esc_attr( $cc_field_id ); ?>" />
39 -
40 74 <p class="frm6">
41 - <label>
42 - <?php esc_html_e( 'Payment Type', 'formidable' ); ?>
75 + <label for="<?php echo esc_attr( $action_control->get_field_id( 'currency' ) ); ?>">
76 + <?php esc_html_e( 'Currency', 'formidable' ); ?>
43 77 </label>
44 - <select name="<?php echo esc_attr( $this->get_field_name( 'type' ) ); ?>" class="frm_trans_type">
45 - <option value="single" <?php selected( $form_action->post_content['type'], 'one_time' ); ?>><?php esc_html_e( 'One-time Payment', 'formidable' ); ?></option>
46 - <option value="recurring" <?php selected( $form_action->post_content['type'], 'recurring' ); ?>><?php esc_html_e( 'Recurring', 'formidable' ); ?></option>
47 - </select>
78 + <?php FrmTransLiteAppHelper::show_currency_dropdown( $action_control->get_field_id( 'currency' ), $action_control->get_field_name( 'currency' ), $form_action->post_content ); ?>
48 79 </p>
49 80
50 - <?php $this->echo_capture_payment_upsell( $form_action->post_content['gateway'] ); ?>
51 -
52 - <p class="frm6 frm_trans_sub_opts <?php echo $form_action->post_content['type'] === 'recurring' ? '' : 'frm_hidden'; ?>">
53 - <label>
54 - <?php esc_html_e( 'Repeat', 'formidable' ); ?>
55 - </label>
56 - <span>
57 - <span class="frm_grid_container">
58 - <input class="frm6" type="number" name="<?php echo esc_attr( $this->get_field_name( 'interval_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['interval_count'] ); ?>" max="90" min="1" step="1" />
59 - <select class="frm6" name="<?php echo esc_attr( $this->get_field_name( 'interval' ) ); ?>" class="auto_width">
60 - <?php foreach ( $repeat_times as $k => $v ) { ?>
61 - <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $form_action->post_content['interval'], $k ); ?>><?php echo esc_html( $v ); ?></option>
62 - <?php } ?>
63 - </select>
64 - <input type="hidden" name="<?php echo esc_attr( $this->get_field_name( 'payment_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['payment_count'] ); ?>" />
65 - </span>
66 - </span>
67 - </p>
68 -
69 81 <?php
70 - /*
71 - Note: The Repeat Cadence setting is added with JavaScript.
72 - This hidden input is added so the JS knows what value is set.
73 - */
82 + // Only show radio buttons when there's a single gateway (tabs are shown for multiple gateways).
83 + if ( count( $gateways ) === 1 ) :
74 84 ?>
75 - <input type="hidden" class="frm-repeat-cadence-value" value="<?php echo esc_attr( $form_action->post_content['repeat_cadence'] ?? 'DAILY' ); ?>" />
76 -
77 - <p class="frm_trans_sub_opts frm6 <?php echo $form_action->post_content['type'] === 'recurring' ? '' : 'frm_hidden'; ?>">
78 - <label>
79 - <?php esc_html_e( 'Recurring Payment Limit', 'formidable' ); ?>
80 - </label>
81 - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'payment_limit' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['payment_limit'] ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'payment_limit' ) ); ?>" class="frm_not_email_subject" />
82 - </p>
83 -
84 - <p class="frm_trans_sub_opts frm6 <?php echo $form_action->post_content['type'] === 'recurring' ? '' : 'frm_hidden'; ?>">
85 - <label>
86 - <?php esc_html_e( 'Trial Period', 'formidable' ); ?>
87 - </label>
88 - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'trial_interval_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['trial_interval_count'] ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'trial_interval_count' ) ); ?>" class="frm_not_email_subject" />
89 - <?php esc_html_e( 'day(s)', 'formidable' ); ?>
90 - </p>
91 -
92 - <p class="frm6">
93 - <label for="<?php echo esc_attr( $this->get_field_id( 'currency' ) ); ?>">
94 - <?php esc_html_e( 'Currency', 'formidable' ); ?>
95 - </label>
96 - <?php FrmTransLiteAppHelper::show_currency_dropdown( $this->get_field_id( 'currency' ), $this->get_field_name( 'currency' ), $form_action->post_content ); ?>
97 - </p>
98 -
99 85 <p>
86 + <span class="frm-block frm-mb-6"><?php esc_html_e( 'Gateway(s)', 'formidable' ); ?></span>
100 87 <?php
101 - esc_html_e( 'Gateway(s)', 'formidable' );
102 -
103 88 foreach ( $gateways as $gateway_name => $gateway ) {
104 89 $gateway_classes = $gateway['recurring'] ? '' : 'frm_gateway_no_recur';
105 90 $gateway_classes .= $form_action->post_content['type'] === 'recurring' && ! $gateway['recurring'] ? ' frm_hidden' : '';
106 - $gateway_id = $this->get_field_id( 'gateways' ) . '_' . $gateway_name;
107 -
108 - $radio_atts = array(
91 + $gateway_id = $action_control->get_field_id( 'gateways' ) . '_' . $gateway_name;
92 + $radio_atts = array(
109 93 'type' => 'radio',
110 94 'value' => $gateway_name,
111 - 'name' => $this->get_field_name( 'gateway' ),
95 + 'name' => $action_control->get_field_name( 'gateway' ),
112 96 'id' => $gateway_id,
113 97 );
114 98 ?>
115 - <label for="<?php echo esc_attr( $gateway_id ); ?>" class="frm_gateway_opt <?php echo esc_attr( $gateway_classes ); ?>">
116 - <input
117 - <?php
118 - FrmAppHelper::array_to_html_params( $radio_atts, true );
119 - echo ' ';
120 - FrmAppHelper::checked( $form_action->post_content['gateway'], $gateway_name );
121 - ?>
122 - />
123 - <?php echo esc_html( $gateway['label'] ); ?> &nbsp;
124 - </label>
99 + <label for="<?php echo esc_attr( $gateway_id ); ?>" class="frm_gateway_opt <?php echo esc_attr( $gateway_classes ); ?>">
100 + <input
101 + <?php
102 + FrmAppHelper::array_to_html_params( $radio_atts, true );
103 + echo ' ';
104 + FrmAppHelper::checked( $form_action->post_content['gateway'], $gateway_name );
105 + ?>
106 + />
107 + <?php echo esc_html( $gateway['label'] ); ?> &nbsp;
108 + </label>
125 109 <?php
126 110 }//end foreach
127 111 ?>
128 112 </p>
113 + <?php endif; ?>
129 114
130 115 <?php
131 116 FrmStrpLiteActionsController::add_action_options(
132 117 array(
133 118 'form_action' => $form_action,
134 - 'action_control' => $this,
119 + 'action_control' => $action_control,
135 120 )
136 121 );
137 122 ?>
123 +
124 + <?php $cc_field_id = $action_control->get_credit_card_field_id( $field_dropdown_atts ); ?>
125 + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'credit_card' ) ); ?>" value="<?php echo esc_attr( $cc_field_id ); ?>" />
126 +
127 + <?php $action_control->echo_capture_payment_upsell( $form_action->post_content['gateway'] ); ?>
128 +
129 + <div class="frm_trans_sub_opts <?php echo $form_action->post_content['type'] === 'recurring' ? '' : 'frm_hidden'; ?>">
130 + <div class="frm_grid_container">
131 + <h3><?php esc_html_e( 'Recurring Payment Settings', 'formidable' ); ?></h3>
132 + <?php
133 + /**
134 + * Show warning if PayPal is selected and product name is empty.
135 + * Only show for existing actions (has ID), not new actions.
136 + * Only show when payment type is recurring.
137 + *
138 + * @since 6.31
139 + */
140 + if ( ! empty( $form_action->ID ) && 'recurring' === $form_action->post_content['type'] && in_array( 'paypal', (array) $form_action->post_content['gateway'], true ) && empty( $form_action->post_content['product_name'] ) ) :
141 + ?>
142 + <div class="frm_warning_style frm-with-icon frm-mt-0">
143 + <?php FrmAppHelper::icon_by_class( 'frmfont frm_alert_icon', array( 'style' => 'width:24px' ) ); ?>
144 + <span><?php esc_html_e( 'Product Name is required for PayPal recurring payments.', 'formidable' ); ?></span>
145 + </div>
146 + <?php endif; ?>
147 +
148 + <?php
149 + /**
150 + * @since 6.31
151 + *
152 + * @param array $args
153 + */
154 + do_action(
155 + 'frm_payments_settings_recurring_product_info',
156 + array(
157 + 'form_action' => $form_action,
158 + 'action_control' => $action_control,
159 + )
160 + );
161 + ?>
162 +
163 + <p class="frm6">
164 + <label>
165 + <?php esc_html_e( 'Repeat', 'formidable' ); ?>
166 + </label>
167 + <span>
168 + <span class="frm_grid_container">
169 + <input class="frm6" type="number" name="<?php echo esc_attr( $action_control->get_field_name( 'interval_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['interval_count'] ); ?>" max="90" min="1" step="1" />
170 + <select class="frm6" name="<?php echo esc_attr( $action_control->get_field_name( 'interval' ) ); ?>" class="auto_width">
171 + <?php foreach ( $repeat_times as $k => $v ) { ?>
172 + <option value="<?php echo esc_attr( $k ); ?>" <?php selected( $form_action->post_content['interval'], $k ); ?>><?php echo esc_html( $v ); ?></option>
173 + <?php } ?>
174 + </select>
175 + <input type="hidden" name="<?php echo esc_attr( $action_control->get_field_name( 'payment_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['payment_count'] ); ?>" />
176 + </span>
177 + </span>
178 + </p>
179 +
180 + <?php
181 + /*
182 + Note: The Repeat Cadence setting is added with JavaScript.
183 + This hidden input is added so the JS knows what value is set.
184 + */
185 + ?>
186 + <input type="hidden" class="frm-repeat-cadence-value" value="<?php echo esc_attr( $form_action->post_content['repeat_cadence'] ?? 'DAILY' ); ?>" />
187 +
188 + <p class="frm6">
189 + <label>
190 + <?php esc_html_e( 'Recurring Payment Limit', 'formidable' ); ?>
191 + </label>
192 + <input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'payment_limit' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['payment_limit'] ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'payment_limit' ) ); ?>" class="frm_not_email_subject" />
193 + </p>
194 +
195 + <p class="frm6">
196 + <label>
197 + <?php esc_html_e( 'Trial Period', 'formidable' ); ?>
198 + </label>
199 + <input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'trial_interval_count' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['trial_interval_count'] ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'trial_interval_count' ) ); ?>" class="frm_not_email_subject" />
200 + <?php esc_html_e( 'day(s)', 'formidable' ); ?>
201 + </p>
202 + </div>
203 + </div>
204 +
205 + <?php
206 + /**
207 + * Allow add-ons to inject settings after the Recurring Payment Settings section.
208 + *
209 + * @since 6.31
210 + *
211 + * @param array $args {
212 + *
213 + * @type object $form_action The form action post object.
214 + * @type object $action_control The action controller object.
215 + * }
216 + */
217 + do_action(
218 + 'frm_payments_settings_after_recurring',
219 + array(
220 + 'form_action' => $form_action,
221 + 'action_control' => $action_control,
222 + )
223 + );
224 + ?>
138 225 </div>
139 -<div class="frm_grid_container">
140 - <h3>
141 - <?php esc_html_e( 'Customer Information', 'formidable' ); ?>
226 +<div class="frm_grid_container frm-mb-xs">
227 + <?php
228 + $billing_label = __( 'Billing Information', 'formidable' );
229 + $customer_label = __( 'Customer Information', 'formidable' );
230 + $is_paypal = in_array( 'paypal', (array) $form_action->post_content['gateway'], true );
231 + ?>
232 + <h3 class="frm-billing-section-heading frm-mt-0" data-billing-label="<?php echo esc_attr( $billing_label ); ?>" data-customer-label="<?php echo esc_attr( $customer_label ); ?>">
233 + <?php echo esc_html( $is_paypal ? $billing_label : $customer_label ); ?>
142 234 </h3>
143 235
144 236 <p class="frm6">
145 237 <label for="<?php echo esc_attr( $action_control->get_field_id( 'email' ) ); ?>">
@@ -144,38 +236,82 @@
144 236 <p class="frm6">
145 237 <label for="<?php echo esc_attr( $action_control->get_field_id( 'email' ) ); ?>">
146 238 <?php esc_html_e( 'Email', 'formidable' ); ?>
147 239 </label>
148 - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'email' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'email' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['email'] ); ?>" class="frm_not_email_to large-text" />
240 + <input type="text" name="<?php echo esc_attr( $action_control->get_field_name( 'email' ) ); ?>" id="<?php echo esc_attr( $action_control->get_field_id( 'email' ) ); ?>" value="<?php echo esc_attr( $form_action->post_content['email'] ); ?>" class="frm_not_email_to large-text" />
149 241 </p>
150 242
243 + <?php if ( ! has_action( 'frm_stripe_lite_customer_info_after_email' ) ) : ?>
244 + <p class="frm6">
245 + <label for="<?php echo esc_attr( $action_control->get_field_id( 'billing_address' ) ); ?>">
246 + <?php esc_html_e( 'Address', 'formidable' ); ?>
247 + </label>
248 + <?php
249 + $action_control->show_fields_dropdown(
250 + $field_dropdown_atts,
251 + array(
252 + 'name' => 'billing_address',
253 + 'allowed_fields' => 'address',
254 + )
255 + );
256 + ?>
257 + </p>
258 + <?php endif; ?>
259 +
151 260 <?php
152 261 /**
153 262 * Trigger an action so Pro can include an Address dropdown.
263 + * When a plugin hooks in here, the default Address dropdown above is not rendered.
154 264 *
155 265 * @since 6.5
156 266 *
157 267 * @param array $args {
158 268 *
159 - * @type FrmFormAction $action_control
160 - * @type array $field_dropdown_atts
269 + * @type WP_Post $form_action The form action post object.
270 + * @type FrmFormAction $action_control The action controller object.
271 + * @type array $field_dropdown_atts Attributes for field dropdown rendering.
161 272 * }
162 273 */
163 274 do_action(
164 275 'frm_stripe_lite_customer_info_after_email',
165 - compact( 'action_control', 'field_dropdown_atts' )
276 + compact( 'form_action', 'action_control', 'field_dropdown_atts' )
166 277 );
167 278 ?>
168 279
169 280 <p class="frm6">
170 - <label for="<?php echo esc_attr( $this->get_field_id( 'billing_first_name' ) ); ?>">
281 + <label for="<?php echo esc_attr( $action_control->get_field_id( 'billing_first_name' ) ); ?>">
171 282 <?php esc_html_e( 'First Name', 'formidable' ); ?>
172 283 </label>
173 - <?php $this->show_fields_dropdown( $field_dropdown_atts, array( 'name' => 'billing_first_name' ) ); ?>
284 + <?php $action_control->show_fields_dropdown( $field_dropdown_atts, array( 'name' => 'billing_first_name' ) ); ?>
174 285 </p>
175 286 <p class="frm6">
176 - <label for="<?php echo esc_attr( $this->get_field_id( 'billing_last_name' ) ); ?>">
287 + <label for="<?php echo esc_attr( $action_control->get_field_id( 'billing_last_name' ) ); ?>">
177 288 <?php esc_html_e( 'Last Name', 'formidable' ); ?>
178 289 </label>
179 - <?php $this->show_fields_dropdown( $field_dropdown_atts, array( 'name' => 'billing_last_name' ) ); ?>
290 + <?php $action_control->show_fields_dropdown( $field_dropdown_atts, array( 'name' => 'billing_last_name' ) ); ?>
180 291 </p>
181 292 </div>
293 +
294 +<?php
295 +if ( ! has_action( 'frm_payment_settings_after_customer_info' ) ) {
296 + include FrmTransLiteAppHelper::plugin_path() . '/views/action-settings/paypal-shipping.php';
297 +}
298 +
299 +/**
300 + * Fires after the Customer Information section in payment action settings.
301 + * Used by Pro to add gateway-specific Shipping and Billing sections.
302 + * When a plugin hooks in here, the default Shipping Information section above is not rendered.
303 + *
304 + * @since 6.31
305 + *
306 + * @param array $args {
307 + *
308 + * @type WP_Post $form_action The form action post object.
309 + * @type FrmFormAction $action_control The action controller object.
310 + * @type array $field_dropdown_atts Attributes for field dropdown rendering.
311 + * }
312 + */
313 +do_action(
314 + 'frm_payment_settings_after_customer_info',
315 + compact( 'form_action', 'action_control', 'field_dropdown_atts' )
316 +);
317 +?>