';
$before_tags_format = '
';
$after_tags_format = '
';
foreach( $values['subtype'] as $sub_type ){
$format = '';
$class = array();
if( $sub_type['type'] == 'color' ){
$class[] .= 'wpmbg_color_picker';
}
$class[] = 'wpmbg_'.$sub_type['type'].'_field';
if( !empty($sub_type['class']) ){
$class[] = $sub_type['class'];
}
$class_text = implode(' ', $class);
$html_format .= sprintf($before_tags_format, $class_text, $values['id'].'[{{i}}]['.$sub_type['id'].']', $sub_type['name']);
if( !empty($sub_type['desc']) ){
$sub_type['desc'] = '
'.$sub_type['desc'].'
';
}else{
$sub_type['desc'] = '';
}
if( $sub_type['type'] == 'text' || $sub_type['type'] == 'numbers_array' || $sub_type['type'] == 'color' ){
$format = '
%s';
$html_format .= sprintf( $format, $values['id'].'[{{i}}]['.$sub_type['id'].']', $values['id'].'[{{i}}]['.$sub_type['id'].']', '', $sub_type['desc'] );
}elseif( $sub_type['type'] == 'radio' ){
$entries = $this->select_entries($sub_type);
$format_radio = '
';
foreach( $entries as $id => $title ) {
$checked = '';
if( $sub_type['std'] == $id ) {
$checked = 'checked = "checked"';
}
$html_format .= sprintf( $format_radio, $values['id'].'[{{i}}]['.$sub_type['id'].']_'.$id, $values['id'].'[{{i}}]['.$sub_type['id'].']_'.$id, $values['id'].'[{{i}}]['.$sub_type['id'].']', $id, $checked, $title );
}
$html_format .= $sub_type['desc'];
}elseif( $sub_type['type'] == 'checkbox' ){
$entries = $this->select_entries($sub_type);
$format_checkbox = '
';
foreach( $entries as $id => $title ) {
$checked ="";
$html_format .= sprintf( $format_checkbox, $values['id'].'[{{i}}]['.$sub_type['id'].']_'.$id, $values['id'].'[{{i}}]['.$sub_type['id'].']_'.$id, $values['id'].'[{{i}}]['.$sub_type['id'].'][]', $id, $checked, $title );
}
$html_format .= $sub_type['desc'];
}elseif( $sub_type['type'] == 'select' ){
$entries = $this->select_entries($sub_type);
$format_select = '
';
$html_format .= '
';
$html_format .= $sub_type['desc'];
}elseif( $sub_type['type'] == 'textarea' ){
$format_textarea = '%s
';
$html_format .= sprintf( $format_textarea, $sub_type['desc'], $values['id'].'[{{i}}]['.$sub_type['id'].']', $values['id'].'[{{i}}]['.$sub_type['id'].']', $sub_type['std'] );
}elseif( $sub_type['type'] == 'upload' ){
$button_text = (empty($sub_type['button_text'])) ? 'Upload' : $sub_type['button_text'];
$format_upload = '
%s';
$html_format .= sprintf( $format_upload, $values['id'].'[{{i}}]['.$sub_type['id'].']_preview', $values['id'].'[{{i}}]['.$sub_type['id'].']_upload', $values['id'].'[{{i}}]['.$sub_type['id'].']', '', $values['id'].'[{{i}}]['.$sub_type['id'].']', $button_text, $sub_type['desc'] );
}elseif( $sub_type['type'] == 'gallery' ){
$button_text = (empty($sub_type['button_text'])) ? 'Upload' : $sub_type['button_text'];
$html_format .= $sub_type['desc'];
$html_format .= '
';
}
$html_format .= $after_tags_format;
}
$html_format .= '