refactor(submit): remove unused aksrt_update_post ajax endpoint
No caller anywhere: front JS updates via aksrt_submit_post (posts_id), guests via aksrt_save_draft. Re-pin the one-captcha-admission contract to ajax_submit_post, the only non-draft entry point.
This commit is contained in:
@@ -30,7 +30,6 @@ class FrontSubmit {
|
||||
public function init(): void {
|
||||
add_action('wp_ajax_aksrt_submit_post', [$this, 'ajax_submit_post']);
|
||||
add_action('wp_ajax_aksrt_save_draft', [$this, 'ajax_save_draft']);
|
||||
add_action('wp_ajax_aksrt_update_post', [$this, 'ajax_update_post']);
|
||||
add_action('wp_ajax_aksrt_delete_draft', [$this, 'ajax_delete_draft']);
|
||||
add_action('wp_ajax_aksrt_delete_post', [$this, 'ajax_delete_post']);
|
||||
|
||||
@@ -383,25 +382,6 @@ class FrontSubmit {
|
||||
$this->send_result($result);
|
||||
}
|
||||
|
||||
public function ajax_update_post(): void {
|
||||
$this->verify_nonce();
|
||||
$data = wp_unslash($_POST);
|
||||
if (!is_array($data)) {
|
||||
$data = [];
|
||||
}
|
||||
$post_id = absint($data['posts_id'] ?? $data['post_id'] ?? $data['edit_id'] ?? 0);
|
||||
if ($post_id <= 0) {
|
||||
wp_send_json_error(['message' => __('文章 ID 无效', 'aksrt')]);
|
||||
}
|
||||
$data['posts_id'] = $post_id;
|
||||
$action = (($data['status'] ?? '') === 'draft') ? 'posts_draft' : 'posts_save';
|
||||
if ($action !== 'posts_draft') {
|
||||
$this->verify_captcha();
|
||||
}
|
||||
$result = $this->persist($data, $action);
|
||||
$this->send_result($result);
|
||||
}
|
||||
|
||||
public function ajax_delete_draft(): void {
|
||||
$this->verify_nonce();
|
||||
$user_id = get_current_user_id();
|
||||
|
||||
Reference in New Issue
Block a user