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:
1 parent
8f349b40fb
commit
aaf458af1c
404 files changed
+13602
-7705
No files matched your search
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Forum;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
trait ViewBuilderPart2 {
|
||||
|
||||
|
||||
public function ajax_search_topics(): void {
|
||||
$search = sanitize_text_field((string) ($_GET['q'] ?? $_POST['q'] ?? ''));
|
||||
$limit = min(50, max(5, (int) ($_GET['limit'] ?? 20)));
|
||||
|
||||
if (!taxonomy_exists('aksrt_forum_topic_cat')) {
|
||||
wp_send_json_success([]);
|
||||
}
|
||||
|
||||
$args = [
|
||||
'taxonomy' => 'aksrt_forum_topic_cat',
|
||||
'hide_empty' => false,
|
||||
'number' => $limit,
|
||||
'orderby' => 'name',
|
||||
'order' => 'ASC',
|
||||
];
|
||||
if ($search !== '') {
|
||||
$args['search'] = $search;
|
||||
}
|
||||
|
||||
$terms = get_terms($args);
|
||||
$results = [];
|
||||
if (!is_wp_error($terms)) {
|
||||
foreach ($terms as $term) {
|
||||
$results[] = ['id' => (int) $term->term_id, 'name' => (string) $term->name];
|
||||
}
|
||||
}
|
||||
|
||||
wp_send_json_success($results);
|
||||
}
|
||||
|
||||
public function template_routing(string $template): string {
|
||||
// Plate CPT single → board template
|
||||
if (is_singular('aksrt_forum_plate')) {
|
||||
$plate_template = AKSRT_DIR . '/templates/forum/forum-plate.php';
|
||||
if (file_exists($plate_template)) {
|
||||
return $plate_template;
|
||||
}
|
||||
$board_template = AKSRT_DIR . '/templates/forum/forum-board.php';
|
||||
if (file_exists($board_template)) {
|
||||
return $board_template;
|
||||
}
|
||||
}
|
||||
|
||||
// Plate category (分区) archive
|
||||
if (is_tax('aksrt_plate_cat')) {
|
||||
$cat_template = AKSRT_DIR . '/templates/forum/forum-plate-cat.php';
|
||||
if (file_exists($cat_template)) {
|
||||
return $cat_template;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_tax('aksrt_forum_board')) {
|
||||
$board_template = AKSRT_DIR . '/templates/forum/forum-board.php';
|
||||
if (file_exists($board_template)) {
|
||||
return $board_template;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_tax('aksrt_forum_tag')) {
|
||||
$tag_template = AKSRT_DIR . '/templates/forum/forum-tag.php';
|
||||
if (file_exists($tag_template)) {
|
||||
return $tag_template;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_singular('aksrt_forum_topic')) {
|
||||
if (isset($_GET['edit']) && $_GET['edit'] === '1') {
|
||||
$edit_template = AKSRT_DIR . '/templates/forum/forum-edit.php';
|
||||
if (file_exists($edit_template)) {
|
||||
return $edit_template;
|
||||
}
|
||||
}
|
||||
|
||||
$topic_template = AKSRT_DIR . '/templates/forum/forum-topic.php';
|
||||
if (file_exists($topic_template)) {
|
||||
return $topic_template;
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
public function ajax_topic_list(): void {
|
||||
$user_id = get_current_user_id();
|
||||
if (!$this->forum->is_forum_admin($user_id)) {
|
||||
wp_send_json_error(['message' => __('权限不足', 'aksrt')]);
|
||||
}
|
||||
|
||||
$board_id = (int) ($_GET['board_id'] ?? 0);
|
||||
$limit = max(1, min(100, (int) ($_GET['limit'] ?? 20)));
|
||||
$view = $this->get_topic_list([
|
||||
'board_id' => $board_id,
|
||||
'limit' => $limit,
|
||||
'status' => 'all',
|
||||
'viewer_user_id' => get_current_user_id(),
|
||||
'include_hidden' => true,
|
||||
]);
|
||||
|
||||
wp_send_json_success([
|
||||
'topics' => $view['items'],
|
||||
'stats' => $this->get_stats(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user