Files
wordpress-theme-aksrt/tests/widget-system/header-multifunction-render-harness.php
T
kate522andClaude Opus 5 35bb96e82f refactor: rename the theme brand and every identifier from AKSRT to Jio
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>
2026-11-01 20:05:04 +08:00

127 lines
5.7 KiB
PHP

<?php
/** Render-level harness for the header multifunction component. */
namespace Jio\Core {
final class Color {
public static function sanitize(string $value): string { return $value; }
}
}
namespace Jio\Settings {
final class Settings {
public static array $headerSlider = [];
public static function get_header_slider_settings(): array { return self::$headerSlider; }
}
}
namespace {
define('ABSPATH', __DIR__);
$GLOBALS['jio_mobile'] = false;
$GLOBALS['jio_lazy'] = true;
final class WP_Query {
public function get(string $key) { return 0; }
}
$GLOBALS['wp_query'] = new WP_Query();
function is_admin(): bool { return false; }
function wp_is_mobile(): bool { return !empty($GLOBALS['jio_mobile']); }
function is_author(): bool { return false; }
function is_front_page(): bool { return true; }
function is_category(): bool { return false; }
function is_tag(): bool { return false; }
function is_singular($type = ''): bool { return false; }
function is_search(): bool { return false; }
function is_page(): bool { return false; }
function is_home(): bool { return false; }
function get_query_var(string $key) { return ''; }
function sanitize_key($value): string { return preg_replace('/[^a-z0-9_-]/', '', strtolower((string) $value)); }
function sanitize_html_class($value): string { return preg_replace('/[^a-zA-Z0-9_-]/', '', (string) $value); }
function wp_parse_args($args, array $defaults = []): array { return array_merge($defaults, is_array($args) ? $args : []); }
function esc_url($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
function esc_url_raw($value): string { return (string) $value; }
function esc_attr($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
function esc_html($value): string { return htmlspecialchars((string) $value, ENT_QUOTES); }
function wp_strip_all_tags($value): string { return strip_tags((string) $value); }
function __($value, $domain = ''): string { return (string) $value; }
function get_bloginfo($show = ''): string { return 'Jio'; }
function home_url($path = ''): string { return 'https://example.test/' . ltrim((string) $path, '/'); }
function wp_kses($value, $allowed = []): string { return (string) $value; }
function jio_is_lazy(string $key): bool { return !empty($GLOBALS['jio_lazy']); }
function jio_get_lazy_thumb(string $size = ''): string { return 'https://example.test/placeholder.svg'; }
function jio_get_lazy_attr(string $key, string $src, string $class = '', string $lazy_src = ''): string {
if (jio_is_lazy($key)) {
return ' class="lazyload ' . esc_attr($class) . '" src="' . esc_url($lazy_src) . '" data-src="' . esc_url($src) . '"';
}
return ' class="' . esc_attr($class) . '" src="' . esc_url($src) . '"';
}
function jio_get_search_box(array $args = []): string { return '<div class="search-input">search-box</div>'; }
function jio_icon_cover_card(array $card): string {
return '<div class="icon-cover-card flex ac ' . esc_attr((string) ($card['class'] ?? '')) . '">' . esc_html((string) ($card['title'] ?? '')) . '</div>';
}
require_once dirname(__DIR__, 2) . '/inc/helpers/homepage/header-components.php';
$slides = [
['background' => 'https://example.test/slide.jpg', 'link' => ['url' => 'https://example.test/one', 'target' => '_blank', 'text' => 'One'], 'text' => ['title' => 'Title', 'desc' => 'Description'], 'image_layer' => [['image' => 'https://example.test/layer.png', 'free_size' => true, 'align' => 'right', 'parallax' => 40, 'parallax_opacity' => 80, 'parallax_scale' => 110]]],
['background_video' => 'https://example.test/background.mp4', 'background' => 'https://example.test/poster.jpg'],
['video' => 'https://example.test/content.mp4', 'background' => 'https://example.test/content-poster.jpg'],
['background' => 'https://example.test/pc-only.jpg', 'hide' => 'm'],
['background' => 'https://example.test/mobile-only.jpg', 'hide' => 'pc'],
];
$settings = [
'slides' => $slides,
'show_on_pages' => ['home'],
'show_type' => '',
'nav_color' => '#ffffff',
'slider_config' => ['loop' => true, 'autoplay' => true, 'interval' => 6, 'pagination' => true],
'search_show' => ['pc_s', 'm_s'],
'search_config' => ['before_html' => '<div>Search intro</div>'],
'card_show' => ['pc_s', 'm_s'],
'card_config' => ['show_widget_bg' => false, 'cards' => [['icon' => 'fa fas fa-star', 'title' => 'Card one']]],
'filter_blur' => ['pc_s', 'm_s'],
];
\Jio\Settings\Settings::$headerSlider = $settings;
ob_start();
jio_header_slide();
$desktop = (string) ob_get_clean();
$GLOBALS['jio_mobile'] = true;
ob_start();
jio_header_slide();
$mobile = (string) ob_get_clean();
$settings['card_config']['show_widget_bg'] = true;
\Jio\Settings\Settings::$headerSlider = $settings;
ob_start();
jio_header_slide();
$module_background = (string) ob_get_clean();
$GLOBALS['jio_mobile'] = false;
$GLOBALS['jio_lazy'] = false;
$lazy_disabled = jio_get_header_slider_markup([
'slides' => [['background' => 'https://example.test/eager.jpg']],
'class' => 'slide-index slide-header',
]);
$single_slide = jio_get_header_slider_markup([
'slides' => [['background' => 'https://example.test/single.jpg']],
'class' => 'slide-index slide-header',
'pagination' => true,
'button' => true,
]);
require_once dirname(__DIR__, 2) . '/src/Admin/PageConfigMetaBox.php';
$sanitize_cards = new \ReflectionMethod('Jio\\Admin\\PageConfigMetaBox', 'sanitize_card_options');
$page_config_save = $sanitize_cards->invoke(null, ['show_widget_bg' => true, 'cards' => []]);
echo json_encode([
'desktop' => $desktop,
'mobile' => $mobile,
'module_background' => $module_background,
'lazy_disabled' => $lazy_disabled,
'single_slide' => $single_slide,
'page_config_save' => $page_config_save,
], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}