GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-post_content-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default post_content field output template.
4  *
5  * @global \GV\Template_Context $gravityview
6  * @since 2.0
7  */
8 
9 if ( ! isset( $gravityview ) || empty( $gravityview->template ) ) {
10  gravityview()->log->error( '{file} template loaded without context', array( 'file' => __FILE__ ) );
11  return;
12 }
13 
14 $display_value = $gravityview->display_value;
15 $entry = $gravityview->entry->as_entry();
16 $field_settings = $gravityview->field->as_configuration();
17 
18 if ( ! empty( $field_settings['dynamic_data'] ) && ! empty( $entry['post_id'] ) ) {
19 
20  global $post, $wp_query;
21 
22  /** Backup! */
23  $_the_post = $post;
24 
25  $post = get_post( $entry['post_id'] );
26 
27  if ( empty( $post ) ) {
28  do_action( 'gravityview_log_debug', 'Dynamic data for post #' . $entry['post_id'] . ' doesnt exist.' );
29  $post = $_the_post;
30  return;
31  }
32 
33  setup_postdata( $post );
34  $_in_the_loop = $wp_query->in_the_loop;
35  $wp_query->in_the_loop = false;
36  the_content(); /** Prevent the old the_content filter from running. @todo Remove this hack along with the old filter. */
37  $wp_query->in_the_loop = $_in_the_loop;
38  wp_reset_postdata();
39 
40  /** Restore! */
41  $post = $_the_post;
42 
43 } else {
44  echo $display_value;
45 }
global $post
Definition: delete-entry.php:7
$entry
$field_settings
gravityview()
The main GravityView wrapper function.
if(! isset( $gravityview)||empty( $gravityview->template)) $display_value
The default post_content field output template.