From c5614290aadd8a20e450e2b8f69089a13273d193 Mon Sep 17 00:00:00 2001 From: Moutushi Date: Thu, 21 May 2020 16:26:23 -0400 Subject: [PATCH 1/3] Reset plugin data --- admin/class-gdpr-requests-admin.php | 59 +++++++++++++++++++++++++++++ admin/partials/settings.php | 12 ++++++ includes/class-gdpr.php | 1 + src/js/admin.js | 18 +++++++++ 4 files changed, 90 insertions(+) diff --git a/admin/class-gdpr-requests-admin.php b/admin/class-gdpr-requests-admin.php index 6dd4bcc5..18c585c4 100644 --- a/admin/class-gdpr-requests-admin.php +++ b/admin/class-gdpr-requests-admin.php @@ -366,4 +366,63 @@ public function reassign_content() { wp_send_json_error( esc_html__( 'Something went wrong. Please try again.', 'gdpr' ) ); } + /** + * Reset all plugin data + * @since 1.0.0 + * @author Moutushi Mandal + */ + public function reset_plugin_data() { + if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'gdpr_reset_data' ) ) { // phpcs:ignore + wp_send_json_error( esc_html__( 'We could not verify the security token. Please try again.', 'gdpr' ) ); + } + + // Add new options + update_option( 'gdpr_disable_css', false ); + update_option( 'gdpr_use_recaptcha', false ); + update_option( 'gdpr_recaptcha_site_key', '' ); + update_option( 'gdpr_recaptcha_secret_key', '' ); + update_option( 'gdpr_add_consent_checkboxes_registration', true ); + update_option( 'gdpr_add_consent_checkboxes_checkout', true ); + update_option( + 'gdpr_cookie_popup_content', array( + 'necessary' => array( + 'name' => 'Necessary', + 'status' => 'required', + 'cookies_used' => '', + 'how_we_use' => '', + ), + 'advertising' => array( + 'name' => 'Advertising', + 'status' => 'on', + 'cookies_used' => '', + 'how_we_use' => '', + ), + 'analytics' => array( + 'name' => 'Analytics', + 'status' => 'on', + 'cookies_used' => '', + 'how_we_use' => '', + ), + 'other' => array( + 'name' => 'Other', + 'status' => 'on', + 'cookies_used' => '', + 'how_we_use' => '', + ), + ) + ); + update_option( 'gdpr_refresh_after_preferences_update', true ); + update_option( 'gdpr_enable_privacy_bar', true ); + update_option( 'gdpr_display_cookie_categories_in_bar', false ); + update_option( 'gdpr_hide_from_bots', true ); + update_option( 'gdpr_reconsent_template', 'modal' ); + update_option( 'gdpr_cookie_banner_content', '' ); + update_option( 'gdpr_cookie_privacy_excerpt', '' ); + update_option( 'gdpr_consent_types', '' ); + + GDPR_Audit_Log::log( $user->ID, sprintf( esc_html__( 'Plugin data reset on %1$s.', 'gdpr' ), date( 'm/d/Y' ) ) ); + wp_send_json_success(); + + } + } diff --git a/admin/partials/settings.php b/admin/partials/settings.php index 38247013..eb3bdac8 100755 --- a/admin/partials/settings.php +++ b/admin/partials/settings.php @@ -420,6 +420,18 @@ + +
+

+

+ ' . esc_html__( 'here', 'gdpr' ) . '' + ) + ?> +

Date: Thu, 21 May 2020 16:29:34 -0400 Subject: [PATCH 2/3] Fixed typo error & CSS --- admin/partials/settings.php | 2 +- src/scss/admin.scss | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/admin/partials/settings.php b/admin/partials/settings.php index eb3bdac8..021c058d 100755 --- a/admin/partials/settings.php +++ b/admin/partials/settings.php @@ -422,7 +422,7 @@
-

+

Date: Fri, 22 May 2020 11:28:55 -0400 Subject: [PATCH 3/3] Added privacy bar position to reset data --- admin/class-gdpr-requests-admin.php | 1 + 1 file changed, 1 insertion(+) diff --git a/admin/class-gdpr-requests-admin.php b/admin/class-gdpr-requests-admin.php index 18c585c4..dc25633d 100644 --- a/admin/class-gdpr-requests-admin.php +++ b/admin/class-gdpr-requests-admin.php @@ -419,6 +419,7 @@ public function reset_plugin_data() { update_option( 'gdpr_cookie_banner_content', '' ); update_option( 'gdpr_cookie_privacy_excerpt', '' ); update_option( 'gdpr_consent_types', '' ); + update_option( 'gdpr_privacy_bar_position', 'bottom' ); GDPR_Audit_Log::log( $user->ID, sprintf( esc_html__( 'Plugin data reset on %1$s.', 'gdpr' ), date( 'm/d/Y' ) ) ); wp_send_json_success();