feat(widgets): zibll-like in_affix sticky option across side modules

Add sidebar affix (data-affix) to ranking, user/author cards, main/hot/
paid/forum lists, comments, tag cloud, categories and text title with
shared sticky CSS.
This commit is contained in:
kate522 committed 2026-07-21 13:55:16 +08:00
1 parent 53bdd632d0
commit 93833ad381
13 files changed
+115 -12

No files matched your search

+6 -1
View File
@@ -84,13 +84,15 @@ class WidgetAuthorCard extends \WP_Widget {
? aksrt_get_user_name(['id' => $author_id, 'follow' => false, 'class' => 'flex ac jc'])
: '<a href="' . esc_url($home) . '">' . esc_html($user->display_name) . '</a>';
$in_affix = !empty($instance['in_affix']);
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
}
echo '<div class="aksrt-author-card user-card author zib-widget' . ($show_bg ? ' has-cover' : '') . '">';
$card_cls = 'aksrt-author-card user-card author zib-widget' . ($show_bg ? ' has-cover' : '') . ($in_affix ? ' is-affix' : '');
echo '<div class="' . esc_attr($card_cls) . '"' . ($in_affix ? ' data-affix="true"' : '') . '>';
if ($show_bg) {
$bg = $cover !== '' ? ' style="background-image:url(' . esc_url($cover) . ')"' : '';
echo '<div class="aksrt-author-card__cover user-cover graphic"' . $bg . '></div>';
@@ -208,6 +210,9 @@ class WidgetAuthorCard extends \WP_Widget {
</select>
</label>
</p>
<p>
<label><input type="checkbox" name="<?php echo esc_attr($this->get_field_name('in_affix')); ?>" value="1" <?php checked(!empty($instance['in_affix'])); ?>> <?php esc_html_e('侧栏随动', 'aksrt'); ?></label>
</p>
<?php
}