fix(front-submit): let drafts save with partial content

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
kate522andClaude Opus 5 committed 2026-11-07 00:58:13 +08:00
1 parent 4a119358ca
commit 5f31c58df2
5 files changed
+29 -9

No files matched your search

+10 -5
View File
@@ -65,11 +65,16 @@ trait FrontSubmitSave {
$content = (string) ($data['post_content'] ?? $data['content'] ?? '');
$excerpt = sanitize_textarea_field((string) ($data['excerpt'] ?? $data['post_excerpt'] ?? ''));
if ($title === '') {
return ['success' => false, 'message' => __('请填写文章标题', 'jio')];
}
if (trim(wp_strip_all_tags($content)) === '') {
return ['success' => false, 'message' => __('还未填写任何内容', 'jio')];
// 草稿只要有任何可保存的内容就落库;正式投稿才要求标题与正文齐备。
if (!$is_draft) {
if ($title === '') {
return ['success' => false, 'message' => __('请填写文章标题', 'jio')];
}
if (trim(wp_strip_all_tags($content)) === '') {
return ['success' => false, 'message' => __('还未填写任何内容', 'jio')];
}
} elseif ($title === '' && trim(wp_strip_all_tags($content)) === '') {
return ['success' => false, 'message' => __('请先写点什么再保存', 'jio')];
}
$categories = $this->normalize_category_ids($data);