Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions bin/run-server-next-gen-importer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

# @TODO: Figure out how to set up the dev environment to be as similar to
# production as possible.
npx @wp-playground/cli@latest \
server \
--php=8.2 \
--mount=`pwd`/plugins/next-gen-importer:/wordpress/wp-content/plugins/next-gen-importer \
--blueprint=./blueprint-next-gen-importer.json \
--mount=`pwd`:/wordpress/wp-content/data-liberation \
--mount=`pwd`/debug.log:/wordpress/wp-content/debug.log

16 changes: 16 additions & 0 deletions blueprint-next-gen-importer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"login": true,
"constants": {
"WP_DEBUG": true,
"WP_DEBUG_LOG": "/wordpress/wp-content/debug.log",
"WP_DEBUG_DISPLAY": true,
"DISABLE_WP_CRON": false
},
"plugins": ["wp-crontrol"],
"steps": [
{
"step": "activatePlugin",
"pluginPath": "next-gen-importer/plugin.php"
}
]
}
1 change: 1 addition & 0 deletions components/BlockParser/class-wp-block-parser-block.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
namespace WordPress\BlockParser;
/**
* Block Serialization Parser
*
Expand Down
3 changes: 3 additions & 0 deletions components/BlockParser/class-wp-block-parser-error.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<?php
namespace WordPress\BlockParser;
use Exception;

/**
* @package WordPress
*/
Expand Down
1 change: 1 addition & 0 deletions components/BlockParser/class-wp-block-parser-frame.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
namespace WordPress\BlockParser;
/**
* Block Serialization Parser
*
Expand Down
2 changes: 2 additions & 0 deletions components/BlockParser/class-wp-block-parser.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php
namespace WordPress\BlockParser;

/**
* Block Serialization Parser
*
Expand Down
1 change: 1 addition & 0 deletions components/Blueprints/Steps/scripts/import-content.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use WordPress\Zip\ZipFilesystem;

use function WordPress\Filesystem\wp_join_unix_paths;
use function WordPress\Filesystem\add_filter;

require_once getenv('DOCROOT') . '/wp-load.php';
require_once getenv('DOCROOT') . '/php-toolkit.phar';
Expand Down
2 changes: 1 addition & 1 deletion components/ByteStream/ReadStream/BaseByteReadStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

abstract class BaseByteReadStream implements ByteReadStream {

const CHUNK_SIZE = 100;// 64 * 1024;
const CHUNK_SIZE = 64 * 1024;

protected $buffer_size = 2048;

Expand Down
Binary file added components/DataLiberation/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace WordPress\DataLiberation\BlockMarkup;

use WP_Block_Parser_Error;
use WP_HTML_Tag_Processor;
use WordPress\BlockParser\WP_Block_Parser_Error;
use WordPress\HTML\WP_HTML_Tag_Processor;

/**
* A processor class capable of reading and rewriting block markup.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace WordPress\DataLiberation\DataFormatConsumer;

use WP_HTML_Processor;
use WordPress\HTML\WP_HTML_Processor;
use function WordPress\Polyfill\parse_blocks;
use function WordPress\Polyfill\serialize_block;

/**
* Converts a metadata-annotated block markup into block markup+metadata pair.
Expand Down Expand Up @@ -48,7 +50,7 @@ public function consume() {
$metadata = array();
foreach ( parse_blocks( $this->original_html ) as $block ) {
if ( $block['blockName'] === null ) {
$html_converter = new MarkupProcessorConsumer( WP_HTML_Processor::create_fragment( $block['innerHTML'] ) );
$html_converter = new MarkupProcessorConsumer( \WordPress\HTML\WP_HTML_Processor::create_fragment( $block['innerHTML'] ) );
$result = $html_converter->consume();
$block_markup .= $result->get_block_markup() . "\n";
$metadata = array_merge( $metadata, $result->get_all_metadata() );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use WordPress\DataLiberation\DataLiberationException;
use WordPress\DataLiberation\Importer\ImportUtils;
use WordPress\XML\XMLProcessor;
use WP_HTML_Processor;
use WP_HTML_Tag_Processor;
use WordPress\HTML\WP_HTML_Processor;
use WordPress\HTML\WP_HTML_Tag_Processor;

/**
* Creates block markup from a WP_HTML_Processor or WP_XML_Processor instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace WordPress\DataLiberation\DataFormatProducer;

use WordPress\DataLiberation\DataFormatConsumer\BlocksWithMetadata;
use WP_HTML_Tag_Processor;
use WordPress\HTML\WP_HTML_Tag_Processor;

/**
* Turns Block Markup + Metadata into a metadata-annotated Block Markup.
Expand Down
4 changes: 2 additions & 2 deletions components/DataLiberation/DataLiberationHTMLProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace WordPress\DataLiberation;

use WP_HTML_Processor;
use WP_HTML_Tag_Processor;
use WordPress\HTML\WP_HTML_Processor;
use WordPress\HTML\WP_HTML_Tag_Processor;

class DataLiberationHTMLProcessor extends WP_HTML_Processor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use WordPress\XML\XMLProcessor;

use function WordPress\Filesystem\wp_join_unix_paths;
use function WordPress\Polyfill\_doing_it_wrong;

/**
* https://www.w3.org/AudioVideo/ebook/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use WordPress\Filesystem\Visitor\FilesystemVisitor;
use WordPress\Markdown\MarkdownConsumer;
use WordPress\XML\XMLProcessor;
use WP_HTML_Processor;
use WordPress\HTML\WP_HTML_Processor;

use function WordPress\Filesystem\wp_join_unix_paths;

Expand Down Expand Up @@ -277,7 +277,7 @@ public function next_entity(): bool {
$result = $converter->consume();
break;
case 'html':
$converter = new MarkupProcessorConsumer( WP_HTML_Processor::create_fragment( $content ) );
$converter = new MarkupProcessorConsumer( \WordPress\HTML\WP_HTML_Processor::create_fragment( $content ) );
$result = $converter->consume();
break;
default:
Expand Down
15 changes: 12 additions & 3 deletions components/DataLiberation/EntityReader/WXREntityReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use WordPress\DataLiberation\ImportEntity;
use WordPress\XML\XMLProcessor;
use WordPress\XML\XMLUnsupportedException;
use function WordPress\Polyfill\_doing_it_wrong;

/**
* Data Liberation API: WP_WXR_Entity_Reader class
Expand Down Expand Up @@ -819,7 +820,11 @@ private function read_next_entity() {
$this->entity_data['terms'][] = array(
'taxonomy' => $this->last_opener_attributes['domain'],
'slug' => $this->last_opener_attributes['nicename'],
'description' => $this->text_buffer,
/**
* trim() – in XML, trailing whitespace in text nodes must be ignored.
* @TODO: Only trim text nodes, not CDATA sections.
*/
'description' => trim( $this->text_buffer ),
);
$this->text_buffer = '';
continue;
Expand All @@ -838,8 +843,12 @@ private function read_next_entity() {
continue;
}

$key = $this->KNOWN_ENITIES[ $this->entity_tag ]['fields'][ $tag_with_namespace ];
$this->entity_data[ $key ] = $this->text_buffer;
$key = $this->KNOWN_ENITIES[ $this->entity_tag ]['fields'][ $tag_with_namespace ];
/**
* trim() – in XML, trailing whitespace in text nodes must be ignored.
* @TODO: Only trim text nodes, not CDATA sections.
*/
$this->entity_data[ $key ] = trim( $this->text_buffer );
$this->text_buffer = '';
} while ( $this->xml->next_token() );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use WordPress\HttpClient\Request;

use function WordPress\Filesystem\wp_join_unix_paths;
use function WordPress\Polyfill\_doing_it_wrong;

class AttachmentDownloader {
private $client;
Expand Down
Loading
Loading