Add WordPress filter hook to customize or disable Permissions-Policy client hint headers

未关闭 适合新手
#1,239 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
php, wordpress

调研方向

从 inc/admin.php 中的 get_permissions_policy() 和 add_permission_policy() 开始,这两个函数在 issue 中被点名,并追踪 Permissions-Policy 的值在哪里被传给 header()。用有文档记录的 hook 名称将键/值数组包在 apply_filters() 中,并在过滤后的结果为 false、空字符串或空数组时,在发送前短路。完成意味着该 header 可以从主题或插件中被抑制或修改,并且该 hook 已写入开发者文档。

由索引模型根据 Issue 内容生成。

描述

customer report feature-request-triage

Impact: 60 · Confidence: 95 · Complexity: 20

Description

Problem

The Optimole WordPress plugin automatically emits a Permissions-Policy: ch-viewport-width=(self ...) header in inc/admin.php to enable Client Hints / Smart Image Scaling. However, there is currently no WordPress filter hook wrapping this response header. Site administrators who want to remove or customize the header (for example, to prevent low-resolution image selection on cached pages or mobile viewports where text density is critical) must write custom code to strip headers late in execution, which is fragile and prone to breaking during plugin updates.

Desired Behavior

Expose a WordPress filter hook (e.g. optimole_permissions_policy_header or optml_permissions_policy) allowing developers to filter the header key/value array or disable the Permissions-Policy header completely before it is sent via header().

Acceptance Criteria
  • Introduce a WordPress filter hook surrounding the generation/output of the Permissions-Policy header in inc/admin.php.
  • Returning false, an empty string, or an empty array from the filter suppresses the header from being sent.
  • Document the filter hook for site developers in technical/developer docs.

Customer Context

John Green (Founder & CEO at Fighting Arts Health Lab, starter-2 paid subscriber) observed that client hints were sending smaller 414px images to mobile viewports, which rendered text inside card images visibly soft/blurry on high-density mobile screens. To fix this, his team decided to strip the ch-viewport-width Permissions-Policy header. Because Optimole currently has no filter hook on get_permissions_policy() / add_permission_policy() in inc/admin.php, they were forced to strip the header with custom code after Optimole sends it. He requested a supported filter or setting so custom header modifications won't break on plugin updates.

Root Cause Analysis

The customer's underlying goal is to control whether Optimole sends the Permissions-Policy Client Hint header without having to write fragile post-header removal scripts. Optimole's inc/admin.php sends hardcoded header directives without passing them through WordPress apply_filters(). Providing a developer filter hook directly addresses this capability gap in a standard WordPress-idiomatic way.


Source: HelpScout #3513913699
Generated by feature-request-triage workflow (ID: feature-request-triage_6af9bb9d556245.38695477)

主要语言
PHP
星标
74
派生
14
平均合并
1 天 20 小时
30 天内合并 PR
39

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Codeinwp/optimole-wp 的其他 Issue

查看 Codeinwp/optimole-wp 的全部 Issue

相似的 Issue

更多 PHP Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。