This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

WordPress 3 Twenty Ten Change Headers

By: a guest on Sep 5th, 2010  |  syntax: PHP  |  size: 1.98 KB  |  views: 984  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. $themename = 'your theme name';
  4.  
  5. /** Tell WordPress to run child_theme_setup() when the 'after_setup_theme' hook is run. */
  6. add_action( 'after_setup_theme', 'child_theme_setup' );
  7.  
  8. if ( !function_exists( 'child_theme_setup' ) ):
  9. function child_theme_setup() {
  10.        
  11.         // Header Images are now in Child Themes Directory
  12.         define( 'HEADER_IMAGE', get_bloginfo('stylesheet_directory') .'/images/header.png' );
  13.        
  14.         // Change the header Height here if you need to
  15.         define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 75 ) );
  16.  
  17.     /* From Aaron Jorbin http://aaron.jorb.in/ */
  18.         function jorbin_remove_twenty_ten_headers(){
  19.                 unregister_default_headers( array(
  20.                         'berries',
  21.                         'cherryblossom',
  22.                         'concave',
  23.                         'fern',
  24.                         'forestfloor',
  25.                         'inkwell',
  26.                         'path' ,
  27.                         'sunset')
  28.                         );
  29.         }
  30.         add_action( 'after_setup_theme', 'jorbin_remove_twenty_ten_headers', 11 );
  31.  
  32.        
  33.         // Add our own custom headers packaged with the theme. in the theme template directory 'images/headers/'
  34.         register_default_headers( cms_theme_headers() );       
  35. }
  36. endif;
  37.  
  38.  
  39. /* Build the Header Array from the theme headers */
  40. // No need to code the headers just loop through the folder and return a list
  41. function cms_theme_headers() {
  42.         global $themename;
  43.     $list = array();
  44.         $imagepath = STYLESHEETPATH .'/images/headers/';
  45.         $imageurl = get_bloginfo('stylesheet_directory');
  46.     $dir_handle = @opendir($imagepath) or die("Unable to open $path");
  47.     while($file = readdir($dir_handle)){
  48.         if($file == "." || $file == ".."){continue;}
  49.         $filename = explode(".",$file);
  50.         $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
  51.         if(strtolower($ext) == ('png' || 'jpg')){
  52.                   if (!strpos($file, '-thumbnail') > 0) {        
  53.                                 $header = array(
  54.                                         'url' => $imageurl .'/images/headers/' .$file,
  55.                                         'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
  56.                                         'description' => __( $filename[0], $themename )
  57.                                 );
  58.                                 array_push($list, $header);
  59.                   }
  60.         }
  61.     }
  62.     return $list;
  63. }
clone this paste RAW Paste Data