评论区硬切换实现
This commit is contained in:
1 parent
ed914d2eec
commit
b8ef4d81a4
32 files changed
+946
-1008
No files matched your search
@@ -39,9 +39,9 @@ if (!function_exists('aksrt_get_input_expand_but')) :
|
||||
/**
|
||||
* legacy-style expand toolbar button + dropdown (legacy: legacy).
|
||||
*
|
||||
* @param string $type code|image|quick|link.
|
||||
* @param string $type code|image|link.
|
||||
* @param mixed $arg1 Type-specific arg.
|
||||
* @param array<string,mixed> $ctx Optional context (upload, phrases).
|
||||
* @param array<string,mixed> $ctx Optional context (upload).
|
||||
* @return string
|
||||
*/
|
||||
function aksrt_get_input_expand_but(string $type, $arg1 = null, array $ctx = []): string {
|
||||
@@ -59,25 +59,6 @@ if (!function_exists('aksrt_get_input_expand_but')) :
|
||||
$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 '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">';
|
||||
@@ -114,15 +95,14 @@ endif;
|
||||
|
||||
if (!function_exists('aksrt_render_comment_expand_toolbar')) :
|
||||
/**
|
||||
* Render left-side expand tools based on settings (legacy order: code/image/link/quick).
|
||||
* 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']);
|
||||
$phrases = is_array($ctx['quick_phrases'] ?? null) ? $ctx['quick_phrases'] : [];
|
||||
$quick_s = !isset($ctx['quick_s']) || !empty($ctx['quick_s']);
|
||||
$link_s = !empty($ctx['link_enabled']);
|
||||
|
||||
if (!empty($toolbar['code'])) {
|
||||
echo aksrt_get_input_expand_but('code'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
@@ -130,8 +110,8 @@ if (!function_exists('aksrt_render_comment_expand_toolbar')) :
|
||||
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
|
||||
if ($link_s) {
|
||||
echo aksrt_get_input_expand_but('link'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
}
|
||||
}
|
||||
endif;
|
||||
Reference in new issue
Block a user