$value){ $font_options.=''; } return $font_options; } function itls_logo_showcase_metaboxname() { global $itls_logo_showcase_metaboxname_fields, $post; // Use nonce for verification $html= ''; // Begin the field table and loop $html.= ''; foreach ($itls_logo_showcase_metaboxname_fields as $field) { if(isset($field['dependency'])) { $html.=itls_logo_showcase_dependency($field['id'],$field['dependency']); } // get value of this field if it exists for this post $meta = get_post_meta($post->ID, $field['id'], true); // begin a table row with if($field['type']=='hidden') { $html.= ''; continue; } // begin a table row with $style=''; if($field['type']=='notype') $style='style="border-bottom:solid 1px #ccc"'; $html.= ''; } // end foreach $html.= '
'; switch($field['type']) { case 'html_editor': { ob_start(); $html.= '

'.$field['desc'].'

'; $editor_id =$field['id']; wp_editor( $meta, $editor_id ); $html.= ob_get_clean(); $html.='

'; } break; case 'textarea': $html.= '
'.$field['desc'].' '; break; case 'url': $html.= '
'.$field['desc'].' '; break; case 'email': $html.= '
'.$field['desc'].' '; break; case 'text': $html.= '
'.$field['desc'].' '; break; case 'hidden': $html.= ''; break; case 'radio': foreach ( $field['options'] as $option ) { $html.= '

'; } break; case 'select': $html.= '
'.$field['desc'].''; break; case 'numeric': $default_value=(isset($field['value'])? $field['value']:""); $html.= ' '; $html.= '
'.$field['desc'].''; break; case 'checkbox': $html.= '
'.$field['desc'].''; break; case 'radio': foreach ( $field['options'] as $option ) { $html.= '

'; } break; case "upload": { $image=''; $image = ITLS_LOGO_SHOWCASE_URL.'/assets/images/it-transparent.gif'; $html.= '
'.basename(wp_get_attachment_url($meta)).'
'; } break; case "gallery": { $image=''; $image = ITLS_LOGO_SHOWCASE_URL.'/assets/images/it-transparent.gif'; if ($meta) { $image_gallery=explode(",",$meta); $images=''; foreach($image_gallery as $ima){ $image = wp_get_attachment_image_src($ima, 'medium'); $image = $image[0]; $images.='
X
'; } $image=$images; }else { $image=''; } $html.= '
'.$image.'
'; } break; } //end switch $html.= '
'; // end table echo $html; } function itls_logo_showcase_save_custom_meta ($post_id) { //die(print_r($_POST)); global $itls_logo_showcase_metaboxname_fields; // verify nonce if(isset($_POST) && !empty($_POST)){ if (isset($_POST['show_custom_meta_box_logo_showcase_grid_nonce']) && !wp_verify_nonce($_POST['show_custom_meta_box_logo_showcase_grid_nonce'], basename(__FILE__))) return $post_id; // check autosave if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return $post_id; // check permissions if (isset($_POST['post_type']) && 'page' == $_POST['post_type']) { if (!current_user_can('editls_page', $post_id)) return $post_id; } elseif (!current_user_can('editls_post', $post_id)) { return $post_id; } foreach ($itls_logo_showcase_metaboxname_fields as $field) { if(!isset($_POST[$field['id']])){ delete_post_meta($post_id, $field['id']); continue; } $post = get_post($post_id); $category = $_POST[$field['id']]; wp_set_post_terms( $post_id, $category, $field['id'],false ); $old = get_post_meta($post_id, $field['id'], true); $new = $_POST[$field['id']]; if ('' == $new && ($old||$old==0)) { delete_post_meta($post_id, $field['id'], $old); }elseif (($new ||$new==0) && $new != $old) { update_post_meta($post_id, $field['id'], $new); } } // end foreach } } add_action('save_post', 'itls_logo_showcase_save_custom_meta'); ?>