Guest User

Untitled

a guest
Jul 7th, 2012
201
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. // Add support for post thumbnails
  4. if ( function_exists( 'add_theme_support' ) ) {
  5. add_theme_support( 'post-thumbnails', array('post','page') );
  6. }
  7.  
  8. if ( function_exists( 'add_image_size' ) ) {
  9.     add_image_size( 'portfolio_image', 350, 223, true ); // 350 pixels wide by 223 pixels tall, hard crop mode
  10.     add_image_size( 'slider_image', 1140, 500, true ); // 1140 pixels wide by 500 pixels tall, hard crop mode
  11. }
  12.        
  13. // Run automatic-feed-links after the theme is set up
  14. add_theme_support('automatic-feed-links');
  15.  
  16. // Add custom field boxes
  17. add_action( 'add_meta_boxes', 'admin_init' );  
  18.  
  19. function admin_init(){
  20.   add_meta_box("ptime", "Effektiv tid", "ptime_box", "post", "normal", "low");
  21.   add_meta_box("services", "Tjänster", "services_box", "post", "normal", "low");
  22.   add_meta_box("tools", "Verktyg", "tools_box", "post", "normal", "low");
  23.   add_meta_box("url", 'Adress (inkludera "http://")', "url_box", "post", "normal", "low");
  24.   add_meta_box("images", 'Bilder för slidern (inkludera &#060;li&#062;- och &#060;img&#062;-taggar)', "images_box", "post", "normal", "low");
  25. }
  26.  
  27. function ptime_box(){
  28. global $post;
  29. $custom = get_post_custom($post->ID);
  30. $ptime = $custom["ptime"][0];
  31. ?>
  32. <input name="ptime" size="100" value="<?php echo $ptime; ?>" />
  33. <?php
  34. }
  35.  
  36.  
  37. function services_box(){
  38.   global $post;
  39.   $custom = get_post_custom($post->ID);
  40.   $services = $custom["services"][0];
  41.   ?>
  42.   <input name="services" size="100" value="<?php echo $services; ?>" />
  43.   <?php
  44. }
  45.  
  46.  
  47. function tools_box(){
  48.   global $post;
  49.   $custom = get_post_custom($post->ID);
  50.   $tools = $custom["tools"][0];
  51.   ?>
  52.   <input name="tools" size="100" value="<?php echo $tools; ?>" />
  53.   <?php
  54. }
  55.  
  56. function url_box(){
  57.   global $post;
  58.   $custom = get_post_custom($post->ID);
  59.   $url = $custom["url"][0];
  60.   ?>
  61.   <input name="url" size="100" value="<?php echo $url; ?>" />
  62.   <?php
  63. }
  64.  
  65. function images_box($echo = FALSE){
  66.   global $post;
  67.   $custom = get_post_custom($post->ID);
  68.   $city = $custom["images"][0];
  69.   ?>
  70.   <textarea name="images" cols="100" rows="10" value="<?php echo $images; ?>"></textarea>
  71.   <?php
  72. }
  73.  
  74. add_action('save_post', 'save_details');
  75.  
  76. function save_details(){
  77.     global $post;
  78.    
  79.     update_post_meta($post->ID, "ptime", $_POST["ptime"]);
  80.     update_post_meta($post->ID, "services", $_POST["services"]);
  81.     update_post_meta($post->ID, "tools", $_POST["tools"]);
  82.     update_post_meta($post->ID, "url", $_POST["url"]);
  83.     update_post_meta($post->ID, "images", $_POST["images"]);
  84. }
  85.  
  86. ?>
RAW Paste Data