<?php
/**
 * WordPress privacy policy content for SEOvault AI.
 *
 * @package SEOvaultSEO
 */

namespace SEOvaultSEO\Admin;

if ( ! defined( 'ABSPATH' ) ) {
	exit;
}

/**
 * Registers suggested privacy policy text via wp_add_privacy_policy_content().
 */
class Privacy {

	/**
	 * Hook privacy policy registration.
	 *
	 * @return void
	 */
	public static function init() {
		add_action( 'admin_init', array( __CLASS__, 'add_privacy_policy_content' ) );
	}

	/**
	 * Add suggested privacy policy content for this plugin.
	 *
	 * @return void
	 */
	public static function add_privacy_policy_content() {
		if ( ! function_exists( 'wp_add_privacy_policy_content' ) ) {
			return;
		}

		$content = self::get_privacy_policy_content();
		wp_add_privacy_policy_content(
			__( 'SEOvault AI', 'seovault-ai' ),
			wp_kses_post( $content )
		);
	}

	/**
	 * Build the suggested privacy policy HTML.
	 *
	 * @return string
	 */
	public static function get_privacy_policy_content() {
		return '<p>' . esc_html__( 'SEOvault AI is a WordPress SEO plugin. Core SEO features can operate fully on your site without sending content to SEOvault AI servers. Optional features may store data locally or communicate with external services only when you enable or configure them. A full product privacy policy is available at https://seovaultai.com/privacy/.', 'seovault-ai' ) . '</p>'
			. '<h3>' . esc_html__( 'Data stored on your site', 'seovault-ai' ) . '</h3>'
			. '<ul>'
			. '<li>' . esc_html__( 'SEO settings and per-post SEO metadata (titles, descriptions, robots directives, schema, social fields, redirects, llms.txt content, and related fields).', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Optional connection credentials (site API keys) used to authenticate the SEOvault web app or scoped integrations. Keys are stored in your WordPress database.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Optional 404 Monitor logs. When enabled, requested URIs may be stored locally. In advanced mode, referring URLs and visitor user agents may also be stored. Visitor IP addresses are not stored by the 404 monitor.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Optional API audit logs for connector requests, which store SHA-256 hashed IP and User-Agent values rather than raw identifiers, together with route and event metadata.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Temporary rate-limiting data may store hashed identifiers as WordPress transients to limit abusive connector requests.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Optional AI crawler visit logs. When crawler logging is enabled and populated, visitor IP addresses and User-Agent strings are stored only as SHA-256 hashes, together with related visit metadata such as request URL and timestamp. Raw IPs and User-Agents are not retained.', 'seovault-ai' ) . '</li>'
			. '</ul>'
			. '<h3>' . esc_html__( 'Optional external services', 'seovault-ai' ) . '</h3>'
			. '<ul>'
			. '<li>' . esc_html__( 'SEOvault web app (optional): When you connect your site with a site key, authorized API clients connect to your WordPress REST API and may read and update SEO-related content and settings, including full post content needed for SEO workflows. The plugin does not automatically upload posts to SEOvault AI in the background. Connecting is optional; the plugin works without it.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'SEOvault AI Pro (optional separate plugin): If the Pro plugin is installed and licensed, it may contact SEOvault licensing and update services to verify entitlements and deliver updates. Free SEO features continue without Pro. A paid license is required for Pro features.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'IndexNow (optional): When enabled, published or updated URLs and a verification key may be submitted to the IndexNow API (https://api.indexnow.org/) to notify search engines. The verification key file is publicly accessible by design of the IndexNow protocol.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Google Analytics (optional): If enabled in settings with a Measurement ID, the plugin may output Google tag / gtag code that loads from googletagmanager.com and sends analytics data according to your Google Analytics configuration. SEOvault AI Pro may provide additional analytics configuration when separately installed.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Google Maps (optional): If you configure a Maps API key and use Local SEO map shortcodes, the plugin may load the Google Maps JavaScript API from maps.googleapis.com on pages that display the map.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( 'Schema import from URL (admin-initiated): If an administrator enters an external URL in the schema import tool, the plugin may fetch that URL to parse schema markup locally.', 'seovault-ai' ) . '</li>'
			. '</ul>'
			. '<h3>' . esc_html__( 'Uninstall and data retention', 'seovault-ai' ) . '</h3>'
			. '<p>' . esc_html__( 'Under SEOvault AI → Tools → Data & Uninstall, administrators can choose whether plugin data should be permanently deleted when the plugin is uninstalled.', 'seovault-ai' ) . '</p>'
			. '<ul>'
			. '<li>' . esc_html__( 'Default (checkbox off): Deleting the plugin removes connection secrets and operational leftovers (site API keys, connection state, related rate-limit/auth transients, and scheduled cron events), but keeps SEO settings, per-post SEO metadata, redirects, 404 logs, Local SEO data, schema-related content, and other stored plugin data in your WordPress database and related local files until you remove them manually.', 'seovault-ai' ) . '</li>'
			. '<li>' . esc_html__( '“Erase all data on uninstall” (checkbox on): Deleting the plugin permanently removes SEOvault AI data from your site, including SEO metadata, redirects, 404 logs, Local SEO locations, schema templates, sitemap cache files, plugin settings, custom tables, and related stored files. This cannot be undone.', 'seovault-ai' ) . '</li>'
			. '</ul>'
			. '<p>' . esc_html__( 'Uninstall cleanup runs on your WordPress site only and does not delete your SEOvault AI web app account, subscription, or workspace data. The Free plugin does not include hidden telemetry or license phone-homes. License verification, if any, is performed only by the separate SEOvault AI Pro plugin when it is installed and activated.', 'seovault-ai' ) . '</p>';
	}
}
