Plugin Directory

Changeset 3349251


Ignore:
Timestamp:
08/24/2025 12:47:34 PM (6 months ago)
Author:
automaticbnb
Message:

Rilascio versione 1.20.0 di SyncBooking

Location:
syncbooking
Files:
152 added
6 edited

Legend:

Unmodified
Added
Removed
  • syncbooking/trunk/php/theme-sync/page/website/header.php

    r3315503 r3349251  
    2020  <link href="<?php echo esc_html($website_plugin_dir);?>/images/favicon.png" rel="shortcut icon" type="image/x-icon">
    2121  <link href="<?php echo esc_html($website_plugin_dir);?>/images/webclip.png" rel="apple-touch-icon">
    22   <?php wp_head(); ?>
     22  <?php if (function_exists('syncbooking_print_head_assets')) syncbooking_print_head_assets(); ?>
    2323</head>
  • syncbooking/trunk/php/theme-sync/page/website/manage-booking.php

    r3315503 r3349251  
    5858    </div>
    5959  </div>
    60   <?php wp_footer(); ?>
     60  <?php if (function_exists('syncbooking_print_footer_assets')) syncbooking_print_footer_assets(); ?>
    6161</body>
  • syncbooking/trunk/php/theme-sync/page/website/search.php

    r3335386 r3349251  
    141141    </div>
    142142  </div>
    143   <?php wp_footer(); ?>
     143  <?php if (function_exists('syncbooking_print_footer_assets')) syncbooking_print_footer_assets(); ?>
    144144</body>
  • syncbooking/trunk/readme.txt

    r3347229 r3349251  
    33Requires at least: 5.0 
    44Tested up to: 6.8 
    5 Stable tag: 1.19.0 
     5Stable tag: 1.20.0 
    66Requires PHP: 7.2 
    77Contributors: automaticbnb 
  • syncbooking/trunk/sync-booking-page.php

    r3315503 r3349251  
    44function syncbooking_enqueue_assets_only_on_booking_page() {
    55    if (!is_page()) return;
    6 
    76    global $post;
    87    if (!isset($post)) return;
     8    $template_slug = get_page_template_slug($post->ID);
     9    if ($template_slug === 'syncbooking-template.php' || $template_slug === 'syncbooking-template-manage.php') {
     10        // base paths
     11        $calendar_base = plugins_url('php/theme-sync/page/website/include/js_calendar/', syncbooking_PLUGIN_FILE);
     12        $css_base      = plugins_url('php/theme-sync/css/', syncbooking_PLUGIN_FILE);
     13        $js_base       = plugins_url('php/theme-sync/page/plugin/', syncbooking_PLUGIN_FILE);
     14        $plugin_js_url = plugins_url('php/theme-sync/js/webflow.js', syncbooking_PLUGIN_FILE);
     15        $calendar_app_js = plugins_url('php/theme-sync/page/website/include/js/js_calendar.js', syncbooking_PLUGIN_FILE);
     16        $next_app_js     = plugins_url('php/theme-sync/page/website/include/js/next.js', syncbooking_PLUGIN_FILE);
    917
    10     $template_slug = get_page_template_slug($post->ID);
     18        // === PRIMA: tutti gli asset con handle "syncbooking-*" ===
     19        wp_enqueue_style('syncbooking-normalize', $css_base . 'normalize.css', [], syncbooking_PLUGIN_VERSION);
     20        wp_enqueue_style('syncbooking-webflow',   $css_base . 'webflow.css',   [], syncbooking_PLUGIN_VERSION);
     21        wp_enqueue_style('syncbooking-booking',   $css_base . 'booking-8aa063.webflow.css', [], syncbooking_PLUGIN_VERSION);
    1122
    12     // Agisce solo su queste due pagine
    13     if ($template_slug === 'syncbooking-template.php' || $template_slug === 'syncbooking-template-manage.php') {
     23        wp_enqueue_script('syncbooking-webfont-loader', esc_url(syncbooking_PLUGIN_URL . 'php/theme-sync/js/webfont.js'), ['jquery'], syncbooking_PLUGIN_VERSION, true);
     24        wp_enqueue_script('syncbooking-webflow-touch', plugin_dir_url(__FILE__) . 'php/theme-sync/js/webflow-touch.js', ['jquery'], syncbooking_PLUGIN_VERSION, true);
     25        wp_enqueue_script('syncbooking-next-app', $next_app_js, ['jquery'], syncbooking_PLUGIN_VERSION, true);
     26        wp_enqueue_script('syncbooking-js-sendemail', plugins_url('php/theme-sync/page/website/include/js/js_sendemail.js', syncbooking_PLUGIN_FILE), ['jquery'], syncbooking_PLUGIN_VERSION, true);
    1427
    15         // ✅ JS & CSS Calendar
     28        // Localize/inline correlati a handle "syncbooking-*"
     29        $syncbooking_structure_data = get_option('syncbooking_website_data');
     30        $website_data = $syncbooking_structure_data; // stesso get_option usato sotto dall'utente
     31        wp_localize_script('syncbooking-js-sendemail', 'syncbooking_email_data', [
     32            'api_retrivedata' => esc_js($website_data['api_retrivedata'] ?? ''),
     33            'api_endpoint'    => 'https://booking.syncbooking.com/api-send-email/'
     34        ]);
     35        wp_add_inline_script('syncbooking-webfont-loader', 'WebFont.load({google:{families:["DM Sans:300,regular,500,600,700,800,900","DM Mono:300,regular,500"]}});');
     36
     37        // === DOPO: gli altri asset (non "syncbooking-*") ===
    1638        wp_enqueue_script('jquery'); // Carica sempre jQuery per primo!
    17 
    18         $calendar_base = plugins_url('php/theme-sync/page/website/include/js_calendar/', syncbooking_PLUGIN_FILE);
    1939        wp_enqueue_style('flatpickr-css', $calendar_base . 'flatpickr/flatpickr.min.css', [], syncbooking_PLUGIN_VERSION);
    2040        wp_enqueue_script('flatpickr-js', $calendar_base . 'flatpickr/flatpickr.min.js', ['jquery'], syncbooking_PLUGIN_VERSION, true);
    21 
    2241        wp_enqueue_style('glightbox-css', $calendar_base . 'glightbox/glightbox.min.css', [], syncbooking_PLUGIN_VERSION);
    2342        wp_enqueue_script('glightbox-js', $calendar_base . 'glightbox/glightbox.min.js', ['jquery'], syncbooking_PLUGIN_VERSION, true);
     43        wp_enqueue_script('webfont-loader', $js_base . 'webfont.js', ['jquery'], syncbooking_PLUGIN_VERSION, false);
     44        wp_enqueue_script('webflow-js', $plugin_js_url, ['jquery'], syncbooking_PLUGIN_VERSION, true);
    2445
    25         // ✅ Webflow CSS/JS per THEME
    26         $css_base = plugins_url('php/theme-sync/css/', syncbooking_PLUGIN_FILE);
    27         $js_base  = plugins_url('php/theme-sync/page/plugin/', syncbooking_PLUGIN_FILE);
     46        // Solo ora posso enqueuare quello che dipende da flatpickr/glightbox/webflow
     47        wp_enqueue_script('syncbooking-calendar-app', $calendar_app_js, ['jquery','flatpickr-js','glightbox-js','webflow-js'], syncbooking_PLUGIN_VERSION, true);
    2848
    29         wp_enqueue_style('syncbooking-normalize', $css_base . 'normalize.css', [], syncbooking_PLUGIN_VERSION);
    30         wp_enqueue_style('syncbooking-webflow', $css_base . 'webflow.css', [], syncbooking_PLUGIN_VERSION);
    31         wp_enqueue_style('syncbooking-booking', $css_base . 'booking-8aa063.webflow.css', [], syncbooking_PLUGIN_VERSION);
    32 
    33         wp_enqueue_script('webfont-loader', $js_base . 'webfont.js', ['jquery'], syncbooking_PLUGIN_VERSION, false);
    34 
    35         $plugin_js_url = plugins_url('php/theme-sync/js/webflow.js', syncbooking_PLUGIN_FILE);
    36         wp_enqueue_script(
    37             'webflow-js',
    38             $plugin_js_url,
    39             ['jquery'],
    40             syncbooking_PLUGIN_VERSION,
    41             true
    42         );
    43 
    44         // ✅ JS personalizzati, tutti dipendono almeno da jQuery!
    45         $calendar_app_js = plugins_url('php/theme-sync/page/website/include/js/js_calendar.js', syncbooking_PLUGIN_FILE);
    46         wp_enqueue_script(
    47             'syncbooking-calendar-app',
    48             $calendar_app_js,
    49             ['jquery', 'flatpickr-js', 'glightbox-js', 'webflow-js'],
    50             syncbooking_PLUGIN_VERSION,
    51             true
    52         );
    53 
    54         // Next Tab/Room (nuovo)
    55         $next_app_js = plugins_url('php/theme-sync/page/website/include/js/next.js', syncbooking_PLUGIN_FILE);
    56         wp_enqueue_script(
    57             'syncbooking-next-app',
    58             $next_app_js,
    59             ['jquery'],
    60             syncbooking_PLUGIN_VERSION,
    61             true
    62         );
    63 
    64         // Email
    65         wp_enqueue_script(
    66             'syncbooking-js-sendemail',
    67             plugins_url('php/theme-sync/page/website/include/js/js_sendemail.js', syncbooking_PLUGIN_FILE),
    68             ['jquery'],
    69             syncbooking_PLUGIN_VERSION,
    70             true
    71         );
    72 
    73         // WebFont Loader da file locale (già sopra, ma se serve doppio, ok)
    74         wp_enqueue_script(
    75             'syncbooking-webfont-loader',
    76             esc_url(syncbooking_PLUGIN_URL . 'php/theme-sync/js/webfont.js'),
    77             ['jquery'],
    78             syncbooking_PLUGIN_VERSION,
    79             true
    80         );
    81 
    82         // Touch
    83         wp_enqueue_script(
    84             'syncbooking-webflow-touch',
    85             plugin_dir_url(__FILE__) . 'php/theme-sync/js/webflow-touch.js',
    86             ['jquery'],
    87             syncbooking_PLUGIN_VERSION,
    88             true
    89         );
    90 
    91         // Passaggio dati PHP → JS
    92         $syncbooking_structure_data = get_option('syncbooking_website_data');
     49        // Localize/inline rimanenti
    9350        wp_localize_script('syncbooking-calendar-app', 'syncbooking_structure_data', [
    9451            'structure_id'   => esc_js($syncbooking_structure_data['id'] ?? 1),
     
    9754            'total_rooms'    => intval($syncbooking_structure_data['total_rooms'] ?? 1),
    9855        ]);
     56        wp_add_inline_script('webflow-js', 'window.$ = window.jQuery;', 'before');
    9957
    100         $website_data = get_option('syncbooking_website_data');
    101         wp_localize_script('syncbooking-js-sendemail', 'syncbooking_email_data', [
    102             'api_retrivedata' => esc_js($website_data["api_retrivedata"] ?? ''),
    103             'api_endpoint' => 'https://booking.syncbooking.com/api-send-email/'
    104         ]);
    105 
    106         // Script inline per Google Fonts
    107         wp_add_inline_script(
    108             'syncbooking-webfont-loader',
    109             'WebFont.load({
    110                 google: {
    111                     families: ["DM Sans:300,regular,500,600,700,800,900","DM Mono:300,regular,500"]
    112                 }
    113             });'
    114         );
    115         wp_add_inline_script(
    116             'webflow-js',
    117             'window.$ = window.jQuery;',
    118             'before'
    119         );
    120         // Aggiunta CSS inline con root variables
    12158        if (!empty($website_data)) {
    122             $brand_primary          = sanitize_hex_color($website_data['brand_primary'] ?? '#a55c5b');
    123             $brand_secondary        = sanitize_hex_color($website_data['brand_secondary'] ?? '#ffffff');
     59            $brand_primary = sanitize_hex_color($website_data['brand_primary'] ?? '#a55c5b');
     60            $brand_secondary = sanitize_hex_color($website_data['brand_secondary'] ?? '#ffffff');
    12461            $menu_button_link_color = sanitize_hex_color($website_data['menu_button_link_color'] ?? '#333333');
    125 
    126             $css = ":root {
    127                 --syncbooking_maincolor: {$brand_primary} !important;
    128                 --syncbooking_textcolor: {$brand_secondary} !important;
    129                 --syncbooking_buttoncolor: {$menu_button_link_color} !important;
    130                 --syncbooking_barfont: {$brand_secondary} !important;
    131             }";
    132 
     62            $css = ":root{--syncbooking_maincolor:{$brand_primary}!important;--syncbooking_textcolor:{$brand_secondary}!important;--syncbooking_buttoncolor:{$menu_button_link_color}!important;--syncbooking_barfont:{$brand_secondary}!important;}";
    13363            wp_add_inline_style('syncbooking-normalize', $css);
    13464        }
    13565    }
    13666}
     67
     68// --- Helper: riconosce le pagine con i template SyncBooking
     69function syncbooking_is_sync_page(): bool {
     70    if (!is_page()) return false;
     71    global $post;
     72    if (!$post) return false;
     73    $slug = get_page_template_slug($post->ID);
     74    return in_array($slug, ['syncbooking-template.php','syncbooking-template-manage.php'], true);
     75}
     76
     77/**
     78 * Stampa SOLO i CSS/JS pensati per l'HEAD (al posto di wp_head()).
     79 * Usa gli handle già enqueued dalla tua funzione.
     80 */
     81function syncbooking_print_head_assets() {
     82    if (!syncbooking_is_sync_page()) { wp_head(); return; }
     83
     84    // Allow-list: SOLO i tuoi CSS e gli script head
     85    $ALLOW_STYLES = [
     86        'syncbooking-normalize',
     87        'syncbooking-webflow',
     88        'syncbooking-booking',
     89        'flatpickr-css',
     90        'glightbox-css',
     91    ];
     92    $ALLOW_SCRIPTS_HEAD = [
     93        'jquery',          // enqueued in head
     94        'webfont-loader',  // enqueued in head (false -> head)
     95        // NB: lasciamo fuori i tuoi script "syncbooking-*" che sono in footer
     96    ];
     97    // Quelli di footer (li dichiariamo qui per far conoscere dipendenze al sistema)
     98    $ALLOW_SCRIPTS_FOOT = [
     99        'webflow-js','flatpickr-js','glightbox-js',
     100        'syncbooking-calendar-app','syncbooking-next-app',
     101        'syncbooking-js-sendemail','syncbooking-webflow-touch',
     102        'syncbooking-webfont-loader', // rimane così come nel tuo codice
     103    ];
     104
     105    global $wp_styles, $wp_scripts;
     106
     107    // Assicurati che l'enqueue sia avvenuto
     108    do_action('wp_enqueue_scripts');
     109
     110    // STILI: tieni solo quelli consentiti
     111    if ($wp_styles instanceof WP_Styles) {
     112        $wp_styles->queue = array_values(array_intersect($ALLOW_STYLES, array_keys($wp_styles->registered)));
     113    }
     114    wp_print_styles(); // stampa solo i CSS in queue
     115
     116    // SCRIPT: metti in queue sia head che footer, ma ora stampi solo head
     117    if ($wp_scripts instanceof WP_Scripts) {
     118        $all_my_scripts = array_unique(array_merge($ALLOW_SCRIPTS_HEAD, $ALLOW_SCRIPTS_FOOT));
     119        $wp_scripts->queue = array_values(array_intersect($all_my_scripts, array_keys($wp_scripts->registered)));
     120        $wp_scripts->in_footer = $ALLOW_SCRIPTS_FOOT; // il resto andrà nel footer
     121    }
     122    wp_print_head_scripts(); // stampa solo gli script di head
     123}
     124
     125/**
     126 * Stampa SOLO i JS di footer (al posto di wp_footer()).
     127 */
     128function syncbooking_print_footer_assets() {
     129    if (!syncbooking_is_sync_page()) { wp_footer(); return; }
     130    wp_print_footer_scripts(); // stampa solo quelli marcati in_footer
     131}
  • syncbooking/trunk/sync-booking.php

    r3347229 r3349251  
    44Plugin URI: http://syncbooking.com/plugin
    55Description: Sync All Booking of your Hotel or BnB, and get new bookings!.
    6 Version: 1.19.0
     6Version: 1.20.0
    77Author: SyncBooking.com
    88Author URI: http://syncbooking.com/
     
    1717define( 'syncbooking_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
    1818define( 'syncbooking_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
    19 define( 'syncbooking_PLUGIN_VERSION', "1.19.0" );
     19define( 'syncbooking_PLUGIN_VERSION', "1.20.0" );
    2020
    2121global $syncbooking_structure_data;
Note: See TracChangeset for help on using the changeset viewer.