修复了一些问题

This commit is contained in:
kate522 committed 2026-08-23 20:59:34 +08:00
1 parent af52f9e94d
commit d7634d1ff6
9 files changed
+316 -24

No files matched your search

+4
View File
@@ -92,6 +92,10 @@ abstract class ControllerBase {
case 'array':
$out[$key] = is_array($val) ? $val : [];
break;
case 'attachment_ids':
$ids = is_array($val) ? array_filter(array_map('absint', $val)) : [];
$out[$key] = array_values(array_unique($ids));
break;
default:
$out[$key] = sanitize_text_field($val);
}
+11
View File
@@ -443,6 +443,12 @@ class SchemaProvider {
private function sanitize_value($value, string $type) {
switch ($type) {
case 'attachment_ids':
if (!is_array($value)) {
return [];
}
$ids = array_values(array_filter(array_map('absint', $value)));
return array_values(array_unique($ids));
case 'html':
return wp_kses_post((string) $value);
case 'textarea':
@@ -488,6 +494,10 @@ class SchemaProvider {
return $this->sanitize_value($value, $sanitize_type);
}
if ($type === 'gallery') {
return $this->sanitize_value($value, 'attachment_ids');
}
if (in_array($type, ['fieldset', 'accordion'], true)) {
return $this->sanitize_object_fields($value, (array) ($field['fields'] ?? []));
}
@@ -658,6 +668,7 @@ class SchemaProvider {
'icon' => 'string',
'media' => 'url',
'upload' => 'url',
'gallery' => 'attachment_ids',
'code' => 'code',
];
+19 -8
View File
@@ -86,7 +86,7 @@ trait AuthReader {
$theme_mode = 'no';
}
return [
'background' => self::get_value('sign_page_background', []),
'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)
@@ -99,16 +99,27 @@ trait AuthReader {
/** 弹窗 UI 配置数组 */
public static function modal_ui(): array {
return [
'background' => self::get_value('sign_modal_background', []),
'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::get_value('user_logo', []);
if (is_array($ids) && !empty($ids)) {
$url = wp_get_attachment_url((int) $ids[0]);
$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();
@@ -116,9 +127,9 @@ trait AuthReader {
/** 登录框夜间 LOGO URL(空时回退全局 logo_dark_url) */
public static function user_logo_dark_url(): string {
$ids = self::get_value('user_logo_dark', []);
if (is_array($ids) && !empty($ids)) {
$url = wp_get_attachment_url((int) $ids[0]);
$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();