auto-append ?pretty=1 to feedwright_feed permalinks in admin context (#25)#26
Merged
auto-append ?pretty=1 to feedwright_feed permalinks in admin context (#25)#26
?pretty=1 to feedwright_feed permalinks in admin context (#25)#26Conversation
#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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.php:filter_permalink()に admin-context 条件分岐を追加tests/Integration/PostTypeTest.php:admin context で付く / front-end で付かない / 非管理者で付かない / 他の post_type に影響しない の 4 ケース追加docs/requirements.md§17.3:プレビュー / 公開フローの説明に admin pretty 付与を追記Test plan
?pretty=1が付いている?pretty=1が付かないcomposer test:unit(72 passed)、wp-env tests (123 passed)、composer phpcs(29 passed)トレードオフ(再確認)
?pretty=1が混じる。共有用クリーン URL が欲しい場合は手で削除する必要あり