/
www
/
wwwroot
/
fxdst.com
/
wp-content
/
themes
/
fxdst
/
inc
/
Upload File
HOME
<?php if ( ! defined( 'ABSPATH' ) ) { exit; } function fxdst_get_quick_page_url($path) { $page = get_page_by_path($path); if ($page && $page->post_status === 'publish') { return get_permalink($page); } return home_url('/' . trim($path, '/') . '/'); } add_action('template_redirect', function () { if (!isset($_GET['fxdst_random_site']) || is_admin() || headers_sent()) { return; } $ids = get_posts(array( 'post_type' => 'sites', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 1, 'orderby' => 'rand', 'fields' => 'ids', 'no_found_rows' => true, )); $target = !empty($ids) ? get_permalink((int) $ids[0]) : home_url('/'); wp_safe_redirect($target, 302); exit; }); add_action('template_redirect', function () { if (is_admin() || headers_sent() || empty($_SERVER['REQUEST_URI'])) { return; } $path = trim((string) wp_parse_url(wp_unslash($_SERVER['REQUEST_URI']), PHP_URL_PATH), '/'); if ($path !== 'favorites/ai-tools-overview') { return; } wp_safe_redirect(home_url('/favorites/ai-development'), 301); exit; }); function fxdst_quick_text($key) { static $strings = null; if ($strings === null) { $strings = array( 'hot_title' => '本周热门', 'hot_desc' => '按站内推荐度、内容完整度和近期收录综合排序,方便快速发现值得优先看的工具。', 'open_title' => '免费开源', 'open_desc' => '优先展示免费、开源、GitHub 或可自托管的实用工具。', 'compare_title' => '工具对比', 'compare_desc' => '汇总特定场景的工具对比和选型文章,帮你少走弯路。', 'open_detail' => '查看详情', 'read_article' => '阅读对比', 'empty_sites' => '暂时没有符合条件的工具,后续收录后会自动显示。', 'empty_posts' => '暂时没有对比文章,可以先从工具分类页查看。', ); } return isset($strings[$key]) ? $strings[$key] : ''; } function fxdst_quick_term_names($post_id) { $names = array(); $terms = wp_get_post_terms($post_id, 'favorites'); if (!is_wp_error($terms)) { foreach ($terms as $term) { $names[] = $term->name; $names[] = $term->slug; } } return implode(' ', $names); } function fxdst_quick_site_matches($post_id, $mode) { if ($mode !== 'free-open-source') { return true; } $keywords = array( 'github.com', 'open source', 'opensource', 'self-host', 'self host', 'source-available', 'community edition', json_decode('"\u514d\u8d39"'), json_decode('"\u5f00\u6e90"'), json_decode('"\u81ea\u6258\u7ba1"'), json_decode('"\u6c38\u4e45\u514d\u8d39"'), ); $haystack = implode(' ', array( get_the_title($post_id), get_post_meta($post_id, '_sites_sescribe', true), get_post_meta($post_id, '_sites_link', true), fxdst_quick_term_names($post_id), wp_strip_all_tags(get_post_field('post_content', $post_id)), )); $haystack_lower = function_exists('mb_strtolower') ? mb_strtolower($haystack, 'UTF-8') : strtolower($haystack); foreach ($keywords as $keyword) { if (!$keyword) { continue; } $needle = function_exists('mb_strtolower') ? mb_strtolower($keyword, 'UTF-8') : strtolower($keyword); if (strpos($haystack_lower, $needle) !== false) { return true; } } return false; } function fxdst_quick_site_score($post_id) { $order = (int) get_post_meta($post_id, '_sites_order', true); return ($order * 100000) + (int) $post_id; } function fxdst_quick_get_sites($mode, $limit) { $ids = get_posts(array( 'post_type' => 'sites', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 320, 'orderby' => 'date', 'order' => 'DESC', 'fields' => 'ids', 'no_found_rows' => true, )); $items = array(); foreach ($ids as $post_id) { $visible = get_post_meta($post_id, '_visible', true); if (function_exists('io_is_visible') && !io_is_visible($visible)) { continue; } if (!fxdst_quick_site_matches($post_id, $mode)) { continue; } $items[] = array( 'id' => (int) $post_id, 'score' => fxdst_quick_site_score($post_id), ); } usort($items, function ($a, $b) { if ($a['score'] === $b['score']) { return $b['id'] - $a['id']; } return $b['score'] - $a['score']; }); return array_slice($items, 0, $limit); } function fxdst_quick_site_icon($post_id) { $thumbnail = get_post_meta($post_id, '_thumbnail', true); if ($thumbnail) { return $thumbnail; } if (has_post_thumbnail($post_id)) { $image = get_the_post_thumbnail_url($post_id, 'thumbnail'); if ($image) { return $image; } } $link = get_post_meta($post_id, '_sites_link', true); if ($link && function_exists('io_get_option') && function_exists('format_url')) { $ico_url = io_get_option('ico_url'); if ($ico_url) { return $ico_url . format_url($link) . io_get_option('ico_png'); } } return get_theme_file_uri('/images/logo_dark@2x.png'); } function fxdst_quick_excerpt($post_id, $length) { $text = get_post_meta($post_id, '_sites_sescribe', true); if (!$text) { $text = get_post_field('post_excerpt', $post_id); } if (!$text) { $text = wp_strip_all_tags(get_post_field('post_content', $post_id)); } $text = trim(preg_replace('/\s+/', ' ', wp_strip_all_tags($text))); return wp_trim_words($text, $length, '...'); } function fxdst_quick_render_site_cards($mode, $limit) { $sites = fxdst_quick_get_sites($mode, $limit); if (empty($sites)) { return '<div class="fxdst-quick-empty">' . fxdst_quick_text('empty_sites') . '</div>'; } $html = '<div class="fxdst-quick-grid">'; foreach ($sites as $site) { $post_id = $site['id']; $html .= '<a class="fxdst-quick-card" href="' . esc_url(get_permalink($post_id)) . '">'; $html .= '<span class="fxdst-quick-icon"><img src="' . esc_url(fxdst_quick_site_icon($post_id)) . '" alt="' . esc_attr(get_the_title($post_id)) . '"></span>'; $html .= '<span class="fxdst-quick-body">'; $html .= '<strong>' . esc_html(get_the_title($post_id)) . '</strong>'; $html .= '<span>' . esc_html(fxdst_quick_excerpt($post_id, 22)) . '</span>'; $html .= '<em>' . fxdst_quick_text('open_detail') . '<i class="fa fa-angle-right"></i></em>'; $html .= '</span></a>'; } $html .= '</div>'; return $html; } function fxdst_quick_render_compare_cards($limit) { $ids = get_posts(array( 'post_type' => 'post', 'post_status' => 'publish', 'ignore_sticky_posts' => 1, 'posts_per_page' => 80, 'orderby' => 'date', 'order' => 'DESC', 'fields' => 'ids', 'no_found_rows' => true, )); $matched = array(); $needles = array(json_decode('"\u5bf9\u6bd4"'), ' vs ', ' VS ', ' Vs '); foreach ($ids as $post_id) { $haystack = ' ' . get_the_title($post_id) . ' ' . wp_strip_all_tags(get_post_field('post_content', $post_id)) . ' '; foreach ($needles as $needle) { if ($needle && strpos($haystack, $needle) !== false) { $matched[] = (int) $post_id; break; } } if (count($matched) >= $limit) { break; } } if (empty($matched)) { return '<div class="fxdst-quick-empty">' . fxdst_quick_text('empty_posts') . '</div>'; } $html = '<div class="fxdst-quick-grid fxdst-quick-grid-articles">'; foreach ($matched as $post_id) { $category = get_the_category($post_id); $cat_name = !empty($category) ? $category[0]->name : 'AI / SaaS'; $excerpt = has_excerpt($post_id) ? get_the_excerpt($post_id) : wp_trim_words(wp_strip_all_tags(get_post_field('post_content', $post_id)), 36, '...'); $html .= '<a class="fxdst-quick-card fxdst-quick-article-card" href="' . esc_url(get_permalink($post_id)) . '">'; $html .= '<span class="fxdst-quick-article-meta"><i class="fa fa-folder"></i>' . esc_html($cat_name) . '<i class="fa fa-calendar"></i>' . esc_html(get_the_time('Y-m-d', $post_id)) . '</span>'; $html .= '<strong>' . esc_html(get_the_title($post_id)) . '</strong>'; $html .= '<span>' . esc_html($excerpt) . '</span>'; $html .= '<em>' . fxdst_quick_text('read_article') . '<i class="fa fa-angle-right"></i></em>'; $html .= '</a>'; } $html .= '</div>'; return $html; } add_shortcode('fxdst_quick_tools', function ($atts) { $atts = shortcode_atts(array( 'mode' => 'hot', 'limit' => 24, ), $atts, 'fxdst_quick_tools'); $mode = sanitize_key($atts['mode']); $limit = max(1, min(48, (int) $atts['limit'])); $title_key = 'hot_title'; $desc_key = 'hot_desc'; if ($mode === 'free-open-source') { $title_key = 'open_title'; $desc_key = 'open_desc'; } elseif ($mode === 'compare') { $title_key = 'compare_title'; $desc_key = 'compare_desc'; } $content = $mode === 'compare' ? fxdst_quick_render_compare_cards($limit) : fxdst_quick_render_site_cards($mode, $limit); return '<section class="fxdst-quick-tools fxdst-quick-tools-' . esc_attr($mode) . '">' . '<header class="fxdst-quick-head"><span class="fxdst-eyebrow">AI / SaaS / Global Tools</span><h2>' . fxdst_quick_text($title_key) . '</h2><p>' . fxdst_quick_text($desc_key) . '</p></header>' . $content . '</section>'; }); function fxdst_related_normalize_text($text) { $text = html_entity_decode((string) $text, ENT_QUOTES, 'UTF-8'); $text = wp_strip_all_tags($text); $text = function_exists('mb_strtolower') ? mb_strtolower($text, 'UTF-8') : strtolower($text); $text = preg_replace('/[^\p{L}\p{N}\+#\.]+/u', ' ', $text); $text = preg_replace('/\s+/u', ' ', $text); return trim($text); } function fxdst_related_contains_term($haystack, $needle) { $haystack = ' ' . $haystack . ' '; $needle = trim((string) $needle); if ($needle === '') { return false; } if (preg_match('/^[a-z0-9\+#\.]+$/', $needle)) { return strpos($haystack, ' ' . $needle . ' ') !== false; } return strpos($haystack, $needle) !== false; } function fxdst_related_site_terms($site_id) { $title = fxdst_related_normalize_text(get_the_title($site_id)); $stopwords = array( 'ai', 'api', 'app', 'apps', 'tool', 'tools', 'saas', 'llm', 'seo', 'crm', 'ui', 'ux', 'web', 'dev', 'code', 'cloud', 'data', 'open', 'source', 'global', 'model', 'models', 'platform', 'builder', 'builders', 'agent', ); $terms = array( 'full' => $title, 'tokens' => array(), ); $parts = preg_split('/\s+/u', $title, -1, PREG_SPLIT_NO_EMPTY); foreach ((array) $parts as $part) { $part = trim($part, '.'); if ($part === '' || in_array($part, $stopwords, true)) { continue; } if (strlen($part) >= 4 || preg_match('/\d/', $part)) { $terms['tokens'][] = $part; } } $link = get_post_meta($site_id, '_sites_link', true); $host = $link ? parse_url($link, PHP_URL_HOST) : ''; if ($host) { $host = preg_replace('/^www\./i', '', $host); $host_parts = preg_split('/[.\-]+/', fxdst_related_normalize_text($host), -1, PREG_SPLIT_NO_EMPTY); foreach ((array) $host_parts as $part) { if ($part !== '' && !in_array($part, $stopwords, true) && (strlen($part) >= 4 || preg_match('/\d/', $part))) { $terms['tokens'][] = $part; break; } } } $terms['tokens'] = array_values(array_unique($terms['tokens'])); return $terms; } function fxdst_related_article_score($post_id, $site_terms) { $full = isset($site_terms['full']) ? $site_terms['full'] : ''; $tokens = isset($site_terms['tokens']) ? (array) $site_terms['tokens'] : array(); if ($full === '' && empty($tokens)) { return 0; } $article_title = fxdst_related_normalize_text(get_the_title($post_id)); $article_body = fxdst_related_normalize_text( get_post_field('post_excerpt', $post_id) . ' ' . get_post_field('post_content', $post_id) ); $score = 0; $full_parts = $full ? preg_split('/\s+/u', $full, -1, PREG_SPLIT_NO_EMPTY) : array(); $is_multi_word_name = count((array) $full_parts) > 1; if ($full && strlen($full) >= 3) { if (fxdst_related_contains_term($article_title, $full)) { $score += 5; } elseif ($is_multi_word_name && fxdst_related_contains_term($article_body, $full)) { $score += 4; } } $broad_tokens = array('openai', 'google', 'microsoft', 'github', 'anthropic', 'claude', 'gemini', 'meta', 'xai', 'amazon', 'aws'); foreach ($tokens as $token) { $is_broad_token = $is_multi_word_name && in_array($token, $broad_tokens, true); if (fxdst_related_contains_term($article_title, $token)) { $score += $is_broad_token ? 1 : 2; } elseif (!$is_broad_token && fxdst_related_contains_term($article_body, $token)) { $score += 1; } } return $score; } function fxdst_get_site_related_article_ids($site_id, $limit = 3) { $site_terms = fxdst_related_site_terms($site_id); $candidate_ids = get_posts(array( 'post_type' => 'post', 'post_status' => 'publish', 'posts_per_page' => 120, 'ignore_sticky_posts' => 1, 'orderby' => 'date', 'order' => 'DESC', 'fields' => 'ids', 'no_found_rows' => true, )); $scored = array(); foreach ($candidate_ids as $candidate_id) { $score = fxdst_related_article_score($candidate_id, $site_terms); if ($score >= 2) { $scored[] = array( 'id' => (int) $candidate_id, 'score' => $score, ); } } usort($scored, function ($a, $b) { if ($a['score'] === $b['score']) { return $b['id'] - $a['id']; } return $b['score'] - $a['score']; }); return array_map(function ($item) { return $item['id']; }, array_slice($scored, 0, max(1, (int) $limit))); } function fxdst_submit_msg($json) { return json_decode($json); } function fxdst_ajax_response($status, $message, $data = array()) { wp_send_json(array( 'status' => (int) $status, 'msg' => $message, 'data' => $data, )); } function fxdst_verify_submit_nonce() { $nonce = isset($_POST['fxdst_submit_nonce']) ? sanitize_text_field(wp_unslash($_POST['fxdst_submit_nonce'])) : ''; return $nonce && wp_verify_nonce($nonce, 'fxdst_submit_tool'); } if (!function_exists('fxdst_submit_normalize_domain')) { function fxdst_submit_normalize_domain($url) { $url = trim(html_entity_decode((string) $url, ENT_QUOTES, 'UTF-8')); if ($url === '') { return ''; } if (!preg_match('#^https?://#i', $url)) { $url = 'https://' . $url; } $parts = wp_parse_url($url); if (empty($parts['host'])) { return ''; } $host = strtolower(rtrim($parts['host'], '.')); if (strpos($host, 'www.') === 0) { $host = substr($host, 4); } return sanitize_text_field($host); } } if (!function_exists('fxdst_submit_domain_exists')) { function fxdst_submit_domain_exists($domain, $exclude_id = 0) { $domain = fxdst_submit_normalize_domain($domain); if ($domain === '') { return 0; } $direct = get_posts(array( 'post_type' => 'sites', 'post_status' => array('publish', 'pending', 'draft', 'private', 'future'), 'posts_per_page' => 1, 'fields' => 'ids', 'meta_key' => '_sites_domain', 'meta_value' => $domain, 'post__not_in' => $exclude_id ? array((int) $exclude_id) : array(), 'no_found_rows' => true, )); if (!empty($direct)) { return (int) $direct[0]; } $ids = get_posts(array( 'post_type' => 'sites', 'post_status' => array('publish', 'pending', 'draft', 'private', 'future'), 'posts_per_page' => -1, 'fields' => 'ids', 'meta_query' => array( array( 'key' => '_sites_link', 'compare' => 'EXISTS', ), ), 'post__not_in' => $exclude_id ? array((int) $exclude_id) : array(), 'no_found_rows' => true, )); foreach ($ids as $post_id) { if (fxdst_submit_normalize_domain(get_post_meta($post_id, '_sites_link', true)) === $domain) { return (int) $post_id; } } return 0; } } add_action('wp_ajax_contribute_post', 'fxdst_handle_contribute_post'); add_action('wp_ajax_nopriv_contribute_post', 'fxdst_handle_contribute_post'); function fxdst_handle_contribute_post() { if (!fxdst_verify_submit_nonce()) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8868\u5355\u5df2\u8fc7\u671f\uff0c\u8bf7\u5237\u65b0\u540e\u91cd\u8bd5\u3002"')); } $title = isset($_POST['tougao_title']) ? sanitize_text_field(wp_unslash($_POST['tougao_title'])) : ''; $link = isset($_POST['tougao_sites_link']) ? esc_url_raw(wp_unslash($_POST['tougao_sites_link'])) : ''; $desc = isset($_POST['tougao_sites_sescribe']) ? sanitize_text_field(wp_unslash($_POST['tougao_sites_sescribe'])) : ''; $content = isset($_POST['tougao_content']) ? wp_kses_post(wp_unslash($_POST['tougao_content'])) : ''; $cat_id = isset($_POST['tougao_cat']) ? absint($_POST['tougao_cat']) : 0; $icon = isset($_POST['tougao_sites_ico']) ? esc_url_raw(wp_unslash($_POST['tougao_sites_ico'])) : ''; $screenshot = isset($_POST['tougao_sites_screenshot']) ? esc_url_raw(wp_unslash($_POST['tougao_sites_screenshot'])) : ''; $price_mode = isset($_POST['tougao_price_mode']) ? sanitize_key(wp_unslash($_POST['tougao_price_mode'])) : ''; $price_options = array( 'free' => fxdst_submit_msg('"\u514d\u8d39"'), 'freemium' => fxdst_submit_msg('"Freemium / \u514d\u8d39\u589e\u503c"'), 'paid_subscription' => fxdst_submit_msg('"\u4ed8\u8d39\u8ba2\u9605"'), 'one_time' => fxdst_submit_msg('"\u4e70\u65ad\u5236"'), 'open_source' => fxdst_submit_msg('"\u5f00\u6e90\u514d\u8d39"'), 'contact_sales' => fxdst_submit_msg('"\u8054\u7cfb\u9500\u552e / \u5b9a\u5236\u5b9a\u4ef7"'), 'unknown' => fxdst_submit_msg('"\u6682\u4e0d\u786e\u5b9a"'), ); if ($title === '' || $desc === '' || $link === '') { fxdst_ajax_response(3, fxdst_submit_msg('"\u8bf7\u586b\u5199\u5de5\u5177\u540d\u79f0\u3001\u5b98\u7f51\u94fe\u63a5\u548c\u7b80\u4ecb\u3002"')); } if (!wp_http_validate_url($link)) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8bf7\u586b\u5199\u5b8c\u6574\u6709\u6548\u7684\u5b98\u7f51\u94fe\u63a5\u3002"')); } $submitted_domain = fxdst_submit_normalize_domain($link); if ($submitted_domain === '') { fxdst_ajax_response(3, fxdst_submit_msg('"\u8bf7\u586b\u5199\u5b8c\u6574\u6709\u6548\u7684\u5b98\u7f51\u94fe\u63a5\u3002"')); } if (fxdst_submit_domain_exists($submitted_domain)) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8be5\u57df\u540d\u5df2\u7ecf\u6536\u5f55\u6216\u6b63\u5728\u5ba1\u6838\u4e2d\uff0c\u8bf7\u4e0d\u8981\u91cd\u590d\u63d0\u4ea4\u3002"')); } if (!$cat_id || !term_exists($cat_id, 'favorites')) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8bf7\u9009\u62e9\u4e00\u4e2a\u5408\u9002\u7684\u5206\u7c7b\u3002"')); } $post_id = wp_insert_post(array( 'post_type' => 'sites', 'post_status' => 'draft', 'post_title' => $title, 'post_content' => $content, 'post_excerpt' => $desc, ), true); if (is_wp_error($post_id)) { fxdst_ajax_response(4, fxdst_submit_msg('"\u63d0\u4ea4\u5931\u8d25\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5\u3002"')); } wp_set_object_terms($post_id, array($cat_id), 'favorites'); update_post_meta($post_id, '_sites_link', $link); update_post_meta($post_id, '_sites_domain', $submitted_domain); update_post_meta($post_id, '_sites_sescribe', $desc); update_post_meta($post_id, '_sites_order', 0); update_post_meta($post_id, '_visible', '1'); if ($icon) { update_post_meta($post_id, '_thumbnail', $icon); } if ($screenshot) { update_post_meta($post_id, '_sites_screenshot', $screenshot); } if ($price_mode && isset($price_options[$price_mode])) { update_post_meta($post_id, '_sites_price_mode', $price_mode); update_post_meta($post_id, '_sites_price', $price_options[$price_mode]); } fxdst_ajax_response(1, fxdst_submit_msg('"\u63d0\u4ea4\u6210\u529f\uff0c\u5ba1\u6838\u540e\u4f1a\u6536\u5f55\u5230\u7ad9\u5185\u3002"'), array('id' => $post_id)); } add_action('wp_ajax_img_upload', 'fxdst_handle_submit_image_upload'); add_action('wp_ajax_nopriv_img_upload', 'fxdst_handle_submit_image_upload'); function fxdst_handle_submit_image_upload() { if (!fxdst_verify_submit_nonce()) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8868\u5355\u5df2\u8fc7\u671f\uff0c\u8bf7\u5237\u65b0\u540e\u91cd\u8bd5\u3002"')); } if (empty($_FILES['files']) || empty($_FILES['files']['tmp_name'])) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8bf7\u9009\u62e9\u8981\u4e0a\u4f20\u7684\u56fe\u7247\u3002"')); } $file = $_FILES['files']; $upload_type = isset($_POST['upload_type']) ? sanitize_key(wp_unslash($_POST['upload_type'])) : ''; $max_upload_size = $upload_type === 'sites_screenshot' ? 512 * 1024 : 128 * 1024; if (!empty($file['size']) && (int) $file['size'] > $max_upload_size) { if ($upload_type === 'sites_screenshot') { fxdst_ajax_response(3, fxdst_submit_msg('"\u4ea7\u54c1\u622a\u56fe\u5927\u5c0f\u4e0d\u80fd\u8d85\u8fc7 512KB\u3002"')); } fxdst_ajax_response(3, fxdst_submit_msg('"\u56fe\u7247\u5927\u5c0f\u4e0d\u80fd\u8d85\u8fc7 128KB\u3002"')); } require_once ABSPATH . 'wp-admin/includes/file.php'; require_once ABSPATH . 'wp-admin/includes/media.php'; require_once ABSPATH . 'wp-admin/includes/image.php'; $checked = wp_check_filetype_and_ext($file['tmp_name'], $file['name'], array( 'jpg|jpeg|jpe' => 'image/jpeg', 'png' => 'image/png', )); if (empty($checked['type']) || empty($checked['ext'])) { fxdst_ajax_response(3, fxdst_submit_msg('"\u56fe\u7247\u7c7b\u578b\u53ea\u652f\u6301 jpg\u3001jpeg\u3001png\u3002"')); } $attachment_id = media_handle_upload('files', 0); if (is_wp_error($attachment_id)) { fxdst_ajax_response(4, fxdst_submit_msg('"\u56fe\u7247\u4e0a\u4f20\u5931\u8d25\uff0c\u8bf7\u6362\u4e00\u5f20\u91cd\u8bd5\u3002"')); } update_post_meta($attachment_id, '_fxdst_submit_upload', '1'); fxdst_ajax_response(1, fxdst_submit_msg('"\u56fe\u7247\u4e0a\u4f20\u6210\u529f\u3002"'), array( 'id' => $attachment_id, 'src' => wp_get_attachment_url($attachment_id), )); } add_action('wp_ajax_img_remove', 'fxdst_handle_submit_image_remove'); add_action('wp_ajax_nopriv_img_remove', 'fxdst_handle_submit_image_remove'); function fxdst_handle_submit_image_remove() { if (!fxdst_verify_submit_nonce()) { fxdst_ajax_response(3, fxdst_submit_msg('"\u8868\u5355\u5df2\u8fc7\u671f\uff0c\u8bf7\u5237\u65b0\u540e\u91cd\u8bd5\u3002"')); } $id = isset($_POST['id']) ? absint($_POST['id']) : 0; if (!$id || get_post_meta($id, '_fxdst_submit_upload', true) !== '1') { fxdst_ajax_response(3, fxdst_submit_msg('"\u672a\u627e\u5230\u53ef\u5220\u9664\u7684\u56fe\u7247\u3002"')); } if (wp_delete_attachment($id, true)) { fxdst_ajax_response(1, fxdst_submit_msg('"\u56fe\u7247\u5df2\u5220\u9664\u3002"')); } fxdst_ajax_response(4, fxdst_submit_msg('"\u56fe\u7247\u5220\u9664\u5931\u8d25\u3002"')); }