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

Abierto Apto para principiantes
#1,239 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
72/100
Tipo de issue
Nueva funcionalidad
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
php, wordpress

Línea de trabajo

Empieza en inc/admin.php en get_permissions_policy() y add_permission_policy(), las dos funciones nombradas en el issue, y rastrea dónde se pasa el valor de Permissions-Policy a header(). Envuelve el array de clave/valor en apply_filters() con un nombre de hook documentado, y corta el flujo antes de enviar cuando el resultado filtrado sea false, una cadena vacía o un array vacío. Hecho significa que la cabecera se puede suprimir o alterar desde un tema o plugin, y que el hook está documentado en la documentación para desarrolladores.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)

Lenguaje dominante
PHP
Estrellas
74
Forks
14
Merge medio
1 d 20 h
PR fusionados (30 d)
39

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de Codeinwp/optimole-wp

Todos los issues de Codeinwp/optimole-wp

Issues similares

Más issues de PHP

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.