errr… sorry I later realized that the function sf_get_postmeta_values
was meant for completely different purposes
not being able to know a Types plugin native alternative
whereas the type of the field could be more simply checked with _wpcf_is_checkboxes_field( $m );
I changed the applied filters to
$meta = apply_filters( 'sf_post_meta_key_values', $meta, get_the_ID(), $m );
$meta = maybe_unserialize($meta);
and added them in the init (e.g. includes\types-checkboxes.php)
add_filter( 'sf_post_meta_key_values', array( $this, 'sf_types_postmeta_values_of_checkboxes' ), 10, 4 );
and finally the new function
function sf_types_postmeta_values_of_checkboxes( $return, $object_id, $meta_key, $single=false ){
if( !preg_match( '^wpcf^', $meta_key ) )
return null;
//if ( !_wpcf_is_checkboxes_field( $meta_key ) )
$keycheckbox = array( 'add_this' => false, 'meta_key' => $m );
$checkbox = sf_types_is_checkbox( $keycheckbox );
if( $checkbox['add_this'] )
return null;
$meta_cache = wp_cache_get($object_id, 'post_meta');
if ( !$meta_cache ) {
$meta_cache = update_meta_cache( $meta_type, array( $object_id ) );
$meta_cache = $meta_cache[$object_id];
}
if ( ! $meta_key ) {
$return = $meta_cache;
}elseif( isset($meta_cache[$meta_key]) ) {
if ( $single )
$return = maybe_unserialize( $meta_cache[$meta_key][0] );
else
$return = array_map('maybe_unserialize', $meta_cache[$meta_key]);
}elseif ($single)
$return = '';
else
$return = array();
if(is_array($return) && !empty($return)) {
$types = get_option( 'wpcf-fields' );
$choices = array();
//echo '<pre>'; print_r($types); echo '</pre>';
foreach( $types as $type ){
if( isset( $type['data']['options'] ) && isset( $type['meta_key'] ) && $type['meta_key'] == $meta_key ){
foreach( $type['data']['options'] as $index => $option ){
if(isset($return[$index]) && !empty($return[$index]))
if( isset( $type['type'] )&& $type['type'] == 'checkboxes' )
if(isset($option['set_value']) && in_array($option['set_value'], $return[$index]) && !in_array($option['set_value'], array_keys($choices)))
$choices[$option['set_value']] = $option['title'];
elseif( isset( $type['type'] )&& $type['type'] == 'select' )
if(isset($option['value']) && in_array($option['value'], $return[$index]) && !in_array($option['value'], array_keys($choices)))
$choices[$option['value']] = $option['title'];
}
}
}
if( count( $choices ) > 0 ){
sort($choices);
$choices = array_unique(array_filter($choices));
//print_r($choices);
if ($single)
return maybe_serialize($choices);
//return '<ul><li>'.implode('</li><li>', $choices).'</li></ul>';
else
return $choices;
}
}
return $return;
}
however, I had to further fork the original code to support manipulating output with a filter at the end of the sf_do_search
function in ajax.php
$data = apply_filters('sf-get-search-data',$data,$args);
it would be extremely useful in a possible future update, in addition to the already existing and useful previous query $args filtering, to have the chance to filter the output data array as well