-
Notifications
You must be signed in to change notification settings - Fork 16
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
base: main
Are you sure you want to change the base?
Conversation
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)
post-meta-inspector.php
Outdated
@@ -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 ); |
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.
Typo; should be apply_filters
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.
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?
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.
Why are we unserializing now but weren't before?
The WPcom version was maybe_unserializing so I ported that behavior here.
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.
The filter name should probably just be pmi_post_meta_value;
Good idea
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)