diff --git a/env/export-content/includes/parser.php b/env/export-content/includes/parser.php index 8ca45dd2..5b56ea61 100644 --- a/env/export-content/includes/parser.php +++ b/env/export-content/includes/parser.php @@ -6,8 +6,9 @@ require_once __DIR__ . '/parsers/BasicText.php'; require_once __DIR__ . '/parsers/Button.php'; require_once __DIR__ . '/parsers/Heading.php'; +require_once __DIR__ . '/parsers/ListItem.php'; require_once __DIR__ . '/parsers/Noop.php'; -require_once __DIR__ . '/parsers/RichText.php'; +require_once __DIR__ . '/parsers/Paragraph.php'; // Unused. require_once __DIR__ . '/parsers/ShortcodeBlock.php'; @@ -21,8 +22,8 @@ class BlockParser { public function __construct() { $this->parsers = [ // Core blocks that have custom parsers. - 'core/paragraph' => new Parsers\RichText(), - 'core/list-item' => new Parsers\RichText(), + 'core/paragraph' => new Parsers\Paragraph(), + 'core/list-item' => new Parsers\ListItem(), 'core/heading' => new Parsers\Heading(), 'core/button' => new Parsers\Button(), 'core/spacer' => new Parsers\Noop(), diff --git a/env/export-content/includes/parsers/ListItem.php b/env/export-content/includes/parsers/ListItem.php new file mode 100644 index 00000000..15a55c04 --- /dev/null +++ b/env/export-content/includes/parsers/ListItem.php @@ -0,0 +1,40 @@ +get_attribute( 'placeholder', $block ); + + $matches = []; + + if ( preg_match( '/
]*>(.+)<\/p>/is'; - - if ( $block['blockName'] === 'core/list-item' ) { - $regex = '/
]*>(.+)<\/p>/is', $block['innerHTML'], $matches ) ) { if ( ! empty( $matches[1] ) ) { $strings[] = $matches[1]; } @@ -35,11 +28,6 @@ public function replace_strings( array $block, array $replacements ) : array { foreach ( $this->to_strings( $block ) as $original ) { if ( ! empty( $original ) && isset( $replacements[ $original ] ) ) { $regex = '#(
]*>)(' . preg_quote( $original, '/' ) . ')(<\/p>)#is'; - - if ( $block['blockName'] === 'core/list-item' ) { - $regex = '#(