web/wp-content/themes/selecta/ocmx/ocmx-create-options.php
changeset 1 0d28b7c10758
equal deleted inserted replaced
0:0d9a58d2c515 1:0d28b7c10758
       
     1 <?php
       
     2 global $general_site_options, $social_media_options, $advert_options, $category_menu_options, $page_menu_options, $menu_options, $which_array;
       
     3 $general_site_options =
       
     4 	array(
       
     5 		array("label" => "Custom Logo", "description" => "Full URL or folder path to your custom logo.", "name" => $input_prefix."custom_logo", "default" => "/images/layout/logo.gif", "id" => "", "input_type" => "file"),
       
     6 		array("label" => "Color Options", "description" => "Select your desired colour option.", "name" => $input_prefix."theme_style", "default" => "blue", "id" => "", "input_type" => "select", "options" => array("Blue (Default)" => "blue", "Sea Blue" => "sea-blue", "White Rose" => "white-rose", "Blue &amp; Black" => "black-blue", "Black &amp; Green" => "black-green", "Black &amp; Red" => "black-red")),
       
     7 		array("label" => "Home Page Posts", "description" => "Number of Posts to display on the Home Page.", "name" => $input_prefix."home_page_posts", "default" => "5", "id" => "", "input_type" => "select", "options" => array("1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10", "15" => "15", "20" => "20")),
       
     8 		array("label" => "Home Page Categories", "description" => "Which Category will we display on the Home Page?", "name" => $input_prefix."home_page_categories", "default" => "", "id" => "", "input_type" => "select", "options" => "loop_categories"),
       
     9 		array("label" => "Home Page Images", "description" => "This will automatically generate an image for your posts on the home page if you have not specified an image in the 'image url' field when adding/updating a post.", "name" => $input_prefix."auto_home_images", "default" => "yes", "id" => "", "input_type" => "select", "options" => array("Yes" => "yes", "No" => "no")),
       
    10 		array("label" => "Site Analytics", "description" => "Enter in the Google Analytics Script here.","name" => $input_prefix."googleAnalytics", "default" => "", "id" => "","input_type" => "memo")
       
    11 	);
       
    12 	
       
    13 $social_media_options =
       
    14 	array(
       
    15 		array(
       
    16 			"main_section" => "RSS Details",
       
    17 			"main_description" => "This will allow visitors to subscribe to your custom RSS feed, as well as your Feedburner Feed via e-mail.",
       
    18 			"sub_elements" => 
       
    19 				array(
       
    20 					array("label" => "RSS URL", "description" => "", "name" => $input_prefix."rss_url", "default" => "", "id" => "", "input_type" => "text"),
       
    21 					array("label" => "Feedburner ID", "description" => "", "name" => $input_prefix."feedburner_id", "default" => "", "id" => "", "input_type" => "text")
       
    22 				)
       
    23 		),
       
    24 		array("label" => "Promote Post Options", "description" => "This will allow you to include Digg, Moo, Bump and Tweetmeme links in your posts.", "name" => $input_prefix."promote_posts", "default" => "yes", "id" => $input_prefix."promote_posts", "input_type" => "select", "options" => array("Yes" => "yes", "No" => "no"))
       
    25 	);
       
    26 
       
    27 $auto_advert_options =
       
    28 	array(
       
    29 		array(
       
    30 			"main_section" => "3<sup>rd</sup> Party Adverts",
       
    31 			"main_description" => "These settings allow you to manage your 3<sup>rd</sup> party (eg. BuySellAds, Afrigator etc.) adverts which display in the right side bar, and underneathe the Article in your home and post pages.",
       
    32 			"sub_elements" => 
       
    33 				array(
       
    34 					array("label" => "Post Page Script", "description" => "", "name" => $input_prefix."main_ad_buysell_ads", "default" => "0", "id" => $input_prefix."main_ad_buysell_ads", "input_type" => "select", "options" => array("On" => "on", "Off" => "off")),
       
    35 					array("label" => "Insert Page Script", "description" => "", "name" => $input_prefix."main_ad_buysell_id", "default" => "", "id" => $input_prefix."main_ad_buysell_id", "input_type" => "memo"),
       
    36 					array("label" => "Right Sidebar Script", "description" => "", "name" => $input_prefix."small_buysell_ads", "default" => "0", "id" => $input_prefix."small_buysell_ads", "input_type" => "select", "options" => array("On" => "on", "Off" => "off")),
       
    37 					array("label" => "Insert Sidebar Script", "description" => "", "name" => $input_prefix."small_buysell_id", "default" => "", "id" => $input_prefix."small_buysell_id", "input_type" => "memo")
       
    38 				)
       
    39 		)
       
    40 	);
       
    41 	
       
    42 $custom_advert_options =
       
    43 	array(
       
    44 		array(
       
    45 			"main_section" => "Post Page Ads",
       
    46 			"main_description" => "These settings allow you to manage your custom adverts which display in the post pages of your site. (Recommended size for the post ad is 560px by 60px.)",
       
    47 			"sub_elements" => 
       
    48 				array(
       
    49 					array("label" => "Advert Title", "description" => "", "name" => $input_prefix."post_ad_title", "default" => "", "id" =>  $input_prefix."post_ad_title", "input_type" => "text"),
       
    50 					array("label" => "Advert Link", "description" => "", "name" => $input_prefix."post_ad_link", "default" => "", "id" =>  $input_prefix."post_ad_link", "input_type" => "text"),
       
    51 					array("label" => "Image URL", "description" => "", "name" => $input_prefix."post_ad_image", "default" => "", "id" =>  $input_prefix."post_ad_image", "input_type" => "text")
       
    52 				)
       
    53 		),
       
    54 		array(
       
    55 			"main_section" => "Sidebar Ads",
       
    56 			"main_description" => "These settings allow you to manage your custom adverts which display in the right side bar. Use the \"Media\" section to upload you ad image, and paste the image url into the \"Image url\" text field. (Recommended width is 125px by 125px.)",
       
    57 			"sub_elements" => 
       
    58 				array(
       
    59 					array("label" => "Number of Small Ads", "description" => "", "name" => $input_prefix."small_ads", "default" => "0", "id" =>  $input_prefix."small_ads", "input_type" => "select", "options" => array("None" => "0", "1" => "1", "2" => "2", "3" => "3", "4" => "4", "5" => "5", "6" => "6", "7" => "7", "8" => "8", "9" => "9", "10" => "10"))
       
    60 				)
       
    61 		)
       
    62 	);
       
    63 $menu_options = array(array("label" => "Menu Order", "description" => "Would you like to list your pages or categories first?", "name" => $input_prefix."page_category_order", "default" => "pages_first", "id" => "", "input_type" => "select", "options" => array("Pages First" => "pages_first", "Categories First" => "categories_first")));		
       
    64 $page_menu_options =
       
    65 	array(
       
    66 		array(
       
    67 			"main_section" => "Pages",
       
    68 			"main_description" => "Order your pages by the following.",
       
    69 			"sub_elements" => 
       
    70 				array(
       
    71 					array("label" => "Order By", "description" => "", "name" => $input_prefix."page_order", "default" => "", "id" =>  $input_prefix."page_order", "input_type" => "select", "options" => array("Title" => "post_title", "Page Order" => "menu_order", "Creation Date/Time" => "post_date", "Modified Date/Time" => "post_modified", "Page ID" => "ID", "Post Slug" => "post_name")),
       
    72 					array("label" => "Direction", "description" => "", "name" => $input_prefix."page_updown", "default" => "", "id" =>  $input_prefix."page_updown", "input_type" => "select", "options" => array("Ascending" => "ASC", "Descending" => "DESC"))
       
    73 				)
       
    74 		)
       
    75 	);
       
    76 $category_menu_options =
       
    77 	array(
       
    78 		array(
       
    79 			"main_section" => "Categories",
       
    80 			"main_description" => "Order your categories by the following.",
       
    81 			"sub_elements" => 
       
    82 				array(
       
    83 					array("label" => "Order By", "description" => "", "name" => $input_prefix."category_order", "default" => "ID", "id" =>  $input_prefix."category_order", "input_type" => "select", "options" => array("Category ID" => "ID", "Name" => "name")),
       
    84 					array("label" => "Direction", "description" => "", "name" => $input_prefix."category_updown", "default" => "", "id" =>  $input_prefix."category_updown", "input_type" => "select", "options" => array("Ascending" => "ASC", "Descending" => "DESC"))
       
    85 				)
       
    86 		)
       
    87 	);
       
    88 // Set the global var to see which array we're dealing with
       
    89 
       
    90 /*********************************************************************************/
       
    91 /* Below we create the form containers, according to our arrays in functions.php */
       
    92 function fetch_options($which_array)
       
    93 	{		
       
    94 	
       
    95 		global $input, $counter, $label_class;
       
    96 		if($which_array) :
       
    97 			foreach($which_array as $input)
       
    98 				{
       
    99 					// This option Has Sub Options, so loop them and give them slightly different classes
       
   100 					if($input['description'] !== "") :
       
   101 ?>
       
   102 						<p class="section_notice"><?php echo $input["description"];?></p>
       
   103 <?php
       
   104 					endif;
       
   105 ?>
       
   106 					<div class="form_item clearfix">
       
   107 <?php
       
   108 					// If this option has sub-options
       
   109 					if($input["main_section"]) :
       
   110 						$i = 0;
       
   111 ?>
       
   112 						<h3><?php echo $input["main_section"] ?></h3>
       
   113                           
       
   114 <?php 
       
   115 						if($input["main_description"] && $input["main_description"] !== "") :
       
   116 ?>
       
   117 							 <p class="section_notice"><?php echo $input["main_description"]; ?></p>
       
   118 <?php
       
   119 						endif;
       
   120 						foreach($input["sub_elements"] as $sub_input)
       
   121 							{
       
   122 								$i++;
       
   123 ?>
       
   124 							 <div class="form_label">
       
   125 								<div class="input_label"><?php echo $sub_input["label"]; ?></div>
       
   126 <?php 
       
   127 								/* Set the class for the div */
       
   128 								if($sub_input["options"] && $sub_input["input_type"] == "checkbox")
       
   129 									{$label_class = "catagories";}
       
   130 								else
       
   131 									{$label_class = "input_form";}
       
   132 									
       
   133 								/* Output the form items using the create_form function */
       
   134 								create_form($sub_input, count($input), $label_class);
       
   135 								
       
   136 								/* Special case, a bit of a hard-code we know - if this is the "Sidebar Ad Number" option, bring into play the small_ad_form function
       
   137 								Which can be found below */
       
   138 								if($sub_input["name"] == "ocmx_small_ads") :
       
   139 									if(get_option("ocmx_small_buysell_ads") == "1") :
       
   140 										$no_display = "no_display";
       
   141 									else :
       
   142 										$no_display = ""; 
       
   143 									endif;
       
   144 ?>
       
   145                                     <br />
       
   146                                     <div class="clearfix <?php echo $no_display; ?>" id="small-ads-div">
       
   147 <?php 
       
   148                                     for($i = 1; $i <= get_option("ocmx_small_ads"); $i++)
       
   149                                         {small_ad_form($i);}
       
   150 ?>
       
   151                                     </div>
       
   152 <?php 
       
   153                                 endif;
       
   154 ?>
       
   155 							</div> 
       
   156 <?php
       
   157 							}
       
   158 					//This Option just sits on its own...
       
   159 					else :			
       
   160 ?>
       
   161                         <div class="form_label">
       
   162 							<div class="input_label"><?php echo $input["label"]; ?></div>
       
   163 <?php 						
       
   164 							if($input["options"] && $input["input_type"] == "checkbox")
       
   165 								{$label_class = "catagories";}
       
   166 							else
       
   167 								{$label_class = "input_form";}
       
   168 								
       
   169 							/* Output the form items using the create_form function */
       
   170 							create_form($input, count($input), $label_class);
       
   171 ?>
       
   172 						</div>
       
   173 <?php 
       
   174 					endif;					
       
   175 ?>					
       
   176 					</div>
       
   177 <?php
       
   178 				}
       
   179 		endif;		
       
   180 	}
       
   181 	
       
   182 /************************************************************************/
       
   183 /* Below we check which kind of form item we're creating, and output it */
       
   184 function create_form($input, $counter, $label_class)
       
   185 	{
       
   186 ?>
       
   187 		<div class="<?php echo $label_class; ?>">
       
   188 <?php 
       
   189 		// Set the input value to default or get_option()
       
   190 		if(!get_option($input["name"])) :			
       
   191 			$input_value = $input["default"];			
       
   192 		else :
       
   193 			$input_value = get_option($input["name"]);
       
   194 		endif;	
       
   195 		
       
   196 		// This denotes that we're using the wp-categories instead of set options
       
   197 		if($input["options"] == "loop_categories") :
       
   198 			$option_loop = get_categories();
       
   199 		elseif($input["options"] == "loop_pages") :
       
   200 			$option_loop = get_pages();
       
   201 		else :
       
   202 			//$values =  array_values($input["options"]);	
       
   203 			$option_loop = $input["options"];
       
   204 		endif;
       
   205 		
       
   206 		//Switch through the input_type
       
   207 		switch($input["input_type"]) 
       
   208 			{
       
   209 				case 'select';
       
   210 				if($input['linked']) :
       
   211 ?>
       
   212 	    			<select size="1" name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>" onchange="javacript: check_linked('<?php echo $input['id'];?>', '<?php echo $input['linked'];?>')">
       
   213 <?php
       
   214 				else :
       
   215 ?>
       
   216 	    			<select size="1" name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>">
       
   217 <?php
       
   218 				endif;
       
   219 					// Tiny little hack.. if we've set the options to loop through the categories, we must have an "All" option
       
   220 					if ($input["options"] == "loop_categories") :
       
   221 ?>
       
   222 						<option <?php if($input_value == 0){echo "selected=\"selected\"";} ?> value="0">All</option>
       
   223 <?php 
       
   224 					elseif($input["options"] == "loop_pages") :
       
   225 ?>
       
   226 						<option <?php if($input_value == 0){echo "selected=\"selected\"";} ?> value="0">Use a Custom Description</option>
       
   227 <?php
       
   228 					endif;
       
   229                     foreach($option_loop as $option_label => $value)
       
   230                         { 	
       
   231 							// Set the $value and $label for the options
       
   232 							if($input["options"] == "loop_categories") : 
       
   233 								$use_value =  $value->slug;
       
   234 								$label =  $value->cat_name;
       
   235 							elseif($input["options"] == "loop_pages") : 
       
   236 								$use_value =  $value->ID;
       
   237 								$label =  $value->post_title;
       
   238 							else :		
       
   239 								$use_value  =  $value;
       
   240 								$label =  $option_label;
       
   241 							endif;
       
   242 							//If this option == the value we set above, select it
       
   243                             if($use_value == $input_value)
       
   244                                 {$selected = " selected='selected' ";}
       
   245                             else
       
   246                                 {$selected = " ";}
       
   247 ?>
       
   248                             <option <?php echo $selected; ?> value="<?php echo $use_value; ?>"><?php echo $label; ?></option>
       
   249 <?php 
       
   250                         }
       
   251 ?>
       
   252                 </select>
       
   253 <?php 
       
   254 				break;
       
   255 				case 'checkbox' :								
       
   256 ?>			
       
   257                 <div class="selection_catagory clearfix">
       
   258                     <ul class="cat_option clearfix">
       
   259 <?php 
       
   260 					 foreach($option_loop as $option_label => $value) :
       
   261 						// Set the $value and $label for the options
       
   262 						if($input["options"] == "loop_categories") : 
       
   263 							$use_value =  $value->slug;
       
   264 							$label =  $value->cat_name;
       
   265 						elseif($input["options"] == "loop_pages") : 
       
   266 							$use_value =  $value->ID;
       
   267 							$label =  $value->post_title;
       
   268 						else :		
       
   269 							$use_value  =  $value;
       
   270 							$label =  $option_label;
       
   271 						endif;
       
   272 						if($use_value == $input_value)
       
   273 							{$selected = " checked='checkeds' ";}
       
   274 						else
       
   275 							{$selected = " ";}
       
   276 ?>
       
   277 						<li><input type="checkbox" name="<?php echo $input["name"]."_".$counter; ?>" value="<?php echo $use_value; ?>" /> <?php echo $label; ?></li>
       
   278 <?php 
       
   279 					endforeach;
       
   280 ?>
       
   281                     </ul>
       
   282                 </div>
       
   283 <?php 
       
   284 				break;
       
   285 				case 'radio' :
       
   286 ?>
       
   287                 <div class="selection_catagory clearfix">
       
   288                     <ul class="cat_option">
       
   289 <?php                         
       
   290 					 foreach($option_loop as $option_label => $value) :
       
   291 					 	// Check whether we must loop through the categories for the options
       
   292 						if($input["options"] == "loop_categories") : 
       
   293 							$use_value =  $value->slug;
       
   294 							$label =  $value->cat_name;
       
   295 						else :		
       
   296 							$use_value  =  $value;
       
   297 							$label =  $option_label;
       
   298 						endif;
       
   299 						if($use_value == $input_value) {$selected = " selected='selected' ";}
       
   300 						else
       
   301 							{$selected = " ";}
       
   302 ?>
       
   303 						<li><input type="radio" name="<?php echo $input["name"]; ?>" value="<?php echo $use_value; ?>" />&nbsp;<?php echo $option_label; ?> </li>
       
   304 <?php 
       
   305 					endforeach;
       
   306 ?>
       
   307                     </ul>
       
   308                 </div>
       
   309 <?php                    
       
   310 				break;
       
   311 				case 'memo':
       
   312 					if($input['linked']) :
       
   313 						if((get_option($input['linked'])) && get_option($input['linked']) !== "0") :
       
   314 							$disabled_element = "disabled=\"disabled\"";
       
   315 						else :
       
   316 							$disabled_element = "";
       
   317 						endif;
       
   318 					else :
       
   319 							$disabled_element = "";
       
   320 					endif;
       
   321 ?>
       
   322 					<textarea name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>" <?php echo $disabled_element; ?> class="mceNoEditor"><?php echo stripslashes($input_value); ?></textarea>
       
   323 <?php 					
       
   324 				break;
       
   325 				case 'file':
       
   326 ?>
       
   327                     <input type="file" style="width: 300px;" name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>" value="<?php echo $input_value; ?>" />
       
   328                     <br /> <br />
       
   329                     <em>Current Image</em>
       
   330                     <div class="form-thumbnail">
       
   331                     	<a id="<?php echo $ad_href_id; ?>" style="background: url('<?php bloginfo('wpurl');?><?php echo "/wp-content/uploads/".$input_value; ?>')  no-repeat center;" href="<?php bloginfo('wpurl');?><?php echo "/wp-content/uploads/".$input_value; ?>" class="std_link" rel="lightbox" target="_blank">
       
   332 	                    </a>
       
   333                     </div>
       
   334 					
       
   335 <?php 					
       
   336 				break;
       
   337 				case 'zip_file':
       
   338 ?>
       
   339                     <input type="file" style="width: 300px;" name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>" value="<?php echo $input_value; ?>" />
       
   340 <?php 					
       
   341 				break;
       
   342 				default :
       
   343 ?>
       
   344 					<input type="text" name="<?php echo $input["name"]; ?>" id="<?php echo $input["id"]; ?>" value="<?php echo $input_value; ?>" />
       
   345 <?php
       
   346 				break;
       
   347 			}		
       
   348 ?>
       
   349 		</div>
       
   350 <?php 
       
   351 	}
       
   352 function menu_options($defaults) {
       
   353 		global $input_prefix, $parent_count, $advert_options, $page_menu_options, $category_menu_options, $menu_options;
       
   354 		$page_args = array("sort_column" => get_option("ocmx_page_order"), "sort_order" => get_option("ocmx_page_updown"));		
       
   355 		$fetch_pages= get_pages($page_args);
       
   356 ?>
       
   357         <?php fetch_options($page_menu_options); ?>
       
   358 		<div class="selection_sections clearfix">
       
   359             <ul class="section_option">
       
   360 <?php
       
   361 				//Set the $i var to count through as we loop through the pages
       
   362 				$i = 0;
       
   363 				foreach ($fetch_pages as $this_page) : 
       
   364 					$use_id = $input_prefix."menu_page_".$this_page->ID;					
       
   365 					// Check/Uncheck Categories
       
   366 					if(get_option($use_id)) : $main_checked = "checked='checked'"; else : $main_checked = ""; endif;
       
   367 					// If we're halfway then place create a new <ul> to seperate the categories
       
   368 					if ($i == number_format(count($fetch_pages)/2, 0)) :
       
   369 ?>
       
   370                         </ul>     
       
   371                         <ul class="section_option clearfix">
       
   372 <?php
       
   373 					endif;
       
   374 					if($this_page->post_parent == 0) :
       
   375 ?>
       
   376 	                	<li class="clearfix">
       
   377                         	<input type="checkbox" <?php echo $main_checked; ?> name="<?php echo $use_id ?>" id="main_page_<?php echo $this_page->ID; ?>" /> <?php echo $this_page->post_title; ?>
       
   378 <?php 						$sub_page_count = 0;
       
   379 							if(get_option("ocmx_page_order") !== "post_title") :
       
   380 								$sub_page_defaults = array("child_of" => $this_page->ID, "sort_column" => get_option("ocmx_page_order"), "sort_order" => get_option("ocmx_page_updown"));
       
   381 							else :
       
   382 								$sub_page_defaults = array("child_of" => $this_page->ID, "sort_order" => get_option("ocmx_page_updown"));
       
   383 							endif;
       
   384 							$sub_pages = get_pages($sub_page_defaults);
       
   385 ?>
       
   386                             <ul class="section_option clearfix" id="sub_pages_<?php echo $this_page->ID; ?>" style="display: none;">
       
   387                                 <?php
       
   388                                     foreach ($sub_pages as $sub_page) :
       
   389                                         $use_id = "ocmx_subpage_".$sub_page->ID;
       
   390                                         // Check/Uncheck Categories
       
   391                                         if(get_option($use_id)) : $sub_checked = "checked='checked'"; else : $sub_checked = ""; endif;
       
   392 ?>
       
   393                                     <li><input type="checkbox" <?php echo $sub_checked; ?> name="<?php echo $use_id ?>" id="<?php echo $use_id; ?>" /> <?php echo $sub_page->post_title; ?></li>
       
   394                                 <?php
       
   395                                     endforeach;
       
   396                                 ?>
       
   397                             </ul>      
       
   398 						</li>        
       
   399                                                 
       
   400 <?php
       
   401 						$i++;
       
   402 					endif;
       
   403 				endforeach;
       
   404 ?>
       
   405 			</ul>
       
   406 		</div>
       
   407         <?php fetch_options($category_menu_options); ?>
       
   408         <div class="selection_sections clearfix">
       
   409             <ul class="section_option">
       
   410 <?php
       
   411 			//Set the $i var to count through as we loop through the categories
       
   412 			$i = 0;
       
   413 			$parent_count = 0;
       
   414 			$cat_args = array("orderby" => get_option("ocmx_category_order"), "order" => get_option("ocmx_category_updown"), "hide_empty" => false);
       
   415 			$parent_categories = get_categories($cat_args);
       
   416 			// Count the Parent Categories (That is Categories without Parents themselves (To be used in the loop, explained below)
       
   417 			foreach ($parent_categories as $this_category) :
       
   418 				if($this_category->category_parent == 0) :
       
   419 					$parent_count++;
       
   420 				endif;
       
   421 			endforeach;
       
   422 			//Loop through the categories				
       
   423 			foreach ($parent_categories as $this_category) :
       
   424 				//Create the checkbox Name/Id
       
   425 				$use_id = $input_prefix."maincategory_".$this_category->cat_ID;
       
   426 				
       
   427 				// Check/Uncheck Categories
       
   428 				if(get_option($use_id)) : $main_checked = "checked='checked'"; else : $main_checked = ""; endif;
       
   429 				
       
   430 				// If we're halfway then place create a new <ul> to seperate the categories
       
   431 				if ($i == number_format($parent_count/2, 0)) :
       
   432 ?>
       
   433 					</ul>     
       
   434 					<ul class="section_option clearfix">
       
   435 <?php
       
   436 				endif;
       
   437 				// Now List the Subcategories
       
   438 				$sub_category_defaults = array('type' => 'post', 'child_of' => $this_category->cat_ID, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false);
       
   439 				$sub_categories = get_categories($sub_category_defaults);
       
   440 	
       
   441 				if($this_category->category_parent == 0) :
       
   442 ?>
       
   443 	
       
   444 					<li class="clearfix">
       
   445 						<input type="checkbox" <?php echo $main_checked; ?> name="<?php echo $use_id; ?>" id="main_category_<?php echo $this_category->cat_ID; ?>" /> <?php echo $this_category->cat_name; ?>
       
   446 						<ul class="section_option clearfix" id="sub_categories_<?php echo $this_category->cat_ID; ?>" style="display: none;">
       
   447 <?php
       
   448 						foreach ($sub_categories as $sub_category) :
       
   449 							//Create the checkbox name
       
   450 							$sub_category->cat_name;
       
   451 							$use_id = $input_prefix."subcategory_".$sub_category->cat_ID;
       
   452 							
       
   453 							// Check/Uncheck Categories
       
   454 							if(get_option($use_id)) : $sub_checked = "checked='checked'"; else : $sub_checked = ""; endif;
       
   455 ?>
       
   456 							<li><input type="checkbox" <?php echo $sub_checked; ?> name="<?php echo $use_id ?>" id="<?php echo $use_id; ?>" /> <?php echo $sub_category->cat_name; ?></li>
       
   457 <?php
       
   458 						endforeach;
       
   459 ?>                
       
   460 						</ul>
       
   461 					</li>
       
   462 <?php 
       
   463 					$i++;	
       
   464 				endif;
       
   465 			endforeach;	
       
   466 ?>
       
   467             </ul>
       
   468             <br class="clearboth "/>
       
   469         </div>
       
   470 <?php 
       
   471 	}
       
   472 function small_ad_form($id) {
       
   473 		global $input_prefix;
       
   474 		$ad_title_id = $input_prefix."small_ad_title_".$id;
       
   475 		$ad_link_id = $input_prefix."small_ad_link_".$id;
       
   476 		$ad_img_id = $input_prefix."small_ad_img_".$id;
       
   477 		$ad_href_id = $input_prefix."small_ad_href_".$id;
       
   478 ?>
       
   479 		<div class="form_label">
       
   480 			<div class="label_tag">
       
   481 				<div class="input_label">Advert Title</div>
       
   482 				<div class="input_form"><input type="text" name="<?php echo $ad_title_id ?>" id="<?php echo $ad_title_id ?>" value="<?php echo get_option($ad_title_id); ?>" /></div>
       
   483 			</div>
       
   484 		</div>
       
   485 		<div class="form_label">
       
   486 			<div class="label_tag">
       
   487 				<div class="input_label">Advert Link</div>
       
   488 				<div class="input_form"><input type="text" name="<?php echo $ad_link_id ?>" id="<?php echo $ad_link_id ?>" value="<?php echo get_option($ad_link_id); ?>" /></div>
       
   489 			</div>
       
   490 		</div>
       
   491 		<div class="form_label">
       
   492 			<div class="label_tag">
       
   493 				<div class="input_label">Image URL</div>
       
   494 				<div class="input_form"><input type="text" name="<?php echo $ad_img_id ?>" id="<?php echo $ad_img_id ?>" value="<?php echo get_option($ad_img_id); ?>" /></div>
       
   495 			</div>
       
   496 		</div>
       
   497 		<div class="form_label">
       
   498 			<div class="label_tag">
       
   499 				<div class="input_label">&nbsp;</div>
       
   500 				<div class="thumbnail"><a id="<?php echo $ad_href_id; ?>" style="background: url('<?php echo get_option($ad_img_id); ?>')  no-repeat center;" href="<?php echo get_option($ad_link_id); ?>" class="std_link" rel="lightbox" target="_blank">&nbsp;</a></div>
       
   501 			</div>
       
   502 		</div>
       
   503 
       
   504 <?php
       
   505 	}
       
   506 ?>