Skip to content

Conversation

@adamziel
Copy link
Collaborator

A part of #1894

Adds a new API for loading content from a WP_Filesystem instance:

  • WP_Filesystem_To_Post_Tree for traversing a directory tree and mapping the structure a hierarchical WordPress post/meta entity stream
  • WP_Filesystem_Entity_Reader for converting the raw file content into WordPress blocks

To convert a set of zipped files into WordPress entities:

// Any Filesystem instance works here. Could be WP_Local_Filesystem,
// WP_Git_Filesystem, or anything else. Let's read from a zip file here:
$fs = new WP_Zip_Filesystem(
    WP_File_Reader::create('./docs.zip')
);

$reader = new WP_Filesystem_Entity_Reader( $fs );

foreach($reader as $entity) {
    var_dump($entity);
}

Testing

The code isn't used anywhere yet – just rely on the CI checks.

A part of #1894

Adds a new API for loading content from a WP_Filesystem instance:

* `WP_Filesystem_To_Post_Tree` for traversing a directory tree and
  mapping the structure a hierarchical WordPress post/meta entity stream
* `WP_Filesystem_Entity_Reader` for converting the raw file content into
  WordPress blocks

To convert a set of zipped files into WordPress entities:

```php
// Any Filesystem instance works here. Could be WP_Local_Filesystem,
// WP_Git_Filesystem, or anything else. Let's read from a zip file here:
$fs = new WP_Zip_Filesystem(
    WP_File_Reader::create('./docs.zip')
);

$reader = new WP_Filesystem_Entity_Reader( $fs );

foreach($reader as $entity) {
    var_dump($entity);
}
```

 ## Testing

The code isn't used anywhere yet – just rely on the CI checks.
@adamziel adamziel merged commit de7ff45 into trunk Jan 10, 2025
10 checks passed
@adamziel adamziel deleted the filesystem-reader branch January 10, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants