This commit is contained in:
2026-04-22 22:00:50 +02:00
parent 16be247ce1
commit e979fbe755
46 changed files with 5302 additions and 274 deletions

View File

@@ -52,6 +52,13 @@ require_once CAREI_RESERVATION_PATH . 'includes/class-softra-api.php';
require_once CAREI_RESERVATION_PATH . 'includes/class-rest-proxy.php';
require_once CAREI_RESERVATION_PATH . 'includes/class-admin-panel.php';
/**
* Load plugin textdomain
*/
add_action( 'plugins_loaded', function () {
load_plugin_textdomain( 'carei-reservation', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
} );
/**
* Initialize plugin on plugins_loaded
*/
@@ -64,7 +71,7 @@ add_action( 'plugins_loaded', function () {
if ( empty( $api_url ) || empty( $username ) || empty( $password ) ) {
add_action( 'admin_notices', function () {
echo '<div class="notice notice-error"><p><strong>Carei Reservation:</strong> Brak konfiguracji API w pliku .env (url, username, password).</p></div>';
echo '<div class="notice notice-error"><p><strong>Carei Reservation:</strong> ' . esc_html__( 'Brak konfiguracji API w pliku .env (url, username, password).', 'carei-reservation' ) . '</p></div>';
} );
return;
}
@@ -103,16 +110,38 @@ add_action( 'elementor/widgets/register', function ( $widgets_manager ) {
* Enqueue frontend assets
*/
add_action( 'wp_enqueue_scripts', function () {
// Flatpickr — cross-browser, locale-aware date/time picker (CDN)
wp_register_style(
'carei-flatpickr-css',
'https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.css',
array(),
'4.6.13'
);
wp_register_script(
'carei-flatpickr-js',
'https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/flatpickr.min.js',
array(),
'4.6.13',
true
);
wp_register_script(
'carei-flatpickr-pl',
'https://cdn.jsdelivr.net/npm/flatpickr@4.6.13/dist/l10n/pl.js',
array( 'carei-flatpickr-js' ),
'4.6.13',
true
);
wp_register_style(
'carei-reservation-css',
CAREI_RESERVATION_URL . 'assets/css/carei-reservation.css',
array(),
array( 'carei-flatpickr-css' ),
CAREI_RESERVATION_VERSION
);
wp_register_script(
'carei-reservation-js',
CAREI_RESERVATION_URL . 'assets/js/carei-reservation.js',
array(),
array( 'carei-flatpickr-js', 'carei-flatpickr-pl' ),
CAREI_RESERVATION_VERSION,
true
);
@@ -120,4 +149,115 @@ add_action( 'wp_enqueue_scripts', function () {
'restUrl' => esc_url_raw( rest_url( 'carei/v1/' ) ),
'nonce' => wp_create_nonce( 'wp_rest' ),
) );
wp_localize_script( 'carei-reservation-js', 'careiI18n', array(
// API / sieć
'errorApiHttp' => esc_html__( 'Błąd API: HTTP %status%', 'carei-reservation' ),
'errorTimeout' => esc_html__( 'Przekroczono czas oczekiwania. Spróbuj ponownie.', 'carei-reservation' ),
'errorNetwork' => esc_html__( 'Brak połączenia z serwerem. Sprawdź internet i spróbuj ponownie.', 'carei-reservation' ),
'errorLoading' => esc_html__( 'Błąd ładowania', 'carei-reservation' ),
// Selecty / placeholdery
'selectPlaceholder' => esc_html__( 'Wybierz...', 'carei-reservation' ),
'selectSegment' => esc_html__( 'Wybierz segment pojazdu', 'carei-reservation' ),
'selectSegmentShort' => esc_html__( 'Wybierz segment', 'carei-reservation' ),
'selectPickup' => esc_html__( 'Wybierz miejsce odbioru', 'carei-reservation' ),
'selectReturn' => esc_html__( 'Wybierz miejsce zwrotu', 'carei-reservation' ),
'segmentLabel' => esc_html__( 'Segment %name%', 'carei-reservation' ),
'noSegments' => esc_html__( 'Brak segmentów', 'carei-reservation' ),
'pickupPlaceholder' => esc_html__( 'Najpierw wybierz segment', 'carei-reservation' ),
'pickupLabel' => esc_html__( 'Miejsce odbioru', 'carei-reservation' ),
'returnLabel' => esc_html__( 'Miejsce zwrotu', 'carei-reservation' ),
'noPickupForSegment' => esc_html__( 'Brak lokalizacji dla tego segmentu', 'carei-reservation' ),
'noLocations' => esc_html__( 'Brak lokalizacji', 'carei-reservation' ),
// Daty
'dateStart' => esc_html__( 'Rozpoczęcie', 'carei-reservation' ),
'dateEnd' => esc_html__( 'Zakończenie', 'carei-reservation' ),
'warnPastDate' => esc_html__( '%label% — data lub godzina już minęły', 'carei-reservation' ),
'dateStartPast' => esc_html__( 'Data lub godzina rozpoczęcia już minęły', 'carei-reservation' ),
'dateEndPast' => esc_html__( 'Data lub godzina zakończenia już minęły', 'carei-reservation' ),
'dateEndAfterStart' => esc_html__( 'Data zakończenia musi być po dacie rozpoczęcia', 'carei-reservation' ),
'enterDateFrom' => esc_html__( 'Podaj datę rozpoczęcia', 'carei-reservation' ),
'enterDateTo' => esc_html__( 'Podaj datę zakończenia', 'carei-reservation' ),
// Dni/Doby (pluralizacja PL)
'daysCount' => wp_kses( __( 'Wybrano: <strong>%count% %unit%</strong>', 'carei-reservation' ), array( 'strong' => array() ) ),
'dayWord' => esc_html__( 'dzień', 'carei-reservation' ),
'daysWord' => esc_html__( 'dni', 'carei-reservation' ),
'dayOne' => esc_html__( 'doba', 'carei-reservation' ),
'dayFew' => esc_html__( 'doby', 'carei-reservation' ),
'dayMany' => esc_html__( 'dób', 'carei-reservation' ),
// Ceny
'pricePerDay' => esc_html__( '%price% zł/doba', 'carei-reservation' ),
'priceSimple' => esc_html__( '%price% zł', 'carei-reservation' ),
'priceSimpleFmt' => esc_html__( '%price% zł', 'carei-reservation' ),
'priceRange' => esc_html__( 'od %min% do %max% zł', 'carei-reservation' ),
'priceLineDaily' => esc_html__( '%perDay% zł/doba × %days% = %total% zł', 'carei-reservation' ),
'free' => esc_html__( 'Gratis', 'carei-reservation' ),
// Zagranica / akcje
'btnRemove' => esc_html__( 'Usuń', 'carei-reservation' ),
'btnAdd' => esc_html__( 'Dodaj', 'carei-reservation' ),
// Walidacja formularza
'enterFirstName' => esc_html__( 'Podaj imię', 'carei-reservation' ),
'enterLastName' => esc_html__( 'Podaj nazwisko', 'carei-reservation' ),
'enterEmail' => esc_html__( 'Podaj poprawny adres e-mail', 'carei-reservation' ),
'enterPhone' => esc_html__( 'Podaj numer telefonu (min. 9 cyfr)', 'carei-reservation' ),
'privacyRequired' => esc_html__( 'Wymagana zgoda na Politykę Prywatności', 'carei-reservation' ),
// Przyciski
'btnSubmit' => esc_html__( 'Wyślij', 'carei-reservation' ),
'btnProcessing' => esc_html__( 'Przetwarzanie...', 'carei-reservation' ),
'btnBookingInProgress' => esc_html__( 'Rezerwuję...', 'carei-reservation' ),
'btnConfirmBooking' => esc_html__( 'Potwierdź rezerwację', 'carei-reservation' ),
// Flow klienta / rezerwacji
'loadingSummary' => esc_html__( 'Ładowanie podsumowania...', 'carei-reservation' ),
'errorCustomerCreate' => esc_html__( 'Nie udało się utworzyć klienta', 'carei-reservation' ),
'errorCustomerCreatePrefix' => esc_html__( 'Błąd tworzenia klienta: %msg%', 'carei-reservation' ),
'errorSummaryPrefix' => esc_html__( 'Błąd pobierania podsumowania: %msg%', 'carei-reservation' ),
'errorBookingFailed' => esc_html__( 'Rezerwacja nie powiodła się', 'carei-reservation' ),
// Pakiet ochronny (komentarz booking)
'protectionComment' => esc_html__( 'Pakiet ochronny: %name% — %perDay% zł/doba × %days% = %total% zł (do doliczenia poza systemem)', 'carei-reservation' ),
// Podsumowanie — etykiety
'labelSegment' => esc_html__( 'Segment', 'carei-reservation' ),
'labelFrom' => esc_html__( 'Od', 'carei-reservation' ),
'labelTo' => esc_html__( 'Do', 'carei-reservation' ),
'labelPickup' => esc_html__( 'Miejsce odbioru', 'carei-reservation' ),
'labelReturn' => esc_html__( 'Miejsce zwrotu', 'carei-reservation' ),
'labelRenter' => esc_html__( 'Najemca', 'carei-reservation' ),
'labelEmail' => esc_html__( 'Email', 'carei-reservation' ),
'labelPhone' => esc_html__( 'Telefon', 'carei-reservation' ),
'labelSelectedOptions' => esc_html__( 'Wybrane opcje', 'carei-reservation' ),
'labelMessage' => esc_html__( 'Wiadomość', 'carei-reservation' ),
'labelAuto' => esc_html__( 'auto', 'carei-reservation' ),
'labelExtraCharge' => esc_html__( 'do doliczenia', 'carei-reservation' ),
'labelVat' => esc_html__( 'VAT', 'carei-reservation' ),
'labelProtectionPackage' => esc_html__( 'Pakiet ochronny', 'carei-reservation' ),
'labelToPay' => esc_html__( 'Do zapłaty', 'carei-reservation' ),
// Tabela
'thName' => esc_html__( 'Nazwa', 'carei-reservation' ),
'thQuantity' => esc_html__( 'Ilość', 'carei-reservation' ),
'thNet' => esc_html__( 'Netto', 'carei-reservation' ),
'thGross' => esc_html__( 'Brutto', 'carei-reservation' ),
// Reject reasons (Softra → PL fallback)
'rejectCarNotFound' => esc_html__( 'Brak dostępnego pojazdu w wybranym terminie. Zmień daty lub segment.', 'carei-reservation' ),
'rejectInvalidDateRange' => esc_html__( 'Nieprawidłowy zakres dat', 'carei-reservation' ),
'rejectBranchNotFound' => esc_html__( 'Nie znaleziono oddziału', 'carei-reservation' ),
'rejectCustomerExists' => esc_html__( 'Klient o tych danych już istnieje w systemie', 'carei-reservation' ),
'rejectInvalidPesel' => esc_html__( 'Nieprawidłowy numer PESEL', 'carei-reservation' ),
'rejectPriceListExpired' => esc_html__( 'Cennik wygasł. Odśwież formularz i spróbuj ponownie.', 'carei-reservation' ),
// Success / aria
'orderNumber' => esc_html__( 'Nr zamówienia: %no%', 'carei-reservation' ),
'announceBookingConfirmed' => esc_html__( 'Rezerwacja potwierdzona', 'carei-reservation' ),
'announceSummary' => esc_html__( 'Podsumowanie rezerwacji', 'carei-reservation' ),
) );
} );