Skip to content

Commit bddad13

Browse files
committed
gw-display-html-field-on-entry-detail.php: Added a snippet to display HTML field content on Entry Details page.
1 parent 50ff4df commit bddad13

File tree

1 file changed

+5
-28
lines changed

1 file changed

+5
-28
lines changed

gravity-forms/gw-display-html-field-on-entry-detail.php

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@
22
/**
33
* Gravity Wiz // Gravity Forms // Display HTML Field on Entry Details
44
*
5-
* Instruction Video: https://www.loom.com/share/fa4b49240b6447c7839392af69476bf2
6-
*
7-
* Save and display HTML field content (including Live Merge Tags and shortcodes) in the entry detail view.
8-
* Useful for retaining dynamic HTML field output as it appeared when the entry was submitted.
5+
* Displays dynamically rendered HTML field content (with merge tags and shortcodes) on the entry detail and entry list view.
96
*
107
* Plugin Name: Display HTML Field on Entry Details
118
* Plugin URI: http://gravitywiz.com/
12-
* Description: Save and display HTML field content (including Live Merge Tags and shortcodes) in the entry detail view.
9+
* Description: Display HTML field content (with Live Merge Tags and shortcodes) dynamically in the entry detail view.
1310
* Author: Gravity Wiz
1411
* Version: 0.1
1512
* Author URI: http://gravitywiz.com
@@ -31,7 +28,6 @@ public function __construct( $args = array() ) {
3128
}
3229

3330
public function init() {
34-
add_filter( 'gform_entry_post_save', array( $this, 'save_html_field_content' ), 10, 1 );
3531
add_action( 'gform_entry_detail', array( $this, 'display_html_field_content_entry_detail' ), 10, 2 );
3632
add_filter( 'gform_get_input_value', array( $this, 'display_html_field_content_entry_list' ), 10, 4 );
3733
}
@@ -47,7 +43,7 @@ private function is_applicable_field( $field ) {
4743
}
4844

4945
private function process_html_content( $content, $form, $entry ) {
50-
// Process Live Merge Tags.
46+
// Process Live Merge Tags if available.
5147
if (
5248
method_exists( 'GP_Populate_Anything_Live_Merge_Tags', 'has_live_merge_tag' ) &&
5349
GP_Populate_Anything_Live_Merge_Tags::get_instance()->has_live_merge_tag( $content )
@@ -62,31 +58,14 @@ private function process_html_content( $content, $form, $entry ) {
6258
return ! empty( $content ) ? wp_kses_post( $content ) : '';
6359
}
6460

65-
public function save_html_field_content( $entry ) {
66-
$form = GFAPI::get_form( rgar( $entry, 'form_id' ) );
67-
68-
if ( ! $this->is_applicable_form( $form ) ) {
69-
return $entry;
70-
}
71-
72-
foreach ( $form['fields'] as $field ) {
73-
if ( $this->is_applicable_field( $field ) ) {
74-
gform_update_meta( $entry['id'], 'html_field_' . $field->id, $field->content );
75-
}
76-
}
77-
78-
return $entry;
79-
}
80-
8161
public function display_html_field_content_entry_detail( $form, $entry ) {
8262
if ( ! $this->is_applicable_form( $form ) ) {
8363
return;
8464
}
8565

8666
foreach ( $form['fields'] as $field ) {
8767
if ( $this->is_applicable_field( $field ) ) {
88-
$content = gform_get_meta( $entry['id'], 'html_field_' . $field->id );
89-
$content = $this->process_html_content( $content, $form, $entry );
68+
$content = $this->process_html_content( $field->content, $form, $entry );
9069

9170
if ( $content ) {
9271
printf(
@@ -112,9 +91,7 @@ public function display_html_field_content_entry_list( $value, $entry, $field, $
11291
}
11392

11493
$is_running = true;
115-
$entry = GFAPI::get_entry( $entry['id'] );
116-
$content = gform_get_meta( $entry['id'], 'html_field_' . $field->id );
117-
$content = $this->process_html_content( $content, $form, $entry );
94+
$content = $this->process_html_content( $field->content, $form, $entry );
11895
$is_running = false;
11996

12097
return $content ?: $value;

0 commit comments

Comments
 (0)