| 1 |
<?php |
| 2 |
/** |
| 3 |
* Charitable Privacy Settings UI. |
| 4 |
* |
| 5 |
* @package Charitable/Classes/Charitable_Privacy_Settings |
| 6 |
* @author David Bisset |
| 7 |
* @copyright Copyright (c) 2022, WP Charitable LLC |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.6.0 |
| 10 |
* @version 1.6.0 |
| 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_description' => array( |
| 81 |
'type' => 'content', |
| 82 |
'priority' => 20, |
| 83 |
'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>' |
| 85 |
. '<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 |
. '</div>', |
| 87 |
), |
| 88 |
'minimum_data_retention_period' => array( |
| 89 |
'label_for' => __( 'Minimum Data Retention Period', 'charitable' ), |
| 90 |
'type' => 'select', |
| 91 |
'help' => sprintf( |
| 92 |
/* 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.' ), |
| 94 |
'<strong>', |
| 95 |
'</strong>', |
| 96 |
'<br />' |
| 97 |
), |
| 98 |
'priority' => 25, |
| 99 |
'default' => 2, |
| 100 |
'options' => array( |
| 101 |
0 => __( 'None', 'charitable' ), |
| 102 |
1 => __( 'One year', 'charitable' ), |
| 103 |
2 => __( 'Two years', 'charitable' ), |
| 104 |
3 => __( 'Three years', 'charitable' ), |
| 105 |
4 => __( 'Four years', 'charitable' ), |
| 106 |
5 => __( 'Five years', 'charitable' ), |
| 107 |
6 => __( 'Six years', 'charitable' ), |
| 108 |
7 => __( 'Seven years', 'charitable' ), |
| 109 |
8 => __( 'Eight years', 'charitable' ), |
| 110 |
9 => __( 'Nine years', 'charitable' ), |
| 111 |
10 => __( 'Ten years', 'charitable' ), |
| 112 |
'endless' => __( 'Forever', 'charitable' ), |
| 113 |
), |
| 114 |
), |
| 115 |
'data_retention_fields' => array( |
| 116 |
'label_for' => __( 'Retained Data', 'charitable' ), |
| 117 |
'type' => 'multi-checkbox', |
| 118 |
'priority' => 30, |
| 119 |
'default' => array_keys( $data_fields ), |
| 120 |
'options' => $data_fields, |
| 121 |
'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' ), |
| 122 |
'attrs' => array( |
| 123 |
'data-trigger-key' => '#charitable_settings_minimum_data_retention_period', |
| 124 |
'data-trigger-value' => '!0', |
| 125 |
), |
| 126 |
), |
| 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 |
), |
| 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' ), |
| 142 |
), |
| 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 |
), |
| 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.' |
| 151 |
), |
| 152 |
); |
| 153 |
} |
| 154 |
|
| 155 |
/** |
| 156 |
* Return the list of user donation field options. |
| 157 |
* |
| 158 |
* @since 1.6.0 |
| 159 |
* |
| 160 |
* @return string[] |
| 161 |
*/ |
| 162 |
protected function get_user_donation_field_options() { |
| 163 |
$fields = charitable()->donation_fields()->get_data_type_fields( 'user' ); |
| 164 |
|
| 165 |
return array_combine( |
| 166 |
array_keys( $fields ), |
| 167 |
wp_list_pluck( $fields, 'label' ) |
| 168 |
); |
| 169 |
} |
| 170 |
} |
| 171 |
|
| 172 |
endif; |
| 173 |
|