PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.19
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.19
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 +189 -330 6.266.19 View file →
@@ -4,21 +4,11 @@
4 4 }
5 5
6 6 class FrmField {
7 7
8 - /**
9 - * @var bool
10 - */
11 8 public static $use_cache = true;
12 -
13 - /**
14 - * @var int
15 - */
16 9 public static $transient_size = 200;
17 10
18 - /**
19 - * @return array
20 - */
21 11 public static function field_selection() {
22 12 $fields = array(
23 13 'text' => array(
24 14 'name' => __( 'Text', 'formidable' ),
@@ -37,17 +27,17 @@
37 27 'icon' => 'frm_icon_font frm_radio_checked_icon',
38 28 ),
39 29 'select' => array(
40 30 'name' => __( 'Dropdown', 'formidable' ),
41 - 'icon' => 'frm_icon_font frm_dropdown_icon',
31 + 'icon' => 'frm_icon_font frm_caret_square_down_icon',
42 32 ),
43 33 'email' => array(
44 34 'name' => __( 'Email', 'formidable' ),
45 - 'icon' => 'frm_icon_font frm_email2_icon',
35 + 'icon' => 'frm_icon_font frm_email_icon',
46 36 ),
47 37 'url' => array(
48 38 'name' => __( 'Website/URL', 'formidable' ),
49 - 'icon' => 'frm_icon_font frm_link2_icon',
39 + 'icon' => 'frm_icon_font frm_link_icon',
50 40 ),
51 41 'number' => array(
52 42 'name' => __( 'Number', 'formidable' ),
53 43 'icon' => 'frm_icon_font frm_hashtag_icon',
@@ -61,25 +51,25 @@
61 51 'icon' => 'frm_icon_font frm_phone_icon',
62 52 ),
63 53 'html' => array(
64 54 'name' => __( 'HTML', 'formidable' ),
65 - 'icon' => 'frm_icon_font frm_code2_icon',
55 + 'icon' => 'frm_icon_font frm_code_icon',
66 56 ),
67 57 'hidden' => array(
68 58 'name' => __( 'Hidden', 'formidable' ),
69 - 'icon' => 'frm_icon_font frm_eye_slash2_icon',
59 + 'icon' => 'frm_icon_font frm_eye_slash_icon',
70 60 ),
71 61 'user_id' => array(
72 62 'name' => __( 'User ID', 'formidable' ),
73 - 'icon' => 'frm_icon_font frm_user2_icon',
63 + 'icon' => 'frm_icon_font frm_user_icon',
74 64 ),
75 65 'captcha' => array(
76 66 'name' => self::get_captcha_field_name(),
77 - 'icon' => 'frm_icon_font frm_shield_check2_icon',
67 + 'icon' => 'frm_icon_font frm_shield_check_icon',
78 68 ),
79 69 'credit_card' => array(
80 70 'name' => __( 'Payment', 'formidable' ),
81 - 'icon' => 'frm_icon_font frm_credit_card2_icon',
71 + 'icon' => 'frm_icon_font frm_credit_card_icon',
82 72 ),
83 73 FrmSubmitHelper::FIELD_TYPE => array(
84 74 'name' => __( 'Submit', 'formidable' ),
85 75 'hide' => true,
@@ -105,98 +95,60 @@
105 95 private static function get_captcha_field_name() {
106 96 return 'Captcha';
107 97 }
108 98
109 - /**
110 - * @return array
111 - */
112 99 public static function pro_field_selection() {
113 - $upsell_images_url = FrmAppHelper::plugin_url() . '/images/upsell/';
114 - $fields = array(
100 + $images_url = FrmAppHelper::plugin_url() . '/images/';
101 + $fields = array(
115 102 'file' => array(
116 - 'name' => __( 'File Upload', 'formidable' ),
117 - 'icon' => 'frm_icon_font frm_upload3_icon',
118 - '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 - 'upsell_image' => $upsell_images_url . 'file-upload-field-preview.webp',
120 - 'learn-more' => 'features/wordpress-multiple-file-upload-form',
103 + 'name' => __( 'File Upload', 'formidable' ),
104 + 'icon' => 'frm_icon_font frm_upload_icon',
105 + 'message' => __( 'Add file uploads to save time and cut down on back-and-forth. Upgrade to Pro to get Upload fields and more.', 'formidable' ),
121 106 ),
122 - 'ranking' => array(
123 - 'name' => __( 'Ranking', 'formidable' ),
124 - 'icon' => 'frm_icon_font frm_chart_bar_icon frm_show_upgrade',
125 - 'message' => __( 'Now you can effortlessly gather insights, preferences, and opinions by allowing users to rank options.', 'formidable' ),
126 - 'upsell_image' => $upsell_images_url . 'ranking-field-preview.webp',
127 - 'addon' => 'surveys',
128 - 'learn-more' => 'ranking-survey',
129 - ),
107 + 'ranking' => array(),
130 108 'rte' => array(
131 - 'name' => __( 'Rich Text', 'formidable' ),
132 - 'icon' => 'frm_icon_font frm_align_right_icon',
133 - 'message' => __( 'Go beyond plain text, let your users format their content with bolding, italics, links, lists and more.', 'formidable' ),
134 - 'upsell_image' => $upsell_images_url . 'rich-text-field-preview.webp',
135 - 'learn-more' => 'rich-text',
109 + 'name' => __( 'Rich Text', 'formidable' ),
110 + 'icon' => 'frm_icon_font frm_align_right_icon',
136 111 ),
137 112 'date' => array(
138 - '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' ),
141 - 'upsell_image' => $upsell_images_url . 'date-field-preview.webp',
142 - 'learn-more' => 'date',
113 + 'name' => __( 'Date', 'formidable' ),
114 + 'icon' => 'frm_icon_font frm_calendar_icon',
143 115 ),
144 116 'time' => array(
145 - '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' ),
148 - 'upsell_image' => $upsell_images_url . 'time-field-preview.webp',
149 - 'learn-more' => 'time',
117 + 'name' => __( 'Time', 'formidable' ),
118 + 'icon' => 'frm_icon_font frm_clock_icon',
150 119 ),
151 120 'scale' => array(
152 - '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' ),
155 - 'upsell_image' => $upsell_images_url . 'scale-field-preview.webp',
156 - 'learn-more' => 'scale',
121 + 'name' => __( 'Scale', 'formidable' ),
122 + 'icon' => 'frm_icon_font frm_linear_scale_icon',
123 + 'message' => esc_html__( 'Add a set of radio buttons with whatever range you choose.', 'formidable' ) . '<img src="' . esc_url( $images_url ) . 'scale_field.png" alt="' . esc_attr__( 'Scale Field', 'formidable' ) . '" />',
157 124 ),
158 125 'star' => array(
159 - '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' ),
162 - 'upsell_image' => $upsell_images_url . 'star-field-preview.webp',
163 - 'learn-more' => 'star-ratings',
126 + 'name' => __( 'Star Rating', 'formidable' ),
127 + 'icon' => 'frm_icon_font frm_star_icon',
164 128 ),
165 129 'range' => array(
166 - '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' ),
169 - 'upsell_image' => $upsell_images_url . 'slider-field-preview.webp',
170 - 'learn-more' => 'slider',
130 + 'name' => __( 'Slider', 'formidable' ),
131 + 'icon' => 'frm_icon_font frm_code_commit_icon',
171 132 ),
172 133 'toggle' => array(
173 - 'name' => __( 'Toggle', 'formidable' ),
174 - 'icon' => 'frm_icon_font frm_toggle_on_icon',
175 - 'message' => esc_html__( 'Quickly and easily create cascading fields, populate fields by search and more.', 'formidable' ),
176 - 'upsell_image' => $upsell_images_url . 'toggle-field-preview.webp',
177 - 'learn-more' => 'toggle',
134 + 'name' => __( 'Toggle', 'formidable' ),
135 + 'icon' => 'frm_icon_font frm_toggle_on_icon',
178 136 ),
179 137 'data' => array(
180 - 'name' => __( 'Dynamic', 'formidable' ),
181 - 'icon' => 'frm_icon_font frm_dynamic_icon',
182 - 'message' => __( 'Link entries together, dynamic display information, and even make selections from data entered on another form.', 'formidable' ),
183 - 'upsell_image' => $upsell_images_url . 'dynamic-field-preview.webp',
184 - 'learn-more' => 'dynamic',
138 + 'name' => __( 'Dynamic', 'formidable' ),
139 + 'icon' => 'frm_icon_font frm_sitemap_icon',
140 + 'message' => __( 'Create relationships between multiple forms. You can link a member to a team, a rating to a product, a comment to a submission, and much more.', 'formidable' ),
185 141 ),
186 142 'lookup' => array(
187 - 'name' => __( 'Lookup', 'formidable' ),
188 - 'icon' => 'frm_icon_font frm_search_icon',
189 - 'message' => esc_html__( 'Link entries together, dynamic display information, and even make selections from data entered on another form.', 'formidable' ),
190 - 'upsell_image' => $upsell_images_url . 'lookup-field-preview.webp',
191 - 'learn-more' => 'lookup',
143 + 'name' => __( 'Lookup', 'formidable' ),
144 + 'icon' => 'frm_icon_font frm_search_icon',
145 + 'message' => esc_html__( 'Filter the options in the next field and automatically add values to other fields. Upgrade to Pro to get Lookup fields and more.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'look-up_year-make-model.gif" alt="' . esc_attr__( 'cascading lookup fields', 'formidable' ) . '" />',
192 146 ),
193 147 'divider|repeat' => array(
194 - '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' ),
197 - 'upsell_image' => $upsell_images_url . 'repeater-field-preview.webp',
198 - 'learn-more' => 'repeatable-section',
148 + 'name' => __( 'Repeater', 'formidable' ),
149 + 'icon' => 'frm_icon_font frm_repeater_icon',
150 + 'message' => esc_html__( 'Allow your visitors to add new sets of fields while filling out forms. Increase conversions while saving building time and server resources.', 'formidable' ) . ' <img src="' . esc_url( $images_url ) . 'repeatable-section_frontend.gif" alt="' . esc_attr__( 'Dynamically Add Form Fields with repeatable sections', 'formidable' ) . '" />',
199 151 ),
200 152 'end_divider' => array(
201 153 'name' => __( 'Section Buttons', 'formidable' ),
202 154 'switch_from' => 'divider',
@@ -201,57 +153,37 @@
201 153 'name' => __( 'Section Buttons', 'formidable' ),
202 154 'switch_from' => 'divider',
203 155 ),
204 156 'divider' => array(
205 - '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' ),
208 - 'upsell_image' => $upsell_images_url . 'section-field-preview.webp',
209 - 'learn-more' => 'section-heading',
157 + 'name' => __( 'Section', 'formidable' ),
158 + 'icon' => 'frm_icon_font frm_header_icon',
210 159 ),
211 160 'break' => array(
212 - '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' ),
215 - 'upsell_image' => $upsell_images_url . 'page-break-field-preview.webp',
216 - 'learn-more' => 'page-breaks',
161 + 'name' => __( 'Page Break', 'formidable' ),
162 + 'icon' => 'frm_icon_font frm_page_break_icon',
163 + 'message' => __( 'Get multi-paged forms with progress bars. Did you know you can upgrade to PRO to unlock multi-step forms with more awesome features?', 'formidable' ),
217 164 ),
218 165 'form' => array(
219 - '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' ),
222 - 'upsell_image' => $upsell_images_url . 'embed-form-field-preview.webp',
223 - 'learn-more' => 'embed-form',
166 + 'name' => __( 'Embed Form', 'formidable' ),
167 + 'icon' => 'frm_icon_font frm_file_text_icon',
224 168 ),
225 169 'likert' => array(
226 - 'name' => __( 'Likert Scale', 'formidable' ),
227 - 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade',
228 - 'addon' => 'surveys',
229 - 'message' => esc_html__( 'Get nuanced, detailed opinions using standardized agreement scales, unlocking deeper insights beyond simple yes/no answers.', 'formidable' ),
230 - 'upsell_image' => $upsell_images_url . 'likert-field-preview.webp',
231 - 'learn-more' => 'likert-scale',
170 + 'name' => __( 'Likert Scale', 'formidable' ),
171 + 'icon' => 'frm_icon_font frm_likert_scale frm_show_upgrade',
172 + 'addon' => 'surveys',
232 173 ),
233 174 'nps' => array(
234 - 'name' => __( 'NPS', 'formidable' ),
235 - 'icon' => 'frm_icon_font frm_nps frm_show_upgrade',
236 - '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' ),
238 - 'upsell_image' => $upsell_images_url . 'nps-field-preview.webp',
239 - 'learn-more' => 'net-promoter-score',
175 + 'name' => __( 'NPS', 'formidable' ),
176 + 'icon' => 'frm_icon_font frm_nps frm_show_upgrade',
177 + 'addon' => 'surveys',
240 178 ),
241 179 'password' => array(
242 - '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' ),
245 - 'upsell_image' => $upsell_images_url . 'password-field-preview.webp',
246 - 'learn-more' => 'password-2',
180 + 'name' => __( 'Password', 'formidable' ),
181 + 'icon' => 'frm_icon_font frm_lock_open_icon',
247 182 ),
248 183 'tag' => array(
249 - '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' ),
252 - 'upsell_image' => $upsell_images_url . 'tags-field-preview.webp',
253 - 'learn-more' => 'tags',
184 + 'name' => __( 'Tags', 'formidable' ),
185 + 'icon' => 'frm_icon_font frm_price_tags_icon',
254 186 ),
255 187 // This is no longer a Pro field, but without this here, Pro triggers "undefined index" notices.
256 188 // Right now it leaves a gap. Maybe we can skip anything without a name or something.
257 189 'credit_card' => array(
@@ -258,80 +190,75 @@
258 190 'name' => '',
259 191 'icon' => '',
260 192 ),
261 193 'address' => array(
262 - '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' ),
265 - 'upsell_image' => $upsell_images_url . 'address-field-preview.webp',
266 - 'learn-more' => 'address',
194 + 'name' => __( 'Address', 'formidable' ),
195 + 'icon' => 'frm_icon_font frm_location_icon',
267 196 ),
268 197 'summary' => array(
269 - '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' ),
272 - 'upsell_image' => $upsell_images_url . 'summary-field-preview.webp',
273 - 'learn-more' => 'summary-review-before-submit',
198 + 'name' => __( 'Summary', 'formidable' ),
199 + 'icon' => 'frm_icon_font frm_file_text_icon',
200 + 'message' => __( 'Allow visitors to review their responses before a form is submitted. Upgrade to Pro to get Summary fields and more.', 'formidable' ),
274 201 ),
275 202 'signature' => array(
276 - 'name' => __( 'Signature', 'formidable' ),
277 - 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade',
278 - 'addon' => 'signature',
279 - 'message' => __( 'Capture digital e-signatures directly within your form, making official agreements and authorizations straightforward.', 'formidable' ),
280 - 'upsell_image' => $upsell_images_url . 'signature-field-preview.webp',
281 - 'learn-more' => 'formidable-signature',
203 + 'name' => __( 'Signature', 'formidable' ),
204 + 'icon' => 'frm_icon_font frm_signature_icon frm_show_upgrade',
205 + 'addon' => 'signature',
282 206 ),
283 207 'ai' => array(
284 - 'name' => __( 'AI', 'formidable' ),
285 - 'icon' => 'frm_icon_font frm-ai-icon frm_show_upgrade',
286 - 'addon' => 'ai',
287 - 'message' => __( 'Harness artificial intelligence by taking user input and let the model of your choice create an output, quickly and easily.', 'formidable' ),
288 - 'upsell_image' => $upsell_images_url . 'ai-field-preview.webp',
289 - 'learn-more' => 'form-ai',
208 + 'name' => __( 'AI', 'formidable' ),
209 + 'icon' => 'frm_icon_font frm_eye_icon frm_show_upgrade',
210 + 'addon' => 'ai',
211 + 'message' => __( 'Streamline workflows and reclaim valuable time with the power of AI. You can effortlessly respond to your visitors in real-time with ChatGPT as your automated assistant. Upgrade to Pro and unlock AI-powered fields.', 'formidable' ),
290 212 ),
291 213 'ssa-appointment' => array(
292 - 'name' => __( 'Appointment', 'formidable' ),
293 - 'icon' => 'frm_icon_font frm_schedule_icon frm_show_upgrade',
294 - 'require' => 'Simply Schedule Appointments',
295 - 'message' => sprintf(
214 + 'name' => __( 'Appointment', 'formidable' ),
215 + 'icon' => 'frm_icon_font frm_calendar_icon frm_show_upgrade',
216 + 'require' => 'Simply Schedule Appointments',
217 + 'message' => sprintf(
296 218 /* translators: %1$s: Link opening HTML, %2$s: Link tag closing */
297 219 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' ),
298 - '<a class="frm-inline-flex" href="https://simplyscheduleappointments.com/meet/formidable/" target="_blank" rel="noopener">',
220 + '<a href="https://simplyscheduleappointments.com/meet/formidable/">',
299 221 '</a>'
300 - ),
301 - 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
302 - 'upsell_image' => $upsell_images_url . 'appointment-field-preview.webp',
303 - 'learn-more' => 'simply-schedule-appointments-forms',
222 + ) . '<img src="' . esc_url( $images_url ) . 'appointments.png" alt="' . esc_attr__( 'Scheduling', 'formidable' ) . '" />',
223 + 'link' => 'https://simplyscheduleappointments.com/meet/formidable/',
304 224 ),
305 225 'product' => array(
306 - 'name' => __( 'Product', 'formidable' ),
307 - 'icon' => 'frm_icon_font frm_product2_icon',
308 - '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' ),
310 - 'upsell_image' => $upsell_images_url . 'product-field-preview.webp',
311 - 'learn-more' => 'features/pricing-fields',
226 + 'name' => __( 'Product', 'formidable' ),
227 + 'icon' => 'frm_icon_font frm_product_icon',
228 + 'section' => 'pricing',
312 229 ),
313 230 'quantity' => array(
314 - 'name' => __( 'Quantity', 'formidable' ),
315 - 'icon' => 'frm_icon_font frm_quantity_icon',
316 - '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' ),
318 - 'upsell_image' => $upsell_images_url . 'quantity-field-preview.webp',
319 - 'learn-more' => 'features/pricing-fields',
231 + 'name' => __( 'Quantity', 'formidable' ),
232 + 'icon' => 'frm_icon_font frm_quantity_icon',
233 + 'section' => 'pricing',
320 234 ),
321 235 'total' => array(
322 - 'name' => __( 'Total', 'formidable' ),
323 - 'icon' => 'frm_icon_font frm_total2_icon',
324 - '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' ),
326 - 'upsell_image' => $upsell_images_url . 'total-field-preview.webp',
327 - 'learn-more' => 'features/pricing-fields',
236 + 'name' => __( 'Total', 'formidable' ),
237 + 'icon' => 'frm_icon_font frm_total_icon',
238 + 'section' => 'pricing',
328 239 ),
329 240 );
330 241
242 + if ( self::include_ranking_fields() ) {
243 + $fields['ranking'] = array(
244 + 'name' => __( 'Ranking', 'formidable' ),
245 + 'icon' => 'frm_icon_font frm_chart_bar_icon frm_show_upgrade',
246 + 'message' => __( 'Now you can effortlessly gather insights, preferences, and opinions by allowing users to rank options.', 'formidable' ),
247 + 'upsell_image' => esc_url( $images_url ) . 'ranking-field.svg',
248 + 'addon' => 'surveys',
249 + 'is_new' => self::field_is_new( 'ranking' ),
250 + );
251 + } else {
252 + unset( $fields['ranking'] );
253 + }
254 +
255 + if ( ! FrmAppHelper::show_new_feature( 'ai' ) ) {
256 + unset( $fields['ai'] );
257 + }
258 +
331 259 // Since the signature field may be in a different section, don't show it twice.
332 260 $lite_fields = self::field_selection();
333 -
334 261 if ( isset( $lite_fields['signature'] ) ) {
335 262 unset( $fields['signature'] );
336 263 }
337 264
@@ -338,32 +265,99 @@
338 265 return apply_filters( 'frm_pro_available_fields', $fields );
339 266 }
340 267
341 268 /**
342 - * Consider a field new for 90 days after the release date.
269 + * Check if we should show ranking fields in the builder.
270 + * This is based on the active version coming from our API data.
271 + * If Surveys v1.1 is not released yet, we don't want to display ranking fields yet.
343 272 *
344 273 * @since 6.8.3
345 274 *
346 - * @param string $type
275 + * @return bool
276 + */
277 + private static function include_ranking_fields() {
278 + if ( class_exists( 'FrmSurveys\models\fields\Ranking' ) ) {
279 + // Always return true if Ranking fields exist.
280 + return true;
281 + }
282 +
283 + $plugin = 'formidable-surveys/formidable-surveys.php';
284 + $expected_version = '1.1';
285 +
286 + return self::installed_plugin_meets_version( $plugin, $expected_version ) || self::api_meets_version( $plugin, $expected_version );
287 + }
288 +
289 + /**
290 + * @since 6.8.3
347 291 *
292 + * @param string $plugin
293 + * @param string $expected_version
348 294 * @return bool
349 295 */
350 - private static function field_is_new( $type ) {
351 - $release_dates = array(
352 - 'ranking' => '2024-03-12',
353 - );
296 + private static function installed_plugin_meets_version( $plugin, $expected_version ) {
297 + $installed_version = self::get_installed_version( $plugin );
298 + return $installed_version && version_compare( $installed_version, $expected_version, '>=' );
299 + }
354 300
355 - if ( ! isset( $release_dates[ $type ] ) ) {
301 + /**
302 + * @since 6.8.3
303 + *
304 + * @param string $plugin
305 + * @return false|string String version. False if the plugin is not installed.
306 + */
307 + private static function get_installed_version( $plugin ) {
308 + if ( ! function_exists( 'get_plugins' ) ) {
309 + require_once ABSPATH . 'wp-admin/includes/plugin.php';
310 + }
311 + $plugins = get_plugins();
312 + if ( isset( $plugins[ $plugin ] ) && ! empty( $plugins[ $plugin ]['Version'] ) ) {
313 + return $plugins[ $plugin ]['Version'];
314 + }
315 + return false;
316 + }
317 +
318 + /**
319 + * @since 6.8.3
320 + *
321 + * @param string $plugin
322 + * @param string $expected_version
323 + * @return bool
324 + */
325 + private static function api_meets_version( $plugin, $expected_version ) {
326 + $api = new FrmFormApi();
327 + $addons = $api->get_api_info();
328 + $matches = wp_list_filter( $addons, array( 'plugin' => $plugin ) );
329 + if ( ! $matches ) {
356 330 return false;
357 331 }
358 332
359 - $release_date = $release_dates[ $type ];
333 + $match = reset( $matches );
334 + if ( empty( $match['new_version'] ) ) {
335 + return false;
336 + }
360 337
361 - $three_months_after_release = gmdate( 'Y-m-d', strtotime( $release_date . ' + 90 days' ) );
362 - return gmdate( 'Y-m-d' ) < $three_months_after_release;
338 + $api_version = $match['new_version'];
339 + return version_compare( $api_version, $expected_version, '>=' );
363 340 }
364 341
365 342 /**
343 + * Consider a field new for 90 days after the release date.
344 + *
345 + * @since 6.8.3
346 + *
347 + * @param string $type
348 + * @return bool
349 + */
350 + private static function field_is_new( $type ) {
351 + if ( 'ranking' === $type ) {
352 + $ranking_release_date = '2024-03-12';
353 + $three_months_after_release = gmdate( 'Y-m-d', strtotime( $ranking_release_date . ' + 90 days' ) );
354 + return gmdate( 'Y-m-d' ) < $three_months_after_release;
355 + }
356 + return false;
357 + }
358 +
359 + /**
366 360 * @since 4.0
367 361 *
368 362 * @return array
369 363 */
@@ -376,9 +370,8 @@
376 370 * Create a field.
377 371 *
378 372 * @param array $values
379 373 * @param bool $return
380 - *
381 374 * @return false|int
382 375 */
383 376 public static function create( $values, $return = true ) {
384 377 global $wpdb, $frm_duplicate_ids;
@@ -383,9 +376,9 @@
383 376 public static function create( $values, $return = true ) {
384 377 global $wpdb, $frm_duplicate_ids;
385 378
386 379 $new_values = array();
387 - $key = $values['field_key'] ?? $values['name'];
380 + $key = isset( $values['field_key'] ) ? $values['field_key'] : $values['name'];
388 381 $new_values['field_key'] = FrmAppHelper::get_unique_key( $key, $wpdb->prefix . 'frm_fields', 'field_key' );
389 382
390 383 $values = FrmAppHelper::maybe_filter_array( $values, array( 'name', 'description' ) );
391 384
@@ -447,9 +440,8 @@
447 440 *
448 441 * @since 5.0.08
449 442 *
450 443 * @param array $options
451 - *
452 444 * @return array
453 445 */
454 446 private static function maybe_filter_options( $options ) {
455 447 $options = FrmAppHelper::maybe_filter_array( $options, array( 'custom_html' ) );
@@ -471,9 +463,8 @@
471 463 *
472 464 * @since 6.11.2
473 465 *
474 466 * @param string $html
475 - *
476 467 * @return string
477 468 */
478 469 private static function maybe_filter_custom_html_input_attributes( $html ) {
479 470 if ( FrmAppHelper::allow_unfiltered_html() ) {
@@ -484,9 +475,8 @@
484 475 return preg_replace_callback(
485 476 "/$pattern/",
486 477 /**
487 478 * @param array $match Shortcode data.
488 - *
489 479 * @return string
490 480 */
491 481 function ( $match ) {
492 482 $attr = shortcode_parse_atts( $match[3] );
@@ -496,9 +486,8 @@
496 486 return '[input]';
497 487 }
498 488
499 489 $safe_atts = array();
500 -
501 490 foreach ( $attr as $attr_key => $att ) {
502 491 if ( ! is_numeric( $attr_key ) ) {
503 492 // opt=1 without parentheses for example is mapped like 'opt' => 1.
504 493 $key = $attr_key;
@@ -505,13 +494,11 @@
505 494 $value = $att;
506 495 } else {
507 496 // Some data is mapped like 0 => 'placeholder="Placeholder"'.
508 497 $split = explode( '=', $att, 2 );
509 -
510 498 if ( 2 !== count( $split ) ) {
511 499 continue;
512 500 }
513 -
514 501 $key = trim( $split[0] );
515 502 $value = trim( $split[1], '"' );
516 503 }
517 504
@@ -517,9 +504,9 @@
517 504
518 505 if ( FrmAppHelper::input_key_is_safe( $key, 'update' ) ) {
519 506 $safe_atts[ $key ] = $value;
520 507 }
521 - }//end foreach
508 + }
522 509
523 510 if ( ! $safe_atts ) {
524 511 return '[input]';
525 512 }
@@ -533,17 +520,11 @@
533 520 /**
534 521 * Process the field duplication.
535 522 *
536 523 * @since 5.0.05
537 - *
538 - * @param int|string $field_id Field ID.
539 - * @param int|string $form_id Form ID.
540 - *
541 - * @return array|false
542 524 */
543 525 public static function duplicate_single_field( $field_id, $form_id ) {
544 526 $copy_field = self::getOne( $field_id );
545 -
546 527 if ( ! $copy_field ) {
547 528 return false;
548 529 }
549 530
@@ -576,16 +557,8 @@
576 557
577 558 return compact( 'field_id', 'values' );
578 559 }
579 560
580 - /**
581 - * @param int|string $old_form_id
582 - * @param int|string $form_id
583 - * @param bool $copy_keys
584 - * @param false|int $blog_id
585 - *
586 - * @return void
587 - */
588 561 public static function duplicate( $old_form_id, $form_id, $copy_keys = false, $blog_id = false ) {
589 562 global $frm_duplicate_ids;
590 563
591 564 $where = array(
@@ -598,9 +571,8 @@
598 571 $fields = self::getAll( $where, 'field_order', '', $blog_id );
599 572
600 573 foreach ( (array) $fields as $field ) {
601 574 $new_key = $copy_keys ? $field->field_key : '';
602 -
603 575 if ( $copy_keys && substr( $field->field_key, - 1 ) == 2 ) {
604 576 $new_key = rtrim( $new_key, 2 );
605 577 }
606 578
@@ -643,9 +615,8 @@
643 615
644 616 /**
645 617 * @param int|string $id
646 618 * @param array $values
647 - *
648 619 * @return false|int
649 620 */
650 621 public static function update( $id, $values ) {
651 622 global $wpdb;
@@ -692,9 +663,8 @@
692 663 }
693 664 $values[ $opt ] = serialize( $values[ $opt ] );
694 665 }
695 666 }
696 -
697 667 if ( isset( $values['default_value'] ) && is_array( $values['default_value'] ) ) {
698 668 $values['default_value'] = json_encode( $values['default_value'] );
699 669 }
700 670
@@ -700,14 +670,12 @@
700 670
701 671 $query_results = $wpdb->update( $wpdb->prefix . 'frm_fields', $values, array( 'id' => $id ) );
702 672
703 673 $form_id = 0;
704 -
705 674 if ( isset( $values['form_id'] ) ) {
706 675 $form_id = absint( $values['form_id'] );
707 676 } else {
708 677 $field = self::getOne( $id );
709 -
710 678 if ( $field ) {
711 679 $form_id = $field->form_id;
712 680 }
713 681 unset( $field );
@@ -715,9 +683,8 @@
715 683 unset( $values );
716 684
717 685 if ( $query_results ) {
718 686 wp_cache_delete( $id, 'frm_field' );
719 -
720 687 if ( $form_id ) {
721 688 self::delete_form_transient( $form_id );
722 689 }
723 690 }
@@ -730,10 +697,8 @@
730 697 *
731 698 * @since 2.0.8
732 699 *
733 700 * @param array $values Pass by reference.
734 - *
735 - * @return void
736 701 */
737 702 private static function preserve_format_option_backslashes( &$values ) {
738 703 if ( isset( $values['field_options']['format'] ) ) {
739 704 $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
@@ -739,13 +704,8 @@
739 704 $values['field_options']['format'] = FrmAppHelper::preserve_backslashes( $values['field_options']['format'] );
740 705 }
741 706 }
742 707
743 - /**
744 - * @param int|string $id
745 - *
746 - * @return bool|int
747 - */
748 708 public static function destroy( $id ) {
749 709 global $wpdb;
750 710
751 711 do_action( 'frm_before_destroy_field', $id );
@@ -751,9 +711,8 @@
751 711 do_action( 'frm_before_destroy_field', $id );
752 712
753 713 wp_cache_delete( $id, 'frm_field' );
754 714 $field = self::getOne( $id );
755 -
756 715 if ( ! $field ) {
757 716 return false;
758 717 }
759 718
@@ -763,13 +722,8 @@
763 722
764 723 return $wpdb->query( $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'frm_fields WHERE id=%d', $id ) );
765 724 }
766 725
767 - /**
768 - * @param int|string $form_id
769 - *
770 - * @return void
771 - */
772 726 public static function delete_form_transient( $form_id ) {
773 727 $form_id = absint( $form_id );
774 728 delete_transient( 'frm_form_fields_' . $form_id . 'excludeinclude' );
775 729 delete_transient( 'frm_form_fields_' . $form_id . 'includeinclude' );
@@ -781,9 +735,8 @@
781 735
782 736 FrmDb::cache_delete_group( 'frm_field' );
783 737
784 738 $form = FrmForm::getOne( $form_id );
785 -
786 739 if ( $form && $form->parent_form_id && $form->parent_form_id != $form_id ) {
787 740 self::delete_form_transient( $form->parent_form_id );
788 741 }
789 742 }
@@ -791,9 +744,8 @@
791 744 /**
792 745 * If $field is numeric, get the field object
793 746 *
794 747 * @param int|object|string $field
795 - *
796 748 * @return void
797 749 */
798 750 public static function maybe_get_field( &$field ) {
799 751 if ( ! is_object( $field ) ) {
@@ -803,10 +755,8 @@
803 755
804 756 /**
805 757 * @param int|string $id The field id or key.
806 758 * @param bool $filter When true, run the frm_field filter.
807 - *
808 - * @return object|null
809 759 */
810 760 public static function getOne( $id, $filter = false ) {
811 761 if ( empty( $id ) ) {
812 762 return null;
@@ -837,13 +787,10 @@
837 787 }
838 788
839 789 /**
840 790 * @since 3.06.01
841 - *
842 791 * @param bool $filter When true, run the frm_field filter.
843 792 * @param object $results
844 - *
845 - * @return void
846 793 */
847 794 private static function filter_field( $filter, &$results ) {
848 795 if ( $filter ) {
849 796 /**
@@ -857,14 +804,11 @@
857 804 * Get the field type by key or id
858 805 *
859 806 * @param int|string $id The field id or key.
860 807 * @param mixed $col The name of the column in the fields database table.
861 - *
862 - * @return mixed
863 808 */
864 809 public static function get_type( $id, $col = 'type' ) {
865 810 $field = FrmDb::check_cache( $id, 'frm_field' );
866 -
867 811 if ( $field ) {
868 812 $type = $field->{$col};
869 813 } else {
870 814 if ( is_numeric( $id ) ) {
@@ -871,9 +815,8 @@
871 815 $where = array( 'id' => $id );
872 816 } else {
873 817 $where = array( 'field_key' => $id );
874 818 }
875 -
876 819 $type = FrmDb::get_var( 'frm_fields', $where, $col );
877 820 }
878 821
879 822 return $type;
@@ -883,10 +826,8 @@
883 826 * @param int|string $form_id
884 827 * @param string $type
885 828 * @param int|string $limit
886 829 * @param string $inc_sub
887 - *
888 - * @return array|object
889 830 */
890 831 public static function get_all_types_in_form( $form_id, $type, $limit = '', $inc_sub = 'exclude' ) {
891 832 if ( ! $form_id ) {
892 833 return array();
@@ -898,13 +839,11 @@
898 839 'inc_embed' => $inc_sub,
899 840 'inc_repeat' => $inc_sub,
900 841 )
901 842 );
902 -
903 843 if ( ! empty( $results ) ) {
904 844 $fields = array();
905 845 $count = 0;
906 -
907 846 foreach ( $results as $result ) {
908 847 if ( $type != $result->type ) {
909 848 continue;
910 849 }
@@ -910,9 +849,8 @@
910 849 }
911 850
912 851 $fields[ $result->id ] = $result;
913 852 ++$count;
914 -
915 853 if ( $limit == 1 ) {
916 854 $fields = $result;
917 855 break;
918 856 }
@@ -945,9 +883,8 @@
945 883 * @param int|string $form_id
946 884 * @param int|string $limit
947 885 * @param string $inc_embed
948 886 * @param string $inc_repeat
949 - *
950 887 * @return array
951 888 */
952 889 public static function get_all_for_form( $form_id, $limit = '', $inc_embed = 'exclude', $inc_repeat = 'include' ) {
953 890 if ( ! (int) $form_id ) {
@@ -954,9 +891,8 @@
954 891 return array();
955 892 }
956 893
957 894 $results = self::get_fields_from_transients( $form_id, compact( 'inc_embed', 'inc_repeat' ) );
958 -
959 895 if ( ! empty( $results ) ) {
960 896 if ( empty( $limit ) ) {
961 897 return $results;
962 898 }
@@ -962,13 +898,11 @@
962 898 }
963 899
964 900 $fields = array();
965 901 $count = 0;
966 -
967 902 foreach ( $results as $result ) {
968 903 ++$count;
969 904 $fields[ $result->id ] = $result;
970 -
971 905 if ( ! empty( $limit ) && $count >= $limit ) {
972 906 break;
973 907 }
974 908 }
@@ -997,10 +931,8 @@
997 931 * If repeating fields should be included, adjust $where accordingly
998 932 *
999 933 * @param string $inc_repeat
1000 934 * @param array $where Pass by reference.
1001 - *
1002 - * @return void
1003 935 */
1004 936 private static function maybe_include_repeating_fields( $inc_repeat, &$where ) {
1005 937 if ( $inc_repeat === 'include' ) {
1006 938 $form_id = $where['fi.form_id'];
@@ -1012,19 +944,10 @@
1012 944 unset( $where['fi.form_id'] );
1013 945 }
1014 946 }
1015 947
1016 - /**
1017 - * @param array $results
1018 - * @param string $inc_embed
1019 - * @param string $type
1020 - * @param int|string $form_id
1021 - *
1022 - * @return void
1023 - */
1024 948 public static function include_sub_fields( &$results, $inc_embed, $type = 'all', $form_id = '' ) {
1025 949 $no_sub_forms = empty( $results ) && $type === 'all';
1026 -
1027 950 if ( 'include' != $inc_embed || $no_sub_forms ) {
1028 951 return;
1029 952 }
1030 953
@@ -1029,15 +952,13 @@
1029 952 }
1030 953
1031 954 $form_fields = $results;
1032 955 $should_get_subforms = ( $type !== 'all' && $type !== 'form' && ! empty( $form_id ) );
1033 -
1034 956 if ( $should_get_subforms ) {
1035 957 $form_fields = self::get_all_types_in_form( $form_id, 'form' );
1036 958 }
1037 959
1038 960 $index_offset = 1;
1039 -
1040 961 foreach ( $form_fields as $k => $field ) {
1041 962 if ( 'form' != $field->type || ! isset( $field->field_options['form_select'] ) ) {
1042 963 continue;
1043 964 }
@@ -1056,23 +977,13 @@
1056 977 unset( $field, $sub_fields );
1057 978 }
1058 979 }
1059 980
1060 - /**
1061 - * @param array|string $where
1062 - * @param string $order_by
1063 - * @param string $limit
1064 - * @param false|int $blog_id
1065 - *
1066 - * @return array|object|null
1067 - */
1068 981 public static function getAll( $where = array(), $order_by = '', $limit = '', $blog_id = false ) {
1069 982 $cache_key = FrmAppHelper::maybe_json_encode( $where ) . $order_by . 'l' . $limit . 'b' . $blog_id;
1070 -
1071 983 if ( self::$use_cache ) {
1072 984 // make sure old cache doesn't get saved as a transient
1073 985 $results = wp_cache_get( $cache_key, 'frm_field' );
1074 -
1075 986 if ( false !== $results ) {
1076 987 return wp_unslash( $results );
1077 988 }
1078 989 }
@@ -1079,9 +990,14 @@
1079 990
1080 991 global $wpdb;
1081 992
1082 993 if ( $blog_id && is_multisite() ) {
1083 - $prefix = $wpdb->get_blog_prefix( $blog_id );
994 + global $wpmuBaseTablePrefix;
995 + if ( $wpmuBaseTablePrefix ) {
996 + $prefix = $wpmuBaseTablePrefix . $blog_id . '_';
997 + } else {
998 + $prefix = $wpdb->get_blog_prefix( $blog_id );
999 + }
1084 1000
1085 1001 $table_name = $prefix . 'frm_fields';
1086 1002 $form_table_name = $prefix . 'frm_forms';
1087 1003 } else {
@@ -1121,12 +1037,8 @@
1121 1037 }
1122 1038
1123 1039 /**
1124 1040 * @since 2.0.8
1125 - *
1126 - * @param array|object|null $results Results.
1127 - *
1128 - * @return void
1129 1041 */
1130 1042 private static function format_field_results( &$results ) {
1131 1043 if ( is_array( $results ) ) {
1132 1044 foreach ( $results as $r_key => $result ) {
@@ -1157,9 +1069,8 @@
1157 1069 *
1158 1070 * @since 6.15
1159 1071 *
1160 1072 * @param stdClass $result
1161 - *
1162 1073 * @return void
1163 1074 */
1164 1075 private static function add_slashes_to_format_before_setting_field_cache( $result ) {
1165 1076 if ( ! isset( $result->field_options ) || ! is_array( $result->field_options ) || empty( $result->field_options['format'] ) ) {
@@ -1172,12 +1083,8 @@
1172 1083 /**
1173 1084 * Unserialize all the serialized field data
1174 1085 *
1175 1086 * @since 2.0
1176 - *
1177 - * @param object $results
1178 - *
1179 - * @return void
1180 1087 */
1181 1088 private static function prepare_options( &$results ) {
1182 1089 FrmAppHelper::unserialize_or_decode( $results->field_options );
1183 1090 FrmAppHelper::unserialize_or_decode( $results->options );
@@ -1188,10 +1095,9 @@
1188 1095 $field_object = FrmFieldFactory::get_field_type( $results->type );
1189 1096
1190 1097 if ( $field_object->should_unserialize_value() ) {
1191 1098 FrmAppHelper::unserialize_or_decode( $results->default_value );
1192 -
1193 - if ( $before === $results->default_value && is_string( $before ) && strpos( $before, '["' ) === 0 ) {
1099 + if ( $before === $results->default_value && ! is_array( $before ) && strpos( $before, '["' ) === 0 ) {
1194 1100 $results->default_value = FrmAppHelper::maybe_json_decode( $results->default_value );
1195 1101 }
1196 1102 }
1197 1103 }
@@ -1200,13 +1106,8 @@
1200 1106 * If a form has too many fields, they won't all save into a single transient.
1201 1107 * We'll break them into groups of 200
1202 1108 *
1203 1109 * @since 2.0.1
1204 - *
1205 - * @param int|string $form_id Form ID.
1206 - * @param array $args Additional arguments.
1207 - *
1208 - * @return array
1209 1110 */
1210 1111 private static function get_fields_from_transients( $form_id, $args ) {
1211 1112 $fields = array();
1212 1113 self::get_next_transient( $fields, 'frm_form_fields_' . $form_id . $args['inc_embed'] . $args['inc_repeat'] );
@@ -1217,14 +1118,8 @@
1217 1118 /**
1218 1119 * Called by get_fields_from_transients
1219 1120 *
1220 1121 * @since 2.0.1
1221 - *
1222 - * @param array $fields Array of fields.
1223 - * @param string $base_name Base name.
1224 - * @param int $next Next transient number.
1225 - *
1226 - * @return void
1227 1122 */
1228 1123 private static function get_next_transient( &$fields, $base_name, $next = 0 ) {
1229 1124 $name = $next ? $base_name . $next : $base_name;
1230 1125 $next_fields = get_transient( $name );
@@ -1243,15 +1138,8 @@
1243 1138 /**
1244 1139 * Save the transients in chunks for large forms
1245 1140 *
1246 1141 * @since 2.0.1
1247 - *
1248 - * @param array $fields Array of fields.
1249 - * @param int|string $form_id Form ID.
1250 - * @param int $next Next transient number.
1251 - * @param array $args Additional arguments.
1252 - *
1253 - * @return void
1254 1142 */
1255 1143 private static function set_field_transient( &$fields, $form_id, $next = 0, $args = array() ) {
1256 1144 $base_name = 'frm_form_fields_' . $form_id . $args['inc_embed'] . $args['inc_repeat'];
1257 1145 $field_chunks = array_chunk( $fields, self::$transient_size );
@@ -1258,13 +1146,12 @@
1258 1146
1259 1147 foreach ( $field_chunks as $field ) {
1260 1148 $name = $next ? $base_name . $next : $base_name;
1261 1149 $set = set_transient( $name, $field, 60 * 60 * 6 );
1262 -
1263 1150 if ( ! $set ) {
1264 1151 // the transient didn't save
1265 - if ( $name !== $base_name ) {
1266 - // if the first saved an others fail, this will show an incomplete form
1152 + if ( $name != $base_name ) {
1153 + // if the first saved an others fail, this will show an incmoplete form
1267 1154 self::delete_form_transient( $form_id );
1268 1155 }
1269 1156
1270 1157 return;
@@ -1275,9 +1162,8 @@
1275 1162 }
1276 1163
1277 1164 /**
1278 1165 * @param string $type
1279 - *
1280 1166 * @return bool
1281 1167 */
1282 1168 public static function is_no_save_field( $type ) {
1283 1169 return in_array( $type, self::no_save_fields(), true );
@@ -1316,11 +1202,9 @@
1316 1202 }
1317 1203
1318 1204 /**
1319 1205 * @since 3.0
1320 - *
1321 1206 * @param array|object $field
1322 - *
1323 1207 * @return string
1324 1208 */
1325 1209 public static function get_field_type( $field ) {
1326 1210 return is_array( $field ) ? $field['type'] : $field->type;
@@ -1327,11 +1211,8 @@
1327 1211 }
1328 1212
1329 1213 /**
1330 1214 * @since 3.0
1331 - *
1332 - * @param array|object $field
1333 - *
1334 1215 * @return string
1335 1216 */
1336 1217 public static function get_original_field_type( $field ) {
1337 1218 $field_type = self::get_field_type( $field );
@@ -1348,11 +1229,8 @@
1348 1229 /**
1349 1230 * Check if this is a multiselect dropdown field
1350 1231 *
1351 1232 * @since 2.0.9
1352 - *
1353 - * @param array|object $field Field object.
1354 - *
1355 1233 * @return bool
1356 1234 */
1357 1235 public static function is_multiple_select( $field ) {
1358 1236 $field_type = self::get_field_type( $field );
@@ -1367,9 +1245,8 @@
1367 1245 *
1368 1246 * @since 2.0.9
1369 1247 *
1370 1248 * @param array|object $field
1371 - *
1372 1249 * @return bool
1373 1250 */
1374 1251 public static function is_read_only( $field ) {
1375 1252 global $frm_vars;
@@ -1379,9 +1256,8 @@
1379 1256 /**
1380 1257 * @since 2.0.9
1381 1258 *
1382 1259 * @param array $field
1383 - *
1384 1260 * @return bool
1385 1261 */
1386 1262 public static function is_required( $field ) {
1387 1263 $required = $field['required'] != '0';
@@ -1399,9 +1275,8 @@
1399 1275 * @since 2.0.9
1400 1276 *
1401 1277 * @param array|object $field
1402 1278 * @param string $option
1403 - *
1404 1279 * @return bool
1405 1280 */
1406 1281 public static function is_option_true( $field, $option ) {
1407 1282 if ( is_array( $field ) ) {
@@ -1414,9 +1289,8 @@
1414 1289 * @since 2.0.9
1415 1290 *
1416 1291 * @param array|object $field
1417 1292 * @param string $option
1418 - *
1419 1293 * @return bool
1420 1294 */
1421 1295 public static function is_option_empty( $field, $option ) {
1422 1296 if ( is_array( $field ) ) {
@@ -1427,9 +1301,8 @@
1427 1301
1428 1302 /**
1429 1303 * @param array $field
1430 1304 * @param string $option
1431 - *
1432 1305 * @return bool
1433 1306 */
1434 1307 public static function is_option_true_in_array( $field, $option ) {
1435 1308 return ! empty( $field[ $option ] );
@@ -1437,9 +1310,8 @@
1437 1310
1438 1311 /**
1439 1312 * @param object $field
1440 1313 * @param string $option
1441 - *
1442 1314 * @return bool
1443 1315 */
1444 1316 public static function is_option_true_in_object( $field, $option ) {
1445 1317 return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ];
@@ -1447,9 +1319,8 @@
1447 1319
1448 1320 /**
1449 1321 * @param array $field
1450 1322 * @param string $option
1451 - *
1452 1323 * @return bool
1453 1324 */
1454 1325 public static function is_option_empty_in_array( $field, $option ) {
1455 1326 return empty( $field[ $option ] );
@@ -1457,9 +1328,8 @@
1457 1328
1458 1329 /**
1459 1330 * @param object $field
1460 1331 * @param string $option
1461 - *
1462 1332 * @return bool
1463 1333 */
1464 1334 public static function is_option_empty_in_object( $field, $option ) {
1465 1335 return empty( $field->field_options[ $option ] );
@@ -1467,9 +1337,8 @@
1467 1337
1468 1338 /**
1469 1339 * @param stdClass $field
1470 1340 * @param string $option
1471 - *
1472 1341 * @return bool
1473 1342 */
1474 1343 public static function is_option_value_in_object( $field, $option ) {
1475 1344 return isset( $field->field_options[ $option ] ) && $field->field_options[ $option ] != '';
@@ -1479,9 +1348,8 @@
1479 1348 * @since 2.0.18
1480 1349 *
1481 1350 * @param array|object $field
1482 1351 * @param string $option
1483 - *
1484 1352 * @return mixed
1485 1353 */
1486 1354 public static function get_option( $field, $option ) {
1487 1355 if ( is_array( $field ) ) {
@@ -1495,9 +1363,8 @@
1495 1363
1496 1364 /**
1497 1365 * @param array $field
1498 1366 * @param string $option
1499 - *
1500 1367 * @return mixed
1501 1368 */
1502 1369 public static function get_option_in_array( $field, $option ) {
1503 1370 if ( isset( $field[ $option ] ) ) {
@@ -1513,13 +1380,12 @@
1513 1380
1514 1381 /**
1515 1382 * @param object $field
1516 1383 * @param string $option
1517 - *
1518 1384 * @return mixed
1519 1385 */
1520 1386 public static function get_option_in_object( $field, $option ) {
1521 - return $field->field_options[ $option ] ?? '';
1387 + return isset( $field->field_options[ $option ] ) ? $field->field_options[ $option ] : '';
1522 1388 }
1523 1389
1524 1390 /**
1525 1391 * @since 2.0.09
@@ -1524,9 +1390,8 @@
1524 1390 /**
1525 1391 * @since 2.0.09
1526 1392 *
1527 1393 * @param array|object $field
1528 - *
1529 1394 * @return bool
1530 1395 */
1531 1396 public static function is_repeating_field( $field ) {
1532 1397 if ( is_array( $field ) ) {
@@ -1557,13 +1422,8 @@
1557 1422 public static function get_key_by_id( $id ) {
1558 1423 return FrmDb::get_var( 'frm_fields', array( 'id' => $id ), 'field_key' );
1559 1424 }
1560 1425
1561 - /**
1562 - * @param array|object $field
1563 - *
1564 - * @return bool
1565 - */
1566 1426 public static function is_image( $field ) {
1567 1427 $type = self::get_field_type( $field );
1568 1428
1569 1429 return ( $type === 'url' && self::get_option( $field, 'show_image' ) );
@@ -1630,9 +1490,8 @@
1630 1490 *
1631 1491 * @since 4.10.02
1632 1492 *
1633 1493 * @param array $field Field array.
1634 - *
1635 1494 * @return bool
1636 1495 */
1637 1496 public static function is_combo_field( $field ) {
1638 1497 $field_type_obj = FrmFieldFactory::get_field_factory( $field );