GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
entry-list.php
Go to the documentation of this file.
1 <?php
2 
3 /**
4  * Actions to be performed on the Gravity Forms Entries list screen
5  */
7 
8  function __construct() {
9 
10  // Add Edit link to the entry actions
11  add_action( 'gform_entries_first_column_actions', array( $this, 'add_edit_link' ), 10, 5 );
12 
13  // Add script to enable edit link
14  add_action( 'admin_head', array( $this, 'add_edit_script') );
15  }
16 
17  /**
18  * When clicking the edit link, convert the Entries form to go to the edit screen.
19  *
20  * Gravity Forms requires $_POST['screen_mode'] to be set to get to the "Edit" mode. This enables direct access to the edit mode.
21  *
22  * @hack
23  * @return void
24  */
25  public function add_edit_script() {
26 
27  if ( ! class_exists( 'GFForms' ) ) {
28  return;
29  }
30 
31  if ( ! in_array( GFForms::get_page(), array( 'entry_list', 'entry_detail' ) ) ) {
32  return;
33  }
34  ?>
35  <script>
36  jQuery( document ).ready( function( $ ) {
37  $('.edit_entry a').click(function(e) {
38  e.preventDefault();
39  $( e.target ).parents('form')
40  .prepend('<input name="screen_mode" type="hidden" value="edit" />')
41  .attr('action', $(e.target).attr('href') )
42  .submit();
43  });
44  });
45  </script>
46  <?php
47  }
48 
49  /**
50  * Add an Edit link to the GF Entry actions row
51  * @param int $form_id ID of the current form
52  * @param int $field_id The ID of the field in the first column, where the row actions are shown
53  * @param string $value The value of the `$field_id` field
54  * @param array $lead The current entry data
55  * @param string $query_string URL query string for a link to the current entry. Missing the `?page=` part, which is strange. Example: `gf_entries&view=entry&id=35&lid=5212&filter=&paged=1`
56  */
57  function add_edit_link( $form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL ) {
58 
59  $params = array(
60  'page' => 'gf_entries',
61  'view' => 'entry',
62  'id' => (int)$form_id,
63  'lid' => (int)$lead["id"],
64  'screen_mode' => 'edit',
65  );
66  ?>
67 
68  <span class="edit edit_entry">
69  |
70  <a title="<?php esc_attr_e( 'Edit this entry', 'gk-gravityview'); ?>" href="<?php echo esc_url( add_query_arg( $params, admin_url( 'admin.php?page='.$query_string ) ) ); ?>"><?php esc_html_e( 'Edit', 'gk-gravityview' ); ?></a>
71  </span>
72  <?php
73  }
74 
75 }
76 
Actions to be performed on the Gravity Forms Entries list screen.
Definition: entry-list.php:6
add_edit_script()
When clicking the edit link, convert the Entries form to go to the edit screen.
Definition: entry-list.php:25
if(empty( $created_by)) $form_id
add_edit_link( $form_id=NULL, $field_id=NULL, $value=NULL, $lead=array(), $query_string=NULL)
Add an Edit link to the GF Entry actions row.
Definition: entry-list.php:57
if(false !==strpos( $value, '00:00')) $field_id
string $field_id ID of the field being displayed
Definition: time.php:22
new GravityView_GF_Entries_List
Definition: entry-list.php:77