Strona główna (static front page) z PostX/Kadence nie serwuje Markdown #1

Open
opened 2026-02-15 12:49:46 +00:00 by roman · 0 comments
Owner

Problem

Strona główna webporadnik.pl (static front page, ID 2421, typ page) nie zwraca Markdown przy ?format=md ani przez Accept: text/markdown. Zwraca normalny HTML.

Diagnoza

Headery z curl -sI 'https://webporadnik.pl/?format=md':

  • Content-Type: text/html; charset=UTF-8 — plugin nie zadziałał
  • Vary: User-Agent — brak Vary: Accept od pluginu
  • Brak X-Markdown-Tokenshandle_markdown_request() nie został wykonany lub nie trafił w żaden warunek

Konfiguracja:

  • Strona główna to statyczna strona (page) ustawiona w Ustawienia → Czytanie
  • Strona zbudowana przez PostX Site Builder + bloki Kadence Post Grid
  • Treść strony (REST API) zawiera Gutenberg blocks (Kadence postgrid, grupy, nagłówki)

Co już sprawdzono

  1. Priorytet template_redirect zmieniony z 5 na 0 — nie pomogło (commit 11ea481)
  2. $_GET['format'] fallback — już istnieje (commit ce8f9c0), is_markdown_requested() działa poprawnie
  3. PostX przechwytuje rendering — PostX Site Builder prawdopodobnie hookuje się na template_redirect lub template_include i wywołuje exit przed pluginem, LUB...
  4. is_singular() zwraca false na static front page — WordPress może nie traktować static front page jako is_singular() w kontekście PostX template override

Potrzebna diagnostyka

Dodać debug logging na początku handle_markdown_request():

error_log('MDFA debug: markdown_requested=' . (self::is_markdown_requested() ? 'yes' : 'no'));
error_log('MDFA debug: is_singular=' . (is_singular() ? 'yes' : 'no'));
error_log('MDFA debug: is_front_page=' . (is_front_page() ? 'yes' : 'no'));
$obj = get_queried_object();
error_log('MDFA debug: obj_class=' . (is_object($obj) ? get_class($obj) : 'null'));

Możliwe scenariusze:

  • A) Metoda nie jest wywoływana → PostX exit przed hookiem
  • B) is_singular() = false → potrzebna dodatkowa obsługa is_front_page()
  • C) get_queried_object() = null → potrzebny fallback na get_option('page_on_front')

Możliwe rozwiązania

  1. Dodać explicit obsługę is_front_page() w handle_markdown_request()
  2. Użyć get_post(get_option('page_on_front')) jako fallback gdy get_queried_object() nie zwraca WP_Post
  3. Przenieść logikę na wcześniejszy hook (np. parse_request lub wp)
  4. Sprawdzić czy template_include filter zadziała lepiej niż template_redirect action

Pliki

  • markdown-for-agents/includes/class-content-negotiation.phphandle_markdown_request() linia 30
## Problem Strona główna webporadnik.pl (static front page, ID 2421, typ `page`) nie zwraca Markdown przy `?format=md` ani przez `Accept: text/markdown`. Zwraca normalny HTML. ## Diagnoza **Headery z `curl -sI 'https://webporadnik.pl/?format=md'`:** - `Content-Type: text/html; charset=UTF-8` — plugin nie zadziałał - `Vary: User-Agent` — brak `Vary: Accept` od pluginu - Brak `X-Markdown-Tokens` — `handle_markdown_request()` nie został wykonany lub nie trafił w żaden warunek **Konfiguracja:** - Strona główna to statyczna strona (page) ustawiona w Ustawienia → Czytanie - Strona zbudowana przez PostX Site Builder + bloki Kadence Post Grid - Treść strony (REST API) zawiera Gutenberg blocks (Kadence postgrid, grupy, nagłówki) ## Co już sprawdzono 1. **Priorytet `template_redirect` zmieniony z 5 na 0** — nie pomogło (commit 11ea481) 2. **`$_GET['format']` fallback** — już istnieje (commit ce8f9c0), `is_markdown_requested()` działa poprawnie 3. **PostX przechwytuje rendering** — PostX Site Builder prawdopodobnie hookuje się na `template_redirect` lub `template_include` i wywołuje `exit` przed pluginem, LUB... 4. **`is_singular()` zwraca `false` na static front page** — WordPress może nie traktować static front page jako `is_singular()` w kontekście PostX template override ## Potrzebna diagnostyka Dodać debug logging na początku `handle_markdown_request()`: ```php error_log('MDFA debug: markdown_requested=' . (self::is_markdown_requested() ? 'yes' : 'no')); error_log('MDFA debug: is_singular=' . (is_singular() ? 'yes' : 'no')); error_log('MDFA debug: is_front_page=' . (is_front_page() ? 'yes' : 'no')); $obj = get_queried_object(); error_log('MDFA debug: obj_class=' . (is_object($obj) ? get_class($obj) : 'null')); ``` Możliwe scenariusze: - **A)** Metoda nie jest wywoływana → PostX exit przed hookiem - **B)** `is_singular()` = false → potrzebna dodatkowa obsługa `is_front_page()` - **C)** `get_queried_object()` = null → potrzebny fallback na `get_option('page_on_front')` ## Możliwe rozwiązania 1. Dodać explicit obsługę `is_front_page()` w `handle_markdown_request()` 2. Użyć `get_post(get_option('page_on_front'))` jako fallback gdy `get_queried_object()` nie zwraca WP_Post 3. Przenieść logikę na wcześniejszy hook (np. `parse_request` lub `wp`) 4. Sprawdzić czy `template_include` filter zadziała lepiej niż `template_redirect` action ## Pliki - `markdown-for-agents/includes/class-content-negotiation.php` — `handle_markdown_request()` linia 30
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
roman/wordpress-markdown-for-agents#1
No description provided.