refactor(autoload): migrate theme classes to Composer PSR-4
Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Core;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class Scripts {
|
||||
use ScriptsPart1b;
|
||||
use ScriptsPart1c;
|
||||
use ScriptsPart2;
|
||||
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
private function __construct() {}
|
||||
|
||||
public static function get_instance(): self {
|
||||
if (null === self::$instance) {
|
||||
self::$instance = new self();
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public function init(): void {
|
||||
add_action('wp_enqueue_scripts', [$this, 'enqueue_public']);
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_admin']);
|
||||
add_action('admin_enqueue_scripts', [$this, 'enqueue_passive_polyfill'], 1);
|
||||
add_action('wp_head', [$this, 'inline_css_vars']);
|
||||
add_action('wp_head', [$this, 'output_custom_codes']);
|
||||
add_action('wp_body_open', [$this, 'output_loading_overlay'], 1);
|
||||
add_action('wp_footer', [$this, 'output_custom_footer_codes'], 99);
|
||||
add_action('wp_ajax_aksrt_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_nopriv_aksrt_frontend_debug', [$this, 'handle_frontend_debug']);
|
||||
add_action('wp_ajax_aksrt_search_history', [$this, 'handle_search_history']);
|
||||
add_action('wp_ajax_aksrt_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_action('wp_ajax_nopriv_aksrt_search_suggestions', [$this, 'handle_search_suggestions']);
|
||||
add_filter('body_class', [$this, 'body_classes']);
|
||||
add_filter('wp_resource_hints', [$this, 'resource_hints'], 10, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字体 CDN 的 preconnect 提示(提前 DNS + TLS 握手,加速首屏字体加载)
|
||||
*/
|
||||
public function resource_hints(array $hints, string $relation): array {
|
||||
if ('preconnect' === $relation) {
|
||||
$hints[] = [
|
||||
'href' => 'https://fonts.googleapis.com',
|
||||
'crossorigin',
|
||||
];
|
||||
$hints[] = [
|
||||
'href' => 'https://fonts.gstatic.com',
|
||||
'crossorigin',
|
||||
];
|
||||
$hints[] = [
|
||||
'href' => 'https://cdn.jsdelivr.net',
|
||||
'crossorigin',
|
||||
];
|
||||
}
|
||||
return $hints;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user