prefix . 'schema_ai_schemas', $wpdb->prefix . 'schema_ai_generations', $wpdb->prefix . 'schema_ai_usage', $wpdb->prefix . 'schema_ai_templates', $wpdb->prefix . 'schema_ai_analytics', ); foreach ( $tables as $table ) { $table = esc_sql( $table ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared -- Intentional schema removal during plugin uninstall; table names are $wpdb->prefix plus hardcoded suffix only. $wpdb->query( "DROP TABLE IF EXISTS {$table}" ); } // Delete all plugin options delete_option( 'schema_ai_settings' ); delete_option( 'schema_ai_db_version' ); delete_option( 'schema_ai_activation_time' ); delete_option( 'schema_ai_flush_rewrite' ); delete_option( 'schema_ai_restore_result' ); delete_option( 'schema_ai_llms_txt_last' ); delete_option( 'schema_ai_hidden_notice_dismissed' ); delete_transient( 'schema_ai_llms_txt' ); delete_transient( 'schema_ai_ai_crawler_status' ); delete_option( 'schema_ai_bulk_kick_token' ); delete_option( 'schema_ai_bulk_debug' ); // Delete all user-specific options $user_ids = get_users( array( 'fields' => 'ID', ) ); foreach ( $user_ids as $user_id ) { delete_option( 'schema_ai_user_' . $user_id ); delete_user_meta( $user_id, 'schema_ai_plan' ); delete_user_meta( $user_id, 'schema_ai_api_key' ); delete_user_meta( $user_id, 'schema_ai_dismissed_notices' ); } // Clear all transients created by Schema AI // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.PreparedSQL.NotPrepared -- Required for custom table; write/DDL operation, caching not applicable. $wpdb->query( 'DELETE FROM ' . $wpdb->options . " WHERE option_name LIKE '%\_transient\_schema\_ai\_%' OR option_name LIKE '%\_transient\_timeout\_schema\_ai\_%'" ); // Clear scheduled cron events wp_clear_scheduled_hook( 'schema_ai_daily_cleanup' ); wp_clear_scheduled_hook( 'schema_ai_usage_reset' ); wp_clear_scheduled_hook( 'schema_ai_analytics_sync' ); wp_clear_scheduled_hook( 'schema_ai_validate' ); wp_clear_scheduled_hook( 'schema_ai_bulk_validate' ); wp_clear_scheduled_hook( 'schema_ai_bulk_poll' ); wp_clear_scheduled_hook( 'schema_ai_bulk_next' ); wp_clear_scheduled_hook( 'schema_ai_site_sync' ); wp_clear_scheduled_hook( 'schema_ai_sync_single' ); wp_clear_scheduled_hook( 'schema_ai_sync_after_key_change' );