<?php
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
    exit;
}

/** ------------------------------
 * Core Licensing & Identity
 * ------------------------------ */
delete_option( 'ss_domain' );
delete_option( 'ss_license_status' );
delete_transient( 'ss_license_status' );

/** ------------------------------
 * Telemetry + install id
 * ------------------------------ */
delete_option( 'ss_telemetry_opt_in' );
delete_option( 'ss_installation_id' );

/** ------------------------------
 * AI Policy page (only if auto-created)
 * ------------------------------ */
/** @phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound */

$ss_page_id = (int) get_option( 'ss_ai_policy_page_id' );
if ( $ss_page_id > 0 ) {
    if ( get_post_meta( $ss_page_id, '_ss_ai_autocreated', true ) ) {
        wp_delete_post( $ss_page_id, true );
    }
}
delete_option( 'ss_ai_policy_page_id' );

/** ------------------------------
 * llms.txt file pointer
 * ------------------------------ */
$ss_llms_path = get_option( 'ss_llms_written_path' );
if ( $ss_llms_path && file_exists( $ss_llms_path ) ) {
    wp_delete_file( $ss_llms_path );
}
delete_option( 'ss_llms_written_path' );

/** @phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound */

/** ------------------------------
 * Organization sync
 * ------------------------------ */
delete_option( 'ss_org_sync' );
