feat(navigation): hard-switch to Zibll navigation and Font Awesome 5
This commit is contained in:
@@ -54,13 +54,7 @@ final class AssetManager {
|
||||
$css = $root . '/assets/widgets/frontend.css';
|
||||
$js = $root . '/assets/widgets/frontend.js';
|
||||
wp_register_style(self::STYLE_HANDLE, $uri . '/assets/widgets/frontend.css', ['aksrt-style'], is_file($css) ? (string) filemtime($css) : null);
|
||||
wp_register_script(self::SCRIPT_HANDLE, $uri . '/assets/widgets/frontend.js', [], is_file($js) ? (string) filemtime($js) : null, true);
|
||||
if (!wp_style_is('aksrt-swiper', 'registered')) {
|
||||
wp_register_style('aksrt-swiper', $uri . '/assets/css/frontend/swiper-bundle.min.css', [], '11.2.10');
|
||||
}
|
||||
if (!wp_script_is('aksrt-swiper', 'registered')) {
|
||||
wp_register_script('aksrt-swiper', $uri . '/assets/js/swiper-bundle.min.js', [], '11.2.10', true);
|
||||
}
|
||||
wp_register_script(self::SCRIPT_HANDLE, $uri . '/assets/widgets/frontend.js', ['loader_js'], is_file($js) ? (string) filemtime($js) : null, true);
|
||||
$third_party = $uri . '/assets/widgets/third-party/';
|
||||
wp_register_script('aksrt-widget-hls', $third_party . 'hls.min.js', [], 'reference-pinned', true);
|
||||
wp_register_script('aksrt-widget-flv', $third_party . 'flv.min.js', [], 'reference-pinned', true);
|
||||
@@ -72,8 +66,7 @@ final class AssetManager {
|
||||
|
||||
private static function enqueue_optional(string $asset): void {
|
||||
if ($asset === 'swiper') {
|
||||
wp_enqueue_style('aksrt-swiper');
|
||||
wp_enqueue_script('aksrt-swiper');
|
||||
// Zibll main.js owns the single Swiper runtime and discovers .new-swiper.
|
||||
} elseif ($asset === 'dplayer') {
|
||||
wp_enqueue_script('aksrt-widget-dplayer');
|
||||
} elseif (in_array($asset, ['hls', 'flv', 'dash'], true)) {
|
||||
|
||||
@@ -74,7 +74,7 @@ final class FormRenderer {
|
||||
echo '<input class="widefat aksrt-widget-color" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '">';
|
||||
break;
|
||||
case 'icon':
|
||||
echo '<div class="aksrt-widget-icon"><i class="' . esc_attr((string) $value) . '" aria-hidden="true"></i><input class="widefat" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '" placeholder="fa fa-star"></div>';
|
||||
echo '<div class="aksrt-widget-icon"><i class="' . esc_attr((string) $value) . '" aria-hidden="true"></i><input class="widefat" type="text" id="' . esc_attr($field_id) . '" name="' . esc_attr($field_name) . '" value="' . esc_attr((string) $value) . '" placeholder="fa fas fa-star"></div>';
|
||||
break;
|
||||
case 'link':
|
||||
self::link($widget, $key, is_array($value) ? $value : []);
|
||||
|
||||
@@ -130,7 +130,7 @@ final class ContentRenderer {
|
||||
return RendererHelpers::empty_state(__('当前文章未配置付费内容', 'aksrt'));
|
||||
}
|
||||
if (function_exists('aksrt_has_paid_access') && aksrt_has_paid_access($post)) {
|
||||
$html = '<div class="aksrt-post-pay is-authorized ' . esc_attr((string) $instance['theme']) . '"><i class="fas fa-check-circle" aria-hidden="true"></i><strong>' . esc_html__('内容已解锁', 'aksrt') . '</strong><p>' . esc_html__('你已拥有当前知识内容的访问权限。', 'aksrt') . '</p>';
|
||||
$html = '<div class="aksrt-post-pay is-authorized ' . esc_attr((string) $instance['theme']) . '"><i class="fa fas fa-check-circle" aria-hidden="true"></i><strong>' . esc_html__('内容已解锁', 'aksrt') . '</strong><p>' . esc_html__('你已拥有当前知识内容的访问权限。', 'aksrt') . '</p>';
|
||||
$html .= function_exists('aksrt_get_pay_attributes_html') ? aksrt_get_pay_attributes_html($post, 'aksrt-post-pay__attrs') : '';
|
||||
$html .= function_exists('aksrt_get_demo_link_html') ? aksrt_get_demo_link_html($post, 'aksrt-widget-button') : '';
|
||||
return $html . '</div>';
|
||||
|
||||
@@ -17,20 +17,20 @@ final class GeneralRenderer {
|
||||
$action = esc_url(home_url('/'));
|
||||
$placeholder = esc_attr((string) $i['placeholder']);
|
||||
$style = sanitize_html_class((string) $i['search_style']);
|
||||
return '<form class="aksrt-widget-search aksrt-widget-search--' . $style . '" role="search" method="get" action="' . $action . '"><label><span class="screen-reader-text">' . esc_html__('搜索:', 'aksrt') . '</span><input type="search" name="s" placeholder="' . $placeholder . '" autocomplete="off"></label><button type="submit" aria-label="' . esc_attr__('搜索', 'aksrt') . '"><i class="fas fa-search" aria-hidden="true"></i><span>' . esc_html__('搜索', 'aksrt') . '</span></button></form>';
|
||||
return '<form class="aksrt-widget-search aksrt-widget-search--' . $style . '" role="search" method="get" action="' . $action . '"><label><span class="screen-reader-text">' . esc_html__('搜索:', 'aksrt') . '</span><input type="search" name="s" placeholder="' . $placeholder . '" autocomplete="off"></label><button type="submit" aria-label="' . esc_attr__('搜索', 'aksrt') . '"><i class="fa fas fa-search" aria-hidden="true"></i><span>' . esc_html__('搜索', 'aksrt') . '</span></button></form>';
|
||||
}
|
||||
|
||||
private static function render_posts_toc(array $i): string {
|
||||
if (!is_singular('post')) {
|
||||
return '';
|
||||
}
|
||||
return '<nav class="aksrt-widget-toc' . (!empty($i['collapsed']) ? ' is-collapsed' : '') . '" data-min-headings="' . (int) $i['min_headings'] . '" data-scroll-offset="' . (int) $i['offset'] . '" aria-label="' . esc_attr__('文章目录', 'aksrt') . '"><button class="aksrt-widget-toc__toggle" type="button" aria-expanded="' . (empty($i['collapsed']) ? 'true' : 'false') . '"><span>' . esc_html__('文章目录', 'aksrt') . '</span><i class="fas fa-chevron-down" aria-hidden="true"></i></button><ol class="aksrt-widget-toc__list"></ol><p class="aksrt-widget-toc__empty">' . esc_html__('正在生成目录…', 'aksrt') . '</p></nav>';
|
||||
return '<nav class="aksrt-widget-toc' . (!empty($i['collapsed']) ? ' is-collapsed' : '') . '" data-min-headings="' . (int) $i['min_headings'] . '" data-scroll-offset="' . (int) $i['offset'] . '" aria-label="' . esc_attr__('文章目录', 'aksrt') . '"><button class="aksrt-widget-toc__toggle" type="button" aria-expanded="' . (empty($i['collapsed']) ? 'true' : 'false') . '"><span>' . esc_html__('文章目录', 'aksrt') . '</span><i class="fa fas fa-chevron-down" aria-hidden="true"></i></button><ol class="aksrt-widget-toc__list"></ol><p class="aksrt-widget-toc__empty">' . esc_html__('正在生成目录…', 'aksrt') . '</p></nav>';
|
||||
}
|
||||
|
||||
private static function render_quote(array $i): string {
|
||||
$quotes = RendererHelpers::lines((string) $i['quotes']);
|
||||
$text = $quotes ? $quotes[array_rand($quotes)] : __('保持好奇,持续创造。', 'aksrt');
|
||||
return '<figure class="aksrt-widget-quote" data-source="' . esc_attr((string) $i['source']) . '" data-interval="' . (int) $i['interval'] . '"><i class="fas fa-quote-left" aria-hidden="true"></i><blockquote>' . esc_html($text) . '</blockquote><button type="button" aria-label="' . esc_attr__('换一句', 'aksrt') . '"><i class="fas fa-sync-alt" aria-hidden="true"></i></button></figure>';
|
||||
return '<figure class="aksrt-widget-quote" data-source="' . esc_attr((string) $i['source']) . '" data-interval="' . (int) $i['interval'] . '"><i class="fa fas fa-quote-left" aria-hidden="true"></i><blockquote>' . esc_html($text) . '</blockquote><button type="button" aria-label="' . esc_attr__('换一句', 'aksrt') . '"><i class="fa fas fa-sync-alt" aria-hidden="true"></i></button></figure>';
|
||||
}
|
||||
|
||||
private static function render_icon_cards(array $i): string {
|
||||
@@ -55,7 +55,7 @@ final class GeneralRenderer {
|
||||
} else {
|
||||
$link = RendererHelpers::link((array) ($card['link'] ?? []));
|
||||
$tag = $link['url'] ? 'a' : 'div';
|
||||
$html .= '<' . $tag . ' class="aksrt-widget-icon-card ' . esc_attr((string) ($card['color'] ?? '')) . '"' . ($link['url'] ? ' href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) : '') . '><i class="' . esc_attr((string) ($card['icon'] ?? 'fa fa-star')) . '" aria-hidden="true"></i><span><strong>' . esc_html((string) ($card['title'] ?? '')) . '</strong><small>' . esc_html((string) ($card['description'] ?? '')) . '</small></span></' . $tag . '>';
|
||||
$html .= '<' . $tag . ' class="aksrt-widget-icon-card ' . esc_attr((string) ($card['color'] ?? '')) . '"' . ($link['url'] ? ' href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) : '') . '><i class="' . esc_attr((string) ($card['icon'] ?? 'fa fas fa-star')) . '" aria-hidden="true"></i><span><strong>' . esc_html((string) ($card['title'] ?? '')) . '</strong><small>' . esc_html((string) ($card['description'] ?? '')) . '</small></span></' . $tag . '>';
|
||||
}
|
||||
}
|
||||
return $html . '</div>';
|
||||
@@ -201,6 +201,6 @@ final class GeneralRenderer {
|
||||
$content = '<strong>' . esc_html((string) ($item['title'] ?? '')) . '</strong><span>' . esc_html((string) ($item['description'] ?? '')) . '</span>';
|
||||
$slides .= '<div class="swiper-slide">' . ($link['url'] ? '<a href="' . $link['url'] . '"' . RendererHelpers::link_attrs($link) . '>' . $content . '</a>' : $content) . '</div>';
|
||||
}
|
||||
return '<div class="aksrt-widget-notice"><i class="fas fa-bullhorn" aria-hidden="true"></i><div class="swiper aksrt-widget-swiper" data-aksrt-swiper="notice" data-interval="' . ((int) $i['interval'] * 1000) . '"><div class="swiper-wrapper">' . $slides . '</div></div></div>';
|
||||
return '<div class="aksrt-widget-notice"><i class="fa fas fa-bullhorn" aria-hidden="true"></i><div class="new-swiper aksrt-widget-swiper" data-aksrt-swiper="notice" data-direction="vertical" data-loop="true" data-autoplay="1" data-interval="' . ((int) $i['interval'] * 1000) . '"><div class="swiper-wrapper">' . $slides . '</div></div></div>';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ final class KnowledgeProductRenderer {
|
||||
}
|
||||
$html .= '<h3>' . esc_html((string) ($plan['title'] ?? '')) . '</h3><div class="aksrt-pricing-card__price">' . esc_html((string) ($plan['price'] ?? '')) . '</div><p>' . esc_html((string) ($plan['description'] ?? '')) . '</p><ul>';
|
||||
foreach (RendererHelpers::lines((string) ($plan['features'] ?? '')) as $feature) {
|
||||
$html .= '<li><i class="fas fa-check" aria-hidden="true"></i>' . esc_html($feature) . '</li>';
|
||||
$html .= '<li><i class="fa fas fa-check" aria-hidden="true"></i>' . esc_html($feature) . '</li>';
|
||||
}
|
||||
$html .= '</ul>' . ($url !== '' ? '<a class="aksrt-widget-button" href="' . esc_url($url) . '">' . esc_html($label) . '</a>' : '') . '</article>';
|
||||
}
|
||||
@@ -61,20 +61,20 @@ final class KnowledgeProductRenderer {
|
||||
continue;
|
||||
}
|
||||
$rating = max(1, min(5, (int) ($item['rating'] ?? 5)));
|
||||
$slides .= '<div class="swiper-slide"><article class="aksrt-review-card"><div class="aksrt-review-card__rating" aria-label="' . esc_attr(sprintf(__('%d 星评价', 'aksrt'), $rating)) . '">' . str_repeat('<i class="fas fa-star" aria-hidden="true"></i>', $rating) . '</div><blockquote>' . esc_html((string) ($item['description'] ?? '')) . '</blockquote><footer>' . RendererHelpers::image((string) ($item['image'] ?? ''), '', 'aksrt-review-card__avatar') . '<span><strong>' . esc_html((string) ($item['title'] ?? '')) . '</strong><small>' . esc_html((string) ($item['value'] ?? '')) . '</small></span></footer></article></div>';
|
||||
$slides .= '<div class="swiper-slide"><article class="aksrt-review-card"><div class="aksrt-review-card__rating" aria-label="' . esc_attr(sprintf(__('%d 星评价', 'aksrt'), $rating)) . '">' . str_repeat('<i class="fa fas fa-star" aria-hidden="true"></i>', $rating) . '</div><blockquote>' . esc_html((string) ($item['description'] ?? '')) . '</blockquote><footer>' . RendererHelpers::image((string) ($item['image'] ?? ''), '', 'aksrt-review-card__avatar') . '<span><strong>' . esc_html((string) ($item['title'] ?? '')) . '</strong><small>' . esc_html((string) ($item['value'] ?? '')) . '</small></span></footer></article></div>';
|
||||
}
|
||||
return '<div class="swiper aksrt-widget-swiper aksrt-reviews" data-aksrt-swiper="cards"><div class="swiper-wrapper">' . $slides . '</div><div class="swiper-pagination"></div></div>';
|
||||
return '<div class="new-swiper aksrt-widget-swiper aksrt-reviews" data-aksrt-swiper="cards"><div class="swiper-wrapper">' . $slides . '</div><div class="swiper-pagination"></div></div>';
|
||||
}
|
||||
|
||||
private static function faq(array $i): string {
|
||||
$html = '<div class="aksrt-faq">';
|
||||
if (!empty($i['search'])) {
|
||||
$html .= '<label class="aksrt-faq__search"><i class="fas fa-search" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__('搜索常见问题', 'aksrt') . '</span><input type="search" placeholder="' . esc_attr__('搜索问题', 'aksrt') . '"></label>';
|
||||
$html .= '<label class="aksrt-faq__search"><i class="fa fas fa-search" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__('搜索常见问题', 'aksrt') . '</span><input type="search" placeholder="' . esc_attr__('搜索问题', 'aksrt') . '"></label>';
|
||||
}
|
||||
$html .= '<div class="aksrt-faq__items">';
|
||||
foreach ((array) $i['items'] as $index => $item) {
|
||||
$id = 'aksrt-faq-' . $index . '-' . wp_rand(1000, 9999);
|
||||
$html .= '<section class="aksrt-faq__item" data-search="' . esc_attr(wp_strip_all_tags((string) ($item['question'] ?? '') . ' ' . (string) ($item['answer'] ?? ''))) . '"><button type="button" aria-expanded="false" aria-controls="' . esc_attr($id) . '"><span>' . esc_html((string) ($item['question'] ?? '')) . '</span><i class="fas fa-plus" aria-hidden="true"></i></button><div id="' . esc_attr($id) . '" hidden>' . wp_kses_post((string) ($item['answer'] ?? '')) . '</div></section>';
|
||||
$html .= '<section class="aksrt-faq__item" data-search="' . esc_attr(wp_strip_all_tags((string) ($item['question'] ?? '') . ' ' . (string) ($item['answer'] ?? ''))) . '"><button type="button" aria-expanded="false" aria-controls="' . esc_attr($id) . '"><span>' . esc_html((string) ($item['question'] ?? '')) . '</span><i class="fa fas fa-plus" aria-hidden="true"></i></button><div id="' . esc_attr($id) . '" hidden>' . wp_kses_post((string) ($item['answer'] ?? '')) . '</div></section>';
|
||||
}
|
||||
return $html . '</div></div>';
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ final class SliderRenderer {
|
||||
if ($slides === '') {
|
||||
return RendererHelpers::empty_state(__('请配置幻灯片', 'aksrt'));
|
||||
}
|
||||
$slider = '<div class="swiper aksrt-widget-swiper aksrt-slider" data-aksrt-swiper="slider" data-direction="' . esc_attr((string) $instance['direction']) . '" data-effect="' . esc_attr((string) $instance['effect']) . '" data-loop="' . (!empty($instance['loop']) ? '1' : '0') . '" data-autoplay="' . (!empty($instance['autoplay']) ? '1' : '0') . '" data-interval="' . ((int) $instance['interval'] * 1000) . '" data-speed="' . (int) $instance['speed'] . '" data-space="' . (int) $instance['spacebetween'] . '" style="--aksrt-slider-height:' . (int) $instance['pc_height'] . 'px;--aksrt-slider-height-m:' . (int) $instance['m_height'] . 'px"><div class="swiper-wrapper">' . $slides . '</div>';
|
||||
$slider = '<div class="new-swiper aksrt-widget-swiper aksrt-slider" data-aksrt-swiper="slider" data-direction="' . esc_attr((string) $instance['direction']) . '" data-effect="' . esc_attr((string) $instance['effect']) . '"' . (!empty($instance['loop']) ? ' data-loop="true"' : '') . (!empty($instance['autoplay']) ? ' data-autoplay="1"' : '') . ' data-interval="' . ((int) $instance['interval'] * 1000) . '" data-speed="' . (int) $instance['speed'] . '" data-spaceBetween="' . (int) $instance['spacebetween'] . '" style="--aksrt-slider-height:' . (int) $instance['pc_height'] . 'px;--aksrt-slider-height-m:' . (int) $instance['m_height'] . 'px"><div class="swiper-wrapper">' . $slides . '</div>';
|
||||
if (!empty($instance['button'])) {
|
||||
$slider .= '<button type="button" class="swiper-button-prev" aria-label="' . esc_attr__('上一张', 'aksrt') . '"></button><button type="button" class="swiper-button-next" aria-label="' . esc_attr__('下一张', 'aksrt') . '"></button>';
|
||||
}
|
||||
|
||||
@@ -264,7 +264,7 @@ final class WidgetSchemas {
|
||||
return [
|
||||
['id' => 'title', 'type' => 'text', 'label' => '标题', 'default' => ''],
|
||||
['id' => 'description', 'type' => 'textarea', 'label' => '说明', 'default' => ''],
|
||||
['id' => 'icon', 'type' => 'icon', 'label' => '图标', 'default' => 'fa fa-star'],
|
||||
['id' => 'icon', 'type' => 'icon', 'label' => '图标', 'default' => 'fa fas fa-star'],
|
||||
['id' => 'custom_icon', 'type' => 'upload', 'label' => '自定义图标', 'default' => ''],
|
||||
['id' => 'color', 'type' => 'palette', 'label' => '颜色', 'default' => 'jb-blue', 'options' => CommonFields::palette()],
|
||||
['id' => 'link', 'type' => 'link', 'label' => '链接', 'default' => []],
|
||||
|
||||
Reference in New Issue
Block a user