进行了一些小修复

This commit is contained in:
2026-08-26 18:25:42 +08:00
parent 7c0c21e984
commit ee4e599f2d
13 changed files with 496 additions and 75 deletions
+12
View File
@@ -181,6 +181,13 @@ class DomainModel {
}
$allowed_types = ['direct', 'net_disk', 'external'];
$allowed_classes = [
'',
'c-red', 'c-yellow', 'c-cyan', 'c-blue', 'c-green', 'c-purple',
'b-red', 'b-yellow', 'b-cyan', 'b-blue', 'b-green', 'b-purple',
'jb-red', 'jb-pink', 'jb-yellow', 'jb-cyan', 'jb-blue', 'jb-green', 'jb-purple',
'jb-vip1', 'jb-vip2',
];
$downloads = [];
foreach ($value as $row) {
@@ -229,6 +236,11 @@ class DomainModel {
'url' => $url,
'type' => $type,
'extract_code' => $extract_code,
'copy_key' => isset($row['copy_key']) ? sanitize_text_field((string) $row['copy_key']) : '',
'copy_val' => isset($row['copy_val']) ? sanitize_text_field((string) $row['copy_val']) : '',
'class' => isset($row['class']) && in_array($row['class'], $allowed_classes, true)
? (string) $row['class']
: '',
];
}
+3
View File
@@ -229,6 +229,9 @@ trait FrontSubmitPay {
'url' => $url,
'type' => $attachment_id > 0 ? 'direct' : 'external',
'extract_code' => sanitize_text_field((string) ($row['extract_code'] ?? '')),
'copy_key' => sanitize_text_field((string) ($row['copy_key'] ?? '')),
'copy_val' => sanitize_text_field((string) ($row['copy_val'] ?? '')),
'class' => sanitize_key((string) ($row['class'] ?? '')),
];
}
return DomainModel::sanitize_downloads($out);
+1 -1
View File
@@ -200,7 +200,7 @@ class ResourceMetaBox {
/** @param int|string $index */
private function download_row($index, array $row): void {
?>
<div class="aksrt-pay-meta__group" data-group-row><div class="aksrt-pay-meta__upload"><input type="url" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('上传文件或输入下载地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library=""><?php esc_html_e('选择', 'aksrt'); ?></button></div><input type="text" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][label]" value="<?php echo esc_attr((string) ($row['label'] ?? '')); ?>" placeholder="<?php esc_attr_e('按钮文案', 'aksrt'); ?>"><textarea rows="1" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][extract_code]" placeholder="<?php esc_attr_e('资源备注、提取码或解压密码', 'aksrt'); ?>"><?php echo esc_textarea((string) ($row['extract_code'] ?? '')); ?></textarea><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
<div class="aksrt-pay-meta__group" data-group-row><div class="aksrt-pay-meta__upload"><input type="url" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][url]" value="<?php echo esc_attr((string) ($row['url'] ?? '')); ?>" placeholder="<?php esc_attr_e('上传文件或输入下载地址', 'aksrt'); ?>" data-media-input><button type="button" class="button" data-media-select data-library=""><?php esc_html_e('选择', 'aksrt'); ?></button></div><input type="text" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][label]" value="<?php echo esc_attr((string) ($row['label'] ?? '')); ?>" placeholder="<?php esc_attr_e('按钮文案', 'aksrt'); ?>"><textarea rows="1" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][extract_code]" placeholder="<?php esc_attr_e('资源备注、提取码或解压密码', 'aksrt'); ?>"><?php echo esc_textarea((string) ($row['extract_code'] ?? '')); ?></textarea><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][copy_key]" value="<?php echo esc_attr((string) ($row['copy_key'] ?? '')); ?>"><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][copy_val]" value="<?php echo esc_attr((string) ($row['copy_val'] ?? '')); ?>"><input type="hidden" name="aksrt_pay[downloads][<?php echo esc_attr((string) $index); ?>][class]" value="<?php echo esc_attr((string) ($row['class'] ?? '')); ?>"><button type="button" class="button-link-delete" data-group-remove><?php esc_html_e('移除', 'aksrt'); ?></button></div>
<?php
}
+3
View File
@@ -184,6 +184,9 @@ class Setup {
'url' => ['type' => 'string', 'format' => 'uri'],
'type' => ['type' => 'string'],
'extract_code' => ['type' => 'string'],
'copy_key' => ['type' => 'string'],
'copy_val' => ['type' => 'string'],
'class' => ['type' => 'string'],
],
],
],