diff --git a/src/Frontend/PageAdminSet.php b/src/Frontend/PageAdminSet.php
index 34f99ea1..b00117c7 100644
--- a/src/Frontend/PageAdminSet.php
+++ b/src/Frontend/PageAdminSet.php
@@ -412,13 +412,21 @@ class PageAdminSet {
return $this->render_inputs($inputs);
}
- /** AKSRT 注册的文章格式(standard + add_theme_support 注册项)。 */
+ /**
+ * 文章格式选项(1:1 对齐参考主题的固定列表)。
+ *
+ * 参考主题把标准/图像/画廊/视频四个格式写死在弹窗里,不读
+ * get_theme_support('post-formats')。本站注册的格式比参考主题多
+ * (aside/quote/link 等),动态枚举会让选项集偏离参考主题,
+ * 因此同样固定这四项。
+ */
private function post_format_options(): array {
- $options = ['standard' => __('标准', 'aksrt')];
- foreach (get_theme_support('post-formats') ? (array) get_theme_support('post-formats')[0] : [] as $format) {
- $options[$format] = esc_html(get_post_format_string($format));
- }
- return $options;
+ return [
+ 'standard' => __('标准', 'aksrt'),
+ 'image' => __('图像', 'aksrt'),
+ 'gallery' => __('画廊', 'aksrt'),
+ 'video' => __('视频', 'aksrt'),
+ ];
}
/** 分类术语的弹窗字段(对齐参考主题 tax 分支)。 */
diff --git a/tests/widget-system/frontend-page-edit-harness.php b/tests/widget-system/frontend-page-edit-harness.php
index f7790e2c..ae8b4ee2 100644
--- a/tests/widget-system/frontend-page-edit-harness.php
+++ b/tests/widget-system/frontend-page-edit-harness.php
@@ -21,6 +21,7 @@ namespace {
$GLOBALS['aksrt_set_page_templates'] = [];
$GLOBALS['aksrt_set_can'] = true;
$GLOBALS['aksrt_set_scripts'] = [];
+ $GLOBALS['aksrt_set_post_format'] = '';
function __(string $text, string $domain = ''): string { return $text; }
function esc_html__($t, $d = ''): string { return (string) $t; }
@@ -48,7 +49,7 @@ namespace {
function update_post_meta($id, $key, $value): void { $GLOBALS['aksrt_set_meta'][$key] = $value; }
function get_the_title($id): string { return '示例标题'; }
function get_the_permalink($id): string { return 'https://example.test/post'; }
- function get_post_format($id) { return ''; }
+ function get_post_format($id) { return $GLOBALS['aksrt_set_post_format'] ?? ''; }
function set_post_format($id, $format): void { $GLOBALS['aksrt_set_meta']['__format'] = $format; }
function post_type_supports($type, $feature): bool { return $feature === 'post-formats'; }
function get_theme_support($feature) { return $feature === 'post-formats' ? [['image', 'video']] : false; }
@@ -290,6 +291,29 @@ namespace {
}
set_check(strpos($modal_icons, 'class="fa fa-') === false, 'modal must not use bare FA4 icon classes');
+ // 文章格式:参考主题固定 standard/图像/画廊/视频 四项,不读主题注册集。
+ // 无格式时 WP 的 selected() 不选中任何项,浏览器默认落到第一项 standard。
+ $format_block = substr($modal_icons, (int) strpos($modal_icons, 'name="post_format"'));
+ $format_block = substr($format_block, 0, (int) strpos($format_block, ''));
+ set_check($format_block !== '', 'post inputs must include the post_format select');
+ $option_order = [];
+ preg_match_all('/