0)) $output .= ' style="display:none;"';
$output .= '>';
$output .= '
';
$output .= '
';
$output .= $field_title.'
'.$field_desc.'';
$output .= '
';
$tab_count++;
// Is a field divider
}elseif($field_type == 'divider'){
$output .= '
';
$output .= '
'.$field_title.'
';
$output .= '';
//Is a normal field. Print field containers
}else{
$output .= '
';
$output .= '
';
$output .= '
';
}
if($field_type == 'text')
$output .= cpotheme_form_text($field_name, $field_value, $current_field);
elseif($field_type == 'textarea')
$output .= cpotheme_form_textarea($field_name, $field_value, $current_field);
elseif($field_type == 'select')
$output .= cpotheme_form_select($field_name, $field_value, $current_field['option'], $current_field);
elseif($field_type == 'checkbox')
$output .= cpotheme_form_checkbox($field_name, $field_value, $current_field);
elseif($field_type == 'yesno')
$output .= cpotheme_form_yesno($field_name, $field_value, $current_field);
elseif($field_type == 'color')
$output .= cpotheme_form_color($field_name, $field_value);
elseif($field_type == 'imagelist')
$output .= cpotheme_form_imagelist($field_name, $field_value, $current_field['option'], $current_field);
elseif($field_type == 'upload')
$output .= cpotheme_form_upload($field_name, $field_value);
elseif($field_type == 'font')
$output .= cpotheme_form_font($field_name, $field_value, $current_field['option'], $current_field);
//Separators
if($field_type != 'separator' && $field_type != 'divider'){
$output .= '
';
$output .= '
'.$field_desc.'
';
$output .= '
';
}
unset($current_field);
}
$output .= '
';
$output .= '
';
echo $output;
}
//Save all settings upon submitting the settings form
function cpotheme_custom_save($option_name, $option_fields){
$lang_url = cpotheme_custom_wpml_option_url();
$option_name = $option_name.cpotheme_custom_wpml_option_suffix();
if(isset($_POST['cpotheme_custom_tab']) && $_POST['cpotheme_custom_tab'] != '')
$current_tab = '&tab='.htmlentities($_POST['cpotheme_custom_tab']);
else
$current_tab = '';
//Check if we're submitting a custom page
if(isset($_POST['cpotheme_custom_action']) && $_POST['cpotheme_custom_action'] == $option_name){
if(!wp_verify_nonce($_POST['_wpnonce'], 'cpotheme_nonce')) header("Location: admin.php?page=".$_GET['page'].$lang_url."&error");
//Get the option array, then update the array values
$options_list = get_option($option_name, false);
foreach($option_fields as $current_option){
$field_id = $current_option["id"];
//If the field has an update, process it.
if(isset($_POST[$field_id])){
$field_value = '';
$field_value = esc_attr(trim($_POST[$field_id]));
$current_value = '';
if(isset($options_list[$field_id]))
$current_value = $options_list[$field_id];
// Add option
if($current_value == '' && $field_value != ''){
$options_list[$field_id] = $field_value;
}
// Update option
elseif($field_value != $current_value){
$options_list[$field_id] = $field_value;
}
// Delete unused option
elseif($field_value == ''){
//TODO: Check default values
$options_list[$field_id] = $field_value;
}
}
}
update_option($option_name, $options_list);
header('Location: admin.php?page='.$_GET['page'].$current_tab.$lang_url."&ok");
}
}
function cpotheme_custom_header(){
$theme_data = wp_get_theme(); ?>