Let hosts provide the site's admin URL for AJAX requests

Aperta
#924 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
frontend, mobile

Direzione di ricerca

Start by reading EditorConfiguration, the code that builds ajaxurl and wp.ajax.settings.url, and the iOS relay's admin-ajax.php matching logic; the issue does not name file paths or tests. Trace how WordPress-iOS and WordPress-Android provide the blog's admin_url and how EditorAuthorizationScope handles origins. Done when both platforms can pass a validated optional admin URL, the page and relay use the same value, authorization includes its origin, and the fallback remains compatible.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

[Type] Enhancement

What problem does this address?

GutenbergKit builds ajaxurl and wp.ajax.settings.url from siteURL, which is the site's home URL. When the WordPress address differs from the home URL, admin-ajax.php isn't at that path, so the editor's AJAX calls go to the wrong place. That happens when WordPress is installed in its own directory, or when its address is on another host.

Since #923, the iOS relay adds the site credential to admin-ajax.php only at that same ajaxurl. On these sites, a plugin request that uses its own, correct admin URL reaches the server without the credential. One example is Jetpack's videopressAjax.ajaxUrl, used for the videopress/video block's upload token. That block isn't registered today, and the core Video block's VideoPress uploads use REST, so they aren't affected.

What is your proposed solution?

Add an optional admin URL to EditorConfiguration on iOS and Android:

  • Fallback: when it's absent, keep today's behavior, siteURL + /wp-admin/. Hosts can adopt it independently.
  • Validation: accept it the way siteURL is accepted: an absolute http or https URL with no user name or password. Otherwise use the fallback.
  • One source: build both the page's ajaxurl and the iOS relay's admin-ajax.php match from it, so they can't disagree.
  • Authorization scope: add the admin URL's origin to EditorAuthorizationScope, as it already includes the site and API origins. The admin URL can be on another origin than the home URL, for example with FORCE_SSL_ADMIN or WordPress on its own host.
  • Hosts: WordPress-iOS and WordPress-Android supply it from the blog's admin_url option.

Open question: should GutenbergKit fall back to the site's REST index (url, the WordPress address) before siteURL, so hosts that don't set it are covered too? That costs an extra request or preload entry. Namespaced sites resolve the index locally, but their home and WordPress addresses match.

Lingua principale
JavaScript
Stelle
29
Fork
6
Merge medio
2g 1h
PR unite (30g)
76

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di wordpress-mobile/GutenbergKit

Tutte le issue di wordpress-mobile/GutenbergKit

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.