PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.13
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.13
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / admin / settings / class-charitable-privacy-settings.php

class-charitable-privacy-settings.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.8.13, at includes/admin/settings/class-charitable-privacy-settings.php

253 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Charitable Privacy Settings UI.
4 *
5 * @package Charitable/Classes/Charitable_Privacy_Settings
6 * @author David Bisset
7 * @copyright Copyright (c) 2023, WP Charitable LLC
8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 * @since 1.6.0
10 * @version 1.8.3
11 */
12
13 // Exit if accessed directly.
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 if ( ! class_exists( 'Charitable_Privacy_Settings' ) ) :
19
20 /**
21 * Charitable_Privacy_Settings
22 *
23 * @since 1.6.0
24 */
25 final class Charitable_Privacy_Settings {
26
27 /**
28 * The single instance of this class.
29 *
30 * @since 1.6.0
31 *
32 * @var Charitable_Privacy_Settings|null
33 */
34 private static $instance = null;
35
36 /**
37 * Create object instance.
38 *
39 * @since 1.6.0
40 */
41 private function __construct() {
42 }
43
44 /**
45 * Returns and/or create the single instance of this class.
46 *
47 * @since 1.6.0
48 *
49 * @return Charitable_Privacy_Settings
50 */
51 public static function get_instance() {
52 if ( is_null( self::$instance ) ) {
53 self::$instance = new self();
54 }
55
56 return self::$instance;
57 }
58
59 /**
60 * Add the privacy tab settings fields.
61 *
62 * @since 1.6.0
63 *
64 * @return array<string,array>
65 */
66 public function add_privacy_fields() {
67 if ( ! charitable_is_settings_view( 'privacy' ) ) {
68 return array();
69 }
70
71 $data_fields = $this->get_user_donation_field_options();
72
73 return array(
74 'section' => array(
75 'title' => '',
76 'type' => 'hidden',
77 'priority' => 10000,
78 'value' => 'privacy',
79 ),
80 'section_privacy' => array(
81 'title' => __( 'Privacy', 'charitable' ),
82 'type' => 'heading',
83 'class' => 'section-heading',
84 'priority' => 10,
85 ),
86 'section_privacy_description' => array(
87 'type' => 'content',
88 'priority' => 20,
89 'content' => '<div class="charitable-settings-notice">'
90 . '<p>' . __( 'Charitable stores personal data such as donors\' names, email addresses, addresses and phone numbers in your database. Donors may request to have their personal data erased, but you may be legally required to retain some personal data for donations made within a certain time. Below you can control how long personal data is retained for at a minimum, as well as which data fields must be retained.', 'charitable' ) . '</p>'
91 . '<p><a href="https://wpcharitable.com/documentation/charitable-user-privacy/?utm_source=WordPress&utm_campaign=WP+Charitable&utm_medium=Settings+Privacy+Tab+Page&utm_content=Read+More+About+Privacy">' . __( 'Read more about Charitable & user privacy', 'charitable' ) . '</a></p>'
92 . '</div>',
93 ),
94 'minimum_data_retention_period' => array(
95 'label_for' => __( 'Minimum Data Retention Period', 'charitable' ),
96 'type' => 'select',
97 'help' => sprintf(
98 /* translators: %1$s: HTML strong tag. %2$s: HTML closing strong tag. %1$s: HTML break tag. */
99 __( 'Prevent personal data from being erased for donations made within a certain amount of time.%3$sChoose %1$sNone%2$s to allow the personal data of any donation to be erased.%3$sChoose %1$sForever%2$s to prevent any personal data from being erased from donations, regardless of how long ago they were made.', 'charitable' ),
100 '<strong>',
101 '</strong>',
102 '<br />'
103 ),
104 'priority' => 25,
105 'default' => 2,
106 'options' => array(
107 0 => __( 'None', 'charitable' ),
108 1 => __( 'One year', 'charitable' ),
109 2 => __( 'Two years', 'charitable' ),
110 3 => __( 'Three years', 'charitable' ),
111 4 => __( 'Four years', 'charitable' ),
112 5 => __( 'Five years', 'charitable' ),
113 6 => __( 'Six years', 'charitable' ),
114 7 => __( 'Seven years', 'charitable' ),
115 8 => __( 'Eight years', 'charitable' ),
116 9 => __( 'Nine years', 'charitable' ),
117 10 => __( 'Ten years', 'charitable' ),
118 'endless' => __( 'Forever', 'charitable' ),
119 ),
120 ),
121 'data_retention_fields' => array(
122 'label_for' => __( 'Retained Data', 'charitable' ),
123 'type' => 'multi-checkbox',
124 'priority' => 30,
125 'default' => array_keys( $data_fields ),
126 'options' => $data_fields,
127 'help' => __( 'The checked fields will not be erased fields when personal data is erased for a donation made within the Minimum Data Retention Period.', 'charitable' ),
128 'attrs' => array(
129 'data-trigger-key' => '#charitable_settings_minimum_data_retention_period',
130 'data-trigger-value' => '!0',
131 ),
132 ),
133 'contact_consent' => array(
134 'title' => __( 'Contact Consent Field', 'charitable' ),
135 'type' => 'checkbox',
136 'priority' => 32,
137 'default' => '0',
138 'help' => __( 'Display a checkbox asking people for their consent to being contacted when they donate, register an account, or manage their profile.', 'charitable' ),
139 ),
140 'contact_consent_required' => array(
141 'label_for' => __( 'Make Consent Field Required For Donation Forms', 'charitable' ),
142 'type' => 'checkbox',
143 'help' => __( 'Requires the user acknowledge consent before submitting a donation, which might be required for some countries or situations.', 'charitable' ),
144 'priority' => 34,
145 'default' => false,
146 ),
147 'contact_consent_label' => array(
148 'title' => __( 'Contact Consent Label', 'charitable' ),
149 'type' => 'textarea',
150 'priority' => 36,
151 'default' => __( 'Yes, I am happy for you to contact me via email or phone.', 'charitable' ),
152 'help' => __( 'A short statement describing how you would like to contact people.', 'charitable' ),
153 ),
154 'privacy_policy_enabled' => array(
155 'title' => __( 'Privacy Policy Field', 'charitable' ),
156 'type' => 'checkbox',
157 'priority' => 40,
158 'default' => charitable_get_option( 'privacy_policy_page', 0 ) ? true : false,
159 'help' => __( 'Display a field showing the privacy policy (must have a policy page set and terms added below).', 'charitable' ),
160 ),
161 'privacy_policy' => array(
162 'title' => __( 'Privacy Policy', 'charitable' ),
163 'type' => 'textarea',
164 'priority' => 45,
165 'default' => __( 'Your personal data will be used to process your donation, support your experience throughout this website, and for other purposes described in our [privacy_policy].', 'charitable' ),
166 'help' => sprintf(
167 /* translators: %1$s: HTML code tag. %2$s: HTML closing code tag. %3$s: HTML anchor tag. %4$s: HTML closing anchor tag. */
168 __( 'Privacy policy information to be seen when individuals donate, register an account, or manage their profile. Use <code>[privacy_policy]</code> to link to the page assigned in <a href="%s">general settings</a>.', 'charitable' ),
169 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
170 ),
171 ),
172 'terms_and_conditions_enabled' => array(
173 'title' => __( 'Terms And Conditions Field', 'charitable' ),
174 'type' => 'checkbox',
175 'priority' => 50,
176 'default' => charitable_get_option( 'terms_conditions_page', 0 ) ? true : false,
177 'help' => __( 'Display a field showing the terms and conditions (must have a terms page set and terms added below).', 'charitable' ),
178 ),
179 'terms_conditions' => array(
180 'title' => __( 'Terms And Conditions', 'charitable' ),
181 'type' => 'textarea',
182 'priority' => 55,
183 'default' => __( 'I have read and agree to the website [terms].', 'charitable' ),
184 'help' => sprintf(
185 /* translators: %1$s: HTML code tag. %2$s: HTML closing code tag. %3$s: HTML anchor tag. %4$s: HTML closing anchor tag. */
186 __( 'Terms and conditions statement to display on donation forms. Use <code>[terms]</code> to link to the page assigned in <a href="%s">general settings</a>.', 'charitable' ),
187 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
188 ),
189 ),
190 );
191 }
192
193 /**
194 * Return the list of user donation field options.
195 *
196 * @since 1.6.0
197 *
198 * @return string[]
199 */
200 protected function get_user_donation_field_options() {
201 $fields = charitable()->donation_fields()->get_data_type_fields( 'user' );
202
203 return array_combine(
204 array_keys( $fields ),
205 wp_list_pluck( $fields, 'label' )
206 );
207 }
208
209 /**
210 * Sanitize the privacy policy field to prevent XSS attacks.
211 *
212 * @since 1.8.6.2
213 *
214 * @param mixed $value The submitted value.
215 * @param array $field The field configuration.
216 * @param array $submitted All submitted data.
217 * @return string
218 */
219 public function sanitize_privacy_policy_field( $value, $field, $submitted ) { // phpcs:ignore
220 return wp_kses_post( $value );
221 }
222
223 /**
224 * Sanitize the terms and conditions field to prevent XSS attacks.
225 *
226 * @since 1.8.6.2
227 *
228 * @param mixed $value The submitted value.
229 * @param array $field The field configuration.
230 * @param array $submitted All submitted data.
231 * @return string
232 */
233 public function sanitize_terms_conditions_field( $value, $field, $submitted ) { // phpcs:ignore
234 return wp_kses_post( $value );
235 }
236
237 /**
238 * Sanitize the contact consent label field to prevent XSS attacks.
239 *
240 * @since 1.8.6.2
241 *
242 * @param mixed $value The submitted value.
243 * @param array $field The field configuration.
244 * @param array $submitted All submitted data.
245 * @return string
246 */
247 public function sanitize_contact_consent_label_field( $value, $field, $submitted ) { // phpcs:ignore
248 return wp_kses_post( $value );
249 }
250 }
251
252 endif;
253