diff --git a/src/Widgets/WidgetUserCard.php b/src/Widgets/WidgetUserCard.php index c60891e0..3cc48fb4 100644 --- a/src/Widgets/WidgetUserCard.php +++ b/src/Widgets/WidgetUserCard.php @@ -28,24 +28,15 @@ class WidgetUserCard extends \WP_Widget { $show_stats = !empty($instance['show_stats']) || !isset($instance['show_stats']); $show_actions = !empty($instance['show_button']) || !isset($instance['show_button']); $show_checkin = !empty($instance['show_checkin']) || !isset($instance['show_checkin']); - // zibll user widget forces show_posts=false; author widget enables it. - // AKSRT keeps optional show_posts for current-user card (default off). - $show_posts = !empty($instance['show_posts']); $affix = function_exists('aksrt_widget_affix_attrs') ? aksrt_widget_affix_attrs($instance) : ['class' => '', 'attr' => '']; $loged_title = (string) ($instance['loged_title'] ?? __('Hi!请登录', 'aksrt')); $btn1_text = (string) ($instance['button_1_text'] ?? __('发布文章', 'aksrt')); $btn2_text = (string) ($instance['button_2_text'] ?? __('用户中心', 'aksrt')); + $btn1_url = (string) ($instance['button_1_url'] ?? ''); + $btn2_url = (string) ($instance['button_2_url'] ?? ''); // Zibll button color palettes (button_1_class / button_2_class). $btn1_class = sanitize_html_class((string) ($instance['button_1_class'] ?? 'jb-pink')) ?: 'jb-pink'; $btn2_class = sanitize_html_class((string) ($instance['button_2_class'] ?? 'jb-blue')) ?: 'jb-blue'; - // Zibll button types: button_1 = 'post' (compose); button_2 ∈ {home,center}. - $btn2_type = (string) ($instance['button_2'] ?? 'center'); - $post_style = sanitize_key((string) ($instance['post_style'] ?? 'mini')); - if (!in_array($post_style, ['card', 'mini'], true)) { - $post_style = 'mini'; - } - $limit = max(0, min(12, (int) ($instance['limit'] ?? 6))); - $orderby = sanitize_key((string) ($instance['orderby'] ?? 'date')); // Fixed user id wins; else current user. $user_id = !empty($instance['user_id']) ? (int) $instance['user_id'] : 0; @@ -79,6 +70,8 @@ class WidgetUserCard extends \WP_Widget { echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped return; } + $btn1_url = esc_url($btn1_url !== '' ? $btn1_url : $this->get_default_compose_url()); + $btn2_url = esc_url($btn2_url !== '' ? $btn2_url : $this->get_default_center_url()); $is_self = is_user_logged_in() && (int) get_current_user_id() === $user_id; $avatar_url = function_exists('aksrt_get_avatar_url') @@ -87,21 +80,6 @@ class WidgetUserCard extends \WP_Widget { $profile_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url($user_id) : get_author_posts_url($user_id); - $center_url = function_exists('aksrt_get_user_center_url') - ? aksrt_get_user_center_url() - : $profile_url; - // Zibll button_2 type: home → profile, center → user center. - $btn2_url = $btn2_type === 'home' ? $profile_url : $center_url; - $compose_url = home_url('/'); - if (function_exists('get_pages')) { - $pages = get_pages(['meta_key' => '_wp_page_template', 'meta_value' => 'templates/pages/page-submit.php', 'number' => 1]); - if (!empty($pages[0])) { - $compose_url = get_permalink($pages[0]); - } - } - if ($compose_url === home_url('/') && function_exists('aksrt_get_user_center_url')) { - $compose_url = aksrt_get_user_center_url('posts'); - } $bio = get_user_meta($user_id, 'description', true); if (!is_string($bio) || $bio === '') { $bio = (string) $user->description; @@ -161,24 +139,13 @@ class WidgetUserCard extends \WP_Widget { } if ($show_actions && $is_self) { echo '
-
-
-
-