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:
@@ -40,15 +40,14 @@ if (!function_exists('aksrt_comment_action_permissions')) :
|
||||
return false;
|
||||
};
|
||||
|
||||
$edit_window = 10;
|
||||
// 允许用户编辑评论:参考主题 user_edit_comment 总开关(关闭后本人亦不可编辑)。
|
||||
$user_edit = true;
|
||||
if (class_exists('\AKSRT\Settings\Settings')) {
|
||||
$display = \AKSRT\Settings\Settings::get_comment_display_settings();
|
||||
$edit_window = (int) ($display['edit_window'] ?? 10);
|
||||
$user_edit = !isset($display['user_edit']) || !empty($display['user_edit']);
|
||||
}
|
||||
$within_window = $edit_window > 0
|
||||
&& (time() - strtotime((string) $comment->comment_date_gmt)) < ($edit_window * MINUTE_IN_SECONDS);
|
||||
|
||||
$can_edit_own = $is_owner && $within_window && $can('comment_edit');
|
||||
$can_edit_own = $is_owner && $user_edit && $can('comment_edit');
|
||||
$can_edit_others = (!$is_owner) && (
|
||||
($is_post_author && $can('comment_edit_my_post'))
|
||||
|| $can('comment_edit_other')
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Comment city / IP geo helpers.
|
||||
*
|
||||
* Meta: aksrt_comment_addr {country,province,city}
|
||||
* Gates: ip_geo_enabled + ip_geo_display has comment + comment_city_s
|
||||
* Gates: ip_geo_enabled + ip_geo_display has comment(扩展&增强 / IP归属地统一控制)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -12,27 +12,14 @@ defined('ABSPATH') || exit;
|
||||
|
||||
if (!function_exists('aksrt_comment_city_enabled')) :
|
||||
function aksrt_comment_city_enabled(): bool {
|
||||
if (function_exists('aksrt_ip_geo_display_enabled') && !aksrt_ip_geo_display_enabled('comment')) {
|
||||
return false;
|
||||
}
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return false;
|
||||
}
|
||||
$s = \AKSRT\Settings\Settings::get_comment_display_settings();
|
||||
return !empty($s['city_s']);
|
||||
// 评论区位置显示的开关与精度统一由「扩展&增强 / IP归属地」配置提供。
|
||||
return function_exists('aksrt_ip_geo_display_enabled') && aksrt_ip_geo_display_enabled('comment');
|
||||
}
|
||||
endif;
|
||||
|
||||
if (!function_exists('aksrt_comment_city_type')) :
|
||||
function aksrt_comment_city_type(): string {
|
||||
if (!class_exists('\AKSRT\Settings\Settings')) {
|
||||
return function_exists('aksrt_ip_geo_format_key') ? aksrt_ip_geo_format_key() : 'province_city';
|
||||
}
|
||||
$s = \AKSRT\Settings\Settings::get_comment_display_settings();
|
||||
$type = sanitize_key((string) ($s['city_type'] ?? 'province_city'));
|
||||
return in_array($type, ['province_city', 'province', 'country_province'], true)
|
||||
? $type
|
||||
: 'province_city';
|
||||
return function_exists('aksrt_ip_geo_format_key') ? aksrt_ip_geo_format_key() : 'province_city';
|
||||
}
|
||||
endif;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user