Skip to content

Export just wp-content instead of full WordPress #780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 26 commits into from
Nov 29, 2023

Conversation

adamziel
Copy link
Collaborator

@adamziel adamziel commented Nov 23, 2023

Description

This PR modifies the Playground import/export feature to focus on the wp-content directory instead of the entire WordPress installation.

  • Exporting from Playground will only download the wp-content directory without Playground artifacts like the sqlite-database-integration plugin or the 0-playground mu-plugin
  • Importing into Playground will overwrite Playground files the imported files, including the wp-includes, wp-admin, and the wp-content directories. The wp-content directory gets a special treatment in that Playground artifacts such as the sqlite-database-integration and the 0-playground mu-plugin are restored.

Rationale

Exporting the full WordPress from Playground doesn't make much sense. It's an optimized bundle that's missing some files, it locks you in in an outdated WordPress version, and it inflates the zip size. What matters is the wp-content directory. This should enable easy GitHub-based management of WordPress core feature showcases.

Remaining work

  • Add E2E tests to confirm that exporting and importing a zip file continue to work

Other changes

  • Breaking: Removes the replaceSite step. SourceGraph suggests it wasn't used in any public repo 🤞 Use the new importWordPressFiles step instead.
  • Splits the import/export steps into different files

Testing

  • Verify export contains just the wp-content directory
  • Test import works with zips containing just wp-content or wp-content + wp-includes
  • Confirm the WordPress PR Previewer changes and TypeScript fixes work as expected

@adamziel adamziel self-assigned this Nov 23, 2023
@adamziel adamziel force-pushed the export-import-wp-content branch from 7316553 to 66001e8 Compare November 24, 2023 15:19
@adamziel adamziel marked this pull request as ready for review November 25, 2023 10:00
@adamziel adamziel changed the title Import/Export just the wp-content directory instead of the entire WordPress directory Export just wp-content instead of full WordPress Nov 25, 2023
@adamziel adamziel force-pushed the export-import-wp-content branch from c626cbb to 9d48969 Compare November 27, 2023 15:33
@adamziel adamziel requested a review from a team as a code owner November 27, 2023 15:34
@adamziel adamziel force-pushed the export-import-wp-content branch from b0ffb5d to 015ece2 Compare November 27, 2023 18:11
});
</script>
<?php
});
Copy link
Member

Choose a reason for hiding this comment

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

is there enough of a warrant to move this into the service worker? or would that leave out CLI Playgrounds?

or perform it on render output from PHP to ensure that we don't miss it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is only relevant for the web version so you're on to something here.

The main challenge with doing it outside of WordPress, like in the service worker or the PHP rendering pipeline, is deciding whether the output is meant to be a document displayed by the browser. There may be static HTML files, XHR queries, HTML-like files, CSS files, binary blobs etc, but we only ever want to add this code snippet to UI rendered by WordPress.

@adamziel adamziel merged commit 9e54503 into trunk Nov 29, 2023
@adamziel adamziel deleted the export-import-wp-content branch November 29, 2023 10:19
adamziel added a commit that referenced this pull request Dec 2, 2023
The importFile step, which allows developers to import WordPress content
bia WXR and WXZ files, got accidentally removed in Pull Request #780.
This commit restores that step.

Testing instructions

Go to the following localhost URL and confirm the WordPress reflects the
non-standard content it imported from WordPress theme unit tests data:

http://localhost:5400/website-server/#{%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22importFile%22,%22file%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/WordPress/theme-test-data/master/themeunittestdata.wordpress.xml%22}}]}

In particular, the menu should say twitter.com, facebook.com etc

As the Playground codebase starts supporting using WordPress in unit
tests, let's add a test case for this step.

Closes #833
adamziel added a commit that referenced this pull request Dec 6, 2023
The importFile step, which allows developers to import WordPress content
bia WXR and WXZ files, got accidentally removed in Pull Request #780.
This commit restores that step.

Testing instructions

Go to the following localhost URL and confirm the WordPress reflects the
non-standard content it imported from WordPress theme unit tests data:

http://localhost:5400/website-server/#{%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22importFile%22,%22file%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/WordPress/theme-test-data/master/themeunittestdata.wordpress.xml%22}}]}

In particular, the menu should say twitter.com, facebook.com etc

As the Playground codebase starts supporting using WordPress in unit
tests, let's add a test case for this step.

Closes #833
adamziel added a commit that referenced this pull request Dec 6, 2023
The importFile step, which allows developers to import WordPress content
bia WXR and WXZ files, got accidentally removed in Pull Request #780.
This commit restores that step.

## Open questions

`importFile` sounds ambiguous. What if it was split into two distinct
steps called `importWxr` and `importWxz`? Then, the new `importWpFiles`
step could be called `importWpContentDirectory` instead.

## Follow-up work

The importFile step uses `DOMParser` which isn't available in Node.js.
It could, instead:

* Call the appropriate import-related PHP functions directly, or...
* Use the HTML Tag Processor available in WordPress 6.3+ (and polyfill
it in the older WordPress versions).

## Testing Instructions

Go to the following localhost URL and confirm the WordPress reflects the
non-standard content it imported from WordPress theme unit tests data:


http://localhost:5400/website-server/#{%22steps%22:[{%22step%22:%22login%22},{%22step%22:%22importFile%22,%22file%22:{%22resource%22:%22url%22,%22url%22:%22https://raw.githubusercontent.com/WordPress/theme-test-data/master/themeunittestdata.wordpress.xml%22}}]}

In particular, the menu should say twitter.com, facebook.com etc

As the Playground codebase starts supporting using WordPress in unit
tests, let's add a test case for this step.

Closes #833

CC @eliot-akira @aplamada
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.

3 participants