-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Extensibility: Add a way for third parties to perform additional save validation #13413
Comments
@gziolo @youknowriad: Any thoughts or ideas for alternative approaches? |
Adding @aduth and @adamsilverstein as they may have thoughts on async filters. |
I'm not that familiar with all the parties involved in the post save flow. I know that we use all those effects for actions which operate on the store: I think @aduth had some thoughts about how to deal with extensibility in that area. |
Previously: #7020 |
In what way is |
Calling There's no other good opportunity to call |
Have a look at AdvancedCustomFields/acf#113 for some context on the requirements here. |
It took me some time to find a very related issue #4674 where TLDR; is
The proposed solution by @adamsilverstein was sufficient for the author:
|
Such an approach won't work as it will be too late to lock post saving by time |
Good point. My original proposal of something like a filter for the 'isPublishable' selector could have addressed this. I am working a similar feature for another plugin (trying to prevent publishing when certain conditions are not met when the user clicks publish or update). I'll report back here if I have a viable approach for this without adding a new filter. |
My use case for a similar need:
We're working around this with subsequent calls to those 3rd party tools when a product is changed back to draft, but ideally the transition to |
Sorry, I have a question on my closed case #13620 Why do you not listen MutationObserver for handling all changes in the DOM? How do you plan to work with native browser spell check? There are many other third party scripts which make changes using Range API (for changing some part of text). So you will ignore these changes too. We can emulate changes after replace some part of text with Range API. We do it using fake InputEvent which we fire on editable field. But this is not clear solution. And this fake event doesn't work for Classic block (TinyMCE editor in Gutenberg). Solutions suggested by you is not applicable in our case. |
There is an issue in trac that seems related, at least server-side. |
Related: #16249 which adds the ability to lock (prevent) post autosaving. |
Any updates on this? |
Hello All, I have created a ticket to WordPress where we can all contribute there. As this issue goes to a blocker we need to find the solutions as earliest. Ticket: https://core.trac.wordpress.org/ticket/48959 Best |
Any updates on this? |
Hi @noisysocks, @zhitaryksergey, @acafourek & @eballeste - I'm still trying to understand what is required here, or if perhaps your needs can be met with existing features - namely post saving/autosaving locks and data store subscriptions.
Can you start with post saving locked and only unlock it when validation passes? See my comment on the ACF thread - AdvancedCustomFields/acf#113 (comment) |
In an easy, perfect world, PHP would be able to easily validate the saving data - like an AJAX call to the back end that fires a filter like But, everyone keeps telling me that JavaScript is the present and future :) We're using some JS validation now that watches for field changes, then uses It's all very doable to people with a lot of WP+Gutenberg knowledge and dev resources but it doesn't seem very straight forward to the less experienced. It would be great to roll everything up into one simple event or filter that lets you check what's being saved and return true/false with error message(s). |
Any of you guys have fixed or hacked it? |
Hey there, I want to bring some attention to this issue. Advanced Custom Fields is waiting for years (3.5 years to be exact) for a hook to implement the much-used validation prior to Gutenberg (AdvancedCustomFields/acf#113). Are there any updates on this or a reason why this can't be implemented? Thanks |
As per this comment - #44971 (comment) what is still missing here is an async |
I took a pass at adding a preSave hook in #58022 |
Does Thank you @adamsilverstein for your work! |
Is your feature request related to a problem? Please describe.
Plugins like Advanced Custom Fields require a way to perform additional validation when a post is published or updated. This validation can be asynchronous.
Describe the solution you'd like
I'm thinking that the most flexible solution here would be to wrap the call to
apiFetch()
made byrequestPostUpdate()
with a filter. This will let third parties perform as much additional asynchronous validation as they would like, or even replace the entire API call with their own.Example:
Describe alternatives you've considered
I considered an alternative approach using
PluginPrePublishPanel
but this does not handle the case where validation needs to happen on an update to an already published post.The text was updated successfully, but these errors were encountered: