Skip to content

auto-append ?pretty=1 to feedwright_feed permalinks in admin context (#25)#26

Merged
mt8 merged 1 commit intomainfrom
feature/25-admin-pretty-permalink
Apr 28, 2026
Merged

auto-append ?pretty=1 to feedwright_feed permalinks in admin context (#25)#26
mt8 merged 1 commit intomainfrom
feature/25-admin-pretty-permalink

Conversation

@mt8
Copy link
Copy Markdown
Owner

@mt8 mt8 commented Apr 28, 2026

Closes #25.

Summary

管理画面コンテキスト (is_admin() 真) で 管理者 (current_user_can('manage_options')) がパーマリンクを取得する経路では、PostType::filter_permalink が返す URL に ?pretty=1 を自動付与する。これにより編集画面・投稿一覧・admin bar の「フィードを表示」リンクから整形済み XML が直接開くようになる。

フロントエンドや REST API レスポンスのパーマリンクには影響なし — 共有用の canonical URL は引き続き ?pretty=1 無しのクリーンな形のまま。仮に管理画面の URL バーから admin が ?pretty=1 入りの URL をコピーしてしまっても、FeedEndpoint::is_pretty_request() で gating されるので非管理者には minified XML が返り実害なし。

Changes

  • src/PostType.phpfilter_permalink() に admin-context 条件分岐を追加
  • tests/Integration/PostTypeTest.php:admin context で付く / front-end で付かない / 非管理者で付かない / 他の post_type に影響しない の 4 ケース追加
  • docs/requirements.md §17.3:プレビュー / 公開フローの説明に admin pretty 付与を追記

Test plan

  • Visual:管理画面の編集画面・投稿一覧・admin bar の「フィードを表示」リンク URL に ?pretty=1 が付いている
  • Visual:クリックすると整形済み XML が表示される
  • Visual:ログアウト状態 / フロントエンド経由のパーマリンクには ?pretty=1 が付かない
  • Testscomposer test:unit (72 passed)、wp-env tests (123 passed)、composer phpcs (29 passed)

トレードオフ(再確認)

  • 管理画面の URL バーに表示される Permalink にも ?pretty=1 が混じる。共有用クリーン URL が欲しい場合は手で削除する必要あり
  • 当面この挙動で OK としているが、UI で「クリーンな共有 URL」を別表示する case が出てきたら別 issue で扱う

#25)

When an admin (current_user_can('manage_options')) requests the
permalink of a feedwright_feed post in an admin context (is_admin()
true — editor / list table / admin bar), append ?pretty=1 so the
'Feed を表示' / 'View' link opens the formatted variant. Front-end
contexts and REST API responses keep the canonical clean URL. Even
if a ?pretty=1 URL leaks to a non-admin, FeedEndpoint::is_pretty_request
gates it server-side and the response is the normal minified XML.

- src/PostType.php: condition added inside filter_permalink
- tests/Integration/PostTypeTest.php: cover admin-context add, frontend
  no-add, non-admin no-add, and untouched non-feedwright_feed posts
- docs/requirements.md §17.3 prose update
@mt8 mt8 merged commit f9d7983 into main Apr 28, 2026
7 checks passed
@mt8 mt8 deleted the feature/25-admin-pretty-permalink branch April 28, 2026 10:11
@mt8 mt8 mentioned this pull request Apr 28, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feedwright_feed の admin 経由パーマリンクに ?pretty=1 を自動付与する

1 participant