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>
184 lines
5.3 KiB
PHP
184 lines
5.3 KiB
PHP
<?php
|
|
/**
|
|
* One-shot generator for src/Icons/fa5-icons.php.
|
|
*
|
|
* Sources (shipped with the theme):
|
|
* - assets/fontawesome5/css/all.min.css → glyph class names + codepoints
|
|
* - assets/fontawesome5/webfonts/fa-*.woff → per-style codepoints (cmap table)
|
|
*
|
|
* Usage: php tools/generate-fa5-icons.php
|
|
*
|
|
* The style split comes from each font's own cmap subtable rather than from the
|
|
* CSS: FA5 assigns the same codepoint to different glyphs per style (e.g. far
|
|
* "address-book" and fas "address-book" are different drawings), so membership
|
|
* in fas / far / fab can only be answered by the font itself.
|
|
*/
|
|
|
|
defined('ABSPATH') || define('ABSPATH', __DIR__ . '/');
|
|
|
|
$root = dirname(__DIR__);
|
|
$css_path = $root . '/assets/fontawesome5/css/all.min.css';
|
|
$fonts_path = $root . '/assets/fontawesome5/webfonts';
|
|
$out_path = $root . '/src/Icons/fa5-icons.php';
|
|
|
|
/** Font file per style group, matching the FA5 family naming. */
|
|
const FA5_FONTS = [
|
|
'fas' => 'fa-solid-900.woff',
|
|
'far' => 'fa-regular-400.woff',
|
|
'fab' => 'fa-brands-400.woff',
|
|
];
|
|
|
|
/**
|
|
* Extract one table's uncompressed bytes from a WOFF container.
|
|
*
|
|
* WOFF stores each table zlib-deflated when compLen differs from origLen.
|
|
*/
|
|
function fa5_woff_table(string $raw, string $tag): ?string {
|
|
$num_tables = (int) (unpack('n', substr($raw, 12, 2))[1] ?? 0);
|
|
if ($num_tables < 1 || strlen($raw) < 44 + $num_tables * 20) {
|
|
return null;
|
|
}
|
|
for ($i = 0; $i < $num_tables; $i++) {
|
|
$entry = substr($raw, 44 + $i * 20, 20);
|
|
if (substr($entry, 0, 4) !== $tag) {
|
|
continue;
|
|
}
|
|
$p = unpack('Noffset/NcompLen/NorigLen', substr($entry, 4, 12));
|
|
$data = substr($raw, $p['offset'], $p['compLen']);
|
|
if ($p['compLen'] !== $p['origLen']) {
|
|
$data = gzuncompress($data);
|
|
if ($data === false) {
|
|
return null;
|
|
}
|
|
}
|
|
return $data;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Codepoints mapped by a cmap table, keyed for O(1) membership tests.
|
|
*
|
|
* Only format-4 (Unicode BMP) subtables are decoded — the (3,1) record is
|
|
* preferred, falling back to the first (3,x) then (0,x) record so a font that
|
|
* ships a different platform order still resolves.
|
|
*/
|
|
function fa5_cmap_codepoints(string $cmap): array {
|
|
$records = (int) (unpack('n', substr($cmap, 2, 2))[1] ?? 0);
|
|
$best = null;
|
|
$fallback = null;
|
|
for ($i = 0; $i < $records; $i++) {
|
|
$rec = unpack('nplatform/nencoding/Noffset', substr($cmap, 4 + $i * 8, 8));
|
|
if ($rec['platform'] === 3 && $rec['encoding'] === 1) {
|
|
$best = $rec['offset'];
|
|
break;
|
|
}
|
|
if ($fallback === null && ($rec['platform'] === 3 || $rec['platform'] === 0)) {
|
|
$fallback = $rec['offset'];
|
|
}
|
|
}
|
|
$offset = $best ?? $fallback;
|
|
if ($offset === null || $offset + 14 > strlen($cmap)) {
|
|
return [];
|
|
}
|
|
|
|
$table = substr($cmap, $offset);
|
|
$format = (int) (unpack('n', substr($table, 0, 2))[1] ?? 0);
|
|
if ($format !== 4) {
|
|
fwrite(STDERR, "Unsupported cmap format {$format}; only format 4 is decoded\n");
|
|
exit(1);
|
|
}
|
|
|
|
$seg_x2 = (int) (unpack('n', substr($table, 6, 2))[1] ?? 0);
|
|
$seg_count = intdiv($seg_x2, 2);
|
|
if ($seg_count < 1) {
|
|
return [];
|
|
}
|
|
$end_base = 14;
|
|
$start_base = $end_base + $seg_x2 + 2;
|
|
|
|
$codes = [];
|
|
for ($i = 0; $i < $seg_count; $i++) {
|
|
$start = (int) (unpack('n', substr($table, $start_base + $i * 2, 2))[1] ?? 0);
|
|
$end = (int) (unpack('n', substr($table, $end_base + $i * 2, 2))[1] ?? 0);
|
|
if ($start > $end || $end === 0xFFFF) {
|
|
continue;
|
|
}
|
|
for ($code = $start; $code <= $end; $code++) {
|
|
$codes[$code] = true;
|
|
}
|
|
}
|
|
return $codes;
|
|
}
|
|
|
|
$css = (string) file_get_contents($css_path);
|
|
|
|
// class name → codepoint (e.g. 'home' => 0xf015)
|
|
if (!preg_match_all('/\.fa-([a-z0-9-]+):before\{content:"\\\\([0-9a-f]{4})"\}/i', $css, $m, PREG_SET_ORDER)) {
|
|
fwrite(STDERR, "No glyph rules matched in all.min.css\n");
|
|
exit(1);
|
|
}
|
|
$name_to_code = [];
|
|
foreach ($m as $hit) {
|
|
$name_to_code[$hit[1]] = hexdec($hit[2]);
|
|
}
|
|
|
|
// style → set of codepoints, decoded from the shipped woff cmaps
|
|
$code_to_style = [];
|
|
foreach (FA5_FONTS as $style => $file) {
|
|
$path = $fonts_path . '/' . $file;
|
|
if (!is_readable($path)) {
|
|
fwrite(STDERR, "Missing font: {$path}\n");
|
|
exit(1);
|
|
}
|
|
$cmap = fa5_woff_table((string) file_get_contents($path), 'cmap');
|
|
if ($cmap === null) {
|
|
fwrite(STDERR, "No readable cmap table in {$path}\n");
|
|
exit(1);
|
|
}
|
|
$code_to_style[$style] = fa5_cmap_codepoints($cmap);
|
|
}
|
|
|
|
$groups = ['fas' => [], 'far' => [], 'fab' => []];
|
|
foreach ($name_to_code as $name => $code) {
|
|
foreach ($groups as $style => $unused) {
|
|
if (!empty($code_to_style[$style][$code])) {
|
|
$groups[$style][] = $name;
|
|
}
|
|
}
|
|
}
|
|
foreach ($groups as $style => $names) {
|
|
sort($groups[$style], SORT_NATURAL | SORT_FLAG_CASE);
|
|
}
|
|
|
|
$export = var_export($groups, true);
|
|
|
|
$php = <<<PHP
|
|
<?php
|
|
/**
|
|
* Font Awesome 5 Free (5.15.4) icon catalog, grouped by style.
|
|
*
|
|
* Generated by tools/generate-fa5-icons.php — do not edit by hand.
|
|
* Bare glyph names; the picker composes "fa {fas|far|fab} fa-{name}".
|
|
*
|
|
* @package Jio
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
return {$export}
|
|
PHP;
|
|
|
|
// .gitattributes declares *.php eol=crlf for the working tree; emit CRLF so the
|
|
// regenerated file matches its neighbours instead of tripping the normalize warning.
|
|
file_put_contents($out_path, str_replace("\n", "\r\n", $php . ";\n"));
|
|
|
|
printf(
|
|
"fas=%d far=%d fab=%d (css glyph classes=%d)\nWrote %s\n",
|
|
count($groups['fas']),
|
|
count($groups['far']),
|
|
count($groups['fab']),
|
|
count($name_to_code),
|
|
$out_path
|
|
);
|