93 lines
4.3 KiB
PHP
93 lines
4.3 KiB
PHP
<?php
|
|
/**
|
|
* Comment form partials — expand toolbar (legacy DOM contract).
|
|
*
|
|
* Mirrors legacy()
|
|
* from legacy/inc/functions.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (!function_exists('aksrt_get_input_expand_but')) :
|
|
/**
|
|
* legacy-style expand toolbar button + dropdown (legacy: legacy).
|
|
*
|
|
* @param string $type code|image|link.
|
|
* @param mixed $arg1 Type-specific arg.
|
|
* @param array<string,mixed> $ctx Optional context (upload).
|
|
* @return string
|
|
*/
|
|
function aksrt_get_input_expand_but(string $type, $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 '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: 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']);
|
|
$link_s = !empty($ctx['link_enabled']);
|
|
|
|
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 ($link_s) {
|
|
echo aksrt_get_input_expand_but('link'); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
|
}
|
|
}
|
|
endif;
|