Simple-Calendar icon indicating copy to clipboard operation
Simple-Calendar copied to clipboard

Fix WPML Compatibility Issue with Event Bubbles Revert

Open Akhill2020 opened this issue 3 months ago • 1 comments

Summary by CodeRabbit

  • New Features
    • Added multilingual compatibility: calendar AJAX requests now include the current language when available (WPML), ensuring language-appropriate data.
  • Bug Fixes
    • Improved resilience of tooltips: failures during tooltip initialization no longer break calendar rendering; errors are safely logged.
  • Documentation
    • Updated shortcode reference to use [simple_calendar] for embedding calendars.

Akhill2020 avatar Oct 09 '25 09:10 Akhill2020

Walkthrough

Adds WPML language propagation to AJAX requests and localized script variables, updates shortcode name in documentation, and wraps qTip2 initialization in try-catch. JavaScript now uses shared ajaxData for grid/list navigation and includes lang when available. PHP appends lang to admin-ajax URL and exposes wpml_language to scripts.

Changes

Cohort / File(s) Summary of Changes
Documentation update
CLAUDE.md
Replace shortcode reference from "[calendar]" to "[simple_calendar]".
AJAX data + tooltip handling
assets/js/default-calendar.js
Switch to shared ajaxData for grid/list navigation; include lang when available; add try-catch around qTip2 initialization; keep existing behavior for positioning/show/hide/render.
WPML var localization
includes/functions/shared.php
Inject wpml_language into localized JS variables when ICL_LANGUAGE_CODE is defined.
AJAX URL language support
includes/main.php
Modify ajax_url() to append lang query parameter when WPML is active; otherwise return base admin-ajax.php URL.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User as User
  participant UI as Calendar UI (JS)
  participant WP as WordPress admin-ajax.php
  participant WPML as WPML (lang context)

  Note over UI: Localized vars include wpml_language (if defined)
  User->>UI: Navigate calendar (grid/list)
  UI->>UI: Build ajaxData { action, ... , id, lang? }
  alt WPML active
    UI->>WP: AJAX request with lang query + ajaxData.lang
    WP->>WPML: Resolve language context
    WPML-->>WP: Language applied
  else No WPML
    UI->>WP: AJAX request without lang
  end
  WP-->>UI: JSON response (events/calendar HTML)
  rect rgba(230,250,230,0.6)
    Note right of UI: Initialize qTip2 tooltips
    UI->>UI: try { qTip2(...) } catch { warn and continue }
  end

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • Xtendify/Simple-Calendar#626 — Implements the same WPML lang additions and ajaxData/qTip2 adjustments across JS and PHP.
  • Xtendify/Simple-Calendar#625 — Touches the same documentation file, introducing CLAUDE.md which this PR updates.
  • Xtendify/Simple-Calendar#630 — Reverts the WPML lang and qTip2/ajaxData changes introduced here.

Suggested reviewers

  • enginnk

Poem

A hop, a skip, a multilingual spin—
Calendars whisper, “lang” tucked in.
Tooltips behave (we try, we catch),
Dates align, a perfect match.
From grid to list, I thump with cheer—
Simple hops, clearer days appear! 🐇📅

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The title is confusing and does not clearly convey the main change because it awkwardly combines “Fix WPML Compatibility Issue with Event Bubbles” and “Revert” without explaining what is being reverted, and the summary changes do not actually perform a revert, making the title misleading and unclear. Rename the title to clearly reflect the actual change, for example “Restore WPML compatibility for event bubbles” or “Add WPML language support to event bubble AJAX calls,” so that it clearly and concisely summarizes the main update.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch rohit/wpml-event-bubble-issue-revert

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 09 '25 09:10 coderabbitai[bot]