GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes | Private Member Functions
GravityView_Delete_Entry Class Reference

Public Member Functions

 __construct ()
 
 add_available_field ($available_fields=array())
 Add Delete Entry Link to the Add Field dialog. More...
 
 add_default_field ($entry_default_fields, $form=array(), $zone= '')
 Add Edit Link as a default field, outside those set in the Gravity Form form. More...
 
 add_delete_button ($form=array(), $entry=array(), $view_id=NULL)
 Add a Delete button to the #publishing-action section of the Delete Entry form. More...
 
 add_template_path ($file_paths)
 Include this extension templates path. More...
 
 delete_link_field_options ($field_options, $template_id, $field_id, $context, $input_type)
 Add "Delete Link Text" setting to the edit_link field settings. More...
 
 display_message ($current_view_id=0)
 After processing delete entry, the user will be redirected to the referring View or embedded post/page. More...
 
 modify_visibility_caps ($visibility_caps=array(), $template_id= '', $field_id= '', $context= '', $input_type= '')
 Change wording for the Edit context to read Entry Creator. More...
 
 process_connected_posts ($entry_id=0, $entry=array())
 Delete or trash a post connected to an entry. More...
 
 process_delete ()
 Handle the deletion request, if $_GET['action'] is set to "delete". More...
 
 set_entry ($entry=null)
 Make sure there's an entry. More...
 
 user_can_delete_entry ($entry=array())
 Check if the user can edit the entry. More...
 
 verify_nonce ()
 Is the current nonce valid for editing the entry? More...
 

Static Public Member Functions

static check_user_cap_delete_entry ($entry, $field=array(), $view_id=0)
 checks if user has permissions to view the link or delete a specific entry More...
 
static get_confirm_dialog ()
 Get the onclick attribute for the confirm dialogs that warns users before they delete an entry. More...
 
static get_delete_link ($entry, $view_id=0, $post_id=null)
 Generate a nonce link with the base URL of the current View embed. More...
 
static get_nonce_key ($entry_id)
 Generate a consistent nonce key based on the Entry ID. More...
 
static getInstance ()
 Return the instantiated class object. More...
 

Data Fields

 $entry
 
 $form
 
 $is_valid = NULL
 
 $view_id
 

Static Public Attributes

static $file
 
static $instance
 

Private Member Functions

 add_hooks ()
 
 delete_or_trash_entry ($entry)
 
 get_delete_mode ()
 Delete mode: permanently delete, or move to trash? More...
 

Detailed Description

Since
1.5.1

Definition at line 22 of file class-delete-entry.php.

Constructor & Destructor Documentation

__construct ( )

Definition at line 31 of file class-delete-entry.php.

References add_hooks().

Member Function Documentation

add_available_field (   $available_fields = array())

Add Delete Entry Link to the Add Field dialog.

Since
1.5.1
Parameters
array$available_fields

Definition at line 161 of file class-delete-entry.php.

add_default_field (   $entry_default_fields,
  $form = array(),
  $zone = '' 
)

Add Edit Link as a default field, outside those set in the Gravity Form form.

Since
1.5.1
Parameters
array$entry_default_fieldsExisting fields
string | array$formform_ID or form object
string$zoneEither 'single', 'directory', 'edit', 'header', 'footer'

Definition at line 143 of file class-delete-entry.php.

add_delete_button (   $form = array(),
  $entry = array(),
  $view_id = NULL 
)

Add a Delete button to the #publishing-action section of the Delete Entry form.

Since
1.5.1
Parameters
array$formGravity Forms form array
array$entryGravity Forms entry array
int$view_idGravityView View ID
Runs Filter:
gravityview/delete-entry/show-delete-button Should the Delete button be shown in the Edit Entry screen?
Parameters
boolean$show_entryDefault: true

Definition at line 270 of file class-delete-entry.php.

References $attributes, and gravityview_get_link().

add_hooks ( )
private
Since
1.9.2

Definition at line 41 of file class-delete-entry.php.

Referenced by __construct().

add_template_path (   $file_paths)

Include this extension templates path.

Since
1.5.1
Parameters
array$file_pathsList of template paths ordered

Definition at line 85 of file class-delete-entry.php.

static check_user_cap_delete_entry (   $entry,
  $field = array(),
  $view_id = 0 
)
static

checks if user has permissions to view the link or delete a specific entry

Since
1.5.1
1.15 Added $view_id param
Parameters
array$entryGravity Forms entry array
array$fieldField settings (optional)
int$view_idPass a View ID to check caps against. If not set, check against current View (optional)
Returns
bool

Definition at line 603 of file class-delete-entry.php.

References $field, $gravityview_view, $view_id, GravityView_View\getInstance(), gravityview_get_current_view_data(), and GVCommon\has_cap().

Referenced by GravityView_Entry_Link_Shortcode\has_cap().

delete_link_field_options (   $field_options,
  $template_id,
  $field_id,
  $context,
  $input_type 
)

Add "Delete Link Text" setting to the edit_link field settings.

Since
1.5.1
Parameters
[type]$field_options [description]
[type]$template_id [description]
[type]$field_id [description]
[type]$context [description]
[type]$input_type [description]
Returns
[type] [description]

Definition at line 105 of file class-delete-entry.php.

References $field_id, and GravityView_Render_Settings\get_cap_choices().

delete_or_trash_entry (   $entry)
private
Since
1.13.1
See also
GFAPI::delete_entry()
Returns
WP_Error|boolean GFAPI::delete_entry() returns a WP_Error on error
Runs Actions:
gravityview/delete-entry/deleted Triggered when an entry is deleted
Since
1.16.4
Parameters
int$entry_idID of the Gravity Forms entry
array$entryDeleted entry array
Runs Actions:
gravityview/delete-entry/trashed Triggered when an entry is trashed
Since
1.16.4
Parameters
int$entry_idID of the Gravity Forms entry
array$entryDeleted entry array

Definition at line 406 of file class-delete-entry.php.

References get_delete_mode(), and GravityView_Cache.

Referenced by process_delete().

display_message (   $current_view_id = 0)

After processing delete entry, the user will be redirected to the referring View or embedded post/page.

Display a message on redirection.

If success, there will be status URL parameters status=>success If an error, there will be status and message URL parameters status=>error&message=example

Since
1.15.2 Only show message when the URL parameter's View ID matches the current View ID
1.5.1
Parameters
int$current_view_idThe ID of the View being rendered
Returns
void
Runs Filter:
gravityview/delete-entry/message Modify the Delete Entry messages
Since
1.13.1
Parameters
string$messageMessage to be displayed
string$statusMessage status (error or success)
string$message_from_urlThe original error message, if any, without the "There was an error deleting the entry:" prefix

Definition at line 694 of file class-delete-entry.php.

References $class, and getInstance().

static get_confirm_dialog ( )
static

Get the onclick attribute for the confirm dialogs that warns users before they delete an entry.

Since
1.5.1
Returns
string HTML onclick attribute
Runs Filter:
gravityview/delete-entry/confirm-text Modify the Delete Entry Javascript confirmation text
Parameters
string$confirmDefault: "Are you sure you want to delete this entry? This cannot be undone."

Definition at line 537 of file class-delete-entry.php.

Referenced by GravityView_Entry_Link_Shortcode\get_link_atts().

static get_delete_link (   $entry,
  $view_id = 0,
  $post_id = null 
)
static

Generate a nonce link with the base URL of the current View embed.

We don't want to link to the single entry, because when deleted, there would be nothing to return to.

Since
1.5.1
Parameters
array$entryGravity Forms entry array
Returns
string|null If directory link is valid, the URL to process the delete request. Otherwise, NULL.

Definition at line 233 of file class-delete-entry.php.

References $entry_slug, $url, $view_id, GravityView_API\directory_link(), GravityView_API\get_entry_slug(), and gravityview_get_view_id().

Referenced by GravityView_Entry_Link_Shortcode\get_url().

get_delete_mode ( )
private

Delete mode: permanently delete, or move to trash?

Returns
string delete or trash
Runs Filter:
gravityview/delete-entry/mode Delete mode: permanently delete, or move to trash?
Since
1.13.1
Parameters
string$delete_modeDelete mode: trash or delete. Default: delete

Definition at line 389 of file class-delete-entry.php.

Referenced by delete_or_trash_entry().

static get_nonce_key (   $entry_id)
static

Generate a consistent nonce key based on the Entry ID.

Since
1.5.1
Parameters
int$entry_idEntry ID
Returns
string Key used to validate request

Definition at line 219 of file class-delete-entry.php.

static getInstance ( )
static

Return the instantiated class object.

Since
1.5.1
Returns
GravityView_Delete_Entry

Definition at line 70 of file class-delete-entry.php.

Referenced by display_message().

modify_visibility_caps (   $visibility_caps = array(),
  $template_id = '',
  $field_id = '',
  $context = '',
  $input_type = '' 
)

Change wording for the Edit context to read Entry Creator.

Since
1.5.1
Parameters
array$visibility_capsArray of capabilities to display in field dropdown.
string$field_typeType of field options to render (field or widget)
string$template_idTable slug
float$field_idGF Field ID - Example: 3, 5.2, entry_link, created_by
string$contextWhat context are we in? Example: single or directory
string$input_type(textarea, list, select, etc.)
Returns
array Array of field options with label, value, type, default keys

Definition at line 186 of file class-delete-entry.php.

References $field_id.

process_connected_posts (   $entry_id = 0,
  $entry = array() 
)

Delete or trash a post connected to an entry.

Since
1.17
Parameters
int$entry_idID of entry being deleted/trashed
array$entryArray of the entry being deleted/trashed
Runs Filter:
gravityview/delete-entry/delete-connected-post Should posts connected to an entry be deleted when the entry is deleted?
Since
1.17
Parameters
boolean$delete_postIf trashing an entry, trash the post. If deleting an entry, delete the post. Default: true

Definition at line 469 of file class-delete-entry.php.

process_delete ( )

Handle the deletion request, if $_GET['action'] is set to "delete".

  1. Check referrer validity
  2. Make sure there's an entry with the slug of $_GET['entry_id']
  3. If so, attempt to delete the entry. If not, set the error status
  4. Remove action=delete from the URL
  5. Redirect to the page using wp_safe_redirect()
Since
1.5.1 wp_safe_redirect()
Returns
void

Definition at line 311 of file class-delete-entry.php.

References $entry_slug, delete_or_trash_entry(), gravityview_get_entry(), and user_can_delete_entry().

set_entry (   $entry = null)

Make sure there's an entry.

Since
1.5.1
Parameters
[type]$entry [description]

Definition at line 208 of file class-delete-entry.php.

References $entry, and GravityView_View\getInstance().

user_can_delete_entry (   $entry = array())

Check if the user can edit the entry.

  • Is the nonce valid?
  • Does the user have the right caps for the entry
  • Is the entry in the trash?
Since
1.5.1
Parameters
array$entryGravity Forms entry array
Returns
boolean|WP_Error True: can edit form. WP_Error: nope.

Definition at line 561 of file class-delete-entry.php.

Referenced by process_delete().

verify_nonce ( )

Is the current nonce valid for editing the entry?

Since
1.5.1
Returns
boolean
Runs Filter:
gravityview/delete-entry/verify_nonce Override Delete Entry nonce validation. Return true to declare nonce valid.
Since
1.15.2
See also
wp_verify_nonce()
Parameters
int | boolean$validFalse if invalid; 1 or 2 when nonce was generated
string$nonce_keyName of nonce action used in wp_verify_nonce. $_GET['delete'] holds the nonce value itself. Default: delete_{entry_id}

Definition at line 508 of file class-delete-entry.php.

Field Documentation

$entry

Definition at line 26 of file class-delete-entry.php.

Referenced by set_entry().

$file
static

Definition at line 24 of file class-delete-entry.php.

$form

Definition at line 27 of file class-delete-entry.php.

$instance
static

Definition at line 25 of file class-delete-entry.php.

$is_valid = NULL

Definition at line 29 of file class-delete-entry.php.

$view_id

Definition at line 28 of file class-delete-entry.php.

Referenced by check_user_cap_delete_entry(), and get_delete_link().


The documentation for this class was generated from the following file: