$default_header_color, // Header image default 'default-image' => get_template_directory_uri() . '/images/headers/buddha.jpg', // Set height and width, with a maximum value for the width. 'height' => 400, 'width' => 1200, // Support flexible height and width. 'flex-height' => true, 'flex-width' => true, // Random image rotation off by default. 'random-default' => false, // Callbacks for styling the header and the admin preview. 'admin-head-callback' => 'automobile_admin_header_style', 'admin-preview-callback' => 'automobile_admin_header_image', ); $args = apply_filters( 'custom-header', $args ); // Add support for custom header add_theme_support( 'custom-header', $args ); } endif; // automobile_custom_header add_action( 'after_setup_theme', 'automobile_custom_header' ); if ( ! function_exists( 'automobile_admin_header_style' ) ) : /** * Styles the header image displayed on the Appearance > Header admin panel. * * @since Automobile 0.1 */ function automobile_admin_header_style() { $options = automobile_get_theme_options(); $defaults = automobile_get_default_theme_options(); ?> Header admin panel. * * @since Automobile 0.1 */ function automobile_admin_header_image() { automobile_site_branding(); automobile_featured_image(); ?> '. get_custom_logo() . ''; } } $automobile_header_text = ' '; $text_color = get_header_textcolor(); if ( function_exists( 'has_custom_logo' ) && has_custom_logo() ) { if ( ! $options['move_title_tagline'] && 'blank' != $text_color ) { $automobile_site_branding = '
'; $automobile_site_branding .= $automobile_site_logo; $automobile_site_branding .= $automobile_header_text; } else { $automobile_site_branding = '
'; $automobile_site_branding .= $automobile_header_text; $automobile_site_branding .= $automobile_site_logo; } } else { $automobile_site_branding = '
'; $automobile_site_branding .= $automobile_header_text; } $automobile_site_branding .= '
'; echo $automobile_site_branding ; } endif; // automobile_site_branding add_action( 'automobile_header', 'automobile_site_branding', 60 ); if ( ! function_exists( 'automobile_featured_image' ) ) : /** * Template for Featured Header Image from theme options * * To override this in a child theme * simply create your own automobile_featured_image(), and that function will be used instead. * * @since Automobile 0.1 */ function automobile_featured_image() { $options = automobile_get_theme_options(); $header_image = get_header_image(); //Support Random Header Image if ( is_random_header_image() ) { delete_transient( 'automobile_featured_image' ); } if ( !$automobile_featured_image = get_transient( 'automobile_featured_image' ) ) { echo ''; if ( $header_image != '' ) { // Header Image Link and Target if ( !empty( $options[ 'featured_header_image_url' ] ) ) { //support for qtranslate custom link if ( function_exists( 'qtrans_convertURL' ) ) { $link = qtrans_convertURL($options[ 'featured_header_image_url' ]); } else { $link = esc_url( $options[ 'featured_header_image_url' ] ); } //Checking Link Target if ( !empty( $options[ 'featured_header_image_base' ] ) ) { $target = '_blank'; } else { $target = '_self'; } } else { $link = ''; $target = ''; } // Header Image Title/Alt if ( !empty( $options[ 'featured_header_image_alt' ] ) ) { $title = esc_attr( $options[ 'featured_header_image_alt' ] ); } else { $title = ''; } // Header Image $feat_image = ''.$title.''; $automobile_featured_image = ''; } set_transient( 'automobile_featured_image', $automobile_featured_image, 86940 ); } echo $automobile_featured_image; } // automobile_featured_image endif; if ( ! function_exists( 'automobile_featured_page_post_image' ) ) : /** * Template for Featured Header Image from Post and Page * * To override this in a child theme * simply create your own automobile_featured_imaage_pagepost(), and that function will be used instead. * * @since Automobile 0.1 */ function automobile_featured_page_post_image() { global $post, $wp_query; // Get Page ID outside Loop $page_id = $wp_query->get_queried_object_id(); $page_for_posts = get_option('page_for_posts'); if ( is_home() && $page_for_posts == $page_id ) { $header_page_id = $page_id; } else { $header_page_id = $post->ID; } if( has_post_thumbnail( $header_page_id ) ) { $options = automobile_get_theme_options(); $featured_header_image_url = $options['featured_header_image_url']; $featured_header_image_base = $options['featured_header_image_base']; if ( '' != $featured_header_image_url ) { //support for qtranslate custom link if ( function_exists( 'qtrans_convertURL' ) ) { $link = qtrans_convertURL( $featured_header_image_url ); } else { $link = esc_url( $featured_header_image_url ); } //Checking Link Target if ( '1' == $featured_header_image_base ) { $target = '_blank'; } else { $target = '_self'; } } else { $link = ''; $target = ''; } $featured_header_image_alt = $options['featured_header_image_alt']; // Header Image Title/Alt if ( '' != $featured_header_image_alt ) { $title = esc_attr( $featured_header_image_alt ); } else { $title = ''; } $featured_image_size = $options['featured_image_size']; if ( 'slider' == $featured_image_size ) { $feat_image = get_the_post_thumbnail( $post->ID, 'automobileslider', array('id' => 'main-feat-img')); } else if ( 'full' == $featured_image_size ) { $feat_image = get_the_post_thumbnail( $post->ID, 'full', array('id' => 'main-feat-img')); } else { $feat_image = get_the_post_thumbnail( $post->ID, 'automobilelarge', array('id' => 'main-feat-img')); } $automobile_featured_image = ''; echo $automobile_featured_image; } else { automobile_featured_image(); } } // automobile_featured_page_post_image endif; if ( ! function_exists( 'automobile_featured_overall_image' ) ) : /** * Template for Featured Header Image from theme options * * To override this in a child theme * simply create your own automobile_featured_pagepost_image(), and that function will be used instead. * * @since Automobile 0.1 */ function automobile_featured_overall_image() { global $post, $wp_query; $options = automobile_get_theme_options(); $defaults = automobile_get_default_theme_options(); $enableheaderimage = $options['enable_featured_header_image']; // Get Page ID outside Loop $page_id = $wp_query->get_queried_object_id(); $page_for_posts = get_option('page_for_posts'); // Check Enable/Disable header image in Page/Post Meta box if ( is_page() || is_single() ) { //Individual Page/Post Image Setting $individual_featured_image = get_post_meta( $post->ID, 'automobileheader-image', true ); if ( $individual_featured_image == 'disable' || ( $individual_featured_image == 'default' && $enableheaderimage == 'disable' ) ) { echo ''; return; } elseif ( $individual_featured_image == 'enable' && $enableheaderimage == 'disabled' ) { automobile_featured_page_post_image(); } } // Check Homepage if ( $enableheaderimage == 'homepage' ) { if ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) { automobile_featured_image(); } } // Check Excluding Homepage if ( $enableheaderimage == 'exclude-home' ) { if ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) { return false; } else { automobile_featured_image(); } } elseif ( $enableheaderimage == 'exclude-home-page-post' ) { if ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) { return false; } elseif ( is_page() || is_single() ) { automobile_featured_page_post_image(); } else { automobile_featured_image(); } } // Check Entire Site elseif ( $enableheaderimage == 'entire-site' ) { automobile_featured_image(); } // Check Entire Site (Post/Page) elseif ( $enableheaderimage == 'entire-site-page-post' ) { if ( is_page() || is_single() ) { automobile_featured_page_post_image(); } else { automobile_featured_image(); } } // Check Page/Post elseif ( $enableheaderimage == 'pages-posts' ) { if ( is_page() || is_single() ) { automobile_featured_page_post_image(); } } else { echo ''; } } // automobile_featured_overall_image endif; add_action( 'automobile_after_header', 'automobile_featured_overall_image', 10 );