cmb2_get_metabox_sanitized_values

Returns array of sanitized field values from a metabox (without saving them).

Description

cmb2_get_metabox_sanitized_values( (mixed) $meta_box, (array) array $data_to_sanitize ); 

Parameters (2)

0. $meta_box (mixed)
Metabox ID or Metabox config array
1. $data_to_sanitize (array) => array $data_to_sanitize
Array of field_id => value data for sanitizing (likely $_POST data).

Usage

  1. if ( !function_exists( 'cmb2_get_metabox_sanitized_values' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'cmb2/includes/helper-functions.php'; 
  3.  
  4. // Metabox ID or Metabox config array 
  5. $meta_box = null; 
  6.  
  7. // Array of field_id => value data for sanitizing (likely $_POST data). 
  8. $data_to_sanitize = array(); 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = cmb2_get_metabox_sanitized_values($meta_box, $data_to_sanitize); 
  12.  

Defined (1)

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

/includes/helper-functions.php  
  1. function cmb2_get_metabox_sanitized_values( $meta_box, array $data_to_sanitize ) { 
  2. $cmb = cmb2_get_metabox( $meta_box ); 
  3. return $cmb ? $cmb->get_sanitized_values( $data_to_sanitize ) : false;