prefix . 'wof_wheels'; // Handle adding a new wheel if (isset($_POST['add_wheel_submit']) && check_admin_referer('wof_add_wheel_nonce')) { $wheel_name = sanitize_text_field($_POST['wheel_name']); $wheel_slug = sanitize_title($_POST['wheel_name']); // Generate slug from name if (!empty($wheel_name)) { $wpdb->insert( $wheels_table, ['name' => $wheel_name, 'slug' => $wheel_slug, 'created_at' => current_time('mysql')], ['%s', '%s', '%s'] ); echo '

' . __('New wheel created successfully!', 'wheel-of-fortune') . '

'; } else { echo '

' . __('Please provide a name for the wheel.', 'wheel-of-fortune') . '

'; } } // Handle deleting a wheel if (isset($_GET['action']) && $_GET['action'] === 'delete' && isset($_GET['wheel_id']) && check_admin_referer('wof_delete_wheel_' . $_GET['wheel_id'])) { $wheel_id_to_delete = intval($_GET['wheel_id']); if ($wheel_id_to_delete !== 1) { // Prevent deleting the default wheel // TODO: Consider what to do with prizes associated with this wheel. For now, we'll just delete the wheel. $wpdb->delete($wheels_table, ['id' => $wheel_id_to_delete], ['%d']); echo '

' . __('Wheel deleted successfully.', 'wheel-of-fortune') . '

'; } else { echo '

' . __('The default wheel cannot be deleted.', 'wheel-of-fortune') . '

'; } } $wheels = $wpdb->get_results("SELECT * FROM $wheels_table ORDER BY id ASC", ARRAY_A); ?>

[wheel_of_fortune id=""] |