feat(attachment): 按参考主题重构后台上传配置套件
- 新增 AKSRT\Attachment\UploadLimits:按用户类型解析图片/视频/文件 上传上限(取最大值+默认兜底,钳制到 PHP 上限)、允许/禁止格式过滤、 上传自动重命名、非管理员附件页 404;不含论坛角色 - 后台「附件配置」重做:大小限制/格式限制/上传行为三组配置, PHP Schema 与 SPA Schema 逐字段镜像(v1.2.0) - 定制页 AttachmentPermissions.vue 改为标准 schemaPage,清理失效的 API 包装、组件加载器与旧配置键(submit_image_max_size 等) - 投稿/评论上传、批量上传数量全部切换到新链路;AksField 数字组件 支持单位展示 - 更新 captcha harness 与 front-submit 契约测试;421 项测试通过
This commit is contained in:
1 parent
505d9156fe
commit
d4bb43a275
16 files changed
+643
-269
No files matched your search
@@ -118,18 +118,13 @@ class FrontSubmit {
|
||||
}
|
||||
|
||||
public static function upload_limit_bytes(string $kind): int {
|
||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$configured_mb = match ($kind) {
|
||||
'image' => max(1, min(20, (int) ($settings['submit_image_max_size'] ?? 5))),
|
||||
'video' => max(1, min(200, (int) ($settings['submit_video_max_size'] ?? 30))),
|
||||
'resource' => max(1, min(200, (int) ($settings['resource_max_size'] ?? 50))),
|
||||
default => 0,
|
||||
};
|
||||
if ($configured_mb === 0) {
|
||||
return 0;
|
||||
// Kind names follow the REST route; the config rows use the reference
|
||||
// theme's naming (image / video / file).
|
||||
$config_kind = $kind === 'resource' ? 'file' : $kind;
|
||||
if (class_exists('\AKSRT\Attachment\UploadLimits')) {
|
||||
return \AKSRT\Attachment\UploadLimits::limit_bytes($config_kind);
|
||||
}
|
||||
|
||||
return min($configured_mb * MB_IN_BYTES, (int) wp_max_upload_size());
|
||||
return (int) wp_max_upload_size();
|
||||
}
|
||||
|
||||
public function rest_upload_attachment(\WP_REST_Request $request) {
|
||||
|
||||
@@ -479,9 +479,9 @@ trait ScriptsPart1c {
|
||||
'commentIasAuto' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias'] : true,
|
||||
'commentUploadUrl' => esc_url_raw(rest_url('aksrt/v1/comment/upload-image')),
|
||||
'commentUploadMaxSize' => (function () {
|
||||
$settings = class_exists('\\AKSRT\\Settings\\Settings') ? \AKSRT\Settings\Settings::get_all() : [];
|
||||
$max_size_mb = max(1, min(10, (int) ($settings['comment_image_max_size'] ?? 2)));
|
||||
return $max_size_mb * MB_IN_BYTES;
|
||||
return class_exists('\AKSRT\Attachment\UploadLimits')
|
||||
? \AKSRT\Attachment\UploadLimits::limit_bytes('image')
|
||||
: (int) wp_max_upload_size();
|
||||
})(),
|
||||
'commentIasMax' => class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_comment_display_settings()['paging_ajax_ias_max'] : 3,
|
||||
'restUrl' => esc_url_raw(rest_url('aksrt/v1')),
|
||||
|
||||
Reference in new issue
Block a user