<?php
/**
 * Privacy Policy Suggestions
 *
 * Provides suggested privacy policy text for site owners.
 *
 * @package DonorCore\Privacy
 */

namespace DonorCore\Privacy;

defined( 'ABSPATH' ) || exit;

/**
 * Privacy Policy Class
 */
class Privacy_Policy {

	/**
	 * Initialize hooks.
	 */
	public function init() {
		add_action( 'admin_init', array( $this, 'add_privacy_policy_content' ) );
	}

	/**
	 * Add suggested privacy policy content.
	 */
	public function add_privacy_policy_content() {
		if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
			return;
		}

		$content = $this->get_privacy_policy_text();

		wp_add_privacy_policy_content(
			'DonorCore',
			wp_kses_post( wpautop( $content, false ) )
		);
	}

	/**
	 * Get privacy policy text.
	 *
	 * @return string
	 */
	private function get_privacy_policy_text() {
		return '
			<h2>Donation Data Collection</h2>

			<p>When you make a donation through our site, we collect and process the following personal data:</p>

			<ul>
				<li><strong>Contact Information:</strong> Your name and email address (required for sending donation receipts)</li>
				<li><strong>Donation Details:</strong> Donation amount, date, and campaign you supported</li>
				<li><strong>Payment Information:</strong> Payment gateway used (payment details are processed securely by our payment provider and not stored on our server)</li>
			</ul>

			<h3>Why We Collect This Data</h3>

			<p>We collect this information to:</p>

			<ul>
				<li>Send you donation receipts via email with PDF attachments</li>
				<li>Track campaign fundraising progress and goals</li>
				<li>Maintain donation history for your records</li>
				<li>Comply with financial record-keeping and tax requirements</li>
				<li>Prevent fraud and ensure donation security</li>
			</ul>

			<h3>How Long We Keep Your Data</h3>

			<p>We retain donation data as follows:</p>

			<ul>
				<li><strong>Donation transaction records:</strong> Retained for 7 years to comply with tax and financial regulations</li>
				<li><strong>Donor analytics:</strong> Stored while you remain an active donor; may be deleted upon request (subject to legal retention requirements)</li>
				<li><strong>PDF receipts:</strong> Stored in our system and can be deleted upon request</li>
			</ul>

			<h3>Your Rights</h3>

			<p>Under data protection laws (including GDPR), you have the right to:</p>

			<ul>
				<li><strong>Access your data:</strong> Request a copy of your donation data via WordPress Tools → Export Personal Data</li>
				<li><strong>Erase your data:</strong> Request deletion of your donor analytics and PDF receipts via WordPress Tools → Erase Personal Data</li>
				<li><strong>Rectify inaccurate data:</strong> Contact us to correct any errors in your donation records</li>
			</ul>

			<p><strong>Important:</strong> Some donation transaction data may be retained in anonymized form due to legal requirements.</p>

			<h3>Data Security</h3>

			<p>We protect your donation data using secure storage, encryption, and regular monitoring.</p>

			<p>If you have questions about how we handle your donation data, please contact us.</p>
		';
	}
}
