feat(widgets): shared forum topic/plate renderers for list depth
Extract aksrt_render_forum_topic_mini/detail and plate row/card helpers, then wire TopicLists, PlateLists, and BoardList for zibll-aligned DOM, lazy thumbs, and identity-aware topic rows.
This commit is contained in:
1 parent
8b73a9443f
commit
9c5ac01119
5 files changed
+443
-42
No files matched your search
@@ -57,27 +57,44 @@ class WidgetForumBoardList extends \WP_Widget {
|
||||
$plates = get_posts($query_args);
|
||||
if ($plates) {
|
||||
ob_start();
|
||||
echo '<ul class="aksrt-forum-widget__boards style-' . esc_attr($style) . ' ajax-item">';
|
||||
foreach ($plates as $plate) {
|
||||
$icon = (string) get_post_meta($plate->ID, '_aksrt_icon', true);
|
||||
$count = (int) get_post_meta($plate->ID, '_aksrt_posts_count', true);
|
||||
$thumb = get_the_post_thumbnail_url($plate->ID, 'thumbnail');
|
||||
echo '<li class="aksrt-forum-widget__board">';
|
||||
echo '<a href="' . esc_url(get_permalink($plate)) . '">';
|
||||
if ($style === 'mini' && $thumb) {
|
||||
echo '<img class="aksrt-forum-widget__thumb" src="' . esc_url($thumb) . '" alt="" width="28" height="28" loading="lazy" />';
|
||||
} elseif ($icon !== '') {
|
||||
echo '<i class="' . esc_attr($icon) . '"></i> ';
|
||||
if ($style === 'mini' && function_exists('aksrt_render_plate_row')) {
|
||||
// Compact mini still uses shared plate row for consistent DOM/lazy.
|
||||
echo '<div class="plate-lists aksrt-forum-widget__boards style-mini ajax-item">';
|
||||
foreach ($plates as $plate) {
|
||||
echo aksrt_render_plate_row($plate); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
echo '<span class="aksrt-forum-widget__name">' . esc_html(get_the_title($plate)) . '</span>';
|
||||
echo '<span class="aksrt-forum-widget__count">' . esc_html((string) $count) . '</span>';
|
||||
echo '</a></li>';
|
||||
echo '</div>';
|
||||
} elseif (function_exists('aksrt_render_plate_row')) {
|
||||
echo '<div class="plate-lists aksrt-forum-widget__boards style-list ajax-item">';
|
||||
foreach ($plates as $plate) {
|
||||
echo aksrt_render_plate_row($plate); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<ul class="aksrt-forum-widget__boards style-' . esc_attr($style) . ' ajax-item">';
|
||||
foreach ($plates as $plate) {
|
||||
$icon = (string) get_post_meta($plate->ID, '_aksrt_icon', true);
|
||||
$count = (int) get_post_meta($plate->ID, '_aksrt_posts_count', true);
|
||||
$thumb = get_the_post_thumbnail_url($plate->ID, 'thumbnail');
|
||||
$ph = get_template_directory_uri() . '/assets/img/placeholder.svg';
|
||||
echo '<li class="aksrt-forum-widget__board">';
|
||||
echo '<a href="' . esc_url(get_permalink($plate)) . '">';
|
||||
if ($style === 'mini' && $thumb) {
|
||||
echo '<img class="aksrt-forum-widget__thumb aksrt-lazy lazyload" data-src="' . esc_url($thumb) . '" src="' . esc_url($ph) . '" alt="" width="28" height="28" loading="lazy" />';
|
||||
} elseif ($icon !== '') {
|
||||
echo '<i class="' . esc_attr($icon) . '"></i> ';
|
||||
}
|
||||
echo '<span class="aksrt-forum-widget__name">' . esc_html(get_the_title($plate)) . '</span>';
|
||||
echo '<span class="aksrt-forum-widget__count">' . esc_html((string) $count) . '</span>';
|
||||
echo '</a></li>';
|
||||
}
|
||||
echo '</ul>';
|
||||
}
|
||||
echo '</ul>';
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Taxonomy fallback.
|
||||
$term_args = [
|
||||
'taxonomy' => 'aksrt_forum_board',
|
||||
|
||||
Reference in new issue
Block a user