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

Add filter to post_meta value #15

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add filter to post_meta value #15

wants to merge 5 commits into from

Conversation

sboisvert
Copy link

In some cases it is useful to have a more granular control over what post_meta is shown to the end user. Or modify some values before showing them to the user (json_decode, base64_decode, etc)

In some cases it is useful to have a more granular control over what post_meta is shown to the end user. Or modify some values before showing them to the user (json_decode, base64_decode, etc)
@@ -93,7 +93,7 @@ public function post_meta_inspector() {
?>
<?php foreach( $values as $value ) : ?>
<?php
$value = var_export( $value, true );
$value = apply_filter( 'pmi_modify_post_meta_value', var_export( maybe_unserialize( $value ), true ), $key, $value );
Copy link
Member

Choose a reason for hiding this comment

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

Typo; should be apply_filters

Copy link
Member

Choose a reason for hiding this comment

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

Two other things:

  • The filter name should probably just be pmi_post_meta_value; we're not actually modifying the value so the name is misleading.
  • Why are we unserializing now but weren't before?

Copy link
Author

Choose a reason for hiding this comment

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

Why are we unserializing now but weren't before?

The WPcom version was maybe_unserializing so I ported that behavior here.

Copy link
Author

Choose a reason for hiding this comment

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

The filter name should probably just be pmi_post_meta_value;

Good idea

@trepmal
Copy link
Contributor

trepmal commented Jun 3, 2021

Note: this PR addresses also #7 and #18 (unserializing data). I see no harm, but we may want to reconfirm after all these years.

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.

3 participants