data_store = $data_store; } protected function get_nonce_name() { return self::ACTION_NAME; } private function reset_setup_wizard_data() { $this->data_store->save( Save_Plugin_Settings_Endpoint::PARAM_SETUP_WIZARD_SHOULD_DISPLAY, 'true' ); $this->data_store->save( Save_Plugin_Settings_Endpoint::PARAM_LICENSE_KEY, '' ); update_option( 'gravitysmtp_generic', '' ); update_option( 'gravitysmtp_mailgun', '' ); update_option( 'gravitysmtp_postmark', '' ); update_option( 'gravitysmtp_sendgrid', '' ); wp_send_json_success( __( 'Setup wizard data reset.', 'gravitysmtp' ) ); } public function handle() { if ( ! $this->validate() ) { wp_send_json_error( __( 'Missing required parameters.', 'gravitysmtp' ), 400 ); } $target = filter_input( INPUT_POST, self::PARAM_TARGET ); $target = htmlspecialchars( $target ); // handle data clean up or resets here switch( $target ) { case 'setup_wizard': $this->reset_setup_wizard_data(); break; default: break; } } protected function validate() { if ( ! parent::validate() ) { return false; } if ( empty( $_REQUEST[ self::PARAM_TARGET ] ) ) { return false; } return true; } }