58 lines
2.1 KiB
PHP
58 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* User center notification preferences panel.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
|
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
|
$preferences = class_exists('\AKSRT\User\NotificationPreferences')
|
|
? \AKSRT\User\NotificationPreferences::get($user_id)
|
|
: ['posts' => true, 'like' => true, 'system' => true];
|
|
$items = [
|
|
'posts' => [
|
|
'title' => __('文章评论', 'aksrt'),
|
|
'description' => __('接收文章、评论、收藏等相关消息', 'aksrt'),
|
|
],
|
|
'like' => [
|
|
'title' => __('点赞喜欢', 'aksrt'),
|
|
'description' => __('接收点赞、关注等相关消息', 'aksrt'),
|
|
],
|
|
'system' => [
|
|
'title' => __('系统消息', 'aksrt'),
|
|
'description' => __('接收订单、活动、等系统消息', 'aksrt'),
|
|
],
|
|
];
|
|
?>
|
|
<form class="uc-notification-preferences" data-aksrt-notification-preferences>
|
|
<div class="uc-notification-preferences__header">
|
|
<div>
|
|
<h2><?php esc_html_e('消息通知', 'aksrt'); ?></h2>
|
|
<p><?php esc_html_e('选择你希望接收的站内消息类型。', 'aksrt'); ?></p>
|
|
</div>
|
|
<span class="uc-notification-preferences__header-icon" aria-hidden="true"><i class="fa fas fa-bell"></i></span>
|
|
</div>
|
|
|
|
<div class="uc-notification-preferences__list">
|
|
<?php foreach ($items as $key => $item) : ?>
|
|
<label class="uc-notification-preference" for="aksrt-notification-<?php echo esc_attr($key); ?>">
|
|
<span class="uc-notification-preference__copy">
|
|
<strong><?php echo esc_html($item['title']); ?></strong>
|
|
<small><?php echo esc_html($item['description']); ?></small>
|
|
</span>
|
|
<span class="uc-notification-switch">
|
|
<input id="aksrt-notification-<?php echo esc_attr($key); ?>" type="checkbox" name="<?php echo esc_attr($key); ?>" value="1" role="switch" <?php checked(!empty($preferences[$key])); ?>>
|
|
<span aria-hidden="true"></span>
|
|
</span>
|
|
</label>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
|
|
<div class="uc-notification-preferences__footer">
|
|
<button type="submit" class="btn-primary"><?php esc_html_e('保存设置', 'aksrt'); ?></button>
|
|
</div>
|
|
</form>
|