-
Notifications
You must be signed in to change notification settings - Fork 43
Tkgdpr 36 reset data #265
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Tkgdpr 36 reset data #265
Changes from all commits
ddd75db
a429f66
5d0aa1d
abc1275
c561429
f7b8865
3e35e44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,4 +366,64 @@ 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 <moutushi82@gmail.com> | ||
| */ | ||
| public function reset_plugin_data() { | ||
| if ( ! isset( $_POST['nonce'] ) || ! wp_verify_nonce( sanitize_key( wp_unslash( $_POST['nonce'] ) ), 'gdpr_reset_data' ) ) { // phpcs:ignore | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gdpr_reset_settings |
||
| 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', '' ); | ||
| 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' ) ) ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rephrase this to "Plugin Settings were reset on %1$s" |
||
| wp_send_json_success(); | ||
|
|
||
| } | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -420,6 +420,18 @@ | |
| <?php endforeach ?> | ||
| <?php endif ?> | ||
| </div> | ||
|
|
||
| <hr> | ||
| <h2><?php esc_html_e( 'Reset Data', 'gdpr' ); ?></h2> | ||
| <p> | ||
| <?php | ||
| echo sprintf( | ||
| /* translators: External link with instructions on how to proceed. */ | ||
| esc_html__( 'To reset plugin data please click %s.', 'gdpr' ), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "To reset these settings, please click %s" |
||
| '<a href="#" class="gdpr-reset-data" data-nonce="' . esc_attr( wp_create_nonce( 'gdpr_reset_data' ) ) .'">' . esc_html__( 'here', 'gdpr' ) . '</a>' | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gdpr-reset-settings |
||
| ) | ||
| ?> | ||
| </p> | ||
| <?php | ||
| do_action( 'gdpr_extra_settings' ); | ||
| submit_button(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -216,6 +216,7 @@ private function define_admin_hooks() { | |
| add_action( 'admin_post_gdpr_mark_resolved', array( $requests_admin, 'mark_resolved' ) ); | ||
| add_action( 'wp_ajax_gdpr_anonymize_comments', array( $requests_admin, 'anonymize_comments' ) ); | ||
| add_action( 'wp_ajax_gdpr_reassign_content', array( $requests_admin, 'reassign_content' ) ); | ||
| add_action( 'wp_ajax_gdpr_reset_plugin_data', array( $requests_admin, 'reset_plugin_data' ) ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use the new function name
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and it should also bee wp_ajax_gdpr_reset_plugin_settings |
||
|
|
||
| // CRON JOBS | ||
| add_action( 'clean_gdpr_requests', array( $requests, 'clean_requests' ) ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -315,4 +315,22 @@ $( function() { | |
| ); | ||
| } ); | ||
|
|
||
| $( document ).on( 'click', '.gdpr-reset-data', function( e ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .gdpr-reset-settings |
||
| e.preventDefault(); | ||
| if ( confirm( 'Are you sure! This action will delete all previous settings.' ) ) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Are you sure? This action will delete all existing settings."
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This also needs to be translatable. |
||
| const nonce = $( this ).data( 'nonce' ); | ||
| $.post( | ||
| ajaxurl, | ||
| { | ||
| action: 'gdpr_reset_plugin_data', | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. gdpr_reset_plugin_settings |
||
| nonce: nonce | ||
| }, | ||
| function( res ) { | ||
| alert( 'All data deleted successfully!' ); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All settings deleted successfully! This also needs to be translatable. |
||
| location.reload(); | ||
| } | ||
| ); | ||
|
|
||
| } | ||
| }); | ||
| } ); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -220,3 +220,7 @@ | |
| } | ||
| } | ||
| } | ||
|
|
||
| .gdpr-reset-data { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. .gdpr-reset-settings |
||
| color: red; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please rename to reset_plugin_settings