Skip to content

Instantly share code, notes, and snippets.

@eduardozulian
Last active February 21, 2024 11:01
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save eduardozulian/4354337 to your computer and use it in GitHub Desktop.
Save eduardozulian/4354337 to your computer and use it in GitHub Desktop.
WordPress filter to replace the default "_" (underscore) with "-" (hyphen) in protected custom fields for debugging purposes
<?php
/**
* Replace the default "_" (underscore) with "-" (hyphen) in protected custom fields for debugging purposes
*
* @param bool $protected The default value
* @param string $meta_key The meta key
* @return bool True for meta keys starting with "-" (hyphen), false otherwise
*/
function unprotected_meta( $protected, $meta_key ) {
$protected = ( '-' == $meta_key[0] );
return $protected;
}
add_filter( 'is_protected_meta', 'unprotected_meta', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment