-
Notifications
You must be signed in to change notification settings - Fork 20
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
Bulk conversion #56
Comments
What are the functions to call to convert a post to block? |
@ActuallyConnor Most of the transformation happens client-side in the Browser. This makes a WP CLI based solution difficult, as it has to match all the core & custom raw handling api's on the backend. One way we have gotten around this limitation is by building a Puppeteer (or similar) script. The script works like this,
Hope that helps. |
Hello all! Really impressed with this plugin so far and the "just in time" approach is a nice one. I also think batch processing would be really useful (for our use-case) and for that of the wider community. However, as @dsawardekar notes, this spends on using client side code, in particular, looping over all the blocks on the page (after conversion) and running Obviously you can run Javascript without a browser, but looking through this code in Gutenberg, a great deal depends on the browser environment existing. What one is tempted to do here is write an application in Javascript that queries the WordPress database and then uses these transformations directly on the HTML (if possible) then saves the results back out. This seems to break some pretty fundamental assumptions of this project, for example, that it is in PHP, with client-side Javascript. Another approach would be to port a sub-set of these transformations to PHP. You could even use a PHP DOM manipulation library to port the code more quickly - handling the insertion of Gutenberg comments and so on. I am not sure of the best way forward here, so would welcome everyone in the community throwing around ideas. Happy to try some experiments out and see how far we get! |
Note this is also how the relatively popular Bulk Block Converter also operates, except this runs this using the WordPress API rather than loading it on the editor page. |
Also the way in which this plugin from Automattic works, though how the PHP elements operate isn't clear to me. |
Is your enhancement related to a problem? Please describe.
As noted on Twitter (and in a couple other dotorg/etc. places), some folks are requesting the ability to bulk convert posts vs. the one-at-a-time approach that C2B was built for.
Describe the solution you'd like
Initial approach is probably a CLI command as that limits the use to more technical users who we can gain initial feedback from before considering whether to expose this in a Bulk Edit dropdown option or not.
Designs
The CLI command could default to
all
posts in a specified post type, but accept a list or range of IDs to convert as an option? Open to how we might structure the commend / input / output.Describe alternatives you've considered
Additional context
The text was updated successfully, but these errors were encountered: