Skip to content

Fix #65024: Add item_draft_saved label to make 'Draft saved.' message…#11477

Open
Vedanshmini26 wants to merge 1 commit intoWordPress:trunkfrom
Vedanshmini26:draft-message-change-patch
Open

Fix #65024: Add item_draft_saved label to make 'Draft saved.' message…#11477
Vedanshmini26 wants to merge 1 commit intoWordPress:trunkfrom
Vedanshmini26:draft-message-change-patch

Conversation

@Vedanshmini26
Copy link
Copy Markdown

@Vedanshmini26 Vedanshmini26 commented Apr 9, 2026

Core Trac Ticket: https://core.trac.wordpress.org/ticket/65024

Problem
The "Draft saved." message that appears in the block editor snackbar notification when saving a post in draft status cannot be modified by plugins or themes. Unlike other editor save messages (e.g. "Post published.", "Post updated.", "Post trashed."), there is no WordPress filter or hook that exposes this string.

Root Cause
All other save notification messages in the block editor are sourced from postType.labels — PHP-defined post type label objects that are exposed via the REST API and filterable using the post_type_labels_{post_type} hook. However, the "Draft saved." message is hardcoded directly in JavaScript (wp-includes/js/dist/editor.js) inside the getNotificationArgumentsForSaveSuccess() function, bypassing the label system entirely and making it impossible to override.

Solution
This PR handles the PHP side of the fix by adding a new item_draft_saved label to the post type labels system, following the same pattern as existing labels like item_updated, item_published, and item_trashed:

class-wp-post-type.php: Added item_draft_saved to WP_Post_Type::get_default_labels() with a default value of 'Draft saved.' for both hierarchical and non-hierarchical post types.
post.php: Added a contextual 'Pattern draft saved.' label for the wp_block post type (which already defines its own full set of custom labels), and updated the get_post_type_labels() docblock to document the new label.
Since the REST API post types controller already exposes the full $post_type->labels object, the new label flows to the JavaScript side automatically with no REST API changes needed.

The corresponding JS change — replacing the hardcoded __("Draft saved.") with postType2.labels.item_draft_saved in packages/editor/src/store/utils/notice-builder.js — needs to be made in a separate Gutenberg PR, as wp-includes/js/dist/editor.js is a compiled build artifact synced from the Gutenberg monorepo.

Once both the PHP (this PR) and the Gutenberg JS change land, plugins will be able to filter the message using the existing hook:

add_filter( 'post_type_labels_post', function( $labels ) {
$labels->item_draft_saved = 'Your custom message.';
return $labels;
} );

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props sheldorofazeroth.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@Vedanshmini26 Vedanshmini26 force-pushed the draft-message-change-patch branch 2 times, most recently from a856dc0 to 47f2ec3 Compare April 9, 2026 05:13
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant