Home / APIs / _wp_register_meta_args_whitelist() – Filter out `register_meta()` args based on a whitelist.

Description

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.

Usage

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

Parameters

$args
( array ) required – Arguments from `register_meta()`.
$default_args
( array ) required – Default arguments for `register_meta()`.

Returns

array Filtered arguments.

Source

File name: wordpress/wp-includes/meta.php
Lines: 1 to 12 of 12

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;
}
 

 View on GitHub View on Trac

Called by

    Invoked by

      Calls

      1 to 1 of 1

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

      Call hooks

      Function name: _wp_register_meta_args_whitelist
      Plugin ref: WordPress
      Version: 4.9
      Sourcefile: wp-includes/meta.php
      File ref: wp-includes/meta.php
      API type: private
      Deprecated?: No
      API Letters: _,A,M,R,W

      Published: 12th March 2017 | Last updated: 12th March 2017

      Information

      Function name: _wp_register_meta_args_whitelist
      Plugin ref: WordPress
      Version: 4.9
      Sourcefile: wp-includes/meta.php
      File ref: wp-includes/meta.php
      API type: private
      Deprecated?: No
      API Letters: _,A,M,R,W

      • Plugins
      • Themes
      • Shortcodes
      • APIs
      • Files
      • Hooks
      • Classes
      • Sites
      • Sitemap
      • Blog
      WooCommerce a2z WooCommerce a2z
      WooCommerce

      Site:  woocommerce.wp-a2z.org
      © Copyright WooCommerce a2z 2014-2018. All rights reserved.


      Website designed and developed by Herb Miller
      Proudly powered by WordPress and oik plugins