<?php
$cat_display=get_option('ptthemes_category_dislay');
if($cat_display=='select'){
	for($c=0;$c<count($cat_array);$c++)
	{
		$catid = $cat_array[$c];
		$taxonomy = CUSTOM_CATEGORY_TYPE1;
		$catname = $wpdb->get_var("select t.term_id from $wpdb->terms t join $wpdb->term_taxonomy tt on tt.term_id=t.term_id  where t.name=\"$catid\" and tt.taxonomy=\"$taxonomy\"");
		$cat_array = $catname;	
	}
$cat_args = array('name' => 'category[]', 'id' => 'scat', 'selected' => $cat_array, 'class' => 'textfield', 'orderby' => 'name', 'echo' => '1', 'hierarchical' => 1, 'taxonomy'=>CUSTOM_CATEGORY_TYPE1);
$cat_args['show_option_none'] = __('Select Category');
wp_dropdown_categories(apply_filters('widget_categories_dropdown_args', $cat_args));
}else
{
	global $wpdb;
	$catsql = "select c.term_id, c.name from $wpdb->terms c,$wpdb->term_taxonomy tt  where tt.term_id=c.term_id and tt.taxonomy='".CUSTOM_CATEGORY_TYPE1."' $substr order by c.name";
	$catinfo = $wpdb->get_results($catsql);
	global $cat_array;
	if($catinfo)
	{
		$cat_display=get_option('ptthemes_category_dislay');
		if($cat_display==''){$cat_display='checkbox';}
		$counter = 0;
		foreach($catinfo as $catinfo_obj)
		{
			$counter++;
			$termid = $catinfo_obj->term_id;
			$name = $catinfo_obj->name;
			if($cat_display=='checkbox'){
			?>
			<div class="form_cat" ><label><input type="checkbox" name="category[]" id="category_<?php echo $counter;?>" value="<?php echo $name; ?>" class="checkbox" <?php if(isset($cat_array) && in_array($name,$cat_array)){echo 'checked="checked"'; }?> />&nbsp;<?php echo $name; ?></label></div>
			<?php
			}elseif($cat_display=='radio')
			{
			?>
			<div class="form_cat" ><label><input type="radio" name="category[]" id="category_<?php echo $counter;?>" value="<?php echo $name; ?>" class="checkbox" <?php if(isset($cat_array) && in_array($name,$cat_array)){echo 'checked="checked"'; }?> />&nbsp;<?php echo $name; ?></label></div>
			<?php
			}
		}
	}
}
?>