Skip to content

Commit

Permalink
Templates: Only allow renaming user-created and non-default templates (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored May 6, 2022
1 parent 7aeaae5 commit f738d6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ export default function EditTemplateTitle() {
const { getEditorSettings } = useSelect( editorStore );
const { updateEditorSettings } = useDispatch( editorStore );

if ( template.has_theme_file ) {
// Only user-created and non-default templates can change the name.
if ( ! template.is_custom || template.has_theme_file ) {
return null;
}

Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/template-details/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ export default function TemplateDetails( { template, onClose } ) {
postId: undefined,
} );

// Only user-created and non-default templates can change the name.
const canEditTitle = template.is_custom && ! template.has_theme_file;

if ( ! template ) {
return null;
}
Expand All @@ -62,7 +65,7 @@ export default function TemplateDetails( { template, onClose } ) {
return (
<div className="edit-site-template-details">
<div className="edit-site-template-details__group">
{ template.is_custom ? (
{ canEditTitle ? (
<EditTemplateTitle template={ template } />
) : (
<Heading
Expand Down

0 comments on commit f738d6b

Please sign in to comment.