This documentation is deprecated since Admin Columns version 4.
Please view the updated version of this documentation here.

Change the available custom field types with this filter cac/column/meta/types

Usage

/**
 * Filter cac/column/meta/types
 *
 * @param array $custom_field_types All available custom field types
 */
function my_cac_custom_field_types( $custom_field_types ) {

    // Possibly modify $custom_field_types

    return $custom_field_types;
}
add_filter( 'cac/column/meta/types', 'my_cac_custom_field_types' );

Examples

In this example we will add price type to the Custom Field column.

/**
 * Example: Add a price type to the Custom Field types
 *
 */
function my_cac_custom_field_type_add_price( $custom_field_types ) {

    $custom_field_types['price'] = __( 'Price', 'plugin_textdomain' );

    return $custom_field_types;
}
add_filter( 'cac/column/meta/types', 'my_cac_custom_field_type_add_price' );

With the filter cac/column/meta/value wil will add a $ sign to each outputted column value.

/**
 * Example: Add a currency symbol to the price type
 *
 */
function my_column_meta_value_display_price( $value, $object_id, $column ) {

	if ( 'column-meta' == $column->get_type() && 'price' == $column->get_field_type() ) {
		$value = '$ ' . $value;
	}

	return $value;
}
add_filter( 'cac/column/meta/value', 'my_column_meta_value_display_price', 10, 3 );