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:
1 parent
c331b2aeef
commit
4d6b2c6045
12 files changed
+469
-85
No files matched your search
@@ -31,6 +31,35 @@ add_filter('comment_text', function ($comment_text, $comment = null, $args = [])
|
||||
return $comment_text;
|
||||
}, 20, 3);
|
||||
|
||||
// ============================================================
|
||||
// 文章预置参数:新建文章按区间随机填入浏览/点赞(参考主题 post_default_mate)
|
||||
// ============================================================
|
||||
|
||||
add_action('save_post', static function ($post_id, $post = null): void {
|
||||
$post_id = (int) $post_id;
|
||||
if ($post_id <= 0 || wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
|
||||
return;
|
||||
}
|
||||
if (!($post instanceof \WP_Post) || $post->post_type !== 'post') {
|
||||
return;
|
||||
}
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return;
|
||||
}
|
||||
$page = \AKSRT\Settings\Settings::get_post_page_settings();
|
||||
$views_min = max(0, (int) ($page['default_views_min'] ?? 20));
|
||||
$views_max = max($views_min, (int) ($page['default_views_max'] ?? 50));
|
||||
$likes_min = max(0, (int) ($page['default_likes_min'] ?? 5));
|
||||
$likes_max = max($likes_min, (int) ($page['default_likes_max'] ?? 15));
|
||||
|
||||
if ('' === (string) get_post_meta($post_id, \AKSRT\Core\DomainModel::POST_VIEW_COUNT_KEY, true)) {
|
||||
update_post_meta($post_id, \AKSRT\Core\DomainModel::POST_VIEW_COUNT_KEY, wp_rand($views_min, $views_max));
|
||||
}
|
||||
if ('' === (string) get_post_meta($post_id, '_aksrt_like_count', true)) {
|
||||
update_post_meta($post_id, '_aksrt_like_count', wp_rand($likes_min, $likes_max));
|
||||
}
|
||||
}, 10, 2);
|
||||
|
||||
// ============================================================
|
||||
|
||||
// 前端隐藏 WordPress Admin Bar
|
||||
|
||||
Reference in new issue
Block a user