PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.24.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.24.1
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 | square/controllers/FrmSquareLiteAppController.php +24 -69 6.316.24.1 View file →
@@ -9,9 +9,8 @@
9 9 * Add the gateway for compatibility with the Payments submodule.
10 10 * This adds the Stripe checkbox option to the list of gateways.
11 11 *
12 12 * @param array $gateways
13 - *
14 13 * @return array
15 14 */
16 15 public static function add_gateway( $gateways ) {
17 16 $gateways['square'] = array(
@@ -35,15 +34,13 @@
35 34 * @return void
36 35 */
37 36 public static function handle_oauth() {
38 37 FrmAppHelper::permission_check( 'frm_change_settings' );
39 -
40 38 if ( ! check_admin_referer( 'frm_ajax', 'nonce' ) ) {
41 39 wp_send_json_error();
42 40 }
43 41
44 42 $redirect_url = FrmSquareLiteConnectHelper::get_oauth_redirect_url();
45 -
46 43 if ( false === $redirect_url ) {
47 44 wp_send_json_error( 'Unable to connect to Square successfully' );
48 45 }
49 46
@@ -54,9 +51,8 @@
54 51 }
55 52
56 53 public static function handle_disconnect() {
57 54 FrmAppHelper::permission_check( 'frm_change_settings' );
58 -
59 55 if ( ! check_admin_referer( 'frm_ajax', 'nonce' ) ) {
60 56 wp_send_json_error();
61 57 }
62 58
@@ -72,16 +68,14 @@
72 68 public static function verify_buyer() {
73 69 check_ajax_referer( 'frm_square_ajax', 'nonce' );
74 70
75 71 $form_id = FrmAppHelper::get_post_param( 'form_id', 0, 'absint' );
76 -
77 72 if ( ! $form_id ) {
78 73 wp_send_json_error( __( 'Invalid form ID', 'formidable' ) );
79 74 }
80 75
81 76 $actions = FrmSquareLiteActionsController::get_actions_before_submit( $form_id );
82 -
83 - if ( ! $actions ) {
77 + if ( empty( $actions ) ) {
84 78 wp_send_json_error( __( 'No Square actions found for this form', 'formidable' ) );
85 79 }
86 80
87 81 $action = reset( $actions );
@@ -103,33 +97,30 @@
103 97 /**
104 98 * Get the amount value for verification.
105 99 *
106 100 * @param WP_Post $action
107 - *
108 101 * @return string
109 102 */
110 103 private static function get_amount_value_for_verification( $action ) {
111 104 $amount = $action->post_content['amount'];
112 -
113 - if ( ! str_contains( $amount, '[' ) ) {
105 + if ( strpos( $amount, '[' ) === false ) {
114 106 return $amount;
115 107 }
116 108
117 109 $form = FrmForm::getOne( $action->menu_order );
118 -
119 110 if ( ! $form ) {
120 111 return $amount;
121 112 }
122 113
123 114 // Update amount based on field shortcodes.
124 - $entry = self::generate_false_entry();
115 + $entry = self::generate_false_entry();
116 + $amount = FrmSquareLiteActionsController::prepare_amount( $amount, compact( 'form', 'entry', 'action' ) );
125 117
126 - return FrmSquareLiteActionsController::prepare_amount( $amount, compact( 'form', 'entry', 'action' ) );
118 + return $amount;
127 119 }
128 120
129 121 /**
130 122 * @param WP_Post $action
131 - *
132 123 * @return array
133 124 */
134 125 public static function get_billing_contact( $action ) {
135 126 $email_setting = $action->post_content['email'];
@@ -163,63 +154,30 @@
163 154 );
164 155 $details['email'] = FrmTransLiteAppHelper::process_shortcodes( $shortcode_atts );
165 156 }
166 157
167 - self::maybe_add_address_data( $details, $address, (int) $address_setting );
158 + if ( is_array( $address ) && isset( $address['line1'] ) && isset( $address['line2'] ) && is_callable( 'FrmProAddressesController::get_country_code' ) ) {
159 + $details['addressLines'] = array( $address['line1'], $address['line2'] );
160 + $details['city'] = $address['city'];
161 + $details['state'] = $address['state'];
162 + $details['postalCode'] = $address['zip'];
163 + $details['countryCode'] = FrmProAddressesController::get_country_code( $address['country'] );
164 + }
168 165
169 166 return $details;
170 167 }
171 168
172 169 /**
173 - * @since 6.25
174 - *
175 - * @param array $details
176 - * @param array $address
177 - * @param int $address_field_id
178 - *
179 - * @return void
180 - */
181 - private static function maybe_add_address_data( &$details, $address, $address_field_id ) {
182 - if ( ! is_array( $address ) || ! isset( $address['line1'] ) || ! isset( $address['line2'] ) || ! is_callable( 'FrmProAddressesController::get_country_code' ) ) {
183 - return;
184 - }
185 -
186 - $address_field = FrmField::getOne( $address_field_id );
187 -
188 - if ( ! $address_field ) {
189 - return;
190 - }
191 -
192 - if ( 'us' === $address_field->field_options['address_type'] ) {
193 - $country_code = 'US';
194 - } else {
195 - $country_code = FrmProAddressesController::get_country_code( $address['country'] );
196 - }
197 -
198 - if ( ! $address['line1'] && ! $address['line2'] && ! $address['city'] && ! $address['state'] && ! $address['zip'] && ! $country_code ) {
199 - return;
200 - }
201 -
202 - $details['addressLines'] = array( $address['line1'], $address['line2'] );
203 - $details['city'] = $address['city'];
204 - $details['state'] = $address['state'];
205 - $details['postalCode'] = $address['zip'];
206 - $details['countryCode'] = $country_code;
207 - }
208 -
209 - /**
210 170 * Create an entry object with posted values.
211 171 *
212 172 * @since 6.22
213 - *
214 173 * @return stdClass
215 174 */
216 175 private static function generate_false_entry() {
217 - $entry = new stdClass();
218 - $entry->post_id = 0;
219 - $entry->id = 0;
220 - $entry->item_key = '';
221 - $entry->metas = array();
176 + $entry = new stdClass();
177 + $entry->post_id = 0;
178 + $entry->id = 0;
179 + $entry->metas = array();
222 180
223 181 // phpcs:ignore WordPress.Security.NonceVerification.Missing
224 182 foreach ( $_POST as $k => $v ) {
225 183 $k = sanitize_text_field( stripslashes( $k ) );
@@ -224,21 +182,18 @@
224 182 foreach ( $_POST as $k => $v ) {
225 183 $k = sanitize_text_field( stripslashes( $k ) );
226 184 $v = wp_unslash( $v );
227 185
228 - if ( $k !== 'item_meta' ) {
186 + if ( $k === 'item_meta' ) {
187 + if ( is_array( $v ) ) {
188 + foreach ( $v as $f => $value ) {
189 + FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
190 + $entry->metas[ absint( $f ) ] = $value;
191 + }
192 + }
193 + } else {
229 194 FrmAppHelper::sanitize_value( 'wp_kses_post', $v );
230 195 $entry->{$k} = $v;
231 - continue;
232 - }
233 -
234 - if ( ! is_array( $v ) ) {
235 - continue;
236 - }
237 -
238 - foreach ( $v as $f => $value ) {
239 - FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
240 - $entry->metas[ absint( $f ) ] = $value;
241 196 }
242 197 }
243 198
244 199 return $entry;