Advertisement
geminilabs

[site-reviews-forms] enable Custom Fields meta box and unprotect custom fields

Sep 13th, 2022 (edited)
1,038
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. /**
  2.  * Enable the Custom Fields metabox for reviews
  3.  * @return void
  4.  */
  5. add_action('admin_init', function () {
  6.     add_post_type_support('site-review', 'custom-fields');
  7. });
  8.  
  9. /**
  10.  * Unprotect "_custom_*" meta_keys
  11.  * @param bool $protected
  12.  * @param string $metakey
  13.  * @return bool
  14.  */
  15. add_filter('is_protected_meta', function ($protected, $metakey) {
  16.     $prefix = '_custom_';
  17.     if (0 === strncmp($metakey, $prefix, strlen($prefix))) {
  18.         return false;
  19.     }
  20.     return $protected;
  21. }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement