From 1030f65037674c2aa306d15a48e7c71d18661d86 Mon Sep 17 00:00:00 2001 From: saurab018 Date: Thu, 21 May 2026 15:45:35 +0545 Subject: [PATCH] Fix: uploaded files not displayed in entries single view - Pass $meta_key as 5th arg to everest_forms_html_field_value filter in entry-single view template so the upload class receives it directly - Accept $field_meta_key as 5th parameter in html_field_value() and increase add_filter accepted_args from 4 to 5 - Use passed meta_key directly in entry-single context instead of fragile array_search() with strict comparison, which silently failed when esc_html() altered the URL string - Add missing continue after setting empty output to prevent string/array type conflict on subsequent loop iterations --- includes/abstracts/class-evf-form-fields-upload.php | 7 ++++--- includes/admin/views/html-admin-page-entries-view.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/includes/abstracts/class-evf-form-fields-upload.php b/includes/abstracts/class-evf-form-fields-upload.php index b589b2643..485d11446 100644 --- a/includes/abstracts/class-evf-form-fields-upload.php +++ b/includes/abstracts/class-evf-form-fields-upload.php @@ -35,7 +35,7 @@ abstract class EVF_Form_Fields_Upload extends EVF_Form_Fields { */ public function init_hooks() { add_action( 'everest_forms_shortcode_scripts', array( $this, 'load_assets' ) ); - add_filter( 'everest_forms_html_field_value', array( $this, 'html_field_value' ), 10, 4 ); + add_filter( 'everest_forms_html_field_value', array( $this, 'html_field_value' ), 10, 5 ); add_filter( 'everest_forms_plaintext_field_value', array( $this, 'plaintext_field_value' ), 10, 4 ); add_filter( 'everest_forms_field_exporter_' . $this->type, array( $this, 'field_exporter' ) ); add_filter( 'everest_forms_email_file_attachments', array( $this, 'send_file_as_email_attachment' ), 99, 6 ); @@ -777,7 +777,7 @@ public function media_library( $field ) { * @param string $context Value display context. * @return string $val Html Value. */ - public function html_field_value( $val, $field_val, $form_data = array(), $context = '' ) { + public function html_field_value( $val, $field_val, $form_data = array(), $context = '', $field_meta_key = '' ) { $meta_key = ''; $entry_id = false; $uploads = wp_upload_dir(); @@ -843,7 +843,7 @@ public function html_field_value( $val, $field_val, $form_data = array(), $conte if ( isset( $_GET['view-entry'] ) && 'entry-single' === $context ) { // phpcs:ignore WordPress.Security.NonceVerification $entry_id = absint( $_GET['view-entry'] ); // phpcs:ignore WordPress.Security.NonceVerification - $meta_key = array_search( $val, $form_data, true ); + $meta_key = ! empty( $field_meta_key ) ? evf_clean( $field_meta_key ) : array_search( $val, $form_data, true ); } elseif ( isset( $_GET['edit-entry'], $field_val['meta_key'] ) && 'entry-single' === $context ) { // phpcs:ignore WordPress.Security.NonceVerification $entry_id = absint( $_GET['edit-entry'] ); // phpcs:ignore WordPress.Security.NonceVerification $meta_key = evf_clean( $field_val['meta_key'] ); @@ -873,6 +873,7 @@ public function html_field_value( $val, $field_val, $form_data = array(), $conte foreach ( $field['value_raw'] as $file ) { if ( empty( $file['value'] ) || empty( $file['file_original'] ) ) { $output[ $meta_key ] = ''; + continue; } $file_url = esc_url( $file['value'] ); diff --git a/includes/admin/views/html-admin-page-entries-view.php b/includes/admin/views/html-admin-page-entries-view.php index 5f92cfd6b..e6e2eb0dd 100644 --- a/includes/admin/views/html-admin-page-entries-view.php +++ b/includes/admin/views/html-admin-page-entries-view.php @@ -162,7 +162,7 @@ class="evf-toggle-empty everest-forms-empty-field-toggle password_preview dashic $meta_value = $meta_value['value']; } - $field_value = apply_filters( 'everest_forms_html_field_value', $meta_value, $entry_meta[ $meta_key ], $entry_meta, 'entry-single' ); + $field_value = apply_filters( 'everest_forms_html_field_value', $meta_value, $entry_meta[ $meta_key ], $entry_meta, 'entry-single', $meta_key ); $is_empty = is_string( $field_value ) && ( '(empty)' === wp_strip_all_tags( $field_value ) || '' === $field_value ); $field_class = $is_empty ? 'evf-field-empty' : ''; $correct_answers = false;