GravityView  1.19.4
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-forms_page_gf_entries', array( $this, 'add_edit_script') );
15 
16  }
17 
18  /**
19  * When clicking the edit link, convert the Entries form to go to the edit screen.
20  *
21  * Gravity Forms requires $_POST['screen_mode'] to be set to get to the "Edit" mode. This enables direct access to the edit mode.
22  *
23  * @hack
24  * @return void
25  */
26  public function add_edit_script() {
27 
28  // We're on a single entry page, or at least not the Entries page.
29  if( !empty( $_GET['view'] ) && $_GET['view'] !== 'entries' ) { return; }
30  ?>
31  <script>
32  jQuery( document ).ready( function( $ ) {
33  $('.edit_entry a').click(function(e) {
34  e.preventDefault();
35  $( e.target ).parents('form')
36  .prepend('<input name="screen_mode" type="hidden" value="edit" />')
37  .attr('action', $(e.target).attr('href') )
38  .submit();
39  });
40  });
41  </script>
42  <?php
43  }
44 
45  /**
46  * Add an Edit link to the GF Entry actions row
47  * @param int $form_id ID of the current form
48  * @param int $field_id The ID of the field in the first column, where the row actions are shown
49  * @param string $value The value of the `$field_id` field
50  * @param array $lead The current entry data
51  * @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`
52  */
53  function add_edit_link( $form_id = NULL, $field_id = NULL, $value = NULL, $lead = array(), $query_string = NULL ) {
54 
55  $params = array(
56  'page' => 'gf_entries',
57  'view' => 'entry',
58  'id' => (int)$form_id,
59  'lid' => (int)$lead["id"],
60  'screen_mode' => 'edit',
61  );
62  ?>
63 
64  <span class="edit edit_entry">
65  |
66  <a title="<?php esc_attr_e( 'Edit this entry', 'gravityview'); ?>" href="<?php echo esc_url( add_query_arg( $params, admin_url( 'admin.php?page='.$query_string ) ) ); ?>"><?php esc_html_e( 'Edit', 'gravityview' ); ?></a>
67  </span>
68  <?php
69  }
70 
71 }
72 
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:26
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:53
$field_id
Definition: time.php:17
if(empty($created_by)) $form_id
new GravityView_GF_Entries_List
Definition: entry-list.php:73