Automattic / Automattic/php-toolkit

Feature: Add Classic Editor & Standard HTML Support for Post Import/Export (PushMd)

オープン
#91 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
PHP
スター
22
フォーク
5
PR マージ指標
30日以内にマージされた PR はありません

説明

## Overview
Currently, Push MD assumes all WordPress posts use the Gutenberg Block Editor and wraps content in block comments (e.g., ``). On sites or post types where the Classic Editor is active (or where Gutenberg is disabled), importing Markdown yields block-comment markup in plain HTML editors, while exporting classic HTML posts is broken and even simple headings and lists do not convert to clean Markdown.

I understand Gutenberg is much cleaner to implement and HTML can be messy. But a lot of people still use Classic Editor or hand coded HTML.

We should support Classic Editor and non-block post types natively during both import (Markdown → HTML) and export (HTML → Markdown).

Note: I've already implemented this and will be sending a PR soon. Creating this issue for reference.

---

## Technical Plan

### 1. Editor Detection Strategy
- Introduce a helper method `is_block_editor_enabled( $post_type )` in `Push_MD_Plugin`:
- Check WordPress core's `use_block_editor_for_post_type( $post_type )` when available.
- Fall back to checking if `register_block_type` exists.
- Provide a filter `push_md_use_block_editor` allowing developers to override the decision per post type.

### 2. Markdown Consumer Wrapper (`Push_MD_Markdown_Consumer`)
- Wrap `WordPress\Markdown\MarkdownConsumer` to handle classic editor post targets _(because we may not want to modify the vendor components)_:
- When block editor is **enabled** for the target post type: delegate directly to `MarkdownConsumer` to return Gutenberg block markup.
- When block editor is **disabled** for the target post type:
- Consume Markdown via `MarkdownConsumer`.
- Strip Gutenberg block comment wrappers (e.g., `` and ``).
- Remove block-specific CSS classes (`wp-block-*`).
- Normalize excess blank lines to output clean standard HTML suitable for the Classic Editor.

### 3. Markdown Producer Wrapper (`Push_MD_Markdown_Producer`)
- Wrap `WordPress\Markdown\MarkdownProducer` to handle posts without block markup _(because we may not want to modify the vendor components)_:
- Detect whether content contains Gutenberg blocks (`has_blocks( $content )` or fallback delimiter check `

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

Push_MD_Plugin から始め、Push_MD_Markdown_Consumer と Push_MD_Markdown_Producer を通るインポート/エクスポートの経路を追跡します。指定された WordPress のエディター検出 API と Push_MD_HTML_Converter の要件を確認します。ブロックエディターの投稿が Gutenberg の動作を維持し、Classic Editor と標準 HTML の投稿がメタデータと書式を含めて両方向に正しく変換されれば完了です。

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

評価

技術スタック
php, wordpress
領域
backend, content
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
25/100

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

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