Files
WP-LIT-MCP/tests/Integration/divi-convert-fixture.php
janniclas.loosenandClaude Opus 5.5 b24eb6c3e9 fix(security): no direct HTTP access to plugin PHP files (audit L2, cheap part)
Every file under src/ exits outside WordPress (defined('ABSPATH') ||
exit; after the use block, so a direct request no longer prints a fatal
error with the server path); divi-convert-fixture.php gets the WP_CLI
guard the other integration scripts have. A unit test keeps both true;
PSR1 side-effects warning excluded for the guard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
2026-09-26 19:32:12 +02:00

38 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.
*/
defined('WP_CLI') && WP_CLI || exit;
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)));