<?php
$themename = 'your theme name';
/** Tell WordPress to run child_theme_setup() when the 'after_setup_theme' hook is run. */
add_action( 'after_setup_theme', 'child_theme_setup' );
if ( !function_exists( 'child_theme_setup' ) ):
function child_theme_setup() {
// Header Images are now in Child Themes Directory
define( 'HEADER_IMAGE', get_bloginfo('stylesheet_directory') .'/images/header.png' );
// Change the header Height here if you need to
define( 'HEADER_IMAGE_HEIGHT', apply_filters( 'twentyten_header_image_height', 75 ) );
/* From Aaron Jorbin http://aaron.jorb.in/ */
function jorbin_remove_twenty_ten_headers(){
unregister_default_headers( array(
'berries',
'cherryblossom',
'concave',
'fern',
'forestfloor',
'inkwell',
'path' ,
'sunset')
);
}
add_action( 'after_setup_theme', 'jorbin_remove_twenty_ten_headers', 11 );
// Add our own custom headers packaged with the theme. in the theme template directory 'images/headers/'
register_default_headers( cms_theme_headers() );
}
endif;
/* Build the Header Array from the theme headers */
// No need to code the headers just loop through the folder and return a list
function cms_theme_headers() {
global $themename;
$list = array();
$imagepath = STYLESHEETPATH .'/images/headers/';
$imageurl = get_bloginfo('stylesheet_directory');
$dir_handle = @opendir($imagepath) or die("Unable to open $path");
while($file = readdir($dir_handle)){
if($file == "." || $file == ".."){continue;}
$filename = explode(".",$file);
$cnt = count($filename); $cnt--; $ext = $filename[$cnt];
if(strtolower($ext) == ('png' || 'jpg')){
if (!strpos($file, '-thumbnail') > 0) {
$header = array(
'url' => $imageurl .'/images/headers/' .$file,
'thumbnail_url' => $imageurl .'/images/headers/' .$filename[0] .'-thumbnail.' .$ext,
'description' => __( $filename[0], $themename )
);
array_push($list, $header);
}
}
}
return $list;
}