Advertisement
kaed

fr - options.php - 6/27/13 (2)

Jun 27th, 2013
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.42 KB | None | 0 0
  1. <?php
  2.  
  3. //theme vars
  4. $themename = "Fuckin Round";
  5. $shortname = "fuckinround";
  6. $options = array();
  7.  
  8. function theme_options(){
  9.     global $themename, $shortname, $options;
  10.    
  11.     $options = array (
  12.            
  13.         array("name" => "General Settings",
  14.             "type" => "section"),
  15.         array("type" => "open"),
  16.            
  17.         array("name" => "Type of Logo",
  18.             "desc" => "Select your logo type ( Image or Text )",
  19.             "id" => $shortname."_type_of_logo",
  20.             "type" => "select",
  21.             "options" => array("text", "logo"),
  22.             "std" => "text"),
  23.            
  24.         array("name" => "Logo Upload",
  25.             "desc" => "Upload images using the native media uploader, or define the URL directly",
  26.             "id" => $shortname."_logo_upload",
  27.             "type" => "imageupload",
  28.             "std" => ""),
  29.            
  30.         array("name" => "Logo Text",
  31.             "desc" => "Enter text for logo",
  32.             "id" => $shortname."_logo_text",
  33.             "type" => "text",
  34.             "std" => ""),
  35.            
  36.         array("name" => "Logo Slogan",
  37.             "desc" => "Enter text for logo slogan",
  38.             "id" => $shortname."_logo_slogan",
  39.             "type" => "text",
  40.             "std" => ""),
  41.            
  42.         array("name" => "Custom Favicon",
  43.             "desc" => "Upload a 16px x 16px Png/Gif image that will represent your website's favicon",
  44.             "id" => $shortname."_favicon_upload",
  45.             "type" => "imageupload",
  46.             "std" => ""),
  47.            
  48.         array("type" => "close"),
  49.         array("name" => "Styling Options",
  50.             "type" => "section"),
  51.         array("type" => "open"),
  52.        
  53.         array("name" => "Background Color",
  54.             "desc" => "Pick a color for the background",
  55.             "id" => $shortname."_background_color",
  56.             "type" => "color",
  57.             "std" => "#ffffff"),
  58.  
  59.         array("name" => "Body Color",
  60.             "desc" => "Pick a color for the body",
  61.             "id" => $shortname."_body_color",
  62.             "type" => "color",
  63.             "std" => "#ffffff"),
  64.            
  65.         array("type" => "close"),
  66.         array("name" => "Footer Options",
  67.             "type" => "section"),
  68.         array("type" => "open"),
  69.        
  70.         array("name" => "Copyright Text",
  71.             "desc" => "Enter text for copyright in footer (if empty it will be removed)",
  72.             "id" => $shortname."_footer_text",
  73.             "type" => "text",
  74.             "std" => "Copyright TestSite.com"),
  75.            
  76.         array("type" => "close")
  77.        
  78.     );
  79. }
  80.  
  81. //add options page
  82. function fuckinround_add_admin(){
  83.     global $themename, $shortname, $options;
  84.    
  85.     if ( $_GET['page'] == basename(__FILE__) ){
  86.        
  87.         if ( 'save' == $_REQUEST['action'] ) {
  88.             //protect against request forgery
  89.             check_admin_referer('theme-save');
  90.            
  91.             //save the options
  92.             foreach ($options as $value) {
  93.                 if( isset( $_REQUEST[ $value['id'] ] ) ) {
  94.                     update_option( $value['id'], $_REQUEST[ $value['id'] ] );
  95.                 } else {
  96.                     delete_option( $value['id'] );
  97.                 }
  98.             }
  99.            
  100.             header("Location: themes.php?page=options.php&saved=true");
  101.             die;
  102.            
  103.         } else if ( 'reset' == $_REQUEST['action'] ) {
  104.             //protect against request forgery
  105.             check_admin_referer('theme-reset');
  106.             //delete the options
  107.             foreach ($option as $value) {
  108.                 delete_option( $value['id'] );
  109.             }
  110.            
  111.             header("Location: themes.php?page=options.php&reset=true");
  112.             die;
  113.         }
  114.     }
  115.     add_theme_page($themename." Options", "$themename Options", 'edit_themes', basename(__FILE__), 'fuckinround_admin');
  116. }
  117. add_action('admin_menu' , 'fuckinround_add_admin');
  118.  
  119. //main function
  120. function fuckinround_admin() {
  121.     global $themename, $shortname, $options;
  122.    
  123.     //saved or reset messages
  124.     if ( $_REQUEST['saved'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings saved.</strong></p></div>';
  125.     if ( $_REQUEST['reset'] ) echo '<div id="message" class="updated fade"><p><strong>'.$themename.' settings reset.</strong></p></div>';
  126.    
  127.     //form
  128.     ?>
  129.     <header>
  130.         <h1><?php echo $themename; ?></h1>
  131.     </header>
  132.    
  133.     <aside>
  134.         <nav>
  135.             <ul>
  136.             <?php
  137.                 foreach ($options as $value){
  138.                     switch ( $value['type'] ){
  139.                         case 'section':
  140.                             echo '<li><a>'.$value['name'].'</li></a>';
  141.                             break;
  142.                     }
  143.                 }
  144.             ?>
  145.             </ul>
  146.         </nav>
  147.     </aside>
  148.    
  149.     <form method="post">
  150.     <?php wp_nonce_field('theme-save'); ?>
  151.    
  152.     <main>
  153.     <?php
  154.         //loop 2
  155.     ?>
  156.     </main>
  157.    
  158.     <footer>
  159.        
  160.         <p class="submit">
  161.             <input name="save" type="submit" value="Save changes" class="button-primary" />
  162.             <input type="hidden" name="action" value="save" />
  163.         </p>
  164.     </form>
  165.    
  166.         <form method="post">
  167.             <?php wp_nonce_field('theme-reset'); ?>
  168.             <p class="submit">
  169.                 <input name="reset" type="submit" value="Reset changes" />
  170.                 <input type="hidden" name="action" value="reset" />
  171.             </p>
  172.         </form>
  173.     </footer>
  174.     <?php
  175. }
  176. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement