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 +158 -152 6.26 → trunk View file →
@@ -41,9 +41,9 @@
41 41 );
42 42
43 43 $values['fields'] = array();
44 44
45 - if ( empty( $fields ) ) {
45 + if ( ! $fields ) {
46 46 return apply_filters( 'frm_setup_new_entry', $values );
47 47 }
48 48
49 49 foreach ( (array) $fields as $field ) {
@@ -48,10 +48,9 @@
48 48
49 49 foreach ( (array) $fields as $field ) {
50 50 $original_default = $field->default_value;
51 51 self::prepare_field_default_value( $field );
52 - $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
53 -
52 + $new_value = self::get_field_value_for_new_entry( $field, $reset, $args );
54 53 $field_array = FrmAppHelper::start_field_array( $field );
55 54 $field_array['value'] = $new_value;
56 55 $field_array['type'] = apply_filters( 'frm_field_type', $field->type, $field, $new_value );
57 56 $field_array['parent_form_id'] = $args['parent_form_id'] ?? $field->form_id;
@@ -119,9 +118,9 @@
119 118 * @param object $field - this is passed by reference since it is an object.
120 119 * @param bool $reset
121 120 * @param array $args
122 121 *
123 - * @return array|string $new_value
122 + * @return array|string New value.
124 123 */
125 124 private static function get_field_value_for_new_entry( $field, $reset, $args ) {
126 125 $new_value = $field->default_value;
127 126
@@ -129,9 +128,9 @@
129 128 self::get_posted_value( $field, $new_value, $args );
130 129 }
131 130
132 131 if ( ! is_array( $new_value ) ) {
133 - $new_value = str_replace( '"', '"', $new_value );
132 + return str_replace( '"', '"', $new_value );
134 133 }
135 134
136 135 return $new_value;
137 136 }
@@ -143,23 +142,25 @@
143 142 *
144 143 * @param object $field
145 144 * @param array $args
146 145 *
147 - * @return bool $value_is_posted
146 + * @return bool True if a value is posted.
148 147 */
149 148 public static function value_is_posted( $field, $args ) {
150 149 $value_is_posted = false;
151 150
152 - if ( $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
153 - $repeating = isset( $args['repeating'] ) && $args['repeating'];
151 + if ( ! $_POST ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
152 + return $value_is_posted;
153 + }
154 154
155 - if ( $repeating ) {
156 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
157 - $value_is_posted = true;
158 - }
159 - } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
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
160 159 $value_is_posted = true;
161 160 }
161 + } elseif ( isset( $_POST['item_meta'][ $field->id ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
162 + $value_is_posted = true;
162 163 }
163 164
164 165 return $value_is_posted;
165 166 }
@@ -186,15 +187,15 @@
186 187 *
187 188 * @return string
188 189 */
189 190 public static function replace_default_message( $message, $atts ) {
190 - if ( strpos( $message, '[default-message' ) === false &&
191 - strpos( $message, '[default_message' ) === false &&
192 - ! empty( $message ) ) {
191 + if ( ! str_contains( $message, '[default-message' ) &&
192 + ! str_contains( $message, '[default_message' ) &&
193 + $message ) {
193 194 return $message;
194 195 }
195 196
196 - if ( empty( $message ) ) {
197 + if ( ! $message ) {
197 198 $message = '[default-message]';
198 199 }
199 200
200 201 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
@@ -199,18 +200,12 @@
199 200
200 201 preg_match_all( "/\[(default-message|default_message)\b(.*?)(?:(\/))?\]/s", $message, $shortcodes, PREG_PATTERN_ORDER );
201 202
202 203 foreach ( $shortcodes[0] as $short_key => $tag ) {
203 - $add_atts = FrmShortcodeHelper::get_shortcode_attribute_array( $shortcodes[2][ $short_key ] );
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 );
204 207
205 - if ( ! empty( $add_atts ) ) {
206 - $this_atts = array_merge( $atts, $add_atts );
207 - } else {
208 - $this_atts = $atts;
209 - }
210 -
211 - $default = FrmEntriesController::show_entry_shortcode( $this_atts );
212 -
213 208 // Add the default message.
214 209 $message = str_replace( $shortcodes[0][ $short_key ], $default, $message );
215 210 }
216 211
@@ -227,17 +222,18 @@
227 222 public static function prepare_display_value( $entry, $field, $atts ) {
228 223 $field_value = $entry->metas[ $field->id ] ?? false;
229 224
230 225 if ( FrmAppHelper::pro_is_installed() ) {
231 - $empty = empty( $field_value );
226 + $empty = ! $field_value;
232 227 FrmProEntriesHelper::get_dynamic_list_values( $field, $entry, $field_value );
233 228
234 - if ( $empty && ! empty( $field_value ) ) {
229 + if ( $empty && $field_value ) {
235 230 // We've got an entry id, so switch it to a value.
236 231 $atts['force_id'] = true;
237 232 }
238 233 }
239 234
235 + // phpcs:ignore Universal.Operators.StrictComparisons
240 236 if ( $field->form_id == $entry->form_id || empty( $atts['embedded_field_id'] ) ) {
241 237 return self::display_value( $field_value, $field, $atts );
242 238 }
243 239
@@ -249,9 +245,9 @@
249 245 return FrmProEntriesHelper::prepare_child_display_value( $entry, $field, $atts );
250 246 }
251 247
252 248 // This is an embedded form.
253 - if ( strpos( $atts['embedded_field_id'], 'form' ) === 0 ) {
249 + if ( str_starts_with( $atts['embedded_field_id'], 'form' ) ) {
254 250 // This is a repeating section.
255 251 $child_entries = FrmEntry::getAll( array( 'it.parent_item_id' => $entry->id ), '', '', true );
256 252 } else {
257 253 // Get all values for this field.
@@ -261,14 +257,14 @@
261 257 $child_entries = FrmEntry::getAll( array( 'it.id' => (array) $child_values ) );
262 258 }
263 259 }
264 260
265 - $field_value = array();
266 -
267 261 if ( empty( $child_entries ) ) {
268 262 return '';
269 263 }
270 264
265 + $field_value = array();
266 +
271 267 foreach ( $child_entries as $child_entry ) {
272 268 $atts['item_id'] = $child_entry->id;
273 269 $atts['post_id'] = $child_entry->post_id;
274 270
@@ -275,9 +271,9 @@
275 271 // Fet the value for this field -- check for post values as well.
276 272 $entry_val = FrmProEntryMetaHelper::get_post_or_meta_value( $child_entry, $field );
277 273
278 274 if ( $entry_val || '0' === $entry_val ) {
279 - // foreach entry get display_value.
275 + // For each entry get display_value.
280 276 $field_value[] = self::display_value( $entry_val, $field, $atts );
281 277 }
282 278
283 279 unset( $child_entry );
@@ -284,9 +280,9 @@
284 280 }
285 281
286 282 $sep = ', ';
287 283
288 - if ( strpos( implode( ' ', $field_value ), '<img' ) !== false ) {
284 + if ( str_contains( implode( ' ', $field_value ), '<img' ) ) {
289 285 $sep = '<br/>';
290 286 }
291 287
292 288 $val = implode( $sep, $field_value );
@@ -303,9 +299,8 @@
303 299 *
304 300 * @return string
305 301 */
306 302 public static function display_value( $value, $field, $atts = array() ) {
307 -
308 303 $defaults = array(
309 304 'type' => '',
310 305 'html' => false,
311 306 'show_filename' => true,
@@ -347,8 +342,9 @@
347 342 $value = FrmProEntryMetaHelper::get_post_value( $atts['post_id'], $field->field_options['post_field'], $field->field_options['custom_field'], $atts );
348 343 $atts['truncate'] = $atts['pre_truncate'];
349 344 }
350 345
346 + // phpcs:ignore Universal.Operators.StrictComparisons
351 347 if ( $value == '' ) {
352 348 return $value;
353 349 }
354 350
@@ -357,8 +353,9 @@
357 353
358 354 $value = apply_filters( 'frm_display_value_custom', $unfiltered_value, $field, $atts );
359 355 $value = apply_filters( 'frm_display_' . $field->type . '_value_custom', $value, compact( 'field', 'atts' ) );
360 356
357 + // phpcs:ignore Universal.Operators.StrictComparisons
361 358 if ( $value == $unfiltered_value ) {
362 359 $value = FrmFieldsHelper::get_unfiltered_display_value( compact( 'value', 'field', 'atts' ) );
363 360 }
364 361
@@ -404,10 +401,10 @@
404 401 *
405 402 * @return void
406 403 */
407 404 private static function set_parent_field_posted_value( $field, $value, $args ) {
408 - if ( isset( $_POST['item_meta'][ $args['parent_field_id'] ] ) && is_array( $_POST['item_meta'][ $args['parent_field_id'] ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
409 - 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
410 407 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ] = array(); // phpcs:ignore WordPress.Security.NonceVerification.Missing
411 408 }
412 409 } else {
413 410 // All of the section was probably removed.
@@ -418,11 +415,11 @@
418 415 $_POST['item_meta'][ $args['parent_field_id'] ][ $args['key_pointer'] ][ $field->id ] = $value; // phpcs:ignore WordPress.Security.NonceVerification.Missing
419 416 }
420 417
421 418 /**
422 - * @param array|int|object $field
423 - * @param mixed $value
424 - * @param array $args
419 + * @param array|int|object|string $field
420 + * @param mixed $value
421 + * @param array $args
425 422 *
426 423 * @return void
427 424 */
428 425 public static function get_posted_value( $field, &$value, $args ) {
@@ -429,9 +426,9 @@
429 426 if ( is_array( $field ) ) {
430 427 $field_id = $field['id'];
431 428 $field_obj = FrmFieldFactory::get_field_object( $field['id'] );
432 429 } elseif ( is_object( $field ) ) {
433 - $field_id = $field->id;
430 + $field_id = $field->id;
434 431
435 432 if ( 'hidden' === $field->type && ! empty( $field->field_options['original_type'] ) ) {
436 433 $field_obj = FrmFieldFactory::get_field_type( $field->field_options['original_type'], $field );
437 434 } else {
@@ -452,8 +449,9 @@
452 449 }
453 450
454 451 /**
455 452 * @since 4.02.04
453 + * @since 6.29 This is public.
456 454 *
457 455 * @param int|string $field_id Field ID.
458 456 * @param array $args Additional arguments.
459 457 *
@@ -458,14 +456,14 @@
458 456 * @param array $args Additional arguments.
459 457 *
460 458 * @return mixed
461 459 */
462 - private static function get_posted_meta( $field_id, $args ) {
460 + public static function get_posted_meta( $field_id, $args ) {
463 461 if ( empty( $args['parent_field_id'] ) ) {
464 462 // Sanitizing is done next.
465 - $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
466 464 } else {
467 - $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
468 466 }
469 467 return $value;
470 468 }
471 469
@@ -497,21 +495,22 @@
497 495 // Get other value for fields in repeating section.
498 496 self::set_other_repeating_vals( $field, $value, $args );
499 497
500 498 // Check if there are any posted "Other" values.
501 - 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 + }
502 502
503 - // Save original value.
504 - $args['temp_value'] = $value;
505 - $args['other'] = true;
503 + // Save original value.
504 + $args['temp_value'] = $value;
505 + $args['other'] = true;
506 506
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
509 - 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 );
510 510
511 - // Set the validation value now
512 - self::set_other_validation_val( $value, $other_vals, $field, $args );
513 - }
511 + // Set the validation value now
512 + self::set_other_validation_val( $value, $other_vals, $field, $args );
514 513 }
515 514
516 515 /**
517 516 * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
@@ -529,19 +528,20 @@
529 528 return;
530 529 }
531 530
532 531 // Check if there are any other posted "other" values for this field.
533 - 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
534 - // Save original value
535 - $args['temp_value'] = $value;
536 - $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 + }
537 535
538 - $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
539 - 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 );
540 541
541 - // Set the validation value now.
542 - self::set_other_validation_val( $value, $other_vals, $field, $args );
543 - }
542 + // Set the validation value now.
543 + self::set_other_validation_val( $value, $other_vals, $field, $args );
544 544 }
545 545
546 546 /**
547 547 * Modify value used for validation
@@ -559,9 +559,9 @@
559 559 *
560 560 * @return void
561 561 */
562 562 public static function set_other_validation_val( &$value, $other_vals, $field, &$args ) {
563 - // Checkboxes and multi-select dropdowns.
563 + // Checkboxes.
564 564 if ( is_array( $value ) && $field->type === 'checkbox' ) {
565 565 // Combine "Other" values with checked values. "Other" values will override checked box values.
566 566 foreach ( $other_vals as $k => $v ) {
567 567 if ( isset( $value[ $k ] ) && trim( $v ) === '' ) {
@@ -570,40 +570,43 @@
570 570 break;
571 571 }
572 572 }
573 573
574 - if ( is_array( $value ) && ! empty( $value ) ) {
574 + if ( is_array( $value ) && $value ) {
575 575 $value = array_merge( $value, $other_vals );
576 576 }
577 - } else {
578 - // Radio and dropdowns.
579 - $other_key = array_filter( array_keys( $field->options ), 'is_string' );
580 - $other_key = reset( $other_key );
581 577
582 - // Multi-select dropdown.
583 - if ( is_array( $value ) ) {
584 - $o_key = array_search( $field->options[ $other_key ], $value );
578 + return;
579 + }
585 580
586 - if ( $o_key !== false ) {
587 - // Modify the original value so other key will be preserved.
588 - $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 );
589 584
590 - // By default, the array keys will be numeric for multi-select dropdowns.
591 - // If going backwards and forwards between pages, the array key will match the other key.
592 - if ( $o_key !== $other_key ) {
593 - unset( $value[ $o_key ] );
594 - }
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 );
595 589
596 - $args['temp_value'] = $value;
597 - $value[ $other_key ] = reset( $other_vals );
590 + if ( $o_key !== false ) {
591 + // Modify the original value so other key will be preserved.
592 + $value[ $other_key ] = $value[ $o_key ];
598 593
599 - if ( FrmAppHelper::is_empty_value( $value[ $other_key ] ) ) {
600 - unset( $value[ $other_key ] );
601 - }
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 ] );
602 598 }
603 - } elseif ( $field->options[ $other_key ] == $value ) {
604 - $value = $other_vals;
605 - }//end if
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 + }
606 + }
607 + } elseif ( $field->options[ $other_key ] == $value ) { // phpcs:ignore Universal.Operators.StrictComparisons
608 + $value = $other_vals;
606 609 }//end if
607 610 }
608 611
609 612 /**
@@ -665,14 +668,14 @@
665 668 'Firefox' => 'Mozilla Firefox',
666 669 );
667 670
668 671 // Next get the name of the useragent yes separately and for good reason.
669 - if ( strpos( $u_agent, 'MSIE' ) !== false && strpos( $u_agent, 'Opera' ) === false ) {
672 + if ( str_contains( $u_agent, 'MSIE' ) && ! str_contains( $u_agent, 'Opera' ) ) {
670 673 $bname = 'Internet Explorer';
671 674 $ub = 'MSIE';
672 675 } else {
673 676 foreach ( $agent_options as $agent_key => $agent_name ) {
674 - if ( strpos( $u_agent, $agent_key ) !== false ) {
677 + if ( str_contains( $u_agent, $agent_key ) ) {
675 678 $bname = $agent_name;
676 679 $ub = $agent_key;
677 680 break;
678 681 }
@@ -678,25 +681,21 @@
678 681 }
679 682 }
680 683 }
681 684
682 - // finally get the correct version number
685 + // Finally get the correct version number
683 686 $known = array( 'Version', $ub, 'other' );
684 687 $pattern = '#(?<browser>' . implode( '|', $known ) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
685 688 // Get the matching numbers.
686 689 preg_match_all( $pattern, $u_agent, $matches );
687 690
688 - // see how many we have
691 + // See how many we have
689 692 $i = count( $matches['browser'] );
690 693
691 694 if ( $i > 1 ) {
692 695 // We will have two since we are not using 'other' argument yet
693 - // see if version is before or after the name.
694 - if ( strripos( $u_agent, 'Version' ) < strripos( $u_agent, $ub ) ) {
695 - $version = $matches['version'][0];
696 - } else {
697 - $version = $matches['version'][1];
698 - }
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];
699 698 } elseif ( $i === 1 ) {
700 699 $version = $matches['version'][0];
701 700 } else {
702 701 $version = '';
@@ -701,9 +700,9 @@
701 700 } else {
702 701 $version = '';
703 702 }
704 703
705 - // check if we have a number
704 + // Check if we have a number
706 705 if ( $version === '' ) {
707 706 $version = '?';
708 707 }
709 708
@@ -721,8 +720,9 @@
721 720 $id = $atts['id'] ?? FrmAppHelper::get_param( 'id', 0, 'get', 'absint' );
722 721 $links = self::get_action_links( $id, $atts['entry'] );
723 722
724 723 foreach ( $links as $link ) {
724 + // phpcs:disable Generic.WhiteSpace.ScopeIndent
725 725 ?>
726 726 <div class="misc-pub-section">
727 727 <a href="<?php echo esc_url( $link['url'] ); ?>"
728 728 <?php
@@ -745,8 +745,9 @@
745 745 <span class="frm_link_label"><?php echo esc_html( $link['label'] ); ?></span>
746 746 </a>
747 747 </div>
748 748 <?php
749 + // phpcs:enable Generic.WhiteSpace.ScopeIndent
749 750 }//end foreach
750 751 }
751 752
752 753 /**
@@ -760,28 +761,28 @@
760 761 private static function get_action_links( $id, $entry ) {
761 762 $page = FrmAppHelper::get_param( 'frm_action' );
762 763 $actions = array();
763 764
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 +
764 777 if ( $page !== 'show' ) {
765 778 $actions['frm_view'] = array(
766 779 'url' => admin_url( 'admin.php?page=formidable-entries&frm_action=show&id=' . $id . '&form=' . $entry->form_id ),
767 780 'label' => __( 'View Entry', 'formidable' ),
768 - 'icon' => 'frm_icon_font frm_save_icon',
781 + 'icon' => 'frmfont frm_save_icon',
769 782 );
770 783 }
771 784
772 - if ( current_user_can( 'frm_delete_entries' ) ) {
773 - $actions['frm_delete'] = array(
774 - 'url' => wp_nonce_url( admin_url( 'admin.php?page=formidable-entries&frm_action=destroy&id=' . $id . '&form=' . $entry->form_id ) ),
775 - 'label' => __( 'Delete Entry', 'formidable' ),
776 - 'icon' => 'frm_icon_font frm_delete_icon',
777 - 'data' => array(
778 - 'frmverify' => __( 'Permanently delete this entry?', 'formidable' ),
779 - 'frmverify-btn' => 'frm-button-red',
780 - ),
781 - );
782 - }
783 -
784 785 if ( $page === 'show' ) {
785 786 $actions['frm_print'] = array(
786 787 'url' => '#',
787 788 'label' => __( 'Print Entry', 'formidable' ),
@@ -787,24 +788,12 @@
787 788 'label' => __( 'Print Entry', 'formidable' ),
788 789 'data' => array(
789 790 'frmprint' => '1',
790 791 ),
791 - 'icon' => 'frm_icon_font frm_printer_icon',
792 + 'icon' => 'frmfont frm_printer_icon',
792 793 );
793 794 }
794 795
795 - $actions['frm_resend'] = array(
796 - 'url' => '#',
797 - 'label' => __( 'Resend Emails', 'formidable' ),
798 - 'class' => 'frm_noallow',
799 - 'data' => array(
800 - 'upgrade' => __( 'Resend Emails', 'formidable' ),
801 - 'medium' => 'resend-email',
802 - 'content' => 'entry',
803 - ),
804 - 'icon' => 'frm_icon_font frm_email_icon',
805 - );
806 -
807 796 if ( ! function_exists( 'frm_pdfs_autoloader' ) ) {
808 797 $actions['frm_download_pdf'] = array(
809 798 'url' => '#',
810 799 'label' => __( 'Download as PDF', 'formidable' ),
@@ -809,25 +798,49 @@
809 798 'url' => '#',
810 799 'label' => __( 'Download as PDF', 'formidable' ),
811 800 'class' => 'frm_noallow',
812 801 'data' => self::get_pdfs_upgrade_link_data( 'download-pdf-entry' ),
813 - 'icon' => 'frm_icon_font frm_download_icon',
802 + 'icon' => 'frmfont frm_download_icon',
814 803 );
815 804 }
816 805
817 - $actions['frm_edit'] = array(
806 + $actions['frm_resend'] = array(
818 807 'url' => '#',
819 - 'label' => __( 'Edit Entry', 'formidable' ),
808 + 'label' => __( 'Resend Emails', 'formidable' ),
820 809 'class' => 'frm_noallow',
821 810 'data' => array(
822 - 'upgrade' => __( 'Entry edits', 'formidable' ),
823 - 'medium' => 'edit-entries',
811 + 'upgrade' => __( 'Resend Emails', 'formidable' ),
812 + 'medium' => 'resend-email',
824 813 'content' => 'entry',
825 814 ),
826 - 'icon' => 'frm_icon_font frm_pencil_icon',
815 + 'icon' => 'frmfont frm_email_icon',
827 816 );
828 817
829 - return apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
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 + ),
828 + );
829 + }
830 +
831 + $actions = apply_filters( 'frm_entry_actions_dropdown', $actions, compact( 'id', 'entry' ) );
832 +
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;
830 843 }
831 844
832 845 /**
833 846 * Gets data attributes for PDFs addon upgrade link.
@@ -869,16 +882,18 @@
869 882 );
870 883 $metas_without_a_field = (array) FrmEntryMeta::getAll( $query, ' ORDER BY it.created_at DESC', '', true );
871 884
872 885 foreach ( $metas_without_a_field as $meta ) {
873 - if ( ! empty( $meta->meta_value['captcha_score'] ) ) {
874 - echo '<div class="misc-pub-section">';
875 - FrmAppHelper::icon_by_class( 'frm_icon_font frm_shield_check_icon', array( 'aria-hidden' => 'true' ) );
876 - echo ' ' . esc_html__( 'reCAPTCHA Score', 'formidable' ) . ': ';
877 - echo '<b>' . esc_html( $meta->meta_value['captcha_score'] ) . '</b>';
878 - echo '</div>';
879 - return;
886 + if ( empty( $meta->meta_value['captcha_score'] ) ) {
887 + continue;
880 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;
881 896 }
882 897 }
883 898
884 899 /**
@@ -890,15 +905,13 @@
890 905 *
891 906 * @return int
892 907 */
893 908 public static function get_entry_status( $status ) {
894 - $statuses = self::get_entry_statuses();
895 -
896 - if ( array_key_exists( $status, $statuses ) ) {
909 + if ( array_key_exists( $status, self::get_entry_statuses() ) ) {
897 910 return $status;
898 911 }
899 912
900 - if ( empty( $status ) ) {
913 + if ( ! $status ) {
901 914 // If the status is empty, let's default to 0.
902 915 return self::SUBMITTED_ENTRY_STATUS;
903 916 }
904 917
@@ -915,11 +928,9 @@
915 928 *
916 929 * @return string
917 930 */
918 931 public static function get_entry_status_label( $status ) {
919 - $statuses = self::get_entry_statuses();
920 -
921 - return $statuses[ self::get_entry_status( $status ) ];
932 + return self::get_entry_statuses()[ self::get_entry_status( $status ) ];
922 933 }
923 934
924 935 /**
925 936 * Get all entry statuses.
@@ -929,9 +940,8 @@
929 940 *
930 941 * @return array<string>
931 942 */
932 943 public static function get_entry_statuses() {
933 -
934 944 $default_entry_statuses = array(
935 945 self::SUBMITTED_ENTRY_STATUS => __( 'Submitted', 'formidable' ),
936 946 self::DRAFT_ENTRY_STATUS => __( 'Draft', 'formidable' ),
937 947 );
@@ -952,11 +962,9 @@
952 962 _doing_it_wrong( __METHOD__, esc_html__( 'Entry status must be return in array format.', 'formidable' ), '6.5' );
953 963 $extended_entry_status = array();
954 964 }
955 965
956 - $existing_entry_statuses = array_replace( $default_entry_statuses, $extended_entry_status );
957 -
958 - return $existing_entry_statuses;
966 + return array_replace( $default_entry_statuses, $extended_entry_status );
959 967 }
960 968
961 969 /**
962 970 * @since 6.17
@@ -963,11 +971,9 @@
963 971 *
964 972 * @return int
965 973 */
966 974 public static function get_visible_unread_inbox_count() {
967 - $menu_name = FrmAppHelper::get_menu_name();
968 -
969 - if ( ! in_array( $menu_name, array( 'Formidable', 'Forms' ), true ) ) {
975 + if ( ! in_array( FrmAppHelper::get_menu_name(), array( 'Formidable', 'Forms' ), true ) ) {
970 976 return 0;
971 977 }
972 978
973 979 $inbox = new FrmInbox();