Full-project rename. `git grep -i aksrt` is now empty apart from the
DBMigrator 3.3.0 changelog note that documents the rename itself.
Code identifiers
- PHP namespace AKSRT\ -> Jio\ (composer PSR-4 + 378 declarations)
- global constants AKSRT_* -> JIO_* (VERSION/DIR/URI, PAY_TYPE_*, CAPTCHA_*)
- procedural functions, hooks, options, meta keys, table names,
cookies, query vars, ajax actions and nonces: aksrt_ -> jio_
- text domain aksrt -> jio; Theme Name -> Jio
- JS globals: aksrtData/aksrtAdminData/... -> jioData/jioAdminData/...,
window.AKSRTCaptcha & friends -> window.JioCaptcha, Aksrt* -> Jio*
- Vue components Aks*.vue -> Jio*.vue (15 files renamed + imports)
- CSS classes/data-attrs/custom properties: aksrt- -> jio-
- REST namespace aksrt/v1 -> jio/v1 (incl. payment gateway callbacks)
Storage layer
- DB tables {prefix}aksrt_* -> {prefix}jio_*; SCHEMA_VERSION 3.2.0 -> 3.3.0
so dbDelta creates the new names on install
- widget id_base aksrt_widget_* -> jio_widget_*
- uninstall.php drop list rebuilt from the actual migrator tables
(dropped 3 stale entries, added the 17 missing ones)
Removed
- hardcoded https://api.aksrt.com/version.json default update endpoint;
get_endpoint() now reads the 「更新端点」 setting and do_check() no-ops
when it is empty
Files renamed: inc/helpers/aksrt-*.php -> jio-*.php (54),
assets/admin/src/components/form/Aks*.vue -> Jio*.vue (15).
Build artifacts regenerated: assets/css/build, assets/js/runtime,
assets/admin/build.
Verified: audit-psr4-paths errors=0, audit-admin-contracts errors=0
(warnings=56, unchanged baseline), 813/813 widget-system tests,
44/44 phpunit, php -l clean across all PHP.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
122 lines
7.5 KiB
PHP
122 lines
7.5 KiB
PHP
<?php
|
|
|
|
namespace Jio\WidgetSystem\Renderers;
|
|
|
|
use Jio\WidgetSystem\RendererHelpers;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
/** Render the seven knowledge-product presentation widgets. */
|
|
final class KnowledgeProductRenderer {
|
|
public static function render(string $slug, array $instance, array $context = []): string {
|
|
switch ($slug) {
|
|
case 'pricing_plans': return self::pricing($instance);
|
|
case 'reviews': return self::reviews($instance);
|
|
case 'faq': return self::faq($instance);
|
|
case 'stats': return self::stats($instance);
|
|
case 'highlights': return self::highlights($instance);
|
|
case 'feature_intro': return self::feature_intro($instance, $context);
|
|
case 'tilt_cases': return self::tilt($instance);
|
|
}
|
|
return '';
|
|
}
|
|
|
|
private static function pricing(array $i): string {
|
|
$html = '<div class="jio-widget-grid jio-pricing" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
|
foreach ((array) $i['plans'] as $plan) {
|
|
if (!is_array($plan)) {
|
|
continue;
|
|
}
|
|
$url = '';
|
|
$label = __('立即了解', 'jio');
|
|
if (($plan['cta_type'] ?? 'link') === 'post' && !empty($plan['post_id'])) {
|
|
$url = (string) get_permalink((int) $plan['post_id']);
|
|
$label = __('查看付费内容', 'jio');
|
|
} elseif (($plan['cta_type'] ?? 'link') === 'vip') {
|
|
$url = function_exists('jio_get_user_center_url') ? jio_get_user_center_url('vip') : home_url('/');
|
|
$url = add_query_arg('level', (int) ($plan['vip_level'] ?? 1), $url);
|
|
$label = __('开通会员', 'jio');
|
|
} else {
|
|
$link = RendererHelpers::link((array) ($plan['link'] ?? []));
|
|
$url = $link['url'];
|
|
$label = $link['text'] ?: $label;
|
|
}
|
|
$html .= '<article class="jio-pricing-card' . (!empty($plan['featured']) ? ' is-featured' : '') . '">';
|
|
if (!empty($plan['featured'])) {
|
|
$html .= '<span class="jio-pricing-card__badge">' . esc_html__('推荐', 'jio') . '</span>';
|
|
}
|
|
$html .= '<h3>' . esc_html((string) ($plan['title'] ?? '')) . '</h3><div class="jio-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="fa fas fa-check" aria-hidden="true"></i>' . esc_html($feature) . '</li>';
|
|
}
|
|
$html .= '</ul>' . ($url !== '' ? '<a class="jio-widget-button" href="' . esc_url($url) . '">' . esc_html($label) . '</a>' : '') . '</article>';
|
|
}
|
|
return $html . '</div>';
|
|
}
|
|
|
|
private static function reviews(array $i): string {
|
|
$slides = '';
|
|
foreach ((array) $i['items'] as $item) {
|
|
if (!is_array($item)) {
|
|
continue;
|
|
}
|
|
$rating = max(1, min(5, (int) ($item['rating'] ?? 5)));
|
|
$slides .= '<div class="swiper-slide"><article class="jio-review-card"><div class="jio-review-card__rating" aria-label="' . esc_attr(sprintf(__('%d 星评价', 'jio'), $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'] ?? ''), '', 'jio-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="new-swiper jio-widget-swiper jio-reviews" data-jio-swiper="cards"><div class="swiper-wrapper">' . $slides . '</div><div class="swiper-pagination"></div></div>';
|
|
}
|
|
|
|
private static function faq(array $i): string {
|
|
$html = '<div class="jio-faq">';
|
|
if (!empty($i['search'])) {
|
|
$html .= '<label class="jio-faq__search"><i class="fa fas fa-search" aria-hidden="true"></i><span class="screen-reader-text">' . esc_html__('搜索常见问题', 'jio') . '</span><input type="search" placeholder="' . esc_attr__('搜索问题', 'jio') . '"></label>';
|
|
}
|
|
$html .= '<div class="jio-faq__items">';
|
|
foreach ((array) $i['items'] as $index => $item) {
|
|
$id = 'jio-faq-' . $index . '-' . wp_rand(1000, 9999);
|
|
$html .= '<section class="jio-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>';
|
|
}
|
|
|
|
private static function stats(array $i): string {
|
|
$html = '<div class="jio-widget-grid jio-stats" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
|
foreach ((array) $i['items'] as $item) {
|
|
$html .= '<article class="jio-stat"><strong data-count-up="' . esc_attr((string) ($item['value'] ?? '')) . '">' . esc_html((string) ($item['value'] ?? '')) . '</strong><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p></article>';
|
|
}
|
|
return $html . '</div>';
|
|
}
|
|
|
|
private static function highlights(array $i): string {
|
|
$html = '<div class="jio-widget-grid jio-highlights" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
|
foreach ((array) $i['items'] as $index => $item) {
|
|
$html .= RendererHelpers::card_media((array) $item, 'jio-highlight jio-highlight--' . (($index % 5 === 0) ? 'large' : 'normal'));
|
|
}
|
|
return $html . '</div>';
|
|
}
|
|
|
|
private static function feature_intro(array $i, array $context): string {
|
|
$tabs = $panels = '';
|
|
$key = sanitize_html_class((string) ($context['widget_id'] ?? 'preview')) ?: 'preview';
|
|
foreach ((array) $i['items'] as $index => $item) {
|
|
$tab_id = 'jio-feature-' . $key . '-tab-' . $index;
|
|
$panel_id = 'jio-feature-' . $key . '-panel-' . $index;
|
|
$tabs .= '<button type="button" role="tab" id="' . esc_attr($tab_id) . '" aria-controls="' . esc_attr($panel_id) . '" data-feature-index="' . $index . '" aria-selected="' . ($index === 0 ? 'true' : 'false') . '" tabindex="' . ($index === 0 ? '0' : '-1') . '">' . esc_html((string) ($item['title'] ?? '')) . '</button>';
|
|
$features = '';
|
|
foreach (RendererHelpers::lines((string) ($item['features'] ?? '')) as $feature) {
|
|
$features .= '<li>' . esc_html($feature) . '</li>';
|
|
}
|
|
$panels .= '<article role="tabpanel" id="' . esc_attr($panel_id) . '" aria-labelledby="' . esc_attr($tab_id) . '" tabindex="0" data-feature-panel="' . $index . '"' . ($index ? ' hidden' : '') . '><div class="jio-feature-intro__media">' . RendererHelpers::card_media((array) $item) . '</div><div class="jio-feature-intro__copy"><h3>' . esc_html((string) ($item['title'] ?? '')) . '</h3><p>' . esc_html((string) ($item['description'] ?? '')) . '</p><ul>' . $features . '</ul></div></article>';
|
|
}
|
|
return '<div class="jio-feature-intro"><div class="jio-feature-intro__tabs" role="tablist" aria-label="' . esc_attr__('知识产品亮点', 'jio') . '">' . $tabs . '</div><div class="jio-feature-intro__panels">' . $panels . '</div></div>';
|
|
}
|
|
|
|
private static function tilt(array $i): string {
|
|
$html = '<div class="jio-widget-grid jio-tilt-cases" style="--jio-cols:' . (int) $i['pc_row'] . ';--jio-cols-m:' . (int) $i['m_row'] . '">';
|
|
foreach ((array) $i['items'] as $item) {
|
|
$html .= '<div class="jio-tilt-case" data-jio-tilt data-tilt-max="9" data-tilt-speed="500">' . RendererHelpers::card_media((array) $item) . '</div>';
|
|
}
|
|
return $html . '</div>';
|
|
}
|
|
}
|