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/helpers/FrmEntriesHelper.php +334 -197 6.4.2 → trunk View file →
@@ -7,9 +7,10 @@
7 7
8 8 /**
9 9 * "Submitted" entry status.
10 10 *
11 - * @since x.x
11 + * @since 6.4.2
12 + *
12 13 * @var int
13 14 */
14 15 const SUBMITTED_ENTRY_STATUS = 0;
15 16
@@ -15,13 +16,22 @@
15 16
16 17 /**
17 18 * "Draft" entry status.
18 19 *
19 - * @since x.x
20 + * @since 6.4.2
21 + *
20 22 * @var int
21 23 */
22 24 const DRAFT_ENTRY_STATUS = 1;
23 25
26 + /**
27 + * @param mixed $fields
28 + * @param object|string $form
29 + * @param bool $reset
30 + * @param array $args
31 + *
32 + * @return array
33 + */
24 34 public static function setup_new_vars( $fields, $form = '', $reset = false, $args = array() ) {
25 35 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
26 36
27 37 $values = array(
@@ -30,9 +40,10 @@
30 40 'item_key' => '',
31 41 );
32 42
33 43 $values['fields'] = array();
34 - if ( empty( $fields ) ) {
44 +
45 + if ( ! $fields ) {
35 46 return apply_filters( 'frm_setup_new_entry', $values );
36 47 }
37 48
38 49 foreach ( (array) $fields as $field ) {
@@ -37,16 +48,15 @@
37 48
38 49 foreach ( (array) $fields as $field ) {
39 50 $original_default = $field->default_value;
40 51 self::prepare_field_default_value( $field );
41 - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
42 -
52 + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
43 53 $field_array = FrmAppHelper::start_field_array( $field );
44 54 $field_array['value'] = $new_value;
45 55 $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value );
46 - $field_array['parent_form_id'] = isset( $args['parent_form_id'] ) ? $args['parent_form_id'] : $field->form_id;
56 + $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
47 57 $field_array['reset_value'] = $reset;
48 - $field_array['in_embed_form'] = isset( $args['in_embed_form'] ) ? $args['in_embed_form'] : '0';
58 + $field_array['in_embed_form'] = $args['in_embed_form'] ?? '0';
49 59 $field_array['original_default'] = $original_default;
50 60
51 61 FrmFieldsHelper::prepare_new_front_field( $field_array, $field, $args );
52 62
@@ -60,11 +70,12 @@
60 70
61 71 if ( ! $form || ! isset( $form->id ) ) {
62 72 $form = FrmForm::getOne( $field->form_id );
63 73 }
64 - }
74 + }//end foreach
65 75
66 76 FrmAppHelper::unserialize_or_decode( $form->options );
77 +
67 78 if ( is_array( $form->options ) ) {
68 79 $values = array_merge( $values, $form->options );
69 80 }
70 81
@@ -79,11 +90,13 @@
79 90 /**
80 91 * @since 2.05
81 92 *
82 93 * @param object $field
94 + *
95 + * @return void
83 96 */
84 97 private static function prepare_field_default_value( &$field ) {
85 - //If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array
98 + // If checkbox, multi-select dropdown, or checkbox data from entries field, the value should be an array.
86 99 $return_array = FrmField::is_field_with_multiple_values( $field );
87 100
88 101 /**
89 102 * Do any shortcodes in default value and allow customization of default value.
@@ -101,13 +114,13 @@
101 114 * This function is used when the form is first loaded and on all page turns *for a new entry*
102 115 *
103 116 * @since 2.0.13
104 117 *
105 - * @param object $field - this is passed by reference since it is an object
106 - * @param boolean $reset
107 - * @param array $args
118 + * @param object $field - this is passed by reference since it is an object.
119 + * @param bool $reset
120 + * @param array $args
108 121 *
109 - * @return string|array $new_value
122 + * @return array|string New value.
110 123 */
111 124 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
112 125 $new_value = $field->default_value;
113 126
@@ -115,9 +128,9 @@
115 128 self::get_posted_value( $field, $new_value, $args );
116 129 }
117 130
118 131 if ( ! is_array( $new_value ) ) {
119 - $new_value = str_replace( '"', '"', $new_value );
132 + return str_replace( '"', '"', $new_value );
120 133 }
121 134
122 135 return $new_value;
123 136 }
@@ -127,28 +140,38 @@
127 140 *
128 141 * @since 2.01.0
129 142 *
130 143 * @param object $field
131 - * @param array $args
144 + * @param array $args
132 145 *
133 - * @return boolean $value_is_posted
146 + * @return bool True if a value is posted.
134 147 */
135 148 public static function value_is_posted( $field, $args ) {
136 149 $value_is_posted = false;
137 - if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
138 - $repeating = isset( $args['repeating'] ) && $args['repeating'];
139 - if ( $repeating ) {
140 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
141 - $value_is_posted = true;
142 - }
143 - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
150 +
151 + if ( ! $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
152 + return $value_is_posted;
153 + }
154 +
155 + $repeating = ! empty( $args['repeating'] );
156 +
157 + if ( $repeating ) {
158 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
144 159 $value_is_posted = true;
145 160 }
161 + } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
162 + $value_is_posted = true;
146 163 }
147 164
148 165 return $value_is_posted;
149 166 }
150 167
168 + /**
169 + * @param array $values
170 + * @param object $record
171 + *
172 + * @return array
173 + */
151 174 public static function setup_edit_vars( $values, $record ) {
152 175 remove_action( 'media_buttons', 'FrmFormsController::insert_form_button' );
153 176
154 177 $values['item_key'] = FrmAppHelper::get_post_param( 'item_key', $record->item_key, 'sanitize_title' );
@@ -157,16 +180,22 @@
157 180
158 181 return apply_filters( 'frm_setup_edit_entry_vars', $values, $record );
159 182 }
160 183
184 + /**
185 + * @param string $message
186 + * @param array $atts
187 + *
188 + * @return string
189 + */
161 190 public static function replace_default_message( $message, $atts ) {
162 - if ( strpos( $message, '[default-message' ) === false &&
163 - strpos( $message, '[default_message' ) === false &&
164 - ! empty( $message ) ) {
191 + if ( ! str_contains( $message, '[default-message' ) &&
192 + ! str_contains( $message, '[default_message' ) &&
193 + $message ) {
165 194 return $message;
166 195 }
167 196
168 - if ( empty( $message ) ) {
197 + if ( ! $message ) {
169 198 $message = '[default-message]';
170 199 }
171 200
172 201 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
@@ -171,17 +200,12 @@
171 200
172 201 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
173 202
174 203 foreach ( $shortcodes[0] as $short_key => $tag ) {
175 - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
176 - if ( ! empty( $add_atts ) ) {
177 - $this_atts = array_merge( $atts, $add_atts );
178 - } else {
179 - $this_atts = $atts;
180 - }
204 + $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
205 + $this_atts = $add_atts ? array_merge( $atts, $add_atts ) : $atts;
206 + $default = FrmEntriesController::show_entry_shortcode( $this_atts );
181 207
182 - $default = FrmEntriesController::show_entry_shortcode( $this_atts );
183 -
184 208 // Add the default message.
185 209 $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
186 210 }
187 211
@@ -191,22 +215,25 @@
191 215 /**
192 216 * @param stdClass $entry
193 217 * @param stdClass $field
194 218 * @param array $atts
219 + *
195 220 * @return string
196 221 */
197 222 public static function prepare_display_value( $entry, $field, $atts ) {
198 - $field_value = isset( $entry->metas[ $field->id ] ) ? $entry->metas[ $field->id ] : false;
223 + $field_value = $entry->metas[ $field->id ] ?? false;
199 224
200 225 if ( FrmAppHelper::pro_is_installed() ) {
201 - $empty = empty( $field_value );
226 + $empty = ! $field_value;
202 227 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
203 - if ( $empty && ! empty( $field_value ) ) {
228 +
229 + if ( $empty && $field_value ) {
204 230 // We've got an entry id, so switch it to a value.
205 231 $atts['force_id'] = true;
206 232 }
207 233 }
208 234
235 + // phpcs:ignore Universal.Operators.StrictComparisons
209 236 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
210 237 return self::display_value( $field_value, $field, $atts );
211 238 }
212 239
@@ -213,15 +240,19 @@
213 240 if ( ! FrmAppHelper::pro_is_installed() ) {
214 241 return '';
215 242 }
216 243
217 - // This is an embeded form.
218 - if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
244 + if ( is_callable( 'FrmProEntriesHelper::prepare_child_display_value' ) ) {
245 + return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts );
246 + }
247 +
248 + // This is an embedded form.
249 + if ( str_starts_with( $atts['embedded_field_id'], 'form' ) ) {
219 250 // This is a repeating section.
220 251 $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
221 252 } else {
222 253 // Get all values for this field.
223 - $child_values = isset( $entry->metas[ $atts['embedded_field_id'] ] ) ? $entry->metas[ $atts['embedded_field_id'] ] : false;
254 + $child_values = $entry->metas[ $atts['embedded_field_id'] ] ?? false;
224 255
225 256 if ( $child_values ) {
226 257 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
227 258 }
@@ -226,14 +257,14 @@
226 257 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
227 258 }
228 259 }
229 260
230 - $field_value = array();
231 -
232 261 if ( empty( $child_entries ) ) {
233 262 return '';
234 263 }
235 264
265 + $field_value = array();
266 +
236 267 foreach ( $child_entries as $child_entry ) {
237 268 $atts['item_id'] = $child_entry->id;
238 269 $atts['post_id'] = $child_entry->post_id;
239 270
@@ -240,9 +271,9 @@
240 271 // Fet the value for this field -- check for post values as well.
241 272 $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
242 273
243 274 if ( $entry_val || '0' === $entry_val ) {
244 - // foreach entry get display_value.
275 + // For each entry get display_value.
245 276 $field_value[] = self::display_value( $entry_val, $field, $atts );
246 277 }
247 278
248 279 unset( $child_entry );
@@ -248,13 +279,15 @@
248 279 unset( $child_entry );
249 280 }
250 281
251 282 $sep = ', ';
252 - if ( strpos( implode( ' ', (array) $field_value ), '<img' ) !== false ) {
283 +
284 + if ( str_contains( implode( ' ', $field_value ), '<img' ) ) {
253 285 $sep = '<br/>';
254 286 }
255 - $val = implode( $sep, (array) $field_value );
256 287
288 + $val = implode( $sep, $field_value );
289 +
257 290 return FrmAppHelper::kses( $val, 'all' );
258 291 }
259 292
260 293 /**
@@ -260,15 +293,14 @@
260 293 /**
261 294 * Prepare the saved value for display
262 295 *
263 296 * @param array|string $value
264 - * @param object $field
265 - * @param array $atts
297 + * @param object $field
298 + * @param array $atts
266 299 *
267 300 * @return string
268 301 */
269 302 public static function display_value( $value, $field, $atts = array() ) {
270 -
271 303 $defaults = array(
272 304 'type' => '',
273 305 'html' => false,
274 306 'show_filename' => true,
@@ -282,9 +314,9 @@
282 314 );
283 315
284 316 $atts = wp_parse_args( $atts, $defaults );
285 317
286 - if ( FrmField::is_image( $field ) || $field->type == 'star' ) {
318 + if ( FrmField::is_image( $field ) || $field->type === 'star' ) {
287 319 $atts['truncate'] = false;
288 320 $atts['html'] = true;
289 321 }
290 322
@@ -289,8 +321,12 @@
289 321 }
290 322
291 323 $atts = apply_filters( 'frm_display_value_atts', $atts, $field, $value );
292 324
325 + if ( is_string( $field->field_options ) ) {
326 + $field->field_options = array();
327 + }
328 +
293 329 if ( ! isset( $field->field_options['post_field'] ) ) {
294 330 $field->field_options['post_field'] = '';
295 331 }
296 332
@@ -297,17 +333,18 @@
297 333 if ( ! isset( $field->field_options['custom_field'] ) ) {
298 334 $field->field_options['custom_field'] = '';
299 335 }
300 336
301 - if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] == 'tag' ) ) {
337 + if ( FrmAppHelper::pro_is_installed() && $atts['post_id'] && ( $field->field_options['post_field'] || $atts['type'] === 'tag' ) ) {
302 338 $atts['pre_truncate'] = $atts['truncate'];
303 339 $atts['truncate'] = true;
304 - $atts['exclude_cat'] = isset( $field->field_options['exclude_cat'] ) ? $field->field_options['exclude_cat'] : 0;
340 + $atts['exclude_cat'] = $field->field_options['exclude_cat'] ?? 0;
305 341
306 342 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
307 343 $atts['truncate'] = $atts['pre_truncate'];
308 344 }
309 345
346 + // phpcs:ignore Universal.Operators.StrictComparisons
310 347 if ( $value == '' ) {
311 348 return $value;
312 349 }
313 350
@@ -316,13 +353,14 @@
316 353
317 354 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
318 355 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
319 356
357 + // phpcs:ignore Universal.Operators.StrictComparisons
320 358 if ( $value == $unfiltered_value ) {
321 359 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
322 360 }
323 361
324 - if ( $atts['truncate'] && $atts['type'] != 'url' ) {
362 + if ( $atts['truncate'] && $atts['type'] !== 'url' ) {
325 363 $value = FrmAppHelper::truncate( $value, 50 );
326 364 }
327 365
328 366 if ( ! $atts['keepjs'] && ! is_array( $value ) ) {
@@ -331,13 +369,21 @@
331 369
332 370 return apply_filters( 'frm_display_value', $value, $field, $atts );
333 371 }
334 372
373 + /**
374 + * @param object $field
375 + * @param mixed $value
376 + * @param array $args
377 + *
378 + * @return void
379 + */
335 380 public static function set_posted_value( $field, $value, $args ) {
336 381 // If validating a field with "other" opt, set back to prev value now.
337 - if ( isset( $args['other'] ) && $args['other'] ) {
382 + if ( ! empty( $args['other'] ) ) {
338 383 $value = $args['temp_value'];
339 384 }
385 +
340 386 if ( empty( $args['parent_field_id'] ) ) {
341 387 $_POST['item_meta'][ $field->id ] = $value;
342 388 } else {
343 389 self::set_parent_field_posted_value( $field, $value, $args );
@@ -347,12 +393,18 @@
347 393 /**
348 394 * Init arrays if necessary, else we get fatal error.
349 395 *
350 396 * @since 4.01
397 + *
398 + * @param object $field Field object.
399 + * @param mixed $value Value to set.
400 + * @param array $args Additional arguments.
401 + *
402 + * @return void
351 403 */
352 404 private static function set_parent_field_posted_value( $field, $value, $args ) {
353 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
354 - if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
405 + if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
406 + if ( ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) || ! is_array( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
355 407 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
356 408 }
357 409 } else {
358 410 // All of the section was probably removed.
@@ -362,15 +414,27 @@
362 414
363 415 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
364 416 }
365 417
418 + /**
419 + * @param array|int|object|string $field
420 + * @param mixed $value
421 + * @param array $args
422 + *
423 + * @return void
424 + */
366 425 public static function get_posted_value( $field, &$value, $args ) {
367 426 if ( is_array( $field ) ) {
368 427 $field_id = $field['id'];
369 428 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
370 429 } elseif ( is_object( $field ) ) {
371 - $field_id = $field->id;
372 - $field_obj = FrmFieldFactory::get_field_object( $field );
430 + $field_id = $field->id;
431 +
432 + if ( 'hidden' === $field->type && ! empty( $field->field_options['original_type'] ) ) {
433 + $field_obj = FrmFieldFactory::get_field_type( $field->field_options['original_type'], $field );
434 + } else {
435 + $field_obj = FrmFieldFactory::get_field_object( $field );
436 + }
373 437 } elseif ( is_numeric( $field ) ) {
374 438 $field_id = $field;
375 439 $field_obj = FrmFieldFactory::get_field_object( $field );
376 440 } else {
@@ -385,15 +449,21 @@
385 449 }
386 450
387 451 /**
388 452 * @since 4.02.04
453 + * @since 6.29 This is public.
454 + *
455 + * @param int|string $field_id Field ID.
456 + * @param array $args Additional arguments.
457 + *
458 + * @return mixed
389 459 */
390 - private static function get_posted_meta( $field_id, $args ) {
460 + public static function get_posted_meta( $field_id, $args ) {
391 461 if ( empty( $args['parent_field_id'] ) ) {
392 462 // Sanitizing is done next.
393 - $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
463 + $value = isset( $_POST['item_meta'][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
394 464 } else {
395 - $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
465 + $value = isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) ? wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field_id ] ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
396 466 }
397 467 return $value;
398 468 }
399 469
@@ -401,14 +471,17 @@
401 471 * Check if field has an "Other" option and if any other values are posted
402 472 *
403 473 * @since 2.0
404 474 *
405 - * @param object $field
406 - * @param string|array $value
407 - * @param array $args
475 + * @param object $field Field object.
476 + * @param array|string $value Field value, passed by reference.
477 + * @param array $args Arguments array, passed by reference.
478 + *
479 + * @return void
408 480 */
409 481 public static function maybe_set_other_validation( $field, &$value, &$args ) {
410 482 $args['other'] = false;
483 +
411 484 if ( ! $value || ! FrmAppHelper::pro_is_installed() ) {
412 485 return;
413 486 }
414 487
@@ -422,21 +495,22 @@
422 495 // Get other value for fields in repeating section.
423 496 self::set_other_repeating_vals( $field, $value, $args );
424 497
425 498 // Check if there are any posted "Other" values.
426 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
499 + if ( ! FrmField::is_option_true( $field, 'other' ) || ! isset( $_POST['item_meta']['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
500 + return;
501 + }
427 502
428 - // Save original value.
429 - $args['temp_value'] = $value;
430 - $args['other'] = true;
503 + // Save original value.
504 + $args['temp_value'] = $value;
505 + $args['other'] = true;
431 506
432 - // Sanitizing is done next.
433 - $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
434 - FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
507 + // Sanitizing is done next.
508 + $other_vals = wp_unslash( $_POST['item_meta']['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
509 + FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
435 510
436 - // Set the validation value now
437 - self::set_other_validation_val( $value, $other_vals, $field, $args );
438 - }
511 + // Set the validation value now
512 + self::set_other_validation_val( $value, $other_vals, $field, $args );
439 513 }
440 514
441 515 /**
442 516 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
@@ -442,11 +516,13 @@
442 516 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
443 517 *
444 518 * @since 2.0
445 519 *
446 - * @param object $field
447 - * @param string|array $value
448 - * @param array $args
520 + * @param object $field Field object.
521 + * @param array|string $value Field value, passed by reference.
522 + * @param array $args Arguments array, passed by reference.
523 + *
524 + * @return void
449 525 */
450 526 public static function set_other_repeating_vals( $field, &$value, &$args ) {
451 527 if ( ! $args['parent_field_id'] ) {
452 528 return;
@@ -452,19 +528,20 @@
452 528 return;
453 529 }
454 530
455 531 // Check if there are any other posted "other" values for this field.
456 - if ( FrmField::is_option_true( $field, 'other' ) && isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
457 - // Save original value
458 - $args['temp_value'] = $value;
459 - $args['other'] = true;
532 + if ( ! FrmField::is_option_true( $field, 'other' ) || ! isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
533 + return;
534 + }
460 535
461 - $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing
462 - FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
536 + // Save original value
537 + $args['temp_value'] = $value;
538 + $args['other'] = true;
539 + $other_vals = wp_unslash( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ]['other'][ $field->id ] ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.NonceVerification.Missing, SlevomatCodingStandard.Files.LineLength.LineTooLong
540 + FrmAppHelper::sanitize_value( 'sanitize_text_field', $other_vals );
463 541
464 - // Set the validation value now.
465 - self::set_other_validation_val( $value, $other_vals, $field, $args );
466 - }
542 + // Set the validation value now.
543 + self::set_other_validation_val( $value, $other_vals, $field, $args );
467 544 }
468 545
469 546 /**
470 547 * Modify value used for validation
@@ -474,15 +551,17 @@
474 551 * Needs to accommodate for times when other opt is selected, but no other free text is entered
475 552 *
476 553 * @since 2.0
477 554 *
478 - * @param string|array $value
479 - * @param string|array $other_vals (usually of posted values)
480 - * @param object $field
481 - * @param array $args
555 + * @param array|string $value
556 + * @param array|string $other_vals (usually of posted values).
557 + * @param object $field
558 + * @param array $args
559 + *
560 + * @return void
482 561 */
483 562 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
484 - // Checkboxes and multi-select dropdowns.
563 + // Checkboxes.
485 564 if ( is_array( $value ) && $field->type === 'checkbox' ) {
486 565 // Combine "Other" values with checked values. "Other" values will override checked box values.
487 566 foreach ( $other_vals as $k => $v ) {
488 567 if ( isset( $value[ $k ] ) && trim( $v ) === '' ) {
@@ -491,40 +570,44 @@
491 570 break;
492 571 }
493 572 }
494 573
495 - if ( is_array( $value ) && ! empty( $value ) ) {
574 + if ( is_array( $value ) && $value ) {
496 575 $value = array_merge( $value, $other_vals );
497 576 }
498 - } else {
499 - // Radio and dropdowns.
500 - $other_key = array_filter( array_keys( $field->options ), 'is_string' );
501 - $other_key = reset( $other_key );
502 577
503 - // Multi-select dropdown.
504 - if ( is_array( $value ) ) {
505 - $o_key = array_search( $field->options[ $other_key ], $value );
578 + return;
579 + }
506 580
507 - if ( $o_key !== false ) {
508 - // Modify the original value so other key will be preserved.
509 - $value[ $other_key ] = $value[ $o_key ];
581 + // Radio and dropdowns.
582 + $other_key = array_filter( array_keys( $field->options ), 'is_string' );
583 + $other_key = reset( $other_key );
510 584
511 - // By default, the array keys will be numeric for multi-select dropdowns.
512 - // If going backwards and forwards between pages, the array key will match the other key.
513 - if ( $o_key !== $other_key ) {
514 - unset( $value[ $o_key ] );
515 - }
585 + // Multi-select dropdown.
586 + if ( is_array( $value ) ) {
587 + // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
588 + $o_key = array_search( $field->options[ $other_key ], $value );
516 589
517 - $args['temp_value'] = $value;
518 - $value[ $other_key ] = reset( $other_vals );
519 - if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
520 - unset( $value[ $other_key ] );
521 - }
590 + if ( $o_key !== false ) {
591 + // Modify the original value so other key will be preserved.
592 + $value[ $other_key ] = $value[ $o_key ];
593 +
594 + // By default, the array keys will be numeric for multi-select dropdowns.
595 + // If going backwards and forwards between pages, the array key will match the other key.
596 + if ( $o_key !== $other_key ) {
597 + unset( $value[ $o_key ] );
522 598 }
523 - } elseif ( $field->options[ $other_key ] == $value ) {
524 - $value = $other_vals;
599 +
600 + $args['temp_value'] = $value;
601 + $value[ $other_key ] = reset( $other_vals );
602 +
603 + if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
604 + unset( $value[ $other_key ] );
605 + }
525 606 }
526 - }
607 + } elseif ( $field->options[ $other_key ] == $value ) { // phpcs:ignore Universal.Operators.StrictComparisons
608 + $value = $other_vals;
609 + }//end if
527 610 }
528 611
529 612 /**
530 613 * Add submitted values to a string for spam checking.
@@ -529,14 +612,16 @@
529 612 /**
530 613 * Add submitted values to a string for spam checking.
531 614 *
532 615 * @param array $values
616 + *
533 617 * @return string
534 618 */
535 619 public static function entry_array_to_string( $values ) {
536 620 $content = '';
621 +
537 622 foreach ( $values['item_meta'] as $val ) {
538 - if ( $content != '' ) {
623 + if ( $content !== '' ) {
539 624 $content .= "\n\n";
540 625 }
541 626
542 627 if ( is_array( $val ) ) {
@@ -560,9 +645,9 @@
560 645 * @return string
561 646 */
562 647 public static function get_browser( $u_agent ) {
563 648 $bname = __( 'Unknown', 'formidable' );
564 - $platform = __( 'Unknown', 'formidable' );
649 + $platform = $bname;
565 650 $ub = '';
566 651
567 652 // Get the operating system
568 653 if ( preg_match( '/windows|win32/i', $u_agent ) ) {
@@ -582,15 +667,15 @@
582 667 'Netscape' => 'Netscape',
583 668 'Firefox' => 'Mozilla Firefox',
584 669 );
585 670
586 - // Next get the name of the useragent yes seperately and for good reason
587 - if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
671 + // Next get the name of the useragent yes separately and for good reason.
672 + if ( str_contains( $u_agent, 'MSIE' ) && ! str_contains( $u_agent, 'Opera' ) ) {
588 673 $bname = 'Internet Explorer';
589 674 $ub = 'MSIE';
590 675 } else {
591 676 foreach ( $agent_options as $agent_key => $agent_name ) {
592 - if ( strpos( $u_agent, $agent_key ) !== false ) {
677 + if ( str_contains( $u_agent, $agent_key ) ) {
593 678 $bname = $agent_name;
594 679 $ub = $agent_key;
595 680 break;
596 681 }
@@ -596,24 +681,21 @@
596 681 }
597 682 }
598 683 }
599 684
600 - // finally get the correct version number
685 + // Finally get the correct version number
601 686 $known = array( 'Version', $ub, 'other' );
602 - $pattern = '#(?<browser>' . join( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
603 - preg_match_all( $pattern, $u_agent, $matches ); // get the matching numbers
687 + $pattern = '#(?<browser>' . implode( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
688 + // Get the matching numbers.
689 + preg_match_all( $pattern, $u_agent, $matches );
604 690
605 - // see how many we have
691 + // See how many we have
606 692 $i = count( $matches['browser'] );
607 693
608 694 if ( $i > 1 ) {
609 - //we will have two since we are not using 'other' argument yet
610 - //see if version is before or after the name
611 - if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
612 - $version = $matches['version'][0];
613 - } else {
614 - $version = $matches['version'][1];
615 - }
695 + // We will have two since we are not using 'other' argument yet
696 + // See if version is before or after the name.
697 + $version = strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ? $matches['version'][0] : $matches['version'][1];
616 698 } elseif ( $i === 1 ) {
617 699 $version = $matches['version'][0];
618 700 } else {
619 701 $version = '';
@@ -618,10 +700,10 @@
618 700 } else {
619 701 $version = '';
620 702 }
621 703
622 - // check if we have a number
623 - if ( $version == '' ) {
704 + // Check if we have a number
705 + if ( $version === '' ) {
624 706 $version = '?';
625 707 }
626 708
627 709 return $bname . ' ' . $version . ' / ' . $platform;
@@ -628,14 +710,19 @@
628 710 }
629 711
630 712 /**
631 713 * @since 3.0
714 + *
715 + * @param array $atts Action dropdown attributes.
716 + *
717 + * @return void
632 718 */
633 719 public static function actions_dropdown( $atts ) {
634 - $id = isset( $atts['id'] ) ? $atts['id'] : FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
720 + $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
635 721 $links = self::get_action_links( $id, $atts['entry'] );
636 722
637 723 foreach ( $links as $link ) {
724 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
638 725 ?>
639 726 <div class="misc-pub-section">
640 727 <a href="<?php echo esc_url( $link['url'] ); ?>"
641 728 <?php
@@ -643,11 +730,13 @@
643 730 foreach ( $link['data'] as $data => $value ) {
644 731 echo 'data-' . esc_attr( $data ) . '="' . esc_attr( $value ) . '" ';
645 732 }
646 733 }
734 +
647 735 if ( isset( $link['class'] ) ) {
648 736 echo 'class="' . esc_attr( $link['class'] ) . '" ';
649 737 }
738 +
650 739 if ( isset( $link['id'] ) ) {
651 740 echo 'id="' . esc_attr( $link['id'] ) . '" ';
652 741 }
653 742 ?>
@@ -656,45 +745,62 @@
656 745 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
657 746 </a>
658 747 </div>
659 748 <?php
660 - }
749 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
750 + }//end foreach
661 751 }
662 752
663 753 /**
664 754 * @since 3.0
755 + *
756 + * @param int $id Entry ID.
757 + * @param array|object $entry Entry object.
758 + *
759 + * @return array
665 760 */
666 761 private static function get_action_links( $id, $entry ) {
667 762 $page = FrmAppHelper::get_param( 'frm_action' );
668 763 $actions = array();
669 764
670 - if ( $page != 'show' ) {
765 + $actions['frm_edit'] = array(
766 + 'url' => '#',
767 + 'label' => __( 'Edit Entry', 'formidable' ),
768 + 'class' => 'frm_noallow',
769 + 'data' => array(
770 + 'upgrade' => __( 'Entry edits', 'formidable' ),
771 + 'medium' => 'edit-entries',
772 + 'content' => 'entry',
773 + ),
774 + 'icon' => 'frmfont frm_pencil_icon',
775 + );
776 +
777 + if ( $page !== 'show' ) {
671 778 $actions['frm_view'] = array(
672 779 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
673 780 'label' => __( 'View Entry', 'formidable' ),
674 - 'icon' => 'frm_icon_font frm_save_icon',
781 + 'icon' => 'frmfont frm_save_icon',
675 782 );
676 783 }
677 784
678 - if ( current_user_can( 'frm_delete_entries' ) ) {
679 - $actions['frm_delete'] = array(
680 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
681 - 'label' => __( 'Delete Entry', 'formidable' ),
682 - 'icon' => 'frm_icon_font frm_delete_icon',
785 + if ( $page === 'show' ) {
786 + $actions['frm_print'] = array(
787 + 'url' => '#',
788 + 'label' => __( 'Print Entry', 'formidable' ),
683 789 'data' => array(
684 - 'frmverify' => __( 'Delete this form entry?', 'formidable' ),
790 + 'frmprint' => '1',
685 791 ),
792 + 'icon' => 'frmfont frm_printer_icon',
686 793 );
687 794 }
688 795
689 - if ( $page == 'show' ) {
690 - $actions['frm_print'] = array(
796 + if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
797 + $actions['frm_download_pdf'] = array(
691 798 'url' => '#',
692 - 'label' => __( 'Print Entry', 'formidable' ),
693 - 'data' => array(
694 - 'frmprint' => '1',
695 - ),
696 - 'icon' => 'frm_icon_font frm_printer_icon',
799 + 'label' => __( 'Download as PDF', 'formidable' ),
800 + 'class' => 'frm_noallow',
801 + 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
802 + 'icon' => 'frmfont frm_download_icon',
697 803 );
698 804 }
699 805
700 806 $actions['frm_resend'] = array(
@@ -705,34 +811,36 @@
705 811 'upgrade' => __( 'Resend Emails', 'formidable' ),
706 812 'medium' => 'resend-email',
707 813 'content' => 'entry',
708 814 ),
709 - 'icon' => 'frm_icon_font frm_email_icon',
815 + 'icon' => 'frmfont frm_email_icon',
710 816 );
711 817
712 - if ( ! function_exists( 'frm_pdfs_autoloader' ) && FrmAppHelper::show_new_feature( 'pdfs' ) ) {
713 - $actions['frm_download_pdf'] = array(
714 - 'url' => '#',
715 - 'label' => __( 'Download as PDF', 'formidable' ),
716 - 'class' => 'frm_noallow',
717 - 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
718 - 'icon' => 'frm_icon_font frm_download_icon',
818 + if ( current_user_can( 'frm_delete_entries' ) ) {
819 + $actions['frm_delete'] = array(
820 + 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
821 + 'label' => __( 'Delete Entry', 'formidable' ),
822 + 'class' => 'frm_delete_entry',
823 + 'icon' => 'frmfont frm_delete_icon',
824 + 'data' => array(
825 + 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
826 + 'frmverify-btn' => 'frm-button-red',
827 + ),
719 828 );
720 829 }
721 830
722 - $actions['frm_edit'] = array(
723 - 'url' => '#',
724 - 'label' => __( 'Edit Entry', 'formidable' ),
725 - 'class' => 'frm_noallow',
726 - 'data' => array(
727 - 'upgrade' => __( 'Entry edits', 'formidable' ),
728 - 'medium' => 'edit-entries',
729 - 'content' => 'entry',
730 - ),
731 - 'icon' => 'frm_icon_font frm_pencil_icon',
732 - );
831 + $actions = apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
733 832
734 - return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
833 + if ( ! isset( $actions['frm_delete'] ) ) {
834 + return $actions;
835 + }
836 +
837 + // Make delete the last link.
838 + $delete_action = $actions['frm_delete'];
839 + unset( $actions['frm_delete'] );
840 + $actions['frm_delete'] = $delete_action;
841 +
842 + return $actions;
735 843 }
736 844
737 845 /**
738 846 * Gets data attributes for PDFs addon upgrade link.
@@ -737,8 +845,9 @@
737 845 /**
738 846 * Gets data attributes for PDFs addon upgrade link.
739 847 *
740 848 * @param string $medium The source of the upgrade link used for analytics data.
849 + *
741 850 * @return array
742 851 */
743 852 private static function get_pdfs_upgrade_link_data( $medium = 'pdfs' ) {
744 853 $data = array(
@@ -748,8 +857,9 @@
748 857 'medium' => $medium,
749 858 );
750 859
751 860 $upgrading = FrmAddonsController::install_link( 'pdfs' );
861 +
752 862 if ( isset( $upgrading['url'] ) ) {
753 863 $data['oneclick'] = json_encode( $upgrading );
754 864 } else {
755 865 $data['requires'] = FrmAddonsController::get_addon_required_plan( 28136428 );
@@ -760,9 +870,10 @@
760 870
761 871 /**
762 872 * @since 5.0.15
763 873 *
764 - * @param string|int $entry_id
874 + * @param int|string $entry_id
875 + *
765 876 * @return void
766 877 */
767 878 public static function maybe_render_captcha_score( $entry_id ) {
768 879 $query = array(
@@ -769,17 +880,20 @@
769 880 'item_id' => (int) $entry_id,
770 881 'field_id' => 0,
771 882 );
772 883 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
884 +
773 885 foreach ( $metas_without_a_field as $meta ) {
774 - if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
775 - echo '<div class="misc-pub-section">';
776 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
777 - echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
778 - echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
779 - echo '</div>';
780 - return;
886 + if ( empty( $meta->meta_value['captcha_score'] ) ) {
887 + continue;
781 888 }
889 +
890 + echo '<div class="misc-pub-section">';
891 + FrmAppHelper::icon_by_class( 'frmfont frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
892 + echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
893 + echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
894 + echo '</div>';
895 + return;
782 896 }
783 897 }
784 898
785 899 /**
@@ -784,9 +898,9 @@
784 898
785 899 /**
786 900 * Return entry status based on is_draft column value.
787 901 *
788 - * @since x.x
902 + * @since 6.5
789 903 *
790 904 * @param int $status is_draft column.
791 905 *
792 906 * @return int
@@ -791,25 +905,25 @@
791 905 *
792 906 * @return int
793 907 */
794 908 public static function get_entry_status( $status ) {
795 - $statuses = self::get_entry_statuses();
796 -
797 - if ( array_key_exists( $status, $statuses ) ) {
909 + if ( array_key_exists( $status, self::get_entry_statuses() ) ) {
798 910 return $status;
799 911 }
800 912
801 - if ( empty( $status ) ) {
802 - return self::SUBMITTED_ENTRY_STATUS; // If the status is empty, let's default to 0.
913 + if ( ! $status ) {
914 + // If the status is empty, let's default to 0.
915 + return self::SUBMITTED_ENTRY_STATUS;
803 916 }
804 917
805 - return self::DRAFT_ENTRY_STATUS; // If it has a value that isn't in the array, let's default to 1. There may be old entries that don't have a value for is_draft.
918 + // If it has a value that isn't in the array, let's default to 1. There may be old entries that don't have a value for is_draft.
919 + return self::DRAFT_ENTRY_STATUS;
806 920 }
807 921
808 922 /**
809 923 * Return entry status label based on passed value.
810 924 *
811 - * @since x.x
925 + * @since 6.5
812 926 *
813 927 * @param int $status is_draft column.
814 928 *
815 929 * @return string
@@ -814,22 +928,20 @@
814 928 *
815 929 * @return string
816 930 */
817 931 public static function get_entry_status_label( $status ) {
818 - $statuses = self::get_entry_statuses();
819 -
820 - return $statuses[ self::get_entry_status( $status ) ];
932 + return self::get_entry_statuses()[ self::get_entry_status( $status ) ];
821 933 }
822 934
823 935 /**
824 936 * Get all entry statuses.
825 937 *
826 - * @since x.x
938 + * @since 6.5
939 + * @since 6.6 function went from private to public.
827 940 *
828 941 * @return array<string>
829 942 */
830 - private static function get_entry_statuses() {
831 -
943 + public static function get_entry_statuses() {
832 944 $default_entry_statuses = array(
833 945 self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ),
834 946 self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ),
835 947 );
@@ -839,9 +951,9 @@
839 951 *
840 952 * "2" is used in abandonment-addon and reserved for "In progress".
841 953 * "3" is used in abandonment-addon and reserved for "Abandoned".
842 954 *
843 - * @since x.x
955 + * @since 6.5
844 956 *
845 957 * @param array<string> $extended_entry_status Entry statuses.
846 958 */
847 959 $extended_entry_status = apply_filters( 'frm_entry_statuses', array() );
@@ -846,14 +958,39 @@
846 958 */
847 959 $extended_entry_status = apply_filters( 'frm_entry_statuses', array() );
848 960
849 961 if ( ! is_array( $extended_entry_status ) ) {
850 - _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), 'x.x' );
962 + _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' );
851 963 $extended_entry_status = array();
852 964 }
853 965
854 - $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status );
966 + return array_replace( $default_entry_statuses, $extended_entry_status );
967 + }
855 968
856 - return $existing_entry_statuses;
969 + /**
970 + * @since 6.17
971 + *
972 + * @return int
973 + */
974 + public static function get_visible_unread_inbox_count() {
975 + if ( ! in_array( FrmAppHelper::get_menu_name(), array( 'Formidable', 'Forms' ), true ) ) {
976 + return 0;
977 + }
978 +
979 + $inbox = new FrmInbox();
980 + $inbox_count = count( $inbox->unread() );
981 +
982 + if ( ! $inbox_count ) {
983 + return 0;
984 + }
985 +
986 + if ( is_callable( 'FrmProSettingsController::inbox_badge' ) ) {
987 + $inbox_count = FrmProSettingsController::inbox_badge( $inbox_count );
988 +
989 + if ( ! $inbox_count ) {
990 + return 0;
991 + }
992 + }
993 +
994 + return $inbox_count;
857 995 }
858 -
859 996 }