Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'after_setup_theme', 'dr_post_theme_setup' );
- if ( !function_exists( 'dr_post_theme_setup' ) ):
- function dr_post_theme_setup() {
- /* Remove the twenty eleven default Headers */
- function dr_update_twenty_eleven_headers(){
- unregister_default_headers( array(
- 'wheel',
- 'shore',
- 'trolley',
- 'pine-cone',
- 'chessboard',
- 'lanterns',
- 'willow' ,
- 'hanoi')
- );
- // Register default custom headers packaged with the child theme.
- $headers = dr_default_headers();
- if( $headers ) register_default_headers( $headers );
- }
- add_action( 'after_setup_theme', 'dr_update_twenty_eleven_headers', 11 );
- }
- endif;
- // read through the /images/headers/ to get a list of custom headers.
- function dr_default_headers(){
- // Create an empty array
- $list = array();
- // Get the file directory path and url
- $path = get_stylesheet_directory() .'/images/headers/';
- $url = get_stylesheet_directory_uri() .'/images/headers/';
- // Open the /images/headers/ folder
- $dir_handle = @opendir($path) or die("Unable to open $path");
- // Loop through the header images
- while($file = readdir($dir_handle)){
- if($file == "." || $file == ".."){continue;}
- $filename = explode(".",$file);
- $cnt = count($filename); $cnt--; $ext = $filename[$cnt];
- // Is the image a jpg or png
- if(strtolower($ext) == ('png' || 'jpg')){
- // if the image is post fixed with -thumbnail add it to the array
- if ( strpos($file, '-thumbnail') > 0 ) {
- $name = substr($file, 0, strpos($file, '-thumbnail') );
- $list[$name] = array(
- 'url' => $url .$name .'.' .$ext,
- 'thumbnail_url' => $url .$file,
- 'description' => __( ucwords( str_replace("-"," ",$name) ), 'twentyeleven' )
- );
- }
- }
- }
- return $list;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement