Skip to content

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

Merged
swissspidy merged 11 commits into
mainfrom
copilot/allow-import-wxr-file-http-stdin
Mar 20, 2026
Merged

swissspidy merged 11 commits into
mainfrom
copilot/allow-import-wxr-file-http-stdin

Conversation

Copilot AI commented Mar 19, 2026 •

Copy link
Copy Markdown
Contributor

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.

@github-actions github-actions Bot added command:import Related to 'import' command scope:distribution Related to distribution scope:testing Related to testing labels Mar 19, 2026
@codecov

codecov Bot commented Mar 19, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.92453% with 17 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/Import_Command.php 67.92% 17 Missing ⚠️

📢 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
Comment thread src/Import_Command.php Resolved
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI requested a review from swissspidy March 19, 2026 18:18
Comment thread features/import.feature Resolved
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

swissspidy and others added 3 commits March 20, 2026 09:56
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

@swissspidy
swissspidy marked this pull request as ready for review March 20, 2026 11:30
@swissspidy
swissspidy requested a review from a team as a code owner March 20, 2026 11:30
@swissspidy swissspidy added this to the 2.0.17 milestone Mar 20, 2026
@swissspidy
swissspidy merged commit e09d28a into main Mar 20, 2026
60 checks passed
@swissspidy
swissspidy deleted the copilot/allow-import-wxr-file-http-stdin branch March 20, 2026 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:import Related to 'import' command scope:distribution Related to distribution scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow to import WXR file through HTTP and STDIN

3 participants