Advertisement
Zeaks

Remove and replace twentyeleven headers

Nov 8th, 2011
400
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. // Remove the default headers  
  2. function nomnom_remove_twenty_ten_headers(){
  3.     unregister_default_headers( array(
  4.         'wheel',
  5.         'shore',
  6.         'trolley',
  7.         'pine-cone',
  8.         'chessboard',
  9.         'lanterns',
  10.         'willow',
  11.         'hanoi')
  12.         );
  13. }
  14. add_action( 'after_setup_theme', 'nomnom_remove_twenty_ten_headers', 11 );
  15.  
  16. // set our own default header image.
  17.     define('HEADER_IMAGE', get_stylesheet_directory_uri() . '/images/headers/wheel.jpg');
  18.  
  19. // Add our own custom headers packaged with the child theme. in the child theme template directory 'images/headers/'
  20.     register_default_headers( nomnom_theme_headers() );
  21. /* Build the Header Array from the theme headers */
  22. // No need to code the headers just loop through the folder and return a list
  23. function nomnom_theme_headers() {
  24.     global $themename;
  25.     $list = array();
  26.     $imagepath = STYLESHEETPATH .'/images/headers/';
  27.     $imageurl = get_stylesheet_directory_uri();
  28.     $dir_handle = @opendir($imagepath) or die("Unable to open $path");
  29.     while($file = readdir($dir_handle)){
  30.         if($file == "." || $file == ".."){continue;}
  31.         $filename = explode(".",$file);
  32.         $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
  33.         if(strtolower($ext) == ('png' || 'jpg')){
  34.           if (!strpos($file, '-thumbnail') > 0) {
  35.                 $header = array(
  36.                     'url' => $imageurl .'/images/headers/' .$file,
  37.                     'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
  38.                     'description' => __( $filename[0], $themename )
  39.                 );
  40.                 array_push($list, $header);
  41.           }
  42.         }
  43.     }
  44.     return $list;
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement