This plugin is a set of WP CLI commands, and scripts used during Newspack sites Live Launches and/or Content Updates.
This Plugin consists of various Migrators (which perform reusable or publisher-specific content migration), and the "Content Diff" logic.
Run composer install
.
The Plugin is installed on a the Staging Site, and executed there to import the most recent content from the current live site.
Migrators are classes which perform content migration and data reformatting functionality. They are organized like this:
- located in
src/Command
are WP CLI Command classes - located in
src/Logic
are business logic classes
There are two kinds of Commands
:
- General purpose -- located in
src/Command/General
, these contain the reusable WP data migration logic, used by multiple Live Launches; - Publisher-specific -- located in
src/Command/PublisherSpecific
, these are custom functionalities used one-time only for individual Publisher's specific needs.
The Content Diff is a functionality which updates Staging site's content by syncing the newest/freshest content from the Live site on top of the Staging site.
It fetches the newest content from the JP Rewind backup archive, by importing "live site's DB tables" side-by-side to the existing local WP tables, and then searches and imports the live site's newest content, and imports the missing "content diff" on top of the Staging site.
Take any existing migrator from the src/Command
and copy it either into the src/Command/General
or the src/Command/PublisherSpecific
with a new name.
Command classes implement the InterfaceCommand
which simply makes sure they register WP CLI commands.
The new Command should be registered in the newspack-custom-content-migrator.php
.
After creating a new Command, run composer dump-autoload
to update the autoloading files.
The Knife uses the content_diff_update.sh script to run the whole CD update automatically.
Alternatively, the Content Diff CLI command class exposes commands which we can run manually to first detect the newest content (newspack-content-migrator content-diff-search-new-content-on-live
) and then import it (newspack-content-migrator content-diff-migrate-live-content
).