GravityView  2.17
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-plugin-hooks-gravityformspartialentries.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Add Gravity Forms Partial Entries customizations
4  *
5  * @file class-gravityview-plugin-hooks-gravityformspartialentries.php
6  * @package GravityView
7  * @license GPL2
8  * @author GravityView <[email protected]>
9  * @link https://gravityview.co
10  * @copyright Copyright 2016, Katz Web Services, Inc.
11  *
12  * @since 1.17
13  */
14 
15 /**
16  * @inheritDoc
17  * @since 2.8
18  */
20 
21  /**
22  * @inheritDoc
23  * @since 2.8
24  */
25  protected $constant_name = 'GF_PARTIAL_ENTRIES_VERSION';
26 
27  /**
28  * @since 2.8
29  */
30  protected function add_hooks() {
31 
32  // Don't show "Please note that your information is saved on our server as you enter it." message.
33  add_action( 'gravityview/edit-entry/render/before', function() {
34  add_filter( 'gform_partialentries_warning_message', '__return_empty_string' );
35  } );
36 
37  add_action( 'gravityview/edit-entry/render/after', function() {
38  remove_filter( 'gform_partialentries_warning_message', '__return_empty_string' );
39  } );
40 
41  add_action( 'gravityview/edit_entry/after_update', array( $this, 'maybe_save_partial_entry' ), 10, 3 );
42 
43  parent::add_hooks();
44  }
45 
46  /**
47  * Update the Partial Entries progress after an entry is updated in Edit Entry
48  *
49  * @since 2.8
50  *
51  * @param array $form Gravity Forms form array
52  * @param string $entry_id Numeric ID of the entry that was updated
53  * @param GravityView_Edit_Entry_Render $edit_entry_render This object
54  *
55  * @return void
56  */
57  function maybe_save_partial_entry( $form, $entry_id, $edit_entry_render ) {
58 
59  if ( ! class_exists( 'GF_Partial_Entries' ) ) {
60  return;
61  }
62 
63  $partial_entries_addon = GF_Partial_Entries::get_instance();
64 
65  $feed_settings = $partial_entries_addon->get_feed_settings( $form['id'] );
66 
67  $is_enabled = \GV\Utils::get( $feed_settings, 'enable', 0 );
68 
69  if ( ! $is_enabled ) {
70  return;
71  }
72 
73  $entry = $edit_entry_render->get_entry();
74 
75  $partial_entry_id = \GV\Utils::get( $entry, 'partial_entry_id' );
76 
77  if ( empty( $partial_entry_id ) ) {
78  return;
79  }
80 
81  // Set the expected $_POST key for the Add-On to use
82  $_POST['partial_entry_id'] = $partial_entry_id;
83 
84  gravityview()->log->debug( 'Saving partial entry (ID #{partial_entry_id}) for Entry #{entry_id}', array(
85  'partial_entry_id' => $partial_entry_id,
86  'entry_id' => $entry_id
87  ) );
88 
89  $partial_entries_addon->maybe_save_partial_entry( $form['id'] );
90  }
91 }
92 
if(gravityview() ->plugin->is_GF_25()) $form
maybe_save_partial_entry( $form, $entry_id, $edit_entry_render)
Update the Partial Entries progress after an entry is updated in Edit Entry.
static get( $array, $key, $default=null)
Grab a value from an array or an object or default.
gravityview()
The main GravityView wrapper function.
Abstract class that makes it easy for plugins and themes to register no-conflict scripts and styles...
$entry
Definition: notes.php:27