PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22
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 -70 6.306.22 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 );
@@ -94,9 +88,8 @@
94 88
95 89 wp_send_json_success(
96 90 array(
97 91 'verificationDetails' => $verification_details,
98 - 'hash' => md5( serialize( $verification_details ) ),
99 92 )
100 93 );
101 94 }
102 95
@@ -103,33 +96,30 @@
103 96 /**
104 97 * Get the amount value for verification.
105 98 *
106 99 * @param WP_Post $action
107 - *
108 100 * @return string
109 101 */
110 102 private static function get_amount_value_for_verification( $action ) {
111 103 $amount = $action->post_content['amount'];
112 -
113 - if ( ! str_contains( $amount, '[' ) ) {
104 + if ( strpos( $amount, '[' ) === false ) {
114 105 return $amount;
115 106 }
116 107
117 108 $form = FrmForm::getOne( $action->menu_order );
118 -
119 109 if ( ! $form ) {
120 110 return $amount;
121 111 }
122 112
123 113 // Update amount based on field shortcodes.
124 - $entry = self::generate_false_entry();
114 + $entry = self::generate_false_entry();
115 + $amount = FrmSquareLiteActionsController::prepare_amount( $amount, compact( 'form', 'entry', 'action' ) );
125 116
126 - return FrmSquareLiteActionsController::prepare_amount( $amount, compact( 'form', 'entry', 'action' ) );
117 + return $amount;
127 118 }
128 119
129 120 /**
130 121 * @param WP_Post $action
131 - *
132 122 * @return array
133 123 */
134 124 public static function get_billing_contact( $action ) {
135 125 $email_setting = $action->post_content['email'];
@@ -163,63 +153,30 @@
163 153 );
164 154 $details['email'] = FrmTransLiteAppHelper::process_shortcodes( $shortcode_atts );
165 155 }
166 156
167 - self::maybe_add_address_data( $details, $address, (int) $address_setting );
157 + if ( is_array( $address ) && isset( $address['line1'] ) && isset( $address['line2'] ) && is_callable( 'FrmProAddressesController::get_country_code' ) ) {
158 + $details['addressLines'] = array( $address['line1'], $address['line2'] );
159 + $details['city'] = $address['city'];
160 + $details['state'] = $address['state'];
161 + $details['postalCode'] = $address['zip'];
162 + $details['countryCode'] = FrmProAddressesController::get_country_code( $address['country'] );
163 + }
168 164
169 165 return $details;
170 166 }
171 167
172 168 /**
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 169 * Create an entry object with posted values.
211 170 *
212 171 * @since 6.22
213 - *
214 172 * @return stdClass
215 173 */
216 174 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();
175 + $entry = new stdClass();
176 + $entry->post_id = 0;
177 + $entry->id = 0;
178 + $entry->metas = array();
222 179
223 180 // phpcs:ignore WordPress.Security.NonceVerification.Missing
224 181 foreach ( $_POST as $k => $v ) {
225 182 $k = sanitize_text_field( stripslashes( $k ) );
@@ -224,21 +181,18 @@
224 181 foreach ( $_POST as $k => $v ) {
225 182 $k = sanitize_text_field( stripslashes( $k ) );
226 183 $v = wp_unslash( $v );
227 184
228 - if ( $k !== 'item_meta' ) {
185 + if ( $k === 'item_meta' ) {
186 + if ( is_array( $v ) ) {
187 + foreach ( $v as $f => $value ) {
188 + FrmAppHelper::sanitize_value( 'wp_kses_post', $value );
189 + $entry->metas[ absint( $f ) ] = $value;
190 + }
191 + }
192 + } else {
229 193 FrmAppHelper::sanitize_value( 'wp_kses_post', $v );
230 194 $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 195 }
242 196 }
243 197
244 198 return $entry;