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

Remove "Add New" for shadow taxonomies #45

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

Conversation

s3rgiosan
Copy link

This pull request addresses this #20

@s3rgiosan
Copy link
Author

Tagging @jeremyfelt for visibility.

@jeremyfelt
Copy link
Member

@s3rgiosan Thank you for the pull request! I took a look and was having a bit of trouble when a shadow taxonomy had more than somewhere around 5 terms. At that point, the UI shifts in the block editor and adds the search box above the list. Removing the action-create- pattern seems to make it so that only the search box remains. The list of terms is removed with the Add New option.

I started poking around at a way to work around it, but then it hit me that we may be able to use capabilities instead. In #46, I've changed the taxonomy registration so that the override_shadow_terms capability (which no user has) is required to add or manage terms. I believe this does the trick, or has in my testing so far.

Can you take a look at that and let me know if it works for your use case?

Separately, I'm intrigued by https://github.com/happyprime/shadow-terms/pull/45/files#diff-88cbf32328b8063e81b548feddc5e234b8a1b7593b71560b31dc300f52151284R260-R284 in your PR, which adds a shadow taxonomy identifier in REST responses. Is that something that would be useful as a whole?

Thanks!

@s3rgiosan
Copy link
Author

Can you take a look at that and let me know if it works for your use case?

Absolutely. I'll test it out asap.

Separately, I'm intrigued by https://github.com/happyprime/shadow-terms/pull/45/files#diff-88cbf32328b8063e81b548feddc5e234b8a1b7593b71560b31dc300f52151284R260-R284 in your PR, which adds a shadow taxonomy identifier in REST responses. Is that something that would be useful as a whole?

I have a use case where the block editor, with its blocks and term selection panels, doesn't align well with the whole editing experience.
I've implemented a custom post type named 'Game Result' and a custom post type named 'Team'. The relation between these two post types is made through a 'Team' shadow taxonomy created using the 'Shadow Terms' plugin.
Each time a content editor creates a game result, it inputs data into specific fields and selects from two different dropdowns the home team and the away team ('Team' shadow taxonomy terms).
This is all done in a wizard-type block in the block editor, providing a similar experience to what we have with the new WooCommerce product creation screen.

In order for this to work, I had to integrate in the block some of the logic we have in PHP. For example, determining if a taxonomy is a shadow taxonomy or not. I believe that exposing some of that logic in the REST responses, would simplify this kind of development.

@s3rgiosan
Copy link
Author

Hi @jeremyfelt

I took a look and was having a bit of trouble when a shadow taxonomy had more than somewhere around 5 terms. At that point, the UI shifts in the block editor and adds the search box above the list. Removing the action-create- pattern seems to make it so that only the search box remains. The list of terms is removed with the Add New option.

I tested out in my local environment and with more than 5 terms I get the search box above the term list, and no "Add New" button, with both my PR and yours #46

For comparison:
trunk

Screenshot 2024-02-24 at 22 05 24

s3rgiosan:feature/remove-add-new

Screenshot 2024-02-24 at 22 04 36

fix/20-remove-add-new

Screenshot 2024-02-24 at 22 06 37

Your approach feels way less hacky than mine 🚀🙌

Please don't hesitate to close my PR if you don't see a need for https://github.com/happyprime/shadow-terms/pull/45/files#diff-88cbf32328b8063e81b548feddc5e234b8a1b7593b71560b31dc300f52151284R260-R284

@s3rgiosan
Copy link
Author

I actually need some additional information in those REST endpoints to avoid having logic in the blocks that can be provided in PHP. I'm going to work on that and update this PR.

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.

None yet

2 participants