prefix . $profit_engine_table; // Table names cannot be parameterised; they are built from a fixed allow-list above. // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.DirectDatabaseQuery $wpdb->query( "DROP TABLE IF EXISTS `{$profit_engine_full}`" ); } // Remove options. $profit_engine_options = array( 'profit_engine_settings', 'profit_engine_db_version', 'profit_engine_version', 'profit_engine_installed_at', 'profit_engine_po_counter', 'profit_engine_forecast_offset', 'profit_engine_backfill_state', 'profit_engine_notifications', 'profit_engine_notification_log', 'profit_engine_notification_state', ); foreach ( $profit_engine_options as $profit_engine_option ) { delete_option( $profit_engine_option ); } // Remove notification cool-down transients (profit_engine_nc_{event}_{id}). // phpcs:ignore WordPress.DB.DirectDatabaseQuery $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_profit_engine_nc_' ) . '%', $wpdb->esc_like( '_transient_timeout_profit_engine_nc_' ) . '%' ) ); // Remove the custom capability from all roles. $profit_engine_roles = wp_roles(); foreach ( array_keys( $profit_engine_roles->roles ) as $profit_engine_role_name ) { $profit_engine_role = get_role( $profit_engine_role_name ); if ( $profit_engine_role && $profit_engine_role->has_cap( 'manage_profit_engine' ) ) { $profit_engine_role->remove_cap( 'manage_profit_engine' ); } }