Files
wordpress-theme-aksrt/src/Core/Templates.php
T
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.

Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
  cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
  window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)

Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
  so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
  (dropped 3 stale entries, added the 17 missing ones)

Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
  get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
  when it is empty

Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.

Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-11-01 20:05:04 +08:00

121 lines
3.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* @package Jio
*/
namespace Jio\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('jio_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' => __('Jio - 登录/注册', 'jio'),
'templates/pages/page-profile.php' => __('Jio - 个人中心', 'jio'),
'templates/pages/page-user-home.php' => __('Jio - 用户主页', 'jio'),
'templates/pages/page-archives.php' => __('Jio - 文章归档', 'jio'),
'templates/pages/page-categories.php' => __('Jio - 分类汇总', 'jio'),
'templates/pages/page-newposts.php' => __('Jio - 最新文章', 'jio'),
// 注意:page-newposts = 最新文章列表;投稿页是 page-submit(写文章/投稿)
'templates/pages/page-submit.php' => __('Jio - 写文章/投稿', 'jio'),
'templates/pages/page-posts-navs.php' => __('Jio - 文章导航', 'jio'),
'templates/pages/page-friends.php' => __('Jio - 友情链接', 'jio'),
];
}
/**
* 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('jio_resolve_page_template_file')
? jio_resolve_page_template_file(
is_string($page_template_meta) ? $page_template_meta : '',
(string) $post->post_name
)
: '';
if ($resolved_template !== '' && function_exists('jio_locate_template_file')) {
$resolved_path = jio_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 = JIO_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 = JIO_DIR . '/templates/shortcodes/profile.php';
if (!file_exists($template)) {
return '';
}
ob_start();
include $template;
return (string) ob_get_clean();
}
}