',
+ 'html',
+ 'blocks',
+ array(
+ 'context' => array(
+ 'asset_metadata' => array(
+ 'assets/hero.jpg' => array(
+ 'id' => 42,
+ 'url' => 'https://example.test/wp-content/uploads/hero.jpg',
+ ),
+ ),
+ ),
+ )
+ );
+
+ $blocks = parse_blocks( $serialized );
+ $image = $this->first_block_named( $blocks, 'core/image' );
+
+ $this->assertNotNull( $image );
+ $this->assertSame( 42, $image['attrs']['id'] ?? null );
+ $this->assertStringContainsString( 'alt="Source alt"', $image['innerHTML'] ?? '' );
+ $this->assertStringContainsString( 'src="https://example.test/wp-content/uploads/hero.jpg"', $image['innerHTML'] ?? '' );
+ }
+
/**
* BFB should expose h2bc's expanded layout transforms through bfb_convert().
*/
@@ -1000,6 +1029,30 @@ private function flatten_blocks( array $blocks ): array {
return $names;
}
+ /**
+ * Find the first block with the requested name in a parsed block tree.
+ *
+ * @param arrayRead more.
', 'Read more.'); $ordinary_link_transform = $find_transform($ordinary_link); $smoke_assert('core/paragraph' === $ordinary_link_transform['blockName'], 'ordinary-link-stays-paragraph'); diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-address-inline-strong-br.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-address-inline-strong-br.php index 270b3d0..7bcc1ce 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-address-inline-strong-br.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-address-inline-strong-br.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-block-supports.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-block-supports.php index 5423339..44e0db1 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-block-supports.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-block-supports.php @@ -37,7 +37,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } $repo_root = \dirname(__DIR__); diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-chrome-decorative-fallbacks.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-chrome-decorative-fallbacks.php index d418550..ce64eeb 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-chrome-decorative-fallbacks.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-chrome-decorative-fallbacks.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-demo-pre-svg.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-demo-pre-svg.php index 59cd166..5a0c316 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-demo-pre-svg.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-demo-pre-svg.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-display-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-display-divs.php index 28c369e..dd77711 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-display-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-display-divs.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-window-fallback-scope.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-window-fallback-scope.php index 2039498..7a0144e 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-window-fallback-scope.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-code-window-fallback-scope.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-cta-wrapper-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-cta-wrapper-divs.php index 93e988e..a65bfda 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-cta-wrapper-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-cta-wrapper-divs.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-div-fallbacks.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-div-fallbacks.php index 13070b4..0db86ae 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-div-fallbacks.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-div-fallbacks.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-strip-marquee.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-strip-marquee.php index b936483..79974cc 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-strip-marquee.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-strip-marquee.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-visual-clusters.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-visual-clusters.php index 28fd8a0..7aab8c2 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-visual-clusters.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-decorative-visual-clusters.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-detail-br-wrapper-fallback.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-detail-br-wrapper-fallback.php index 20188ab..6da9b31 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-detail-br-wrapper-fallback.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-detail-br-wrapper-fallback.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-div-code-snippet-linebreaks.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-div-code-snippet-linebreaks.php index 0150c04..782c572 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-div-code-snippet-linebreaks.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-div-code-snippet-linebreaks.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-bem-decorative-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-bem-decorative-divs.php index 6b5ab49..91e6a46 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-bem-decorative-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-bem-decorative-divs.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-decorative-icon-placeholders.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-decorative-icon-placeholders.php index 89d1cba..079c107 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-decorative-icon-placeholders.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-decorative-icon-placeholders.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-glow-decorative-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-glow-decorative-divs.php index fbf6dfc..9cf9d90 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-glow-decorative-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-empty-glow-decorative-divs.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-info-address-contact-blocks.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-info-address-contact-blocks.php index b68afc9..e8fb904 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-info-address-contact-blocks.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-info-address-contact-blocks.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-script-fallback-scope.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-script-fallback-scope.php index b36e0d1..fb24ee3 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-script-fallback-scope.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-script-fallback-scope.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-fallback-scope.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-fallback-scope.php index 835d42d..f51eed4 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-fallback-scope.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-fallback-scope.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-icon-classification.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-icon-classification.php index 048fa8e..e4e0c5f 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-icon-classification.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-inline-svg-icon-classification.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-layout-transforms.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-layout-transforms.php index 76fa9be..0fc07dc 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-layout-transforms.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-layout-transforms.php @@ -41,7 +41,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } $repo_root = \dirname(__DIR__); diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-media-embed-transforms.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-media-embed-transforms.php index 594348f..a6597fe 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-media-embed-transforms.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-media-embed-transforms.php @@ -34,6 +34,12 @@ function sanitize_html_class($value) return \preg_replace('/[^A-Za-z0-9_-]/', '', (string) $value); } } +if (!\function_exists('BlockFormatBridge\Vendor\wp_parse_url')) { + function wp_parse_url($url, $component = -1) + { + return \parse_url($url, $component); + } +} if (!\class_exists('WP_Block_Type_Registry', \false)) { class WP_Block_Type_Registry { @@ -54,7 +60,7 @@ public function __construct() $this->blocks[$name] = (object) ['attributes' => ['src' => $source_string, 'url' => $source_string, 'alt' => $source_string, 'caption' => $source_rich, 'poster' => $source_string, 'preload' => $source_string, 'autoplay' => ['type' => 'boolean', 'source' => 'attribute'], 'controls' => ['type' => 'boolean', 'source' => 'attribute'], 'loop' => ['type' => 'boolean', 'source' => 'attribute'], 'muted' => ['type' => 'boolean', 'source' => 'attribute'], 'id' => ['type' => 'number'], 'className' => ['type' => 'string']]]; } $this->blocks['core/gallery'] = (object) ['attributes' => ['ids' => ['type' => 'array'], 'columns' => ['type' => 'number']]]; - $this->blocks['core/media-text'] = (object) ['attributes' => ['mediaUrl' => ['type' => 'string'], 'mediaAlt' => $source_string, 'mediaType' => ['type' => 'string'], 'mediaPosition' => ['type' => 'string'], 'mediaWidth' => ['type' => 'number'], 'isStackedOnMobile' => ['type' => 'boolean']]]; + $this->blocks['core/media-text'] = (object) ['attributes' => ['mediaUrl' => ['type' => 'string'], 'mediaId' => ['type' => 'number'], 'mediaAlt' => $source_string, 'mediaType' => ['type' => 'string'], 'mediaPosition' => ['type' => 'string'], 'mediaWidth' => ['type' => 'number'], 'isStackedOnMobile' => ['type' => 'boolean']]]; $this->blocks['core/file'] = (object) ['attributes' => ['href' => ['type' => 'string'], 'textLinkHref' => $source_string, 'fileName' => $source_rich, 'showDownloadButton' => ['type' => 'boolean']]]; $this->blocks['core/embed'] = (object) ['attributes' => ['url' => ['type' => 'string'], 'type' => ['type' => 'string'], 'providerNameSlug' => ['type' => 'string'], 'responsive' => ['type' => 'boolean']]]; foreach (['core/paragraph', 'core/html'] as $name) { @@ -156,7 +162,7 @@ private function matches(string $selector): bool } return null; }; -$convert = function ($element) use ($find_transform) { +$convert = function ($element, array $args = []) use ($find_transform) { $transform = $find_transform($element); if (!$transform) { return null; @@ -164,7 +170,7 @@ private function matches(string $selector): bool $handler = function () { return [HTML_To_Blocks_Block_Factory::create_block('core/paragraph', ['content' => 'Nested text'])]; }; - return \call_user_func($transform['transform'], $element, $handler); + return \call_user_func($transform['transform'], $element, $handler, $args); }; $video = $convert(new H2BC_Fake_Element('video', ['src' => 'movie.mp4', 'poster' => 'poster.jpg', 'controls' => ''])); $assert('core/video' === $video['blockName'], 'video-direct-block'); @@ -180,10 +186,22 @@ private function matches(string $selector): bool $assert(\count($gallery['innerBlocks']) === 2, 'gallery-inner-image-count'); $assert(\strpos($gallery['innerHTML'], 'wp-block-gallery') !== \false, 'gallery-wrapper-html'); $assert(\strpos($gallery['innerBlocks'][0]['innerHTML'], 'Caption A') !== \false, 'gallery-caption-preserved'); +$resolved_gallery = $convert(new H2BC_Fake_Element('div', ['class' => 'gallery columns-2'], '', [new H2BC_Fake_Element('figure', [], '', [new H2BC_Fake_Element('img', ['src' => 'a.jpg', 'alt' => 'A'])]), new H2BC_Fake_Element('figure', [], '', [new H2BC_Fake_Element('img', ['src' => 'b.jpg', 'alt' => 'B'])])]), ['context' => ['asset_metadata' => ['a.jpg' => ['id' => 101, 'url' => 'https://example.test/uploads/a.jpg'], 'b.jpg' => ['id' => 102, 'url' => 'https://example.test/uploads/b.jpg']]]]); +$assert([101, 102] === ($resolved_gallery['attrs']['ids'] ?? []), 'gallery-resolved-ids'); +$assert(\strpos($resolved_gallery['innerBlocks'][0]['innerHTML'], 'https://example.test/uploads/a.jpg') !== \false, 'gallery-resolved-image-url'); $media_text = $convert(new H2BC_Fake_Element('div', ['class' => 'wp-block-media-text'], '', [new H2BC_Fake_Element('figure', [], '', [new H2BC_Fake_Element('img', ['src' => 'hero.jpg', 'alt' => 'Hero'])]), new H2BC_Fake_Element('div', ['class' => 'wp-block-media-text__content'], 'Copy
')])); $assert('core/media-text' === $media_text['blockName'], 'media-text-block'); $assert(($media_text['attrs']['mediaUrl'] ?? '') === 'hero.jpg', 'media-text-media-url'); $assert(\count($media_text['innerBlocks']) === 1, 'media-text-inner-blocks'); +$resolved_media_text = $convert(new H2BC_Fake_Element('div', ['class' => 'wp-block-media-text'], '', [new H2BC_Fake_Element('figure', [], '', [new H2BC_Fake_Element('img', ['src' => 'hero.jpg', 'alt' => 'Hero'])]), new H2BC_Fake_Element('div', ['class' => 'wp-block-media-text__content'], 'Copy
')]), ['context' => ['asset_metadata' => ['hero.jpg' => ['id' => 201, 'url' => 'https://example.test/uploads/hero.jpg', 'alt' => 'Resolved alt']]]]); +$assert(($resolved_media_text['attrs']['mediaUrl'] ?? '') === 'https://example.test/uploads/hero.jpg', 'media-text-resolved-url'); +$assert(($resolved_media_text['attrs']['mediaId'] ?? null) === 201, 'media-text-resolved-id'); +$assert(\strpos($resolved_media_text['innerHTML'], 'alt="Hero"') !== \false, 'media-text-preserves-source-alt'); +$resolved_image = $convert(new H2BC_Fake_Element('img', ['src' => 'product.jpg', 'alt' => 'Product', 'width' => '640', 'height' => '480']), ['context' => ['asset_metadata' => ['product.jpg' => ['id' => 301, 'url' => 'https://example.test/uploads/product.jpg', 'width' => '1280']]]]); +$assert(($resolved_image['attrs']['id'] ?? null) === 301, 'image-resolved-id'); +$assert(\strpos($resolved_image['innerHTML'], 'https://example.test/uploads/product.jpg') !== \false, 'image-resolved-url'); +$assert(\strpos($resolved_image['innerHTML'], 'width="640"') !== \false, 'image-preserves-source-width'); +$assert(\strpos($resolved_image['innerHTML'], 'https://example.test/uploads/product.jpg') !== \false, 'image-resolved-inner-html'); $file = $convert(new H2BC_Fake_Element('a', ['href' => 'https://example.com/report.pdf'], 'Download report')); $assert('core/file' === $file['blockName'], 'file-link-block'); $assert(($file['attrs']['href'] ?? '') === 'https://example.com/report.pdf', 'file-link-href'); diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-nested-landing-layout-content.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-nested-landing-layout-content.php index 5f7be9c..8f6a76e 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-nested-landing-layout-content.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-nested-landing-layout-content.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-no-duplicate-descendants.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-no-duplicate-descendants.php index 1e0d891..9f91ffc 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-no-duplicate-descendants.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-no-duplicate-descendants.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-product-card-decorative-placeholders.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-product-card-decorative-placeholders.php index 53201ff..8ac641a 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-product-card-decorative-placeholders.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-product-card-decorative-placeholders.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-progress-fill-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-progress-fill-divs.php index 5099e75..04041bf 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-progress-fill-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-progress-fill-divs.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-project-card-status-divs.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-project-card-status-divs.php index 23d8af2..ba4571b 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-project-card-status-divs.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-project-card-status-divs.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-attribution-wrapper.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-attribution-wrapper.php index e88f2a6..92476a7 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-attribution-wrapper.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-attribution-wrapper.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-author-avatar-meta.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-author-avatar-meta.php index 9629fb1..cfdc937 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-author-avatar-meta.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-quote-author-avatar-meta.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-raw-handler-context.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-raw-handler-context.php index 40fa00d..894bf63 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-raw-handler-context.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-raw-handler-context.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-resized-svg-image-serialization.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-resized-svg-image-serialization.php index 3e48ee3..897f62c 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-resized-svg-image-serialization.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-resized-svg-image-serialization.php @@ -36,7 +36,7 @@ if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-rich-ui-clusters.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-rich-ui-clusters.php index a7d52f2..66bfbbc 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-rich-ui-clusters.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-rich-ui-clusters.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-static-site-chrome.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-static-site-chrome.php index 76c1b60..343f770 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-static-site-chrome.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-static-site-chrome.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-step-timeline-connectors.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-step-timeline-connectors.php index 28094f7..8b6af2e 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-step-timeline-connectors.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-step-timeline-connectors.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-testimonial-figure-blockquote.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-testimonial-figure-blockquote.php index c413f6e..707dcc2 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-testimonial-figure-blockquote.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-testimonial-figure-blockquote.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-text-metric-stat-cards.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-text-metric-stat-cards.php index 322242c..2feec4b 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-text-metric-stat-cards.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-text-metric-stat-cards.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-traffic-light-decorative-dots.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-traffic-light-decorative-dots.php index 514e090..a896666 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-traffic-light-decorative-dots.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-traffic-light-decorative-dots.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-trivial-theme-part-fragments.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-trivial-theme-part-fragments.php index b54cea8..df4c27c 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-trivial-theme-part-fragments.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-trivial-theme-part-fragments.php @@ -54,7 +54,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) { diff --git a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-visual-list-groups.php b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-visual-list-groups.php index d15d1f3..59f37fb 100644 --- a/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-visual-list-groups.php +++ b/vendor_prefixed/chubes4/html-to-blocks-converter/tests/smoke-visual-list-groups.php @@ -61,7 +61,7 @@ public function get_registered($name) if (!\function_exists('BlockFormatBridge\Vendor\wp_strip_all_tags')) { function wp_strip_all_tags($text) { - return wp_strip_all_tags($text); + return \strip_tags((string) $text); } } if (!\function_exists('BlockFormatBridge\Vendor\get_shortcode_regex')) {