← All changes
|
includes/admin/settings/class-charitable-privacy-settings.php
+105
-25
1.7.0
→
1.8.13
View file →
| @@ -3,12 +3,12 @@ | ||
| 3 | 3 | * Charitable Privacy Settings UI. |
| 4 | 4 | * |
| 5 | 5 | * @package Charitable/Classes/Charitable_Privacy_Settings |
| 6 | 6 | * @author David Bisset |
| 7 | - * @copyright Copyright (c) 2022, WP Charitable LLC | |
| 7 | + * @copyright Copyright (c) 2023, WP Charitable LLC | |
| 8 | 8 | * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 | 9 | * @since 1.6.0 |
| 10 | - * @version 1.6.0 | |
| 10 | + * @version 1.8.3 | |
| 11 | 11 | */ |
| 12 | 12 | |
| 13 | 13 | // Exit if accessed directly. |
| 14 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| @@ -76,13 +76,19 @@ | ||
| 76 | 76 | 'type' => 'hidden', |
| 77 | 77 | 'priority' => 10000, |
| 78 | 78 | 'value' => 'privacy', |
| 79 | 79 | ), |
| 80 | + 'section_privacy' => array( | |
| 81 | + 'title' => __( 'Privacy', 'charitable' ), | |
| 82 | + 'type' => 'heading', | |
| 83 | + 'class' => 'section-heading', | |
| 84 | + 'priority' => 10, | |
| 85 | + ), | |
| 80 | 86 | 'section_privacy_description' => array( |
| 81 | 87 | 'type' => 'content', |
| 82 | 88 | 'priority' => 20, |
| 83 | 89 | 'content' => '<div class="charitable-settings-notice">' |
| 84 | - . '<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.' ) . '</p>' | |
| 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>' | |
| 85 | 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>' |
| 86 | 92 | . '</div>', |
| 87 | 93 | ), |
| 88 | 94 | 'minimum_data_retention_period' => array( |
| @@ -89,9 +95,9 @@ | ||
| 89 | 95 | 'label_for' => __( 'Minimum Data Retention Period', 'charitable' ), |
| 90 | 96 | 'type' => 'select', |
| 91 | 97 | 'help' => sprintf( |
| 92 | 98 | /* translators: %1$s: HTML strong tag. %2$s: HTML closing strong tag. %1$s: HTML break tag. */ |
| 93 | - __( '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.' ), | |
| 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' ), | |
| 94 | 100 | '<strong>', |
| 95 | 101 | '</strong>', |
| 96 | 102 | '<br />' |
| 97 | 103 | ), |
| @@ -123,33 +129,65 @@ | ||
| 123 | 129 | 'data-trigger-key' => '#charitable_settings_minimum_data_retention_period', |
| 124 | 130 | 'data-trigger-value' => '!0', |
| 125 | 131 | ), |
| 126 | 132 | ), |
| 127 | - 'privacy_policy' => array( | |
| 128 | - 'title' => __( 'Privacy Policy', 'charitable' ), | |
| 129 | - 'type' => 'textarea', | |
| 130 | - 'priority' => 35, | |
| 131 | - '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].', | |
| 132 | - 'help' => 'Information about your website privacy policy for people to see when they donate, register an account, or manage their profile. Leave empty to disable.' | |
| 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' ), | |
| 133 | 139 | ), |
| 134 | - 'donation_form_minimal_fields' => array( | |
| 135 | - 'title' => __( 'Contact Consent Field', 'charitable' ), | |
| 136 | - 'type' => 'radio', | |
| 137 | - 'priority' => 40, | |
| 138 | - 'default' => '1', | |
| 139 | - 'options' => array( | |
| 140 | - '1' => __( 'Yes', 'charitable' ), | |
| 141 | - '0' => __( 'No', 'charitable' ), | |
| 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' ) ) | |
| 142 | 170 | ), |
| 143 | - 'help' => __( 'Display a checkbox asking people for their consent to being contacted when they donate, register an account, or manage their profile.', 'charitable' ), | |
| 144 | 171 | ), |
| 145 | - 'contact_consent_label' => array( | |
| 146 | - 'title' => __( 'Contact Consent Label', 'charitable' ), | |
| 147 | - 'type' => 'textarea', | |
| 148 | - 'priority' => 50, | |
| 149 | - 'default' => 'Yes, I am happy for you to contact me via email or phone.', | |
| 150 | - 'help' => 'A short statement describing how you would like to contact people.' | |
| 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' ), | |
| 151 | 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 | + ), | |
| 152 | 190 | ); |
| 153 | 191 | } |
| 154 | 192 | |
| 155 | 193 | /** |
| @@ -165,8 +203,50 @@ | ||
| 165 | 203 | return array_combine( |
| 166 | 204 | array_keys( $fields ), |
| 167 | 205 | wp_list_pluck( $fields, 'label' ) |
| 168 | 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 ); | |
| 169 | 249 | } |
| 170 | 250 | } |
| 171 | 251 | |
| 172 | 252 | endif; |