Skip to content

Conversation

@profanek
Copy link

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/
image

Copy link
Contributor

Copilot AI left a 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-attachments action hook with the ajax_query_attachments_args filter 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.

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