对小工具进行了一些修复
This commit is contained in:
@@ -23,6 +23,13 @@ final class FrontendRenderer {
|
||||
}
|
||||
|
||||
AssetManager::enqueue_for($definition);
|
||||
if (in_array($definition->slug(), ['tab_posts', 'slider', 'slider_media_combo'], true)) {
|
||||
echo (string) ($args['before_widget'] ?? '');
|
||||
echo self::reference_title($instance);
|
||||
echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo (string) ($args['after_widget'] ?? '');
|
||||
return;
|
||||
}
|
||||
$classes = ['aksrt-widget', 'aksrt-panel-wrap', 'aksrt-widget--' . $definition->slug(), 'aksrt-widget--' . $definition->size()];
|
||||
if ($definition->size() === 'sidebar' && $definition->slug() !== 'user_card') {
|
||||
$classes[] = 'aksrt-panel';
|
||||
@@ -62,7 +69,7 @@ final class FrontendRenderer {
|
||||
if ($title === '') {
|
||||
return '';
|
||||
}
|
||||
$safe_title = esc_html($title);
|
||||
$safe_title = wp_kses_post($title);
|
||||
$highlight = trim((string) ($instance['title_highlight'] ?? ''));
|
||||
if ($highlight !== '') {
|
||||
$safe_highlight = esc_html($highlight);
|
||||
@@ -70,7 +77,7 @@ final class FrontendRenderer {
|
||||
}
|
||||
$html = '<header class="aksrt-widget__header' . (($instance['title_style'] ?? '') === 'big' ? ' aksrt-widget__header--big' : '') . '"><div><h2 class="aksrt-widget__title">' . nl2br($safe_title) . '</h2>';
|
||||
if (!empty($instance['subtitle'])) {
|
||||
$html .= '<p class="aksrt-widget__subtitle">' . nl2br(esc_html((string) $instance['subtitle'])) . '</p>';
|
||||
$html .= '<p class="aksrt-widget__subtitle">' . nl2br(wp_kses_post((string) $instance['subtitle'])) . '</p>';
|
||||
}
|
||||
$html .= '</div><nav class="aksrt-widget__title-links" aria-label="' . esc_attr__('模块链接', 'aksrt') . '">';
|
||||
foreach (['title_link', 'title_link2', 'title_link3'] as $index => $key) {
|
||||
@@ -83,6 +90,23 @@ final class FrontendRenderer {
|
||||
return $html . '</nav></header>';
|
||||
}
|
||||
|
||||
private static function reference_title(array $instance): string {
|
||||
$title = trim((string) ($instance['title'] ?? ''));
|
||||
if ($title === '') return '';
|
||||
$title = wp_kses_post($title);
|
||||
$highlight = trim((string) ($instance['title_highlight'] ?? ''));
|
||||
if ($highlight !== '') $title = str_replace(esc_html($highlight), '<span class="title-highlight ' . esc_attr((string) ($instance['title_highlight_color'] ?? 'focus-color')) . '">' . esc_html($highlight) . '</span>', $title);
|
||||
$subtitle = !empty($instance['subtitle']) ? wp_kses_post((string) $instance['subtitle']) : '';
|
||||
if (($instance['title_style'] ?? '') === 'big') {
|
||||
$links = '';
|
||||
foreach (['title_link', 'title_link2', 'title_link3'] as $index => $key) { $link = RendererHelpers::link((array) ($instance[$key] ?? [])); if ($link['url'] && $link['text']) $links .= '<a class="but ' . esc_attr((string) ($instance['title_link_style']['color_' . ($index + 1)] ?? '')) . '" href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) . '>' . esc_html($link['text']) . '</a>'; }
|
||||
return '<div class="big-title-wrap"><h2 class="big-title">' . $title . '</h2>' . ($subtitle ? '<p class="big-title-sub muted-2-color">' . $subtitle . '</p>' : '') . ($links ? '<div class="flex jc big-title-buts">' . $links . '</div>' : '') . '</div>';
|
||||
}
|
||||
$link = RendererHelpers::link((array) ($instance['title_link'] ?? []));
|
||||
$more = $link['url'] ? '<div class="pull-right em09 mt3"><a class="muted-2-color" href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) . '>' . esc_html($link['text'] ?: __('更多', 'aksrt')) . '</a></div>' : '';
|
||||
return '<div class="box-body notop"><div class="title-theme">' . $title . ($subtitle ? '<small class="ml10">' . $subtitle . '</small>' : '') . $more . '</div></div>';
|
||||
}
|
||||
|
||||
private static function style(array $instance): string {
|
||||
$properties = [];
|
||||
foreach (['layout_pin_pc' => 'space', 'layout_pin_m' => 'space-m'] as $key => $prefix) {
|
||||
|
||||
Reference in New Issue
Block a user