GravityView  2.10.1
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_delete_button ( $form=array(), $entry=array(), $view_id=null, $post_id=null)
 Add a Delete button to the "#publishing-action" section of the Delete Entry form. More...
 
 add_reserved_arg ( $args)
 Adds "delete" to the list of internal reserved query args. More...
 
 add_template_path ( $file_paths)
 Include this extension templates path. More...
 
 display_message ()
 
 maybe_display_message ( $current_view_id=0)
 After processing delete entry, the user will be redirected to the referring View or embedded post/page. More...
 
 maybe_not_visible ( $visible, $field, $view)
 Hide the field or not. 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(), $view_id=null)
 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=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
 
 $instances = array()
 
 $is_valid = null
 
 $view_id
 
const REDIRECT_TO_MULTIPLE_ENTRIES_VALUE = 1
 The value of the delete_redirect option when the setting is to redirect to Multiple Entries after delete. More...
 
const REDIRECT_TO_URL_VALUE = 2
 The value of the delete_redirect option when the setting is to redirect to URL. More...
 

Static Public Attributes

static $file
 
static $instance
 

Private Member Functions

 _redirect_and_exit ( $url, $message='', $status='', $safe_redirect=true)
 Redirects the user to a URL and exits. More...
 
 add_hooks ()
 
 delete_or_trash_entry ( $entry)
 
 get_delete_mode ()
 Delete mode: permanently delete, or move to trash? More...
 
 load_components ( $component)
 Load other files related to Delete Entry functionality. More...
 

Detailed Description

Since
1.5.1

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

Constructor & Destructor Documentation

◆ __construct()

__construct ( )

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

References add_hooks(), and load_components().

Member Function Documentation

◆ _redirect_and_exit()

_redirect_and_exit (   $url,
  $message = '',
  $status = '',
  $safe_redirect = true 
)
private

Redirects the user to a URL and exits.

Since
2.9.2
Parameters
string$urlThe URL to redirect to.
string$messageMessage to pass through URL.
string$statusThe deletion status ("deleted", "trashed", or "error").
bool$safe_redirectWhether to use wp_safe_redirect() or not.
Runs Filter:
gravityview/delete-entry/redirect-args Modify the query args added to the delete entry redirect
Since
2.9.2
Parameters
array$delete_redirect_argsArray with _delete_nonce, message and status keys

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

References $url.

Referenced by process_delete().

◆ add_delete_button()

add_delete_button (   $form = array(),
  $entry = array(),
  $view_id = null,
  $post_id = null 
)

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

Since
1.5.1
2.0.13 Added $post_id
Parameters
array$formGravity Forms form array
array$entryGravity Forms entry array
int$view_idGravityView View ID
int$post_idCurrent post ID. May be same as View ID.
Returns
void
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 280 of file class-delete-entry.php.

References $attributes, and gravityview_get_link().

◆ add_hooks()

add_hooks ( )
private
Since
1.9.2

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

Referenced by __construct().

◆ add_reserved_arg()

add_reserved_arg (   $args)

Adds "delete" to the list of internal reserved query args.

Since
2.10
Parameters
array$argsExisting reserved args
Returns
array

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

References $args.

◆ add_template_path()

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 181 of file class-delete-entry.php.

◆ check_user_cap_delete_entry()

static check_user_cap_delete_entry (   $entry,
  $field = array(),
  $view = 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 | \GV\View$viewPass a View ID to check caps against. If not set, check against current View (
Returns
bool

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

References $field, View\by_id(), GravityView_View\getInstance(), gravityview(), and GVCommon\has_cap().

Referenced by GravityView_Entry_Link_Shortcode\has_cap().

◆ delete_or_trash_entry()

delete_or_trash_entry (   $entry)
private
Since
1.13.1

GFAPI::delete_entry() GFAPI::update_entry_property()

Returns
WP_Error|string "deleted" or "trashed" if successful, WP_Error if GFAPI::delete_entry() or updating entry failed.
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 456 of file class-delete-entry.php.

References get_delete_mode(), gravityview(), and GravityView_Cache.

Referenced by process_delete().

◆ display_message()

display_message ( )
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 767 of file class-delete-entry.php.

References $class, Utils\_GET(), GVCommon\generate_notice(), and getInstance().

Referenced by maybe_display_message().

◆ get_confirm_dialog()

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 599 of file class-delete-entry.php.

Referenced by GravityView_Entry_Link_Shortcode\get_link_atts().

◆ get_delete_link()

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
int$view_idThe View id. Not optional since 2.0
Returns
string|null If directory link is valid, the URL to process the delete request. Otherwise, NULL.
Runs Filter:
gravityview/delete-entry/add_query_args Modify whether to include passed $_GET parameters to the end of the url
Since
2.10
Parameters
bool$add_query_paramsWhether to include passed $_GET parameters to the end of the Delete Link URL. Default: true.

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

References $add_query_args, $entry_slug, $url, GravityView_API\directory_link(), GF_Entry\from_entry(), gravityview(), gravityview_get_view_id(), and gv_get_query_args().

Referenced by GravityView_Entry_Link_Shortcode\get_url().

◆ get_delete_mode()

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 436 of file class-delete-entry.php.

Referenced by delete_or_trash_entry().

◆ get_nonce_key()

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 207 of file class-delete-entry.php.

◆ getInstance()

static getInstance ( )
static

Return the instantiated class object.

Since
1.5.1
Returns
GravityView_Delete_Entry

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

Referenced by display_message().

◆ load_components()

load_components (   $component)
private

Load other files related to Delete Entry functionality.

Since
2.9.2
Parameters
$component

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

Referenced by __construct().

◆ maybe_display_message()

maybe_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

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

References display_message().

◆ maybe_not_visible()

maybe_not_visible (   $visible,
  $field,
  $view 
)

Hide the field or not.

For non-logged in users. For users that have no delete rights on any of the current entries.

Parameters
bool$visibleVisible or not.
\GV\Field$fieldThe field.
\GV\View$viewThe View context.
Returns
bool

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

References $entry, $field, and GV\get().

◆ process_connected_posts()

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 519 of file class-delete-entry.php.

References gravityview().

◆ process_delete()

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_redirect()
Since
1.5.1 wp_redirect()
Returns
void

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

References $entry_slug, _redirect_and_exit(), View\by_id(), delete_or_trash_entry(), gravityview(), gravityview_get_entry(), and user_can_delete_entry().

◆ set_entry()

set_entry (   $entry = null)

Make sure there's an entry.

Since
1.5.1
Parameters
[type]$entry [description]

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

Referenced by GravityView_Welcome\getting_started_screen().

◆ user_can_delete_entry()

user_can_delete_entry (   $entry = array(),
  $view_id = null 
)

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 623 of file class-delete-entry.php.

References gravityview().

Referenced by process_delete().

◆ verify_nonce()

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 570 of file class-delete-entry.php.

Field Documentation

◆ $entry

$entry

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

Referenced by maybe_not_visible().

◆ $file

$file
static

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

◆ $form

$form

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

◆ $instance

$instance
static

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

◆ $instances

$instances = array()

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

◆ $is_valid

$is_valid = null

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

◆ $view_id

$view_id

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

◆ REDIRECT_TO_MULTIPLE_ENTRIES_VALUE

const REDIRECT_TO_MULTIPLE_ENTRIES_VALUE = 1

The value of the delete_redirect option when the setting is to redirect to Multiple Entries after delete.

Since
2.9.2

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

Referenced by View_Settings\defaults().

◆ REDIRECT_TO_URL_VALUE

const REDIRECT_TO_URL_VALUE = 2

The value of the delete_redirect option when the setting is to redirect to URL.

Since
2.9.2

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

Referenced by View_Settings\defaults().


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