文章目录[隐藏]
网络传媒柔性内容智能查重与原创保护WordPress插件教程
引言:内容原创保护的重要性
在当今数字化媒体时代,内容创作已成为网络传媒的核心竞争力。然而,随着信息传播速度的加快,内容抄袭和重复使用的问题日益严重。对于WordPress网站运营者而言,保护原创内容不仅是维护品牌声誉的需要,更是提升SEO排名和用户体验的关键。本教程将详细介绍如何开发一款柔性内容智能查重与原创保护WordPress插件,帮助内容创作者有效保护自己的劳动成果。
插件功能概述
我们的插件将具备以下核心功能:
- 智能内容查重:自动检测网站内容与互联网上已有内容的相似度
- 原创性评分系统:为每篇文章生成原创性评分
- 柔性查重策略:支持设置相似度阈值,避免误判合理引用
- 实时监测:在文章发布时自动进行查重检测
- 原创保护水印:为原创内容添加隐形标识
- 抄袭报告生成:发现抄袭时生成详细报告
开发环境准备
在开始开发之前,请确保您已准备好以下环境:
- WordPress开发环境(建议使用Local by Flywheel或XAMPP)
- PHP 7.0或更高版本
- 文本编辑器或IDE(如VS Code、PHPStorm)
- 基本的PHP和WordPress插件开发知识
插件基础结构
首先,我们创建插件的基本文件结构:
flexible-content-checker/
├── flexible-content-checker.php # 主插件文件
├── includes/
│ ├── class-content-checker.php # 内容查重核心类
│ ├── class-originality-scorer.php # 原创性评分类
│ └── class-report-generator.php # 报告生成类
├── admin/
│ ├── css/
│ │ └── admin-style.css # 后台样式
│ ├── js/
│ │ └── admin-script.js # 后台脚本
│ └── admin-settings.php # 设置页面
├── assets/
│ └── js/
│ └── watermark.js # 水印功能脚本
└── uninstall.php # 卸载处理文件
主插件文件实现
以下是主插件文件的基本代码:
<?php
/**
* Plugin Name: 柔性内容智能查重与原创保护
* Plugin URI: https://yourwebsite.com/flexible-content-checker
* Description: 智能检测内容原创性,保护您的创作成果
* Version: 1.0.0
* Author: 您的名称
* License: GPL v2 or later
* Text Domain: flexible-content-checker
*/
// 防止直接访问
if (!defined('ABSPATH')) {
exit;
}
// 定义插件常量
define('FCC_VERSION', '1.0.0');
define('FCC_PLUGIN_DIR', plugin_dir_path(__FILE__));
define('FCC_PLUGIN_URL', plugin_dir_url(__FILE__));
// 初始化插件
class FlexibleContentChecker {
private static $instance = null;
public static function get_instance() {
if (null === self::$instance) {
self::$instance = new self();
}
return self::$instance;
}
private function __construct() {
$this->init_hooks();
}
private function init_hooks() {
// 激活/停用钩子
register_activation_hook(__FILE__, array($this, 'activate'));
register_deactivation_hook(__FILE__, array($this, 'deactivate'));
// 初始化
add_action('plugins_loaded', array($this, 'init'));
// 加载文本域
add_action('init', array($this, 'load_textdomain'));
}
public function activate() {
// 创建必要的数据库表
$this->create_tables();
// 设置默认选项
$default_options = array(
'similarity_threshold' => 70, // 相似度阈值70%
'auto_check' => true, // 自动检查
'watermark_enabled' => true, // 启用水印
'api_key' => '' // API密钥
);
if (!get_option('fcc_options')) {
add_option('fcc_options', $default_options);
}
// 设置版本号
update_option('fcc_version', FCC_VERSION);
}
public function deactivate() {
// 清理临时数据
// 注意:这里不删除用户数据,仅在卸载时删除
}
public function load_textdomain() {
load_plugin_textdomain(
'flexible-content-checker',
false,
dirname(plugin_basename(__FILE__)) . '/languages/'
);
}
public function init() {
// 加载必要文件
require_once FCC_PLUGIN_DIR . 'includes/class-content-checker.php';
require_once FCC_PLUGIN_DIR . 'includes/class-originality-scorer.php';
require_once FCC_PLUGIN_DIR . 'includes/class-report-generator.php';
// 初始化核心组件
$content_checker = new FCC_Content_Checker();
$originality_scorer = new FCC_Originality_Scorer();
// 如果是后台,加载管理界面
if (is_admin()) {
require_once FCC_PLUGIN_DIR . 'admin/admin-settings.php';
new FCC_Admin_Settings();
}
// 添加前端水印功能
add_action('wp_footer', array($this, 'add_watermark_script'));
}
private function create_tables() {
global $wpdb;
$charset_collate = $wpdb->get_charset_collate();
$table_name = $wpdb->prefix . 'fcc_scan_results';
$sql = "CREATE TABLE IF NOT EXISTS $table_name (
id bigint(20) NOT NULL AUTO_INCREMENT,
post_id bigint(20) NOT NULL,
scan_date datetime DEFAULT CURRENT_TIMESTAMP NOT NULL,
originality_score int(3) NOT NULL,
similarity_percentage int(3) NOT NULL,
sources_found text,
scan_details longtext,
PRIMARY KEY (id),
KEY post_id (post_id)
) $charset_collate;";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
dbDelta($sql);
}
public function add_watermark_script() {
if (is_single() && get_option('fcc_options')['watermark_enabled']) {
wp_enqueue_script(
'fcc-watermark',
FCC_PLUGIN_URL . 'assets/js/watermark.js',
array('jquery'),
FCC_VERSION,
true
);
// 传递数据到JavaScript
wp_localize_script('fcc-watermark', 'fcc_watermark_data', array(
'site_url' => get_site_url(),
'post_id' => get_the_ID(),
'author' => get_the_author()
));
}
}
}
// 启动插件
FlexibleContentChecker::get_instance();
?>
内容查重核心类实现
<?php
/**
* 内容查重核心类
* 负责与查重API交互并处理结果
*/
class FCC_Content_Checker {
private $api_endpoint = 'https://api.content-checker.com/v1/check';
private $options;
public function __construct() {
$this->options = get_option('fcc_options');
// 添加文章保存时的查重钩子
add_action('save_post', array($this, 'check_post_on_save'), 10, 3);
// 添加手动查重按钮
add_filter('post_row_actions', array($this, 'add_check_action'), 10, 2);
add_action('admin_action_fcc_check_post', array($this, 'handle_manual_check'));
}
/**
* 在文章保存时自动查重
*/
public function check_post_on_save($post_id, $post, $update) {
// 跳过自动保存和修订
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
if (wp_is_post_revision($post_id)) {
return;
}
// 检查是否启用自动查重
if (!$this->options['auto_check']) {
return;
}
// 只检查文章类型
if ($post->post_type !== 'post') {
return;
}
// 获取文章内容
$content = $post->post_content;
// 去除HTML标签,获取纯文本
$plain_text = wp_strip_all_tags($content);
// 如果内容太短,跳过检查
if (strlen($plain_text) < 100) {
return;
}
// 执行查重
$result = $this->check_content($plain_text, $post_id);
// 保存结果
$this->save_scan_result($post_id, $result);
// 如果相似度超过阈值,发送通知
if ($result['similarity_percentage'] > $this->options['similarity_threshold']) {
$this->send_alert_notification($post_id, $result);
}
}
/**
* 调用API检查内容原创性
*/
private function check_content($content, $post_id) {
// 如果有API密钥,使用外部API
if (!empty($this->options['api_key'])) {
return $this->check_with_external_api($content);
} else {
// 否则使用本地简单检查(示例)
return $this->simple_local_check($content, $post_id);
}
}
/**
* 使用外部API检查内容
*/
private function check_with_external_api($content) {
$api_key = $this->options['api_key'];
// 准备API请求数据
$data = array(
'content' => $content,
'language' => 'zh-CN',
'sensitivity' => 'medium'
);
// 发送请求
$response = wp_remote_post($this->api_endpoint, array(
'headers' => array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json'
),
'body' => json_encode($data),
'timeout' => 30
));
// 处理响应
if (is_wp_error($response)) {
// 如果API请求失败,返回默认结果
return array(
'originality_score' => 0,
'similarity_percentage' => 0,
'sources_found' => array(),
'error' => $response->get_error_message()
);
}
$body = wp_remote_retrieve_body($response);
$result = json_decode($body, true);
// 计算原创性评分(100 - 相似度百分比)
$originality_score = 100 - $result['similarity_percentage'];
return array(
'originality_score' => $originality_score,
'similarity_percentage' => $result['similarity_percentage'],
'sources_found' => $result['sources'],
'scan_details' => $result
);
}
/**
* 简单的本地查重(示例,实际应用中需要更复杂的算法)
*/
private function simple_local_check($content, $post_id) {
// 这是一个简化的示例,实际应用中应该使用更复杂的算法
// 例如:文本指纹、分词比较等
// 提取关键词
$keywords = $this->extract_keywords($content);
// 在本地数据库中查找相似内容
$similar_posts = $this->find_similar_posts($keywords, $post_id);
// 计算相似度
$similarity = $this->calculate_similarity($content, $similar_posts);
// 计算原创性评分
$originality_score = 100 - $similarity;
return array(
'originality_score' => $originality_score,
'similarity_percentage' => $similarity,
'sources_found' => $similar_posts,
'scan_details' => array(
'keywords' => $keywords,
'method' => 'local_simple_check'
)
);
}
/**
* 提取关键词(简化版)
*/
private function extract_keywords($content) {
// 去除停用词
$stop_words = array('的', '了', '在', '是', '我', '有', '和', '就', '不', '人', '都', '一', '一个', '上', '也', '很', '到', '说', '要', '去', '你', '会', '着', '没有', '看', '好', '自己', '这');
$words = preg_split('/s+/', $content);
$keywords = array();
foreach ($words as $word) {
$word = trim($word);
if (mb_strlen($word) > 1 && !in_array($word, $stop_words)) {
$keywords[] = $word;
}
}
// 返回前20个关键词
return array_slice(array_unique($keywords), 0, 20);
}
/**
* 保存扫描结果到数据库
*/
private function save_scan_result($post_id, $result) {
global $wpdb;
$table_name = $wpdb->prefix . 'fcc_scan_results';
$data = array(
'post_id' => $post_id,
'originality_score' => $result['originality_score'],
'similarity_percentage' => $result['similarity_percentage'],
'sources_found' => json_encode($result['sources_found'], JSON_UNESCAPED_UNICODE),
'scan_details' => json_encode($result['scan_details'], JSON_UNESCAPED_UNICODE)
);
// 检查是否已有该文章的记录
$existing = $wpdb->get_var($wpdb->prepare(
"SELECT id FROM $table_name WHERE post_id = %d ORDER BY scan_date DESC LIMIT 1",
$post_id
));
if ($existing) {
// 更新现有记录
$wpdb->update($table_name, $data, array('id' => $existing));
} else {
// 插入新记录
$wpdb->insert($table_name, $data);
}
// 更新文章元数据,便于快速访问
update_post_meta($post_id, '_fcc_originality_score', $result['originality_score']);
update_post_meta($post_id, '_fcc_last_checked', current_time('mysql'));
}
/**
* 在文章列表添加手动查重按钮
*/
public function add_check_action($actions, $post) {
if ($post->post_type === 'post') {
$check_url = admin_url('admin.php?action=fcc_check_post&post=' . $post->ID);
$actions['fcc_check'] = '<a href="' . $check_url . '" title="检查原创性">检查原创性</a>';
}
return $actions;
}
/**
* 处理手动查重请求
*/
public function handle_manual_check() {
if (!current_user_can('edit_posts')) {
wp_die('权限不足');
}
$post_id = intval($_GET['post']);
// 执行查重
$post = get_post($post_id);
$content = wp_strip_all_tags($post->post_content);
$result = $this->check_content($content, $post_id);
// 保存结果
$this->save_scan_result($post_id, $result);
// 重定向回文章列表,并显示结果
wp_redirect(admin_url('edit.php?post_type=post&fcc_message=checked&score=' . $result['originality_score']));
exit;
}
}
?>
前端水印保护脚本
/**
* 前端水印保护脚本
* 为原创内容添加隐形标识
*/
(function($) {
'use strict';
$(document).ready(function() {
// 检查是否应该添加水印
if (typeof fcc_watermark_data === 'undefined') {
return;
}
// 创建水印容器
var watermark = $('<div class="fcc-watermark"></div>');
// 设置水印内容(使用不可见但机器可读的方式)
var watermarkContent =
'原创内容标识|' +
fcc_watermark_data.site_url + '|' +
fcc_watermark_data.post_id + '|' +
fcc_watermark_data.author + '|' +
new Date().toISOString().split('T')[0];
// 将水印内容编码为Base64
var encodedContent = btoa(encodeURIComponent(watermarkContent));
// 设置水印样式(完全透明,不影响用户)
watermark.css({
'position': 'fixed',
'bottom': '10px',
'right': '10px',
'opacity': '0.001',
'font-size': '1px',
'color': 'transparent',
'z-index': '-9999',
'user-select': 'none',
'pointer-events': 'none'
});
// 添加水印文本
watermark.text(encodedContent);
// 将水印添加到页面
$('body').append(watermark);
// 额外保护:为文章内容添加数据属性
$('.entry-content, .post-content').attr('data-fcc-original', encodedContent);
// 防止简单的内容复制
$('article').on('copy', function(e) {
var selectedText = window.getSelection().toString();
// 如果复制的内容超过一定长度,添加来源标识
if (selectedText.length > 100) {
e.preventDefault();
var sourceText = selectedText + 'nn---n来源: ' +
window.location.href + 'n' +
'© ' + fcc_watermark_data.site_url;
// 尝试将文本写入剪贴板
if (e.clipboardData) {
e.clipboardData.setData('text/plain', sourceText);
}
}
});
// 定期验证页面完整性
setInterval(function() {
var currentWatermark = $('.fcc-watermark').text();
if (currentWatermark !== encodedContent) {
// 水印被篡改,尝试恢复
$('.fcc-watermark').text(encodedContent);
// 可选:向管理员报告异常
if (Math.random() < 0.1) { // 10%概率报告,避免过多请求
$.post(fcc_watermark_data.site_url + '/wp-admin/admin-ajax.php', {
action: 'fcc_report_tamper',
post_id: fcc_watermark_data.post_id,
nonce: fcc_watermark_data.nonce
});
}
}
}, 30000); // 每30秒检查一次
});
})(jQuery);
## 原创性评分类实现
<?php
/**
- 原创性评分类
- 负责计算和展示内容的原创性评分
*/
class FCC_Originality_Scorer {
public function __construct() {
// 在文章列表添加原创性评分列
add_filter('manage_posts_columns', array($this, 'add_originality_column'));
add_action('manage_posts_custom_column', array($this, 'display_originality_column'), 10, 2);
// 添加文章编辑页面的原创性评分元框
add_action('add_meta_boxes', array($this, 'add_originality_metabox'));
// 添加快速查重按钮到文章编辑页面
add_action('post_submitbox_misc_actions', array($this, 'add_quick_check_button'));
}
/**
* 在文章列表添加原创性评分列
*/
public function add_originality_column($columns) {
$columns['originality_score'] = __('原创评分', 'flexible-content-checker');
return $columns;
}
/**
* 显示原创性评分列内容
*/
public function display_originality_column($column, $post_id) {
if ($column === 'originality_score') {
$score = get_post_meta($post_id, '_fcc_originality_score', true);
$last_checked = get_post_meta($post_id, '_fcc_last_checked', true);
if ($score !== '') {
$score = intval($score);
$color = $this->get_score_color($score);
echo '<div class="fcc-score-display" style="text-align: center;">';
echo '<span class="score-circle" style="';
echo 'display: inline-block; width: 40px; height: 40px; ';
echo 'line-height: 40px; border-radius: 50%; ';
echo 'background-color: ' . $color . '; color: white; ';
echo 'font-weight: bold; font-size: 14px;">';
echo esc_html($score);
echo '</span>';
if ($last_checked) {
echo '<br><small style="font-size: 10px; color: #666;">';
echo date('m-d H:i', strtotime($last_checked));
echo '</small>';
}
echo '</div>';
} else {
echo '<span class="fcc-not-checked">未检查</span>';
echo '<br><a href="' . admin_url('admin.php?action=fcc_check_post&post=' . $post_id) . '" class="button button-small">立即检查</a>';
}
}
}
/**
* 根据评分获取对应的颜色
*/
private function get_score_color($score) {
if ($score >= 90) {
return '#4CAF50'; // 绿色 - 优秀
} elseif ($score >= 70) {
return '#8BC34A'; // 浅绿 - 良好
} elseif ($score >= 50) {
return '#FFC107'; // 黄色 - 一般
} elseif ($score >= 30) {
return '#FF9800'; // 橙色 - 较差
} else {
return '#F44336'; // 红色 - 很差
}
}
/**
* 添加原创性评分元框到文章编辑页面
*/
public function add_originality_metabox() {
add_meta_box(
'fcc_originality_metabox',
__('内容原创性分析', 'flexible-content-checker'),
array($this, 'render_originality_metabox'),
'post',
'side',
'high'
);
}
/**
* 渲染原创性评分元框
*/
public function render_originality_metabox($post) {
$score = get_post_meta($post->ID, '_fcc_originality_score', true);
$last_checked = get_post_meta($post->ID, '_fcc_last_checked', true);
$details = $this->get_scan_details($post->ID);
wp_nonce_field('fcc_check_nonce', 'fcc_nonce');
echo '<div id="fcc-originality-container">';
if ($score !== '') {
$score = intval($score);
$color = $this->get_score_color($score);
echo '<div class="fcc-score-main" style="text-align: center; margin-bottom: 15px;">';
echo '<div class="score-circle-large" style="';
echo 'width: 80px; height: 80px; margin: 0 auto 10px; ';
echo 'line-height: 80px; border-radius: 50%; ';
echo 'background-color: ' . $color . '; color: white; ';
echo 'font-weight: bold; font-size: 24px;">';
echo esc_html($score);
echo '</div>';
echo '<div class="score-label">';
echo $this->get_score_label($score);
echo '</div>';
if ($last_checked) {
echo '<div class="last-checked" style="font-size: 12px; color: #666; margin-top: 5px;">';
echo '最后检查: ' . date('Y-m-d H:i', strtotime($last_checked));
echo '</div>';
}
echo '</div>';
// 显示详细报告
if (!empty($details)) {
echo '<div class="fcc-details">';
echo '<h4>详细报告</h4>';
if (isset($details['similarity_percentage'])) {
echo '<p>相似度: ' . esc_html($details['similarity_percentage']) . '%</p>';
}
if (isset($details['sources_found']) && !empty($details['sources_found'])) {
echo '<p>发现相似来源: ' . count($details['sources_found']) . '个</p>';
echo '<ul style="font-size: 12px; max-height: 100px; overflow-y: auto;">';
foreach (array_slice($details['sources_found'], 0, 3) as $source) {
echo '<li>';
if (isset($source['url'])) {
echo '<a href="' . esc_url($source['url']) . '" target="_blank">';
echo esc_html($this->truncate_text($source['url'], 40));
echo '</a>';
}
if (isset($source['similarity'])) {
echo ' (' . esc_html($source['similarity']) . '%)';
}
echo '</li>';
}
echo '</ul>';
}
echo '</div>';
}
} else {
echo '<p>这篇文章尚未进行原创性检查。</p>';
}
echo '<div class="fcc-actions" style="margin-top: 15px; text-align: center;">';
echo '<button type="button" id="fcc-check-now" class="button button-primary" ';
echo 'data-post-id="' . esc_attr($post->ID) . '">';
echo ($score !== '') ? '重新检查' : '立即检查';
echo '</button>';
echo '<span id="fcc-checking-spinner" style="display: none; margin-left: 10px;">';
echo '<span class="spinner is-active"></span> 检查中...';
echo '</span>';
echo '</div>';
echo '<div id="fcc-check-result" style="margin-top: 10px; display: none;"></div>';
echo '</div>';
// 内联JavaScript
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#fcc-check-now').on('click', function() {
var postId = $(this).data('post-id');
var nonce = $('#fcc_nonce').val();
$('#fcc-checking-spinner').show();
$('#fcc-check-result').hide().empty();
$.post(ajaxurl, {
action: 'fcc_check_single_post',
post_id: postId,
nonce: nonce
}, function(response) {
$('#fcc-checking-spinner').hide();
if (response.success) {
$('#fcc-check-result').html(
'<div class="notice notice-success"><p>' +
response.data.message +
'</p></div>'
).show();
// 重新加载元框内容
setTimeout(function() {
location.reload();
}, 1500);
} else {
$('#fcc-check-result').html(
'<div class="notice notice-error"><p>' +
response.data +
'</p></div>'
).show();
}
});
});
});
</script>
<?php
}
/**
* 根据评分获取标签
*/
private function get_score_label($score) {
if ($score >= 90) return '优秀原创';
if ($score >= 70) return '良好原创';
if ($score >= 50) return '一般原创';
if ($score >= 30) return '原创性较低';
return '可能存在抄袭';
}
/**
* 获取扫描详情
*/
private function get_scan_details($post_id) {
global $wpdb;
$table_name = $wpdb->prefix . 'fcc_scan_results';
$result = $wpdb->get_row($wpdb->prepare(
"SELECT * FROM $table_name WHERE post_id = %d ORDER BY scan_date DESC LIMIT 1",
$post_id
), ARRAY_A);
if ($result) {
$result['sources_found'] = json_decode($result['sources_found'], true);
$result['scan_details'] = json_decode($result['scan_details'], true);
return $result;
}
return array();
}
/**
* 截断文本
*/
private function truncate_text($text, $length) {
if (mb_strlen($text) > $length) {
return mb_substr($text, 0, $length) . '...';
}
return $text;
}
/**
* 在文章发布框添加快速查重按钮
*/
public function add_quick_check_button() {
global $post;
if ($post && $post->post_type === 'post') {
$score = get_post_meta($post->ID, '_fcc_originality_score', true);
echo '<div class="misc-pub-section misc-pub-fcc">';
echo '<span class="dashicons dashicons-search" style="vertical-align: middle;"></span> ';
echo '原创性: ';
if ($score !== '') {
$score = intval($score);
$color = $this->get_score_color($score);
echo '<span style="color: ' . $color . '; font-weight: bold;">';
echo esc_html($score) . '/100';
echo '</span>';
} else {
echo '<span style="color: #999;">未检查</span>';
}
echo '<a href="#" id="fcc-quick-check" style="margin-left: 10px;">检查</a>';
echo '</div>';
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
$('#fcc-quick-check').on('click', function(e) {
e.preventDefault();
$('#fcc-check-now').trigger('click');
});
});
</script>
<?php
}
}
}
?>
## 后台设置页面实现
<?php
/**
- 后台设置页面
*/
class FCC_Admin_Settings {
private $options;
public function __construct() {
$this->options = get_option('fcc_options');
// 添加设置菜单
add_action('admin_menu', array($this, 'add_settings_menu'));
// 注册设置
add_action('admin_init', array($this, 'register_settings'));
// 添加AJAX处理
add_action('wp_ajax_fcc_check_single_post', array($this, 'ajax_check_single_post'));
// 添加批量操作
add_filter('bulk_actions-edit-post', array($this, 'add_bulk_actions'));
add_filter('handle_bulk_actions-edit-post', array($this, 'handle_bulk_actions'), 10, 3);
}
/**
* 添加设置菜单
*/
public function add_settings_menu() {
add_options_page(
__('内容查重设置', 'flexible-content-checker'),
__('内容查重', 'flexible-content-checker'),
'manage_options',
'fcc-settings',
array($this, 'render_settings_page')
);
// 添加统计页面
add_menu_page(
__('内容原创性统计', 'flexible-content-checker'),
__('原创保护', 'flexible-content-checker'),
'edit_posts',
'fcc-statistics',
array($this, 'render_statistics_page'),
'dashicons-shield',
30
);
}
/**
* 渲染设置页面
*/
public function render_settings_page() {
?>
<div class="wrap">
<h1><?php echo esc_html__('柔性内容智能查重设置', 'flexible-content-checker'); ?></h1>
<form method="post" action="options.php">
<?php
settings_fields('fcc_options_group');
do_settings_sections('fcc-settings');
submit_button();
?>
</form>
<div class="fcc-settings-info">
<h3>使用说明</h3>
<ol>
<li>设置相似度阈值:超过此阈值的内容将被标记为可能抄袭</li>
<li>如需使用高级查重功能,请填写API密钥</li>
<li>水印功能可在前端为原创内容添加隐形标识</li>
<li>自动检查功能将在文章保存时自动进行查重</li>
</ol>
<h3>统计信息</h3>
<?php
$stats = $this->get_statistics();
echo '<p>已检查文章: ' . $stats['total_checked'] . ' 篇</p>';
echo '<p>平均原创评分: ' . $stats['average_score'] . '</p>';
echo '<p>疑似抄袭文章: ' . $stats['suspected_count'] . ' 篇</p>';
?>
</div>
</div>
<?php
}
/**
* 注册设置
*/
public function register_settings() {
register_setting(
'fcc_options_group',
'fcc_options',
array($this, 'sanitize_options')
);
// 基本设置部分
add_settings_section(
'fcc_basic_settings',
__('基本设置', 'flexible-content-checker'),
array($this, 'render_basic_section'),
'fcc-settings'
);
// API设置部分
add_settings_section(
'fcc_api_settings',
__('API设置', 'flexible-content-checker'),
array($this, 'render_api_section'),
'fcc-settings'
);
// 高级设置部分
add_settings_section(
'fcc_advanced_settings',
__('高级设置', 'flexible-content-checker'),
array($this, 'render_advanced_section'),
'fcc-settings'
);
// 添加字段
$this->add_settings_fields();
}
/**
* 添加设置字段
*/
private function add_settings_fields() {
// 相似度阈值
add_settings_field(
'similarity_threshold',
__('相似度阈值 (%)', 'flexible-content-checker'),
array($this, 'render_threshold_field'),
'fcc-settings',
'fcc_basic_settings'
);
// 自动检查
add_settings_field(
'auto_check',
__('自动检查', 'flexible-content-checker'),
array($this, 'render_auto_check_field'),
'fcc-settings',
'fcc_basic_settings'
);
// API密钥
add_settings_field(
'api_key',
__('API密钥', 'flexible-content-checker'),
array($this, 'render_api_key_field'),
'fcc-settings',
'fcc_api_settings'
);
// 水印功能
add_settings_field(
'watermark_enabled',
__('启用水印保护', 'flexible-content-checker'),
array


