Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Remove the default headers
- function nomnom_remove_twenty_ten_headers(){
- unregister_default_headers( array(
- 'wheel',
- 'shore',
- 'trolley',
- 'pine-cone',
- 'chessboard',
- 'lanterns',
- 'willow',
- 'hanoi')
- );
- }
- add_action( 'after_setup_theme', 'nomnom_remove_twenty_ten_headers', 11 );
- // set our own default header image.
- define('HEADER_IMAGE', get_stylesheet_directory_uri() . '/images/headers/wheel.jpg');
- // Add our own custom headers packaged with the child theme. in the child theme template directory 'images/headers/'
- register_default_headers( nomnom_theme_headers() );
- /* Build the Header Array from the theme headers */
- // No need to code the headers just loop through the folder and return a list
- function nomnom_theme_headers() {
- global $themename;
- $list = array();
- $imagepath = STYLESHEETPATH .'/images/headers/';
- $imageurl = get_stylesheet_directory_uri();
- $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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement