Skip to content
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

New Feat: Admin List Tables - allow third party plugin to add filters #7285

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

pulsovi
Copy link
Contributor

@pulsovi pulsovi commented Mar 10, 2024

Description

My donations come from a limited number of donors.

Some of them have several email addresses and use them randomly.

I took care to merge the different accounts of each donor.

Thus, donors can access their entire donation history, regardless of the email address used to make these donations.

For my part, I want to be able to filter the list of donations in the back office according to a donor ID.

I found that the API endpoint is perfectly capable of handling this filter, it is simply missing in the React version of the donations view.

This PR aims to extend the flexibility of ListTable:

The Give\Donations\Endpoints\ListDonations class is extendable since version 3.4.0, so we can make the API capable of handling all kinds of filters.

With this modification, we can now add these filters to the native view.

Affects

Admin List Tables

Testing Instructions

Add some JS code on the front end page (via some snippet) :

document.addEventListener("DOMContentLoaded", () => {
    wp.hooks.addFilter('give-donations-list-table-filters', 'namespace', filters => {
        return [
            ...filters,
            {
                name: 'donor',
                type: 'search',
                text: 'Donor',
                ariaLabel: 'Search by Donor'
            },
        ];
    });
});

Go to back office > Give > Donations

New Field appears in filter fields : Donor.
Type in it ID of a Donor.

And Tadaaa ! You can filter donation by donor id.

Pre-review Checklist

  • Acceptance criteria satisfied and marked in related issue
  • Relevant @unreleased tags included in DocBlocks
  • Includes unit tests
  • Reviewed by the designer (if follows a design)
  • Self Review of code and UX completed

Copy link

This PR is stale because it has been open 45 days with no activity. Stale PRs will NOT be automatically closed.

@github-actions github-actions bot added the Stale label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant