A WordPress-centric search engine for devs and theme authors



_wp_register_meta_args_whitelist ›

Since4.6.0
Deprecatedn/a
_wp_register_meta_args_whitelist ( $args, $default_args )
Access:
  • private
Parameters: (2)
  • (array) $args Arguments from `register_meta()`.
    Required: Yes
  • (array) $default_args Default arguments for `register_meta()`.
    Required: Yes
Returns:
  • (array) Filtered arguments.
Defined at:
Codex:

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

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



Source

function _wp_register_meta_args_whitelist( $args, $default_args ) {
	$whitelist = array_keys( $default_args );

	// In an anonymous function world, this would be better as an array_filter()
	foreach ( $args as $key => $value ) {
		if ( ! in_array( $key, $whitelist ) ) {
			unset( $args[ $key ] );
		}
	}

	return $args;
}