$lines[$i], 'cn' => $lines[$i + 1]]; } } } if (!$pairs) { wp_send_json_error(['message' => __('一言内容暂不可用', 'jio')], 503); } wp_send_json_success($pairs[array_rand($pairs)]); } endif; if (!function_exists('jio_render_yiyan_block')) : /** * Shared 一言 shell for single-post placements (and reusable markup). * * Reads bilingual pairs from the bundled reference file and supports the * same optional wp-content/yiyan.txt override used by the reference theme. * * @param array $args { * @type string $class Extra CSS classes on the root. * } */ function jio_render_yiyan_block(array $args = []): void { echo jio_get_yiyan_markup($args); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped by the markup helper. } function jio_get_yiyan_markup(array $args = []): string { $class = trim((string) ($args['class'] ?? 'jio-yiyan')); if (strpos($class, 'jio-yiyan') === false) { $class = trim($class . ' jio-yiyan'); } // 与参考结构一致:.yiyan 初始为空,由脚本写入 .cn(首行)与 .en(次行)。 $html = '
' . '
' . '
'; return $html; } endif;