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

Post meta: Update meta keys to be private #1090

Open
wants to merge 14 commits into
base: trunk
Choose a base branch
from

Conversation

obenland
Copy link
Member

WordPress convention states that meta keys prefixed with an underscore are considered private and hidden from the custom fields UI. Since our meta keys are for internal plugin use only, they should follow this convention.

This change helps prevent accidental modification of ActivityPub meta data through WordPress's custom fields interface while maintaining the expected pattern for plugin developers.

See: https://developer.wordpress.org/plugins/metadata/managing-post-metadata/#hidden-custom-fields

Fixes #943

Proposed changes:

  • Added a migration routine in class-migration.php to prefix meta keys with underscores
  • Updated class-test-followers.php to use the new prefixed meta keys (activitypub*)
  • Updated class-test-migration.php to test the migration directly instead of through maybe_migrate()
  • Fixed all meta key references across the codebase to use the new prefixed versions (e.g., activitypub_user_id_activitypub_user_id)

Other information:

  • Have you written new tests for your changes, if applicable?

Testing instructions:

  • Go to '..'

@obenland obenland requested a review from a team December 17, 2024 21:37
@obenland obenland self-assigned this Dec 17, 2024
@github-actions github-actions bot added [Feature] Collections [Focus] Compatibility Ensuring the plugin plays well with other plugins [Focus] Editor Changes to the ActivityPub experience in the block editor labels Dec 17, 2024
@obenland
Copy link
Member Author

@pfefferle I remember you mentioning certain post meta keys that should be private, which ones were those?

@pfefferle
Copy link
Member

pfefferle commented Dec 18, 2024

It was more about if there are some that should not be private. Like for example the visibility one. So that classic editor users can add that through the meta forms for example.

WordPress convention states that meta keys prefixed with an underscore are
considered private and hidden from the custom fields UI. Since our meta keys
are for internal plugin use only, they should follow this convention.

This change helps prevent accidental modification of ActivityPub meta data
through WordPress's custom fields interface while maintaining the expected
pattern for plugin developers.

See: https://developer.wordpress.org/plugins/metadata/managing-post-metadata/#hidden-custom-fields
Needs to be editable in editor
@obenland obenland force-pushed the update/private-post-meta-keys branch from edfd9b5 to cbf88af Compare December 18, 2024 18:03
pfefferle
pfefferle previously approved these changes Dec 18, 2024
Copy link
Member

@pfefferle pfefferle left a comment

Choose a reason for hiding this comment

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

Nice!

pfefferle
pfefferle previously approved these changes Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post settings [Feature] Collections [Focus] Compatibility Ensuring the plugin plays well with other plugins [Focus] Editor Changes to the ActivityPub experience in the block editor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Underscore prefix for meta keys
2 participants