绕过 wp-login 替换) */ public static function admin_sign_key(): string { return trim((string) self::get_value('admin_sign_key', '')); } /** Whether wp-login.php is replaced by /sign/. */ public static function replace_wp_login(): bool { return (bool) self::get_value('replace_wp_login', true); } /** 登录页 UI 配置数组 */ public static function sign_page_ui(): array { $theme_mode = (string) self::get_value('sign_theme_mode', 'no'); if (!in_array($theme_mode, ['no', 'white-theme', 'dark-theme'], true)) { $theme_mode = 'no'; } return [ 'background' => self::auth_gallery_ids('sign_page_background'), 'theme_mode' => $theme_mode, 'show_header' => (bool) self::get_value('sign_show_header', true), 'card_position' => in_array((string) self::get_value('sign_card_position', 'right'), ['left', 'center', 'right'], true) ? (string) self::get_value('sign_card_position', 'right') : 'right', 'show_logo' => (bool) self::get_value('sign_show_logo', false), 'footer' => (string) self::get_value('sign_page_footer', ''), ]; } /** 弹窗 UI 配置数组 */ public static function modal_ui(): array { return [ 'background' => self::auth_gallery_ids('sign_modal_background'), 'show_logo' => (bool) self::get_value('sign_modal_show_logo', false), ]; } /** 认证图片库的唯一存储格式:正整数附件 ID 数组。 */ private static function auth_gallery_ids(string $key): array { $value = self::get_value($key, []); if (!is_array($value)) { return []; } $ids = array_values(array_filter(array_map('absint', $value))); return array_values(array_unique($ids)); } /** 登录框日间 LOGO URL(空时回退全局 logo_url) */ public static function user_logo_url(): string { $ids = self::auth_gallery_ids('user_logo'); if ($ids) { $url = wp_get_attachment_image_url($ids[0], 'full'); if ($url) return $url; } return self::logo_url(); } /** 登录框夜间 LOGO URL(空时回退全局 logo_dark_url) */ public static function user_logo_dark_url(): string { $ids = self::auth_gallery_ids('user_logo_dark'); if ($ids) { $url = wp_get_attachment_image_url($ids[0], 'full'); if ($url) return $url; } return self::logo_dark_url(); } /** 是否允许手机号登录 */ public static function signin_phone_enabled(): bool { return (bool) self::get_value('user_signin_phone_s', false); } /** 是否启用验证码免密登录。 */ public static function passwordless_login_enabled(): bool { return (bool) self::get_value('user_signin_nopas_s', false); } /** 免密登录验证渠道。 */ public static function passwordless_login_type(): string { $type = (string) self::get_value('user_signin_nopas_type', 'email'); return in_array($type, ['email', 'phone', 'email_phone'], true) ? $type : 'email'; } /** 免密登录显示模式 */ public static function nopas_active_mode(): string { $mode = (string) self::get_value('user_signin_nopas_active', 'nopas'); return in_array($mode, ['nopas', 'pas', 'only_nopas'], true) ? $mode : 'nopas'; } /** 是否在注册前验证邮箱或手机号。 */ public static function signup_verification_enabled(): bool { return (bool) self::get_value('user_signup_captch', false); } /** 注册验证渠道。 */ public static function signup_verification_type(): string { $type = (string) self::get_value('captch_type', 'email'); return in_array($type, ['email', 'phone', 'email_phone'], true) ? $type : 'email'; } /** 找回密码验证渠道。 */ public static function reset_password_verification_type(): string { $type = (string) self::get_value('user_repas_captch_type', 'email'); return in_array($type, ['email', 'phone', 'email_phone'], true) ? $type : 'email'; } /** 注册时是否省略重复密码。 */ public static function signup_omit_password_confirmation(): bool { return (bool) self::get_value('user_signup_no_repas', true); } /** 推广码在注册表单中的唯一显示模式。 */ public static function invitation_mode(): string { $mode = (string) self::get_value('invit_code_s', 'close'); return in_array($mode, ['close', 'open', 'must'], true) ? $mode : 'close'; } /** 自动弹窗配置。 */ public static function sign_modal_auto(): array { return [ 'enabled' => self::user_sign_type() === 'modal' && (bool) self::get_value('sign_modal_auto_s', false), 'waiting' => max(1, min(100, (int) self::get_value('sign_modal_auto_waiting_time', 5))), 'expires' => max(0, min(2000, (float) self::get_value('sign_modal_auto_expires', 1))), ]; } /** 绑定提醒类型 */ public static function bind_reminder_type(): string { $val = self::get_value('bind_reminder', 'close'); $val = (string) $val; return in_array($val, ['email', 'phone', 'email_phone', 'close'], true) ? $val : 'close'; } /** 强制绑定类型 */ public static function mandatory_bind_type(): string { $val = self::get_value('mandatory_bind', 'close'); $val = (string) $val; return in_array($val, ['email', 'phone', 'email_phone', 'close'], true) ? $val : 'close'; } /** 昵称黑名单关键词数组 */ public static function nickname_blacklist(): array { $raw = (string) self::get_value('user_nickname_out', ''); if ($raw === '') return []; // 支持逗号分隔和换行分隔 $items = preg_split('/[,,\r\n]+/', $raw); return array_values(array_filter(array_map('trim', $items), 'strlen')); } /** 邮箱限制配置:['type' => 'not'|'allow', 'domains' => [...]] */ public static function email_limit(): array { $type = (string) self::get_value('user_email_limit_type', 'not'); if (!in_array($type, ['not', 'allow'], true)) $type = 'not'; $raw = (string) self::get_value('user_email_out', ''); $domains = []; if ($raw !== '') { $items = preg_split('/[\r\n]+/', $raw); $domains = array_values(array_filter(array_map('trim', $items), 'strlen')); } return ['type' => $type, 'domains' => $domains]; } /** 用户协议及隐私协议前台配置。 */ public static function user_agreement_settings(): array { return [ 'enabled' => (bool) self::get_value('user_agreement_s', false), 'privacy' => (bool) self::get_value('user_privacy_s', false), 'required' => (bool) self::get_value('user_agreement_check', false), 'page' => trim((string) self::get_value('user_agreement_page', '')), 'privacy_page'=> trim((string) self::get_value('user_privacy_page', '')), ]; } }