*
* @package Catch Themes
* @subpackage Adventurous
* @since Adventurous 1.0
*/
/**
* Setup the WordPress core custom header feature.
*
* Use add_theme_support to register support for WordPress 3.4+
* as well as provide backward compatibility for previous versions.
* Use feature detection of wp_get_theme() which was introduced
* in WordPress 3.4.
*
* @todo Rework this function to remove WordPress 3.4 support when WordPress 3.6 is released.
*
* @uses adventurous_header_style()
* @uses adventurous_admin_header_style()
* @uses adventurous_header_image()
*
* @package Adventurous
*/
function adventurous_custom_header_setup() {
// Default custom headers packaged with the theme. %s is a placeholder for the theme template directory URI.
register_default_headers( array(
'highway' => 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: HEADER_TEXTCOLOR is default, hide text (returns 'blank') or any hex value
if ( HEADER_TEXTCOLOR == 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
global $adventurous_options_settings;
$options = $adventurous_options_settings;
$text_color = get_header_textcolor();
?>
';
}
else {
$sitedetails = 'logo-disable';
$adventurous_header_logo = '';
}
if ( 'blank' == get_header_textcolor() ) {
$sitedetails .= ' assistive-text';
}
// Checking Header Details
$adventurous_header_details = '
' . esc_attr( get_bloginfo( 'description', 'display' ) ) . '
';
echo $adventurous_header_logo;
echo $adventurous_header_details;
?>
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() {
// Getting Data from Theme Options Panel
global $adventurous_options_settings, $_wp_default_headers;
$options = $adventurous_options_settings;
$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, $wp_query, $adventurous_options_settings, $adventurous_options_defaults;
$options = $adventurous_options_settings;
$defaults = $adventurous_options_defaults;
$enableheaderimage = $options[ 'enable_featured_header_image' ];
$featured_image = $options['page_featured_image'];
// Front page displays in Reading Settings
$page_on_front = get_option('page_on_front') ;
$page_for_posts = get_option('page_for_posts');
// Get Page ID outside Loop
$page_id = $wp_query->get_queried_object_id();
//Individual Page/Post Image Setting
$individual_featured_image = get_post_meta( $post->ID, 'adventurous-header-image', true );
if ( $individual_featured_image == 'disable' || ( $individual_featured_image == 'default' && $enableheaderimage == 'disable' ) ) {
echo '';
}
elseif ( is_home() || is_archive() ) {
if ( $enableheaderimage == 'postpage' ) {
adventurous_featured_image();
}
else {
echo '';
}
}
elseif ( has_post_thumbnail() ) {
echo '