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

@@ -2,7 +2,8 @@
/**
* Home Module · Ranking
*
* config: { metric: 'views|downloads|comments', count, post_type: 'post'|'resource', title? }
* config: { metric: 'views|downloads|comments', count, title? }
* Lists ordinary posts only (no content-type split).
*/
defined('ABSPATH') || exit;
@@ -13,30 +14,18 @@ if (!is_array($cfg)) {
$metric = (string) ($cfg['metric'] ?? 'downloads');
$count = max(1, min(20, (int) ($cfg['count'] ?? 6)));
$scope = function_exists('aksrt_normalize_content_scope')
? aksrt_normalize_content_scope($cfg['post_type'] ?? 'resource')
: 'resource';
$title = (string) ($cfg['title'] ?? '');
if (!in_array($metric, ['views', 'downloads', 'comments'], true)) {
$metric = 'downloads';
}
$is_resource_module = $scope === 'resource';
$args = [
'post_type' => 'post',
'posts_per_page' => $count,
'post_status' => 'publish',
'no_found_rows' => true,
];
if ($is_resource_module) {
$args['meta_query'] = [
function_exists('aksrt_resource_meta_query')
? aksrt_resource_meta_query()
: ['key' => '_aksrt_is_resource', 'value' => '1', 'compare' => '='],
];
}
switch ($metric) {
case 'views':