| Server IP : 62.72.47.131 / Your IP : 216.73.217.34 Web Server : Apache/2.4.66 (Debian) System : Linux 975cdb959a49 5.14.0-611.55.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 19 15:19:29 EDT 2026 x86_64 User : ( 501) PHP Version : 8.3.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/themes/flatsome-child/ |
Upload File : |
<?php
function enqueue_fullcalendar_assets() {
wp_enqueue_style('fullcalendar-css', 'https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.css');
wp_enqueue_script('fullcalendar-js', 'https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/index.global.min.js', array(), null, true);
wp_enqueue_script('fullcalendar-locales', 'https://cdn.jsdelivr.net/npm/fullcalendar@6.1.9/locales-all.global.min.js', array('fullcalendar-js'), null, true);
// Example PHP event array
$events = [
[
'title' => '✅ เปิด 16.30-19.30',
'start' => '2025-10-01',
],
[
'title' => '❌ ปิด',
'start' => '2025-10-02',
'color' => '#e74c3c'
],
[
'title' => '✅ เปิด 08.30-11.30',
'start' => '2025-10-03',
],
[
'title' => '✅ เปิด 16.30-19.30',
'start' => '2025-10-06',
],
[
'title' => '❌ ปิด',
'start' => '2025-10-07',
'color' => '#e74c3c'
],
[
'title' => '✅ เปิด 16.30-19.30',
'start' => '2025-10-08',
],
[
'title' => '✅ เปิด 08.30-11.30',
'start' => '2025-10-09',
],
[
'title' => '❌ ปิด',
'start' => '2025-10-10',
'color' => '#e74c3c'
]
];
wp_localize_script('fullcalendar-locales', 'myCalendarData', [
'events' => $events
]);
// Inline JS to render calendar with PHP events
wp_add_inline_script('fullcalendar-locales', "
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
if (!calendarEl) return;
var calendar = new FullCalendar.Calendar(calendarEl, {
locale: 'th',
initialView: 'dayGridMonth',
events: myCalendarData.events
});
calendar.render();
});
");
}
add_action('wp_enqueue_scripts', 'enqueue_fullcalendar_assets');
function render_fullcalendar_shortcode() {
return '<div id="calendar" style="max-width: 900px; margin: 0 auto;"></div>';
}
add_shortcode('fullcalendar', 'render_fullcalendar_shortcode');
function add_fontawesome() {
wp_enqueue_style('fa', 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css');
}
add_action('wp_enqueue_scripts', 'add_fontawesome');
function add_thai_fonts() {
wp_enqueue_style('prompt-font', 'https://fonts.googleapis.com/css2?family=Prompt:wght@300;400;600&display=swap');
}
add_action('wp_enqueue_scripts', 'add_thai_fonts');