mirror of
https://github.com/WenPai-org/wp-china-yes.git
synced 2025-10-04 01:45:06 +08:00
Refactored service initialization to support modular loading and error handling. Enhanced Acceleration service with unified output buffering, regex/string replacement, performance logging, and version control for static assets. Added new services for comments, language, lazy translation, migration, modern settings, translation management, and widgets. Improved font loading logic and added RTL mirror support. Updated avatar service to support preconnect for multiple providers. Various bug fixes and code organization improvements.
61 lines
1.4 KiB
PHP
Executable file
61 lines
1.4 KiB
PHP
Executable file
<?php
|
|
|
|
namespace WenPai\ChinaYes\Service;
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
|
|
|
/**
|
|
* Class Base
|
|
* 插件主服务
|
|
* @package WenPai\ChinaYes\Service
|
|
*/
|
|
class Base {
|
|
|
|
private $services = [];
|
|
|
|
public function __construct() {
|
|
$this->init_services();
|
|
}
|
|
|
|
private function init_services() {
|
|
$core_services = [
|
|
'Super',
|
|
'Monitor',
|
|
'Memory',
|
|
'Update',
|
|
'Database',
|
|
'Acceleration',
|
|
'Avatar',
|
|
'Fonts',
|
|
'Comments',
|
|
'Media',
|
|
'Performance',
|
|
'Maintenance'
|
|
];
|
|
|
|
foreach ($core_services as $service) {
|
|
$this->load_service($service);
|
|
}
|
|
|
|
if (is_admin()) {
|
|
$this->load_service('Setting');
|
|
$this->load_service('Adblock');
|
|
}
|
|
}
|
|
|
|
private function load_service($service_name) {
|
|
$class_name = __NAMESPACE__ . '\\' . $service_name;
|
|
|
|
if (class_exists($class_name)) {
|
|
try {
|
|
$this->services[$service_name] = new $class_name();
|
|
} catch (\Exception $e) {
|
|
error_log("WP-China-Yes: Failed to load service {$service_name}: " . $e->getMessage());
|
|
}
|
|
}
|
|
}
|
|
|
|
public function get_service($service_name) {
|
|
return $this->services[$service_name] ?? null;
|
|
}
|
|
}
|