/*
Theme Name: Listeo Child
Theme URI: http://listeo.pro/
Template: listeo
Author: Purethemes.me
Author URI: http://purethemes.net/
Description: Directory WordPress Theme by Purethemes
Tags: theme-options,translation-ready,two-columns
Version: 2.0.34.1777996756
Updated: 2026-05-05 17:59:16

*/
add_action('trashed_post', 'schedule_listing_count_fix', 9999);
add_action('deleted_post', 'schedule_listing_count_fix', 9999);

function schedule_listing_count_fix($post_id) {
    if (get_post_type($post_id) !== 'listing') return;
    
    $user_id = get_post_field('post_author', $post_id);
    $package_id = get_post_meta($post_id, '_user_package_id', true);
    
    wp_schedule_single_event(time() + 3, 'do_listing_count_fix', array($user_id, $package_id));
}

add_action('do_listing_count_fix', 'execute_listing_count_fix', 10, 2);

function execute_listing_count_fix($user_id, $package_id) {
    $count = count(get_posts(array(
        'post_type'      => 'listing',
        'author'         => $user_id,
        'post_status'    => 'publish',
        'posts_per_page' => -1,
        'fields'         => 'ids'
    )));

    global $wpdb;
    $wpdb->update(
        $wpdb->prefix . 'listeo_core_user_packages',
        array('package_count' => $count),
        array('id' => $package_id)
    );
}
/* Masquer la barre titre+menu sur la vue calendrier */
.dashboard-calendar-view .headline-with-filters { display: none !important; }

/* Masquer QR Scan du menu dashboard */
a[href*="qr-scan"] { display: none !important; }

/* Masquer "Détails de la réservation" et "Paiement du..." dans la popup calendrier */
div.inner-booking-list:has(li#details),
div.inner-booking-list:has(li#payment_due) { display: none !important; }

/* Masquer bouton "Confirmer paiement" et badge "non payé" sur les fiches réservation */
.mark-as-paid, a.mark-as-paid { display: none !important; }
.booking-status.unpaid { display: none !important; }

/* Légende calendrier réservations — couleurs alignées sur les événements FullCalendar */
#calendar-legend ul li.confirmed {
    color: #fff;
    background: #64bc36;
}
#calendar-legend ul li.confirmed:before {
    background: #fff;
}
#calendar-legend ul li.waiting {
    color: #3a8fb5;
    background: #61b2db20;
}
#calendar-legend ul li.waiting:before {
    background: #61b2db;
}
#calendar-legend ul li.expired {
    color: #fff;
    background: #ee3535;
}
#calendar-legend ul li.expired:before {
    background: #fff;
}

/* TEST FILEZILLA - TEMPORAIRE */
.enable-filters-button span, .enable-filters-button i { background-color: green !important; }
