Removes unnecessary commented out code
This commit is contained in:
parent
2038f9c42f
commit
96331dea98
@ -384,144 +384,6 @@
|
|||||||
return "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
return "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// private function convert_to_blocks($html)
|
|
||||||
// {
|
|
||||||
// $doc = new DOMDocument();
|
|
||||||
// libxml_use_internal_errors(true);
|
|
||||||
// $doc->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', 'UTF-8'));
|
|
||||||
// libxml_clear_errors();
|
|
||||||
|
|
||||||
// $body = $doc->getElementsByTagName('body')->item(0);
|
|
||||||
// $output = '';
|
|
||||||
|
|
||||||
// // foreach ($body->childNodes as $node) {
|
|
||||||
// // if (!($node instanceof DOMElement)) {
|
|
||||||
// // continue;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // // Check if this node (or its children) contain an <img>
|
|
||||||
// // $img_tag = $node->getElementsByTagName('img')->item(0);
|
|
||||||
|
|
||||||
// // if ($img_tag) {
|
|
||||||
// // // Extract src and alt
|
|
||||||
// // $src = $img_tag->getAttribute('src');
|
|
||||||
// // $alt = $img_tag->getAttribute('alt') ?: '';
|
|
||||||
|
|
||||||
// // // Check for a wrapping <a>
|
|
||||||
// // $link = $node->getElementsByTagName('a')->item(0);
|
|
||||||
// // $image_html = '<img src="' . esc_url($src) . '" alt="' . esc_attr($alt) . '" />';
|
|
||||||
|
|
||||||
// // if ($link) {
|
|
||||||
// // $href = $link->getAttribute('href');
|
|
||||||
// // $image_html = '<a href="' . esc_url($href) . '">' . $image_html . '</a>';
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // // Wrap in figure block
|
|
||||||
// // $figure = '<figure class="wp-block-image">' . $image_html . '</figure>';
|
|
||||||
|
|
||||||
// // $output .= "<!-- wp:image -->\n" . $figure . "\n<!-- /wp:image -->\n\n";
|
|
||||||
// // continue;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // // Render other HTML blocks
|
|
||||||
// // $innerHTML = $doc->saveHTML($node);
|
|
||||||
|
|
||||||
// // // Fix insecure YouTube embeds
|
|
||||||
// // $innerHTML = preg_replace(
|
|
||||||
// // '#src=["\']http://(www\.)?youtube\.com#i',
|
|
||||||
// // 'src="https://www.youtube.com',
|
|
||||||
// // $innerHTML
|
|
||||||
// // );
|
|
||||||
|
|
||||||
// // switch ($node->nodeName) {
|
|
||||||
// // case 'p':
|
|
||||||
// // $output .= "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // case 'ol':
|
|
||||||
// // $output .= "<!-- wp:list {\"ordered\":true} -->\n{$innerHTML}\n<!-- /wp:list -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // case 'ul':
|
|
||||||
// // $output .= "<!-- wp:list -->\n{$innerHTML}\n<!-- /wp:list -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // case 'h2':
|
|
||||||
// // case 'h3':
|
|
||||||
// // $output .= "<!-- wp:heading -->\n{$innerHTML}\n<!-- /wp:heading -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // case 'blockquote':
|
|
||||||
// // $output .= "<!-- wp:quote -->\n{$innerHTML}\n<!-- /wp:quote -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // default:
|
|
||||||
// // $output .= "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
|
||||||
// // break;
|
|
||||||
// // }
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// foreach ($body->childNodes as $node) {
|
|
||||||
// if (!($node instanceof DOMElement)) {
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 🖼 Render all images first
|
|
||||||
// $img_tags = $node->getElementsByTagName('img');
|
|
||||||
// if ($img_tags->length > 0) {
|
|
||||||
// foreach ($img_tags as $img_tag) {
|
|
||||||
// $src = $img_tag->getAttribute('src');
|
|
||||||
// $alt = $img_tag->getAttribute('alt') ?: '';
|
|
||||||
|
|
||||||
// // Check for wrapping <a>
|
|
||||||
// $link = $img_tag->parentNode instanceof DOMElement && $img_tag->parentNode->nodeName === 'a'
|
|
||||||
// ? $img_tag->parentNode
|
|
||||||
// : null;
|
|
||||||
|
|
||||||
// $image_html = '<img src="' . esc_url($src) . '" alt="' . esc_attr($alt) . '" />';
|
|
||||||
// if ($link) {
|
|
||||||
// $href = $link->getAttribute('href');
|
|
||||||
// $image_html = '<a href="' . esc_url($href) . '">' . $image_html . '</a>';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// $figure = '<figure class="wp-block-image">' . $image_html . '</figure>';
|
|
||||||
// $output .= "<!-- wp:image -->\n" . $figure . "\n<!-- /wp:image -->\n\n";
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// // 💡 Continue with other content
|
|
||||||
// $innerHTML = $doc->saveHTML($node);
|
|
||||||
|
|
||||||
// // Fix insecure embeds
|
|
||||||
// $innerHTML = preg_replace(
|
|
||||||
// '#src=["\']http://(www\.)?youtube\.com#i',
|
|
||||||
// 'src="https://www.youtube.com',
|
|
||||||
// $innerHTML
|
|
||||||
// );
|
|
||||||
|
|
||||||
// switch ($node->nodeName) {
|
|
||||||
// case 'p':
|
|
||||||
// $output .= "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
|
||||||
// break;
|
|
||||||
// case 'ol':
|
|
||||||
// $output .= "<!-- wp:list {\"ordered\":true} -->\n{$innerHTML}\n<!-- /wp:list -->\n\n";
|
|
||||||
// break;
|
|
||||||
// case 'ul':
|
|
||||||
// $output .= "<!-- wp:list -->\n{$innerHTML}\n<!-- /wp:list -->\n\n";
|
|
||||||
// break;
|
|
||||||
// case 'h2':
|
|
||||||
// case 'h3':
|
|
||||||
// $output .= "<!-- wp:heading -->\n{$innerHTML}\n<!-- /wp:heading -->\n\n";
|
|
||||||
// break;
|
|
||||||
// case 'blockquote':
|
|
||||||
// $output .= "<!-- wp:quote -->\n{$innerHTML}\n<!-- /wp:quote -->\n\n";
|
|
||||||
// break;
|
|
||||||
// default:
|
|
||||||
// $output .= "<!-- wp:paragraph -->\n{$innerHTML}\n<!-- /wp:paragraph -->\n\n";
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// return $output;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
WP_CLI::add_command('drupal-import', 'Drupal_Import_Command');
|
WP_CLI::add_command('drupal-import', 'Drupal_Import_Command');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user