用户功能设置收口与废弃后台链路清理
This commit is contained in:
@@ -49,8 +49,6 @@ class Capabilities {
|
||||
'comment_delete_my_post' => ['label' => __('删除自己文章下的评论', 'aksrt'), 'exclude_roles' => ['all']],
|
||||
'comment_delete_other' => ['label' => __('删除其他文章下的评论', 'aksrt'), 'exclude_roles' => ['all']],
|
||||
|
||||
'upload_avatar' => ['label' => __('上传头像', 'aksrt'), 'default' => ['logged' => true]],
|
||||
'upload_profile_background' => ['label' => __('上传用户资料卡背景图', 'aksrt'), 'default' => ['logged' => true]],
|
||||
'upload_submit_image' => ['label' => __('投稿图片上传', 'aksrt'), 'exclude_roles' => ['all']],
|
||||
'upload_comment_image' => ['label' => __('评论图片上传', 'aksrt'), 'exclude_roles' => ['all']],
|
||||
'upload_resource_attachment'=> ['label' => __('资源附件上传', 'aksrt'), 'exclude_roles' => ['all']],
|
||||
@@ -153,36 +151,4 @@ class Capabilities {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"系统工具"设置
|
||||
*/
|
||||
public static function get_system_tools_settings(): array {
|
||||
$s = Settings::get_all();
|
||||
$time_format = sanitize_text_field((string) ($s['time_format'] ?? 'n月j日 H:i'));
|
||||
|
||||
return [
|
||||
'remove_emoji' => !empty($s['remove_emoji'] ?? true),
|
||||
'remove_open_sans' => !empty($s['remove_open_sans'] ?? true),
|
||||
'remove_more_wp_head' => !empty($s['remove_more_wp_head'] ?? true),
|
||||
'hide_admin_bar' => !empty($s['hide_admin_bar'] ?? true),
|
||||
'remove_dashboard_widgets' => !empty($s['remove_dashboard_widgets'] ?? true),
|
||||
'admin_frontend_set' => !empty($s['admin_frontend_set'] ?? true),
|
||||
'display_wp_update' => !empty($s['display_wp_update'] ?? true),
|
||||
'close_gutenberg' => !empty($s['close_gutenberg']),
|
||||
'admin_user_del_fields' => !empty($s['admin_user_del_fields'] ?? true),
|
||||
'split_upload_s' => !empty($s['split_upload_s'] ?? true),
|
||||
'split_minimum_size' => max(4, min(100, (int) ($s['split_minimum_size'] ?? 20))),
|
||||
'newfilename' => !empty($s['newfilename']),
|
||||
'newfilename_type' => in_array($s['newfilename_type'] ?? 'time', ['random', 'time'], true)
|
||||
? $s['newfilename_type'] : 'time',
|
||||
'disabled_large_thumbnail' => !empty($s['disabled_large_thumbnail'] ?? true),
|
||||
'disabled_autoembed' => !empty($s['disabled_autoembed'] ?? true),
|
||||
'mce_float_toolbar' => [
|
||||
'pc_s' => !empty($s['mce_float_toolbar_pc_s'] ?? true),
|
||||
'm_s' => !empty($s['mce_float_toolbar_m_s'] ?? true),
|
||||
],
|
||||
'time_ago_s' => !empty($s['time_ago_s'] ?? true),
|
||||
'time_format' => $time_format,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,11 +146,4 @@ trait DomainGroups {
|
||||
return Capabilities::user_can($cap, $user_id, $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取"系统工具"设置
|
||||
*/
|
||||
public static function get_system_tools_settings(): array {
|
||||
return Capabilities::get_system_tools_settings();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Frontend modal runtime settings.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
namespace AKSRT\Settings;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
class FrontendModalRuntime {
|
||||
|
||||
/**
|
||||
* Read the per-domain frontend modal rollout switches.
|
||||
*
|
||||
* @return array{vip:bool,order:bool,identity:bool}
|
||||
*/
|
||||
public static function get_frontend_modal_rollout(): array {
|
||||
$settings = Settings::get_all();
|
||||
|
||||
return [
|
||||
// Canonical-only flows must be live when the option has never been configured.
|
||||
// An explicit false remains an intentional per-domain kill switch.
|
||||
'vip' => !array_key_exists('frontend_modal_rollout_vip', $settings) || !empty($settings['frontend_modal_rollout_vip']),
|
||||
'order' => !array_key_exists('frontend_modal_rollout_order', $settings) || !empty($settings['frontend_modal_rollout_order']),
|
||||
'identity' => !array_key_exists('frontend_modal_rollout_identity', $settings) || !empty($settings['frontend_modal_rollout_identity']),
|
||||
];
|
||||
}
|
||||
}
|
||||
+11
-11
@@ -513,17 +513,6 @@ class Settings {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取前台弹窗按领域灰度开关。
|
||||
*
|
||||
* @return array{vip:bool,order:bool,identity:bool}
|
||||
*/
|
||||
public static function get_frontend_modal_rollout(): array {
|
||||
return FrontendModalRuntime::get_frontend_modal_rollout();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取侧边栏配置
|
||||
*
|
||||
@@ -557,6 +546,17 @@ class Settings {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Canonical avatar, cover, and signature settings.
|
||||
*
|
||||
* @return array{avatar_upload_s:bool,avatar_external:string,avatar_default_img:string,user_cover_upload_s:bool,user_cover_img:string,user_desc_std:string}
|
||||
*/
|
||||
public static function get_user_feature_settings(): array {
|
||||
return UserRuntime::get_user_feature_settings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Private user-center display settings.
|
||||
*
|
||||
|
||||
@@ -9,6 +9,31 @@ defined('ABSPATH') || exit;
|
||||
|
||||
class UserRuntime {
|
||||
|
||||
/**
|
||||
* Canonical avatar, cover, and signature settings.
|
||||
*
|
||||
* @return array{avatar_upload_s:bool,avatar_external:string,avatar_default_img:string,user_cover_upload_s:bool,user_cover_img:string,user_desc_std:string}
|
||||
*/
|
||||
public static function get_user_feature_settings(): array {
|
||||
$settings = Settings::read_domain('users', 'features');
|
||||
$source = sanitize_key((string) ($settings['avatar_external'] ?? ''));
|
||||
if (!in_array($source, ['', 'gravatar', 'weavatar', 'cravatar', 'geekzu', 'loli', 'sep', 'v2ex'], true)) {
|
||||
$source = '';
|
||||
}
|
||||
|
||||
$avatar = esc_url_raw((string) ($settings['avatar_default_img'] ?? ''));
|
||||
$cover = esc_url_raw((string) ($settings['user_cover_img'] ?? ''));
|
||||
|
||||
return [
|
||||
'avatar_upload_s' => !array_key_exists('avatar_upload_s', $settings) || !empty($settings['avatar_upload_s']),
|
||||
'avatar_external' => $source,
|
||||
'avatar_default_img' => $avatar !== '' ? $avatar : get_theme_file_uri('assets/img/avatar-default.png'),
|
||||
'user_cover_upload_s' => !array_key_exists('user_cover_upload_s', $settings) || !empty($settings['user_cover_upload_s']),
|
||||
'user_cover_img' => $cover !== '' ? $cover : get_theme_file_uri('assets/img/user_t.jpg'),
|
||||
'user_desc_std' => sanitize_text_field((string) ($settings['user_desc_std'] ?? '这家伙很懒,什么都没有写...')),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Public user-home display settings.
|
||||
*
|
||||
@@ -70,59 +95,11 @@ class UserRuntime {
|
||||
*
|
||||
* @return array{tabs:string[]}
|
||||
*/
|
||||
public static function get_user_center_settings(): array {
|
||||
$settings = Settings::get_all();
|
||||
$raw_tabs = $settings['user_center_tabs'] ?? 'profile,level,comments,credits,revenue,favorites,auth';
|
||||
$tabs = is_array($raw_tabs)
|
||||
? $raw_tabs
|
||||
: preg_split('/[\s,]+/', (string) $raw_tabs, -1, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
// Built-in switchable panels. VIP is always auto-injected when enabled
|
||||
// by AKSRT\User\Center — keep it allowed for explicit config too.
|
||||
$allowed_tabs = ['profile', 'level', 'comments', 'favorites', 'credits', 'revenue', 'vip', 'orders', 'auth', 'settings'];
|
||||
$normalized_tabs = ['profile'];
|
||||
|
||||
foreach ((array) $tabs as $tab) {
|
||||
$tab = sanitize_key((string) $tab);
|
||||
if ($tab === 'profile') {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (in_array($tab, $allowed_tabs, true) && !in_array($tab, $normalized_tabs, true)) {
|
||||
$normalized_tabs[] = $tab;
|
||||
}
|
||||
}
|
||||
|
||||
if (!in_array('comments', $normalized_tabs, true)) {
|
||||
$normalized_tabs[] = 'comments';
|
||||
}
|
||||
|
||||
// Ensure VIP appears in configured tabs when membership is on, even if
|
||||
// the stored option string is older and omits it.
|
||||
$vip_on = !empty(Settings::get_payment_vip_settings()['enabled']);
|
||||
if ($vip_on && !in_array('vip', $normalized_tabs, true)) {
|
||||
// Prefer after credits, else after favorites, else append before settings.
|
||||
$insert_at = count($normalized_tabs);
|
||||
foreach (['credits', 'favorites', 'posts'] as $anchor) {
|
||||
$idx = array_search($anchor, $normalized_tabs, true);
|
||||
if ($idx !== false) {
|
||||
$insert_at = (int) $idx + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
array_splice($normalized_tabs, $insert_at, 0, ['vip']);
|
||||
}
|
||||
if (!$vip_on) {
|
||||
$normalized_tabs = array_values(array_filter(
|
||||
$normalized_tabs,
|
||||
static fn(string $t): bool => $t !== 'vip'
|
||||
));
|
||||
}
|
||||
|
||||
return [
|
||||
'tabs' => $normalized_tabs,
|
||||
];
|
||||
}
|
||||
public static function get_user_center_settings(): array {
|
||||
return [
|
||||
'tabs' => ['profile', 'level', 'comments', 'credits', 'revenue', 'favorites', 'auth'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* User identity, level, medal, and report governance settings.
|
||||
|
||||
Reference in New Issue
Block a user