-
Notifications
You must be signed in to change notification settings - Fork 7
Fix bug with Wordpress 5.8 - media library grid mode infinite loading was replaced by button load #7
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
base: master
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR fixes a compatibility issue with WordPress 5.8 where the media library grid mode's infinite loading feature was replaced by a button load mechanism. The fix transitions from hooking into the AJAX action directly to using WordPress's built-in ajax_query_attachments_args filter, which allows the plugin to modify query arguments without interfering with WordPress's response structure.
Key Changes:
- Replaced the
wp_ajax_query-attachmentsaction hook with theajax_query_attachments_argsfilter hook - Added a new
wp_media_categories_ajax_filter_query()function that focuses solely on filtering query arguments - Preserved the existing taxonomy filtering logic (specific categories and "no category" filtering)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| wp-media-categories/includes/hooks.php | Updated hook registration to use the filter-based approach instead of the action-based approach for WordPress 5.8 compatibility |
| wp-media-categories/includes/ajax.php | Added new filter function that extracts taxonomy filtering logic from the original AJAX handler |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Hi, I think filtering query should be enough for using taxonomy in media grid.
The problem is with additional data, that original Wordpress ajax request return (version 5.8).
https://developer.wordpress.org/reference/functions/wp_ajax_query_attachments/
