GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
class-delete-entry.php
Go to the documentation of this file.
1 <?php
2 /**
3  * The GravityView Delete Entry Extension
4  *
5  * Delete entries in GravityView.
6  *
7  * @since 1.5.1
8  * @package GravityView
9  * @license GPL2+
10  * @author Katz Web Services, Inc.
11  * @link http://gravityview.co
12  * @copyright Copyright 2014, Katz Web Services, Inc.
13  */
14 
15 if ( ! defined( 'WPINC' ) ) {
16  die;
17 }
18 
19 /**
20  * @since 1.5.1
21  */
23 
24  static $file;
25  static $instance;
26  var $entry;
27  var $form;
28  var $view_id;
29  var $is_valid = NULL;
30 
31  function __construct() {
32 
33  self::$file = plugin_dir_path( __FILE__ );
34 
35  $this->add_hooks();
36  }
37 
38  /**
39  * @since 1.9.2
40  */
41  private function add_hooks() {
42 
43  add_action( 'wp', array( $this, 'process_delete' ), 10000 );
44 
45  add_filter( 'gravityview_entry_default_fields', array( $this, 'add_default_field'), 10, 3 );
46 
47  add_action( 'gravityview_before', array( $this, 'display_message' ) );
48 
49  // For the Delete Entry Link, you don't want visible to all users.
50  add_filter( 'gravityview_field_visibility_caps', array( $this, 'modify_visibility_caps'), 10, 5 );
51 
52  // Modify the field options based on the name of the field type
53  add_filter( 'gravityview_template_delete_link_options', array( $this, 'delete_link_field_options' ), 10, 5 );
54 
55  // add template path to check for field
56  add_filter( 'gravityview_template_paths', array( $this, 'add_template_path' ) );
57 
58  add_action( 'gravityview/edit-entry/publishing-action/after', array( $this, 'add_delete_button'), 10, 3 );
59 
60  add_action ( 'gravityview/delete-entry/deleted', array( $this, 'process_connected_posts' ), 10, 2 );
61  add_action ( 'gravityview/delete-entry/trashed', array( $this, 'process_connected_posts' ), 10, 2 );
62  }
63 
64  /**
65  * Return the instantiated class object
66  *
67  * @since 1.5.1
68  * @return GravityView_Delete_Entry
69  */
70  static function getInstance() {
71 
72  if( empty( self::$instance ) ) {
73  self::$instance = new self;
74  }
75 
76  return self::$instance;
77  }
78 
79  /**
80  * Include this extension templates path
81  *
82  * @since 1.5.1
83  * @param array $file_paths List of template paths ordered
84  */
85  function add_template_path( $file_paths ) {
86 
87  // Index 100 is the default GravityView template path.
88  // Index 110 is Edit Entry link
89  $file_paths[ 115 ] = self::$file;
90 
91  return $file_paths;
92  }
93 
94  /**
95  * Add "Delete Link Text" setting to the edit_link field settings
96  *
97  * @since 1.5.1
98  * @param [type] $field_options [description]
99  * @param [type] $template_id [description]
100  * @param [type] $field_id [description]
101  * @param [type] $context [description]
102  * @param [type] $input_type [description]
103  * @return [type] [description]
104  */
105  function delete_link_field_options( $field_options, $template_id, $field_id, $context, $input_type ) {
106 
107  // Always a link, never a filter
108  unset( $field_options['show_as_link'], $field_options['search_filter'] );
109 
110  // Delete Entry link should only appear to visitors capable of editing entries
111  unset( $field_options['only_loggedin'], $field_options['only_loggedin_cap'] );
112 
113  $add_option['delete_link'] = array(
114  'type' => 'text',
115  'label' => __( 'Delete Link Text', 'gravityview' ),
116  'desc' => NULL,
117  'value' => __('Delete Entry', 'gravityview'),
118  'merge_tags' => true,
119  );
120 
121  $field_options['allow_edit_cap'] = array(
122  'type' => 'select',
123  'label' => __( 'Allow the following users to delete the entry:', 'gravityview' ),
124  'choices' => GravityView_Render_Settings::get_cap_choices( $template_id, $field_id, $context, $input_type ),
125  'tooltip' => 'allow_edit_cap',
126  'class' => 'widefat',
127  'value' => 'read', // Default: entry creator
128  );
129 
130 
131  return array_merge( $add_option, $field_options );
132  }
133 
134 
135  /**
136  * Add Edit Link as a default field, outside those set in the Gravity Form form
137  *
138  * @since 1.5.1
139  * @param array $entry_default_fields Existing fields
140  * @param string|array $form form_ID or form object
141  * @param string $zone Either 'single', 'directory', 'edit', 'header', 'footer'
142  */
143  function add_default_field( $entry_default_fields, $form = array(), $zone = '' ) {
144 
145  if( 'edit' !== $zone ) {
146  $entry_default_fields['delete_link'] = array(
147  'label' => __( 'Delete Entry', 'gravityview' ),
148  'type' => 'delete_link',
149  'desc' => __( 'A link to delete the entry. Respects the Delete Entry permissions.', 'gravityview' ),
150  );
151  }
152 
153  return $entry_default_fields;
154  }
155 
156  /**
157  * Add Delete Entry Link to the Add Field dialog
158  * @since 1.5.1
159  * @param array $available_fields
160  */
161  function add_available_field( $available_fields = array() ) {
162 
163  $available_fields['delete_link'] = array(
164  'label_text' => __( 'Delete Entry', 'gravityview' ),
165  'field_id' => 'delete_link',
166  'label_type' => 'field',
167  'input_type' => 'delete_link',
168  'field_options' => NULL
169  );
170 
171  return $available_fields;
172  }
173 
174  /**
175  * Change wording for the Edit context to read Entry Creator
176  *
177  * @since 1.5.1
178  * @param array $visibility_caps Array of capabilities to display in field dropdown.
179  * @param string $field_type Type of field options to render (`field` or `widget`)
180  * @param string $template_id Table slug
181  * @param float $field_id GF Field ID - Example: `3`, `5.2`, `entry_link`, `created_by`
182  * @param string $context What context are we in? Example: `single` or `directory`
183  * @param string $input_type (textarea, list, select, etc.)
184  * @return array Array of field options with `label`, `value`, `type`, `default` keys
185  */
186  public function modify_visibility_caps( $visibility_caps = array(), $template_id = '', $field_id = '', $context = '', $input_type = '' ) {
187 
188  $caps = $visibility_caps;
189 
190  // If we're configuring fields in the edit context, we want a limited selection
191  if( $field_id === 'delete_link' ) {
192 
193  // Remove other built-in caps.
194  unset( $caps['publish_posts'], $caps['gravityforms_view_entries'], $caps['delete_others_posts'] );
195 
196  $caps['read'] = _x('Entry Creator', 'User capability', 'gravityview');
197  }
198 
199  return $caps;
200  }
201 
202  /**
203  * Make sure there's an entry
204  *
205  * @since 1.5.1
206  * @param [type] $entry [description]
207  */
208  function set_entry( $entry = null ) {
209  $this->entry = empty( $entry ) ? GravityView_View::getInstance()->entries[0] : $entry;
210  }
211 
212  /**
213  * Generate a consistent nonce key based on the Entry ID
214  *
215  * @since 1.5.1
216  * @param int $entry_id Entry ID
217  * @return string Key used to validate request
218  */
219  public static function get_nonce_key( $entry_id ) {
220  return sprintf( 'delete_%s', $entry_id );
221  }
222 
223 
224  /**
225  * Generate a nonce link with the base URL of the current View embed
226  *
227  * We don't want to link to the single entry, because when deleted, there would be nothing to return to.
228  *
229  * @since 1.5.1
230  * @param array $entry Gravity Forms entry array
231  * @return string|null If directory link is valid, the URL to process the delete request. Otherwise, `NULL`.
232  */
233  public static function get_delete_link( $entry, $view_id = 0, $post_id = null ) {
234 
235  self::getInstance()->set_entry( $entry );
236 
237  $base = GravityView_API::directory_link( $post_id, true );
238 
239  if( empty( $base ) ) {
240  do_action( 'gravityview_log_error', __METHOD__ . ' - Post ID does not exist: '.$post_id );
241  return NULL;
242  }
243 
244  // Use the slug instead of the ID for consistent security
245  $entry_slug = GravityView_API::get_entry_slug( $entry['id'], $entry );
246 
247  $view_id = empty( $view_id ) ? gravityview_get_view_id() : $view_id;
248 
249  $actionurl = add_query_arg( array(
250  'action' => 'delete',
251  'entry_id' => $entry_slug,
252  'gvid' => $view_id,
253  'view_id' => $view_id,
254  ), $base );
255 
256  $url = wp_nonce_url( $actionurl, 'delete_'.$entry_slug, 'delete' );
257 
258  return $url;
259  }
260 
261 
262  /**
263  * Add a Delete button to the #publishing-action section of the Delete Entry form
264  *
265  * @since 1.5.1
266  * @param array $form Gravity Forms form array
267  * @param array $entry Gravity Forms entry array
268  * @param int $view_id GravityView View ID
269  */
270  function add_delete_button( $form = array(), $entry = array(), $view_id = NULL ) {
271 
272  // Only show the link to those who are allowed to see it.
273  if( !self::check_user_cap_delete_entry( $entry ) ) {
274  return;
275  }
276 
277  /**
278  * @filter `gravityview/delete-entry/show-delete-button` Should the Delete button be shown in the Edit Entry screen?
279  * @param boolean $show_entry Default: true
280  */
281  $show_delete_button = apply_filters( 'gravityview/delete-entry/show-delete-button', true );
282 
283  // If the button is hidden by the filter, don't show.
284  if( !$show_delete_button ) {
285  return;
286  }
287 
288  $attributes = array(
289  'class' => 'btn btn-sm button button-small alignright pull-right btn-danger gv-button-delete',
290  'tabindex' => '5',
291  'onclick' => self::get_confirm_dialog(),
292  );
293 
294  echo gravityview_get_link( self::get_delete_link( $entry, $view_id ), esc_attr__( 'Delete', 'gravityview' ), $attributes );
295 
296  }
297 
298  /**
299  * Handle the deletion request, if $_GET['action'] is set to "delete"
300  *
301  * 1. Check referrer validity
302  * 2. Make sure there's an entry with the slug of $_GET['entry_id']
303  * 3. If so, attempt to delete the entry. If not, set the error status
304  * 4. Remove `action=delete` from the URL
305  * 5. Redirect to the page using `wp_safe_redirect()`
306  *
307  * @since 1.5.1
308  * @uses wp_safe_redirect()
309  * @return void
310  */
311  function process_delete() {
312 
313  // If the form is submitted
314  if( isset( $_GET['action'] ) && 'delete' === $_GET['action'] && isset( $_GET['entry_id'] ) ) {
315 
316  // Make sure it's a GravityView request
317  $valid_nonce_key = wp_verify_nonce( $_GET['delete'], self::get_nonce_key( $_GET['entry_id'] ) );
318 
319  if( ! $valid_nonce_key ) {
320  do_action('gravityview_log_debug', __METHOD__ . ' Delete entry not processed: nonce validation failed.' );
321  return;
322  }
323 
324  // Get the entry slug
325  $entry_slug = esc_attr( $_GET['entry_id'] );
326 
327  // See if there's an entry there
329 
330  if( $entry ) {
331 
332  $has_permission = $this->user_can_delete_entry( $entry );
333 
334  if( is_wp_error( $has_permission ) ) {
335 
336  $messages = array(
337  'message' => urlencode( $has_permission->get_error_message() ),
338  'status' => 'error',
339  );
340 
341  } else {
342 
343  // Delete the entry
344  $delete_response = $this->delete_or_trash_entry( $entry );
345 
346  if( is_wp_error( $delete_response ) ) {
347 
348  $messages = array(
349  'message' => urlencode( $delete_response->get_error_message() ),
350  'status' => 'error',
351  );
352 
353  } else {
354 
355  $messages = array(
356  'status' => $delete_response,
357  );
358 
359  }
360 
361  }
362 
363  } else {
364 
365  do_action('gravityview_log_debug', __METHOD__ . ' Delete entry failed: there was no entry with the entry slug '. $entry_slug );
366 
367  $messages = array(
368  'message' => urlencode( __('The entry does not exist.', 'gravityview') ),
369  'status' => 'error',
370  );
371  }
372 
373  $redirect_to_base = esc_url_raw( remove_query_arg( array( 'action' ) ) );
374  $redirect_to = add_query_arg( $messages, $redirect_to_base );
375 
376  wp_safe_redirect( $redirect_to );
377 
378  exit();
379 
380  } // endif action is delete.
381 
382  }
383 
384  /**
385  * Delete mode: permanently delete, or move to trash?
386  *
387  * @return string `delete` or `trash`
388  */
389  private function get_delete_mode() {
390 
391  /**
392  * @filter `gravityview/delete-entry/mode` Delete mode: permanently delete, or move to trash?
393  * @since 1.13.1
394  * @param string $delete_mode Delete mode: `trash` or `delete`. Default: `delete`
395  */
396  $delete_mode = apply_filters( 'gravityview/delete-entry/mode', 'delete' );
397 
398  return ( 'trash' === $delete_mode ) ? 'trash' : 'delete';
399  }
400 
401  /**
402  * @since 1.13.1
403  * @see GFAPI::delete_entry()
404  * @return WP_Error|boolean GFAPI::delete_entry() returns a WP_Error on error
405  */
406  private function delete_or_trash_entry( $entry ) {
407 
408  $entry_id = $entry['id'];
409 
410  $mode = $this->get_delete_mode();
411 
412  if( 'delete' === $mode ) {
413 
414  do_action( 'gravityview_log_debug', __METHOD__ . ' Starting delete entry: ', $entry_id );
415 
416  // Delete the entry
417  $delete_response = GFAPI::delete_entry( $entry_id );
418 
419  if( ! is_wp_error( $delete_response ) ) {
420  $delete_response = 'deleted';
421 
422  /**
423  * @action `gravityview/delete-entry/deleted` Triggered when an entry is deleted
424  * @since 1.16.4
425  * @param int $entry_id ID of the Gravity Forms entry
426  * @param array $entry Deleted entry array
427  */
428  do_action( 'gravityview/delete-entry/deleted', $entry_id, $entry );
429  }
430 
431  do_action( 'gravityview_log_debug', __METHOD__ . ' Delete response: ', $delete_response );
432 
433  } else {
434 
435  do_action( 'gravityview_log_debug', __METHOD__ . ' Starting trash entry: ', $entry_id );
436 
437  $trashed = GFAPI::update_entry_property( $entry_id, 'status', 'trash' );
438  new GravityView_Cache;
439 
440  if( ! $trashed ) {
441  $delete_response = new WP_Error( 'trash_entry_failed', __('Moving the entry to the trash failed.', 'gravityview' ) );
442  } else {
443 
444  /**
445  * @action `gravityview/delete-entry/trashed` Triggered when an entry is trashed
446  * @since 1.16.4
447  * @param int $entry_id ID of the Gravity Forms entry
448  * @param array $entry Deleted entry array
449  */
450  do_action( 'gravityview/delete-entry/trashed', $entry_id, $entry );
451 
452  $delete_response = 'trashed';
453  }
454 
455  do_action( 'gravityview_log_debug', __METHOD__ . ' Trashed? ', $delete_response );
456  }
457 
458  return $delete_response;
459  }
460 
461  /**
462  * Delete or trash a post connected to an entry
463  *
464  * @since 1.17
465  *
466  * @param int $entry_id ID of entry being deleted/trashed
467  * @param array $entry Array of the entry being deleted/trashed
468  */
469  public function process_connected_posts( $entry_id = 0, $entry = array() ) {
470 
471  // The entry had no connected post
472  if( empty( $entry['post_id'] ) ) {
473  return;
474  }
475 
476  /**
477  * @filter `gravityview/delete-entry/delete-connected-post` Should posts connected to an entry be deleted when the entry is deleted?
478  * @since 1.17
479  * @param boolean $delete_post If trashing an entry, trash the post. If deleting an entry, delete the post. Default: true
480  */
481  $delete_post = apply_filters( 'gravityview/delete-entry/delete-connected-post', true );
482 
483  if( false === $delete_post ) {
484  return;
485  }
486 
487  $action = current_action();
488 
489  if( 'gravityview/delete-entry/deleted' === $action ) {
490  $result = wp_delete_post( $entry['post_id'], true );
491  } else {
492  $result = wp_trash_post( $entry['post_id'] );
493  }
494 
495  if( false === $result ) {
496  do_action( 'gravityview_log_error', __METHOD__ . ' (called by '.$action.'): Error processing the Post connected to the entry.', $entry );
497  } else {
498  do_action( 'gravityview_log_debug', __METHOD__ . ' (called by '.$action.'): Successfully processed Post connected to the entry.', $entry );
499  }
500  }
501 
502  /**
503  * Is the current nonce valid for editing the entry?
504  *
505  * @since 1.5.1
506  * @return boolean
507  */
508  public function verify_nonce() {
509 
510  // No delete entry request was made
511  if( empty( $_GET['entry_id'] ) || empty( $_GET['delete'] ) ) {
512  return false;
513  }
514 
515  $nonce_key = self::get_nonce_key( $_GET['entry_id'] );
516 
517  $valid = wp_verify_nonce( $_GET['delete'], $nonce_key );
518 
519  /**
520  * @filter `gravityview/delete-entry/verify_nonce` Override Delete Entry nonce validation. Return true to declare nonce valid.
521  * @since 1.15.2
522  * @see wp_verify_nonce()
523  * @param int|boolean $valid False if invalid; 1 or 2 when nonce was generated
524  * @param string $nonce_key Name of nonce action used in wp_verify_nonce. $_GET['delete'] holds the nonce value itself. Default: `delete_{entry_id}`
525  */
526  $valid = apply_filters( 'gravityview/delete-entry/verify_nonce', $valid, $nonce_key );
527 
528  return $valid;
529  }
530 
531  /**
532  * Get the onclick attribute for the confirm dialogs that warns users before they delete an entry
533  *
534  * @since 1.5.1
535  * @return string HTML `onclick` attribute
536  */
537  public static function get_confirm_dialog() {
538 
539  $confirm = __('Are you sure you want to delete this entry? This cannot be undone.', 'gravityview');
540 
541  /**
542  * @filter `gravityview/delete-entry/confirm-text` Modify the Delete Entry Javascript confirmation text
543  * @param string $confirm Default: "Are you sure you want to delete this entry? This cannot be undone."
544  */
545  $confirm = apply_filters( 'gravityview/delete-entry/confirm-text', $confirm );
546 
547  return 'return window.confirm(\''. esc_js( $confirm ) .'\');';
548  }
549 
550  /**
551  * Check if the user can edit the entry
552  *
553  * - Is the nonce valid?
554  * - Does the user have the right caps for the entry
555  * - Is the entry in the trash?
556  *
557  * @since 1.5.1
558  * @param array $entry Gravity Forms entry array
559  * @return boolean|WP_Error True: can edit form. WP_Error: nope.
560  */
561  function user_can_delete_entry( $entry = array() ) {
562 
563  $error = NULL;
564 
565  if( ! $this->verify_nonce() ) {
566  $error = __( 'The link to delete this entry is not valid; it may have expired.', 'gravityview');
567  }
568 
569  if( ! self::check_user_cap_delete_entry( $entry ) ) {
570  $error = __( 'You do not have permission to delete this entry.', 'gravityview');
571  }
572 
573  if( $entry['status'] === 'trash' ) {
574  if( 'trash' === $this->get_delete_mode() ) {
575  $error = __( 'The entry is already in the trash.', 'gravityview' );
576  } else {
577  $error = __( 'You cannot delete the entry; it is already in the trash.', 'gravityview' );
578  }
579  }
580 
581  // No errors; everything's fine here!
582  if( empty( $error ) ) {
583  return true;
584  }
585 
586  do_action('gravityview_log_error', 'GravityView_Delete_Entry[user_can_delete_entry]' . $error );
587 
588  return new WP_Error( 'gravityview-delete-entry-permissions', $error );
589  }
590 
591 
592  /**
593  * checks if user has permissions to view the link or delete a specific entry
594  *
595  * @since 1.5.1
596  * @since 1.15 Added `$view_id` param
597  *
598  * @param array $entry Gravity Forms entry array
599  * @param array $field Field settings (optional)
600  * @param int $view_id Pass a View ID to check caps against. If not set, check against current View (optional)
601  * @return bool
602  */
603  public static function check_user_cap_delete_entry( $entry, $field = array(), $view_id = 0 ) {
605 
606  $current_user = wp_get_current_user();
607 
608  $entry_id = isset( $entry['id'] ) ? $entry['id'] : NULL;
609 
610  // Or if they can delete any entries (as defined in Gravity Forms), we're good.
611  if( GVCommon::has_cap( array( 'gravityforms_delete_entries', 'gravityview_delete_others_entries' ), $entry_id ) ) {
612 
613  do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Current user has `gravityforms_delete_entries` or `gravityview_delete_others_entries` capability.' );
614 
615  return true;
616  }
617 
618 
619  // If field options are passed, check if current user can view the link
620  if( !empty( $field ) ) {
621 
622  // If capability is not defined, something is not right!
623  if( empty( $field['allow_edit_cap'] ) ) {
624 
625  do_action( 'gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Cannot read delete entry field caps', $field );
626 
627  return false;
628  }
629 
630  if( GVCommon::has_cap( $field['allow_edit_cap'] ) ) {
631 
632  // Do not return true if cap is read, as we need to check if the current user created the entry
633  if( $field['allow_edit_cap'] !== 'read' ) {
634  return true;
635  }
636 
637  } else {
638 
639  do_action( 'gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s is not authorized to view delete entry link ', $current_user->ID ) );
640 
641  return false;
642  }
643 
644  }
645 
646  if( !isset( $entry['created_by'] ) ) {
647 
648  do_action('gravityview_log_error', 'GravityView_Delete_Entry[check_user_cap_delete_entry] Entry `created_by` doesn\'t exist.');
649 
650  return false;
651  }
652 
653  $view_id = empty( $view_id ) ? $gravityview_view->getViewId() : $view_id;
654 
655  // Only checks user_delete view option if view is already set
656  if( $view_id ) {
657 
658  $current_view = gravityview_get_current_view_data( $view_id );
659 
660  $user_delete = isset( $current_view['atts']['user_delete'] ) ? $current_view['atts']['user_delete'] : false;
661 
662  if( empty( $user_delete ) ) {
663 
664  do_action('gravityview_log_debug', 'GravityView_Delete_Entry[check_user_cap_delete_entry] User Delete is disabled. Returning false.' );
665 
666  return false;
667  }
668  }
669 
670  // If the logged-in user is the same as the user who created the entry, we're good.
671  if( is_user_logged_in() && intval( $current_user->ID ) === intval( $entry['created_by'] ) ) {
672 
673  do_action('gravityview_log_debug', sprintf( 'GravityView_Delete_Entry[check_user_cap_delete_entry] User %s created the entry.', $current_user->ID ) );
674 
675  return true;
676  }
677 
678  return false;
679  }
680 
681 
682  /**
683  * After processing delete entry, the user will be redirected to the referring View or embedded post/page. Display a message on redirection.
684  *
685  * If success, there will be `status` URL parameters `status=>success`
686  * If an error, there will be `status` and `message` URL parameters `status=>error&message=example`
687  *
688  * @since 1.15.2 Only show message when the URL parameter's View ID matches the current View ID
689  * @since 1.5.1
690  *
691  * @param int $current_view_id The ID of the View being rendered
692  * @return void
693  */
694  public function display_message( $current_view_id = 0 ) {
695 
696  if( empty( $_GET['status'] ) || ! self::verify_nonce() ) {
697  return;
698  }
699 
700  // Entry wasn't deleted from current View
701  if( intval( $_GET['gvid'] ) !== intval( $current_view_id ) ) {
702  return;
703  }
704 
705  $status = esc_attr( $_GET['status'] );
706  $message_from_url = rgget('message');
707  $message_from_url = rawurldecode( stripslashes_deep( $message_from_url ) );
708  $class = '';
709 
710  switch ( $status ) {
711  case 'error':
712  $class = ' gv-error error';
713  $error_message = __('There was an error deleting the entry: %s', 'gravityview');
714  $message = sprintf( $error_message, $message_from_url );
715  break;
716  case 'trashed':
717  $message = __('The entry was successfully moved to the trash.', 'gravityview');
718  break;
719  default:
720  $message = __('The entry was successfully deleted.', 'gravityview');
721  break;
722  }
723 
724  /**
725  * @filter `gravityview/delete-entry/message` Modify the Delete Entry messages
726  * @since 1.13.1
727  * @param string $message Message to be displayed
728  * @param string $status Message status (`error` or `success`)
729  * @param string $message_from_url The original error message, if any, without the "There was an error deleting the entry:" prefix
730  */
731  $message = apply_filters( 'gravityview/delete-entry/message', esc_attr( $message ), $status, $message_from_url );
732 
733  // DISPLAY ERROR/SUCCESS MESSAGE
734  echo '<div class="gv-notice' . esc_attr( $class ) .'">'. $message .'</div>';
735  }
736 
737 
738 } // end class
739 
741 
gravityview_get_view_id()
Get the current View ID being rendered.
Definition: class-api.php:1037
$url
Definition: post_image.php:25
$is_valid
verify_nonce()
Is the current nonce valid for editing the entry?
new GravityView_Cache
delete_link_field_options($field_options, $template_id, $field_id, $context, $input_type)
Add "Delete Link Text" setting to the edit_link field settings.
delete_or_trash_entry($entry)
process_delete()
Handle the deletion request, if $_GET[&#39;action&#39;] is set to "delete".
static directory_link($post_id=NULL, $add_query_args=true)
Generate a URL to the Directory context.
Definition: class-api.php:428
$entry
$form
static $instance
$class
static has_cap($caps= '', $object_id=null, $user_id=null)
Alias of GravityView_Roles_Capabilities::has_cap()
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
add_template_path($file_paths)
Include this extension templates path.
static get_delete_link($entry, $view_id=0, $post_id=null)
Generate a nonce link with the base URL of the current View embed.
modify_visibility_caps($visibility_caps=array(), $template_id= '', $field_id= '', $context= '', $input_type= '')
Change wording for the Edit context to read Entry Creator.
__construct()
gravityview_get_current_view_data($view_id=0)
Get data for a specific view.
Definition: class-api.php:984
static get_confirm_dialog()
Get the onclick attribute for the confirm dialogs that warns users before they delete an entry...
static get_nonce_key($entry_id)
Generate a consistent nonce key based on the Entry ID.
add_delete_button($form=array(), $entry=array(), $view_id=NULL)
Add a Delete button to the #publishing-action section of the Delete Entry form.
process_connected_posts($entry_id=0, $entry=array())
Delete or trash a post connected to an entry.
gravityview_get_link($href= '', $anchor_text= '', $atts=array())
Generate an HTML anchor tag with a list of supported attributes.
$field_id
Definition: time.php:17
static get_cap_choices($template_id= '', $field_id= '', $context= '', $input_type= '')
Get capabilities options for GravityView.
gravityview_get_entry($entry_slug, $force_allow_ids=false, $check_entry_display=true)
Return a single entry object.
add_available_field($available_fields=array())
Add Delete Entry Link to the Add Field dialog.
static getInstance()
Return the instantiated class object.
add_hooks()
user_can_delete_entry($entry=array())
Check if the user can edit the entry.
static getInstance($passed_post=NULL)
static $file
$entry_slug
Definition: notes.php:30
get_delete_mode()
Delete mode: permanently delete, or move to trash?
$view_id
add_default_field($entry_default_fields, $form=array(), $zone= '')
Add Edit Link as a default field, outside those set in the Gravity Form form.
display_message($current_view_id=0)
After processing delete entry, the user will be redirected to the referring View or embedded post/pag...
static get_entry_slug($id_or_string, $entry=array())
Get the entry slug for the entry.
Definition: class-api.php:567
set_entry($entry=null)
Make sure there&#39;s an entry.
$field
Definition: gquiz_grade.php:11