GravityView  1.19.4
The best, easiest way to display Gravity Forms entries on your website.
class-gravityview-uninstall.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Fired when the plugin is uninstalled.
4  *
5  * @package GravityView
6  * @author Zack Katz <zack@katzwebservices.com>
7  * @license ToBeDefined
8  * @link http://gravityview.co
9  * @copyright Copyright 2015, Katz Web Services, Inc.
10  */
11 
12 /**
13  * Delete GravityView content when GravityView is uninstalled, if the setting is set to "Delete on Uninstall"
14  * @since 1.15
15  */
17 
18  /**
19  * Delete GravityView Views, settings, roles, caps, etc.
20  * @see https://youtu.be/FXy_DO6IZOA?t=35s
21  * @since 1.15
22  * @return void
23  */
24  public function fire_everything() {
25  $this->delete_posts();
26  $this->delete_capabilities();
27  $this->delete_entry_meta();
28  $this->delete_entry_notes();
29 
30  // Keep this as last to make sure the GravityView Cache blacklist option is deleted
31  $this->delete_options();
32  }
33 
34  /**
35  * Delete GravityView "approved entry" meta
36  * @since 1.15
37  * @return void
38  */
39  private function delete_entry_meta() {
40  global $wpdb;
41 
42  $meta_table = class_exists( 'GFFormsModel' ) ? GFFormsModel::get_lead_meta_table_name() : $wpdb->prefix . 'rg_lead_meta';
43 
44  $sql = "
45  DELETE FROM $meta_table
46  WHERE (
47  `meta_key` = 'is_approved'
48  );
49  ";
50 
51  $wpdb->query( $sql );
52  }
53 
54  /**
55  * Delete all GravityView-generated entry notes
56  * @since 1.15
57  * @return void
58  */
59  private function delete_entry_notes() {
60  global $wpdb;
61 
62  $notes_table = class_exists( 'GFFormsModel' ) ? GFFormsModel::get_lead_notes_table_name() : $wpdb->prefix . 'rg_lead_notes';
63 
64  $disapproved = __('Disapproved the Entry for GravityView', 'gravityview');
65  $approved = __('Approved the Entry for GravityView', 'gravityview');
66 
67  $sql = $wpdb->prepare( "
68  DELETE FROM $notes_table
69  WHERE (
70  `note_type` = 'gravityview' OR
71  `value` = %s OR
72  `value` = %s
73  );
74  ", $approved, $disapproved );
75 
76  $wpdb->query( $sql );
77  }
78 
79  /**
80  * Delete capabilities added by GravityView
81  * @since 1.15
82  * @return void
83  */
84  private function delete_capabilities() {
86  }
87 
88  /**
89  * Delete all the GravityView custom post type posts
90  * @since 1.15
91  * @return void
92  */
93  private function delete_posts() {
94 
95  $items = get_posts( array(
96  'post_type' => 'gravityview',
97  'post_status' => 'any',
98  'numberposts' => -1,
99  'fields' => 'ids'
100  ) );
101 
102  if ( $items ) {
103  foreach ( $items as $item ) {
104  wp_delete_post( $item, true );
105  }
106  }
107  }
108 
109  /**
110  * Delete GravityView options
111  * @since 1.15
112  * @return void
113  */
114  private function delete_options() {
115  delete_option( 'gravityview_cache_blacklist' );
116  delete_option( 'gv_version_upgraded_from' );
117  delete_transient( 'gravityview_edd-activate_valid' );
118  delete_transient( 'gravityview_edd-deactivate_valid' );
119  delete_transient( 'gravityview_dismissed_notices' );
120  delete_site_transient( 'gravityview_related_plugins' );
121  }
122 }
delete_capabilities()
Delete capabilities added by GravityView.
delete_entry_notes()
Delete all GravityView-generated entry notes.
fire_everything()
Delete GravityView Views, settings, roles, caps, etc.
delete_options()
Delete GravityView options.
delete_posts()
Delete all the GravityView custom post type posts.
delete_entry_meta()
Delete GravityView "approved entry" meta.
Delete GravityView content when GravityView is uninstalled, if the setting is set to "Delete on Unins...