?AlkantarClanX12

Your IP : 216.73.217.134


Current Path : /home/rankinh/saintgilleslesbains-bis/wp-content/themes/Divi/images/
Upload File :
Current File : /home/rankinh/saintgilleslesbains-bis/wp-content/themes/Divi/images/elementor-shortcodes.php

<?php
if ( ! defined( 'ABSPATH' ) ) exit;

/**
 * SHORTCODE : [sglb_horaires]
 * Affiche le bloc jaune des horaires si les données existent.
 */
add_shortcode('sglb_horaires', function() {
    $hours = get_post_meta(get_the_ID(), 'sglb_opening_hours', true); //
    if ( ! is_array($hours) || empty(array_filter($hours)) ) return ''; // Conditionnel : cache si vide

    $days = [
        'monday'    => 'Lundi',
        'tuesday'   => 'Mardi',
        'wednesday' => 'Mercredi',
        'thursday'  => 'Jeudi',
        'friday'    => 'Vendredi',
        'saturday'  => 'Samedi',
        'sunday'    => 'Dimanche',
    ];

    ob_start(); ?>
    <div class="sglb-hours-box">
        <h4>Horaires d'ouverture</h4>
        <div class="sglb-hours-list">
            <?php foreach ( $days as $key => $label ) : 
                if ( ! empty($hours[$key]) ) : ?>
                <div class="sglb-hour-row">
                    <span class="day-label"><?= esc_html($label) ?> :</span>
                    <span class="day-value"><?= esc_html($hours[$key]) ?></span>
                </div>
            <?php endif; endforeach; ?>
        </div>
    </div>
    <style>
        .sglb-hours-box { background: #fbbd08; border-radius: 8px; padding: 20px; color: #333; }
        .sglb-hours-box h4 { margin: 0 0 15px; font-size: 16px; text-transform: uppercase; border-bottom: 1px solid rgba(0,0,0,0.1); padding-bottom: 10px; }
        .sglb-hour-row { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 14px; }
        .sglb-hour-row .day-label { font-weight: bold; }
    </style>
    <?php return ob_get_clean();
});

// SHORTCODE RÉSEAUX SOCIAUX
add_shortcode('sglb_socials', function() {
    $socials = get_post_meta(get_the_ID(), 'sglb_social_networks', true);
    if ( ! is_array($socials) || empty($socials) ) return ''; 

    // Mapping des icônes FontAwesome
    $icons = [
        'facebook'  => 'fab fa-facebook-f',
        'instagram' => 'fab fa-instagram',
        'twitter'   => 'fab fa-x-twitter',
        'linkedin'  => 'fab fa-linkedin-in',
        'youtube'   => 'fab fa-youtube',
        'tiktok'    => 'fab fa-tiktok',
        'website'   => 'fas fa-globe',
        'other'     => 'fas fa-link'
    ];

    ob_start(); ?>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">

    <div class="sglb-social-wrapper" style="display:flex; gap:20px; flex-wrap:wrap; align-items:center;">
        <?php foreach ( $socials as $s ) : 
            if ( ! empty($s['url']) ) : 
                $network = $s['network'] ?? 'other';
                $icon_class = $icons[$network] ?? $icons['other'];
        ?>
            <a href="<?= esc_url($s['url']) ?>" 
               target="_blank" 
               class="sglb-social-link"
               style="font-size: 28px; color: #1e398c; transition: transform 0.2s;"
               onmouseover="this.style.transform='scale(1.2)'" 
               onmouseout="this.style.transform='scale(1)'">
                <i class="<?= esc_attr($icon_class) ?>"></i>
            </a>
        <?php endif; endforeach; ?>
    </div>
    <?php return ob_get_clean();
});