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

Open Beginner friendly
#1,239 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
php, wordpress

Research direction

Start in inc/admin.php at get_permissions_policy() and add_permission_policy(), the two functions named in the issue, and trace where the Permissions-Policy value is passed to header(). Wrap the key/value array in apply_filters() with a documented hook name, and short-circuit before sending when the filtered result is false, an empty string or an empty array. Done means the header can be suppressed or altered from a theme or plugin, and the hook is written up in the developer docs.

Written by the indexing model from the issue text.

Description

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)

Dominant language
PHP
Stars
74
Forks
14
Avg merge
1d 20h
Merged PRs (30d)
39

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Codeinwp/optimole-wp

All issues in Codeinwp/optimole-wp

Similar issues

More PHP issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.