` text/title. Fixed clock so the expectations are deterministic. */ declare(strict_types=1); define('ABSPATH', dirname(__DIR__, 2) . DIRECTORY_SEPARATOR); // 固定时钟:2026-11-03 12:00:00(站点时区)。 $GLOBALS['NOW'] = strtotime('2026-11-03 12:00:00'); $GLOBALS['STATUS'] = 'publish'; $GLOBALS['SOURCE'] = 'modified'; $GLOBALS['PUBLISHED'] = strtotime('2026-10-29 08:00:00'); $GLOBALS['MODIFIED'] = strtotime('2026-10-29 08:00:00'); $GLOBALS['TIME_AGO'] = false; function __($text): string { return (string) $text; } function esc_html($value): string { return htmlspecialchars((string) $value, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } function esc_attr($value): string { return esc_html($value); } function esc_url($value): string { return (string) $value; } function esc_url_raw($value): string { return (string) $value; } function wp_kses_post($value): string { return (string) $value; } function get_the_author_meta($key) { return $key === 'ID' ? 7 : '张三'; } function get_the_author(): string { return '张三'; } function jio_get_user_home_url($id): string { return '/u/' . (int) $id; } function get_author_posts_url($id): string { return '/author/' . (int) $id; } function get_post_status($post = null): string { return $GLOBALS['STATUS']; } function get_the_time($format) { return format_time((int) $GLOBALS['PUBLISHED'], $format); } function get_the_modified_time($format) { return format_time((int) $GLOBALS['MODIFIED'], $format); } function current_time($type) { return $type === 'timestamp' ? (int) $GLOBALS['NOW'] : date('Y-m-d H:i:s', (int) $GLOBALS['NOW']); } function format_time(int $timestamp, $format) { return $format === 'U' ? (string) $timestamp : date((string) $format, $timestamp); } /** 与生产同一套相对时间规则,但以固定 NOW 为基准。 */ function jio_time_ago(string $date): string { $time = (int) strtotime($date); $diff = (int) $GLOBALS['NOW'] - $time; $days = (int) floor($diff / 86400); return $days > 0 ? $days . '天前' : '刚刚'; } function human_time_diff($from, $to = 0): string { return 'x'; } function get_the_ID(): int { return 42; } function get_current_user_id(): int { return 0; } function jio_get_user_description($id): string { return '作者简介'; } function jio_get_user_name(array $args): string { return '张三'; } function jio_get_user_follow($class, $id): string { return ''; } function jio_get_rewards_button($id, $class, $post_id): string { return ''; } function jio_get_avatar_html($id, $size, array $args): string { return ''; } function get_avatar($id, $size, $default, $alt, array $args): string { return ''; } function jio_render_rewards_template_for_user($author_id, $post_id): void {} function jio_get_post_author_city_badge_html($author_id, $class): string { return ''; } class JioSettingsStub { public static function get_post_list_style_settings(): array { return ['post_time_source' => (string) $GLOBALS['SOURCE']]; } } class_alias('JioSettingsStub', 'Jio\\Settings\\Settings'); $cases = [ 'date_updated' => ['publish', 'date', '2026-10-29 08:00:00', '2026-11-02 09:00:00'], 'modified_clean' => ['publish', 'modified', '2026-10-29 08:00:00', '2026-10-29 08:00:00'], 'modified_updated' => ['publish', 'modified', '2026-10-29 08:00:00', '2026-11-02 09:00:00'], 'draft' => ['draft', 'modified', '2026-10-29 08:00:00', '2026-11-02 09:00:00'], ]; $out = []; foreach ($cases as $name => [$status, $source, $published, $modified]) { $GLOBALS['STATUS'] = $status; $GLOBALS['SOURCE'] = $source; $GLOBALS['PUBLISHED'] = strtotime($published); $GLOBALS['MODIFIED'] = strtotime($modified); ob_start(); $args = ['show_time' => true, 'meta_html' => '']; include ABSPATH . 'templates/parts/single-author-bar.php'; $html = (string) ob_get_clean(); $text = ''; $title = ''; if (preg_match('/([^<]*)<\/span>/', $html, $m)) { $title = html_entity_decode($m[1], ENT_QUOTES | ENT_HTML5, 'UTF-8'); $text = html_entity_decode($m[2], ENT_QUOTES | ENT_HTML5, 'UTF-8'); } $out[$name] = ['text' => $text, 'title' => $title]; } echo json_encode($out, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_THROW_ON_ERROR);