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 | classes/models/FrmField.php +253 -194 6.26 → trunk View file →
@@ -7,9 +7,9 @@
7 7
8 8 /**
9 9 * @var bool
10 10 */
11 - public static $use_cache = true;
11 + public static $use_cache = true;
12 12
13 13 /**
14 14 * @var int
15 15 */
@@ -21,66 +21,70 @@
21 21 public static function field_selection() {
22 22 $fields = array(
23 23 'text' => array(
24 24 'name' => __( 'Text', 'formidable' ),
25 - 'icon' => 'frm_icon_font frm_text2_icon',
25 + 'icon' => 'frmfont frm_text2_icon',
26 26 ),
27 27 'textarea' => array(
28 28 'name' => __( 'Paragraph', 'formidable' ),
29 - 'icon' => 'frm_icon_font frm_paragraph_icon',
29 + 'icon' => 'frmfont frm_paragraph_icon',
30 30 ),
31 31 'checkbox' => array(
32 32 'name' => __( 'Checkboxes', 'formidable' ),
33 - 'icon' => 'frm_icon_font frm_check_square_icon',
33 + 'icon' => 'frmfont frm_check_square_icon',
34 34 ),
35 35 'radio' => array(
36 36 'name' => __( 'Radio Buttons', 'formidable' ),
37 - 'icon' => 'frm_icon_font frm_radio_checked_icon',
37 + 'icon' => 'frmfont frm_radio_checked_icon',
38 38 ),
39 39 'select' => array(
40 40 'name' => __( 'Dropdown', 'formidable' ),
41 - 'icon' => 'frm_icon_font frm_dropdown_icon',
41 + 'icon' => 'frmfont frm_dropdown_icon',
42 42 ),
43 43 'email' => array(
44 44 'name' => __( 'Email', 'formidable' ),
45 - 'icon' => 'frm_icon_font frm_email2_icon',
45 + 'icon' => 'frmfont frm_email2_icon',
46 46 ),
47 47 'url' => array(
48 48 'name' => __( 'Website/URL', 'formidable' ),
49 - 'icon' => 'frm_icon_font frm_link2_icon',
49 + 'icon' => 'frmfont frm_link2_icon',
50 50 ),
51 51 'number' => array(
52 52 'name' => __( 'Number', 'formidable' ),
53 - 'icon' => 'frm_icon_font frm_hashtag_icon',
53 + 'icon' => 'frmfont frm_hashtag_icon',
54 54 ),
55 55 'name' => array(
56 56 'name' => __( 'Name', 'formidable' ),
57 - 'icon' => 'frm_icon_font frm_user_name_icon',
57 + 'icon' => 'frmfont frm_user_name_icon',
58 58 ),
59 59 'phone' => array(
60 60 'name' => __( 'Phone', 'formidable' ),
61 - 'icon' => 'frm_icon_font frm_phone_icon',
61 + 'icon' => 'frmfont frm_phone_icon',
62 62 ),
63 63 'html' => array(
64 64 'name' => __( 'HTML', 'formidable' ),
65 - 'icon' => 'frm_icon_font frm_code2_icon',
65 + 'icon' => 'frmfont frm_code2_icon',
66 66 ),
67 67 'hidden' => array(
68 68 'name' => __( 'Hidden', 'formidable' ),
69 - 'icon' => 'frm_icon_font frm_eye_slash2_icon',
69 + 'icon' => 'frmfont frm_eye_slash2_icon',
70 70 ),
71 71 'user_id' => array(
72 72 'name' => __( 'User ID', 'formidable' ),
73 - 'icon' => 'frm_icon_font frm_user2_icon',
73 + 'icon' => 'frmfont frm_user2_icon',
74 74 ),
75 75 'captcha' => array(
76 76 'name' => self::get_captcha_field_name(),
77 - 'icon' => 'frm_icon_font frm_shield_check2_icon',
77 + 'icon' => 'frmfont frm_shield_check2_icon',
78 78 ),
79 79 'credit_card' => array(
80 80 'name' => __( 'Payment', 'formidable' ),
81 - 'icon' => 'frm_icon_font frm_credit_card2_icon',
81 + 'icon' => 'frmfont frm_credit_card2_icon',
82 82 ),
83 + 'address' => array(
84 + 'name' => __( 'Address', 'formidable' ),
85 + 'icon' => 'frmfont frm_location2_icon',
86 + ),
83 87 FrmSubmitHelper::FIELD_TYPE => array(
84 88 'name' => __( 'Submit', 'formidable' ),
85 89 'hide' => true,
86 90 ),
@@ -85,11 +89,26 @@
85 89 'hide' => true,
86 90 ),
87 91 FrmFieldGdprHelper::FIELD_TYPE => array(
88 92 'name' => __( 'GDPR', 'formidable' ),
89 - 'icon' => 'frm_icon_font frm-gdpr-icon',
93 + 'icon' => 'frmfont frm-gdpr-icon',
90 94 'hide' => FrmFieldGdprHelper::hide_gdpr_field(),
91 95 ),
96 + 'product' => array(
97 + 'name' => __( 'Product', 'formidable' ),
98 + 'icon' => 'frmfont frm_product2_icon',
99 + 'section' => 'pricing',
100 + ),
101 + 'quantity' => array(
102 + 'name' => __( 'Quantity', 'formidable' ),
103 + 'icon' => 'frmfont frm_quantity_icon',
104 + 'section' => 'pricing',
105 + ),
106 + 'total' => array(
107 + 'name' => __( 'Total', 'formidable' ),
108 + 'icon' => 'frmfont frm_total2_icon',
109 + 'section' => 'pricing',
110 + ),
92 111 );
93 112
94 113 /**
95 114 * @param array $fields
@@ -113,9 +132,9 @@
113 132 $upsell_images_url = FrmAppHelper::plugin_url() . '/images/upsell/';
114 133 $fields = array(
115 134 'file' => array(
116 135 'name' => __( 'File Upload', 'formidable' ),
117 - 'icon' => 'frm_icon_font frm_upload3_icon',
136 + 'icon' => 'frmfont frm_upload3_icon',
118 137 'message' => __( 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.', 'formidable' ),
119 138 'upsell_image' => $upsell_images_url . 'file-upload-field-preview.webp',
120 139 'learn-more' => 'features/wordpress-multiple-file-upload-form',
121 140 ),
@@ -120,9 +139,9 @@
120 139 'learn-more' => 'features/wordpress-multiple-file-upload-form',
121 140 ),
122 141 'ranking' => array(
123 142 'name' => __( 'Ranking', 'formidable' ),
124 - 'icon' => 'frm_icon_font frm_chart_bar_icon frm_show_upgrade',
143 + 'icon' => 'frmfont frm_chart_bar_icon frm_show_upgrade',
125 144 'message' => __( 'Now you can effortlessly gather insights, preferences, and opinions by allowing users to rank options.', 'formidable' ),
126 145 'upsell_image' => $upsell_images_url . 'ranking-field-preview.webp',
127 146 'addon' => 'surveys',
128 147 'learn-more' => 'ranking-survey',
@@ -128,9 +147,9 @@
128 147 'learn-more' => 'ranking-survey',
129 148 ),
130 149 'rte' => array(
131 150 'name' => __( 'Rich Text', 'formidable' ),
132 - 'icon' => 'frm_icon_font frm_align_right_icon',
151 + 'icon' => 'frmfont frm_align_right_icon',
133 152 'message' => __( 'Go beyond plain text, let your users format their content with bolding, italics, links, lists and more.', 'formidable' ),
134 153 'upsell_image' => $upsell_images_url . 'rich-text-field-preview.webp',
135 154 'learn-more' => 'rich-text',
136 155 ),
@@ -135,44 +154,44 @@
135 154 'learn-more' => 'rich-text',
136 155 ),
137 156 'date' => array(
138 157 'name' => __( 'Date', 'formidable' ),
139 - 'icon' => 'frm_icon_font frm_calendar2_icon',
140 - 'message' => __( 'Capture exact calendar dates effortlessly with a sleek pop-up date picker, ensuring clarity and consistency for scheduling, tracking deadlines, and more.', 'formidable' ),
158 + 'icon' => 'frmfont frm_calendar2_icon',
159 + 'message' => __( 'Capture exact calendar dates effortlessly with a sleek pop-up date picker, ensuring clarity and consistency for scheduling, tracking deadlines, and more.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
141 160 'upsell_image' => $upsell_images_url . 'date-field-preview.webp',
142 161 'learn-more' => 'date',
143 162 ),
144 163 'time' => array(
145 164 'name' => __( 'Time', 'formidable' ),
146 - 'icon' => 'frm_icon_font frm_clock_icon',
147 - 'message' => __( 'Precisely log important moments with an intuitive time selection tool, perfect for managing events, availability, or operational hours.', 'formidable' ),
165 + 'icon' => 'frmfont frm_clock_icon',
166 + 'message' => __( 'Precisely log important moments with an intuitive time selection tool, perfect for managing events, availability, or operational hours.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
148 167 'upsell_image' => $upsell_images_url . 'time-field-preview.webp',
149 168 'learn-more' => 'time',
150 169 ),
151 170 'scale' => array(
152 171 'name' => __( 'Scale', 'formidable' ),
153 - 'icon' => 'frm_icon_font frm_linear_scale_icon',
154 - 'message' => esc_html__( 'Easily measure satisfaction or quantity using a simple, clear numerical scale, giving you fast, quantifiable insights into user feedback.', 'formidable' ),
172 + 'icon' => 'frmfont frm_linear_scale_icon',
173 + 'message' => esc_html__( 'Easily measure satisfaction or quantity using a simple, clear numerical scale, giving you fast, quantifiable insights into user feedback.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
155 174 'upsell_image' => $upsell_images_url . 'scale-field-preview.webp',
156 175 'learn-more' => 'scale',
157 176 ),
158 177 'star' => array(
159 178 'name' => __( 'Star Rating', 'formidable' ),
160 - 'icon' => 'frm_icon_font frm_star2_icon',
161 - 'message' => esc_html__( 'Capture instant, appealing feedback with a familiar visual star system, providing immediate and engaging quality assessments from your users.', 'formidable' ),
179 + 'icon' => 'frmfont frm_star2_icon',
180 + 'message' => esc_html__( 'Capture instant, appealing feedback with a familiar visual star system, providing immediate and engaging quality assessments from your users.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
162 181 'upsell_image' => $upsell_images_url . 'star-field-preview.webp',
163 182 'learn-more' => 'star-ratings',
164 183 ),
165 184 'range' => array(
166 185 'name' => __( 'Slider', 'formidable' ),
167 - 'icon' => 'frm_icon_font frm_code_commit_icon',
168 - 'message' => esc_html__( 'Let users quickly select values within a range using a dynamic, interactive slider, creating a modern and enjoyable data input experience.', 'formidable' ),
186 + 'icon' => 'frmfont frm_code_commit_icon',
187 + 'message' => esc_html__( 'Let users quickly select values within a range using a dynamic, interactive slider, creating a modern and enjoyable data input experience.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
169 188 'upsell_image' => $upsell_images_url . 'slider-field-preview.webp',
170 189 'learn-more' => 'slider',
171 190 ),
172 191 'toggle' => array(
173 192 'name' => __( 'Toggle', 'formidable' ),
174 - 'icon' => 'frm_icon_font frm_toggle_on_icon',
193 + 'icon' => 'frmfont frm_toggle_on_icon',
175 194 'message' => esc_html__( 'Quickly and easily create cascading fields, populate fields by search and more.', 'formidable' ),
176 195 'upsell_image' => $upsell_images_url . 'toggle-field-preview.webp',
177 196 'learn-more' => 'toggle',
178 197 ),
@@ -177,9 +196,9 @@
177 196 'learn-more' => 'toggle',
178 197 ),
179 198 'data' => array(
180 199 'name' => __( 'Dynamic', 'formidable' ),
181 - 'icon' => 'frm_icon_font frm_dynamic_icon',
200 + 'icon' => 'frmfont frm_dynamic_icon',
182 201 'message' => __( 'Link entries together, dynamic display information, and even make selections from data entered on another form.', 'formidable' ),
183 202 'upsell_image' => $upsell_images_url . 'dynamic-field-preview.webp',
184 203 'learn-more' => 'dynamic',
185 204 ),
@@ -184,9 +203,9 @@
184 203 'learn-more' => 'dynamic',
185 204 ),
186 205 'lookup' => array(
187 206 'name' => __( 'Lookup', 'formidable' ),
188 - 'icon' => 'frm_icon_font frm_search_icon',
207 + 'icon' => 'frmfont frm_search_icon',
189 208 'message' => esc_html__( 'Link entries together, dynamic display information, and even make selections from data entered on another form.', 'formidable' ),
190 209 'upsell_image' => $upsell_images_url . 'lookup-field-preview.webp',
191 210 'learn-more' => 'lookup',
192 211 ),
@@ -191,10 +210,10 @@
191 210 'learn-more' => 'lookup',
192 211 ),
193 212 'divider|repeat' => array(
194 213 'name' => __( 'Repeater', 'formidable' ),
195 - 'icon' => 'frm_icon_font frm_refresh_icon',
196 - 'message' => esc_html__( 'Allow users to add rows of fields dynamically as needed (like for multiple attendees or items), making complex data entry flexible and intuitive.', 'formidable' ),
214 + 'icon' => 'frmfont frm_refresh_icon',
215 + 'message' => esc_html__( 'Allow users to add rows of fields dynamically as needed (like for multiple attendees or items), making complex data entry flexible and intuitive.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
197 216 'upsell_image' => $upsell_images_url . 'repeater-field-preview.webp',
198 217 'learn-more' => 'repeatable-section',
199 218 ),
200 219 'end_divider' => array(
@@ -202,54 +221,54 @@
202 221 'switch_from' => 'divider',
203 222 ),
204 223 'divider' => array(
205 224 'name' => __( 'Section', 'formidable' ),
206 - 'icon' => 'frm_icon_font frm_header_icon',
207 - 'message' => esc_html__( 'Enhance the user experience and improve completion rates by dividing long surveys into clean, manageable steps with distinct pages.', 'formidable' ),
225 + 'icon' => 'frmfont frm_header_icon',
226 + 'message' => esc_html__( 'Enhance the user experience and improve completion rates by dividing long surveys into clean, manageable steps with distinct pages.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
208 227 'upsell_image' => $upsell_images_url . 'section-field-preview.webp',
209 228 'learn-more' => 'section-heading',
210 229 ),
211 230 'break' => array(
212 231 'name' => __( 'Page Break', 'formidable' ),
213 - 'icon' => 'frm_icon_font frm_page_break_icon',
214 - 'message' => esc_html__( 'Enhance the user experience and improve completion rates by dividing long surveys into clean, manageable steps with distinct pages.', 'formidable' ),
232 + 'icon' => 'frmfont frm_page_break_icon',
233 + 'message' => esc_html__( 'Enhance the user experience and improve completion rates by dividing long surveys into clean, manageable steps with distinct pages.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
215 234 'upsell_image' => $upsell_images_url . 'page-break-field-preview.webp',
216 235 'learn-more' => 'page-breaks',
217 236 ),
218 237 'form' => array(
219 238 'name' => __( 'Embed Form', 'formidable' ),
220 - 'icon' => 'frm_icon_font frm_file_text2_icon',
221 - 'message' => esc_html__( 'Seamlessly integrate other existing forms or external content directly inside your current form, creating powerful, interconnected workflows.', 'formidable' ),
239 + 'icon' => 'frmfont frm_file_text2_icon',
240 + 'message' => esc_html__( 'Seamlessly integrate other existing forms or external content directly inside your current form, creating powerful, interconnected workflows.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
222 241 'upsell_image' => $upsell_images_url . 'embed-form-field-preview.webp',
223 242 'learn-more' => 'embed-form',
224 243 ),
225 244 'likert' => array(
226 245 'name' => __( 'Likert Scale', 'formidable' ),
227 - 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade',
246 + 'icon' => 'frmfont frm_likert_scale frm_show_upgrade',
228 247 'addon' => 'surveys',
229 - 'message' => esc_html__( 'Get nuanced, detailed opinions using standardized agreement scales, unlocking deeper insights beyond simple yes/no answers.', 'formidable' ),
248 + 'message' => esc_html__( 'Get nuanced, detailed opinions using standardized agreement scales, unlocking deeper insights beyond simple yes/no answers.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
230 249 'upsell_image' => $upsell_images_url . 'likert-field-preview.webp',
231 250 'learn-more' => 'likert-scale',
232 251 ),
233 252 'nps' => array(
234 253 'name' => __( 'NPS', 'formidable' ),
235 - 'icon' => 'frm_icon_font frm_nps frm_show_upgrade',
254 + 'icon' => 'frmfont frm_nps frm_show_upgrade',
236 255 'addon' => 'surveys',
237 - 'message' => esc_html__( 'Directly measure customer loyalty with the industry-standard Net Promoter Score® field, giving you a single, vital metric for business growth.', 'formidable' ),
256 + 'message' => esc_html__( 'Directly measure customer loyalty with the industry-standard Net Promoter Score® field, giving you a single, vital metric for business growth.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
238 257 'upsell_image' => $upsell_images_url . 'nps-field-preview.webp',
239 258 'learn-more' => 'net-promoter-score',
240 259 ),
241 260 'password' => array(
242 261 'name' => __( 'Password', 'formidable' ),
243 - 'icon' => 'frm_icon_font frm_lock_closed2_icon',
244 - 'message' => esc_html__( 'Confidently collect sensitive credentials or create secure sections with a dedicated field that masks input for privacy and security.', 'formidable' ),
262 + 'icon' => 'frmfont frm_lock_closed2_icon',
263 + 'message' => esc_html__( 'Confidently collect sensitive credentials or create secure sections with a dedicated field that masks input for privacy and security.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
245 264 'upsell_image' => $upsell_images_url . 'password-field-preview.webp',
246 265 'learn-more' => 'password-2',
247 266 ),
248 267 'tag' => array(
249 268 'name' => __( 'Tags', 'formidable' ),
250 - 'icon' => 'frm_icon_font frm_price_tags2_icon',
251 - 'message' => esc_html__( 'Facilitate easy categorization and analysis by letting users select or create multiple relevant keywords or labels for their entry.', 'formidable' ),
269 + 'icon' => 'frmfont frm_price_tags2_icon',
270 + 'message' => esc_html__( 'Facilitate easy categorization and analysis by letting users select or create multiple relevant keywords or labels for their entry.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
252 271 'upsell_image' => $upsell_images_url . 'tags-field-preview.webp',
253 272 'learn-more' => 'tags',
254 273 ),
255 274 // This is no longer a Pro field, but without this here, Pro triggers "undefined index" notices.
@@ -259,23 +278,23 @@
259 278 'icon' => '',
260 279 ),
261 280 'address' => array(
262 281 'name' => __( 'Address', 'formidable' ),
263 - 'icon' => 'frm_icon_font frm_location2_icon',
264 - 'message' => esc_html__( 'Instantly capture location information, simplifying logistics and contact collection. (Or go further with our Geolocation add-on!)', 'formidable' ),
282 + 'icon' => 'frmfont frm_location2_icon',
283 + 'message' => esc_html__( 'Instantly capture location information, simplifying logistics and contact collection. (Or go further with our Geolocation add-on!)', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
265 284 'upsell_image' => $upsell_images_url . 'address-field-preview.webp',
266 285 'learn-more' => 'address',
267 286 ),
268 287 'summary' => array(
269 288 'name' => __( 'Summary', 'formidable' ),
270 - 'icon' => 'frm_icon_font frm_file_text3_icon',
271 - 'message' => __( 'Provide users with a clean, final review of all their entered data before submission, reducing errors and improving data quality.', 'formidable' ),
289 + 'icon' => 'frmfont frm_file_text3_icon',
290 + 'message' => __( 'Provide users with a clean, final review of all their entered data before submission, reducing errors and improving data quality.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
272 291 'upsell_image' => $upsell_images_url . 'summary-field-preview.webp',
273 292 'learn-more' => 'summary-review-before-submit',
274 293 ),
275 294 'signature' => array(
276 295 'name' => __( 'Signature', 'formidable' ),
277 - 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade',
296 + 'icon' => 'frmfont frm_signature_icon frm_show_upgrade',
278 297 'addon' => 'signature',
279 298 'message' => __( 'Capture digital e-signatures directly within your form, making official agreements and authorizations straightforward.', 'formidable' ),
280 299 'upsell_image' => $upsell_images_url . 'signature-field-preview.webp',
281 300 'learn-more' => 'formidable-signature',
@@ -281,9 +300,9 @@
281 300 'learn-more' => 'formidable-signature',
282 301 ),
283 302 'ai' => array(
284 303 'name' => __( 'AI', 'formidable' ),
285 - 'icon' => 'frm_icon_font frm-ai-icon frm_show_upgrade',
304 + 'icon' => 'frmfont frm-ai-icon frm_show_upgrade',
286 305 'addon' => 'ai',
287 306 'message' => __( 'Harness artificial intelligence by taking user input and let the model of your choice create an output, quickly and easily.', 'formidable' ),
288 307 'upsell_image' => $upsell_images_url . 'ai-field-preview.webp',
289 308 'learn-more' => 'form-ai',
@@ -289,13 +308,13 @@
289 308 'learn-more' => 'form-ai',
290 309 ),
291 310 'ssa-appointment' => array(
292 311 'name' => __( 'Appointment', 'formidable' ),
293 - 'icon' => 'frm_icon_font frm_schedule_icon frm_show_upgrade',
312 + 'icon' => 'frmfont frm_schedule_icon frm_show_upgrade',
294 313 'require' => 'Simply Schedule Appointments',
295 314 'message' => sprintf(
296 315 /* translators: %1$s: Link opening HTML, %2$s: Link tag closing */
297 - esc_html__( 'Appointment fields are an integration with %1$sSimply Schedule Appointments%2$s. Get started now to schedule appointments directly from your forms.', 'formidable' ),
316 + esc_html__( 'Appointment fields are an integration with %1$sSimply Schedule Appointments%2$s. Get started now to schedule appointments directly from your forms.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
298 317 '<a class="frm-inline-flex" href="https://simplyscheduleappointments.com/meet/formidable/" target="_blank" rel="noopener">',
299 318 '</a>'
300 319 ),
301 320 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
@@ -301,32 +320,48 @@
301 320 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
302 321 'upsell_image' => $upsell_images_url . 'appointment-field-preview.webp',
303 322 'learn-more' => 'simply-schedule-appointments-forms',
304 323 ),
324 + 'virtual' => array(
325 + 'name' => __( 'Virtual', 'formidable' ),
326 + 'icon' => 'frmfont frm-virtual-field-icon',
327 + 'message' => esc_html__( 'Protect sensitive data by storing field values server-side only, preventing users from viewing or manipulating them in their browser.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
328 + 'upsell_image' => $upsell_images_url . 'virtual-field-preview.webp',
329 + 'learn-more' => '/virtual',
330 + 'is_new' => self::field_is_new( 'virtual' ),
331 + ),
305 332 'product' => array(
306 333 'name' => __( 'Product', 'formidable' ),
307 - 'icon' => 'frm_icon_font frm_product2_icon',
334 + 'icon' => 'frmfont frm_product2_icon',
308 335 'section' => 'pricing',
309 - 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ),
336 + 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
310 337 'upsell_image' => $upsell_images_url . 'product-field-preview.webp',
311 338 'learn-more' => 'features/pricing-fields',
312 339 ),
313 340 'quantity' => array(
314 341 'name' => __( 'Quantity', 'formidable' ),
315 - 'icon' => 'frm_icon_font frm_quantity_icon',
342 + 'icon' => 'frmfont frm_quantity_icon',
316 343 'section' => 'pricing',
317 - 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ),
344 + 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
318 345 'upsell_image' => $upsell_images_url . 'quantity-field-preview.webp',
319 346 'learn-more' => 'features/pricing-fields',
320 347 ),
321 348 'total' => array(
322 349 'name' => __( 'Total', 'formidable' ),
323 - 'icon' => 'frm_icon_font frm_total2_icon',
350 + 'icon' => 'frmfont frm_total2_icon',
324 351 'section' => 'pricing',
325 - 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ),
352 + 'message' => __( 'Turn your form into a simple storefront by adding fields to list products, choose quantities, and calculate totals, enabling direct sales.', 'formidable' ), // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
326 353 'upsell_image' => $upsell_images_url . 'total-field-preview.webp',
327 354 'learn-more' => 'features/pricing-fields',
328 355 ),
356 + 'coupon' => array(
357 + 'name' => __( 'Coupon', 'formidable' ),
358 + 'icon' => 'frm_icon_font frm_coupon_icon frm_show_upgrade',
359 + 'addon' => 'coupons',
360 + 'section' => 'pricing',
361 + 'limit' => 1,
362 + 'is_new' => self::field_is_new( 'coupon' ),
363 + ),
329 364 );
330 365
331 366 // Since the signature field may be in a different section, don't show it twice.
332 367 $lite_fields = self::field_selection();
@@ -338,8 +373,41 @@
338 373 return apply_filters( 'frm_pro_available_fields', $fields );
339 374 }
340 375
341 376 /**
377 + * Flag Pro field types that require a newer Pro version with frm_show_update.
378 + *
379 + * @since 6.29
380 + *
381 + * @param array $fields Available Pro field types.
382 + *
383 + * @return array
384 + */
385 + public static function show_update_for_pro_fields( $fields ) {
386 + if ( FrmAppHelper::pro_is_installed() && ! class_exists( 'FrmProVirtualFieldController', false ) ) {
387 + $fields['virtual']['icon'] .= ' frm_show_update';
388 + }
389 +
390 + return $fields;
391 + }
392 +
393 + /**
394 + * Gets field section labels in the form builder.
395 + *
396 + * @since 6.30
397 + *
398 + * @return array
399 + */
400 + public static function field_section_labels() {
401 + return apply_filters(
402 + 'frm_available_field_sections',
403 + array(
404 + 'pricing' => __( 'Pricing Fields', 'formidable' ),
405 + )
406 + );
407 + }
408 +
409 + /**
342 410 * Consider a field new for 90 days after the release date.
343 411 *
344 412 * @since 6.8.3
345 413 *
@@ -348,9 +416,9 @@
348 416 * @return bool
349 417 */
350 418 private static function field_is_new( $type ) {
351 419 $release_dates = array(
352 - 'ranking' => '2024-03-12',
420 + 'virtual' => '2026-03-10',
353 421 );
354 422
355 423 if ( ! isset( $release_dates[ $type ] ) ) {
356 424 return false;
@@ -355,22 +423,37 @@
355 423 if ( ! isset( $release_dates[ $type ] ) ) {
356 424 return false;
357 425 }
358 426
359 - $release_date = $release_dates[ $type ];
360 -
427 + $release_date = $release_dates[ $type ];
361 428 $three_months_after_release = gmdate( 'Y-m-d', strtotime( $release_date . ' + 90 days' ) );
362 429 return gmdate( 'Y-m-d' ) < $three_months_after_release;
363 430 }
364 431
365 432 /**
433 + * Remove field types that are moved from Pro to Lite.
434 + *
435 + * @since 6.30
436 + *
437 + * @param array $pro_fields
438 + *
439 + * @return void
440 + */
441 + public static function remove_moved_field_types_from_pro( &$pro_fields ) {
442 + unset( $pro_fields['credit_card'] );
443 + unset( $pro_fields['product'] );
444 + unset( $pro_fields['quantity'] );
445 + unset( $pro_fields['total'] );
446 + unset( $pro_fields['address'] );
447 + }
448 +
449 + /**
366 450 * @since 4.0
367 451 *
368 452 * @return array
369 453 */
370 454 public static function all_field_selection() {
371 - $pro_field_selection = self::pro_field_selection();
372 - return array_merge( $pro_field_selection, self::field_selection() );
455 + return array_merge( self::pro_field_selection(), self::field_selection() );
373 456 }
374 457
375 458 /**
376 459 * Create a field.
@@ -394,13 +477,19 @@
394 477 $new_values[ $col ] = $values[ $col ];
395 478 }
396 479 }
397 480
398 - $new_values['options'] = self::maybe_filter_options( $values['options'] );
481 + // Both option columns are stored serialized, but they do not accept the same shapes.
482 + // Choice fields pass options already serialized, as does FrmFieldsHelper::fill_field
483 + // when a field is duplicated, and fields with no choices pass an empty string, so a
484 + // missing key is the only thing worth defaulting. An is_array check here would throw
485 + // every one of those defaults away. field_options is always an array, so anything
486 + // else is invalid input, and replacing it stops consumers getting null.
487 + $new_values['options'] = self::maybe_filter_options( $values['options'] ?? array() );
399 488 $new_values['field_order'] = isset( $values['field_order'] ) ? (int) $values['field_order'] : null;
400 489 $new_values['required'] = isset( $values['required'] ) ? (int) $values['required'] : 0;
401 490 $new_values['form_id'] = isset( $values['form_id'] ) ? (int) $values['form_id'] : null;
402 - $new_values['field_options'] = $values['field_options'];
491 + $new_values['field_options'] = isset( $values['field_options'] ) && is_array( $values['field_options'] ) ? $values['field_options'] : array();
403 492 $new_values['created_at'] = current_time( 'mysql', 1 );
404 493
405 494 if ( isset( $values['id'] ) ) {
406 495 $frm_duplicate_ids[ $values['field_key'] ] = $new_values['field_key'];
@@ -410,13 +499,9 @@
410 499 self::preserve_format_option_backslashes( $new_values );
411 500
412 501 foreach ( $new_values as $k => $v ) {
413 502 if ( is_array( $v ) ) {
414 - if ( $k === 'default_value' ) {
415 - $new_values[ $k ] = FrmAppHelper::maybe_json_encode( $v );
416 - } else {
417 - $new_values[ $k ] = serialize( $v );
418 - }
503 + $new_values[ $k ] = $k === 'default_value' ? FrmAppHelper::maybe_json_encode( $v ) : serialize( $v );
419 504 }
420 505 unset( $k, $v );
421 506 }
422 507
@@ -426,14 +511,15 @@
426 511 return false;
427 512 }
428 513
429 514 self::delete_form_transient( $new_values['form_id'] );
430 - $new_id = $wpdb->insert_id;
431 515
432 516 if ( ! $return ) {
433 517 return false;
434 518 }
435 519
520 + $new_id = $wpdb->insert_id;
521 +
436 522 if ( isset( $values['id'] ) ) {
437 523 $frm_duplicate_ids[ $values['id'] ] = $new_id;
438 524 }
439 525
@@ -446,9 +532,9 @@
446 532 * See FrmAppHelper::allow_unfiltered_html.
447 533 *
448 534 * @since 5.0.08
449 535 *
450 - * @param array $options
536 + * @param array|string $options Already serialized for choice fields, and an empty string for fields with no choices.
451 537 *
452 538 * @return array
453 539 */
454 540 private static function maybe_filter_options( $options ) {
@@ -498,13 +584,9 @@
498 584
499 585 $safe_atts = array();
500 586
501 587 foreach ( $attr as $attr_key => $att ) {
502 - if ( ! is_numeric( $attr_key ) ) {
503 - // opt=1 without parentheses for example is mapped like 'opt' => 1.
504 - $key = $attr_key;
505 - $value = $att;
506 - } else {
588 + if ( is_numeric( $attr_key ) ) {
507 589 // Some data is mapped like 0 => 'placeholder="Placeholder"'.
508 590 $split = explode( '=', $att, 2 );
509 591
510 592 if ( 2 !== count( $split ) ) {
@@ -512,8 +594,12 @@
512 594 }
513 595
514 596 $key = trim( $split[0] );
515 597 $value = trim( $split[1], '"' );
598 + } else {
599 + // opt=1 without parentheses for example is mapped like 'opt' => 1.
600 + $key = $attr_key;
601 + $value = $att;
516 602 }
517 603
518 604 if ( FrmAppHelper::input_key_is_safe( $key, 'update' ) ) {
519 605 $safe_atts[ $key ] = $value;
@@ -553,10 +639,9 @@
553 639 $values = array(
554 640 'id' => $copy_field->id,
555 641 );
556 642 FrmFieldsHelper::fill_field( $values, $copy_field, $copy_field->form_id );
557 - $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
558 -
643 + $values = apply_filters( 'frm_prepare_single_field_for_duplication', $values );
559 644 $field_id = self::create( $values );
560 645
561 646 /**
562 647 * Fires after duplicating a field.
@@ -599,8 +684,9 @@
599 684
600 685 foreach ( (array) $fields as $field ) {
601 686 $new_key = $copy_keys ? $field->field_key : '';
602 687
688 + // phpcs:ignore Universal.Operators.StrictComparisons
603 689 if ( $copy_keys && substr( $field->field_key, - 1 ) == 2 ) {
604 690 $new_key = rtrim( $new_key, 2 );
605 691 }
606 692
@@ -608,9 +694,9 @@
608 694 FrmFieldsHelper::fill_field( $values, $field, $form_id, $new_key );
609 695
610 696 // If this is a repeating section, create new form
611 697 if ( self::is_repeating_field( $field ) ) {
612 - // create the repeatable form
698 + // Create the repeatable form
613 699 $new_repeat_form_id = apply_filters(
614 700 'frm_create_repeat_form',
615 701 0,
616 702 array(
@@ -626,9 +712,9 @@
626 712 $values['field_options']['form_select'] = $new_repeat_form_id;
627 713 }
628 714
629 715 // If this is a field inside of a repeating section, associate it with the correct form
630 - if ( $field->form_id != $old_form_id && isset( $old_repeat_form_id ) && isset( $new_repeat_form_id ) && $field->form_id == $old_repeat_form_id ) {
716 + if ( (int) $field->form_id !== (int) $old_form_id && isset( $old_repeat_form_id ) && isset( $new_repeat_form_id ) && (int) $field->form_id === (int) $old_repeat_form_id ) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
631 717 $values['form_id'] = $new_repeat_form_id;
632 718 }
633 719
634 720 $values['description'] = FrmFieldsHelper::switch_field_ids( $values['description'] );
@@ -678,21 +764,24 @@
678 764 */
679 765 $values = apply_filters( 'frm_clean_' . $values['type'] . '_field_options_before_update', $values, $id );
680 766
681 767 if ( $values['type'] === 'hidden' && isset( $values['field_options'] ) && isset( $values['field_options']['clear_on_focus'] ) ) {
682 - // don't keep the old placeholder setting for hidden fields
768 + // Don't keep the old placeholder setting for hidden fields
683 769 $values['field_options']['clear_on_focus'] = 0;
684 770 }
685 771 }
686 772
687 - // serialize array values
773 + // Serialize array values
688 774 foreach ( array( 'field_options', 'options' ) as $opt ) {
689 - if ( isset( $values[ $opt ] ) && is_array( $values[ $opt ] ) ) {
690 - if ( 'field_options' === $opt ) {
691 - $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] );
692 - }
693 - $values[ $opt ] = serialize( $values[ $opt ] );
775 + if ( ! isset( $values[ $opt ] ) || ! is_array( $values[ $opt ] ) ) {
776 + continue;
694 777 }
778 +
779 + if ( 'field_options' === $opt ) {
780 + $values[ $opt ] = self::maybe_filter_options( $values[ $opt ] );
781 + }
782 +
783 + $values[ $opt ] = serialize( $values[ $opt ] );
695 784 }
696 785
697 786 if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) {
698 787 $values['default_value'] = json_encode( $values['default_value'] );
@@ -698,11 +787,10 @@
698 787 $values['default_value'] = json_encode( $values['default_value'] );
699 788 }
700 789
701 790 $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
791 + $form_id = 0;
702 792
703 - $form_id = 0;
704 -
705 793 if ( isset( $values['form_id'] ) ) {
706 794 $form_id = absint( $values['form_id'] );
707 795 } else {
708 796 $field = self::getOne( $id );
@@ -776,15 +864,15 @@
776 864 delete_transient( 'frm_form_fields_' . $form_id . 'includeexclude' );
777 865 delete_transient( 'frm_form_fields_' . $form_id . 'excludeexclude' );
778 866
779 867 global $wpdb;
780 - $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) );
868 + $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->options . ' WHERE option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s OR option_name LIKE %s', '_transient_timeout_frm_form_fields_' . $form_id . 'ex%', '_transient_frm_form_fields_' . $form_id . 'ex%', '_transient_timeout_frm_form_fields_' . $form_id . 'in%', '_transient_frm_form_fields_' . $form_id . 'in%' ) ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
781 869
782 870 FrmDb::cache_delete_group( 'frm_field' );
783 871
784 872 $form = FrmForm::getOne( $form_id );
785 873
786 - if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
874 + if ( $form && $form->parent_form_id && (int) $form->parent_form_id !== $form_id ) {
787 875 self::delete_form_transient( $form->parent_form_id );
788 876 }
789 877 }
790 878
@@ -807,9 +895,9 @@
807 895 *
808 896 * @return object|null
809 897 */
810 898 public static function getOne( $id, $filter = false ) {
811 - if ( empty( $id ) ) {
899 + if ( ! $id ) {
812 900 return null;
813 901 }
814 902
815 903 global $wpdb;
@@ -818,9 +906,9 @@
818 906 $query = $wpdb->prepare( 'SELECT * FROM ' . $wpdb->prefix . 'frm_fields WHERE ' . $where, $id ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
819 907
820 908 $results = FrmDb::check_cache( $id, 'frm_field', $query, 'get_row', 0 );
821 909
822 - if ( empty( $results ) ) {
910 + if ( ! $results ) {
823 911 self::filter_field( $filter, $results );
824 912 return $results;
825 913 }
826 914
@@ -864,20 +952,14 @@
864 952 public static function get_type( $id, $col = 'type' ) {
865 953 $field = FrmDb::check_cache( $id, 'frm_field' );
866 954
867 955 if ( $field ) {
868 - $type = $field->{$col};
869 - } else {
870 - if ( is_numeric( $id ) ) {
871 - $where = array( 'id' => $id );
872 - } else {
873 - $where = array( 'field_key' => $id );
874 - }
956 + return $field->{$col};
957 + }
875 958
876 - $type = FrmDb::get_var( 'frm_fields', $where, $col );
877 - }
959 + $where = is_numeric( $id ) ? array( 'id' => $id ) : array( 'field_key' => $id );
878 960
879 - return $type;
961 + return FrmDb::get_var( 'frm_fields', $where, $col );
880 962 }
881 963
882 964 /**
883 965 * @param int|string $form_id
@@ -899,14 +981,14 @@
899 981 'inc_repeat' => $inc_sub,
900 982 )
901 983 );
902 984
903 - if ( ! empty( $results ) ) {
985 + if ( $results ) {
904 986 $fields = array();
905 987 $count = 0;
906 988
907 989 foreach ( $results as $result ) {
908 - if ( $type != $result->type ) {
990 + if ( $type !== $result->type ) {
909 991 continue;
910 992 }
911 993
912 994 $fields[ $result->id ] = $result;
@@ -911,14 +993,15 @@
911 993
912 994 $fields[ $result->id ] = $result;
913 995 ++$count;
914 996
997 + // phpcs:ignore Universal.Operators.StrictComparisons
915 998 if ( $limit == 1 ) {
916 999 $fields = $result;
917 1000 break;
918 1001 }
919 1002
920 - if ( ! empty( $limit ) && $count >= $limit ) {
1003 + if ( $limit && $count >= $limit ) {
921 1004 break;
922 1005 }
923 1006
924 1007 unset( $result );
@@ -955,10 +1038,10 @@
955 1038 }
956 1039
957 1040 $results = self::get_fields_from_transients( $form_id, compact( 'inc_embed', 'inc_repeat' ) );
958 1041
959 - if ( ! empty( $results ) ) {
960 - if ( empty( $limit ) ) {
1042 + if ( $results ) {
1043 + if ( ! $limit ) {
961 1044 return $results;
962 1045 }
963 1046
964 1047 $fields = array();
@@ -967,9 +1050,9 @@
967 1050 foreach ( $results as $result ) {
968 1051 ++$count;
969 1052 $fields[ $result->id ] = $result;
970 1053
971 - if ( ! empty( $limit ) && $count >= $limit ) {
1054 + if ( $limit && $count >= $limit ) {
972 1055 break;
973 1056 }
974 1057 }
975 1058
@@ -985,9 +1068,9 @@
985 1068 self::$use_cache = true;
986 1069
987 1070 self::include_sub_fields( $results, $inc_embed, 'all', $form_id );
988 1071
989 - if ( empty( $limit ) ) {
1072 + if ( ! $limit ) {
990 1073 self::set_field_transient( $results, $form_id, 0, compact( 'inc_embed', 'inc_repeat' ) );
991 1074 }
992 1075
993 1076 return $results;
@@ -1001,17 +1084,19 @@
1001 1084 *
1002 1085 * @return void
1003 1086 */
1004 1087 private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
1005 - if ( $inc_repeat === 'include' ) {
1006 - $form_id = $where['fi.form_id'];
1007 - $where[] = array(
1008 - 'or' => 1,
1009 - 'fi.form_id' => $form_id,
1010 - 'fr.parent_form_id' => $form_id,
1011 - );
1012 - unset( $where['fi.form_id'] );
1088 + if ( $inc_repeat !== 'include' ) {
1089 + return;
1013 1090 }
1091 +
1092 + $form_id = $where['fi.form_id'];
1093 + $where[] = array(
1094 + 'or' => 1,
1095 + 'fi.form_id' => $form_id,
1096 + 'fr.parent_form_id' => $form_id,
1097 + );
1098 + unset( $where['fi.form_id'] );
1014 1099 }
1015 1100
1016 1101 /**
1017 1102 * @param array $results
@@ -1021,16 +1106,16 @@
1021 1106 *
1022 1107 * @return void
1023 1108 */
1024 1109 public static function include_sub_fields( &$results, $inc_embed, $type = 'all', $form_id = '' ) {
1025 - $no_sub_forms = empty( $results ) && $type === 'all';
1110 + $no_sub_forms = ! $results && $type === 'all';
1026 1111
1027 - if ( 'include' != $inc_embed || $no_sub_forms ) {
1112 + if ( 'include' !== $inc_embed || $no_sub_forms ) {
1028 1113 return;
1029 1114 }
1030 1115
1031 1116 $form_fields = $results;
1032 - $should_get_subforms = ( $type !== 'all' && $type !== 'form' && ! empty( $form_id ) );
1117 + $should_get_subforms = $type !== 'all' && $type !== 'form' && $form_id;
1033 1118
1034 1119 if ( $should_get_subforms ) {
1035 1120 $form_fields = self::get_all_types_in_form( $form_id, 'form' );
1036 1121 }
@@ -1037,9 +1122,9 @@
1037 1122
1038 1123 $index_offset = 1;
1039 1124
1040 1125 foreach ( $form_fields as $k => $field ) {
1041 - if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
1126 + if ( 'form' !== $field->type || ! isset( $field->field_options['form_select'] ) ) {
1042 1127 continue;
1043 1128 }
1044 1129
1045 1130 if ( $type === 'all' ) {
@@ -1068,9 +1153,9 @@
1068 1153 public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
1069 1154 $cache_key = FrmAppHelper::maybe_json_encode( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
1070 1155
1071 1156 if ( self::$use_cache ) {
1072 - // make sure old cache doesn't get saved as a transient
1157 + // Make sure old cache doesn't get saved as a transient
1073 1158 $results = wp_cache_get( $cache_key, 'frm_field' );
1074 1159
1075 1160 if ( false !== $results ) {
1076 1161 return wp_unslash( $results );
@@ -1079,10 +1164,9 @@
1079 1164
1080 1165 global $wpdb;
1081 1166
1082 1167 if ( $blog_id && is_multisite() ) {
1083 - $prefix = $wpdb->get_blog_prefix( $blog_id );
1084 -
1168 + $prefix = $wpdb->get_blog_prefix( $blog_id );
1085 1169 $table_name = $prefix . 'frm_fields';
1086 1170 $form_table_name = $prefix . 'frm_forms';
1087 1171 } else {
1088 1172 $table_name = $wpdb->prefix . 'frm_fields';
@@ -1088,16 +1172,15 @@
1088 1172 $table_name = $wpdb->prefix . 'frm_fields';
1089 1173 $form_table_name = $wpdb->prefix . 'frm_forms';
1090 1174 }
1091 1175
1092 - if ( ! empty( $order_by ) && strpos( $order_by, 'ORDER BY' ) === false ) {
1176 + if ( $order_by && ! str_contains( $order_by, 'ORDER BY' ) ) {
1093 1177 $order_by = ' ORDER BY ' . $order_by;
1094 1178 }
1095 1179
1096 - $limit = FrmDb::esc_limit( $limit );
1097 -
1180 + $limit = FrmDb::esc_limit( $limit );
1098 1181 $query = "SELECT fi.*, fr.name as form_name FROM {$table_name} fi JOIN {$form_table_name} fr ON fi.form_id=fr.id";
1099 - $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results';
1182 + $query_type = $limit === ' LIMIT 1' || $limit == 1 ? 'row' : 'results'; // phpcs:ignore Universal.Operators.StrictComparisons
1100 1183
1101 1184 if ( is_array( $where ) ) {
1102 1185 $args = array(
1103 1186 'order_by' => $order_by,
@@ -1104,9 +1187,9 @@
1104 1187 'limit' => $limit,
1105 1188 );
1106 1189 $results = FrmDb::get_var( $table_name . ' fi JOIN ' . $form_table_name . ' fr ON fi.form_id=fr.id', $where, 'fi.*, fr.name as form_name', $args, '', $query_type );
1107 1190 } else {
1108 - // if the query is not an array, then it has already been prepared
1191 + // If the query is not an array, then it has already been prepared
1109 1192 $query .= FrmDb::prepend_and_or_where( ' WHERE ', $where ) . $order_by . $limit;
1110 1193
1111 1194 $function_name = $query_type === 'row' ? 'get_row' : 'get_results';
1112 1195 $results = $wpdb->$function_name( $query );
@@ -1186,14 +1269,16 @@
1186 1269 $before = $results->default_value;
1187 1270
1188 1271 $field_object = FrmFieldFactory::get_field_type( $results->type );
1189 1272
1190 - if ( $field_object->should_unserialize_value() ) {
1191 - FrmAppHelper::unserialize_or_decode( $results->default_value );
1273 + if ( ! $field_object->should_unserialize_value() ) {
1274 + return;
1275 + }
1192 1276
1193 - if ( $before === $results->default_value && is_string( $before ) && strpos( $before, '["' ) === 0 ) {
1194 - $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
1195 - }
1277 + FrmAppHelper::unserialize_or_decode( $results->default_value );
1278 +
1279 + if ( $before === $results->default_value && is_string( $before ) && str_starts_with( $before, '["' ) ) {
1280 + $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
1196 1281 }
1197 1282 }
1198 1283
1199 1284 /**
@@ -1228,17 +1313,21 @@
1228 1313 private static function get_next_transient( &$fields, $base_name, $next = 0 ) {
1229 1314 $name = $next ? $base_name . $next : $base_name;
1230 1315 $next_fields = get_transient( $name );
1231 1316
1232 - if ( $next_fields ) {
1233 - $fields = array_merge( $fields, $next_fields );
1317 + if ( ! $next_fields ) {
1318 + return;
1319 + }
1234 1320
1235 - if ( count( $next_fields ) >= self::$transient_size ) {
1236 - // if this transient is full, check for another
1237 - ++$next;
1238 - self::get_next_transient( $fields, $base_name, $next );
1239 - }
1321 + $fields = array_merge( $fields, $next_fields );
1322 +
1323 + if ( count( $next_fields ) < self::$transient_size ) {
1324 + return;
1240 1325 }
1326 +
1327 + // If this transient is full, check for another
1328 + ++$next;
1329 + self::get_next_transient( $fields, $base_name, $next );
1241 1330 }
1242 1331
1243 1332 /**
1244 1333 * Save the transients in chunks for large forms
@@ -1260,11 +1349,11 @@
1260 1349 $name = $next ? $base_name . $next : $base_name;
1261 1350 $set = set_transient( $name, $field, 60 * 60 * 6 );
1262 1351
1263 1352 if ( ! $set ) {
1264 - // the transient didn't save
1353 + // The transient didn't save
1265 1354 if ( $name !== $base_name ) {
1266 - // if the first saved an others fail, this will show an incomplete form
1355 + // If the first saved an others fail, this will show an incomplete form
1267 1356 self::delete_form_transient( $form_id );
1268 1357 }
1269 1358
1270 1359 return;
@@ -1305,15 +1394,9 @@
1305 1394 }
1306 1395
1307 1396 $field_type = self::get_original_field_type( $field );
1308 1397
1309 - $is_multi_value_field = (
1310 - self::is_checkbox( $field ) ||
1311 - $field_type === 'address' ||
1312 - self::is_multiple_select( $field )
1313 - );
1314 -
1315 - return $is_multi_value_field;
1398 + return self::is_checkbox( $field ) || $field_type === 'address' || self::is_multiple_select( $field );
1316 1399 }
1317 1400
1318 1401 /**
1319 1402 * @since 3.0
@@ -1336,11 +1419,11 @@
1336 1419 public static function get_original_field_type( $field ) {
1337 1420 $field_type = self::get_field_type( $field );
1338 1421 $original_type = self::get_option( $field, 'original_type' );
1339 1422
1340 - if ( ! empty( $original_type ) && $original_type != $field_type ) {
1423 + if ( $original_type && $original_type !== $field_type ) {
1341 1424 // Check the original type for arrays.
1342 - $field_type = $original_type;
1425 + return $original_type;
1343 1426 }
1344 1427
1345 1428 return $field_type;
1346 1429 }
@@ -1354,11 +1437,9 @@
1354 1437 *
1355 1438 * @return bool
1356 1439 */
1357 1440 public static function is_multiple_select( $field ) {
1358 - $field_type = self::get_field_type( $field );
1359 - $is_multiple = self::is_option_true( $field, 'multiple' ) && self::is_field_type( $field, 'select' ) && $field_type !== 'hidden';
1360 -
1441 + $is_multiple = self::is_option_true( $field, 'multiple' ) && self::is_field_type( $field, 'select' ) && self::get_field_type( $field ) !== 'hidden';
1361 1442 return apply_filters( 'frm_is_multiple_select', $is_multiple, $field );
1362 1443 }
1363 1444
1364 1445 /**
@@ -1383,17 +1464,15 @@
1383 1464 *
1384 1465 * @return bool
1385 1466 */
1386 1467 public static function is_required( $field ) {
1387 - $required = $field['required'] != '0';
1468 + $required = $field['required'] != '0'; // phpcs:ignore Universal.Operators.StrictComparisons
1388 1469
1389 1470 /**
1390 1471 * @param bool $required
1391 1472 * @param array $field
1392 1473 */
1393 - $required = (bool) apply_filters( 'frm_is_field_required', $required, $field );
1394 -
1395 - return $required;
1474 + return (bool) apply_filters( 'frm_is_field_required', $required, $field );
1396 1475 }
1397 1476
1398 1477 /**
1399 1478 * @since 2.0.9
@@ -1441,9 +1520,9 @@
1441 1520 *
1442 1521 * @return bool
1443 1522 */
1444 1523 public static function is_option_true_in_object( $field, $option ) {
1445 - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
1524 + return ! empty( $field->field_options[ $option ] );
1446 1525 }
1447 1526
1448 1527 /**
1449 1528 * @param array $field
@@ -1471,9 +1550,9 @@
1471 1550 *
1472 1551 * @return bool
1473 1552 */
1474 1553 public static function is_option_value_in_object( $field, $option ) {
1475 - return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
1554 + return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != ''; // phpcs:ignore Universal.Operators.StrictComparisons
1476 1555 }
1477 1556
1478 1557 /**
1479 1558 * @since 2.0.18
@@ -1483,15 +1562,9 @@
1483 1562 *
1484 1563 * @return mixed
1485 1564 */
1486 1565 public static function get_option( $field, $option ) {
1487 - if ( is_array( $field ) ) {
1488 - $option = self::get_option_in_array( $field, $option );
1489 - } else {
1490 - $option = self::get_option_in_object( $field, $option );
1491 - }
1492 -
1493 - return $option;
1566 + return is_array( $field ) ? self::get_option_in_array( $field, $option ) : self::get_option_in_object( $field, $option );
1494 1567 }
1495 1568
1496 1569 /**
1497 1570 * @param array $field
@@ -1528,14 +1601,9 @@
1528 1601 *
1529 1602 * @return bool
1530 1603 */
1531 1604 public static function is_repeating_field( $field ) {
1532 - if ( is_array( $field ) ) {
1533 - $is_repeating_field = ( 'divider' === $field['type'] );
1534 - } else {
1535 - $is_repeating_field = ( 'divider' === $field->type );
1536 - }
1537 -
1605 + $is_repeating_field = is_array( $field ) ? 'divider' === $field['type'] : 'divider' === $field->type;
1538 1606 return $is_repeating_field && self::is_option_true( $field, 'repeat' );
1539 1607 }
1540 1608
1541 1609 /**
@@ -1544,9 +1612,8 @@
1544 1612 * @return int field id
1545 1613 */
1546 1614 public static function get_id_by_key( $key ) {
1547 1615 $id = FrmDb::get_var( 'frm_fields', array( 'field_key' => sanitize_title( $key ) ) );
1548 -
1549 1616 return (int) $id;
1550 1617 }
1551 1618
1552 1619 /**
@@ -1564,10 +1631,9 @@
1564 1631 * @return bool
1565 1632 */
1566 1633 public static function is_image( $field ) {
1567 1634 $type = self::get_field_type( $field );
1568 -
1569 - return ( $type === 'url' && self::get_option( $field, 'show_image' ) );
1635 + return $type === 'url' && self::get_option( $field, 'show_image' );
1570 1636 }
1571 1637
1572 1638 /**
1573 1639 * Check if field is radio or Dynamic radio
@@ -1605,18 +1671,12 @@
1605 1671 *
1606 1672 * @return bool true if field type is checkbox or Dynamic checkbox
1607 1673 */
1608 1674 public static function is_field_type( $field, $is_type ) {
1609 - $field_type = self::get_original_field_type( $field );
1610 - $data_type = self::get_option( $field, 'data_type' );
1675 + $field_type = self::get_original_field_type( $field );
1676 + $data_type = self::get_option( $field, 'data_type' );
1677 + $is_field_type = $is_type === $field_type || ( 'data' === $field_type && $is_type === $data_type ) || ( 'lookup' === $field_type && $is_type === $data_type ) || ( 'product' === $field_type && $is_type === $data_type ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
1611 1678
1612 - $is_field_type = (
1613 - $is_type === $field_type ||
1614 - ( 'data' === $field_type && $is_type === $data_type ) ||
1615 - ( 'lookup' === $field_type && $is_type === $data_type ) ||
1616 - ( 'product' === $field_type && $is_type === $data_type )
1617 - );
1618 -
1619 1679 /**
1620 1680 * When a field type is checked, allow individual fields
1621 1681 * to set the type.
1622 1682 *
@@ -1635,8 +1695,7 @@
1635 1695 * @return bool
1636 1696 */
1637 1697 public static function is_combo_field( $field ) {
1638 1698 $field_type_obj = FrmFieldFactory::get_field_factory( $field );
1639 -
1640 1699 return ! empty( $field_type_obj->is_combo_field );
1641 1700 }
1642 1701 }