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

Đang mở
#924 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript
Lĩnh vực
frontend, mobile

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
JavaScript
Star
29
Fork
6
Merge trung bình
2 ngày 1 giờ
Pull request đã merge (30 ngày)
76

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của wordpress-mobile/GutenbergKit

Tất cả issue của wordpress-mobile/GutenbergKit

Issue tương tự

Thêm issue về JavaScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.