function ptthemes_meta_box()
 {
     $custom_post_types_args = array();
     $custom_post_types = get_post_types($custom_post_types_args, 'objects');
     foreach ($custom_post_types as $content_type) {
         if ($content_type->name != 'nav_menu_item' && $content_type->name != 'attachment' && $content_type->name != 'revision' && $content_type->name != 'page') {
             $post_types = $content_type->name;
             $pt_metaboxes = get_post_custom_fields_templ($post_types);
             if (function_exists('add_meta_box') && $pt_metaboxes) {
                 apply_filters('templ_admin_post_type_custom_filter', add_meta_box('ptthemes-settings', apply_filters('templ_admin_post_custom_fields_title_filter', 'Custom Settings'), 'ptthemes_meta_box_content', $post_types, 'normal', 'high', array('post_types' => $post_types)));
             }
         }
     }
 }
 function ptthemes_metabox_insert($post_id)
 {
     global $globals;
     // verify nonce
     if (!wp_verify_nonce($_POST['templatic_meta_box_nonce'], basename(__FILE__))) {
         return $post_id;
     }
     // check autosave
     if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
         return $post_id;
     }
     $pt_metaboxes = get_post_custom_fields_templ($_POST['post_type']);
     $pID = $_POST['post_ID'];
     $counter = 0;
     foreach ($pt_metaboxes as $pt_metabox) {
         // On Save.. this gets looped in the header response and saves the values submitted
         if ($pt_metabox['type'] == 'text' or $pt_metabox['type'] == 'select' or $pt_metabox['type'] == 'checkbox' or $pt_metabox['type'] == 'textarea' or $pt_metabox['type'] == 'radio' or $pt_metabox['type'] == 'upload' or $pt_metabox['type'] == 'date' or $pt_metabox['type'] == 'multicheckbox' or $pt_metabox['type'] == 'geo_map' or $pt_metabox['type'] == 'texteditor') {
             $var = "ptthemes_" . $pt_metabox["name"];
             if ($pt_metabox['type'] == 'multicheckbox') {
                 if (is_array($_POST[$var])) {
                     $multi_chb = implode(",", $_POST[$var]);
                     unset($_POST[$var]);
                     $_POST[$var] = $multi_chb;
                 }
             }
             if ($pt_metabox['type'] == 'geo_map') {
                 update_post_meta($pID, 'geo_address', $_POST['ptthemes_geo_address']);
                 update_post_meta($pID, 'geo_latitude', $_POST['ptthemes_geo_latitude']);
                 update_post_meta($pID, 'geo_longitude', $_POST['ptthemes_geo_longitude']);
             }
             // if (isset($_POST[$var])) {
             if (get_post_meta($pID, $pt_metabox["name"]) == "") {
                 add_post_meta($pID, $pt_metabox["name"], $_POST[$var], true);
             } elseif ($_POST[$var] != get_post_meta($pID, $pt_metabox["name"], true)) {
                 update_post_meta($pID, $pt_metabox["name"], $_POST[$var]);
             } elseif ($_POST[$var] == "") {
                 delete_post_meta($pID, $pt_metabox["name"], get_post_meta($pID, $pt_metabox["name"], true));
             }
             // }
         }
     }
 }