- 评论项/表单/工具栏/筛选/分页/空状态 DOM 全部替换为 zibll 原始类名 (li.comment、comt-main、comt-meta、list-inline、dropup 工具栏、 theme-pagination/pagenav、post_ajax_loader 骨架等) - 移植 zibll main.css L9412–9751 桌面 + 移动端评论样式, 缺失基础组件(title-theme/dropdown-menu/line-form/tab-nav-theme 等) 以 #comments 作用域补齐 - 删除全部 aksrt-comment__* 旧类名与旧样式,无兼容层 - JS 选择器对齐 zibll DOM:片段整块替换 #postcomments、骨架加载、 跳页输入、prepend 插入、addComment onclick 剥离, 移除 WP comment-reply enqueue 避免双 moveForm - 表情资源替换为 zibll 全套 gif(内容逐字节一致,git 无差异) - REST 后端 (CommentActions) 不变 验证:php -l 全部通过;5 个改动 JS 语法校验通过; node --test tests/widget-system/post-visual-contract.test.cjs 12/12 通过
151 lines
7.3 KiB
PHP
151 lines
7.3 KiB
PHP
<?php
|
|
/**
|
|
* Comment form partials — virtual-input + expand toolbar (Zibll DOM contract).
|
|
*
|
|
* Mirrors zib_get_respond_mobile() and zib_get_input_expand_but()
|
|
* from zibll/inc/functions.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (!function_exists('aksrt_get_comment_virtual_input_html')) :
|
|
/**
|
|
* Mobile virtual input bar (zibll: zib_get_respond_mobile).
|
|
*
|
|
* @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')) :
|
|
/**
|
|
* zibll-style expand toolbar button + dropdown (zibll: zib_get_input_expand_but).
|
|
*
|
|
* @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 (zibll 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;
|