refactor(admin): consolidate duplicate configuration
Remove duplicate comment, captcha, filing, and website-security configuration paths. Move front submission verification to the captcha scene matrix and retire obsolete admin routes and components.
This commit is contained in:
@@ -9,18 +9,8 @@ defined('ABSPATH') || exit;
|
||||
|
||||
trait AuthReader {
|
||||
|
||||
/** 评论是否启用 */
|
||||
public static function comment_enabled(): bool {
|
||||
$s = self::get_all();
|
||||
return !isset($s['comment_enabled']) || !empty($s['comment_enabled']);
|
||||
}
|
||||
|
||||
/** 是否要求注册用户才能评论 */
|
||||
public static function comment_requires_registration(): bool {
|
||||
if (!self::comment_enabled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
return !class_exists(Capabilities::class) || !Capabilities::user_can('comment_add', $user_id);
|
||||
}
|
||||
|
||||
@@ -153,48 +153,6 @@ class Capabilities {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"网站安全"设置(人机验证见 aksrt_get_captcha_status_summary)。
|
||||
*/
|
||||
public static function get_security_settings(): array {
|
||||
$s = Settings::get_all();
|
||||
|
||||
$captcha = function_exists('aksrt_get_captcha_status_summary')
|
||||
? aksrt_get_captcha_status_summary()
|
||||
: ['enabled' => false, 'provider' => '', 'configured' => false, 'scenes' => []];
|
||||
|
||||
return [
|
||||
'captcha' => $captcha,
|
||||
'brush_limit_post' => [
|
||||
'enabled' => !empty($s['brush_limit_post_enabled']),
|
||||
'minutes_10' => (int) ($s['brush_limit_post_minutes_10'] ?? 20),
|
||||
'day_1' => (int) ($s['brush_limit_post_day_1'] ?? 50),
|
||||
],
|
||||
'brush_limit_comment' => [
|
||||
'enabled' => !empty($s['brush_limit_comment_enabled']),
|
||||
'minutes_10' => (int) ($s['brush_limit_comment_minutes_10'] ?? 20),
|
||||
'day_1' => (int) ($s['brush_limit_comment_day_1'] ?? 100),
|
||||
],
|
||||
'brush_limit_upload' => [
|
||||
'enabled' => !empty($s['brush_limit_upload_enabled']),
|
||||
'minutes_10' => (int) ($s['brush_limit_upload_minutes_10'] ?? 50),
|
||||
'day_1' => (int) ($s['brush_limit_upload_day_1'] ?? 200),
|
||||
],
|
||||
'brush_limit_register' => [
|
||||
'enabled' => !empty($s['brush_limit_register_enabled']),
|
||||
'minutes_10' => (int) ($s['brush_limit_register_minutes_10'] ?? 20),
|
||||
'day_1' => (int) ($s['brush_limit_register_day_1'] ?? 100),
|
||||
],
|
||||
'brush_limit_order' => [
|
||||
'enabled' => !empty($s['brush_limit_order_enabled']),
|
||||
'minutes_10' => (int) ($s['brush_limit_order_minutes_10'] ?? 30),
|
||||
'day_1' => (int) ($s['brush_limit_order_day_1'] ?? 100),
|
||||
],
|
||||
'error_frequency_limit' => !empty($s['error_frequency_limit'] ?? true),
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取"系统工具"设置
|
||||
*/
|
||||
|
||||
@@ -137,7 +137,6 @@ trait DisplayPageGroups {
|
||||
'header_newposts' => self::get_header_newposts_config(),
|
||||
'header_theme' => self::get_header_theme_config(),
|
||||
'friend_links' => self::get_friend_links(),
|
||||
'comment_enabled' => self::comment_enabled(),
|
||||
'cms_features' => self::get_cms_features(),
|
||||
'page_display' => self::get_page_display_settings(),
|
||||
'footer_theme' => self::get_footer_theme_config(),
|
||||
|
||||
@@ -158,13 +158,6 @@ trait DomainGroups {
|
||||
return Capabilities::user_can($cap, $user_id, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"网站安全"设置
|
||||
*/
|
||||
public static function get_security_settings(): array {
|
||||
return Capabilities::get_security_settings();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"系统工具"设置
|
||||
*/
|
||||
|
||||
@@ -362,21 +362,20 @@ trait FacadeBulk {
|
||||
|
||||
|
||||
/**
|
||||
* 获取备案配置(统一 page-display footer schema 和全局设置)
|
||||
* @return array {icp_enabled, icp_number, police_enabled, police_number}
|
||||
* 获取备案配置。
|
||||
* @return array {icp_enabled, icp_filing, police_enabled, police_filing}
|
||||
*/
|
||||
public static function get_filing_settings(): array {
|
||||
$s = self::get_all();
|
||||
$icp_enabled = !isset($s['footer_icp']) || !empty($s['footer_icp']);
|
||||
$police_enabled = !isset($s['footer_police']) || !empty($s['footer_police']);
|
||||
// 优先读 footer schema 的 icp_number,回退到全局 icp_filing
|
||||
$icp_number = trim((string) ($s['icp_number'] ?? $s['icp_filing'] ?? ''));
|
||||
$police_number = trim((string) ($s['police_number'] ?? ''));
|
||||
$icp_filing = trim((string) ($s['icp_filing'] ?? ''));
|
||||
$police_filing = trim((string) ($s['police_filing'] ?? ''));
|
||||
return [
|
||||
'icp_enabled' => $icp_enabled,
|
||||
'icp_number' => $icp_number,
|
||||
'icp_filing' => $icp_filing,
|
||||
'police_enabled' => $police_enabled,
|
||||
'police_number' => $police_number,
|
||||
'police_filing' => $police_filing,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -398,7 +397,7 @@ trait FacadeBulk {
|
||||
|
||||
/** 获取公安备案号 */
|
||||
public static function police_filing(): string {
|
||||
return trim((string) self::get_value('police_number', ''));
|
||||
return trim((string) self::get_value('police_filing', ''));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ class HomeCms {
|
||||
|
||||
$s = Settings::get_all();
|
||||
$bridge_keys = [
|
||||
'footer_columns', 'footer_copyright', 'footer_icp', 'icp_number',
|
||||
'footer_police', 'police_number',
|
||||
'footer_columns', 'footer_copyright', 'footer_icp', 'footer_police',
|
||||
'footer_theme_custom', 'footer_theme_bg_custom', 'footer_theme_bg', 'footer_theme_color_custom',
|
||||
'footer_contact_wechat_img', 'footer_contact_qq', 'footer_contact_weibo', 'footer_contact_email',
|
||||
];
|
||||
|
||||
@@ -429,7 +429,6 @@ class PostDisplay {
|
||||
'editor_mode' => $editor_mode,
|
||||
'draft_save' => !isset($settings['front_submit_draft_save']) || !empty($settings['front_submit_draft_save']),
|
||||
'leave_warning' => !isset($settings['front_submit_leave_warning']) || !empty($settings['front_submit_leave_warning']),
|
||||
'captcha' => !empty($settings['front_submit_captcha']) || !empty($settings['verification_newposts_s']),
|
||||
'pay_free_s' => !isset($settings['post_article_pay_free_s']) || !empty($settings['post_article_pay_free_s']),
|
||||
'pay_price_min' => max(0, (float) ($settings['post_article_pay_price_min'] ?? 0)),
|
||||
'pay_price_max' => max(0, (float) ($settings['post_article_pay_price_max'] ?? 100)),
|
||||
|
||||
Reference in New Issue
Block a user