Autonomía digital y tecnológica

Código e ideas para una internet distribuida

Linkoteca. Archivo de navegación


add_filter( 'pods_field_pick_data_ajax_items', 'custom_pods_labels_in_pick_field_ajax', 1, 6 );
add_filter( 'pods_field_pick_data', 'custom_pods_labels_in_pick_field_data', 1, 6 );

function custom_pods_labels_in_pick_field_ajax($items, $name, $value, $options, $pod, $id) {
    if ( 'FIELDNAME' == $name ) {
        foreach ( $items as $key => &$data ) {
            if ( isset( $data['id'] ) ) {
                $data['text'] = custom_pods_select_field_label( $data['id'] );
                $data['name'] = $data['text'];
            }
        }
    }
    return $items;
}


function custom_pods_labels_in_pick_field_data($items, $name, $value, $options, $pod, $id) {
    // pods_meta_ prefix for Pods backend, pods_field_ prefix for front-facing Pods form
    if ( 'pods_meta_FIELDNAME' === $name || 'pods_field_FIELDNAME' === $name ) {
        if ( ! empty( $items ) && is_array( $items ) ) {
            foreach ( $items as $key => $item ) {
                if ( isset( $item['id'] ) ) {
                    $data['text'] = custom_pods_select_field_label( $data['id'] );
                    $data['name'] = $data['text'];
                } elseif ( is_numeric( $key ) && ! is_array( $item ) ) {
                    $items[ $key ] = custom_pods_select_field_label( $key );
                }
            }
        }
    }
    
    return $items;
}

function custom_pods_select_field_label( $id ) {
    // You can return anything you want here.
}
Compartir