Skip to content
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

FIX / Media Credit Plugin Migrator: save by-hand credits into postmeta #498

Merged
merged 6 commits into from May 21, 2024

Conversation

ronchambers
Copy link
Collaborator

@ronchambers ronchambers commented May 9, 2024

This PR fixes a previously merged PR ( #462 ) and adds a new supporting general use command.

The fix:

The previous PR had a note about a possible "loss of data" if a dry-run was not performed. This has been fixed so that a dry-run (while still available) is not required, since the data is now stored into post meta instead of being lost.

The new supporting command:

Now that the data (that would have been lost) is instead stored into post meta, there is now a new CLI command to output this data into a log file for human review. A human can review the data and decide if any further action needs to be taken.

The command: wp newspack-content-migrator review-media-credit-plugin-other-credits

Output log: MediaCreditPluginMigrator_cmd_review_media_credit_plugin_other_credits.log

The output log will contain SQL commands that can be reviewed and executed to update existing _media_credit post metas.

Sample log file output:

-- Attachment ID: 1028176 / Current media credit: Photo courtesy of Twitter

UPDATE wp_postmeta set meta_value = 'Photo from Eden Prairie' where meta_key = '_media_credit' and post_id = 1028176;
UPDATE wp_postmeta set meta_value = 'Courtesy of Eden on Twitter` where meta_key = '_media_credit' and post_id = 1028176;

Each block will contain the attachment id and the current _media_credit postmeta. If the current media credit is acceptable, then no action is needed for this attachment. But if the current media credit is not acceptable (misspellings, grammar, etc) or if one of the other found meta values is better, then execute the SQL to update the value. Or just write your own value and run the update sql or go to the attachment edit page in the wordpress admin and edit the _media_credit input box there.

Caution:

When executing the human-reviewed SQL, be sure to run locally first to make sure it's still valid sql and that single quotes are properly escaped \'.

Future idea:

  • Add a control to the existing Newspack Plugin "media credit" admin panel so that "other credits" (if exists) can be shown to an admin for review. Or change the output logging from SQL to just a CSV for easier client/publisher to review (since sql might not be understandable).

  • confirmed that PHPCS has been run

Copy link
Member

@naxoc naxoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this! Great idea with a less "destructive" approach.

I added some very small things in comments.

src/Command/General/MediaCreditPluginMigrator.php Outdated Show resolved Hide resolved
src/Command/General/MediaCreditPluginMigrator.php Outdated Show resolved Hide resolved
@ronchambers ronchambers requested a review from naxoc May 21, 2024 15:56
Copy link
Member

@naxoc naxoc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This looks great 👍

@ronchambers ronchambers merged commit 5be442d into trunk May 21, 2024
@ronchambers ronchambers deleted the fix/media-credit-save-postmeta branch May 21, 2024 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants