-
Notifications
You must be signed in to change notification settings - Fork 274
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blueprints: Rename importFile to importWxr, switch to humanmade/WordP…
…ress-Importer Rewires the importFile step to: * Be named importWxz. The old name continues to work, though. * Use the humanmade/WordPress-Importer for importing content – it is more reliable than the official wordpress-importer and has a convenient PHP API. * Drop WXZ support – it's a maintenance burden and doesn't add clear value. Closes #1183 Closes #379 Closes #1158 Closes #1161
- Loading branch information
Showing
802 changed files
with
156,310 additions
and
158,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 0 additions & 15 deletions
15
packages/playground/blueprints/src/lib/steps/export-wxz.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 0 additions & 93 deletions
93
packages/playground/blueprints/src/lib/steps/import-file.ts
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
packages/playground/blueprints/src/lib/steps/import-wxr.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { StepHandler } from '.'; | ||
import { writeFile } from './write-file'; | ||
import { phpVar } from '@php-wasm/util'; | ||
|
||
/** | ||
* @inheritDoc importWxr | ||
* @example | ||
* | ||
* <code> | ||
* { | ||
* "step": "importWxr", | ||
* "file": { | ||
* "resource": "url", | ||
* "url": "https://your-site.com/starter-content.wxr" | ||
* } | ||
* } | ||
* </code> | ||
*/ | ||
export interface ImportWxrStep<ResourceType> { | ||
step: 'importWxr' | 'importFile'; | ||
/** The file to import */ | ||
file: ResourceType; | ||
} | ||
|
||
/** | ||
* Imports a WXR file into WordPress. | ||
* | ||
* @param playground Playground client. | ||
* @param file The file to import. | ||
*/ | ||
export const importWxr: StepHandler<ImportWxrStep<File>> = async ( | ||
playground, | ||
{ file }, | ||
progress? | ||
) => { | ||
progress?.tracker?.setCaption('Importing content'); | ||
await writeFile(playground, { | ||
path: '/tmp/import.wxr', | ||
data: file, | ||
}); | ||
const docroot = await playground.documentRoot; | ||
await playground.run({ | ||
code: `<?php | ||
require ${phpVar(docroot)} . '/wp-load.php'; | ||
$admin_id = get_users(array('role' => 'Administrator') )[0]; | ||
$importer = new WXR_Importer( array( | ||
'fetch_attachments' => true, | ||
'default_author' => $admin_id | ||
) ); | ||
$logger = new WP_Importer_Logger_CLI(); | ||
$importer->set_logger( $logger ); | ||
$result = $importer->import( '/tmp/import.wxr' ); | ||
`, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.