prefix . 'glovario_variables', $wpdb->prefix . 'glovario_categories', $wpdb->prefix . 'glovario_rules', $wpdb->prefix . 'glovario_revisions', ); foreach ( $tables as $table ) { $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $table ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Removes Glovario's own tables when the administrator chose to delete all data. } $options = array( 'glovario_db_version', 'glovario_pro_db_version', 'glovario_delete_on_uninstall', 'glovario_title_shortcodes', 'glovario_ai_api_keys', 'glovario_ai_settings', 'glovario_locale_settings', 'glovario_client_editing', 'glovario_litespeed_vary', 'glovario_litespeed_vary_changed', 'glovario_slug_notes_backfilled', 'glovario_has_page_redirects', ); foreach ( $options as $option ) { delete_option( $option ); } // Address notes and earlier page addresses (their redirects stop with the plugin). foreach ( array( '_glovario_slug_from_title', '_glovario_slug_kept', '_glovario_old_slug' ) as $glovario_meta_key ) { delete_post_meta_by_key( $glovario_meta_key ); } // Per-user, per-site dismissal of the OpenLiteSpeed notice (user option). delete_metadata( 'user', 0, $wpdb->get_blog_prefix() . 'glovario_openlitespeed_notice', '', true ); // Short-lived notices, AI model lists, and AI translation drafts. With a persistent // object cache, transients are not stored in the options table and expire on their own. $wpdb->query( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- WordPress has no API to delete transients by prefix; runs once, on uninstall. $wpdb->prepare( 'DELETE FROM %i WHERE option_name LIKE %s OR option_name LIKE %s', $wpdb->options, $wpdb->esc_like( '_transient_glovario_' ) . '%', $wpdb->esc_like( '_transient_timeout_glovario_' ) . '%' ) ); } } if ( is_multisite() ) { // Network variables follow the main site's data-removal choice; read it before sites are cleaned. $glovario_delete_network = '1' === get_blog_option( get_main_site_id(), 'glovario_delete_on_uninstall', '0' ); foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0, ) ) as $glovario_site_id ) { switch_to_blog( $glovario_site_id ); glovario_uninstall_site(); restore_current_blog(); } if ( $glovario_delete_network ) { global $wpdb; $wpdb->query( $wpdb->prepare( 'DROP TABLE IF EXISTS %i', $wpdb->base_prefix . 'glovario_network_variables' ) ); // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.DirectDatabaseQuery.SchemaChange -- Removes the network table when the main site chose to delete all data. delete_site_option( 'glovario_network_db_version' ); } } else { glovario_uninstall_site(); }