-
Notifications
You must be signed in to change notification settings - Fork 39
Fix WPML Compatibility Issue with Event Bubbles #626
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughAdds WPML language propagation to frontend scripts and AJAX (via localized vars, AJAX payload, and ajax_url), wraps qTip2 tooltip initialization in a try/catch with console warnings, and applies formatting-only edits to documentation ( Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CalendarJS
participant WP_AJAX
participant WP_Server
User->>CalendarJS: navigate / request events
CalendarJS->>CalendarJS: build ajaxData (include wpml_language.lang if present)
CalendarJS->>WP_AJAX: POST ajaxData (includes lang when available)
WP_AJAX->>WP_Server: handle request (respect lang param if provided)
WP_Server-->>WP_AJAX: return localized events
WP_AJAX-->>CalendarJS: respond with events
CalendarJS->>User: render calendar/events
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
assets/js/default-calendar.js (1)
72-76: Minor: lang is passed in both URL and POST dataYou’re appending lang to the AJAX URL in PHP and also including it in POST data here. Redundant but harmless. If you want to reduce duplication, you can omit one (prefer keeping it on the URL for WPML).
Also applies to: 120-124
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
CLAUDE.md(2 hunks)assets/js/default-calendar.js(3 hunks)includes/main.php(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- CLAUDE.md
🧰 Additional context used
📓 Path-based instructions (1)
**/*.php
📄 CodeRabbit Inference Engine (CLAUDE.md)
**/*.php: Ensure code remains compatible with WordPress 4.2 or higher (avoid using WordPress APIs introduced after 4.2 without fallbacks).
Use PHP features compatible with PHP 7.3+ and do not require newer PHP versions.
You may rely on required PHP extensions cURL, iconv, JSON, and mbstring; ensure proper error handling when using them.
Files:
includes/main.php
🧬 Code Graph Analysis (1)
assets/js/default-calendar.js (2)
includes/admin/fields/datetime-format.php (2)
month(248-276)year(284-304)includes/browser.php (1)
isMobile(241-244)
🪛 Biome (2.1.2)
assets/js/default-calendar.js
[error] 114-114: Shouldn't redeclare 'ajaxData'. Consider to delete it or rename it.
'ajaxData' is defined here:
(lint/suspicious/noRedeclare)
🔇 Additional comments (1)
includes/main.php (1)
277-285: WPML: lang propagation via ajax_url looks goodThe conditional add_query_arg using ICL_LANGUAGE_CODE is a safe, backward-compatible way to ensure WPML context on admin-ajax. This should resolve the missing-content issue leading to qTip errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
CLAUDE.md (1)
57-57: License line is correct; consider linking and SPDX clarity (nit).Text matches the required “GPL v2 or later.” For clarity and discoverability, link to the LICENSE file and include the SPDX identifier in code headers.
Suggested tweak:
-This plugin is licensed under the GPL v2 or later. +This plugin is licensed under the GNU General Public License v2.0 or later (GPL-2.0-or-later). See the [LICENSE](LICENSE) file for details.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
CLAUDE.md(2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-11T05:36:37.203Z
Learnt from: CR
PR: Xtendify/Simple-Calendar#0
File: CLAUDE.md:0-0
Timestamp: 2025-08-11T05:36:37.203Z
Learning: The plugin is licensed under GPL v2 or later; ensure contributions are compatible with this license.
Applied to files:
CLAUDE.md
🔇 Additional comments (3)
CLAUDE.md (3)
19-19: No-op content change.Appears to be formatting-only; no semantic change.
24-24: Whitespace tidy-up — OK.Trailing whitespace removal improves diffs and consistency.
16-16: Shortcode registration is correct: both[simple_calendar]and[calendar]are supportedVerification shows in includes/shortcodes.php that both
add_shortcode('simple_calendar', …)add_shortcode('calendar', …)are registered (with
gcalas a deprecated alias). The documentation’s use of[simple_calendar]is valid and does not need reverting.
This reverts commit 877b907.
🐛 Problem
Event bubbles do not work when clicking on calendar dots/events when WPML (WordPress Multilingual Plugin) is activated. This causes JavaScript errors
(
getClientRects is not a function) and prevents users from viewing event details on multilingual sites.Related Issues:
🔍 Root Cause
getClientRectserrors💡 Solution
Implemented comprehensive WPML compatibility by:
1. Enhanced AJAX URL Generation (
includes/main.php)ajax_url()method to detect WPML activationlang=en,lang=es, etc.) to AJAX URLs when WPML is active2. Language-aware JavaScript Variables (
includes/functions/shared.php)3. Updated AJAX Requests (
assets/js/default-calendar.js)4. Error Handling Improvements
📁 Files Changed
google-calendar-events/includes/main.phpgoogle-calendar-events/includes/functions/shared.phpgoogle-calendar-events/assets/js/default-calendar.js✅ Testing
📈 Impact
🔧 Add-on Compatibility
No updates required for premium add-ons as they rely on the core plugin's calendar rendering and AJAX systems.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation