refactor(admin): remove content-type resource/post module option
This commit is contained in:
1 parent
1af0e9b753
commit
fb1a4e110c
6 files changed
+22
-100
No files matched your search
@@ -3,7 +3,7 @@
|
||||
* Home Module · Hotspot 热点推荐
|
||||
*
|
||||
* 纯文章列表(无图片),仅桌面端显示。
|
||||
* config: { count, post_type: 'post'|'resource', source, title? }
|
||||
* config: { count, source, title? }
|
||||
*
|
||||
* source:
|
||||
* 'auto' → 优先读取 aksrt_recommend meta,不足时用最新补充
|
||||
@@ -18,9 +18,6 @@ if (!is_array($cfg)) {
|
||||
}
|
||||
|
||||
$count = max(3, min(20, (int) ($cfg['count'] ?? 6)));
|
||||
$scope = function_exists('aksrt_normalize_content_scope')
|
||||
? aksrt_normalize_content_scope($cfg['post_type'] ?? 'post')
|
||||
: 'post';
|
||||
$source = (string) ($cfg['source'] ?? 'auto');
|
||||
$title = (string) ($cfg['title'] ?? '');
|
||||
|
||||
@@ -28,8 +25,6 @@ if (!in_array($source, ['auto', 'recent', 'views'], true)) {
|
||||
$source = 'auto';
|
||||
}
|
||||
|
||||
$is_resource = $scope === 'resource';
|
||||
|
||||
$args = [
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => $count,
|
||||
@@ -37,15 +32,8 @@ $args = [
|
||||
'no_found_rows' => true,
|
||||
];
|
||||
|
||||
$meta_query = [];
|
||||
if ($is_resource) {
|
||||
$meta_query[] = function_exists('aksrt_resource_meta_query')
|
||||
? aksrt_resource_meta_query()
|
||||
: ['key' => '_aksrt_is_resource', 'value' => '1', 'compare' => '='];
|
||||
}
|
||||
|
||||
if ($source === 'auto') {
|
||||
$meta_query[] = [
|
||||
$args['meta_query'] = [
|
||||
'relation' => 'OR',
|
||||
['key' => 'aksrt_recommend', 'value' => '1', 'compare' => '='],
|
||||
['key' => 'aksrt_recommend', 'compare' => 'NOT EXISTS'],
|
||||
@@ -61,20 +49,13 @@ if ($source === 'auto') {
|
||||
$args['order'] = 'DESC';
|
||||
}
|
||||
|
||||
if (count($meta_query) === 1) {
|
||||
$args['meta_query'] = $meta_query;
|
||||
} elseif (count($meta_query) > 1) {
|
||||
$args['meta_query'] = array_merge(['relation' => 'AND'], $meta_query);
|
||||
}
|
||||
|
||||
$query = new WP_Query($args);
|
||||
if (!$query->have_posts()) {
|
||||
wp_reset_postdata();
|
||||
return;
|
||||
}
|
||||
|
||||
$default_title = __('热点推荐', 'aksrt');
|
||||
$display_title = $title ?: $default_title;
|
||||
$display_title = $title ?: __('热点推荐', 'aksrt');
|
||||
?>
|
||||
|
||||
<section class="home-module home-module--hotspot hotspot--desktop-only" aria-label="<?php echo esc_attr($display_title); ?>">
|
||||
|
||||
Reference in new issue
Block a user