fix(admin): replicate reference comment settings page 1:1

- Rewrite post_list/comment schema (PHP + JS) with the reference theme's
  field set, order, defaults and dependencies; smilie, comment location
  and quick-reply fields excluded
- Map PostDisplay::get_comment_display_settings() to the new keys without
  legacy fallback: close_comments, comment_paginate_type (ajax_lists),
  user_edit_comment master switch, WP comment_order for sorting
- Wire comment_box_hide visibility gate (signin / vip / vip_2 / auth)
- Drop dead comment settings (order/per_page/depth/avatar/hot threshold/
  empty text/city), the dead post_close_comments field, and city readers
  now fully owned by the IP-geo extension
- Add comment settings reference contract test
This commit is contained in:
2026-09-24 13:43:51 +08:00
parent 264f2c51b2
commit c331b2aeef
11 changed files with 382 additions and 200 deletions
+28 -1
View File
@@ -63,6 +63,32 @@ add_filter('comments_template_query_args', static function ($args) {
: $args;
});
if (!function_exists('aksrt_comment_box_visible')) :
/**
* Whether the comment module may render for the current visitor.
*
* Mirrors the reference theme's comment_box_hide conditions.
*/
function aksrt_comment_box_visible(): bool {
$settings = class_exists('\AKSRT\Settings\Settings')
? \AKSRT\Settings\Settings::get_comment_display_settings()
: [];
$hide = sanitize_key((string) ($settings['box_hide'] ?? ''));
switch ($hide) {
case 'signin':
return is_user_logged_in();
case 'vip':
return function_exists('aksrt_is_vip') && aksrt_is_vip();
case 'vip_2':
return function_exists('aksrt_is_vip2') && aksrt_is_vip2();
case 'auth':
return function_exists('aksrt_current_user_is_verified') && aksrt_current_user_is_verified();
default:
return true;
}
}
endif;
if (!function_exists('aksrt_comments_build_context')) :
/**
* Resolve comments runtime context once.
@@ -116,6 +142,7 @@ if (!function_exists('aksrt_comments_build_context')) :
'title_text' => (string) ($settings['title'] ?? __('评论', 'aksrt')),
'corderby_enabled' => !empty($settings['corderby']),
'close_comments' => !empty($settings['close_comments']),
'box_hidden' => !aksrt_comment_box_visible(),
'oauth_providers' => class_exists('\AKSRT\Auth\OAuth')
? \AKSRT\Auth\OAuth::get_instance()->get_auth_providers_data()
: [],
@@ -646,7 +673,7 @@ if (!function_exists('aksrt_comments_render')) :
}
$ctx = aksrt_comments_build_context();
if (!empty($ctx['close_comments'])) {
if (!empty($ctx['close_comments']) || !empty($ctx['box_hidden'])) {
return;
}