$lines[$i], 'cn' => $lines[$i + 1]]; } } } if (!$pairs) { wp_send_json_error(['message' => __('一言内容暂不可用', 'aksrt')], 503); } wp_send_json_success($pairs[array_rand($pairs)]); } endif; if (!function_exists('aksrt_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 aksrt_render_yiyan_block(array $args = []): void { echo aksrt_get_yiyan_markup($args); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Escaped by the markup helper. } function aksrt_get_yiyan_markup(array $args = []): string { $class = trim((string) ($args['class'] ?? 'aksrt-yiyan')); if (strpos($class, 'aksrt-yiyan') === false) { $class = trim($class . ' aksrt-yiyan'); } $html = '
' . '
' . esc_html__('加载中…', 'aksrt') . '
' . '
'; return $html; } endif;