feat(users): govern profiles and access
Normalize fixed profile fields, profile actions, and the five-column capability matrix for comments, uploads, and downloads.
This commit is contained in:
1 parent
0b06b2c7df
commit
8241570ca2
67 files changed
+780
-1127
No files matched your search
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User center profile form: contact rows block.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (empty($user_center_settings['social_links'])) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('联系方式', 'aksrt'); ?></h3>
|
||||
<p class="profile-hint profile-hint--top"><?php esc_html_e('添加你的社交链接,显示在公开用户主页', 'aksrt'); ?></p>
|
||||
<div id="contacts-list">
|
||||
<?php foreach ((array) $user_contacts as $i => $contact) : ?>
|
||||
<div class="contact-row" data-index="<?php echo (int) $i; ?>">
|
||||
<select name="contacts[<?php echo (int) $i; ?>][icon]" class="profile-input contact-icon">
|
||||
<?php echo aksrt_contact_icon_options($contact['icon'] ?? ''); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
|
||||
</select>
|
||||
<input type="hidden" name="contacts[<?php echo (int) $i; ?>][name]" value="">
|
||||
<input type="url" name="contacts[<?php echo (int) $i; ?>][url]"
|
||||
value="<?php echo esc_url($contact['url'] ?? ''); ?>"
|
||||
class="profile-input contact-url" placeholder="<?php esc_attr_e('链接 URL', 'aksrt'); ?>">
|
||||
<button type="button" class="contact-remove" onclick="this.parentElement.remove()" title="<?php esc_attr_e('删除', 'aksrt'); ?>">×</button>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<button type="button" class="btn-ghost btn-sm profile-add-contact" id="add-contact-btn">+ <?php esc_html_e('添加联系方式', 'aksrt'); ?></button>
|
||||
</div>
|
||||
@@ -9,6 +9,7 @@ defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
$profile_details = isset($profile_details) && is_array($profile_details) ? $profile_details : aksrt_get_user_profile_details((int) $user_id);
|
||||
?>
|
||||
<form class="profile-form" id="profile-form" method="post">
|
||||
<?php wp_nonce_field('aksrt_profile_save', '_profile_nonce'); ?>
|
||||
@@ -24,13 +25,39 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('个人简介', 'aksrt'); ?></h3>
|
||||
<h3 class="widget-title"><?php esc_html_e('个人签名', 'aksrt'); ?></h3>
|
||||
<textarea name="description" id="profile-bio" class="profile-input profile-textarea"
|
||||
rows="4" maxlength="500" placeholder="<?php esc_attr_e('介绍一下自己…', 'aksrt'); ?>"><?php echo esc_textarea($target_user->description); ?></textarea>
|
||||
<p class="profile-hint"><?php esc_html_e('显示在你的公开用户主页上,最多 500 字', 'aksrt'); ?></p>
|
||||
</div>
|
||||
|
||||
<?php require __DIR__ . '/form-contacts.php'; ?>
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('隐私设置', 'aksrt'); ?></h3>
|
||||
<select name="privacy" class="profile-input">
|
||||
<option value="private" <?php selected($profile_details['privacy'], 'private'); ?>><?php esc_html_e('社交资料 所有人不可见', 'aksrt'); ?></option>
|
||||
<option value="public" <?php selected($profile_details['privacy'], 'public'); ?>><?php esc_html_e('社交资料 所有人可见', 'aksrt'); ?></option>
|
||||
<option value="members" <?php selected($profile_details['privacy'], 'members'); ?>><?php esc_html_e('社交资料 仅注册用户可见', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('性别', 'aksrt'); ?></h3>
|
||||
<select name="gender" class="profile-input">
|
||||
<option value="secret" <?php selected($profile_details['gender'], 'secret'); ?>><?php esc_html_e('保密', 'aksrt'); ?></option>
|
||||
<option value="male" <?php selected($profile_details['gender'], 'male'); ?>><?php esc_html_e('男', 'aksrt'); ?></option>
|
||||
<option value="female" <?php selected($profile_details['gender'], 'female'); ?>><?php esc_html_e('女', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e('社交资料', 'aksrt'); ?></h3>
|
||||
<div class="profile-form__fields">
|
||||
<label><span><?php esc_html_e('个人网站', 'aksrt'); ?></span><input type="url" name="website" class="profile-input" value="<?php echo esc_attr($profile_details['website']); ?>" placeholder="https://"></label>
|
||||
<label><span>QQ</span><input type="text" name="qq" class="profile-input" maxlength="50" value="<?php echo esc_attr($profile_details['qq']); ?>"></label>
|
||||
<label><span><?php esc_html_e('微信', 'aksrt'); ?></span><input type="text" name="wechat" class="profile-input" maxlength="100" value="<?php echo esc_attr($profile_details['wechat']); ?>"></label>
|
||||
<label><span>GitHub</span><input type="url" name="github" class="profile-input" value="<?php echo esc_attr($profile_details['github']); ?>" placeholder="https://github.com/"></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="profile-form__submit">
|
||||
|
||||
@@ -14,13 +14,18 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
<div class="uc-header__cover">
|
||||
<img id="aksrt-cover-img" class="uc-header__cover-img" src="<?php echo esc_url($user_background_url ? $user_background_url : get_theme_file_uri('assets/img/person_background.png')); ?>" alt="">
|
||||
<div class="uc-header__cover-mask"></div>
|
||||
<?php if ($allow_bg_upload) : ?>
|
||||
<button type="button" class="uc-header__cover-upload" id="aksrt-upload-bg-btn" title="<?php esc_attr_e('编辑背景图', 'aksrt'); ?>">
|
||||
<i class="fas fa-pen" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('编辑', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<input type="file" id="aksrt-bg-file-input" accept="image/jpeg,image/png,image/webp,image/gif" style="display:none">
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-cover-menu" data-aksrt-menu>
|
||||
<button type="button" class="aksrt-cover-menu__trigger" aria-haspopup="true" aria-expanded="false" aria-label="<?php esc_attr_e('个人主页操作', 'aksrt'); ?>">
|
||||
<i class="fas fa-ellipsis-h" aria-hidden="true"></i>
|
||||
</button>
|
||||
<div class="aksrt-cover-menu__panel" role="menu" hidden>
|
||||
<a role="menuitem" href="<?php echo esc_url(aksrt_get_user_home_url()); ?>"><i class="fas fa-home" aria-hidden="true"></i><?php esc_html_e('我的主页', 'aksrt'); ?></a>
|
||||
<?php if ($allow_bg_upload) : ?>
|
||||
<button type="button" role="menuitem" id="aksrt-upload-bg-btn"><i class="fas fa-image" aria-hidden="true"></i><span><?php esc_html_e('修改背景图', 'aksrt'); ?></span></button>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ($allow_bg_upload) : ?><input type="file" id="aksrt-bg-file-input" accept="image/jpeg,image/png,image/webp,image/gif" hidden><?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-header__content">
|
||||
<div class="uc-header__avatar">
|
||||
@@ -72,9 +77,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
|
||||
<?php endif; ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url(aksrt_get_user_home_url()); ?>" class="btn-ghost btn-sm">
|
||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i> <?php esc_html_e('我的主页', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Reference in new issue
Block a user