-
Notifications
You must be signed in to change notification settings - Fork 5
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
Add / Media Credit Plugin Migrator #462
Conversation
@iuravic - feel free to review. I worked with Andrew on the first "caution/dry-run" issue already and I posted to Slack in regards to the second "caution". So I feel confident on the logic here, but if you see any issues within the code feel free to let me know :-) |
Commit f328cfb FIXES an issue with how the Media Credit Plugin wrote Old/wrong with line break:
New/fixed without line break:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep in mind even if the plugin code is changed, and the CLI outputs Blocks, there is a chance that a single block inside classic HTML might make the block converter not convert the other content within the post (it appears that if a classic html post has a block as the first element, the remaining content might no be converted).
In this PR #487 there are some CLI tools to "nudge" posts that start with a block so the NCC will pick it up, so that should not be a concern once we merge that.
This PR adds a general command to migrate the Media Credit Plugin to native
[caption]
shortcodes and post meta_media_credit
for use with the Newspack Plugin media credits.Caution: (FIXED WITH #498) This command can cause data to be lost. Please perform a
--dry-run
and examine the final "Report" section for data differences that will be removed from the post content image captions. The Media Credit Plugin not only stores media credits in the post meta table using the_media_credit
key, it also allows Admins to add custom credits on images directly in the post editor. In many cases these custom strings match the value in post meta, but many times they do not. The CLI command in this PR will attempt to save the custom string into the post meta if the post meta is blank, but in the cases where the post meta already exists and is different than the custom string, the custom strings are removed from the post content. The only way to capture these for Publisher review is to do a--dry-run
and view the "Report" section at the end of the log output for "by-hand" review.Caution: This command must be run prior to converting post content to Blocks, otherwise the block converter will be unable to properly remove the Media Credit Plugin's
[media-credit]
shortcode. This command will convert[media-credit]
shortcodes to native[caption]
shortcodes that the Block converter can properly convert.Command:
wp newspack-content-migrator migrate-media-credit-plugin
Output:
MediaCreditPluginMigrator_cmd_migrate_media_credit_plugin.log
Options:
--dry-run
will provide adata loss"Report" at the end of the log. (Data loss is fixed with PR)Future ideas:
[caption]
and[media-credit]
shortcodes directly into Blocks and stash the custom credit strings into the blocksmeta
. The Newspack Plugin allows custommeta
, but only if post meta isn't set. What we need is the ability to add custom meta even if post meta exists. This line needs to move to this line. Keep in mind even if the plugin code is changed, and the CLI outputs Blocks, there is a chance that a single block inside classic HTML might make the block converter not convert the other content within the post (it appears that if a classic html post has a block as the first element, the remaining content might no be converted).--dry-run
"Report" differences to additional post meta so text file differences don't need to be captured (ie: the lost data will be saved to the attachment image's post meta for safe keeping).