Skip to content

64952 quick draft prevent empty draft - #12194

Closed
afercia wants to merge 12 commits into
WordPress:trunkfrom
afercia:64952-quick-draft-prevent-empty-draft
Closed

64952 quick draft prevent empty draft#12194
afercia wants to merge 12 commits into
WordPress:trunkfrom
afercia:64952-quick-draft-prevent-empty-draft

Conversation

@afercia

@afercia afercia commented Jun 16, 2026

Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/64952

Use of AI Tools

Example disclosure:

AI assistance: Yes
Tool(s): GitHub Copilot
Model(s): Claude HAIKU 4.5
Used for: Initial research of the change that introduced the regrsssion.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions

Copy link
Copy Markdown

Hi there! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown

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 afercia, joedolson.

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

@github-actions

Copy link
Copy Markdown

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.

@afercia
afercia requested a review from SergeyBiryukov June 19, 2026 12:34
Comment thread src/wp-admin/post.php Outdated

// Wrap Quick Draft content in a Paragraph block.
if (
use_block_editor_for_post_type( 'post' ) &&

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: is Quick Draft used only for 'post' post types?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was unable to find any evidence it's usable by any other post type.

@afercia
afercia force-pushed the 64952-quick-draft-prevent-empty-draft branch from b790734 to 7e947a8 Compare June 21, 2026 13:21

@joedolson joedolson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mostly looking pretty good; there are a few polishing elements I think would help.

Comment thread src/js/_enqueues/wp/dashboard.js Outdated
// Focus the title to allow for quickly drafting another post.
$('#title').trigger( 'focus' );
});
$( '#title' ).focus();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .focus() shorthand was deprecated; is there a reason you're making this change? https://api.jquery.com/focus-shorthand/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will revert it

Comment thread src/wp-admin/includes/dashboard.php Outdated
* @param string $notice_type Optional. Admin notice type. Default 'notice-error'.
*/
function wp_dashboard_quick_press( $error_msg = false ) {
function wp_dashboard_quick_press( $message = false, $notice_type = 'notice-error' ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wp_admin_notice() takes an array argument that has a type parameter, accepting just 'error', 'success', 'warning', etc. I think that $notice_type should just pass the value used by the type param in that function.

Comment thread src/wp-admin/includes/dashboard.php Outdated
$message,
array(
'additional_classes' => array( 'error' ),
'additional_classes' => array( $notice_type ),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding this as an additional class, pass the type param with a simple type from $notice_type, as suggested above.

Comment thread src/wp-admin/post.php
// Wrap Quick Draft content in the Paragraph block.
if ( ! str_contains( $_POST['content'], '<!-- wp:paragraph -->' ) ) {
$quickdraft_post_title = trim( $_POST['post_title'] );
$quickdraft_post_content = trim( $_POST['content'] );

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't sanitized in the original, but it seems like it would be better to sanitize these variables here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the sanitization is in the chain of calls: edit_post(), wp_update_post(), and ultimately wp_insert_post(), which calls sanitize_post().

$('#quick-press').removeClass('initial-form');
$( '#dashboard_quick_press .inside' ).html( data );
quickPressLoad();
highlightLatestPost();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highlightLatestPost() shouldn't fire if the quick draft throws an error; will need to add a check for an error message as a condition in that.

@afercia
afercia force-pushed the 64952-quick-draft-prevent-empty-draft branch from 7e947a8 to 931067b Compare July 1, 2026 13:57
@afercia

afercia commented Jul 1, 2026

Copy link
Copy Markdown
Member Author

Addressed CR feedback. Should be good to go now.

@afercia
afercia force-pushed the 64952-quick-draft-prevent-empty-draft branch from 2e02089 to 00f3566 Compare July 7, 2026 13:45
@afercia
afercia force-pushed the 64952-quick-draft-prevent-empty-draft branch from 00f3566 to 8db8ed1 Compare July 8, 2026 16:03
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 62670
GitHub commit: 585ec6c

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions Bot closed this Jul 8, 2026
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.

2 participants