_get_random_header_data

Get random header image data from registered images in theme.

Description

(object) _get_random_header_data(); 

Returns (object)


Usage

  1. if ( !function_exists( '_get_random_header_data' ) ) { 
  2. require_once ABSPATH . WPINC . '/theme.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = _get_random_header_data(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/theme.php  
  1. function _get_random_header_data() { 
  2. static $_wp_random_header = null; 
  3.  
  4. if ( empty( $_wp_random_header ) ) { 
  5. global $_wp_default_headers; 
  6. $header_image_mod = get_theme_mod( 'header_image', '' ); 
  7. $headers = array(); 
  8.  
  9. if ( 'random-uploaded-image' == $header_image_mod ) 
  10. elseif ( ! empty( $_wp_default_headers ) ) { 
  11. if ( 'random-default-image' == $header_image_mod ) { 
  12. $headers = $_wp_default_headers; 
  13. } else { 
  14. if ( current_theme_supports( 'custom-header', 'random-default' ) ) 
  15. $headers = $_wp_default_headers; 
  16.  
  17. if ( empty( $headers ) ) 
  18. return new stdClass; 
  19.  
  20. $_wp_random_header = (object) $headers[ array_rand( $headers ) ]; 
  21.  
  22. $_wp_random_header->url = sprintf( $_wp_random_header->url, get_template_directory_uri(), get_stylesheet_directory_uri() ); 
  23. $_wp_random_header->thumbnail_url = sprintf( $_wp_random_header->thumbnail_url, get_template_directory_uri(), get_stylesheet_directory_uri() ); 
  24. return $_wp_random_header;