ID ) ) $post_id = $post->ID;
// Check if static frontpage (but not landing page)
if ( is_front_page() && ! is_home() && ! cryout_is_landingpage() ) {
$front_id = get_option( 'page_on_front' );
if ( !empty( $front_id ) ) $post_id = $front_id;
}
// Check if blog page
if ( cryout_on_blog() ) {
$blog_id = get_option( 'page_for_posts' );
if ( !empty( $blog_id ) ) $post_id = $blog_id;
}
// WooCommerce gets separate handling for its non-page sections
$woo = false;
$woo_featured_in_header = apply_filters( 'bravada_featured_header_in_wc', true );
if ( $woo_featured_in_header && function_exists ( "is_woocommerce" ) && is_woocommerce() && ! is_singular() ) {
$shop_id = wc_get_page_id( 'shop' ); // myaccount, edit_address, shop, cart, checkout, pay, view_order, terms
if ( !empty( $shop_id ) ) {
$post_id = $shop_id;
$woo = true;
}
}
// default to general header image
$header_image = FALSE;
if ( get_header_image() != '' ) { $header_image = get_header_image(); }
if ( ( is_singular() || $woo || cryout_on_blog() ) && has_post_thumbnail( $post_id ) && $theme_fheader &&
( $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'bravada-header' ) )
) :
if ( ( absint($image[1]) >= $theme_headerw ) && ( absint($image[2]) >= $theme_headerh ) ) {
// 'header' image is large enough
$header_image = $image[0];
} else {
// 'header' image too small, try 'full' image instead
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'full' );
if ( ( absint($image[1]) >= $theme_headerw ) && ( absint($image[2]) >= $theme_headerh ) ) {
// 'full' image is large enough
$header_image = $image[0];
}
// else: even 'full' image is too small, don't return an image
}
endif;
return apply_filters( 'bravada_header_image_url', $header_image );
} //bravada_header_image_url()
endif;
/**
* Header image handler
* Both as normal img and background image
*/
add_action ( 'cryout_headerimage_hook', 'bravada_header_image', 99 );
if ( ! function_exists( 'bravada_header_image' ) ) :
function bravada_header_image() {
if ( cryout_on_landingpage() && cryout_get_option('theme_lpslider') != 3) return; // if on landing page and static slider not set to header image, exit.
$header_image = bravada_header_image_url();
if ( is_front_page() && function_exists( 'the_custom_header_markup' ) && has_header_video() ) {
the_custom_header_markup();
} elseif ( ! empty( $header_image ) ) { ?>
' . get_the_author() . '';
} elseif ( is_post_type_archive() ) {
$title = post_type_archive_title( '', false );
} elseif ( is_tax() ) {
$title = single_term_title( '', false );
}
return $title;
} // bravada_archive_title()
add_filter( 'get_the_archive_title', 'bravada_archive_title' );
/**
* Adds title and description to header
* Used in header.php
*/
if ( ! function_exists( 'bravada_title_and_description' ) ) :
function bravada_title_and_description() {
$options = cryout_get_option( array( 'theme_logoupload', 'theme_siteheader' ) );
if ( in_array( $options['theme_siteheader'], array( 'logo', 'both' ) ) ) {
bravada_logo_helper( $options['theme_logoupload'] );
}
if ( in_array( $options['theme_siteheader'], array( 'title', 'both', 'logo', 'empty' ) ) ) {
$heading_tag = ( is_front_page() || ( is_home() ) ) ? 'h1' : 'div';
echo '';
echo '<' . $heading_tag . cryout_schema_microdata( 'site-title', 0 ) . ' id="site-title">';
echo '
' . esc_attr( get_bloginfo( 'name' ) ) . ' ';
echo '' . $heading_tag . '>';
echo '
' . esc_attr( get_bloginfo( 'description' ) ). ' ';
echo '
';
}
} // bravada_title_and_description()
endif;
add_action ( 'cryout_branding_hook', 'bravada_title_and_description' );
function bravada_logo_helper( $theme_logo ) {
$wp_logo = str_replace( 'class="custom-logo-link"', 'id="logo" class="custom-logo-link" title="' . esc_attr( get_bloginfo( 'name', 'display' ) ) . '"', get_custom_logo() );
if ( ! empty( $wp_logo ) ) {
echo '' . $wp_logo . '
';
} else {
echo '';
}
} // bravada_logo_helper()
// cryout_schema_publisher() located in cryout/prototypes.php
add_action( 'cryout_after_inner_hook', 'cryout_schema_publisher' );
add_action( 'cryout_singular_after_inner_hook', 'cryout_schema_publisher' );
// cryout_schema_main() located in cryout/prototypes.php
add_action( 'cryout_after_inner_hook', 'cryout_schema_main' );
add_action( 'cryout_singular_after_inner_hook', 'cryout_schema_main' );
// cryout_skiplink() located in cryout/prototypes.php
add_action( 'wp_body_open', 'cryout_skiplink', 2 );
/**
* Back to top button
*/
function bravada_back_top() {
echo '' . __('Back to Top', 'bravada') . ' ';
} // bravada_back_top()
add_action( 'cryout_master_topfooter_hook', 'bravada_back_top' );
/**
* Creates pagination for blog pages.
*/
if ( ! function_exists( 'bravada_pagination' ) ) :
function bravada_pagination( $pages = '', $range = 2, $prefix ='' ) {
$pagination = cryout_get_option( 'theme_pagination' );
if ( $pagination && function_exists( 'the_posts_pagination' ) ):
the_posts_pagination( array(
'prev_text' => '',
'next_text' => '',
'mid_size' => $range
) );
else:
//posts_nav_link();
bravada_content_nav( 'nav-old-below' );
endif;
} // bravada_pagination()
endif;
/**
* Prev/Next page links
*/
if ( ! function_exists( 'bravada_nextpage_links' ) ) :
function bravada_nextpage_links( $defaults ) {
$args = array(
'link_before' => '',
'link_after' => ' ',
);
$r = wp_parse_args( $args, $defaults );
return $r;
} // bravada_nextpage_links()
endif;
add_filter( 'wp_link_pages_args', 'bravada_nextpage_links' );
/**
* Fixed prev/next post links
*/
if ( ! function_exists( 'bravada_fixed_nav_links' ) ) :
function bravada_fixed_nav_links() { ?>
', true ); previous_post_link( '%link', '%title ', true ); ?>
', true ); next_post_link( '%link', '%title ', true ); ?>
' . __( "Powered by", "bravada" ) .
' ' . 'Bravada' .' & ' . sprintf( " %s", "WordPress" ) . ' .';
}
add_action( 'cryout_master_footer_hook', 'bravada_copyright' );
function bravada_copyright() {
echo '' . do_shortcode( cryout_get_option( 'theme_copyright' ) ). '
';
}
/*
* Sidebar handler
*/
if ( ! function_exists( 'bravada_get_sidebar' ) ) :
function bravada_get_sidebar() {
$layout = cryout_get_layout();
switch( $layout ) {
case '2cSl':
get_sidebar( 'left' );
break;
case '2cSr':
get_sidebar( 'right' );
break;
case '3cSl' : case '3cSr' : case '3cSs' :
get_sidebar( 'left' );
get_sidebar( 'right' );
break;
default:
break;
}
} // bravada_get_sidebar()
endif;
/*
* General layout class
*/
if ( ! function_exists( 'bravada_get_layout_class' ) ) :
function bravada_get_layout_class( $echo = true ) {
$layout = cryout_get_layout();
/* If not, return the general layout */
switch( $layout ) {
case '2cSl': $class = "two-columns-left"; break;
case '2cSr': $class = "two-columns-right"; break;
case '3cSl': $class = "three-columns-left"; break;
case '3cSr' : $class = "three-columns-right"; break;
case '3cSs' : $class = "three-columns-sided"; break;
case '1c':
default: $class = "one-column"; break;
}
// allow the generated layout class to be filtered
$output = esc_attr( apply_filters( 'bravada_general_layout_class', $class, $layout ) );
if ( $echo ) {
echo $output;
} else {
return $output;
}
} // bravada_get_layout_class()
endif;
/**
* Checks the browser agent string for mobile ids and adds "mobile" class to body if true
*/
add_filter( 'body_class', 'cryout_mobile_body_class');
/**
* Creates breadcrumbs with page sublevels and category sublevels.
* Hooked in master hook
*/
if ( ! function_exists( 'bravada_breadcrumbs' ) ) :
function bravada_breadcrumbs() {
cryout_breadcrumbs(
'', // $separator, usually
' ', // $home
1, // $showCurrent
'', // $before
' ', // $after
'', // $wrapper_post
bravada_get_layout_class(false), // $layout_class
__( 'Home', 'bravada' ), // $text_home
__( 'Archive for category "%s"', 'bravada' ), // $text_archive
__( 'Search results for "%s"', 'bravada' ), // $text_search
__( 'Posts tagged', 'bravada' ), // $text_tag
__( 'Articles posted by', 'bravada' ), // $text_author
__( 'Not Found', 'bravada' ), // $text_404
__( 'Post format', 'bravada' ), // $text_format
__( 'Page', 'bravada' ) // $text_page
);
} // bravada_breadcrumbs()
endif;
/**
* Adds searchboxes to the appropriate menu location
* Hooked in master hook
*/
if ( ! function_exists( 'cryout_search_menu' ) ) :
function cryout_search_menu( $items, $args ) {
$options = cryout_get_option( array( 'theme_searchboxmain', 'theme_searchboxfooter' ) );
if( $args->theme_location == 'primary' && $options['theme_searchboxmain'] ) {
$container_class = 'menu-main-search';
$items = "" . $items; // reverse order
}
if( $args->theme_location == 'footer' && $options['theme_searchboxfooter'] ) {
$container_class = 'menu-footer-search';
$items .= "" . get_search_form( false ) . " ";
}
return $items;
} // cryout_search_mainmenu()
endif;
/**
* Adds burger icon to main menu for an extra menu
* Hooked in master hook
*/
if ( ! function_exists( 'cryout_burger_menu' ) ) :
function cryout_burger_menu( $items, $args = array() ) {
$button_html = "
";
if (isset($args->theme_location)) {
// filtering wp_nav_menu_items
if( $args->theme_location == 'primary' ) {
$items .= $button_html;
}
} elseif (isset($args['menu_id']) && ('prime_nav' == $args['menu_id'])) {
// filtering wp_page_menu_args
$items = preg_replace( '/<\/ul>/is', $button_html . '', $items );
};
return $items;
} // cryout_burger_menu()
endif;
/**
* Normalizes tags widget font when needed
*/
if ( TRUE === cryout_get_option( 'theme_normalizetags' ) ) add_filter( 'wp_generate_tag_cloud', 'cryout_normalizetags' );
/**
* Adds preloader
*/
function bravada_preloader() {
$theme_preloader = cryout_get_option( 'theme_preloader' );
if ( ( $theme_preloader == 1) || ( $theme_preloader == 2 && (is_front_page() || is_home()) ) ): ?>
and tags
$moretag = false;
if (strpos( $text, '' )) $explodemore = explode('', $text);
if (strpos( $text, '' )) $explodemore = explode('', $text);
if (!empty($explodemore[1])) {
// tag was found
$text = $explodemore[0];
$moretag = true;
}
if ( '' != $text ) {
$text = strip_shortcodes( $text );
$text = str_replace(']]>', ']]>', $text);
// Filters the number of words in an excerpt. Default 35.
$excerpt_length = apply_filters( 'bravada_custom_excerpt_length', $length );
if ($excerpt_length == 0) return '';
// Filters the string in the "more" link displayed after a trimmed excerpt.
$excerpt_more = apply_filters( 'bravada_custom_excerpt_more', $more );
if (!$moretag) {
$text = wp_trim_words( $text, $excerpt_length, $excerpt_more );
}
}
return apply_filters( 'bravada_custom_excerpt', $text, $raw_excerpt );
} // bravada_custom_excerpt()
// ajax load more button alternative hook
add_action( 'template_redirect', 'cryout_ajax_init' );
//
function bravada_check_empty_menu( $menu_id ) {
if (! has_nav_menu( $menu_id ) ) return true;
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_id ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $menu_id ] );
$menu_items = wp_get_nav_menu_items( $menu->term_id );
if( isset($menu_items) ) {
return $menu_items;
}
}
return false;
}
/* FIN */