premik gumba
Deploy to Development and Production / deploy (push) Successful in 5s Details

This commit is contained in:
Mark Poljanšek 2025-11-20 22:24:46 +01:00
parent 557c1d341f
commit 97b9cd64be
4 changed files with 513 additions and 53 deletions

View File

@ -1,3 +1,7 @@
# Wheel of Fortune Plugin
Test posodobitve za preverjanje Gitea workflow.
# Wheel of Fortune - WordPress Plugin
Vtičnik "Kolo Sreče" (Wheel of Fortune) omogoča uporabnikom vrtenje kolesa za nagrade. Povezan je z WooCommerce za dodeljevanje spinov ob nakupu izdelkov.

View File

@ -301,7 +301,7 @@
align-items: center;
justify-content: center;
margin: 20px auto 0 auto;
padding: 0 40px;
padding: 0 40px !important;
background: linear-gradient(135deg, #ff00c4, #00dfe9);
color: #fff;
border: none;
@ -316,7 +316,10 @@
height: 56px;
min-width: 140px;
letter-spacing: 2px;
line-height: 1 !important;
text-shadow: 0 2px 8px #000, 0 0 10px #0cf101;
-webkit-appearance: none;
appearance: none;
}
/* Button hover effect */

View File

@ -1,5 +1,9 @@
"./README.md" :
"""
# Wheel of Fortune Plugin
Test posodobitve za preverjanje Gitea workflow.
# Wheel of Fortune - WordPress Plugin
Vtičnik "Kolo Sreče" (Wheel of Fortune) omogoča uporabnikom vrtenje kolesa za nagrade. Povezan je z WooCommerce za dodeljevanje spinov ob nakupu izdelkov.
@ -1346,6 +1350,17 @@ if (class_exists('WooCommerce')) {
<hr class="wp-header-end">
<!-- Gumb za migracijo is_try_again stolpca -->
<div class="notice notice-info">
<p><strong><?php _e('Database Migration', 'wheel-of-fortune'); ?>:</strong>
<?php _e('If you encounter "Unknown column is_try_again" error, click the button below to add the missing column to the database.', 'wheel-of-fortune'); ?>
<button id="migrate-try-again-btn" class="button button-secondary" style="margin-left: 10px;">
<?php _e('Add is_try_again Column', 'wheel-of-fortune'); ?>
</button>
<span id="migrate-result" style="margin-left: 10px;"></span>
</p>
</div>
<div class="wheel-card">
<h2><?php echo esc_html__('Prizes for this Wheel', 'wheel-of-fortune'); ?></h2>
@ -1533,6 +1548,43 @@ jQuery(document).ready(function($) {
});
});
});
</script>
<script>
jQuery(document).ready(function($) {
// Gumb za migracijo is_try_again stolpca
$('#migrate-try-again-btn').on('click', function(e) {
e.preventDefault();
const button = $(this);
const resultSpan = $('#migrate-result');
button.prop('disabled', true).text('<?php _e('Running migration...', 'wheel-of-fortune'); ?>');
resultSpan.html('');
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action: 'wheel_migrate_try_again',
_ajax_nonce: '<?php echo wp_create_nonce('wheel_admin_nonce'); ?>'
},
success: function(response) {
if (response.success) {
resultSpan.html('<span style="color: green;">✓ ' + response.data.message + '</span>');
button.text('<?php _e('Migration Completed', 'wheel-of-fortune'); ?>').addClass('button-primary');
} else {
resultSpan.html('<span style="color: red;">✗ ' + (response.data.message || '<?php _e('Migration failed', 'wheel-of-fortune'); ?>') + '</span>');
button.prop('disabled', false).text('<?php _e('Add is_try_again Column', 'wheel-of-fortune'); ?>');
}
},
error: function() {
resultSpan.html('<span style="color: red;">✗ <?php _e('Network error occurred', 'wheel-of-fortune'); ?></span>');
button.prop('disabled', false).text('<?php _e('Add is_try_again Column', 'wheel-of-fortune'); ?>');
}
});
});
});
</script> """
@ -2800,6 +2852,41 @@ if (isset($_POST['mark_redeemed']) && isset($_POST['prize_id'])) {
'</p></div>';
}
// Ponastavi spine na 0 za vse uporabnike na izbranem kolesu
if (isset($_POST['reset_all_spins_wheel']) && isset($_POST['wheel_id'])) {
check_admin_referer('reset_spins_wheel_nonce', 'reset_spins_wheel_nonce');
$wheel_id = intval($_POST['wheel_id']);
// Preveri, če kolo obstaja
$wheel_exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wheels_table WHERE id = %d", $wheel_id));
if ($wheel_exists) {
// Ponastavi spine na 0 za vse uporabnike na tem kolesu
$result = $wpdb->update(
$spins_table,
array('spins_available' => 0),
array('wheel_id' => $wheel_id),
array('%d'),
array('%d')
);
if ($result !== false) {
echo '<div class="notice notice-success is-dismissible"><p>' .
sprintf(__('Vsi spini za kolo ID %d so bili uspešno ponastavljeni na 0.', 'wheel-of-fortune'), $wheel_id) .
'</p></div>';
} else {
echo '<div class="notice notice-error is-dismissible"><p>' .
__('Prišlo je do napake pri ponastavitvi spinov.', 'wheel-of-fortune') .
'</p></div>';
}
} else {
echo '<div class="notice notice-error is-dismissible"><p>' .
__('Izbrano kolo ne obstaja.', 'wheel-of-fortune') .
'</p></div>';
}
}
// Izberi uporabnika za podrobnosti
$selected_user_id = isset($_GET['user_id']) ? intval($_GET['user_id']) : 0;
@ -2825,6 +2912,22 @@ if ($selected_user_id > 0) {
<div class="wrap">
<h1><?php echo esc_html__('Statistika Kolesa Sreče', 'wheel-of-fortune'); ?></h1>
<!-- Gumb za ponastavitev spinov za izbrano kolo -->
<div class="notice notice-warning" style="margin: 20px 0;">
<p>
<strong><?php echo esc_html__('Ponastavitev spinov', 'wheel-of-fortune'); ?>:</strong>
<?php echo esc_html__('To dejanje bo ponastavilo vse spine na 0 za vse uporabnike na izbranem kolesu. To dejanje ni mogoče razveljaviti.', 'wheel-of-fortune'); ?>
<form method="post" style="display: inline-block; margin-left: 10px;">
<?php wp_nonce_field('reset_spins_wheel_nonce', 'reset_spins_wheel_nonce'); ?>
<input type="hidden" name="wheel_id" value="<?php echo esc_attr($selected_wheel_id); ?>">
<button type="submit" name="reset_all_spins_wheel" class="button button-secondary"
onclick="return confirm('<?php echo esc_js(__('Ste prepričani, da želite ponastaviti vse spine na 0 za vse uporabnike na tem kolesu? To dejanje ni mogoče razveljaviti.', 'wheel-of-fortune')); ?>')">
<?php echo esc_html__('Ponastavi vse spine na 0 za to kolo', 'wheel-of-fortune'); ?>
</button>
</form>
</p>
</div>
<!-- Izbira kolesa -->
<div class="tablenav top">
<div class="alignleft actions">
@ -2851,9 +2954,45 @@ if ($selected_user_id > 0) {
<br class="clear">
</div>
<h2><?php echo sprintf(esc_html__('Seznam uporabnikov s spini za kolo: %s', 'wheel-of-fortune'), esc_html($selected_wheel['name'])); ?></h2>
<table class="wp-list-table widefat fixed striped">
<!-- Filtriranje uporabnikov -->
<div class="user-filters" style="margin: 20px 0; padding: 15px; background: #f9f9f9; border: 1px solid #ddd; border-radius: 5px;">
<h4><?php echo esc_html__('Filtriranje uporabnikov', 'wheel-of-fortune'); ?></h4>
<div style="display: flex; gap: 15px; align-items: center; flex-wrap: wrap;">
<div>
<label for="filter-spins"><?php echo esc_html__('Preostali spini:', 'wheel-of-fortune'); ?></label>
<select id="filter-spins" style="margin-left: 5px;">
<option value=""><?php echo esc_html__('Vsi', 'wheel-of-fortune'); ?></option>
<option value="0"><?php echo esc_html__('0 spinov (porabili)', 'wheel-of-fortune'); ?></option>
<option value="1"><?php echo esc_html__('1 spin', 'wheel-of-fortune'); ?></option>
<option value="2"><?php echo esc_html__('2 spina', 'wheel-of-fortune'); ?></option>
<option value="3"><?php echo esc_html__('3 spini', 'wheel-of-fortune'); ?></option>
<option value="4"><?php echo esc_html__('4 spini', 'wheel-of-fortune'); ?></option>
<option value="5"><?php echo esc_html__('5+ spinov', 'wheel-of-fortune'); ?></option>
</select>
</div>
<div>
<label for="filter-total-spins"><?php echo esc_html__('Skupno spinov:', 'wheel-of-fortune'); ?></label>
<select id="filter-total-spins" style="margin-left: 5px;">
<option value=""><?php echo esc_html__('Vsi', 'wheel-of-fortune'); ?></option>
<option value="0"><?php echo esc_html__('0', 'wheel-of-fortune'); ?></option>
<option value="1"><?php echo esc_html__('1', 'wheel-of-fortune'); ?></option>
<option value="2-5"><?php echo esc_html__('2-5', 'wheel-of-fortune'); ?></option>
<option value="6-10"><?php echo esc_html__('6-10', 'wheel-of-fortune'); ?></option>
<option value="11+"><?php echo esc_html__('11+', 'wheel-of-fortune'); ?></option>
</select>
</div>
<div>
<button type="button" onclick="filterUsers()" class="button button-primary"><?php echo esc_html__('Potrdi filtriranje', 'wheel-of-fortune'); ?></button>
<button type="button" onclick="clearFilters()" class="button" style="margin-left: 10px;"><?php echo esc_html__('Počisti filtre', 'wheel-of-fortune'); ?></button>
</div>
</div>
<div id="filter-results" style="margin-top: 10px; font-weight: bold; color: #0073aa;"></div>
</div>
<table class="wp-list-table widefat fixed striped" id="users-table">
<thead>
<tr>
<th scope="col"><?php echo esc_html__('ID', 'wheel-of-fortune'); ?></th>
@ -2973,7 +3112,203 @@ if ($selected_user_id > 0) {
<p><?php echo esc_html__('Uporabnik ni bil najden.', 'wheel-of-fortune'); ?></p>
<?php endif; ?>
<?php endif; ?>
</div> """
</div>
<script>
// Funkcija za filtriranje uporabnikov
function filterUsers() {
const filterSpins = document.getElementById('filter-spins').value;
const filterTotalSpins = document.getElementById('filter-total-spins').value;
const table = document.getElementById('users-table');
const tbody = table.getElementsByTagName('tbody')[0];
if (!tbody) {
console.error('Tabela ni najdena');
return;
}
const rows = tbody.getElementsByTagName('tr');
let visibleCount = 0;
console.log('Filtriranje uporabnikov:', { filterSpins, filterTotalSpins, totalRows: rows.length });
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
const cells = row.getElementsByTagName('td');
if (cells.length < 4) {
console.log('Preskočena vrstica (premalo stolpcev):', cells.length);
continue; // Preskoči header vrstice ali vrstice brez dovolj stolpcev
}
// Debug: prikaži vsebino vseh stolpcev
console.log(`Vrstica ${i} stolpci:`, {
stolpec0: cells[0] ? cells[0].textContent.trim() : 'N/A',
stolpec1: cells[1] ? cells[1].textContent.trim() : 'N/A',
stolpec2: cells[2] ? cells[2].textContent.trim() : 'N/A',
stolpec3: cells[3] ? cells[3].textContent.trim() : 'N/A',
stolpec4: cells[4] ? cells[4].textContent.trim() : 'N/A',
stolpec5: cells[5] ? cells[5].textContent.trim() : 'N/A'
});
const currentSpins = parseInt(cells[3].textContent.trim()) || 0; // Preostali spini (4. stolpec)
const totalSpins = parseInt(cells[2].textContent.trim()) || 0; // Skupno št. spinov (3. stolpec)
console.log(`Vrstica ${i}: currentSpins=${currentSpins}, totalSpins=${totalSpins}`);
let showRow = true;
// Filtriranje po preostalih spinih
if (filterSpins !== '') {
if (filterSpins === '0') {
showRow = showRow && (currentSpins === 0);
} else if (filterSpins === '1') {
showRow = showRow && (currentSpins === 1);
} else if (filterSpins === '2') {
showRow = showRow && (currentSpins === 2);
} else if (filterSpins === '3') {
showRow = showRow && (currentSpins === 3);
} else if (filterSpins === '4') {
showRow = showRow && (currentSpins === 4);
} else if (filterSpins === '5') {
showRow = showRow && (currentSpins >= 5);
}
}
// Filtriranje po skupnem številu spinov
if (filterTotalSpins !== '') {
if (filterTotalSpins === '0') {
showRow = showRow && (totalSpins === 0);
} else if (filterTotalSpins === '1') {
showRow = showRow && (totalSpins === 1);
} else if (filterTotalSpins === '2-5') {
showRow = showRow && (totalSpins >= 2 && totalSpins <= 5);
} else if (filterTotalSpins === '6-10') {
showRow = showRow && (totalSpins >= 6 && totalSpins <= 10);
} else if (filterTotalSpins === '11+') {
showRow = showRow && (totalSpins >= 11);
}
}
// Prikaži/skrij vrstico
if (showRow) {
row.style.display = '';
visibleCount++;
console.log(`Prikazana vrstica ${i}`);
} else {
row.style.display = 'none';
console.log(`Skrita vrstica ${i}`);
}
}
console.log(`Filtriranje končano: ${visibleCount} od ${rows.length} vrstic prikazanih`);
// Posodobi števec rezultatov
updateFilterResults(visibleCount, rows.length);
}
function clearFilters() {
document.getElementById('filter-spins').value = '';
document.getElementById('filter-total-spins').value = '';
filterUsers();
}
function updateFilterResults(visible, total) {
const resultsDiv = document.getElementById('filter-results');
if (visible === total) {
resultsDiv.innerHTML = '<?php echo esc_js(__('Prikazani vsi uporabniki:', 'wheel-of-fortune')); ?> ' + total;
} else {
resultsDiv.innerHTML = '<?php echo esc_js(__('Prikazano:', 'wheel-of-fortune')); ?> ' + visible + ' <?php echo esc_js(__('od', 'wheel-of-fortune')); ?> ' + total + ' <?php echo esc_js(__('uporabnikov', 'wheel-of-fortune')); ?>';
}
}
// Testna funkcija za preverjanje strukture tabele
function testTableStructure() {
const table = document.getElementById('users-table');
if (!table) {
console.log('Tabela ni najdena!');
return;
}
const tbody = table.getElementsByTagName('tbody')[0];
if (!tbody) {
console.log('Tbody ni najden!');
return;
}
const rows = tbody.getElementsByTagName('tr');
console.log(`Najdenih ${rows.length} vrstic v tabeli`);
if (rows.length > 0) {
const firstRow = rows[0];
const cells = firstRow.getElementsByTagName('td');
console.log(`Prva vrstica ima ${cells.length} stolpcev`);
for (let i = 0; i < cells.length; i++) {
console.log(`Stolpec ${i}: "${cells[i].textContent.trim()}"`);
}
}
}
// Inicializiraj števec rezultatov ob nalaganju strani
jQuery(document).ready(function($) {
// Gumb za ponastavitev spinov preko AJAX
$('button[name="reset_all_spins_wheel"]').on('click', function(e) {
e.preventDefault();
const button = $(this);
const originalText = button.text();
const wheelId = $('input[name="wheel_id"]').val();
if (!confirm('<?php echo esc_js(__('Ste prepričani, da želite ponastaviti vse spine na 0 za vse uporabnike na tem kolesu? To dejanje ni mogoče razveljaviti.', 'wheel-of-fortune')); ?>')) {
return;
}
button.prop('disabled', true).text('<?php echo esc_js(__('Ponastavljam spine...', 'wheel-of-fortune')); ?>');
$.ajax({
url: ajaxurl,
method: 'POST',
data: {
action: 'wheel_reset_spins_wheel',
wheel_id: wheelId,
_ajax_nonce: '<?php echo wp_create_nonce('wheel_admin_nonce'); ?>'
},
success: function(response) {
if (response.success) {
// Prikaži uspešno sporočilo
$('<div class="notice notice-success is-dismissible"><p>' + response.data.message + '</p></div>')
.insertAfter('h1')
.delay(3000)
.fadeOut();
// Osveži stran po 2 sekundah
setTimeout(function() {
location.reload();
}, 2000);
} else {
alert(response.data.message || '<?php echo esc_js(__('Prišlo je do napake.', 'wheel-of-fortune')); ?>');
button.prop('disabled', false).text(originalText);
}
},
error: function() {
alert('<?php echo esc_js(__('Prišlo je do napake pri komunikaciji s strežnikom.', 'wheel-of-fortune')); ?>');
button.prop('disabled', false).text(originalText);
}
});
});
// Posodobi števec rezultatov ob nalaganju strani
const table = document.getElementById('users-table');
if (table) {
const rows = table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
updateFilterResults(rows.length, rows.length);
// Testiraj strukturo tabele
testTableStructure();
}
});
</script> """
"./admin/users-page.php" :
@ -3803,12 +4138,12 @@ $wheels = $wpdb->get_results("SELECT * FROM $wheels_table ORDER BY id ASC", ARRA
transition: all 0.2s;
}
/* Simple gradients for cross-browser compatibility */
.wheel-segment-yellow { fill: #ffdd00; }
.wheel-segment-green { fill: #88ff00; }
.wheel-segment-red { fill: #ff5500; }
.wheel-segment-pink { fill: #ff44aa; }
.wheel-segment-blue { fill: #00ccff; }
/* Simple solid fills for segment color classes */
.wheel-segment-red { fill: #ff3131; }
.wheel-segment-green { fill: #7ed957; }
.wheel-segment-purple { fill: #8c52ff; }
.wheel-segment-orange { fill: #ff914d; }
.wheel-segment-blue { fill: #1da3e7; }
/* Divider between segments */
.wheel-divider {
@ -5551,8 +5886,10 @@ class WheelOfFortune {
add_action('wp_ajax_wheel_get_product', array($this, 'ajax_get_product'));
add_action('wp_ajax_wheel_test_email', array($this, 'ajax_test_email'));
add_action('wp_ajax_wheel_get_prizes', array($this, 'ajax_get_prizes'));
add_action('wp_ajax_ajax_update_wheel_product_spins', array($this, 'ajax_update_wheel_product_spins'));
add_action('wp_ajax_wof_delete_wheel_product', array($this, 'ajax_delete_wheel_product'));
add_action('wp_ajax_wof_update_wheel_product_spins', array($this, 'ajax_update_wheel_product_spins'));
add_action('wp_ajax_wheel_migrate_try_again', array($this, 'ajax_migrate_try_again'));
add_action('wp_ajax_wheel_reset_spins_wheel', array($this, 'ajax_reset_spins_wheel'));
// Vključi testno skripto za kupone
if (is_admin()) {
@ -5652,19 +5989,17 @@ class WheelOfFortune {
}
public function activate() {
error_log("Wheel of Fortune: Aktivacija plugina...");
$this->create_database_tables();
$this->run_migration();
$this->set_default_options();
$this->add_default_prizes();
// --- TUKAJ OSTANE SAMO NAČRTOVANJE DOGODKA ---
if (!wp_next_scheduled('wof_daily_spin_event')) {
wp_schedule_event(time(), 'daily', 'wof_daily_spin_event');
error_log("Wheel of Fortune: Cron job 'wof_daily_spin_event' scheduled.");
// Dodaj cron opravilo za dnevne spine
if (!wp_next_scheduled('wheel_daily_spins_cron')) {
wp_schedule_event(time(), 'wheel_daily', 'wheel_daily_spins_cron');
}
// ---------------------------------------------
flush_rewrite_rules();
error_log("Wheel of Fortune: Aktivacija končana.");
// Izvedi migracijo za is_try_again stolpec
$this->migrate_add_is_try_again_column();
}
public function deactivate() {
@ -5741,6 +6076,7 @@ class WheelOfFortune {
redemption_code varchar(100) DEFAULT '',
is_discount tinyint(1) NOT NULL DEFAULT 0,
discount_value float DEFAULT 0,
is_try_again tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (id),
KEY wheel_id (wheel_id)
) $charset_collate;";
@ -5800,6 +6136,29 @@ class WheelOfFortune {
} else {
error_log("Wheel of Fortune: Tabela $wheel_products_table uspešno ustvarjena.");
}
// Migracija: dodaj stolpec is_try_again v obstoječe tabele
$this->migrate_add_is_try_again_column();
}
private function migrate_add_is_try_again_column() {
global $wpdb;
$table_prizes = $wpdb->prefix . 'wheel_prizes';
// Preveri, če stolpec is_try_again že obstaja
$column_exists = $wpdb->get_results("SHOW COLUMNS FROM $table_prizes LIKE 'is_try_again'");
if (empty($column_exists)) {
// Dodaj stolpec is_try_again
$result = $wpdb->query("ALTER TABLE $table_prizes ADD COLUMN is_try_again tinyint(1) NOT NULL DEFAULT 0");
if ($result !== false) {
error_log("Wheel of Fortune: Stolpec is_try_again uspešno dodan v tabelo $table_prizes");
} else {
error_log("Wheel of Fortune: Napaka pri dodajanju stolpca is_try_again v tabelo $table_prizes");
}
} else {
error_log("Wheel of Fortune: Stolpec is_try_again že obstaja v tabeli $table_prizes");
}
}
private function run_migration() {
@ -6051,7 +6410,8 @@ class WheelOfFortune {
}
}
if (get_option('wheel_send_emails', true)) {
// Pošlji email samo, če ni "try again" nagrada
if (get_option('wheel_send_emails', true) && (!isset($prize['is_try_again']) || $prize['is_try_again'] != 1)) {
$this->send_prize_email($user_id, $prize);
}
@ -6266,7 +6626,8 @@ class WheelOfFortune {
$text_paths = '';
// Generate segments and text paths
$segment_colors = ['#00dfe9', '#ff00c4', '#0cf101'];
// Updated segment color palette
$segment_colors = ['#ff3131', '#7ed957', '#8c52ff', '#ff914d', '#1da3e7'];
for ($i = 0; $i < $num_prizes; $i++) {
$prize = $prizes[$i];
$start_angle = $i * $angle;
@ -6372,6 +6733,7 @@ class WheelOfFortune {
$email_subject = isset($_POST['email_subject']) ? sanitize_text_field($_POST['email_subject']) : '';
$email_template = isset($_POST['email_template']) ? wp_kses_post($_POST['email_template']) : '';
$discount_value = isset($_POST['discount_value']) ? floatval($_POST['discount_value']) : 0;
$is_try_again = isset($_POST['is_try_again']) ? intval($_POST['is_try_again']) : 0;
if (empty($name)) {
wp_send_json_error(['message' => __('Prize name is required.', 'wheel-of-fortune')]);
@ -6399,9 +6761,10 @@ class WheelOfFortune {
'email_subject' => $email_subject,
'email_template' => $email_template,
'discount_value' => $discount_value,
'is_try_again' => $is_try_again,
];
$format = ['%d', '%s', '%s', '%f', '%d', '%s', '%d', '%s', '%s', '%f'];
$format = ['%d', '%s', '%s', '%f', '%d', '%s', '%d', '%s', '%s', '%f', '%d'];
if ($prize_id > 0) {
$result = $wpdb->update($table_name, $data, ['id' => $prize_id], $format, ['%d']);
@ -6835,6 +7198,12 @@ class WheelOfFortune {
* @param array $prize The prize details array.
*/
public function send_prize_email($user_id, $prize) {
// Ne pošlji emaila, če je nagrada "try again"
if (isset($prize['is_try_again']) && $prize['is_try_again'] == 1) {
wheel_of_fortune_debug_log("send_prize_email: Email ni poslan za 'try again' nagrado: {$prize['name']}");
return;
}
$user = get_userdata($user_id);
if (!$user) {
wheel_of_fortune_debug_log("send_prize_email: Uporabnik z ID {$user_id} ni bil najden.");
@ -6956,32 +7325,83 @@ class WheelOfFortune {
}
public function ajax_delete_wheel_product() {
check_ajax_referer('wof_delete_wheel_product');
check_ajax_referer('wof_delete_wheel_product', '_ajax_nonce');
if (!current_user_can('manage_options')) {
wp_send_json_error(__('Nimaš dovoljenja.', 'wheel-of-fortune'));
wp_send_json_error(['message' => __('You do not have permission to perform this action.', 'wheel-of-fortune')]);
}
global $wpdb;
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
// Debug informacije
error_log("=== AJAX DELETE WHEEL PRODUCT DEBUG ===");
error_log("POST data: " . print_r($_POST, true));
error_log("ID to delete: " . $id);
if (!$id) {
wp_send_json_error(['message' => __('Invalid ID.', 'wheel-of-fortune')]);
}
if ($id > 0) {
$table = $wpdb->prefix . 'wheel_of_fortune_products';
error_log("Table: " . $table);
global $wpdb;
$table_name = $wpdb->prefix . 'wheel_of_fortune_products';
$result = $wpdb->delete($table, ['id' => $id], ['%d']);
error_log("Delete result: " . $result);
error_log("Last SQL query: " . $wpdb->last_query);
error_log("Last SQL error: " . $wpdb->last_error);
$result = $wpdb->delete($table_name, ['id' => $id]);
if ($result !== false) {
wp_send_json_success();
wp_send_json_success(['message' => __('Product deleted successfully.', 'wheel-of-fortune')]);
} else {
wp_send_json_error(['message' => __('Failed to delete product.', 'wheel-of-fortune')]);
}
}
wp_send_json_error(__('Napaka pri brisanju.', 'wheel-of-fortune'));
public function ajax_migrate_try_again() {
check_ajax_referer('wheel_admin_nonce', '_ajax_nonce');
if (!current_user_can('manage_options')) {
wp_send_json_error(['message' => __('You do not have permission to perform this action.', 'wheel-of-fortune')]);
}
$this->migrate_add_is_try_again_column();
wp_send_json_success(['message' => __('Migration completed successfully. The is_try_again column has been added to the database.', 'wheel-of-fortune')]);
}
public function ajax_reset_spins_wheel() {
check_ajax_referer('wheel_admin_nonce', '_ajax_nonce');
if (!current_user_can('manage_options')) {
wp_send_json_error(['message' => __('You do not have permission to perform this action.', 'wheel-of-fortune')]);
}
$wheel_id = isset($_POST['wheel_id']) ? intval($_POST['wheel_id']) : 0;
if (!$wheel_id) {
wp_send_json_error(['message' => __('Wheel ID is required.', 'wheel-of-fortune')]);
}
global $wpdb;
$wheels_table = $wpdb->prefix . 'wof_wheels';
$spins_table = $wpdb->prefix . 'wheel_spins';
// Preveri, če kolo obstaja
$wheel_exists = $wpdb->get_var($wpdb->prepare("SELECT id FROM $wheels_table WHERE id = %d", $wheel_id));
if (!$wheel_exists) {
wp_send_json_error(['message' => __('Selected wheel does not exist.', 'wheel-of-fortune')]);
}
// Ponastavi spine na 0 za vse uporabnike na tem kolesu
$result = $wpdb->update(
$spins_table,
array('spins_available' => 0),
array('wheel_id' => $wheel_id),
array('%d'),
array('%d')
);
if ($result !== false) {
wp_send_json_success([
'message' => sprintf(__('All spins for wheel ID %d have been successfully reset to 0.', 'wheel-of-fortune'), $wheel_id),
'affected_users' => $result
]);
} else {
wp_send_json_error(['message' => __('An error occurred while resetting spins.', 'wheel-of-fortune')]);
}
}
// --- NOVE METODE ZA CRON ---
@ -7020,6 +7440,7 @@ class WheelOfFortune {
}
}
}
// ----------------------------
}

50
export_code.sh Normal file → Executable file
View File

@ -1,26 +1,58 @@
#!/bin/bash
# Set the output file
# Nastavitev imena izhodne datoteke
OUTPUT_FILE="code_export.txt"
# Remove the output file if it exists
# Odstrani izhodno datoteko, če že obstaja, da začnemo s čisto datoteko
if [ -f "$OUTPUT_FILE" ]; then
rm "$OUTPUT_FILE"
fi
# Find all files except hidden files and directories
find . -type f -not -path "*/\.*" -not -path "*node_modules*" -not -path "*vendor*" | sort | while read -r file; do
# Skip the output file itself and this script
# Poišči vse datoteke, razen skritih datotek in določenih map (npr. node_modules).
# Dodane so izjeme za slike, videoposnetke, PDF-je, arhive in druge binarne datoteke
# neposredno v ukaz 'find' za boljšo zmogljivost.
find . -type f \
-not -path "*/\.*" \
-not -path "*node_modules*" \
-not -path "*vendor*" \
-not -path "*dist*" \
-not -path "*build*" \
-not -path "*/images/*" \
-not -iname "*.jpg" -not -iname "*.jpeg" \
-not -iname "*.png" -not -iname "*.gif" \
-not -iname "*.bmp" -not -iname "*.tiff" \
-not -iname "*.svg" -not -iname "*.ico" \
-not -iname "*.webp" \
-not -iname "*.mp4" -not -iname "*.mov" \
-not -iname "*.avi" -not -iname "*.mkv" \
-not -iname "*.webm" \
-not -iname "*.mp3" -not -iname "*.wav" \
-not -iname "*.ogg" -not -iname "*.flac" \
-not -iname "*.pdf" \
-not -iname "*.zip" \
-not -iname "*.tar" \
-not -iname "*.gz" \
-not -iname "*.bz2" \
-not -iname "*.rar" \
-not -iname "*.7z" \
-not -iname "*.doc" -not -iname "*.docx" \
-not -iname "*.xls" -not -iname "*.xlsx" \
-not -iname "*.ppt" -not -iname "*.pptx" \
-not -iname "*.eot" -not -iname "*.ttf" \
-not -iname "*.woff" -not -iname "*.woff2" \
| sort | while read -r file; do
# Preskoči samo izhodno datoteko in to skripto
if [[ "$file" == "./$OUTPUT_FILE" || "$file" == "./export_code.sh" ]]; then
continue
fi
# Skip binary files and the output file itself
if file "$file" | grep -q "binary"; then
# Dodatna varnostna preverba: preskoči slikovne datoteke po MIME tipu
if file --mime-type -b "$file" | grep -qiE '^(image)/'; then
continue
fi
# Add the filename and content to the output file
# Dodaj ime datoteke in njeno vsebino v izhodno datoteko
echo "\"$file\" : " >> "$OUTPUT_FILE"
echo "\"\"\"" >> "$OUTPUT_FILE"
cat "$file" >> "$OUTPUT_FILE"
@ -29,4 +61,4 @@ find . -type f -not -path "*/\.*" -not -path "*node_modules*" -not -path "*vendo
echo "" >> "$OUTPUT_FILE"
done
echo "Code export completed. Output saved to $OUTPUT_FILE"
echo "Izvoz kode končan. Vsebina je shranjena v datoteko $OUTPUT_FILE"