diff --git a/src/Widgets/WidgetAuthorCard.php b/src/Widgets/WidgetAuthorCard.php
index 61db9bba..d86db1ab 100644
--- a/src/Widgets/WidgetAuthorCard.php
+++ b/src/Widgets/WidgetAuthorCard.php
@@ -7,19 +7,15 @@
namespace AKSRT\Widgets;
-use AKSRT\Widgets\Traits\CommonWidgetFields;
-
defined('ABSPATH') || exit;
class WidgetAuthorCard extends \WP_Widget {
- use CommonWidgetFields;
-
public function __construct() {
parent::__construct(
'aksrt_author_card',
esc_html__('AKSRT 文章作者卡片', 'aksrt'),
[
- 'description' => esc_html__('在文章/帖子侧栏显示当前内容作者信息与更多文章。', 'aksrt'),
+ 'description' => esc_html__('在文章/帖子侧栏显示当前内容作者信息。', 'aksrt'),
'classname' => 'widget_aksrt_author_card',
]
);
@@ -46,25 +42,6 @@ class WidgetAuthorCard extends \WP_Widget {
$show_bg = !isset($instance['show_img_bg']) || !empty($instance['show_img_bg']);
$show_stats = !isset($instance['show_stats']) || !empty($instance['show_stats']);
- $show_posts = !isset($instance['show_posts']) || !empty($instance['show_posts']);
- $post_style = sanitize_key((string) ($instance['post_style'] ?? 'mini'));
- if (!in_array($post_style, ['card', 'mini'], true)) {
- // Legacy show_img checkbox from zibll.
- if (isset($instance['show_img'])) {
- $post_style = !empty($instance['show_img']) ? 'card' : 'mini';
- } else {
- $post_style = 'mini';
- }
- }
- $limit = max(0, min(12, (int) ($instance['limit'] ?? 6)));
- $orderby = sanitize_key((string) ($instance['orderby'] ?? 'date'));
- // Zibll button palettes / button_2 type (shown only when viewer is the author).
- $show_button = !isset($instance['show_button']) || !empty($instance['show_button']);
- $btn1_text = (string) ($instance['button_1_text'] ?? __('发布文章', 'aksrt'));
- $btn2_text = (string) ($instance['button_2_text'] ?? __('用户中心', 'aksrt'));
- $btn1_class = WidgetUserCard::sanitize_palette((string) ($instance['button_1_class'] ?? 'jb-pink'), 'jb-pink');
- $btn2_class = WidgetUserCard::sanitize_palette((string) ($instance['button_2_class'] ?? 'jb-blue'), 'jb-blue');
- $btn2_type = (string) ($instance['button_2'] ?? 'center');
$avatar = function_exists('aksrt_get_avatar_url')
? aksrt_get_avatar_url($author_id, ['size' => 120])
@@ -91,15 +68,10 @@ class WidgetAuthorCard extends \WP_Widget {
? aksrt_get_user_name(['id' => $author_id, 'follow' => false, 'class' => 'flex ac jc'])
: '' . esc_html($user->display_name) . '';
- $affix = function_exists('aksrt_widget_affix_attrs') ? aksrt_widget_affix_attrs($instance) : ['class' => '', 'attr' => ''];
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- $title = apply_filters('widget_title', (string) ($instance['title'] ?? ''), $instance, $this->id_base);
- if ($title !== '') {
- echo $args['before_title'] . esc_html($title) . $args['after_title']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- }
- $card_cls = 'aksrt-author-card user-card author' . ($show_bg ? ' has-cover' : '') . $affix['class'];
- echo '
';
+ $card_cls = 'aksrt-author-card user-card author' . ($show_bg ? ' has-cover' : '');
+ echo '
';
if ($show_bg) {
$bg = $cover !== '' ? ' style="background-image:url(' . esc_url($cover) . ')"' : '';
echo '
';
@@ -112,8 +84,7 @@ class WidgetAuthorCard extends \WP_Widget {
if ($bio !== '') {
echo '
' . esc_html(wp_trim_words($bio, 28)) . '
';
}
- $show_badge = !isset($instance['show_badge']) || !empty($instance['show_badge']);
- if ($show_badge && class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::public_display()) {
+ if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::public_display()) {
$wear = \AKSRT\User\Badges::get_wear($author_id);
if ($wear !== '') {
$map = \AKSRT\User\Badges::get_dictionary_map();
@@ -145,48 +116,17 @@ class WidgetAuthorCard extends \WP_Widget {
echo '
';
}
echo '
' . esc_html__('查看主页', 'aksrt') . '';
- // Zibll: button_1 / button_2 only render when the logged-in viewer IS the author.
- if ($show_button && $cuid > 0 && $cuid === $author_id) {
- $center_url = function_exists('aksrt_get_user_center_url') ? aksrt_get_user_center_url() : $home;
- $btn2_url = $btn2_type === 'home' ? $home : $center_url;
- $compose_url = $home;
- if (function_exists('aksrt_get_user_center_url')) {
- $compose_url = aksrt_get_user_center_url('posts');
- }
- echo '
' . esc_html($btn1_text) . '';
- echo '
' . esc_html($btn2_text) . '';
- }
echo '
';
echo '
'; // .user-content
- if ($show_posts && $limit > 0 && function_exists('aksrt_render_user_card_posts')) {
- echo aksrt_render_user_card_posts([ // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
- 'user_id' => $author_id,
- 'limit' => $limit,
- 'orderby' => $orderby,
- 'post_style' => $post_style,
- 'post_type' => 'post',
- 'show_empty' => true,
- ]);
- }
-
echo '';
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
public function form($instance): void {
- $post_style = sanitize_key((string) ($instance['post_style'] ?? 'mini'));
- if (!in_array($post_style, ['card', 'mini'], true)) {
- $post_style = !empty($instance['show_img']) ? 'card' : 'mini';
- }
?>
-
-
-