94 lines
2.5 KiB
PHP
94 lines
2.5 KiB
PHP
<?php
|
||
/**
|
||
* AKSRT Flow Helper
|
||
*
|
||
* v4 起主题统一为 CMS / 资源站形态,不再提供 blog 形态分流。
|
||
* 历史 helper 全部保留签名以保证兼容,但实际行为已收敛:
|
||
*
|
||
* aksrt_get_site_profile() 始终返回 'cms'
|
||
* aksrt_get_term_flow() 始终返回 'inherit'(不再读取 term meta)
|
||
* aksrt_is_resource_post() 仍按 _aksrt_is_resource meta 判定
|
||
* aksrt_get_post_flow() 始终返回 'cms'
|
||
* aksrt_is_cms_mode() 始终返回 true
|
||
* aksrt_flow_layout_for() 始终返回 'grid-cms'
|
||
*
|
||
* @package AKSRT
|
||
*/
|
||
|
||
defined('ABSPATH') || exit;
|
||
|
||
if (!function_exists('aksrt_get_site_profile')) {
|
||
/**
|
||
* @deprecated v4 起恒为 'cms',保留仅为向后兼容。
|
||
* @return string 'cms'
|
||
*/
|
||
function aksrt_get_site_profile(): string {
|
||
return 'cms';
|
||
}
|
||
}
|
||
|
||
if (!function_exists('aksrt_get_term_flow')) {
|
||
/**
|
||
* @deprecated v4 起恒为 'inherit',term meta 不再生效。
|
||
* @param int $term_id
|
||
* @return string
|
||
*/
|
||
function aksrt_get_term_flow(int $term_id): string {
|
||
unset($term_id);
|
||
return 'inherit';
|
||
}
|
||
}
|
||
|
||
if (!function_exists('aksrt_is_resource_post')) {
|
||
/**
|
||
* 是否为资源(post + _aksrt_is_resource meta,或历史 aksrt_resource CPT)。
|
||
*
|
||
* @param int|WP_Post|null $post
|
||
* @return bool
|
||
*/
|
||
function aksrt_is_resource_post($post = null): bool {
|
||
$p = get_post($post);
|
||
if (!($p instanceof WP_Post)) return false;
|
||
if ($p->post_type === 'aksrt_resource') return true;
|
||
if ($p->post_type !== 'post') return false;
|
||
return (bool) get_post_meta($p->ID, '_aksrt_is_resource', true);
|
||
}
|
||
}
|
||
|
||
if (!function_exists('aksrt_get_post_flow')) {
|
||
/**
|
||
* @deprecated v4 起恒为 'cms'。
|
||
*
|
||
* @param int|WP_Post|null $post
|
||
* @return string 'cms'
|
||
*/
|
||
function aksrt_get_post_flow($post = null): string {
|
||
unset($post);
|
||
return 'cms';
|
||
}
|
||
}
|
||
|
||
if (!function_exists('aksrt_is_cms_mode')) {
|
||
/**
|
||
* 当前请求是否处在 CMS 形态。v4 起全站统一 CMS。
|
||
*
|
||
* @return bool
|
||
*/
|
||
function aksrt_is_cms_mode(): bool {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
if (!function_exists('aksrt_flow_layout_for')) {
|
||
/**
|
||
* @deprecated v4 起恒为 'grid-cms'。
|
||
*
|
||
* @param string $flow
|
||
* @return string
|
||
*/
|
||
function aksrt_flow_layout_for(string $flow): string {
|
||
unset($flow);
|
||
return 'grid-cms';
|
||
}
|
||
}
|