GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
field-notes-html.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The default notes 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 $entry = $gravityview->entry->as_entry();
15 $field_settings = $gravityview->field->as_configuration();
16 
17 if ( ! class_exists( 'GravityView_Entry_Notes' ) ) {
18  return;
19 }
20 
21 $visibility_settings = empty( $field_settings['notes'] ) ? array() : $field_settings['notes'];
22 $show_notes_logged_out = ( ! empty( $visibility_settings['view'] ) && ! empty( $visibility_settings['view_loggedout'] ) );
23 
24 if ( ! GVCommon::has_cap( array( 'gravityview_view_entry_notes', 'gravityview_add_entry_notes', 'gravityview_delete_entry_notes' ) ) && ! $show_notes_logged_out ) {
25  return;
26 }
27 
28 require_once( GFCommon::get_base_path() . '/entry_detail.php' );
29 
30 /**
31  * @action `gravityview/field/notes/scripts` Print scripts and styles required for the Notes field
32  * @see GravityView_Field_Notes::enqueue_scripts
33  * @since 1.17
34  * @since 2.0
35  * @param \GV\Template_Context $gravityview The context.
36  */
37 do_action( 'gravityview/field/notes/scripts', $gravityview );
38 
42 
43 $show_add = ! empty( $visibility_settings['add'] );
44 $show_delete = ( ! empty( $visibility_settings['delete'] ) && GVCommon::has_cap( 'gravityview_delete_entry_notes' ) );
45 $show_notes = $show_notes_logged_out || ( ! empty( $visibility_settings['view'] ) && GVCommon::has_cap( 'gravityview_view_entry_notes' ) );
46 
47 $container_class = ( sizeof( $notes ) > 0 ? 'gv-has-notes' : 'gv-no-notes' );
48 $container_class .= $show_notes ? ' gv-show-notes' : ' gv-hide-notes';
49 ?>
50 <div class="gv-notes <?php echo $container_class; ?>">
51 <?php
52  if ( $show_notes ) {
53 ?>
54  <form method="post" class="gv-notes-list">
55  <?php if ( $show_delete ) { wp_nonce_field( 'gv_delete_notes_' . $entry_slug, 'gv_delete_notes' ); } ?>
56  <div>
57  <input type="hidden" name="action" value="gv_delete_notes" />
58  <input type="hidden" name="entry-slug" value="<?php echo esc_attr( $entry_slug ); ?>" />
59  <table>
60  <caption><?php echo $strings['caption']; ?></caption>
61  <?php
62  if ( $show_delete ) {
63  ?>
64  <thead>
65  <tr>
66  <th colspan="2">
67  <label><input type="checkbox" value="" class="gv-notes-toggle" title="<?php echo $strings['toggle-notes']; ?>"><span class="screen-reader-text"><?php echo $strings['toggle-notes']; ?></span></label>
68  <button type="submit" class="button button-small gv-notes-delete"><?php echo $strings['delete']; ?></button>
69  </th>
70  </tr>
71  </thead>
72  <?php } ?>
73  <tbody>
74  <tr class="gv-notes-no-notes"><td colspan="2"><?php echo $strings['no-notes']; ?></td></tr>
75  <?php
76  foreach ( $notes as $note ) {
77  echo GravityView_Field_Notes::display_note( $note, $show_delete, $gravityview );
78  }
79  ?>
80  </tbody>
81  </table>
82  </div>
83  </form>
84 <?php
85  } // End if can view notes
86 
87  if ( $show_add ) {
88  echo GravityView_Field_Notes::get_add_note_part( array(), $gravityview );
89  }
90 ?>
91 </div>
$show_delete
$container_class
if(! isset( $gravityview)||empty( $gravityview->template)) $entry
The default notes field output template.
$field_settings
static get_notes( $entry_id)
Alias for GFFormsModel::get_lead_notes()
$show_notes
$entry_slug
$show_notes_logged_out
static display_note( $note, $show_delete=false, $context=null)
Generate HTML output for a single note.
if(! class_exists( 'GravityView_Entry_Notes')) $visibility_settings
static strings( $key='')
Get strings used by the Entry Notes field.
static get_entry_slug( $id_or_string, $entry=array())
Get the entry slug for the entry.
Definition: class-api.php:550
gravityview()
The main GravityView wrapper function.
static get_add_note_part( $atts, $context=null)
Get the Add Note form HTML.
static has_cap( $caps='', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()