Skip to content

Commit fbe6975

Browse files
committed
Add uninstall option and update settings labels
Added documentation and code to support optional database cleanup on plugin deactivation via the WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN constant. Updated admin settings field labels for clarity in the Basic Configuration tab.
1 parent 1c7daf8 commit fbe6975

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed

plugins/wpgraphql-logging/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,35 @@ Once you have the composer repository setup, please run `composer req wpengine/w
4848

4949
Plugin should start logging data, once activated.
5050

51+
---
52+
53+
## Uninstallation and Data Cleanup
54+
55+
By default, WPGraphQL Logging preserves all logged data when the plugin is deactivated to prevent accidental data loss. If you want to completely remove all plugin data (including database tables) when deactivating the plugin, you must explicitly enable this behavior.
56+
57+
### Enabling Database Cleanup on Deactivation
58+
59+
To enable automatic database cleanup when the plugin is deactivated, add the following constant to your `wp-config.php` file or in a must-use plugin:
60+
61+
```php
62+
define( 'WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN', true );
63+
```
64+
65+
> [!WARNING]
66+
> **Data Loss Warning**: When `WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN` is defined as `true`, deactivating the plugin will permanently delete all logged data and drop the plugin's database tables. This action is irreversible.
67+
68+
### Manual Data Cleanup
69+
70+
If you prefer to manually clean up data without defining the constant, you can:
71+
72+
1. Use the plugin's admin interface to clear logs (when available)
73+
2. Manually drop the database table: `{$wpdb->prefix}wpgraphql_logging`
74+
3. Remove plugin options from the WordPress options table
75+
76+
---
77+
78+
@TODO add more info once we have configuration setup.
79+
5180
@TODO add more info once we have configuration setup.
5281

5382

plugins/wpgraphql-logging/src/Admin/Settings/Fields/Tab/Basic_Configuration_Tab.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function get_fields(): array {
110110
$fields[ self::EXCLUDE_QUERY ] = new Text_Input_Field(
111111
self::EXCLUDE_QUERY,
112112
$this->get_name(),
113-
__( 'Exclude Query', 'wpgraphql-logging' ),
113+
__( 'Exclude Queries', 'wpgraphql-logging' ),
114114
'',
115115
__( 'Comma-separated list of GraphQL query names to exclude from logging.', 'wpgraphql-logging' ),
116116
__( 'e.g., __schema,SeedNode,__typename', 'wpgraphql-logging' )
@@ -119,7 +119,7 @@ public function get_fields(): array {
119119
$fields[ self::ADMIN_USER_LOGGING ] = new Checkbox_Field(
120120
self::ADMIN_USER_LOGGING,
121121
$this->get_name(),
122-
__( 'Log only for admin users', 'wpgraphql-logging' ),
122+
__( 'Admin User Logging', 'wpgraphql-logging' ),
123123
'',
124124
__( 'Log only for admin users.', 'wpgraphql-logging' )
125125
);

plugins/wpgraphql-logging/src/Plugin.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,13 @@ public static function activate(): void {
101101

102102
/**
103103
* Deactivation callback for the plugin.
104+
*
105+
* @since 0.0.1
104106
*/
105107
public static function deactivate(): void {
106-
// @TODO: Add configuration to determine if the table should be dropped on deactivation.
108+
if ( ! defined( 'WP_GRAPHQL_LOGGING_UNINSTALL_PLUGIN' ) ) {
109+
return;
110+
}
107111
DatabaseEntity::drop_table();
108112
}
109113

0 commit comments

Comments
 (0)