Skip to content

Allow importing WXR files via HTTP/HTTPS/FTP and STDIN#104

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/allow-import-wxr-file-http-stdin
Draft

Allow importing WXR files via HTTP/HTTPS/FTP and STDIN#104
Copilot wants to merge 3 commits intomainfrom
copilot/allow-import-wxr-file-http-stdin

Conversation

Copy link
Contributor

Copilot AI commented Mar 19, 2026

wp import only accepted local file paths and directories. This adds support for remote URLs and piped STDIN input.

Changes

  • STDIN (-): Reads from php://stdin, buffers to a temp file, imports, then cleans up
  • Remote URLs (http://, https://, ftp://, ftps://): Downloads via WordPress's download_url() to a temp file, imports, then cleans up
  • Display names: import_wxr() accepts an optional $display_name so log output shows the original URL or STDIN rather than the temp file path
  • Temp file cleanup: cleanup_temp_files() helper ensures temp files are removed after import or on error
  • Tests: New Behat scenarios covering STDIN and HTTP URL import

Usage

# Import from a remote URL
wp import https://raw.githubusercontent.com/WPTRT/theme-unit-test/master/themeunittestdata.wordpress.xml --authors=skip

# Import from STDIN
wp export --stdout | wp import - --authors=skip
Original prompt

This section details on the original issue you should resolve

<issue_title>Allow to import WXR file through HTTP and STDIN</issue_title>
<issue_description>It will be useful if we can import WXR file through HTTP.
Following is an example to import theme unit test data of the theme review team.

$ wp import https://raw.githubusercontent.com/WPTRT/theme-unit-test/master/themeunittestdata.wordpress.xml --authors=import

Also, I think it should to be able to import from STDIN like following and it looks useful.

$ wp export --stdout | wp @staging import - --authors=import
```</issue_description>

<agent_instructions>Related: https://github.com/wp-cli/media-command/issues/50, https://github.com/wp-cli/media-command/pull/221</agent_instructions>

## Comments on the Issue (you are @copilot in this section)

<comments>
<comment_new><author>@swissspidy</author><body>
Related:

* https://github.com/wp-cli/media-command/issues/50</body></comment_new>
</comments>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for importing WXR file through HTTP and STDIN Allow importing WXR files via HTTP/HTTPS/FTP and STDIN Mar 19, 2026
Copilot AI requested a review from swissspidy March 19, 2026 17:46
* Success: Finished importing from 'example.wordpress.2016-06-21.xml' file.
*
* # Import content from a WXR file via HTTP
* $ wp import https://raw.githubusercontent.com/WPTRT/theme-unit-test/master/themeunittestdata.wordpress.xml --authors=import
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 8c48eec — updated the example URL in the docblock to https://raw.githubusercontent.com/WordPress/theme-test-data/refs/heads/master/theme-preview.xml. The Behat tests use a local PHP built-in web server rather than a hardcoded remote URL, so no changes were needed there.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy March 19, 2026 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to import WXR file through HTTP and STDIN

2 participants