PluginProbe
weForms – Easy Drag & Drop Contact Form Builder For WordPress / 1.2.9
weForms – Easy Drag & Drop Contact Form Builder For WordPress v1.2.9
1.6.7 1.6.8 1.6.9 1.6.12 1.6.13 1.6.14 1.6.15 1.6.16 1.6.17 1.6.18 1.6.19 1.6.2 1.6.20 1.6.21 1.6.22 1.6.23 1.6.24 1.6.25 1.6.26 1.6.27 1.6.28 1.6.3 1.6.4 1.6.5 1.6.6 All 74 releases
weforms / includes / admin / class-privacy.php

class-privacy.php in weForms – Easy Drag & Drop Contact Form Builder For WordPress 1.2.9, at includes/admin/class-privacy.php

282 lines 14.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class WeForms_Privacy
4 *
5 * Add Exporters and Erasers to WP data exporter
6 *
7 * @since 1.2.9
8 */
9 Class WeForms_Privacy {
10
11 private $name = "weForms";
12
13 public function __construct(){
14 add_action( 'admin_init', array( $this, 'add_privacy_message' ) );
15
16 $payment_export = weforms_get_settings( 'privacy_payment_export' );
17 $payment_erase = weforms_get_settings( 'privacy_payment_erase' );
18
19 if ( isset( $payment_export ) && $payment_export ) {
20 add_filter( 'wp_privacy_personal_data_exporters', array( $this, 'register_exporters' ), 10 );
21 }
22 if ( isset( $payment_erase ) && $payment_erase ) {
23 add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'), 10);
24 }
25 }
26
27 function add_privacy_message(){
28 if ( function_exists( 'wp_add_privacy_policy_content' ) ) {
29 $content = $this->get_privacy_message();
30 wp_add_privacy_policy_content( $this->name, $content );
31 }
32 }
33
34 /**
35 * Add privacy policy content for the privacy policy page.
36 */
37 function get_privacy_message() {
38 $content = '
39 <div contenteditable="false">' .
40 '<p class="wp-policy-help">' .
41 __( 'This sample policy includes the basics around what personal data you may be collecting, storing and sharing, as well as who may have access to that data. Depending on what settings are enabled and which additional plugins are used, the specific information shared by your form will vary. We recommend consulting with a lawyer when deciding what information to disclose on your privacy policy.', 'weforms' ) .
42 '</p>' .
43 '</div>' .
44 '<p>' . __( 'We collect information about you during the form submission process on our WordPress website.', 'weforms' ) . '</p>' .
45 '<h2>' . __( 'What we collect and store', 'weforms' ) . '</h2>' .
46 '<p>' . __( 'While you visit our site, we’ll track:', 'weforms' ) . '</p>' .
47 '<ul>' .
48 '<li>' . __( 'Form Fields Data: Forms Fields data includes the available field types when creating a form. We’ll use this to, for example, collect informations like Name, Email and other available fields.', 'weforms' ) . '</li>' .
49 '<li>' . __( 'Location, IP address and browser type: we’ll use this for purposes like estimating taxes and shipping. Also, for reducing fraudulent activities and prevent identity theft while placing orders', 'weforms' ) . '</li>' .
50 '<li>' . __( 'Transaction Details: we’ll ask you to enter this so we can, for instance, provide & regulate subscription packs that you bought and keep track of your payment details for subscription packs!', 'weforms' ) . '</li>' .
51 '</ul>' .
52 '<p>' . __( 'We’ll also use cookies to keep track of form elements while you’re browsing our site.', 'weforms' ) . '</p>' .
53 '<div contenteditable="false">' .
54 '<p class="wp-policy-help">' . __( 'Note: you may want to further detail your cookie policy, and link to that section from here.', 'weforms' ) . '</p>' .
55 '</div>' .
56 '<p>' . __( 'When you fill up a form, we’ll ask you to provide information including your name, billing address, shipping address, email address, phone number, credit card/payment details and optional account information like username and password and any other form fields found in the form building options. We’ll use this information for purposes, such as, to:', 'weforms' ) . '</p>' .
57 '<ul>' .
58 '<li>' . __( 'Send you information about your account and order', 'weforms' ) . '</li>' .
59 '<li>' . __( 'Respond to your requests, including transaction details and complaints', 'weforms' ) . '</li>' .
60 '<li>' . __( 'Process payments and prevent fraud', 'weforms' ) . '</li>' .
61 '<li>' . __( 'Set up your account', 'weforms' ) . '</li>' .
62 '<li>' . __( 'Comply with any legal obligations we have, such as calculating taxes', 'weforms' ) . '</li>' .
63 '<li>' . __( 'Improve our form offerings', 'weforms' ) . '</li>' .
64 '<li>' . __( 'Send you marketing messages, if you choose to receive them', 'weforms' ) . '</li>' .
65 '<li>' . __( 'Or any other service the built form was created to comply with and it’s necessary information', 'weforms' ) . '</li>' .
66 '</ul>' .
67 '<p>' . __( 'If you create an account, we will store your name, address, email and phone number, which will be used to populate the form fields for future submissions.', 'weforms' ) . '</p>' .
68 '<p>' . __( 'We generally store information about you for as long as we need the information for the purposes for which we collect and use it, and we are not legally required to continue keeping it. For example, we will store form submission information for XXX years for tax, accounting and marketing purposes. This includes your name, email address and billing and shipping addresses.', 'weforms' ) . '</p>' .
69 '<h2>' . __( 'Who on our team has access', 'weforms' ) . '</h2>' .
70 '<p>' . __( 'Members of our team have access to the information you provide us. For example, Administrators and Editors and any body else who has permission can access:', 'weforms' ) . '</p>' .
71 '<ul>' .
72 '<li>' . __( 'Form submission information and other details related to it', 'weforms' ) . '</li>' .
73 '<li>' . __( 'Customer information like your name, email address, and billing and shipping information.', 'weforms' ) . '</li>' .
74 '</ul>' .
75 '<p>' . __( 'Our team members have access to this information to help fulfill transactions and support you.', 'weforms' ) . '</p>' .
76 '<h2>' . __( 'What we share with others', 'weforms' ) . '</h2>' .
77 '<div contenteditable="false">' .
78 '<p class="wp-policy-help">' . __( 'In this section you should list who you’re sharing data with, and for what purpose. This could include, but may not be limited to, analytics, marketing, payment gateways, shipping providers, and third party embeds.', 'weforms' ) . '</p>' .
79 '</div>' .
80 '<p>' . __( 'We share information with third parties who help us provide our orders and store services to you; for example --', 'weforms' ) . '</p>' .
81 '<h3>' . __( 'Payments', 'weforms' ) . '</h3>' .
82 '<div contenteditable="false">' .
83 '<p class="wp-policy-help">' . __( 'In this subsection you should list which third party payment processors you’re using to take payments on your site since these may handle customer data. We’ve included PayPal as an example, but you should remove this if you’re not using PayPal.', 'weforms' ) . '</p>' .
84 '</div>' .
85 '<p>' . __( 'We accept payments through PayPal. When processing payments, some of your data will be passed to PayPal, including information required to process or support the payment, such as the purchase total and billing information.', 'weforms' ) . '</p>' .
86 '<p>' . __( 'Please see the <a href="https://www.paypal.com/us/webapps/mpp/ua/privacy-full">PayPal Privacy Policy</a> for more details.', 'weforms' ) . '</p>'.
87 '<p>' . __( 'Also, we accept payments through Stripe. When processing payments, some of your data will be passed to Stripe, including information required to process or support the payment, such as the purchase total and billing information.', 'weforms' ) . '</p>' .
88 '<p>' . __( 'Please see the <a href="https://stripe.com/us/privacy">Stripe Privacy Policy</a> for more details.', 'weforms' ) . '</p>'.
89 '<h3>' . __( 'Available Modules', 'weforms' ) . '</h3>' .
90 '<p>' . __( 'In this subsection you should list which third party modules you’re using to increase the functionality of your created forms using weForms since these may handle customer data.', 'weforms' ) . '</p>' .
91 '<p>' . __( 'weForms Pro comes with support for modules like HubSpot, Constant Contact, Salesforce, PayPal, Stripe, Google Analytics, ConvertKit, Zapier, Campaign Monitor, Aweber, MailChimp, Zoho, Trello, SMS Notification(Using Twilio, Nexmo and other popular gateways), Google Sheets, GetResponse. Data sent to those platforms will be handled by their own privacy policy.', 'weforms' ) . '</p>' .
92 '<p>' . __( 'Please note any future modules that will be added will have some data transferred to their own platform which falls in their own data policy.', 'weforms' ) . '</p>' .
93 '<p>' . __( 'As an example while using MailChimp for your marketing email automation service by integrating it with weForms, some of your data will be passed to MailChimp, including information required to process or support the email marketing services, such as name, email address and any other information that you intend to pass or collect including all collected information through subscription. ', 'weforms' ) . '</p>' .
94 '<p>' . __( 'Please see the <a href="https://mailchimp.com/legal/privacy/">MailChimp Privacy Policy</a> for more details.', 'weforms' ) . '</p>';
95
96 return apply_filters( 'weforms_privacy_policy_content', $content );
97 }
98
99 /**
100 * Register WeForms Exporter to export data
101 *
102 * @param $exporters
103 *
104 * @return array
105 */
106 function register_exporters( $exporters ) {
107 $exporters['weforms-transaction-data-export'] = array(
108 'exporter_friendly_name' => __( 'weForms Transaction Data', 'weforms' ),
109 'callback' => array( 'WeForms_Privacy', 'export_payment_data'),
110 );
111
112 return apply_filters( 'weforms_privacy_register_exporters', $exporters );
113 }
114
115 /**
116 * Register WeForms Eraser to delete data
117 *
118 * @param $erasers
119 *
120 * @return array
121 */
122 function register_erasers( $erasers ) {
123 $erasers['weforms-transaction-data-export'] = array(
124 'eraser_friendly_name' => __( 'weForms Transaction Data', 'weforms' ),
125 'callback' => array( 'WeForms_Privacy', 'erase_payment_data'),
126 );
127
128 return apply_filters( 'weforms_privacy_register_erasers', $erasers );
129 }
130
131 /**
132 * Get current user id
133 *
134 */
135 public static function get_user_id() {
136 if ( is_user_logged_in() ) {
137 $user = get_current_user_id();
138 return $user;
139 }
140 return false;
141 }
142
143 /**
144 * Finds and exports payment data
145 *
146 *
147 * @return array An array of data in name value pairs
148 */
149 public static function export_payment_data(){
150
151 $data_to_export = array();
152 $weforms_user = self::get_user_id();
153
154 $payment_data = self::get_form_payments( $weforms_user );
155
156 $idx = 0;
157
158 if ( !empty( $payment_data ) ) {
159 foreach ( $payment_data as $pay_data ) {
160 $data_to_export[] = array(
161 'group_id' => 'weforms-payment-data',
162 'group_label' => __( 'weForms Payment Data', 'weforms' ),
163 'item_id' => "weforms-payment-{$idx}",
164 'data' => self::process_payment_data( $pay_data ),
165 );
166 $idx++;
167 }
168 }
169
170 /**
171 * Filters the export data array
172 *
173 * @param array
174 */
175 $data_to_export = apply_filters( 'weforms_privacy_export_data', $data_to_export, $weforms_user );
176
177 return array(
178 'data' => $data_to_export,
179 'done' => true
180 );
181 }
182
183 /**
184 * Anonymize payment data of a user
185 *
186 * @return array
187 */
188 public static function erase_payment_data(){
189 global $wpdb;
190
191 $weforms_user = self::get_user_id();
192
193 $query = "Update " . $wpdb->prefix . 'weforms_payments' . " Set `user_id` = 0 WHERE `user_id` = {$weforms_user}";
194 $wpdb->query( $query );
195
196 $erased = apply_filters( 'weforms_erase_payment_data', array(
197 'items_removed' => true,
198 'items_retained' => false,
199 'messages' => array(),
200 'done' => true,
201 ), $weforms_user
202 );
203
204 return $erased;
205
206 }
207
208 /**
209 * Get payments by a user_id
210 *
211 * @param int $form_id
212 * @param array $args
213 *
214 * @return Object
215 */
216 public static function get_form_payments( $user_id ) {
217 global $wpdb;
218
219 $query = 'SELECT * FROM ' . $wpdb->prefix . 'weforms_payments' .
220 ' WHERE user_id = ' . $user_id ;
221
222 $results = $wpdb->get_results( $query );
223
224 return $results;
225 }
226
227 public static function process_payment_data( $payment_data ) {
228
229 $field_value = unserialize( $payment_data->payment_data );
230
231 $serialized_value = array(); $transaction_data = array();
232
233 $user_data = get_userdata( $payment_data->user_id );
234
235 if ( is_array( $field_value ) ) {
236
237 foreach ( $field_value as $key => $sfv ) {
238 $sfv = str_replace( array( '_', '-' ), ' ', $key ) . ': ' . $sfv;
239 $sfv = ucwords( $sfv );
240 $serialized_value[] = $sfv;
241 }
242
243 $payment_data->payment_data = implode( '<br> ', $serialized_value );
244 }
245 if ( !empty( $user_data ) && !empty( $payment_data ) ) {
246 $transaction_data = array(
247 array(
248 'name' => __( 'User', 'weforms' ),
249 'value' => $user_data->user_login,
250 ),
251 array(
252 'name' => __( 'Total', 'weforms' ),
253 'value' => $payment_data->total,
254 ),
255 array(
256 'name' => __( 'Gateway', 'weforms' ),
257 'value' => $payment_data->gateway,
258 ),
259 array(
260 'name' => __( 'Transaction ID', 'weforms' ),
261 'value' => $payment_data->transaction_id,
262 ),
263 array(
264 'name' => __( 'Payment Status', 'weforms' ),
265 'value' => $payment_data->status,
266 ),
267 array(
268 'name' => __( 'Payment Data', 'weforms' ),
269 'value' => $payment_data->payment_data,
270 ),
271 array(
272 'name' => __( 'Transaction Time', 'weforms' ),
273 'value' => $payment_data->created_at,
274 ),
275 );
276 }
277
278 return apply_filters( 'weforms_export_payment_data', $transaction_data );
279 }
280
281 }
282