array(
'url' => '%s/images/demo/header-1-1600x400.jpg',
'thumbnail_url' => '%s/images/demo/header-1-320x66.jpg',
/* translators: header image description */
'description' => __( 'Highway', 'adventurous' )
),
'buddha' => array(
'url' => '%s/images/demo/header-2-1600x400.jpg',
'thumbnail_url' => '%s/images/demo/header-2-320x66.jpg',
/* translators: header image description */
'description' => __( 'Buddha', 'adventurous' )
),
) );
$args = array(
// Header image random rotation default
'random-default' => false,
// Text color and image (empty to use none).
'default-text-color' => '000',
// Set height and width, with a maximum value for the width.
'height' => 400,
'width' => 1600,
// Support flexible height and width.
'flex-height' => false,
'flex-width' => false,
// Random image rotation off by default.
'random-default' => false,
// Callbacks for styling the header and the admin preview.
'wp-head-callback' => 'adventurous_header_style',
'admin-head-callback' => 'adventurous_admin_header_style',
'admin-preview-callback' => 'adventurous_admin_header_image',
);
$args = apply_filters( 'adventurous_custom_header_args', $args );
/*
* This theme supports custom header for logo
*
*/
add_theme_support( 'custom-header', $args );
}
add_action( 'after_setup_theme', 'adventurous_custom_header_setup' );
/**
* Shiv for get_custom_header().
*
* get_custom_header() was introduced to WordPress
* in version 3.4. To provide backward compatibility
* with previous versions, we will define our own version
* of this function.
*
* @todo Remove this function when WordPress 3.6 is released.
* @return stdClass All properties represent attributes of the curent header image.
*
* @package Catch Themes
* @subpackage Adventurous
* @since Adventurous 1.0
*/
if ( ! function_exists( 'get_custom_header' ) ) {
function get_custom_header() {
return (object) array(
'url' => get_header_image(),
'thumbnail_url' => get_header_image(),
'width' => HEADER_IMAGE_WIDTH,
'height' => HEADER_IMAGE_HEIGHT,
);
}
}
if ( ! function_exists( 'adventurous_header_style' ) ) :
/**
* Styles the header image and text displayed on the blog
*
* @see adventurous_custom_header_setup().
*
* @since Adventurous 1.0
*/
function adventurous_header_style() {
// If no custom options for text are set, let's bail
// get_header_textcolor() options: get_theme_support( 'custom-header', 'default-text-color' ) is default, hide text (returns 'blank') or any hex value
if ( get_theme_support( 'custom-header', 'default-text-color' ) === get_header_textcolor() )
return;
// If we get this far, we have custom styles. Let's do this.
?>
Header admin panel.
*
* @see adventurous_custom_header_setup().
*
* @since Adventurous 1.0
*/
function adventurous_admin_header_style() {
?>
Header admin panel.
*
* @see adventurous_custom_header_setup().
*
* @since Adventurous 1.0
*/
function adventurous_header_image() {
//Get Theme Options Data
$options = adventurous_get_options();
$text_color = get_header_textcolor();
echo '
Header admin panel.
*
* @since Adventurous 1.0
*/
function adventurous_admin_header_image() {
adventurous_header_image();
adventurous_featured_image();
}
endif; // adventurous_admin_header_image
if ( ! function_exists( 'adventurous_featured_image' ) ) :
/**
* Template for Custom Header Image
*
* To override this in a child theme
* simply create your own adventurous_featured_image(), and that function will be used instead.
*
* @since Adventurous 1.0
*/
function adventurous_featured_image() {
$options = adventurous_get_options();
$header_image = get_header_image();
$enableheaderimage = $options['enable_featured_header_image'];
if ( !empty( $header_image ) ) {
// Header Image Title/Alt
if ( !empty( $options['featured_header_image_alt'] ) ) :
$title = esc_attr($options['featured_header_image_alt']);
else:
$title = '';
endif;
// Header Image Link
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']);
}
if ( !empty( $options['featured_header_image_base'] ) ) :
$base = '_blank';
else:
$base = '_self';
endif;
$linkopen = '';
$linkclose = '';
else:
$link = '';
$base = '';
$linkopen = '';
$linkclose = '';
endif;
echo '';
}
} // adventurous_featured_image
endif;
if ( ! function_exists( 'adventurous_featured_page_post_image' ) ) :
/**
* Template for Featured Header Image from Post and Page
*
* To override this in a child theme
* simply create your own adventurous_featured_imaage_pagepost(), and that function will be used instead.
*
* @since Adventurous 1.0
*/
function adventurous_featured_page_post_image() {
global $post;
$options = adventurous_get_options();
$featured_image = $options['page_featured_image'];
if ( has_post_thumbnail() ) {
echo '';
}
else {
adventurous_featured_image();
}
} // adventurous_featured_page_post_image
endif;
if ( ! function_exists( 'adventurous_featured_overall_image' ) ) :
/**
* Template for Featured Header Image from theme options
*
* To override this in a child theme
* simply create your own adventurous_featured_pagepost_image(), and that function will be used instead.
*
* @since Adventurous 1.0
*/
function adventurous_featured_overall_image() {
global $post, $wp_query;
$options = adventurous_get_options();
$enableheaderimage = $options['enable_featured_header_image'];
// Front page displays in Reading Settings
$page_for_posts = get_option('page_for_posts');
// Get Page ID outside Loop
$page_id = $wp_query->get_queried_object_id();
// 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, 'adventurous-header-image', true );
if ( 'disable' == $individual_featured_image || ( 'default' == $individual_featured_image && 'disable' == $enableheaderimage ) ) {
echo '';
return;
}
elseif ( 'enable' == $individual_featured_image && 'disable' == $enableheaderimage ) {
adventurous_featured_page_post_image();
}
}
// Check Homepage
if ( 'homepage' == $enableheaderimage ) {
if ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) {
adventurous_featured_image();
}
}
// Check Excluding Homepage
if ( 'excludehome' == $enableheaderimage ) {
if ( is_front_page() || ( is_home() && $page_for_posts != $page_id ) ) {
return false;
}
else {
adventurous_featured_image();
}
}
// Check Entire Site
elseif ( 'allpage' == $enableheaderimage ) {
adventurous_featured_image();
}
// Check Entire Site (Post/Page)
elseif ( 'postpage' == $enableheaderimage ) {
if ( is_page() || is_single() ) {
adventurous_featured_page_post_image();
}
else {
adventurous_featured_image();
}
}
// Check Page/Post
elseif ( 'pagespostes' == $enableheaderimage ) {
if ( is_page() || is_single() ) {
adventurous_featured_page_post_image();
}
}
else {
echo '';
}
} // adventurous_featured_overall_image
endif;
add_action( 'adventurous_before_main', 'adventurous_featured_overall_image', 5 );