woothemes/projects — pull request #51 by helgatheviking (2014-03-25 10:53:33+00:00)
Title: Custom fields for product data

Allow custom fields to be built out by users. A sample select type could then be created via:

`

function gb_custom_fields( $fields ){
$fields['select'] = array(
'name'	=> __( 'Select', 'projects' ),
'description'	=> __( 'Test a dropdown', 'projects' ),
'type'	=> 'select',
'default'	=> 'b',
'section'	=> 'info',
'options'	=> array( 'a' => 'Apple', 'b' => 'Bacon' )
);
return $fields;
}
add_filter( 'projects_custom_fields', 'gb_custom_fields' );

function gb_select_field( $html, $k, $data, $v ){
$html = ''. "\n";

if( isset( $v['options'] ) && is_array( $v['options'] ) ){
foreach ( $v['options'] as $val => $option ){
$html .= '
'. $option .'
' . "\n";
}
}
$html .= ''. "\n";
return $html;
}
add_filter( 'projects_data_field_type_select', 'gb_select_field', 10, 4 );
`