主题打包的是 Font Awesome 5,solid 字形必须带样式类 fas。全站有 18 处仍写成 FA4 的裸 fa fa-*,FA5 下并不存在对应字形,表现为图标位置空白;而 FA5-only 契约此前只扫描部分运行时文件,没有覆盖模板与渲染器,这些写法一直没被拦下。 同时发现一处真实的失效图标名:profile-level.php 用的是 fa-line-chart。这是 FA4 名称,FA5 把该系列重命名为 chart-*,正确写法是 fa-chart-line。 - 18 处 "fa fa-*" 补上 fas:首页模板、组件标记、评论表单、用户等级页、菜单 装饰、SchemaPayment 促销标签默认值、VIP 服务弹窗、ContentRenderer / GeneralRenderer、后台卡片样式校验、pay-vip.js - profile-level.php 的 fa-line-chart 修正为 fa-chart-line - 三处注释里的示例值同步为合法形态("fa fas fa-star"),避免被当成正确写法 抄走;credits.css 注释中直接写出旧字体族名的一处改为描述性表述,否则会被 FA5-only 契约当作违规命中 - legacy-navigation-contract:FA 资产断言改为跟随 aksrt_enqueue_fontawesome() 这一间接层(注册点已从脚本文件移到 inc/helpers/aksrt-icons.php),并把 fa-zibsvg-<key> 识别为项目自有 SVG sprite 族,而非 Font Awesome 字形 - vip-points-exchange-modal 契约同步断言 fa fas fa-angle-right 验证:改动前在干净 HEAD 上跑 node --test(已追踪用例)为 327 项 / 325 通过 / 2 失败,两项失败正是本次修复的失效图标名断言与 FA 版本号断言;改动后 333 项 / 333 通过(含 5 个本地专用用例共 370 项全部通过)。php -l 全部改动的 PHP 文件 通过。
133 lines
6.7 KiB
PHP
133 lines
6.7 KiB
PHP
<?php
|
|
/**
|
|
* Comment form partials — virtual-input + expand toolbar (legacy DOM contract).
|
|
*
|
|
* Mirrors legacy() and legacy()
|
|
* from legacy/inc/functions.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (!function_exists('aksrt_get_comment_virtual_input_html')) :
|
|
/**
|
|
* Mobile virtual input bar (legacy: legacy).
|
|
*
|
|
* @param string $placeholder Placeholder text.
|
|
* @param string $target CSS selector for the FixedInput target.
|
|
* @return string
|
|
*/
|
|
function aksrt_get_comment_virtual_input_html(string $placeholder = '', string $target = '#respond'): string {
|
|
$user_id = get_current_user_id();
|
|
$avatar = get_avatar($user_id, 36, '', '', ['class' => 'avatar']);
|
|
if ($placeholder === '') {
|
|
$placeholder = __('说点什么吧...', 'aksrt');
|
|
}
|
|
$html = '<div class="flex ac jsb virtual-input" fixed-input="' . esc_attr($target) . '">';
|
|
$html .= '<div class="flex flex1 ac">';
|
|
$html .= $avatar;
|
|
$html .= '<div class="text-ellipsis simulation mr10">' . esc_html($placeholder) . '</div>';
|
|
$html .= '</div>';
|
|
$html .= '<span class="but c-blue">' . esc_html__('提交', 'aksrt') . '</span>';
|
|
$html .= '</div>';
|
|
return $html;
|
|
}
|
|
endif;
|
|
|
|
if (!function_exists('aksrt_get_input_expand_but')) :
|
|
/**
|
|
* legacy-style expand toolbar button + dropdown (legacy: legacy).
|
|
*
|
|
* @param string $type code|image|link.
|
|
* @param mixed $arg1 Type-specific arg.
|
|
* @param array<string,mixed> $ctx Optional context (upload).
|
|
* @return string
|
|
*/
|
|
function aksrt_get_input_expand_but(string $type, $arg1 = null, array $ctx = []): string {
|
|
$but = '';
|
|
$dropdown = '';
|
|
|
|
switch ($type) {
|
|
case 'link':
|
|
$but = '<a class="but btn-input-expand input-link mr6" href="javascript:;"><i class="fa fas fa-fw fa-link" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('链接', 'aksrt') . '</span></a>';
|
|
$dropdown = '<div class="dropdown-link">';
|
|
$dropdown .= '<p>' . esc_html__('请输入链接:', 'aksrt') . '</p>';
|
|
$dropdown .= '<p><textarea rows="2" tabindex="1" class="form-control input-textarea link-textarea" style="height:55px;" placeholder="https://..."></textarea></p>';
|
|
$dropdown .= '<p><input type="text" class="form-control link-text" placeholder="' . esc_attr__('链接文本', 'aksrt') . '"></p>';
|
|
$dropdown .= '<div class="text-right"><a type="submit" class="but c-blue pw-1em input-link-submit" href="javascript:;">' . esc_html__('确认', 'aksrt') . '</a></div>';
|
|
$dropdown .= '</div>';
|
|
break;
|
|
|
|
case 'code':
|
|
$but = '<a class="but btn-input-expand input-code mr6" href="javascript:;"><i class="fa fas fa-fw fa-code" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('代码', 'aksrt') . '</span></a>';
|
|
$dropdown = '<div class="dropdown-code">';
|
|
$dropdown .= '<p>' . esc_html__('请输入代码:', 'aksrt') . '</p>';
|
|
$dropdown .= '<p><textarea rows="6" tabindex="1" class="form-control input-textarea" placeholder="' . esc_attr__('在此处粘贴或输入代码', 'aksrt') . '"></textarea></p>';
|
|
$dropdown .= '<div class="text-right"><a type="submit" class="but c-blue pw-1em input-code-submit" href="javascript:;">' . esc_html__('确认', 'aksrt') . '</a></div>';
|
|
$dropdown .= '</div>';
|
|
break;
|
|
|
|
case 'image':
|
|
$upload = !empty($arg1) || !empty($ctx['upload']);
|
|
$upload_id = 'comment';
|
|
$but = '<a class="but btn-input-expand input-image mr6" href="javascript:;"><i class="fa fas fa-fw fa-image" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('图片', 'aksrt') . '</span></a>';
|
|
|
|
$dropdown = '<div class="tab-content comment-image-tabs">';
|
|
$dropdown .= '<div class="tab-pane fade in active dropdown-image" id="image-tab-' . esc_attr($upload_id) . '-1">';
|
|
$dropdown .= '<p>' . esc_html__('请填写图片地址:', 'aksrt') . '</p>';
|
|
$dropdown .= '<p><textarea rows="2" tabindex="1" class="form-control input-textarea input-image-url" style="height:95px;" placeholder="http://..."></textarea></p>';
|
|
$dropdown .= '<div class="text-right">';
|
|
if ($upload) {
|
|
$dropdown .= '<a class="but c-yellow mr10 pw-1em input-image-upload-tab" data-image-tab="#image-tab-' . esc_attr($upload_id) . '-2" href="javascript:;">' . esc_html__('上传图片', 'aksrt') . '</a>';
|
|
}
|
|
$dropdown .= '<a type="submit" class="but c-blue pw-1em input-image-submit" href="javascript:;">' . esc_html__('确认', 'aksrt') . '</a>';
|
|
$dropdown .= '</div></div>';
|
|
|
|
if ($upload) {
|
|
$placeholder = get_template_directory_uri() . '/assets/icons/upload-add.svg';
|
|
$dropdown .= '<div class="tab-pane fade dropdown-image" id="image-tab-' . esc_attr($upload_id) . '-2">';
|
|
$dropdown .= '<p><a class="muted-color input-image-address-tab" data-image-tab="#image-tab-' . esc_attr($upload_id) . '-1" href="javascript:;"><i class="fa fas fa-angle-left mr6" aria-hidden="true"></i>' . esc_html__('填写图片地址', 'aksrt') . '</a></p>';
|
|
$dropdown .= '<div class="form-upload comment-image-upload">';
|
|
$dropdown .= '<label class="pointer comment-image-upload-label">';
|
|
$dropdown .= '<div class="preview text-center mb6"><img src="' . esc_url($placeholder) . '" alt="" /></div>';
|
|
$dropdown .= '<input class="hide comment-image-file" type="file" id="input_' . esc_attr($upload_id) . '_image_upload" accept="image/gif,image/jpeg,image/jpg,image/png" name="image">';
|
|
$dropdown .= '</label>';
|
|
$dropdown .= '<div class="text-right"><button type="button" class="but jb-blue pw-1em input-expand-upload" data-comment-upload-submit="1">' . esc_html__('确认上传', 'aksrt') . '</button></div>';
|
|
$dropdown .= '</div></div>';
|
|
}
|
|
$dropdown .= '</div>';
|
|
break;
|
|
|
|
default:
|
|
return '';
|
|
}
|
|
|
|
$con = $but . '<div class="dropdown-menu">' . $dropdown . '</div>';
|
|
return '<span class="dropup relative ' . esc_attr($type) . '">' . $con . '</span>';
|
|
}
|
|
endif;
|
|
|
|
if (!function_exists('aksrt_render_comment_expand_toolbar')) :
|
|
/**
|
|
* Render left-side expand tools based on settings (legacy order: code/image/link).
|
|
*
|
|
* @param array<string,mixed> $ctx Comments context.
|
|
*/
|
|
function aksrt_render_comment_expand_toolbar(array $ctx): void {
|
|
$toolbar = is_array($ctx['toolbar'] ?? null) ? $ctx['toolbar'] : [];
|
|
$upload = !empty($ctx['upload_enabled']);
|
|
$link_s = !empty($ctx['link_enabled']);
|
|
|
|
if (!empty($toolbar['code'])) {
|
|
echo aksrt_get_input_expand_but('code'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
if (!empty($toolbar['image'])) {
|
|
echo aksrt_get_input_expand_but('image', $upload, ['upload' => $upload]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
if ($link_s) {
|
|
echo aksrt_get_input_expand_but('link'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
}
|
|
endif;
|