refactor(admin): remove content-type resource/post module option

This commit is contained in:
kate522 committed 2026-07-13 23:59:32 +08:00
1 parent 1af0e9b753
commit fb1a4e110c
6 files changed
+22 -100

No files matched your search

+4 -18
View File
@@ -2,7 +2,8 @@
/**
* Home Module · Recent
*
* config: { post_type: 'post'|'resource', count, layout, title? }
* config: { count, layout, title? }
* Lists ordinary posts only (no content-type split).
*/
defined('ABSPATH') || exit;
@@ -11,9 +12,6 @@ if (!is_array($cfg)) {
$cfg = [];
}
$scope = function_exists('aksrt_normalize_content_scope')
? aksrt_normalize_content_scope($cfg['post_type'] ?? 'post')
: ((string) ($cfg['post_type'] ?? 'post') === 'resource' ? 'resource' : 'post');
$count = max(1, min(20, (int) ($cfg['count'] ?? 6)));
$layout = (string) ($cfg['layout'] ?? 'card');
$title = (string) ($cfg['title'] ?? '');
@@ -22,8 +20,6 @@ if (!in_array($layout, ['card', 'list', 'masonry', 'grid-cms'], true)) {
$layout = 'card';
}
$is_resource_module = $scope === 'resource';
$args = [
'post_type' => 'post',
'posts_per_page' => $count,
@@ -32,13 +28,6 @@ $args = [
'orderby' => 'date',
'order' => 'DESC',
];
if ($is_resource_module) {
$args['meta_query'] = [
function_exists('aksrt_resource_meta_query')
? aksrt_resource_meta_query()
: ['key' => '_aksrt_is_resource', 'value' => '1', 'compare' => '='],
];
}
$query = new WP_Query($args);
if (!$query->have_posts()) {
@@ -46,11 +35,8 @@ if (!$query->have_posts()) {
return;
}
$default_title = $is_resource_module ? __('最新资源', 'aksrt') : __('最新文章', 'aksrt');
$display_title = $title ?: $default_title;
$archive_link = $is_resource_module
? (function_exists('aksrt_resource_archive_url') ? aksrt_resource_archive_url() : home_url('/resources/'))
: get_permalink(get_option('page_for_posts'));
$display_title = $title ?: __('最新文章', 'aksrt');
$archive_link = get_permalink(get_option('page_for_posts'));
?>
<section class="home-module home-module--recent container" aria-label="<?php echo esc_attr($display_title); ?>">