Files
wordpress-theme-aksrt/inc/helpers/user-center-renderers/profile-form.php
T
kate522 8241570ca2 feat(users): govern profiles and access
Normalize fixed profile fields, profile actions, and the five-column capability matrix for comments, uploads, and downloads.
2026-08-13 00:24:54 +08:00

70 lines
3.8 KiB
PHP

<?php
/**
* User center profile form part (orchestrator).
*
* @package AKSRT
*/
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'); ?>
<input type="hidden" name="action" value="aksrt_save_profile">
<input type="hidden" name="user_id" value="<?php echo (int) $user_id; ?>">
<div class="widget-card">
<h3 class="widget-title"><?php esc_html_e('昵称', 'aksrt'); ?></h3>
<input type="text" name="nickname" id="profile-nickname"
value="<?php echo esc_attr($target_user->display_name); ?>"
class="profile-input" maxlength="50" required>
<p class="profile-hint"><?php esc_html_e('修改后会同步更新个人主页地址', 'aksrt'); ?></p>
</div>
<div class="widget-card">
<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>
<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">
<button type="submit" class="btn-primary btn-lg" id="profile-save-btn">
<?php esc_html_e('保存修改', 'aksrt'); ?>
</button>
<span id="profile-save-msg" class="profile-form__submit-msg"></span>
</div>
</form>