|
5 | 5 | namespace WPGraphQL\Logging\Admin\Settings\Fields\Tab; |
6 | 6 |
|
7 | 7 | use WPGraphQL\Logging\Admin\Settings\Fields\Field\Checkbox_Field; |
| 8 | +use WPGraphQL\Logging\Admin\Settings\Fields\Field\Select_Field; |
8 | 9 | use WPGraphQL\Logging\Admin\Settings\Fields\Field\Text_Input_Field; |
9 | 10 | use WPGraphQL\Logging\Admin\Settings\Fields\Field\Text_Integer_Field; |
10 | 11 |
|
@@ -38,11 +39,32 @@ class Data_Management_Tab implements Settings_Tab_Interface { |
38 | 39 | public const DATA_SANITIZATION_ENABLED = 'data_sanitization_enabled'; |
39 | 40 |
|
40 | 41 | /** |
41 | | - * The field ID for the data sanitization fields. |
| 42 | + * The field ID for the data sanitization method. |
42 | 43 | * |
43 | 44 | * @var string |
44 | 45 | */ |
45 | | - public const DATA_SANITIZATION_FIELDS = 'data_sanitization_fields'; |
| 46 | + public const DATA_SANITIZATION_METHOD = 'data_sanitization_method'; |
| 47 | + |
| 48 | + /** |
| 49 | + * The field ID for the custom fields to sanitize. |
| 50 | + * |
| 51 | + * @var string |
| 52 | + */ |
| 53 | + public const DATA_SANITIZATION_CUSTOM_FIELD_ANONYMIZE = 'data_sanitization_custom_field_anonymize'; |
| 54 | + |
| 55 | + /** |
| 56 | + * The field ID for the custom fields to remove. |
| 57 | + * |
| 58 | + * @var string |
| 59 | + */ |
| 60 | + public const DATA_SANITIZATION_CUSTOM_FIELD_REMOVE = 'data_sanitization_custom_field_remove'; |
| 61 | + |
| 62 | + /** |
| 63 | + * The field ID for the custom fields to truncate. |
| 64 | + * |
| 65 | + * @var string |
| 66 | + */ |
| 67 | + public const DATA_SANITIZATION_CUSTOM_FIELD_TRUNCATE = 'data_sanitization_custom_field_truncate'; |
46 | 68 |
|
47 | 69 | /** |
48 | 70 | * Get the name/identifier of the tab. |
@@ -95,16 +117,44 @@ public function get_fields(): array { |
95 | 117 | ); |
96 | 118 |
|
97 | 119 |
|
98 | | - $fields[ self::DATA_SANITIZATION_FIELDS ] = new Text_Input_Field( |
99 | | - self::DATA_SANITIZATION_FIELDS, |
| 120 | + $fields[ self::DATA_SANITIZATION_METHOD ] = new Select_Field( |
| 121 | + self::DATA_SANITIZATION_METHOD, |
100 | 122 | $this->get_name(), |
101 | | - __( 'Data Sanitization Fields', 'wpgraphql-logging' ), |
| 123 | + __( 'Data Sanitization Method', 'wpgraphql-logging' ), |
| 124 | + [ |
| 125 | + 'recommended' => __( 'Recommended', 'wpgraphql-logging' ), |
| 126 | + 'custom' => __( 'Custom', 'wpgraphql-logging' ), |
| 127 | + ], |
102 | 128 | '', |
103 | | - __( 'A comma-separated list of fields to sanitize for WPGraphQL logging.', 'wpgraphql-logging' ), |
104 | | - __( 'e.g., user.email, user.name, user.firstName, user.lastName', 'wpgraphql-logging' ), |
105 | | - 'user_email, user_pass, user_login, user_status, display_name, nickname, first_name, last_name' |
| 129 | + __( 'Select the method to use for data sanitization.', 'wpgraphql-logging' ), |
| 130 | + false |
| 131 | + ); |
| 132 | + |
| 133 | + |
| 134 | + $fields[ self::DATA_SANITIZATION_CUSTOM_FIELD_ANONYMIZE ] = new Text_Input_Field( |
| 135 | + self::DATA_SANITIZATION_CUSTOM_FIELD_ANONYMIZE, |
| 136 | + $this->get_name(), |
| 137 | + __( 'Custom Fields to Anonymize', 'wpgraphql-logging' ), |
| 138 | + 'wpgraphql-logging-custom', |
| 139 | + __( 'Comma-separated list of custom fields to anonymize.', 'wpgraphql-logging' ), |
| 140 | + 'e.g., user_email, user_ip' |
| 141 | + ); |
| 142 | + |
| 143 | + $fields[ self::DATA_SANITIZATION_CUSTOM_FIELD_REMOVE ] = new Text_Input_Field( |
| 144 | + self::DATA_SANITIZATION_CUSTOM_FIELD_REMOVE, |
| 145 | + $this->get_name(), |
| 146 | + __( 'Custom Fields to Remove', 'wpgraphql-logging' ), |
| 147 | + 'wpgraphql-logging-custom', |
| 148 | + __( 'Comma-separated list of custom fields to remove.', 'wpgraphql-logging' ), |
106 | 149 | ); |
107 | 150 |
|
| 151 | + $fields[ self::DATA_SANITIZATION_CUSTOM_FIELD_TRUNCATE ] = new Text_Input_Field( |
| 152 | + self::DATA_SANITIZATION_CUSTOM_FIELD_TRUNCATE, |
| 153 | + $this->get_name(), |
| 154 | + __( 'Custom Fields to Truncate', 'wpgraphql-logging' ), |
| 155 | + 'wpgraphql-logging-custom', |
| 156 | + __( 'Comma-separated list of custom fields to truncate.', 'wpgraphql-logging' ), |
| 157 | + ); |
108 | 158 |
|
109 | 159 | return apply_filters( 'wpgraphql_logging_data_management_fields', $fields ); |
110 | 160 | } |
|
0 commit comments