html-admin-header-skeleton.php
1 month ago
html-admin-page-addons.php
1 year ago
html-admin-page-builder.php
4 months ago
html-admin-page-dashboard.php
2 years ago
html-admin-page-entries-view.php
1 month ago
html-admin-page-export.php
1 year ago
html-admin-page-form-migrator.php
2 years ago
html-admin-page-form-templates.php
4 months ago
html-admin-page-import.php
1 year ago
html-admin-page-payments.php
1 month ago
html-admin-page-setting.php
2 years ago
html-admin-page-smart-smtp-setup.php
1 month ago
html-admin-page-tools-logs.php
2 months ago
html-admin-page-tools.php
3 months ago
html-admin-settings.php
1 month ago
html-deactivation-popup.php
3 years ago
html-notice-allow-usage.php
3 months ago
html-notice-custom.php
3 months ago
html-notice-email-failed-notice.php
3 months ago
html-notice-php-deprecation.php
3 months ago
html-notice-review.php
3 months ago
html-notice-survey.php
3 months ago
html-notice-update.php
3 months ago
html-notice-updated.php
3 months ago
html-notice-updating.php
3 months ago
html-admin-page-entries-view.php
388 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Admin View: Entries |
| 4 | * |
| 5 | * @package EverestForms/Admin/Entries/Views |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | $form_id = isset( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification |
| 11 | $entry_id = isset( $_GET['view-entry'] ) ? absint( $_GET['view-entry'] ) : 0; // phpcs:ignore WordPress.Security.NonceVerification |
| 12 | $entry = evf_get_entry( $entry_id, true ); |
| 13 | $entry_fields = json_decode( $entry->fields ); |
| 14 | $form_data = evf()->form->get( $form_id, array( 'content_only' => true ) ); |
| 15 | $hide_empty = isset( $_COOKIE['everest_forms_entry_hide_empty'] ) && 'true' === $_COOKIE['everest_forms_entry_hide_empty']; |
| 16 | |
| 17 | $form_entries = evf_get_entries_by_form_id( $form_id, '', '', true ); |
| 18 | $form_entries = array_map( |
| 19 | function ( $el ) { |
| 20 | return $el['entry_id']; |
| 21 | }, |
| 22 | $form_entries |
| 23 | ); |
| 24 | |
| 25 | $entry_index = array_search( $entry_id, $form_entries ); // phpcs:ignore WordPress.PHP.StrictInArray |
| 26 | $prev_entry = ''; |
| 27 | $next_entry = ''; |
| 28 | $prev_entry_url = '#'; |
| 29 | $next_entry_url = '#'; |
| 30 | |
| 31 | if ( false !== $entry_index ) { |
| 32 | if ( isset( $form_entries[ $entry_index - 1 ] ) ) { |
| 33 | $prev_entry = $form_entries[ $entry_index - 1 ]; |
| 34 | $prev_entry_url = admin_url( sprintf( 'admin.php?page=evf-entries&form_id=%d&view-entry=%d', $form_id, $prev_entry ) ); |
| 35 | } |
| 36 | |
| 37 | if ( isset( $form_entries[ $entry_index + 1 ] ) ) { |
| 38 | $next_entry = $form_entries[ $entry_index + 1 ]; |
| 39 | $next_entry_url = admin_url( sprintf( 'admin.php?page=evf-entries&form_id=%d&view-entry=%d', $form_id, $next_entry ) ); |
| 40 | } |
| 41 | |
| 42 | $next_entry = isset( $form_entries[ $entry_index + 1 ] ) ? $form_entries[ $entry_index + 1 ] : ''; |
| 43 | } |
| 44 | |
| 45 | ?> |
| 46 | <div class="wrap everest-forms evf-entry-view-wrapper"> |
| 47 | <!-- Header Section --> |
| 48 | <div class="evf-entry-header"> |
| 49 | <div class="evf-entry-header-left"> |
| 50 | <a href="<?php echo esc_url( admin_url( 'admin.php?page=evf-entries&form_id=' . $form_id ) ); ?>" class="evf-back-link"> |
| 51 | <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 22 22"><path d="M10.352 3.935a.917.917 0 0 1 1.296 1.297l-5.769 5.767 5.769 5.77a.916.916 0 1 1-1.296 1.296l-6.417-6.417a.917.917 0 0 1 0-1.296z"/><path d="M17.416 10.083a.917.917 0 0 1 0 1.834H4.583a.917.917 0 0 1 0-1.834z"/></svg> |
| 52 | </a> |
| 53 | <span class="evf-entry-title"> |
| 54 | <?php |
| 55 | printf( esc_html__( '%1$s: Entry #%2$s', 'everest-forms' ), esc_html( _draft_or_post_title( $form_id ) ), absint( $entry_id ) ); |
| 56 | ?> |
| 57 | </span> |
| 58 | </div> |
| 59 | <div class="evf-entry-header-right"> |
| 60 | <a class="evf-nav-btn evf-prev-btn" href="<?php echo esc_url( $prev_entry_url ); ?>" <?php echo empty( $prev_entry ) ? 'disabled' : ''; ?>> |
| 61 | <span class="dashicons dashicons-arrow-left-alt2"></span> |
| 62 | <?php esc_html_e( 'Previous', 'everest-forms' ); ?> |
| 63 | </a> |
| 64 | <a class="evf-nav-btn evf-next-btn" href="<?php echo esc_url( $next_entry_url ); ?>" <?php echo empty( $next_entry ) ? 'disabled' : ''; ?>> |
| 65 | <?php esc_html_e( 'Next', 'everest-forms' ); ?> |
| 66 | <span class="dashicons dashicons-arrow-right-alt2"></span> |
| 67 | </a> |
| 68 | </div> |
| 69 | </div> |
| 70 | |
| 71 | <?php do_action( 'everest_forms_view_entries_notices' ); ?> |
| 72 | |
| 73 | <!-- Main Content Wrapper --> |
| 74 | <div class="evf-entry-content-wrapper"> |
| 75 | <!-- Left Column: Entry Fields and Details --> |
| 76 | <div class="evf-entry-main-content"> |
| 77 | <!-- Personal Information Section --> |
| 78 | <div id="everest-forms-entry-fields" class="evf-entry-section evf-personal-info stuffbox"> |
| 79 | <div class="evf-section-header"> |
| 80 | <div class="evf-section-title hndle"> |
| 81 | <?php do_action( 'everest_forms_before_entry_details_hndle', $entry ); ?> |
| 82 | <span><?php esc_html_e( 'Personal Information', 'everest-forms' ); ?></span> |
| 83 | <?php do_action( 'everest_forms_after_entry_details_hndle', $entry ); ?> |
| 84 | </div> |
| 85 | <div class="evf-section-header-actions"> |
| 86 | <a href="#" |
| 87 | class="evf-toggle-empty everest-forms-empty-field-toggle password_preview dashicons <?php echo $hide_empty ? 'dashicons-hidden' : 'dashicons-visibility'; ?>" |
| 88 | title="<?php echo $hide_empty ? esc_attr__( 'Show empty fields', 'everest-forms' ) : esc_attr__( 'Hide empty fields', 'everest-forms' ); ?>"> |
| 89 | <?php |
| 90 | echo $hide_empty |
| 91 | ? esc_html__( 'Show Empty Fields', 'everest-forms' ) |
| 92 | : esc_html__( 'Hide Empty Fields', 'everest-forms' ); |
| 93 | ?> |
| 94 | </a> |
| 95 | <?php if ( current_user_can( 'everest_forms_edit_entry', $entry->entry_id ) ) : ?> |
| 96 | <?php do_action( 'everest_forms_entry_details_sidebar_action', $entry, $form_data ); ?> |
| 97 | <?php endif; ?> |
| 98 | </div> |
| 99 | </div> |
| 100 | |
| 101 | <div class="evf-section-content inside"> |
| 102 | <?php |
| 103 | $entry_meta = apply_filters( 'everest_forms_entry_single_data', $entry->meta, $entry, $form_data ); |
| 104 | |
| 105 | $field_type_by_meta_key = array(); |
| 106 | $exclude_fields_array = array( 'captcha', 'recaptcha', 'hcaptcha', 'turnstile', 'private-note', 'authorize-net' ); |
| 107 | $exclude_fields_array = apply_filters( 'everest_forms_view_entry_exclude_fields', $exclude_fields_array, $entry_meta, $form_data ); |
| 108 | |
| 109 | foreach ( $form_data['form_fields'] as $field ) { |
| 110 | if ( isset( $field['meta-key'] ) ) { |
| 111 | $field_type_by_meta_key[ $field['meta-key'] ] = $field['type']; |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | if ( empty( $entry_meta ) ) { |
| 116 | echo '<p class="evf-no-fields">' . esc_html__( 'This entry does not have any fields.', 'everest-forms' ) . '</p>'; |
| 117 | } else { |
| 118 | foreach ( $entry_meta as $meta_key => $meta_value ) { |
| 119 | if ( in_array( $meta_key, array_keys( $field_type_by_meta_key ), true ) && in_array( $field_type_by_meta_key[ $meta_key ], $exclude_fields_array, true ) ) { |
| 120 | continue; |
| 121 | } |
| 122 | |
| 123 | if ( in_array( $meta_key, apply_filters( 'everest_forms_hidden_entry_fields', array() ), true ) ) { |
| 124 | continue; |
| 125 | } |
| 126 | |
| 127 | // Escape plain text values; leave serialized data untouched for further processing. |
| 128 | $meta_value = is_serialized( $meta_value ) ? $meta_value : esc_html( $meta_value ); |
| 129 | |
| 130 | if ( is_serialized( $meta_value ) ) { |
| 131 | $raw_meta_val = evf_maybe_unserialize( $meta_value ); |
| 132 | |
| 133 | $field_type_array = apply_filters( |
| 134 | 'everest_forms_serialized_value_field_type', |
| 135 | array( |
| 136 | 'payment-checkbox', |
| 137 | 'checkbox', |
| 138 | 'radio', |
| 139 | 'payment-multiple', |
| 140 | ) |
| 141 | ); |
| 142 | |
| 143 | if ( ! empty( $raw_meta_val['type'] ) && in_array( $raw_meta_val['type'], $field_type_array, true ) && empty( $raw_meta_val['label'][0] ) ) { |
| 144 | $meta_value = ''; |
| 145 | } else { |
| 146 | $is_dropdown = false; |
| 147 | foreach ( $entry_fields as $field ) { |
| 148 | if ( $meta_key === $field->meta_key && 'select' === $field->type ) { |
| 149 | $is_dropdown = true; |
| 150 | break; |
| 151 | } |
| 152 | } |
| 153 | |
| 154 | if ( $is_dropdown && empty( $raw_meta_val[0] ) ) { |
| 155 | $meta_value = ''; |
| 156 | } |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | if ( evf_is_json( $meta_value ) ) { |
| 161 | $meta_value = json_decode( $meta_value, true ); |
| 162 | $meta_value = $meta_value['value']; |
| 163 | } |
| 164 | |
| 165 | $field_value = apply_filters( 'everest_forms_html_field_value', $meta_value, $entry_meta[ $meta_key ], $entry_meta, 'entry-single', $meta_key ); |
| 166 | $is_empty = is_string( $field_value ) && ( '(empty)' === wp_strip_all_tags( $field_value ) || '' === $field_value ); |
| 167 | $field_class = $is_empty ? 'evf-field-empty' : ''; |
| 168 | $correct_answers = false; |
| 169 | |
| 170 | $field_label = evf_get_form_data_by_meta_key( $form_id, $meta_key, $entry_fields ); |
| 171 | if ( ! $field_label ) { |
| 172 | $field_label = esc_html__( 'Field ID', 'everest-forms' ); |
| 173 | } |
| 174 | |
| 175 | if ( apply_filters( 'everest_forms_html_field_label', false ) ) { |
| 176 | $correct_answers = apply_filters( 'everest_forms_single_entry_label', $field_label, $meta_key, $field_value ); |
| 177 | } |
| 178 | |
| 179 | echo '<div class="evf-field-row everest-forms-entry-field ' . esc_attr( $field_class ) . '">'; |
| 180 | echo '<div class="evf-field-label field-name"><strong>' . esc_html( $field_label ) . '</strong></div>'; |
| 181 | echo '<div class="evf-field-value field-value">'; |
| 182 | |
| 183 | if ( ! empty( $field_value ) || is_numeric( $field_value ) ) { |
| 184 | if ( is_serialized( $field_value ) ) { |
| 185 | $field_value = evf_maybe_unserialize( $field_value ); |
| 186 | $field_label_val = isset( $field_value['label'] ) ? $field_value['label'] : $field_value; |
| 187 | |
| 188 | if ( ! empty( $field_label_val ) && is_array( $field_label_val ) ) { |
| 189 | foreach ( $field_label_val as $field => $value ) { |
| 190 | $answer_class = ''; |
| 191 | if ( $correct_answers ) { |
| 192 | if ( in_array( $value, $correct_answers, true ) ) { |
| 193 | $answer_class = 'correct_answer'; |
| 194 | } else { |
| 195 | $answer_class = 'wrong_answer'; |
| 196 | } |
| 197 | } |
| 198 | echo '<span class="list evf-answer-badge ' . esc_attr( $answer_class ) . '">' . esc_html( wp_strip_all_tags( $value ) ) . '</span>'; |
| 199 | } |
| 200 | } else { |
| 201 | // Output serialized non-array label value safely. |
| 202 | echo nl2br( esc_html( $field_label_val ) ); |
| 203 | } |
| 204 | } elseif ( $correct_answers && false !== $correct_answers ) { |
| 205 | if ( in_array( $field_value, $correct_answers, true ) ) { |
| 206 | $answer_class = 'correct_answer'; |
| 207 | } else { |
| 208 | $answer_class = 'wrong_answer'; |
| 209 | } |
| 210 | echo '<span class="list evf-answer-badge ' . esc_attr( $answer_class ) . '">' . esc_html( wp_strip_all_tags( $field_value ) ) . '</span>'; |
| 211 | } else { |
| 212 | $allow_html_types = apply_filters( |
| 213 | 'everest_forms_entry_view_field_types_allowing_html', |
| 214 | array( 'wysiwyg', 'repeater-fields' ), |
| 215 | $meta_key, |
| 216 | $form_data |
| 217 | ); |
| 218 | $meta_field_type = isset( $field_type_by_meta_key[ $meta_key ] ) ? $field_type_by_meta_key[ $meta_key ] : ''; |
| 219 | if ( is_string( $field_value ) && in_array( $meta_field_type, $allow_html_types, true ) ) { |
| 220 | echo wp_kses_post( $field_value ); |
| 221 | } elseif ( in_array( $meta_field_type, array( 'file-upload', 'image-upload', 'signature', 'color', 'rating', 'country', 'likert', 'checkbox', 'radio', 'payment-checkbox' ), true ) ) { |
| 222 | echo nl2br( make_clickable( $field_value ) ); |
| 223 | } else { |
| 224 | // Output plain field value safely. |
| 225 | echo nl2br( esc_html( $field_value ) ); |
| 226 | } |
| 227 | } |
| 228 | } else { |
| 229 | echo '<span class="evf-empty-value">' . esc_html__( 'Empty', 'everest-forms' ) . '</span>'; |
| 230 | } |
| 231 | |
| 232 | echo '</div>'; |
| 233 | echo '</div>'; |
| 234 | } |
| 235 | } |
| 236 | ?> |
| 237 | </div> |
| 238 | </div> |
| 239 | |
| 240 | <?php do_action( 'everest_forms_entry_details_content', $entry, $form_id ); ?> |
| 241 | |
| 242 | <!-- Entry Details Section --> |
| 243 | <div id="everest-forms-entry-details-table" class="evf-entry-section evf-entry-details-section stuffbox"> |
| 244 | <div class="evf-section-header"> |
| 245 | <div class="evf-section-title hndle"><span><?php esc_html_e( 'Entry Details', 'everest-forms' ); ?></span></div> |
| 246 | </div> |
| 247 | |
| 248 | <div class="evf-section-content inside"> |
| 249 | <div class="evf-details-table-wrapper"> |
| 250 | <table class="evf-details-table wp-list-table widefat fixed striped"> |
| 251 | <thead> |
| 252 | <tr> |
| 253 | <th><?php esc_html_e( 'ID', 'everest-forms' ); ?></th> |
| 254 | <th><?php esc_html_e( 'User', 'everest-forms' ); ?></th> |
| 255 | <th><?php esc_html_e( 'IP', 'everest-forms' ); ?></th> |
| 256 | <th><?php esc_html_e( 'Status', 'everest-forms' ); ?></th> |
| 257 | <th><?php esc_html_e( 'Submitted Date', 'everest-forms' ); ?></th> |
| 258 | <?php if ( ! empty( $entry->date_modified ) ) : ?> |
| 259 | <th><?php esc_html_e( 'Modified Date', 'everest-forms' ); ?></th> |
| 260 | <?php endif; ?> |
| 261 | <th><?php esc_html_e( 'Referer Link', 'everest-forms' ); ?></th> |
| 262 | </tr> |
| 263 | </thead> |
| 264 | <tbody> |
| 265 | <tr> |
| 266 | <td><?php echo absint( $entry_id ); ?></td> |
| 267 | <td> |
| 268 | <?php |
| 269 | if ( ! empty( $entry->user_id ) && 0 !== $entry->user_id ) { |
| 270 | $user = get_userdata( $entry->user_id ); |
| 271 | $user_name = ! empty( $user->display_name ) ? $user->display_name : $user->user_login; |
| 272 | $user_url = add_query_arg( |
| 273 | array( |
| 274 | 'user_id' => absint( $user->ID ), |
| 275 | ), |
| 276 | admin_url( 'user-edit.php' ) |
| 277 | ); |
| 278 | echo '<a href="' . esc_url( $user_url ) . '">' . esc_html( $user_name ) . '</a>'; |
| 279 | } else { |
| 280 | esc_html_e( 'Guest', 'everest-forms' ); |
| 281 | } |
| 282 | ?> |
| 283 | </td> |
| 284 | <td><?php echo ! empty( $entry->user_ip_address ) ? esc_html( $entry->user_ip_address ) : '-'; ?></td> |
| 285 | <td> |
| 286 | <?php |
| 287 | $status = ! empty( $entry->status ) ? sanitize_text_field( $entry->status ) : 'completed'; |
| 288 | $status_class = 'evf-status-' . strtolower( $status ); |
| 289 | ?> |
| 290 | <span class="evf-status-badge <?php echo esc_attr( $status_class ); ?>"> |
| 291 | <?php echo esc_html( ucwords( $status ) ); ?> |
| 292 | </span> |
| 293 | </td> |
| 294 | <td><?php echo esc_html( date_i18n( 'Y-m-d H:i:s', strtotime( $entry->date_created ) + ( get_option( 'gmt_offset' ) * 3600 ) ) ); ?></td> |
| 295 | <?php if ( ! empty( $entry->date_modified ) ) : ?> |
| 296 | <td><?php echo esc_html( date_i18n( 'Y-m-d H:i:s', strtotime( $entry->date_modified ) + ( get_option( 'gmt_offset' ) * 3600 ) ) ); ?></td> |
| 297 | <?php endif; ?> |
| 298 | <td> |
| 299 | <?php if ( ! empty( $entry->referer ) ) : ?> |
| 300 | <a href="<?php echo esc_url( $entry->referer ); ?>" target="_blank" class="evf-referer-link"> |
| 301 | <?php esc_html_e( 'View', 'everest-forms' ); ?> |
| 302 | </a> |
| 303 | <?php else : ?> |
| 304 | - |
| 305 | <?php endif; ?> |
| 306 | </td> |
| 307 | </tr> |
| 308 | </tbody> |
| 309 | </table> |
| 310 | </div> |
| 311 | |
| 312 | <?php do_action( 'everest_forms_entry_details_sidebar_details', $entry, $entry_meta, $form_data ); ?> |
| 313 | </div> |
| 314 | </div> |
| 315 | </div> |
| 316 | |
| 317 | <!-- Right Sidebar --> |
| 318 | <div class="evf-entry-sidebar"> |
| 319 | <div id="everest-forms-entry-actions" class="stuffbox"> |
| 320 | <div class="evf-entry-actions-header"><?php esc_html_e( 'Entry Actions', 'everest-forms' ); ?></div> |
| 321 | <div class="inside"> |
| 322 | <div class="everest-forms-entry-actions-meta"> |
| 323 | <?php do_action( 'everest_forms_entry_details_sidebar_actions', $entry, $form_data ); ?> |
| 324 | |
| 325 | <?php if ( current_user_can( 'everest_forms_delete_entry', $entry->entry_id ) ) : ?> |
| 326 | <?php |
| 327 | $trash_link = wp_nonce_url( |
| 328 | add_query_arg( |
| 329 | array( |
| 330 | 'trash' => $entry_id, |
| 331 | ), |
| 332 | admin_url( 'admin.php?page=evf-entries&form_id=' . $form_id ) |
| 333 | ), |
| 334 | 'trash-entry' |
| 335 | ); |
| 336 | ?> |
| 337 | <p class="everest-forms-entry-delete"> |
| 338 | <a href="<?php echo esc_url( $trash_link ); ?>"> |
| 339 | <span class="dashicons dashicons-trash"></span> |
| 340 | <?php esc_html_e( 'Delete Entry', 'everest-forms' ); ?> |
| 341 | </a> |
| 342 | </p> |
| 343 | <?php endif; ?> |
| 344 | </div> |
| 345 | </div> |
| 346 | </div> |
| 347 | |
| 348 | <?php do_action( 'everest_forms_after_entry_details', $entry, $entry_meta, $form_data ); ?> |
| 349 | </div> |
| 350 | </div> |
| 351 | </div> |
| 352 | |
| 353 | <script type="text/javascript"> |
| 354 | jQuery(document).on('click', '.everest-forms-empty-field-toggle', function (event) { |
| 355 | event.preventDefault(); |
| 356 | |
| 357 | var $btn = jQuery(this); |
| 358 | |
| 359 | if (wpCookies.get('everest_forms_entry_hide_empty') === 'true') { |
| 360 | wpCookies.remove('everest_forms_entry_hide_empty'); |
| 361 | |
| 362 | $btn |
| 363 | .removeClass('dashicons-hidden') |
| 364 | .addClass('dashicons-visibility') |
| 365 | .attr('title', '<?php esc_attr_e( 'Hide empty fields', 'everest-forms' ); ?>') |
| 366 | .text('<?php esc_html_e( 'Hide Empty Fields', 'everest-forms' ); ?>'); |
| 367 | |
| 368 | jQuery('.evf-field-empty').show(); |
| 369 | } else { |
| 370 | wpCookies.set('everest_forms_entry_hide_empty', 'true', 2592000); |
| 371 | |
| 372 | $btn |
| 373 | .removeClass('dashicons-visibility') |
| 374 | .addClass('dashicons-hidden') |
| 375 | .attr('title', '<?php esc_attr_e( 'Show empty fields', 'everest-forms' ); ?>') |
| 376 | .text('<?php esc_html_e( 'Show Empty Fields', 'everest-forms' ); ?>'); |
| 377 | |
| 378 | jQuery('.evf-field-empty').hide(); |
| 379 | } |
| 380 | }); |
| 381 | |
| 382 | jQuery(document).ready(function($) { |
| 383 | if (wpCookies.get('everest_forms_entry_hide_empty') === 'true') { |
| 384 | $('.evf-field-empty').hide(); |
| 385 | } |
| 386 | }); |
| 387 | </script> |
| 388 |