-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
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):
- WP 6.1 => didn't exist yet!
- WP 6.2 => returns
{templateSlug: your-template-slug}but only for templates, not template parts! (which are the only entities managed in Site Editor at this point). - WP 6.3 => returns
{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 orundefinedfor navigation. - WP 6.4 => returns same as WP 6.3
- WP 6.5 => returns always
{}...
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() and getEditedPostType() 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() and getEditedPostType().
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