-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Site Editor: Allow editing custom template title (#36933)
* Site Editor: Allow editing custom template title * Fallback to slug
- Loading branch information
1 parent
223023d
commit ea2bd81
Showing
2 changed files
with
40 additions
and
7 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
packages/edit-site/src/components/template-details/edit-template-title.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { TextControl } from '@wordpress/components'; | ||
import { useEntityProp } from '@wordpress/core-data'; | ||
|
||
export default function EditTemplateTitle( { template } ) { | ||
const [ title, setTitle ] = useEntityProp( | ||
'postType', | ||
template.type, | ||
'title', | ||
template.id | ||
); | ||
|
||
return ( | ||
<TextControl | ||
label={ __( 'Title' ) } | ||
value={ title } | ||
help={ __( | ||
'Give the template a title that indicates its purpose, e.g. "Full Width".' | ||
) } | ||
onChange={ ( newTitle ) => { | ||
setTitle( newTitle || template.slug ); | ||
} } | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters