-
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
WIP - Hybrid themes implementation #29298
Changes from all commits
953dfc1
d930f7d
31dad0e
4962acd
3fe3ba0
414ea92
c7866de
670a763
dbe1e8a
e8a5bbc
c93b84f
44dba24
b2f7ae4
30469de
47e9f5f
0878b04
2c14b90
46eaf1c
5a0f108
94a48e2
1fe8fce
b58f67e
ce82405
d06d6fc
fc2bb3c
af13580
82bc77b
298b463
9aa4fae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,21 @@ | |
import { find } from 'lodash'; | ||
|
||
export default function getClosestAvailableTemplate( slug, templates ) { | ||
// Fallback in case there are no templates. | ||
if ( ! templates.length ) { | ||
return { | ||
id: 'index', | ||
content: { | ||
raw: '', | ||
}, | ||
slug: 'index', | ||
is_custom: false, | ||
type: 'wp_template', | ||
status: 'publish', | ||
wp_id: null, | ||
}; | ||
} | ||
|
||
Comment on lines
+8
to
+21
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part allows the creation of a new template from the dashboard. If the theme doesn't have any templates, there's nothing to fallback to and the site-editor throws errors which prevents the user from creating a template. |
||
const template = find( templates, { slug } ); | ||
if ( template ) { | ||
return template; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow showing the site-editor if the user has opted-in, or we're in an FSE theme.