'avatar-img']); 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. * * @param string $type smilie|code|image|quick|upload. * @param mixed $arg1 Type-specific. * @param array $ctx Optional context (upload enabled, phrases). */ function aksrt_get_input_expand_but(string $type = 'smilie', $arg1 = null, array $ctx = []): string { switch ($type) { case 'smilie': $map = function_exists('aksrt_comment_smilie_map') ? aksrt_comment_smilie_map() : []; $icons = ''; foreach ($map as $key => $url) { $icons .= '[' . esc_attr((string) $key) . ']'; } $but = '' . esc_html__('表情', 'aksrt') . ''; $drop = ''; return '' . $but . $drop . ''; case 'code': $but = '' . esc_html__('代码', 'aksrt') . ''; $drop = ''; return '' . $but . $drop . ''; case 'image': $upload = !empty($arg1) || !empty($ctx['upload']); $but = '' . esc_html__('图片', 'aksrt') . ''; $upload_btn = $upload ? '' : ''; $drop = ''; return '' . $but . $drop . ''; 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']; } if (empty($phrases)) { $phrases = [ __('不错,学习了', 'aksrt'), __('感谢分享', 'aksrt'), __('期待更新', 'aksrt'), ]; } $items = ''; foreach ($phrases as $p) { $items .= '' . esc_html((string) $p) . ''; } $but = '' . esc_html__('快捷', 'aksrt') . ''; $drop = ''; return '' . $but . $drop . ''; default: return ''; } } endif; if (!function_exists('aksrt_render_comment_expand_toolbar')) : /** * Render left-side expand tools based on settings. * * @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;