| @@ -1,73 +1,73 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. | |
| 3 | - | |
| 4 | -add_action('admin_enqueue_scripts', 'eshb_admin_enqueue_scripts'); | |
| 5 | -function eshb_admin_enqueue_scripts (){ | |
| 6 | - wp_enqueue_style( 'eshb-daterangepicker-style', ESHB_PL_URL . 'public/assets/css/date-range-picker.css', array(), ESHB_VERSION ); | |
| 7 | - wp_enqueue_style( 'eshb-admin-style', ESHB_PL_URL . 'admin/assets/css/admin.min.css', array(), ESHB_VERSION); | |
| 8 | - wp_enqueue_script('moment'); | |
| 9 | - wp_enqueue_script( 'eshb-date-range-picker-js', ESHB_PL_URL . 'public/assets/js/date-range-picker.js', array('jquery'),'3.1',true ); | |
| 10 | - wp_enqueue_script( 'eshb-admin-script', ESHB_PL_URL . 'admin/assets/js/admin.js', array('jquery'), ESHB_VERSION, true ); | |
| 11 | - wp_enqueue_script( 'eshb-admin-booking-script', ESHB_PL_URL . 'public/assets/js/booking.js', array('jquery'), ESHB_VERSION, true ); | |
| 12 | - | |
| 13 | - $min_max_settings_global = [ | |
| 14 | - 'calendar_start_date_buffer' => 0, | |
| 15 | - ]; | |
| 16 | - $min_max_settings = apply_filters( 'eshb_min_max_global_settings_localize', $min_max_settings_global); | |
| 17 | - $calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0; | |
| 18 | - | |
| 19 | - $eshb_admin_translations = [ | |
| 20 | - 'billingEmailErr' => __('Billing email not found!', 'easy-hotel'), | |
| 21 | - 'maximumTimeSlot' => __('Allowed max time for this slot is', 'easy-hotel'), | |
| 22 | - 'minimumTimeSlot' => __('Allowed min time for this slot is', 'easy-hotel'), | |
| 23 | - 'minNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Minimum', 'easy-hotel'), | |
| 24 | - 'maxNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Maximum', 'easy-hotel'), | |
| 25 | - 'minNightsErrorMsgAvCal' => __('Requried Minimum Nights:', 'easy-hotel'), | |
| 26 | - 'maxNightsErrorMsgAvCal' => __('Requried Maximum Nights:', 'easy-hotel'), | |
| 27 | - ]; | |
| 28 | - | |
| 29 | - $nonce_action = ESHB_Helper::generate_secure_nonce_action('eshb_global_nonce_action'); | |
| 30 | - wp_localize_script( 'eshb-admin-script', 'eshb_ajax', | |
| 31 | - array( | |
| 32 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 33 | - 'is_admin' => is_admin(), | |
| 34 | - 'nonce' => wp_create_nonce($nonce_action), | |
| 35 | - 'pluginURL' => ESHB_DIR_URL, | |
| 36 | - 'admin_translations' => $eshb_admin_translations, | |
| 37 | - 'calendar_start_date_buffer' => $calendar_start_date_buffer, | |
| 38 | - ) | |
| 39 | - ); | |
| 40 | - | |
| 41 | - | |
| 42 | - wp_localize_script('eshb-admin-script', 'eshb_rest', [ | |
| 43 | - 'root' => esc_url(rest_url()), | |
| 44 | - 'nonce' => wp_create_nonce('wp_rest'), | |
| 45 | - 'is_admin' => is_admin(), | |
| 46 | - ]); | |
| 47 | - | |
| 48 | - | |
| 49 | - // Get WordPress current locale | |
| 50 | - $locale = get_locale(); | |
| 51 | - $eshb_settings = get_option('eshb_settings'); | |
| 52 | - $apply_text_default = isset($eshb_settings['string_apply']) && !empty($eshb_settings['string_apply']) ? $eshb_settings['string_apply'] : ''; | |
| 53 | - $cancel_text_default = isset($eshb_settings['string_cancel']) && !empty($eshb_settings['string_cancel']) ? $eshb_settings['string_cancel'] : ''; | |
| 54 | - | |
| 55 | - | |
| 56 | - // Prepare translations dynamically based on current locale | |
| 57 | - $calendar_translations = [ | |
| 58 | - 'applyLabel' => !empty($apply_text_default) ? eshb_get_translated_string($apply_text_default) : __('Apply', 'easy-hotel'), | |
| 59 | - 'cancelLabel' => !empty($cancel_text_default) ? eshb_get_translated_string($cancel_text_default) : __('Cancel', 'easy-hotel'), | |
| 60 | - 'BookedTooltip' => __('Already Booked!', 'easy-hotel'), | |
| 61 | - 'holidayTooltip' => __('This is Holiday!', 'easy-hotel'), | |
| 62 | - 'fromLabel' => __('From', 'easy-hotel'), | |
| 63 | - 'toLabel' => __('To', 'easy-hotel'), | |
| 64 | - 'customRangeLabel' => __('Custom Range', 'easy-hotel'), | |
| 65 | - 'weekLabel' => __('W', 'easy-hotel'), | |
| 66 | - 'firstDay' => get_option('start_of_week'), // Get WordPress's start of the week setting | |
| 67 | - 'currentLocale' => $locale, // Pass current locale for debugging or further use | |
| 68 | - ]; | |
| 69 | - | |
| 70 | - | |
| 71 | - // Pass translations to JavaScript | |
| 72 | - wp_localize_script('eshb-date-range-picker-js', 'eshb_daterangepicker_i18n', $calendar_translations); | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. | |
| 3 | + | |
| 4 | +add_action('admin_enqueue_scripts', 'eshb_admin_enqueue_scripts'); | |
| 5 | +function eshb_admin_enqueue_scripts (){ | |
| 6 | + wp_enqueue_style( 'eshb-daterangepicker-style', ESHB_PL_URL . 'public/assets/css/date-range-picker.css', array(), ESHB_VERSION ); | |
| 7 | + wp_enqueue_style( 'eshb-admin-style', ESHB_PL_URL . 'admin/assets/css/admin.min.css', array(), ESHB_VERSION); | |
| 8 | + wp_enqueue_script('moment'); | |
| 9 | + wp_enqueue_script( 'eshb-date-range-picker-js', ESHB_PL_URL . 'public/assets/js/date-range-picker.js', array('jquery'),'3.1',true ); | |
| 10 | + wp_enqueue_script( 'eshb-admin-script', ESHB_PL_URL . 'admin/assets/js/admin.js', array('jquery'), ESHB_VERSION, true ); | |
| 11 | + wp_enqueue_script( 'eshb-admin-booking-script', ESHB_PL_URL . 'public/assets/js/booking.js', array('jquery'), ESHB_VERSION, true ); | |
| 12 | + | |
| 13 | + $min_max_settings_global = [ | |
| 14 | + 'calendar_start_date_buffer' => 0, | |
| 15 | + ]; | |
| 16 | + $min_max_settings = apply_filters( 'eshb_min_max_global_settings_localize', $min_max_settings_global); | |
| 17 | + $calendar_start_date_buffer = !empty($eshb_min_max_settings['calendar_start_date_buffer']) ? $eshb_min_max_settings['calendar_start_date_buffer'] : 0; | |
| 18 | + | |
| 19 | + $eshb_admin_translations = [ | |
| 20 | + 'billingEmailErr' => __('Billing email not found!', 'easy-hotel'), | |
| 21 | + 'maximumTimeSlot' => __('Allowed max time for this slot is', 'easy-hotel'), | |
| 22 | + 'minimumTimeSlot' => __('Allowed min time for this slot is', 'easy-hotel'), | |
| 23 | + 'minNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Minimum', 'easy-hotel'), | |
| 24 | + 'maxNightsErrorMsg' => __('Ops! This Reservation has been failed. Requried Maximum', 'easy-hotel'), | |
| 25 | + 'minNightsErrorMsgAvCal' => __('Requried Minimum Nights:', 'easy-hotel'), | |
| 26 | + 'maxNightsErrorMsgAvCal' => __('Requried Maximum Nights:', 'easy-hotel'), | |
| 27 | + ]; | |
| 28 | + | |
| 29 | + $nonce_action = ESHB_Helper::generate_secure_nonce_action('eshb_global_nonce_action'); | |
| 30 | + wp_localize_script( 'eshb-admin-script', 'eshb_ajax', | |
| 31 | + array( | |
| 32 | + 'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 33 | + 'is_admin' => is_admin(), | |
| 34 | + 'nonce' => wp_create_nonce($nonce_action), | |
| 35 | + 'pluginURL' => ESHB_DIR_URL, | |
| 36 | + 'admin_translations' => $eshb_admin_translations, | |
| 37 | + 'calendar_start_date_buffer' => $calendar_start_date_buffer, | |
| 38 | + ) | |
| 39 | + ); | |
| 40 | + | |
| 41 | + | |
| 42 | + wp_localize_script('eshb-admin-script', 'eshb_rest', [ | |
| 43 | + 'root' => esc_url(rest_url()), | |
| 44 | + 'nonce' => wp_create_nonce('wp_rest'), | |
| 45 | + 'is_admin' => is_admin(), | |
| 46 | + ]); | |
| 47 | + | |
| 48 | + | |
| 49 | + // Get WordPress current locale | |
| 50 | + $locale = get_locale(); | |
| 51 | + $eshb_settings = get_option('eshb_settings'); | |
| 52 | + $apply_text_default = isset($eshb_settings['string_apply']) && !empty($eshb_settings['string_apply']) ? $eshb_settings['string_apply'] : ''; | |
| 53 | + $cancel_text_default = isset($eshb_settings['string_cancel']) && !empty($eshb_settings['string_cancel']) ? $eshb_settings['string_cancel'] : ''; | |
| 54 | + | |
| 55 | + | |
| 56 | + // Prepare translations dynamically based on current locale | |
| 57 | + $calendar_translations = [ | |
| 58 | + 'applyLabel' => !empty($apply_text_default) ? eshb_get_translated_string($apply_text_default) : __('Apply', 'easy-hotel'), | |
| 59 | + 'cancelLabel' => !empty($cancel_text_default) ? eshb_get_translated_string($cancel_text_default) : __('Cancel', 'easy-hotel'), | |
| 60 | + 'BookedTooltip' => __('Already Booked!', 'easy-hotel'), | |
| 61 | + 'holidayTooltip' => __('This is Holiday!', 'easy-hotel'), | |
| 62 | + 'fromLabel' => __('From', 'easy-hotel'), | |
| 63 | + 'toLabel' => __('To', 'easy-hotel'), | |
| 64 | + 'customRangeLabel' => __('Custom Range', 'easy-hotel'), | |
| 65 | + 'weekLabel' => __('W', 'easy-hotel'), | |
| 66 | + 'firstDay' => get_option('start_of_week'), // Get WordPress's start of the week setting | |
| 67 | + 'currentLocale' => $locale, // Pass current locale for debugging or further use | |
| 68 | + ]; | |
| 69 | + | |
| 70 | + | |
| 71 | + // Pass translations to JavaScript | |
| 72 | + wp_localize_script('eshb-date-range-picker-js', 'eshb_daterangepicker_i18n', $calendar_translations); | |
| 73 | 73 | } |