64952 quick draft prevent empty draft - #12194
Conversation
|
Hi there! 👋 Thank you for your contribution to WordPress! 💖 It looks like this is your first pull request to 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 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 Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
|
||
| // Wrap Quick Draft content in a Paragraph block. | ||
| if ( | ||
| use_block_editor_for_post_type( 'post' ) && |
There was a problem hiding this comment.
Question: is Quick Draft used only for 'post' post types?
There was a problem hiding this comment.
I was unable to find any evidence it's usable by any other post type.
b790734 to
7e947a8
Compare
joedolson
left a comment
There was a problem hiding this comment.
This is mostly looking pretty good; there are a few polishing elements I think would help.
| // Focus the title to allow for quickly drafting another post. | ||
| $('#title').trigger( 'focus' ); | ||
| }); | ||
| $( '#title' ).focus(); |
There was a problem hiding this comment.
The .focus() shorthand was deprecated; is there a reason you're making this change? https://api.jquery.com/focus-shorthand/
| * @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' ) { |
There was a problem hiding this comment.
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.
| $message, | ||
| array( | ||
| 'additional_classes' => array( 'error' ), | ||
| 'additional_classes' => array( $notice_type ), |
There was a problem hiding this comment.
Instead of adding this as an additional class, pass the type param with a simple type from $notice_type, as suggested above.
| // 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'] ); |
There was a problem hiding this comment.
This wasn't sanitized in the original, but it seems like it would be better to sanitize these variables here.
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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.
7e947a8 to
931067b
Compare
|
Addressed CR feedback. Should be good to go now. |
2e02089 to
00f3566
Compare
00f3566 to
8db8ed1
Compare
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.