Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
36 lines
1.3 KiB
PHP
36 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Generates a Divi 5 fixture from a Divi 4 shortcode file with Divi's own server-side
|
|
* conversion (the same code the Divi 5 migrator uses) and writes it into tests/Fixtures/divi/.
|
|
* Usage (inside DDEV, from the WordPress root):
|
|
* wp eval-file wp-content/plugins/WP-LIT-MCP/tests/Integration/divi-convert-fixture.php <source.shortcode> <target.html>
|
|
* Paths are relative to the plugin's tests/Fixtures/divi directory.
|
|
*/
|
|
|
|
use ET\Builder\Packages\Conversion\Conversion;
|
|
|
|
$args = $args ?? [];
|
|
if (count($args) !== 2) {
|
|
WP_CLI::error('Usage: divi-convert-fixture.php <source.shortcode> <target.html>');
|
|
}
|
|
if (! class_exists(Conversion::class)) {
|
|
WP_CLI::error('Divi 5 is not active.');
|
|
}
|
|
|
|
$dir = dirname(__DIR__) . '/Fixtures/divi/';
|
|
$source = file_get_contents($dir . $args[0]);
|
|
if ($source === false) {
|
|
WP_CLI::error('Cannot read ' . $dir . $args[0]);
|
|
}
|
|
|
|
$converted = Conversion::maybeConvertContent(trim($source));
|
|
if (! str_contains($converted, '<!-- wp:divi/section')) {
|
|
WP_CLI::error('Conversion produced no Divi 5 sections.');
|
|
}
|
|
|
|
$markup = '<!-- wp:divi/placeholder -->' . $converted . '<!-- /wp:divi/placeholder -->';
|
|
if (file_put_contents($dir . $args[1], $markup) === false) {
|
|
WP_CLI::error('Cannot write ' . $dir . $args[1]);
|
|
}
|
|
WP_CLI::success(sprintf('%s: %d bytes', $args[1], strlen($markup)));
|