Skip to content

Added ICS Feed option#728

Open
Akhill2020 wants to merge 6 commits into
mainfrom
ICS-import
Open

Added ICS Feed option#728
Akhill2020 wants to merge 6 commits into
mainfrom
ICS-import

Conversation

@Akhill2020

@Akhill2020 Akhill2020 commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description: I have added new feed type ie "ICS Feed" and add fields for that to display event via ICS feed.
Clikcup: https://app.clickup.com/t/1867958/86d3e1phg
After: https://drive.google.com/file/d/1lYjaemX1WqR8ogPzk7wmHJqlUR7slwYH/view?usp=drivesdk

Summary by CodeRabbit

  • New Features
    • Added support for events from uploaded ICS/iCal calendar files, including optional recurring-event expansion.
    • Added an ICS feed admin settings tab with instant file upload, filename display, and removal, plus search, recurring mode, and configurable max results.
    • Registered the new ics-feed feed type by default.
  • Bug Fixes
    • Improved the admin UI with immediate switching between URL vs file input modes, conditional event color picker visibility, clearer upload status messaging, and responsive layout adjustments.
  • Chores
    • Bumped the npm package version to 4.1.0.

@Akhill2020
Akhill2020 requested a review from rosinghal July 13, 2026 09:01
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds an ICS feed type with uploaded-file storage, ICS event parsing and recurrence support, calendar admin settings, AJAX uploads, feed registration, and related admin UI updates.

Changes

ICS feed support

Layer / File(s) Summary
ICS storage and event engine
includes/feeds/ics-feed.php
Adds ICS upload validation and storage, file cleanup, source loading, event parsing, recurrence expansion, filtering, limiting, and transient caching.
ICS settings and save processing
includes/feeds/admin/ics-feed-admin.php
Adds the ICS settings tab and panel, upload MIME support, metadata handling, and save/delete processing.
AJAX upload flow
includes/admin/ajax.php, assets/js/admin.js
Adds the upload endpoint and client-side file-change handler with validation, success, and error states.
Feed registration and editor integration
includes/installation.php, includes/objects.php, assets/css/admin.css, package.json
Registers the ICS feed type and taxonomy term, initializes admin hooks, enables object-class filtering, styles ICS controls, and updates the package version.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

Suggested reviewers: rosinghal

Sequence Diagram(s)

sequenceDiagram
  participant AdminFileInput
  participant Ajax
  participant Ics_Feed
  AdminFileInput->>Ajax: submit FormData to simcal_upload_ics_feed
  Ajax->>Ajax: verify nonce and calendar edit capability
  Ajax->>Ics_Feed: save_uploaded_file(post_id, file)
  Ics_Feed-->>Ajax: return saved filename or error
  Ajax-->>AdminFileInput: return JSON upload result
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding a new ICS Feed option and related UI/handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ICS-import

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 PHPStan (2.2.5)

PHP Warning: require(/vendor/composer/../guzzlehttp/promises/src/functions_include.php): Failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 39
Warning: require(/vendor/composer/../guzzlehttp/promises/src/functions_include.php): Failed to open stream: No such file or directory in /vendor/composer/autoload_real.php on line 39
PHP Fatal error: Uncaught Error: Failed opening required '/vendor/composer/../guzzlehttp/promises/src/functions_include.php' (include_path='.:/usr/share/php') in /vendor/composer/autoload_real.php:39
Stack trace:
#0 /vendor/composer/autoload_real.php(43): {closure}()
#1 /vendor/autoload.php(25): ComposerAutoloaderInit0248fdf029b8abd0ce3787652580d175::getLoader()
#2 phar:///usr/bin/phpstan/bin/phpstan(46): require_once('...')
#3 phar:///usr/bin/phpstan/bin/phpstan(107): _PHPStan_02959ca10{closure}()
#4 /usr/bin/phpstan(7): require('...')
#5 {main}
thrown in /vendor/composer/autoload_real.php on line 39
Fatal error: Uncaught Error: Failed opening required '/vendor/composer/../guzzlehttp/promises/src/functions_include.php' (include_path='.:/usr/share/php') in /vendor/composer/autoload_real.php:39
Stack trace:
#0 /vendor/composer/autoload_real.php(43): {closure}()
#1 /vendor/autoload.php(25): ComposerAutoloaderInit0248fdf029b8abd0ce3787652580d175::getLoader()
#2 phar:///usr/bin/phpstan/bin/phpstan(46): require_once('...')
#3 phar:///usr/bin/phpstan/bin/phpstan(107): _PHPStan_02959ca10{closure}()
#4 /usr/bin/phpstan(7): require('...')
#5 {main}
thrown in /vendor/composer/autoload_real.php on line 39


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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
assets/js/admin.js (1)

613-657: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

User-facing strings are hardcoded in English.

Messages like 'Uploading ICS file...', 'Current file: ', the reload prompt, the failure message, and the injected Remove uploaded ICS file label bypass translation, whereas their server-rendered counterparts in ics-feed-admin.php use __()/esc_html_e(). Consider passing localized strings through the existing simcal_admin localized object (or wp.i18n) for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@assets/js/admin.js` around lines 613 - 657, Replace the hardcoded English
strings in the ICS upload flow with localized values supplied through the
existing simcal_admin object (or the established wp.i18n mechanism), including
the reload prompt, upload status, current-file prefix, upload failure fallback,
and injected remove-file label. Add the corresponding translations where
simcal_admin is localized, while preserving the existing success and error
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@includes/feeds/admin/ics-feed-admin.php`:
- Around line 126-172: Run Prettier with write mode on the changed files,
including the panel-rendering block around the
simcal_ics_feed_settings_fields_before action, to normalize mixed tab/space
indentation and resolve all formatting failures reported by Prettier --check.
- Around line 255-256: Update the _ics_feed_search_query handling in the POST
save flow to unslash the submitted value with wp_unslash() and sanitize it with
sanitize_text_field() before passing it to update_post_meta(). Replace
esc_attr() for this stored value so filter_events_by_search_query compares the
plain sanitized query against event text.

In `@includes/feeds/ics-feed.php`:
- Around line 638-673: Update the RRULE iteration around fast_forward_rrule(),
$matched, and the count_limit check so COUNT tracks every recurrence in the
series, including occurrences skipped before time_min. Derive and preserve the
skipped recurrence ordinal or increment the count while fast-forwarding, then
ensure visible occurrences stop once the original COUNT is exhausted.

---

Nitpick comments:
In `@assets/js/admin.js`:
- Around line 613-657: Replace the hardcoded English strings in the ICS upload
flow with localized values supplied through the existing simcal_admin object (or
the established wp.i18n mechanism), including the reload prompt, upload status,
current-file prefix, upload failure fallback, and injected remove-file label.
Add the corresponding translations where simcal_admin is localized, while
preserving the existing success and error behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 95aa7086-45f2-410f-8706-ca9ae1282cfe

📥 Commits

Reviewing files that changed from the base of the PR and between c791d7d and a9bbe44.

📒 Files selected for processing (8)
  • assets/css/admin.css
  • assets/js/admin.js
  • includes/admin/ajax.php
  • includes/feeds/admin/ics-feed-admin.php
  • includes/feeds/ics-feed.php
  • includes/installation.php
  • includes/objects.php
  • package.json

Comment thread includes/feeds/admin/ics-feed-admin.php Outdated
Comment thread includes/feeds/admin/ics-feed-admin.php Outdated
Comment thread includes/feeds/ics-feed.php

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@includes/feeds/admin/ics-feed-admin.php`:
- Around line 127-135: Move the PHP opening tag before the docblock surrounding
the simcal_ics_feed_settings_fields_before hook, so the documentation remains a
PHP comment rather than being emitted as page content. Keep the hook invocation
and its $post_id argument unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a4ba575c-81d1-47b6-8c71-1ab6dc0ef5cc

📥 Commits

Reviewing files that changed from the base of the PR and between fc3c97b and 7eb45e6.

📒 Files selected for processing (4)
  • assets/css/admin.css
  • assets/js/admin.js
  • includes/feeds/admin/ics-feed-admin.php
  • includes/feeds/ics-feed.php
🚧 Files skipped from review as they are similar to previous changes (2)
  • assets/js/admin.js
  • includes/feeds/ics-feed.php

Comment thread includes/feeds/admin/ics-feed-admin.php Outdated
Comment thread includes/feeds/admin/ics-feed-admin.php
Comment thread includes/feeds/ics-feed.php
Comment thread includes/feeds/ics-feed.php
Comment thread includes/feeds/ics-feed.php

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
includes/feeds/admin/ics-feed-admin.php (2)

324-325: 🚀 Performance & Scalability | 🟡 Minor | ⚡ Quick win

Enforce the 2,500-event cap server-side.

The HTML max attribute is bypassable; a crafted save request can persist a value above 2500 and defeat the intended event-processing limit.

Proposed fix
-			$max_results = isset($_POST['_ics_feed_max_results']) ? absint(esc_attr($_POST['_ics_feed_max_results'])) : 2500;
+			$max_results = isset($_POST['_ics_feed_max_results'])
+				? min(2500, absint(esc_attr($_POST['_ics_feed_max_results'])))
+				: 2500;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@includes/feeds/admin/ics-feed-admin.php` around lines 324 - 325, Update the
_ics_feed_max_results handling in the admin save flow to clamp the sanitized
submitted value to a maximum of 2,500 before calling update_post_meta. Preserve
the existing 2,500 default when the field is absent and ensure crafted requests
above the cap are persisted as 2,500.

63-66: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Register the ICS MIME allowance before AJAX upload validation.

wp_ajax_simcal_upload_ics_feed calls save_uploaded_file() on the uploaded file, but the upload_mimes filter is only registered from the calendar edit screen’s constructor. On admin-ajax.php, that screen guard is false, so .ics/.ical uploads can be rejected before the handler runs. Register this filter for the AJAX upload path before running wp_handle_upload().

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@includes/feeds/admin/ics-feed-admin.php` around lines 63 - 66, Update the
hook initialization around simcal_is_admin_screen() and register_hooks() so the
ICS MIME allowance is also registered for the wp_ajax_simcal_upload_ics_feed
path. Ensure the relevant upload_mimes filter is attached before
save_uploaded_file() reaches wp_handle_upload(), while preserving the existing
calendar-screen behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@includes/feeds/admin/ics-feed-admin.php`:
- Around line 324-325: Update the _ics_feed_max_results handling in the admin
save flow to clamp the sanitized submitted value to a maximum of 2,500 before
calling update_post_meta. Preserve the existing 2,500 default when the field is
absent and ensure crafted requests above the cap are persisted as 2,500.
- Around line 63-66: Update the hook initialization around
simcal_is_admin_screen() and register_hooks() so the ICS MIME allowance is also
registered for the wp_ajax_simcal_upload_ics_feed path. Ensure the relevant
upload_mimes filter is attached before save_uploaded_file() reaches
wp_handle_upload(), while preserving the existing calendar-screen behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 867e6087-3ce8-49df-9319-fc39451ea501

📥 Commits

Reviewing files that changed from the base of the PR and between 0f641c3 and 61e9844.

📒 Files selected for processing (2)
  • assets/css/admin.css
  • includes/feeds/admin/ics-feed-admin.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • assets/css/admin.css

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants