feat(creator-studio): 图片宽度四档与作者行
- 通过 editor.BlockEdit 过滤器给 core/image 增加「半屏 / 中等 / 通栏 / 全宽」 四档宽度,选中图片时出现在区块工具条;宽度写入 className 并序列化到 post_content,前台样式即可生效,无需自定义区块或额外元数据 - 前台样式:半屏靠左 50%,中等 72%,通栏跟随正文行宽,全宽突破行宽但受容器 内边距约束;移动端半屏与全宽回退为整行,避免横向滚动 - 新增作者行(头像 + 昵称 + 身份说明),数据由 CreatorRest::author_payload() 从服务端给出,前端不自行拼装;无昵称时整行不渲染,头像缺失时回退首字占位 - 作者行放在摘要之后、正文之前 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
79909f449e
commit
f5e9420266
11 files changed
+680
-39
No files matched your search
@@ -153,6 +153,8 @@ final class CreatorRest {
|
||||
'titlePlaceholder' => (string) $settings['title_placeholder'],
|
||||
'contentPlaceholder' => (string) $settings['content_placeholder'],
|
||||
],
|
||||
// 作者行数据由服务端给出,前端不自行拼装昵称/头像。
|
||||
'author' => $this->author_payload($editable, $user_id),
|
||||
'privateUploads' => $this->private_upload_rows($user_id, $post_id),
|
||||
'privateStorage' => PrivateAssets::is_available(),
|
||||
'media' => [
|
||||
@@ -573,6 +575,37 @@ final class CreatorRest {
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 作者行数据:昵称、头像与身份说明。
|
||||
*
|
||||
* @return array{name:string,avatar:string,meta:string}
|
||||
*/
|
||||
private function author_payload(?\WP_Post $editable, int $user_id): array {
|
||||
$author_id = $editable instanceof \WP_Post ? (int) $editable->post_author : $user_id;
|
||||
$user = $author_id > 0 ? get_userdata($author_id) : null;
|
||||
if (!$user) {
|
||||
return ['name' => '', 'avatar' => '', 'meta' => ''];
|
||||
}
|
||||
|
||||
$avatar = function_exists('jio_get_avatar_url') ? (string) jio_get_avatar_url($author_id, ['size' => 64]) : '';
|
||||
if ($avatar === '' && function_exists('get_avatar_url')) {
|
||||
$avatar = (string) get_avatar_url($author_id, ['size' => 64]);
|
||||
}
|
||||
|
||||
$meta = '';
|
||||
if ($author_id !== $user_id) {
|
||||
$meta = __('原作者', 'jio');
|
||||
} elseif (function_exists('jio_get_user_vip_level') && (int) jio_get_user_vip_level($user_id) > 0) {
|
||||
$meta = sprintf(__('VIP%s', 'jio'), (string) max(1, min(2, (int) jio_get_user_vip_level($user_id))));
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => (string) $user->display_name,
|
||||
'avatar' => $avatar,
|
||||
'meta' => $meta,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $post_meta
|
||||
* @return array<string, mixed>
|
||||
|
||||
Reference in new issue
Block a user