refactor(resource): drop aksrt_resource CPT residue, post+meta only

This commit is contained in:
2026-07-13 23:47:04 +08:00
parent 24c135aeec
commit 1af0e9b753
22 changed files with 362 additions and 986 deletions
+2 -2
View File
@@ -225,8 +225,8 @@ class AKSRT_Home_Modules {
return [
['type' => 'hero', 'config' => []],
['type' => 'tabs', 'config' => ['count' => 8]],
['type' => 'recent', 'config' => ['post_type' => 'aksrt_resource', 'count' => 8, 'layout' => 'grid-cms']],
['type' => 'ranking', 'config' => ['metric' => 'downloads', 'count' => 6, 'post_type' => 'aksrt_resource']],
['type' => 'recent', 'config' => ['post_type' => 'resource', 'count' => 8, 'layout' => 'grid-cms']],
['type' => 'ranking', 'config' => ['metric' => 'downloads', 'count' => 6, 'post_type' => 'resource']],
];
}
}
+1 -1
View File
@@ -95,7 +95,7 @@ class AKSRT_SEO_Head {
if ($post instanceof WP_Post) {
$payload['object'] = $post;
$payload['canonical'] = (string) get_permalink($post);
$payload['og_type'] = in_array($post->post_type, ['post', 'aksrt_resource'], true) ? 'article' : 'website';
$payload['og_type'] = ($post->post_type === 'post') ? 'article' : 'website';
// 单篇 SEO 覆盖:per-post meta → 文章字段 → 站点默认。
$meta = $this->post_seo_meta($post->ID);
+2 -2
View File
@@ -108,8 +108,8 @@ class AKSRT_Setup {
/**
* 注册自定义文章类型
*
* v3.4: 移除 aksrt_resource CPT,资源元数据统一挂在 post 上,
* 通过 _aksrt_is_resource meta 标记单篇文章是否为“资源”。
* 资源不是 CPT:元数据挂在普通 post 上,
* 通过 _aksrt_is_resource meta 标记是否为资源。
*/
public function register_post_types(): void {
// Shop rewrite settings (safe fallback if settings not yet loaded)
@@ -136,11 +136,11 @@ trait AKSRT_Scripts_Part_1b {
// 4b. 路由判定
$is_home_or_archive = is_home() || is_front_page() || is_archive() || is_search();
// 资源单页(post + _aksrt_is_resource,或历史 aksrt_resource CPT)
// 资源单页(post + _aksrt_is_resource)
$is_single_resource = (function_exists('aksrt_is_resource_post') && is_singular() && aksrt_is_resource_post(get_queried_object_id()));
// 普通博客 single(排除资源型 post)
$is_single_post = is_singular('post') && !$is_single_resource;
// 资源虚拟归档 /resources(含历史 CPT 归档)
// 资源虚拟列表 /resources/
$is_resource_archive = function_exists('aksrt_is_resource_archive') && aksrt_is_resource_archive();
// /user/{nicename}/ 自定义重写路由(class-aksrt-user.php 注册)
// 此路径下 is_page() / is_page_template() 均为 false,需手动识别以正确入队 CSS
@@ -29,13 +29,7 @@ if (!function_exists('aksrt_home_widget_post_types')) {
* @return array<int, string>
*/
function aksrt_home_widget_post_types(): array {
$post_types = ['post'];
if (function_exists('aksrt_resource_post_types')) {
$post_types = array_unique(array_merge($post_types, aksrt_resource_post_types()));
}
return array_values(array_filter(array_map('sanitize_key', $post_types)));
return ['post'];
}
}