mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 12:50:28 +00:00
Site Editor: Resolve homepage template on server-side
Backports change from Gutenberg to support server-side home template resolution in the Site Editor. Original PR https://github.com/WordPress/gutenberg/pull/38817. Props Mamaduka. See #55505. git-svn-id: https://develop.svn.wordpress.org/trunk@53093 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -331,3 +331,35 @@ function _resolve_template_for_new_post( $wp_query ) {
|
||||
$wp_query->set( 'post_status', 'auto-draft' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the correct template for the site's home page.
|
||||
*
|
||||
* @access private
|
||||
* @since 6.0.0
|
||||
*
|
||||
* @return array|null A template object, or null if none could be found.
|
||||
*/
|
||||
function _resolve_home_block_template() {
|
||||
$show_on_front = get_option( 'show_on_front' );
|
||||
$front_page_id = get_option( 'page_on_front' );
|
||||
|
||||
if ( 'page' === $show_on_front && $front_page_id ) {
|
||||
return array(
|
||||
'postType' => 'page',
|
||||
'postId' => $front_page_id,
|
||||
);
|
||||
}
|
||||
|
||||
$hierarchy = array( 'front-page', 'home', 'index' );
|
||||
$template = resolve_block_template( 'home', $hierarchy, '' );
|
||||
|
||||
if ( ! $template ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return array(
|
||||
'postType' => 'wp_template',
|
||||
'postId' => $template->id,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user