delete( $wpdb->postmeta, array( 'meta_key' => '_aisp_exclusive_users' ), array( '%s' ) ); // ------------------------------------------------------------------------- // 2. Remove _aisp_category_users term meta from all product categories. // ------------------------------------------------------------------------- // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching, WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Uninstall cleanup: bulk delete by meta_key is intentional and unavoidable. $wpdb->delete( $wpdb->termmeta, array( 'meta_key' => '_aisp_category_users' ), array( '%s' ) ); // ------------------------------------------------------------------------- // 3. Remove the cache-version option. // ------------------------------------------------------------------------- delete_option( 'aisp_exclusive_products_cache_ver' ); // ------------------------------------------------------------------------- // 4. Remove all per-user hidden-IDs transients (aisp_hidden_u{id}_v{ver}). // delete_transient() requires knowing each exact key; a LIKE query is // the only way to bulk-delete dynamically named transients. // ------------------------------------------------------------------------- // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_aisp_hidden_u' ) . '%', $wpdb->esc_like( '_transient_timeout_aisp_hidden_u' ) . '%' ) ); // ------------------------------------------------------------------------- // 5. Remove all per-user bulk-action transients (aisp_bulk_*_u{id}). // ------------------------------------------------------------------------- // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_aisp_bulk_' ) . '%', $wpdb->esc_like( '_transient_timeout_aisp_bulk_' ) . '%' ) ); // ------------------------------------------------------------------------- // 6. If a persistent object cache is active, clear our specific keys. // wp_cache_flush() would nuke everything — too aggressive. // ------------------------------------------------------------------------- if ( wp_using_ext_object_cache() ) { $aisp_ep_user_ids = get_users( array( 'fields' => 'ID', 'number' => 0 ) ); $aisp_ep_cache_ver = (int) get_option( 'aisp_exclusive_products_cache_ver', 1 ); foreach ( $aisp_ep_user_ids as $aisp_ep_uid ) { for ( $aisp_ep_v = 1; $aisp_ep_v <= $aisp_ep_cache_ver + 1; $aisp_ep_v++ ) { wp_cache_delete( 'aisp_hidden_u' . $aisp_ep_uid . '_v' . $aisp_ep_v, 'transient' ); } wp_cache_delete( 'aisp_bulk_products_u' . $aisp_ep_uid, 'transient' ); wp_cache_delete( 'aisp_bulk_action_u' . $aisp_ep_uid, 'transient' ); } } } aisp_ep_run_uninstall();