Add argument to specify alternative importer class (e.g. PLL_WP_Import)
Hi WP-CLI Team,
While working on a multi-language site which uses Polylang I noticed that translations get damaged after running import via CLI. The same WXR works fine from admin UI (Tools -> Import). Polylang leverages heavily custom taxonomy and custom post types to store translations and trac related posts and terms (i.e. variants of the same entry in different language). After a short investigation I figured out that Polylang comes with a custom PLL_WP_Import class [1], derived from the regular WP_Import, which implements the special handling of Polylang entities during import.
In admin page the standard WP_Import gets swapped with PLL_WP_Import by removing the regular WordPress action and adding Polylang variant in the same place [2]. In CLI there doesn't seem to be any API which would allow for that.
I came up with a rather rudimentary patch [3] which will fork fine for my project. I wonder if you'd be interested in pulling it. Anticipating your question - I didn't investigate other translation plugins or run any tests except smoke-testing it against my development instance.
Cheers, Bartosz Moczulski
References: [1] PLL_WP_Import = https://github.com/polylang/polylang/blob/master/integrations/wp-importer/wp-import.php [2] WP_Import -> PLL_WP_Import replacement = https://github.com/polylang/polylang/blob/master/integrations/wp-importer/wordpress-importer.php [3] my humble change = https://github.com/bmoczulski/import-command/commit/e493025d314b646ef223ac9d396a3adabb733648
Thanks for the suggestion, @bmoczulski !
I don't think we want to add a hardcoded reference to PLL_WP_Import, but we could add an optional argument to specify an import class to use (assuming it subclassed WP_Import).
Feel free to submit a pull request, if you'd like. Here is some guidance on our pull request best practices, if it's helpful.
You can also stop by the #cli channel on WordPress.org Slack if you'd like help further.