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
@@ -56,20 +56,20 @@ if (!function_exists('aksrt_homepage_get_tab_terms')) {
|
||||
* @return array<int, array{term:WP_Term, title:string, orderby:string, term_id:int}>
|
||||
*/
|
||||
function aksrt_homepage_get_tab_configs(): array {
|
||||
$limit = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_tab_limit()
|
||||
$limit = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_tab_limit()
|
||||
: 4;
|
||||
|
||||
if (!class_exists('AKSRT_Settings')) {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$structured_tabs = AKSRT_Settings::homepage_tabs();
|
||||
$structured_tabs = \AKSRT\Settings\Settings::homepage_tabs();
|
||||
if (empty($structured_tabs)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$excluded_cat_ids = array_flip(AKSRT_Settings::home_exclude_category_ids());
|
||||
$excluded_cat_ids = array_flip(\AKSRT\Settings\Settings::home_exclude_category_ids());
|
||||
$configs = [];
|
||||
|
||||
foreach ($structured_tabs as $tab) {
|
||||
@@ -119,8 +119,8 @@ if (!function_exists('aksrt_homepage_get_tab_posts_per_page')) {
|
||||
* Per-tab homepage post count.
|
||||
*/
|
||||
function aksrt_homepage_get_tab_posts_per_page(): int {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
$count = AKSRT_Settings::homepage_tab_posts_per_page();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$count = \AKSRT\Settings\Settings::homepage_tab_posts_per_page();
|
||||
if ($count > 0) {
|
||||
return max(1, min(20, $count));
|
||||
}
|
||||
@@ -135,8 +135,8 @@ if (!function_exists('aksrt_homepage_get_default_view_mode')) {
|
||||
* Default homepage view mode.
|
||||
*/
|
||||
function aksrt_homepage_get_default_view_mode(): string {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
return AKSRT_Settings::homepage_default_view();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::homepage_default_view();
|
||||
}
|
||||
|
||||
return 'list';
|
||||
@@ -148,8 +148,8 @@ if (!function_exists('aksrt_homepage_sticky_tabs_enabled')) {
|
||||
* Whether homepage tabs should stick below the primary nav.
|
||||
*/
|
||||
function aksrt_homepage_sticky_tabs_enabled(): bool {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
return AKSRT_Settings::homepage_sticky_tabs_enabled();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::homepage_sticky_tabs_enabled();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -161,8 +161,8 @@ if (!function_exists('aksrt_homepage_module_hero_enabled')) {
|
||||
* Whether the fixed homepage should render the built-in hero section.
|
||||
*/
|
||||
function aksrt_homepage_module_hero_enabled(): bool {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
return AKSRT_Settings::homepage_module_hero_enabled();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::homepage_module_hero_enabled();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -174,8 +174,8 @@ if (!function_exists('aksrt_homepage_module_banner_enabled')) {
|
||||
* Whether the fixed homepage should render the built-in banner section.
|
||||
*/
|
||||
function aksrt_homepage_module_banner_enabled(): bool {
|
||||
if (class_exists('AKSRT_Settings')) {
|
||||
return AKSRT_Settings::homepage_module_banner_enabled();
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
return \AKSRT\Settings\Settings::homepage_module_banner_enabled();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -187,11 +187,11 @@ if (!function_exists('aksrt_homepage_get_sort_mode')) {
|
||||
* Current homepage main-stream sort mode.
|
||||
*/
|
||||
function aksrt_homepage_get_sort_mode(): string {
|
||||
$allowed = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_allowed_sorts()
|
||||
$allowed = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
||||
$default_sort = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_default_sort()
|
||||
$default_sort = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_default_sort()
|
||||
: 'date';
|
||||
$override_sort = get_query_var('aksrt_homepage_sort_override');
|
||||
$sort = is_string($override_sort) && $override_sort !== ''
|
||||
@@ -209,16 +209,16 @@ if (!function_exists('aksrt_homepage_get_sort_items')) {
|
||||
* @return array<string,string>
|
||||
*/
|
||||
function aksrt_homepage_get_sort_items(): array {
|
||||
$all_labels = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_sort_labels()
|
||||
$all_labels = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_sort_labels()
|
||||
: [
|
||||
'modified' => '更新', 'date' => '发布', 'views' => '浏览',
|
||||
'likes' => '点赞', 'comments' => '评论', 'favorites' => '收藏',
|
||||
'downloads' => '下载', 'rand' => '随机',
|
||||
];
|
||||
|
||||
$enabled_keys = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_list_sort_options()
|
||||
$enabled_keys = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_list_sort_options()
|
||||
: array_keys($all_labels);
|
||||
|
||||
$items = [];
|
||||
@@ -302,8 +302,8 @@ if (!function_exists('aksrt_homepage_apply_named_sort_args')) {
|
||||
* Apply a specific named sort to query args (used by per-tab orderby).
|
||||
*/
|
||||
function aksrt_homepage_apply_named_sort_args(array $args, string $sort_mode): array {
|
||||
$allowed = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_allowed_sorts()
|
||||
$allowed = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_allowed_sorts()
|
||||
: ['modified', 'date', 'views', 'likes', 'comments', 'favorites', 'downloads', 'rand'];
|
||||
|
||||
if (!in_array($sort_mode, $allowed, true)) {
|
||||
@@ -324,21 +324,21 @@ if (!function_exists('aksrt_homepage_render_sortbar')) {
|
||||
* Render the main-stream sort bar.
|
||||
*/
|
||||
function aksrt_homepage_render_sortbar(): void {
|
||||
if (class_exists('AKSRT_Settings') && !AKSRT_Settings::home_list_sort_enabled()) {
|
||||
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::home_list_sort_enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$current = aksrt_homepage_get_sort_mode();
|
||||
$sort_ajax_enabled = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_sort_ajax_enabled()
|
||||
$sort_ajax_enabled = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_sort_ajax_enabled()
|
||||
: true;
|
||||
$is_dropdown = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_list_sort_dropdown()
|
||||
$is_dropdown = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_list_sort_dropdown()
|
||||
: false;
|
||||
$base_url = remove_query_arg('home_sort', get_pagenum_link(aksrt_homepage_get_current_page()));
|
||||
$sort_items = aksrt_homepage_get_sort_items();
|
||||
$all_labels = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_sort_labels()
|
||||
$all_labels = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_sort_labels()
|
||||
: $sort_items;
|
||||
?>
|
||||
<div class="aksrt-homepage__sortbar" data-sort-ajax="<?php echo $sort_ajax_enabled ? 'true' : 'false'; ?>" aria-label="<?php esc_attr_e('Homepage Sort', 'aksrt'); ?>">
|
||||
@@ -415,15 +415,15 @@ if (!function_exists('aksrt_homepage_get_latest_query')) {
|
||||
'no_found_rows' => false,
|
||||
];
|
||||
|
||||
$exclude_ids = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_exclude_post_ids()
|
||||
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_exclude_post_ids()
|
||||
: [];
|
||||
if (!empty($exclude_ids)) {
|
||||
$query_args['post__not_in'] = $exclude_ids;
|
||||
}
|
||||
|
||||
$exclude_cat_ids = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_exclude_category_ids()
|
||||
$exclude_cat_ids = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_exclude_category_ids()
|
||||
: [];
|
||||
if (!empty($exclude_cat_ids)) {
|
||||
$query_args['category__not_in'] = $exclude_cat_ids;
|
||||
@@ -456,8 +456,8 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
|
||||
$query_args = [
|
||||
'post_type' => aksrt_homepage_get_post_types(),
|
||||
'post_status' => 'publish',
|
||||
'posts_per_page' => class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::homepage_tab_posts_per_page()
|
||||
'posts_per_page' => class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::homepage_tab_posts_per_page()
|
||||
: 6,
|
||||
'ignore_sticky_posts' => true,
|
||||
'orderby' => 'date',
|
||||
@@ -472,8 +472,8 @@ if (!function_exists('aksrt_homepage_get_tab_query')) {
|
||||
],
|
||||
];
|
||||
|
||||
$exclude_ids = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_exclude_post_ids()
|
||||
$exclude_ids = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_exclude_post_ids()
|
||||
: [];
|
||||
if (!empty($exclude_ids)) {
|
||||
$query_args['post__not_in'] = $exclude_ids;
|
||||
@@ -616,8 +616,8 @@ if (!function_exists('aksrt_homepage_render_pagination')) {
|
||||
|
||||
$query_page = (int) $query->get('paged');
|
||||
$current_page = min(max(1, $query_page > 0 ? $query_page : aksrt_homepage_get_current_page()), $max_pages);
|
||||
$pagination_mode = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::get_post_pagination_mode()
|
||||
$pagination_mode = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_post_pagination_mode()
|
||||
: 'numbered';
|
||||
|
||||
if ($pagination_mode === 'numbered') {
|
||||
@@ -951,8 +951,8 @@ if (!function_exists('aksrt_header_slide_is_show')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$settings = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::get_header_components_settings()
|
||||
$settings = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::get_header_components_settings()
|
||||
: [];
|
||||
$show_on = isset($settings['show_on_pages']) ? (array) $settings['show_on_pages'] : [];
|
||||
$allowed = array_values(array_intersect(
|
||||
@@ -1013,9 +1013,9 @@ if (!function_exists('aksrt_homepage_render_layout')) {
|
||||
$latest_contract = aksrt_homepage_get_latest_panel_contract();
|
||||
$has_sidebar = aksrt_homepage_has_sidebar();
|
||||
$banner_on = $show_tabs && aksrt_homepage_module_banner_enabled();
|
||||
$main_list_enabled = !class_exists('AKSRT_Settings') || AKSRT_Settings::home_posts_list_enabled();
|
||||
$list_title = class_exists('AKSRT_Settings')
|
||||
? AKSRT_Settings::home_list_title()
|
||||
$main_list_enabled = !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::home_posts_list_enabled();
|
||||
$list_title = class_exists('\AKSRT\Settings\Settings')
|
||||
? \AKSRT\Settings\Settings::home_list_title()
|
||||
: __('最新发布', 'aksrt');
|
||||
|
||||
// Fluid zones live outside <main>, once only (removed from header.php).
|
||||
|
||||
Reference in new issue
Block a user