Implementacija funkcionalnosti brezplačnega dnevnega vrtenja
Deploy to Test Server / deploy (push) Failing after 9s

This commit is contained in:
Mark Poljanšek committed 2025-06-22 21:58:51 +02:00
1 parent 175f79e303
commit d77be150d9
7 files changed
+366 -149

No files matched your search

+47 -1
View File
@@ -193,6 +193,29 @@ if (
}
}
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_wheel_settings') {
if (check_admin_referer('wheel_edit_settings_nonce')) {
global $wpdb;
$wheels_table = $wpdb->prefix . 'wof_wheels';
$wheel_id = isset($_POST['wheel_id']) ? intval($_POST['wheel_id']) : 0;
$has_daily_spin = isset($_POST['has_daily_spin']) ? 1 : 0;
if ($wheel_id > 0) {
$wpdb->update(
$wheels_table,
['has_daily_spin' => $has_daily_spin],
['id' => $wheel_id],
['%d'],
['%d']
);
echo '<div class="notice notice-success is-dismissible"><p>' . __('Wheel settings updated!', 'wheel-of-fortune') . '</p></div>';
// Osvežimo podatke o kolesu po shranjevanju
$wheel = $wpdb->get_row($wpdb->prepare("SELECT * FROM $wheels_table WHERE id = %d", $wheel_id), ARRAY_A);
}
}
}
global $wpdb;
$wheels_table = $wpdb->prefix . 'wof_wheels';
$prizes_table = $wpdb->prefix . 'wheel_prizes';
@@ -231,6 +254,28 @@ if (class_exists('WooCommerce')) {
<hr class="wp-header-end">
<div class="wheel-card">
<h2><?php _e('Wheel Settings', 'wheel-of-fortune'); ?></h2>
<form method="post" action="">
<?php wp_nonce_field('wheel_edit_settings_nonce'); ?>
<input type="hidden" name="action" value="update_wheel_settings">
<input type="hidden" name="wheel_id" value="<?php echo esc_attr($wheel_id); ?>">
<table class="form-table">
<tr>
<th scope="row"><?php _e('Daily Free Spin', 'wheel-of-fortune'); ?></th>
<td>
<label for="has_daily_spin">
<input name="has_daily_spin" type="checkbox" id="has_daily_spin" value="1" <?php checked(isset($wheel['has_daily_spin']) && $wheel['has_daily_spin'], 1); ?>>
<?php _e('Enable 1 free daily spin for all logged-in users on this wheel.', 'wheel-of-fortune'); ?>
</label>
<p class="description"><?php _e('If checked, users can spin this wheel once per day for free, regardless of their purchased spins.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
</table>
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="<?php _e('Save Wheel Settings', 'wheel-of-fortune'); ?>"></p>
</form>
</div>
<div class="wheel-card">
<h2><?php echo esc_html__('Prizes for this Wheel', 'wheel-of-fortune'); ?></h2>
@@ -354,7 +399,8 @@ if (class_exists('WooCommerce')) {
<table class="wheel-form-table">
<tr><th scope="row"><label for="edit-prize-name"><?php _e('Prize Name', 'wheel-of-fortune'); ?></label></th><td><input type="text" id="edit-prize-name" name="prize_name" class="regular-text" required></td></tr>
<tr><th scope="row"><label for="edit-prize-description"><?php _e('Description', 'wheel-of-fortune'); ?></label></th><td><textarea id="edit-prize-description" name="prize_description" rows="3" class="large-text"></textarea></td></tr>
<tr><th scope="row"><label for="edit-prize-probability"><?php _e('Probability', 'wheel-of-fortune'); ?></label></th><td><input type="number" id="edit-prize-probability" name="prize_probability" step="any" min="0" max="1" required><p class="description"><?php _e('Enter a value between 0 and 1. Use 0 for prizes that cannot be won.', 'wheel-of-fortune'); ?></p></td></tr>
<tr><th scope="row"><label for="edit-prize-probability"><?php _e('Probability (Paid Spin)', 'wheel-of-fortune'); ?></label></th><td><input type="number" id="edit-prize-probability" name="prize_probability" step="any" min="0" max="1" required><p class="description"><?php _e('Enter a value between 0 and 1. Use 0 for prizes that cannot be won.', 'wheel-of-fortune'); ?></p></td></tr>
<tr><th scope="row"><label for="edit-prize-daily-spin-probability"><?php _e('Probability (Daily Spin)', 'wheel-of-fortune'); ?></label></th><td><input type="number" id="edit-prize-daily-spin-probability" name="prize_daily_spin_probability" step="any" min="0" max="1"><p class="description"><?php _e('Chance for a FREE daily spin. Leave empty to use the same probability as the paid spin.', 'wheel-of-fortune'); ?></p></td></tr>
<tr><th scope="row"><?php _e('Status', 'wheel-of-fortune'); ?></th><td><label for="edit-prize-is-active"><input type="checkbox" id="edit-prize-is-active" name="prize_is_active" value="1"><?php _e('Prize is active', 'wheel-of-fortune'); ?></label></td></tr>
<tr><th scope="row"><label for="edit-prize-redemption-code"><?php _e('Redemption Code', 'wheel-of-fortune'); ?></label></th><td><input type="text" id="edit-prize-redemption-code" name="prize_redemption_code" class="regular-text"><p class="description"><?php _e('Optional code for the user to redeem the prize.', 'wheel-of-fortune'); ?></p></td></tr>
<tr><th scope="row"><label for="edit-prize-is-discount"><?php _e('Is Discount?', 'wheel-of-fortune'); ?></label></th><td><input type="checkbox" id="edit-prize-is-discount" name="prize_is_discount" value="1"><p class="description"><?php _e('Check if the prize is a discount.', 'wheel-of-fortune'); ?></p></td></tr>
+2
View File
@@ -65,6 +65,7 @@ jQuery(document).ready(function($) {
$('#edit-prize-name').val(prize.name);
$('#edit-prize-description').val(prize.description);
$('#edit-prize-probability').val(prize.probability);
$('#edit-prize-daily-spin-probability').val(prize.daily_spin_probability);
$('#edit-prize-is-active').prop('checked', parseInt(prize.is_active, 10));
$('#edit-prize-redemption-code').val(prize.redemption_code);
$('#edit-prize-is-discount').prop('checked', parseInt(prize.is_discount, 10));
@@ -94,6 +95,7 @@ jQuery(document).ready(function($) {
name: $('#edit-prize-name').val(),
description: $('#edit-prize-description').val(),
probability: $('#edit-prize-probability').val(),
daily_spin_probability: $('#edit-prize-daily-spin-probability').val(),
is_active: $('#edit-prize-is-active').is(':checked') ? 1 : 0,
redemption_code: $('#edit-prize-redemption-code').val(),
is_discount: $('#edit-prize-is-discount').is(':checked') ? 1 : 0,
+8 -1
View File
@@ -13,12 +13,19 @@ if (!defined('ABSPATH')) exit;
<td><textarea id="prize_description" name="prize_description" rows="3" class="large-text"></textarea></td>
</tr>
<tr>
<th scope="row"><label for="prize_probability"><?php _e('Probability', 'wheel-of-fortune'); ?></label></th>
<th scope="row"><label for="prize_probability"><?php _e('Probability (Paid Spin)', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="number" id="prize_probability" name="prize_probability" step="any" min="0" max="1" required>
<p class="description"><?php _e('Enter a value between 0 and 1 (e.g., 0.1 for 10% chance). Use 0 for prizes that cannot be won.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><label for="prize_daily_spin_probability"><?php _e('Probability (Daily Spin)', 'wheel-of-fortune'); ?></label></th>
<td>
<input type="number" id="prize_daily_spin_probability" name="prize_daily_spin_probability" step="any" min="0" max="1">
<p class="description"><?php _e('Chance for a FREE daily spin. Leave empty to use the same probability as the paid spin.', 'wheel-of-fortune'); ?></p>
</td>
</tr>
<tr>
<th scope="row"><?php _e('Status', 'wheel-of-fortune'); ?></th>
<td>