Exemple #1
0
/**
 * Get fields by group.
 * 
 * Returns array of fields and their values:
 * array( 'myfield' => 'some text' )
 * 
 * @global type $wpcf
 * @staticvar array $cache
 * @param type $group_id
 * @param type $active
 * @return array
 */
function types_get_fields_by_group($group, $only_active = 'only_active')
{
    static $cache = array();
    $cache_key = md5(serialize(func_get_args()));
    if (isset($cache[$cache_key])) {
        return $cache[$cache_key];
    }
    $results = array();
    $only_active = $only_active === 'only_active' || $only_active === true ? true : false;
    $group = wpcf_admin_fields_get_group($group);
    if (!empty($group['id'])) {
        if ($only_active && $group['is_active']) {
            $fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug');
            foreach ($fields as $field) {
                $results[$field['id']] = wpcf_api_field_meta_value($field);
            }
        }
    }
    $cache[$cache_key] = $results;
    return $cache[$cache_key];
}
Exemple #2
0
/**
 * Gets field meta value.
 * 
 * @global type $wpcf
 * @param type $field
 * @param type $post_id
 * @return type 
 */
function types_field_meta_value($field, $post_id = null, $raw = false)
{
    return wpcf_api_field_meta_value($field, $post_id, $raw);
}