How to differentiate b/w REST and POST requests of Gutenberg inside “save_post”
-
As we know that Gutenberg sends two requests when we hit the Publish/Update button:
- Request to WP REST API to create/update the post
- Request to post.php to save/submit the metaboxes
save_post
is triggered by both the requests. How do I know inside thesave_post
callback that the post is created/updated via Gutenberg, preferably in the second request? This is to avoid the double effect of the hook.I know some would suggest to add some meta value in the first request and use it to short-circuit the second callback or use a transient in a similar way. Filling up the meta table with useless data is not a good idea and transients don’t look to be a better solution IMHO.
Is there a consistent query argument or a header that can be relied upon? I couldn’t find any such thing in the two requests.
- The topic ‘How to differentiate b/w REST and POST requests of Gutenberg inside “save_post”’ is closed to new replies.