From 0d15a36a5790e261ddf078c95a80c09a7d87860e Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Thu, 15 Jun 2017 13:38:02 +0200 Subject: [PATCH 1/3] Update PHP parser to recognize shorthand block syntax --- lib/blocks.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/blocks.php b/lib/blocks.php index bffc2f16453968..30ac2872e11933 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -102,7 +102,7 @@ function do_blocks( $content ) { global $wp_registered_blocks; // Extract the blocks from the post content. - $open_matcher = '/).)*)-->.*?/'; + $open_matcher = '/).)*)\s*\/?-->(?:.*?)?/'; preg_match_all( $open_matcher, $content, $matches, PREG_OFFSET_CAPTURE ); $new_content = $content; From 0bf98a89c5f3c61b2d853d295ccfbc487e46aeb7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 17 Jun 2017 09:35:34 +0200 Subject: [PATCH 2/3] Improve naming of matcher variable --- lib/blocks.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/blocks.php b/lib/blocks.php index 30ac2872e11933..4f334700f12836 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -102,8 +102,8 @@ function do_blocks( $content ) { global $wp_registered_blocks; // Extract the blocks from the post content. - $open_matcher = '/).)*)\s*\/?-->(?:.*?)?/'; - preg_match_all( $open_matcher, $content, $matches, PREG_OFFSET_CAPTURE ); + $matcher = '/).)*)\s*\/?-->(?:.*?)?/'; + preg_match_all( $matcher, $content, $matches, PREG_OFFSET_CAPTURE ); $new_content = $content; foreach ( $matches[0] as $index => $block_match ) { From 578b38623dea2d9f1012b40f3e0d35a4804cf572 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Sat, 17 Jun 2017 09:35:55 +0200 Subject: [PATCH 3/3] Remove unused variable --- lib/blocks.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/blocks.php b/lib/blocks.php index 4f334700f12836..1d5692889b0913 100644 --- a/lib/blocks.php +++ b/lib/blocks.php @@ -114,7 +114,6 @@ function do_blocks( $content ) { } $block_markup = $block_match[0]; - $block_position = $block_match[1]; $block_attributes_string = $matches[2][ $index ][0]; $block_attributes = parse_block_attributes( $block_attributes_string );