This is a major refactoring of how the plugin processes posts for conversion, with several bigger simplifications. The build process is fixed and new features are added. Plugin is now ready for v.1.
Big changes
Fixed build process
Removed custom table -- no longer using ncc_wp_posts and the complex queuing system
Removed hooks during plugin installation and uninstallation (which previously populated the "conversion queue") and that whole logic. Plugin installation/activation and deactivation/deletion do not affect the data
Simple queuing system -- removed the previous conversion queue mechanism. Now whenever a conversion is clicked and started, it picks up all the existing posts that can to be converted on the fly, without any longer needing for the reset CLI command to "queue" new posts. The reset command was completely removed
Now using postmeta to store original post_content before conversion. Revisions were also considered, but those can get deleted because of the max number of revisions WP param -- when multiple revisions are created, old ones get deleted. Postmeta is permanent
New Restore plugin screen -- ability to restore posts via GUI, option to restore all posts, or just some specific post IDs. Removed the CLI command because GUI has more options
Added filters and actions instead of old OOP style filtering -- just for now, the patchers classes are still kept all the same, but they now get added to the new filters and executed WP-style. Moved all filtering (new filters) into NewspackContentConverter\Converter::register_filters() where they're now hardcoded and simplified
New filters are:
ncc_filter_html_before_conversion
ncc_filter_blocks_after_conversion
And a new action, as proposed by an external contributor PR #127
ncc_after_post_content_updated
Smaller changes
Added a function which detects the blank screen, that is if the converter app fails to load. If the app is not loaded and rendered correctly, after 15sec a popup alert notifies the user to try and temporarily disable plugins, then try running again. This is the most common "fix" to make the plugin work, because some plugins modify Gutenberg layout, and this plugin can't catch up with all those possible modifications
Refactored names of variables, methods and endpoints for more clarity
Downloadable list of converted and unconverted IDs from GUI
Posts get converted in ID DESC order (requested by our Team member)
"Flush backups" button in the new "Restore" screen optionally permanently cleans up all the postmeta/backups (there's also an explicit recommendation that DB should be fully backed up before running the conversion, and the README contains a warning that authors of this plugin are not responsible for data loss)
Updated composer dependencies
Updated PHPCS to newer
Future steps we can take, after this v.1 gets merged and released
Improve conversion logic in Gutenberg even further -- it seems that conversion done by this plugin does not always a 100% equal to the effect of manually clicking "Convert to blocks" in Gutenberg editor. This might be improved further to make it 100% the same. All this logic is compact in assets/src/utilities/index.js, runSinglePost
Improve filters -- now that filters and actions are much simplified and all located in a single place NewspackContentConverter\Converter::register_filters(), these filters can be optimized on more easily. Proposed that we next add a checkbox option in "Settings" saying "Use recommended Newspack filters?", and make our filters/patchers on/off in settings. That lets anyone use "clean conversion" or our custom filters.
Test instructions
build the plugin
clone repo
checkout branch add/fix-build-and-refactor
pull
composer install
nvm use 16
npm ci
npm run build
install and activate plugin
create enough for 3 batches of posts, like 250 posts on a site with HTML content
run entire conversion in one tab, once finished go to "Converter" (1st plugin menu subitem), see that it can not be converted again, and that "Run" button is disabled (unless some posts are not converted, then Run will still be enabled to be able to try again)
go to "Restore" (2nd plugin menu subitem), try resetting just a few post IDs by providing CSV. Then also reset all the other posts by leaving CSV field empty and clicking "Restore"
once all posts are restored, run conversion again in two tabs. Start running in one tab, then click the link when conversion is running to open another tab
when done, go to "Restore" and click "Flush" to delete all old HTML backed up content
TL;DR
This is a major refactoring of how the plugin processes posts for conversion, with several bigger simplifications. The build process is fixed and new features are added. Plugin is now ready for v.1.
Big changes
ncc_wp_posts
and the complex queuing systemreset
CLI command to "queue" new posts. Thereset
command was completely removedNewspackContentConverter\Converter::register_filters()
where they're now hardcoded and simplifiedncc_filter_html_before_conversion
ncc_filter_blocks_after_conversion
ncc_after_post_content_updated
Smaller changes
Future steps we can take, after this v.1 gets merged and released
runSinglePost
Test instructions
add/fix-build-and-refactor
composer install
nvm use 16
npm ci
npm run build