daily pastebin goal
4%
SHARE
TWEET

optionpanel.php

downloadtaky Sep 13th, 2011 198 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $themename = "Centenario Pascoliano";
  4. $shortname = "cp";
  5.  
  6. $categories = get_categories('hide_empty=1&orderby=name');
  7. $wp_cats = array();
  8. foreach ($categories as $category_list ) {
  9.        $wp_cats[$category_list->cat_ID] = $category_list->cat_name;
  10. }
  11. array_unshift($wp_cats, "Choose a category");
  12.  
  13. $options = array (
  14.  
  15. array( "name" => $themename." Opzioni",
  16.         "type" => "title"),
  17.  
  18.  
  19. array( "name" => "Generale",
  20.         "type" => "section"),
  21. array( "type" => "open"),
  22.  
  23. array( "name" => "Colour Scheme",
  24.         "desc" => "Select the colour scheme for the theme",
  25.         "id" => $shortname."_color_scheme",
  26.         "type" => "select",
  27.         "options" => array("blue", "red", "green"),
  28.         "std" => "blue"),
  29.        
  30. array( "name" => "URL Locandina",
  31.         "desc" => "Inserisci il link alla locandina",
  32.         "id" => $shortname."_locandinah",
  33.         "type" => "text",
  34.         "std" => "/wp-content/themes/centenario/images/locandinacentenario.png"),
  35.        
  36. array( "name" => "Product Image Upload",  
  37.         "desc" => "Upload product image",  
  38.         "id" => $shortname."_upload_one",  
  39.         "type" => "upload",  
  40.         "std" => ""),          
  41.        
  42. array( "type" => "close"),
  43. array( "name" => "Homepage",
  44.         "type" => "section"),
  45. array( "type" => "open"),
  46.  
  47. array( "name" => "Homepage header image",
  48.         "desc" => "Enter the link to an image used for the homepage header.",
  49.         "id" => $shortname."_header_img",
  50.         "type" => "text",
  51.         "std" => ""),
  52.        
  53. array( "name" => "Prima categoria da mostrare",
  54.         "desc" => "Scegli la prima categoria da mostrare in HomePage",
  55.         "id" => $shortname."_feat_cat",
  56.         "type" => "select",
  57.         "options" => $wp_cats,
  58.         "std" => "Scegli la prima categoria"),
  59.        
  60. array( "name" => "Seconda categoria da mostrare",
  61.         "desc" => "Scegli la seconda categoria da mostrare in HomePage",
  62.         "id" => $shortname."_feat_cat2",
  63.         "type" => "select",
  64.         "options" => $wp_cats,
  65.         "std" => "Scegli la seconda categoria"),
  66.        
  67. array( "type" => "close"),
  68. array( "name" => "Footer",
  69.         "type" => "section"),
  70. array( "type" => "open"),
  71.        
  72. array( "name" => "Footer copyright text",
  73.         "desc" => "Enter text used in the right side of the footer. It can be HTML",
  74.         "id" => $shortname."_footer_text",
  75.         "type" => "text",
  76.         "std" => ""),
  77.        
  78. array( "name" => "Google Analytics Code",
  79.         "desc" => "You can paste your Google Analytics or other tracking code in this box. This will be automatically added to the footer.",
  80.         "id" => $shortname."_ga_code",
  81.         "type" => "textarea",
  82.         "std" => ""),  
  83.        
  84. array( "name" => "Custom Favicon",
  85.         "desc" => "A favicon is a 16x16 pixel icon that represents your site; paste the URL to a .ico image that you want to use as the image",
  86.         "id" => $shortname."_favicon",
  87.         "type" => "text",
  88.         "std" => get_bloginfo('url') ."/favicon.ico"), 
  89.        
  90. array( "name" => "Feedburner URL",
  91.         "desc" => "Feedburner is a Google service that takes care of your RSS feed. Paste your Feedburner URL here to let readers see it in your website",
  92.         "id" => $shortname."_feedburner",
  93.         "type" => "text",
  94.         "std" => get_bloginfo('rss2_url')),
  95.  
  96.  
  97. array( "type" => "close")
  98.  
  99. );
  100.  
  101.  
  102. function mytheme_add_admin() {
  103.  
  104. global $themename, $shortname, $options;
  105.  
  106. if ( $_GET['page'] == basename(__FILE__) ) {
  107.  
  108.         if ( 'save' == $_REQUEST['action'] ) {
  109.  
  110.                 foreach ($options as $value) {
  111.                 update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
  112.  
  113. foreach ($options as $value) {  
  114.  
  115.         if( $value['type'] == 'upload' )
  116.  
  117.         {
  118.  
  119.                 $upload = wp_handle_upload( $_FILES[ $value['id'] ] );
  120.  
  121.                 if( isset( $upload['url'] ) )
  122.  
  123.                 {
  124.  
  125.                         update_option( $value['id'], $upload['url'] );
  126.  
  127.                 }
  128.  
  129.         }
  130.  
  131.     elseif( isset( $_REQUEST[ $value['id'] ] ) )
  132.  
  133.         {
  134.  
  135.                 update_option( $value['id'], $_REQUEST[ $value['id'] ]  );
  136.  
  137.         }
  138.  
  139. }
  140.  
  141.         header("Location: admin.php?page=optionpanel.php&saved=true");
  142. die;
  143.  
  144. }
  145. else if( 'reset' == $_REQUEST['action'] ) {
  146.  
  147.         foreach ($options as $value) {
  148.                 delete_option( $value['id'] ); }
  149.  
  150.         header("Location: admin.php?page=optionpanel.php&reset=true");
  151. die;
  152.  
  153. }
  154. }
  155.  
  156. add_menu_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin');
  157. }
  158.  
  159. function mytheme_add_init() {
  160.  
  161. $file_dir=get_bloginfo('template_directory');
  162. wp_enqueue_style("functions", $file_dir."/functions/functions.css", false, "1.0", "all");
  163. wp_enqueue_script("rm_script", $file_dir."/functions/rm_script.js", false, "1.0");
  164.  
  165. }
  166. function mytheme_admin() {
  167.  
  168. global $themename, $shortname, $options;
  169. $i=0;
  170.  
  171. if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  172. if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  173.  
  174. ?>
  175. <div class="wrap rm_wrap">
  176. <h2><?php echo $themename; ?> Settings</h2>
  177.  
  178. <div class="rm_opts">
  179. <form method="post" enctype="multipart/form-data" >  
  180. <?php foreach ($options as $value) {
  181. switch ( $value['type'] ) {
  182.  
  183. case "open":
  184. ?>
  185.  
  186. <?php break;
  187.  
  188. case "close":
  189. ?>
  190.  
  191. </div>
  192. </div>
  193. <br />
  194.  
  195.  
  196. <?php break;
  197.  
  198. case "title":
  199. ?>
  200. <p>To easily use the <?php echo $themename;?> theme, you can use the menu below.</p>
  201.  
  202.  
  203. <?php break;
  204.  
  205. case 'text':
  206. ?>
  207.  
  208. <div class="rm_input rm_text">
  209.         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  210.         <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" />
  211.  <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  212.  
  213.  </div>
  214. <?php
  215. break;
  216.  
  217. case 'textarea':
  218. ?>
  219.  
  220. <div class="rm_input rm_textarea">
  221.         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  222.         <textarea name="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" cols="" rows=""><?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id']) ); } else { echo $value['std']; } ?></textarea>
  223.  <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  224.  
  225.  </div>
  226.  
  227. <?php
  228. break;
  229.  
  230. case 'select':
  231. ?>
  232.  
  233. <div class="rm_input rm_select">
  234.         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  235.        
  236. <select name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>">
  237. <?php foreach ($value['options'] as $option) { ?>
  238.                 <option <?php if (get_settings( $value['id'] ) == $option) { echo 'selected="selected"'; } ?>><?php echo $option; ?></option><?php } ?>
  239. </select>
  240.  
  241.         <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  242. </div>
  243. <?php
  244. break;
  245.  
  246. case "checkbox":
  247. ?>
  248.  
  249. <div class="rm_input rm_checkbox">
  250.         <label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label>
  251.        
  252. <?php if(get_option($value['id'])){ $checked = "checked=\"checked\""; }else{ $checked = "";} ?>
  253. <input type="checkbox" name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" value="true" <?php echo $checked; ?> />
  254.  
  255.  
  256.         <small><?php echo $value['desc']; ?></small><div class="clearfix"></div>
  257.  </div>
  258. <?php break;
  259. case "section":
  260.  
  261. $i++;
  262.  
  263. ?>
  264.  
  265. <div class="rm_section">
  266. <div class="rm_title"><h3><img src="<?php bloginfo('template_directory')?>/functions/images/trans.png" class="inactive" alt="""><?php echo $value['name']; ?></h3><span class="submit"><input name="save<?php echo $i; ?>" type="submit" value="Save changes" />
  267. </span><div class="clearfix"></div></div>
  268. <div class="rm_options">
  269.  
  270.  
  271. <?php break;
  272. case "upload";?>
  273. <div class="rm_input rm_upload">
  274.                 <tr valign="top">
  275. <th scope="row">Upload Image</th>
  276. <td><label for="upload_image">
  277. <input id="upload_image" type="text" size="36" name="upload_image" value="" />
  278. <input id="upload_image_button" type="button" value="Upload Image" />
  279. <br />Enter an URL or upload an image for the banner.
  280. </label></td>
  281. </tr>
  282. <div class="clearfix"></div>
  283. </div>
  284.  
  285. <?php break;
  286. }
  287. }
  288. ?>
  289.  
  290. <input type="hidden" name="action" value="save" />
  291. </form>
  292. <form method="post">
  293. <p class="submit">
  294. <input name="reset" type="submit" value="Reset" />
  295. <input type="hidden" name="action" value="reset" />
  296. </p>
  297. </form>
  298. <div style="font-size:9px; margin-bottom:10px;">Icons: <a href="http://www.woothemes.com/2009/09/woofunction/">WooFunction</a></div>
  299.  </div>
  300.  
  301.  
  302. <?php
  303. }
  304. ?>
  305. <?php
  306. function my_admin_scripts() {
  307. wp_enqueue_script('media-upload');
  308. wp_enqueue_script('thickbox');
  309. wp_register_script('my-upload', get_bloginfo('template_url') . '/functions/maisdesignscript.js', array('jquery','media-upload','thickbox'));
  310. wp_enqueue_script('my-upload');
  311. }
  312. function my_admin_styles() {
  313. wp_enqueue_style('thickbox');
  314. }
  315. if (isset($_GET['page']) && $_GET['page'] == 'optionpanel.php') {
  316. add_action('admin_print_scripts', 'my_admin_scripts');
  317. add_action('admin_print_styles', 'my_admin_styles');}
  318. add_action('admin_init', 'mytheme_add_init');
  319. add_action('admin_menu', 'mytheme_add_admin');
  320. ?>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top