'."\n";
foreach ($woo_metaboxes as $woo_id => $woo_metabox) {
if(
$woo_metabox['type'] == 'text'
OR $woo_metabox['type'] == 'select'
OR $woo_metabox['type'] == 'checkbox'
OR $woo_metabox['type'] == 'textarea'
OR $woo_metabox['type'] == 'radio'
)
$woo_metaboxvalue = get_post_meta($post->ID,$woo_metabox["name"],true);
if ($woo_metaboxvalue == "" || !isset($woo_metaboxvalue)) {
$woo_metaboxvalue = $woo_metabox['std'];
}
if($woo_metabox['type'] == 'text'){
$output .= "\t".'
';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".'';
$output .= ''.$woo_metabox['desc'].' | '."\n";
$output .= "\t".' |
'."\n";
}
elseif ($woo_metabox['type'] == 'textarea'){
$output .= "\t".'';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".'';
$output .= ''.$woo_metabox['desc'].' | '."\n";
$output .= "\t".' |
'."\n";
}
elseif ($woo_metabox['type'] == 'select'){
$output .= "\t".'';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".''.$woo_metabox['desc'].' | | '."\n";
$output .= "\t".'
'."\n";
}
elseif ($woo_metabox['type'] == 'checkbox'){
if($woo_metaboxvalue == 'true') { $checked = ' checked="checked"';} else {$checked='';}
$output .= "\t".'';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".'';
$output .= ''.$woo_metabox['desc'].' | | '."\n";
$output .= "\t".'
'."\n";
}
elseif ($woo_metabox['type'] == 'radio'){
$array = $woo_metabox['options'];
if($array){
$output .= "\t".'';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".'';
foreach ( $array as $id => $option ) {
if($woo_metaboxvalue == $option) { $checked = ' checked';} else {$checked='';}
$output .= '';
$output .= ''. $option .'';
}
$output .= ' | | '."\n";
$output .= "\t".'
'."\n";
}
}
elseif($woo_metabox['type'] == 'upload')
{
$output .= "\t".'';
$output .= "\t\t".' | '."\n";
$output .= "\t\t".''. woothemes_uploader_custom_fields($post->ID,$woo_metabox["name"],$woo_metabox["default"],$woo_metabox["desc"]);
$output .= ' | '."\n";
$output .= "\t".'
'."\n";
}
}
$output .= ''."\n\n";
echo $output;
}
function woothemes_uploader_custom_fields($pID,$id,$std,$desc){
// Start Uploader
$upload = get_post_meta( $pID, $id, true);
$uploader .= '';
$uploader .= ''."\n";
$uploader .= '';
$uploader .= '';
$uploader .= ''.$desc.''."\n".' ';
return $uploader;
}
function woothemes_metabox_handle(){
global $globals;
$woo_metaboxes = get_option('woo_custom_template');
$pID = $_POST['post_ID'];
$upload_tracking = array();
if ($_POST['action'] == 'editpost'){
foreach ($woo_metaboxes as $woo_metabox) { // On Save.. this gets looped in the header response and saves the values submitted
if($woo_metabox['type'] == 'text' OR $woo_metabox['type'] == 'select' OR $woo_metabox['type'] == 'checkbox' OR $woo_metabox['type'] == 'textarea' ) // Normal Type Things...
{
$var = "woothemes_".$woo_metabox["name"];
if (isset($_POST[$var])) {
if( get_post_meta( $pID, $woo_metabox["name"] ) == "" )
add_post_meta($pID, $woo_metabox["name"], $_POST[$var], true );
elseif($_POST[$var] != get_post_meta($pID, $woo_metabox["name"], true))
update_post_meta($pID, $woo_metabox["name"], $_POST[$var]);
elseif($_POST[$var] == "") {
delete_post_meta($pID, $woo_metabox["name"], get_post_meta($pID, $woo_metabox["name"], true));
}
}
elseif(!isset($_POST[$var]) && $woo_metabox['type'] == 'checkbox') {
update_post_meta($pID, $woo_metabox["name"], 'false');
}
else {
delete_post_meta($pID, $woo_metabox["name"], get_post_meta($pID, $woo_metabox["name"], true)); // Deletes check boxes OR no $_POST
}
}
elseif($woo_metabox['type'] == 'upload') // So, the upload inputs will do this rather
{
$id = $woo_metabox['name'];
$override['action'] = 'editpost';
if(!empty($_FILES['attachement_'.$id]['name'])){ //New upload
$uploaded_file = wp_handle_upload($_FILES['attachement_' . $id ],$override);
$uploaded_file['option_name'] = $woo_metabox['label'];
$upload_tracking[] = $uploaded_file;
update_post_meta($pID, $id, $uploaded_file['url']);
}
elseif(empty( $_FILES['attachement_'.$id]['name']) && isset($_POST[ $id ])){
update_post_meta($pID, $id, $_POST[ $id ]);
}
elseif($_POST[ $id ] == '') { delete_post_meta($pID, $id, get_post_meta($pID, $id, true));
}
}
// Error Tracking - File upload was not an Image
update_option('woo_custom_upload_tracking', $upload_tracking);
}
}
}
function woothemes_metabox_add() {
if ( function_exists('add_meta_box') ) {
add_meta_box('woothemes-settings',get_option('woo_themename').' Custom Settings','woothemes_metabox_create','post','normal');
add_meta_box('woothemes-settings',get_option('woo_themename').' Custom Settings','woothemes_metabox_create','page','normal');
}
}
function woothemes_metabox_header(){
?>
|