Open lophas opened 5 years ago
class cmb2_fix { const TYPES = ['term', 'user']; static private $_instance;function instance() {if(!isset(self::$_instance)) self::$_instance = new self();return self::$_instance;} function __construct() { add_filter('cmb2_override_meta_value', function($data, $object_id, $a, $instance) { if(!in_array($a['type'], self::TYPES) || !$a['repeat']) return $data; $data = get_metadata( $a['type'], $a['id'], $a['field_id'], false ); return $data; }, 10, 4); add_filter( 'cmb2_override_meta_save', function($override, $a, Array $args, $instance ) { if(!in_array($a['type'], self::TYPES) || !$a['repeat']) return $override; $id = delete_metadata($a['type'], $a['id'], $a['field_id']); if(!empty($a['value'])) foreach($a['value'] as $value) $id = add_metadata( $a['type'], $a['id'], $a['field_id'], $value, false ); return $id ? $id : false; }, 10, 4); } //__construct } //cmb2_fix cmb2_fix::instance();
Hi,
could you clarify your intention here? Is this a PR? A suggestion? A problem?
Closed by mistake.