-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
getEditedPostContext()
doesn't return what it used to.
#59224
Comments
Possibly the I'm not sure the back compatibility break was intentional. I think @youknowriad has been working on some of this so might know more. |
Yes, Call |
Can you share more in which case it's returning empty for you? |
@Hug0-Drelon tagging you once more in case you can follow up on this as we're in the midst of the 6.5 release cycle. |
Sorry for the delay @youknowriad.
|
This matches my expectation personally, the page are the only places where we actually set a "context" for the block editor template. For the others, there's no need. |
Hi @youknowriad, Could you explain why there is no need for other screens (e.g. Navigations, Patterns, Templates, Global Styles...) to have a context? In other word, I don't mind |
The
|
Thanks for the insight @youknowriad! |
Closing this for now. Thanks @Hug0-Drelon |
Description
What?
getEditedPostContext()
selector from the Site Editor store doesn't return what it used to as of WordPress 6.5.Also it seems to be deprecated reading this, but no warning is raised in the console.
Given that, I think it breaks backward compatibility. For instance, it broke Polylang Pro plugin sidebar in the Site Editor.
Here is a summary of what we got (might not be exhaustive be we can get an idea):
{templateSlug: your-template-slug}
but only for templates, not template parts! (which are the only entities managed in Site Editor at this point).{templateSlug: your-template-slug}
for global style, page as template (e.g. 404), templates. Otherwise{postType: 'your-post-type', postId: 'your-post-id', templateSlug: 'if-applicable'}
for patterns orundefined
for navigation.{}
...We manage to find a way to fix this in Polylang Pro plugin, but it'd be great to have some insight on how to get the current post type and post id (currently we're using
getEditedPostId()
andgetEditedPostType()
but it doesn't return the same values for global styles for instance).In other words, we would like to have a trustful way of retrieving the current edited post type and post id.
Step-by-step reproduction instructions
Call
getEditedPostContext()
in several WordPress versions.Call
getEditedPostId()
andgetEditedPostType()
.Screenshots, screen recording, code snippet
No response
Environment info
We reproduce with Polylang Pro activated of course, but any plugin using
getEditedPostContext()
could face this issue.Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
The text was updated successfully, but these errors were encountered: