@@ -40,26 +40,32 @@ function NextPublishSlot( { children }: NextButtonSlotPropType ) {
40
40
41
41
export function PublishSave ( ) {
42
42
const observerRef = useRef < MutationObserver | null > ( null ) ;
43
- const { hasNonPostEntityChanges, isEditedPostDirty, currentPost } =
43
+ const { hasNonPostEntityChanges, isEditedPostDirty, isEditingTemplate } =
44
44
useSelect (
45
45
( select ) => ( {
46
46
hasNonPostEntityChanges :
47
47
// @ts -expect-error hasNonPostEntityChanges is not typed in @types/wordpress__editor
48
48
select ( editorStore ) . hasNonPostEntityChanges ( ) ,
49
49
isEditedPostDirty : select ( editorStore ) . isEditedPostDirty ( ) ,
50
- currentPost : select ( editorStore ) . getCurrentPost ( ) ,
50
+ isEditingTemplate :
51
+ select ( editorStore ) . getCurrentPostType ( ) ===
52
+ 'wp_template' ,
51
53
} ) ,
52
54
[ ]
53
55
) ;
54
56
55
- // Check the post status
56
- const isDraftPost = currentPost . status === 'draft' ;
57
-
58
- // Display original button when there are changes to save except for draft
59
- // For draft, there is an extra save button to save as draft
60
- // Also display original button when the post is in draft status
57
+ // Display the original publish button when:
58
+ // - The user is editing a template (regardless of detected changes).
59
+ // - There are changes outside of the post (e.g., in a linked template).
60
+ // - There are changes in the post together with changes outside of it.
61
+ //
62
+ // Do not display the button when:
63
+ // - There are only changes in the post content with no related entity changes.
64
+ // Draft posts have their own "Save as draft" button.
61
65
const displayOriginalPublishButton =
62
- ( hasNonPostEntityChanges || isEditedPostDirty ) && ! isDraftPost ;
66
+ isEditingTemplate ||
67
+ hasNonPostEntityChanges ||
68
+ ( isEditedPostDirty && hasNonPostEntityChanges ) ;
63
69
64
70
const toggleElementVisible = useCallback (
65
71
( element : Element , visible : boolean ) => {
0 commit comments