Skip to content

Add native asset cachebusting and redundant-plugin notice - #11

Merged
eleshar merged 10 commits into
developfrom
feat/native-cachebusting
Jul 29, 2026
Merged

Add native asset cachebusting and redundant-plugin notice#11
eleshar merged 10 commits into
developfrom
feat/native-cachebusting

Conversation

@eleshar

@eleshar eleshar commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Filter `script_loader_src`/`style_loader_src` to rewrite local assets' `ver` query arg to `filemtime()`, replacing the Cachebuster plugin globally (theme, plugin, core), with disable/skip-handle filters and a request-scoped mtime cache.
  • Dismissible admin notice (registry-based) flagging Cachebuster, Safe SVG and Change Mail Sender when active, since this codebase already covers (or, for Safe SVG, will cover) their function natively. Notice-only, never deactivates.
  • Version bump to 0.2.0 and CHANGELOG entries for both features.

Closes #10

Test plan

  • `php -l` clean on all PHP files
  • CI: PHP code quality (PHPCS) passes
  • CI: Validate plugin passes
  • Manual: enqueue a local script/style and confirm `ver` becomes a filemtime; confirm an external URL is untouched
  • Manual: activate Cachebuster/Safe SVG/Change Mail Sender on a test site and confirm the notice renders, is dismissible, and stays dismissed

Summary by CodeRabbit

  • New Features

    • Added native cachebusting for local scripts and styles using their file modification times.
    • Added controls to enable cachebusting or exclude specific assets.
    • Added dismissible admin notices identifying redundant plugins whose functionality is provided natively.
  • Bug Fixes

    • External and unresolved asset URLs remain unchanged, preventing broken links.
  • Documentation

    • Updated the changelog with the new cachebusting and admin notice features.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@eleshar, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 40 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: fe6c025c-6e8f-40a2-a973-89ba6523576d

📥 Commits

Reviewing files that changed from the base of the PR and between 8a24538 and 74b4b23.

📒 Files selected for processing (2)
  • inc/class-cachebusting.php
  • inc/class-redundant-plugins-notice.php

Note

.coderabbit.yml has unrecognized properties

CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.

⚠️ Parsing warnings (1)
Validation error: Unrecognized keys: "version", "path_instructions"
⚙️ Configuration instructions
  • Please see the configuration documentation for more information.
  • You can also validate your configuration using the online YAML validator.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Walkthrough

The plugin now provides native local-asset cachebusting and a dismissible admin notice for redundant plugins. Both modules are loaded during initialization, the plugin version is updated to 0.2.0, and the changelog documents the additions.

Changes

Native plugin features

Layer / File(s) Summary
Local asset cachebusting
inc/class-cachebusting.php
Local script and style URLs use guarded filesystem resolution and cached filemtime() values to rewrite the ver query argument, while external and unresolved assets remain unchanged.
Redundant plugin detection
inc/class-redundant-plugins-notice.php
A slug-keyed registry identifies active redundant plugins through plugin paths, names, and multisite network activation.
Dismissible admin notices
inc/class-redundant-plugins-notice.php
Authorized administrators see undis­missed notices, and nonce-checked AJAX requests persist per-user dismissals.
Plugin integration and release metadata
{{PLUGIN_SLUG}}.php, CHANGELOG.md
Both modules are loaded during initialization, version values are bumped to 0.2.0, and the new features are documented.

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

Sequence Diagram(s)

Asset version rewriting

sequenceDiagram
  participant WordPress
  participant CachebustingFilter
  participant MtimeCache
  participant PathResolver
  WordPress->>CachebustingFilter: Filter script/style URL
  CachebustingFilter->>MtimeCache: Get mtime for cleaned local URL
  MtimeCache->>PathResolver: Resolve URL to filesystem path
  PathResolver-->>MtimeCache: Return validated path
  MtimeCache-->>CachebustingFilter: Return cached filemtime
  CachebustingFilter-->>WordPress: Return URL with updated ver
Loading

Redundant plugin notice dismissal

sequenceDiagram
  participant Administrator
  participant AdminNotice
  participant DismissalAjax
  participant UserMeta
  Administrator->>AdminNotice: Load admin page
  AdminNotice->>UserMeta: Read dismissed slugs
  AdminNotice-->>Administrator: Render matching notice
  Administrator->>DismissalAjax: Dismiss notice with nonce and slug
  DismissalAjax->>UserMeta: Store dismissed slug
  DismissalAjax-->>Administrator: Return JSON success
Loading

Possibly related issues

🚥 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 set: native cachebusting plus a redundant-plugin notice.
Linked Issues check ✅ Passed The summary indicates the cachebusting, notice, version bump, and changelog updates align with the linked issue requirements.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are indicated beyond the requested implementation, version bump, and changelog update.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ 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 feat/native-cachebusting

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.

@mergify

mergify Bot commented Jul 29, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@eleshar

eleshar commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 2

🤖 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 `@inc/class-cachebusting.php`:
- Around line 47-62: Update the containment check in the path-resolution flow
around $real_base and $real_path to require either an exact base-directory match
or a path beginning with the normalized base directory followed by a directory
separator. Preserve the existing false returns for unresolved paths and reject
sibling paths such as similarly prefixed directories.

In `@inc/class-redundant-plugins-notice.php`:
- Around line 28-46: Update ls_starter_redundant_plugins_registry and
ls_starter_redundant_plugins_notice so the safe-svg entry is marked with a
planned/status value and rendered with an informational-only template that does
not recommend deactivation; preserve the existing deactivation notice for
entries without that status.
🪄 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: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro Plus

Run ID: 1e43fc17-2f6d-4e70-af7e-da6c17b2bf16

📥 Commits

Reviewing files that changed from the base of the PR and between ac05cd6 and 8a24538.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • inc/class-cachebusting.php
  • inc/class-redundant-plugins-notice.php
  • {{PLUGIN_SLUG}}.php

Comment thread inc/class-cachebusting.php
Comment thread inc/class-redundant-plugins-notice.php
@eleshar

eleshar commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

Both points applied.

  1. Traversal guard now compares against a trailing-slashed base, so a sibling directory whose name merely prefixes the base (wp-content-backup) no longer passes.
  2. Registry entries carry a status. planned entries render an informational notice with no deactivation prompt — Safe SVG must not be suggested for deactivation while no native replacement exists. replaced entries keep the original wording.

@eleshar

eleshar commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@eleshar
eleshar merged commit 571c7da into develop Jul 29, 2026
6 checks passed
@eleshar
eleshar deleted the feat/native-cachebusting branch July 29, 2026 11:53
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.

Native cachebusting and redundant-plugin notice

1 participant