feat(admin): rebuild page display settings
This commit is contained in:
+32
-151
@@ -13,34 +13,13 @@ defined('ABSPATH') || exit;
|
||||
// 数据准备
|
||||
$blog_name = function_exists('aksrt_get_site_logo_text') ? aksrt_get_site_logo_text() : get_bloginfo('name');
|
||||
$has_settings = class_exists('\AKSRT\Settings\Settings');
|
||||
$search_placeholder = function_exists('aksrt_get_search_placeholder') ? aksrt_get_search_placeholder() : __('开启精彩搜索', 'aksrt');
|
||||
$search_hot_keywords = function_exists('aksrt_get_search_hot_keywords') ? aksrt_get_search_hot_keywords() : [];
|
||||
|
||||
// 联系图标 / 社交链接(legacy contacts list — fallback for more icons)
|
||||
$footer_contacts = $has_settings ? \AKSRT\Settings\Settings::get_footer_contacts() : [];
|
||||
if (empty($footer_contacts) && function_exists('aksrt_get_about_info')) {
|
||||
$about = aksrt_get_about_info();
|
||||
$footer_contacts = $about['contacts'] ?? [];
|
||||
}
|
||||
|
||||
// 友情链接 / 快速链接(仅当 fcode_t2_code_1 为空时回退)
|
||||
$friend_links = function_exists('aksrt_get_friend_links') ? aksrt_get_friend_links() : [];
|
||||
$quick_links = $has_settings ? \AKSRT\Settings\Settings::get_quick_links() : [];
|
||||
$more_links = $has_settings ? \AKSRT\Settings\Settings::get_more_links() : [];
|
||||
$hot_cat_count = $has_settings ? \AKSRT\Settings\Settings::get_hot_categories_count() : 0;
|
||||
|
||||
// 备案 / 版权(customize 为空时回退)
|
||||
$filing = $has_settings ? \AKSRT\Settings\Settings::get_filing_settings() : ['icp_enabled' => true, 'icp_filing' => '', 'police_enabled' => true, 'police_filing' => ''];
|
||||
$icp_filing = !empty($filing['icp_enabled']) ? (string) ($filing['icp_filing'] ?? '') : '';
|
||||
$police_filing = !empty($filing['police_enabled']) ? (string) ($filing['police_filing'] ?? '') : '';
|
||||
$footer_text = $has_settings ? \AKSRT\Settings\Settings::footer_text() : '';
|
||||
$copyright_text = $has_settings ? \AKSRT\Settings\Settings::get_copyright_text() : '';
|
||||
|
||||
// §2.3 三列结构化字段(Zibll keys)
|
||||
$footer_brand = $has_settings ? \AKSRT\Settings\Settings::get_footer_brand_settings() : ['m_s' => ['pc', 'mobile'], 'img' => '', 'img_dark' => '', 'title' => '', 'custom_code' => ''];
|
||||
$footer_contact_ext = $has_settings ? \AKSRT\Settings\Settings::get_footer_contact_extended_settings() : ['m_s' => ['pc', 'mobile'], 'wechat_img' => '', 'qq' => '', 'weibo' => '', 'email' => '', 'more' => [], 'code_1' => '', 'code_2' => ''];
|
||||
$footer_mini = $has_settings ? \AKSRT\Settings\Settings::get_footer_mini_img_settings() : ['m_s' => ['pc', 'mobile'], 'items' => []];
|
||||
$footer_mini = $has_settings ? \AKSRT\Settings\Settings::get_footer_mini_img_settings() : ['m_s' => ['pc', 'mobile'], 'items' => [], 'items_2' => []];
|
||||
$footer_customize_code = $has_settings ? \AKSRT\Settings\Settings::get_footer_customize_code() : '';
|
||||
$footer_template = $has_settings ? \AKSRT\Settings\Settings::get_footer_template() : 'template_1';
|
||||
|
||||
// 设备可见性 → Zibll hidden-xs(仅在不含 mobile 时隐藏移动端)
|
||||
$_brand_show_sm = in_array('mobile', (array) ($footer_brand['m_s'] ?? []), true);
|
||||
@@ -50,67 +29,6 @@ $_brand_xs_cls = $_brand_show_sm ? '' : ' hidden-xs';
|
||||
$_contact_xs_cls = $_contact_show_sm ? '' : ' hidden-xs';
|
||||
$_mini_xs_cls = $_mini_show_sm ? '' : ' hidden-xs';
|
||||
|
||||
/**
|
||||
* 渲染快速链接 URL:支持外链 / 站内相对路径
|
||||
*/
|
||||
$render_link_url = static function ($raw) {
|
||||
if (empty($raw)) {
|
||||
return '#';
|
||||
}
|
||||
if (strpos((string) $raw, 'http') === 0) {
|
||||
return esc_url($raw);
|
||||
}
|
||||
return esc_url(home_url($raw));
|
||||
};
|
||||
|
||||
/**
|
||||
* 构建 fcode-links 回退 HTML(structured links)
|
||||
*/
|
||||
$build_fallback_links_html = static function () use ($quick_links, $more_links, $friend_links, $hot_cat_count, $render_link_url) {
|
||||
$link_bits = [];
|
||||
foreach ((array) $quick_links as $ql) {
|
||||
$label = $ql['name'] ?? $ql['label'] ?? '';
|
||||
$url = $render_link_url($ql['url'] ?? '');
|
||||
if ($label !== '') {
|
||||
$link_bits[] = '<a href="' . esc_url($url) . '">' . esc_html($label) . '</a>';
|
||||
}
|
||||
}
|
||||
foreach ((array) $more_links as $ml) {
|
||||
$label = $ml['name'] ?? $ml['label'] ?? '';
|
||||
$url = $render_link_url($ml['url'] ?? '');
|
||||
if ($label !== '') {
|
||||
$link_bits[] = '<a href="' . esc_url($url) . '">' . esc_html($label) . '</a>';
|
||||
}
|
||||
}
|
||||
foreach ((array) $friend_links as $fl) {
|
||||
$label = $fl['name'] ?? '';
|
||||
$url = $fl['url'] ?? '#';
|
||||
if ($label !== '') {
|
||||
$link_bits[] = '<a href="' . esc_url($url) . '" target="_blank" rel="noopener noreferrer nofollow">' . esc_html($label) . '</a>';
|
||||
}
|
||||
}
|
||||
if ($hot_cat_count > 0) {
|
||||
$_hot_cache_key = 'aksrt_footer_hot_cats_' . (int) $hot_cat_count;
|
||||
$_hot_cats = wp_cache_get($_hot_cache_key, 'aksrt');
|
||||
if (!is_array($_hot_cats)) {
|
||||
$_hot_cats = get_categories([
|
||||
'orderby' => 'count',
|
||||
'order' => 'DESC',
|
||||
'number' => $hot_cat_count,
|
||||
'hide_empty' => true,
|
||||
]);
|
||||
if (!is_array($_hot_cats)) {
|
||||
$_hot_cats = [];
|
||||
}
|
||||
wp_cache_set($_hot_cache_key, $_hot_cats, 'aksrt', 12 * HOUR_IN_SECONDS);
|
||||
}
|
||||
foreach ($_hot_cats as $hc) {
|
||||
$link_bits[] = '<a href="' . esc_url(get_category_link($hc->term_id)) . '">' . esc_html($hc->name) . '</a>';
|
||||
}
|
||||
}
|
||||
return implode(' ', $link_bits);
|
||||
};
|
||||
|
||||
// 品牌 / 联系 / 二维码列内容存在性
|
||||
$_logo_html = '';
|
||||
if (function_exists('aksrt_get_adaptive_theme_img')) {
|
||||
@@ -124,45 +42,17 @@ if (function_exists('aksrt_get_adaptive_theme_img')) {
|
||||
$_has_brand = $_logo_html !== '' || !empty($footer_brand['title']) || !empty($footer_brand['custom_code']);
|
||||
|
||||
$_fcode_links = trim((string) ($footer_contact_ext['code_1'] ?? ''));
|
||||
if ($_fcode_links === '') {
|
||||
$_fcode_links = $build_fallback_links_html();
|
||||
}
|
||||
$_fcode_links_is_raw = trim((string) ($footer_contact_ext['code_1'] ?? '')) !== '';
|
||||
|
||||
$_has_contact_icons = !empty($footer_contacts)
|
||||
|| !empty($footer_contact_ext['wechat_img'])
|
||||
$_has_contact_icons = !empty($footer_contact_ext['wechat_img'])
|
||||
|| !empty($footer_contact_ext['qq'])
|
||||
|| !empty($footer_contact_ext['email'])
|
||||
|| !empty($footer_contact_ext['more'])
|
||||
|| !empty($footer_contact_ext['weibo']);
|
||||
$_has_links_col = $_fcode_links !== '' || !empty($footer_contact_ext['code_2']) || $_has_contact_icons;
|
||||
$_has_mini = !empty($footer_mini['items']);
|
||||
$_has_mini = !empty($footer_mini['items']) || !empty($footer_mini['items_2']);
|
||||
$_has_cols = $_has_brand || $_has_links_col || $_has_mini;
|
||||
|
||||
// 底栏:customize 优先;否则回退版权/备案
|
||||
$_footer_conter = trim((string) $footer_customize_code);
|
||||
if ($_footer_conter === '') {
|
||||
$footer_bits = [];
|
||||
if ($icp_filing !== '') {
|
||||
$footer_bits[] = '<a href="https://beian.miit.gov.cn/" target="_blank" rel="noopener noreferrer nofollow">' . esc_html($icp_filing) . '</a>';
|
||||
}
|
||||
if ($police_filing !== '') {
|
||||
$footer_bits[] = '<a href="https://beian.mps.gov.cn/" target="_blank" rel="noopener noreferrer nofollow">' . esc_html($police_filing) . '</a>';
|
||||
}
|
||||
$copy = '© ' . esc_html(gmdate('Y')) . ' ' . esc_html($blog_name) . '.';
|
||||
if ($copyright_text !== '') {
|
||||
$copy .= ' ' . wp_kses_post($copyright_text);
|
||||
}
|
||||
if ($footer_text !== '') {
|
||||
$copy .= ' ' . esc_html($footer_text);
|
||||
}
|
||||
if (!empty($footer_bits)) {
|
||||
$copy .= ' ' . implode(' · ', $footer_bits);
|
||||
}
|
||||
$_footer_conter = $copy;
|
||||
} else {
|
||||
$_footer_conter = wp_kses_post($_footer_conter);
|
||||
}
|
||||
$_footer_conter = wp_kses_post(trim((string) $footer_customize_code));
|
||||
?>
|
||||
|
||||
<?php if (is_active_sidebar('single_bottom_fluid') && is_singular('post')) : ?>
|
||||
@@ -173,7 +63,7 @@ if ($_footer_conter === '') {
|
||||
|
||||
<?php \AKSRT\WidgetSystem\WidgetAreas::render('all_bottom_fluid', 'fluid-widget-wrap'); ?>
|
||||
|
||||
<footer class="footer" data-aksrt-shell="site-footer" role="contentinfo">
|
||||
<footer class="footer" data-aksrt-shell="site-footer" data-footer-template="<?php echo esc_attr($footer_template); ?>" role="contentinfo">
|
||||
<?php if (is_active_sidebar('all_footer')) : ?>
|
||||
<?php dynamic_sidebar('all_footer'); ?>
|
||||
<?php endif; ?>
|
||||
@@ -202,13 +92,7 @@ if ($_footer_conter === '') {
|
||||
<?php if ($_has_links_col) : ?>
|
||||
<li style="max-width: 550px;">
|
||||
<?php if ($_fcode_links !== '') : ?>
|
||||
<p class="fcode-links"><?php
|
||||
if ($_fcode_links_is_raw) {
|
||||
echo wp_kses_post($_fcode_links);
|
||||
} else {
|
||||
echo $_fcode_links; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built with esc_* above
|
||||
}
|
||||
?></p>
|
||||
<p class="fcode-links"><?php echo wp_kses_post($_fcode_links); ?></p>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($footer_contact_ext['code_2'])) : ?>
|
||||
@@ -245,7 +129,7 @@ if ($_footer_conter === '') {
|
||||
continue;
|
||||
}
|
||||
$m_img = (string) ($more_item['img'] ?? '');
|
||||
$m_url = (string) ($more_item['link'] ?? '');
|
||||
$m_url = (string) ($more_item['link'] ?? '');
|
||||
$m_text = (string) ($more_item['desc'] ?? '');
|
||||
$m_icon = (string) ($more_item['icon'] ?? '');
|
||||
$m_icon_html = ($m_icon !== '' && function_exists('aksrt_brand_icon'))
|
||||
@@ -268,19 +152,6 @@ if ($_footer_conter === '') {
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php foreach ((array) $footer_contacts as $contact) :
|
||||
$c_icon = $contact['icon'] ?? '';
|
||||
$c_url = $contact['url'] ?? '#';
|
||||
$c_label = $contact['title'] ?? ($contact['label'] ?? (function_exists('aksrt_icon_key_to_name') ? aksrt_icon_key_to_name($c_icon) : ''));
|
||||
$c_icon_html = function_exists('aksrt_brand_icon') ? aksrt_brand_icon((string) $c_icon) : '';
|
||||
if ($c_icon_html === '') {
|
||||
$c_icon_html = '<i class="fa fas fa-globe" aria-hidden="true"></i>';
|
||||
}
|
||||
?>
|
||||
<a class="toggle-radius" href="<?php echo esc_url($c_url); ?>" target="_blank" rel="noopener noreferrer" title="<?php echo esc_attr($c_label); ?>" aria-label="<?php echo esc_attr($c_label); ?>">
|
||||
<?php echo $c_icon_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</li>
|
||||
@@ -288,21 +159,31 @@ if ($_footer_conter === '') {
|
||||
|
||||
<?php if ($_has_mini) : ?>
|
||||
<li class="<?php echo esc_attr(trim($_mini_xs_cls)); ?>">
|
||||
<?php foreach ($footer_mini['items'] as $mi) :
|
||||
$mi_img = (string) ($mi['img'] ?? $mi['image'] ?? '');
|
||||
$mi_text = (string) ($mi['text'] ?? $mi['label'] ?? '');
|
||||
if ($mi_img === '') {
|
||||
continue;
|
||||
}
|
||||
?>
|
||||
<div class="footer-miniimg"<?php echo $mi_text !== '' ? ' title="' . esc_attr($mi_text) . '"' : ''; ?>>
|
||||
<p>
|
||||
<img<?php echo aksrt_get_lazy_attr('lazy_other', (string) $mi_img); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr($mi_text !== '' ? $mi_text : $blog_name); ?>">
|
||||
</p>
|
||||
<?php if ($mi_text !== '') : ?>
|
||||
<span class="opacity8 em09"><?php echo esc_html($mi_text); ?></span>
|
||||
<?php endif; ?>
|
||||
<?php foreach (['items' => 'footer-miniimg flex at hh gap6', 'items_2' => 'footer-miniimg-2 flex at hh gap6'] as $items_key => $items_class) : ?>
|
||||
<?php if (!empty($footer_mini[$items_key])) : ?>
|
||||
<div class="<?php echo esc_attr($items_class); ?>">
|
||||
<?php foreach ($footer_mini[$items_key] as $mi) :
|
||||
$mi_img = (string) ($mi['image'] ?? '');
|
||||
$mi_text = (string) ($mi['text'] ?? '');
|
||||
$mi_link = is_array($mi['link'] ?? null) ? $mi['link'] : [];
|
||||
$mi_url = (string) ($mi_link['url'] ?? '');
|
||||
$mi_target = (string) ($mi_link['target'] ?? '');
|
||||
?>
|
||||
<?php if ($mi_url !== '') : ?>
|
||||
<a href="<?php echo esc_url($mi_url); ?>"<?php echo $mi_target !== '' ? ' target="' . esc_attr($mi_target) . '"' : ''; ?>>
|
||||
<?php endif; ?>
|
||||
<div<?php echo $mi_text !== '' ? ' title="' . esc_attr($mi_text) . '"' : ''; ?>>
|
||||
<img<?php echo aksrt_get_lazy_attr('lazy_other', $mi_img); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="<?php echo esc_attr($mi_text !== '' ? $mi_text : $blog_name); ?>">
|
||||
<?php if ($mi_text !== '') : ?>
|
||||
<div class="opacity8 em09 mt6 text-center"><?php echo esc_html($mi_text); ?></div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php if ($mi_url !== '') : ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</li>
|
||||
<?php endif; ?>
|
||||
|
||||
Reference in New Issue
Block a user