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>
76 lines
2.6 KiB
PHP
76 lines
2.6 KiB
PHP
<?php
|
|
/**
|
|
* 一言 (Hitokoto) markup helper.
|
|
*
|
|
* Shared shell for single-post placements and the yiyan widget.
|
|
*
|
|
* @package Jio
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
add_action('wp_ajax_jio_yiyan', 'jio_ajax_yiyan');
|
|
add_action('wp_ajax_nopriv_jio_yiyan', 'jio_ajax_yiyan');
|
|
|
|
if (!function_exists('jio_ajax_yiyan')) :
|
|
/** Return one random Chinese/English pair from the theme quote file. */
|
|
function jio_ajax_yiyan(): void {
|
|
$custom_file = WP_CONTENT_DIR . '/yiyan.txt';
|
|
$theme_file = get_template_directory() . '/yiyan/qv-yiyan.txt';
|
|
$file = is_readable($custom_file) ? $custom_file : $theme_file;
|
|
$lines = is_readable($file) ? file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) : false;
|
|
$pairs = [];
|
|
|
|
if (is_array($lines)) {
|
|
// The first line is the reference file's title; the rest alternate EN/CN.
|
|
array_shift($lines);
|
|
$lines = array_values(array_map('trim', $lines));
|
|
for ($i = 0, $length = count($lines); $i + 1 < $length; $i += 2) {
|
|
if ($lines[$i] !== '' && $lines[$i + 1] !== '') {
|
|
$pairs[] = ['en' => $lines[$i], 'cn' => $lines[$i + 1]];
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!$pairs) {
|
|
wp_send_json_error(['message' => __('一言内容暂不可用', 'jio')], 503);
|
|
}
|
|
|
|
wp_send_json_success($pairs[array_rand($pairs)]);
|
|
}
|
|
endif;
|
|
|
|
if (!function_exists('jio_render_yiyan_block')) :
|
|
/**
|
|
* Shared 一言 shell for single-post placements (and reusable markup).
|
|
*
|
|
* Reads bilingual pairs from the bundled reference file and supports the
|
|
* same optional wp-content/yiyan.txt override used by the reference theme.
|
|
*
|
|
* @param array<string,mixed> $args {
|
|
* @type string $class Extra CSS classes on the root.
|
|
* }
|
|
*/
|
|
function jio_render_yiyan_block(array $args = []): void {
|
|
echo jio_get_yiyan_markup($args); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped by the markup helper.
|
|
}
|
|
function jio_get_yiyan_markup(array $args = []): string {
|
|
$class = trim((string) ($args['class'] ?? 'jio-yiyan'));
|
|
|
|
if (strpos($class, 'jio-yiyan') === false) {
|
|
$class = trim($class . ' jio-yiyan');
|
|
}
|
|
$html = '<div class="' . esc_attr($class) . '"'
|
|
. ' data-jio-yiyan'
|
|
. ' data-endpoint="' . esc_url(admin_url('admin-ajax.php')) . '"'
|
|
. ' data-toggle="tooltip"'
|
|
. ' title="' . esc_attr__('点击切换一言', 'jio') . '"'
|
|
. ' role="button" tabindex="0"'
|
|
. ' aria-label="' . esc_attr__('点击切换一言', 'jio') . '"'
|
|
. ' aria-live="polite">'
|
|
. '<div class="yiyan"><div class="en"></div><div class="cn">' . esc_html__('加载中…', 'jio') . '</div></div>'
|
|
. '</div>';
|
|
return $html;
|
|
}
|
|
endif;
|