Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 11, 2025

Ajaxify Cache Purging Notice ✅

Implementation complete!

  • Analyze current cache purge notice implementation
  • Understand requirements: AJAX dismiss without page reload, keep it simple, no new JS files
  • Add AJAX handler for dismissing the notice in includes/admin/notices.php
  • Add inline JavaScript to handle AJAX dismiss on button click
  • Run linter to ensure code quality (passed with no errors)
  • Run security scanner (no issues found)
  • Revert .gitignore changes per feedback
  • Implementation complete and ready for review

Summary

This PR adds AJAX functionality to the cache purge notice that appears after plugin activation/deactivation.

Changes Made

1. Added AJAX Handler (dismiss_notice_ajax())

  • Handles notice dismissal via AJAX
  • Verifies nonce for security
  • Checks user permissions (manage_options)
  • Deletes transient/site_transient based on network mode

2. Updated Notice Display (maybe_display_purge_cache_plugin_notice())

  • Added data-notice-id and data-nonce attributes
  • Added CSS class powered-cache-dismissible-notice for targeting
  • Added CSS class powered-cache-dismiss-button to secondary dismiss button
  • Removed duplicate X dismiss button markup (WordPress adds it automatically)
  • Added inline JavaScript for AJAX handling

3. Inline JavaScript Implementation

  • Uses vanilla JavaScript (no jQuery dependency)
  • Intercepts clicks on both .notice-dismiss (X button) and .powered-cache-dismiss-button
  • Sends AJAX request using XMLHttpRequest
  • Smooth fade-out animation (300ms) before removing notice
  • Graceful degradation: if JavaScript disabled, href fallback still works

Key Features

✅ Notice dismisses without page reload
✅ Works with both "X" button and "Dismiss this notice" button
✅ Smooth fade-out animation for better UX
✅ Proper nonce verification for security
✅ Graceful fallback if JavaScript disabled
✅ Works on all admin pages (dashboard, plugins, etc.)
✅ No new JS file needed (inline script)
✅ No external dependencies
✅ PHPCS clean (no errors or warnings)

Testing Notes

  • Passes PHPCS linting with no errors
  • Uses WordPress core AJAX functions
  • Maintains backward compatibility
  • CodeQL security scan: no issues found
Original prompt

This section details on the original issue you should resolve

<issue_title>ajaxify cache purging notice</issue_title>
<issue_description>It'd give a better UX if you just ajaxified the cache purge notification so it pops up right after a plugin (de)activation.</issue_description>

<agent_instructions>implement this dismissing notice thing, without adding extra complexity to plugin. Don't load a new js file, keep it simple since notification will be displayed admin dashboard not just setting page</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Ajaxify cache purging notice for better UX Ajaxify cache purge notice dismissal Nov 11, 2025
Copilot AI requested a review from mustafauysal November 11, 2025 12:11
Copy link
Member

@mustafauysal mustafauysal left a comment

Choose a reason for hiding this comment

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

@copilot skip adding tests at this time, the tests are way too bigger than the actual code itself

Copy link
Member

@mustafauysal mustafauysal left a comment

Choose a reason for hiding this comment

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

@copilot undo changes in .gitignore

Co-authored-by: mustafauysal <[email protected]>
Copy link
Contributor Author

Copilot AI commented Nov 11, 2025

@copilot undo changes in .gitignore

Reverted .gitignore changes in ba2442e

@mustafauysal mustafauysal marked this pull request as ready for review November 11, 2025 12:31
@mustafauysal mustafauysal merged commit e112641 into develop Nov 11, 2025
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.

ajaxify cache purging notice

2 participants