- assets/vendor 全量迁移: fontawesome5→assets/fontawesome5, css→assets/css, js→assets/js/runtime(避开 14 个同名自有文件), img 合并去重→assets/img, fonts→assets/fonts; 删除 assets/vendor - libs 五个与 widgets/third-party 字节相同的库不重复入库, loader paths 改指向 - 运行时切换: _win.uri=assets 根, loader baseUrl=/js/runtime, enlighter 注入 路径同步; PHP 7 个引用文件切换并改名 $zibll_*→$runtime_* - 去品牌: Qinver 头注释/品牌 console.log/演示链接清除, 默认文案中性化 - 功能标识符改名: zib__→aksrt__, zib_ajax→aksrt_ajax, window.zib→ window.aksrtLegacy, zibllblock/*→aksrtblock/*, .zib-widget→.aksrt-panel, .zib-slider→.aksrt-slider, zib_menu_options meta 键等 - 自有 CSS 改名: legacy-utilities/compat-vars/footer shell - admin SPA 重建; 契约测试同步(路径/断言/文件更名) - 例外保留: tests/visual 对照环境与 fixtures 前缀(外部 Zibll 产品引用) 验证: php -l 133 个改动文件通过; runtime 86 个 JS node --check 通过; 契约测试 68/70(2 个失败经 stash 对照确认为存量问题)
151 lines
7.3 KiB
PHP
151 lines
7.3 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 smilie|code|image|quick|link.
|
|
* @param mixed $arg1 Type-specific arg.
|
|
* @param array<string,mixed> $ctx Optional context (upload, phrases).
|
|
* @return string
|
|
*/
|
|
function aksrt_get_input_expand_but(string $type = 'smilie', $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 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 'quick':
|
|
$phrases = [];
|
|
if (is_string($arg1) && $arg1 !== '') {
|
|
$phrases = array_values(array_filter(array_map('trim', preg_split('/\r\n|\r|\n/', $arg1) ?: [])));
|
|
} elseif (!empty($ctx['quick_phrases']) && is_array($ctx['quick_phrases'])) {
|
|
$phrases = $ctx['quick_phrases'];
|
|
}
|
|
$sys_lists = '';
|
|
foreach ($phrases as $p) {
|
|
$sys_lists .= '<div class="quick-reply-item">' . esc_html((string) $p) . '</div>';
|
|
}
|
|
if ($sys_lists === '') {
|
|
$sys_lists = '<div class="text-center muted-2-color" style="margin: 60px 0;">' . esc_html__('系统暂无快捷回复', 'aksrt') . '</div>';
|
|
}
|
|
|
|
$but = '<a class="but btn-input-expand input-quick mr6" href="javascript:;"><i class="fa fa-fw fa-bolt" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('快捷回复', 'aksrt') . '</span></a>';
|
|
$dropdown = '<div class="relative dropdown-quick-often"><div class="quick-often-box scroll-y mini-scrollbar">' . $sys_lists . '</div></div>';
|
|
break;
|
|
|
|
case 'smilie':
|
|
$map = function_exists('aksrt_comment_smilie_map') ? aksrt_comment_smilie_map() : [];
|
|
$smilie_icon = '';
|
|
foreach ($map as $key => $url) {
|
|
$smilie_icon .= '<a class="smilie-icon" href="javascript:;" data-smilie="' . esc_attr((string) $key) . '"><img src="' . esc_url((string) $url) . '" alt="[' . esc_attr((string) $key) . ']" /></a>';
|
|
}
|
|
$but = '<a class="but btn-input-expand input-smilie mr6" href="javascript:;"><i class="fa fa-fw fa-smile-o" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('表情', 'aksrt') . '</span></a>';
|
|
$dropdown = '<div class="dropdown-smilie scroll-y mini-scrollbar">' . $smilie_icon . '</div>';
|
|
break;
|
|
|
|
case 'code':
|
|
$but = '<a class="but btn-input-expand input-code mr6" href="javascript:;"><i class="fa 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']);
|
|
$but = '<a class="but btn-input-expand input-image mr6" href="javascript:;"><i class="fa fa-fw fa-image" aria-hidden="true"></i><span class="hide-sm">' . esc_html__('图片', 'aksrt') . '</span></a>';
|
|
|
|
$dropdown = '<div class="dropdown-image">';
|
|
$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" 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>';
|
|
$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: smilie/code/image/link/quick).
|
|
*
|
|
* @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']);
|
|
$phrases = is_array($ctx['quick_phrases'] ?? null) ? $ctx['quick_phrases'] : [];
|
|
$quick_s = !isset($ctx['quick_s']) || !empty($ctx['quick_s']);
|
|
|
|
if (!empty($toolbar['smilie'])) {
|
|
echo aksrt_get_input_expand_but('smilie'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
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 ($quick_s) {
|
|
echo aksrt_get_input_expand_but('quick', null, ['quick_phrases' => $phrases]); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
}
|
|
endif;
|