'avatar']); if ($placeholder === '') { $placeholder = __('说点什么吧...', 'aksrt'); } $html = '
'; $html .= '
'; $html .= $avatar; $html .= '
' . esc_html($placeholder) . '
'; $html .= '
'; $html .= '' . esc_html__('提交', 'aksrt') . ''; $html .= '
'; 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 $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 = '' . esc_html__('链接', 'aksrt') . ''; $dropdown = ''; 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 .= '
' . esc_html((string) $p) . '
'; } if ($sys_lists === '') { $sys_lists = '
' . esc_html__('系统暂无快捷回复', 'aksrt') . '
'; } $but = '' . esc_html__('快捷回复', 'aksrt') . ''; $dropdown = ''; break; case 'smilie': $map = function_exists('aksrt_comment_smilie_map') ? aksrt_comment_smilie_map() : []; $smilie_icon = ''; foreach ($map as $key => $url) { $smilie_icon .= '[' . esc_attr((string) $key) . ']'; } $but = '' . esc_html__('表情', 'aksrt') . ''; $dropdown = ''; break; case 'code': $but = '' . esc_html__('代码', 'aksrt') . ''; $dropdown = ''; break; case 'image': $upload = !empty($arg1) || !empty($ctx['upload']); $but = '' . esc_html__('图片', 'aksrt') . ''; $dropdown = ''; break; default: return ''; } $con = $but . ''; return '' . $con . ''; } 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 $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;