153 lines
4.9 KiB
PHP
153 lines
4.9 KiB
PHP
<?php
|
|
/**
|
|
* AKSRT settings category integration and customizer groups.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
trait AKSRT_Settings_Category_Integration_Groups {
|
|
|
|
/**
|
|
* 获取分类推荐配置(含默认值)
|
|
* @return array
|
|
*/
|
|
public static function get_category_recommend_settings(): array {
|
|
return AKSRT_Settings_Category_Runtime::get_category_recommend_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取分类封面图 URL(带优先级回退)
|
|
*
|
|
* 优先级:
|
|
* 1. aksrt_category_cover_id term meta
|
|
* 2. 该分类最新一篇有缩略图文章的缩略图
|
|
* 3. 默认占位图
|
|
*/
|
|
public static function get_category_cover_url(int $term_id): string {
|
|
return AKSRT_Settings_Category_Runtime::get_category_cover_url($term_id);
|
|
}
|
|
|
|
/**
|
|
* 获取分类推荐描述(带优先级回退)
|
|
*
|
|
* 优先级:
|
|
* 1. aksrt_category_recommend_desc term meta
|
|
* 2. 原生 category description
|
|
* 3. 空字符串
|
|
*/
|
|
public static function get_category_recommend_desc(int $term_id): string {
|
|
return AKSRT_Settings_Category_Runtime::get_category_recommend_desc($term_id);
|
|
}
|
|
|
|
/**
|
|
* 清理分类推荐缓存
|
|
*/
|
|
public static function flush_category_recommend_cache(): void {
|
|
AKSRT_Settings_Category_Runtime::flush_category_recommend_cache();
|
|
}
|
|
|
|
/**
|
|
* 获取分类推荐渲染数据(带缓存)
|
|
*
|
|
* @param array $settings 分类推荐配置
|
|
* @return array 每项包含 term_id, name, description, count, link, cover, posts
|
|
*/
|
|
public static function get_category_recommend_items(array $settings): array {
|
|
return AKSRT_Settings_Category_Runtime::get_category_recommend_items($settings);
|
|
}
|
|
|
|
/**
|
|
* 获取底部Tab完整配置
|
|
* @return array {enabled, scroll_hide, scroll_down_hide, items}
|
|
*/
|
|
public static function get_footer_tabbar_settings(): array {
|
|
return AKSRT_Settings_Integration::get_footer_tabbar_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取底部Tab项(仅返回启用的,按排序)
|
|
* @return array
|
|
*/
|
|
public static function get_footer_tabbar_items(): array {
|
|
return AKSRT_Settings_Integration::get_footer_tabbar_items();
|
|
}
|
|
|
|
/**
|
|
* 获取文章页专属Tab模式
|
|
* @return string 'default' | 'extend'
|
|
*/
|
|
public static function get_footer_tabbar_single(): string {
|
|
return AKSRT_Settings_Integration::get_footer_tabbar_single();
|
|
}
|
|
|
|
/**
|
|
* 获取通知系统设置
|
|
* @return array {read_retention_days, unread_retention_days, max_per_user}
|
|
*/
|
|
public static function get_notification_settings(): array {
|
|
return AKSRT_Settings_Integration::get_notification_settings();
|
|
}
|
|
|
|
/** 单项通知是否启用 */
|
|
public static function notification_enabled(string $type): bool {
|
|
return AKSRT_Settings_Integration::notification_enabled($type);
|
|
}
|
|
|
|
/** user 徽标是否启用 */
|
|
public static function notification_user_badge_enabled(): bool {
|
|
return AKSRT_Settings_Integration::notification_user_badge_enabled();
|
|
}
|
|
|
|
/** user 徽标是否包含即时提醒 */
|
|
public static function notification_badge_include_stateful(): bool {
|
|
return AKSRT_Settings_Integration::notification_badge_include_stateful();
|
|
}
|
|
|
|
/**
|
|
* 获取右侧浮动按钮完整配置
|
|
* @return array {enabled, style, position, scroll_hide, scroll_down_hide, filter_blur, items}
|
|
*/
|
|
public static function get_floating_buttons_settings(): array {
|
|
return AKSRT_Settings_Integration::get_floating_buttons_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取右侧浮动按钮项(仅返回启用的,按排序)
|
|
* @return array
|
|
*/
|
|
public static function get_floating_buttons_items(): array {
|
|
return AKSRT_Settings_Integration::get_floating_buttons_items();
|
|
}
|
|
|
|
/**
|
|
* Customizer 注册(可选)
|
|
*/
|
|
public function customizer(WP_Customize_Manager $wp_customize): void {
|
|
$wp_customize->add_setting('blogname', ['default' => get_bloginfo('name'), 'type' => 'option']);
|
|
|
|
$wp_customize->add_setting('aksrt_logo', [
|
|
'default' => '',
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
'transport' => 'postMessage',
|
|
]);
|
|
$wp_customize->add_control(new WP_Customize_Image_Control(
|
|
$wp_customize,
|
|
'aksrt_logo',
|
|
['label' => __('Logo', 'aksrt'), 'section' => 'title_tagline']
|
|
));
|
|
|
|
$wp_customize->add_setting('aksrt_favicon', [
|
|
'default' => '',
|
|
'sanitize_callback' => 'esc_url_raw',
|
|
'transport' => 'postMessage',
|
|
]);
|
|
$wp_customize->add_control(new WP_Customize_Upload_Control(
|
|
$wp_customize,
|
|
'aksrt_favicon',
|
|
['label' => __('Favicon', 'aksrt'), 'section' => 'title_tagline']
|
|
));
|
|
}
|
|
}
|