与参考主题(zibll)1:1 对齐百度推送,并清掉存量双路与死代码: - 新增普通/快速收录通道开关,快速收录走 &type=daily;自动推送 JS 与参考实现一致 - 分类法 saved_term 推送(可推送类型推导公开分类法,排除 post_format,aksrt_baidu_push_taxonomies 可过滤) - 推送结果写入 meta 去重,成功后不重复提交;编辑页 Metabox 展示结果并提供「重新提交」(nonce 校验后强制推送) - 配置面收敛到扩展页单一 canonical 键:删除 SEO 页 seo_baidu_* 重复面与两处合并逻辑,不写迁移兜底 - 清理死代码:push_batch(零调用)及 batch_size、从不写入的 baidu_push_verified、零消费的熊掌号 xzh_* 七键;baidu_push_log_enabled 接入 log() 新增 PHP harness 驱动真实逻辑(通道/去重/重试/重新提交/术语/面板渲染)+ 参考主题契约测试;tests/admin 与 tests/widget-system 全量通过。
302 lines
14 KiB
PHP
302 lines
14 KiB
PHP
<?php
|
|
/**
|
|
* @package AKSRT
|
|
*/
|
|
|
|
namespace AKSRT\Settings;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
trait DisplayPageGroups {
|
|
|
|
/**
|
|
* 获取 SEO 设置(从 aksrt_settings 读取)
|
|
*/
|
|
public static function get_seo_settings(): array {
|
|
$s = self::get_all();
|
|
return [
|
|
'seo_enabled' => !isset($s['seo_enabled']) || !empty($s['seo_enabled']),
|
|
'seo_connector' => trim((string) ($s['seo_connector'] ?? '-')),
|
|
'seo_title' => $s['seo_title'] ?? '',
|
|
'seo_description' => $s['seo_description'] ?? '',
|
|
'seo_keywords' => self::seo_keywords(),
|
|
'seo_ai_enabled' => !empty($s['seo_ai_enabled']),
|
|
'ai_seo_title_prompt' => trim((string) ($s['ai_seo_title_prompt'] ?? '')),
|
|
'ai_seo_keywords_prompt' => trim((string) ($s['ai_seo_keywords_prompt'] ?? '')),
|
|
'ai_seo_description_prompt' => trim((string) ($s['ai_seo_description_prompt'] ?? '')),
|
|
'seo_image_optimize' => !isset($s['seo_image_optimize']) || !empty($s['seo_image_optimize']),
|
|
'seo_image_default' => esc_url_raw((string) ($s['seo_image_default'] ?? '')),
|
|
'seo_image_always_default'=> !empty($s['seo_image_always_default']),
|
|
'seo_auto_alt' => !isset($s['seo_auto_alt']) || !empty($s['seo_auto_alt']),
|
|
'seo_go_link' => !isset($s['seo_go_link']) || !empty($s['seo_go_link']),
|
|
'seo_go_link_nonce' => !isset($s['seo_go_link_nonce']) || !empty($s['seo_go_link_nonce']),
|
|
'seo_go_link_post' => !isset($s['seo_go_link_post']) || !empty($s['seo_go_link_post']),
|
|
'seo_go_link_exclude' => trim((string) ($s['seo_go_link_exclude'] ?? '')),
|
|
'seo_no_category' => !empty($s['seo_no_category']),
|
|
'seo_jsonld' => !isset($s['seo_jsonld']) || !empty($s['seo_jsonld']),
|
|
'seo_jsonld_single' => !isset($s['seo_jsonld_single']) || !empty($s['seo_jsonld_single']),
|
|
'seo_jsonld_page' => !isset($s['seo_jsonld_page']) || !empty($s['seo_jsonld_page']),
|
|
'head_code' => self::custom_head_code(),
|
|
'foot_code' => self::custom_footer_code(),
|
|
'trackcode' => self::trackcode(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取顶部多功能组件设置
|
|
*/
|
|
public static function get_header_slider_settings(): array {
|
|
$s = self::read_domain('page_display', 'header-components');
|
|
$allowed_page_types = [
|
|
'home',
|
|
'category',
|
|
'tag',
|
|
'author',
|
|
'user_center',
|
|
'single',
|
|
'search',
|
|
'page',
|
|
];
|
|
$show_on = isset($s['header_slider_show']) ? (array) $s['header_slider_show'] : [];
|
|
$show_on = array_map(static function ($type): string {
|
|
$type = sanitize_key((string) $type);
|
|
return $type === 'user_home' ? 'author' : $type;
|
|
}, $show_on);
|
|
$show_on = array_values(array_intersect(
|
|
$show_on,
|
|
$allowed_page_types
|
|
));
|
|
$show_type = $s['header_slider_show_type'] ?? '';
|
|
if (!in_array($show_type, ['', 'only_pc', 'only_sm'], true)) {
|
|
$show_type = '';
|
|
}
|
|
$slider_option = is_array($s['header_slider_option'] ?? null) ? $s['header_slider_option'] : self::header_slider_option_defaults();
|
|
$search_option = is_array($s['header_slider_search_option'] ?? null) ? $s['header_slider_search_option'] : self::header_slider_search_defaults();
|
|
$card_option = is_array($s['header_slider_card_option'] ?? null) ? $s['header_slider_card_option'] : self::header_slider_card_defaults();
|
|
return [
|
|
'slides' => is_array($s['header_slider'] ?? null) ? $s['header_slider'] : self::header_slider_default_slides(),
|
|
'show_on_pages' => $show_on,
|
|
'show_type' => $show_type,
|
|
'nav_color' => sanitize_hex_color((string) ($s['header_slider_nav_color'] ?? '')) ?: '',
|
|
'slider_config' => $slider_option,
|
|
'search_show' => self::sanitize_device_visibility($s['header_slider_search_s'] ?? ['pc_s', 'm_s']),
|
|
'search_config' => $search_option,
|
|
'card_show' => self::sanitize_device_visibility($s['header_slider_card_s'] ?? ['pc_s', 'm_s']),
|
|
'card_config' => $card_option,
|
|
'filter_blur' => self::sanitize_device_visibility($s['header_slider_filter_blur'] ?? ['pc_s', 'm_s']),
|
|
];
|
|
}
|
|
|
|
/** @return list<array<string,mixed>> */
|
|
private static function header_slider_default_slides(): array {
|
|
$base = defined('AKSRT_URI') ? trailingslashit(AKSRT_URI) . 'assets/img/' : '';
|
|
$slides = [];
|
|
foreach (['slider-bg.jpg', 'user_t.jpg'] as $image) {
|
|
$slides[] = [
|
|
'background' => $base . $image,
|
|
'link' => ['url' => 'https://www.legacy.com/', 'target' => '_blank'],
|
|
'text' => ['desc' => '', 'title' => ''],
|
|
'text_align' => 'left-bottom',
|
|
'text_parallax' => 30,
|
|
'text_size_m' => 20,
|
|
'text_size_pc' => 30,
|
|
];
|
|
}
|
|
return $slides;
|
|
}
|
|
|
|
/** @return array<string,mixed> */
|
|
private static function header_slider_option_defaults(): array {
|
|
return [
|
|
'direction' => 'horizontal', 'loop' => true, 'button' => true,
|
|
'pagination' => true, 'effect' => 'slide', 'scale_height' => false,
|
|
'auto_height' => false, 'pc_height' => 550, 'm_height' => 280,
|
|
'spacebetween' => 0, 'speed' => 0, 'autoplay' => true, 'interval' => 6,
|
|
];
|
|
}
|
|
|
|
/** @return array<string,mixed> */
|
|
private static function header_slider_search_defaults(): array {
|
|
return [
|
|
'show_keywords' => true, 'popular_limit' => 6, 'show_input_cat' => false,
|
|
'in_cat' => '', 'more_cats' => [], 'show_type' => false, 'in_type' => 'post',
|
|
'before_html' => '<div class="em16 font-bold mb10">更优雅的Wordpress主题</div><div>这是导航栏幻灯片多功能组件,可在后台进行配置</div>',
|
|
'after_html' => '',
|
|
];
|
|
}
|
|
|
|
/** @return array<string,mixed> */
|
|
private static function header_slider_card_defaults(): array {
|
|
return [
|
|
'icon_radius4' => false,
|
|
'cards' => [
|
|
['icon' => 'fa fas fa-gem', 'customize_icon' => '', 'icon_class' => 'c-yellow', 'link' => [], 'title' => '图标卡片', 'desc' => '这是一个图标卡片示例'],
|
|
['icon' => 'fa fas fa-star', 'customize_icon' => '', 'icon_class' => 'c-blue-2', 'link' => [], 'title' => '原创作品', 'desc' => '这是一个图标卡片示例'],
|
|
['icon' => 'fa fas fa-fire', 'customize_icon' => '', 'icon_class' => 'jb-pink', 'link' => [], 'title' => '灵感来源<badge class="ml6 jb-yellow">NEW</badge>', 'desc' => '这是一个图标卡片示例'],
|
|
['icon' => 'fa fas fa-wrench', 'customize_icon' => '', 'icon_class' => 'jb-cyan', 'link' => [], 'title' => '系统工具 <badge class="ml6 jb-blue">GO <span class="fa fas fa-angle-right em12"></span></badge>', 'desc' => '这是一个图标卡片示例'],
|
|
],
|
|
];
|
|
}
|
|
|
|
/** @return list<string> */
|
|
private static function sanitize_device_visibility($value): array {
|
|
return array_values(array_intersect(array_map('sanitize_key', (array) $value), ['pc_s', 'm_s']));
|
|
}
|
|
|
|
/**
|
|
* 获取"全局&功能"域的合并设置
|
|
*/
|
|
public static function get_global_settings(): array {
|
|
$s = self::get_all();
|
|
return [
|
|
'site_logo' => self::logo_url(),
|
|
'site_logo_dark' => self::logo_dark_url(),
|
|
'logo_text' => self::logo_text(),
|
|
'logo_width' => self::logo_width(),
|
|
'site_favicon' => self::favicon_url(),
|
|
'icp_filing' => self::icp_filing(),
|
|
'footer_text' => self::footer_text(),
|
|
'theme_mode' => self::theme_mode(),
|
|
'theme_mode_button' => self::get_theme_mode_button_positions(),
|
|
'primary_color' => self::primary_color(),
|
|
'border_radius' => self::border_radius(),
|
|
'theme_main_radius' => self::card_radius(),
|
|
'qj_loading' => self::is_qj_loading_enabled(),
|
|
'qj_dh_xs' => self::get_qj_loading_style(),
|
|
'container_max_width' => self::container_max_width(),
|
|
'font_family' => self::font_family(),
|
|
'search_type' => !isset($s['search_type']) || !empty($s['search_type']),
|
|
'search_type_in' => sanitize_key((string) ($s['search_type_in'] ?? 'post')),
|
|
'search_placeholder' => self::search_placeholder(),
|
|
'search_history' => self::search_history_enabled(),
|
|
'search_popular_key' => self::hot_search_enabled(),
|
|
'search_popular_title' => self::search_popular_title(),
|
|
'search_popular_sticky' => self::search_popular_sticky(),
|
|
'search_popular_key_num' => max(10, min(50, (int) ($s['search_popular_key_num'] ?? 20))),
|
|
'search_posts' => self::search_posts_enabled(),
|
|
'search_no_page' => self::search_no_page(),
|
|
'search_exclude_cats' => self::search_exclude_cats(),
|
|
'search_cat' => self::search_cat_enabled(),
|
|
'search_cat_in' => self::search_cat_in(),
|
|
'search_more_cat_obj' => self::search_more_cat_obj(),
|
|
'search_custom_key_s' => self::search_custom_key_enabled(),
|
|
'search_custom_key' => self::search_custom_key(),
|
|
'search_facets' => self::search_facets_enabled(),
|
|
'search_facets_order' => self::search_facets_order(),
|
|
'custom_css' => self::custom_css(),
|
|
'head_code' => self::custom_head_code(),
|
|
'foot_code' => self::custom_footer_code(),
|
|
'trackcode' => self::trackcode(),
|
|
'seo' => self::get_seo_settings(),
|
|
'mail' => self::get_smtp(),
|
|
'footer' => self::get_footer_settings(),
|
|
'tabbar' => self::get_footer_tabbar_settings(),
|
|
'floating_buttons' => self::get_floating_buttons_settings(),
|
|
'header_theme' => self::get_header_theme_config(),
|
|
'friend_links' => self::get_friend_links(),
|
|
'cms_features' => self::get_cms_features(),
|
|
'page_display' => self::get_page_display_settings(),
|
|
'footer_theme' => self::get_footer_theme_config(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取"页面&显示"域的合并设置
|
|
*/
|
|
public static function get_page_display_settings(): array {
|
|
return [
|
|
'header_slider' => self::get_header_slider_settings(),
|
|
'homepage' => self::get_homepage_fixed_settings(),
|
|
'category_recommend' => self::get_category_recommend_settings(),
|
|
'category' => self::get_category_page_settings(),
|
|
'tag' => self::get_tag_page_settings(),
|
|
'user_home' => self::get_user_home_settings(),
|
|
'other' => self::get_other_page_settings(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取"文章&列表"域的合并设置
|
|
*/
|
|
public static function get_post_list_settings(): array {
|
|
$list = self::get_post_list_style_settings();
|
|
$thumb = self::get_post_thumb_settings();
|
|
$filter = self::get_post_filter_settings();
|
|
|
|
return [
|
|
'list' => $list,
|
|
'thumb' => $thumb,
|
|
'filter' => [
|
|
'custom_filter_show' => $filter['custom_filter_show'],
|
|
'custom_filter' => $filter['custom_filter'],
|
|
'cat_custom_filter' => $filter['cat_custom_filter'],
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取"用户&互动"域的合并设置
|
|
*/
|
|
public static function get_user_interaction_settings(): array {
|
|
return [
|
|
'oauth' => self::get_oauth(),
|
|
'notifications' => self::get_notification_settings(),
|
|
'credits' => self::get_credit_settings(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取"功能&权限"域的合并设置
|
|
*/
|
|
public static function get_permission_settings(): array {
|
|
return [
|
|
'moderation' => self::get_moderation(),
|
|
'capabilities' => self::get_user_capabilities(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取"支付&付费"域的合并设置
|
|
*/
|
|
public static function get_payment_settings(): array {
|
|
return [
|
|
'paid' => self::get_paid_content_settings(),
|
|
'recharge' => self::get_payment_recharge_settings(),
|
|
'vip' => self::get_payment_vip_settings(),
|
|
'revenue' => self::get_payment_revenue_settings(),
|
|
'affiliate' => self::get_payment_affiliate_settings(),
|
|
'gateway' => self::get_payment_gateway_settings(),
|
|
'order' => self::get_order_settings(),
|
|
'withdrawal' => self::get_withdrawal_settings(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 获取 IP 归属地设置
|
|
*/
|
|
public static function get_ip_geo_settings(): array {
|
|
return ExtensionRuntime::get_ip_geo_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取内容审核设置
|
|
*/
|
|
public static function get_content_audit_settings(): array {
|
|
return ExtensionRuntime::get_content_audit_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取搜索引擎推送设置
|
|
*/
|
|
public static function get_search_push_settings(): array {
|
|
return ExtensionRuntime::get_search_push_settings();
|
|
}
|
|
|
|
/**
|
|
* 获取短信接口设置
|
|
*/
|
|
public static function get_sms_settings(): array {
|
|
return ExtensionRuntime::get_sms_settings();
|
|
}
|
|
}
|