refactor: flatten src/AKSRT → src (drop theme-identifier dir)

Move all domain folders from src/AKSRT/{Domain} to src/{Domain}; remap
Composer PSR-4 "AKSRT\\": "src/"; update audit script + README + ADR
paths; remove dead tools/build-psr4-map.php (scanned deleted inc/classes).
This commit is contained in:
kate522 committed 2026-08-02 22:06:06 +08:00
1 parent 56f1a8175f
commit 8c5b1555c9
285 files changed
+26 -3600

No files matched your search

+126
View File
@@ -0,0 +1,126 @@
<?php
/**
* @package AKSRT
*/
namespace AKSRT\Core;
defined('ABSPATH') || exit;
class Templates {
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_filter('theme_page_templates', [$this, 'register_page_templates']);
add_filter('template_include', [$this, 'load_page_template']);
add_filter('page_template_hierarchy', [$this, 'template_hierarchy']);
add_filter('aksrt_page_template_hierarchy', [$this, 'template_hierarchy']);
// 短代码注册统一在 Shortcodes(registry);本类只提供 archive/profile 渲染实现。
}
/**
* Selectable page templates shown in wp-admin for the rebuilt mainline.
*/
private function page_template_map(): array {
return [
'templates/pages/page-sign.php' => __('AKSRT - 登录/注册', 'aksrt'),
'templates/pages/page-profile.php' => __('AKSRT - 个人中心', 'aksrt'),
'templates/pages/page-user-home.php' => __('AKSRT - 用户主页', 'aksrt'),
'templates/pages/page-archives.php' => __('AKSRT - 文章归档', 'aksrt'),
'templates/pages/page-documentnav.php' => __('AKSRT - 文档导航', 'aksrt'),
'templates/pages/page-categories.php' => __('AKSRT - 分类汇总', 'aksrt'),
'templates/pages/page-newposts.php' => __('AKSRT - 最新文章', 'aksrt'),
// 注意:page-newposts = 最新文章列表;投稿页是 page-submit(写文章/投稿)
'templates/pages/page-submit.php' => __('AKSRT - 写文章/投稿', 'aksrt'),
'templates/pages/page-posts-navs.php' => __('AKSRT - 文章导航', 'aksrt'),
'templates/pages/page-friends.php' => __('AKSRT - 友情链接', 'aksrt'),
'templates/pages/page-links.php' => __('AKSRT - 网址导航', 'aksrt'),
'templates/pages/page-ban-appeal.php' => __('AKSRT - 禁封申诉', 'aksrt'),
'templates/pages/page-orders.php' => __('AKSRT - 订单中心', 'aksrt'),
'templates/pages/page-revenue.php' => __('AKSRT - 收益中心', 'aksrt'),
'templates/pages/page-messages.php' => __('AKSRT - 消息中心', 'aksrt'),
];
}
/**
* Register selectable page templates in wp-admin.
*/
public function register_page_templates(array $templates): array {
foreach ($this->page_template_map() as $template_file => $label) {
$templates[$template_file] = $label;
}
return $templates;
}
/**
* Resolve theme page templates through the shared page-template router.
*/
public function load_page_template(string $template): string {
global $post;
if (!$post) {
return $template;
}
$page_template_meta = get_post_meta($post->ID, '_wp_page_template', true);
$resolved_template = function_exists('aksrt_resolve_page_template_file')
? aksrt_resolve_page_template_file(
is_string($page_template_meta) ? $page_template_meta : '',
(string) $post->post_name
)
: '';
if ($resolved_template !== '' && function_exists('aksrt_locate_template_file')) {
$resolved_path = aksrt_locate_template_file($resolved_template);
if ($resolved_path) {
return $resolved_path;
}
}
return $template;
}
public function template_hierarchy(array $templates): array {
return $templates;
}
/**
* Load dedicated taxonomy templates.
*/
public function load_taxonomy_template(string $template): string {
return $template;
}
public function render_archive_shortcode(array $attrs = [], string $content = ''): string {
$template = AKSRT_DIR . '/templates/shortcodes/archive.php';
if (!file_exists($template)) {
return '';
}
ob_start();
include $template;
return (string) ob_get_clean();
}
public function render_profile_shortcode(array $attrs = [], string $content = ''): string {
$template = AKSRT_DIR . '/templates/shortcodes/profile.php';
if (!file_exists($template)) {
return '';
}
ob_start();
include $template;
return (string) ob_get_clean();
}
}