_wp_register_meta_args_whitelist

Filter out `register_meta()` args based on a whitelist.

Description

(array) _wp_register_meta_args_whitelist( (array) $args, (array) $default_args ); 

'register_meta()' args may change over time, so requiring the whitelist to be explicitly turned off is a warranty seal of sorts.

Returns (array)

Filtered arguments.

Parameters (2)

0. $args (array)
Arguments from register_meta()..
1. $default_args (array)
Default arguments for register_meta()..

Usage

  1. if ( !function_exists( '_wp_register_meta_args_whitelist' ) ) { 
  2. require_once ABSPATH . WPINC . '/meta.php'; 
  3.  
  4. // Arguments from `register_meta()`. 
  5. $args = array(); 
  6.  
  7. // Default arguments for `register_meta()`. 
  8. $default_args = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = _wp_register_meta_args_whitelist($args, $default_args); 
  12.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/meta.php  
  1. function _wp_register_meta_args_whitelist( $args, $default_args ) { 
  2. $whitelist = array_keys( $default_args ); 
  3.  
  4. // In an anonymous function world, this would be better as an array_filter() 
  5. foreach ( $args as $key => $value ) { 
  6. if ( ! in_array( $key, $whitelist ) ) { 
  7. unset( $args[ $key ] ); 
  8.  
  9. return $args;