Merge pull request 'Worktree ux depth batch49 51' (#245) from worktree-ux-depth-batch49-51 into main
Reviewed-on: CYL/wordpress-theme-aksrt#245
This commit is contained in:
@@ -2565,3 +2565,38 @@ a.main-color > .icon-cover-card:hover,
|
||||
z-index: 2;
|
||||
}
|
||||
.avatar-img.link-img img.aksrt-lazy { object-fit: cover; }
|
||||
|
||||
|
||||
/* batch49-51 residual */
|
||||
.aksrt-mod-apply-modal[hidden] { display: none !important; }
|
||||
.aksrt-mod-apply-modal {
|
||||
position: fixed; inset: 0; z-index: 10050;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.aksrt-mod-apply-modal__backdrop {
|
||||
position: absolute; inset: 0; background: rgba(15, 23, 42, .45);
|
||||
}
|
||||
.aksrt-mod-apply-modal__dialog {
|
||||
position: relative; z-index: 1; width: min(420px, calc(100vw - 32px));
|
||||
max-height: min(80vh, 560px); overflow: auto;
|
||||
padding: 16px; border-radius: 12px; background: var(--surface-1, #fff);
|
||||
box-shadow: 0 18px 50px rgba(0,0,0,.2);
|
||||
}
|
||||
.aksrt-mod-apply-modal__dialog textarea {
|
||||
width: 100%; min-height: 96px; border: 1px solid var(--color-line, #e5e7eb);
|
||||
border-radius: 8px; padding: 8px 10px; resize: vertical;
|
||||
}
|
||||
.aksrt-mod-apply-modal__dialog .js-aksrt-action-feedback.is-error { color: #ef4444; }
|
||||
.aksrt-mod-apply-modal__dialog .js-aksrt-action-feedback.is-success { color: #10b981; }
|
||||
.aksrt-mod-apply-modal__dialog .js-aksrt-action-feedback.is-loading { color: #64748b; }
|
||||
body.aksrt-mod-apply-open { overflow: hidden; }
|
||||
.aksrt-product-widget__item--list { gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-line, rgba(0,0,0,.06)); }
|
||||
.aksrt-product-widget__item--list:last-child { border-bottom: 0; }
|
||||
.aksrt-product-widget__thumb.list {
|
||||
flex: 0 0 80px; width: 80px; height: 80px; border-radius: 10px; overflow: hidden;
|
||||
background: var(--surface-2, #f3f4f6); display: block;
|
||||
}
|
||||
.aksrt-product-widget__thumb.list img { width: 100%; height: 100%; object-fit: cover; display: block; }
|
||||
.text-ellipsis-2 {
|
||||
display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
|
||||
}
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
tab_count: tabCount,
|
||||
style: style,
|
||||
paginate: paginate,
|
||||
topics: tab.getAttribute('data-topics') || '',
|
||||
limit_day: tab.getAttribute('data-limit-day') || '0',
|
||||
pay_type: tab.getAttribute('data-pay-type') || '',
|
||||
});
|
||||
var url = rest + (rest.indexOf('?') > -1 ? '&' : '?') + qs.toString();
|
||||
panel.classList.add('is-ajax-loading');
|
||||
@@ -379,6 +382,87 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function initModeratorApplyModal() {
|
||||
document.addEventListener('click', function (e) {
|
||||
var openBtn = e.target.closest('[data-aksrt-mod-apply-open]');
|
||||
if (openBtn) {
|
||||
e.preventDefault();
|
||||
var id = openBtn.getAttribute('data-aksrt-mod-apply-open');
|
||||
var modal = id ? document.getElementById(id) : null;
|
||||
if (modal) {
|
||||
modal.hidden = false;
|
||||
document.body.classList.add('aksrt-mod-apply-open');
|
||||
}
|
||||
return;
|
||||
}
|
||||
var closeBtn = e.target.closest('[data-aksrt-mod-apply-close]');
|
||||
if (closeBtn) {
|
||||
var box = closeBtn.closest('.aksrt-mod-apply-modal');
|
||||
if (box) {
|
||||
box.hidden = true;
|
||||
document.body.classList.remove('aksrt-mod-apply-open');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.js-aksrt-moderator-apply-form').forEach(function (form) {
|
||||
if (form.dataset.aksrtModApplyBound === '1') return;
|
||||
form.dataset.aksrtModApplyBound = '1';
|
||||
form.addEventListener('submit', function (event) {
|
||||
event.preventDefault();
|
||||
var boardId = parseInt(form.getAttribute('data-board-id') || '0', 10);
|
||||
var reasonField = form.querySelector('[name="reason"]');
|
||||
var reason = reasonField ? reasonField.value.trim() : '';
|
||||
var feedback = form.querySelector('.js-aksrt-action-feedback');
|
||||
var submitButton = form.querySelector('button[type="submit"]');
|
||||
if (!boardId || !reason) {
|
||||
if (feedback) {
|
||||
feedback.textContent = '请填写完整的申请理由。';
|
||||
feedback.className = 'js-aksrt-action-feedback mb10 is-error';
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (submitButton) submitButton.disabled = true;
|
||||
if (feedback) {
|
||||
feedback.textContent = '正在提交申请…';
|
||||
feedback.className = 'js-aksrt-action-feedback mb10 is-loading';
|
||||
}
|
||||
var siteUrl = (window.aksrtData && aksrtData.siteUrl) ? String(aksrtData.siteUrl).replace(/\/+$/, '') : '';
|
||||
var url = siteUrl + '/wp-json/aksrt/v1/forum/moderator/apply';
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
credentials: 'same-origin',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
'X-WP-Nonce': (window.aksrtData && aksrtData.restNonce) || '',
|
||||
},
|
||||
body: JSON.stringify({ board_id: boardId, reason: reason }),
|
||||
})
|
||||
.then(function (r) { return r.json().then(function (j) { return { ok: r.ok, j: j }; }); })
|
||||
.then(function (res) {
|
||||
if (!res.ok || (res.j && res.j.success === false)) {
|
||||
throw new Error((res.j && res.j.message) || '申请提交失败');
|
||||
}
|
||||
var msg = (res.j && (res.j.message || (res.j.data && res.j.data.message))) || '申请已提交';
|
||||
if (feedback) {
|
||||
feedback.textContent = msg;
|
||||
feedback.className = 'js-aksrt-action-feedback mb10 is-success';
|
||||
}
|
||||
if (reasonField) reasonField.disabled = true;
|
||||
})
|
||||
.catch(function (err) {
|
||||
if (feedback) {
|
||||
feedback.textContent = (err && err.message) || '申请提交失败。';
|
||||
feedback.className = 'js-aksrt-action-feedback mb10 is-error';
|
||||
}
|
||||
if (submitButton) submitButton.disabled = false;
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function initFloatingQRCodes() {
|
||||
var wrap = document.querySelector('.float-right');
|
||||
if (!wrap) return;
|
||||
@@ -424,6 +508,7 @@
|
||||
initProductTabs();
|
||||
initMainPostsLazy();
|
||||
initFeatureIntro();
|
||||
initModeratorApplyModal();
|
||||
initFloatingQRCodes();
|
||||
}
|
||||
|
||||
|
||||
@@ -93,7 +93,10 @@ class WidgetAjax {
|
||||
'orderby' => sanitize_key((string) ($request->get_param('orderby') ?? 'date')),
|
||||
'count' => max(0, min(20, (int) ($request->get_param('tab_count') ?? 0))),
|
||||
'enabled' => true,
|
||||
];
|
||||
|
||||
'topics' => sanitize_text_field((string) ($request->get_param('topics') ?? '')),
|
||||
'limit_day' => max(0, (int) ($request->get_param('limit_day') ?? 0)),
|
||||
'pay_type' => sanitize_key((string) ($request->get_param('pay_type') ?? '')),];
|
||||
$opts = [
|
||||
'style' => $style,
|
||||
'paginate' => $paginate,
|
||||
|
||||
@@ -38,7 +38,9 @@ class CustomHtmlGapWidget extends \WP_Widget {
|
||||
if (trim(wp_strip_all_tags($content)) === '' && trim($content) === '') {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '<div class="c-red muted-box mb10"><b>' . esc_html__('自定义 HTML:', 'aksrt') . '</b>' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '</div>';
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('请填写 HTML 内容或切换为间距模式', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<div class="c-red muted-box mb10"><b>' . esc_html__('自定义 HTML:', 'aksrt') . '</b>' . esc_html__('请填写内容或切换为间距模式', 'aksrt') . '</div>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -107,6 +107,9 @@ class TabPostsWidget extends \WP_Widget {
|
||||
'count' => max(1, min(30, $count)),
|
||||
'orderby' => sanitize_key((string) ($tab['orderby'] ?? 'date')),
|
||||
'cat' => absint($tab['category_id'] ?? 0),
|
||||
'topics' => sanitize_text_field((string) ($tab['topics'] ?? '')),
|
||||
'limit_day' => max(0, (int) ($tab['limit_day'] ?? 0)),
|
||||
'pay_type' => sanitize_key((string) ($tab['pay_type'] ?? '')),
|
||||
'style' => $style,
|
||||
'show_thumb' => !isset($opts['show_thumb']) ? 1 : (int) $opts['show_thumb'],
|
||||
'show_meta' => !isset($opts['show_meta']) ? 1 : (int) $opts['show_meta'],
|
||||
@@ -213,6 +216,9 @@ class TabPostsWidget extends \WP_Widget {
|
||||
data-orderby="<?php echo esc_attr($tab['orderby']); ?>"
|
||||
data-cat="<?php echo (int) $tab['category_id']; ?>"
|
||||
data-tab-count="<?php echo (int) $tab['count']; ?>"
|
||||
data-topics="<?php echo esc_attr((string) ($tab['topics'] ?? '')); ?>"
|
||||
data-limit-day="<?php echo esc_attr((string) ((int) ($tab['limit_day'] ?? 0))); ?>"
|
||||
data-pay-type="<?php echo esc_attr((string) ($tab['pay_type'] ?? '')); ?>"
|
||||
aria-selected="<?php echo $first ? 'true' : 'false'; ?>"
|
||||
><?php echo esc_html($tab_title); ?></button>
|
||||
</li>
|
||||
@@ -295,7 +301,7 @@ class TabPostsWidget extends \WP_Widget {
|
||||
$max_tabs = 8;
|
||||
$tabs = array_slice($tabs, 0, $max_tabs);
|
||||
while (count($tabs) < 3) {
|
||||
$tabs[] = ['title' => '', 'category_id' => 0, 'orderby' => 'date', 'count' => 0, 'enabled' => false];
|
||||
$tabs[] = ['title' => '', 'category_id' => 0, 'orderby' => 'date', 'count' => 0, 'topics' => '', 'limit_day' => 0, 'pay_type' => '', 'enabled' => false];
|
||||
}
|
||||
foreach ($tabs as $i => $tab) :
|
||||
?>
|
||||
@@ -323,6 +329,23 @@ class TabPostsWidget extends \WP_Widget {
|
||||
<label><?php esc_html_e('数量(0=使用默认):', 'aksrt'); ?></label>
|
||||
<input class="tiny-text" type="number" min="0" max="20" name="<?php echo esc_attr($this->get_field_name("tabs[{$i}][count]")); ?>" value="<?php echo (int) $tab['count']; ?>">
|
||||
</p>
|
||||
<p style="margin:0 0 6px;">
|
||||
<label><?php esc_html_e('专题 topics ID(逗号):', 'aksrt'); ?></label>
|
||||
<input class="widefat" type="text" name="<?php echo esc_attr($this->get_field_name("tabs[{$i}][topics]")); ?>" value="<?php echo esc_attr((string) ($tab['topics'] ?? '')); ?>">
|
||||
</p>
|
||||
<p style="margin:0 0 6px;">
|
||||
<label><?php esc_html_e('最近 N 天(0=不限):', 'aksrt'); ?></label>
|
||||
<input class="tiny-text" type="number" min="0" name="<?php echo esc_attr($this->get_field_name("tabs[{$i}][limit_day]")); ?>" value="<?php echo (int) ($tab['limit_day'] ?? 0); ?>">
|
||||
</p>
|
||||
<p style="margin:0;">
|
||||
<label><?php esc_html_e('付费类型:', 'aksrt'); ?></label>
|
||||
<select class="widefat" name="<?php echo esc_attr($this->get_field_name("tabs[{$i}][pay_type]")); ?>">
|
||||
<option value="" <?php selected(($tab['pay_type'] ?? ''), ''); ?>><?php esc_html_e('不限', 'aksrt'); ?></option>
|
||||
<option value="paid" <?php selected(($tab['pay_type'] ?? ''), 'paid'); ?>><?php esc_html_e('任意付费', 'aksrt'); ?></option>
|
||||
<option value="reading" <?php selected(($tab['pay_type'] ?? ''), 'reading'); ?>><?php esc_html_e('付费阅读', 'aksrt'); ?></option>
|
||||
<option value="download" <?php selected(($tab['pay_type'] ?? ''), 'download'); ?>><?php esc_html_e('付费下载', 'aksrt'); ?></option>
|
||||
</select>
|
||||
</p>
|
||||
</div>
|
||||
<?php endforeach;
|
||||
}
|
||||
@@ -358,6 +381,9 @@ class TabPostsWidget extends \WP_Widget {
|
||||
'category_id' => absint($tab['category_id'] ?? 0),
|
||||
'orderby' => $orderby,
|
||||
'count' => max(0, min(20, (int) ($tab['count'] ?? 0))),
|
||||
'topics' => sanitize_text_field((string) ($tab['topics'] ?? '')),
|
||||
'limit_day' => max(0, (int) ($tab['limit_day'] ?? 0)),
|
||||
'pay_type' => sanitize_key((string) ($tab['pay_type'] ?? '')),
|
||||
'enabled' => !empty($tab['enabled']),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -22,6 +22,70 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build apply entry HTML (modal form).
|
||||
*/
|
||||
public static function render_apply_html(int $plate_id, bool $show_apply = true): string {
|
||||
if (!$show_apply || $plate_id <= 0) {
|
||||
return '';
|
||||
}
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$cuid = get_current_user_id();
|
||||
$show_always = true;
|
||||
if (function_exists('aksrt_get_setting')) {
|
||||
$show_always = (bool) aksrt_get_setting('bbs_show_apply_moderator', true);
|
||||
}
|
||||
$can_apply = $cuid > 0 && $forum && method_exists($forum, 'forum_user_can')
|
||||
? $forum->forum_user_can($cuid, 'moderator_apply')
|
||||
: ($cuid > 0);
|
||||
if (!$show_always && !$can_apply) {
|
||||
return '';
|
||||
}
|
||||
$is_mod = false;
|
||||
if ($cuid > 0 && $forum && method_exists($forum, 'is_board_moderator')) {
|
||||
$is_mod = $forum->is_board_moderator($cuid, $plate_id);
|
||||
}
|
||||
if ($is_mod || ($cuid > 0 && user_can($cuid, 'manage_options'))) {
|
||||
return '';
|
||||
}
|
||||
if ($cuid <= 0) {
|
||||
$login = function_exists('aksrt_get_login_url') ? aksrt_get_login_url(get_permalink($plate_id)) : wp_login_url(get_permalink($plate_id));
|
||||
return '<a class="but hollow c-blue p2-10 em09" href="' . esc_url($login) . '">' . esc_html__('登录后申请版主', 'aksrt') . '</a>';
|
||||
}
|
||||
$pending = false;
|
||||
if ($forum && method_exists($forum, 'get_board_moderator_applications')) {
|
||||
foreach ((array) $forum->get_board_moderator_applications($plate_id) as $app) {
|
||||
if ((int) ($app['user_id'] ?? 0) === $cuid && (string) ($app['status'] ?? '') === 'pending') {
|
||||
$pending = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($pending) {
|
||||
return '<span class="badg c-yellow hollow em09">' . esc_html__('申请审核中', 'aksrt') . '</span>';
|
||||
}
|
||||
$uid = 'aksrt-mod-apply-' . $plate_id . '-' . wp_rand(1000, 9999);
|
||||
$desc = function_exists('aksrt_get_setting') ? (string) aksrt_get_setting('bbs_apply_moderator_desc', '') : '';
|
||||
if ($desc === '') {
|
||||
$desc = __('欢迎有热情的用户申请成为版主,协助管理社区秩序。', 'aksrt');
|
||||
}
|
||||
obs_start();
|
||||
echo '<button type="button" class="but hollow c-blue p2-10 em09" data-aksrt-mod-apply-open="' . esc_attr((string) $uid) . '">' . esc_html__('申请版主', 'aksrt') . '</button>';
|
||||
echo '<div class="aksrt-mod-apply-modal" id="' . esc_attr((string) $uid) . '" hidden>';
|
||||
echo '<div class="aksrt-mod-apply-modal__backdrop" data-aksrt-mod-apply-close></div>';
|
||||
echo '<div class="aksrt-mod-apply-modal__dialog zib-widget" role="dialog" aria-modal="true">';
|
||||
echo '<div class="flex jsb ac mb10"><div class="title-theme">' . esc_html__('申请版主', 'aksrt') . '</div>';
|
||||
echo '<button type="button" class="but hollow p2-10 em09" data-aksrt-mod-apply-close aria-label="' . esc_attr__('关闭', 'aksrt') . '">×</button></div>';
|
||||
echo '<div class="muted-2-color em09 mb10">' . esc_html($desc) . '</div>';
|
||||
echo '<form class="js-aksrt-moderator-apply-form" data-board-id="' . esc_attr((string) $plate_id) . '">';
|
||||
echo '<label class="mb6 block">' . esc_html__('申请理由', 'aksrt') . '</label>';
|
||||
echo '<textarea name="reason" rows="4" class="mb10" required placeholder="' . esc_attr__('请简要说明你的社区经验、擅长领域或管理计划。', 'aksrt') . '"></textarea>';
|
||||
echo '<div class="js-aksrt-action-feedback mb10" aria-live="polite"></div>';
|
||||
echo '<button type="submit" class="but c-blue padding-lg btn-block">' . esc_html__('提交版主申请', 'aksrt') . '</button>';
|
||||
echo '</form></div></div>';
|
||||
return (string) ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{html:string}
|
||||
*/
|
||||
@@ -62,10 +126,6 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
}
|
||||
$people[] = ['id' => $mid, 'role' => 'moderator'];
|
||||
}
|
||||
if (!$people) {
|
||||
return ['html' => ''];
|
||||
}
|
||||
|
||||
$title_text = (string) ($instance['title_text'] ?? __('版主', 'aksrt'));
|
||||
$show_avatar = !isset($instance['show_avatar']) || !empty($instance['show_avatar']);
|
||||
$style = sanitize_key((string) ($instance['style'] ?? 'list'));
|
||||
@@ -73,31 +133,30 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
$style = 'list';
|
||||
}
|
||||
|
||||
$show_apply = !isset($instance['apply_btn']) || !empty($instance['apply_btn']);
|
||||
$apply_html = '';
|
||||
if ($show_apply && is_user_logged_in()) {
|
||||
$forum = class_exists('\AKSRT\Forum\Forum') ? \AKSRT\Forum\Forum::get_instance() : null;
|
||||
$cuid = get_current_user_id();
|
||||
$can_apply = $forum && method_exists($forum, 'forum_user_can')
|
||||
? $forum->forum_user_can($cuid, 'moderator_apply')
|
||||
: true;
|
||||
$is_mod = $forum && method_exists($forum, 'is_board_moderator')
|
||||
? $forum->is_board_moderator($cuid, $id)
|
||||
: in_array($cuid, array_merge([$author_id], $mods, $super), true);
|
||||
if ($can_apply && !$is_mod) {
|
||||
$apply_url = add_query_arg(['aksrt_apply_moderator' => 1, 'plate' => $id], get_permalink($id));
|
||||
$apply_html = '<a class="but hollow c-blue p2-10 em09" href="' . esc_url($apply_url) . '">' . esc_html__('申请版主', 'aksrt') . '</a>';
|
||||
$show_apply = !isset($instance['apply_btn']) || !empty($instance['apply_btn']);
|
||||
$apply_html = self::render_apply_html($id, $show_apply);
|
||||
|
||||
if (!$people && $apply_html === '') {
|
||||
if (current_user_can('manage_options')) {
|
||||
return [
|
||||
'html' => function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('当前版块暂无版主', 'aksrt'))
|
||||
: '<p class="widget-empty">' . esc_html__('当前版块暂无版主', 'aksrt') . '</p>',
|
||||
];
|
||||
}
|
||||
return ['html' => ''];
|
||||
}
|
||||
ob_start();
|
||||
echo '<div class="zib-widget moderator-box aksrt-plate-mods style-' . esc_attr($style) . ' ajax-item">';
|
||||
|
||||
obs_start();
|
||||
echo '<div class="zib-widget moderator-box aksrt-plate-mods style-' . esc_attr($style) . ' ajax-item" data-aksrt-plate-mods="1">';
|
||||
if ($title_text !== '' || $apply_html !== '') {
|
||||
echo '<div class="mb10 flex jsb ac aksrt-plate-mods__head">';
|
||||
echo $title_text !== '' ? '<div class="title-theme">' . esc_html($title_text) . '</div>' : '<div></div>';
|
||||
echo $apply_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo '</div>';
|
||||
}
|
||||
echo '<div class="aksrt-plate-mods__list">';
|
||||
if ($people) {
|
||||
echo '<div class="aksrt-plate-mods__list">';
|
||||
foreach ($people as $row) {
|
||||
$uid = (int) $row['id'];
|
||||
if (function_exists('aksrt_render_moderator_row')) {
|
||||
@@ -121,14 +180,18 @@ class WidgetForumPlateModerator extends \WP_Widget {
|
||||
}
|
||||
echo '<a class="aksrt-plate-mods__item role-' . esc_attr($row['role']) . '" href="' . esc_url($home) . '">';
|
||||
if ($show_avatar) {
|
||||
echo '<img src="' . esc_url($avatar) . '" alt="" class="aksrt-plate-mods__avatar" loading="lazy" width="40" height="40" />';
|
||||
echo '<img class="aksrt-plate-mods__avatar aksrt-lazy lazyload" data-src="' . esc_url($avatar) . '" src="' . esc_url(get_template_directory_uri() . '/assets/img/placeholder.svg') . '" alt="" loading="lazy" width="40" height="40" />';
|
||||
}
|
||||
echo '<span class="aksrt-plate-mods__name">' . esc_html($user->display_name) . '</span>';
|
||||
echo '<span class="aksrt-plate-mods__role">' . esc_html($role_label) . '</span>';
|
||||
echo '</a>';
|
||||
}
|
||||
echo '</div></div>';
|
||||
return ['html' => (string) ob_get_clean()];
|
||||
echo '</div>';
|
||||
} else {
|
||||
echo '<div class="muted-2-color em09 mb10">' . esc_html__('暂无版主,欢迎申请加入管理。', 'aksrt') . '</div>';
|
||||
}
|
||||
echo '</div>';
|
||||
return ['html' => (string) ob_get_clean()];
|
||||
}
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
|
||||
@@ -27,6 +27,13 @@ class WidgetPostsNavs extends \WP_Widget {
|
||||
|
||||
public function widget($args, $instance): void {
|
||||
if (!is_singular(['post', 'page', 'aksrt_forum_topic', 'aksrt_product'])) {
|
||||
if (current_user_can('manage_options')) {
|
||||
echo $args['before_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo function_exists('aksrt_get_widget_null')
|
||||
? aksrt_get_widget_null(__('目录树仅在文章/帖子/商品详情页显示', 'aksrt')) // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
: '<p class="widget-empty">' . esc_html__('目录树仅在详情页显示', 'aksrt') . '</p>';
|
||||
echo $args['after_widget']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,7 +94,8 @@ class WidgetProductList extends \WP_Widget {
|
||||
return '';
|
||||
}
|
||||
$oneline = $style === 'oneline';
|
||||
$mini = $style === 'mini' || $style === 'list';
|
||||
$mini = $style === 'mini';
|
||||
$list = $style === 'list';
|
||||
ob_start();
|
||||
while ($products->have_posts()) {
|
||||
$products->the_post();
|
||||
@@ -108,16 +109,18 @@ class WidgetProductList extends \WP_Widget {
|
||||
if ($oneline) {
|
||||
echo '<div class="swiper-slide ajax-item">';
|
||||
}
|
||||
if ($mini) {
|
||||
// Compact row: thumb + title + price (zibll mini shop row lite).
|
||||
echo '<div class="aksrt-product-widget__item aksrt-product-widget__item--mini ajax-item flex ac">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__thumb mini">';
|
||||
if ($mini || $list) {
|
||||
$row_cls = $list ? 'aksrt-product-widget__item aksrt-product-widget__item--list ajax-item flex ac' : 'aksrt-product-widget__item aksrt-product-widget__item--mini ajax-item flex ac';
|
||||
$thumb_cls = $list ? 'aksrt-product-widget__thumb list' : 'aksrt-product-widget__thumb mini';
|
||||
$wh = $list ? 80 : 56;
|
||||
echo '<div class="' . esc_attr($row_cls) . '">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="' . esc_attr($thumb_cls) . '">';
|
||||
if ($image !== '') {
|
||||
echo '<img class="aksrt-lazy lazyload fit-cover" data-src="' . esc_url($image) . '" src="' . esc_url($ph) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy" width="56" height="56">';
|
||||
echo '<img class="aksrt-lazy lazyload fit-cover" data-src="' . esc_url($image) . '" src="' . esc_url($ph) . '" alt="' . esc_attr(get_the_title($pid)) . '" loading="lazy" width="' . (int) $wh . '" height="' . (int) $wh . '">';
|
||||
}
|
||||
echo '</a>';
|
||||
echo '<div class="aksrt-product-widget__info flex1 min-w0">';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__title text-ellipsis">' . esc_html(get_the_title($pid)) . '</a>';
|
||||
echo '<a href="' . esc_url(get_permalink($pid)) . '" class="aksrt-product-widget__title' . ($mini ? ' text-ellipsis' : ' text-ellipsis-2') . '">' . esc_html(get_the_title($pid)) . '</a>';
|
||||
echo '<div class="aksrt-product-widget__meta flex jsb ac">';
|
||||
echo '<span class="aksrt-product-widget__price c-red">¥' . esc_html(number_format_i18n($price, 2)) . '</span>';
|
||||
if (!empty($card['sales'])) {
|
||||
|
||||
Reference in New Issue
Block a user