can_submit($user_id); if (!$can_submit) { wp_redirect(home_url('/')); exit; } // Check if editing existing draft $edit_id = isset($_GET['edit']) ? absint($_GET['edit']) : 0; $edit_post = null; if ($edit_id > 0) { $edit_post = get_post($edit_id); if (!$edit_post || (int) $edit_post->post_author !== $user_id || $edit_post->post_status !== 'draft') { $edit_post = null; $edit_id = 0; } } get_header(); // Submit settings $submit_settings = []; if (class_exists('\AKSRT\Settings\Settings')) { $all = \AKSRT\Settings\Settings::get_all(); $submit_settings = [ 'enabled' => !empty($all['front_submit_enabled']), 'review_mode' => $all['front_submit_review_mode'] ?? 'pending', 'allow_cover' => !isset($all['front_submit_cover']) || !empty($all['front_submit_cover']), 'allow_excerpt' => !isset($all['front_submit_excerpt']) || !empty($all['front_submit_excerpt']), 'allow_category' => !isset($all['front_submit_category']) || !empty($all['front_submit_category']), 'allow_tags' => !isset($all['front_submit_tags']) || !empty($all['front_submit_tags']), 'max_images' => (int) ($all['front_submit_max_images'] ?? 5), 'allowed_cat_ids' => is_array($all['post_article_cat'] ?? null) ? array_map('intval', $all['post_article_cat']) : [], 'topics_s' => !empty($all['post_article_topics_s']), 'custom_filter_s' => !isset($all['post_article_custom_filter_s']) || !empty($all['post_article_custom_filter_s']), ]; } // §3.7 topics: load topics taxonomy terms $topics_terms = []; if (!empty($submit_settings['topics_s']) && taxonomy_exists('topics')) { $topics_terms = get_terms(['taxonomy' => 'topics', 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC']); if (is_wp_error($topics_terms)) $topics_terms = []; } $current_topics = []; if ($edit_post && taxonomy_exists('topics')) { $terms = wp_get_object_terms($edit_post->ID, 'topics', ['fields' => 'ids']); if (!is_wp_error($terms)) $current_topics = $terms; } // §3.4 custom_filter: load dimension definitions for submit form $custom_dimensions = []; if (!empty($submit_settings['custom_filter_s']) && class_exists('\AKSRT\Settings\Settings')) { $filter_all = \AKSRT\Settings\Settings::get_post_filter_settings(); $custom_dimensions = $filter_all['custom_filter']; } // §3.4 custom_filter: load current values for edit mode $current_cf = []; if ($edit_post && !empty($custom_dimensions)) { foreach ($custom_dimensions as $dim) { $current_cf[$dim['key']] = get_post_meta($edit_post->ID, '_aksrt_cf_' . $dim['key'], true); } } // §3.7 post_article_cat: filter categories by allowed list $cat_args = [ 'taxonomy' => 'category', 'hide_empty' => false, 'orderby' => 'name', 'order' => 'ASC', ]; if (!empty($submit_settings['allowed_cat_ids'])) { $cat_args['include'] = $submit_settings['allowed_cat_ids']; } $categories = get_categories($cat_args); // Current values for edit mode $current_title = $edit_post ? $edit_post->post_title : ''; $current_content = $edit_post ? $edit_post->post_content : ''; $current_excerpt = $edit_post ? $edit_post->post_excerpt : ''; $current_cats = $edit_post ? wp_get_post_categories($edit_post->ID) : []; $current_tags = $edit_post ? implode(', ', wp_get_post_tags($edit_post->ID, ['fields' => 'names'])) : ''; $current_thumb = $edit_post ? get_the_post_thumbnail_url($edit_post->ID, 'large') : ''; ?>

0) : ?>
>
'post', 'post_status' => 'draft', 'author' => $user_id, 'numberposts' => 10, 'orderby' => 'modified', 'order' => 'DESC', ]); if (!empty($user_drafts)) : ?>
is_available(); wp_localize_script('aksrt-front-submit', 'aksrtSubmitData', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('aksrt_submit_nonce'), 'restUrl' => esc_url_raw(rest_url('aksrt/v1')), 'restNonce' => wp_create_nonce('wp_rest'), 'ai' => [ 'available' => $ai_available, 'summary' => $ai_available, 'tags' => $ai_available, ], 'i18n' => [ 'confirmLeave' => __('你有未保存的更改,确定要离开吗?', 'aksrt'), 'saving' => __('保存中...', 'aksrt'), 'saved' => __('草稿已保存', 'aksrt'), 'submitting' => __('提交中...', 'aksrt'), 'submitted' => __('投稿已提交', 'aksrt'), 'error' => __('操作失败,请重试', 'aksrt'), 'confirmDelete' => __('确定要删除这个草稿吗?', 'aksrt'), 'aiGenerating' => __('生成中…', 'aksrt'), 'aiFailed' => __('AI 生成失败', 'aksrt'), 'needContent' => __('请先填写正文内容', 'aksrt'), 'aiFilled' => __('已填入,可继续编辑', 'aksrt'), ], ]); } get_footer();