fix(admin): replicate reference post-feature settings page 1:1
- Rewrite post_list/feature schema (PHP + JS) with the reference theme's field set, order, defaults and dependencies; print/PDF toggles dropped - Move the migrated reference fields off the post-page schema (lightbox six switches, post like, default view/like ranges) to kill the dual path - Map PostDisplay::get_post_page_settings() to the new keys without legacy fallback: imagelightbox* (pc_s/m_s checkboxes merged), post_like_s, post_default_mate ranges, article_nav + article_nav_mobile_nav_s - Wire article_nav runtime: content data-nav/no-nav gate with per-post override, mobile drawer TOC box, imgbox_type config - Seed random views/likes on new posts from post_default_mate ranges - Keep the print stylesheet enqueued unconditionally (no switch); drop the dead print/PDF settings and needs_print requirement - Add post-feature settings reference contract test
This commit is contained in:
@@ -200,6 +200,28 @@ class PostDisplay {
|
||||
$maxheight = 1000;
|
||||
}
|
||||
|
||||
// 图片灯箱(参考主题 imagelightbox*):pc_s/m_s 复选框归并为单一开关。
|
||||
$lightbox_type = sanitize_key((string) ($settings['imagelightbox_type'] ?? 'group'));
|
||||
if (!in_array($lightbox_type, ['group', 'alone'], true)) {
|
||||
$lightbox_type = 'group';
|
||||
}
|
||||
$lightbox_button = static function ($value, bool $default): bool {
|
||||
if (!is_array($value)) {
|
||||
return $default;
|
||||
}
|
||||
return !empty($value['pc_s']) || !empty($value['m_s']);
|
||||
};
|
||||
$lightbox_thumbs = $lightbox_button($settings['imagelightbox_thumbs_s'] ?? null, true);
|
||||
$lightbox_zoom = $lightbox_button($settings['imagelightbox_zoom_s'] ?? null, true);
|
||||
$lightbox_full = $lightbox_button($settings['imagelightbox_full_s'] ?? null, true);
|
||||
$lightbox_down = $lightbox_button($settings['imagelightbox_down_s'] ?? null, true);
|
||||
$lightbox_play = $lightbox_button($settings['imagelightbox_play_s'] ?? null, true);
|
||||
|
||||
// 文章预置参数:新建文章时按区间随机填入浏览/点赞(参考主题 post_default_mate)。
|
||||
$default_mate = is_array($settings['post_default_mate'] ?? null) ? $settings['post_default_mate'] : [];
|
||||
$views_range = is_array($default_mate['views'] ?? null) ? $default_mate['views'] : [];
|
||||
$like_range = is_array($default_mate['like'] ?? null) ? $default_mate['like'] : [];
|
||||
|
||||
$related_style = sanitize_key((string) ($settings['post_related_type'] ?? 'img'));
|
||||
if (!in_array($related_style, ['img', 'list', 'text'], true)) {
|
||||
$related_style = 'img';
|
||||
@@ -229,18 +251,19 @@ class PostDisplay {
|
||||
'article_slide_cover' => !isset($settings['post_article_slide_cover']) || !empty($settings['post_article_slide_cover']),
|
||||
'article_video_cover' => !isset($settings['post_article_video_cover']) || !empty($settings['post_article_video_cover']),
|
||||
'article_video_cover_scale'=> max(20, min(100, (int) ($settings['post_article_video_cover_scale'] ?? 56))),
|
||||
'lightbox' => !isset($settings['post_lightbox']) || !empty($settings['post_lightbox']),
|
||||
'lightbox_thumbs' => !isset($settings['post_lightbox_thumbs']) || !empty($settings['post_lightbox_thumbs']),
|
||||
'lightbox_zoom' => !isset($settings['post_lightbox_zoom']) || !empty($settings['post_lightbox_zoom']),
|
||||
'lightbox_full' => !isset($settings['post_lightbox_full']) || !empty($settings['post_lightbox_full']),
|
||||
'lightbox_down' => !empty($settings['post_lightbox_down']),
|
||||
'lightbox_play' => !empty($settings['post_lightbox_play']),
|
||||
'lightbox' => !isset($settings['imagelightbox']) || !empty($settings['imagelightbox']),
|
||||
'lightbox_type' => $lightbox_type,
|
||||
'lightbox_thumbs' => $lightbox_thumbs,
|
||||
'lightbox_zoom' => $lightbox_zoom,
|
||||
'lightbox_full' => $lightbox_full,
|
||||
'lightbox_down' => $lightbox_down,
|
||||
'lightbox_play' => $lightbox_play,
|
||||
'related_enabled' => !isset($settings['post_related_s']) || !empty($settings['post_related_s']),
|
||||
'related_count' => max(4, min(12, (int) ($settings['post_related_n'] ?? 6))),
|
||||
'related_style' => $related_style,
|
||||
'related_orderby' => $related_orderby,
|
||||
'related_title' => sanitize_text_field((string) ($settings['related_title'] ?? '相关推荐')),
|
||||
'like_enabled' => !isset($settings['post_like_enabled']) || !empty($settings['post_like_enabled']),
|
||||
'like_enabled' => !isset($settings['post_like_s']) || !empty($settings['post_like_s']),
|
||||
'favorite_enabled' => !isset($settings['post_favorite_enabled']) || !empty($settings['post_favorite_enabled']),
|
||||
// Canonical + legacy share.
|
||||
'share_enabled' => $share_enabled,
|
||||
@@ -269,12 +292,12 @@ class PostDisplay {
|
||||
'yiyan_header' => !empty($settings['post_yiyan_header']),
|
||||
'yiyan_footer' => !empty($settings['post_yiyan_footer']),
|
||||
'yiyan_box' => !empty($settings['post_yiyan_box']),
|
||||
'default_views_min' => max(0, min(9999, (int) ($settings['post_default_views_min'] ?? 20))),
|
||||
'default_views_max' => max(1, min(9999, (int) ($settings['post_default_views_max'] ?? 50))),
|
||||
'default_likes_min' => max(0, min(9999, (int) ($settings['post_default_likes_min'] ?? 5))),
|
||||
'default_likes_max' => max(1, min(9999, (int) ($settings['post_default_likes_max'] ?? 15))),
|
||||
'print_enabled' => !isset($settings['feature_print']) || !empty($settings['feature_print']),
|
||||
'pdf_export_enabled' => !empty($settings['feature_pdf_export']),
|
||||
'default_views_min' => max(0, min(9999, (int) ($views_range['min'] ?? 20))),
|
||||
'default_views_max' => max(1, min(9999, (int) ($views_range['max'] ?? 50))),
|
||||
'default_likes_min' => max(0, min(9999, (int) ($like_range['min'] ?? 5))),
|
||||
'default_likes_max' => max(1, min(9999, (int) ($like_range['max'] ?? 15))),
|
||||
'article_nav' => !isset($settings['article_nav']) || !empty($settings['article_nav']),
|
||||
'article_nav_mobile' => !isset($settings['article_nav_mobile_nav_s']) || !empty($settings['article_nav_mobile_nav_s']),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user