sad
This commit is contained in:
@@ -27,22 +27,25 @@ function igny8_parse_content_sections($content) {
|
|||||||
$dom = new DOMDocument('1.0', 'UTF-8');
|
$dom = new DOMDocument('1.0', 'UTF-8');
|
||||||
libxml_use_internal_errors(true);
|
libxml_use_internal_errors(true);
|
||||||
|
|
||||||
// Load HTML with proper encoding
|
// Wrap content in a div to ensure proper parsing
|
||||||
$dom->loadHTML('<?xml encoding="UTF-8">' . $content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
$wrapped_content = '<div>' . $content . '</div>';
|
||||||
|
$dom->loadHTML('<?xml encoding="UTF-8">' . $wrapped_content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
|
||||||
libxml_clear_errors();
|
libxml_clear_errors();
|
||||||
|
|
||||||
$intro_html = '';
|
$intro_html = '';
|
||||||
$sections = [];
|
$sections = [];
|
||||||
$current_section = null;
|
$current_section = null;
|
||||||
|
|
||||||
// Get body node
|
// Get the wrapper div
|
||||||
$body = $dom->getElementsByTagName('body')->item(0);
|
$xpath = new DOMXPath($dom);
|
||||||
if (!$body) {
|
$nodes = $xpath->query('//div/*');
|
||||||
|
|
||||||
|
if ($nodes->length === 0) {
|
||||||
return ['intro' => $content, 'sections' => []];
|
return ['intro' => $content, 'sections' => []];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Iterate through all child nodes
|
// Iterate through all child nodes
|
||||||
foreach ($body->childNodes as $node) {
|
foreach ($nodes as $node) {
|
||||||
// Check if node is an H2 heading
|
// Check if node is an H2 heading
|
||||||
if ($node->nodeName === 'h2') {
|
if ($node->nodeName === 'h2') {
|
||||||
// Save previous section if exists
|
// Save previous section if exists
|
||||||
|
|||||||
@@ -51,6 +51,21 @@ $featured_image_prompt = igny8_get_featured_image_prompt(get_the_ID());
|
|||||||
$content = get_the_content();
|
$content = get_the_content();
|
||||||
$content = apply_filters('the_content', $content);
|
$content = apply_filters('the_content', $content);
|
||||||
$parsed_content = igny8_parse_content_sections($content);
|
$parsed_content = igny8_parse_content_sections($content);
|
||||||
|
|
||||||
|
// Debug logging
|
||||||
|
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||||
|
error_log('IGNY8 Template Debug - Post ID: ' . get_the_ID());
|
||||||
|
error_log('Content length: ' . strlen($content));
|
||||||
|
error_log('Intro length: ' . strlen($parsed_content['intro']));
|
||||||
|
error_log('Sections count: ' . count($parsed_content['sections']));
|
||||||
|
if (!empty($parsed_content['sections'])) {
|
||||||
|
foreach ($parsed_content['sections'] as $idx => $sec) {
|
||||||
|
error_log('Section ' . ($idx + 1) . ': ' . $sec['heading']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
error_log('In-article images count: ' . count($in_article_images));
|
||||||
|
error_log('Imported images meta: ' . print_r(get_post_meta(get_the_ID(), '_igny8_imported_images', true), true));
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="igny8-content-wrapper">
|
<div class="igny8-content-wrapper">
|
||||||
|
|||||||
Reference in New Issue
Block a user