v0.1.0 核心功能: - 更新源管理 (SourceManager, SourceModel, SourceType) - 插件/主题更新器 (PluginUpdater, ThemeUpdater) - 缓存系统 (CacheManager, HealthChecker, FallbackStrategy) - 安全模块 (Validator, Encryption) - 管理界面 (AdminPage, templates, CSS, JS) - 预设源支持 (ArkPress, AspireCloud) v0.2.0 新增功能: - 性能优化 (ParallelRequestManager, RequestDeduplicator) - 条件请求 (ConditionalRequest - ETag/Last-Modified) - 后台更新 (BackgroundUpdater - WP-Cron) - Git 平台支持 (GitHub, GitLab, Gitee handlers) - WP-CLI 命令 (wp bridge source/check/cache/diagnose/config) 安全修复: - SQL 注入防护 ($wpdb->prepare) - GET 参数清理 (sanitize_text_field) - auth_token 加密存储 (AES-256-CBC) - 缓存键哈希 (md5 + site_url) - 卸载清理 (uninstall.php) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
68 lines
1.3 KiB
PHP
68 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* 自动加载器
|
|
*
|
|
* @package WPBridge
|
|
*/
|
|
|
|
namespace WPBridge\Core;
|
|
|
|
// 防止直接访问
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
/**
|
|
* PSR-4 风格自动加载器
|
|
*/
|
|
class Loader {
|
|
|
|
/**
|
|
* 命名空间前缀
|
|
*
|
|
* @var string
|
|
*/
|
|
private static string $namespace_prefix = 'WPBridge\\';
|
|
|
|
/**
|
|
* 基础目录
|
|
*
|
|
* @var string
|
|
*/
|
|
private static string $base_dir = '';
|
|
|
|
/**
|
|
* 注册自动加载器
|
|
*/
|
|
public static function register(): void {
|
|
self::$base_dir = WPBRIDGE_PATH . 'includes/';
|
|
spl_autoload_register( [ __CLASS__, 'autoload' ] );
|
|
}
|
|
|
|
/**
|
|
* 自动加载类
|
|
*
|
|
* @param string $class 完整类名
|
|
*/
|
|
public static function autoload( string $class ): void {
|
|
// 检查是否是我们的命名空间
|
|
$len = strlen( self::$namespace_prefix );
|
|
if ( strncmp( self::$namespace_prefix, $class, $len ) !== 0 ) {
|
|
return;
|
|
}
|
|
|
|
// 获取相对类名
|
|
$relative_class = substr( $class, $len );
|
|
|
|
// 转换为文件路径
|
|
$file = self::$base_dir . str_replace( '\\', '/', $relative_class ) . '.php';
|
|
|
|
// 如果文件存在则加载
|
|
if ( file_exists( $file ) ) {
|
|
require_once $file;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 立即注册自动加载器
|
|
Loader::register();
|