esc_html__('展示论坛话题标签(aksrt_forum_tag)。', 'aksrt'), 'classname' => 'widget_aksrt_forum_topic_terms', ] ); } public function widget($args, $instance): void { $tax = taxonomy_exists('aksrt_forum_tag') ? 'aksrt_forum_tag' : (taxonomy_exists('aksrt_forum_topic_cat') ? 'aksrt_forum_topic_cat' : ''); if ($tax === '') { return; } $number = max(1, min(40, (int) ($instance['number'] ?? 12))); $orderby = sanitize_key((string) ($instance['orderby'] ?? 'count')); $hide_empty = !isset($instance['hide_empty']) || !empty($instance['hide_empty']); $include = $this->parse_ids((string) ($instance['include'] ?? '')); $style = sanitize_key((string) ($instance['style'] ?? 'mini')); $term_args = [ 'taxonomy' => $tax, 'number' => $number, 'hide_empty' => $hide_empty, ]; if ($include) { $term_args['include'] = $include; $term_args['orderby'] = 'include'; } else { if ($orderby === 'name') { $term_args['orderby'] = 'name'; $term_args['order'] = 'ASC'; } elseif ($orderby === 'views') { $term_args['meta_key'] = '_aksrt_views'; $term_args['orderby'] = 'meta_value_num'; $term_args['order'] = 'DESC'; } else { $term_args['orderby'] = 'count'; $term_args['order'] = 'DESC'; } } $terms = get_terms($term_args); if (is_wp_error($terms) || !$terms) { return; } 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 } $list_cls = $style === 'card' ? 'aksrt-ftag-list is-card' : 'aksrt-ftag-list is-mini'; echo '
sanitize_text_field((string) ($new_instance['title'] ?? '')), 'number' => max(1, min(40, (int) ($new_instance['number'] ?? 12))), 'orderby' => $orderby, 'style' => ($new_instance['style'] ?? '') === 'card' ? 'card' : 'mini', 'include' => sanitize_text_field((string) ($new_instance['include'] ?? '')), 'hide_empty' => !empty($new_instance['hide_empty']) ? 1 : 0, ]; } }