summaryrefslogtreecommitdiffstats
path: root/wp-includes/js/dist/edit-post.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-19 12:16:56 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-19 12:16:56 +0000
commit8a58fd166251eccbb629f18b0873caed32673115 (patch)
tree357d2ca62286e1c369d6fea2b51f3385b8e20d6b /wp-includes/js/dist/edit-post.js
parentReleasing progress-linux version 6.5.2+dfsg1-1~progress7.99u1. (diff)
downloadwordpress-8a58fd166251eccbb629f18b0873caed32673115.tar.xz
wordpress-8a58fd166251eccbb629f18b0873caed32673115.zip
Merging upstream version 6.5.3+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wp-includes/js/dist/edit-post.js')
-rw-r--r--wp-includes/js/dist/edit-post.js30
1 files changed, 24 insertions, 6 deletions
diff --git a/wp-includes/js/dist/edit-post.js b/wp-includes/js/dist/edit-post.js
index 1fda610..5ea7449 100644
--- a/wp-includes/js/dist/edit-post.js
+++ b/wp-includes/js/dist/edit-post.js
@@ -3490,26 +3490,44 @@ function areMetaBoxesInitialized(state) {
* @return {Object?} Post Template.
*/
const getEditedPostTemplate = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
+ const {
+ id: postId,
+ type: postType,
+ slug
+ } = select(external_wp_editor_namespaceObject.store).getCurrentPost();
+ const {
+ getSite,
+ getEditedEntityRecord,
+ getEntityRecords
+ } = select(external_wp_coreData_namespaceObject.store);
+ const siteSettings = getSite();
+ // First check if the current page is set as the posts page.
+ const isPostsPage = +postId === siteSettings?.page_for_posts;
+ if (isPostsPage) {
+ const defaultTemplateId = select(external_wp_coreData_namespaceObject.store).getDefaultTemplateId({
+ slug: 'home'
+ });
+ return getEditedEntityRecord('postType', 'wp_template', defaultTemplateId);
+ }
const currentTemplate = select(external_wp_editor_namespaceObject.store).getEditedPostAttribute('template');
if (currentTemplate) {
- const templateWithSameSlug = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
+ const templateWithSameSlug = getEntityRecords('postType', 'wp_template', {
per_page: -1
})?.find(template => template.slug === currentTemplate);
if (!templateWithSameSlug) {
return templateWithSameSlug;
}
- return select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', 'wp_template', templateWithSameSlug.id);
+ return getEditedEntityRecord('postType', 'wp_template', templateWithSameSlug.id);
}
- const post = select(external_wp_editor_namespaceObject.store).getCurrentPost();
let slugToCheck;
// In `draft` status we might not have a slug available, so we use the `single`
// post type templates slug(ex page, single-post, single-product etc..).
// Pages do not need the `single` prefix in the slug to be prioritized
// through template hierarchy.
- if (post.slug) {
- slugToCheck = post.type === 'page' ? `${post.type}-${post.slug}` : `single-${post.type}-${post.slug}`;
+ if (slug) {
+ slugToCheck = postType === 'page' ? `${postType}-${slug}` : `single-${postType}-${slug}`;
} else {
- slugToCheck = post.type === 'page' ? 'page' : `single-${post.type}`;
+ slugToCheck = postType === 'page' ? 'page' : `single-${postType}`;
}
const defaultTemplateId = select(external_wp_coreData_namespaceObject.store).getDefaultTemplateId({
slug: slugToCheck