‘GET’,
‘permission_callback’ => ‘__return_true’,
‘callback’ => function() {
$uploads = wp_upload_dir();
$file = trailingslashit($uploads[‘basedir’]) . ‘dmf-home/home.html’;
if (!file_exists($file)) {
return new WP_REST_Response([‘error’ => ‘File not found’], 404);
}
$base = untrailingslashit($uploads[‘baseurl’]) . ‘/dmf-home’;
$html = str_replace(‘{{ASSET_BASE}}’, $base, file_get_contents($file));
return new WP_REST_Response($html, 200, [‘Content-Type’ => ‘text/html; charset=utf-8’]);
}
));
});

// Also hook into template_include filter – this fires during page rendering
add_filter(‘template_include’, function($template) {
if (is_front_page()) {
$uploads = wp_upload_dir();
$file = trailingslashit($uploads[‘basedir’]) . ‘dmf-home/home.html’;
if (file_exists($file)) {
$base = untrailingslashit($uploads[‘baseurl’]) . ‘/dmf-home’;
$html = str_replace(‘{{ASSET_BASE}}’, $base, file_get_contents($file));
echo $html;
exit;
}
}
return $template;
}, 1);