feat(user-center): deepen zibll parity and profile media
This commit is contained in:
@@ -388,6 +388,32 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_user_center_avatar_upload_config')) {
|
||||
/**
|
||||
* Avatar upload config for the private user center.
|
||||
*/
|
||||
function aksrt_user_center_avatar_upload_config(bool $enabled): array {
|
||||
if (!$enabled) {
|
||||
return [];
|
||||
}
|
||||
return [
|
||||
'enabled' => true,
|
||||
'restUrl' => rest_url('aksrt/v1/user/avatar'),
|
||||
'restNonce' => wp_create_nonce('wp_rest'),
|
||||
'buttonId' => 'aksrt-upload-avatar-btn',
|
||||
'inputId' => 'aksrt-avatar-file-input',
|
||||
'imageId' => 'aksrt-user-avatar-image',
|
||||
'fieldName' => 'avatar',
|
||||
'maxSize' => 2 * MB_IN_BYTES,
|
||||
'idleText' => __('更换头像', 'aksrt'),
|
||||
'loadingText' => __('上传中…', 'aksrt'),
|
||||
'tooLargeText' => __('图片大小不能超过 2MB', 'aksrt'),
|
||||
'successText' => __('头像已更新', 'aksrt'),
|
||||
'errorText' => __('头像上传失败', 'aksrt'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('aksrt_user_center_cover_upload_config')) {
|
||||
/**
|
||||
* Cover upload config for the private user-center hero.
|
||||
@@ -450,7 +476,9 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
$user_contacts = $dashboard['user_contacts'] ?? get_user_meta($user_id, 'aksrt_user_contacts', true);
|
||||
$user_contacts = is_array($user_contacts) ? $user_contacts : [];
|
||||
$user_background_url = (string) ($dashboard['background_url'] ?? get_user_meta($user_id, 'aksrt_background_image', true));
|
||||
$allow_avatar_upload = !empty($user_center_settings['avatar_upload']);
|
||||
$allow_bg_upload = !empty($user_center_settings['cover_upload']) && class_exists('\AKSRT\Settings\Settings') && aksrt_get_setting('allow_background_upload', false);
|
||||
$messages_enabled = !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::message_enabled();
|
||||
|
||||
$post_status_filter = isset($_GET['post_status']) ? sanitize_key(wp_unslash($_GET['post_status'])) : 'publish';
|
||||
if (!in_array($post_status_filter, ['all', 'publish', 'draft', 'pending', 'private'], true)) {
|
||||
@@ -472,6 +500,23 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
$currency_name = (string) ($dashboard['currency_name'] ?? __('积分', 'aksrt'));
|
||||
$balance_enabled = (bool) ($dashboard['balance_enabled'] ?? false);
|
||||
$wallet_balance = (float) ($dashboard['wallet_balance'] ?? 0.0);
|
||||
$runtime_config = aksrt_user_center_runtime_config($user_id, $tabs['default'], $active_tab, $tabs['urls']);
|
||||
$runtime_config['avatarUpload'] = aksrt_user_center_avatar_upload_config($allow_avatar_upload);
|
||||
$shop_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_shop_settings() : [];
|
||||
$forum_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_forum_settings() : [];
|
||||
$revenue_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_payment_revenue_settings() : [];
|
||||
$shop_enabled = !empty($shop_settings['enabled']);
|
||||
$forum_enabled = !empty($forum_settings['enabled']);
|
||||
$new_post_url = function_exists('aksrt_get_new_post_url') ? aksrt_get_new_post_url() : '';
|
||||
$new_product_url = $shop_enabled && function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/pages/page-product-edit.php')
|
||||
: '';
|
||||
$forum_compose_url = $forum_enabled && function_exists('aksrt_get_page_url_by_template')
|
||||
? aksrt_get_page_url_by_template('templates/forum/forum-compose.php')
|
||||
: '';
|
||||
$revenue_url = (!empty($revenue_settings['enabled']) || !empty($affiliate_settings['enabled'])) && function_exists('aksrt_get_revenue_page_url')
|
||||
? aksrt_get_revenue_page_url()
|
||||
: '';
|
||||
|
||||
$render_context = [
|
||||
'user_center_settings' => $user_center_settings,
|
||||
@@ -490,10 +535,13 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
'profile_signals' => $dashboard['profile_signals'] ?? [],
|
||||
'user_background_url' => $user_background_url,
|
||||
'allow_bg_upload' => $allow_bg_upload,
|
||||
'show_avatar_edit' => !empty($user_center_settings['avatar_upload']),
|
||||
'avatar_settings_url' => admin_url('profile.php'),
|
||||
'show_avatar_edit' => $allow_avatar_upload,
|
||||
'notification_unread_count' => function_exists('aksrt_get_user_unread_notification_count') ? aksrt_get_user_unread_notification_count($user_id) : 0,
|
||||
'messages_url' => function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
|
||||
'messages_url' => $messages_enabled && function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '',
|
||||
'new_post_url' => $new_post_url,
|
||||
'new_product_url' => $new_product_url,
|
||||
'forum_compose_url' => $forum_compose_url,
|
||||
'revenue_url' => $revenue_url,
|
||||
'per_page' => 10,
|
||||
'posts_page' => max(1, isset($_GET['posts_page']) ? (int) $_GET['posts_page'] : 1),
|
||||
'comments_page' => max(1, isset($_GET['comments_page']) ? (int) $_GET['comments_page'] : 1),
|
||||
@@ -520,7 +568,7 @@ if (!function_exists('aksrt_get_user_center_render_context')) {
|
||||
&& \AKSRT\Settings\Settings::invite_enabled()
|
||||
&& \AKSRT\Settings\Settings::invite_registration_enabled(),
|
||||
'user_email' => (string) $current_user->user_email,
|
||||
'runtime_config' => aksrt_user_center_runtime_config($user_id, $tabs['default'], $active_tab, $tabs['urls']),
|
||||
'runtime_config' => $runtime_config,
|
||||
'cover_upload_config' => aksrt_user_center_cover_upload_config($allow_bg_upload),
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user