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

オープン
#924 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
42/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript
領域
frontend, mobile

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

[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.

主要言語
JavaScript
スター
29
フォーク
6
平均マージ
2日 1時間
マージ済み PR(30日)
76

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

wordpress-mobile/GutenbergKit のほかの issue

wordpress-mobile/GutenbergKit の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。